package D;

import B.V;
import B.h1;
import F.AbstractC0158l;
import F.C0150d;
import F.C0156j;
import F.C0167v;
import F.N;
import F.P;
import F.Q;
import F.U;
import V4.B0;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.saveable.ListSaverKt;
import androidx.compose.runtime.saveable.Saver;
import androidx.compose.runtime.snapshots.Snapshot;
import m3.AbstractC2467b;
import q.AbstractC2771e;
import q.C2789n;
import v.z0;
import w4.C3137A;
import x.C3189q;
import x.InterfaceC3146a1;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public final class H implements InterfaceC3146a1 {

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final Saver f766x = ListSaverKt.listSaver(new A4.b(5), new h1(4));

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final B f771e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final MutableState f772f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final z.m f773g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public float f774h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final C3189q f775i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final boolean f776j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public I0.H f777k;
    public final E l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final C0150d f778m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final C0167v f779n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final C0156j f780o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final Q f781p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final D f782q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final N f783r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final MutableState f784s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final MutableState f785t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final MutableState f786u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final MutableState f787v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final U f788w;

    public H(int i6, int i7) {
        C0130a c0130a = new C0130a();
        c0130a.f790a = -1;
        c0130a.f792c = -1;
        this.f767a = c0130a;
        this.f771e = new B(i6, i7, 0);
        this.f772f = SnapshotStateKt.mutableStateOf(J.f789a, SnapshotStateKt.neverEqualPolicy());
        this.f773g = new z.m();
        this.f775i = new C3189q(new V(this, 4));
        this.f776j = true;
        this.l = new E(this, 0);
        this.f778m = new C0150d();
        this.f779n = new C0167v();
        this.f780o = new C0156j();
        this.f781p = new Q(new C(this, i6, 0));
        this.f782q = new D(this);
        this.f783r = new N();
        this.f784s = AbstractC0158l.k();
        Boolean bool = Boolean.FALSE;
        this.f785t = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(bool, null, 2, null);
        this.f786u = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(bool, null, 2, null);
        this.f787v = AbstractC0158l.k();
        this.f788w = new U();
    }

    public static Object k(H h5, int i6, A4.d dVar) {
        h5.getClass();
        Object objE = h5.e(z0.f24987a, new G(h5, i6, 0, null), dVar);
        return objE == B4.a.f492a ? objE : C3137A.f25453a;
    }

    @Override // x.InterfaceC3146a1
    public final boolean a() {
        return this.f775i.a();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // x.InterfaceC3146a1
    public final boolean b() {
        return ((Boolean) this.f786u.getValue()).booleanValue();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // x.InterfaceC3146a1
    public final boolean c() {
        return ((Boolean) this.f785t.getValue()).booleanValue();
    }

    @Override // x.InterfaceC3146a1
    public final float d(float f6) {
        return this.f775i.d(f6);
    }

    /* JADX WARN: Code restructure failed: missing block: B:22:0x0063, code lost:
    
        if (r5.f775i.e(r6, r7, r0) == r1) goto L23;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @Override // x.InterfaceC3146a1
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object e(z0 z0Var, J4.e eVar, A4.d dVar) {
        F f6;
        if (dVar instanceof F) {
            f6 = (F) dVar;
            int i6 = f6.f762e;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                f6.f762e = i6 - Integer.MIN_VALUE;
            } else {
                f6 = new F(this, dVar);
            }
        }
        Object obj = f6.f760c;
        B4.a aVar = B4.a.f492a;
        int i7 = f6.f762e;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            if (this.f772f.getValue() == J.f789a) {
                f6.f758a = z0Var;
                f6.f759b = eVar;
                f6.f762e = 1;
                if (this.f778m.d(f6) != aVar) {
                }
                return aVar;
            }
        } else {
            if (i7 != 1) {
                if (i7 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                return C3137A.f25453a;
            }
            eVar = f6.f759b;
            z0Var = f6.f758a;
            AbstractC2467b.l(obj);
        }
        f6.f758a = null;
        f6.f759b = null;
        f6.f762e = 2;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v0, types: [java.lang.Object, java.util.Collection, java.util.List] */
    public final void f(w wVar, boolean z6, boolean z7) {
        String str;
        long j4;
        ?? r22 = wVar.f901k;
        this.f781p.f1223e = r22.size();
        U u6 = this.f788w;
        B b5 = this.f771e;
        int i6 = wVar.f892b;
        x xVar = wVar.f891a;
        if (!z6 && this.f768b) {
            this.f769c = wVar;
            Snapshot.Companion companion = Snapshot.Companion;
            Snapshot currentThreadSnapshot = companion.getCurrentThreadSnapshot();
            J4.c readObserver = currentThreadSnapshot != null ? currentThreadSnapshot.getReadObserver() : null;
            Snapshot snapshotMakeCurrentNonObservable = companion.makeCurrentNonObservable(currentThreadSnapshot);
            try {
                if (((Number) u6.f1229b.f23390b.getValue()).floatValue() != 0.0f && xVar != null && xVar.f907a == b5.f747b.getIntValue() && i6 == b5.f748c.getIntValue()) {
                    B0 b02 = u6.f1228a;
                    if (b02 != null) {
                        b02.cancel(null);
                    }
                    u6.f1229b = new C2789n(AbstractC2771e.f23306j, Float.valueOf(0.0f), null, 60);
                }
                return;
            } finally {
                companion.restoreNonObservable(currentThreadSnapshot, snapshotMakeCurrentNonObservable, readObserver);
            }
        }
        if (z6) {
            this.f768b = true;
        }
        this.f786u.setValue(Boolean.valueOf(((xVar != null ? xVar.f907a : 0) == 0 && i6 == 0) ? false : true));
        this.f785t.setValue(Boolean.valueOf(wVar.f893c));
        this.f774h -= wVar.f894d;
        this.f772f.setValue(wVar);
        if (z7) {
            b5.getClass();
            if (!(((float) i6) >= 0.0f)) {
                A.b.c("scrollOffset should be non-negative");
            }
            b5.f748c.setIntValue(i6);
        } else {
            x xVar2 = (x) AbstractC3251q.g0(r22);
            x xVar3 = (x) AbstractC3251q.o0(r22);
            if (xVar2 != null) {
                str = "scrollOffset should be non-negative";
                j4 = xVar2.f907a;
            } else {
                str = "scrollOffset should be non-negative";
                j4 = -1;
            }
            W.a.B0("firstVisibleItem:index", j4);
            W.a.B0("lastVisibleItem:index", xVar3 != null ? xVar3.f907a : -1L);
            b5.getClass();
            b5.f750e = xVar != null ? xVar.f915i : null;
            boolean z8 = b5.f749d;
            int i7 = wVar.f903n;
            if (z8 || i7 > 0) {
                b5.f749d = true;
                if (!(((float) i6) >= 0.0f)) {
                    A.b.c(str);
                }
                b5.a(xVar != null ? xVar.f907a : 0, i6);
            }
            if (this.f776j) {
                C0130a c0130a = this.f767a;
                int i8 = c0130a.f790a;
                boolean z9 = c0130a.f791b;
                if (i8 != -1 && !r22.isEmpty() && i8 != C0130a.b(wVar, z9)) {
                    c0130a.f790a = -1;
                    P p6 = (P) c0130a.f794e;
                    if (p6 != null) {
                        p6.cancel();
                    }
                    c0130a.f794e = null;
                }
                int i9 = c0130a.f792c;
                if (i9 != -1 && c0130a.f793d != 0.0f && i9 != i7 && !r22.isEmpty()) {
                    int iB = C0130a.b(wVar, c0130a.f793d < 0.0f);
                    if (iB >= 0 && iB < i7) {
                        c0130a.f790a = iB;
                        c0130a.f794e = y.a(this.f782q, iB);
                    }
                }
                c0130a.f792c = i7;
            }
        }
        if (z6) {
            u6.a(wVar.f896f, wVar.f899i, wVar.f898h);
        }
    }

    public final int g() {
        return this.f771e.f747b.getIntValue();
    }

    public final int h() {
        return this.f771e.f748c.getIntValue();
    }

    public final w i() {
        return (w) this.f772f.getValue();
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [java.lang.Object, java.util.Collection] */
    /* JADX WARN: Type inference failed for: r2v1, types: [java.lang.Object, java.util.List] */
    public final void j(float f6, w wVar) {
        P p6;
        P p7;
        if (this.f776j) {
            C0130a c0130a = this.f767a;
            c0130a.getClass();
            if (!wVar.f901k.isEmpty()) {
                boolean z6 = f6 < 0.0f;
                int iB = C0130a.b(wVar, z6);
                if (iB >= 0 && iB < wVar.f903n) {
                    if (iB != c0130a.f790a) {
                        if (c0130a.f791b != z6) {
                            c0130a.f790a = -1;
                            P p8 = (P) c0130a.f794e;
                            if (p8 != null) {
                                p8.cancel();
                            }
                            c0130a.f794e = null;
                        }
                        c0130a.f791b = z6;
                        c0130a.f790a = iB;
                        c0130a.f794e = y.a(this.f782q, iB);
                    }
                    ?? r22 = wVar.f901k;
                    if (z6) {
                        x xVar = (x) AbstractC3251q.n0(r22);
                        if (((xVar.l + xVar.f918m) + wVar.f906q) - wVar.f902m < (-f6) && (p7 = (P) c0130a.f794e) != null) {
                            p7.a();
                        }
                    } else if (wVar.l - ((x) AbstractC3251q.e0(r22)).l < f6 && (p6 = (P) c0130a.f794e) != null) {
                        p6.a();
                    }
                }
            }
            c0130a.f793d = f6;
        }
    }
}
