package f0;

import androidx.compose.foundation.lazy.layout.d;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import g0.k0;

/* loaded from: classes.dex */
final class a implements w {

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

    /* renamed from: b, reason: collision with root package name */
    private int f17340b = -1;

    /* renamed from: c, reason: collision with root package name */
    private d.b f17341c;

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

    public a(int i10) {
        this.f17339a = i10;
    }

    @Override // f0.w
    public void a(k0 k0Var, int i10) {
        int i11 = this.f17339a;
        for (int i12 = 0; i12 < i11; i12++) {
            k0Var.a(i10 + i12);
        }
    }

    @Override // f0.w
    public void b(v vVar, q qVar) {
        Object c02;
        int index;
        Object o02;
        if (this.f17340b == -1 || !(!qVar.k().isEmpty())) {
            return;
        }
        if (this.f17342d) {
            o02 = sm.c0.o0(qVar.k());
            index = ((l) o02).getIndex() + 1;
        } else {
            c02 = sm.c0.c0(qVar.k());
            index = ((l) c02).getIndex() - 1;
        }
        if (this.f17340b != index) {
            this.f17340b = -1;
            d.b bVar = this.f17341c;
            if (bVar != null) {
                bVar.cancel();
            }
            this.f17341c = null;
        }
    }

    @Override // f0.w
    public void d(v vVar, float f10, q qVar) {
        Object c02;
        int index;
        Object c03;
        d.b bVar;
        Object o02;
        d.b bVar2;
        d.b bVar3;
        Object o03;
        if (!qVar.k().isEmpty()) {
            boolean z10 = f10 < BitmapDescriptorFactory.HUE_RED;
            if (z10) {
                o03 = sm.c0.o0(qVar.k());
                index = ((l) o03).getIndex() + 1;
            } else {
                c02 = sm.c0.c0(qVar.k());
                index = ((l) c02).getIndex() - 1;
            }
            if (index >= 0 && index < qVar.g()) {
                if (index != this.f17340b) {
                    if (this.f17342d != z10 && (bVar3 = this.f17341c) != null) {
                        bVar3.cancel();
                    }
                    this.f17342d = z10;
                    this.f17340b = index;
                    this.f17341c = vVar.a(index);
                }
                if (!z10) {
                    c03 = sm.c0.c0(qVar.k());
                    if (qVar.f() - ((l) c03).b() >= f10 || (bVar = this.f17341c) == null) {
                        return;
                    }
                    bVar.b();
                    return;
                }
                o02 = sm.c0.o0(qVar.k());
                l lVar = (l) o02;
                if (((lVar.b() + lVar.a()) + qVar.j()) - qVar.c() >= (-f10) || (bVar2 = this.f17341c) == null) {
                    return;
                }
                bVar2.b();
            }
        }
    }
}
