package defpackage;

import defpackage.bj4;
import defpackage.fj4;
import java.io.Serializable;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes2.dex */
@hi2
final class f1a {
    public static final cy4 a = new cy4(", ").e();

    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    public static abstract class a {
        public static final a a;
        public static final /* synthetic */ a[] b = {new C0137a(), new b()};

        /* JADX INFO: Fake field, exist only in values array */
        a EF2;

        /* JADX INFO: renamed from: f1a$a$a, reason: collision with other inner class name */
        public enum C0137a extends a {
            public C0137a() {
                super("OWNED_BY_ENCLOSING_CLASS", 0);
            }

            @Override // f1a.a
            public final Class a(Class cls) {
                return cls.getEnclosingClass();
            }
        }

        public enum b extends a {
            public b() {
                super("LOCAL_CLASS_HAS_NO_OWNER", 1);
            }

            @Override // f1a.a
            public final Class a(Class cls) {
                if (cls.isLocalClass()) {
                    return null;
                }
                return cls.getEnclosingClass();
            }
        }

        static {
            ParameterizedType parameterizedType = (ParameterizedType) h1a.class.getGenericSuperclass();
            Objects.requireNonNull(parameterizedType);
            for (a aVar : values()) {
                if (aVar.a(g1a.class) == parameterizedType.getOwnerType()) {
                    a = aVar;
                    return;
                }
            }
            throw new AssertionError();
        }

        public static a valueOf(String str) {
            return (a) Enum.valueOf(a.class, str);
        }

        public static a[] values() {
            return (a[]) b.clone();
        }

        public abstract Class a(Class cls);
    }

    public static final class b implements GenericArrayType, Serializable {
        public final Type a;

        public b(Type type) {
            this.a = c.c.d(type);
        }

        public final boolean equals(Object obj) {
            if (obj instanceof GenericArrayType) {
                return ts6.a(this.a, ((GenericArrayType) obj).getGenericComponentType());
            }
            return false;
        }

        @Override // java.lang.reflect.GenericArrayType
        public final Type getGenericComponentType() {
            return this.a;
        }

        public final int hashCode() {
            return this.a.hashCode();
        }

        public final String toString() {
            StringBuilder sb = new StringBuilder();
            cy4 cy4Var = f1a.a;
            Type type = this.a;
            return n41.s(sb, type instanceof Class ? ((Class) type).getName() : type.toString(), HttpUrl.PATH_SEGMENT_ENCODE_SET_URI);
        }
    }

    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    public static abstract class c {
        public static final b a;
        public static final C0138c b;
        public static final c c;
        public static final /* synthetic */ c[] d;

        public enum a extends c {
            public a() {
                super("JAVA6", 0);
            }

            @Override // f1a.c
            public final Type a(Type type) {
                return new b(type);
            }

            @Override // f1a.c
            public final Type d(Type type) {
                type.getClass();
                if (!(type instanceof Class)) {
                    return type;
                }
                Class cls = (Class) type;
                return cls.isArray() ? new b(cls.getComponentType()) : type;
            }
        }

        public enum b extends c {
            public b() {
                super("JAVA7", 1);
            }

            @Override // f1a.c
            public final Type a(Type type) {
                if (!(type instanceof Class)) {
                    return new b(type);
                }
                cy4 cy4Var = f1a.a;
                return Array.newInstance((Class<?>) type, 0).getClass();
            }

            @Override // f1a.c
            public final Type d(Type type) {
                type.getClass();
                return type;
            }
        }

        /* JADX INFO: renamed from: f1a$c$c, reason: collision with other inner class name */
        public enum C0138c extends c {
            public C0138c() {
                super("JAVA8", 2);
            }

            @Override // f1a.c
            public final Type a(Type type) {
                return c.a.a(type);
            }

            @Override // f1a.c
            public final String b(Type type) {
                try {
                    return (String) Type.class.getMethod("getTypeName", null).invoke(type, null);
                } catch (IllegalAccessException e) {
                    e = e;
                    throw new RuntimeException(e);
                } catch (NoSuchMethodException unused) {
                    throw new AssertionError("Type.getTypeName should be available in Java 8");
                } catch (InvocationTargetException e2) {
                    e = e2;
                    throw new RuntimeException(e);
                }
            }

            @Override // f1a.c
            public final Type d(Type type) {
                type.getClass();
                return type;
            }
        }

        public enum d extends c {
            public d() {
                super("JAVA9", 3);
            }

            @Override // f1a.c
            public final Type a(Type type) {
                return c.a.a(type);
            }

            @Override // f1a.c
            public final String b(Type type) {
                return c.b.b(type);
            }

            @Override // f1a.c
            public final Type d(Type type) {
                type.getClass();
                return type;
            }
        }

        public class e extends bz9<Map.Entry<String, int[][]>> {
        }

        public class f extends bz9<int[]> {
        }

        static {
            a aVar = new a();
            b bVar = new b();
            a = bVar;
            C0138c c0138c = new C0138c();
            b = c0138c;
            d dVar = new d();
            d = new c[]{aVar, bVar, c0138c, dVar};
            if (AnnotatedElement.class.isAssignableFrom(TypeVariable.class)) {
                Type genericSuperclass = e.class.getGenericSuperclass();
                if7.h(genericSuperclass instanceof ParameterizedType, "%s isn't parameterized", genericSuperclass);
                if (((ParameterizedType) genericSuperclass).getActualTypeArguments()[0].toString().contains("java.util.Map.java.util.Map")) {
                    c = c0138c;
                    return;
                } else {
                    c = dVar;
                    return;
                }
            }
            Type genericSuperclass2 = f.class.getGenericSuperclass();
            if7.h(genericSuperclass2 instanceof ParameterizedType, "%s isn't parameterized", genericSuperclass2);
            if (((ParameterizedType) genericSuperclass2).getActualTypeArguments()[0] instanceof Class) {
                c = bVar;
            } else {
                c = aVar;
            }
        }

        public static c valueOf(String str) {
            return (c) Enum.valueOf(c.class, str);
        }

        public static c[] values() {
            return (c[]) d.clone();
        }

        public abstract Type a(Type type);

        public String b(Type type) {
            cy4 cy4Var = f1a.a;
            return type instanceof Class ? ((Class) type).getName() : type.toString();
        }

        public final bj4 c(Type[] typeArr) {
            bj4.a aVarI = bj4.i();
            for (Type type : typeArr) {
                aVarI.h(d(type));
            }
            return aVarI.j();
        }

        public abstract Type d(Type type);
    }

    public static final class d<X> {
        public static final boolean a = !d.class.getTypeParameters()[0].equals(f1a.d(d.class, "X", new Type[0]));
    }

    public static final class e implements ParameterizedType, Serializable {
        public final Type a;
        public final bj4 b;
        public final Class c;

        public e(Type type, Class cls, Type[] typeArr) {
            cls.getClass();
            if7.e(typeArr.length == cls.getTypeParameters().length);
            f1a.b(typeArr, "type parameter");
            this.a = type;
            this.c = cls;
            this.b = c.c.c(typeArr);
        }

        public final boolean equals(Object obj) {
            if (obj instanceof ParameterizedType) {
                ParameterizedType parameterizedType = (ParameterizedType) obj;
                if (this.c.equals(parameterizedType.getRawType()) && ts6.a(this.a, parameterizedType.getOwnerType())) {
                    cy4 cy4Var = f1a.a;
                    if (Arrays.equals((Type[]) this.b.toArray(new Type[0]), parameterizedType.getActualTypeArguments())) {
                        return true;
                    }
                }
            }
            return false;
        }

        @Override // java.lang.reflect.ParameterizedType
        public final Type[] getActualTypeArguments() {
            cy4 cy4Var = f1a.a;
            return (Type[]) this.b.toArray(new Type[0]);
        }

        @Override // java.lang.reflect.ParameterizedType
        public final Type getOwnerType() {
            return this.a;
        }

        @Override // java.lang.reflect.ParameterizedType
        public final Type getRawType() {
            return this.c;
        }

        public final int hashCode() {
            Type type = this.a;
            return ((type == null ? 0 : type.hashCode()) ^ this.b.hashCode()) ^ this.c.hashCode();
        }

        public final String toString() {
            StringBuilder sb = new StringBuilder();
            Type type = this.a;
            if (type != null) {
                c cVar = c.c;
                cVar.getClass();
                if (!(cVar instanceof c.d)) {
                    sb.append(cVar.b(type));
                    sb.append('.');
                }
            }
            sb.append(this.c.getName());
            sb.append('<');
            cy4 cy4Var = f1a.a;
            c cVar2 = c.c;
            Objects.requireNonNull(cVar2);
            sb.append(cy4Var.c(fw4.j(this.b, new ld5(cVar2, 2))));
            sb.append('>');
            return sb.toString();
        }
    }

    public static final class f<D extends GenericDeclaration> {
        public final GenericDeclaration a;
        public final String b;
        public final bj4 c;

        public f(GenericDeclaration genericDeclaration, String str, Type[] typeArr) {
            f1a.b(typeArr, "bound for type variable");
            genericDeclaration.getClass();
            this.a = genericDeclaration;
            str.getClass();
            this.b = str;
            this.c = bj4.m(typeArr);
        }

        public final boolean equals(Object obj) {
            boolean z = d.a;
            GenericDeclaration genericDeclaration = this.a;
            String str = this.b;
            if (!z) {
                if (obj instanceof TypeVariable) {
                    TypeVariable typeVariable = (TypeVariable) obj;
                    if (str.equals(typeVariable.getName()) && genericDeclaration.equals(typeVariable.getGenericDeclaration())) {
                        return true;
                    }
                }
                return false;
            }
            if (obj != null && Proxy.isProxyClass(obj.getClass()) && (Proxy.getInvocationHandler(obj) instanceof g)) {
                f fVar = ((g) Proxy.getInvocationHandler(obj)).a;
                if (str.equals(fVar.b) && genericDeclaration.equals(fVar.a) && this.c.equals(fVar.c)) {
                    return true;
                }
            }
            return false;
        }

        public final int hashCode() {
            return this.a.hashCode() ^ this.b.hashCode();
        }

        public final String toString() {
            return this.b;
        }
    }

    public static final class g implements InvocationHandler {
        public static final fj4 b;
        public final f a;

        static {
            fj4.a aVarA = fj4.a();
            for (Method method : f.class.getMethods()) {
                if (method.getDeclaringClass().equals(f.class)) {
                    try {
                        method.setAccessible(true);
                    } catch (AccessControlException unused) {
                    }
                    aVarA.c(method.getName(), method);
                }
            }
            b = aVarA.a(false);
        }

        public g(f fVar) {
            this.a = fVar;
        }

        @Override // java.lang.reflect.InvocationHandler
        public final Object invoke(Object obj, Method method, Object[] objArr) throws Throwable {
            String name = method.getName();
            Method method2 = (Method) b.get(name);
            if (method2 == null) {
                throw new UnsupportedOperationException(name);
            }
            try {
                return method2.invoke(this.a, objArr);
            } catch (InvocationTargetException e) {
                throw e.getCause();
            }
        }
    }

    public static final class h implements WildcardType, Serializable {
        public final bj4 a;
        public final bj4 b;

        public h(Type[] typeArr, Type[] typeArr2) {
            f1a.b(typeArr, "lower bound for wildcard");
            f1a.b(typeArr2, "upper bound for wildcard");
            c cVar = c.c;
            this.a = cVar.c(typeArr);
            this.b = cVar.c(typeArr2);
        }

        public final boolean equals(Object obj) {
            if (obj instanceof WildcardType) {
                WildcardType wildcardType = (WildcardType) obj;
                if (this.a.equals(Arrays.asList(wildcardType.getLowerBounds()))) {
                    if (this.b.equals(Arrays.asList(wildcardType.getUpperBounds()))) {
                        return true;
                    }
                }
            }
            return false;
        }

        @Override // java.lang.reflect.WildcardType
        public final Type[] getLowerBounds() {
            cy4 cy4Var = f1a.a;
            return (Type[]) this.a.toArray(new Type[0]);
        }

        @Override // java.lang.reflect.WildcardType
        public final Type[] getUpperBounds() {
            cy4 cy4Var = f1a.a;
            return (Type[]) this.b.toArray(new Type[0]);
        }

        public final int hashCode() {
            return this.a.hashCode() ^ this.b.hashCode();
        }

        public final String toString() {
            StringBuilder sb = new StringBuilder("?");
            t7a t7aVarListIterator = this.a.listIterator(0);
            while (t7aVarListIterator.hasNext()) {
                Type type = (Type) t7aVarListIterator.next();
                sb.append(" super ");
                sb.append(c.c.b(type));
            }
            cy4 cy4Var = f1a.a;
            for (Type type2 : fw4.b(this.b, tf7.h(tf7.e(Object.class)))) {
                sb.append(" extends ");
                sb.append(c.c.b(type2));
            }
            return sb.toString();
        }
    }

    public static Type a(Type[] typeArr) {
        for (Type type : typeArr) {
            type.getClass();
            AtomicReference atomicReference = new AtomicReference();
            new e1a(atomicReference).a(type);
            Type type2 = (Type) atomicReference.get();
            if (type2 != null) {
                if (type2 instanceof Class) {
                    Class cls = (Class) type2;
                    if (cls.isPrimitive()) {
                        return cls;
                    }
                }
                return new h(new Type[0], new Type[]{type2});
            }
        }
        return null;
    }

    public static void b(Type[] typeArr, String str) {
        for (Type type : typeArr) {
            if (type instanceof Class) {
                if7.i(!r2.isPrimitive(), "Primitive type '%s' used as %s", (Class) type, str);
            }
        }
    }

    public static Type c(Type type) {
        if (!(type instanceof WildcardType)) {
            return c.c.a(type);
        }
        WildcardType wildcardType = (WildcardType) type;
        Type[] lowerBounds = wildcardType.getLowerBounds();
        if7.f(lowerBounds.length <= 1, "Wildcard cannot have more than one lower bounds.");
        if (lowerBounds.length == 1) {
            return new h(new Type[]{c(lowerBounds[0])}, new Type[]{Object.class});
        }
        Type[] upperBounds = wildcardType.getUpperBounds();
        if7.f(upperBounds.length == 1, "Wildcard should have only one upper bound.");
        return new h(new Type[0], new Type[]{c(upperBounds[0])});
    }

    public static TypeVariable d(GenericDeclaration genericDeclaration, String str, Type... typeArr) {
        if (typeArr.length == 0) {
            typeArr = new Type[]{Object.class};
        }
        g gVar = new g(new f(genericDeclaration, str, typeArr));
        if7.h(TypeVariable.class.isInterface(), "%s is not an interface", TypeVariable.class);
        return (TypeVariable) TypeVariable.class.cast(Proxy.newProxyInstance(TypeVariable.class.getClassLoader(), new Class[]{TypeVariable.class}, gVar));
    }

    public static ParameterizedType e(Type type, Class cls, Type... typeArr) {
        if (type == null) {
            return new e(a.a.a(cls), cls, typeArr);
        }
        if7.h(cls.getEnclosingClass() != null, "Owner type for unenclosed %s", cls);
        return new e(type, cls, typeArr);
    }
}
