package o;

import com.google.android.gms.common.api.Api;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.pO, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2140pO extends VW implements InterfaceC1760lO, InterfaceC3059z2, InterfaceC0712aQ {
    public Object A;
    public boolean B;
    public boolean C;
    public boolean D;
    public boolean E;
    public boolean F;
    public boolean J;
    public float N;
    public boolean O;
    public OC P;
    public float R;
    public boolean T;
    public final C2800wK q;
    public boolean r;
    public boolean u;
    public boolean v;
    public OC x;
    public float y;
    public int s = Api.BaseClientBuilder.API_PRIORITY_OTHER;
    public int t = Api.BaseClientBuilder.API_PRIORITY_OTHER;
    public int U = 3;
    public long w = 0;
    public boolean z = true;
    public final C2515tK G = new C2515tK(this, 0);
    public final C1479iR H = new C1479iR(new C2140pO[16]);
    public boolean I = true;
    public long K = AbstractC0842bm.b(0, 0, 15);
    public final C2045oO L = new C2045oO(this, 1);
    public final C2045oO M = new C2045oO(this, 0);
    public long Q = 0;
    public final C2045oO S = new C2045oO(this, 2);

    public C2140pO(C2800wK c2800wK) {
        this.q = c2800wK;
    }

    @Override // o.InterfaceC1760lO
    public final int O(int i) {
        C2800wK c2800wK = this.q;
        if (AbstractC1904ms0.q(c2800wK.a)) {
            return c2800wK.p.O(i);
        }
        h0();
        return c2800wK.a().O(i);
    }

    @Override // o.InterfaceC3059z2
    public final void R() {
        C2420sK.Q(this.q.a, false, 7);
    }

    @Override // o.InterfaceC1760lO
    public final int U(int i) {
        C2800wK c2800wK = this.q;
        if (AbstractC1904ms0.q(c2800wK.a)) {
            return c2800wK.p.U(i);
        }
        h0();
        return c2800wK.a().U(i);
    }

    @Override // o.InterfaceC1760lO
    public final int V(int i) {
        C2800wK c2800wK = this.q;
        if (AbstractC1904ms0.q(c2800wK.a)) {
            return c2800wK.p.V(i);
        }
        h0();
        return c2800wK.a().V(i);
    }

    @Override // o.VW
    public final int W() {
        return this.q.a().W();
    }

    @Override // o.VW
    public final int Y() {
        return this.q.a().Y();
    }

    @Override // o.InterfaceC3059z2
    public final C2515tK a() {
        return this.G;
    }

    @Override // o.VW
    public final void a0(long j, float f, OC oc) throws Throwable {
        boolean z;
        UW placementScope;
        C2800wK c2800wK = this.q;
        C2420sK c2420sK = c2800wK.a;
        boolean z2 = true;
        try {
            this.C = true;
            if (!C0704aI.a(j, this.w) || this.T) {
                if (c2800wK.j || c2800wK.i || this.T) {
                    this.E = true;
                    this.T = false;
                }
                g0();
            }
            C1091eN c1091eN = c2800wK.p;
            if (c1091eN != null) {
                C2800wK c2800wK2 = c1091eN.q;
                if (AbstractC1904ms0.q(c2800wK2.a)) {
                    z = true;
                } else {
                    if (c1091eN.A == 3) {
                        c2800wK2.b = true;
                    }
                    z = c2800wK2.b;
                }
                if (z) {
                    AbstractC2239qS abstractC2239qS = c2800wK.a().B;
                    if (abstractC2239qS == null || (placementScope = abstractC2239qS.w) == null) {
                        placementScope = ((C2207q3) AbstractC2705vK.a(c2420sK)).getPlacementScope();
                    }
                    C1091eN c1091eN2 = c2800wK.p;
                    C2420sK c2420sKS = c2420sK.s();
                    if (c2420sKS != null) {
                        c2420sKS.O.g = 0;
                    }
                    c1091eN2.t = Api.BaseClientBuilder.API_PRIORITY_OTHER;
                    UW.g(placementScope, c1091eN2, (int) (j >> 32), (int) (4294967295L & j));
                }
            }
            C1091eN c1091eN3 = c2800wK.p;
            if (c1091eN3 == null || c1091eN3.v) {
                z2 = false;
            }
            if (z2) {
                AbstractC2133pH.b("Error: Placement happened before lookahead.");
            }
            p0(j, f, oc);
        } catch (Throwable th) {
            c2420sK.T(th);
            throw null;
        }
    }

    @Override // o.InterfaceC1760lO
    public final VW c(long j) throws Throwable {
        int i;
        C2800wK c2800wK = this.q;
        C2420sK c2420sK = c2800wK.a;
        C2420sK c2420sK2 = c2800wK.a;
        if (c2420sK.Y == 3) {
            c2420sK.c();
        }
        if (AbstractC1904ms0.q(c2420sK2)) {
            C1091eN c1091eN = c2800wK.p;
            c1091eN.u = 3;
            c1091eN.c(j);
        }
        C2420sK c2420sKS = c2420sK2.s();
        if (c2420sKS != null) {
            C2800wK c2800wK2 = c2420sKS.O;
            if (this.U != 3 && !c2420sK2.M) {
                AbstractC2133pH.b("measure() may not be called multiple times on the same Measurable. If you want to get the content size of the Measurable before calculating the final constraints, please use methods like minIntrinsicWidth()/maxIntrinsicWidth() and minIntrinsicHeight()/maxIntrinsicHeight()");
            }
            int iW = AbstractC2462sn.w(c2800wK2.c);
            if (iW != 0) {
                i = 2;
                if (iW != 2) {
                    throw new IllegalStateException("Measurable could be only measured from the parent's measure or layout block. Parents state is ".concat(AbstractC0126Ew.r(c2800wK2.c)));
                }
            } else {
                i = 1;
            }
            this.U = i;
        } else {
            this.U = 3;
        }
        v0(j);
        return this;
    }

    @Override // o.InterfaceC1760lO
    public final int d(int i) {
        C2800wK c2800wK = this.q;
        if (AbstractC1904ms0.q(c2800wK.a)) {
            return c2800wK.p.d(i);
        }
        h0();
        return c2800wK.a().d(i);
    }

    public final void d0() {
        boolean z = this.B;
        this.B = true;
        C2420sK c2420sK = this.q.a;
        C0312Mb c0312Mb = c2420sK.N;
        if (!z) {
            ((C2702vH) c0312Mb.d).b1();
            if (c2420sK.o()) {
                C2420sK.Q(c2420sK, true, 6);
            } else if (c2420sK.O.d) {
                C2420sK.O(c2420sK, true, 6);
            }
        }
        AbstractC2239qS abstractC2239qS = ((C2702vH) c0312Mb.d).A;
        for (AbstractC2239qS abstractC2239qS2 = (AbstractC2239qS) c0312Mb.e; !F3.c(abstractC2239qS2, abstractC2239qS) && abstractC2239qS2 != null; abstractC2239qS2 = abstractC2239qS2.A) {
            if (abstractC2239qS2.S) {
                abstractC2239qS2.W0();
            }
        }
        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.t() != Integer.MAX_VALUE) {
                c2420sK2.O.f773o.d0();
                C2420sK.R(c2420sK2);
            }
        }
    }

    public final void f0() {
        if (this.B) {
            this.B = false;
            C2800wK c2800wK = this.q;
            C0312Mb c0312Mb = c2800wK.a.N;
            AbstractC2239qS abstractC2239qS = ((C2702vH) c0312Mb.d).A;
            for (AbstractC2239qS abstractC2239qS2 = (AbstractC2239qS) c0312Mb.e; !F3.c(abstractC2239qS2, abstractC2239qS) && abstractC2239qS2 != null; abstractC2239qS2 = abstractC2239qS2.A) {
                LP lpR0 = abstractC2239qS2.R0(AbstractC2333rS.g(1048576));
                if (lpR0 != null && (lpR0.l.f209o & 1048576) != 0) {
                    boolean zG = AbstractC2333rS.g(1048576);
                    LP lpP0 = abstractC2239qS2.P0();
                    if (zG || (lpP0 = lpP0.p) != null) {
                        for (LP lpR02 = abstractC2239qS2.R0(zG); lpR02 != null && (lpR02.f209o & 1048576) != 0; lpR02 = lpR02.q) {
                            if ((lpR02.n & 1048576) != 0) {
                                LP lpI = lpR02;
                                C1479iR c1479iR = null;
                                while (lpI != null) {
                                    if ((lpI.n & 1048576) != 0 && (lpI instanceof AbstractC0561Vq)) {
                                        int i = 0;
                                        for (LP lp = ((AbstractC0561Vq) lpI).A; lp != null; lp = lp.q) {
                                            if ((lp.n & 1048576) != 0) {
                                                i++;
                                                if (i == 1) {
                                                    lpI = lp;
                                                } else {
                                                    if (c1479iR == null) {
                                                        c1479iR = new C1479iR(new LP[16]);
                                                    }
                                                    if (lpI != null) {
                                                        c1479iR.b(lpI);
                                                        lpI = null;
                                                    }
                                                    c1479iR.b(lp);
                                                }
                                            }
                                        }
                                        if (i == 1) {
                                        }
                                    }
                                    lpI = AbstractC2539te.i(c1479iR);
                                }
                            }
                            if (lpR02 != lpP0) {
                            }
                        }
                    }
                }
                abstractC2239qS2.h1();
            }
            C1479iR c1479iRW = c2800wK.a.w();
            Object[] objArr = c1479iRW.l;
            int i2 = c1479iRW.n;
            for (int i3 = 0; i3 < i2; i3++) {
                ((C2420sK) objArr[i3]).O.f773o.f0();
            }
        }
    }

    public final void g0() {
        C2800wK c2800wK = this.q;
        if (c2800wK.k > 0) {
            C1479iR c1479iRW = c2800wK.a.w();
            Object[] objArr = c1479iRW.l;
            int i = c1479iRW.n;
            for (int i2 = 0; i2 < i; i2++) {
                C2420sK c2420sK = (C2420sK) objArr[i2];
                C2800wK c2800wK2 = c2420sK.O;
                boolean z = c2800wK2.i;
                C2140pO c2140pO = c2800wK2.f773o;
                if ((z || c2800wK2.j) && !c2140pO.E) {
                    c2420sK.P(false);
                }
                c2140pO.g0();
            }
        }
    }

    public final void h0() {
        int i;
        C2800wK c2800wK = this.q;
        C2420sK.Q(c2800wK.a, false, 7);
        C2420sK c2420sK = c2800wK.a;
        C2420sK c2420sKS = c2420sK.s();
        if (c2420sKS == null || c2420sK.Y != 3) {
            return;
        }
        int iW = AbstractC2462sn.w(c2420sKS.O.c);
        if (iW != 0) {
            i = 2;
            if (iW != 2) {
                i = c2420sKS.Y;
            }
        } else {
            i = 1;
        }
        c2420sK.Y = i;
    }

    @Override // o.InterfaceC3059z2
    public final void j(C2769w c2769w) {
        C1479iR c1479iRW = this.q.a.w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            c2769w.g(((C2420sK) objArr[i2]).O.f773o);
        }
    }

    @Override // o.VW, o.InterfaceC1760lO
    public final Object k() {
        return this.A;
    }

    public final void l0() {
        this.O = true;
        C2800wK c2800wK = this.q;
        C2420sK c2420sKS = c2800wK.a.s();
        float f = n().L;
        C2420sK c2420sK = c2800wK.a;
        C0312Mb c0312Mb = c2420sK.N;
        AbstractC2239qS abstractC2239qS = (AbstractC2239qS) c0312Mb.e;
        C2702vH c2702vH = (C2702vH) c0312Mb.d;
        while (abstractC2239qS != c2702vH) {
            C2041oK c2041oK = (C2041oK) abstractC2239qS;
            f += c2041oK.L;
            abstractC2239qS = c2041oK.A;
        }
        if (f != this.N) {
            this.N = f;
            if (c2420sKS != null) {
                c2420sKS.L();
            }
            if (c2420sKS != null) {
                c2420sKS.z();
            }
        }
        if (this.B) {
            ((C2702vH) c2420sK.N.d).b1();
        } else {
            if (c2420sKS != null) {
                c2420sKS.z();
            }
            d0();
            if (this.r && c2420sKS != null) {
                c2420sKS.P(false);
            }
        }
        if (c2420sKS != null) {
            C2800wK c2800wK2 = c2420sKS.O;
            if (!this.r && c2800wK2.c == 3) {
                if (this.t != Integer.MAX_VALUE) {
                    AbstractC2133pH.b("Place was called on a node which was placed already");
                }
                int i = c2800wK2.h;
                this.t = i;
                c2800wK2.h = i + 1;
            }
        } else {
            this.t = 0;
        }
        s();
    }

    @Override // o.InterfaceC0712aQ
    public final void m(boolean z) {
        C2800wK c2800wK = this.q;
        if (z != c2800wK.a().t) {
            c2800wK.a().t = z;
            this.T = true;
        }
    }

    @Override // o.InterfaceC3059z2
    public final C2702vH n() {
        return (C2702vH) this.q.a.N.d;
    }

    public final void o0(long j) {
        C2800wK c2800wK = this.q;
        int i = c2800wK.c;
        C2420sK c2420sK = c2800wK.a;
        if (i != 5) {
            AbstractC2133pH.b("layout state is not idle before measure starts");
        }
        this.K = j;
        c2800wK.c = 1;
        this.D = false;
        C1767lV snapshotObserver = ((C2207q3) AbstractC2705vK.a(c2420sK)).getSnapshotObserver();
        snapshotObserver.a(c2420sK, snapshotObserver.c, this.L);
        if (c2800wK.c == 1) {
            this.E = true;
            this.F = true;
            c2800wK.c = 5;
        }
    }

    public final void p0(long j, float f, OC oc) {
        C2800wK c2800wK = this.q;
        C2420sK c2420sK = c2800wK.a;
        C2420sK c2420sK2 = c2800wK.a;
        if (c2420sK.X) {
            AbstractC2133pH.a("place is called on a deactivated node");
        }
        c2800wK.c = 3;
        this.w = j;
        this.y = f;
        this.x = oc;
        this.O = false;
        InterfaceC1577jV interfaceC1577jVA = AbstractC2705vK.a(c2420sK2);
        if (this.E || !this.B) {
            this.G.e = false;
            c2800wK.f(false);
            this.P = oc;
            this.Q = j;
            this.R = f;
            C1767lV snapshotObserver = ((C2207q3) interfaceC1577jVA).getSnapshotObserver();
            snapshotObserver.a(c2420sK2, snapshotObserver.f, this.S);
        } else {
            AbstractC2239qS abstractC2239qSA = c2800wK.a();
            abstractC2239qSA.f1(C0704aI.c(j, abstractC2239qSA.p), f, oc);
            l0();
        }
        c2800wK.c = 5;
        this.v = true;
    }

    @Override // o.InterfaceC3059z2
    public final InterfaceC3059z2 r() {
        C2800wK c2800wK;
        C2420sK c2420sKS = this.q.a.s();
        if (c2420sKS == null || (c2800wK = c2420sKS.O) == null) {
            return null;
        }
        return c2800wK.f773o;
    }

    @Override // o.InterfaceC3059z2
    public final void requestLayout() {
        this.q.a.P(false);
    }

    @Override // o.InterfaceC3059z2
    public final void s() {
        this.J = true;
        C2515tK c2515tK = this.G;
        c2515tK.h();
        boolean z = this.E;
        C2800wK c2800wK = this.q;
        if (z) {
            C1479iR c1479iRW = c2800wK.a.w();
            Object[] objArr = c1479iRW.l;
            int i = c1479iRW.n;
            for (int i2 = 0; i2 < i; i2++) {
                C2420sK c2420sK = (C2420sK) objArr[i2];
                if (c2420sK.o() && c2420sK.p() == 1 && C2420sK.M(c2420sK)) {
                    C2420sK.Q(c2800wK.a, false, 7);
                }
            }
        }
        if (this.F || (!n().v && this.E)) {
            this.E = false;
            int i3 = c2800wK.c;
            c2800wK.c = 3;
            c2800wK.g(false);
            C2420sK c2420sK2 = c2800wK.a;
            C1767lV snapshotObserver = ((C2207q3) AbstractC2705vK.a(c2420sK2)).getSnapshotObserver();
            snapshotObserver.a(c2420sK2, snapshotObserver.e, this.M);
            c2800wK.c = i3;
            if (n().v && c2800wK.i) {
                requestLayout();
            }
            this.F = false;
        }
        if (c2515tK.b && c2515tK.e()) {
            c2515tK.g();
        }
        this.J = false;
    }

    @Override // o.InterfaceC3059z2
    public final boolean u() {
        return this.B;
    }

    public final boolean v0(long j) throws Throwable {
        C2800wK c2800wK = this.q;
        C2420sK c2420sK = c2800wK.a;
        C2420sK c2420sK2 = c2800wK.a;
        try {
            if (c2420sK.X) {
                AbstractC2133pH.a("measure is called on a deactivated node");
            }
            InterfaceC1577jV interfaceC1577jVA = AbstractC2705vK.a(c2420sK2);
            C2420sK c2420sKS = c2420sK2.s();
            boolean z = true;
            c2420sK2.M = c2420sK2.M || (c2420sKS != null && c2420sKS.M);
            if (!c2420sK2.o() && C0634Yl.b(this.f376o, j)) {
                ((C2207q3) interfaceC1577jVA).m(c2420sK2, false);
                c2420sK2.S();
                return false;
            }
            this.G.d = false;
            C1479iR c1479iRW = c2420sK2.w();
            Object[] objArr = c1479iRW.l;
            int i = c1479iRW.n;
            for (int i2 = 0; i2 < i; i2++) {
                ((C2420sK) objArr[i2]).O.f773o.G.getClass();
            }
            this.u = true;
            long j2 = c2800wK.a().n;
            c0(j);
            o0(j);
            if (C1470iI.a(c2800wK.a().n, j2) && c2800wK.a().l == this.l && c2800wK.a().m == this.m) {
                z = false;
            }
            b0((c2800wK.a().m & 4294967295L) | (c2800wK.a().l << 32));
            return z;
        } catch (Throwable th) {
            c2420sK.T(th);
            throw null;
        }
    }
}
