package y0;

import com.google.android.gms.common.api.Api;
import j1.k;
import y0.i0;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class h0 extends j1.y implements i0 {

    /* renamed from: q, reason: collision with root package name */
    private final dn.a f51556q;

    /* renamed from: r, reason: collision with root package name */
    private final m3 f51557r;

    /* renamed from: s, reason: collision with root package name */
    private a f51558s = new a();

    /* loaded from: classes.dex */
    public static final class a extends j1.z implements i0.a {

        /* renamed from: h, reason: collision with root package name */
        public static final C1032a f51559h = new C1032a(null);

        /* renamed from: i, reason: collision with root package name */
        public static final int f51560i = 8;

        /* renamed from: j, reason: collision with root package name */
        private static final Object f51561j = new Object();

        /* renamed from: c, reason: collision with root package name */
        private int f51562c;

        /* renamed from: d, reason: collision with root package name */
        private int f51563d;

        /* renamed from: e, reason: collision with root package name */
        private androidx.collection.j0 f51564e = androidx.collection.k0.a();

        /* renamed from: f, reason: collision with root package name */
        private Object f51565f = f51561j;

        /* renamed from: g, reason: collision with root package name */
        private int f51566g;

        /* renamed from: y0.h0$a$a, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public static final class C1032a {
            private C1032a() {
            }

            public /* synthetic */ C1032a(kotlin.jvm.internal.k kVar) {
                this();
            }

            public final Object a() {
                return a.f51561j;
            }
        }

        @Override // y0.i0.a
        public Object a() {
            return this.f51565f;
        }

        @Override // y0.i0.a
        public androidx.collection.j0 b() {
            return this.f51564e;
        }

        @Override // j1.z
        public void c(j1.z zVar) {
            kotlin.jvm.internal.t.e(zVar, "null cannot be cast to non-null type androidx.compose.runtime.DerivedSnapshotState.ResultRecord<T of androidx.compose.runtime.DerivedSnapshotState.ResultRecord>");
            a aVar = (a) zVar;
            m(aVar.b());
            this.f51565f = aVar.f51565f;
            this.f51566g = aVar.f51566g;
        }

        @Override // j1.z
        public j1.z d() {
            return new a();
        }

        public final Object j() {
            return this.f51565f;
        }

        public final boolean k(i0 i0Var, j1.k kVar) {
            boolean z10;
            boolean z11;
            synchronized (j1.p.I()) {
                z10 = false;
                if (this.f51562c == kVar.f()) {
                    if (this.f51563d == kVar.j()) {
                        z11 = false;
                    }
                }
                z11 = true;
            }
            if (this.f51565f != f51561j && (!z11 || this.f51566g == l(i0Var, kVar))) {
                z10 = true;
            }
            if (z10 && z11) {
                synchronized (j1.p.I()) {
                    this.f51562c = kVar.f();
                    this.f51563d = kVar.j();
                    rm.n0 n0Var = rm.n0.f34904a;
                }
            }
            return z10;
        }

        public final int l(i0 i0Var, j1.k kVar) {
            androidx.collection.j0 b10;
            int i10;
            int i11;
            synchronized (j1.p.I()) {
                b10 = b();
            }
            char c10 = 7;
            if (!b10.g()) {
                return 7;
            }
            a1.b c11 = n3.c();
            int q10 = c11.q();
            if (q10 > 0) {
                Object[] p10 = c11.p();
                int i12 = 0;
                do {
                    ((j0) p10[i12]).a(i0Var);
                    i12++;
                } while (i12 < q10);
            }
            try {
                Object[] objArr = b10.f1332b;
                int[] iArr = b10.f1333c;
                long[] jArr = b10.f1331a;
                int length = jArr.length - 2;
                if (length >= 0) {
                    int i13 = 7;
                    int i14 = 0;
                    while (true) {
                        long j10 = jArr[i14];
                        if ((((~j10) << c10) & j10 & (-9187201950435737472L)) != -9187201950435737472L) {
                            int i15 = 8;
                            int i16 = 8 - ((~(i14 - length)) >>> 31);
                            int i17 = 0;
                            while (i17 < i16) {
                                if ((j10 & 255) < 128) {
                                    int i18 = (i14 << 3) + i17;
                                    j1.x xVar = (j1.x) objArr[i18];
                                    if (iArr[i18] == 1) {
                                        j1.z u10 = xVar instanceof h0 ? ((h0) xVar).u(kVar) : j1.p.G(xVar.g(), kVar);
                                        i13 = (((i13 * 31) + c.c(u10)) * 31) + u10.f();
                                    }
                                    i11 = 8;
                                } else {
                                    i11 = i15;
                                }
                                j10 >>= i11;
                                i17++;
                                i15 = i11;
                            }
                            if (i16 != i15) {
                                break;
                            }
                        }
                        if (i14 == length) {
                            break;
                        }
                        i14++;
                        c10 = 7;
                    }
                    i10 = i13;
                } else {
                    i10 = 7;
                }
                rm.n0 n0Var = rm.n0.f34904a;
                int q11 = c11.q();
                if (q11 <= 0) {
                    return i10;
                }
                Object[] p11 = c11.p();
                int i19 = 0;
                do {
                    ((j0) p11[i19]).b(i0Var);
                    i19++;
                } while (i19 < q11);
                return i10;
            } catch (Throwable th2) {
                int q12 = c11.q();
                if (q12 > 0) {
                    Object[] p12 = c11.p();
                    int i20 = 0;
                    do {
                        ((j0) p12[i20]).b(i0Var);
                        i20++;
                    } while (i20 < q12);
                }
                throw th2;
            }
        }

        public void m(androidx.collection.j0 j0Var) {
            this.f51564e = j0Var;
        }

        public final void n(Object obj) {
            this.f51565f = obj;
        }

        public final void o(int i10) {
            this.f51566g = i10;
        }

        public final void p(int i10) {
            this.f51562c = i10;
        }

        public final void q(int i10) {
            this.f51563d = i10;
        }
    }

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

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ g1.d f51568q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ androidx.collection.d0 f51569r;

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(g1.d dVar, androidx.collection.d0 d0Var, int i10) {
            super(1);
            this.f51568q = dVar;
            this.f51569r = d0Var;
            this.f51570s = i10;
        }

        public final void a(Object obj) {
            if (obj == h0.this) {
                throw new IllegalStateException("A derived state calculation cannot read itself".toString());
            }
            if (obj instanceof j1.x) {
                int a10 = this.f51568q.a();
                androidx.collection.d0 d0Var = this.f51569r;
                d0Var.r(obj, Math.min(a10 - this.f51570s, d0Var.d(obj, Api.BaseClientBuilder.API_PRIORITY_OTHER)));
            }
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a(obj);
            return rm.n0.f34904a;
        }
    }

    public h0(dn.a aVar, m3 m3Var) {
        this.f51556q = aVar;
        this.f51557r = m3Var;
    }

    /* JADX WARN: Finally extract failed */
    private final a w(a aVar, j1.k kVar, boolean z10, dn.a aVar2) {
        t3 t3Var;
        k.a aVar3;
        t3 t3Var2;
        t3 t3Var3;
        t3 t3Var4;
        int i10;
        t3 t3Var5;
        a aVar4 = aVar;
        boolean z11 = true;
        if (!aVar4.k(this, kVar)) {
            int i11 = 0;
            androidx.collection.d0 d0Var = new androidx.collection.d0(0, 1, null);
            t3Var = o3.f51741a;
            g1.d dVar = (g1.d) t3Var.a();
            if (dVar == null) {
                dVar = new g1.d(0);
                t3Var3 = o3.f51741a;
                t3Var3.b(dVar);
            }
            int a10 = dVar.a();
            a1.b c10 = n3.c();
            int q10 = c10.q();
            if (q10 > 0) {
                Object[] p10 = c10.p();
                int i12 = 0;
                while (true) {
                    ((j0) p10[i12]).a(this);
                    int i13 = i12 + 1;
                    if (i13 >= q10) {
                        break;
                    }
                    i12 = i13;
                }
            }
            try {
                dVar.b(a10 + 1);
                Object h10 = j1.k.f23492e.h(new b(dVar, d0Var, a10), null, aVar2);
                dVar.b(a10);
                int q11 = c10.q();
                if (q11 > 0) {
                    Object[] p11 = c10.p();
                    int i14 = 0;
                    while (true) {
                        ((j0) p11[i14]).b(this);
                        int i15 = i14 + 1;
                        if (i15 >= q11) {
                            break;
                        }
                        i14 = i15;
                    }
                }
                synchronized (j1.p.I()) {
                    aVar3 = j1.k.f23492e;
                    j1.k c11 = aVar3.c();
                    if (aVar.j() != a.f51559h.a()) {
                        m3 c12 = c();
                        if (c12 != null && c12.a(h10, aVar.j())) {
                            aVar4.m(d0Var);
                            aVar4.o(aVar4.l(this, c11));
                        }
                    }
                    aVar4 = (a) j1.p.O(this.f51558s, this, c11);
                    aVar4.m(d0Var);
                    aVar4.o(aVar4.l(this, c11));
                    aVar4.n(h10);
                }
                t3Var2 = o3.f51741a;
                g1.d dVar2 = (g1.d) t3Var2.a();
                if (dVar2 != null && dVar2.a() == 0) {
                    aVar3.g();
                    synchronized (j1.p.I()) {
                        j1.k c13 = aVar3.c();
                        aVar4.p(c13.f());
                        aVar4.q(c13.j());
                        rm.n0 n0Var = rm.n0.f34904a;
                    }
                }
                return aVar4;
            } catch (Throwable th2) {
                int q12 = c10.q();
                if (q12 > 0) {
                    Object[] p12 = c10.p();
                    do {
                        ((j0) p12[i11]).b(this);
                        i11++;
                    } while (i11 < q12);
                }
                throw th2;
            }
        }
        if (z10) {
            a1.b c14 = n3.c();
            int q13 = c14.q();
            if (q13 > 0) {
                Object[] p13 = c14.p();
                int i16 = 0;
                do {
                    ((j0) p13[i16]).a(this);
                    i16++;
                } while (i16 < q13);
            }
            try {
                androidx.collection.j0 b10 = aVar.b();
                t3Var4 = o3.f51741a;
                g1.d dVar3 = (g1.d) t3Var4.a();
                if (dVar3 == null) {
                    dVar3 = new g1.d(0);
                    t3Var5 = o3.f51741a;
                    t3Var5.b(dVar3);
                }
                int a11 = dVar3.a();
                Object[] objArr = b10.f1332b;
                int[] iArr = b10.f1333c;
                long[] jArr = b10.f1331a;
                int length = jArr.length - 2;
                if (length >= 0) {
                    int i17 = 0;
                    while (true) {
                        long j10 = jArr[i17];
                        long[] jArr2 = jArr;
                        if ((((~j10) << 7) & j10 & (-9187201950435737472L)) != -9187201950435737472L) {
                            int i18 = 8;
                            int i19 = 8 - ((~(i17 - length)) >>> 31);
                            int i20 = 0;
                            while (i20 < i19) {
                                if ((j10 & 255) < 128 ? z11 : false) {
                                    int i21 = (i17 << 3) + i20;
                                    j1.x xVar = (j1.x) objArr[i21];
                                    dVar3.b(a11 + iArr[i21]);
                                    dn.l h11 = kVar.h();
                                    if (h11 != null) {
                                        h11.invoke(xVar);
                                    }
                                    i10 = 8;
                                } else {
                                    i10 = i18;
                                }
                                j10 >>= i10;
                                i20++;
                                i18 = i10;
                                z11 = true;
                            }
                            if (i19 != i18) {
                                break;
                            }
                        }
                        if (i17 == length) {
                            break;
                        }
                        i17++;
                        jArr = jArr2;
                        z11 = true;
                    }
                }
                dVar3.b(a11);
                rm.n0 n0Var2 = rm.n0.f34904a;
                int q14 = c14.q();
                if (q14 > 0) {
                    Object[] p14 = c14.p();
                    int i22 = 0;
                    do {
                        ((j0) p14[i22]).b(this);
                        i22++;
                    } while (i22 < q14);
                }
            } catch (Throwable th3) {
                int q15 = c14.q();
                if (q15 > 0) {
                    Object[] p15 = c14.p();
                    int i23 = 0;
                    do {
                        ((j0) p15[i23]).b(this);
                        i23++;
                    } while (i23 < q15);
                }
                throw th3;
            }
        }
        return aVar4;
    }

    private final String x() {
        a aVar = (a) j1.p.F(this.f51558s);
        return aVar.k(this, j1.k.f23492e.c()) ? String.valueOf(aVar.j()) : "<Not calculated>";
    }

    @Override // y0.i0
    public m3 c() {
        return this.f51557r;
    }

    @Override // j1.x
    public j1.z g() {
        return this.f51558s;
    }

    @Override // y0.y3
    public Object getValue() {
        k.a aVar = j1.k.f23492e;
        dn.l h10 = aVar.c().h();
        if (h10 != null) {
            h10.invoke(this);
        }
        j1.k c10 = aVar.c();
        return w((a) j1.p.G(this.f51558s, c10), c10, true, this.f51556q).j();
    }

    @Override // y0.i0
    public i0.a p() {
        j1.k c10 = j1.k.f23492e.c();
        return w((a) j1.p.G(this.f51558s, c10), c10, false, this.f51556q);
    }

    @Override // j1.x
    public void r(j1.z zVar) {
        kotlin.jvm.internal.t.e(zVar, "null cannot be cast to non-null type androidx.compose.runtime.DerivedSnapshotState.ResultRecord<T of androidx.compose.runtime.DerivedSnapshotState>");
        this.f51558s = (a) zVar;
    }

    public String toString() {
        return "DerivedState(value=" + x() + ")@" + hashCode();
    }

    public final j1.z u(j1.k kVar) {
        return w((a) j1.p.G(this.f51558s, kVar), kVar, false, this.f51556q);
    }
}
