package a;

import A1.H;
import C3.W;
import D0.AbstractC0064a;
import E1.Q;
import E1.T;
import I0.l;
import I0.w;
import I0.z;
import P6.g;
import X6.n;
import android.graphics.Bitmap;
import android.media.MediaCodecInfo;
import android.os.Build;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.RelativeSizeSpan;
import android.util.Property;
import android.view.View;
import androidx.leanback.transition.e;
import b7.C0556f;
import b7.C0559i;
import b7.EnumC0551a;
import b7.InterfaceC0560j;
import b7.q;
import com.google.android.gms.internal.measurement.AbstractC0641h;
import com.google.android.gms.internal.measurement.AbstractC0707u1;
import com.google.android.gms.internal.measurement.C0621d;
import com.google.android.gms.internal.measurement.C0631f;
import com.google.android.gms.internal.measurement.C0636g;
import com.google.android.gms.internal.measurement.C0666m;
import com.google.android.gms.internal.measurement.C0700t;
import com.google.android.gms.internal.measurement.InterfaceC0671n;
import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import k7.s;
import k7.x;
import u0.C1578n;
import u0.C1579o;
import u0.E;

/* JADX INFO: renamed from: a.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0386a implements e {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public static final /* synthetic */ int f7574q = 0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public static final /* synthetic */ int f7575r = 0;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static final /* synthetic */ int f7576s = 0;

    public static String A(Object... objArr) {
        int length;
        int length2;
        int iIndexOf;
        String string;
        int i = 0;
        int i5 = 0;
        while (true) {
            length = objArr.length;
            if (i5 >= length) {
                break;
            }
            Object obj = objArr[i5];
            if (obj == null) {
                string = "null";
            } else {
                try {
                    string = obj.toString();
                } catch (Exception e8) {
                    String str = obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj));
                    Logger.getLogger("com.google.common.base.Strings").logp(Level.WARNING, "com.google.common.base.Strings", "lenientToString", "Exception during lenientFormat for ".concat(str), (Throwable) e8);
                    string = "<" + str + " threw " + e8.getClass().getName() + ">";
                }
            }
            objArr[i5] = string;
            i5++;
        }
        StringBuilder sb = new StringBuilder((length * 16) + 29);
        int i8 = 0;
        while (true) {
            length2 = objArr.length;
            if (i >= length2 || (iIndexOf = "expected a non-null reference".indexOf("%s", i8)) == -1) {
                break;
            }
            sb.append((CharSequence) "expected a non-null reference", i8, iIndexOf);
            sb.append(objArr[i]);
            i++;
            i8 = iIndexOf + 2;
        }
        sb.append((CharSequence) "expected a non-null reference", i8, 29);
        if (i < length2) {
            sb.append(" [");
            sb.append(objArr[i]);
            for (int i9 = i + 1; i9 < objArr.length; i9++) {
                sb.append(", ");
                sb.append(objArr[i9]);
            }
            sb.append(']');
        }
        return sb.toString();
    }

    public static C0621d B(C0621d c0621d, C2.a aVar, C0666m c0666m, Boolean bool, Boolean bool2) {
        C0621d c0621d2 = new C0621d();
        Iterator itP = c0621d.p();
        while (itP.hasNext()) {
            int iIntValue = ((Integer) itP.next()).intValue();
            if (c0621d.v(iIntValue)) {
                InterfaceC0671n interfaceC0671nD = c0666m.d(aVar, Arrays.asList(c0621d.n(iIntValue), new C0636g(Double.valueOf(iIntValue)), c0621d));
                if (interfaceC0671nD.i().equals(bool)) {
                    break;
                }
                if (bool2 == null || interfaceC0671nD.i().equals(bool2)) {
                    c0621d2.u(iIntValue, interfaceC0671nD);
                }
            }
        }
        return c0621d2;
    }

    public static InterfaceC0671n D(C0621d c0621d, C2.a aVar, ArrayList arrayList, boolean z8) {
        InterfaceC0671n interfaceC0671nD;
        AbstractC0707u1.z("reduce", 1, arrayList);
        AbstractC0707u1.A("reduce", 2, arrayList);
        InterfaceC0671n interfaceC0671nA = ((C0700t) aVar.f1157r).a(aVar, (InterfaceC0671n) arrayList.get(0));
        if (!(interfaceC0671nA instanceof AbstractC0641h)) {
            throw new IllegalArgumentException("Callback should be a method");
        }
        if (arrayList.size() == 2) {
            interfaceC0671nD = ((C0700t) aVar.f1157r).a(aVar, (InterfaceC0671n) arrayList.get(1));
            if (interfaceC0671nD instanceof C0631f) {
                throw new IllegalArgumentException("Failed to parse initial value");
            }
        } else {
            if (c0621d.l() == 0) {
                throw new IllegalStateException("Empty array with no initial value error");
            }
            interfaceC0671nD = null;
        }
        AbstractC0641h abstractC0641h = (AbstractC0641h) interfaceC0671nA;
        int iL = c0621d.l();
        int i = z8 ? 0 : iL - 1;
        int i5 = z8 ? iL - 1 : 0;
        int i8 = true == z8 ? 1 : -1;
        if (interfaceC0671nD == null) {
            interfaceC0671nD = c0621d.n(i);
            i += i8;
        }
        while ((i5 - i) * i8 >= 0) {
            if (c0621d.v(i)) {
                interfaceC0671nD = abstractC0641h.d(aVar, Arrays.asList(interfaceC0671nD, c0621d.n(i), new C0636g(Double.valueOf(i)), c0621d));
                if (interfaceC0671nD instanceof C0631f) {
                    throw new IllegalStateException("Reduce operation failed");
                }
                i += i8;
            } else {
                i += i8;
            }
        }
        return interfaceC0671nD;
    }

    public static C0556f e(int i, int i5, EnumC0551a enumC0551a) {
        int i8 = i5 & 2;
        EnumC0551a enumC0551a2 = EnumC0551a.f9221q;
        if (i8 != 0) {
            enumC0551a = enumC0551a2;
        }
        if (i == -2) {
            if (enumC0551a != enumC0551a2) {
                return new q(1, enumC0551a);
            }
            InterfaceC0560j.f9261f.getClass();
            return new C0556f(C0559i.f9260b);
        }
        if (i != -1) {
            return i != 0 ? i != Integer.MAX_VALUE ? enumC0551a == enumC0551a2 ? new C0556f(i) : new q(i, enumC0551a) : new C0556f(Integer.MAX_VALUE) : enumC0551a == enumC0551a2 ? new C0556f(0) : new q(1, enumC0551a);
        }
        if (enumC0551a == enumC0551a2) {
            return new q(1, EnumC0551a.f9222r);
        }
        throw new IllegalArgumentException("CONFLATED capacity cannot be used with non-default onBufferOverflow");
    }

    public static void f(String str, boolean z8) {
        if (!z8) {
            throw new IllegalArgumentException(str);
        }
    }

    public static void i(int i) {
        if (i < 0) {
            throw new IllegalArgumentException();
        }
    }

    public static void j(Object obj, String str) {
        if (obj == null) {
            throw new NullPointerException(str);
        }
    }

    public static final long k() {
        return Thread.currentThread().getId();
    }

    public static int l(boolean z8) {
        List supportedPerformancePoints;
        try {
            C1578n c1578n = new C1578n();
            c1578n.f17320m = E.m("video/avc");
            C1579o c1579o = new C1579o(c1578n);
            if (c1579o.f17358n != null) {
                W wG = z.g(l.f3232r, c1579o, z8, false);
                for (int i = 0; i < wG.f1227t; i++) {
                    if (((I0.q) wG.get(i)).f3237d != null && ((I0.q) wG.get(i)).f3237d.getVideoCapabilities() != null && (supportedPerformancePoints = ((I0.q) wG.get(i)).f3237d.getVideoCapabilities().getSupportedPerformancePoints()) != null && !supportedPerformancePoints.isEmpty()) {
                        AbstractC0064a.k();
                        MediaCodecInfo.VideoCapabilities.PerformancePoint performancePointB = AbstractC0064a.b();
                        for (int i5 = 0; i5 < supportedPerformancePoints.size(); i5++) {
                            if (AbstractC0064a.d(supportedPerformancePoints.get(i5)).covers(performancePointB)) {
                                return 2;
                            }
                        }
                        return 1;
                    }
                }
            }
        } catch (w unused) {
        }
        return 0;
    }

    public static s m(String str) {
        g.e(str, "<this>");
        Matcher matcher = s.f14130d.matcher(str);
        if (!matcher.lookingAt()) {
            throw new IllegalArgumentException(("No subtype found for: \"" + str + '\"').toString());
        }
        String strGroup = matcher.group(1);
        g.d(strGroup, "typeSubtype.group(1)");
        Locale locale = Locale.US;
        g.d(locale, "US");
        String lowerCase = strGroup.toLowerCase(locale);
        g.d(lowerCase, "this as java.lang.String).toLowerCase(locale)");
        String strGroup2 = matcher.group(2);
        g.d(strGroup2, "typeSubtype.group(2)");
        g.d(strGroup2.toLowerCase(locale), "this as java.lang.String).toLowerCase(locale)");
        ArrayList arrayList = new ArrayList();
        Matcher matcher2 = s.f14131e.matcher(str);
        int iEnd = matcher.end();
        while (iEnd < str.length()) {
            matcher2.region(iEnd, str.length());
            if (!matcher2.lookingAt()) {
                StringBuilder sb = new StringBuilder("Parameter is not formatted correctly: \"");
                String strSubstring = str.substring(iEnd);
                g.d(strSubstring, "this as java.lang.String).substring(startIndex)");
                sb.append(strSubstring);
                sb.append("\" for: \"");
                sb.append(str);
                sb.append('\"');
                throw new IllegalArgumentException(sb.toString().toString());
            }
            String strGroup3 = matcher2.group(1);
            if (strGroup3 == null) {
                iEnd = matcher2.end();
            } else {
                String strGroup4 = matcher2.group(2);
                if (strGroup4 == null) {
                    strGroup4 = matcher2.group(3);
                } else if (n.M(strGroup4, "'", false) && n.H(strGroup4, "'", false) && strGroup4.length() > 2) {
                    strGroup4 = strGroup4.substring(1, strGroup4.length() - 1);
                    g.d(strGroup4, "this as java.lang.String…ing(startIndex, endIndex)");
                }
                arrayList.add(strGroup3);
                arrayList.add(strGroup4);
                iEnd = matcher2.end();
            }
        }
        return new s(str, lowerCase, (String[]) arrayList.toArray(new String[0]));
    }

    public static final int n(Bitmap bitmap) {
        if (!bitmap.isRecycled()) {
            try {
                return bitmap.getAllocationByteCount();
            } catch (Exception unused) {
                int height = bitmap.getHeight() * bitmap.getWidth();
                Bitmap.Config config = bitmap.getConfig();
                return height * (config == Bitmap.Config.ALPHA_8 ? 1 : (config == Bitmap.Config.RGB_565 || config == Bitmap.Config.ARGB_4444) ? 2 : (Build.VERSION.SDK_INT < 26 || config != Bitmap.Config.RGBA_F16) ? 4 : 8);
            }
        }
        throw new IllegalStateException(("Cannot obtain size for recycled bitmap: " + bitmap + " [" + bitmap.getWidth() + " x " + bitmap.getHeight() + "] + " + bitmap.getConfig()).toString());
    }

    public static String o(Class cls) {
        LinkedHashMap linkedHashMap = T.f2056b;
        String strValue = (String) linkedHashMap.get(cls);
        if (strValue == null) {
            Q q8 = (Q) cls.getAnnotation(Q.class);
            strValue = q8 != null ? q8.value() : null;
            if (strValue == null || strValue.length() <= 0) {
                throw new IllegalArgumentException("No @Navigator.Name annotation found for ".concat(cls.getSimpleName()).toString());
            }
            linkedHashMap.put(cls, strValue);
        }
        g.b(strValue);
        return strValue;
    }

    public static final Bundle p(String str, Bundle bundle) {
        Bundle bundle2 = bundle.getBundle(str);
        if (bundle2 != null) {
            return bundle2;
        }
        throw new IllegalArgumentException(I1.a.p("No valid saved state was found for the key '", str, "'. It may be missing, null, or not of the expected type. This can occur if the value was saved with a different type or if the saved state was modified unexpectedly."));
    }

    public static int q(long j8) {
        return (int) (j8 ^ (j8 >>> 32));
    }

    public static final boolean s(Bitmap.Config config) {
        return Build.VERSION.SDK_INT >= 26 && config == Bitmap.Config.HARDWARE;
    }

    public static boolean t(byte b8) {
        return b8 > -65;
    }

    public static String u(String str, String str2) {
        int length = str.length() - str2.length();
        if (length < 0 || length > 1) {
            throw new IllegalArgumentException("Invalid input received");
        }
        StringBuilder sb = new StringBuilder(str2.length() + str.length());
        for (int i = 0; i < str.length(); i++) {
            sb.append(str.charAt(i));
            if (str2.length() > i) {
                sb.append(str2.charAt(i));
            }
        }
        return sb.toString();
    }

    public static H x(String str) throws ProtocolException {
        int i;
        String strSubstring;
        g.e(str, "statusLine");
        boolean zM = n.M(str, "HTTP/1.", false);
        x xVar = x.f14194r;
        if (zM) {
            i = 9;
            if (str.length() < 9 || str.charAt(8) != ' ') {
                throw new ProtocolException("Unexpected status line: ".concat(str));
            }
            int iCharAt = str.charAt(7) - '0';
            if (iCharAt != 0) {
                if (iCharAt != 1) {
                    throw new ProtocolException("Unexpected status line: ".concat(str));
                }
                xVar = x.f14195s;
            }
        } else {
            if (!n.M(str, "ICY ", false)) {
                throw new ProtocolException("Unexpected status line: ".concat(str));
            }
            i = 4;
        }
        int i5 = i + 3;
        if (str.length() < i5) {
            throw new ProtocolException("Unexpected status line: ".concat(str));
        }
        try {
            String strSubstring2 = str.substring(i, i5);
            g.d(strSubstring2, "this as java.lang.String…ing(startIndex, endIndex)");
            int i8 = Integer.parseInt(strSubstring2);
            if (str.length() <= i5) {
                strSubstring = "";
            } else {
                if (str.charAt(i5) != ' ') {
                    throw new ProtocolException("Unexpected status line: ".concat(str));
                }
                strSubstring = str.substring(i + 4);
                g.d(strSubstring, "this as java.lang.String).substring(startIndex)");
            }
            return new H(xVar, i8, strSubstring, 9);
        } catch (NumberFormatException unused) {
            throw new ProtocolException("Unexpected status line: ".concat(str));
        }
    }

    public static void y(w0.a aVar) {
        aVar.f18173k = -3.4028235E38f;
        aVar.f18172j = Integer.MIN_VALUE;
        CharSequence charSequence = aVar.f18164a;
        if (charSequence instanceof Spanned) {
            if (!(charSequence instanceof Spannable)) {
                aVar.f18164a = SpannableString.valueOf(charSequence);
            }
            CharSequence charSequence2 = aVar.f18164a;
            charSequence2.getClass();
            Spannable spannable = (Spannable) charSequence2;
            for (Object obj : spannable.getSpans(0, spannable.length(), Object.class)) {
                if ((obj instanceof AbsoluteSizeSpan) || (obj instanceof RelativeSizeSpan)) {
                    spannable.removeSpan(obj);
                }
            }
        }
    }

    public static float z(int i, float f3, int i5, int i8) {
        float f7;
        if (f3 == -3.4028235E38f) {
            return -3.4028235E38f;
        }
        if (i == 0) {
            f7 = i8;
        } else {
            if (i != 1) {
                if (i != 2) {
                    return -3.4028235E38f;
                }
                return f3;
            }
            f7 = i5;
        }
        return f3 * f7;
    }

    @Override // androidx.leanback.transition.e
    public float c(View view) {
        return view.getTranslationY();
    }

    @Override // androidx.leanback.transition.e
    public Property d() {
        return View.TRANSLATION_Y;
    }

    public abstract View v(int i);

    public abstract boolean w();
}
