package C0;

import F1.C0191u;
import F1.n0;
import F1.o0;
import F1.p0;
import I0.AbstractC0303l;
import I0.E0;
import I2.C0327k;
import I2.C0340y;
import O1.C0562b;
import O1.C0564d;
import O1.InterfaceC0563c;
import X0.C0795h;
import Y4.c0;
import a0.AbstractC0946w;
import a0.C0894e0;
import a0.C0897f0;
import a0.x2;
import android.R;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.SparseArray;
import android.view.View;
import android.view.Window;
import android.view.autofill.AutofillManager;
import android.view.inputmethod.InputMethodManager;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.State;
import androidx.leanback.widget.C1081m;
import androidx.leanback.widget.C1082n;
import androidx.leanback.widget.C1084p;
import androidx.recyclerview.widget.RecyclerView;
import c1.C1232g;
import c1.C1236k;
import com.google.android.gms.internal.play_billing.zzbt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.concurrent.atomic.AtomicInteger;
import m3.AbstractC2467b;
import n.C2592t;
import n.C2594v;
import o0.C2631b;
import q.C2790n0;

/* JADX INFO: loaded from: classes.dex */
public class B implements InterfaceC0563c, B0.a, androidx.leanback.widget.K {

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

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

    @Override // B0.a
    public long J(int i6, long j4) {
        C0897f0 c0897f0 = (C0897f0) this.f506b;
        if (!((Boolean) c0897f0.f9859d.invoke()).booleanValue()) {
            return 0L;
        }
        int i7 = (int) (4294967295L & j4);
        if (Float.intBitsToFloat(i7) > 0.0f) {
            return 0L;
        }
        x2 x2Var = c0897f0.f9856a;
        float floatValue = x2Var.f10328c.getFloatValue();
        x2Var.b(Float.intBitsToFloat(i7) + x2Var.f10328c.getFloatValue());
        if (floatValue == x2Var.f10328c.getFloatValue()) {
            return 0L;
        }
        return C2631b.a(j4, 0.0f, 2);
    }

    /* JADX WARN: Type inference failed for: r0v1, types: [J4.c, kotlin.jvm.internal.p] */
    @Override // O1.InterfaceC0563c
    public Object a(C0562b c0562b) {
        return ((kotlin.jvm.internal.p) this.f506b).invoke(c0562b);
    }

    public void b(I0.H h5) {
        if (!h5.F()) {
            F0.a.b("DepthSortedSet.add called on an unattached node");
        }
        ((E0) this.f506b).add(h5);
    }

    public void d(Object obj, int i6, int i7, int i8, int i9) {
        int i10;
        int i11;
        C1082n c1082n;
        int i12;
        View view = (View) obj;
        C1084p c1084p = (C1084p) this.f506b;
        if (i9 == Integer.MIN_VALUE || i9 == Integer.MAX_VALUE) {
            boolean z6 = c1084p.f12039S.f11984c;
            J j4 = c1084p.f12041U;
            if (z6) {
                androidx.leanback.widget.X x6 = (androidx.leanback.widget.X) j4.f535d;
                i9 = x6.f11973i - x6.f11975k;
            } else {
                i9 = ((androidx.leanback.widget.X) j4.f535d).f11974j;
            }
        }
        if (c1084p.f12039S.f11984c) {
            i10 = i9 - i7;
            i11 = i9;
        } else {
            i11 = i7 + i9;
            i10 = i9;
        }
        int iV0 = (c1084p.V0(i8) + ((androidx.leanback.widget.X) c1084p.f12041U.f536e).f11974j) - c1084p.f12027G;
        C0327k c0327k = c1084p.f12044Z;
        if (((C2594v) c0327k.f2635c) != null) {
            SparseArray<Parcelable> sparseArray = (SparseArray) ((C2594v) c0327k.f2635c).remove(Integer.toString(i6));
            if (sparseArray != null) {
                view.restoreHierarchyState(sparseArray);
            }
        }
        ((C1084p) this.f506b).a1(view, i8, i10, i11, iV0);
        if (!c1084p.f12051t.f13003g) {
            c1084p.w1();
        }
        boolean z7 = true;
        if ((c1084p.f12057z & 3) == 1 || (c1082n = c1084p.f12024D) == null) {
            return;
        }
        boolean z8 = c1082n.f12014r;
        C1084p c1084p2 = c1082n.f12016t;
        if (z8 && (i12 = c1082n.f12015s) != 0) {
            c1082n.f12015s = c1084p2.g1(i12, true);
        }
        int i13 = c1082n.f12015s;
        if (i13 != 0 && (i13 <= 0 || !c1084p2.Y0())) {
            if (c1082n.f12015s >= 0) {
                return;
            }
            RecyclerView recyclerView = c1084p2.f12843b;
            androidx.recyclerview.widget.B adapter = recyclerView != null ? recyclerView.getAdapter() : null;
            if ((adapter != null ? adapter.getItemCount() : 0) != 0 && c1084p2.f12048q.C(0) == null) {
                z7 = false;
            }
            if (!z7) {
                return;
            }
        }
        c1082n.f11992a = c1084p2.f12022B;
        c1082n.e();
    }

    public long e(long j4) {
        D0.b bVar = (D0.b) this.f506b;
        bVar.getClass();
        if (h1.q.b(j4) <= 0.0f || h1.q.c(j4) <= 0.0f) {
            F0.a.b("maximumVelocity should be a positive value. You specified=" + ((Object) h1.q.g(j4)));
        }
        return W.b.S(bVar.f927a.b(h1.q.b(j4)), bVar.f928b.b(h1.q.c(j4)));
    }

    public G1.g f(int i6) {
        return null;
    }

    @Override // B0.a
    public long f0(int i6, long j4, long j6) {
        long jFloatToRawIntBits;
        int iFloatToRawIntBits;
        C0897f0 c0897f0 = (C0897f0) this.f506b;
        if (!((Boolean) c0897f0.f9859d.invoke()).booleanValue()) {
            return 0L;
        }
        x2 x2Var = c0897f0.f9856a;
        int i7 = (int) (j4 & 4294967295L);
        x2Var.f10327b.setFloatValue(Float.intBitsToFloat(i7) + x2Var.f10327b.getFloatValue());
        int i8 = (int) (j6 & 4294967295L);
        if (Float.intBitsToFloat(i8) < 0.0f || Float.intBitsToFloat(i7) < 0.0f) {
            float floatValue = x2Var.f10328c.getFloatValue();
            x2Var.b(Float.intBitsToFloat(i7) + x2Var.f10328c.getFloatValue());
            float floatValue2 = x2Var.f10328c.getFloatValue() - floatValue;
            jFloatToRawIntBits = Float.floatToRawIntBits(0.0f);
            iFloatToRawIntBits = Float.floatToRawIntBits(floatValue2);
        } else {
            if (Float.intBitsToFloat(i8) <= 0.0f) {
                return 0L;
            }
            float floatValue3 = x2Var.f10328c.getFloatValue();
            x2Var.b(Float.intBitsToFloat(i8) + x2Var.f10328c.getFloatValue());
            float floatValue4 = x2Var.f10328c.getFloatValue() - floatValue3;
            jFloatToRawIntBits = Float.floatToRawIntBits(0.0f);
            iFloatToRawIntBits = Float.floatToRawIntBits(floatValue4);
        }
        return (jFloatToRawIntBits << 32) | (((long) iFloatToRawIntBits) & 4294967295L);
    }

    public int g(int i6, boolean z6, Object[] objArr, boolean z7) {
        int i7;
        View viewR;
        C1084p c1084p = (C1084p) this.f506b;
        View viewD = c1084p.f12056y.d(i6 - c1084p.f12052u);
        C1081m c1081m = (C1081m) viewD.getLayoutParams();
        c1084p.f12048q.F(viewD);
        c1081m.getClass();
        if (!c1081m.f12856a.isRemoved()) {
            if (z7) {
                if (z6) {
                    c1084p.a(viewD, -1, true);
                } else {
                    c1084p.a(viewD, 0, true);
                }
            } else if (z6) {
                c1084p.a(viewD, -1, false);
            } else {
                c1084p.a(viewD, 0, false);
            }
            int i8 = c1084p.f12026F;
            if (i8 != -1) {
                viewD.setVisibility(i8);
            }
            C1082n c1082n = c1084p.f12024D;
            if (c1082n != null && !c1082n.f12014r && (i7 = c1082n.f12015s) != 0) {
                C1084p c1084p2 = c1082n.f12016t;
                int i9 = i7 > 0 ? c1084p2.f12022B + c1084p2.f12037Q : c1084p2.f12022B - c1084p2.f12037Q;
                View view = null;
                while (c1082n.f12015s != 0 && (viewR = c1082n.f11993b.f12946q.r(i9)) != null) {
                    c1084p2.getClass();
                    if (viewR.getVisibility() == 0 && (!c1084p2.P() || viewR.hasFocusable())) {
                        c1084p2.f12022B = i9;
                        int i10 = c1082n.f12015s;
                        if (i10 > 0) {
                            c1082n.f12015s = i10 - 1;
                        } else {
                            c1082n.f12015s = i10 + 1;
                        }
                        view = viewR;
                    }
                    i9 = c1082n.f12015s > 0 ? i9 + c1084p2.f12037Q : i9 - c1084p2.f12037Q;
                }
                if (view != null && c1084p2.P()) {
                    c1084p2.f12057z |= 32;
                    view.requestFocus();
                    c1084p2.f12057z &= -33;
                }
            }
            if (viewD.findFocus() != null) {
                ((C1081m) viewD.getLayoutParams()).getClass();
            }
            int i11 = c1084p.f12057z;
            if ((i11 & 3) != 1) {
                if (i6 == c1084p.f12022B && c1084p.f12024D == null) {
                    c1084p.N0();
                }
            } else if ((i11 & 4) == 0) {
                int i12 = i11 & 16;
                if (i12 == 0 && i6 == c1084p.f12022B) {
                    c1084p.N0();
                } else if (i12 != 0 && i6 >= c1084p.f12022B && viewD.hasFocusable()) {
                    c1084p.f12022B = i6;
                    c1084p.f12057z &= -17;
                    c1084p.N0();
                }
            }
            c1084p.c1(viewD);
        }
        objArr[0] = viewD;
        return c1084p.f12049r == 0 ? C1084p.S0(viewD) : C1084p.R0(viewD);
    }

    public G1.g h(int i6) {
        return null;
    }

    public int i() {
        C1084p c1084p = (C1084p) this.f506b;
        return c1084p.f12051t.b() + c1084p.f12052u;
    }

    public O1.Z j() {
        return (O1.Z) ((c0) this.f506b).getValue();
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x007b, code lost:
    
        if (r14 == r0) goto L26;
     */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    @Override // B0.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object k(long j4, long j6, A4.d dVar) {
        C0894e0 c0894e0;
        long j7;
        long j8;
        if (dVar instanceof C0894e0) {
            c0894e0 = (C0894e0) dVar;
            int i6 = c0894e0.f9834d;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c0894e0.f9834d = i6 - Integer.MIN_VALUE;
            } else {
                c0894e0 = new C0894e0(this, (C4.c) dVar);
            }
        }
        C0894e0 c0894e02 = c0894e0;
        Object objK = c0894e02.f9832b;
        Object obj = B4.a.f492a;
        int i7 = c0894e02.f9834d;
        C0897f0 c0897f0 = (C0897f0) this.f506b;
        if (i7 == 0) {
            AbstractC2467b.l(objK);
            if (h1.q.c(j6) > 0.0f) {
                c0897f0.f9856a.f10327b.setFloatValue(0.0f);
            }
            c0894e02.f9831a = j6;
            c0894e02.f9834d = 1;
            objK = super.k(j4, j6, c0894e02);
            if (objK != obj) {
                j7 = j6;
            }
            return obj;
        }
        if (i7 != 1) {
            if (i7 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            j8 = c0894e02.f9831a;
            AbstractC2467b.l(objK);
            return new h1.q(h1.q.e(j8, ((h1.q) objK).f16636a));
        }
        j7 = c0894e02.f9831a;
        AbstractC2467b.l(objK);
        j8 = ((h1.q) objK).f16636a;
        x2 x2Var = c0897f0.f9856a;
        float fC = h1.q.c(j7);
        C2790n0 c2790n0 = c0897f0.f9857b;
        c0894e02.f9831a = j8;
        c0894e02.f9834d = 2;
        objK = AbstractC0946w.f(x2Var, fC, c0897f0.f9858c, c2790n0, c0894e02);
    }

    public int l(int i6) {
        C1084p c1084p = (C1084p) this.f506b;
        View viewR = c1084p.r(i6 - c1084p.f12052u);
        return (c1084p.f12057z & 262144) != 0 ? c1084p.f12050s.b(viewR) : c1084p.f12050s.e(viewR);
    }

    public State m() {
        T1.h hVarA = T1.h.a();
        if (hVarA.c() == 1) {
            return new C1236k(true);
        }
        MutableState mutableStateMutableStateOf$default = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(Boolean.FALSE, null, 2, null);
        C1232g c1232g = new C1232g(mutableStateMutableStateOf$default, this);
        hVarA.f6585a.writeLock().lock();
        try {
            if (hVarA.f6587c == 1 || hVarA.f6587c == 2) {
                hVarA.f6588d.post(new C1.b(Arrays.asList(c1232g), hVarA.f6587c, (Throwable) null));
            } else {
                hVarA.f6586b.add(c1232g);
            }
            hVarA.f6585a.writeLock().unlock();
            return mutableStateMutableStateOf$default;
        } catch (Throwable th) {
            hVarA.f6585a.writeLock().unlock();
            throw th;
        }
    }

    public int n(int i6) {
        C1084p c1084p = (C1084p) this.f506b;
        View viewR = c1084p.r(i6 - c1084p.f12052u);
        Rect rect = C1084p.f12019c0;
        c1084p.A(viewR, rect);
        return c1084p.f12049r == 0 ? rect.width() : rect.height();
    }

    public T2.g o(ArrayList arrayList, String str, String scraperName) {
        String str2;
        String str3;
        kotlin.jvm.internal.o.h(scraperName, "scraperName");
        if (!arrayList.isEmpty()) {
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                T2.h hVar = (T2.h) it.next();
                String str4 = hVar.f6661b;
                LinkedHashSet linkedHashSet = (LinkedHashSet) this.f506b;
                String str5 = hVar.f6663d;
                T2.a aVar = hVar.f6664e;
                String str6 = hVar.f6662c;
                String str7 = hVar.f6665f;
                if (str4 != null) {
                    S4.m mVar = P2.c.f5650a;
                    String strC = P2.c.c(aVar != null ? aVar.f6629b : null, str7, str6);
                    String strB = (strC == null || S4.p.Q0(strC)) ? str4 : Z0.o.B(str4, "\u0000", strC);
                    if (!linkedHashSet.contains(strB)) {
                        linkedHashSet.add(strB);
                        if (str6 != null) {
                            str5 = str6;
                        } else if (str5 == null) {
                            str5 = "";
                        }
                        Long l = aVar != null ? aVar.f6628a : null;
                        if (strC == null) {
                            str3 = str7;
                            str2 = strC;
                        } else {
                            str2 = strC;
                            str3 = str2;
                        }
                        linkedHashMap.put(strB, new T2.d(l, str5, str2, str4, str3, str4, hVar.f6663d));
                    }
                } else {
                    String str8 = hVar.f6660a;
                    if (str8 != null && !linkedHashSet.contains(str8)) {
                        linkedHashSet.add(str8);
                        S4.m mVar2 = P2.c.f5650a;
                        String strC2 = P2.c.c(aVar != null ? aVar.f6629b : null, str7, str6);
                        linkedHashMap.put(str8, new T2.d(aVar != null ? aVar.f6628a : null, str6 == null ? str5 == null ? "" : str5 : str6, strC2, str8, strC2 == null ? str7 : strC2, null, null));
                    }
                }
            }
            if (!linkedHashMap.isEmpty()) {
                return new T2.g(linkedHashMap, scraperName);
            }
        }
        return null;
    }

    public void p() {
        View view = (View) this.f506b;
        if (view != null) {
            ((InputMethodManager) view.getContext().getSystemService("input_method")).hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }

    public void q(View view, int i6, boolean z6) {
        if (Build.VERSION.SDK_INT >= 27) {
            ((AutofillManager) this.f506b).notifyViewVisibilityChanged(view, i6, z6);
        }
    }

    public boolean r(int i6, int i7, Bundle bundle) {
        return false;
    }

    public C0109j s(T.p pVar, J0.A a6) {
        long jG;
        boolean z6;
        long j4;
        ArrayList arrayList = (ArrayList) pVar.f6345b;
        C2592t c2592t = new C2592t(arrayList.size());
        int size = arrayList.size();
        int i6 = 0;
        while (i6 < size) {
            C c6 = (C) arrayList.get(i6);
            long j6 = c6.f507a;
            C2592t c2592t2 = (C2592t) this.f506b;
            A a7 = (A) c2592t2.b(j6);
            if (a7 == null) {
                long j7 = c6.f508b;
                jG = c6.f510d;
                j4 = j7;
                z6 = false;
            } else {
                jG = a6.G(a7.f503b);
                long j8 = a7.f502a;
                z6 = a7.f504c;
                j4 = j8;
            }
            long j9 = jG;
            ArrayList arrayList2 = c6.f515i;
            long j10 = c6.f516j;
            long j11 = c6.f517k;
            int i7 = i6;
            long j12 = c6.f507a;
            ArrayList arrayList3 = arrayList;
            int i8 = size;
            c2592t.e(j12, new C0124z(j12, c6.f508b, c6.f510d, c6.f511e, c6.f512f, j4, j9, z6, c6.f513g, arrayList2, j10, j11));
            long j13 = c6.f507a;
            boolean z7 = c6.f511e;
            if (z7) {
                c2592t2.e(j13, new A(c6.f508b, c6.f509c, z7));
            } else {
                c2592t2.f(j13);
            }
            i6 = i7 + 1;
            arrayList = arrayList3;
            size = i8;
        }
        return new C0109j(c2592t, pVar);
    }

    public boolean t(I0.H h5) {
        if (!h5.F()) {
            F0.a.b("DepthSortedSet.remove called on an unattached node");
        }
        return ((E0) this.f506b).remove(h5);
    }

    public String toString() {
        switch (this.f505a) {
            case 9:
                return ((E0) this.f506b).toString();
            default:
                return super.toString();
        }
    }

    public void u(int i6) {
        C1084p c1084p = (C1084p) this.f506b;
        View viewR = c1084p.r(i6 - c1084p.f12052u);
        if ((c1084p.f12057z & 3) == 1) {
            c1084p.z0(c1084p.f12056y, c1084p.f12842a.G(viewR), viewR);
        } else {
            c1084p.u0(viewR, c1084p.f12056y);
        }
    }

    public void v(ArrayList arrayList) {
        if (arrayList.isEmpty()) {
            throw new IllegalArgumentException("Product list cannot be empty.");
        }
        HashSet hashSet = new HashSet();
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            C0340y c0340y = (C0340y) it.next();
            if (!"play_pass_subs".equals(c0340y.f2677b)) {
                hashSet.add(c0340y.f2677b);
            }
        }
        if (hashSet.size() > 1) {
            throw new IllegalArgumentException("All products should be of the same product type.");
        }
        this.f506b = zzbt.zzj(arrayList);
    }

    public void w() {
        View viewFindViewById;
        View view = (View) this.f506b;
        if (view == null) {
            return;
        }
        if (view.isInEditMode() || view.onCheckIsTextEditor()) {
            view.requestFocus();
            viewFindViewById = view;
        } else {
            viewFindViewById = view.getRootView().findFocus();
        }
        if (viewFindViewById == null) {
            viewFindViewById = view.getRootView().findViewById(R.id.content);
        }
        if (viewFindViewById == null || !viewFindViewById.hasWindowFocus()) {
            return;
        }
        viewFindViewById.post(new F1.r(viewFindViewById, 0));
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0029  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void x(O1.Z newState) {
        c0 c0Var;
        Object value;
        O1.Z z6;
        kotlin.jvm.internal.o.h(newState, "newState");
        do {
            c0Var = (c0) this.f506b;
            value = c0Var.getValue();
            z6 = (O1.Z) value;
            if (!(z6 instanceof O1.S ? true : kotlin.jvm.internal.o.c(z6, O1.b0.f5395b))) {
                if (z6 instanceof C0564d) {
                    if (newState.f5392a > z6.f5392a) {
                        z6 = newState;
                    }
                } else if (!(z6 instanceof O1.P)) {
                    throw new E3.v();
                }
            }
        } while (!c0Var.i(value, z6));
    }

    public /* synthetic */ B(Object obj, int i6) {
        this.f505a = i6;
        this.f506b = obj;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public B(J4.c produceNewData) {
        this.f505a = 16;
        kotlin.jvm.internal.o.h(produceNewData, "produceNewData");
        this.f506b = (kotlin.jvm.internal.p) produceNewData;
    }

    public B(View view) {
        this.f505a = 5;
        if (Build.VERSION.SDK_INT >= 30) {
            C0191u c0191u = new C0191u(view, 4);
            c0191u.f1470c = view;
            this.f506b = c0191u;
            return;
        }
        this.f506b = new B(view, 4);
    }

    public B(Window window, View view) {
        this.f505a = 6;
        B b5 = new B(view);
        int i6 = Build.VERSION.SDK_INT;
        if (i6 >= 35) {
            this.f506b = new p0(window, b5, 1);
            return;
        }
        if (i6 >= 30) {
            this.f506b = new n0(window, b5, 1);
        } else if (i6 >= 26) {
            this.f506b = new o0(window, b5, 0);
        } else {
            this.f506b = new n0(window, b5, 0);
        }
    }

    public B(int i6) {
        C0795h c0795h;
        this.f505a = i6;
        switch (i6) {
            case 1:
                this.f506b = new D0.b();
                break;
            case 8:
                if (Build.VERSION.SDK_INT >= 26) {
                    this.f506b = new G1.i(this);
                } else {
                    this.f506b = new G1.h(this);
                }
                break;
            case 9:
                this.f506b = new E0(AbstractC0303l.f2433a);
                break;
            case 13:
                this.f506b = new AtomicInteger(0);
                break;
            case 14:
                this.f506b = Y4.O.c(O1.b0.f5395b);
                break;
            case 15:
                this.f506b = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(Boolean.FALSE, null, 2, null);
                break;
            case 17:
                this.f506b = new Region();
                break;
            case 19:
                this.f506b = new LinkedHashSet();
                break;
            case 20:
                if (Build.VERSION.SDK_INT >= 28) {
                    c0795h = new C0795h(3);
                } else {
                    c0795h = new C0795h(4);
                }
                this.f506b = c0795h;
                break;
            default:
                this.f506b = new C2592t((Object) null);
                break;
        }
    }

    public void c(int i6, G1.g gVar, String str, Bundle bundle) {
    }
}
