package o;

import com.google.android.gms.common.api.Api;
import java.util.Arrays;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.sK, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2420sK implements InterfaceC2646uk, InterfaceC1672kV, InterfaceC0062Ck {
    public static final C1733l30 a0 = new C1733l30(1);
    public static final C2231qK b0 = new C2231qK();
    public static final C0347Nk c0 = new C0347Nk(8);
    public boolean A;
    public boolean B;
    public N50 C;
    public boolean D;
    public final C1479iR E;
    public boolean F;
    public InterfaceC2235qO G;
    public C3040yr H;
    public InterfaceC2281qr I;
    public EnumC1280gK J;
    public Qj0 K;
    public InterfaceC0633Yk L;
    public boolean M;
    public final C0312Mb N;
    public final C2800wK O;
    public AbstractC2239qS P;
    public boolean Q;
    public MP R;
    public MP S;
    public S5 T;
    public T5 U;
    public boolean V;
    public int W;
    public boolean X;
    public int Y;
    public int Z;
    public final boolean l;
    public int m;
    public long n;

    /* renamed from: o, reason: collision with root package name */
    public long f713o;
    public long p;
    public boolean q;
    public C2420sK r;
    public int s;
    public final DH t;
    public C1479iR u;
    public boolean v;
    public C2420sK w;
    public InterfaceC1577jV x;
    public Tj0 y;
    public int z;

    public C2420sK(int i) {
        this((i & 1) == 0, O50.a.addAndGet(1));
    }

    public static boolean M(C2420sK c2420sK) {
        C2140pO c2140pO = c2420sK.O.f773o;
        C0634Yl c0634Yl = c2140pO.u ? new C0634Yl(c2140pO.f376o) : null;
        if (c0634Yl == null) {
            c2420sK.getClass();
            return false;
        }
        if (c2420sK.Y == 3) {
            c2420sK.c();
        }
        return c2420sK.O.f773o.v0(c0634Yl.a);
    }

    public static void O(C2420sK c2420sK, boolean z, int i) {
        C2420sK c2420sKS;
        if ((i & 1) != 0) {
            z = false;
        }
        boolean z2 = (i & 4) != 0;
        if (c2420sK.r == null) {
            AbstractC2133pH.b("Lookahead measure cannot be requested on a node that is not a part of the LookaheadScope");
        }
        InterfaceC1577jV interfaceC1577jV = c2420sK.x;
        if (interfaceC1577jV == null || c2420sK.A || c2420sK.l) {
            return;
        }
        ((C2207q3) interfaceC1577jV).z(c2420sK, true, z);
        if (z2) {
            C2800wK c2800wK = c2420sK.O.p.q;
            C2420sK c2420sKS2 = c2800wK.a.s();
            int i2 = c2800wK.a.Y;
            if (c2420sKS2 == null || i2 == 3) {
                return;
            }
            while (c2420sKS2.Y == i2 && (c2420sKS = c2420sKS2.s()) != null) {
                c2420sKS2 = c2420sKS;
            }
            int iW = AbstractC2462sn.w(i2);
            if (iW == 0) {
                if (c2420sKS2.r != null) {
                    O(c2420sKS2, z, 6);
                    return;
                } else {
                    Q(c2420sKS2, z, 6);
                    return;
                }
            }
            if (iW != 1) {
                throw new IllegalStateException("Intrinsics isn't used by the parent");
            }
            if (c2420sKS2.r != null) {
                c2420sKS2.N(z);
            } else {
                c2420sKS2.P(z);
            }
        }
    }

    public static void Q(C2420sK c2420sK, boolean z, int i) {
        InterfaceC1577jV interfaceC1577jV;
        C2420sK c2420sKS;
        if ((i & 1) != 0) {
            z = false;
        }
        boolean z2 = (i & 4) != 0;
        if (c2420sK.A || c2420sK.l || (interfaceC1577jV = c2420sK.x) == null) {
            return;
        }
        ((C2207q3) interfaceC1577jV).z(c2420sK, false, z);
        if (z2) {
            C2800wK c2800wK = c2420sK.O.f773o.q;
            C2420sK c2420sKS2 = c2800wK.a.s();
            int i2 = c2800wK.a.Y;
            if (c2420sKS2 == null || i2 == 3) {
                return;
            }
            while (c2420sKS2.Y == i2 && (c2420sKS = c2420sKS2.s()) != null) {
                c2420sKS2 = c2420sKS;
            }
            int iW = AbstractC2462sn.w(i2);
            if (iW == 0) {
                Q(c2420sKS2, z, 6);
            } else {
                if (iW != 1) {
                    throw new IllegalStateException("Intrinsics isn't used by the parent");
                }
                c2420sKS2.P(z);
            }
        }
    }

    public static void R(C2420sK c2420sK) {
        C2800wK c2800wK = c2420sK.O;
        if (AbstractC2325rK.a[AbstractC2462sn.w(c2800wK.c)] != 1) {
            throw new IllegalStateException("Unexpected state ".concat(AbstractC0126Ew.r(c2800wK.c)));
        }
        if (c2800wK.d) {
            O(c2420sK, true, 6);
            return;
        }
        if (c2800wK.e) {
            c2420sK.N(true);
        }
        if (c2420sK.o()) {
            Q(c2420sK, true, 6);
        } else if (c2420sK.n()) {
            c2420sK.P(true);
        }
    }

    private final String j(C2420sK c2420sK) {
        StringBuilder sb = new StringBuilder("Cannot insert ");
        sb.append(c2420sK);
        sb.append(" because it already has a parent or an owner. This tree: ");
        sb.append(g(0));
        sb.append(" Other tree: ");
        C2420sK c2420sK2 = c2420sK.w;
        sb.append(c2420sK2 != null ? c2420sK2.g(0) : null);
        return sb.toString();
    }

    public final void A() {
        C0312Mb c0312Mb = this.N;
        AbstractC2239qS abstractC2239qS = (AbstractC2239qS) c0312Mb.e;
        C2702vH c2702vH = (C2702vH) c0312Mb.d;
        while (abstractC2239qS != c2702vH) {
            C2041oK c2041oK = (C2041oK) abstractC2239qS;
            InterfaceC1483iV interfaceC1483iV = c2041oK.T;
            if (interfaceC1483iV != null) {
                interfaceC1483iV.invalidate();
            }
            abstractC2239qS = c2041oK.A;
        }
        InterfaceC1483iV interfaceC1483iV2 = ((C2702vH) c0312Mb.d).T;
        if (interfaceC1483iV2 != null) {
            interfaceC1483iV2.invalidate();
        }
    }

    public final void B() {
        if (this.l) {
            C2420sK c2420sKS = s();
            if (c2420sKS != null) {
                c2420sKS.B();
                return;
            }
            return;
        }
        if (this.r != null) {
            O(this, false, 7);
        } else {
            Q(this, false, 7);
        }
    }

    @Override // o.InterfaceC1672kV
    public final boolean C() {
        return G();
    }

    public final void D() {
        if (C0704aI.a(this.n, 9223372034707292159L)) {
            return;
        }
        this.n = 9223372034707292159L;
        C1479iR c1479iRW = w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            ((C2420sK) objArr[i2]).D();
        }
    }

    public final void E() {
        if (this.D) {
            return;
        }
        if (((C1954nS) this.N.c).q != null || this.S != null) {
            this.B = true;
            return;
        }
        N50 n50 = this.C;
        this.D = true;
        B10 b10 = new B10();
        b10.l = new N50();
        C1767lV snapshotObserver = ((C2207q3) AbstractC2705vK.a(this)).getSnapshotObserver();
        snapshotObserver.a(this, snapshotObserver.d, new C1352h3(7, this, b10));
        this.D = false;
        this.C = (N50) b10.l;
        this.B = false;
        C2207q3 c2207q3 = (C2207q3) AbstractC2705vK.a(this);
        c2207q3.getSemanticsOwner().b(this, n50);
        c2207q3.B();
    }

    public final void F() {
        C2420sK c2420sK;
        if (this.s > 0) {
            this.v = true;
        }
        if (!this.l || (c2420sK = this.w) == null) {
            return;
        }
        c2420sK.F();
    }

    public final boolean G() {
        return this.x != null;
    }

    public final boolean H() {
        return this.O.f773o.B;
    }

    public final Boolean I() {
        C1091eN c1091eN = this.O.p;
        if (c1091eN != null) {
            return Boolean.valueOf(c1091eN.u());
        }
        return null;
    }

    public final void J(C2420sK c2420sK) {
        if (c2420sK.O.k > 0) {
            this.O.d(r0.k - 1);
        }
        if (this.x != null) {
            c2420sK.h();
        }
        c2420sK.w = null;
        if (c2420sK.W > 0) {
            W(this.W - 1);
        }
        ((AbstractC2239qS) c2420sK.N.e).B = null;
        if (c2420sK.l) {
            this.s--;
            C1479iR c1479iR = (C1479iR) c2420sK.t.l;
            Object[] objArr = c1479iR.l;
            int i = c1479iR.n;
            for (int i2 = 0; i2 < i; i2++) {
                ((AbstractC2239qS) ((C2420sK) objArr[i2]).N.e).B = null;
            }
        }
        F();
        L();
    }

    public final void K() {
        this.q = true;
        C1479iR c1479iRW = w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            ((C2420sK) objArr[i2]).D();
        }
    }

    public final void L() {
        if (!this.l) {
            this.F = true;
            return;
        }
        C2420sK c2420sKS = s();
        if (c2420sKS != null) {
            c2420sKS.L();
        }
    }

    public final void N(boolean z) {
        InterfaceC1577jV interfaceC1577jV;
        if (this.l || (interfaceC1577jV = this.x) == null) {
            return;
        }
        ((C2207q3) interfaceC1577jV).A(this, true, z);
    }

    public final void P(boolean z) {
        InterfaceC1577jV interfaceC1577jV;
        if (this.l || (interfaceC1577jV = this.x) == null) {
            return;
        }
        ((C2207q3) interfaceC1577jV).A(this, false, z);
    }

    public final void S() {
        C1479iR c1479iRW = w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            C2420sK c2420sK = (C2420sK) objArr[i2];
            int i3 = c2420sK.Z;
            c2420sK.Y = i3;
            if (i3 != 3) {
                c2420sK.S();
            }
        }
    }

    public final void T(Throwable th) throws Throwable {
        InterfaceC0633Yk interfaceC0633Yk = this.L;
        Ma0 ma0 = AbstractC0529Uk.a;
        C3097zW c3097zW = (C3097zW) interfaceC0633Yk;
        c3097zW.getClass();
        C0503Tk c0503Tk = (C0503Tk) AbstractC0940cn0.F(c3097zW, ma0);
        if (c0503Tk == null) {
            throw th;
        }
        C80.Z(th, new C2590u5(4, c0503Tk, this));
        throw th;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v1 */
    /* JADX WARN: Type inference failed for: r2v10 */
    /* JADX WARN: Type inference failed for: r2v11 */
    /* JADX WARN: Type inference failed for: r2v12 */
    /* JADX WARN: Type inference failed for: r2v13 */
    /* JADX WARN: Type inference failed for: r2v14 */
    /* JADX WARN: Type inference failed for: r2v2, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r2v6 */
    /* JADX WARN: Type inference failed for: r2v7, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r2v8, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v9 */
    /* JADX WARN: Type inference failed for: r3v0 */
    /* JADX WARN: Type inference failed for: r3v1 */
    /* JADX WARN: Type inference failed for: r3v10 */
    /* JADX WARN: Type inference failed for: r3v11 */
    /* JADX WARN: Type inference failed for: r3v2 */
    /* JADX WARN: Type inference failed for: r3v3, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r3v4 */
    /* JADX WARN: Type inference failed for: r3v5 */
    /* JADX WARN: Type inference failed for: r3v6, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r3v8 */
    /* JADX WARN: Type inference failed for: r3v9 */
    public final void U(InterfaceC0633Yk interfaceC0633Yk) {
        this.L = interfaceC0633Yk;
        Ma0 ma0 = AbstractC0840bl.h;
        C3097zW c3097zW = (C3097zW) interfaceC0633Yk;
        c3097zW.getClass();
        V((InterfaceC2281qr) AbstractC0940cn0.F(c3097zW, ma0));
        EnumC1280gK enumC1280gK = (EnumC1280gK) AbstractC0940cn0.F(c3097zW, AbstractC0840bl.n);
        EnumC1280gK enumC1280gK2 = this.J;
        C0312Mb c0312Mb = this.N;
        if (enumC1280gK2 != enumC1280gK) {
            this.J = enumC1280gK;
            B();
            C2420sK c2420sKS = s();
            if (c2420sKS != null) {
                c2420sKS.z();
            }
            A();
            for (LP lp = (LP) c0312Mb.g; lp != null; lp = lp.q) {
                lp.p0();
            }
        }
        a0((Qj0) AbstractC0940cn0.F(c3097zW, AbstractC0840bl.s));
        LP lp2 = (LP) c0312Mb.g;
        if ((lp2.f209o & 32768) != 0) {
            while (lp2 != null) {
                if ((lp2.n & 32768) != 0) {
                    AbstractC0561Vq abstractC0561VqI = lp2;
                    ?? c1479iR = 0;
                    while (abstractC0561VqI != 0) {
                        if (abstractC0561VqI instanceof InterfaceC0581Wk) {
                            LP lp3 = ((LP) ((InterfaceC0581Wk) abstractC0561VqI)).l;
                            if (lp3.y) {
                                AbstractC2333rS.c(lp3);
                            } else {
                                lp3.u = true;
                            }
                        } else if ((abstractC0561VqI.n & 32768) != 0 && (abstractC0561VqI instanceof AbstractC0561Vq)) {
                            LP lp4 = abstractC0561VqI.A;
                            int i = 0;
                            abstractC0561VqI = abstractC0561VqI;
                            c1479iR = c1479iR;
                            while (lp4 != null) {
                                if ((lp4.n & 32768) != 0) {
                                    i++;
                                    c1479iR = c1479iR;
                                    if (i == 1) {
                                        abstractC0561VqI = lp4;
                                    } else {
                                        if (c1479iR == 0) {
                                            c1479iR = new C1479iR(new LP[16]);
                                        }
                                        if (abstractC0561VqI != 0) {
                                            c1479iR.b(abstractC0561VqI);
                                            abstractC0561VqI = 0;
                                        }
                                        c1479iR.b(lp4);
                                    }
                                }
                                lp4 = lp4.q;
                                abstractC0561VqI = abstractC0561VqI;
                                c1479iR = c1479iR;
                            }
                            if (i == 1) {
                            }
                        }
                        abstractC0561VqI = AbstractC2539te.i(c1479iR);
                    }
                }
                if ((lp2.f209o & 32768) == 0) {
                    return;
                } else {
                    lp2 = lp2.q;
                }
            }
        }
    }

    public final void V(InterfaceC2281qr interfaceC2281qr) {
        if (F3.c(this.I, interfaceC2281qr)) {
            return;
        }
        this.I = interfaceC2281qr;
        B();
        C2420sK c2420sKS = s();
        if (c2420sKS != null) {
            c2420sKS.z();
        }
        A();
        for (LP lp = (LP) this.N.g; lp != null; lp = lp.q) {
            lp.c();
        }
    }

    public final void W(int i) {
        C2420sK c2420sKS;
        C2420sK c2420sKS2;
        int i2 = this.W;
        if (i2 != i) {
            if (i > 0 && i2 == 0 && (c2420sKS2 = s()) != null) {
                c2420sKS2.W(c2420sKS2.W + 1);
            }
            if (i == 0 && this.W > 0 && (c2420sKS = s()) != null) {
                c2420sKS.W(c2420sKS.W - 1);
            }
            this.W = i;
        }
    }

    public final void X(C2420sK c2420sK) {
        if (F3.c(c2420sK, this.r)) {
            return;
        }
        this.r = c2420sK;
        C2800wK c2800wK = this.O;
        if (c2420sK != null) {
            if (c2800wK.p == null) {
                c2800wK.p = new C1091eN(c2800wK);
            }
            C0312Mb c0312Mb = this.N;
            AbstractC2239qS abstractC2239qS = ((C2702vH) c0312Mb.d).A;
            for (AbstractC2239qS abstractC2239qS2 = (AbstractC2239qS) c0312Mb.e; !F3.c(abstractC2239qS2, abstractC2239qS) && abstractC2239qS2 != null; abstractC2239qS2 = abstractC2239qS2.A) {
                abstractC2239qS2.K0();
            }
        } else {
            c2800wK.p = null;
            c2800wK.e = false;
            c2800wK.d = false;
        }
        B();
    }

    public final void Y(InterfaceC2235qO interfaceC2235qO) {
        if (F3.c(this.G, interfaceC2235qO)) {
            return;
        }
        this.G = interfaceC2235qO;
        C3040yr c3040yr = this.H;
        if (c3040yr != null) {
            ((MV) c3040yr.n).setValue(interfaceC2235qO);
        }
        B();
    }

    public final void Z(MP mp) {
        if (this.l && this.R != JP.a) {
            AbstractC2133pH.a("Modifiers are not supported on virtual LayoutNodes");
        }
        if (this.X) {
            AbstractC2133pH.a("modifier is updated when deactivated");
        }
        if (!G()) {
            this.S = mp;
            return;
        }
        a(mp);
        if (this.B) {
            E();
        }
    }

    /* JADX WARN: Type inference failed for: r7v1 */
    /* JADX WARN: Type inference failed for: r7v15 */
    /* JADX WARN: Type inference failed for: r7v16 */
    /* JADX WARN: Type inference failed for: r7v3, types: [o.LP, o.qS] */
    public final void a(MP mp) {
        ?? r7;
        C1479iR c1479iR;
        C0312Mb c0312Mb;
        C1954nS c1954nS;
        C1479iR c1479iR2;
        boolean z;
        boolean z2;
        boolean z3;
        C0312Mb c0312Mb2;
        boolean z4;
        C2769w c2769w;
        C0312Mb c0312Mb3 = this.N;
        boolean zJ = c0312Mb3.j(16);
        LP lp = (Bc0) c0312Mb3.f;
        boolean zJ2 = c0312Mb3.j(1024);
        this.R = mp;
        C2702vH c2702vH = (C2702vH) c0312Mb3.d;
        C2420sK c2420sK = (C2420sK) c0312Mb3.b;
        LP lp2 = (LP) c0312Mb3.g;
        C1954nS c1954nS2 = (C1954nS) c0312Mb3.c;
        if (lp2 == c1954nS2) {
            AbstractC2133pH.b("padChain called on already padded chain");
        }
        LP lp3 = (LP) c0312Mb3.g;
        lp3.p = c1954nS2;
        c1954nS2.q = lp3;
        C1479iR c1479iR3 = (C1479iR) c0312Mb3.h;
        int i = c1479iR3 != null ? c1479iR3.n : 0;
        C1479iR c1479iR4 = (C1479iR) c0312Mb3.i;
        if (c1479iR4 == null) {
            c1479iR4 = new C1479iR(new KP[16]);
        }
        C1479iR c1479iR5 = (C1479iR) c0312Mb3.j;
        c1479iR5.b(mp);
        C2769w c2769w2 = null;
        while (true) {
            int i2 = c1479iR5.n;
            if (i2 == 0) {
                break;
            }
            MP mp2 = (MP) c1479iR5.k(i2 - 1);
            if (mp2 instanceof C1122ej) {
                C1122ej c1122ej = (C1122ej) mp2;
                c1479iR5.b(c1122ej.b);
                c1479iR5.b(c1122ej.a);
            } else if (mp2 instanceof KP) {
                c1479iR4.b(mp2);
            } else {
                if (c2769w2 == null) {
                    c2769w = new C2769w(24, c1479iR4);
                    c2769w2 = c2769w;
                } else {
                    c2769w = c2769w2;
                }
                mp2.c(c2769w);
            }
        }
        int i3 = c1479iR4.n;
        if (i3 == i) {
            LP lp4 = c1954nS2.q;
            C0312Mb c0312Mb4 = c0312Mb3;
            int i4 = 0;
            while (lp4 != null && i4 < i) {
                if (c1479iR3 == null) {
                    throw AbstractC2462sn.q("expected prior modifier list to be non-empty");
                }
                KP kp = (KP) c1479iR3.l[i4];
                KP kp2 = (KP) c1479iR4.l[i4];
                if (F3.c(kp, kp2)) {
                    c0312Mb2 = c0312Mb4;
                    z4 = 2;
                } else {
                    c0312Mb2 = c0312Mb4;
                    z4 = kp.getClass() == kp2.getClass();
                }
                if (!z4) {
                    lp4 = lp4.p;
                    break;
                }
                if (z4) {
                    C0312Mb.o(kp, kp2, lp4);
                }
                lp4 = lp4.q;
                i4++;
                c0312Mb4 = c0312Mb2;
            }
            c0312Mb2 = c0312Mb4;
            if (i4 >= i) {
                c0312Mb3 = c0312Mb2;
                z2 = false;
                c0312Mb = c0312Mb3;
                c1479iR = c1479iR3;
                c1954nS = c1954nS2;
                c1479iR2 = c1479iR4;
                z = false;
                r7 = z2;
            } else {
                if (c1479iR3 == null) {
                    throw AbstractC2462sn.q("expected prior modifier list to be non-empty");
                }
                if (lp4 == null) {
                    throw AbstractC2462sn.q("structuralUpdate requires a non-null tail");
                }
                boolean z5 = c2420sK.S != null;
                c1479iR = c1479iR3;
                c1479iR2 = c1479iR4;
                z3 = false;
                LP lp5 = lp4;
                c0312Mb = c0312Mb2;
                c0312Mb.m(i4, c1479iR, c1479iR2, lp5, !z5);
                c1954nS = c1954nS2;
                z = true;
                r7 = z3;
            }
        } else {
            r7 = 0;
            z3 = false;
            z2 = false;
            MP mp3 = c2420sK.S;
            if (mp3 != null && i == 0) {
                LP lpE = c1954nS2;
                for (int i5 = 0; i5 < c1479iR4.n; i5++) {
                    lpE = C0312Mb.e((KP) c1479iR4.l[i5], lpE);
                }
                int i6 = 0;
                for (LP lp6 = lp.p; lp6 != null && lp6 != c1954nS2; lp6 = lp6.p) {
                    i6 |= lp6.n;
                    lp6.f209o = i6;
                }
                c0312Mb = c0312Mb3;
                c1479iR = c1479iR3;
                c1954nS = c1954nS2;
                c1479iR2 = c1479iR4;
                z = true;
                r7 = z3;
            } else if (i3 != 0) {
                if (c1479iR3 == null) {
                    c1479iR3 = new C1479iR(new KP[16]);
                }
                c1479iR = c1479iR3;
                c0312Mb = c0312Mb3;
                c1954nS = c1954nS2;
                c1479iR2 = c1479iR4;
                c0312Mb.m(0, c1479iR, c1479iR2, c1954nS, !(mp3 != null));
                z = true;
            } else {
                if (c1479iR3 == null) {
                    throw AbstractC2462sn.q("expected prior modifier list to be non-empty");
                }
                LP lp7 = c1954nS2.q;
                for (int i7 = 0; lp7 != null && i7 < c1479iR3.n; i7++) {
                    lp7 = C0312Mb.f(lp7).q;
                }
                C2420sK c2420sKS = c2420sK.s();
                c2702vH.B = c2420sKS != null ? (C2702vH) c2420sKS.N.d : null;
                c0312Mb3.e = c2702vH;
                c0312Mb = c0312Mb3;
                c1479iR = c1479iR3;
                c1954nS = c1954nS2;
                c1479iR2 = c1479iR4;
                z = false;
                r7 = z2;
            }
        }
        c0312Mb.h = c1479iR2;
        if (c1479iR != null) {
            c1479iR.h();
        } else {
            c1479iR = r7;
        }
        c0312Mb.i = c1479iR;
        LP lp8 = c1954nS.q;
        if (lp8 != null) {
            lp = lp8;
        }
        lp.p = r7;
        c1954nS.q = r7;
        c1954nS.f209o = -1;
        c1954nS.s = r7;
        if (lp == c1954nS) {
            AbstractC2133pH.b("trimChain did not update the head");
        }
        c0312Mb.g = lp;
        if (z) {
            c0312Mb.n();
        }
        boolean zJ3 = c0312Mb.j(16);
        boolean zJ4 = c0312Mb.j(1024);
        this.O.j();
        if (this.r == null && c0312Mb.j(512)) {
            X(this);
        }
        if (zJ == zJ3 && zJ2 == zJ4) {
            return;
        }
        U00 rectManager = ((C2207q3) AbstractC2705vK.a(this)).getRectManager();
        rectManager.getClass();
        if (G()) {
            C0692a8 c0692a8 = rectManager.a;
            int i8 = this.m & 67108863;
            long[] jArr = (long[]) c0692a8.c;
            int i9 = c0692a8.b;
            for (int i10 = 0; i10 < jArr.length - 2 && i10 < i9; i10 += 3) {
                int i11 = i10 + 2;
                long j = jArr[i11];
                if ((((int) j) & 67108863) == i8) {
                    jArr[i11] = ((zJ3 ? 1L : 0L) * Long.MIN_VALUE) | (4611686018427387903L & j) | ((zJ4 ? 1L : 0L) * 4611686018427387904L);
                    return;
                }
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v0 */
    /* JADX WARN: Type inference failed for: r2v1, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r2v10 */
    /* JADX WARN: Type inference failed for: r2v11 */
    /* JADX WARN: Type inference failed for: r2v3 */
    /* JADX WARN: Type inference failed for: r2v4, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r2v5, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v6 */
    /* JADX WARN: Type inference failed for: r2v7 */
    /* JADX WARN: Type inference failed for: r2v8 */
    /* JADX WARN: Type inference failed for: r2v9 */
    /* JADX WARN: Type inference failed for: r3v0 */
    /* JADX WARN: Type inference failed for: r3v1 */
    /* JADX WARN: Type inference failed for: r3v10 */
    /* JADX WARN: Type inference failed for: r3v11 */
    /* JADX WARN: Type inference failed for: r3v2 */
    /* JADX WARN: Type inference failed for: r3v3, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r3v4 */
    /* JADX WARN: Type inference failed for: r3v5 */
    /* JADX WARN: Type inference failed for: r3v6, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r3v8 */
    /* JADX WARN: Type inference failed for: r3v9 */
    public final void a0(Qj0 qj0) {
        if (F3.c(this.K, qj0)) {
            return;
        }
        this.K = qj0;
        LP lp = (LP) this.N.g;
        if ((lp.f209o & 16) != 0) {
            while (lp != null) {
                if ((lp.n & 16) != 0) {
                    AbstractC0561Vq abstractC0561VqI = lp;
                    ?? c1479iR = 0;
                    while (abstractC0561VqI != 0) {
                        if (abstractC0561VqI instanceof LX) {
                            ((LX) abstractC0561VqI).W();
                        } else if ((abstractC0561VqI.n & 16) != 0 && (abstractC0561VqI instanceof AbstractC0561Vq)) {
                            LP lp2 = abstractC0561VqI.A;
                            int i = 0;
                            abstractC0561VqI = abstractC0561VqI;
                            c1479iR = c1479iR;
                            while (lp2 != null) {
                                if ((lp2.n & 16) != 0) {
                                    i++;
                                    c1479iR = c1479iR;
                                    if (i == 1) {
                                        abstractC0561VqI = lp2;
                                    } else {
                                        if (c1479iR == 0) {
                                            c1479iR = new C1479iR(new LP[16]);
                                        }
                                        if (abstractC0561VqI != 0) {
                                            c1479iR.b(abstractC0561VqI);
                                            abstractC0561VqI = 0;
                                        }
                                        c1479iR.b(lp2);
                                    }
                                }
                                lp2 = lp2.q;
                                abstractC0561VqI = abstractC0561VqI;
                                c1479iR = c1479iR;
                            }
                            if (i == 1) {
                            }
                        }
                        abstractC0561VqI = AbstractC2539te.i(c1479iR);
                    }
                }
                if ((lp.f209o & 16) == 0) {
                    return;
                } else {
                    lp = lp.q;
                }
            }
        }
    }

    public final void b(InterfaceC1577jV interfaceC1577jV) {
        C2420sK c2420sK;
        R2 r2;
        N50 n50U;
        if (this.x != null) {
            AbstractC2133pH.b("Cannot attach " + this + " as it already is attached.  Tree: " + g(0));
        }
        C2420sK c2420sK2 = this.w;
        if (c2420sK2 != null && !F3.c(c2420sK2.x, interfaceC1577jV)) {
            StringBuilder sb = new StringBuilder("Attaching to a different owner(");
            sb.append(interfaceC1577jV);
            sb.append(") than the parent's owner(");
            C2420sK c2420sKS = s();
            sb.append(c2420sKS != null ? c2420sKS.x : null);
            sb.append("). This tree: ");
            sb.append(g(0));
            sb.append(" Parent tree: ");
            C2420sK c2420sK3 = this.w;
            sb.append(c2420sK3 != null ? c2420sK3.g(0) : null);
            AbstractC2133pH.b(sb.toString());
        }
        C2420sK c2420sKS2 = s();
        C2800wK c2800wK = this.O;
        if (c2420sKS2 == null) {
            c2800wK.f773o.B = true;
            C1091eN c1091eN = c2800wK.p;
            if (c1091eN != null) {
                c1091eN.A = 1;
            }
        }
        C0312Mb c0312Mb = this.N;
        ((AbstractC2239qS) c0312Mb.e).B = c2420sKS2 != null ? (C2702vH) c2420sKS2.N.d : null;
        this.x = interfaceC1577jV;
        this.z = (c2420sKS2 != null ? c2420sKS2.z : -1) + 1;
        MP mp = this.S;
        if (mp != null) {
            a(mp);
        }
        this.S = null;
        C2207q3 c2207q3 = (C2207q3) interfaceC1577jV;
        c2207q3.m6getLayoutNodes().h(this.m, this);
        C2420sK c2420sK4 = this.w;
        if (c2420sK4 == null || (c2420sK = c2420sK4.r) == null) {
            c2420sK = this.r;
        }
        X(c2420sK);
        if (this.r == null && c0312Mb.j(512)) {
            X(this);
        }
        if (!this.X) {
            for (LP lp = (LP) c0312Mb.g; lp != null; lp = lp.q) {
                lp.x0();
            }
        }
        C1479iR c1479iR = (C1479iR) this.t.l;
        Object[] objArr = c1479iR.l;
        int i = c1479iR.n;
        for (int i2 = 0; i2 < i; i2++) {
            ((C2420sK) objArr[i2]).b(interfaceC1577jV);
        }
        if (!this.X) {
            c0312Mb.l();
        }
        B();
        if (c2420sKS2 != null) {
            c2420sKS2.B();
        }
        S5 s5 = this.T;
        if (s5 != null) {
            s5.g(interfaceC1577jV);
        }
        c2800wK.j();
        if (!this.X && c0312Mb.j(8)) {
            E();
        }
        c2207q3.getClass();
        if (!C2207q3.i() || (r2 = c2207q3.Q) == null || (n50U = u()) == null || !n50U.l.b(W50.q)) {
            return;
        }
        r2.h.a(this.m);
        r2.a.e(r2.c, this.m, true);
    }

    public final void b0() {
        if (this.s <= 0 || !this.v) {
            return;
        }
        this.v = false;
        C1479iR c1479iR = this.u;
        if (c1479iR == null) {
            c1479iR = new C1479iR(new C2420sK[16]);
            this.u = c1479iR;
        }
        c1479iR.h();
        C1479iR c1479iR2 = (C1479iR) this.t.l;
        Object[] objArr = c1479iR2.l;
        int i = c1479iR2.n;
        for (int i2 = 0; i2 < i; i2++) {
            C2420sK c2420sK = (C2420sK) objArr[i2];
            if (c2420sK.l) {
                c1479iR.d(c1479iR.n, c2420sK.w());
            } else {
                c1479iR.b(c2420sK);
            }
        }
        C2800wK c2800wK = this.O;
        c2800wK.f773o.I = true;
        C1091eN c1091eN = c2800wK.p;
        if (c1091eN != null) {
            c1091eN.D = true;
        }
    }

    public final void c() {
        this.Z = this.Y;
        this.Y = 3;
        C1479iR c1479iRW = w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            C2420sK c2420sK = (C2420sK) objArr[i2];
            if (c2420sK.Y != 3) {
                c2420sK.c();
            }
        }
    }

    @Override // o.InterfaceC2646uk
    public final void d() {
        Tj0 tj0 = this.y;
        if (tj0 != null) {
            tj0.d();
        }
        C0312Mb c0312Mb = this.N;
        AbstractC2239qS abstractC2239qS = ((C2702vH) c0312Mb.d).A;
        for (AbstractC2239qS abstractC2239qS2 = (AbstractC2239qS) c0312Mb.e; !F3.c(abstractC2239qS2, abstractC2239qS) && abstractC2239qS2 != null; abstractC2239qS2 = abstractC2239qS2.A) {
            abstractC2239qS2.c1();
        }
    }

    @Override // o.InterfaceC2646uk
    public final void e() {
        R2 r2;
        Tj0 tj0 = this.y;
        if (tj0 != null) {
            tj0.e();
        }
        this.X = true;
        LP lp = (Bc0) this.N.f;
        for (LP lp2 = lp; lp2 != null; lp2 = lp2.p) {
            if (lp2.y) {
                lp2.C0();
            }
        }
        for (LP lp3 = lp; lp3 != null; lp3 = lp3.p) {
            if (lp3.y) {
                lp3.E0();
            }
        }
        while (lp != null) {
            if (lp.y) {
                lp.y0();
            }
            lp = lp.p;
        }
        if (G()) {
            this.C = null;
            this.B = false;
        }
        InterfaceC1577jV interfaceC1577jV = this.x;
        if (interfaceC1577jV != null) {
            C2207q3 c2207q3 = (C2207q3) interfaceC1577jV;
            c2207q3.getRectManager().j(this);
            if (C2207q3.i() && (r2 = c2207q3.Q) != null && r2.h.e(this.m)) {
                r2.a.e(r2.c, this.m, false);
            }
        }
    }

    public final void f() {
        this.Z = this.Y;
        this.Y = 3;
        C1479iR c1479iRW = w();
        Object[] objArr = c1479iRW.l;
        int i = c1479iRW.n;
        for (int i2 = 0; i2 < i; i2++) {
            C2420sK c2420sK = (C2420sK) objArr[i2];
            if (c2420sK.Y == 2) {
                c2420sK.f();
            }
        }
    }

    public final String g(int i) {
        StringBuilder sb = new StringBuilder();
        for (int i2 = 0; i2 < i; i2++) {
            sb.append("  ");
        }
        sb.append("|-");
        sb.append(toString());
        sb.append('\n');
        C1479iR c1479iRW = w();
        Object[] objArr = c1479iRW.l;
        int i3 = c1479iRW.n;
        for (int i4 = 0; i4 < i3; i4++) {
            sb.append(((C2420sK) objArr[i4]).g(i + 1));
        }
        String string = sb.toString();
        return i == 0 ? string.substring(0, string.length() - 1) : string;
    }

    public final void h() {
        R2 r2;
        C2515tK c2515tK;
        InterfaceC1577jV interfaceC1577jV = this.x;
        if (interfaceC1577jV == null) {
            StringBuilder sb = new StringBuilder("Cannot detach node that is already detached!  Tree: ");
            C2420sK c2420sKS = s();
            sb.append(c2420sKS != null ? c2420sKS.g(0) : null);
            AbstractC2133pH.c(sb.toString());
            throw new C2170pj();
        }
        C2420sK c2420sKS2 = s();
        C2800wK c2800wK = this.O;
        if (c2420sKS2 != null) {
            c2420sKS2.z();
            c2420sKS2.B();
            c2800wK.f773o.U = 3;
            C1091eN c1091eN = c2800wK.p;
            if (c1091eN != null) {
                c1091eN.u = 3;
            }
        }
        C2515tK c2515tK2 = c2800wK.f773o.G;
        c2515tK2.b = true;
        c2515tK2.c = false;
        c2515tK2.d = false;
        c2515tK2.e = false;
        c2515tK2.f = null;
        C1091eN c1091eN2 = c2800wK.p;
        if (c1091eN2 != null && (c2515tK = c1091eN2.B) != null) {
            c2515tK.b = true;
            c2515tK.c = false;
            c2515tK.d = false;
            c2515tK.e = false;
            c2515tK.f = null;
        }
        C0312Mb c0312Mb = this.N;
        LP lp = (Bc0) c0312Mb.f;
        AbstractC2239qS abstractC2239qS = ((C2702vH) c0312Mb.d).A;
        for (AbstractC2239qS abstractC2239qS2 = (AbstractC2239qS) c0312Mb.e; !F3.c(abstractC2239qS2, abstractC2239qS) && abstractC2239qS2 != null; abstractC2239qS2 = abstractC2239qS2.A) {
            abstractC2239qS2.h1();
        }
        T5 t5 = this.U;
        if (t5 != null) {
            t5.g(interfaceC1577jV);
        }
        for (LP lp2 = lp; lp2 != null; lp2 = lp2.p) {
            if (lp2.y) {
                lp2.E0();
            }
        }
        this.A = true;
        C1479iR c1479iR = (C1479iR) this.t.l;
        Object[] objArr = c1479iR.l;
        int i = c1479iR.n;
        for (int i2 = 0; i2 < i; i2++) {
            ((C2420sK) objArr[i2]).h();
        }
        this.A = false;
        while (lp != null) {
            if (lp.y) {
                lp.y0();
            }
            lp = lp.p;
        }
        C2207q3 c2207q3 = (C2207q3) interfaceC1577jV;
        c2207q3.m6getLayoutNodes().g(this.m);
        C1950nO c1950nO = c2207q3.c0;
        C3126zm0 c3126zm0 = c1950nO.b;
        ((C0247Jn) c3126zm0.m).w(this);
        ((C0247Jn) c3126zm0.n).w(this);
        ((C0247Jn) c3126zm0.f831o).w(this);
        ((C1479iR) c1950nO.e.m).j(this);
        c2207q3.R = true;
        c2207q3.getRectManager().j(this);
        if (C2207q3.i() && (r2 = c2207q3.Q) != null && r2.h.e(this.m)) {
            r2.a.e(r2.c, this.m, false);
        }
        this.x = null;
        this.n = 9223372034707292159L;
        X(null);
        this.z = 0;
        C2140pO c2140pO = c2800wK.f773o;
        c2140pO.t = Api.BaseClientBuilder.API_PRIORITY_OTHER;
        c2140pO.s = Api.BaseClientBuilder.API_PRIORITY_OTHER;
        c2140pO.B = false;
        C1091eN c1091eN3 = c2800wK.p;
        if (c1091eN3 != null) {
            c1091eN3.t = Api.BaseClientBuilder.API_PRIORITY_OTHER;
            c1091eN3.s = Api.BaseClientBuilder.API_PRIORITY_OTHER;
            c1091eN3.A = 3;
        }
        if (c0312Mb.j(8)) {
            N50 n50 = this.C;
            this.C = null;
            this.B = false;
            c2207q3.getSemanticsOwner().b(this, n50);
            c2207q3.B();
        }
    }

    public final void i(InterfaceC2923xg interfaceC2923xg, C1082eE c1082eE) {
        try {
            ((AbstractC2239qS) this.N.e).I0(interfaceC2923xg, c1082eE);
        } catch (Throwable th) {
            T(th);
            throw null;
        }
    }

    public final List k() {
        C1091eN c1091eN = this.O.p;
        C1479iR c1479iR = c1091eN.C;
        C2800wK c2800wK = c1091eN.q;
        c2800wK.a.m();
        if (!c1091eN.D) {
            return c1479iR.f();
        }
        C2420sK c2420sK = c2800wK.a;
        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 (c1479iR.n <= i2) {
                c1479iR.b(c2420sK2.O.p);
            } else {
                C1091eN c1091eN2 = c2420sK2.O.p;
                Object[] objArr2 = c1479iR.l;
                Object obj = objArr2[i2];
                objArr2[i2] = c1091eN2;
            }
        }
        c1479iR.l(((C1479iR) ((SQ) c2420sK.m()).m).n, c1479iR.n);
        c1091eN.D = false;
        return c1479iR.f();
    }

    public final List l() {
        C2140pO c2140pO = this.O.f773o;
        C1479iR c1479iR = c2140pO.H;
        C2800wK c2800wK = c2140pO.q;
        c2800wK.a.b0();
        if (!c2140pO.I) {
            return c1479iR.f();
        }
        C2420sK c2420sK = c2800wK.a;
        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 (c1479iR.n <= i2) {
                c1479iR.b(c2420sK2.O.f773o);
            } else {
                C2140pO c2140pO2 = c2420sK2.O.f773o;
                Object[] objArr2 = c1479iR.l;
                Object obj = objArr2[i2];
                objArr2[i2] = c2140pO2;
            }
        }
        c1479iR.l(((C1479iR) ((SQ) c2420sK.m()).m).n, c1479iR.n);
        c2140pO.I = false;
        return c1479iR.f();
    }

    public final List m() {
        return w().f();
    }

    public final boolean n() {
        return this.O.f773o.E;
    }

    public final boolean o() {
        return this.O.f773o.D;
    }

    public final int p() {
        return this.O.f773o.U;
    }

    public final int q() {
        int i;
        C1091eN c1091eN = this.O.p;
        if (c1091eN == null || (i = c1091eN.u) == 0) {
            return 3;
        }
        return i;
    }

    public final C3040yr r() {
        C3040yr c3040yr = this.H;
        if (c3040yr != null) {
            return c3040yr;
        }
        C3040yr c3040yr2 = new C3040yr(this, this.G);
        this.H = c3040yr2;
        return c3040yr2;
    }

    public final C2420sK s() {
        C2420sK c2420sK = this.w;
        while (c2420sK != null && c2420sK.l) {
            c2420sK = c2420sK.w;
        }
        return c2420sK;
    }

    public final int t() {
        return this.O.f773o.t;
    }

    public final String toString() {
        return AbstractC2798wI.w(this) + " children: " + ((C1479iR) ((SQ) m()).m).n + " measurePolicy: " + this.G + " deactivated: " + this.X;
    }

    public final N50 u() {
        if (G() && !this.X && this.N.j(8)) {
            return this.C;
        }
        return null;
    }

    public final C1479iR v() {
        boolean z = this.F;
        C1479iR c1479iR = this.E;
        if (z) {
            c1479iR.h();
            c1479iR.d(c1479iR.n, w());
            Arrays.sort(c1479iR.l, 0, c1479iR.n, c0);
            this.F = false;
        }
        return c1479iR;
    }

    public final C1479iR w() {
        b0();
        return this.s == 0 ? (C1479iR) this.t.l : this.u;
    }

    public final void x(long j, C1275gF c1275gF, int i, boolean z) {
        C0312Mb c0312Mb = this.N;
        AbstractC2239qS abstractC2239qS = (AbstractC2239qS) c0312Mb.e;
        L20 l20 = AbstractC2239qS.U;
        ((AbstractC2239qS) c0312Mb.e).U0(AbstractC2239qS.X, abstractC2239qS.M0(j), c1275gF, i, z);
    }

    public final void y(int i, C2420sK c2420sK) {
        if (c2420sK.w != null && c2420sK.x != null) {
            AbstractC2133pH.b(j(c2420sK));
        }
        c2420sK.w = this;
        DH dh = this.t;
        ((C1479iR) dh.l).a(i, c2420sK);
        ((U4) dh.m).a();
        L();
        if (c2420sK.l) {
            this.s++;
        }
        F();
        InterfaceC1577jV interfaceC1577jV = this.x;
        if (interfaceC1577jV != null) {
            c2420sK.b(interfaceC1577jV);
        }
        if (c2420sK.O.k > 0) {
            C2800wK c2800wK = this.O;
            c2800wK.d(c2800wK.k + 1);
        }
        if (c2420sK.W > 0) {
            W(this.W + 1);
        }
    }

    public final void z() {
        if (this.Q) {
            C0312Mb c0312Mb = this.N;
            AbstractC2239qS abstractC2239qS = (C2702vH) c0312Mb.d;
            AbstractC2239qS abstractC2239qS2 = ((AbstractC2239qS) c0312Mb.e).B;
            this.P = null;
            while (true) {
                if (F3.c(abstractC2239qS, abstractC2239qS2)) {
                    break;
                }
                if ((abstractC2239qS != null ? abstractC2239qS.T : null) != null) {
                    this.P = abstractC2239qS;
                    break;
                }
                abstractC2239qS = abstractC2239qS != null ? abstractC2239qS.B : null;
            }
        }
        AbstractC2239qS abstractC2239qS3 = this.P;
        if (abstractC2239qS3 != null && abstractC2239qS3.T == null) {
            throw AbstractC2462sn.q("layer was not set");
        }
        if (abstractC2239qS3 != null) {
            abstractC2239qS3.W0();
            return;
        }
        C2420sK c2420sKS = s();
        if (c2420sKS != null) {
            c2420sKS.z();
        }
    }

    public C2420sK(boolean z, int i) {
        this.l = z;
        this.m = i;
        this.n = 9223372034707292159L;
        this.f713o = 0L;
        this.p = 9223372034707292159L;
        this.q = true;
        this.t = new DH(new C1479iR(new C2420sK[16]), new U4(13, this));
        this.E = new C1479iR(new C2420sK[16]);
        this.F = true;
        this.G = a0;
        this.I = AbstractC2705vK.a;
        this.J = EnumC1280gK.l;
        this.K = b0;
        InterfaceC0633Yk.c.getClass();
        this.L = C0607Xk.b;
        this.Y = 3;
        this.Z = 3;
        this.N = new C0312Mb(this);
        this.O = new C2800wK(this);
        this.Q = true;
        this.R = JP.a;
    }
}
