package f0;

import androidx.compose.foundation.lazy.layout.LazyLayoutItemAnimator;
import androidx.compose.foundation.lazy.layout.d;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import g0.d0;
import g0.k0;
import g0.l0;
import h2.r0;
import h2.s0;
import j1.k;
import java.util.List;
import rm.n0;
import tp.m0;
import y.f1;
import y.k1;
import y.s1;
import y0.n3;
import y0.q1;
import y0.s3;
import z.g0;

/* loaded from: classes.dex */
public final class b0 implements b0.x {

    /* renamed from: y, reason: collision with root package name */
    public static final c f17365y = new c(null);

    /* renamed from: z, reason: collision with root package name */
    private static final i1.j f17366z = i1.a.a(a.f17391p, b.f17392p);

    /* renamed from: a, reason: collision with root package name */
    private final w f17367a;

    /* renamed from: b, reason: collision with root package name */
    private boolean f17368b;

    /* renamed from: c, reason: collision with root package name */
    private s f17369c;

    /* renamed from: d, reason: collision with root package name */
    private final z f17370d;

    /* renamed from: e, reason: collision with root package name */
    private final f0.f f17371e;

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

    /* renamed from: g, reason: collision with root package name */
    private final d0.l f17373g;

    /* renamed from: h, reason: collision with root package name */
    private float f17374h;

    /* renamed from: i, reason: collision with root package name */
    private final b0.x f17375i;

    /* renamed from: j, reason: collision with root package name */
    private int f17376j;

    /* renamed from: k, reason: collision with root package name */
    private boolean f17377k;

    /* renamed from: l, reason: collision with root package name */
    private r0 f17378l;

    /* renamed from: m, reason: collision with root package name */
    private final s0 f17379m;

    /* renamed from: n, reason: collision with root package name */
    private final g0.b f17380n;

    /* renamed from: o, reason: collision with root package name */
    private final LazyLayoutItemAnimator f17381o;

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

    /* renamed from: q, reason: collision with root package name */
    private final androidx.compose.foundation.lazy.layout.d f17383q;

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

    /* renamed from: s, reason: collision with root package name */
    private final d0 f17385s;

    /* renamed from: t, reason: collision with root package name */
    private final q1 f17386t;

    /* renamed from: u, reason: collision with root package name */
    private final q1 f17387u;

    /* renamed from: v, reason: collision with root package name */
    private final q1 f17388v;

    /* renamed from: w, reason: collision with root package name */
    private final q1 f17389w;

    /* renamed from: x, reason: collision with root package name */
    private y.k f17390x;

    /* loaded from: classes.dex */
    static final class a extends kotlin.jvm.internal.v implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        public static final a f17391p = new a();

        a() {
            super(2);
        }

        @Override // dn.p
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final List invoke(i1.l lVar, b0 b0Var) {
            List n10;
            n10 = sm.u.n(Integer.valueOf(b0Var.s()), Integer.valueOf(b0Var.t()));
            return n10;
        }
    }

    /* loaded from: classes.dex */
    static final class b extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final b f17392p = new b();

        b() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final b0 invoke(List list) {
            return new b0(((Number) list.get(0)).intValue(), ((Number) list.get(1)).intValue());
        }
    }

    /* loaded from: classes.dex */
    public static final class c {
        private c() {
        }

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

        public final i1.j a() {
            return b0.f17366z;
        }
    }

    /* loaded from: classes.dex */
    public static final class d implements v {
        d() {
        }

        @Override // f0.v
        public d.b a(int i10) {
            k.a aVar = j1.k.f23492e;
            b0 b0Var = b0.this;
            j1.k d10 = aVar.d();
            dn.l h10 = d10 != null ? d10.h() : null;
            j1.k f10 = aVar.f(d10);
            try {
                long o10 = ((s) b0Var.f17372f.getValue()).o();
                aVar.m(d10, f10, h10);
                return b0.this.D().e(i10, o10);
            } catch (Throwable th2) {
                aVar.m(d10, f10, h10);
                throw th2;
            }
        }
    }

    /* loaded from: classes.dex */
    static final class e extends kotlin.jvm.internal.v implements dn.l {

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        e(int i10) {
            super(1);
            this.f17395q = i10;
        }

        public final void a(k0 k0Var) {
            w wVar = b0.this.f17367a;
            int i10 = this.f17395q;
            k.a aVar = j1.k.f23492e;
            j1.k d10 = aVar.d();
            aVar.m(d10, aVar.f(d10), d10 != null ? d10.h() : null);
            wVar.a(k0Var, i10);
        }

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

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

        @Override // h2.s0
        public void d(r0 r0Var) {
            b0.this.f17378l = r0Var;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class g extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f17397p;

        /* renamed from: q, reason: collision with root package name */
        Object f17398q;

        /* renamed from: r, reason: collision with root package name */
        Object f17399r;

        /* renamed from: s, reason: collision with root package name */
        /* synthetic */ Object f17400s;

        /* renamed from: u, reason: collision with root package name */
        int f17402u;

        g(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f17400s = obj;
            this.f17402u |= Integer.MIN_VALUE;
            return b0.this.d(null, null, this);
        }
    }

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

        /* renamed from: p, reason: collision with root package name */
        int f17403p;

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        h(int i10, int i11, vm.d dVar) {
            super(2, dVar);
            this.f17405r = i10;
            this.f17406s = i11;
        }

        @Override // dn.p
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Object invoke(b0.u uVar, vm.d dVar) {
            return ((h) create(uVar, dVar)).invokeSuspend(n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new h(this.f17405r, this.f17406s, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            wm.d.f();
            if (this.f17403p != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            rm.y.b(obj);
            b0.this.O(this.f17405r, this.f17406s, true);
            return n0.f34904a;
        }
    }

    /* loaded from: classes.dex */
    static final class i extends kotlin.jvm.internal.v implements dn.l {
        i() {
            super(1);
        }

        public final Float a(float f10) {
            return Float.valueOf(-b0.this.J(-f10));
        }

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

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

        /* renamed from: p, reason: collision with root package name */
        int f17408p;

        j(vm.d dVar) {
            super(2, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new j(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f17408p;
            if (i10 == 0) {
                rm.y.b(obj);
                y.k kVar = b0.this.f17390x;
                Float b10 = kotlin.coroutines.jvm.internal.b.b(BitmapDescriptorFactory.HUE_RED);
                f1 h10 = y.j.h(BitmapDescriptorFactory.HUE_RED, 400.0f, kotlin.coroutines.jvm.internal.b.b(0.5f), 1, null);
                this.f17408p = 1;
                if (k1.j(kVar, b10, h10, true, null, this, 8, null) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((j) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

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

        /* renamed from: p, reason: collision with root package name */
        int f17410p;

        k(vm.d dVar) {
            super(2, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new k(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f17410p;
            if (i10 == 0) {
                rm.y.b(obj);
                y.k kVar = b0.this.f17390x;
                Float b10 = kotlin.coroutines.jvm.internal.b.b(BitmapDescriptorFactory.HUE_RED);
                f1 h10 = y.j.h(BitmapDescriptorFactory.HUE_RED, 400.0f, kotlin.coroutines.jvm.internal.b.b(0.5f), 1, null);
                this.f17410p = 1;
                if (k1.j(kVar, b10, h10, true, null, this, 8, null) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((k) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    public b0(int i10, int i11, w wVar) {
        s sVar;
        q1 d10;
        q1 d11;
        y.k b10;
        this.f17367a = wVar;
        z zVar = new z(i10, i11);
        this.f17370d = zVar;
        this.f17371e = new f0.f(this);
        sVar = c0.f17413b;
        this.f17372f = n3.h(sVar, n3.j());
        this.f17373g = d0.k.a();
        this.f17375i = b0.y.a(new i());
        this.f17377k = true;
        this.f17379m = new f();
        this.f17380n = new g0.b();
        this.f17381o = new LazyLayoutItemAnimator();
        this.f17382p = new g0.j();
        this.f17383q = new androidx.compose.foundation.lazy.layout.d(wVar.c(), new e(i10));
        this.f17384r = new d();
        this.f17385s = new d0();
        zVar.b();
        this.f17386t = l0.c(null, 1, null);
        Boolean bool = Boolean.FALSE;
        d10 = s3.d(bool, null, 2, null);
        this.f17387u = d10;
        d11 = s3.d(bool, null, 2, null);
        this.f17388v = d11;
        this.f17389w = l0.c(null, 1, null);
        y.q1 f10 = s1.f(kotlin.jvm.internal.m.f26196a);
        Float valueOf = Float.valueOf(BitmapDescriptorFactory.HUE_RED);
        b10 = y.l.b(f10, valueOf, valueOf, (r19 & 8) != 0 ? Long.MIN_VALUE : 0L, (r19 & 16) != 0 ? Long.MIN_VALUE : 0L, (r19 & 32) != 0 ? false : false);
        this.f17390x = b10;
    }

    private final void I(float f10, q qVar) {
        if (this.f17377k) {
            this.f17367a.d(this.f17384r, f10, qVar);
        }
    }

    public static /* synthetic */ Object L(b0 b0Var, int i10, int i11, vm.d dVar, int i12, Object obj) {
        if ((i12 & 2) != 0) {
            i11 = 0;
        }
        return b0Var.K(i10, i11, dVar);
    }

    private void M(boolean z10) {
        this.f17388v.setValue(Boolean.valueOf(z10));
    }

    private void N(boolean z10) {
        this.f17387u.setValue(Boolean.valueOf(z10));
    }

    private final void P(float f10, c3.d dVar, m0 m0Var) {
        float f11;
        f11 = c0.f17412a;
        if (f10 <= dVar.L0(f11)) {
            return;
        }
        k.a aVar = j1.k.f23492e;
        j1.k d10 = aVar.d();
        dn.l h10 = d10 != null ? d10.h() : null;
        j1.k f12 = aVar.f(d10);
        try {
            float floatValue = ((Number) this.f17390x.getValue()).floatValue();
            if (this.f17390x.t()) {
                this.f17390x = y.l.g(this.f17390x, floatValue - f10, BitmapDescriptorFactory.HUE_RED, 0L, 0L, false, 30, null);
                tp.k.d(m0Var, null, null, new j(null), 3, null);
            } else {
                this.f17390x = new y.k(s1.f(kotlin.jvm.internal.m.f26196a), Float.valueOf(-f10), null, 0L, 0L, false, 60, null);
                tp.k.d(m0Var, null, null, new k(null), 3, null);
            }
        } finally {
            aVar.m(d10, f12, h10);
        }
    }

    public static /* synthetic */ Object m(b0 b0Var, int i10, int i11, vm.d dVar, int i12, Object obj) {
        if ((i12 & 2) != 0) {
            i11 = 0;
        }
        return b0Var.l(i10, i11, dVar);
    }

    public static /* synthetic */ void o(b0 b0Var, s sVar, boolean z10, boolean z11, int i10, Object obj) {
        if ((i10 & 4) != 0) {
            z11 = false;
        }
        b0Var.n(sVar, z10, z11);
    }

    public final d0 A() {
        return this.f17385s;
    }

    public final q1 B() {
        return this.f17389w;
    }

    public final s C() {
        return this.f17369c;
    }

    public final androidx.compose.foundation.lazy.layout.d D() {
        return this.f17383q;
    }

    public final r0 E() {
        return this.f17378l;
    }

    public final s0 F() {
        return this.f17379m;
    }

    public final float G() {
        return ((Number) this.f17390x.getValue()).floatValue();
    }

    public final float H() {
        return this.f17374h;
    }

    public final float J(float f10) {
        if ((f10 < BitmapDescriptorFactory.HUE_RED && !e()) || (f10 > BitmapDescriptorFactory.HUE_RED && !c())) {
            return BitmapDescriptorFactory.HUE_RED;
        }
        if (!(Math.abs(this.f17374h) <= 0.5f)) {
            throw new IllegalStateException(("entered drag with non-zero pending scroll: " + this.f17374h).toString());
        }
        float f11 = this.f17374h + f10;
        this.f17374h = f11;
        if (Math.abs(f11) > 0.5f) {
            s sVar = (s) this.f17372f.getValue();
            float f12 = this.f17374h;
            int round = Math.round(f12);
            s sVar2 = this.f17369c;
            boolean v10 = sVar.v(round, !this.f17368b);
            if (v10 && sVar2 != null) {
                v10 = sVar2.v(round, true);
            }
            if (v10) {
                n(sVar, this.f17368b, true);
                l0.d(this.f17389w);
                I(f12 - this.f17374h, sVar);
            } else {
                r0 r0Var = this.f17378l;
                if (r0Var != null) {
                    r0Var.i();
                }
                I(f12 - this.f17374h, x());
            }
        }
        if (Math.abs(this.f17374h) <= 0.5f) {
            return f10;
        }
        float f13 = f10 - this.f17374h;
        this.f17374h = BitmapDescriptorFactory.HUE_RED;
        return f13;
    }

    public final Object K(int i10, int i11, vm.d dVar) {
        Object f10;
        Object b10 = b0.x.b(this, null, new h(i10, i11, null), dVar, 1, null);
        f10 = wm.d.f();
        return b10 == f10 ? b10 : n0.f34904a;
    }

    public final void O(int i10, int i11, boolean z10) {
        if ((this.f17370d.a() == i10 && this.f17370d.c() == i11) ? false : true) {
            this.f17381o.n();
        }
        this.f17370d.d(i10, i11);
        if (!z10) {
            l0.d(this.f17386t);
            return;
        }
        r0 r0Var = this.f17378l;
        if (r0Var != null) {
            r0Var.i();
        }
    }

    public final int Q(m mVar, int i10) {
        return this.f17370d.j(mVar, i10);
    }

    @Override // b0.x
    public boolean a() {
        return this.f17375i.a();
    }

    @Override // b0.x
    public boolean c() {
        return ((Boolean) this.f17388v.getValue()).booleanValue();
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x006b A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0046  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0024  */
    @Override // b0.x
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object d(g0 g0Var, dn.p pVar, vm.d dVar) {
        g gVar;
        Object f10;
        int i10;
        b0.x xVar;
        if (dVar instanceof g) {
            gVar = (g) dVar;
            int i11 = gVar.f17402u;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                gVar.f17402u = i11 - Integer.MIN_VALUE;
                Object obj = gVar.f17400s;
                f10 = wm.d.f();
                i10 = gVar.f17402u;
                if (i10 != 0) {
                    rm.y.b(obj);
                    g0.b bVar = this.f17380n;
                    gVar.f17397p = this;
                    gVar.f17398q = g0Var;
                    gVar.f17399r = pVar;
                    gVar.f17402u = 1;
                    if (bVar.c(gVar) == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        if (i10 != 2) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        rm.y.b(obj);
                        return n0.f34904a;
                    }
                    pVar = (dn.p) gVar.f17399r;
                    g0Var = (g0) gVar.f17398q;
                    this = (b0) gVar.f17397p;
                    rm.y.b(obj);
                }
                xVar = this.f17375i;
                gVar.f17397p = null;
                gVar.f17398q = null;
                gVar.f17399r = null;
                gVar.f17402u = 2;
                if (xVar.d(g0Var, pVar, gVar) == f10) {
                    return f10;
                }
                return n0.f34904a;
            }
        }
        gVar = new g(dVar);
        Object obj2 = gVar.f17400s;
        f10 = wm.d.f();
        i10 = gVar.f17402u;
        if (i10 != 0) {
        }
        xVar = this.f17375i;
        gVar.f17397p = null;
        gVar.f17398q = null;
        gVar.f17399r = null;
        gVar.f17402u = 2;
        if (xVar.d(g0Var, pVar, gVar) == f10) {
        }
        return n0.f34904a;
    }

    @Override // b0.x
    public boolean e() {
        return ((Boolean) this.f17387u.getValue()).booleanValue();
    }

    @Override // b0.x
    public float f(float f10) {
        return this.f17375i.f(f10);
    }

    public final Object l(int i10, int i11, vm.d dVar) {
        Object f10;
        Object d10 = g0.g.d(this.f17371e, i10, i11, 100, r(), dVar);
        f10 = wm.d.f();
        return d10 == f10 ? d10 : n0.f34904a;
    }

    public final void n(s sVar, boolean z10, boolean z11) {
        if (!z10 && this.f17368b) {
            this.f17369c = sVar;
            return;
        }
        if (z10) {
            this.f17368b = true;
        }
        M(sVar.l());
        N(sVar.m());
        this.f17374h -= sVar.p();
        this.f17372f.setValue(sVar);
        if (z11) {
            this.f17370d.i(sVar.t());
        } else {
            this.f17370d.h(sVar);
            if (this.f17377k) {
                this.f17367a.b(this.f17384r, sVar);
            }
        }
        if (z10) {
            P(sVar.u(), sVar.r(), sVar.q());
        }
        this.f17376j++;
    }

    public final g0.b p() {
        return this.f17380n;
    }

    public final g0.j q() {
        return this.f17382p;
    }

    public final c3.d r() {
        return ((s) this.f17372f.getValue()).r();
    }

    public final int s() {
        return this.f17370d.a();
    }

    public final int t() {
        return this.f17370d.c();
    }

    public final boolean u() {
        return this.f17368b;
    }

    public final d0.l v() {
        return this.f17373g;
    }

    public final LazyLayoutItemAnimator w() {
        return this.f17381o;
    }

    public final q x() {
        return (q) this.f17372f.getValue();
    }

    public final q1 y() {
        return this.f17386t;
    }

    public final jn.i z() {
        return (jn.i) this.f17370d.b().getValue();
    }

    public b0(int i10, int i11) {
        this(i10, i11, x.b(0, 1, null));
    }
}
