package e.a.r.y;

import e.a.o.j;
import e.a.o.k;
import e.a.q.v0;

/* JADX INFO: compiled from: TreeJsonDecoder.kt */
/* JADX INFO: loaded from: classes.dex */
@d.n
abstract class c extends v0 implements e.a.r.g {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final e.a.r.a f3001c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private final e.a.r.h f3002d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    protected final e.a.r.f f3003e;

    private c(e.a.r.a aVar, e.a.r.h hVar) {
        this.f3001c = aVar;
        this.f3002d = hVar;
        this.f3003e = d().d();
    }

    public /* synthetic */ c(e.a.r.a aVar, e.a.r.h hVar, d.n0.c.l lVar) {
        this(aVar, hVar);
    }

    private final e.a.r.o c0(e.a.r.v vVar, String str) {
        e.a.r.o oVar = vVar instanceof e.a.r.o ? (e.a.r.o) vVar : null;
        if (oVar != null) {
            return oVar;
        }
        throw y.d(-1, "Unexpected 'null' when " + str + " was expected");
    }

    private final e.a.r.h e0() {
        e.a.r.h hVarD0;
        String strT = T();
        return (strT == null || (hVarD0 = d0(strT)) == null) ? r0() : hVarD0;
    }

    private final Void s0(String str) {
        throw y.e(-1, "Failed to parse '" + str + '\'', e0().toString());
    }

    @Override // e.a.q.r1
    public <T> T G(e.a.a<T> aVar) {
        d.n0.c.s.e(aVar, "deserializer");
        return (T) j0.d(this, aVar);
    }

    @Override // e.a.q.v0
    protected String Y(String str, String str2) {
        d.n0.c.s.e(str, "parentName");
        d.n0.c.s.e(str2, "childName");
        return str2;
    }

    @Override // e.a.p.c
    public void a(e.a.o.f fVar) {
        d.n0.c.s.e(fVar, "descriptor");
    }

    @Override // e.a.p.c
    public e.a.s.c b() {
        return d().e();
    }

    @Override // e.a.p.e
    public e.a.p.c c(e.a.o.f fVar) {
        d.n0.c.s.e(fVar, "descriptor");
        e.a.r.h hVarE0 = e0();
        e.a.o.j jVarE = fVar.e();
        if (d.n0.c.s.a(jVarE, k.b.f2793a) ? true : jVarE instanceof e.a.o.d) {
            e.a.r.a aVarD = d();
            if (hVarE0 instanceof e.a.r.b) {
                return new f0(aVarD, (e.a.r.b) hVarE0);
            }
            throw y.d(-1, "Expected " + d.n0.c.x.b(e.a.r.b.class) + " as the serialized body of " + fVar.a() + ", but had " + d.n0.c.x.b(hVarE0.getClass()));
        }
        if (!d.n0.c.s.a(jVarE, k.c.f2794a)) {
            e.a.r.a aVarD2 = d();
            if (hVarE0 instanceof e.a.r.t) {
                return new e0(aVarD2, (e.a.r.t) hVarE0, null, null, 12, null);
            }
            throw y.d(-1, "Expected " + d.n0.c.x.b(e.a.r.t.class) + " as the serialized body of " + fVar.a() + ", but had " + d.n0.c.x.b(hVarE0.getClass()));
        }
        e.a.r.a aVarD3 = d();
        e.a.o.f fVarA = s0.a(fVar.k(0), aVarD3.e());
        e.a.o.j jVarE2 = fVarA.e();
        if ((jVarE2 instanceof e.a.o.e) || d.n0.c.s.a(jVarE2, j.b.f2791a)) {
            e.a.r.a aVarD4 = d();
            if (hVarE0 instanceof e.a.r.t) {
                return new g0(aVarD4, (e.a.r.t) hVarE0);
            }
            throw y.d(-1, "Expected " + d.n0.c.x.b(e.a.r.t.class) + " as the serialized body of " + fVar.a() + ", but had " + d.n0.c.x.b(hVarE0.getClass()));
        }
        if (!aVarD3.d().b()) {
            throw y.c(fVarA);
        }
        e.a.r.a aVarD5 = d();
        if (hVarE0 instanceof e.a.r.b) {
            return new f0(aVarD5, (e.a.r.b) hVarE0);
        }
        throw y.d(-1, "Expected " + d.n0.c.x.b(e.a.r.b.class) + " as the serialized body of " + fVar.a() + ", but had " + d.n0.c.x.b(hVarE0.getClass()));
    }

    @Override // e.a.r.g
    public e.a.r.a d() {
        return this.f3001c;
    }

    protected abstract e.a.r.h d0(String str);

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: f0, reason: merged with bridge method [inline-methods] */
    public boolean I(String str) {
        d.n0.c.s.e(str, "tag");
        e.a.r.v vVarQ0 = q0(str);
        if (!d().d().l() && c0(vVarQ0, "boolean").c()) {
            throw y.e(-1, "Boolean literal for key '" + str + "' should be unquoted.\nUse 'isLenient = true' in 'Json {}` builder to accept non-compliant JSON.", e0().toString());
        }
        try {
            Boolean boolE = e.a.r.i.e(vVarQ0);
            if (boolE != null) {
                return boolE.booleanValue();
            }
            throw new IllegalArgumentException();
        } catch (IllegalArgumentException unused) {
            s0("boolean");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: g0, reason: merged with bridge method [inline-methods] */
    public byte J(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            int iJ = e.a.r.i.j(q0(str));
            boolean z = false;
            if (-128 <= iJ && iJ <= 127) {
                z = true;
            }
            Byte bValueOf = z ? Byte.valueOf((byte) iJ) : null;
            if (bValueOf != null) {
                return bValueOf.byteValue();
            }
            s0("byte");
            throw new d.h();
        } catch (IllegalArgumentException unused) {
            s0("byte");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: h0, reason: merged with bridge method [inline-methods] */
    public char K(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            return d.s0.t.k0(q0(str).b());
        } catch (IllegalArgumentException unused) {
            s0("char");
            throw new d.h();
        }
    }

    @Override // e.a.r.g
    public e.a.r.h i() {
        return e0();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: i0, reason: merged with bridge method [inline-methods] */
    public double L(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            double dG = e.a.r.i.g(q0(str));
            if (!d().d().a()) {
                if (!((Double.isInfinite(dG) || Double.isNaN(dG)) ? false : true)) {
                    throw y.a(Double.valueOf(dG), str, e0().toString());
                }
            }
            return dG;
        } catch (IllegalArgumentException unused) {
            s0("double");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: j0, reason: merged with bridge method [inline-methods] */
    public int M(String str, e.a.o.f fVar) {
        d.n0.c.s.e(str, "tag");
        d.n0.c.s.e(fVar, "enumDescriptor");
        return z.f(fVar, d(), q0(str).b(), null, 4, null);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: k0, reason: merged with bridge method [inline-methods] */
    public float N(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            float fI = e.a.r.i.i(q0(str));
            if (!d().d().a()) {
                if (!((Float.isInfinite(fI) || Float.isNaN(fI)) ? false : true)) {
                    throw y.a(Float.valueOf(fI), str, e0().toString());
                }
            }
            return fI;
        } catch (IllegalArgumentException unused) {
            s0("float");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: l0, reason: merged with bridge method [inline-methods] */
    public e.a.p.e O(String str, e.a.o.f fVar) {
        d.n0.c.s.e(str, "tag");
        d.n0.c.s.e(fVar, "inlineDescriptor");
        return n0.a(fVar) ? new t(new o0(q0(str).b()), d()) : super.O(str, fVar);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: m0, reason: merged with bridge method [inline-methods] */
    public int P(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            return e.a.r.i.j(q0(str));
        } catch (IllegalArgumentException unused) {
            s0("int");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: n0, reason: merged with bridge method [inline-methods] */
    public long Q(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            return e.a.r.i.m(q0(str));
        } catch (IllegalArgumentException unused) {
            s0("long");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: o0, reason: merged with bridge method [inline-methods] */
    public short R(String str) {
        d.n0.c.s.e(str, "tag");
        try {
            int iJ = e.a.r.i.j(q0(str));
            boolean z = false;
            if (-32768 <= iJ && iJ <= 32767) {
                z = true;
            }
            Short shValueOf = z ? Short.valueOf((short) iJ) : null;
            if (shValueOf != null) {
                return shValueOf.shortValue();
            }
            s0("short");
            throw new d.h();
        } catch (IllegalArgumentException unused) {
            s0("short");
            throw new d.h();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // e.a.q.r1
    /* JADX INFO: renamed from: p0, reason: merged with bridge method [inline-methods] */
    public String S(String str) {
        d.n0.c.s.e(str, "tag");
        e.a.r.v vVarQ0 = q0(str);
        if (d().d().l() || c0(vVarQ0, "string").c()) {
            if (vVarQ0 instanceof e.a.r.r) {
                throw y.e(-1, "Unexpected 'null' value instead of string literal", e0().toString());
            }
            return vVarQ0.b();
        }
        throw y.e(-1, "String literal for key '" + str + "' should be quoted.\nUse 'isLenient = true' in 'Json {}` builder to accept non-compliant JSON.", e0().toString());
    }

    protected final e.a.r.v q0(String str) {
        d.n0.c.s.e(str, "tag");
        e.a.r.h hVarD0 = d0(str);
        e.a.r.v vVar = hVarD0 instanceof e.a.r.v ? (e.a.r.v) hVarD0 : null;
        if (vVar != null) {
            return vVar;
        }
        throw y.e(-1, "Expected JsonPrimitive at " + str + ", found " + hVarD0, e0().toString());
    }

    public abstract e.a.r.h r0();

    @Override // e.a.p.e
    public boolean u() {
        return !(e0() instanceof e.a.r.r);
    }
}
