package I0;

import J0.C0386u;
import androidx.compose.runtime.collection.MutableVector;
import h1.C2069a;
import i0.AbstractC2254r;

/* JADX INFO: loaded from: classes.dex */
public final class W {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final H f2288a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f2290c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f2291d;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public C2069a f2296i;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C4.f f2289b = new C4.f(4);

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final T.p f2292e = new T.p(9);

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final MutableVector f2293f = new MutableVector(new s0[16], 0);

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final long f2294g = 1;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final MutableVector f2295h = new MutableVector(new V[16], 0);

    public W(H h5) {
        this.f2288a = h5;
    }

    /* JADX WARN: Removed duplicated region for block: B:9:0x0018  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static boolean b(H h5, C2069a c2069a) {
        boolean zC0;
        H h6 = h5.l;
        if (h6 == null) {
            return false;
        }
        L l = h5.f2163K;
        if (c2069a == null) {
            U u6 = l.f2228q;
            C2069a c2069a2 = u6 != null ? u6.f2275q : null;
            if (c2069a2 != null && h6 != null) {
                kotlin.jvm.internal.o.e(u6);
                zC0 = u6.C0(c2069a2.f16612a);
            }
        } else if (h6 != null) {
            U u7 = l.f2228q;
            kotlin.jvm.internal.o.e(u7);
            zC0 = u7.C0(c2069a.f16612a);
        } else {
            zC0 = false;
        }
        H hT = h5.t();
        if (zC0 && hT != null) {
            if (hT.l == null) {
                H.V(hT, false, 3);
                return zC0;
            }
            if (h5.q() == F.f2143a) {
                H.T(hT, false, 3);
                return zC0;
            }
            if (h5.q() == F.f2144b) {
                hT.S(false);
            }
        }
        return zC0;
    }

    public static boolean c(H h5, C2069a c2069a) {
        boolean zN = c2069a != null ? h5.N(c2069a) : H.O(h5);
        H hT = h5.t();
        if (zN && hT != null) {
            if (h5.p() == F.f2143a) {
                H.V(hT, false, 3);
                return zN;
            }
            if (h5.p() == F.f2144b) {
                hT.U(false);
            }
        }
        return zN;
    }

    public static boolean h(H h5) {
        U u6;
        I i6;
        if (h5.f2163K.f2217e) {
            return (h5.q() == F.f2145c && ((u6 = h5.f2163K.f2228q) == null || (i6 = u6.f2279u) == null || !i6.e())) ? false : true;
        }
        return false;
    }

    public static boolean i(H h5) {
        if (!h5.o()) {
            return false;
        }
        do {
            if (h5.p() == F.f2145c && !h5.f2163K.f2227p.f2299A.e()) {
                H hT = h5.t();
                if ((hT != null ? hT.f2163K.f2216d : null) != D.f2136a) {
                    return false;
                }
            }
            h5 = h5.t();
            if (h5 == null) {
                return false;
            }
        } while (!h5.G());
        return true;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:13:0x003a  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a(boolean z6) {
        Object[] objArr;
        T.p pVar = this.f2292e;
        if (z6) {
            pVar.getClass();
            H h5 = this.f2288a;
            if (h5.f2172T > 0) {
                MutableVector mutableVector = (MutableVector) pVar.f6345b;
                mutableVector.clear();
                mutableVector.add(h5);
                h5.f2171S = true;
            }
        }
        if (((MutableVector) pVar.f6345b).getSize() != 0) {
            p0 p0Var = p0.f2450b;
            MutableVector mutableVector2 = (MutableVector) pVar.f6345b;
            mutableVector2.sortWith(p0Var);
            int size = mutableVector2.getSize();
            H[] hArr = (H[]) pVar.f6346c;
            if (hArr != null) {
                int length = hArr.length;
                objArr = hArr;
                if (length < size) {
                    objArr = new H[Math.max(16, mutableVector2.getSize())];
                }
            }
            pVar.f6346c = null;
            for (int i6 = 0; i6 < size; i6++) {
                objArr[i6] = mutableVector2.content[i6];
            }
            mutableVector2.clear();
            for (int i7 = size - 1; -1 < i7; i7--) {
                H h6 = objArr[i7];
                kotlin.jvm.internal.o.e(h6);
                if (h6.f2171S) {
                    T.p.m(h6);
                }
                objArr[i7] = 0;
            }
            pVar.f6346c = objArr;
        }
    }

    public final void d() {
        MutableVector mutableVector = this.f2295h;
        if (mutableVector.getSize() != 0) {
            Object[] objArr = mutableVector.content;
            int size = mutableVector.getSize();
            for (int i6 = 0; i6 < size; i6++) {
                V v3 = (V) objArr[i6];
                if (v3.f2285a.F()) {
                    boolean z6 = v3.f2286b;
                    boolean z7 = v3.f2287c;
                    H h5 = v3.f2285a;
                    if (z6) {
                        H.T(h5, z7, 2);
                    } else {
                        H.V(h5, z7, 2);
                    }
                }
            }
            mutableVector.clear();
        }
    }

    public final void e(H h5) {
        MutableVector mutableVectorX = h5.x();
        Object[] objArr = mutableVectorX.content;
        int size = mutableVectorX.getSize();
        for (int i6 = 0; i6 < size; i6++) {
            H h6 = (H) objArr[i6];
            if (kotlin.jvm.internal.o.c(h6.H(), Boolean.TRUE) && !h6.f2173U) {
                if (this.f2289b.q(h6)) {
                    h6.I();
                }
                e(h6);
            }
        }
    }

    public final void f(H h5, boolean z6) {
        if (!this.f2290c) {
            F0.a.b("forceMeasureTheSubtree should be executed during the measureAndLayout pass");
        }
        if (z6 ? h5.f2163K.f2217e : h5.o()) {
            F0.a.a("node not yet measured");
        }
        g(h5, z6);
    }

    public final void g(H h5, boolean z6) {
        U u6;
        I i6;
        MutableVector mutableVectorX = h5.x();
        Object[] objArr = mutableVectorX.content;
        int size = mutableVectorX.getSize();
        for (int i7 = 0; i7 < size; i7++) {
            H h6 = (H) objArr[i7];
            if ((!z6 && (h6.p() == F.f2143a || h6.f2163K.f2227p.f2299A.e())) || (z6 && (h6.q() == F.f2143a || ((u6 = h6.f2163K.f2228q) != null && (i6 = u6.f2279u) != null && i6.e())))) {
                boolean zO = AbstractC0303l.o(h6);
                L l = h6.f2163K;
                if (zO && !z6) {
                    if (l.f2217e && this.f2289b.q(h6)) {
                        m(h6, true, false);
                    } else {
                        f(h6, true);
                    }
                }
                if (z6 ? l.f2217e : h6.o()) {
                    m(h6, z6, false);
                }
                if (!(z6 ? l.f2217e : h6.o())) {
                    g(h6, z6);
                }
            }
        }
        if (z6 ? h5.f2163K.f2217e : h5.o()) {
            m(h5, z6, false);
        }
    }

    /* 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: r13v12 */
    /* JADX WARN: Type inference failed for: r13v13 */
    /* JADX WARN: Type inference failed for: r13v2, types: [i0.r] */
    /* JADX WARN: Type inference failed for: r13v3, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r13v4 */
    /* JADX WARN: Type inference failed for: r13v5 */
    /* JADX WARN: Type inference failed for: r13v6 */
    /* JADX WARN: Type inference failed for: r13v7 */
    /* JADX WARN: Type inference failed for: r13v8 */
    /* JADX WARN: Type inference failed for: r13v9, types: [i0.r] */
    /* JADX WARN: Type inference failed for: r15v4 */
    public final boolean j(C0386u c0386u) {
        boolean z6;
        AbstractC2254r parent$ui;
        int i6;
        ?? E5;
        boolean z7;
        H h5;
        boolean z8;
        C4.f fVar = this.f2289b;
        H h6 = this.f2288a;
        if (!h6.F()) {
            F0.a.a("performMeasureAndLayout called with unattached root");
        }
        if (!h6.G()) {
            F0.a.a("performMeasureAndLayout called with unplaced root");
        }
        if (this.f2290c) {
            F0.a.a("performMeasureAndLayout called during measure layout");
        }
        if (this.f2296i != null) {
            this.f2290c = true;
            this.f2291d = true;
            try {
                boolean zH = fVar.H();
                C0.B b5 = (C0.B) fVar.f741b;
                if (zH) {
                    z6 = false;
                    while (true) {
                        C0.B b6 = (C0.B) fVar.f743d;
                        C0.B b7 = (C0.B) fVar.f742c;
                        if (!((E0) b5.f506b).isEmpty()) {
                            h5 = (H) ((E0) b5.f506b).first();
                            b5.t(h5);
                            z8 = h5.l != null;
                            z7 = false;
                        } else if (!((E0) b7.f506b).isEmpty()) {
                            h5 = (H) ((E0) b7.f506b).first();
                            b7.t(h5);
                            z8 = h5.l != null;
                            z7 = true;
                        } else {
                            if (((E0) b6.f506b).isEmpty()) {
                                break;
                            }
                            H h7 = (H) ((E0) b6.f506b).first();
                            b6.t(h7);
                            z7 = true;
                            h5 = h7;
                            z8 = false;
                        }
                        boolean zM = m(h5, z8, z7);
                        if (!z7) {
                            if (h5.f2163K.f2218f) {
                                fVar.f(h5, EnumC0312v.f2464b);
                            }
                            if (h5.n()) {
                                fVar.f(h5, EnumC0312v.f2466d);
                            }
                        }
                        if (h5 == h6 && zM) {
                            z6 = true;
                        }
                    }
                    if (c0386u != null) {
                        c0386u.invoke();
                    }
                } else {
                    z6 = false;
                }
            } finally {
            }
        } else {
            z6 = false;
        }
        MutableVector mutableVector = this.f2293f;
        Object[] objArr = mutableVector.content;
        int size = mutableVector.getSize();
        for (int i7 = 0; i7 < size; i7++) {
            C0290e0 c0290e0 = ((H) ((s0) objArr[i7])).f2162J;
            C0310t c0310t = (C0310t) c0290e0.f2362d;
            int i8 = 4194304;
            boolean zH2 = AbstractC0302k0.h(4194304);
            if (zH2) {
                parent$ui = c0310t.f2459U;
            } else {
                parent$ui = c0310t.f2459U.getParent$ui();
                if (parent$ui == null) {
                }
            }
            p0.U u6 = AbstractC0300j0.f2401P;
            AbstractC2254r abstractC2254rX0 = c0310t.X0(zH2);
            while (abstractC2254rX0 != null && (abstractC2254rX0.getAggregateChildKindSet$ui() & i8) != 0) {
                if ((abstractC2254rX0.getKindSet$ui() & i8) != 0) {
                    ?? r13 = abstractC2254rX0;
                    MutableVector mutableVector2 = null;
                    while (r13 != 0) {
                        if (r13 instanceof InterfaceC0314x) {
                            ((InterfaceC0314x) r13).h0((C0310t) c0290e0.f2362d);
                        } else {
                            if ((r13.getKindSet$ui() & i8) != 0 && (r13 instanceof AbstractC0301k)) {
                                AbstractC2254r child$ui = ((AbstractC0301k) r13).f2431b;
                                i6 = i8;
                                int i9 = 0;
                                E5 = r13;
                                while (child$ui != null) {
                                    if ((child$ui.getKindSet$ui() & i6) != 0) {
                                        i9++;
                                        if (i9 == 1) {
                                            E5 = child$ui;
                                        } else {
                                            if (mutableVector2 == null) {
                                                mutableVector2 = new MutableVector(new AbstractC2254r[16], 0);
                                            }
                                            if (E5 != 0) {
                                                mutableVector2.add(E5);
                                                E5 = 0;
                                            }
                                            mutableVector2.add(child$ui);
                                        }
                                    }
                                    child$ui = child$ui.getChild$ui();
                                    E5 = E5;
                                }
                                if (i9 == 1) {
                                }
                                i8 = i6;
                                r13 = E5;
                            }
                            E5 = AbstractC0303l.e(mutableVector2);
                            i8 = i6;
                            r13 = E5;
                        }
                        i6 = i8;
                        E5 = AbstractC0303l.e(mutableVector2);
                        i8 = i6;
                        r13 = E5;
                    }
                }
                int i10 = i8;
                if (abstractC2254rX0 != parent$ui) {
                    abstractC2254rX0 = abstractC2254rX0.getChild$ui();
                    i8 = i10;
                }
            }
        }
        mutableVector.clear();
        return z6;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r12v1 */
    /* JADX WARN: Type inference failed for: r12v11 */
    /* JADX WARN: Type inference failed for: r12v12 */
    /* JADX WARN: Type inference failed for: r12v13 */
    /* JADX WARN: Type inference failed for: r12v2, types: [i0.r] */
    /* JADX WARN: Type inference failed for: r12v3, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r12v4 */
    /* JADX WARN: Type inference failed for: r12v5 */
    /* JADX WARN: Type inference failed for: r12v6 */
    /* JADX WARN: Type inference failed for: r12v7 */
    /* JADX WARN: Type inference failed for: r12v8 */
    /* JADX WARN: Type inference failed for: r12v9, types: [i0.r] */
    /* JADX WARN: Type inference failed for: r14v4 */
    /* JADX WARN: Type inference failed for: r18v0, types: [I0.H, java.lang.Object] */
    public final void k(H h5, long j4) {
        AbstractC2254r parent$ui;
        ?? E5;
        if (h5.f2173U) {
            return;
        }
        H h6 = this.f2288a;
        if (h5.equals(h6)) {
            F0.a.a("measureAndLayout called on root");
        }
        if (!h6.F()) {
            F0.a.a("performMeasureAndLayout called with unattached root");
        }
        if (!h6.G()) {
            F0.a.a("performMeasureAndLayout called with unplaced root");
        }
        if (this.f2290c) {
            F0.a.a("performMeasureAndLayout called during measure layout");
        }
        if (this.f2296i != null) {
            this.f2290c = true;
            this.f2291d = false;
            try {
                C4.f fVar = this.f2289b;
                ((C0.B) fVar.f741b).t(h5);
                ((C0.B) fVar.f742c).t(h5);
                ((C0.B) fVar.f743d).t(h5);
                if ((b(h5, new C2069a(j4)) || h5.f2163K.f2218f) && kotlin.jvm.internal.o.c(h5.H(), Boolean.TRUE)) {
                    h5.I();
                }
                e(h5);
                c(h5, new C2069a(j4));
                if (h5.n() && h5.G()) {
                    h5.R();
                    T.p pVar = this.f2292e;
                    pVar.getClass();
                    if (h5.f2172T > 0) {
                        ((MutableVector) pVar.f6345b).add(h5);
                        h5.f2171S = true;
                    }
                }
                d();
            } finally {
            }
        }
        MutableVector mutableVector = this.f2293f;
        Object[] objArr = mutableVector.content;
        int size = mutableVector.getSize();
        for (int i6 = 0; i6 < size; i6++) {
            C0290e0 c0290e0 = ((H) ((s0) objArr[i6])).f2162J;
            C0310t c0310t = (C0310t) c0290e0.f2362d;
            int i7 = 4194304;
            boolean zH = AbstractC0302k0.h(4194304);
            if (zH) {
                parent$ui = c0310t.f2459U;
            } else {
                parent$ui = c0310t.f2459U.getParent$ui();
                if (parent$ui == null) {
                }
            }
            p0.U u6 = AbstractC0300j0.f2401P;
            AbstractC2254r abstractC2254rX0 = c0310t.X0(zH);
            while (abstractC2254rX0 != null && (abstractC2254rX0.getAggregateChildKindSet$ui() & i7) != 0) {
                if ((abstractC2254rX0.getKindSet$ui() & i7) != 0) {
                    ?? r12 = abstractC2254rX0;
                    MutableVector mutableVector2 = null;
                    while (r12 != 0) {
                        if (r12 instanceof InterfaceC0314x) {
                            ((InterfaceC0314x) r12).h0((C0310t) c0290e0.f2362d);
                        } else {
                            if ((r12.getKindSet$ui() & i7) != 0 && (r12 instanceof AbstractC0301k)) {
                                AbstractC2254r child$ui = ((AbstractC0301k) r12).f2431b;
                                int i8 = 0;
                                E5 = r12;
                                while (child$ui != null) {
                                    if ((child$ui.getKindSet$ui() & i7) != 0) {
                                        i8++;
                                        if (i8 == 1) {
                                            E5 = child$ui;
                                        } else {
                                            if (mutableVector2 == null) {
                                                mutableVector2 = new MutableVector(new AbstractC2254r[16], 0);
                                            }
                                            if (E5 != 0) {
                                                mutableVector2.add(E5);
                                                E5 = 0;
                                            }
                                            mutableVector2.add(child$ui);
                                        }
                                    }
                                    child$ui = child$ui.getChild$ui();
                                    i7 = 4194304;
                                    E5 = E5;
                                }
                                if (i8 == 1) {
                                }
                            }
                            i7 = 4194304;
                            r12 = E5;
                        }
                        E5 = AbstractC0303l.e(mutableVector2);
                        i7 = 4194304;
                        r12 = E5;
                    }
                }
                if (abstractC2254rX0 != parent$ui) {
                    abstractC2254rX0 = abstractC2254rX0.getChild$ui();
                    i7 = 4194304;
                }
            }
        }
        mutableVector.clear();
    }

    public final void l() {
        C4.f fVar = this.f2289b;
        if (fVar.H()) {
            H h5 = this.f2288a;
            if (!h5.F()) {
                F0.a.a("performMeasureAndLayout called with unattached root");
            }
            if (!h5.G()) {
                F0.a.a("performMeasureAndLayout called with unplaced root");
            }
            if (this.f2290c) {
                F0.a.a("performMeasureAndLayout called during measure layout");
            }
            if (this.f2296i != null) {
                this.f2290c = true;
                this.f2291d = false;
                try {
                    if (!((E0) ((C0.B) fVar.f743d).f506b).isEmpty() && !((E0) ((C0.B) fVar.f741b).f506b).isEmpty()) {
                        if (h5.l != null) {
                            o(h5, true);
                        } else {
                            n(h5);
                        }
                    }
                    o(h5, false);
                } catch (Throwable th) {
                    try {
                        throw th;
                    } finally {
                        this.f2290c = false;
                        this.f2291d = false;
                    }
                }
            }
        }
    }

    public final boolean m(H h5, boolean z6, boolean z7) {
        C2069a c2069a;
        boolean zB;
        G0.p0 placementScope;
        C0310t c0310t;
        H hT;
        U u6;
        I i6;
        if (!h5.f2173U) {
            boolean zG = h5.G();
            L l = h5.f2163K;
            if (zG || l.f2227p.f2326w || i(h5) || kotlin.jvm.internal.o.c(h5.H(), Boolean.TRUE) || h(h5) || l.f2227p.f2299A.e() || ((u6 = l.f2228q) != null && (i6 = u6.f2279u) != null && i6.e())) {
                H h6 = this.f2288a;
                if (h5 == h6) {
                    c2069a = this.f2296i;
                    kotlin.jvm.internal.o.e(c2069a);
                } else {
                    c2069a = null;
                }
                if (z6) {
                    zB = l.f2217e ? b(h5, c2069a) : false;
                    if (z7 && ((zB || l.f2218f) && kotlin.jvm.internal.o.c(h5.H(), Boolean.TRUE))) {
                        h5.I();
                    }
                } else {
                    boolean zC = h5.o() ? c(h5, c2069a) : false;
                    if (z7 && h5.n() && (h5 == h6 || ((hT = h5.t()) != null && hT.G() && l.f2227p.f2326w))) {
                        if (h5 == h6) {
                            if (h5.f2159G == F.f2145c) {
                                h5.d();
                            }
                            H hT2 = h5.t();
                            if (hT2 == null || (c0310t = (C0310t) hT2.f2162J.f2362d) == null || (placementScope = c0310t.f2248o) == null) {
                                placementScope = ((J0.A) K.a(h5)).getPlacementScope();
                            }
                            G0.p0.r(placementScope, l.f2227p, 0, 0);
                        } else {
                            h5.R();
                        }
                        T.p pVar = this.f2292e;
                        pVar.getClass();
                        if (h5.f2172T > 0) {
                            ((MutableVector) pVar.f6345b).add(h5);
                            h5.f2171S = true;
                        }
                    }
                    zB = zC;
                }
                d();
                return zB;
            }
        }
        return false;
    }

    public final void n(H h5) {
        MutableVector mutableVectorX = h5.x();
        Object[] objArr = mutableVectorX.content;
        int size = mutableVectorX.getSize();
        for (int i6 = 0; i6 < size; i6++) {
            H h6 = (H) objArr[i6];
            if (h6.p() == F.f2143a || h6.f2163K.f2227p.f2299A.e()) {
                if (AbstractC0303l.o(h6)) {
                    o(h6, true);
                } else {
                    n(h6);
                }
            }
        }
    }

    public final void o(H h5, boolean z6) {
        C2069a c2069a;
        if (h5.f2173U) {
            return;
        }
        if (h5 == this.f2288a) {
            c2069a = this.f2296i;
            kotlin.jvm.internal.o.e(c2069a);
        } else {
            c2069a = null;
        }
        if (z6) {
            b(h5, c2069a);
        } else {
            c(h5, c2069a);
        }
    }

    public final boolean p(H h5, boolean z6) {
        int iOrdinal = h5.f2163K.f2216d.ordinal();
        if (iOrdinal != 0 && iOrdinal != 1) {
            if (iOrdinal == 2 || iOrdinal == 3) {
                this.f2295h.add(new V(h5, false, z6));
            } else {
                if (iOrdinal != 4) {
                    throw new E3.v();
                }
                if (!h5.o() || z6) {
                    h5.f2163K.f2227p.f2327x = true;
                    if (!h5.f2173U && (h5.G() || i(h5))) {
                        H hT = h5.t();
                        if (hT == null || !hT.o()) {
                            this.f2289b.f(h5, EnumC0312v.f2465c);
                        }
                        if (!this.f2291d) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    public final void q(long j4) {
        C2069a c2069a = this.f2296i;
        if (c2069a == null ? false : C2069a.b(c2069a.f16612a, j4)) {
            return;
        }
        if (this.f2290c) {
            F0.a.a("updateRootConstraints called while measuring");
        }
        this.f2296i = new C2069a(j4);
        H h5 = this.f2288a;
        H h6 = h5.l;
        L l = h5.f2163K;
        if (h6 != null) {
            l.f2217e = true;
        }
        l.f2227p.f2327x = true;
        this.f2289b.f(h5, h6 != null ? EnumC0312v.f2463a : EnumC0312v.f2465c);
    }
}
