package tn;

import java.util.List;

/* loaded from: classes3.dex */
public abstract class x {

    /* loaded from: classes3.dex */
    /* synthetic */ class a extends kotlin.jvm.internal.p implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final a f36428p = new a();

        a() {
            super(1);
        }

        @Override // kotlin.jvm.internal.f, kn.c
        public final String getName() {
            return "getOuterClassId";
        }

        @Override // kotlin.jvm.internal.f
        public final kn.f getOwner() {
            return kotlin.jvm.internal.p0.b(ro.b.class);
        }

        @Override // kotlin.jvm.internal.f
        public final String getSignature() {
            return "getOuterClassId()Lorg/jetbrains/kotlin/name/ClassId;";
        }

        @Override // dn.l
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public final ro.b invoke(ro.b p02) {
            kotlin.jvm.internal.t.g(p02, "p0");
            return p02.g();
        }
    }

    /* loaded from: classes3.dex */
    static final class b extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final b f36429p = new b();

        b() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Integer invoke(ro.b it) {
            kotlin.jvm.internal.t.g(it, "it");
            return 0;
        }
    }

    public static final e a(g0 g0Var, ro.b classId) {
        kotlin.jvm.internal.t.g(g0Var, "<this>");
        kotlin.jvm.internal.t.g(classId, "classId");
        h b10 = b(g0Var, classId);
        if (b10 instanceof e) {
            return (e) b10;
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x00e6  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0149  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final h b(g0 g0Var, ro.b classId) {
        Object c02;
        Object c03;
        h e10;
        Object c04;
        kotlin.jvm.internal.t.g(g0Var, "<this>");
        kotlin.jvm.internal.t.g(classId, "classId");
        g0 a10 = to.o.a(g0Var);
        if (a10 == null) {
            ro.c h10 = classId.h();
            kotlin.jvm.internal.t.f(h10, "getPackageFqName(...)");
            p0 M = g0Var.M(h10);
            List f10 = classId.i().f();
            kotlin.jvm.internal.t.f(f10, "pathSegments(...)");
            ap.h o10 = M.o();
            c04 = sm.c0.c0(f10);
            kotlin.jvm.internal.t.f(c04, "first(...)");
            e10 = o10.e((ro.f) c04, ao.d.FROM_DESERIALIZATION);
            if (e10 == null) {
                return null;
            }
            for (ro.f fVar : f10.subList(1, f10.size())) {
                if (!(e10 instanceof e)) {
                    return null;
                }
                ap.h v02 = ((e) e10).v0();
                kotlin.jvm.internal.t.d(fVar);
                h e11 = v02.e(fVar, ao.d.FROM_DESERIALIZATION);
                e10 = e11 instanceof e ? (e) e11 : null;
                if (e10 == null) {
                    return null;
                }
            }
        } else {
            ro.c h11 = classId.h();
            kotlin.jvm.internal.t.f(h11, "getPackageFqName(...)");
            p0 M2 = a10.M(h11);
            List f11 = classId.i().f();
            kotlin.jvm.internal.t.f(f11, "pathSegments(...)");
            ap.h o11 = M2.o();
            c02 = sm.c0.c0(f11);
            kotlin.jvm.internal.t.f(c02, "first(...)");
            h e12 = o11.e((ro.f) c02, ao.d.FROM_DESERIALIZATION);
            if (e12 != null) {
                for (ro.f fVar2 : f11.subList(1, f11.size())) {
                    if (e12 instanceof e) {
                        ap.h v03 = ((e) e12).v0();
                        kotlin.jvm.internal.t.d(fVar2);
                        h e13 = v03.e(fVar2, ao.d.FROM_DESERIALIZATION);
                        e12 = e13 instanceof e ? (e) e13 : null;
                        if (e12 != null) {
                        }
                    }
                }
                if (e12 == null) {
                    return e12;
                }
                ro.c h12 = classId.h();
                kotlin.jvm.internal.t.f(h12, "getPackageFqName(...)");
                p0 M3 = g0Var.M(h12);
                List f12 = classId.i().f();
                kotlin.jvm.internal.t.f(f12, "pathSegments(...)");
                ap.h o12 = M3.o();
                c03 = sm.c0.c0(f12);
                kotlin.jvm.internal.t.f(c03, "first(...)");
                e10 = o12.e((ro.f) c03, ao.d.FROM_DESERIALIZATION);
                if (e10 == null) {
                    return null;
                }
                for (ro.f fVar3 : f12.subList(1, f12.size())) {
                    if (!(e10 instanceof e)) {
                        return null;
                    }
                    ap.h v04 = ((e) e10).v0();
                    kotlin.jvm.internal.t.d(fVar3);
                    h e14 = v04.e(fVar3, ao.d.FROM_DESERIALIZATION);
                    e10 = e14 instanceof e ? (e) e14 : null;
                    if (e10 == null) {
                        return null;
                    }
                }
            }
            e12 = null;
            if (e12 == null) {
            }
        }
        return e10;
    }

    public static final e c(g0 g0Var, ro.b classId, j0 notFoundClasses) {
        rp.h i10;
        rp.h x10;
        List E;
        kotlin.jvm.internal.t.g(g0Var, "<this>");
        kotlin.jvm.internal.t.g(classId, "classId");
        kotlin.jvm.internal.t.g(notFoundClasses, "notFoundClasses");
        e a10 = a(g0Var, classId);
        if (a10 != null) {
            return a10;
        }
        i10 = rp.n.i(classId, a.f36428p);
        x10 = rp.p.x(i10, b.f36429p);
        E = rp.p.E(x10);
        return notFoundClasses.d(classId, E);
    }

    public static final d1 d(g0 g0Var, ro.b classId) {
        kotlin.jvm.internal.t.g(g0Var, "<this>");
        kotlin.jvm.internal.t.g(classId, "classId");
        h b10 = b(g0Var, classId);
        if (b10 instanceof d1) {
            return (d1) b10;
        }
        return null;
    }
}
