package p138.p395.p396;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import p138.p139.p143.p144.C2803;

/* JADX INFO: renamed from: ދ.ބ.֏.ޒ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C6496 extends AbstractC6497 {

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public Object[] f19219 = new Object[32];

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    @Nullable
    public String f19220;

    public C6496() {
        m9730(6);
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() throws IOException {
        int i = this.f19221;
        if (i > 1 || (i == 1 && this.f19222[i - 1] != 7)) {
            throw new IOException("Incomplete document");
        }
        this.f19221 = 0;
    }

    @Override // java.io.Flushable
    public void flush() {
        if (this.f19221 == 0) {
            throw new IllegalStateException("JsonWriter is closed.");
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C6496 m9729(@Nullable Object obj) {
        Object objPut;
        int iM9733 = m9733();
        int i = this.f19221;
        if (i == 1) {
            if (iM9733 != 6) {
                throw new IllegalStateException("JSON must have only one top-level value.");
            }
            this.f19222[i - 1] = 7;
            this.f19219[i - 1] = obj;
        } else if (iM9733 != 3 || this.f19220 == null) {
            if (iM9733 != 1) {
                if (iM9733 == 9) {
                    throw new IllegalStateException("Sink from valueSink() was not closed");
                }
                throw new IllegalStateException("Nesting problem.");
            }
            ((List) this.f19219[this.f19221 - 1]).add(obj);
        } else {
            if ((obj != null || this.f19226) && (objPut = ((Map) this.f19219[this.f19221 - 1]).put(this.f19220, obj)) != null) {
                StringBuilder sbM4889 = C2803.m4889("Map key '");
                sbM4889.append(this.f19220);
                sbM4889.append("' has multiple values at path ");
                sbM4889.append(m9732());
                sbM4889.append(": ");
                sbM4889.append(objPut);
                sbM4889.append(" and ");
                sbM4889.append(obj);
                throw new IllegalArgumentException(sbM4889.toString());
            }
            this.f19220 = null;
        }
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ֏ */
    public AbstractC6497 mo9714() {
        if (this.f19227) {
            StringBuilder sbM4889 = C2803.m4889("Array cannot be used as a map key in JSON at path ");
            sbM4889.append(m9732());
            throw new IllegalStateException(sbM4889.toString());
        }
        int i = this.f19221;
        int i2 = this.f19228;
        if (i == i2 && this.f19222[i - 1] == 1) {
            this.f19228 = ~i2;
            return this;
        }
        m9731();
        ArrayList arrayList = new ArrayList();
        m9729(arrayList);
        Object[] objArr = this.f19219;
        int i3 = this.f19221;
        objArr[i3] = arrayList;
        this.f19224[i3] = 0;
        m9730(1);
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ֏ */
    public AbstractC6497 mo9715(double d) {
        if (!this.f19225 && (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY || d == Double.POSITIVE_INFINITY)) {
            throw new IllegalArgumentException("Numeric values must be finite, but was " + d);
        }
        if (this.f19227) {
            mo9721(Double.toString(d));
            return this;
        }
        m9729((Object) Double.valueOf(d));
        int[] iArr = this.f19224;
        int i = this.f19221 - 1;
        iArr[i] = iArr[i] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ֏ */
    public AbstractC6497 mo9717(@Nullable Number number) {
        if ((number instanceof Byte) || (number instanceof Short) || (number instanceof Integer) || (number instanceof Long)) {
            mo9726(number.longValue());
            return this;
        }
        if ((number instanceof Float) || (number instanceof Double)) {
            mo9715(number.doubleValue());
            return this;
        }
        if (number == null) {
            mo9725();
            return this;
        }
        BigDecimal bigDecimal = number instanceof BigDecimal ? (BigDecimal) number : new BigDecimal(number.toString());
        if (this.f19227) {
            mo9721(bigDecimal.toString());
            return this;
        }
        m9729((Object) bigDecimal);
        int[] iArr = this.f19224;
        int i = this.f19221 - 1;
        iArr[i] = iArr[i] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ֏ */
    public AbstractC6497 mo9718(boolean z) {
        if (this.f19227) {
            StringBuilder sbM4889 = C2803.m4889("Boolean cannot be used as a map key in JSON at path ");
            sbM4889.append(m9732());
            throw new IllegalStateException(sbM4889.toString());
        }
        m9729(Boolean.valueOf(z));
        int[] iArr = this.f19224;
        int i = this.f19221 - 1;
        iArr[i] = iArr[i] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ؠ */
    public AbstractC6497 mo9719() {
        if (this.f19227) {
            StringBuilder sbM4889 = C2803.m4889("Object cannot be used as a map key in JSON at path ");
            sbM4889.append(m9732());
            throw new IllegalStateException(sbM4889.toString());
        }
        int i = this.f19221;
        int i2 = this.f19228;
        if (i == i2 && this.f19222[i - 1] == 3) {
            this.f19228 = ~i2;
            return this;
        }
        m9731();
        C6498 c6498 = new C6498();
        m9729(c6498);
        this.f19219[this.f19221] = c6498;
        m9730(3);
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ؠ */
    public AbstractC6497 mo9721(String str) {
        if (str == null) {
            throw new NullPointerException("name == null");
        }
        if (this.f19221 == 0) {
            throw new IllegalStateException("JsonWriter is closed.");
        }
        if (m9733() != 3 || this.f19220 != null) {
            throw new IllegalStateException("Nesting problem.");
        }
        this.f19220 = str;
        this.f19223[this.f19221 - 1] = str;
        this.f19227 = false;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ހ */
    public AbstractC6497 mo9722(@Nullable String str) {
        if (this.f19227) {
            mo9721(str);
            return this;
        }
        m9729(str);
        int[] iArr = this.f19224;
        int i = this.f19221 - 1;
        iArr[i] = iArr[i] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ރ */
    public AbstractC6497 mo9723() {
        if (m9733() != 1) {
            throw new IllegalStateException("Nesting problem.");
        }
        int i = this.f19221;
        int i2 = this.f19228;
        if (i == (~i2)) {
            this.f19228 = ~i2;
            return this;
        }
        int i3 = i - 1;
        this.f19221 = i3;
        this.f19219[i3] = null;
        int[] iArr = this.f19224;
        int i4 = i3 - 1;
        iArr[i4] = iArr[i4] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ބ */
    public AbstractC6497 mo9724() {
        if (m9733() != 3) {
            throw new IllegalStateException("Nesting problem.");
        }
        if (this.f19220 != null) {
            StringBuilder sbM4889 = C2803.m4889("Dangling name: ");
            sbM4889.append(this.f19220);
            throw new IllegalStateException(sbM4889.toString());
        }
        int i = this.f19221;
        int i2 = this.f19228;
        if (i == (~i2)) {
            this.f19228 = ~i2;
            return this;
        }
        this.f19227 = false;
        int i3 = i - 1;
        this.f19221 = i3;
        this.f19219[i3] = null;
        this.f19223[i3] = null;
        int[] iArr = this.f19224;
        int i4 = i3 - 1;
        iArr[i4] = iArr[i4] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ކ */
    public AbstractC6497 mo9725() {
        if (this.f19227) {
            StringBuilder sbM4889 = C2803.m4889("null cannot be used as a map key in JSON at path ");
            sbM4889.append(m9732());
            throw new IllegalStateException(sbM4889.toString());
        }
        m9729((Object) null);
        int[] iArr = this.f19224;
        int i = this.f19221 - 1;
        iArr[i] = iArr[i] + 1;
        return this;
    }

    @Override // p138.p395.p396.AbstractC6497
    /* JADX INFO: renamed from: ކ */
    public AbstractC6497 mo9726(long j) {
        if (this.f19227) {
            mo9721(Long.toString(j));
            return this;
        }
        m9729((Object) Long.valueOf(j));
        int[] iArr = this.f19224;
        int i = this.f19221 - 1;
        iArr[i] = iArr[i] + 1;
        return this;
    }
}
