package o;

import android.os.Trace;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Mb, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0312Mb {
    public final /* synthetic */ int a;
    public Object b;
    public Object c;
    public Object d;
    public Object e;
    public Object f;
    public Object g;
    public Object h;
    public Object i;
    public Object j;
    public Object k;

    public C0312Mb(C2420sK c2420sK) {
        this.a = 1;
        this.b = c2420sK;
        C1954nS c1954nS = new C1954nS();
        c1954nS.f209o = -1;
        this.c = c1954nS;
        C2702vH c2702vH = new C2702vH(c2420sK);
        this.d = c2702vH;
        this.e = c2702vH;
        Bc0 bc0 = c2702vH.Z;
        this.f = bc0;
        this.g = bc0;
        this.j = new C1479iR(new MP[16]);
    }

    public static final void a(C0312Mb c0312Mb, LP lp, AbstractC2239qS abstractC2239qS) {
        for (LP lp2 = lp.p; lp2 != null; lp2 = lp2.p) {
            if (lp2 == ((C1954nS) c0312Mb.c)) {
                C2420sK c2420sKS = ((C2420sK) c0312Mb.b).s();
                abstractC2239qS.B = c2420sKS != null ? (C2702vH) c2420sKS.N.d : null;
                c0312Mb.e = abstractC2239qS;
                return;
            } else {
                if ((lp2.n & 2) != 0) {
                    return;
                }
                lp2.G0(abstractC2239qS);
            }
        }
    }

    public static LP e(KP kp, LP lp) {
        LP lpF;
        if (kp instanceof RP) {
            lpF = ((RP) kp).f();
            lpF.n = AbstractC2333rS.f(lpF);
        } else {
            C0184Hc c0184Hc = new C0184Hc();
            c0184Hc.n = AbstractC2333rS.d(kp);
            c0184Hc.z = kp;
            c0184Hc.B = new HashSet();
            lpF = c0184Hc;
        }
        if (lpF.y) {
            AbstractC2133pH.b("A ModifierNodeElement cannot return an already attached node from create() ");
        }
        lpF.t = true;
        LP lp2 = lp.q;
        if (lp2 != null) {
            lp2.p = lpF;
            lpF.q = lp2;
        }
        lp.q = lpF;
        lpF.p = lp;
        return lpF;
    }

    public static LP f(LP lp) {
        boolean z = lp.y;
        if (z) {
            QQ qq = AbstractC2333rS.a;
            if (!z) {
                AbstractC2133pH.b("autoInvalidateRemovedNode called on unattached node");
            }
            AbstractC2333rS.a(lp, -1, 2);
            lp.E0();
            lp.y0();
        }
        LP lp2 = lp.q;
        LP lp3 = lp.p;
        if (lp2 != null) {
            lp2.p = lp3;
            lp.q = null;
        }
        if (lp3 != null) {
            lp3.q = lp2;
            lp.p = null;
        }
        return lp3;
    }

    public static void o(KP kp, KP kp2, LP lp) {
        if ((kp instanceof RP) && (kp2 instanceof RP)) {
            ((RP) kp2).j(lp);
            if (lp.y) {
                AbstractC2333rS.c(lp);
                return;
            } else {
                lp.u = true;
                return;
            }
        }
        if (!(lp instanceof C0184Hc)) {
            AbstractC2133pH.b("Unknown Modifier.Node type");
            return;
        }
        C0184Hc c0184Hc = (C0184Hc) lp;
        if (c0184Hc.y) {
            c0184Hc.I0();
        }
        c0184Hc.z = kp2;
        c0184Hc.n = AbstractC2333rS.d(kp2);
        if (c0184Hc.y) {
            c0184Hc.H0(false);
        }
        if (lp.y) {
            AbstractC2333rS.c(lp);
        } else {
            lp.u = true;
        }
    }

    public void b(String str, String str2) {
        HashMap map = (HashMap) this.i;
        if (map == null) {
            throw new IllegalStateException("Property \"autoMetadata\" has not been set");
        }
        map.put(str, str2);
    }

    public C0338Nb c() {
        String strI = ((String) this.b) == null ? " transportName" : "";
        if (((C0514Tv) this.f) == null) {
            strI = strI.concat(" encodedPayload");
        }
        if (((Long) this.g) == null) {
            strI = AbstractC2462sn.i(strI, " eventMillis");
        }
        if (((Long) this.h) == null) {
            strI = AbstractC2462sn.i(strI, " uptimeMillis");
        }
        if (((HashMap) this.i) == null) {
            strI = AbstractC2462sn.i(strI, " autoMetadata");
        }
        if (strI.isEmpty()) {
            return new C0338Nb((String) this.b, (Integer) this.d, (C0514Tv) this.f, ((Long) this.g).longValue(), ((Long) this.h).longValue(), (HashMap) this.i, (Integer) this.e, (String) this.c, (byte[]) this.j, (byte[]) this.k);
        }
        throw new IllegalStateException("Missing required properties:".concat(strI));
    }

    public void d() {
        this.b = null;
        this.c = null;
        C1479iR c1479iR = (C1479iR) this.d;
        c1479iR.h();
        ((C0713aR) this.e).b();
        this.f = c1479iR;
        ((C1479iR) this.g).h();
        ((C1479iR) this.h).h();
        this.i = null;
        this.j = null;
        this.k = null;
    }

    public void g() {
        Set set = (Set) this.b;
        if (set == null || set.isEmpty()) {
            return;
        }
        Trace.beginSection("Compose:abandons");
        try {
            Iterator it = set.iterator();
            while (it.hasNext()) {
                Q10 q10 = (Q10) it.next();
                it.remove();
                q10.e();
            }
        } finally {
            Trace.endSection();
        }
    }

    public void h() {
        C1479iR c1479iR = (C1479iR) this.d;
        C1479iR c1479iR2 = (C1479iR) this.g;
        Set set = (Set) this.b;
        if (set == null) {
            return;
        }
        if (c1479iR2.n != 0) {
            Trace.beginSection("Compose:onForgotten");
            try {
                C0713aR c0713aR = (C0713aR) this.i;
                int i = c1479iR2.n;
                while (true) {
                    i--;
                    if (-1 >= i) {
                        break;
                    }
                    Object obj = c1479iR2.l[i];
                    try {
                        if (obj instanceof R10) {
                            Q10 q10 = ((R10) obj).a;
                            set.remove(q10);
                            q10.h();
                        }
                        if (obj instanceof InterfaceC2646uk) {
                            if (c0713aR == null || !c0713aR.c(obj)) {
                                ((InterfaceC2646uk) obj).e();
                            } else {
                                ((InterfaceC2646uk) obj).d();
                            }
                        }
                    } catch (Throwable th) {
                        C0503Tk c0503Tk = (C0503Tk) this.c;
                        if (c0503Tk != null) {
                            C80.Z(th, new C2590u5(4, c0503Tk, obj));
                        }
                        throw th;
                    }
                }
            } finally {
                Trace.endSection();
            }
        }
        if (c1479iR.n != 0) {
            Trace.beginSection("Compose:onRemembered");
            try {
                Set set2 = (Set) this.b;
                if (set2 != null) {
                    Object[] objArr = c1479iR.l;
                    int i2 = c1479iR.n;
                    for (int i3 = 0; i3 < i2; i3++) {
                        R10 r10 = (R10) objArr[i3];
                        Q10 q102 = r10.a;
                        set2.remove(q102);
                        try {
                            q102.a();
                        } catch (Throwable th2) {
                            C0503Tk c0503Tk2 = (C0503Tk) this.c;
                            if (c0503Tk2 != null) {
                                C80.Z(th2, new C2590u5(4, c0503Tk2, r10));
                            }
                            throw th2;
                        }
                    }
                }
            } finally {
            }
        }
    }

    public void i(R10 r10) {
        C1479iR c1479iR = (C1479iR) this.d;
        C0713aR c0713aR = (C0713aR) this.e;
        if (c0713aR.c(r10)) {
            c0713aR.k(r10);
            if (!((C1479iR) this.f).j(r10) && !c1479iR.j(r10)) {
                Object[] objArr = c1479iR.l;
                int i = c1479iR.n;
                for (int i2 = 0; i2 < i; i2++) {
                    if (((R10) objArr[i2]).a instanceof AbstractC2243qW) {
                        throw null;
                    }
                }
            }
            Set set = (Set) this.b;
            if (set == null) {
                return;
            } else {
                set.add(r10.a);
            }
        }
        ((C1479iR) this.g).b(r10);
    }

    public boolean j(int i) {
        return (i & ((LP) this.g).f209o) != 0;
    }

    public void k(Set set, C0503Tk c0503Tk) {
        d();
        this.b = set;
        this.c = c0503Tk;
    }

    public void l() {
        for (LP lp = (LP) this.g; lp != null; lp = lp.q) {
            lp.D0();
            if (lp.t) {
                QQ qq = AbstractC2333rS.a;
                if (!lp.y) {
                    AbstractC2133pH.b("autoInvalidateInsertedNode called on unattached node");
                }
                AbstractC2333rS.a(lp, -1, 1);
            }
            if (lp.u) {
                AbstractC2333rS.c(lp);
            }
            lp.t = false;
            lp.u = false;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:118:0x0264, code lost:
    
        r13 = r28 + 2;
        r11 = r24;
     */
    /* JADX WARN: Code restructure failed: missing block: B:119:0x026a, code lost:
    
        r3 = r3 + 1;
        r12 = r20;
        r11 = r21;
        r13 = r26;
        r14 = r29;
        r35 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:55:0x014a, code lost:
    
        r26 = r13;
        r29 = r14;
     */
    /* JADX WARN: Code restructure failed: missing block: B:56:0x0150, code lost:
    
        if ((r19 & 1) != 0) goto L58;
     */
    /* JADX WARN: Code restructure failed: missing block: B:57:0x0152, code lost:
    
        r11 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:58:0x0154, code lost:
    
        r11 = r33;
     */
    /* JADX WARN: Code restructure failed: missing block: B:59:0x0156, code lost:
    
        r13 = r12;
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x0157, code lost:
    
        if (r13 > r3) goto L180;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x0159, code lost:
    
        if (r13 == r12) goto L68;
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x015b, code lost:
    
        if (r13 == r3) goto L66;
     */
    /* JADX WARN: Code restructure failed: missing block: B:63:0x015d, code lost:
    
        r24 = r11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x016b, code lost:
    
        if (r20[(r13 + 1) + r17] >= r20[(r13 - 1) + r17]) goto L67;
     */
    /* JADX WARN: Code restructure failed: missing block: B:66:0x016e, code lost:
    
        r24 = r11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x0170, code lost:
    
        r11 = r20[(r13 - 1) + r17];
        r14 = r11 - 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x0179, code lost:
    
        r24 = r11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:69:0x017b, code lost:
    
        r11 = r20[(r13 + 1) + r17];
        r14 = r11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:70:0x0182, code lost:
    
        r22 = r10 - ((r6 - r14) - r13);
     */
    /* JADX WARN: Code restructure failed: missing block: B:71:0x0188, code lost:
    
        if (r3 == 0) goto L73;
     */
    /* JADX WARN: Code restructure failed: missing block: B:72:0x018a, code lost:
    
        r25 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:73:0x018d, code lost:
    
        r25 = r33;
     */
    /* JADX WARN: Code restructure failed: missing block: B:74:0x018f, code lost:
    
        if (r14 != r11) goto L76;
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x0191, code lost:
    
        r27 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:76:0x0194, code lost:
    
        r27 = r33;
     */
    /* JADX WARN: Code restructure failed: missing block: B:77:0x0196, code lost:
    
        r25 = r22 + (r25 & r27);
        r22 = r11;
        r11 = r22;
     */
    /* JADX WARN: Code restructure failed: missing block: B:78:0x01a0, code lost:
    
        if (r14 <= r7) goto L186;
     */
    /* JADX WARN: Code restructure failed: missing block: B:79:0x01a2, code lost:
    
        if (r11 <= r15) goto L187;
     */
    /* JADX WARN: Code restructure failed: missing block: B:80:0x01a4, code lost:
    
        r27 = r11;
        r28 = r13;
     */
    /* JADX WARN: Code restructure failed: missing block: B:81:0x01b0, code lost:
    
        if (r0.a(r14 - 1, r27 - 1) == false) goto L185;
     */
    /* JADX WARN: Code restructure failed: missing block: B:82:0x01b2, code lost:
    
        r14 = r14 - 1;
        r11 = r27 - 1;
        r13 = r28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x01b9, code lost:
    
        r27 = r11;
        r28 = r13;
     */
    /* JADX WARN: Code restructure failed: missing block: B:84:0x01bd, code lost:
    
        r20[r17 + r28] = r14;
     */
    /* JADX WARN: Code restructure failed: missing block: B:85:0x01c1, code lost:
    
        if (r24 == 0) goto L181;
     */
    /* JADX WARN: Code restructure failed: missing block: B:86:0x01c3, code lost:
    
        r11 = r19 - r28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:87:0x01c5, code lost:
    
        if (r11 < r12) goto L182;
     */
    /* JADX WARN: Code restructure failed: missing block: B:88:0x01c7, code lost:
    
        if (r11 > r3) goto L183;
     */
    /* JADX WARN: Code restructure failed: missing block: B:90:0x01cd, code lost:
    
        if (r16[r17 + r11] < r14) goto L184;
     */
    /* JADX WARN: Code restructure failed: missing block: B:91:0x01cf, code lost:
    
        r26[r33] = r14;
        r11 = 1;
        r26[1] = r27;
        r26[r32] = r22;
        r26[3] = r25;
        r26[4] = 1;
     */
    /* JADX WARN: Removed duplicated region for block: B:33:0x00f3  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00fa  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00fd  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x010b A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:46:0x011e  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0140  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void m(int r32, o.C1479iR r33, o.C1479iR r34, o.LP r35, boolean r36) {
        /*
            Method dump skipped, instructions count: 907
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0312Mb.m(int, o.iR, o.iR, o.LP, boolean):void");
    }

    public void n() {
        C2041oK c2041oK;
        C2420sK c2420sK = (C2420sK) this.b;
        AbstractC2239qS abstractC2239qS = (C2702vH) this.d;
        for (LP lp = ((Bc0) this.f).p; lp != null; lp = lp.p) {
            InterfaceC1851mK interfaceC1851mKJ = AbstractC2539te.j(lp);
            if (interfaceC1851mKJ != null) {
                AbstractC2239qS abstractC2239qS2 = lp.s;
                if (abstractC2239qS2 != null) {
                    C2041oK c2041oK2 = (C2041oK) abstractC2239qS2;
                    InterfaceC1851mK interfaceC1851mK = c2041oK2.Z;
                    c2041oK2.r1(interfaceC1851mKJ);
                    c2041oK = c2041oK2;
                    if (interfaceC1851mK != lp) {
                        InterfaceC1483iV interfaceC1483iV = c2041oK2.T;
                        c2041oK = c2041oK2;
                        if (interfaceC1483iV != null) {
                            ((C1274gE) interfaceC1483iV).invalidate();
                            c2041oK = c2041oK2;
                        }
                    }
                } else {
                    C2041oK c2041oK3 = new C2041oK(c2420sK, interfaceC1851mKJ);
                    lp.G0(c2041oK3);
                    c2041oK = c2041oK3;
                }
                abstractC2239qS.B = c2041oK;
                c2041oK.A = abstractC2239qS;
                abstractC2239qS = c2041oK;
            } else {
                lp.G0(abstractC2239qS);
            }
        }
        C2420sK c2420sKS = c2420sK.s();
        abstractC2239qS.B = c2420sKS != null ? (C2702vH) c2420sKS.N.d : null;
        this.e = abstractC2239qS;
    }

    public String toString() {
        switch (this.a) {
            case 1:
                StringBuilder sb = new StringBuilder("[");
                LP lp = (LP) this.g;
                Bc0 bc0 = (Bc0) this.f;
                if (lp == bc0) {
                    sb.append("]");
                } else {
                    while (true) {
                        if (lp != null && lp != bc0) {
                            sb.append(String.valueOf(lp));
                            if (lp.q == bc0) {
                                sb.append("]");
                            } else {
                                sb.append(",");
                                lp = lp.q;
                            }
                        }
                    }
                }
                return sb.toString();
            default:
                return super.toString();
        }
    }

    public C0312Mb(int i) {
        this.a = i;
        switch (i) {
            case 2:
                C1479iR c1479iR = new C1479iR(new R10[16]);
                this.d = c1479iR;
                int i2 = A40.a;
                this.e = new C0713aR();
                this.f = c1479iR;
                this.g = new C1479iR(new Object[16]);
                this.h = new C1479iR(new NC[16]);
                break;
        }
    }
}
