package xn;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Set;
import ko.t;
import kotlin.jvm.internal.t;
import qn.j;
import sm.p;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class c {

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

    private c() {
    }

    private final vo.f a(Class cls) {
        int i10 = 0;
        while (cls.isArray()) {
            i10++;
            cls = cls.getComponentType();
            t.f(cls, "getComponentType(...)");
        }
        if (!cls.isPrimitive()) {
            ro.b a10 = yn.d.a(cls);
            sn.c cVar = sn.c.f35881a;
            ro.c b10 = a10.b();
            t.f(b10, "asSingleFqName(...)");
            ro.b m10 = cVar.m(b10);
            if (m10 != null) {
                a10 = m10;
            }
            return new vo.f(a10, i10);
        }
        if (t.b(cls, Void.TYPE)) {
            ro.b m11 = ro.b.m(j.a.f33996f.l());
            t.f(m11, "topLevel(...)");
            return new vo.f(m11, i10);
        }
        qn.h primitiveType = yo.e.get(cls.getName()).getPrimitiveType();
        t.f(primitiveType, "getPrimitiveType(...)");
        if (i10 > 0) {
            ro.b m12 = ro.b.m(primitiveType.getArrayTypeFqName());
            t.f(m12, "topLevel(...)");
            return new vo.f(m12, i10 - 1);
        }
        ro.b m13 = ro.b.m(primitiveType.getTypeFqName());
        t.f(m13, "topLevel(...)");
        return new vo.f(m13, i10);
    }

    private final void c(Class cls, t.d dVar) {
        Constructor<?>[] constructorArr;
        int i10;
        Constructor<?>[] declaredConstructors = cls.getDeclaredConstructors();
        kotlin.jvm.internal.t.f(declaredConstructors, "getDeclaredConstructors(...)");
        int length = declaredConstructors.length;
        int i11 = 0;
        while (i11 < length) {
            Constructor<?> constructor = declaredConstructors[i11];
            ro.f fVar = ro.h.f34974i;
            m mVar = m.f50945a;
            kotlin.jvm.internal.t.d(constructor);
            t.e a10 = dVar.a(fVar, mVar.a(constructor));
            if (a10 == null) {
                constructorArr = declaredConstructors;
                i10 = length;
            } else {
                Annotation[] declaredAnnotations = constructor.getDeclaredAnnotations();
                kotlin.jvm.internal.t.f(declaredAnnotations, "getDeclaredAnnotations(...)");
                for (Annotation annotation : declaredAnnotations) {
                    kotlin.jvm.internal.t.d(annotation);
                    f(a10, annotation);
                }
                Annotation[][] parameterAnnotations = constructor.getParameterAnnotations();
                kotlin.jvm.internal.t.d(parameterAnnotations);
                if (!(parameterAnnotations.length == 0)) {
                    int length2 = constructor.getParameterTypes().length - parameterAnnotations.length;
                    int length3 = parameterAnnotations.length;
                    for (int i12 = 0; i12 < length3; i12++) {
                        Annotation[] annotationArr = parameterAnnotations[i12];
                        kotlin.jvm.internal.t.d(annotationArr);
                        int length4 = annotationArr.length;
                        int i13 = 0;
                        while (i13 < length4) {
                            Annotation annotation2 = annotationArr[i13];
                            Class b10 = cn.a.b(cn.a.a(annotation2));
                            Constructor<?>[] constructorArr2 = declaredConstructors;
                            ro.b a11 = yn.d.a(b10);
                            int i14 = length;
                            kotlin.jvm.internal.t.d(annotation2);
                            t.a c10 = a10.c(i12 + length2, a11, new b(annotation2));
                            if (c10 != null) {
                                f50931a.h(c10, annotation2, b10);
                            }
                            i13++;
                            declaredConstructors = constructorArr2;
                            length = i14;
                        }
                    }
                }
                constructorArr = declaredConstructors;
                i10 = length;
                a10.a();
            }
            i11++;
            declaredConstructors = constructorArr;
            length = i10;
        }
    }

    private final void d(Class cls, t.d dVar) {
        Field[] declaredFields = cls.getDeclaredFields();
        kotlin.jvm.internal.t.f(declaredFields, "getDeclaredFields(...)");
        for (Field field : declaredFields) {
            ro.f s10 = ro.f.s(field.getName());
            kotlin.jvm.internal.t.f(s10, "identifier(...)");
            m mVar = m.f50945a;
            kotlin.jvm.internal.t.d(field);
            t.c b10 = dVar.b(s10, mVar.b(field), null);
            if (b10 != null) {
                Annotation[] declaredAnnotations = field.getDeclaredAnnotations();
                kotlin.jvm.internal.t.f(declaredAnnotations, "getDeclaredAnnotations(...)");
                for (Annotation annotation : declaredAnnotations) {
                    kotlin.jvm.internal.t.d(annotation);
                    f(b10, annotation);
                }
                b10.a();
            }
        }
    }

    private final void e(Class cls, t.d dVar) {
        Method[] declaredMethods = cls.getDeclaredMethods();
        kotlin.jvm.internal.t.f(declaredMethods, "getDeclaredMethods(...)");
        for (Method method : declaredMethods) {
            ro.f s10 = ro.f.s(method.getName());
            kotlin.jvm.internal.t.f(s10, "identifier(...)");
            m mVar = m.f50945a;
            kotlin.jvm.internal.t.d(method);
            t.e a10 = dVar.a(s10, mVar.c(method));
            if (a10 != null) {
                Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
                kotlin.jvm.internal.t.f(declaredAnnotations, "getDeclaredAnnotations(...)");
                for (Annotation annotation : declaredAnnotations) {
                    kotlin.jvm.internal.t.d(annotation);
                    f(a10, annotation);
                }
                Annotation[][] parameterAnnotations = method.getParameterAnnotations();
                kotlin.jvm.internal.t.f(parameterAnnotations, "getParameterAnnotations(...)");
                Annotation[][] annotationArr = parameterAnnotations;
                int length = annotationArr.length;
                for (int i10 = 0; i10 < length; i10++) {
                    Annotation[] annotationArr2 = annotationArr[i10];
                    kotlin.jvm.internal.t.d(annotationArr2);
                    for (Annotation annotation2 : annotationArr2) {
                        Class b10 = cn.a.b(cn.a.a(annotation2));
                        ro.b a11 = yn.d.a(b10);
                        kotlin.jvm.internal.t.d(annotation2);
                        t.a c10 = a10.c(i10, a11, new b(annotation2));
                        if (c10 != null) {
                            f50931a.h(c10, annotation2, b10);
                        }
                    }
                }
                a10.a();
            }
        }
    }

    private final void f(t.c cVar, Annotation annotation) {
        Class b10 = cn.a.b(cn.a.a(annotation));
        t.a b11 = cVar.b(yn.d.a(b10), new b(annotation));
        if (b11 != null) {
            f50931a.h(b11, annotation, b10);
        }
    }

    private final void g(t.a aVar, ro.f fVar, Object obj) {
        Set set;
        Object v02;
        Class<?> cls = obj.getClass();
        if (kotlin.jvm.internal.t.b(cls, Class.class)) {
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type java.lang.Class<*>");
            aVar.b(fVar, a((Class) obj));
            return;
        }
        set = i.f50938a;
        if (set.contains(cls)) {
            aVar.f(fVar, obj);
            return;
        }
        if (yn.d.h(cls)) {
            if (!cls.isEnum()) {
                cls = cls.getEnclosingClass();
            }
            kotlin.jvm.internal.t.d(cls);
            ro.b a10 = yn.d.a(cls);
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type kotlin.Enum<*>");
            ro.f s10 = ro.f.s(((Enum) obj).name());
            kotlin.jvm.internal.t.f(s10, "identifier(...)");
            aVar.c(fVar, a10, s10);
            return;
        }
        if (Annotation.class.isAssignableFrom(cls)) {
            Class<?>[] interfaces = cls.getInterfaces();
            kotlin.jvm.internal.t.f(interfaces, "getInterfaces(...)");
            v02 = p.v0(interfaces);
            Class cls2 = (Class) v02;
            kotlin.jvm.internal.t.d(cls2);
            t.a e10 = aVar.e(fVar, yn.d.a(cls2));
            if (e10 == null) {
                return;
            }
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type kotlin.Annotation");
            h(e10, (Annotation) obj, cls2);
            return;
        }
        if (!cls.isArray()) {
            throw new UnsupportedOperationException("Unsupported annotation argument value (" + cls + "): " + obj);
        }
        t.b d10 = aVar.d(fVar);
        if (d10 == null) {
            return;
        }
        Class<?> componentType = cls.getComponentType();
        int i10 = 0;
        if (componentType.isEnum()) {
            kotlin.jvm.internal.t.d(componentType);
            ro.b a11 = yn.d.a(componentType);
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type kotlin.Array<*>");
            Object[] objArr = (Object[]) obj;
            int length = objArr.length;
            while (i10 < length) {
                Object obj2 = objArr[i10];
                kotlin.jvm.internal.t.e(obj2, "null cannot be cast to non-null type kotlin.Enum<*>");
                ro.f s11 = ro.f.s(((Enum) obj2).name());
                kotlin.jvm.internal.t.f(s11, "identifier(...)");
                d10.b(a11, s11);
                i10++;
            }
        } else if (kotlin.jvm.internal.t.b(componentType, Class.class)) {
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type kotlin.Array<*>");
            Object[] objArr2 = (Object[]) obj;
            int length2 = objArr2.length;
            while (i10 < length2) {
                Object obj3 = objArr2[i10];
                kotlin.jvm.internal.t.e(obj3, "null cannot be cast to non-null type java.lang.Class<*>");
                d10.c(a((Class) obj3));
                i10++;
            }
        } else if (Annotation.class.isAssignableFrom(componentType)) {
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type kotlin.Array<*>");
            Object[] objArr3 = (Object[]) obj;
            int length3 = objArr3.length;
            while (i10 < length3) {
                Object obj4 = objArr3[i10];
                kotlin.jvm.internal.t.d(componentType);
                t.a e11 = d10.e(yn.d.a(componentType));
                if (e11 != null) {
                    kotlin.jvm.internal.t.e(obj4, "null cannot be cast to non-null type kotlin.Annotation");
                    h(e11, (Annotation) obj4, componentType);
                }
                i10++;
            }
        } else {
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type kotlin.Array<*>");
            Object[] objArr4 = (Object[]) obj;
            int length4 = objArr4.length;
            while (i10 < length4) {
                d10.d(objArr4[i10]);
                i10++;
            }
        }
        d10.a();
    }

    private final void h(t.a aVar, Annotation annotation, Class cls) {
        Method[] declaredMethods = cls.getDeclaredMethods();
        kotlin.jvm.internal.t.f(declaredMethods, "getDeclaredMethods(...)");
        for (Method method : declaredMethods) {
            try {
                Object invoke = method.invoke(annotation, new Object[0]);
                kotlin.jvm.internal.t.d(invoke);
                ro.f s10 = ro.f.s(method.getName());
                kotlin.jvm.internal.t.f(s10, "identifier(...)");
                g(aVar, s10, invoke);
            } catch (IllegalAccessException unused) {
            }
        }
        aVar.a();
    }

    public final void b(Class klass, t.c visitor) {
        kotlin.jvm.internal.t.g(klass, "klass");
        kotlin.jvm.internal.t.g(visitor, "visitor");
        Annotation[] declaredAnnotations = klass.getDeclaredAnnotations();
        kotlin.jvm.internal.t.f(declaredAnnotations, "getDeclaredAnnotations(...)");
        for (Annotation annotation : declaredAnnotations) {
            kotlin.jvm.internal.t.d(annotation);
            f(visitor, annotation);
        }
        visitor.a();
    }

    public final void i(Class klass, t.d memberVisitor) {
        kotlin.jvm.internal.t.g(klass, "klass");
        kotlin.jvm.internal.t.g(memberVisitor, "memberVisitor");
        e(klass, memberVisitor);
        c(klass, memberVisitor);
        d(klass, memberVisitor);
    }
}
