package m5;

import F.f0;
import I2.C0317a;
import T0.C0606q;
import java.util.ArrayList;
import java.util.Arrays;
import k5.AbstractC2414b;
import k5.C2431t;
import kotlin.jvm.internal.D;
import l5.AbstractC2458c;
import l5.C;
import x4.AbstractC3251q;
import x4.AbstractC3257w;

/* JADX INFO: loaded from: classes3.dex */
public final class v extends W.a implements l5.k {

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final A f21288h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final y f21289i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final C0606q f21290j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f21291k;
    public C0317a l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final j f21293n;

    public v(AbstractC2458c json, A a6, y yVar, i5.g descriptor, C0317a c0317a) {
        kotlin.jvm.internal.o.h(json, "json");
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        this.f21287g = json;
        this.f21288h = a6;
        this.f21289i = yVar;
        this.f21290j = json.f20334b;
        this.f21291k = -1;
        this.l = c0317a;
        l5.j jVar = json.f20333a;
        this.f21292m = jVar;
        this.f21293n = jVar.f20350b ? null : new j(descriptor);
    }

    @Override // W.a, j5.c
    public final short A() {
        y yVar = this.f21289i;
        long jH = yVar.h();
        short s6 = (short) jH;
        if (jH == s6) {
            return s6;
        }
        y.m(yVar, "Failed to parse short for input '" + jH + '\'', 0, null, 6);
        throw null;
    }

    @Override // W.a, j5.c
    public final float B() {
        y yVar = this.f21289i;
        String strJ = yVar.j();
        try {
            float f6 = Float.parseFloat(strJ);
            l5.j jVar = this.f21287g.f20333a;
            if (!Float.isInfinite(f6) && !Float.isNaN(f6)) {
                return f6;
            }
            l.q(yVar, Float.valueOf(f6));
            throw null;
        } catch (IllegalArgumentException unused) {
            y.m(yVar, A0.a.k('\'', "Failed to parse type 'float' for input '", strJ), 0, null, 6);
            throw null;
        }
    }

    @Override // W.a, j5.c
    public final int D(i5.g enumDescriptor) {
        kotlin.jvm.internal.o.h(enumDescriptor, "enumDescriptor");
        y yVar = this.f21289i;
        return l.k(enumDescriptor, this.f21287g, yVar.i(), " at path ".concat(((f0) yVar.f21305c).f()));
    }

    @Override // W.a, j5.c
    public final double F() {
        y yVar = this.f21289i;
        String strJ = yVar.j();
        try {
            double d6 = Double.parseDouble(strJ);
            l5.j jVar = this.f21287g.f20333a;
            if (!Double.isInfinite(d6) && !Double.isNaN(d6)) {
                return d6;
            }
            l.q(yVar, Double.valueOf(d6));
            throw null;
        } catch (IllegalArgumentException unused) {
            y.m(yVar, A0.a.k('\'', "Failed to parse type 'double' for input '", strJ), 0, null, 6);
            throw null;
        }
    }

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

    @Override // W.a, j5.c
    public final j5.a b(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        AbstractC2458c abstractC2458c = this.f21287g;
        A aP = l.p(descriptor, abstractC2458c);
        y yVar = this.f21289i;
        f0 f0Var = (f0) yVar.f21305c;
        int i6 = f0Var.f1279b + 1;
        f0Var.f1279b = i6;
        Object[] objArr = (Object[]) f0Var.f1280c;
        if (i6 == objArr.length) {
            int i7 = i6 * 2;
            Object[] objArrCopyOf = Arrays.copyOf(objArr, i7);
            kotlin.jvm.internal.o.g(objArrCopyOf, "copyOf(...)");
            f0Var.f1280c = objArrCopyOf;
            int[] iArrCopyOf = Arrays.copyOf((int[]) f0Var.f1281d, i7);
            kotlin.jvm.internal.o.g(iArrCopyOf, "copyOf(...)");
            f0Var.f1281d = iArrCopyOf;
        }
        ((Object[]) f0Var.f1280c)[i6] = descriptor;
        yVar.g(aP.f21234a);
        if (yVar.q() == 4) {
            y.m(yVar, "Unexpected leading comma", 0, null, 6);
            throw null;
        }
        int iOrdinal = aP.ordinal();
        if (iOrdinal == 1 || iOrdinal == 2 || iOrdinal == 3) {
            return new v(this.f21287g, aP, yVar, descriptor, this.l);
        }
        if (this.f21288h == aP && abstractC2458c.f20333a.f20350b) {
            return this;
        }
        return new v(this.f21287g, aP, yVar, descriptor, this.l);
    }

    @Override // W.a, j5.a
    public final void c(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        if (this.f21287g.f20333a.f20349a && descriptor.f() == 0) {
            while (k(descriptor) != -1) {
            }
        }
        y yVar = this.f21289i;
        if (yVar.u()) {
            l.l(yVar, "");
            throw null;
        }
        yVar.g(this.f21288h.f21235b);
        f0 f0Var = (f0) yVar.f21305c;
        int i6 = f0Var.f1279b;
        int[] iArr = (int[]) f0Var.f1281d;
        if (iArr[i6] == -2) {
            iArr[i6] = -1;
            f0Var.f1279b = i6 - 1;
        }
        int i7 = f0Var.f1279b;
        if (i7 != -1) {
            f0Var.f1279b = i7 - 1;
        }
    }

    @Override // W.a, j5.c
    public final j5.c d(i5.g descriptor) {
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        return x.a(descriptor) ? new h(this.f21289i, this.f21287g) : this;
    }

    @Override // W.a, j5.c
    public final boolean f() {
        boolean z6;
        boolean z7;
        y yVar = this.f21289i;
        int iT = yVar.t();
        String str = (String) yVar.f21307e;
        if (iT == str.length()) {
            y.m(yVar, "EOF", 0, null, 6);
            throw null;
        }
        if (str.charAt(iT) == '\"') {
            iT++;
            z6 = true;
        } else {
            z6 = false;
        }
        int iS = yVar.s(iT);
        if (iS >= str.length() || iS == -1) {
            y.m(yVar, "EOF", 0, null, 6);
            throw null;
        }
        int i6 = iS + 1;
        int iCharAt = str.charAt(iS) | ' ';
        if (iCharAt == 102) {
            yVar.c(i6, "alse");
            z7 = false;
        } else {
            if (iCharAt != 116) {
                y.m(yVar, "Expected valid boolean literal prefix, but had '" + yVar.j() + '\'', 0, null, 6);
                throw null;
            }
            yVar.c(i6, "rue");
            z7 = true;
        }
        if (!z6) {
            return z7;
        }
        if (yVar.f21304b == str.length()) {
            y.m(yVar, "EOF", 0, null, 6);
            throw null;
        }
        if (str.charAt(yVar.f21304b) == '\"') {
            yVar.f21304b++;
            return z7;
        }
        y.m(yVar, "Expected closing quotation mark", 0, null, 6);
        throw null;
    }

    @Override // W.a, j5.c
    public final char h() {
        y yVar = this.f21289i;
        String strJ = yVar.j();
        if (strJ.length() == 1) {
            return strJ.charAt(0);
        }
        y.m(yVar, A0.a.k('\'', "Expected single char, but got '", strJ), 0, null, 6);
        throw null;
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // j5.a
    public final int k(i5.g descriptor) {
        String strD;
        String str;
        byte b5;
        kotlin.jvm.internal.o.h(descriptor, "descriptor");
        A a6 = this.f21288h;
        int iOrdinal = a6.ordinal();
        y yVar = this.f21289i;
        byte b6 = 1;
        int i6 = 0;
        zU = false;
        boolean zU = false;
        char c6 = ':';
        AbstractC2458c abstractC2458c = this.f21287g;
        int i7 = -1;
        f0 f0Var = (f0) yVar.f21305c;
        if (iOrdinal == 0) {
            boolean zU2 = yVar.u();
            while (true) {
                boolean zB = yVar.b();
                j jVar = this.f21293n;
                if (zB) {
                    l5.j jVar2 = this.f21292m;
                    strD = yVar.d();
                    yVar.g(c6);
                    int iJ = l.j(descriptor, abstractC2458c, strD);
                    byte b7 = b6;
                    if (iJ != -3) {
                        if (jVar != null) {
                            C2431t c2431t = jVar.f21252a;
                            if (iJ < 64) {
                                c2431t.f20098c |= 1 << iJ;
                            } else {
                                int i8 = (iJ >>> 6) - 1;
                                long[] jArr = c2431t.f20099d;
                                jArr[i8] = jArr[i8] | (1 << (iJ & 63));
                            }
                        }
                        i7 = iJ;
                    } else {
                        boolean z6 = jVar2.f20349a;
                        str = (String) yVar.f21307e;
                        if (!z6) {
                            C0317a c0317a = this.l;
                            if (c0317a == null || !kotlin.jvm.internal.o.c(c0317a.f2580b, strD)) {
                                break;
                            }
                            c0317a.f2580b = null;
                        }
                        ArrayList arrayList = new ArrayList();
                        byte bQ = yVar.q();
                        if (bQ == 8 || bQ == 6) {
                            while (true) {
                                byte bQ2 = yVar.q();
                                b5 = b7;
                                if (bQ2 == b5) {
                                    yVar.d();
                                } else {
                                    if (bQ2 == 8 || bQ2 == 6) {
                                        arrayList.add(Byte.valueOf(bQ2));
                                    } else if (bQ2 == 9) {
                                        if (((Number) AbstractC3251q.n0(arrayList)).byteValue() != 8) {
                                            throw l.c(yVar.f21304b, str, "found ] instead of } at path: " + f0Var);
                                        }
                                        AbstractC3257w.U(arrayList);
                                    } else if (bQ2 == 7) {
                                        if (((Number) AbstractC3251q.n0(arrayList)).byteValue() != 6) {
                                            throw l.c(yVar.f21304b, str, "found } instead of ] at path: " + f0Var);
                                        }
                                        AbstractC3257w.U(arrayList);
                                    } else if (bQ2 == 10) {
                                        y.m(yVar, "Unexpected end of input due to malformed JSON during ignoring unknown keys", 0, null, 6);
                                        throw null;
                                    }
                                    yVar.e();
                                    if (arrayList.size() == 0) {
                                        break;
                                    }
                                }
                                b7 = b5;
                            }
                        } else {
                            yVar.j();
                            b5 = b7;
                        }
                        zU2 = yVar.u();
                        b6 = b5;
                        c6 = ':';
                    }
                } else {
                    if (zU2) {
                        l5.j jVar3 = abstractC2458c.f20333a;
                        l.l(yVar, "object");
                        throw null;
                    }
                    if (jVar != null) {
                        C2431t c2431t2 = jVar.f21252a;
                        i5.g gVar = c2431t2.f20096a;
                        int iF = gVar.f();
                        while (true) {
                            long j4 = c2431t2.f20098c;
                            long j6 = -1;
                            k1.u uVar = c2431t2.f20097b;
                            if (j4 != -1) {
                                int iNumberOfTrailingZeros = Long.numberOfTrailingZeros(~j4);
                                c2431t2.f20098c |= 1 << iNumberOfTrailingZeros;
                                if (((Boolean) uVar.invoke(gVar, Integer.valueOf(iNumberOfTrailingZeros))).booleanValue()) {
                                    i7 = iNumberOfTrailingZeros;
                                    break;
                                }
                            } else if (iF > 64) {
                                long[] jArr2 = c2431t2.f20099d;
                                int length = jArr2.length;
                                loop3: while (i6 < length) {
                                    int i9 = i6 + 1;
                                    int i10 = i9 * 64;
                                    long j7 = jArr2[i6];
                                    while (j7 != j6) {
                                        int iNumberOfTrailingZeros2 = Long.numberOfTrailingZeros(~j7);
                                        j7 |= 1 << iNumberOfTrailingZeros2;
                                        int i11 = iNumberOfTrailingZeros2 + i10;
                                        if (((Boolean) uVar.invoke(gVar, Integer.valueOf(i11))).booleanValue()) {
                                            jArr2[i6] = j7;
                                            i7 = i11;
                                            break loop3;
                                        }
                                        j6 = -1;
                                    }
                                    jArr2[i6] = j7;
                                    i6 = i9;
                                    j6 = -1;
                                }
                            }
                        }
                    } else {
                        i7 = -1;
                    }
                }
            }
            yVar.l(S4.p.S0(6, str.subSequence(0, yVar.f21304b).toString(), strD), A0.a.k('\'', "Encountered an unknown key '", strD), "Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.");
            throw null;
        }
        if (iOrdinal != 2) {
            boolean zU3 = yVar.u();
            if (yVar.b()) {
                int i12 = this.f21291k;
                if (i12 != -1 && !zU3) {
                    y.m(yVar, "Expected end of the array or comma", 0, null, 6);
                    throw null;
                }
                i7 = i12 + 1;
                this.f21291k = i7;
            } else if (zU3) {
                l5.j jVar4 = abstractC2458c.f20333a;
                l.l(yVar, "array");
                throw null;
            }
        } else {
            int i13 = this.f21291k;
            Object[] objArr = i13 % 2 != 0;
            if (objArr != true) {
                yVar.g(':');
            } else if (i13 != -1) {
                zU = yVar.u();
            }
            if (yVar.b()) {
                if (objArr != false) {
                    if (this.f21291k == -1) {
                        int i14 = yVar.f21304b;
                        if (zU) {
                            y.m(yVar, "Unexpected leading comma", i14, null, 4);
                            throw null;
                        }
                    } else {
                        int i15 = yVar.f21304b;
                        if (!zU) {
                            y.m(yVar, "Expected comma after the key-value pair", i15, null, 4);
                            throw null;
                        }
                    }
                }
                i7 = this.f21291k + 1;
                this.f21291k = i7;
            } else if (zU) {
                l5.j jVar5 = abstractC2458c.f20333a;
                l.l(yVar, "object");
                throw null;
            }
        }
        if (a6 != A.f21230e) {
            ((int[]) f0Var.f1281d)[f0Var.f1279b] = i7;
        }
        return i7;
    }

    @Override // l5.k
    public final l5.m l() {
        return new C1.k(this.f21287g.f20333a, this.f21289i).f();
    }

    @Override // W.a, j5.c
    public final int m() {
        y yVar = this.f21289i;
        long jH = yVar.h();
        int i6 = (int) jH;
        if (jH == i6) {
            return i6;
        }
        y.m(yVar, "Failed to parse int for input '" + jH + '\'', 0, null, 6);
        throw null;
    }

    @Override // W.a, 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");
        boolean z6 = this.f21288h == A.f21230e && (i6 & 1) == 0;
        f0 f0Var = (f0) this.f21289i.f21305c;
        if (z6) {
            int[] iArr = (int[]) f0Var.f1281d;
            int i7 = f0Var.f1279b;
            if (iArr[i7] == -2) {
                ((Object[]) f0Var.f1280c)[i7] = m.f21255a;
            }
        }
        Object objP = super.p(descriptor, i6, deserializer, obj);
        if (z6) {
            int[] iArr2 = (int[]) f0Var.f1281d;
            int i8 = f0Var.f1279b;
            if (iArr2[i8] != -2) {
                int i9 = i8 + 1;
                f0Var.f1279b = i9;
                Object[] objArr = (Object[]) f0Var.f1280c;
                if (i9 == objArr.length) {
                    int i10 = i9 * 2;
                    Object[] objArrCopyOf = Arrays.copyOf(objArr, i10);
                    kotlin.jvm.internal.o.g(objArrCopyOf, "copyOf(...)");
                    f0Var.f1280c = objArrCopyOf;
                    int[] iArrCopyOf = Arrays.copyOf((int[]) f0Var.f1281d, i10);
                    kotlin.jvm.internal.o.g(iArrCopyOf, "copyOf(...)");
                    f0Var.f1281d = iArrCopyOf;
                }
            }
            Object[] objArr2 = (Object[]) f0Var.f1280c;
            int i11 = f0Var.f1279b;
            objArr2[i11] = objP;
            ((int[]) f0Var.f1281d)[i11] = -2;
        }
        return objP;
    }

    @Override // W.a, j5.c
    public final String q() {
        return this.f21289i.i();
    }

    @Override // W.a, j5.c
    public final long s() {
        return this.f21289i.h();
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x011f  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0120  */
    @Override // W.a, j5.c
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object u(g5.a deserializer) {
        String message;
        AbstractC2458c abstractC2458c = this.f21287g;
        y yVar = this.f21289i;
        f0 f0Var = (f0) yVar.f21305c;
        kotlin.jvm.internal.o.h(deserializer, "deserializer");
        try {
        } catch (g5.b e6) {
            message = e6.getMessage();
            kotlin.jvm.internal.o.e(message);
            if (!S4.p.D0(message, "at path", false)) {
            }
        }
        if (!(deserializer instanceof AbstractC2414b)) {
            return deserializer.deserialize(this);
        }
        l5.j jVar = abstractC2458c.f20333a;
        String strI = l.i(((AbstractC2414b) deserializer).getDescriptor(), abstractC2458c);
        String strP = yVar.p(strI);
        String strG = null;
        if (strP != null) {
            try {
                g5.a aVarE = W.c.E((AbstractC2414b) deserializer, this, strP);
                C0317a c0317a = new C0317a(7);
                c0317a.f2580b = strI;
                this.l = c0317a;
                return aVarE.deserialize(this);
            } catch (g5.f e7) {
                String message2 = e7.getMessage();
                kotlin.jvm.internal.o.e(message2);
                String strY0 = S4.p.Y0(S4.p.j1('\n', message2, message2), ".");
                String message3 = e7.getMessage();
                kotlin.jvm.internal.o.e(message3);
                y.m(yVar, strY0, 0, S4.p.f1('\n', message3, ""), 2);
                throw null;
            }
        }
        if (!(deserializer instanceof AbstractC2414b)) {
            return deserializer.deserialize(this);
        }
        l5.j jVar2 = abstractC2458c.f20333a;
        String strI2 = l.i(((AbstractC2414b) deserializer).getDescriptor(), abstractC2458c);
        l5.m mVarL = l();
        String strA = ((AbstractC2414b) deserializer).getDescriptor().a();
        if (!(mVarL instanceof l5.y)) {
            throw l.c(-1, mVarL.toString(), "Expected " + D.a(l5.y.class).c() + ", but had " + D.a(mVarL.getClass()).c() + " as the serialized body of " + strA + " at element: " + f0Var.f());
        }
        l5.y yVar2 = (l5.y) mVarL;
        l5.m mVar = (l5.m) yVar2.get(strI2);
        if (mVar != null) {
            C cH = l5.n.h(mVar);
            if (!(cH instanceof l5.v)) {
                strG = cH.g();
            }
        }
        try {
            return l.o(abstractC2458c, strI2, yVar2, W.c.E((AbstractC2414b) deserializer, this, strG));
        } catch (g5.f e8) {
            String message4 = e8.getMessage();
            kotlin.jvm.internal.o.e(message4);
            throw l.c(-1, yVar2.toString(), message4);
        }
        message = e6.getMessage();
        kotlin.jvm.internal.o.e(message);
        if (!S4.p.D0(message, "at path", false)) {
            throw e6;
        }
        throw new g5.b(e6.f16601a, e6.getMessage() + " at path: " + f0Var.f(), e6);
    }

    @Override // W.a, j5.c
    public final boolean v() {
        j jVar = this.f21293n;
        if (!(jVar != null ? jVar.f21253b : false)) {
            y yVar = this.f21289i;
            int iS = yVar.s(yVar.t());
            String str = (String) yVar.f21307e;
            int length = str.length() - iS;
            boolean z6 = false;
            if (length >= 4 && iS != -1) {
                int i6 = 0;
                while (true) {
                    if (i6 < 4) {
                        if ("null".charAt(i6) != str.charAt(iS + i6)) {
                            break;
                        }
                        i6++;
                    } else if (length <= 4 || l.g(str.charAt(iS + 4)) != 0) {
                        yVar.f21304b = iS + 4;
                        z6 = true;
                    }
                }
            }
            if (!z6) {
                return true;
            }
        }
        return false;
    }

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

    @Override // W.a, j5.c
    public final byte z() {
        y yVar = this.f21289i;
        long jH = yVar.h();
        byte b5 = (byte) jH;
        if (jH == b5) {
            return b5;
        }
        y.m(yVar, "Failed to parse byte for input '" + jH + '\'', 0, null, 6);
        throw null;
    }
}
