package v;

import C0.C0116q;
import I0.AbstractC0301k;
import I0.AbstractC0303l;
import I0.InterfaceC0297i;
import I0.InterfaceC0299j;
import J0.AbstractC0391w0;
import J0.j1;
import Q0.C0586a;
import V4.C0763h0;
import V4.InterfaceC0765i0;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.view.ViewParent;
import c0.C1217r;
import java.util.ArrayList;
import n.C2569D;
import o0.C2631b;
import w4.C3137A;
import z.C3288h;
import z.C3289i;
import z0.C3292b;
import z0.InterfaceC3293c;

/* JADX INFO: renamed from: v.r, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC3045r extends AbstractC0301k implements I0.y0, A0.f, I0.D0, I0.I0, InterfaceC0297i, I0.n0, InterfaceC3293c {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public static final C3013b f24919A = new C3013b();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public z.l f24920c;

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f24922e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public String f24923f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public Q0.j f24924j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f24925k;
    public J4.a l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final C3020e0 f24926m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public InterfaceC3050t0 f24927n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public C0.b0 f24928o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public InterfaceC0299j f24929p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public z.o f24930q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public C3288h f24931r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final C2569D f24932s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public long f24933t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public z.o f24934u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public z.l f24935v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public boolean f24936w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public androidx.recyclerview.widget.i0 f24937x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public V4.B0 f24938y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final C3013b f24939z;

    public AbstractC3045r(z.l lVar, InterfaceC3050t0 interfaceC3050t0, boolean z6, boolean z7, String str, Q0.j jVar, J4.a aVar) {
        this.f24920c = lVar;
        this.f24921d = interfaceC3050t0;
        this.f24922e = z6;
        this.f24923f = str;
        this.f24924j = jVar;
        this.f24925k = z7;
        this.l = aVar;
        this.f24926m = new C3020e0(lVar, 0, new K.G0(1, this, AbstractC3045r.class, "onFocusChange", "onFocusChange(Z)V", 0, 4));
        int i6 = n.r.f21472a;
        this.f24932s = new C2569D(6);
        this.f24933t = 0L;
        z.l lVar2 = this.f24920c;
        this.f24935v = lVar2;
        this.f24936w = lVar2 == null;
        this.f24939z = f24919A;
    }

    public final void A0(boolean z6) {
        z.l lVar = this.f24920c;
        if (lVar != null) {
            V4.B0 b02 = this.f24938y;
            if (b02 == null || !b02.isActive()) {
                z.o oVar = z6 ? this.f24934u : this.f24930q;
                if (oVar != null) {
                    z.n nVar = new z.n(oVar);
                    InterfaceC0765i0 interfaceC0765i0 = (InterfaceC0765i0) getCoroutineScope().getCoroutineContext().get(C0763h0.f8306a);
                    V4.E.y(getCoroutineScope(), null, null, new C3023g(lVar, nVar, interfaceC0765i0 != null ? interfaceC0765i0.invokeOnCompletion(new C1217r(23, lVar, nVar)) : null, null), 3);
                }
            } else {
                V4.B0 b03 = this.f24938y;
                if (b03 != null) {
                    b03.cancel(null);
                }
            }
            if (z6) {
                this.f24934u = null;
            } else {
                this.f24930q = null;
            }
        }
    }

    public final void B0(long j4, boolean z6) {
        z.l lVar = this.f24920c;
        if (lVar != null) {
            V4.B0 b02 = this.f24938y;
            if (b02 == null || !b02.isActive()) {
                z.o oVar = z6 ? this.f24934u : this.f24930q;
                if (oVar != null) {
                    V4.E.y(getCoroutineScope(), null, null, new C3027i(null, lVar, oVar), 3);
                }
            } else {
                b02.cancel(null);
                V4.E.y(getCoroutineScope(), null, null, new C3025h(b02, j4, lVar, null), 3);
            }
            if (z6) {
                this.f24934u = null;
            } else {
                this.f24930q = null;
            }
        }
    }

    public final void C0(long j4, boolean z6) {
        z.l lVar = this.f24920c;
        if (lVar != null) {
            z.o oVar = new z.o(j4);
            if (y0()) {
                this.f24938y = V4.E.y(getCoroutineScope(), null, null, new C3029j(lVar, oVar, z6, this, null), 3);
                return;
            }
            if (z6) {
                this.f24934u = oVar;
            } else {
                this.f24930q = oVar;
            }
            V4.E.y(getCoroutineScope(), null, null, new C3031k(null, lVar, oVar), 3);
        }
    }

    public final void D0() {
        if (this.f24929p != null) {
            return;
        }
        InterfaceC3050t0 interfaceC3050t0 = this.f24922e ? this.f24927n : this.f24921d;
        if (interfaceC3050t0 != null) {
            if (this.f24920c == null) {
                this.f24920c = new z.m();
            }
            this.f24926m.y0(this.f24920c);
            z.l lVar = this.f24920c;
            kotlin.jvm.internal.o.e(lVar);
            InterfaceC0299j interfaceC0299jA = interfaceC3050t0.a(lVar);
            t0(interfaceC0299jA);
            this.f24929p = interfaceC0299jA;
        }
    }

    public void F() {
        C3288h c3288h;
        z.l lVar = this.f24920c;
        if (lVar != null && (c3288h = this.f24931r) != null) {
            ((z.m) lVar).b(new C3289i(c3288h));
        }
        this.f24931r = null;
        C0.b0 b0Var = this.f24928o;
        if (b0Var != null) {
            b0Var.F();
        }
    }

    public abstract boolean F0(KeyEvent keyEvent);

    public abstract void G0(KeyEvent keyEvent);

    /* JADX WARN: Removed duplicated region for block: B:39:0x0081  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void H0(z.l lVar, InterfaceC3050t0 interfaceC3050t0, boolean z6, boolean z7, String str, Q0.j jVar, J4.a aVar) throws Throwable {
        boolean z8;
        InterfaceC0299j interfaceC0299j;
        boolean z9 = true;
        if (kotlin.jvm.internal.o.c(this.f24935v, lVar)) {
            z8 = false;
        } else {
            z0();
            this.f24935v = lVar;
            this.f24920c = lVar;
            z8 = true;
        }
        if (!kotlin.jvm.internal.o.c(this.f24921d, interfaceC3050t0)) {
            this.f24921d = interfaceC3050t0;
            z8 = true;
        }
        if (this.f24922e != z6) {
            this.f24922e = z6;
            if (z6) {
                c0();
            }
            z8 = true;
        }
        boolean z10 = this.f24925k;
        C3020e0 c3020e0 = this.f24926m;
        if (z10 != z7) {
            if (z7) {
                t0(c3020e0);
            } else {
                u0(c3020e0);
                z0();
            }
            AbstractC0303l.t(this).D();
            this.f24925k = z7;
        }
        if (!kotlin.jvm.internal.o.c(this.f24923f, str)) {
            this.f24923f = str;
            AbstractC0303l.t(this).D();
        }
        if (!kotlin.jvm.internal.o.c(this.f24924j, jVar)) {
            this.f24924j = jVar;
            AbstractC0303l.t(this).D();
        }
        this.l = aVar;
        boolean z11 = this.f24936w;
        z.l lVar2 = this.f24935v;
        if (z11 == (lVar2 == null)) {
            z9 = z8;
        } else {
            boolean z12 = lVar2 == null;
            this.f24936w = z12;
            if (z12 || this.f24929p != null) {
            }
        }
        if (z9 && ((interfaceC0299j = this.f24929p) != null || !this.f24936w)) {
            if (interfaceC0299j != null) {
                u0(interfaceC0299j);
            }
            this.f24929p = null;
            D0();
        }
        c3020e0.y0(this.f24920c);
    }

    @Override // I0.D0
    public final void R(Q0.A a6) {
        Q0.j jVar = this.f24924j;
        if (jVar != null) {
            Q0.y.b(a6, jVar.f5747a);
        }
        String str = this.f24923f;
        C3011a c3011a = new C3011a(this, 1);
        Q4.m[] mVarArr = Q0.y.f5862a;
        a6.g(Q0.m.f5775b, new C0586a(str, c3011a));
        if (this.f24925k) {
            this.f24926m.R(a6);
        } else {
            a6.g(Q0.w.f5843i, C3137A.f25453a);
        }
        w0(a6);
    }

    @Override // z0.InterfaceC3293c
    public final void X() {
        androidx.recyclerview.widget.i0 i0Var = this.f24937x;
        if (i0Var != null) {
            i0Var.t();
        }
    }

    @Override // z0.InterfaceC3293c
    public final void Z(F.f0 f0Var, C0.r rVar) {
        D0();
        if (!this.f24925k) {
            return;
        }
        if (this.f24937x == null) {
            this.f24937x = new androidx.recyclerview.widget.i0(this, 18);
        }
        androidx.recyclerview.widget.i0 i0Var = this.f24937x;
        if (i0Var == null) {
            return;
        }
        J4.a aVar = this.l;
        C0.r rVar2 = C0.r.f634b;
        ArrayList arrayList = (ArrayList) f0Var.f1280c;
        int i6 = 0;
        if (rVar != rVar2) {
            if (rVar != C0.r.f635c || ((C3292b) i0Var.f13106c) == null) {
                return;
            }
            int size = arrayList.size();
            while (i6 < size) {
                C3292b c3292b = (C3292b) arrayList.get(i6);
                if (c3292b.f26266i && !c3292b.equals((C3292b) i0Var.f13106c)) {
                    i0Var.t();
                    return;
                }
                i6++;
            }
            return;
        }
        C3292b c3292b2 = (C3292b) i0Var.f13106c;
        AbstractC3045r abstractC3045r = (AbstractC3045r) i0Var.f13105b;
        if (c3292b2 == null) {
            int size2 = arrayList.size();
            for (int i7 = 0; i7 < size2; i7++) {
                C3292b c3292b3 = (C3292b) arrayList.get(i7);
                if (!c3292b3.f26265h && c3292b3.f26261d) {
                    C3292b c3292b4 = (C3292b) arrayList.get(0);
                    i0Var.f13106c = c3292b4;
                    abstractC3045r.C0(c3292b4.f26260c, true);
                    c3292b4.f26266i = true;
                    return;
                }
            }
            return;
        }
        int size3 = arrayList.size();
        int i8 = 0;
        while (true) {
            long j4 = c3292b2.f26260c;
            if (i8 >= size3) {
                int size4 = arrayList.size();
                for (int i9 = 0; i9 < size4; i9++) {
                    C3292b c3292b5 = (C3292b) arrayList.get(i9);
                    if (c3292b5.f26266i || !c3292b5.f26265h || c3292b5.f26261d) {
                        int size5 = arrayList.size();
                        while (i6 < size5) {
                            if (((C3292b) arrayList.get(i6)).f26266i) {
                                i0Var.t();
                                return;
                            }
                            i6++;
                        }
                        return;
                    }
                }
                ((C3292b) arrayList.get(0)).f26266i = true;
                abstractC3045r.B0(j4, true);
                aVar.invoke();
                i0Var.f13106c = null;
                return;
            }
            C3292b c3292b6 = (C3292b) arrayList.get(i8);
            if (c3292b6.f26265h && c3292b6.f26261d) {
                if (Math.abs(C2631b.c(C2631b.d(((C3292b) arrayList.get(0)).f26260c, j4))) > ((j1) AbstractC0303l.h(abstractC3045r, AbstractC0391w0.f3110s)).f()) {
                    i0Var.t();
                    return;
                }
                return;
            }
            i8++;
        }
    }

    @Override // I0.n0
    public final void c0() throws Throwable {
        if (this.f24922e) {
            AbstractC0303l.p(this, new C3011a(this, 0));
        }
    }

    @Override // A0.f
    public final boolean d(KeyEvent keyEvent) {
        return false;
    }

    public void d0(C0116q c0116q, C0.r rVar, long j4) {
        C0.b0 b0VarX0;
        long j6 = ((j4 >> 33) << 32) | (((j4 << 32) >> 33) & 4294967295L);
        this.f24933t = (((long) Float.floatToRawIntBits((int) (j6 >> 32))) << 32) | (((long) Float.floatToRawIntBits((int) (j6 & 4294967295L))) & 4294967295L);
        D0();
        if (this.f24925k && rVar == C0.r.f634b) {
            int i6 = c0116q.f632f;
            if (i6 == 4) {
                V4.E.y(getCoroutineScope(), null, null, new C3041p(this, null), 3);
            } else if (i6 == 5) {
                V4.E.y(getCoroutineScope(), null, null, new C3043q(this, null), 3);
            }
        }
        if (this.f24928o == null && (b0VarX0 = x0()) != null) {
            t0(b0VarX0);
            this.f24928o = b0VarX0;
        }
        C0.b0 b0Var = this.f24928o;
        if (b0Var != null) {
            b0Var.d0(c0116q, rVar, j4);
        }
    }

    @Override // i0.AbstractC2254r
    public final boolean getShouldAutoInvalidate() {
        return false;
    }

    @Override // I0.I0
    public final Object i() {
        return this.f24939z;
    }

    @Override // i0.AbstractC2254r
    public final void onAttach() throws Throwable {
        c0();
        if (!this.f24936w) {
            D0();
        }
        if (this.f24925k) {
            t0(this.f24926m);
        }
    }

    @Override // i0.AbstractC2254r
    public final void onDetach() {
        z0();
        if (this.f24935v == null) {
            this.f24920c = null;
        }
        InterfaceC0299j interfaceC0299j = this.f24929p;
        if (interfaceC0299j != null) {
            u0(interfaceC0299j);
        }
        this.f24929p = null;
    }

    @Override // I0.D0
    public final boolean q0() {
        return true;
    }

    public abstract C0.b0 x0();

    public final boolean y0() {
        kotlin.jvm.internal.y yVar = new kotlin.jvm.internal.y();
        AbstractC0303l.w(this, x.H0.f25591b, new androidx.compose.runtime.snapshots.e(yVar, 14));
        if (yVar.f20130a) {
            return true;
        }
        int i6 = AbstractC2986K.f24741b;
        ViewParent parent = AbstractC0303l.v(this).getParent();
        while (parent != null && (parent instanceof ViewGroup)) {
            ViewGroup viewGroup = (ViewGroup) parent;
            if (viewGroup.shouldDelayChildPressedState()) {
                return true;
            }
            parent = viewGroup.getParent();
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:32:0x0077 A[RETURN] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // A0.f
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean z(KeyEvent keyEvent) {
        boolean z6;
        D0();
        long jB = A0.d.b(keyEvent);
        boolean z7 = this.f24925k;
        C2569D c2569d = this.f24932s;
        if (!z7 || A0.d.c(keyEvent) != 2 || !AbstractC3058z.u(keyEvent)) {
            if (this.f24925k && A0.d.c(keyEvent) == 1 && AbstractC3058z.u(keyEvent)) {
                z.o oVar = (z.o) c2569d.f(jB);
                if (oVar != null) {
                    if (this.f24920c != null) {
                        V4.E.y(getCoroutineScope(), null, null, new C3039o(this, oVar, null), 3);
                    }
                    G0(keyEvent);
                }
                if (oVar != null) {
                    return true;
                }
            }
            return false;
        }
        if (c2569d.b(jB)) {
            z6 = false;
        } else {
            z.o oVar2 = new z.o(this.f24933t);
            c2569d.g(jB, oVar2);
            if (this.f24920c != null) {
                V4.E.y(getCoroutineScope(), null, null, new C3037n(this, oVar2, null), 3);
            }
            z6 = true;
        }
        if (!F0(keyEvent) && !z6) {
            return false;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x007d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void z0() {
        z.l lVar = this.f24920c;
        C2569D c2569d = this.f24932s;
        if (lVar != null) {
            z.o oVar = this.f24930q;
            if (oVar != null) {
                ((z.m) lVar).b(new z.n(oVar));
            }
            z.o oVar2 = this.f24934u;
            if (oVar2 != null) {
                ((z.m) lVar).b(new z.n(oVar2));
            }
            C3288h c3288h = this.f24931r;
            if (c3288h != null) {
                ((z.m) lVar).b(new C3289i(c3288h));
            }
            Object[] objArr = c2569d.f21321c;
            long[] jArr = c2569d.f21319a;
            int length = jArr.length - 2;
            if (length >= 0) {
                int i6 = 0;
                while (true) {
                    long j4 = jArr[i6];
                    if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                        int i7 = 8 - ((~(i6 - length)) >>> 31);
                        for (int i8 = 0; i8 < i7; i8++) {
                            if ((255 & j4) < 128) {
                                ((z.m) lVar).b(new z.n((z.o) objArr[(i6 << 3) + i8]));
                            }
                            j4 >>= 8;
                        }
                        if (i7 != 8) {
                            break;
                        } else if (i6 == length) {
                            break;
                        } else {
                            i6++;
                        }
                    }
                }
            }
        }
        this.f24930q = null;
        this.f24934u = null;
        this.f24931r = null;
        c2569d.a();
    }

    public void E0() {
    }

    public void w0(Q0.A a6) {
    }
}
