package nn;

import java.lang.reflect.Method;
import kotlin.reflect.jvm.internal.impl.protobuf.i;
import nn.l;
import nn.m;
import po.a;
import qn.j;
import qo.d;
import tn.t0;
import tn.u0;
import tn.v0;
import tn.z0;

/* loaded from: classes3.dex */
public final class m0 {

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

    /* renamed from: b, reason: collision with root package name */
    private static final ro.b f30219b;

    static {
        ro.b m10 = ro.b.m(new ro.c("java.lang.Void"));
        kotlin.jvm.internal.t.f(m10, "topLevel(...)");
        f30219b = m10;
    }

    private m0() {
    }

    private final qn.h a(Class cls) {
        if (cls.isPrimitive()) {
            return yo.e.get(cls.getSimpleName()).getPrimitiveType();
        }
        return null;
    }

    private final boolean b(tn.y yVar) {
        if (to.e.p(yVar) || to.e.q(yVar)) {
            return true;
        }
        return kotlin.jvm.internal.t.b(yVar.getName(), sn.a.f35877e.a()) && yVar.i().isEmpty();
    }

    private final l.e d(tn.y yVar) {
        return new l.e(new d.b(e(yVar), ko.y.c(yVar, false, false, 1, null)));
    }

    private final String e(tn.b bVar) {
        String b10 = bo.h0.b(bVar);
        if (b10 != null) {
            return b10;
        }
        if (bVar instanceof u0) {
            String e10 = xo.c.t(bVar).getName().e();
            kotlin.jvm.internal.t.f(e10, "asString(...)");
            return bo.a0.b(e10);
        }
        if (bVar instanceof v0) {
            String e11 = xo.c.t(bVar).getName().e();
            kotlin.jvm.internal.t.f(e11, "asString(...)");
            return bo.a0.e(e11);
        }
        String e12 = bVar.getName().e();
        kotlin.jvm.internal.t.f(e12, "asString(...)");
        return e12;
    }

    public final ro.b c(Class klass) {
        kotlin.jvm.internal.t.g(klass, "klass");
        if (klass.isArray()) {
            Class<?> componentType = klass.getComponentType();
            kotlin.jvm.internal.t.f(componentType, "getComponentType(...)");
            qn.h a10 = a(componentType);
            if (a10 != null) {
                return new ro.b(qn.j.f33984y, a10.getArrayTypeName());
            }
            ro.b m10 = ro.b.m(j.a.f34002i.l());
            kotlin.jvm.internal.t.f(m10, "topLevel(...)");
            return m10;
        }
        if (kotlin.jvm.internal.t.b(klass, Void.TYPE)) {
            return f30219b;
        }
        qn.h a11 = a(klass);
        if (a11 != null) {
            return new ro.b(qn.j.f33984y, a11.getTypeName());
        }
        ro.b a12 = yn.d.a(klass);
        if (!a12.k()) {
            sn.c cVar = sn.c.f35881a;
            ro.c b10 = a12.b();
            kotlin.jvm.internal.t.f(b10, "asSingleFqName(...)");
            ro.b m11 = cVar.m(b10);
            if (m11 != null) {
                return m11;
            }
        }
        return a12;
    }

    public final m f(t0 possiblyOverriddenProperty) {
        kotlin.jvm.internal.t.g(possiblyOverriddenProperty, "possiblyOverriddenProperty");
        t0 a10 = ((t0) to.f.L(possiblyOverriddenProperty)).a();
        kotlin.jvm.internal.t.f(a10, "getOriginal(...)");
        if (a10 instanceof fp.j) {
            fp.j jVar = (fp.j) a10;
            mo.n A = jVar.A();
            i.f propertySignature = po.a.f32941d;
            kotlin.jvm.internal.t.f(propertySignature, "propertySignature");
            a.d dVar = (a.d) oo.e.a(A, propertySignature);
            if (dVar != null) {
                return new m.c(a10, A, dVar, jVar.V(), jVar.P());
            }
        } else if (a10 instanceof p002do.f) {
            z0 source = ((p002do.f) a10).getSource();
            ho.a aVar = source instanceof ho.a ? (ho.a) source : null;
            io.l b10 = aVar != null ? aVar.b() : null;
            if (b10 instanceof yn.r) {
                return new m.a(((yn.r) b10).S());
            }
            if (b10 instanceof yn.u) {
                Method S = ((yn.u) b10).S();
                v0 f10 = a10.f();
                z0 source2 = f10 != null ? f10.getSource() : null;
                ho.a aVar2 = source2 instanceof ho.a ? (ho.a) source2 : null;
                io.l b11 = aVar2 != null ? aVar2.b() : null;
                yn.u uVar = b11 instanceof yn.u ? (yn.u) b11 : null;
                return new m.b(S, uVar != null ? uVar.S() : null);
            }
            throw new h0("Incorrect resolution sequence for Java field " + a10 + " (source = " + b10 + ')');
        }
        u0 getter = a10.getGetter();
        kotlin.jvm.internal.t.d(getter);
        l.e d10 = d(getter);
        v0 f11 = a10.f();
        return new m.d(d10, f11 != null ? d(f11) : null);
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x0099, code lost:
    
        if (r8 != false) goto L27;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final l g(tn.y possiblySubstitutedFunction) {
        Method S;
        d.b b10;
        boolean y10;
        boolean y11;
        String z02;
        boolean y12;
        d.b e10;
        kotlin.jvm.internal.t.g(possiblySubstitutedFunction, "possiblySubstitutedFunction");
        tn.y a10 = ((tn.y) to.f.L(possiblySubstitutedFunction)).a();
        kotlin.jvm.internal.t.f(a10, "getOriginal(...)");
        if (!(a10 instanceof fp.b)) {
            if (a10 instanceof p002do.e) {
                z0 source = ((p002do.e) a10).getSource();
                ho.a aVar = source instanceof ho.a ? (ho.a) source : null;
                io.l b11 = aVar != null ? aVar.b() : null;
                yn.u uVar = b11 instanceof yn.u ? (yn.u) b11 : null;
                if (uVar != null && (S = uVar.S()) != null) {
                    return new l.c(S);
                }
                throw new h0("Incorrect resolution sequence for Java method " + a10);
            }
            if (!(a10 instanceof p002do.b)) {
                if (b(a10)) {
                    return d(a10);
                }
                throw new h0("Unknown origin of " + a10 + " (" + a10.getClass() + ')');
            }
            z0 source2 = ((p002do.b) a10).getSource();
            ho.a aVar2 = source2 instanceof ho.a ? (ho.a) source2 : null;
            io.l b12 = aVar2 != null ? aVar2.b() : null;
            if (b12 instanceof yn.o) {
                return new l.b(((yn.o) b12).S());
            }
            if (b12 instanceof yn.l) {
                yn.l lVar = (yn.l) b12;
                if (lVar.p()) {
                    return new l.a(lVar.u());
                }
            }
            throw new h0("Incorrect resolution sequence for Java constructor " + a10 + " (" + b12 + ')');
        }
        fp.b bVar = (fp.b) a10;
        kotlin.reflect.jvm.internal.impl.protobuf.p A = bVar.A();
        if ((A instanceof mo.i) && (e10 = qo.i.f34072a.e((mo.i) A, bVar.V(), bVar.P())) != null) {
            return new l.e(e10);
        }
        if (!(A instanceof mo.d) || (b10 = qo.i.f34072a.b((mo.d) A, bVar.V(), bVar.P())) == null) {
            return d(a10);
        }
        tn.m b13 = possiblySubstitutedFunction.b();
        kotlin.jvm.internal.t.f(b13, "getContainingDeclaration(...)");
        if (to.h.b(b13)) {
            return new l.e(b10);
        }
        tn.m b14 = possiblySubstitutedFunction.b();
        kotlin.jvm.internal.t.f(b14, "getContainingDeclaration(...)");
        if (!to.h.d(b14)) {
            return new l.d(b10);
        }
        tn.l lVar2 = (tn.l) possiblySubstitutedFunction;
        boolean z10 = true;
        if (lVar2.w()) {
            if (kotlin.jvm.internal.t.b(b10.c(), "constructor-impl")) {
                y12 = kotlin.text.y.y(b10.b(), ")V", false, 2, null);
            }
            z10 = false;
            if (!z10) {
                throw new IllegalArgumentException(("Invalid signature: " + b10).toString());
            }
        } else {
            if (!kotlin.jvm.internal.t.b(b10.c(), "constructor-impl")) {
                throw new IllegalArgumentException(("Invalid signature: " + b10).toString());
            }
            tn.e x10 = lVar2.x();
            kotlin.jvm.internal.t.f(x10, "getConstructedClass(...)");
            String t10 = on.k.t(x10);
            y10 = kotlin.text.y.y(b10.b(), ")V", false, 2, null);
            if (y10) {
                StringBuilder sb2 = new StringBuilder();
                z02 = kotlin.text.z.z0(b10.b(), "V");
                sb2.append(z02);
                sb2.append(t10);
                b10 = d.b.e(b10, null, sb2.toString(), 1, null);
            } else {
                y11 = kotlin.text.y.y(b10.b(), t10, false, 2, null);
                if (!y11) {
                    throw new IllegalArgumentException(("Invalid signature: " + b10).toString());
                }
            }
        }
        return new l.e(b10);
    }
}
