package g0;

import g0.d;
import g0.o;

/* loaded from: classes.dex */
public final class j0 implements androidx.compose.foundation.lazy.layout.c {

    /* renamed from: b, reason: collision with root package name */
    private final androidx.collection.j0 f18940b;

    /* renamed from: c, reason: collision with root package name */
    private final Object[] f18941c;

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

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

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

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

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(int i10, int i11, androidx.collection.d0 d0Var, j0 j0Var) {
            super(1);
            this.f18943p = i10;
            this.f18944q = i11;
            this.f18945r = d0Var;
            this.f18946s = j0Var;
        }

        /* JADX WARN: Code restructure failed: missing block: B:5:0x0037, code lost:
        
            if (r3 == null) goto L7;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void a(d.a aVar) {
            Object a10;
            dn.l key = ((o.a) aVar.c()).getKey();
            int max = Math.max(this.f18943p, aVar.b());
            int min = Math.min(this.f18944q, (aVar.b() + aVar.a()) - 1);
            if (max > min) {
                return;
            }
            while (true) {
                if (key != null) {
                    a10 = key.invoke(Integer.valueOf(max - aVar.b()));
                }
                a10 = h0.a(max);
                this.f18945r.r(a10, max);
                this.f18946s.f18941c[max - this.f18946s.f18942d] = a10;
                if (max == min) {
                    return;
                } else {
                    max++;
                }
            }
        }

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

    public j0(jn.i iVar, o oVar) {
        d e10 = oVar.e();
        int g10 = iVar.g();
        if (!(g10 >= 0)) {
            throw new IllegalStateException("negative nearestRange.first".toString());
        }
        int min = Math.min(iVar.m(), e10.a() - 1);
        if (min < g10) {
            this.f18940b = androidx.collection.k0.a();
            this.f18941c = new Object[0];
            this.f18942d = 0;
        } else {
            int i10 = (min - g10) + 1;
            this.f18941c = new Object[i10];
            this.f18942d = g10;
            androidx.collection.d0 d0Var = new androidx.collection.d0(i10);
            e10.b(g10, min, new a(g10, min, d0Var, this));
            this.f18940b = d0Var;
        }
    }

    @Override // androidx.compose.foundation.lazy.layout.c
    public Object b(int i10) {
        int Z;
        Object[] objArr = this.f18941c;
        int i11 = i10 - this.f18942d;
        if (i11 >= 0) {
            Z = sm.p.Z(objArr);
            if (i11 <= Z) {
                return objArr[i11];
            }
        }
        return null;
    }

    @Override // androidx.compose.foundation.lazy.layout.c
    public int c(Object obj) {
        androidx.collection.j0 j0Var = this.f18940b;
        int a10 = j0Var.a(obj);
        if (a10 >= 0) {
            return j0Var.f1333c[a10];
        }
        return -1;
    }
}
