package androidx.compose.ui.focus;

import androidx.compose.ui.focus.d;
import com.google.firebase.crashlytics.internal.metadata.UserMetadata;
import h2.e;
import j2.b1;
import j2.g0;
import j2.x0;
import l1.i;

/* loaded from: classes.dex */
public abstract class a {
    public static final Object a(FocusTargetNode focusTargetNode, int i10, dn.l lVar) {
        i.c cVar;
        h2.e n22;
        int c10;
        x0 k02;
        int a10 = b1.a(UserMetadata.MAX_ATTRIBUTE_SIZE);
        if (!focusTargetNode.P0().O1()) {
            throw new IllegalStateException("visitAncestors called on an unattached node".toString());
        }
        i.c L1 = focusTargetNode.P0().L1();
        g0 m10 = j2.k.m(focusTargetNode);
        loop0: while (true) {
            if (m10 == null) {
                cVar = null;
                break;
            }
            if ((m10.k0().k().E1() & a10) != 0) {
                while (L1 != null) {
                    if ((L1.J1() & a10) != 0) {
                        cVar = L1;
                        a1.b bVar = null;
                        while (cVar != null) {
                            if (cVar instanceof FocusTargetNode) {
                                break loop0;
                            }
                            if (((cVar.J1() & a10) != 0) && (cVar instanceof j2.m)) {
                                int i11 = 0;
                                for (i.c i22 = ((j2.m) cVar).i2(); i22 != null; i22 = i22.F1()) {
                                    if ((i22.J1() & a10) != 0) {
                                        i11++;
                                        if (i11 == 1) {
                                            cVar = i22;
                                        } else {
                                            if (bVar == null) {
                                                bVar = new a1.b(new i.c[16], 0);
                                            }
                                            if (cVar != null) {
                                                bVar.c(cVar);
                                                cVar = null;
                                            }
                                            bVar.c(i22);
                                        }
                                    }
                                }
                                if (i11 == 1) {
                                }
                            }
                            cVar = j2.k.g(bVar);
                        }
                    }
                    L1 = L1.L1();
                }
            }
            m10 = m10.o0();
            L1 = (m10 == null || (k02 = m10.k0()) == null) ? null : k02.o();
        }
        FocusTargetNode focusTargetNode2 = (FocusTargetNode) cVar;
        if ((focusTargetNode2 != null && kotlin.jvm.internal.t.b(focusTargetNode2.n2(), focusTargetNode.n2())) || (n22 = focusTargetNode.n2()) == null) {
            return null;
        }
        d.a aVar = d.f2163b;
        if (d.l(i10, aVar.h())) {
            c10 = e.b.f20677a.a();
        } else if (d.l(i10, aVar.a())) {
            c10 = e.b.f20677a.d();
        } else if (d.l(i10, aVar.d())) {
            c10 = e.b.f20677a.e();
        } else if (d.l(i10, aVar.g())) {
            c10 = e.b.f20677a.f();
        } else if (d.l(i10, aVar.e())) {
            c10 = e.b.f20677a.b();
        } else {
            if (!d.l(i10, aVar.f())) {
                throw new IllegalStateException("Unsupported direction for beyond bounds layout".toString());
            }
            c10 = e.b.f20677a.c();
        }
        return n22.c(c10, lVar);
    }
}
