package g5; import java.io.Closeable; import java.io.Flushable; import java.io.IOException; import java.io.Writer; import java.util.Arrays; /* loaded from: classes2.dex */ public class c implements Closeable, Flushable { /* renamed from: j, reason: collision with root package name */ private static final String[] f9710j = new String[128]; /* renamed from: k, reason: collision with root package name */ private static final String[] f9711k; /* renamed from: a, reason: collision with root package name */ private final Writer f9712a; /* renamed from: b, reason: collision with root package name */ private int[] f9713b = new int[32]; /* renamed from: c, reason: collision with root package name */ private int f9714c = 0; /* renamed from: d, reason: collision with root package name */ private String f9715d; /* renamed from: e, reason: collision with root package name */ private String f9716e; /* renamed from: f, reason: collision with root package name */ private boolean f9717f; /* renamed from: g, reason: collision with root package name */ private boolean f9718g; /* renamed from: h, reason: collision with root package name */ private String f9719h; /* renamed from: i, reason: collision with root package name */ private boolean f9720i; static { for (int i10 = 0; i10 <= 31; i10++) { f9710j[i10] = String.format("\\u%04x", Integer.valueOf(i10)); } String[] strArr = f9710j; strArr[34] = "\\\""; strArr[92] = "\\\\"; strArr[9] = "\\t"; strArr[8] = "\\b"; strArr[10] = "\\n"; strArr[13] = "\\r"; strArr[12] = "\\f"; String[] strArr2 = (String[]) strArr.clone(); f9711k = strArr2; strArr2[60] = "\\u003c"; strArr2[62] = "\\u003e"; strArr2[38] = "\\u0026"; strArr2[61] = "\\u003d"; strArr2[39] = "\\u0027"; } public c(Writer writer) { q0(6); this.f9716e = ":"; this.f9720i = true; if (writer == null) { throw new NullPointerException("out == null"); } this.f9712a = writer; } /* JADX WARN: Removed duplicated region for block: B:11:0x0034 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private void E0(java.lang.String r9) { /* r8 = this; boolean r0 = r8.f9718g if (r0 == 0) goto L7 java.lang.String[] r0 = g5.c.f9711k goto L9 L7: java.lang.String[] r0 = g5.c.f9710j L9: java.io.Writer r1 = r8.f9712a r2 = 34 r1.write(r2) int r1 = r9.length() r3 = 0 r4 = 0 L16: if (r3 >= r1) goto L45 char r5 = r9.charAt(r3) r6 = 128(0x80, float:1.8E-43) if (r5 >= r6) goto L25 r5 = r0[r5] if (r5 != 0) goto L32 goto L42 L25: r6 = 8232(0x2028, float:1.1535E-41) if (r5 != r6) goto L2c java.lang.String r5 = "\\u2028" goto L32 L2c: r6 = 8233(0x2029, float:1.1537E-41) if (r5 != r6) goto L42 java.lang.String r5 = "\\u2029" L32: if (r4 >= r3) goto L3b java.io.Writer r6 = r8.f9712a int r7 = r3 - r4 r6.write(r9, r4, r7) L3b: java.io.Writer r4 = r8.f9712a r4.write(r5) int r4 = r3 + 1 L42: int r3 = r3 + 1 goto L16 L45: if (r4 >= r1) goto L4d java.io.Writer r0 = r8.f9712a int r1 = r1 - r4 r0.write(r9, r4, r1) L4d: java.io.Writer r9 = r8.f9712a r9.write(r2) return */ throw new UnsupportedOperationException("Method not decompiled: g5.c.E0(java.lang.String):void"); } private void K0() { if (this.f9719h != null) { c(); E0(this.f9719h); this.f9719h = null; } } private c O(int i10, int i11, char c10) { int n02 = n0(); if (n02 != i11 && n02 != i10) { throw new IllegalStateException("Nesting problem."); } if (this.f9719h != null) { throw new IllegalStateException("Dangling name: " + this.f9719h); } this.f9714c--; if (n02 == i11) { f0(); } this.f9712a.write(c10); return this; } private void c() { int n02 = n0(); if (n02 == 5) { this.f9712a.write(44); } else if (n02 != 3) { throw new IllegalStateException("Nesting problem."); } f0(); r0(4); } private void f0() { if (this.f9715d == null) { return; } this.f9712a.write(10); int i10 = this.f9714c; for (int i11 = 1; i11 < i10; i11++) { this.f9712a.write(this.f9715d); } } private c m0(int i10, char c10) { z(); q0(i10); this.f9712a.write(c10); return this; } private int n0() { int i10 = this.f9714c; if (i10 != 0) { return this.f9713b[i10 - 1]; } throw new IllegalStateException("JsonWriter is closed."); } private void q0(int i10) { int i11 = this.f9714c; int[] iArr = this.f9713b; if (i11 == iArr.length) { this.f9713b = Arrays.copyOf(iArr, i11 * 2); } int[] iArr2 = this.f9713b; int i12 = this.f9714c; this.f9714c = i12 + 1; iArr2[i12] = i10; } private void r0(int i10) { this.f9713b[this.f9714c - 1] = i10; } private void z() { int n02 = n0(); if (n02 == 1) { r0(2); f0(); return; } if (n02 == 2) { this.f9712a.append(','); f0(); } else { if (n02 == 4) { this.f9712a.append((CharSequence) this.f9716e); r0(5); return; } if (n02 != 6) { if (n02 != 7) { throw new IllegalStateException("Nesting problem."); } if (!this.f9717f) { throw new IllegalStateException("JSON must have only one top-level value."); } } r0(7); } } public final void D0(boolean z10) { this.f9720i = z10; } public c F0(long j10) { K0(); z(); this.f9712a.write(Long.toString(j10)); return this; } public c G() { K0(); return m0(1, '['); } public c G0(Boolean bool) { if (bool == null) { return j0(); } K0(); z(); this.f9712a.write(bool.booleanValue() ? "true" : "false"); return this; } public c H0(Number number) { if (number == null) { return j0(); } K0(); String obj = number.toString(); if (this.f9717f || !(obj.equals("-Infinity") || obj.equals("Infinity") || obj.equals("NaN"))) { z(); this.f9712a.append((CharSequence) obj); return this; } throw new IllegalArgumentException("Numeric values must be finite, but was " + number); } public c I() { K0(); return m0(3, '{'); } public c I0(String str) { if (str == null) { return j0(); } K0(); z(); E0(str); return this; } public c J0(boolean z10) { K0(); z(); this.f9712a.write(z10 ? "true" : "false"); return this; } public c P() { return O(1, 2, ']'); } public c R() { return O(3, 5, '}'); } public final boolean S() { return this.f9720i; } public final boolean Y() { return this.f9718g; } public boolean a0() { return this.f9717f; } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() { this.f9712a.close(); int i10 = this.f9714c; if (i10 > 1 || (i10 == 1 && this.f9713b[i10 - 1] != 7)) { throw new IOException("Incomplete document"); } this.f9714c = 0; } public c d0(String str) { if (str == null) { throw new NullPointerException("name == null"); } if (this.f9719h != null) { throw new IllegalStateException(); } if (this.f9714c == 0) { throw new IllegalStateException("JsonWriter is closed."); } this.f9719h = str; return this; } public void flush() { if (this.f9714c == 0) { throw new IllegalStateException("JsonWriter is closed."); } this.f9712a.flush(); } public c j0() { if (this.f9719h != null) { if (!this.f9720i) { this.f9719h = null; return this; } K0(); } z(); this.f9712a.write("null"); return this; } public final void u0(boolean z10) { this.f9718g = z10; } public final void w0(String str) { if (str.length() == 0) { this.f9715d = null; this.f9716e = ":"; } else { this.f9715d = str; this.f9716e = ": "; } } public final void z0(boolean z10) { this.f9717f = z10; } }