package o;

import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public class Ua0 {
    public final /* synthetic */ int a;
    public int b;
    public final Object c;
    public Object d;
    public final Object e;
    public final Object f;

    public Ua0(C1565jJ c1565jJ, Vm0 vm0, Ua0 ua0, L60 l60) {
        this.a = 0;
        this.c = c1565jJ;
        this.d = vm0;
        this.e = ua0;
        this.b = -1;
        C0688a6 c0688a6 = c1565jJ.a;
        this.f = c0688a6;
        c0688a6.getClass();
    }

    public static /* synthetic */ void w(Ua0 ua0, String str, int i, int i2) {
        if ((i2 & 2) != 0) {
            i = ua0.b;
        }
        ua0.v(i, str, (i2 & 4) != 0 ? "" : "It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'");
        throw null;
    }

    public int A() {
        char cCharAt;
        int i = this.b;
        if (i == -1) {
            return i;
        }
        String str = (String) this.f;
        while (i < str.length() && ((cCharAt = str.charAt(i)) == ' ' || cCharAt == '\n' || cCharAt == '\r' || cCharAt == '\t')) {
            i++;
        }
        this.b = i;
        return i;
    }

    public boolean B() {
        int iA = A();
        String str = (String) this.f;
        if (iA >= str.length() || iA == -1 || str.charAt(iA) != ',') {
            return false;
        }
        this.b++;
        return true;
    }

    public void C(char c) {
        int i = this.b;
        if (i > 0 && c == '\"') {
            try {
                this.b = i - 1;
                String strI = i();
                this.b = i;
                if (F3.c(strI, "null")) {
                    v(this.b - 1, "Expected string literal but 'null' literal was found", "Use 'coerceInputValues = true' in 'Json {}' builder to coerce nulls if property has a default value.");
                    throw null;
                }
            } catch (Throwable th) {
                this.b = i;
                throw th;
            }
        }
        x(AbstractC0662Zn.k(c), true);
        throw null;
    }

    public int a(CharSequence charSequence, int i) {
        int i2 = i + 4;
        if (i2 < charSequence.length()) {
            ((StringBuilder) this.e).append((char) (y(charSequence, i + 3) + (y(charSequence, i) << 12) + (y(charSequence, i + 1) << 8) + (y(charSequence, i + 2) << 4)));
            return i2;
        }
        this.b = i;
        if (i2 < charSequence.length()) {
            return a(charSequence, this.b);
        }
        w(this, "Unexpected EOF during unicode escape", 0, 6);
        throw null;
    }

    public Ua0 b(L60 l60) {
        byte bK;
        C1565jJ c1565jJ = (C1565jJ) this.c;
        Vm0 vm0F = AbstractC1155f00.F(c1565jJ, l60);
        Ua0 ua0 = (Ua0) this.e;
        C0692a8 c0692a8 = (C0692a8) ua0.c;
        int i = c0692a8.b + 1;
        c0692a8.b = i;
        Object[] objArr = (Object[]) c0692a8.c;
        if (i == objArr.length) {
            int i2 = i * 2;
            c0692a8.c = Arrays.copyOf(objArr, i2);
            c0692a8.d = Arrays.copyOf((int[]) c0692a8.d, i2);
        }
        ((Object[]) c0692a8.c)[i] = l60;
        ua0.f(vm0F.l);
        String str = (String) ua0.f;
        int i3 = ua0.b;
        while (true) {
            int iZ = ua0.z(i3);
            bK = 10;
            if (iZ == -1) {
                ua0.b = iZ;
                break;
            }
            char cCharAt = str.charAt(iZ);
            if (cCharAt != '\t' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != ' ') {
                ua0.b = iZ;
                bK = AbstractC0662Zn.k(cCharAt);
                break;
            }
            i3 = iZ + 1;
        }
        if (bK == 4) {
            w(ua0, "Unexpected leading comma", 0, 6);
            throw null;
        }
        int iOrdinal = vm0F.ordinal();
        if (iOrdinal == 1 || iOrdinal == 2 || iOrdinal == 3) {
            return new Ua0(c1565jJ, vm0F, ua0, l60);
        }
        if (((Vm0) this.d) != vm0F) {
            return new Ua0(c1565jJ, vm0F, ua0, l60);
        }
        c1565jJ.a.getClass();
        return this;
    }

    public boolean c() {
        int i = this.b;
        if (i == -1) {
            return false;
        }
        String str = (String) this.f;
        while (i < str.length()) {
            char cCharAt = str.charAt(i);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.b = i;
                return (cCharAt == ',' || cCharAt == ':' || cCharAt == ']' || cCharAt == '}') ? false : true;
            }
            i++;
        }
        this.b = i;
        return false;
    }

    public void d(int i, String str) {
        String str2 = (String) this.f;
        if (str2.length() - i < str.length()) {
            w(this, "Unexpected end of boolean literal", 0, 6);
            throw null;
        }
        int length = str.length();
        for (int i2 = 0; i2 < length; i2++) {
            if (str.charAt(i2) != (str2.charAt(i + i2) | ' ')) {
                w(this, "Expected valid boolean literal prefix, but had '" + i() + '\'', 0, 6);
                throw null;
            }
        }
        this.b = str.length() + i;
    }

    public String e() {
        String string;
        StringBuilder sb = (StringBuilder) this.e;
        String str = (String) this.f;
        f('\"');
        int i = this.b;
        int iV = Za0.V(str, '\"', i, 4);
        if (iV == -1) {
            i();
            x((byte) 1, false);
            throw null;
        }
        int i2 = i;
        while (i2 < iV) {
            if (str.charAt(i2) == '\\') {
                int iZ = this.b;
                char cCharAt = str.charAt(i2);
                boolean z = false;
                while (cCharAt != '\"') {
                    if (cCharAt == '\\') {
                        sb.append((CharSequence) str, iZ, i2);
                        int iZ2 = z(i2 + 1);
                        if (iZ2 == -1) {
                            w(this, "Expected escape sequence to continue, got EOF", 0, 6);
                            throw null;
                        }
                        int iA = iZ2 + 1;
                        char cCharAt2 = str.charAt(iZ2);
                        if (cCharAt2 == 'u') {
                            iA = a(str, iA);
                        } else {
                            char c = cCharAt2 < 'u' ? C2166ph.a[cCharAt2] : (char) 0;
                            if (c == 0) {
                                w(this, "Invalid escaped char '" + cCharAt2 + '\'', 0, 6);
                                throw null;
                            }
                            sb.append(c);
                        }
                        iZ = z(iA);
                        if (iZ == -1) {
                            w(this, "Unexpected EOF", iZ, 4);
                            throw null;
                        }
                    } else {
                        i2++;
                        if (i2 >= str.length()) {
                            sb.append((CharSequence) str, iZ, i2);
                            iZ = z(i2);
                            if (iZ == -1) {
                                w(this, "Unexpected EOF", iZ, 4);
                                throw null;
                            }
                        } else {
                            continue;
                            cCharAt = str.charAt(i2);
                        }
                    }
                    i2 = iZ;
                    z = true;
                    cCharAt = str.charAt(i2);
                }
                if (z) {
                    sb.append((CharSequence) str, iZ, i2);
                    String string2 = sb.toString();
                    sb.setLength(0);
                    string = string2;
                } else {
                    string = str.subSequence(iZ, i2).toString();
                }
                this.b = i2 + 1;
                return string;
            }
            i2++;
        }
        this.b = iV + 1;
        return str.substring(i, iV);
    }

    public void f(char c) {
        int i = this.b;
        if (i == -1) {
            C(c);
            throw null;
        }
        String str = (String) this.f;
        while (i < str.length()) {
            int i2 = i + 1;
            char cCharAt = str.charAt(i);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.b = i2;
                if (cCharAt == c) {
                    return;
                }
                C(c);
                throw null;
            }
            i = i2;
        }
        this.b = -1;
        C(c);
        throw null;
    }

    /* JADX WARN: Code restructure failed: missing block: B:101:0x0185, code lost:
    
        throw new o.C2170pj();
     */
    /* JADX WARN: Code restructure failed: missing block: B:102:0x0186, code lost:
    
        r10 = r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:103:0x0187, code lost:
    
        if (r14 == false) goto L105;
     */
    /* JADX WARN: Code restructure failed: missing block: B:104:0x0189, code lost:
    
        return r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:106:0x018e, code lost:
    
        if (r10 == Long.MIN_VALUE) goto L109;
     */
    /* JADX WARN: Code restructure failed: missing block: B:108:0x0191, code lost:
    
        return -r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:109:0x0192, code lost:
    
        w(r22, "Numeric value overflow", 0, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:110:0x0197, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:111:0x0198, code lost:
    
        w(r22, "Expected numeric literal", 0, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:112:0x019d, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x00e9, code lost:
    
        w(r22, "Unexpected symbol '" + r5 + "' in numeric literal", r7, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x0100, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:63:0x0101, code lost:
    
        if (r12 == r1) goto L65;
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x0103, code lost:
    
        r5 = true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:65:0x0105, code lost:
    
        r5 = false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:66:0x0106, code lost:
    
        if (r1 == r12) goto L71;
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x0108, code lost:
    
        if (r14 == false) goto L72;
     */
    /* JADX WARN: Code restructure failed: missing block: B:69:0x010c, code lost:
    
        if (r1 == (r12 - 1)) goto L71;
     */
    /* JADX WARN: Code restructure failed: missing block: B:72:0x0113, code lost:
    
        if (r3 == false) goto L81;
     */
    /* JADX WARN: Code restructure failed: missing block: B:73:0x0115, code lost:
    
        if (r5 == false) goto L79;
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x011d, code lost:
    
        if (r2.charAt(r12) != '\"') goto L77;
     */
    /* JADX WARN: Code restructure failed: missing block: B:76:0x011f, code lost:
    
        r12 = r12 + 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:77:0x0122, code lost:
    
        w(r22, "Expected closing quotation mark", 0, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:78:0x0129, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:79:0x012a, code lost:
    
        w(r22, "EOF", 0, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:80:0x012f, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:81:0x0130, code lost:
    
        r22.b = r12;
        r1 = r17;
     */
    /* JADX WARN: Code restructure failed: missing block: B:82:0x0134, code lost:
    
        if (r13 == false) goto L102;
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x0136, code lost:
    
        r1 = r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:84:0x0139, code lost:
    
        if (r11 != 0) goto L86;
     */
    /* JADX WARN: Code restructure failed: missing block: B:85:0x013b, code lost:
    
        r3 = java.lang.Math.pow(10.0d, -r9);
     */
    /* JADX WARN: Code restructure failed: missing block: B:87:0x0143, code lost:
    
        if (r11 != 1) goto L100;
     */
    /* JADX WARN: Code restructure failed: missing block: B:88:0x0145, code lost:
    
        r3 = java.lang.Math.pow(10.0d, r9);
     */
    /* JADX WARN: Code restructure failed: missing block: B:89:0x014a, code lost:
    
        r1 = r1 * r3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:90:0x014f, code lost:
    
        if (r1 > 9.223372036854776E18d) goto L98;
     */
    /* JADX WARN: Code restructure failed: missing block: B:92:0x0155, code lost:
    
        if (r1 < (-9.223372036854776E18d)) goto L98;
     */
    /* JADX WARN: Code restructure failed: missing block: B:94:0x015d, code lost:
    
        if (java.lang.Math.floor(r1) != r1) goto L96;
     */
    /* JADX WARN: Code restructure failed: missing block: B:95:0x015f, code lost:
    
        r10 = (long) r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:96:0x0161, code lost:
    
        w(r22, "Can't convert " + r1 + " to Long", 0, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:97:0x0179, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:98:0x017a, code lost:
    
        w(r22, "Numeric value overflow", 0, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:99:0x017f, code lost:
    
        throw null;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public long g() {
        /*
            Method dump skipped, instructions count: 421
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Ua0.g():long");
    }

    public String h() {
        String str = (String) this.d;
        if (str == null) {
            return e();
        }
        this.d = null;
        return str;
    }

    public String i() {
        String string;
        StringBuilder sb = (StringBuilder) this.e;
        String str = (String) this.f;
        String str2 = (String) this.d;
        if (str2 != null) {
            this.d = null;
            return str2;
        }
        int iA = A();
        if (iA >= str.length() || iA == -1) {
            w(this, "EOF", iA, 4);
            throw null;
        }
        byte bK = AbstractC0662Zn.k(str.charAt(iA));
        if (bK == 1) {
            return h();
        }
        if (bK != 0) {
            w(this, "Expected beginning of the string, but got " + str.charAt(iA), 0, 6);
            throw null;
        }
        boolean z = false;
        while (AbstractC0662Zn.k(str.charAt(iA)) == 0) {
            iA++;
            if (iA >= str.length()) {
                sb.append((CharSequence) str, this.b, iA);
                int iZ = z(iA);
                if (iZ == -1) {
                    this.b = iA;
                    sb.append((CharSequence) str, 0, 0);
                    String string2 = sb.toString();
                    sb.setLength(0);
                    return string2;
                }
                iA = iZ;
                z = true;
            }
        }
        if (z) {
            sb.append((CharSequence) str, this.b, iA);
            String string3 = sb.toString();
            sb.setLength(0);
            string = string3;
        } else {
            string = str.subSequence(this.b, iA).toString();
        }
        this.b = iA;
        return string;
    }

    public int j(L60 l60) {
        C1565jJ c1565jJ = (C1565jJ) this.c;
        C0688a6 c0688a6 = c1565jJ.a;
        Ua0 ua0 = (Ua0) this.e;
        Vm0 vm0 = (Vm0) this.d;
        int iOrdinal = vm0.ordinal();
        boolean zB = false;
        int iV = -1;
        if (iOrdinal == 0) {
            C0688a6 c0688a62 = (C0688a6) this.f;
            boolean zB2 = ua0.B();
            if (ua0.c()) {
                c0688a62.getClass();
                String strE = ua0.e();
                ua0.f(':');
                iV = AbstractC0940cn0.v(l60, c1565jJ, strE);
                if (iV == -3) {
                    ua0.v(Za0.a0(6, ((String) ua0.f).subSequence(0, ua0.b).toString(), strE), "Encountered an unknown key '" + strE + '\'', "Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.");
                    throw null;
                }
            } else if (zB2) {
                c0688a6.getClass();
                AbstractC0249Jp.N(ua0);
                throw null;
            }
        } else if (iOrdinal != 2) {
            boolean zB3 = ua0.B();
            if (ua0.c()) {
                int i = this.b;
                if (i != -1 && !zB3) {
                    w(ua0, "Expected end of the array or comma", 0, 6);
                    throw null;
                }
                iV = i + 1;
                this.b = iV;
            } else if (zB3) {
                c0688a6.getClass();
                AbstractC0249Jp.M(ua0, "array");
                throw null;
            }
        } else {
            int i2 = this.b;
            boolean z = i2 % 2 != 0;
            if (!z) {
                ua0.f(':');
            } else if (i2 != -1) {
                zB = ua0.B();
            }
            if (ua0.c()) {
                if (z) {
                    if (this.b == -1) {
                        int i3 = ua0.b;
                        if (zB) {
                            w(ua0, "Unexpected leading comma", i3, 4);
                            throw null;
                        }
                    } else {
                        int i4 = ua0.b;
                        if (!zB) {
                            w(ua0, "Expected comma after the key-value pair", i4, 4);
                            throw null;
                        }
                    }
                }
                iV = this.b + 1;
                this.b = iV;
            } else if (zB) {
                c0688a6.getClass();
                AbstractC0249Jp.N(ua0);
                throw null;
            }
        }
        if (vm0 != Vm0.p) {
            C0692a8 c0692a8 = (C0692a8) ua0.c;
            ((int[]) c0692a8.d)[c0692a8.b] = iV;
        }
        return iV;
    }

    public int k() {
        Ua0 ua0 = (Ua0) this.e;
        long jG = ua0.g();
        int i = (int) jG;
        if (jG == i) {
            return i;
        }
        w(ua0, "Failed to parse int for input '" + jG + '\'', 0, 6);
        throw null;
    }

    public int l(L60 l60, int i) {
        return k();
    }

    public long m() {
        return ((Ua0) this.e).g();
    }

    public long n(L60 l60, int i) {
        return m();
    }

    public boolean o() {
        Ua0 ua0 = (Ua0) this.e;
        int iZ = ua0.z(ua0.A());
        String str = (String) ua0.f;
        int length = str.length() - iZ;
        boolean z = false;
        if (length >= 4 && iZ != -1) {
            int i = 0;
            while (true) {
                if (i < 4) {
                    if ("null".charAt(i) != str.charAt(iZ + i)) {
                        break;
                    }
                    i++;
                } else if (length <= 4 || AbstractC0662Zn.k(str.charAt(iZ + 4)) != 0) {
                    z = true;
                    ua0.b = iZ + 4;
                }
            }
        }
        return !z;
    }

    public Object p(L60 l60, int i, EJ ej, Object obj) {
        if (ej.d().h() || o()) {
            return r(ej);
        }
        return null;
    }

    public Object q(L60 l60, int i, EJ ej, Object obj) {
        C0692a8 c0692a8 = (C0692a8) ((Ua0) this.e).c;
        boolean z = ((Vm0) this.d) == Vm0.p && (i & 1) == 0;
        if (z) {
            int[] iArr = (int[]) c0692a8.d;
            int i2 = c0692a8.b;
            if (iArr[i2] == -2) {
                ((Object[]) c0692a8.c)[i2] = ME.v;
            }
        }
        Object objR = r(ej);
        if (z) {
            int[] iArr2 = (int[]) c0692a8.d;
            int i3 = c0692a8.b;
            if (iArr2[i3] != -2) {
                int i4 = i3 + 1;
                c0692a8.b = i4;
                Object[] objArr = (Object[]) c0692a8.c;
                if (i4 == objArr.length) {
                    int i5 = i4 * 2;
                    c0692a8.c = Arrays.copyOf(objArr, i5);
                    c0692a8.d = Arrays.copyOf((int[]) c0692a8.d, i5);
                }
            }
            Object[] objArr2 = (Object[]) c0692a8.c;
            int i6 = c0692a8.b;
            objArr2[i6] = objR;
            ((int[]) c0692a8.d)[i6] = -2;
        }
        return objR;
    }

    public Object r(EJ ej) {
        try {
            return ej.a(this);
        } catch (HP e) {
            if (Za0.P(e.getMessage(), "at path", false)) {
                throw e;
            }
            throw new HP(e.l, e.getMessage() + " at path: " + ((C0692a8) ((Ua0) this.e).c).f(), e);
        }
    }

    public String s() {
        Ua0 ua0 = (Ua0) this.e;
        ((C0688a6) this.f).getClass();
        return ua0.h();
    }

    public String t(L60 l60, int i) {
        return s();
    }

    public String toString() {
        switch (this.a) {
            case 1:
                StringBuilder sb = new StringBuilder("JsonReader(source='");
                sb.append(this.f);
                sb.append("', currentPosition=");
                return AbstractC2462sn.m(sb, this.b, ')');
            default:
                return super.toString();
        }
    }

    public void u(L60 l60) {
        Ua0 ua0 = (Ua0) this.e;
        C0688a6 c0688a6 = ((C1565jJ) this.c).a;
        c0688a6.getClass();
        if (ua0.B()) {
            c0688a6.getClass();
            AbstractC0249Jp.M(ua0, "");
            throw null;
        }
        ua0.f(((Vm0) this.d).m);
        C0692a8 c0692a8 = (C0692a8) ua0.c;
        int i = c0692a8.b;
        int[] iArr = (int[]) c0692a8.d;
        if (iArr[i] == -2) {
            iArr[i] = -1;
            c0692a8.b = i - 1;
        }
        int i2 = c0692a8.b;
        if (i2 != -1) {
            c0692a8.b = i2 - 1;
        }
    }

    public void v(int i, String str, String str2) {
        throw AbstractC0249Jp.e(i, (String) this.f, str + " at path: " + ((C0692a8) this.c).f() + (str2.length() == 0 ? "" : "\n".concat(str2)));
    }

    public void x(byte b, boolean z) {
        String str = (String) this.f;
        String strK = AbstractC0662Zn.K(b);
        int i = z ? this.b - 1 : this.b;
        w(this, "Expected " + strK + ", but had '" + ((this.b == str.length() || i < 0) ? "EOF" : String.valueOf(str.charAt(i))) + "' instead", i, 4);
        throw null;
    }

    public int y(CharSequence charSequence, int i) {
        char cCharAt = charSequence.charAt(i);
        if ('0' <= cCharAt && cCharAt < ':') {
            return cCharAt - '0';
        }
        if ('a' <= cCharAt && cCharAt < 'g') {
            return cCharAt - 'W';
        }
        if ('A' <= cCharAt && cCharAt < 'G') {
            return cCharAt - '7';
        }
        w(this, "Invalid toHexChar char '" + cCharAt + "' in unicode escape", 0, 6);
        throw null;
    }

    public int z(int i) {
        if (i < ((String) this.f).length()) {
            return i;
        }
        return -1;
    }

    public Ua0(String str) {
        this.a = 1;
        C0692a8 c0692a8 = new C0692a8(5, (byte) 0);
        c0692a8.c = new Object[8];
        int[] iArr = new int[8];
        for (int i = 0; i < 8; i++) {
            iArr[i] = -1;
        }
        c0692a8.d = iArr;
        c0692a8.b = -1;
        this.c = c0692a8;
        this.e = new StringBuilder();
        this.f = str;
    }
}
