package km;

import com.fasterxml.jackson.core.JsonFactory;
import com.google.firebase.perf.util.Constants;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import km.h;
import km.m;

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

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

    /* renamed from: b, reason: collision with root package name */
    static final km.h f26010b = new d();

    /* renamed from: c, reason: collision with root package name */
    static final km.h f26011c = new e();

    /* renamed from: d, reason: collision with root package name */
    static final km.h f26012d = new f();

    /* renamed from: e, reason: collision with root package name */
    static final km.h f26013e = new g();

    /* renamed from: f, reason: collision with root package name */
    static final km.h f26014f = new h();

    /* renamed from: g, reason: collision with root package name */
    static final km.h f26015g = new i();

    /* renamed from: h, reason: collision with root package name */
    static final km.h f26016h = new j();

    /* renamed from: i, reason: collision with root package name */
    static final km.h f26017i = new k();

    /* renamed from: j, reason: collision with root package name */
    static final km.h f26018j = new a();

    /* loaded from: classes3.dex */
    class a extends km.h {
        a() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public String c(km.m mVar) {
            return mVar.s();
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, String str) {
            qVar.C(str);
        }

        public String toString() {
            return "JsonAdapter(String)";
        }
    }

    /* loaded from: classes3.dex */
    static /* synthetic */ class b {

        /* renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f26019a;

        static {
            int[] iArr = new int[m.b.values().length];
            f26019a = iArr;
            try {
                iArr[m.b.BEGIN_ARRAY.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f26019a[m.b.BEGIN_OBJECT.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f26019a[m.b.STRING.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f26019a[m.b.NUMBER.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f26019a[m.b.BOOLEAN.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f26019a[m.b.NULL.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    /* loaded from: classes3.dex */
    class c implements h.e {
        c() {
        }

        @Override // km.h.e
        public km.h a(Type type, Set set, t tVar) {
            if (!set.isEmpty()) {
                return null;
            }
            if (type == Boolean.TYPE) {
                return u.f26010b;
            }
            if (type == Byte.TYPE) {
                return u.f26011c;
            }
            if (type == Character.TYPE) {
                return u.f26012d;
            }
            if (type == Double.TYPE) {
                return u.f26013e;
            }
            if (type == Float.TYPE) {
                return u.f26014f;
            }
            if (type == Integer.TYPE) {
                return u.f26015g;
            }
            if (type == Long.TYPE) {
                return u.f26016h;
            }
            if (type == Short.TYPE) {
                return u.f26017i;
            }
            if (type == Boolean.class) {
                return u.f26010b.f();
            }
            if (type == Byte.class) {
                return u.f26011c.f();
            }
            if (type == Character.class) {
                return u.f26012d.f();
            }
            if (type == Double.class) {
                return u.f26013e.f();
            }
            if (type == Float.class) {
                return u.f26014f.f();
            }
            if (type == Integer.class) {
                return u.f26015g.f();
            }
            if (type == Long.class) {
                return u.f26016h.f();
            }
            if (type == Short.class) {
                return u.f26017i.f();
            }
            if (type == String.class) {
                return u.f26018j.f();
            }
            if (type == Object.class) {
                return new m(tVar).f();
            }
            Class f10 = w.f(type);
            km.h d10 = lm.a.d(tVar, type, f10);
            if (d10 != null) {
                return d10;
            }
            if (f10.isEnum()) {
                return new l(f10).f();
            }
            return null;
        }
    }

    /* loaded from: classes3.dex */
    class d extends km.h {
        d() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Boolean c(km.m mVar) {
            return Boolean.valueOf(mVar.h());
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Boolean bool) {
            qVar.G(bool.booleanValue());
        }

        public String toString() {
            return "JsonAdapter(Boolean)";
        }
    }

    /* loaded from: classes3.dex */
    class e extends km.h {
        e() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Byte c(km.m mVar) {
            return Byte.valueOf((byte) u.a(mVar, "a byte", -128, Constants.MAX_HOST_LENGTH));
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Byte b10) {
            qVar.z(b10.intValue() & Constants.MAX_HOST_LENGTH);
        }

        public String toString() {
            return "JsonAdapter(Byte)";
        }
    }

    /* loaded from: classes3.dex */
    class f extends km.h {
        f() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Character c(km.m mVar) {
            String s10 = mVar.s();
            if (s10.length() <= 1) {
                return Character.valueOf(s10.charAt(0));
            }
            throw new km.j(String.format("Expected %s but was %s at path %s", "a char", JsonFactory.DEFAULT_QUOTE_CHAR + s10 + JsonFactory.DEFAULT_QUOTE_CHAR, mVar.getPath()));
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Character ch2) {
            qVar.C(ch2.toString());
        }

        public String toString() {
            return "JsonAdapter(Character)";
        }
    }

    /* loaded from: classes3.dex */
    class g extends km.h {
        g() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Double c(km.m mVar) {
            return Double.valueOf(mVar.j());
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Double d10) {
            qVar.y(d10.doubleValue());
        }

        public String toString() {
            return "JsonAdapter(Double)";
        }
    }

    /* loaded from: classes3.dex */
    class h extends km.h {
        h() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Float c(km.m mVar) {
            float j10 = (float) mVar.j();
            if (mVar.g() || !Float.isInfinite(j10)) {
                return Float.valueOf(j10);
            }
            throw new km.j("JSON forbids NaN and infinities: " + j10 + " at path " + mVar.getPath());
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Float f10) {
            f10.getClass();
            qVar.A(f10);
        }

        public String toString() {
            return "JsonAdapter(Float)";
        }
    }

    /* loaded from: classes3.dex */
    class i extends km.h {
        i() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Integer c(km.m mVar) {
            return Integer.valueOf(mVar.m());
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Integer num) {
            qVar.z(num.intValue());
        }

        public String toString() {
            return "JsonAdapter(Integer)";
        }
    }

    /* loaded from: classes3.dex */
    class j extends km.h {
        j() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Long c(km.m mVar) {
            return Long.valueOf(mVar.p());
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Long l10) {
            qVar.z(l10.longValue());
        }

        public String toString() {
            return "JsonAdapter(Long)";
        }
    }

    /* loaded from: classes3.dex */
    class k extends km.h {
        k() {
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Short c(km.m mVar) {
            return Short.valueOf((short) u.a(mVar, "a short", -32768, 32767));
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Short sh2) {
            qVar.z(sh2.intValue());
        }

        public String toString() {
            return "JsonAdapter(Short)";
        }
    }

    /* loaded from: classes3.dex */
    static final class l extends km.h {

        /* renamed from: a, reason: collision with root package name */
        private final Class f26020a;

        /* renamed from: b, reason: collision with root package name */
        private final String[] f26021b;

        /* renamed from: c, reason: collision with root package name */
        private final Enum[] f26022c;

        /* renamed from: d, reason: collision with root package name */
        private final m.a f26023d;

        l(Class cls) {
            this.f26020a = cls;
            try {
                Enum[] enumArr = (Enum[]) cls.getEnumConstants();
                this.f26022c = enumArr;
                this.f26021b = new String[enumArr.length];
                int i10 = 0;
                while (true) {
                    Enum[] enumArr2 = this.f26022c;
                    if (i10 >= enumArr2.length) {
                        this.f26023d = m.a.a(this.f26021b);
                        return;
                    }
                    Enum r12 = enumArr2[i10];
                    km.g gVar = (km.g) cls.getField(r12.name()).getAnnotation(km.g.class);
                    this.f26021b[i10] = gVar != null ? gVar.name() : r12.name();
                    i10++;
                }
            } catch (NoSuchFieldException e10) {
                throw new AssertionError("Missing field in " + cls.getName(), e10);
            }
        }

        @Override // km.h
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public Enum c(km.m mVar) {
            int A = mVar.A(this.f26023d);
            if (A != -1) {
                return this.f26022c[A];
            }
            String path = mVar.getPath();
            throw new km.j("Expected one of " + Arrays.asList(this.f26021b) + " but was " + mVar.s() + " at path " + path);
        }

        @Override // km.h
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(q qVar, Enum r22) {
            qVar.C(this.f26021b[r22.ordinal()]);
        }

        public String toString() {
            return "JsonAdapter(" + this.f26020a.getName() + ")";
        }
    }

    /* loaded from: classes3.dex */
    static final class m extends km.h {

        /* renamed from: a, reason: collision with root package name */
        private final t f26024a;

        /* renamed from: b, reason: collision with root package name */
        private final km.h f26025b;

        /* renamed from: c, reason: collision with root package name */
        private final km.h f26026c;

        /* renamed from: d, reason: collision with root package name */
        private final km.h f26027d;

        /* renamed from: e, reason: collision with root package name */
        private final km.h f26028e;

        /* renamed from: f, reason: collision with root package name */
        private final km.h f26029f;

        m(t tVar) {
            this.f26024a = tVar;
            this.f26025b = tVar.c(List.class);
            this.f26026c = tVar.c(Map.class);
            this.f26027d = tVar.c(String.class);
            this.f26028e = tVar.c(Double.class);
            this.f26029f = tVar.c(Boolean.class);
        }

        private Class k(Class cls) {
            return Map.class.isAssignableFrom(cls) ? Map.class : Collection.class.isAssignableFrom(cls) ? Collection.class : cls;
        }

        @Override // km.h
        public Object c(km.m mVar) {
            switch (b.f26019a[mVar.v().ordinal()]) {
                case 1:
                    return this.f26025b.c(mVar);
                case 2:
                    return this.f26026c.c(mVar);
                case 3:
                    return this.f26027d.c(mVar);
                case 4:
                    return this.f26028e.c(mVar);
                case 5:
                    return this.f26029f.c(mVar);
                case 6:
                    return mVar.r();
                default:
                    throw new IllegalStateException("Expected a value but was " + mVar.v() + " at path " + mVar.getPath());
            }
        }

        @Override // km.h
        public void i(q qVar, Object obj) {
            Class<?> cls = obj.getClass();
            if (cls != Object.class) {
                this.f26024a.e(k(cls), lm.a.f28452a).i(qVar, obj);
            } else {
                qVar.b();
                qVar.e();
            }
        }

        public String toString() {
            return "JsonAdapter(Object)";
        }
    }

    static int a(km.m mVar, String str, int i10, int i11) {
        int m10 = mVar.m();
        if (m10 < i10 || m10 > i11) {
            throw new km.j(String.format("Expected %s but was %s at path %s", str, Integer.valueOf(m10), mVar.getPath()));
        }
        return m10;
    }
}
