package o;

import android.util.SparseArray;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.l10, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1729l10 {
    public final ArrayList a;
    public ArrayList b;
    public final ArrayList c;
    public final List d;
    public int e;
    public int f;
    public C1634k10 g;
    public final /* synthetic */ RecyclerView h;

    public C1729l10(RecyclerView recyclerView) {
        this.h = recyclerView;
        ArrayList arrayList = new ArrayList();
        this.a = arrayList;
        this.b = null;
        this.c = new ArrayList();
        this.d = Collections.unmodifiableList(arrayList);
        this.e = 2;
        this.f = 2;
    }

    public final void a(AbstractC2488t10 abstractC2488t10, boolean z) {
        RecyclerView.j(abstractC2488t10);
        View view = abstractC2488t10.a;
        RecyclerView recyclerView = this.h;
        C2678v10 c2678v10 = recyclerView.u0;
        if (c2678v10 != null) {
            C2583u10 c2583u10 = c2678v10.e;
            Oj0.m(view, c2583u10 != null ? (C2011o0) c2583u10.e.remove(view) : null);
        }
        if (z && recyclerView.n0 != null) {
            recyclerView.q.C(abstractC2488t10);
        }
        abstractC2488t10.r = null;
        C1634k10 c1634k10C = c();
        c1634k10C.getClass();
        int i = abstractC2488t10.f;
        ArrayList arrayList = c1634k10C.a(i).a;
        if (((C1539j10) c1634k10C.a.get(i)).b <= arrayList.size()) {
            return;
        }
        abstractC2488t10.m();
        arrayList.add(abstractC2488t10);
    }

    public final int b(int i) {
        RecyclerView recyclerView = this.h;
        if (i >= 0 && i < recyclerView.n0.b()) {
            return !recyclerView.n0.g ? i : recyclerView.f19o.n(i, 0);
        }
        StringBuilder sbO = AbstractC0126Ew.o(i, "invalid position ", ". State item count is ");
        sbO.append(recyclerView.n0.b());
        sbO.append(recyclerView.y());
        throw new IndexOutOfBoundsException(sbO.toString());
    }

    public final C1634k10 c() {
        if (this.g == null) {
            C1634k10 c1634k10 = new C1634k10();
            c1634k10.a = new SparseArray();
            c1634k10.b = 0;
            this.g = c1634k10;
        }
        return this.g;
    }

    public final void d() {
        ArrayList arrayList = this.c;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            e(size);
        }
        arrayList.clear();
        int[] iArr = RecyclerView.D0;
        C2642ui c2642ui = this.h.m0;
        int[] iArr2 = (int[]) c2642ui.e;
        if (iArr2 != null) {
            Arrays.fill(iArr2, -1);
        }
        c2642ui.d = 0;
    }

    public final void e(int i) {
        ArrayList arrayList = this.c;
        a((AbstractC2488t10) arrayList.get(i), true);
        arrayList.remove(i);
    }

    public final void f(View view) {
        AbstractC2488t10 abstractC2488t10I = RecyclerView.I(view);
        boolean zJ = abstractC2488t10I.j();
        RecyclerView recyclerView = this.h;
        if (zJ) {
            recyclerView.removeDetachedView(view, false);
        }
        if (abstractC2488t10I.i()) {
            abstractC2488t10I.n.j(abstractC2488t10I);
        } else if (abstractC2488t10I.p()) {
            abstractC2488t10I.j &= -33;
        }
        g(abstractC2488t10I);
        if (recyclerView.S == null || abstractC2488t10I.g()) {
            return;
        }
        recyclerView.S.d(abstractC2488t10I);
    }

    /* JADX WARN: Code restructure failed: missing block: B:46:0x0095, code lost:
    
        r6 = r6 - 1;
     */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0032  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0078  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void g(o.AbstractC2488t10 r12) {
        /*
            Method dump skipped, instructions count: 284
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1729l10.g(o.t10):void");
    }

    public final void h(View view) {
        AbstractC0775b10 abstractC0775b10;
        AbstractC2488t10 abstractC2488t10I = RecyclerView.I(view);
        int i = abstractC2488t10I.j & 12;
        RecyclerView recyclerView = this.h;
        if (i == 0 && abstractC2488t10I.k() && (abstractC0775b10 = recyclerView.S) != null) {
            C1899mq c1899mq = (C1899mq) abstractC0775b10;
            if (abstractC2488t10I.c().isEmpty() && c1899mq.g && !abstractC2488t10I.f()) {
                if (this.b == null) {
                    this.b = new ArrayList();
                }
                abstractC2488t10I.n = this;
                abstractC2488t10I.f724o = true;
                this.b.add(abstractC2488t10I);
                return;
            }
        }
        if (abstractC2488t10I.f() && !abstractC2488t10I.h() && !recyclerView.v.b) {
            throw new IllegalArgumentException("Called scrap view with an invalid view. Invalid views cannot be reused from scrap, they should rebound from recycler pool." + recyclerView.y());
        }
        abstractC2488t10I.n = this;
        abstractC2488t10I.f724o = false;
        this.a.add(abstractC2488t10I);
    }

    /* JADX WARN: Removed duplicated region for block: B:110:0x01d5  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x01d7  */
    /* JADX WARN: Removed duplicated region for block: B:178:0x0323  */
    /* JADX WARN: Removed duplicated region for block: B:180:0x0326  */
    /* JADX WARN: Removed duplicated region for block: B:253:0x0472  */
    /* JADX WARN: Removed duplicated region for block: B:299:0x052a  */
    /* JADX WARN: Removed duplicated region for block: B:300:0x0534  */
    /* JADX WARN: Removed duplicated region for block: B:306:0x054a A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:308:0x054d  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x007e  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0080  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.AbstractC2488t10 i(int r28, long r29) {
        /*
            Method dump skipped, instructions count: 1408
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1729l10.i(int, long):o.t10");
    }

    public final void j(AbstractC2488t10 abstractC2488t10) {
        if (abstractC2488t10.f724o) {
            this.b.remove(abstractC2488t10);
        } else {
            this.a.remove(abstractC2488t10);
        }
        abstractC2488t10.n = null;
        abstractC2488t10.f724o = false;
        abstractC2488t10.j &= -33;
    }

    public final void k() {
        AbstractC1157f10 abstractC1157f10 = this.h.w;
        this.f = this.e + (abstractC1157f10 != null ? abstractC1157f10.j : 0);
        ArrayList arrayList = this.c;
        for (int size = arrayList.size() - 1; size >= 0 && arrayList.size() > this.f; size--) {
            e(size);
        }
    }
}
