package o;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.nO, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1950nO {
    public final C2420sK a;
    public boolean c;
    public boolean d;
    public C0634Yl i;
    public final C3126zm0 b = new C3126zm0(13);
    public final Gm0 e = new Gm0(8);
    public final C1479iR f = new C1479iR(new C2420sK[16]);
    public final long g = 1;
    public final C1479iR h = new C1479iR(new C1855mO[16]);

    public C1950nO(C2420sK c2420sK) {
        this.a = c2420sK;
    }

    /* JADX WARN: Removed duplicated region for block: B:8:0x0015  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static boolean b(o.C2420sK r5, o.C0634Yl r6) {
        /*
            o.sK r0 = r5.r
            o.wK r1 = r5.O
            r2 = 0
            if (r0 != 0) goto L8
            return r2
        L8:
            if (r6 == 0) goto L17
            if (r0 == 0) goto L15
            o.eN r0 = r1.p
            long r3 = r6.a
            boolean r6 = r0.p0(r3)
            goto L29
        L15:
            r6 = r2
            goto L29
        L17:
            o.eN r6 = r1.p
            if (r6 == 0) goto L1e
            o.Yl r1 = r6.x
            goto L1f
        L1e:
            r1 = 0
        L1f:
            if (r1 == 0) goto L15
            if (r0 == 0) goto L15
            long r0 = r1.a
            boolean r6 = r6.p0(r0)
        L29:
            o.sK r0 = r5.s()
            if (r6 == 0) goto L4f
            if (r0 == 0) goto L4f
            o.sK r1 = r0.r
            r3 = 3
            if (r1 != 0) goto L3a
            o.C2420sK.Q(r0, r2, r3)
            return r6
        L3a:
            int r1 = r5.q()
            r4 = 1
            if (r1 != r4) goto L45
            o.C2420sK.O(r0, r2, r3)
            return r6
        L45:
            int r5 = r5.q()
            r1 = 2
            if (r5 != r1) goto L4f
            r0.N(r2)
        L4f:
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1950nO.b(o.sK, o.Yl):boolean");
    }

    public static boolean c(C2420sK c2420sK, C0634Yl c0634Yl) throws Throwable {
        boolean zM;
        if (c0634Yl != null) {
            if (c2420sK.Y == 3) {
                c2420sK.c();
            }
            zM = c2420sK.O.f773o.v0(c0634Yl.a);
        } else {
            zM = C2420sK.M(c2420sK);
        }
        C2420sK c2420sKS = c2420sK.s();
        if (zM && c2420sKS != null) {
            if (c2420sK.p() == 1) {
                C2420sK.Q(c2420sKS, false, 3);
                return zM;
            }
            if (c2420sK.p() == 2) {
                c2420sKS.P(false);
            }
        }
        return zM;
    }

    public static boolean f(C2420sK c2420sK) {
        C1091eN c1091eN;
        C2515tK c2515tK;
        if (c2420sK.O.d) {
            return (c2420sK.q() == 3 && ((c1091eN = c2420sK.O.p) == null || (c2515tK = c1091eN.B) == null || !c2515tK.e())) ? false : true;
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0029  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static boolean g(o.C2420sK r4) {
        /*
            boolean r0 = r4.o()
            r1 = 0
            if (r0 == 0) goto L37
        L7:
            int r0 = r4.p()
            r2 = 3
            r3 = 1
            if (r0 != r2) goto L29
            o.wK r0 = r4.O
            o.pO r0 = r0.f773o
            o.tK r0 = r0.G
            boolean r0 = r0.e()
            if (r0 != 0) goto L29
            o.sK r0 = r4.s()
            if (r0 == 0) goto L26
            o.wK r0 = r0.O
            int r0 = r0.c
            goto L27
        L26:
            r0 = r1
        L27:
            if (r0 != r3) goto L37
        L29:
            o.sK r4 = r4.s()
            if (r4 != 0) goto L30
            goto L37
        L30:
            boolean r0 = r4.H()
            if (r0 == 0) goto L7
            return r3
        L37:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1950nO.g(o.sK):boolean");
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:13:0x0032  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void a(boolean r8) {
        /*
            r7 = this;
            r0 = 1
            o.Gm0 r1 = r7.e
            if (r8 == 0) goto L17
            java.lang.Object r8 = r1.m
            o.iR r8 = (o.C1479iR) r8
            o.sK r2 = r7.a
            int r3 = r2.W
            if (r3 <= 0) goto L17
            r8.h()
            r8.b(r2)
            r2.V = r0
        L17:
            java.lang.Object r8 = r1.m
            o.iR r8 = (o.C1479iR) r8
            int r2 = r8.n
            if (r2 == 0) goto L5f
            o.lA r3 = o.C1746lA.d
            java.lang.Object[] r4 = r8.l
            r5 = 0
            java.util.Arrays.sort(r4, r5, r2, r3)
            int r2 = r8.n
            java.lang.Object r3 = r1.n
            o.sK[] r3 = (o.C2420sK[]) r3
            if (r3 == 0) goto L32
            int r4 = r3.length
            if (r4 >= r2) goto L3a
        L32:
            r3 = 16
            int r3 = java.lang.Math.max(r3, r2)
            o.sK[] r3 = new o.C2420sK[r3]
        L3a:
            r4 = 0
            r1.n = r4
        L3d:
            if (r5 >= r2) goto L48
            java.lang.Object[] r6 = r8.l
            r6 = r6[r5]
            r3[r5] = r6
            int r5 = r5 + 1
            goto L3d
        L48:
            r8.h()
            int r2 = r2 - r0
        L4c:
            r8 = -1
            if (r8 >= r2) goto L5d
            r8 = r3[r2]
            boolean r0 = r8.V
            if (r0 == 0) goto L58
            o.Gm0.b(r8)
        L58:
            r3[r2] = r4
            int r2 = r2 + (-1)
            goto L4c
        L5d:
            r1.n = r3
        L5f:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1950nO.a(boolean):void");
    }

    public final void d(C2420sK c2420sK, boolean z) {
        if (!this.c) {
            AbstractC2133pH.b("forceMeasureTheSubtree should be executed during the measureAndLayout pass");
        }
        if (z ? c2420sK.O.d : c2420sK.o()) {
            AbstractC2133pH.a("node not yet measured");
        }
        e(c2420sK, z);
    }

    /* JADX WARN: Removed duplicated region for block: B:39:0x0080  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void e(o.C2420sK r11, boolean r12) {
        /*
            r10 = this;
            o.iR r0 = r11.w()
            java.lang.Object[] r1 = r0.l
            int r0 = r0.n
            r2 = 0
            r3 = r2
        La:
            if (r3 >= r0) goto La3
            r4 = r1[r3]
            o.sK r4 = (o.C2420sK) r4
            r5 = 1
            if (r12 != 0) goto L26
            int r6 = r4.p()
            if (r6 == r5) goto L3e
            o.wK r6 = r4.O
            o.pO r6 = r6.f773o
            o.tK r6 = r6.G
            boolean r6 = r6.e()
            if (r6 == 0) goto L26
            goto L3e
        L26:
            if (r12 == 0) goto L9f
            int r6 = r4.q()
            if (r6 == r5) goto L3e
            o.wK r6 = r4.O
            o.eN r6 = r6.p
            if (r6 == 0) goto L9f
            o.tK r6 = r6.B
            if (r6 == 0) goto L9f
            boolean r6 = r6.e()
            if (r6 != r5) goto L9f
        L3e:
            boolean r6 = o.AbstractC1904ms0.q(r4)
            o.wK r7 = r4.O
            if (r6 == 0) goto L83
            if (r12 != 0) goto L83
            boolean r6 = r7.d
            if (r6 == 0) goto L80
            o.zm0 r6 = r10.b
            r6.getClass()
            o.sK r8 = r4.r
            if (r8 != 0) goto L57
            r8 = r5
            goto L58
        L57:
            r8 = r2
        L58:
            java.lang.Object r9 = r6.m
            o.Jn r9 = (o.C0247Jn) r9
            java.lang.Object r9 = r9.m
            o.S90 r9 = (o.S90) r9
            boolean r9 = r9.contains(r4)
            if (r9 != 0) goto L77
            java.lang.Object r6 = r6.n
            o.Jn r6 = (o.C0247Jn) r6
            java.lang.Object r6 = r6.m
            o.S90 r6 = (o.S90) r6
            boolean r6 = r6.contains(r4)
            if (r6 == 0) goto L75
            goto L77
        L75:
            r6 = r2
            goto L78
        L77:
            r6 = r5
        L78:
            if (r8 != 0) goto L80
            if (r6 == 0) goto L80
            r10.j(r4, r5, r2)
            goto L83
        L80:
            r10.d(r4, r5)
        L83:
            if (r12 == 0) goto L88
            boolean r5 = r7.d
            goto L8c
        L88:
            boolean r5 = r4.o()
        L8c:
            if (r5 == 0) goto L91
            r10.j(r4, r12, r2)
        L91:
            if (r12 == 0) goto L96
            boolean r5 = r7.d
            goto L9a
        L96:
            boolean r5 = r4.o()
        L9a:
            if (r5 != 0) goto L9f
            r10.e(r4, r12)
        L9f:
            int r3 = r3 + 1
            goto La
        La3:
            if (r12 == 0) goto Laa
            o.wK r0 = r11.O
            boolean r0 = r0.d
            goto Lae
        Laa:
            boolean r0 = r11.o()
        Lae:
            if (r0 == 0) goto Lb3
            r10.j(r11, r12, r2)
        Lb3:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1950nO.e(o.sK, boolean):void");
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r13v1 */
    /* JADX WARN: Type inference failed for: r13v11 */
    /* JADX WARN: Type inference failed for: r13v2, types: [o.LP] */
    public final boolean h(C1922n3 c1922n3) {
        boolean z;
        LP lp;
        LP lpI;
        boolean z2;
        C2420sK c2420sK;
        boolean z3;
        C3126zm0 c3126zm0 = this.b;
        C2420sK c2420sK2 = this.a;
        if (!c2420sK2.G()) {
            AbstractC2133pH.a("performMeasureAndLayout called with unattached root");
        }
        if (!c2420sK2.H()) {
            AbstractC2133pH.a("performMeasureAndLayout called with unplaced root");
        }
        if (this.c) {
            AbstractC2133pH.a("performMeasureAndLayout called during measure layout");
        }
        int i = 0;
        boolean z4 = false;
        boolean z5 = false;
        boolean z6 = false;
        boolean z7 = false;
        if (this.i != null) {
            this.c = true;
            this.d = true;
            try {
                boolean zK = c3126zm0.K();
                C0247Jn c0247Jn = (C0247Jn) c3126zm0.m;
                if (zK) {
                    z = false;
                    while (true) {
                        C0247Jn c0247Jn2 = (C0247Jn) c3126zm0.f831o;
                        C0247Jn c0247Jn3 = (C0247Jn) c3126zm0.n;
                        if (!((S90) c0247Jn.m).isEmpty()) {
                            c2420sK = (C2420sK) ((S90) c0247Jn.m).first();
                            c0247Jn.w(c2420sK);
                            z3 = c2420sK.r != null;
                            z2 = false;
                        } else if (!((S90) c0247Jn3.m).isEmpty()) {
                            c2420sK = (C2420sK) ((S90) c0247Jn3.m).first();
                            c0247Jn3.w(c2420sK);
                            z3 = c2420sK.r != null;
                            z2 = true;
                        } else {
                            if (((S90) c0247Jn2.m).isEmpty()) {
                                break;
                            }
                            C2420sK c2420sK3 = (C2420sK) ((S90) c0247Jn2.m).first();
                            c0247Jn2.w(c2420sK3);
                            z2 = true;
                            c2420sK = c2420sK3;
                            z3 = false;
                        }
                        boolean zJ = j(c2420sK, z3, z2);
                        if (!z2) {
                            if (c2420sK.O.e) {
                                c3126zm0.i(2, c2420sK);
                            }
                            if (c2420sK.n()) {
                                c3126zm0.i(4, c2420sK);
                            }
                        }
                        if (c2420sK == c2420sK2 && zJ) {
                            z = true;
                        }
                    }
                    if (c1922n3 != null) {
                        c1922n3.a();
                    }
                } else {
                    z = false;
                }
            } finally {
            }
        } else {
            z = false;
        }
        C1479iR c1479iR = this.f;
        Object[] objArr = c1479iR.l;
        int i2 = c1479iR.n;
        int i3 = 0;
        while (i3 < i2) {
            C0312Mb c0312Mb = ((C2420sK) objArr[i3]).N;
            C2702vH c2702vH = (C2702vH) c0312Mb.d;
            boolean zG = AbstractC2333rS.g(128);
            if (zG) {
                lp = c2702vH.Z;
            } else {
                lp = c2702vH.Z.p;
                if (lp == null) {
                }
                i3++;
                i = 0;
            }
            L20 l20 = AbstractC2239qS.U;
            LP lpR0 = c2702vH.R0(zG);
            while (lpR0 != null && (lpR0.f209o & 128) != 0) {
                if ((lpR0.n & 128) != 0) {
                    AbstractC0561Vq abstractC0561Vq = lpR0;
                    C1479iR c1479iR2 = null;
                    while (abstractC0561Vq != 0) {
                        if (abstractC0561Vq instanceof InterfaceC0993dK) {
                            ((InterfaceC0993dK) abstractC0561Vq).p((C2702vH) c0312Mb.d);
                        } else {
                            if ((abstractC0561Vq.n & 128) != 0 && (abstractC0561Vq instanceof AbstractC0561Vq)) {
                                LP lp2 = abstractC0561Vq.A;
                                lpI = abstractC0561Vq;
                                c1479iR2 = c1479iR2;
                                while (lp2 != null) {
                                    if ((lp2.n & 128) != 0) {
                                        i++;
                                        c1479iR2 = c1479iR2;
                                        if (i == 1) {
                                            lpI = lp2;
                                        } else {
                                            if (c1479iR2 == null) {
                                                c1479iR2 = new C1479iR(new LP[16]);
                                            }
                                            if (lpI != null) {
                                                c1479iR2.b(lpI);
                                                lpI = null;
                                            }
                                            c1479iR2.b(lp2);
                                        }
                                    }
                                    lp2 = lp2.q;
                                    lpI = lpI;
                                    c1479iR2 = c1479iR2;
                                }
                                if (i == 1) {
                                }
                            }
                            i = 0;
                            abstractC0561Vq = lpI;
                            c1479iR2 = c1479iR2;
                        }
                        lpI = AbstractC2539te.i(c1479iR2);
                        i = 0;
                        abstractC0561Vq = lpI;
                        c1479iR2 = c1479iR2;
                    }
                }
                if (lpR0 != lp) {
                    lpR0 = lpR0.q;
                    i = 0;
                }
            }
            i3++;
            i = 0;
        }
        c1479iR.h();
        return z;
    }

    public final void i() {
        C3126zm0 c3126zm0 = this.b;
        if (c3126zm0.K()) {
            C2420sK c2420sK = this.a;
            if (!c2420sK.G()) {
                AbstractC2133pH.a("performMeasureAndLayout called with unattached root");
            }
            if (!c2420sK.H()) {
                AbstractC2133pH.a("performMeasureAndLayout called with unplaced root");
            }
            if (this.c) {
                AbstractC2133pH.a("performMeasureAndLayout called during measure layout");
            }
            if (this.i != null) {
                this.c = true;
                this.d = false;
                try {
                    if (!((S90) ((C0247Jn) c3126zm0.f831o).m).isEmpty() && !((S90) ((C0247Jn) c3126zm0.m).m).isEmpty()) {
                        if (c2420sK.r != null) {
                            l(c2420sK, true);
                        } else {
                            k(c2420sK);
                        }
                    }
                    l(c2420sK, false);
                } catch (Throwable th) {
                    try {
                        throw th;
                    } finally {
                        this.c = false;
                        this.d = false;
                    }
                }
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final boolean j(C2420sK c2420sK, boolean z, boolean z2) {
        boolean zC;
        C2420sK c2420sKS;
        UW placementScope;
        C2702vH c2702vH;
        C2420sK c2420sKS2;
        C2420sK c2420sKS3;
        C1091eN c1091eN;
        C2515tK c2515tK;
        boolean z3 = c2420sK.X;
        C2800wK c2800wK = c2420sK.O;
        boolean z4 = false;
        Object[] objArr = 0;
        if (z3 || (!c2420sK.H() && !c2800wK.f773o.C && !g(c2420sK) && !F3.c(c2420sK.I(), Boolean.TRUE) && !f(c2420sK) && !c2800wK.f773o.G.e() && ((c1091eN = c2800wK.p) == null || (c2515tK = c1091eN.B) == null || !c2515tK.e()))) {
            return false;
        }
        C2420sK c2420sK2 = this.a;
        C0634Yl c0634Yl = c2420sK == c2420sK2 ? this.i : null;
        if (z) {
            zC = c2800wK.d ? b(c2420sK, c0634Yl) : false;
            if (z2 && ((zC || c2800wK.e) && F3.c(c2420sK.I(), Boolean.TRUE))) {
                if (c2420sK.Y == 3) {
                    c2420sK.f();
                }
                C1091eN c1091eN2 = c2800wK.p;
                c1091eN2.getClass();
                try {
                    c1091eN2.r = true;
                    if (!c1091eN2.v) {
                        AbstractC2133pH.b("replace() called on item that was not placed");
                    }
                    c1091eN2.H = false;
                    boolean zU = c1091eN2.u();
                    c1091eN2.o0(c1091eN2.y, c1091eN2.z);
                    if (zU && !c1091eN2.H && (c2420sKS3 = c1091eN2.q.a.s()) != null) {
                        c2420sKS3.N(false);
                    }
                    c1091eN2.r = false;
                } catch (Throwable th) {
                    c1091eN2.r = false;
                    throw th;
                }
            }
        } else {
            zC = c2420sK.o() ? c(c2420sK, c0634Yl) : false;
            if (z2 && c2420sK.n() && (c2420sK == c2420sK2 || ((c2420sKS2 = c2420sK.s()) != null && c2420sKS2.H() && c2800wK.f773o.C))) {
                if (c2420sK == c2420sK2) {
                    if (c2420sK.Y == 3) {
                        c2420sK.f();
                    }
                    C2420sK c2420sKS4 = c2420sK.s();
                    if (c2420sKS4 == null || (c2702vH = (C2702vH) c2420sKS4.N.d) == null || (placementScope = c2702vH.w) == null) {
                        placementScope = ((C2207q3) AbstractC2705vK.a(c2420sK)).getPlacementScope();
                    }
                    UW.i(placementScope, c2800wK.f773o, 0, 0);
                } else {
                    if (c2420sK.Y == 3) {
                        c2420sK.f();
                    }
                    C2140pO c2140pO = c2800wK.f773o;
                    C2800wK c2800wK2 = c2140pO.q;
                    try {
                        c2140pO.r = true;
                        if (!c2140pO.v) {
                            AbstractC2133pH.b("replace called on unplaced item");
                        }
                        boolean z5 = c2140pO.B;
                        c2140pO.p0(c2140pO.w, c2140pO.y, c2140pO.x);
                        if (z5 && !c2140pO.O && (c2420sKS = c2800wK2.a.s()) != null) {
                            c2420sKS.P(false);
                        }
                    } finally {
                    }
                }
                Gm0 gm0 = this.e;
                gm0.getClass();
                if (c2420sK.W > 0) {
                    ((C1479iR) gm0.m).b(c2420sK);
                    c2420sK.V = true;
                }
                ((C2207q3) AbstractC2705vK.a(c2420sK)).getRectManager().e(c2420sK);
            }
        }
        C1479iR c1479iR = this.h;
        int i = c1479iR.n;
        if (i != 0) {
            Object[] objArr2 = c1479iR.l;
            for (int i2 = 0; i2 < i; i2++) {
                C1855mO c1855mO = (C1855mO) objArr2[i2];
                C2420sK c2420sK3 = c1855mO.a;
                boolean z6 = c1855mO.c;
                C2420sK c2420sK4 = c1855mO.a;
                if (c2420sK3.G()) {
                    if (c1855mO.b) {
                        C2420sK.O(c2420sK4, z6, 2);
                    } else {
                        C2420sK.Q(c2420sK4, z6, 2);
                    }
                }
            }
            c1479iR.h();
        }
        return zC;
    }

    public final void k(C2420sK c2420sK) throws Throwable {
        C1479iR c1479iRW = c2420sK.w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            C2420sK c2420sK2 = (C2420sK) objArr[i2];
            if (c2420sK2.p() == 1 || c2420sK2.O.f773o.G.e()) {
                if (AbstractC1904ms0.q(c2420sK2)) {
                    l(c2420sK2, true);
                } else {
                    k(c2420sK2);
                }
            }
        }
    }

    public final void l(C2420sK c2420sK, boolean z) throws Throwable {
        if (c2420sK.X) {
            return;
        }
        C0634Yl c0634Yl = c2420sK == this.a ? this.i : null;
        if (z) {
            b(c2420sK, c0634Yl);
        } else {
            c(c2420sK, c0634Yl);
        }
    }

    public final boolean m(C2420sK c2420sK, boolean z) {
        int iW = AbstractC2462sn.w(c2420sK.O.c);
        if (iW != 0 && iW != 1) {
            if (iW == 2 || iW == 3) {
                this.h.b(new C1855mO(c2420sK, false, z));
            } else {
                if (iW != 4) {
                    throw new C2170pj();
                }
                if (!c2420sK.o() || z) {
                    c2420sK.O.f773o.D = true;
                    if (!c2420sK.X && (c2420sK.H() || g(c2420sK))) {
                        C2420sK c2420sKS = c2420sK.s();
                        if (c2420sKS == null || !c2420sKS.o()) {
                            this.b.i(3, c2420sK);
                        }
                        if (!this.d) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    public final void n(long j) {
        C0634Yl c0634Yl = this.i;
        if (c0634Yl == null ? false : C0634Yl.b(c0634Yl.a, j)) {
            return;
        }
        if (this.c) {
            AbstractC2133pH.a("updateRootConstraints called while measuring");
        }
        this.i = new C0634Yl(j);
        C2420sK c2420sK = this.a;
        C2420sK c2420sK2 = c2420sK.r;
        C2800wK c2800wK = c2420sK.O;
        if (c2420sK2 != null) {
            c2800wK.d = true;
        }
        c2800wK.f773o.D = true;
        this.b.i(c2420sK2 == null ? 3 : 1, c2420sK);
    }
}
