package h;

import d.AbstractC0421a;
import d.C0424d;
import d.C0425e;
import g.C0474a;
import g.EnumC0475b;
import g.InterfaceC0476c;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/* JADX INFO: loaded from: classes.dex */
public class r implements t {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static r f4173a = new r();

    public static Object f(C0474a c0474a, Map map, Type type, Type type2, Object obj) {
        Object objB;
        InterfaceC0476c interfaceC0476c = c0474a.f3944H;
        if (interfaceC0476c.F() != 12 && interfaceC0476c.F() != 16) {
            throw new C0424d("syntax error, expect {, actual " + interfaceC0476c.U());
        }
        t tVarN = c0474a.i().n(type);
        t tVarN2 = c0474a.i().n(type2);
        interfaceC0476c.s(tVarN.d());
        g.h hVarJ = c0474a.j();
        while (interfaceC0476c.F() != 13) {
            try {
                Object obj2 = null;
                if (interfaceC0476c.F() == 4 && interfaceC0476c.Y() && !interfaceC0476c.j(EnumC0475b.DisableSpecialKeyDetect)) {
                    interfaceC0476c.z(4);
                    if (interfaceC0476c.F() != 4) {
                        throw new C0424d("illegal ref, " + g.g.a(interfaceC0476c.F()));
                    }
                    String strA = interfaceC0476c.A();
                    if ("..".equals(strA)) {
                        obj2 = hVarJ.f3985b.f3984a;
                    } else if ("$".equals(strA)) {
                        g.h hVar = hVarJ;
                        while (true) {
                            g.h hVar2 = hVar.f3985b;
                            if (hVar2 == null) {
                                break;
                            }
                            hVar = hVar2;
                        }
                        obj2 = hVar.f3984a;
                    } else {
                        c0474a.e(new C0474a.C0072a(hVarJ, strA));
                        c0474a.e0(1);
                    }
                    interfaceC0476c.s(13);
                    if (interfaceC0476c.F() != 13) {
                        throw new C0424d("illegal ref");
                    }
                    interfaceC0476c.s(16);
                    return obj2;
                }
                if (map.size() == 0 && interfaceC0476c.F() == 4 && AbstractC0421a.f3675r.equals(interfaceC0476c.A()) && !interfaceC0476c.j(EnumC0475b.DisableSpecialKeyDetect)) {
                    interfaceC0476c.z(4);
                    interfaceC0476c.s(16);
                    if (interfaceC0476c.F() == 13) {
                        interfaceC0476c.i();
                        return map;
                    }
                    interfaceC0476c.s(tVarN.d());
                }
                if (interfaceC0476c.F() == 4 && (tVarN instanceof o)) {
                    String strA2 = interfaceC0476c.A();
                    interfaceC0476c.i();
                    C0474a c0474a2 = new C0474a(strA2, c0474a.i(), c0474a.s().I());
                    c0474a2.c0(c0474a.l());
                    objB = tVarN.b(c0474a2, type, null);
                } else {
                    objB = tVarN.b(c0474a, type, null);
                }
                if (interfaceC0476c.F() != 17) {
                    throw new C0424d("syntax error, expect :, actual " + interfaceC0476c.F());
                }
                interfaceC0476c.s(tVarN2.d());
                Object objB2 = tVarN2.b(c0474a, type2, objB);
                c0474a.h(map, objB);
                map.put(objB, objB2);
                if (interfaceC0476c.F() == 16) {
                    interfaceC0476c.s(tVarN.d());
                }
            } finally {
                c0474a.a0(hVarJ);
            }
        }
        interfaceC0476c.s(16);
        return map;
    }

    /* JADX WARN: Code restructure failed: missing block: B:94:0x0202, code lost:
    
        return r11;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static java.util.Map g(g.C0474a r10, java.util.Map r11, java.lang.reflect.Type r12, java.lang.Object r13) {
        /*
            Method dump skipped, instruction units count: 558
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: h.r.g(g.a, java.util.Map, java.lang.reflect.Type, java.lang.Object):java.util.Map");
    }

    public Map a(Type type) {
        return c(type, AbstractC0421a.f3669I);
    }

    @Override // h.t
    public Object b(C0474a c0474a, Type type, Object obj) {
        if (type == C0425e.class) {
            c0474a.n();
            return c0474a.L();
        }
        InterfaceC0476c interfaceC0476c = c0474a.f3944H;
        if (interfaceC0476c.F() == 8) {
            interfaceC0476c.s(16);
            return null;
        }
        boolean z2 = (type instanceof Class) && "java.util.Collections$UnmodifiableMap".equals(((Class) type).getName());
        Map mapC = (interfaceC0476c.I() & EnumC0475b.OrderedField.mask) != 0 ? c(type, interfaceC0476c.I()) : a(type);
        g.h hVarJ = c0474a.j();
        try {
            c0474a.X(hVarJ, mapC, obj);
            Object objE = e(c0474a, type, obj, mapC);
            if (z2) {
                objE = Collections.unmodifiableMap((Map) objE);
            }
            return objE;
        } finally {
            c0474a.a0(hVarJ);
        }
    }

    public Map c(Type type, int i2) {
        if (type == Properties.class) {
            return new Properties();
        }
        if (type == Hashtable.class) {
            return new Hashtable();
        }
        if (type == IdentityHashMap.class) {
            return new IdentityHashMap();
        }
        if (type == SortedMap.class || type == TreeMap.class) {
            return new TreeMap();
        }
        if (type == ConcurrentMap.class || type == ConcurrentHashMap.class) {
            return new ConcurrentHashMap();
        }
        if (type == Map.class) {
            return (EnumC0475b.OrderedField.mask & i2) != 0 ? new LinkedHashMap() : new HashMap();
        }
        if (type == HashMap.class) {
            return new HashMap();
        }
        if (type == LinkedHashMap.class) {
            return new LinkedHashMap();
        }
        if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) type;
            Type rawType = parameterizedType.getRawType();
            return EnumMap.class.equals(rawType) ? new EnumMap((Class) parameterizedType.getActualTypeArguments()[0]) : c(rawType, i2);
        }
        Class cls = (Class) type;
        if (cls.isInterface()) {
            throw new C0424d("unsupport type " + type);
        }
        if ("java.util.Collections$UnmodifiableMap".equals(cls.getName())) {
            return new HashMap();
        }
        try {
            return (Map) cls.newInstance();
        } catch (Exception e2) {
            throw new C0424d("unsupport type " + type, e2);
        }
    }

    @Override // h.t
    public int d() {
        return 12;
    }

    protected Object e(C0474a c0474a, Type type, Object obj, Map map) {
        if (!(type instanceof ParameterizedType)) {
            return c0474a.R(map, obj);
        }
        ParameterizedType parameterizedType = (ParameterizedType) type;
        Type type2 = parameterizedType.getActualTypeArguments()[0];
        Type type3 = map.getClass().getName().equals("org.springframework.util.LinkedMultiValueMap") ? List.class : parameterizedType.getActualTypeArguments()[1];
        return String.class == type2 ? g(c0474a, map, type3, obj) : f(c0474a, map, type2, type3, obj);
    }
}
