package o;

import android.R;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.util.LongSparseArray;
import android.view.View;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.HandwritingGesture;
import android.view.translation.TranslationResponseValue;
import android.view.translation.ViewTranslationResponse;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.ms0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC1904ms0 {
    public static C1533iy a = null;
    public static final V8 b = new V8(1);
    public static final Object c = new Object();
    public static final int[] d = {R.attr.state_enabled, R.attr.state_pressed};
    public static CG e = null;
    public static CG f = null;
    public static boolean g = true;
    public static Field h;
    public static boolean i;

    public static final long A(long j, EnumC0382Ot enumC0382Ot) {
        EnumC0382Ot enumC0382Ot2 = EnumC0382Ot.NANOSECONDS;
        TimeUnit timeUnit = enumC0382Ot.l;
        TimeUnit timeUnit2 = enumC0382Ot.l;
        long jConvert = timeUnit.convert(4611686018426999999L, enumC0382Ot2.l);
        return ((-jConvert) > j || j > jConvert) ? e(AbstractC0940cn0.l(EnumC0382Ot.MILLISECONDS.l.convert(j, timeUnit2), -4611686018427387903L, 4611686018427387903L)) : f(enumC0382Ot2.l.convert(j, timeUnit2));
    }

    public static final ExtractedText B(C2730ve0 c2730ve0) {
        ExtractedText extractedText = new ExtractedText();
        String str = c2730ve0.a.m;
        extractedText.text = str;
        extractedText.startOffset = 0;
        extractedText.partialEndOffset = str.length();
        extractedText.partialStartOffset = -1;
        long j = c2730ve0.b;
        extractedText.selectionStart = Ue0.f(j);
        extractedText.selectionEnd = Ue0.e(j);
        extractedText.flags = !Za0.Q(c2730ve0.a.m, '\n') ? 1 : 0;
        return extractedText;
    }

    public static final double C(long j) {
        return ((j >>> 11) * 2048) + (j & 2047);
    }

    public static final int D(int i2) {
        int i3 = 306783378 & i2;
        int i4 = 613566756 & i2;
        return (i2 & (-920350135)) | (i4 >> 1) | i3 | ((i3 << 1) & i4);
    }

    public static int F(int i2) {
        if (i2 == 0) {
            return 1;
        }
        if (i2 == 1) {
            return 2;
        }
        if (i2 == 2) {
            return 3;
        }
        if (i2 != 3) {
            return i2 != 4 ? 0 : 5;
        }
        return 4;
    }

    public static final float a(long j, long j2) {
        return Math.min(Float.intBitsToFloat((int) (j2 >> 32)) / Float.intBitsToFloat((int) (j >> 32)), Float.intBitsToFloat((int) (j2 & 4294967295L)) / Float.intBitsToFloat((int) (j & 4294967295L)));
    }

    public static void b(StringBuilder sb, Object obj, OC oc) {
        if (oc != null) {
            sb.append((CharSequence) oc.g(obj));
            return;
        }
        if (obj == null ? true : obj instanceof CharSequence) {
            sb.append((CharSequence) obj);
        } else if (obj instanceof Character) {
            sb.append(((Character) obj).charValue());
        } else {
            sb.append((CharSequence) String.valueOf(obj));
        }
    }

    public static void c(ArrayList arrayList) {
        HashMap map = new HashMap(arrayList.size());
        int size = arrayList.size();
        int i2 = 0;
        int i3 = 0;
        while (i3 < size) {
            Object obj = arrayList.get(i3);
            i3++;
            C2549tj c2549tj = (C2549tj) obj;
            C0429Qo c0429Qo = new C0429Qo(c2549tj);
            for (JZ jz : c2549tj.b) {
                boolean z = c2549tj.e == 0;
                C0455Ro c0455Ro = new C0455Ro(jz, !z);
                if (!map.containsKey(c0455Ro)) {
                    map.put(c0455Ro, new HashSet());
                }
                Set set = (Set) map.get(c0455Ro);
                if (!set.isEmpty() && z) {
                    throw new IllegalArgumentException("Multiple components provide " + jz + ".");
                }
                set.add(c0429Qo);
            }
        }
        Iterator it = map.values().iterator();
        while (it.hasNext()) {
            for (C0429Qo c0429Qo2 : (Set) it.next()) {
                for (C2660ur c2660ur : c0429Qo2.a.c) {
                    if (c2660ur.c == 0) {
                        Set<C0429Qo> set2 = (Set) map.get(new C0455Ro(c2660ur.a, c2660ur.b == 2));
                        if (set2 != null) {
                            for (C0429Qo c0429Qo3 : set2) {
                                c0429Qo2.b.add(c0429Qo3);
                                c0429Qo3.c.add(c0429Qo2);
                            }
                        }
                    }
                }
            }
        }
        HashSet hashSet = new HashSet();
        Iterator it2 = map.values().iterator();
        while (it2.hasNext()) {
            hashSet.addAll((Set) it2.next());
        }
        HashSet hashSet2 = new HashSet();
        Iterator it3 = hashSet.iterator();
        while (it3.hasNext()) {
            C0429Qo c0429Qo4 = (C0429Qo) it3.next();
            if (c0429Qo4.c.isEmpty()) {
                hashSet2.add(c0429Qo4);
            }
        }
        while (!hashSet2.isEmpty()) {
            C0429Qo c0429Qo5 = (C0429Qo) hashSet2.iterator().next();
            hashSet2.remove(c0429Qo5);
            i2++;
            Iterator it4 = c0429Qo5.b.iterator();
            while (it4.hasNext()) {
                C0429Qo c0429Qo6 = (C0429Qo) it4.next();
                c0429Qo6.c.remove(c0429Qo5);
                if (c0429Qo6.c.isEmpty()) {
                    hashSet2.add(c0429Qo6);
                }
            }
        }
        if (i2 == arrayList.size()) {
            return;
        }
        ArrayList arrayList2 = new ArrayList();
        Iterator it5 = hashSet.iterator();
        while (it5.hasNext()) {
            C0429Qo c0429Qo7 = (C0429Qo) it5.next();
            if (!c0429Qo7.c.isEmpty() && !c0429Qo7.b.isEmpty()) {
                arrayList2.add(c0429Qo7.a);
            }
        }
        throw new C2850wr("Dependency cycle detected: " + Arrays.toString(arrayList2.toArray()));
    }

    public static void d(Q3 q3, LongSparseArray longSparseArray) {
        TranslationResponseValue value;
        CharSequence text;
        T50 t50;
        R50 r50;
        OC oc;
        int size = longSparseArray.size();
        for (int i2 = 0; i2 < size; i2++) {
            long jKeyAt = longSparseArray.keyAt(i2);
            ViewTranslationResponse viewTranslationResponseO = Z2.o(longSparseArray.get(jKeyAt));
            if (viewTranslationResponseO != null && (value = viewTranslationResponseO.getValue("android:text")) != null && (text = value.getText()) != null && (t50 = (T50) q3.h().b((int) jKeyAt)) != null && (r50 = t50.a) != null) {
                Object objG = r50.d.l.g(M50.j);
                if (objG == null) {
                    objG = null;
                }
                C1726l0 c1726l0 = (C1726l0) objG;
                if (c1726l0 != null && (oc = (OC) c1726l0.b) != null) {
                }
            }
        }
    }

    public static final long e(long j) {
        long j2 = (j << 1) + 1;
        int i2 = C0304Lt.f217o;
        int i3 = AbstractC0356Nt.a;
        return j2;
    }

    public static final long f(long j) {
        long j2 = j << 1;
        int i2 = C0304Lt.f217o;
        int i3 = AbstractC0356Nt.a;
        return j2;
    }

    /* JADX WARN: Code restructure failed: missing block: B:32:0x0085, code lost:
    
        if (r1.c(r10, r0) == r5) goto L33;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:27:0x0066  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0067  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0073 A[Catch: all -> 0x0035, TRY_LEAVE, TryCatch #1 {all -> 0x0035, blocks: (B:13:0x002f, B:25:0x0056, B:29:0x006b, B:31:0x0073, B:20:0x0047, B:24:0x0052), top: B:52:0x0021 }] */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0088  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Type inference failed for: r8v5, types: [o.J00] */
    /* JADX WARN: Type inference failed for: r8v7, types: [o.J00] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:32:0x0085 -> B:14:0x0032). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final java.lang.Object g(o.InterfaceC2294qz r7, o.C0721aZ r8, boolean r9, o.AbstractC0298Lm r10) throws java.lang.Throwable {
        /*
            boolean r0 = r10 instanceof o.C2483sz
            if (r0 == 0) goto L13
            r0 = r10
            o.sz r0 = (o.C2483sz) r0
            int r1 = r0.t
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r3 = r1 & r2
            if (r3 == 0) goto L13
            int r1 = r1 - r2
            r0.t = r1
            goto L18
        L13:
            o.sz r0 = new o.sz
            r0.<init>(r10)
        L18:
            java.lang.Object r10 = r0.s
            int r1 = r0.t
            r2 = 0
            r3 = 2
            r4 = 1
            o.Dn r5 = o.EnumC0091Dn.l
            if (r1 == 0) goto L4b
            if (r1 == r4) goto L3f
            if (r1 != r3) goto L37
            boolean r9 = r0.r
            o.cf r7 = r0.q
            o.J00 r8 = r0.p
            o.qz r1 = r0.f722o
            o.IJ.H(r10)     // Catch: java.lang.Throwable -> L35
        L32:
            r10 = r7
            r7 = r1
            goto L56
        L35:
            r7 = move-exception
            goto L90
        L37:
            java.lang.IllegalStateException r7 = new java.lang.IllegalStateException
            java.lang.String r8 = "call to 'resume' before 'invoke' with coroutine"
            r7.<init>(r8)
            throw r7
        L3f:
            boolean r9 = r0.r
            o.cf r7 = r0.q
            o.J00 r8 = r0.p
            o.qz r1 = r0.f722o
            o.IJ.H(r10)     // Catch: java.lang.Throwable -> L35
            goto L6b
        L4b:
            o.IJ.H(r10)
            boolean r10 = r7 instanceof o.C2352rf0
            if (r10 != 0) goto Lab
            o.cf r10 = r8.iterator()     // Catch: java.lang.Throwable -> L35
        L56:
            r0.f722o = r7     // Catch: java.lang.Throwable -> L35
            r0.p = r8     // Catch: java.lang.Throwable -> L35
            r0.q = r10     // Catch: java.lang.Throwable -> L35
            r0.r = r9     // Catch: java.lang.Throwable -> L35
            r0.t = r4     // Catch: java.lang.Throwable -> L35
            java.lang.Object r1 = r10.b(r0)     // Catch: java.lang.Throwable -> L35
            if (r1 != r5) goto L67
            goto L87
        L67:
            r6 = r1
            r1 = r7
            r7 = r10
            r10 = r6
        L6b:
            java.lang.Boolean r10 = (java.lang.Boolean) r10     // Catch: java.lang.Throwable -> L35
            boolean r10 = r10.booleanValue()     // Catch: java.lang.Throwable -> L35
            if (r10 == 0) goto L88
            java.lang.Object r10 = r7.c()     // Catch: java.lang.Throwable -> L35
            r0.f722o = r1     // Catch: java.lang.Throwable -> L35
            r0.p = r8     // Catch: java.lang.Throwable -> L35
            r0.q = r7     // Catch: java.lang.Throwable -> L35
            r0.r = r9     // Catch: java.lang.Throwable -> L35
            r0.t = r3     // Catch: java.lang.Throwable -> L35
            java.lang.Object r10 = r1.c(r10, r0)     // Catch: java.lang.Throwable -> L35
            if (r10 != r5) goto L32
        L87:
            return r5
        L88:
            if (r9 == 0) goto L8d
            r8.c(r2)
        L8d:
            o.Oh0 r7 = o.Oh0.a
            return r7
        L90:
            throw r7     // Catch: java.lang.Throwable -> L91
        L91:
            r10 = move-exception
            if (r9 == 0) goto Laa
            boolean r9 = r7 instanceof java.util.concurrent.CancellationException
            if (r9 == 0) goto L9b
            r2 = r7
            java.util.concurrent.CancellationException r2 = (java.util.concurrent.CancellationException) r2
        L9b:
            if (r2 != 0) goto La7
            java.util.concurrent.CancellationException r2 = new java.util.concurrent.CancellationException
            java.lang.String r9 = "Channel was consumed, consumer had failed"
            r2.<init>(r9)
            r2.initCause(r7)
        La7:
            r8.c(r2)
        Laa:
            throw r10
        Lab:
            o.rf0 r7 = (o.C2352rf0) r7
            java.lang.Throwable r7 = r7.l
            throw r7
        */
        throw new UnsupportedOperationException("Method not decompiled: o.AbstractC1904ms0.g(o.qz, o.aZ, boolean, o.Lm):java.lang.Object");
    }

    public static int h(HandwritingGesture handwritingGesture, S1 s1) {
        String fallbackText = handwritingGesture.getFallbackText();
        if (fallbackText == null) {
            return 3;
        }
        s1.g(new C1314gj(fallbackText, 1));
        return 5;
    }

    public static final int i(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 final float j(int i2, int i3, float[] fArr) {
        return fArr[((i2 - i3) * 2) + 1];
    }

    public static final CG k() {
        CG cg = f;
        if (cg != null) {
            return cg;
        }
        BG bg = new BG("Filled.Check", 24.0f, 24.0f, 24.0f, 24.0f, 0L, 0, false, 96);
        int i2 = Zi0.a;
        Q90 q90 = new Q90(C0190Hi.b);
        ArrayList arrayList = new ArrayList(32);
        arrayList.add(new ZV(9.0f, 16.17f));
        arrayList.add(new YV(4.83f, 12.0f));
        arrayList.add(new C1292gW(-1.42f, 1.41f));
        arrayList.add(new YV(9.0f, 19.0f));
        arrayList.add(new YV(21.0f, 7.0f));
        arrayList.add(new C1292gW(-1.41f, -1.41f));
        arrayList.add(VV.c);
        BG.a(bg, arrayList, q90);
        CG cgB = bg.b();
        f = cgB;
        return cgB;
    }

    /* JADX WARN: Removed duplicated region for block: B:144:0x0265 A[EDGE_INSN: B:203:0x0265->B:144:0x0265 BREAK  A[LOOP:5: B:154:0x0281->B:206:0x0281], EDGE_INSN: B:204:0x0265->B:144:0x0265 BREAK  A[LOOP:5: B:154:0x0281->B:206:0x0281]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final int l(o.Le0 r19, android.text.Layout r20, o.Q1 r21, int r22, android.graphics.RectF r23, o.InterfaceC2686v50 r24, o.C1825m2 r25, boolean r26) {
        /*
            Method dump skipped, instructions count: 721
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.AbstractC1904ms0.l(o.Le0, android.text.Layout, o.Q1, int, android.graphics.RectF, o.v50, o.m2, boolean):int");
    }

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

    public static final boolean o(float[] fArr) {
        return fArr.length >= 16 && fArr[0] == 1.0f && fArr[1] == 0.0f && fArr[2] == 0.0f && fArr[3] == 0.0f && fArr[4] == 0.0f && fArr[5] == 1.0f && fArr[6] == 0.0f && fArr[7] == 0.0f && fArr[8] == 0.0f && fArr[9] == 0.0f && fArr[10] == 1.0f && fArr[11] == 0.0f && fArr[12] == 0.0f && fArr[13] == 0.0f && fArr[14] == 0.0f && fArr[15] == 1.0f;
    }

    public static final boolean p(float f2, float f3, O4 o4) {
        T00 t00 = new T00(f2 - 0.005f, f3 - 0.005f, f2 + 0.005f, f3 + 0.005f);
        O4 o4A = Q4.a();
        O4.a(o4A, t00);
        O4 o4A2 = Q4.a();
        o4A2.d(o4, o4A, 1);
        boolean zIsEmpty = o4A2.a.isEmpty();
        o4A2.e();
        o4A.e();
        return !zIsEmpty;
    }

    public static final boolean q(C2420sK c2420sK) {
        if (c2420sK.r == null) {
            return false;
        }
        C2420sK c2420sKS = c2420sK.s();
        if ((c2420sKS != null ? c2420sKS.r : null) == null) {
            return true;
        }
        c2420sK.O.getClass();
        return false;
    }

    public static final boolean r(float f2, float f3, float f4, float f5, long j) {
        float f6 = f2 - f4;
        float f7 = f3 - f5;
        float fIntBitsToFloat = Float.intBitsToFloat((int) (j >> 32));
        float fIntBitsToFloat2 = Float.intBitsToFloat((int) (j & 4294967295L));
        return ((f7 * f7) / (fIntBitsToFloat2 * fIntBitsToFloat2)) + ((f6 * f6) / (fIntBitsToFloat * fIntBitsToFloat)) <= 1.0f;
    }

    public static void s(long j, C0977d7 c0977d7, boolean z, S1 s1) {
        if (z) {
            int i2 = Ue0.c;
            int iCharCount = (int) (j >> 32);
            int iCharCount2 = (int) (j & 4294967295L);
            int iCodePointBefore = iCharCount > 0 ? Character.codePointBefore(c0977d7, iCharCount) : 10;
            int iCodePointAt = iCharCount2 < c0977d7.m.length() ? Character.codePointAt(c0977d7, iCharCount2) : 10;
            if (AbstractC2378rs0.d0(iCodePointBefore) && (AbstractC2378rs0.c0(iCodePointAt) || AbstractC2378rs0.Z(iCodePointAt))) {
                do {
                    iCharCount -= Character.charCount(iCodePointBefore);
                    if (iCharCount == 0) {
                        break;
                    } else {
                        iCodePointBefore = Character.codePointBefore(c0977d7, iCharCount);
                    }
                } while (AbstractC2378rs0.d0(iCodePointBefore));
                j = AbstractC2378rs0.u(iCharCount, iCharCount2);
            } else if (AbstractC2378rs0.d0(iCodePointAt) && (AbstractC2378rs0.c0(iCodePointBefore) || AbstractC2378rs0.Z(iCodePointBefore))) {
                do {
                    iCharCount2 += Character.charCount(iCodePointAt);
                    if (iCharCount2 == c0977d7.m.length()) {
                        break;
                    } else {
                        iCodePointAt = Character.codePointAt(c0977d7, iCharCount2);
                    }
                } while (AbstractC2378rs0.d0(iCodePointAt));
                j = AbstractC2378rs0.u(iCharCount, iCharCount2);
            }
        }
        int i3 = (int) (4294967295L & j);
        s1.g(new FE(new InterfaceC0764av[]{new C2500t70(i3, i3), new C1711kr(Ue0.d(j), 0)}));
    }

    public static Hw0 t(Pc0 pc0, Pc0 pc02) {
        OD od = new OD(19);
        Qc0 qc0 = new Qc0((C1696kj0) od.m);
        C3034yo c3034yo = new C3034yo(qc0, new AtomicBoolean(false), od, 0);
        V8 v8 = b;
        pc0.d(v8, c3034yo);
        pc02.d(v8, c3034yo);
        return qc0.a;
    }

    public static ColorStateList u(ColorStateList colorStateList) {
        if (colorStateList == null) {
            return ColorStateList.valueOf(0);
        }
        if (Build.VERSION.SDK_INT <= 27 && Color.alpha(colorStateList.getDefaultColor()) == 0) {
            Color.alpha(colorStateList.getColorForState(d, 0));
        }
        return colorStateList;
    }

    public static boolean x(int[] iArr) {
        boolean z = false;
        boolean z2 = false;
        for (int i2 : iArr) {
            if (i2 == 16842910) {
                z = true;
            } else if (i2 == 16842908 || i2 == 16842919 || i2 == 16843623) {
                z2 = true;
            }
        }
        return z && z2;
    }

    public static final void y(int i2, int i3, L60 l60) {
        ArrayList arrayList = new ArrayList();
        int i4 = (~i2) & i3;
        for (int i5 = 0; i5 < 32; i5++) {
            if ((i4 & 1) != 0) {
                arrayList.add(l60.e(i5));
            }
            i4 >>>= 1;
        }
        String strB = l60.b();
        throw new HP(arrayList, arrayList.size() == 1 ? "Field '" + ((String) arrayList.get(0)) + "' is required for type with serial name '" + strB + "', but it was missing" : "Fields " + arrayList + " are required for type with serial name '" + strB + "', but they were missing", null);
    }

    public static final long z(int i2, EnumC0382Ot enumC0382Ot) {
        if (enumC0382Ot.compareTo(EnumC0382Ot.SECONDS) > 0) {
            return A(i2, enumC0382Ot);
        }
        return f(EnumC0382Ot.NANOSECONDS.l.convert(i2, enumC0382Ot.l));
    }

    public abstract void E(byte[] bArr, int i2, int i3);

    public float m(View view) {
        if (g) {
            try {
                return AbstractC2552tk0.a(view);
            } catch (NoSuchMethodError unused) {
                g = false;
            }
        }
        return view.getAlpha();
    }

    public void v(View view, float f2) {
        if (g) {
            try {
                AbstractC2552tk0.b(view, f2);
                return;
            } catch (NoSuchMethodError unused) {
                g = false;
            }
        }
        view.setAlpha(f2);
    }

    public void w(View view, int i2) throws IllegalAccessException, NoSuchFieldException, SecurityException, IllegalArgumentException {
        if (!i) {
            try {
                Field declaredField = View.class.getDeclaredField("mViewFlags");
                h = declaredField;
                declaredField.setAccessible(true);
            } catch (NoSuchFieldException unused) {
            }
            i = true;
        }
        Field field = h;
        if (field != null) {
            try {
                h.setInt(view, i2 | (field.getInt(view) & (-13)));
            } catch (IllegalAccessException unused2) {
            }
        }
    }
}
