package ko;

import com.fasterxml.jackson.core.JsonPointer;
import hp.d1;
import hp.h1;
import hp.p1;
import hp.t1;
import tn.e1;
import tn.k0;
import tn.u0;

/* loaded from: classes3.dex */
public abstract class g {
    public static final String a(tn.e klass, b0 typeMappingConfiguration) {
        String I;
        kotlin.jvm.internal.t.g(klass, "klass");
        kotlin.jvm.internal.t.g(typeMappingConfiguration, "typeMappingConfiguration");
        String e10 = typeMappingConfiguration.e(klass);
        if (e10 != null) {
            return e10;
        }
        tn.m b10 = klass.b();
        kotlin.jvm.internal.t.f(b10, "getContainingDeclaration(...)");
        String m10 = ro.h.b(klass.getName()).m();
        kotlin.jvm.internal.t.f(m10, "getIdentifier(...)");
        if (b10 instanceof k0) {
            ro.c d10 = ((k0) b10).d();
            if (d10.d()) {
                return m10;
            }
            StringBuilder sb2 = new StringBuilder();
            String b11 = d10.b();
            kotlin.jvm.internal.t.f(b11, "asString(...)");
            I = kotlin.text.y.I(b11, '.', JsonPointer.SEPARATOR, false, 4, null);
            sb2.append(I);
            sb2.append(JsonPointer.SEPARATOR);
            sb2.append(m10);
            return sb2.toString();
        }
        tn.e eVar = b10 instanceof tn.e ? (tn.e) b10 : null;
        if (eVar == null) {
            throw new IllegalArgumentException("Unexpected container: " + b10 + " for " + klass);
        }
        String d11 = typeMappingConfiguration.d(eVar);
        if (d11 == null) {
            d11 = a(eVar, typeMappingConfiguration);
        }
        return d11 + '$' + m10;
    }

    public static /* synthetic */ String b(tn.e eVar, b0 b0Var, int i10, Object obj) {
        if ((i10 & 2) != 0) {
            b0Var = c0.f26067a;
        }
        return a(eVar, b0Var);
    }

    public static final boolean c(tn.a descriptor) {
        kotlin.jvm.internal.t.g(descriptor, "descriptor");
        if (descriptor instanceof tn.l) {
            return true;
        }
        hp.e0 returnType = descriptor.getReturnType();
        kotlin.jvm.internal.t.d(returnType);
        if (qn.g.C0(returnType)) {
            hp.e0 returnType2 = descriptor.getReturnType();
            kotlin.jvm.internal.t.d(returnType2);
            if (!p1.l(returnType2) && !(descriptor instanceof u0)) {
                return true;
            }
        }
        return false;
    }

    public static final Object d(hp.e0 kotlinType, p factory, d0 mode, b0 typeMappingConfiguration, m mVar, dn.q writeGenericType) {
        Object obj;
        hp.e0 e0Var;
        Object d10;
        kotlin.jvm.internal.t.g(kotlinType, "kotlinType");
        kotlin.jvm.internal.t.g(factory, "factory");
        kotlin.jvm.internal.t.g(mode, "mode");
        kotlin.jvm.internal.t.g(typeMappingConfiguration, "typeMappingConfiguration");
        kotlin.jvm.internal.t.g(writeGenericType, "writeGenericType");
        hp.e0 f10 = typeMappingConfiguration.f(kotlinType);
        if (f10 != null) {
            return d(f10, factory, mode, typeMappingConfiguration, mVar, writeGenericType);
        }
        if (qn.f.r(kotlinType)) {
            return d(qn.k.a(kotlinType), factory, mode, typeMappingConfiguration, mVar, writeGenericType);
        }
        kotlin.reflect.jvm.internal.impl.types.checker.o oVar = kotlin.reflect.jvm.internal.impl.types.checker.o.f26448a;
        Object b10 = e0.b(oVar, kotlinType, factory, mode);
        if (b10 != null) {
            Object a10 = e0.a(factory, b10, mode.d());
            writeGenericType.invoke(kotlinType, a10, mode);
            return a10;
        }
        d1 K0 = kotlinType.K0();
        if (K0 instanceof hp.d0) {
            hp.d0 d0Var = (hp.d0) K0;
            hp.e0 c10 = d0Var.c();
            if (c10 == null) {
                c10 = typeMappingConfiguration.b(d0Var.n());
            }
            return d(kp.a.y(c10), factory, mode, typeMappingConfiguration, mVar, writeGenericType);
        }
        tn.h p10 = K0.p();
        if (p10 == null) {
            throw new UnsupportedOperationException("no descriptor for type constructor of " + kotlinType);
        }
        if (kotlin.reflect.jvm.internal.impl.types.error.k.m(p10)) {
            Object c11 = factory.c("error/NonExistentClass");
            typeMappingConfiguration.c(kotlinType, (tn.e) p10);
            return c11;
        }
        boolean z10 = p10 instanceof tn.e;
        if (z10 && qn.g.c0(kotlinType)) {
            if (kotlinType.I0().size() != 1) {
                throw new UnsupportedOperationException("arrays must have one type argument");
            }
            h1 h1Var = (h1) kotlinType.I0().get(0);
            hp.e0 type = h1Var.getType();
            kotlin.jvm.internal.t.f(type, "getType(...)");
            if (h1Var.a() == t1.IN_VARIANCE) {
                d10 = factory.c("java/lang/Object");
            } else {
                t1 a11 = h1Var.a();
                kotlin.jvm.internal.t.f(a11, "getProjectionKind(...)");
                d10 = d(type, factory, mode.f(a11, true), typeMappingConfiguration, mVar, writeGenericType);
            }
            return factory.b('[' + factory.a(d10));
        }
        if (!z10) {
            if (p10 instanceof e1) {
                hp.e0 j10 = kp.a.j((e1) p10);
                if (kotlinType.L0()) {
                    j10 = kp.a.w(j10);
                }
                return d(j10, factory, mode, typeMappingConfiguration, null, pp.e.b());
            }
            if ((p10 instanceof tn.d1) && mode.b()) {
                return d(((tn.d1) p10).S(), factory, mode, typeMappingConfiguration, mVar, writeGenericType);
            }
            throw new UnsupportedOperationException("Unknown type " + kotlinType);
        }
        if (to.h.b(p10) && !mode.c() && (e0Var = (hp.e0) hp.x.a(oVar, kotlinType)) != null) {
            return d(e0Var, factory, mode.g(), typeMappingConfiguration, mVar, writeGenericType);
        }
        if (mode.e() && qn.g.l0((tn.e) p10)) {
            obj = factory.f();
        } else {
            tn.e eVar = (tn.e) p10;
            tn.e a12 = eVar.a();
            kotlin.jvm.internal.t.f(a12, "getOriginal(...)");
            Object a13 = typeMappingConfiguration.a(a12);
            if (a13 == null) {
                if (eVar.g() == tn.f.ENUM_ENTRY) {
                    tn.m b11 = eVar.b();
                    kotlin.jvm.internal.t.e(b11, "null cannot be cast to non-null type org.jetbrains.kotlin.descriptors.ClassDescriptor");
                    eVar = (tn.e) b11;
                }
                tn.e a14 = eVar.a();
                kotlin.jvm.internal.t.f(a14, "getOriginal(...)");
                obj = factory.c(a(a14, typeMappingConfiguration));
            } else {
                obj = a13;
            }
        }
        writeGenericType.invoke(kotlinType, obj, mode);
        return obj;
    }

    public static /* synthetic */ Object e(hp.e0 e0Var, p pVar, d0 d0Var, b0 b0Var, m mVar, dn.q qVar, int i10, Object obj) {
        if ((i10 & 32) != 0) {
            qVar = pp.e.b();
        }
        return d(e0Var, pVar, d0Var, b0Var, mVar, qVar);
    }
}
