package h2;

import androidx.compose.ui.platform.p3;
import h2.b1;
import h2.z0;
import j1.k;
import j2.g0;
import j2.l0;
import j2.y1;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import l1.i;
import y0.q1;
import y0.s3;
import y0.u2;

/* loaded from: classes.dex */
public final class z implements y0.k {
    private int C;
    private int D;

    /* renamed from: p, reason: collision with root package name */
    private final j2.g0 f20742p;

    /* renamed from: q, reason: collision with root package name */
    private y0.r f20743q;

    /* renamed from: r, reason: collision with root package name */
    private b1 f20744r;

    /* renamed from: s, reason: collision with root package name */
    private int f20745s;

    /* renamed from: t, reason: collision with root package name */
    private int f20746t;

    /* renamed from: u, reason: collision with root package name */
    private final HashMap f20747u = new HashMap();

    /* renamed from: v, reason: collision with root package name */
    private final HashMap f20748v = new HashMap();

    /* renamed from: w, reason: collision with root package name */
    private final c f20749w = new c();

    /* renamed from: x, reason: collision with root package name */
    private final b f20750x = new b();

    /* renamed from: y, reason: collision with root package name */
    private final HashMap f20751y = new HashMap();

    /* renamed from: z, reason: collision with root package name */
    private final b1.a f20752z = new b1.a(null, 1, null);
    private final Map A = new LinkedHashMap();
    private final a1.b B = new a1.b(new Object[16], 0);
    private final String E = "Asking for intrinsic measurements of SubcomposeLayout layouts is not supported. This includes components that are built on top of SubcomposeLayout, such as lazy lists, BoxWithConstraints, TabRow, etc. To mitigate this:\n- if intrinsic measurements are used to achieve 'match parent' sizing, consider replacing the parent of the component with a custom layout which controls the order in which children are measured, making intrinsic measurement not needed\n- adding a size modifier to the component, in order to fast return the queried intrinsic measurement.";

    /* loaded from: classes.dex */
    private final class b implements a1, g0 {

        /* renamed from: p, reason: collision with root package name */
        private final /* synthetic */ c f20759p;

        public b() {
            this.f20759p = z.this.f20749w;
        }

        @Override // c3.l
        public float G0() {
            return this.f20759p.G0();
        }

        @Override // h2.o
        public boolean K0() {
            return this.f20759p.K0();
        }

        @Override // c3.d
        public float L0(float f10) {
            return this.f20759p.L0(f10);
        }

        @Override // c3.l
        public long U(float f10) {
            return this.f20759p.U(f10);
        }

        @Override // c3.d
        public long V(long j10) {
            return this.f20759p.V(j10);
        }

        @Override // c3.d
        public int Z0(float f10) {
            return this.f20759p.Z0(f10);
        }

        @Override // c3.l
        public float a0(long j10) {
            return this.f20759p.a0(j10);
        }

        @Override // h2.g0
        public f0 e0(int i10, int i11, Map map, dn.l lVar) {
            return this.f20759p.e0(i10, i11, map, lVar);
        }

        @Override // h2.a1
        public List e1(Object obj, dn.p pVar) {
            j2.g0 g0Var = (j2.g0) z.this.f20748v.get(obj);
            List G = g0Var != null ? g0Var.G() : null;
            return G != null ? G : z.this.F(obj, pVar);
        }

        @Override // c3.d
        public float getDensity() {
            return this.f20759p.getDensity();
        }

        @Override // h2.o
        public c3.t getLayoutDirection() {
            return this.f20759p.getLayoutDirection();
        }

        @Override // c3.d
        public long l1(long j10) {
            return this.f20759p.l1(j10);
        }

        @Override // h2.g0
        public f0 m0(int i10, int i11, Map map, dn.l lVar, dn.l lVar2) {
            return this.f20759p.m0(i10, i11, map, lVar, lVar2);
        }

        @Override // c3.d
        public float s1(long j10) {
            return this.f20759p.s1(j10);
        }

        @Override // c3.d
        public long t0(float f10) {
            return this.f20759p.t0(f10);
        }

        @Override // c3.d
        public float w(int i10) {
            return this.f20759p.w(i10);
        }

        @Override // c3.d
        public float y0(float f10) {
            return this.f20759p.y0(f10);
        }
    }

    /* loaded from: classes.dex */
    private final class c implements a1 {

        /* renamed from: p, reason: collision with root package name */
        private c3.t f20761p = c3.t.Rtl;

        /* renamed from: q, reason: collision with root package name */
        private float f20762q;

        /* renamed from: r, reason: collision with root package name */
        private float f20763r;

        /* loaded from: classes.dex */
        public static final class a implements f0 {

            /* renamed from: a, reason: collision with root package name */
            final /* synthetic */ int f20765a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ int f20766b;

            /* renamed from: c, reason: collision with root package name */
            final /* synthetic */ Map f20767c;

            /* renamed from: d, reason: collision with root package name */
            final /* synthetic */ dn.l f20768d;

            /* renamed from: e, reason: collision with root package name */
            final /* synthetic */ c f20769e;

            /* renamed from: f, reason: collision with root package name */
            final /* synthetic */ z f20770f;

            /* renamed from: g, reason: collision with root package name */
            final /* synthetic */ dn.l f20771g;

            a(int i10, int i11, Map map, dn.l lVar, c cVar, z zVar, dn.l lVar2) {
                this.f20765a = i10;
                this.f20766b = i11;
                this.f20767c = map;
                this.f20768d = lVar;
                this.f20769e = cVar;
                this.f20770f = zVar;
                this.f20771g = lVar2;
            }

            @Override // h2.f0
            public int getHeight() {
                return this.f20766b;
            }

            @Override // h2.f0
            public int getWidth() {
                return this.f20765a;
            }

            @Override // h2.f0
            public Map h() {
                return this.f20767c;
            }

            @Override // h2.f0
            public void i() {
                j2.q0 v22;
                if (!this.f20769e.K0() || (v22 = this.f20770f.f20742p.P().v2()) == null) {
                    this.f20771g.invoke(this.f20770f.f20742p.P().E1());
                } else {
                    this.f20771g.invoke(v22.E1());
                }
            }

            @Override // h2.f0
            public dn.l n() {
                return this.f20768d;
            }
        }

        public c() {
        }

        @Override // c3.l
        public float G0() {
            return this.f20763r;
        }

        @Override // h2.o
        public boolean K0() {
            return z.this.f20742p.X() == g0.e.LookaheadLayingOut || z.this.f20742p.X() == g0.e.LookaheadMeasuring;
        }

        @Override // h2.a1
        public List e1(Object obj, dn.p pVar) {
            return z.this.K(obj, pVar);
        }

        @Override // c3.d
        public float getDensity() {
            return this.f20762q;
        }

        @Override // h2.o
        public c3.t getLayoutDirection() {
            return this.f20761p;
        }

        public void h(float f10) {
            this.f20762q = f10;
        }

        @Override // h2.g0
        public f0 m0(int i10, int i11, Map map, dn.l lVar, dn.l lVar2) {
            if (!((i10 & (-16777216)) == 0 && ((-16777216) & i11) == 0)) {
                g2.a.b("Size(" + i10 + " x " + i11 + ") is out of range. Each dimension must be between 0 and 16777215.");
            }
            return new a(i10, i11, map, lVar, this, z.this, lVar2);
        }

        public void p(float f10) {
            this.f20763r = f10;
        }

        public void q(c3.t tVar) {
            this.f20761p = tVar;
        }
    }

    /* loaded from: classes.dex */
    public static final class d extends g0.f {

        /* renamed from: c, reason: collision with root package name */
        final /* synthetic */ dn.p f20773c;

        /* loaded from: classes.dex */
        public static final class a implements f0 {

            /* renamed from: a, reason: collision with root package name */
            private final /* synthetic */ f0 f20774a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ z f20775b;

            /* renamed from: c, reason: collision with root package name */
            final /* synthetic */ int f20776c;

            /* renamed from: d, reason: collision with root package name */
            final /* synthetic */ f0 f20777d;

            public a(f0 f0Var, z zVar, int i10, f0 f0Var2) {
                this.f20775b = zVar;
                this.f20776c = i10;
                this.f20777d = f0Var2;
                this.f20774a = f0Var;
            }

            @Override // h2.f0
            public int getHeight() {
                return this.f20774a.getHeight();
            }

            @Override // h2.f0
            public int getWidth() {
                return this.f20774a.getWidth();
            }

            @Override // h2.f0
            public Map h() {
                return this.f20774a.h();
            }

            @Override // h2.f0
            public void i() {
                this.f20775b.f20746t = this.f20776c;
                this.f20777d.i();
                this.f20775b.y();
            }

            @Override // h2.f0
            public dn.l n() {
                return this.f20774a.n();
            }
        }

        /* loaded from: classes.dex */
        public static final class b implements f0 {

            /* renamed from: a, reason: collision with root package name */
            private final /* synthetic */ f0 f20778a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ z f20779b;

            /* renamed from: c, reason: collision with root package name */
            final /* synthetic */ int f20780c;

            /* renamed from: d, reason: collision with root package name */
            final /* synthetic */ f0 f20781d;

            public b(f0 f0Var, z zVar, int i10, f0 f0Var2) {
                this.f20779b = zVar;
                this.f20780c = i10;
                this.f20781d = f0Var2;
                this.f20778a = f0Var;
            }

            @Override // h2.f0
            public int getHeight() {
                return this.f20778a.getHeight();
            }

            @Override // h2.f0
            public int getWidth() {
                return this.f20778a.getWidth();
            }

            @Override // h2.f0
            public Map h() {
                return this.f20778a.h();
            }

            @Override // h2.f0
            public void i() {
                this.f20779b.f20745s = this.f20780c;
                this.f20781d.i();
                z zVar = this.f20779b;
                zVar.x(zVar.f20745s);
            }

            @Override // h2.f0
            public dn.l n() {
                return this.f20778a.n();
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        d(dn.p pVar, String str) {
            super(str);
            this.f20773c = pVar;
        }

        @Override // h2.e0
        public f0 f(g0 g0Var, List list, long j10) {
            z.this.f20749w.q(g0Var.getLayoutDirection());
            z.this.f20749w.h(g0Var.getDensity());
            z.this.f20749w.p(g0Var.G0());
            if (g0Var.K0() || z.this.f20742p.b0() == null) {
                z.this.f20745s = 0;
                f0 f0Var = (f0) this.f20773c.invoke(z.this.f20749w, c3.b.a(j10));
                return new b(f0Var, z.this, z.this.f20745s, f0Var);
            }
            z.this.f20746t = 0;
            f0 f0Var2 = (f0) this.f20773c.invoke(z.this.f20750x, c3.b.a(j10));
            return new a(f0Var2, z.this, z.this.f20746t, f0Var2);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class e extends kotlin.jvm.internal.v implements dn.l {
        e() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(Map.Entry entry) {
            boolean z10;
            Object key = entry.getKey();
            z0.a aVar = (z0.a) entry.getValue();
            int r10 = z.this.B.r(key);
            if (r10 < 0 || r10 >= z.this.f20746t) {
                aVar.a();
                z10 = true;
            } else {
                z10 = false;
            }
            return Boolean.valueOf(z10);
        }
    }

    /* loaded from: classes.dex */
    public static final class f implements z0.a {
        f() {
        }

        @Override // h2.z0.a
        public void a() {
        }
    }

    /* loaded from: classes.dex */
    public static final class g implements z0.a {

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ Object f20784b;

        g(Object obj) {
            this.f20784b = obj;
        }

        @Override // h2.z0.a
        public void a() {
            z.this.B();
            j2.g0 g0Var = (j2.g0) z.this.f20751y.remove(this.f20784b);
            if (g0Var != null) {
                if (!(z.this.D > 0)) {
                    throw new IllegalStateException("No pre-composed items to dispose".toString());
                }
                int indexOf = z.this.f20742p.M().indexOf(g0Var);
                if (!(indexOf >= z.this.f20742p.M().size() - z.this.D)) {
                    throw new IllegalStateException("Item is not in pre-composed item range".toString());
                }
                z.this.C++;
                z zVar = z.this;
                zVar.D--;
                int size = (z.this.f20742p.M().size() - z.this.D) - z.this.C;
                z.this.D(indexOf, size, 1);
                z.this.x(size);
            }
        }

        @Override // h2.z0.a
        public void b(Object obj, dn.l lVar) {
            j2.x0 k02;
            i.c k10;
            j2.g0 g0Var = (j2.g0) z.this.f20751y.get(this.f20784b);
            if (g0Var == null || (k02 = g0Var.k0()) == null || (k10 = k02.k()) == null) {
                return;
            }
            y1.e(k10, obj, lVar);
        }

        @Override // h2.z0.a
        public int c() {
            List H;
            j2.g0 g0Var = (j2.g0) z.this.f20751y.get(this.f20784b);
            if (g0Var == null || (H = g0Var.H()) == null) {
                return 0;
            }
            return H.size();
        }

        @Override // h2.z0.a
        public void d(int i10, long j10) {
            j2.g0 g0Var = (j2.g0) z.this.f20751y.get(this.f20784b);
            if (g0Var == null || !g0Var.K0()) {
                return;
            }
            int size = g0Var.H().size();
            if (i10 < 0 || i10 >= size) {
                throw new IndexOutOfBoundsException("Index (" + i10 + ") is out of bound of [0, " + size + ')');
            }
            if (!(!g0Var.q())) {
                throw new IllegalArgumentException("Pre-measure called on node that is not placed".toString());
            }
            j2.g0 g0Var2 = z.this.f20742p;
            g0Var2.C = true;
            j2.k0.b(g0Var).l((j2.g0) g0Var.H().get(i10), j10);
            g0Var2.C = false;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class h extends kotlin.jvm.internal.v implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ a f20785p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ dn.p f20786q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        h(a aVar, dn.p pVar) {
            super(2);
            this.f20785p = aVar;
            this.f20786q = pVar;
        }

        public final void a(y0.m mVar, int i10) {
            if ((i10 & 3) == 2 && mVar.v()) {
                mVar.A();
                return;
            }
            if (y0.p.H()) {
                y0.p.Q(-1750409193, i10, -1, "androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose.<anonymous>.<anonymous>.<anonymous> (SubcomposeLayout.kt:493)");
            }
            boolean a10 = this.f20785p.a();
            dn.p pVar = this.f20786q;
            mVar.x(207, Boolean.valueOf(a10));
            boolean c10 = mVar.c(a10);
            mVar.S(-869707859);
            if (a10) {
                pVar.invoke(mVar, 0);
            } else {
                mVar.p(c10);
            }
            mVar.H();
            mVar.d();
            if (y0.p.H()) {
                y0.p.P();
            }
        }

        @Override // dn.p
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2) {
            a((y0.m) obj, ((Number) obj2).intValue());
            return rm.n0.f34904a;
        }
    }

    public z(j2.g0 g0Var, b1 b1Var) {
        this.f20742p = g0Var;
        this.f20744r = b1Var;
    }

    private final Object A(int i10) {
        Object obj = this.f20747u.get((j2.g0) this.f20742p.M().get(i10));
        kotlin.jvm.internal.t.d(obj);
        return ((a) obj).f();
    }

    private final void C(boolean z10) {
        q1 d10;
        this.D = 0;
        this.f20751y.clear();
        int size = this.f20742p.M().size();
        if (this.C != size) {
            this.C = size;
            k.a aVar = j1.k.f23492e;
            j1.k d11 = aVar.d();
            dn.l h10 = d11 != null ? d11.h() : null;
            j1.k f10 = aVar.f(d11);
            for (int i10 = 0; i10 < size; i10++) {
                try {
                    j2.g0 g0Var = (j2.g0) this.f20742p.M().get(i10);
                    a aVar2 = (a) this.f20747u.get(g0Var);
                    if (aVar2 != null && aVar2.a()) {
                        H(g0Var);
                        if (z10) {
                            u2 b10 = aVar2.b();
                            if (b10 != null) {
                                b10.deactivate();
                            }
                            d10 = s3.d(Boolean.FALSE, null, 2, null);
                            aVar2.h(d10);
                        } else {
                            aVar2.g(false);
                        }
                        aVar2.m(y0.c());
                    }
                } catch (Throwable th2) {
                    aVar.m(d11, f10, h10);
                    throw th2;
                }
            }
            rm.n0 n0Var = rm.n0.f34904a;
            aVar.m(d11, f10, h10);
            this.f20748v.clear();
        }
        B();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void D(int i10, int i11, int i12) {
        j2.g0 g0Var = this.f20742p;
        g0Var.C = true;
        this.f20742p.e1(i10, i11, i12);
        g0Var.C = false;
    }

    static /* synthetic */ void E(z zVar, int i10, int i11, int i12, int i13, Object obj) {
        if ((i13 & 4) != 0) {
            i12 = 1;
        }
        zVar.D(i10, i11, i12);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final List F(Object obj, dn.p pVar) {
        List k10;
        if (!(this.B.q() >= this.f20746t)) {
            throw new IllegalArgumentException("Error: currentPostLookaheadIndex cannot be greater than the size of thepostLookaheadComposedSlotIds list.".toString());
        }
        int q10 = this.B.q();
        int i10 = this.f20746t;
        if (q10 == i10) {
            this.B.c(obj);
        } else {
            this.B.D(i10, obj);
        }
        this.f20746t++;
        if (!this.f20751y.containsKey(obj)) {
            this.A.put(obj, G(obj, pVar));
            if (this.f20742p.X() == g0.e.LayingOut) {
                this.f20742p.p1(true);
            } else {
                j2.g0.s1(this.f20742p, true, false, false, 6, null);
            }
        }
        j2.g0 g0Var = (j2.g0) this.f20751y.get(obj);
        if (g0Var == null) {
            k10 = sm.u.k();
            return k10;
        }
        List w12 = g0Var.d0().w1();
        int size = w12.size();
        for (int i11 = 0; i11 < size; i11++) {
            ((l0.b) w12.get(i11)).K1();
        }
        return w12;
    }

    private final void H(j2.g0 g0Var) {
        l0.b d02 = g0Var.d0();
        g0.g gVar = g0.g.NotUsed;
        d02.X1(gVar);
        l0.a a02 = g0Var.a0();
        if (a02 != null) {
            a02.Q1(gVar);
        }
    }

    private final void L(j2.g0 g0Var, a aVar) {
        k.a aVar2 = j1.k.f23492e;
        j1.k d10 = aVar2.d();
        dn.l h10 = d10 != null ? d10.h() : null;
        j1.k f10 = aVar2.f(d10);
        try {
            j2.g0 g0Var2 = this.f20742p;
            g0Var2.C = true;
            dn.p c10 = aVar.c();
            u2 b10 = aVar.b();
            y0.r rVar = this.f20743q;
            if (rVar == null) {
                throw new IllegalStateException("parent composition reference not set".toString());
            }
            aVar.i(N(b10, g0Var, aVar.e(), rVar, g1.c.c(-1750409193, true, new h(aVar, c10))));
            aVar.l(false);
            g0Var2.C = false;
            rm.n0 n0Var = rm.n0.f34904a;
        } finally {
            aVar2.m(d10, f10, h10);
        }
    }

    private final void M(j2.g0 g0Var, Object obj, dn.p pVar) {
        HashMap hashMap = this.f20747u;
        Object obj2 = hashMap.get(g0Var);
        if (obj2 == null) {
            obj2 = new a(obj, h2.g.f20686a.a(), null, 4, null);
            hashMap.put(g0Var, obj2);
        }
        a aVar = (a) obj2;
        u2 b10 = aVar.b();
        boolean u10 = b10 != null ? b10.u() : true;
        if (aVar.c() != pVar || u10 || aVar.d()) {
            aVar.j(pVar);
            L(g0Var, aVar);
            aVar.k(false);
        }
    }

    private final u2 N(u2 u2Var, j2.g0 g0Var, boolean z10, y0.r rVar, dn.p pVar) {
        if (u2Var == null || u2Var.n()) {
            u2Var = p3.a(g0Var, rVar);
        }
        if (z10) {
            u2Var.j(pVar);
        } else {
            u2Var.i(pVar);
        }
        return u2Var;
    }

    private final j2.g0 O(Object obj) {
        int i10;
        q1 d10;
        if (this.C == 0) {
            return null;
        }
        int size = this.f20742p.M().size() - this.D;
        int i11 = size - this.C;
        int i12 = size - 1;
        int i13 = i12;
        while (true) {
            if (i13 < i11) {
                i10 = -1;
                break;
            }
            if (kotlin.jvm.internal.t.b(A(i13), obj)) {
                i10 = i13;
                break;
            }
            i13--;
        }
        if (i10 == -1) {
            while (i12 >= i11) {
                Object obj2 = this.f20747u.get((j2.g0) this.f20742p.M().get(i12));
                kotlin.jvm.internal.t.d(obj2);
                a aVar = (a) obj2;
                if (aVar.f() == y0.c() || this.f20744r.b(obj, aVar.f())) {
                    aVar.m(obj);
                    i13 = i12;
                    i10 = i13;
                    break;
                }
                i12--;
            }
            i13 = i12;
        }
        if (i10 == -1) {
            return null;
        }
        if (i13 != i11) {
            D(i13, i11, 1);
        }
        this.C--;
        j2.g0 g0Var = (j2.g0) this.f20742p.M().get(i11);
        Object obj3 = this.f20747u.get(g0Var);
        kotlin.jvm.internal.t.d(obj3);
        a aVar2 = (a) obj3;
        d10 = s3.d(Boolean.TRUE, null, 2, null);
        aVar2.h(d10);
        aVar2.l(true);
        aVar2.k(true);
        return g0Var;
    }

    private final j2.g0 v(int i10) {
        j2.g0 g0Var = new j2.g0(true, 0, 2, null);
        j2.g0 g0Var2 = this.f20742p;
        g0Var2.C = true;
        this.f20742p.B0(i10, g0Var);
        g0Var2.C = false;
        return g0Var;
    }

    private final void w() {
        j2.g0 g0Var = this.f20742p;
        g0Var.C = true;
        Iterator it = this.f20747u.values().iterator();
        while (it.hasNext()) {
            u2 b10 = ((a) it.next()).b();
            if (b10 != null) {
                b10.a();
            }
        }
        this.f20742p.m1();
        g0Var.C = false;
        this.f20747u.clear();
        this.f20748v.clear();
        this.D = 0;
        this.C = 0;
        this.f20751y.clear();
        B();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void y() {
        sm.z.E(this.A.entrySet(), new e());
    }

    public final void B() {
        int size = this.f20742p.M().size();
        if (!(this.f20747u.size() == size)) {
            throw new IllegalArgumentException(("Inconsistency between the count of nodes tracked by the state (" + this.f20747u.size() + ") and the children count on the SubcomposeLayout (" + size + "). Are you trying to use the state of the disposed SubcomposeLayout?").toString());
        }
        if ((size - this.C) - this.D >= 0) {
            if (this.f20751y.size() == this.D) {
                return;
            }
            throw new IllegalArgumentException(("Incorrect state. Precomposed children " + this.D + ". Map size " + this.f20751y.size()).toString());
        }
        throw new IllegalArgumentException(("Incorrect state. Total children " + size + ". Reusable children " + this.C + ". Precomposed children " + this.D).toString());
    }

    public final z0.a G(Object obj, dn.p pVar) {
        if (!this.f20742p.K0()) {
            return new f();
        }
        B();
        if (!this.f20748v.containsKey(obj)) {
            this.A.remove(obj);
            HashMap hashMap = this.f20751y;
            Object obj2 = hashMap.get(obj);
            if (obj2 == null) {
                obj2 = O(obj);
                if (obj2 != null) {
                    D(this.f20742p.M().indexOf(obj2), this.f20742p.M().size(), 1);
                    this.D++;
                } else {
                    obj2 = v(this.f20742p.M().size());
                    this.D++;
                }
                hashMap.put(obj, obj2);
            }
            M((j2.g0) obj2, obj, pVar);
        }
        return new g(obj);
    }

    public final void I(y0.r rVar) {
        this.f20743q = rVar;
    }

    public final void J(b1 b1Var) {
        if (this.f20744r != b1Var) {
            this.f20744r = b1Var;
            C(false);
            j2.g0.w1(this.f20742p, false, false, false, 7, null);
        }
    }

    public final List K(Object obj, dn.p pVar) {
        Object f02;
        B();
        g0.e X = this.f20742p.X();
        g0.e eVar = g0.e.Measuring;
        if (!(X == eVar || X == g0.e.LayingOut || X == g0.e.LookaheadMeasuring || X == g0.e.LookaheadLayingOut)) {
            g2.a.b("subcompose can only be used inside the measure or layout blocks");
        }
        HashMap hashMap = this.f20748v;
        Object obj2 = hashMap.get(obj);
        if (obj2 == null) {
            obj2 = (j2.g0) this.f20751y.remove(obj);
            if (obj2 != null) {
                if (!(this.D > 0)) {
                    g2.a.b("Check failed.");
                }
                this.D--;
            } else {
                obj2 = O(obj);
                if (obj2 == null) {
                    obj2 = v(this.f20745s);
                }
            }
            hashMap.put(obj, obj2);
        }
        j2.g0 g0Var = (j2.g0) obj2;
        f02 = sm.c0.f0(this.f20742p.M(), this.f20745s);
        if (f02 != g0Var) {
            int indexOf = this.f20742p.M().indexOf(g0Var);
            int i10 = this.f20745s;
            if (!(indexOf >= i10)) {
                throw new IllegalArgumentException(("Key \"" + obj + "\" was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.").toString());
            }
            if (i10 != indexOf) {
                E(this, indexOf, i10, 0, 4, null);
            }
        }
        this.f20745s++;
        M(g0Var, obj, pVar);
        return (X == eVar || X == g0.e.LayingOut) ? g0Var.G() : g0Var.F();
    }

    @Override // y0.k
    public void f() {
        w();
    }

    @Override // y0.k
    public void g() {
        C(true);
    }

    @Override // y0.k
    public void p() {
        C(false);
    }

    public final e0 u(dn.p pVar) {
        return new d(pVar, this.E);
    }

    public final void x(int i10) {
        boolean z10 = false;
        this.C = 0;
        int size = (this.f20742p.M().size() - this.D) - 1;
        if (i10 <= size) {
            this.f20752z.clear();
            if (i10 <= size) {
                int i11 = i10;
                while (true) {
                    this.f20752z.add(A(i11));
                    if (i11 == size) {
                        break;
                    } else {
                        i11++;
                    }
                }
            }
            this.f20744r.a(this.f20752z);
            k.a aVar = j1.k.f23492e;
            j1.k d10 = aVar.d();
            dn.l h10 = d10 != null ? d10.h() : null;
            j1.k f10 = aVar.f(d10);
            boolean z11 = false;
            while (size >= i10) {
                try {
                    j2.g0 g0Var = (j2.g0) this.f20742p.M().get(size);
                    Object obj = this.f20747u.get(g0Var);
                    kotlin.jvm.internal.t.d(obj);
                    a aVar2 = (a) obj;
                    Object f11 = aVar2.f();
                    if (this.f20752z.contains(f11)) {
                        this.C++;
                        if (aVar2.a()) {
                            H(g0Var);
                            aVar2.g(false);
                            z11 = true;
                        }
                    } else {
                        j2.g0 g0Var2 = this.f20742p;
                        g0Var2.C = true;
                        this.f20747u.remove(g0Var);
                        u2 b10 = aVar2.b();
                        if (b10 != null) {
                            b10.a();
                        }
                        this.f20742p.n1(size, 1);
                        g0Var2.C = false;
                    }
                    this.f20748v.remove(f11);
                    size--;
                } catch (Throwable th2) {
                    aVar.m(d10, f10, h10);
                    throw th2;
                }
            }
            rm.n0 n0Var = rm.n0.f34904a;
            aVar.m(d10, f10, h10);
            z10 = z11;
        }
        if (z10) {
            j1.k.f23492e.n();
        }
        B();
    }

    public final void z() {
        if (this.C != this.f20742p.M().size()) {
            Iterator it = this.f20747u.entrySet().iterator();
            while (it.hasNext()) {
                ((a) ((Map.Entry) it.next()).getValue()).k(true);
            }
            if (this.f20742p.e0()) {
                return;
            }
            j2.g0.w1(this.f20742p, false, false, false, 7, null);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static final class a {

        /* renamed from: a, reason: collision with root package name */
        private Object f20753a;

        /* renamed from: b, reason: collision with root package name */
        private dn.p f20754b;

        /* renamed from: c, reason: collision with root package name */
        private u2 f20755c;

        /* renamed from: d, reason: collision with root package name */
        private boolean f20756d;

        /* renamed from: e, reason: collision with root package name */
        private boolean f20757e;

        /* renamed from: f, reason: collision with root package name */
        private q1 f20758f;

        public a(Object obj, dn.p pVar, u2 u2Var) {
            q1 d10;
            this.f20753a = obj;
            this.f20754b = pVar;
            this.f20755c = u2Var;
            d10 = s3.d(Boolean.TRUE, null, 2, null);
            this.f20758f = d10;
        }

        public final boolean a() {
            return ((Boolean) this.f20758f.getValue()).booleanValue();
        }

        public final u2 b() {
            return this.f20755c;
        }

        public final dn.p c() {
            return this.f20754b;
        }

        public final boolean d() {
            return this.f20756d;
        }

        public final boolean e() {
            return this.f20757e;
        }

        public final Object f() {
            return this.f20753a;
        }

        public final void g(boolean z10) {
            this.f20758f.setValue(Boolean.valueOf(z10));
        }

        public final void h(q1 q1Var) {
            this.f20758f = q1Var;
        }

        public final void i(u2 u2Var) {
            this.f20755c = u2Var;
        }

        public final void j(dn.p pVar) {
            this.f20754b = pVar;
        }

        public final void k(boolean z10) {
            this.f20756d = z10;
        }

        public final void l(boolean z10) {
            this.f20757e = z10;
        }

        public final void m(Object obj) {
            this.f20753a = obj;
        }

        public /* synthetic */ a(Object obj, dn.p pVar, u2 u2Var, int i10, kotlin.jvm.internal.k kVar) {
            this(obj, pVar, (i10 & 4) != 0 ? null : u2Var);
        }
    }
}
