package W3;

import E1.C0096c;
import E1.F;
import P.j;
import a.AbstractC0386a;
import android.R;
import android.content.ContentProviderClient;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.sqlite.SQLiteDatabase;
import android.drm.DrmManagerClient;
import android.graphics.Color;
import android.graphics.Paint;
import android.media.MediaDrm;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.text.TextDirectionHeuristic;
import android.text.TextDirectionHeuristics;
import android.text.TextPaint;
import android.text.method.PasswordTransformationMethod;
import android.util.Property;
import android.util.Size;
import android.util.SizeF;
import android.view.ActionMode;
import android.view.View;
import android.widget.TextView;
import com.google.android.gms.internal.measurement.AbstractC0641h;
import com.google.android.gms.internal.measurement.AbstractC0707u1;
import com.google.android.gms.internal.measurement.C0686q;
import com.google.android.gms.internal.measurement.C0700t;
import com.google.android.gms.internal.measurement.InterfaceC0651j;
import com.google.android.gms.internal.measurement.InterfaceC0671n;
import com.google.crypto.tink.shaded.protobuf.AbstractC0742h;
import d5.AbstractC0844a;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import k7.o;
import n.C1190H;
import n4.u0;
import x0.v;

/* JADX INFO: loaded from: classes.dex */
public abstract class b implements androidx.leanback.transition.e {

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

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

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

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

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

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

    public static ActionMode.Callback A(ActionMode.Callback callback, TextView textView) {
        int i = Build.VERSION.SDK_INT;
        return (i < 26 || i > 27 || (callback instanceof j) || callback == null) ? callback : new j(callback, textView);
    }

    public static InterfaceC0671n B(InterfaceC0651j interfaceC0651j, C0686q c0686q, C2.a aVar, ArrayList arrayList) {
        String str = c0686q.f9944q;
        if (interfaceC0651j.f(str)) {
            InterfaceC0671n interfaceC0671nH = interfaceC0651j.h(str);
            if (interfaceC0671nH instanceof AbstractC0641h) {
                return ((AbstractC0641h) interfaceC0671nH).d(aVar, arrayList);
            }
            throw new IllegalArgumentException(AbstractC0844a.l(str, " is not a function"));
        }
        if (!"hasOwnProperty".equals(str)) {
            throw new IllegalArgumentException(AbstractC0844a.x("Object has no function ", str));
        }
        AbstractC0707u1.y("hasOwnProperty", 1, arrayList);
        return interfaceC0651j.f(((C0700t) aVar.f1157r).a(aVar, (InterfaceC0671n) arrayList.get(0)).c()) ? InterfaceC0671n.f9923l : InterfaceC0671n.f9924m;
    }

    public static List a(int... iArr) {
        return iArr.length == 0 ? Collections.EMPTY_LIST : new F3.b(0, iArr.length, iArr);
    }

    public static final Bundle e(A6.h... hVarArr) {
        Bundle bundle = new Bundle(hVarArr.length);
        for (A6.h hVar : hVarArr) {
            String str = (String) hVar.f446q;
            Object obj = hVar.f447r;
            if (obj == null) {
                bundle.putString(str, null);
            } else if (obj instanceof Boolean) {
                bundle.putBoolean(str, ((Boolean) obj).booleanValue());
            } else if (obj instanceof Byte) {
                bundle.putByte(str, ((Number) obj).byteValue());
            } else if (obj instanceof Character) {
                bundle.putChar(str, ((Character) obj).charValue());
            } else if (obj instanceof Double) {
                bundle.putDouble(str, ((Number) obj).doubleValue());
            } else if (obj instanceof Float) {
                bundle.putFloat(str, ((Number) obj).floatValue());
            } else if (obj instanceof Integer) {
                bundle.putInt(str, ((Number) obj).intValue());
            } else if (obj instanceof Long) {
                bundle.putLong(str, ((Number) obj).longValue());
            } else if (obj instanceof Short) {
                bundle.putShort(str, ((Number) obj).shortValue());
            } else if (obj instanceof Bundle) {
                bundle.putBundle(str, (Bundle) obj);
            } else if (obj instanceof CharSequence) {
                bundle.putCharSequence(str, (CharSequence) obj);
            } else if (obj instanceof Parcelable) {
                bundle.putParcelable(str, (Parcelable) obj);
            } else if (obj instanceof boolean[]) {
                bundle.putBooleanArray(str, (boolean[]) obj);
            } else if (obj instanceof byte[]) {
                bundle.putByteArray(str, (byte[]) obj);
            } else if (obj instanceof char[]) {
                bundle.putCharArray(str, (char[]) obj);
            } else if (obj instanceof double[]) {
                bundle.putDoubleArray(str, (double[]) obj);
            } else if (obj instanceof float[]) {
                bundle.putFloatArray(str, (float[]) obj);
            } else if (obj instanceof int[]) {
                bundle.putIntArray(str, (int[]) obj);
            } else if (obj instanceof long[]) {
                bundle.putLongArray(str, (long[]) obj);
            } else if (obj instanceof short[]) {
                bundle.putShortArray(str, (short[]) obj);
            } else if (obj instanceof Object[]) {
                Class<?> componentType = obj.getClass().getComponentType();
                P6.g.b(componentType);
                if (Parcelable.class.isAssignableFrom(componentType)) {
                    bundle.putParcelableArray(str, (Parcelable[]) obj);
                } else if (String.class.isAssignableFrom(componentType)) {
                    bundle.putStringArray(str, (String[]) obj);
                } else if (CharSequence.class.isAssignableFrom(componentType)) {
                    bundle.putCharSequenceArray(str, (CharSequence[]) obj);
                } else {
                    if (!Serializable.class.isAssignableFrom(componentType)) {
                        throw new IllegalArgumentException("Illegal value array type " + componentType.getCanonicalName() + " for key \"" + str + '\"');
                    }
                    bundle.putSerializable(str, (Serializable) obj);
                }
            } else if (obj instanceof Serializable) {
                bundle.putSerializable(str, (Serializable) obj);
            } else if (obj instanceof IBinder) {
                bundle.putBinder(str, (IBinder) obj);
            } else if (obj instanceof Size) {
                bundle.putSize(str, (Size) obj);
            } else {
                if (!(obj instanceof SizeF)) {
                    throw new IllegalArgumentException("Illegal value type " + obj.getClass().getCanonicalName() + " for key \"" + str + '\"');
                }
                bundle.putSizeF(str, (SizeF) obj);
            }
        }
        return bundle;
    }

    public static void f(String str) {
        if (str.length() <= 0) {
            throw new IllegalArgumentException("name is empty");
        }
        int length = str.length();
        for (int i = 0; i < length; i++) {
            char cCharAt = str.charAt(i);
            if ('!' > cCharAt || cCharAt >= 127) {
                throw new IllegalArgumentException(l7.b.i("Unexpected char %#04x at %d in header name: %s", Integer.valueOf(cCharAt), Integer.valueOf(i), str).toString());
            }
        }
    }

    public static void g(String str, String str2) {
        int length = str.length();
        for (int i = 0; i < length; i++) {
            char cCharAt = str.charAt(i);
            if (cCharAt != '\t' && (' ' > cCharAt || cCharAt >= 127)) {
                StringBuilder sb = new StringBuilder();
                sb.append(l7.b.i("Unexpected char %#04x at %d in %s value", Integer.valueOf(cCharAt), Integer.valueOf(i), str2));
                sb.append(l7.b.q(str2) ? "" : ": ".concat(str));
                throw new IllegalArgumentException(sb.toString().toString());
            }
        }
    }

    public static int h(long j8) {
        int i = (int) j8;
        if (((long) i) == j8) {
            return i;
        }
        throw new IllegalArgumentException(U2.a.G("Out of range: %s", Long.valueOf(j8)));
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static final void j(X1.c cVar, Throwable th) {
        if (cVar != 0) {
            if (th != null) {
                try {
                    AbstractC0844a.u(cVar);
                    return;
                } catch (Throwable th2) {
                    android.support.v4.media.session.a.a(th, th2);
                    return;
                }
            }
            if (cVar instanceof AutoCloseable) {
                cVar.close();
                return;
            }
            if (cVar instanceof ExecutorService) {
                A0.c.y((ExecutorService) cVar);
                return;
            }
            if (cVar instanceof TypedArray) {
                ((TypedArray) cVar).recycle();
                return;
            }
            if (cVar instanceof MediaMetadataRetriever) {
                ((MediaMetadataRetriever) cVar).release();
                return;
            }
            if (cVar instanceof MediaDrm) {
                ((MediaDrm) cVar).release();
            } else if (cVar instanceof DrmManagerClient) {
                ((DrmManagerClient) cVar).release();
            } else {
                if (!(cVar instanceof ContentProviderClient)) {
                    throw new IllegalArgumentException();
                }
                ((ContentProviderClient) cVar).release();
            }
        }
    }

    public static void k(z0.h hVar) {
        if (hVar != null) {
            try {
                hVar.close();
            } catch (IOException unused) {
            }
        }
    }

    public static String l(AbstractC0742h abstractC0742h) {
        StringBuilder sb = new StringBuilder(abstractC0742h.size());
        for (int i = 0; i < abstractC0742h.size(); i++) {
            byte bA = abstractC0742h.a(i);
            if (bA == 34) {
                sb.append("\\\"");
            } else if (bA == 39) {
                sb.append("\\'");
            } else if (bA != 92) {
                switch (bA) {
                    case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                        sb.append("\\a");
                        break;
                    case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                        sb.append("\\b");
                        break;
                    case 9:
                        sb.append("\\t");
                        break;
                    case 10:
                        sb.append("\\n");
                        break;
                    case 11:
                        sb.append("\\v");
                        break;
                    case 12:
                        sb.append("\\f");
                        break;
                    case 13:
                        sb.append("\\r");
                        break;
                    default:
                        if (bA < 32 || bA > 126) {
                            sb.append('\\');
                            sb.append((char) (((bA >>> 6) & 3) + 48));
                            sb.append((char) (((bA >>> 3) & 7) + 48));
                            sb.append((char) ((bA & 7) + 48));
                        } else {
                            sb.append((char) bA);
                        }
                        break;
                }
            } else {
                sb.append("\\\\");
            }
        }
        return sb.toString();
    }

    public static final F m(View view) {
        P6.g.e(view, "view");
        F f3 = (F) W6.j.G(W6.j.F(new W6.f(W6.j.H(view, C0096c.f2070y), C0096c.f2071z, 3)));
        if (f3 != null) {
            return f3;
        }
        throw new IllegalStateException("View " + view + " does not have a NavController set");
    }

    public static K.d n(C1190H c1190h) {
        int i = Build.VERSION.SDK_INT;
        if (i >= 28) {
            return new K.d(B.a.f(c1190h));
        }
        TextPaint textPaint = new TextPaint(c1190h.getPaint());
        TextDirectionHeuristic textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_LTR;
        int breakStrategy = c1190h.getBreakStrategy();
        int hyphenationFrequency = c1190h.getHyphenationFrequency();
        if (c1190h.getTransformationMethod() instanceof PasswordTransformationMethod) {
            textDirectionHeuristic = TextDirectionHeuristics.LTR;
        } else if (i < 28 || (c1190h.getInputType() & 15) != 3) {
            boolean z8 = c1190h.getLayoutDirection() == 1;
            switch (c1190h.getTextDirection()) {
                case 2:
                    textDirectionHeuristic = TextDirectionHeuristics.ANYRTL_LTR;
                    break;
                case 3:
                    textDirectionHeuristic = TextDirectionHeuristics.LTR;
                    break;
                case 4:
                    textDirectionHeuristic = TextDirectionHeuristics.RTL;
                    break;
                case 5:
                    textDirectionHeuristic = TextDirectionHeuristics.LOCALE;
                    break;
                case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                    break;
                case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                    textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_RTL;
                    break;
                default:
                    if (z8) {
                        textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_RTL;
                    }
                    break;
            }
        } else {
            byte directionality = Character.getDirectionality(B.a.a(B.g.e(c1190h.getTextLocale()))[0].codePointAt(0));
            textDirectionHeuristic = (directionality == 1 || directionality == 2) ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR;
        }
        return new K.d(textPaint, textDirectionHeuristic, breakStrategy, hyphenationFrequency);
    }

    public static Z1.c o(P.g gVar, SQLiteDatabase sQLiteDatabase) {
        P6.g.e(gVar, "refHolder");
        Z1.c cVar = (Z1.c) gVar.f5246r;
        if (cVar != null && cVar.f7394q.equals(sQLiteDatabase)) {
            return cVar;
        }
        Z1.c cVar2 = new Z1.c(sQLiteDatabase);
        gVar.f5246r = cVar2;
        return cVar2;
    }

    public static int p(int[] iArr, int i, int i5, int i8) {
        while (i5 < i8) {
            if (iArr[i5] == i) {
                return i5;
            }
            i5++;
        }
        return -1;
    }

    public static o q(String... strArr) {
        if (strArr.length % 2 != 0) {
            throw new IllegalArgumentException("Expected alternating header names and values");
        }
        String[] strArr2 = (String[]) strArr.clone();
        int length = strArr2.length;
        int i = 0;
        for (int i5 = 0; i5 < length; i5++) {
            String str = strArr2[i5];
            if (str == null) {
                throw new IllegalArgumentException("Headers cannot be null");
            }
            strArr2[i5] = X6.e.j0(str).toString();
        }
        int iT = u0.t(0, strArr2.length - 1, 2);
        if (iT >= 0) {
            while (true) {
                String str2 = strArr2[i];
                String str3 = strArr2[i + 1];
                f(str2);
                g(str3, str2);
                if (i == iT) {
                    break;
                }
                i += 2;
            }
        }
        return new o(strArr2);
    }

    public static final boolean r(String str) {
        P6.g.e(str, "method");
        return (str.equals("GET") || str.equals("HEAD")) ? false : true;
    }

    public static int s(long j8) {
        if (j8 > 2147483647L) {
            return Integer.MAX_VALUE;
        }
        if (j8 < -2147483648L) {
            return Integer.MIN_VALUE;
        }
        return (int) j8;
    }

    public static void t(TextView textView, int i) {
        AbstractC0386a.i(i);
        if (Build.VERSION.SDK_INT >= 28) {
            B.a.j(textView, i);
            return;
        }
        Paint.FontMetricsInt fontMetricsInt = textView.getPaint().getFontMetricsInt();
        int i5 = textView.getIncludeFontPadding() ? fontMetricsInt.top : fontMetricsInt.ascent;
        if (i > Math.abs(i5)) {
            textView.setPadding(textView.getPaddingLeft(), i + i5, textView.getPaddingRight(), textView.getPaddingBottom());
        }
    }

    public static void u(TextView textView, int i) {
        AbstractC0386a.i(i);
        Paint.FontMetricsInt fontMetricsInt = textView.getPaint().getFontMetricsInt();
        int i5 = textView.getIncludeFontPadding() ? fontMetricsInt.bottom : fontMetricsInt.descent;
        if (i > Math.abs(i5)) {
            textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), i - i5);
        }
    }

    public static int v(Context context, int i) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(R.style.Animation.Activity, new int[]{i});
        int resourceId = typedArrayObtainStyledAttributes.getResourceId(0, -1);
        typedArrayObtainStyledAttributes.recycle();
        return resourceId;
    }

    public static int[] w(Collection collection) {
        if (collection instanceof F3.b) {
            F3.b bVar = (F3.b) collection;
            return Arrays.copyOfRange(bVar.f2490q, bVar.f2491r, bVar.f2492s);
        }
        Object[] array = collection.toArray();
        int length = array.length;
        int[] iArr = new int[length];
        for (int i = 0; i < length; i++) {
            Object obj = array[i];
            obj.getClass();
            iArr[i] = ((Number) obj).intValue();
        }
        return iArr;
    }

    public static String x(int i) {
        Object[] objArr = {Integer.valueOf(Color.red(i)), Integer.valueOf(Color.green(i)), Integer.valueOf(Color.blue(i)), Double.valueOf(((double) Color.alpha(i)) / 255.0d)};
        int i5 = v.f18553a;
        return String.format(Locale.US, "rgba(%d,%d,%d,%.3f)", objArr);
    }

    /* JADX WARN: Removed duplicated region for block: B:4:0x000d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Integer y(String str) {
        byte b8;
        Long lValueOf;
        byte b9;
        str.getClass();
        if (str.isEmpty()) {
            lValueOf = null;
        } else {
            int i = str.charAt(0) == '-' ? 1 : 0;
            if (i != str.length()) {
                int i5 = i + 1;
                char cCharAt = str.charAt(i);
                if (cCharAt < 128) {
                    b8 = F3.c.f2493a[cCharAt];
                } else {
                    byte[] bArr = F3.c.f2493a;
                    b8 = -1;
                }
                if (b8 >= 0 && b8 < 10) {
                    long j8 = -b8;
                    long j9 = 10;
                    long j10 = Long.MIN_VALUE / j9;
                    while (true) {
                        if (i5 < str.length()) {
                            int i8 = i5 + 1;
                            char cCharAt2 = str.charAt(i5);
                            if (cCharAt2 < 128) {
                                b9 = F3.c.f2493a[cCharAt2];
                            } else {
                                byte[] bArr2 = F3.c.f2493a;
                                b9 = -1;
                            }
                            if (b9 < 0 || b9 >= 10 || j8 < j10) {
                                break;
                            }
                            long j11 = j8 * j9;
                            int i9 = i;
                            long j12 = b9;
                            if (j11 < j12 - Long.MIN_VALUE) {
                                break;
                            }
                            j8 = j11 - j12;
                            i5 = i8;
                            i = i9;
                        } else if (i != 0) {
                            lValueOf = Long.valueOf(j8);
                        } else {
                            if (j8 == Long.MIN_VALUE) {
                                break;
                            }
                            lValueOf = Long.valueOf(-j8);
                        }
                    }
                    lValueOf = null;
                }
            }
        }
        if (lValueOf == null || lValueOf.longValue() != lValueOf.intValue()) {
            return null;
        }
        return Integer.valueOf(lValueOf.intValue());
    }

    public static ActionMode.Callback z(ActionMode.Callback callback) {
        return (!(callback instanceof j) || Build.VERSION.SDK_INT < 26) ? callback : ((j) callback).f5248a;
    }

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

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

    public abstract List i(String str, List list);
}
