package m5;

import T0.C0606q;
import androidx.media3.exoplayer.upstream.CmcdData;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import k5.AbstractC2414b;
import k5.B;
import k5.U;
import kotlin.jvm.internal.D;
import l5.AbstractC2458c;
import l5.C;
import x4.AbstractC3251q;
import x4.AbstractC3252r;

/* JADX INFO: renamed from: m5.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC2565a implements l5.k, j5.c, j5.a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f21236a = new ArrayList();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f21237b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final AbstractC2458c f21238c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final String f21239d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final l5.j f21240e;

    public AbstractC2565a(AbstractC2458c abstractC2458c, String str) {
        this.f21238c = abstractC2458c;
        this.f21239d = str;
        this.f21240e = abstractC2458c.f20333a;
    }

    @Override // j5.c
    public final short A() {
        return P(U());
    }

    @Override // j5.c
    public final float B() {
        return L(U());
    }

    @Override // j5.a
    public final String C(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return Q(S(descriptor, i6));
    }

    @Override // j5.c
    public final int D(i5.g enumDescriptor) {
        kotlin.jvm.internal.o.h(enumDescriptor, "enumDescriptor");
        String tag = (String) U();
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        String strA = enumDescriptor.a();
        if (mVarO instanceof C) {
            return l.k(enumDescriptor, this.f21238c, ((C) mVarO).g(), "");
        }
        throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of " + strA + " at element: " + W(tag));
    }

    @Override // j5.a
    public final int E(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return N(S(descriptor, i6));
    }

    @Override // j5.c
    public final double F() {
        return K(U());
    }

    public final boolean G(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (mVarO instanceof C) {
            C c6 = (C) mVarO;
            try {
                Boolean boolD = l5.n.d(c6);
                if (boolD != null) {
                    return boolD.booleanValue();
                }
                X(c6, "boolean", tag);
                throw null;
            } catch (IllegalArgumentException unused) {
                X(c6, "boolean", tag);
                throw null;
            }
        }
        throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of boolean at element: " + W(tag));
    }

    @Override // j5.a
    public final char H(U descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return J(S(descriptor, i6));
    }

    public final byte I(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (!(mVarO instanceof C)) {
            throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of byte at element: " + W(tag));
        }
        C c6 = (C) mVarO;
        try {
            int iE = l5.n.e(c6);
            Byte bValueOf = (-128 > iE || iE > 127) ? null : Byte.valueOf((byte) iE);
            if (bValueOf != null) {
                return bValueOf.byteValue();
            }
            X(c6, "byte", tag);
            throw null;
        } catch (IllegalArgumentException unused) {
            X(c6, "byte", tag);
            throw null;
        }
    }

    public final char J(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (!(mVarO instanceof C)) {
            throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of char at element: " + W(tag));
        }
        C c6 = (C) mVarO;
        try {
            String strG = c6.g();
            kotlin.jvm.internal.o.h(strG, "<this>");
            int length = strG.length();
            if (length == 0) {
                throw new NoSuchElementException("Char sequence is empty.");
            }
            if (length == 1) {
                return strG.charAt(0);
            }
            throw new IllegalArgumentException("Char sequence has more than one element.");
        } catch (IllegalArgumentException unused) {
            X(c6, "char", tag);
            throw null;
        }
    }

    public final double K(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (!(mVarO instanceof C)) {
            throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of double at element: " + W(tag));
        }
        C c6 = (C) mVarO;
        try {
            B b5 = l5.n.f20355a;
            kotlin.jvm.internal.o.h(c6, "<this>");
            double d6 = Double.parseDouble(c6.g());
            l5.j jVar = this.f21238c.f20333a;
            if (!Double.isInfinite(d6) && !Double.isNaN(d6)) {
                return d6;
            }
            Double dValueOf = Double.valueOf(d6);
            String output = t().toString();
            kotlin.jvm.internal.o.h(output, "output");
            throw l.d(-1, l.s(dValueOf, tag, output));
        } catch (IllegalArgumentException unused) {
            X(c6, "double", tag);
            throw null;
        }
    }

    public final float L(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (!(mVarO instanceof C)) {
            throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of float at element: " + W(tag));
        }
        C c6 = (C) mVarO;
        try {
            B b5 = l5.n.f20355a;
            kotlin.jvm.internal.o.h(c6, "<this>");
            float f6 = Float.parseFloat(c6.g());
            l5.j jVar = this.f21238c.f20333a;
            if (!Float.isInfinite(f6) && !Float.isNaN(f6)) {
                return f6;
            }
            Float fValueOf = Float.valueOf(f6);
            String output = t().toString();
            kotlin.jvm.internal.o.h(output, "output");
            throw l.d(-1, l.s(fValueOf, tag, output));
        } catch (IllegalArgumentException unused) {
            X(c6, "float", tag);
            throw null;
        }
    }

    public final j5.c M(Object obj, i5.g inlineDescriptor) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        kotlin.jvm.internal.o.h(inlineDescriptor, "inlineDescriptor");
        if (!x.a(inlineDescriptor)) {
            this.f21236a.add(tag);
            return this;
        }
        l5.m mVarO = o(tag);
        String strA = inlineDescriptor.a();
        if (mVarO instanceof C) {
            String source = ((C) mVarO).g();
            AbstractC2458c json = this.f21238c;
            kotlin.jvm.internal.o.h(json, "json");
            kotlin.jvm.internal.o.h(source, "source");
            return new h(new y(source), json);
        }
        throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of " + strA + " at element: " + W(tag));
    }

    public final int N(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (mVarO instanceof C) {
            C c6 = (C) mVarO;
            try {
                return l5.n.e(c6);
            } catch (IllegalArgumentException unused) {
                X(c6, "int", tag);
                throw null;
            }
        }
        throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of int at element: " + W(tag));
    }

    public final long O(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (mVarO instanceof C) {
            C c6 = (C) mVarO;
            try {
                B b5 = l5.n.f20355a;
                kotlin.jvm.internal.o.h(c6, "<this>");
                try {
                    return new y(c6.g()).h();
                } catch (i e6) {
                    throw new NumberFormatException(e6.getMessage());
                }
            } catch (IllegalArgumentException unused) {
                X(c6, "long", tag);
                throw null;
            }
        }
        throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of long at element: " + W(tag));
    }

    public final short P(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (!(mVarO instanceof C)) {
            throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of short at element: " + W(tag));
        }
        C c6 = (C) mVarO;
        try {
            int iE = l5.n.e(c6);
            Short shValueOf = (-32768 > iE || iE > 32767) ? null : Short.valueOf((short) iE);
            if (shValueOf != null) {
                return shValueOf.shortValue();
            }
            X(c6, "short", tag);
            throw null;
        } catch (IllegalArgumentException unused) {
            X(c6, "short", tag);
            throw null;
        }
    }

    public final String Q(Object obj) {
        String tag = (String) obj;
        kotlin.jvm.internal.o.h(tag, "tag");
        l5.m mVarO = o(tag);
        if (!(mVarO instanceof C)) {
            throw l.c(-1, mVarO.toString(), "Expected " + D.a(C.class).c() + ", but had " + D.a(mVarO.getClass()).c() + " as the serialized body of string at element: " + W(tag));
        }
        C c6 = (C) mVarO;
        if (!(c6 instanceof l5.s)) {
            StringBuilder sbS = com.google.android.recaptcha.internal.a.s("Expected string value for a non-null key '", tag, "', got null literal instead at element: ");
            sbS.append(W(tag));
            throw l.c(-1, t().toString(), sbS.toString());
        }
        l5.s sVar = (l5.s) c6;
        if (sVar.f20359a) {
            return sVar.f20361c;
        }
        l5.j jVar = this.f21238c.f20333a;
        StringBuilder sbS2 = com.google.android.recaptcha.internal.a.s("String literal for key '", tag, "' should be quoted at element: ");
        sbS2.append(W(tag));
        sbS2.append(".\nUse 'isLenient = true' in 'Json {}' builder to accept non-compliant JSON.");
        throw l.c(-1, t().toString(), sbS2.toString());
    }

    public String R(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return descriptor.g(i6);
    }

    public final String S(i5.g gVar, int i6) {
        kotlin.jvm.internal.o.h(gVar, "<this>");
        String nestedName = R(gVar, i6);
        kotlin.jvm.internal.o.h(nestedName, "nestedName");
        return nestedName;
    }

    public abstract l5.m T();

    public final Object U() {
        ArrayList arrayList = this.f21236a;
        Object objRemove = arrayList.remove(AbstractC3252r.A(arrayList));
        this.f21237b = true;
        return objRemove;
    }

    public final String V() {
        ArrayList arrayList = this.f21236a;
        return arrayList.isEmpty() ? "$" : AbstractC3251q.m0(arrayList, ".", "$.", null, null, 60);
    }

    public final String W(String currentTag) {
        kotlin.jvm.internal.o.h(currentTag, "currentTag");
        return V() + '.' + currentTag;
    }

    public final void X(C c6, String str, String str2) {
        throw l.c(-1, t().toString(), "Failed to parse literal '" + c6 + "' as " + (S4.w.A0(str, CmcdData.Factory.OBJECT_TYPE_INIT_SEGMENT, false) ? "an " : "a ").concat(str) + " value at element: " + W(str2));
    }

    @Override // j5.a
    public final C0606q a() {
        return this.f21238c.f20334b;
    }

    @Override // j5.c
    public j5.a b(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        l5.m mVarT = t();
        W.b bVarE = descriptor.e();
        boolean zC = kotlin.jvm.internal.o.c(bVarE, i5.k.f19101k);
        AbstractC2458c abstractC2458c = this.f21238c;
        if (zC || (bVarE instanceof i5.d)) {
            String strA = descriptor.a();
            if (mVarT instanceof l5.e) {
                return new q(abstractC2458c, (l5.e) mVarT);
            }
            throw l.c(-1, mVarT.toString(), "Expected " + D.a(l5.e.class).c() + ", but had " + D.a(mVarT.getClass()).c() + " as the serialized body of " + strA + " at element: " + V());
        }
        if (!kotlin.jvm.internal.o.c(bVarE, i5.k.l)) {
            String strA2 = descriptor.a();
            if (mVarT instanceof l5.y) {
                return new p(abstractC2458c, (l5.y) mVarT, this.f21239d, 8);
            }
            throw l.c(-1, mVarT.toString(), "Expected " + D.a(l5.y.class).c() + ", but had " + D.a(mVarT.getClass()).c() + " as the serialized body of " + strA2 + " at element: " + V());
        }
        i5.g gVarF = l.f(descriptor.i(0), abstractC2458c.f20334b);
        W.b bVarE2 = gVarF.e();
        if (!(bVarE2 instanceof i5.f) && !kotlin.jvm.internal.o.c(bVarE2, i5.j.f19099j)) {
            throw l.b(gVarF);
        }
        String strA3 = descriptor.a();
        if (mVarT instanceof l5.y) {
            return new r(abstractC2458c, (l5.y) mVarT);
        }
        throw l.c(-1, mVarT.toString(), "Expected " + D.a(l5.y.class).c() + ", but had " + D.a(mVarT.getClass()).c() + " as the serialized body of " + strA3 + " at element: " + V());
    }

    @Override // j5.a
    public void c(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
    }

    @Override // j5.c
    public final j5.c d(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        if (AbstractC3251q.o0(this.f21236a) != null) {
            return M(U(), descriptor);
        }
        return new n(this.f21238c, T(), this.f21239d).d(descriptor);
    }

    @Override // j5.a
    public final byte e(U descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return I(S(descriptor, i6));
    }

    @Override // j5.c
    public final boolean f() {
        return G(U());
    }

    @Override // j5.a
    public final short g(U descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return P(S(descriptor, i6));
    }

    @Override // j5.c
    public final char h() {
        return J(U());
    }

    @Override // j5.a
    public final long i(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return O(S(descriptor, i6));
    }

    @Override // j5.a
    public final j5.c j(U descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return M(S(descriptor, i6), descriptor.i(i6));
    }

    @Override // l5.k
    public final l5.m l() {
        return t();
    }

    @Override // j5.c
    public final int m() {
        return N(U());
    }

    @Override // j5.a
    public final double n(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return K(S(descriptor, i6));
    }

    public abstract l5.m o(String str);

    @Override // j5.a
    public final Object p(i5.g descriptor, int i6, g5.a deserializer, Object obj) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        kotlin.jvm.internal.o.h(deserializer, "deserializer");
        this.f21236a.add(S(descriptor, i6));
        kotlin.jvm.internal.o.h(deserializer, "deserializer");
        Object objU = u(deserializer);
        if (!this.f21237b) {
            U();
        }
        this.f21237b = false;
        return objU;
    }

    @Override // j5.c
    public final String q() {
        return Q(U());
    }

    @Override // j5.a
    public final Object r(i5.g descriptor, int i6, g5.a deserializer, Object obj) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        kotlin.jvm.internal.o.h(deserializer, "deserializer");
        this.f21236a.add(S(descriptor, i6));
        Object objU = (deserializer.getDescriptor().c() || v()) ? u(deserializer) : null;
        if (!this.f21237b) {
            U();
        }
        this.f21237b = false;
        return objU;
    }

    @Override // j5.c
    public final long s() {
        return O(U());
    }

    public final l5.m t() {
        l5.m mVarO;
        String str = (String) AbstractC3251q.o0(this.f21236a);
        return (str == null || (mVarO = o(str)) == null) ? T() : mVarO;
    }

    @Override // j5.c
    public final Object u(g5.a deserializer) {
        kotlin.jvm.internal.o.h(deserializer, "deserializer");
        if (!(deserializer instanceof AbstractC2414b)) {
            return deserializer.deserialize(this);
        }
        AbstractC2458c abstractC2458c = this.f21238c;
        l5.j jVar = abstractC2458c.f20333a;
        AbstractC2414b abstractC2414b = (AbstractC2414b) deserializer;
        String strI = l.i(abstractC2414b.getDescriptor(), abstractC2458c);
        l5.m mVarT = t();
        String strA = abstractC2414b.getDescriptor().a();
        if (!(mVarT instanceof l5.y)) {
            throw l.c(-1, mVarT.toString(), "Expected " + D.a(l5.y.class).c() + ", but had " + D.a(mVarT.getClass()).c() + " as the serialized body of " + strA + " at element: " + V());
        }
        l5.y yVar = (l5.y) mVarT;
        l5.m mVar = (l5.m) yVar.get(strI);
        String strG = null;
        if (mVar != null) {
            C cH = l5.n.h(mVar);
            if (!(cH instanceof l5.v)) {
                strG = cH.g();
            }
        }
        try {
            return l.o(abstractC2458c, strI, yVar, W.c.E((AbstractC2414b) deserializer, this, strG));
        } catch (g5.f e6) {
            String message = e6.getMessage();
            kotlin.jvm.internal.o.e(message);
            throw l.c(-1, yVar.toString(), message);
        }
    }

    @Override // j5.c
    public boolean v() {
        return !(t() instanceof l5.v);
    }

    @Override // j5.a
    public final float w(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return L(S(descriptor, i6));
    }

    @Override // j5.a
    public final boolean x(i5.g descriptor, int i6) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return G(S(descriptor, i6));
    }

    @Override // l5.k
    public final AbstractC2458c y() {
        return this.f21238c;
    }

    @Override // j5.c
    public final byte z() {
        return I(U());
    }
}
