package i;

import com.seewo.sdk.model.SDKKeyboardCode;
import d.AbstractC0421a;
import d.C0424d;
import java.io.IOException;
import java.io.Writer;
import java.math.BigDecimal;
import l.AbstractC0613e;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes.dex */
public final class e0 extends Writer {

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    private static final ThreadLocal f4335h0 = new ThreadLocal();

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    private static final ThreadLocal f4336i0 = new ThreadLocal();

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    private static final char[] f4337j0 = ":true".toCharArray();

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    private static final char[] f4338k0 = ":false".toCharArray();

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    private static int f4339l0;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    static final int f4340m0;

    /* JADX INFO: renamed from: H, reason: collision with root package name */
    protected boolean f4341H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    protected boolean f4342I;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    protected boolean f4343L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    protected boolean f4344M;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    protected boolean f4345Q;

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    protected boolean f4346Z;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    protected boolean f4347a0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    protected char[] f4348b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    protected boolean f4349b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    protected boolean f4350c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    protected char f4351d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    protected int f4352e0;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    protected boolean f4353f0;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    protected int f4354g;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    protected long f4355g0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    protected int f4356r;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private final Writer f4357x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    protected boolean f4358y;

    static {
        int i2;
        f4339l0 = 131072;
        try {
            String strG = AbstractC0613e.g("fastjson.serializer_buffer_threshold");
            if (strG != null && strG.length() > 0 && (i2 = Integer.parseInt(strG)) >= 64 && i2 <= 65536) {
                f4339l0 = i2 * 1024;
            }
        } catch (Throwable unused) {
        }
        f4340m0 = f0.UseSingleQuotes.mask | f0.BrowserCompatible.mask | f0.PrettyFormat.mask | f0.WriteEnumUsingToString.mask | f0.WriteNonStringValueAsString.mask | f0.WriteSlashAsSpecial.mask | f0.IgnoreErrorGetter.mask | f0.WriteClassName.mask | f0.NotWriteDefaultValue.mask;
    }

    public e0() {
        this(null);
    }

    private void H(String str) {
        byte[] bArr = AbstractC0613e.f5272g;
        int length = str.length();
        boolean z2 = true;
        int i2 = this.f4354g + length + 1;
        int i3 = 0;
        if (i2 > this.f4348b.length) {
            if (this.f4357x != null) {
                if (length == 0) {
                    write(39);
                    write(39);
                    write(58);
                    return;
                }
                int i4 = 0;
                while (true) {
                    if (i4 < length) {
                        char cCharAt = str.charAt(i4);
                        if (cCharAt < bArr.length && bArr[cCharAt] != 0) {
                            break;
                        } else {
                            i4++;
                        }
                    } else {
                        z2 = false;
                        break;
                    }
                }
                if (z2) {
                    write(39);
                }
                while (i3 < length) {
                    char cCharAt2 = str.charAt(i3);
                    if (cCharAt2 >= bArr.length || bArr[cCharAt2] == 0) {
                        write(cCharAt2);
                    } else {
                        write(92);
                        write(AbstractC0613e.f5275j[cCharAt2]);
                    }
                    i3++;
                }
                if (z2) {
                    write(39);
                }
                write(58);
                return;
            }
            h(i2);
        }
        if (length == 0) {
            int i5 = this.f4354g;
            if (i5 + 3 > this.f4348b.length) {
                h(i5 + 3);
            }
            char[] cArr = this.f4348b;
            int i6 = this.f4354g;
            int i7 = i6 + 1;
            this.f4354g = i7;
            cArr[i6] = '\'';
            int i8 = i6 + 2;
            this.f4354g = i8;
            cArr[i7] = '\'';
            this.f4354g = i6 + 3;
            cArr[i8] = ':';
            return;
        }
        int i9 = this.f4354g;
        int i10 = i9 + length;
        str.getChars(0, length, this.f4348b, i9);
        this.f4354g = i2;
        int i11 = i9;
        boolean z3 = false;
        while (i11 < i10) {
            char[] cArr2 = this.f4348b;
            char c2 = cArr2[i11];
            if (c2 < bArr.length && bArr[c2] != 0) {
                if (z3) {
                    i2++;
                    if (i2 > cArr2.length) {
                        h(i2);
                    }
                    this.f4354g = i2;
                    char[] cArr3 = this.f4348b;
                    int i12 = i11 + 1;
                    System.arraycopy(cArr3, i12, cArr3, i11 + 2, i10 - i11);
                    char[] cArr4 = this.f4348b;
                    cArr4[i11] = '\\';
                    cArr4[i12] = AbstractC0613e.f5275j[c2];
                    i10++;
                    i11 = i12;
                } else {
                    i2 += 3;
                    if (i2 > cArr2.length) {
                        h(i2);
                    }
                    this.f4354g = i2;
                    char[] cArr5 = this.f4348b;
                    int i13 = i11 + 1;
                    System.arraycopy(cArr5, i13, cArr5, i11 + 3, (i10 - i11) - 1);
                    char[] cArr6 = this.f4348b;
                    System.arraycopy(cArr6, i3, cArr6, 1, i11);
                    char[] cArr7 = this.f4348b;
                    cArr7[i9] = '\'';
                    cArr7[i13] = '\\';
                    i11 += 2;
                    cArr7[i11] = AbstractC0613e.f5275j[c2];
                    i10 += 2;
                    cArr7[this.f4354g - 2] = '\'';
                    z3 = true;
                }
            }
            i11++;
            i3 = 0;
        }
        this.f4348b[i2 - 1] = ':';
    }

    public void A(char c2, String str, BigDecimal bigDecimal) {
        write(c2);
        s(str);
        if (bigDecimal == null) {
            K();
        } else {
            int iScale = bigDecimal.scale();
            write((!j(f0.WriteBigDecimalAsPlain) || iScale < -100 || iScale >= 100) ? bigDecimal.toString() : bigDecimal.toPlainString());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x009d A[PHI: r1 r4 r6 r9 r10
      0x009d: PHI (r1v50 int) = (r1v41 int), (r1v3 int) binds: [B:53:0x00d6, B:30:0x0098] A[DONT_GENERATE, DONT_INLINE]
      0x009d: PHI (r4v21 int) = (r4v20 int), (r4v23 int) binds: [B:53:0x00d6, B:30:0x0098] A[DONT_GENERATE, DONT_INLINE]
      0x009d: PHI (r6v7 char) = (r6v6 char), (r6v9 char) binds: [B:53:0x00d6, B:30:0x0098] A[DONT_GENERATE, DONT_INLINE]
      0x009d: PHI (r9v11 int) = (r9v10 int), (r9v13 int) binds: [B:53:0x00d6, B:30:0x0098] A[DONT_GENERATE, DONT_INLINE]
      0x009d: PHI (r10v13 int) = (r10v3 int), (r10v15 int) binds: [B:53:0x00d6, B:30:0x0098] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00d2  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x00d8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void C(char r22, java.lang.String r23, java.lang.String r24) {
        /*
            Method dump skipped, instruction units count: 783
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: i.e0.C(char, java.lang.String, java.lang.String):void");
    }

    public void D(float f2, boolean z2) {
        if (f2 != f2 || f2 == Float.POSITIVE_INFINITY || f2 == Float.NEGATIVE_INFINITY) {
            K();
            return;
        }
        int i2 = this.f4354g + 15;
        if (i2 > this.f4348b.length) {
            if (this.f4357x != null) {
                String strB = l.j.b(f2);
                write(strB, 0, strB.length());
                if (z2 && j(f0.WriteClassName)) {
                    write(70);
                    return;
                }
                return;
            }
            h(i2);
        }
        this.f4354g += l.j.a(f2, this.f4348b, this.f4354g);
        if (z2 && j(f0.WriteClassName)) {
            write(70);
        }
    }

    public void F(byte[] bArr) {
        int length = this.f4354g + (bArr.length * 2) + 3;
        if (length > this.f4348b.length) {
            h(length);
        }
        char[] cArr = this.f4348b;
        int i2 = this.f4354g;
        int i3 = i2 + 1;
        this.f4354g = i3;
        cArr[i2] = 'x';
        this.f4354g = i2 + 2;
        cArr[i3] = '\'';
        for (byte b2 : bArr) {
            int i4 = (b2 & 255) >> 4;
            int i5 = b2 & SDKKeyboardCode.FUNCTION_KEY_BOARD_L;
            char[] cArr2 = this.f4348b;
            int i6 = this.f4354g;
            int i7 = i6 + 1;
            this.f4354g = i7;
            int i8 = 55;
            cArr2[i6] = (char) (i4 + (i4 < 10 ? 48 : 55));
            this.f4354g = i6 + 2;
            if (i5 < 10) {
                i8 = 48;
            }
            cArr2[i7] = (char) (i5 + i8);
        }
        char[] cArr3 = this.f4348b;
        int i9 = this.f4354g;
        this.f4354g = i9 + 1;
        cArr3[i9] = '\'';
    }

    public void G(int i2) {
        if (i2 == Integer.MIN_VALUE) {
            write("-2147483648");
            return;
        }
        int i3 = i2 < 0 ? AbstractC0613e.i(-i2) + 1 : AbstractC0613e.i(i2);
        int i4 = this.f4354g + i3;
        if (i4 > this.f4348b.length) {
            if (this.f4357x != null) {
                char[] cArr = new char[i3];
                AbstractC0613e.e(i2, i3, cArr);
                write(cArr, 0, i3);
                return;
            }
            h(i4);
        }
        AbstractC0613e.e(i2, i4, this.f4348b);
        this.f4354g = i4;
    }

    public void I(long j2) {
        boolean z2 = j(f0.BrowserCompatible) && !j(f0.WriteClassName) && (j2 > 9007199254740991L || j2 < -9007199254740991L);
        if (j2 == Long.MIN_VALUE) {
            if (z2) {
                write("\"-9223372036854775808\"");
                return;
            } else {
                write("-9223372036854775808");
                return;
            }
        }
        int iJ = j2 < 0 ? AbstractC0613e.j(-j2) + 1 : AbstractC0613e.j(j2);
        int i2 = this.f4354g + iJ;
        if (z2) {
            i2 += 2;
        }
        if (i2 > this.f4348b.length) {
            if (this.f4357x != null) {
                char[] cArr = new char[iJ];
                AbstractC0613e.f(j2, iJ, cArr);
                if (!z2) {
                    write(cArr, 0, iJ);
                    return;
                }
                write(34);
                write(cArr, 0, iJ);
                write(34);
                return;
            }
            h(i2);
        }
        if (z2) {
            char[] cArr2 = this.f4348b;
            cArr2[this.f4354g] = '\"';
            int i3 = i2 - 1;
            AbstractC0613e.f(j2, i3, cArr2);
            this.f4348b[i3] = '\"';
        } else {
            AbstractC0613e.f(j2, i2, this.f4348b);
        }
        this.f4354g = i2;
    }

    public void K() {
        write("null");
    }

    public void L(int i2, int i3) {
        if ((i2 & i3) == 0 && (this.f4356r & i3) == 0) {
            K();
            return;
        }
        int i4 = f0.WriteMapNullValue.mask;
        if ((i2 & i4) != 0 && (i2 & (~i4) & f0.WRITE_MAP_NULL_FEATURES) == 0) {
            K();
            return;
        }
        if (i3 == f0.WriteNullListAsEmpty.mask) {
            write(HttpUrl.PATH_SEGMENT_ENCODE_SET_URI);
            return;
        }
        if (i3 == f0.WriteNullStringAsEmpty.mask) {
            O(HttpUrl.FRAGMENT_ENCODE_SET);
            return;
        }
        if (i3 == f0.WriteNullBooleanAsFalse.mask) {
            write("false");
        } else if (i3 == f0.WriteNullNumberAsZero.mask) {
            write(48);
        } else {
            K();
        }
    }

    public void N(f0 f0Var) {
        L(0, f0Var.mask);
    }

    public void O(String str) {
        if (this.f4358y) {
            R(str);
        } else {
            Q(str, (char) 0);
        }
    }

    public void P(char[] cArr) {
        if (this.f4358y) {
            S(cArr);
        } else {
            Q(new String(cArr), (char) 0);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:144:0x02b3 A[PHI: r5 r9 r11 r15
      0x02b3: PHI (r5v29 int) = (r5v27 int), (r5v31 int) binds: [B:166:0x02ed, B:143:0x02af] A[DONT_GENERATE, DONT_INLINE]
      0x02b3: PHI (r9v22 int) = (r9v15 int), (r9v3 int) binds: [B:166:0x02ed, B:143:0x02af] A[DONT_GENERATE, DONT_INLINE]
      0x02b3: PHI (r11v14 int) = (r11v12 int), (r11v16 int) binds: [B:166:0x02ed, B:143:0x02af] A[DONT_GENERATE, DONT_INLINE]
      0x02b3: PHI (r15v13 int) = (r15v2 int), (r15v15 int) binds: [B:166:0x02ed, B:143:0x02af] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:165:0x02ea  */
    /* JADX WARN: Removed duplicated region for block: B:167:0x02ef  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x014f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void Q(java.lang.String r23, char r24) {
        /*
            Method dump skipped, instruction units count: 1345
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: i.e0.Q(java.lang.String, char):void");
    }

    protected void R(String str) {
        int i2 = 0;
        if (str == null) {
            int i3 = this.f4354g + 4;
            if (i3 > this.f4348b.length) {
                h(i3);
            }
            "null".getChars(0, 4, this.f4348b, this.f4354g);
            this.f4354g = i3;
            return;
        }
        int length = str.length();
        int i4 = this.f4354g + length + 2;
        if (i4 > this.f4348b.length) {
            if (this.f4357x != null) {
                write(39);
                while (i2 < str.length()) {
                    char cCharAt = str.charAt(i2);
                    if (cCharAt <= '\r' || cCharAt == '\\' || cCharAt == '\'' || (cCharAt == '/' && j(f0.WriteSlashAsSpecial))) {
                        write(92);
                        write(AbstractC0613e.f5275j[cCharAt]);
                    } else {
                        write(cCharAt);
                    }
                    i2++;
                }
                write(39);
                return;
            }
            h(i4);
        }
        int i5 = this.f4354g;
        int i6 = i5 + 1;
        int i7 = i6 + length;
        char[] cArr = this.f4348b;
        cArr[i5] = '\'';
        str.getChars(0, length, cArr, i6);
        this.f4354g = i4;
        int i8 = -1;
        char c2 = 0;
        for (int i9 = i6; i9 < i7; i9++) {
            char c3 = this.f4348b[i9];
            if (c3 <= '\r' || c3 == '\\' || c3 == '\'' || (c3 == '/' && j(f0.WriteSlashAsSpecial))) {
                i2++;
                i8 = i9;
                c2 = c3;
            }
        }
        int i10 = i4 + i2;
        if (i10 > this.f4348b.length) {
            h(i10);
        }
        this.f4354g = i10;
        if (i2 == 1) {
            char[] cArr2 = this.f4348b;
            int i11 = i8 + 1;
            System.arraycopy(cArr2, i11, cArr2, i8 + 2, (i7 - i8) - 1);
            char[] cArr3 = this.f4348b;
            cArr3[i8] = '\\';
            cArr3[i11] = AbstractC0613e.f5275j[c2];
        } else if (i2 > 1) {
            char[] cArr4 = this.f4348b;
            int i12 = i8 + 1;
            System.arraycopy(cArr4, i12, cArr4, i8 + 2, (i7 - i8) - 1);
            char[] cArr5 = this.f4348b;
            cArr5[i8] = '\\';
            cArr5[i12] = AbstractC0613e.f5275j[c2];
            int i13 = i7 + 1;
            for (int i14 = i8 - 1; i14 >= i6; i14--) {
                char c4 = this.f4348b[i14];
                if (c4 <= '\r' || c4 == '\\' || c4 == '\'' || (c4 == '/' && j(f0.WriteSlashAsSpecial))) {
                    char[] cArr6 = this.f4348b;
                    int i15 = i14 + 1;
                    System.arraycopy(cArr6, i15, cArr6, i14 + 2, (i13 - i14) - 1);
                    char[] cArr7 = this.f4348b;
                    cArr7[i14] = '\\';
                    cArr7[i15] = AbstractC0613e.f5275j[c4];
                    i13++;
                }
            }
        }
        this.f4348b[this.f4354g - 1] = '\'';
    }

    protected void S(char[] cArr) {
        int i2 = 0;
        if (cArr == null) {
            int i3 = this.f4354g + 4;
            if (i3 > this.f4348b.length) {
                h(i3);
            }
            "null".getChars(0, 4, this.f4348b, this.f4354g);
            this.f4354g = i3;
            return;
        }
        int length = cArr.length;
        int i4 = this.f4354g + length + 2;
        if (i4 > this.f4348b.length) {
            if (this.f4357x != null) {
                write(39);
                while (i2 < cArr.length) {
                    char c2 = cArr[i2];
                    if (c2 <= '\r' || c2 == '\\' || c2 == '\'' || (c2 == '/' && j(f0.WriteSlashAsSpecial))) {
                        write(92);
                        write(AbstractC0613e.f5275j[c2]);
                    } else {
                        write(c2);
                    }
                    i2++;
                }
                write(39);
                return;
            }
            h(i4);
        }
        int i5 = this.f4354g;
        int i6 = i5 + 1;
        int i7 = length + i6;
        char[] cArr2 = this.f4348b;
        cArr2[i5] = '\'';
        System.arraycopy(cArr, 0, cArr2, i6, cArr.length);
        this.f4354g = i4;
        int i8 = -1;
        char c3 = 0;
        for (int i9 = i6; i9 < i7; i9++) {
            char c4 = this.f4348b[i9];
            if (c4 <= '\r' || c4 == '\\' || c4 == '\'' || (c4 == '/' && j(f0.WriteSlashAsSpecial))) {
                i2++;
                i8 = i9;
                c3 = c4;
            }
        }
        int i10 = i4 + i2;
        if (i10 > this.f4348b.length) {
            h(i10);
        }
        this.f4354g = i10;
        if (i2 == 1) {
            char[] cArr3 = this.f4348b;
            int i11 = i8 + 1;
            System.arraycopy(cArr3, i11, cArr3, i8 + 2, (i7 - i8) - 1);
            char[] cArr4 = this.f4348b;
            cArr4[i8] = '\\';
            cArr4[i11] = AbstractC0613e.f5275j[c3];
        } else if (i2 > 1) {
            char[] cArr5 = this.f4348b;
            int i12 = i8 + 1;
            System.arraycopy(cArr5, i12, cArr5, i8 + 2, (i7 - i8) - 1);
            char[] cArr6 = this.f4348b;
            cArr6[i8] = '\\';
            cArr6[i12] = AbstractC0613e.f5275j[c3];
            int i13 = i7 + 1;
            for (int i14 = i8 - 1; i14 >= i6; i14--) {
                char c5 = this.f4348b[i14];
                if (c5 <= '\r' || c5 == '\\' || c5 == '\'' || (c5 == '/' && j(f0.WriteSlashAsSpecial))) {
                    char[] cArr7 = this.f4348b;
                    int i15 = i14 + 1;
                    System.arraycopy(cArr7, i15, cArr7, i14 + 2, (i13 - i14) - 1);
                    char[] cArr8 = this.f4348b;
                    cArr8[i14] = '\\';
                    cArr8[i15] = AbstractC0613e.f5275j[c5];
                    i13++;
                }
            }
        }
        this.f4348b[this.f4354g - 1] = '\'';
    }

    @Override // java.io.Writer, java.lang.Appendable
    /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
    public e0 append(char c2) {
        write(c2);
        return this;
    }

    @Override // java.io.Writer, java.lang.Appendable
    /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
    public e0 append(CharSequence charSequence) {
        String string = charSequence == null ? "null" : charSequence.toString();
        write(string, 0, string.length());
        return this;
    }

    @Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        if (this.f4357x != null && this.f4354g > 0) {
            flush();
        }
        char[] cArr = this.f4348b;
        if (cArr.length <= f4339l0) {
            f4335h0.set(cArr);
        }
        this.f4348b = null;
    }

    @Override // java.io.Writer, java.lang.Appendable
    /* JADX INFO: renamed from: d, reason: merged with bridge method [inline-methods] */
    public e0 append(CharSequence charSequence, int i2, int i3) {
        if (charSequence == null) {
            charSequence = "null";
        }
        String string = charSequence.subSequence(i2, i3).toString();
        write(string, 0, string.length());
        return this;
    }

    protected void e() {
        int i2 = this.f4356r;
        boolean z2 = (f0.QuoteFieldNames.mask & i2) != 0;
        this.f4341H = z2;
        boolean z3 = (f0.UseSingleQuotes.mask & i2) != 0;
        this.f4358y = z3;
        this.f4342I = (f0.SortField.mask & i2) != 0;
        this.f4343L = (f0.DisableCircularReferenceDetect.mask & i2) != 0;
        boolean z4 = (f0.BeanToArray.mask & i2) != 0;
        this.f4344M = z4;
        this.f4345Q = (f0.WriteNonStringValueAsString.mask & i2) != 0;
        this.f4346Z = (f0.NotWriteDefaultValue.mask & i2) != 0;
        boolean z5 = (f0.WriteEnumUsingName.mask & i2) != 0;
        this.f4347a0 = z5;
        this.f4349b0 = (f0.WriteEnumUsingToString.mask & i2) != 0;
        this.f4350c0 = z2 && (f4340m0 & i2) == 0 && (z4 || z5);
        this.f4351d0 = z3 ? '\'' : '\"';
        boolean z6 = (f0.BrowserSecure.mask & i2) != 0;
        this.f4353f0 = z6;
        this.f4355g0 = z6 ? 5764610843043954687L : (i2 & f0.WriteSlashAsSpecial.mask) != 0 ? 140758963191807L : 21474836479L;
    }

    public void f(f0 f0Var, boolean z2) {
        if (z2) {
            int mask = this.f4356r | f0Var.getMask();
            this.f4356r = mask;
            f0 f0Var2 = f0.WriteEnumUsingToString;
            if (f0Var == f0Var2) {
                this.f4356r = (~f0.WriteEnumUsingName.getMask()) & mask;
            } else if (f0Var == f0.WriteEnumUsingName) {
                this.f4356r = (~f0Var2.getMask()) & mask;
            }
        } else {
            this.f4356r = (~f0Var.getMask()) & this.f4356r;
        }
        e();
    }

    @Override // java.io.Writer, java.io.Flushable
    public void flush() {
        Writer writer = this.f4357x;
        if (writer == null) {
            return;
        }
        try {
            writer.write(this.f4348b, 0, this.f4354g);
            this.f4357x.flush();
            this.f4354g = 0;
        } catch (IOException e2) {
            throw new C0424d(e2.getMessage(), e2);
        }
    }

    public void h(int i2) {
        int i3 = this.f4352e0;
        if (i3 != -1 && i2 >= i3) {
            throw new C0424d("serialize exceeded MAX_OUTPUT_LENGTH=" + this.f4352e0 + ", minimumCapacity=" + i2);
        }
        char[] cArr = this.f4348b;
        int length = cArr.length + (cArr.length >> 1) + 1;
        if (length >= i2) {
            i2 = length;
        }
        char[] cArr2 = new char[i2];
        System.arraycopy(cArr, 0, cArr2, 0, this.f4354g);
        if (this.f4348b.length < f4339l0) {
            ThreadLocal threadLocal = f4335h0;
            char[] cArr3 = (char[]) threadLocal.get();
            if (cArr3 == null || cArr3.length < this.f4348b.length) {
                threadLocal.set(this.f4348b);
            }
        }
        this.f4348b = cArr2;
    }

    public boolean i(int i2) {
        return (i2 & this.f4356r) != 0;
    }

    public boolean j(f0 f0Var) {
        return (f0Var.mask & this.f4356r) != 0;
    }

    public void l(boolean z2) {
        if (z2) {
            write("true");
        } else {
            write("false");
        }
    }

    public void m(byte[] bArr) {
        if (i(f0.WriteClassName.mask)) {
            F(bArr);
            return;
        }
        int length = bArr.length;
        boolean z2 = this.f4358y;
        char c2 = z2 ? '\'' : '\"';
        if (length == 0) {
            write(z2 ? "''" : "\"\"");
            return;
        }
        char[] cArr = AbstractC0613e.f5281p;
        int i2 = (length / 3) * 3;
        int i3 = length - 1;
        int i4 = this.f4354g;
        int i5 = (((i3 / 3) + 1) << 2) + i4;
        int i6 = i5 + 2;
        if (i6 > this.f4348b.length) {
            if (this.f4357x != null) {
                write(c2);
                int i7 = 0;
                while (i7 < i2) {
                    int i8 = i7 + 2;
                    int i9 = ((bArr[i7 + 1] & 255) << 8) | ((bArr[i7] & 255) << 16);
                    i7 += 3;
                    int i10 = i9 | (bArr[i8] & 255);
                    write(cArr[(i10 >>> 18) & 63]);
                    write(cArr[(i10 >>> 12) & 63]);
                    write(cArr[(i10 >>> 6) & 63]);
                    write(cArr[i10 & 63]);
                }
                int i11 = length - i2;
                if (i11 > 0) {
                    int i12 = ((bArr[i2] & 255) << 10) | (i11 == 2 ? (bArr[i3] & 255) << 2 : 0);
                    write(cArr[i12 >> 12]);
                    write(cArr[(i12 >>> 6) & 63]);
                    write(i11 == 2 ? cArr[i12 & 63] : '=');
                    write(61);
                }
                write(c2);
                return;
            }
            h(i6);
        }
        this.f4354g = i6;
        int i13 = i4 + 1;
        this.f4348b[i4] = c2;
        int i14 = 0;
        while (i14 < i2) {
            int i15 = i14 + 2;
            int i16 = ((bArr[i14 + 1] & 255) << 8) | ((bArr[i14] & 255) << 16);
            i14 += 3;
            int i17 = i16 | (bArr[i15] & 255);
            char[] cArr2 = this.f4348b;
            cArr2[i13] = cArr[(i17 >>> 18) & 63];
            cArr2[i13 + 1] = cArr[(i17 >>> 12) & 63];
            int i18 = i13 + 3;
            cArr2[i13 + 2] = cArr[(i17 >>> 6) & 63];
            i13 += 4;
            cArr2[i18] = cArr[i17 & 63];
        }
        int i19 = length - i2;
        if (i19 > 0) {
            int i20 = ((bArr[i2] & 255) << 10) | (i19 == 2 ? (bArr[i3] & 255) << 2 : 0);
            char[] cArr3 = this.f4348b;
            cArr3[i5 - 3] = cArr[i20 >> 12];
            cArr3[i5 - 2] = cArr[(i20 >>> 6) & 63];
            cArr3[i5 - 1] = i19 == 2 ? cArr[i20 & 63] : '=';
            cArr3[i5] = '=';
        }
        this.f4348b[i5 + 1] = c2;
    }

    public void n(double d2, boolean z2) {
        if (Double.isNaN(d2) || Double.isInfinite(d2)) {
            K();
            return;
        }
        int i2 = this.f4354g + 24;
        if (i2 > this.f4348b.length) {
            if (this.f4357x != null) {
                String strB = l.i.b(d2);
                write(strB, 0, strB.length());
                if (z2 && j(f0.WriteClassName)) {
                    write(68);
                    return;
                }
                return;
            }
            h(i2);
        }
        this.f4354g += l.i.a(d2, this.f4348b, this.f4354g);
        if (z2 && j(f0.WriteClassName)) {
            write(68);
        }
    }

    public void q(Enum r2) {
        if (r2 == null) {
            K();
            return;
        }
        String string = (!this.f4347a0 || this.f4349b0) ? this.f4349b0 ? r2.toString() : null : r2.name();
        if (string == null) {
            G(r2.ordinal());
            return;
        }
        int i2 = j(f0.UseSingleQuotes) ? 39 : 34;
        write(i2);
        write(string);
        write(i2);
    }

    public void s(String str) {
        t(str, false);
    }

    public void t(String str, boolean z2) {
        if (str == null) {
            write("null:");
            return;
        }
        if (this.f4358y) {
            if (!this.f4341H) {
                H(str);
                return;
            } else {
                R(str);
                write(58);
                return;
            }
        }
        if (this.f4341H) {
            Q(str, ':');
            return;
        }
        int i2 = 0;
        boolean z3 = true;
        boolean z4 = str.length() == 0;
        while (true) {
            if (i2 >= str.length()) {
                z3 = z4;
                break;
            }
            char cCharAt = str.charAt(i2);
            if ((cCharAt < '@' && (this.f4355g0 & (1 << cCharAt)) != 0) || cCharAt == '\\') {
                break;
            } else {
                i2++;
            }
        }
        if (z3) {
            Q(str, ':');
        } else {
            write(str);
            write(58);
        }
    }

    public String toString() {
        return new String(this.f4348b, 0, this.f4354g);
    }

    public void u(char c2, String str, double d2) {
        write(c2);
        s(str);
        n(d2, false);
    }

    public void v(char c2, String str, int i2) {
        if (i2 == Integer.MIN_VALUE || !this.f4341H) {
            write(c2);
            s(str);
            G(i2);
            return;
        }
        int i3 = i2 < 0 ? AbstractC0613e.i(-i2) + 1 : AbstractC0613e.i(i2);
        int length = str.length();
        int i4 = this.f4354g + length + 4 + i3;
        if (i4 > this.f4348b.length) {
            if (this.f4357x != null) {
                write(c2);
                s(str);
                G(i2);
                return;
            }
            h(i4);
        }
        int i5 = this.f4354g;
        this.f4354g = i4;
        char[] cArr = this.f4348b;
        cArr[i5] = c2;
        int i6 = i5 + length;
        cArr[i5 + 1] = this.f4351d0;
        str.getChars(0, length, cArr, i5 + 2);
        char[] cArr2 = this.f4348b;
        cArr2[i6 + 2] = this.f4351d0;
        cArr2[i6 + 3] = ':';
        AbstractC0613e.e(i2, this.f4354g, cArr2);
    }

    public void w(char c2, String str, long j2) {
        if (j2 == Long.MIN_VALUE || !this.f4341H || i(f0.BrowserCompatible.mask)) {
            write(c2);
            s(str);
            I(j2);
            return;
        }
        int iJ = j2 < 0 ? AbstractC0613e.j(-j2) + 1 : AbstractC0613e.j(j2);
        int length = str.length();
        int i2 = this.f4354g + length + 4 + iJ;
        if (i2 > this.f4348b.length) {
            if (this.f4357x != null) {
                write(c2);
                s(str);
                I(j2);
                return;
            }
            h(i2);
        }
        int i3 = this.f4354g;
        this.f4354g = i2;
        char[] cArr = this.f4348b;
        cArr[i3] = c2;
        int i4 = i3 + length;
        cArr[i3 + 1] = this.f4351d0;
        str.getChars(0, length, cArr, i3 + 2);
        char[] cArr2 = this.f4348b;
        cArr2[i4 + 2] = this.f4351d0;
        cArr2[i4 + 3] = ':';
        AbstractC0613e.f(j2, this.f4354g, cArr2);
    }

    @Override // java.io.Writer
    public void write(int i2) {
        int i3 = 1;
        int i4 = this.f4354g + 1;
        if (i4 <= this.f4348b.length) {
            i3 = i4;
        } else if (this.f4357x == null) {
            h(i4);
            i3 = i4;
        } else {
            flush();
        }
        this.f4348b[this.f4354g] = (char) i2;
        this.f4354g = i3;
    }

    public void z(char c2, String str, String str2) {
        if (!this.f4341H) {
            write(c2);
            s(str);
            if (str2 == null) {
                K();
                return;
            } else {
                O(str2);
                return;
            }
        }
        if (this.f4358y) {
            write(c2);
            s(str);
            if (str2 == null) {
                K();
                return;
            } else {
                O(str2);
                return;
            }
        }
        if (!j(f0.BrowserCompatible)) {
            C(c2, str, str2);
            return;
        }
        write(c2);
        Q(str, ':');
        Q(str2, (char) 0);
    }

    public e0(Writer writer) {
        this(writer, AbstractC0421a.f3669I, f0.EMPTY);
    }

    public e0(Writer writer, int i2, f0... f0VarArr) {
        this.f4352e0 = -1;
        this.f4357x = writer;
        ThreadLocal threadLocal = f4335h0;
        char[] cArr = (char[]) threadLocal.get();
        this.f4348b = cArr;
        if (cArr != null) {
            threadLocal.set(null);
        } else {
            this.f4348b = new char[2048];
        }
        for (f0 f0Var : f0VarArr) {
            i2 |= f0Var.getMask();
        }
        this.f4356r = i2;
        e();
    }

    @Override // java.io.Writer
    public void write(char[] cArr, int i2, int i3) {
        int i4;
        if (i2 < 0 || i2 > cArr.length || i3 < 0 || (i4 = i2 + i3) > cArr.length || i4 < 0) {
            throw new IndexOutOfBoundsException();
        }
        if (i3 == 0) {
            return;
        }
        int i5 = this.f4354g + i3;
        if (i5 > this.f4348b.length) {
            if (this.f4357x == null) {
                h(i5);
            } else {
                do {
                    char[] cArr2 = this.f4348b;
                    int length = cArr2.length;
                    int i6 = this.f4354g;
                    int i7 = length - i6;
                    System.arraycopy(cArr, i2, cArr2, i6, i7);
                    this.f4354g = this.f4348b.length;
                    flush();
                    i3 -= i7;
                    i2 += i7;
                } while (i3 > this.f4348b.length);
                i5 = i3;
            }
        }
        System.arraycopy(cArr, i2, this.f4348b, this.f4354g, i3);
        this.f4354g = i5;
    }

    @Override // java.io.Writer
    public void write(String str, int i2, int i3) {
        int i4;
        int i5 = this.f4354g + i3;
        if (i5 > this.f4348b.length) {
            if (this.f4357x == null) {
                h(i5);
            } else {
                while (true) {
                    char[] cArr = this.f4348b;
                    int length = cArr.length;
                    int i6 = this.f4354g;
                    int i7 = length - i6;
                    i4 = i2 + i7;
                    str.getChars(i2, i4, cArr, i6);
                    this.f4354g = this.f4348b.length;
                    flush();
                    i3 -= i7;
                    if (i3 <= this.f4348b.length) {
                        break;
                    } else {
                        i2 = i4;
                    }
                }
                i5 = i3;
                i2 = i4;
            }
        }
        str.getChars(i2, i3 + i2, this.f4348b, this.f4354g);
        this.f4354g = i5;
    }

    @Override // java.io.Writer
    public void write(String str) {
        if (str == null) {
            K();
        } else {
            write(str, 0, str.length());
        }
    }
}
