package u0;

import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import w.C1083d;
import w.C1084e;
import y2.C1113a;
import z.C1121e;

/* JADX INFO: renamed from: u0.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1040b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f10150a;

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

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

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

    public /* synthetic */ C1040b(int i) {
        this.f10150a = i;
    }

    public void a(int i, View view, boolean z5) {
        RecyclerView recyclerView = ((C1061x) this.f10151b).f10308a;
        int childCount = i < 0 ? recyclerView.getChildCount() : j(i);
        ((L1.T) this.f10152c).e(childCount, z5);
        if (z5) {
            m(view);
        }
        recyclerView.addView(view, childCount);
        RecyclerView.H(view);
    }

    public void b(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z5) {
        RecyclerView recyclerView = ((C1061x) this.f10151b).f10308a;
        int childCount = i < 0 ? recyclerView.getChildCount() : j(i);
        ((L1.T) this.f10152c).e(childCount, z5);
        if (z5) {
            m(view);
        }
        V vH = RecyclerView.H(view);
        if (vH != null) {
            if (!vH.j() && !vH.o()) {
                throw new IllegalArgumentException("Called attach on a child which is not detached: " + vH + recyclerView.x());
            }
            vH.f10126j &= -257;
        }
        recyclerView.attachViewToParent(view, childCount, layoutParams);
    }

    public u2.j c() throws GeneralSecurityException {
        g3.c cVar;
        u2.k kVar = (u2.k) this.f10151b;
        if (kVar == null || (cVar = (g3.c) this.f10152c) == null) {
            throw new GeneralSecurityException("Cannot build without parameters and/or key material");
        }
        if (kVar.f10349b != ((H2.a) cVar.f6465l).f873a.length) {
            throw new GeneralSecurityException("Key size mismatch");
        }
        u2.g gVar = u2.g.f10327m;
        u2.g gVar2 = kVar.f10352e;
        if (gVar2 != gVar && ((Integer) this.f10153d) == null) {
            throw new GeneralSecurityException("Cannot create key without ID requirement with parameters with ID requirement");
        }
        if (gVar2 == gVar && ((Integer) this.f10153d) != null) {
            throw new GeneralSecurityException("Cannot create key with ID requirement with parameters without ID requirement");
        }
        if (gVar2 == gVar) {
            H2.a.a(new byte[0]);
        } else if (gVar2 == u2.g.f10326l) {
            H2.a.a(ByteBuffer.allocate(5).put((byte) 0).putInt(((Integer) this.f10153d).intValue()).array());
        } else {
            if (gVar2 != u2.g.f10325k) {
                throw new IllegalStateException("Unknown AesEaxParameters.Variant: " + ((u2.k) this.f10151b).f10352e);
            }
            H2.a.a(ByteBuffer.allocate(5).put((byte) 1).putInt(((Integer) this.f10153d).intValue()).array());
        }
        return new u2.j();
    }

    public u2.m d() throws GeneralSecurityException {
        g3.c cVar;
        u2.n nVar = (u2.n) this.f10151b;
        if (nVar == null || (cVar = (g3.c) this.f10152c) == null) {
            throw new GeneralSecurityException("Cannot build without parameters and/or key material");
        }
        if (nVar.f10357b != ((H2.a) cVar.f6465l).f873a.length) {
            throw new GeneralSecurityException("Key size mismatch");
        }
        u2.g gVar = u2.g.p;
        u2.g gVar2 = nVar.f10360e;
        if (gVar2 != gVar && ((Integer) this.f10153d) == null) {
            throw new GeneralSecurityException("Cannot create key without ID requirement with parameters with ID requirement");
        }
        if (gVar2 == gVar && ((Integer) this.f10153d) != null) {
            throw new GeneralSecurityException("Cannot create key with ID requirement with parameters without ID requirement");
        }
        if (gVar2 == gVar) {
            H2.a.a(new byte[0]);
        } else if (gVar2 == u2.g.f10329o) {
            H2.a.a(ByteBuffer.allocate(5).put((byte) 0).putInt(((Integer) this.f10153d).intValue()).array());
        } else {
            if (gVar2 != u2.g.f10328n) {
                throw new IllegalStateException("Unknown AesGcmParameters.Variant: " + ((u2.n) this.f10151b).f10360e);
            }
            H2.a.a(ByteBuffer.allocate(5).put((byte) 1).putInt(((Integer) this.f10153d).intValue()).array());
        }
        return new u2.m();
    }

    public u2.p e() throws GeneralSecurityException {
        g3.c cVar;
        u2.q qVar = (u2.q) this.f10151b;
        if (qVar == null || (cVar = (g3.c) this.f10152c) == null) {
            throw new GeneralSecurityException("Cannot build without parameters and/or key material");
        }
        if (qVar.f10365b != ((H2.a) cVar.f6465l).f873a.length) {
            throw new GeneralSecurityException("Key size mismatch");
        }
        u2.g gVar = u2.g.f10331s;
        u2.g gVar2 = qVar.f10366c;
        if (gVar2 != gVar && ((Integer) this.f10153d) == null) {
            throw new GeneralSecurityException("Cannot create key without ID requirement with parameters with ID requirement");
        }
        if (gVar2 == gVar && ((Integer) this.f10153d) != null) {
            throw new GeneralSecurityException("Cannot create key with ID requirement with parameters without ID requirement");
        }
        if (gVar2 == gVar) {
            H2.a.a(new byte[0]);
        } else if (gVar2 == u2.g.f10330r) {
            H2.a.a(ByteBuffer.allocate(5).put((byte) 0).putInt(((Integer) this.f10153d).intValue()).array());
        } else {
            if (gVar2 != u2.g.q) {
                throw new IllegalStateException("Unknown AesGcmSivParameters.Variant: " + ((u2.q) this.f10151b).f10366c);
            }
            H2.a.a(ByteBuffer.allocate(5).put((byte) 1).putInt(((Integer) this.f10153d).intValue()).array());
        }
        return new u2.p();
    }

    public C1113a f() throws GeneralSecurityException {
        g3.c cVar;
        y2.c cVar2 = (y2.c) this.f10151b;
        if (cVar2 == null || (cVar = (g3.c) this.f10152c) == null) {
            throw new IllegalArgumentException("Cannot build without parameters and/or key material");
        }
        if (cVar2.f10727b != ((H2.a) cVar.f6465l).f873a.length) {
            throw new GeneralSecurityException("Key size mismatch");
        }
        y2.b bVar = y2.b.f10725d;
        y2.b bVar2 = cVar2.f10728c;
        if (bVar2 != bVar && ((Integer) this.f10153d) == null) {
            throw new GeneralSecurityException("Cannot create key without ID requirement with parameters with ID requirement");
        }
        if (bVar2 == bVar && ((Integer) this.f10153d) != null) {
            throw new GeneralSecurityException("Cannot create key with ID requirement with parameters without ID requirement");
        }
        if (bVar2 == bVar) {
            H2.a.a(new byte[0]);
        } else if (bVar2 == y2.b.f10724c) {
            H2.a.a(ByteBuffer.allocate(5).put((byte) 0).putInt(((Integer) this.f10153d).intValue()).array());
        } else {
            if (bVar2 != y2.b.f10723b) {
                throw new IllegalStateException("Unknown AesSivParameters.Variant: " + ((y2.c) this.f10151b).f10728c);
            }
            H2.a.a(ByteBuffer.allocate(5).put((byte) 1).putInt(((Integer) this.f10153d).intValue()).array());
        }
        return new C1113a();
    }

    public void g(int i) {
        V vH;
        int iJ = j(i);
        ((L1.T) this.f10152c).g(iJ);
        RecyclerView recyclerView = ((C1061x) this.f10151b).f10308a;
        View childAt = recyclerView.getChildAt(iJ);
        if (childAt != null && (vH = RecyclerView.H(childAt)) != null) {
            if (vH.j() && !vH.o()) {
                throw new IllegalArgumentException("called detach on an already detached child " + vH + recyclerView.x());
            }
            vH.a(256);
        }
        recyclerView.detachViewFromParent(iJ);
    }

    public View h(int i) {
        return ((C1061x) this.f10151b).f10308a.getChildAt(j(i));
    }

    public int i() {
        return ((C1061x) this.f10151b).f10308a.getChildCount() - ((ArrayList) this.f10153d).size();
    }

    public int j(int i) {
        if (i < 0) {
            return -1;
        }
        int childCount = ((C1061x) this.f10151b).f10308a.getChildCount();
        int i5 = i;
        while (i5 < childCount) {
            L1.T t4 = (L1.T) this.f10152c;
            int iB = i - (i5 - t4.b(i5));
            if (iB == 0) {
                while (t4.d(i5)) {
                    i5++;
                }
                return i5;
            }
            i5 += iB;
        }
        return -1;
    }

    public View k(int i) {
        return ((C1061x) this.f10151b).f10308a.getChildAt(i);
    }

    public int l() {
        return ((C1061x) this.f10151b).f10308a.getChildCount();
    }

    public void m(View view) {
        ((ArrayList) this.f10153d).add(view);
        C1061x c1061x = (C1061x) this.f10151b;
        V vH = RecyclerView.H(view);
        if (vH != null) {
            int i = vH.q;
            View view2 = vH.f10118a;
            if (i != -1) {
                vH.p = i;
            } else {
                Field field = P.Q.f2392a;
                vH.p = view2.getImportantForAccessibility();
            }
            RecyclerView recyclerView = c1061x.f10308a;
            if (recyclerView.K()) {
                vH.q = 4;
                recyclerView.f4597z0.add(vH);
            } else {
                Field field2 = P.Q.f2392a;
                view2.setImportantForAccessibility(4);
            }
        }
    }

    public boolean n(int i, C1083d c1083d, C1121e c1121e) {
        int[] iArr = c1083d.f10519p0;
        int i5 = iArr[0];
        x.b bVar = (x.b) this.f10151b;
        bVar.f10638a = i5;
        bVar.f10639b = iArr[1];
        bVar.f10640c = c1083d.q();
        bVar.f10641d = c1083d.k();
        bVar.i = false;
        bVar.f10646j = i;
        boolean z5 = bVar.f10638a == 3;
        boolean z6 = bVar.f10639b == 3;
        boolean z7 = z5 && c1083d.f10488W > 0.0f;
        boolean z8 = z6 && c1083d.f10488W > 0.0f;
        int[] iArr2 = c1083d.f10522t;
        if (z7 && iArr2[0] == 4) {
            bVar.f10638a = 1;
        }
        if (z8 && iArr2[1] == 4) {
            bVar.f10639b = 1;
        }
        c1121e.b(c1083d, bVar);
        c1083d.O(bVar.f10642e);
        c1083d.L(bVar.f10643f);
        c1083d.f10473E = bVar.f10645h;
        c1083d.I(bVar.f10644g);
        bVar.f10646j = 0;
        return bVar.i;
    }

    public void o(C1084e c1084e, int i, int i5, int i6) {
        int i7 = c1084e.f10494b0;
        int i8 = c1084e.f10496c0;
        c1084e.f10494b0 = 0;
        c1084e.f10496c0 = 0;
        c1084e.O(i5);
        c1084e.L(i6);
        if (i7 < 0) {
            c1084e.f10494b0 = 0;
        } else {
            c1084e.f10494b0 = i7;
        }
        if (i8 < 0) {
            c1084e.f10496c0 = 0;
        } else {
            c1084e.f10496c0 = i8;
        }
        C1084e c1084e2 = (C1084e) this.f10152c;
        c1084e2.f10544t0 = i;
        c1084e2.U();
    }

    public void p(View view) {
        if (((ArrayList) this.f10153d).remove(view)) {
            C1061x c1061x = (C1061x) this.f10151b;
            V vH = RecyclerView.H(view);
            if (vH != null) {
                int i = vH.p;
                RecyclerView recyclerView = c1061x.f10308a;
                if (recyclerView.K()) {
                    vH.q = i;
                    recyclerView.f4597z0.add(vH);
                } else {
                    Field field = P.Q.f2392a;
                    vH.f10118a.setImportantForAccessibility(i);
                }
                vH.p = 0;
            }
        }
    }

    public void q(C1084e c1084e) {
        ArrayList arrayList = (ArrayList) this.f10153d;
        arrayList.clear();
        int size = c1084e.f10541q0.size();
        for (int i = 0; i < size; i++) {
            C1083d c1083d = (C1083d) c1084e.f10541q0.get(i);
            int[] iArr = c1083d.f10519p0;
            if (iArr[0] == 3 || iArr[1] == 3) {
                arrayList.add(c1083d);
            }
        }
        c1084e.f10543s0.f10650b = true;
    }

    public String toString() {
        switch (this.f10150a) {
            case 0:
                return ((L1.T) this.f10152c).toString() + ", hidden list:" + ((ArrayList) this.f10153d).size();
            default:
                return super.toString();
        }
    }

    public C1040b(C1061x c1061x) {
        this.f10150a = 0;
        this.f10151b = c1061x;
        this.f10152c = new L1.T();
        this.f10153d = new ArrayList();
    }

    public C1040b(C1084e c1084e) {
        this.f10150a = 4;
        this.f10153d = new ArrayList();
        this.f10151b = new x.b();
        this.f10152c = c1084e;
    }
}
