package ᨨ;

import android.support.v4.media.session.PlaybackStateCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.internal.NativeProtocol;
import com.google.android.material.progressindicator.BaseProgressIndicator;
import com.google.android.material.slider.BasicLabelFormatter;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.charset.Charset;
import okio.ByteString;
import okio.SegmentedByteString;
import ඓ.K.K.K.C1293;

/* renamed from: ᨨ.㴹  reason: contains not printable characters */
/* compiled from: Buffer */
public final class C1492 implements AbstractC1496, AbstractC1483, Cloneable, ByteChannel {

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final byte[] f5528 = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102};

    /* renamed from: ʬ  reason: contains not printable characters */
    public long f5529;

    /* renamed from: ῲ  reason: contains not printable characters */
    public C1475 f5530;

    /* renamed from: ᨨ.㴹$K  reason: contains not printable characters */
    /* compiled from: Buffer */
    public class C1493 extends InputStream {
        public C1493() {
        }

        @Override // java.io.InputStream
        public int available() {
            return (int) Math.min(C1492.this.f5529, 2147483647L);
        }

        @Override // java.io.Closeable, java.lang.AutoCloseable, java.io.InputStream
        public void close() {
        }

        @Override // java.io.InputStream
        public int read() {
            C1492 r0 = C1492.this;
            if (r0.f5529 > 0) {
                return r0.readByte() & 255;
            }
            return -1;
        }

        public String toString() {
            return C1492.this + ".inputStream()";
        }

        @Override // java.io.InputStream
        public int read(byte[] bArr, int i, int i2) {
            return C1492.this.m3779(bArr, i, i2);
        }
    }

    @Override // java.lang.Object
    public Object clone() throws CloneNotSupportedException {
        C1492 r0 = new C1492();
        if (this.f5529 != 0) {
            r0.f5530 = this.f5530.m3695();
            C1475 r1 = r0.f5530;
            r1.f5497 = r1;
            r1.f5499 = r1;
            C1475 r12 = this.f5530;
            while (true) {
                r12 = r12.f5499;
                if (r12 == this.f5530) {
                    break;
                }
                r0.f5530.f5497.m3698(r12.m3695());
            }
            r0.f5529 = this.f5529;
        }
        return r0;
    }

    @Override // ᨨ.AbstractC1494, java.lang.AutoCloseable, ᨨ.AbstractC1473, java.io.Closeable, java.nio.channels.Channel
    public void close() {
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C1492)) {
            return false;
        }
        C1492 r14 = (C1492) obj;
        long j = this.f5529;
        if (j != r14.f5529) {
            return false;
        }
        long j2 = 0;
        if (j == 0) {
            return true;
        }
        C1475 r1 = this.f5530;
        C1475 r142 = r14.f5530;
        int i = r1.f5496;
        int i2 = r142.f5496;
        while (j2 < this.f5529) {
            long min = (long) Math.min(r1.f5494 - i, r142.f5494 - i2);
            int i3 = i2;
            int i4 = i;
            int i5 = 0;
            while (((long) i5) < min) {
                int i6 = i4 + 1;
                int i7 = i3 + 1;
                if (r1.f5498[i4] != r142.f5498[i3]) {
                    return false;
                }
                i5++;
                i4 = i6;
                i3 = i7;
            }
            if (i4 == r1.f5494) {
                r1 = r1.f5499;
                i = r1.f5496;
            } else {
                i = i4;
            }
            if (i3 == r142.f5494) {
                r142 = r142.f5499;
                i2 = r142.f5496;
            } else {
                i2 = i3;
            }
            j2 += min;
        }
        return true;
    }

    @Override // ᨨ.AbstractC1483, ᨨ.AbstractC1473, java.io.Flushable
    public void flush() {
    }

    public int hashCode() {
        C1475 r0 = this.f5530;
        if (r0 == null) {
            return 0;
        }
        int i = 1;
        do {
            int i2 = r0.f5494;
            for (int i3 = r0.f5496; i3 < i2; i3++) {
                i = (i * 31) + r0.f5498[i3];
            }
            r0 = r0.f5499;
        } while (r0 != this.f5530);
        return i;
    }

    public boolean isOpen() {
        return true;
    }

    @Override // java.nio.channels.ReadableByteChannel
    public int read(ByteBuffer byteBuffer) throws IOException {
        C1475 r0 = this.f5530;
        if (r0 == null) {
            return -1;
        }
        int min = Math.min(byteBuffer.remaining(), r0.f5494 - r0.f5496);
        byteBuffer.put(r0.f5498, r0.f5496, min);
        r0.f5496 += min;
        this.f5529 -= (long) min;
        if (r0.f5496 == r0.f5494) {
            this.f5530 = r0.m3696();
            C1497.m3827(r0);
        }
        return min;
    }

    @Override // ᨨ.AbstractC1496
    public byte readByte() {
        long j = this.f5529;
        if (j != 0) {
            C1475 r2 = this.f5530;
            int i = r2.f5496;
            int i2 = r2.f5494;
            int i3 = i + 1;
            byte b = r2.f5498[i];
            this.f5529 = j - 1;
            if (i3 == i2) {
                this.f5530 = r2.m3696();
                C1497.m3827(r2);
            } else {
                r2.f5496 = i3;
            }
            return b;
        }
        throw new IllegalStateException("size == 0");
    }

    @Override // ᨨ.AbstractC1496
    public int readInt() {
        long j = this.f5529;
        if (j >= 4) {
            C1475 r4 = this.f5530;
            int i = r4.f5496;
            int i2 = r4.f5494;
            if (i2 - i < 4) {
                return ((readByte() & 255) << 24) | ((readByte() & 255) << 16) | ((readByte() & 255) << 8) | (readByte() & 255);
            }
            byte[] bArr = r4.f5498;
            int i3 = i + 1;
            int i4 = i3 + 1;
            int i5 = ((bArr[i] & 255) << 24) | ((bArr[i3] & 255) << 16);
            int i6 = i4 + 1;
            int i7 = i5 | ((bArr[i4] & 255) << 8);
            int i8 = i6 + 1;
            int i9 = i7 | (bArr[i6] & 255);
            this.f5529 = j - 4;
            if (i8 == i2) {
                this.f5530 = r4.m3696();
                C1497.m3827(r4);
            } else {
                r4.f5496 = i8;
            }
            return i9;
        }
        StringBuilder r1 = C1293.m3416("size < 4: ");
        r1.append(this.f5529);
        throw new IllegalStateException(r1.toString());
    }

    @Override // ᨨ.AbstractC1496
    public short readShort() {
        long j = this.f5529;
        if (j >= 2) {
            C1475 r4 = this.f5530;
            int i = r4.f5496;
            int i2 = r4.f5494;
            if (i2 - i < 2) {
                return (short) (((readByte() & 255) << 8) | (readByte() & 255));
            }
            byte[] bArr = r4.f5498;
            int i3 = i + 1;
            int i4 = i3 + 1;
            int i5 = ((bArr[i] & 255) << 8) | (bArr[i3] & 255);
            this.f5529 = j - 2;
            if (i4 == i2) {
                this.f5530 = r4.m3696();
                C1497.m3827(r4);
            } else {
                r4.f5496 = i4;
            }
            return (short) i5;
        }
        StringBuilder r1 = C1293.m3416("size < 2: ");
        r1.append(this.f5529);
        throw new IllegalStateException(r1.toString());
    }

    @Override // ᨨ.AbstractC1496
    public void skip(long j) throws EOFException {
        while (j > 0) {
            C1475 r0 = this.f5530;
            if (r0 != null) {
                int min = (int) Math.min(j, (long) (r0.f5494 - r0.f5496));
                long j2 = (long) min;
                this.f5529 -= j2;
                j -= j2;
                C1475 r02 = this.f5530;
                r02.f5496 += min;
                if (r02.f5496 == r02.f5494) {
                    this.f5530 = r02.m3696();
                    C1497.m3827(r02);
                }
            } else {
                throw new EOFException();
            }
        }
    }

    @Override // ᨨ.AbstractC1494, ᨨ.AbstractC1473
    public C1477 timeout() {
        return C1477.f5502;
    }

    public String toString() {
        ByteString byteString;
        long j = this.f5529;
        if (j <= 2147483647L) {
            int i = (int) j;
            if (i == 0) {
                byteString = ByteString.EMPTY;
            } else {
                byteString = new SegmentedByteString(this, i);
            }
            return byteString.toString();
        }
        StringBuilder r1 = C1293.m3416("size > Integer.MAX_VALUE: ");
        r1.append(this.f5529);
        throw new IllegalArgumentException(r1.toString());
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: ʬ  reason: contains not printable characters */
    public String m3767() throws EOFException {
        return m3768(RecyclerView.FOREVER_NS);
    }

    /* renamed from: ᕣ  reason: contains not printable characters */
    public ByteString m3772() {
        return new ByteString(m3805());
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public void m3773() {
        try {
            skip(this.f5529);
        } catch (EOFException e) {
            throw new AssertionError(e);
        }
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: ῲ  reason: contains not printable characters */
    public short m3776() {
        return C1491.m3763(readShort());
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public byte m3777(long j) {
        int i;
        C1491.m3764(this.f5529, j, 1);
        long j2 = this.f5529;
        if (j2 - j > j) {
            C1475 r0 = this.f5530;
            while (true) {
                int i2 = r0.f5494;
                int i3 = r0.f5496;
                long j3 = (long) (i2 - i3);
                if (j < j3) {
                    return r0.f5498[i3 + ((int) j)];
                }
                j -= j3;
                r0 = r0.f5499;
            }
        } else {
            long j4 = j - j2;
            C1475 r02 = this.f5530;
            do {
                r02 = r02.f5497;
                int i4 = r02.f5494;
                i = r02.f5496;
                j4 += (long) (i4 - i);
            } while (j4 < 0);
            return r02.f5498[i + ((int) j4)];
        }
    }

    @Override // ᨨ.AbstractC1483, ᨨ.AbstractC1496
    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3790() {
        return this;
    }

    /* renamed from: 㑃  reason: contains not printable characters */
    public String m3800() {
        try {
            return m3784(this.f5529, C1491.f5527);
        } catch (EOFException e) {
            throw new AssertionError(e);
        }
    }

    /* renamed from: 㳳  reason: contains not printable characters */
    public long m3801() {
        long j = this.f5529;
        if (j == 0) {
            return 0;
        }
        C1475 r2 = this.f5530.f5497;
        int i = r2.f5494;
        return (i >= 8192 || !r2.f5495) ? j : j - ((long) (i - r2.f5496));
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean m3802() {
        return this.f5529 == 0;
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: 㸾  reason: contains not printable characters */
    public void m3804(long j) throws EOFException {
        if (this.f5529 < j) {
            throw new EOFException();
        }
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: 㿎  reason: contains not printable characters */
    public InputStream m3806() {
        return new C1493();
    }

    @Override // ᨨ.AbstractC1483
    public C1492 writeByte(int i) {
        C1475 r0 = m3786(1);
        byte[] bArr = r0.f5498;
        int i2 = r0.f5494;
        r0.f5494 = i2 + 1;
        bArr[i2] = (byte) i;
        this.f5529++;
        return this;
    }

    @Override // ᨨ.AbstractC1483
    public C1492 writeInt(int i) {
        C1475 r0 = m3786(4);
        byte[] bArr = r0.f5498;
        int i2 = r0.f5494;
        int i3 = i2 + 1;
        bArr[i2] = (byte) ((i >>> 24) & BaseProgressIndicator.MAX_ALPHA);
        int i4 = i3 + 1;
        bArr[i3] = (byte) ((i >>> 16) & BaseProgressIndicator.MAX_ALPHA);
        int i5 = i4 + 1;
        bArr[i4] = (byte) ((i >>> 8) & BaseProgressIndicator.MAX_ALPHA);
        bArr[i5] = (byte) (i & BaseProgressIndicator.MAX_ALPHA);
        r0.f5494 = i5 + 1;
        this.f5529 += 4;
        return this;
    }

    @Override // ᨨ.AbstractC1483
    public C1492 writeShort(int i) {
        C1475 r0 = m3786(2);
        byte[] bArr = r0.f5498;
        int i2 = r0.f5494;
        int i3 = i2 + 1;
        bArr[i2] = (byte) ((i >>> 8) & BaseProgressIndicator.MAX_ALPHA);
        bArr[i3] = (byte) (i & BaseProgressIndicator.MAX_ALPHA);
        r0.f5494 = i3 + 1;
        this.f5529 += 2;
        return this;
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: ʬ  reason: contains not printable characters */
    public String m3768(long j) throws EOFException {
        if (j >= 0) {
            long j2 = RecyclerView.FOREVER_NS;
            if (j != RecyclerView.FOREVER_NS) {
                j2 = j + 1;
            }
            long r4 = m3781((byte) 10, 0, j2);
            if (r4 != -1) {
                return m3807(r4);
            }
            if (j2 < this.f5529 && m3777(j2 - 1) == 13 && m3777(j2) == 10) {
                return m3807(j2);
            }
            C1492 r6 = new C1492();
            m3796(r6, 0, Math.min(32L, this.f5529));
            StringBuilder r1 = C1293.m3416("\\n not found: limit=");
            r1.append(Math.min(this.f5529, j));
            r1.append(" content=");
            r1.append(r6.m3772().hex());
            r1.append((char) 8230);
            throw new EOFException(r1.toString());
        }
        throw new IllegalArgumentException(C1293.m3409("limit < 0: ", j));
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: ඓ  reason: contains not printable characters */
    public int m3769() {
        return C1491.m3762(readInt());
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: ῲ  reason: contains not printable characters */
    public ByteString m3774(long j) throws EOFException {
        return new ByteString(m3803(j));
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: 㴹  reason: contains not printable characters */
    public byte[] m3803(long j) throws EOFException {
        C1491.m3764(this.f5529, 0, j);
        if (j <= 2147483647L) {
            byte[] bArr = new byte[((int) j)];
            m3798(bArr);
            return bArr;
        }
        throw new IllegalArgumentException(C1293.m3409("byteCount > Integer.MAX_VALUE: ", j));
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: 㸾  reason: contains not printable characters */
    public byte[] m3805() {
        try {
            return m3803(this.f5529);
        } catch (EOFException e) {
            throw new AssertionError(e);
        }
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public String m3807(long j) throws EOFException {
        if (j > 0) {
            long j2 = j - 1;
            if (m3777(j2) == 13) {
                String r7 = m3784(j2, C1491.f5527);
                skip(2);
                return r7;
            }
        }
        String r72 = m3784(j, C1491.f5527);
        skip(1);
        return r72;
    }

    @Override // ᨨ.AbstractC1483
    public C1492 write(byte[] bArr) {
        if (bArr != null) {
            write(bArr, 0, bArr.length);
            return this;
        }
        throw new IllegalArgumentException("source == null");
    }

    @Override // ᨨ.AbstractC1483
    /* renamed from: ඓ  reason: contains not printable characters */
    public C1492 m3771(long j) {
        int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
        if (i == 0) {
            writeByte(48);
            return this;
        }
        boolean z = false;
        int i2 = 1;
        if (i < 0) {
            j = -j;
            if (j < 0) {
                m3792("-9223372036854775808");
                return this;
            }
            z = true;
        }
        if (j >= 100000000) {
            i2 = j < BasicLabelFormatter.TRILLION ? j < 10000000000L ? j < 1000000000 ? 9 : 10 : j < 100000000000L ? 11 : 12 : j < 1000000000000000L ? j < 10000000000000L ? 13 : j < 100000000000000L ? 14 : 15 : j < 100000000000000000L ? j < 10000000000000000L ? 16 : 17 : j < 1000000000000000000L ? 18 : 19;
        } else if (j >= 10000) {
            i2 = j < 1000000 ? j < 100000 ? 5 : 6 : j < 10000000 ? 7 : 8;
        } else if (j >= 100) {
            i2 = j < 1000 ? 3 : 4;
        } else if (j >= 10) {
            i2 = 2;
        }
        if (z) {
            i2++;
        }
        C1475 r2 = m3786(i2);
        byte[] bArr = r2.f5498;
        int i3 = r2.f5494 + i2;
        while (j != 0) {
            i3--;
            bArr[i3] = f5528[(int) (j % 10)];
            j /= 10;
        }
        if (z) {
            bArr[i3 - 1] = 45;
        }
        r2.f5494 += i2;
        this.f5529 += (long) i2;
        return this;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public C1492 m3775(int i) {
        if (i < 128) {
            writeByte(i);
        } else if (i < 2048) {
            writeByte((i >> 6) | 192);
            writeByte((i & 63) | 128);
        } else if (i < 65536) {
            if (i < 55296 || i > 57343) {
                writeByte((i >> 12) | 224);
                writeByte(((i >> 6) & 63) | 128);
                writeByte((i & 63) | 128);
            } else {
                writeByte(63);
            }
        } else if (i <= 1114111) {
            writeByte((i >> 18) | 240);
            writeByte(((i >> 12) & 63) | 128);
            writeByte(((i >> 6) & 63) | 128);
            writeByte((i & 63) | 128);
        } else {
            StringBuilder r1 = C1293.m3416("Unexpected code point: ");
            r1.append(Integer.toHexString(i));
            throw new IllegalArgumentException(r1.toString());
        }
        return this;
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3796(C1492 r9, long j, long j2) {
        if (r9 != null) {
            C1491.m3764(this.f5529, j, j2);
            if (j2 == 0) {
                return this;
            }
            r9.f5529 += j2;
            C1475 r2 = this.f5530;
            while (true) {
                int i = r2.f5494;
                int i2 = r2.f5496;
                if (j < ((long) (i - i2))) {
                    break;
                }
                j -= (long) (i - i2);
                r2 = r2.f5499;
            }
            while (j2 > 0) {
                C1475 r3 = r2.m3695();
                r3.f5496 = (int) (((long) r3.f5496) + j);
                r3.f5494 = Math.min(r3.f5496 + ((int) j2), r3.f5494);
                C1475 r10 = r9.f5530;
                if (r10 == null) {
                    r3.f5497 = r3;
                    r3.f5499 = r3;
                    r9.f5530 = r3;
                } else {
                    r10.f5497.m3698(r3);
                }
                j2 -= (long) (r3.f5494 - r3.f5496);
                r2 = r2.f5499;
                j = 0;
            }
            return this;
        }
        throw new IllegalArgumentException("out == null");
    }

    @Override // ᨨ.AbstractC1483
    public C1492 write(byte[] bArr, int i, int i2) {
        if (bArr != null) {
            long j = (long) i2;
            C1491.m3764((long) bArr.length, (long) i, j);
            int i3 = i2 + i;
            while (i < i3) {
                C1475 r0 = m3786(1);
                int min = Math.min(i3 - i, 8192 - r0.f5494);
                System.arraycopy(bArr, i, r0.f5498, r0.f5494, min);
                i += min;
                r0.f5494 += min;
            }
            this.f5529 += j;
            return this;
        }
        throw new IllegalArgumentException("source == null");
    }

    @Override // ᨨ.AbstractC1494
    public long read(C1492 r6, long j) {
        if (r6 == null) {
            throw new IllegalArgumentException("sink == null");
        } else if (j >= 0) {
            long j2 = this.f5529;
            if (j2 == 0) {
                return -1;
            }
            if (j > j2) {
                j = j2;
            }
            r6.m3797(this, j);
            return j;
        } else {
            throw new IllegalArgumentException(C1293.m3409("byteCount < 0: ", j));
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:30:0x0086, code lost:
        if (r8 != r9) goto L_0x0092;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:31:0x0088, code lost:
        r15.f5530 = r6.m3696();
        ᨨ.C1497.m3827(r6);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:32:0x0092, code lost:
        r6.f5496 = r8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x0094, code lost:
        if (r0 != false) goto L_0x009a;
     */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x006d  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x006f A[SYNTHETIC] */
    @Override // ᨨ.AbstractC1496
    /* renamed from: ⁱ  reason: contains not printable characters */
    public long m3778() {
        int i;
        int i2;
        if (this.f5529 != 0) {
            boolean z = false;
            int i3 = 0;
            long j = 0;
            do {
                C1475 r6 = this.f5530;
                byte[] bArr = r6.f5498;
                int i4 = r6.f5496;
                int i5 = r6.f5494;
                while (true) {
                    if (i4 >= i5) {
                        break;
                    }
                    byte b = bArr[i4];
                    if (b < 48 || b > 57) {
                        if (b >= 97 && b <= 102) {
                            i2 = b - 97;
                        } else if (b >= 65 && b <= 70) {
                            i2 = b - 65;
                        } else if (i3 == 0) {
                            z = true;
                        } else {
                            StringBuilder r1 = C1293.m3416("Expected leading [0-9a-fA-F] character but was 0x");
                            r1.append(Integer.toHexString(b));
                            throw new NumberFormatException(r1.toString());
                        }
                        i = i2 + 10;
                    } else {
                        i = b - 48;
                    }
                    if ((-1152921504606846976L & j) == 0) {
                        j = (j << 4) | ((long) i);
                        i4++;
                        i3++;
                    } else {
                        C1492 r0 = new C1492();
                        r0.m3791(j);
                        r0.writeByte((int) b);
                        StringBuilder r2 = C1293.m3416("Number too large: ");
                        r2.append(r0.m3800());
                        throw new NumberFormatException(r2.toString());
                    }
                }
                if (i3 == 0) {
                }
            } while (this.f5530 != null);
            this.f5529 -= (long) i3;
            return j;
        }
        throw new IllegalStateException("size == 0");
    }

    @Override // java.nio.channels.WritableByteChannel
    public int write(ByteBuffer byteBuffer) throws IOException {
        if (byteBuffer != null) {
            int remaining = byteBuffer.remaining();
            int i = remaining;
            while (i > 0) {
                C1475 r2 = m3786(1);
                int min = Math.min(i, 8192 - r2.f5494);
                byteBuffer.get(r2.f5498, r2.f5494, min);
                i -= min;
                r2.f5494 += min;
            }
            this.f5529 += (long) remaining;
            return remaining;
        }
        throw new IllegalArgumentException("source == null");
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: K  reason: contains not printable characters */
    public long m3782(AbstractC1473 r6) throws IOException {
        long j = this.f5529;
        if (j > 0) {
            r6.m3692(this, j);
        }
        return j;
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: K  reason: contains not printable characters */
    public String m3785(Charset charset) {
        try {
            return m3784(this.f5529, charset);
        } catch (EOFException e) {
            throw new AssertionError(e);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public String m3784(long j, Charset charset) throws EOFException {
        C1491.m3764(this.f5529, 0, j);
        if (charset == null) {
            throw new IllegalArgumentException("charset == null");
        } else if (j > 2147483647L) {
            throw new IllegalArgumentException(C1293.m3409("byteCount > Integer.MAX_VALUE: ", j));
        } else if (j == 0) {
            return "";
        } else {
            C1475 r0 = this.f5530;
            int i = r0.f5496;
            if (((long) i) + j > ((long) r0.f5494)) {
                return new String(m3803(j), charset);
            }
            String str = new String(r0.f5498, i, (int) j, charset);
            r0.f5496 = (int) (((long) r0.f5496) + j);
            this.f5529 -= j;
            if (r0.f5496 == r0.f5494) {
                this.f5530 = r0.m3696();
                C1497.m3827(r0);
            }
            return str;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m3798(byte[] bArr) throws EOFException {
        int i = 0;
        while (i < bArr.length) {
            int r1 = m3779(bArr, i, bArr.length - i);
            if (r1 != -1) {
                i += r1;
            } else {
                throw new EOFException();
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m3779(byte[] bArr, int i, int i2) {
        C1491.m3764((long) bArr.length, (long) i, (long) i2);
        C1475 r0 = this.f5530;
        if (r0 == null) {
            return -1;
        }
        int min = Math.min(i2, r0.f5494 - r0.f5496);
        System.arraycopy(r0.f5498, r0.f5496, bArr, i, min);
        r0.f5496 += min;
        this.f5529 -= (long) min;
        if (r0.f5496 == r0.f5494) {
            this.f5530 = r0.m3696();
            C1497.m3827(r0);
        }
        return min;
    }

    @Override // ᨨ.AbstractC1483
    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3795(ByteString byteString) {
        if (byteString != null) {
            byteString.write(this);
            return this;
        }
        throw new IllegalArgumentException("byteString == null");
    }

    @Override // ᨨ.AbstractC1483
    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3792(String str) {
        m3793(str, 0, str.length());
        return this;
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3793(String str, int i, int i2) {
        char charAt;
        if (str == null) {
            throw new IllegalArgumentException("string == null");
        } else if (i < 0) {
            throw new IllegalArgumentException(C1293.m3408("beginIndex < 0: ", i));
        } else if (i2 < i) {
            throw new IllegalArgumentException("endIndex < beginIndex: " + i2 + " < " + i);
        } else if (i2 <= str.length()) {
            while (i < i2) {
                char charAt2 = str.charAt(i);
                if (charAt2 < 128) {
                    C1475 r2 = m3786(1);
                    byte[] bArr = r2.f5498;
                    int i3 = r2.f5494 - i;
                    int min = Math.min(i2, 8192 - i3);
                    int i4 = i + 1;
                    bArr[i + i3] = (byte) charAt2;
                    while (true) {
                        i = i4;
                        if (i >= min || (charAt = str.charAt(i)) >= 128) {
                            int i5 = r2.f5494;
                            int i6 = (i3 + i) - i5;
                            r2.f5494 = i5 + i6;
                            this.f5529 += (long) i6;
                        } else {
                            i4 = i + 1;
                            bArr[i + i3] = (byte) charAt;
                        }
                    }
                    int i52 = r2.f5494;
                    int i62 = (i3 + i) - i52;
                    r2.f5494 = i52 + i62;
                    this.f5529 += (long) i62;
                } else {
                    if (charAt2 < 2048) {
                        writeByte((charAt2 >> 6) | 192);
                        writeByte((charAt2 & '?') | 128);
                    } else if (charAt2 < 55296 || charAt2 > 57343) {
                        writeByte((charAt2 >> '\f') | 224);
                        writeByte(((charAt2 >> 6) & 63) | 128);
                        writeByte((charAt2 & '?') | 128);
                    } else {
                        int i7 = i + 1;
                        char charAt3 = i7 < i2 ? str.charAt(i7) : 0;
                        if (charAt2 > 56319 || charAt3 < 56320 || charAt3 > 57343) {
                            writeByte(63);
                            i = i7;
                        } else {
                            int i8 = (((charAt2 & 10239) << 10) | (9215 & charAt3)) + NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST;
                            writeByte((i8 >> 18) | 240);
                            writeByte(((i8 >> 12) & 63) | 128);
                            writeByte(((i8 >> 6) & 63) | 128);
                            writeByte((i8 & 63) | 128);
                            i += 2;
                        }
                    }
                    i++;
                }
            }
            return this;
        } else {
            throw new IllegalArgumentException("endIndex > string.length: " + i2 + " > " + str.length());
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3794(String str, int i, int i2, Charset charset) {
        if (str == null) {
            throw new IllegalArgumentException("string == null");
        } else if (i < 0) {
            throw new IllegalAccessError(C1293.m3408("beginIndex < 0: ", i));
        } else if (i2 < i) {
            throw new IllegalArgumentException("endIndex < beginIndex: " + i2 + " < " + i);
        } else if (i2 > str.length()) {
            throw new IllegalArgumentException("endIndex > string.length: " + i2 + " > " + str.length());
        } else if (charset == null) {
            throw new IllegalArgumentException("charset == null");
        } else if (charset.equals(C1491.f5527)) {
            m3793(str, i, i2);
            return this;
        } else {
            byte[] bytes = str.substring(i, i2).getBytes(charset);
            write(bytes, 0, bytes.length);
            return this;
        }
    }

    @Override // ᨨ.AbstractC1483
    /* renamed from: K  reason: contains not printable characters */
    public long m3783(AbstractC1494 r8) throws IOException {
        if (r8 != null) {
            long j = 0;
            while (true) {
                long read = r8.read(this, PlaybackStateCompat.ACTION_PLAY_FROM_URI);
                if (read == -1) {
                    return j;
                }
                j += read;
            }
        } else {
            throw new IllegalArgumentException("source == null");
        }
    }

    @Override // ᨨ.AbstractC1483
    /* renamed from: K  reason: contains not printable characters */
    public C1492 m3791(long j) {
        if (j == 0) {
            writeByte(48);
            return this;
        }
        int numberOfTrailingZeros = (Long.numberOfTrailingZeros(Long.highestOneBit(j)) / 4) + 1;
        C1475 r2 = m3786(numberOfTrailingZeros);
        byte[] bArr = r2.f5498;
        int i = r2.f5494;
        for (int i2 = (i + numberOfTrailingZeros) - 1; i2 >= i; i2--) {
            bArr[i2] = f5528[(int) (15 & j)];
            j >>>= 4;
        }
        r2.f5494 += numberOfTrailingZeros;
        this.f5529 += (long) numberOfTrailingZeros;
        return this;
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1475 m3786(int i) {
        if (i < 1 || i > 8192) {
            throw new IllegalArgumentException();
        }
        C1475 r1 = this.f5530;
        if (r1 == null) {
            this.f5530 = C1497.m3826();
            C1475 r4 = this.f5530;
            r4.f5497 = r4;
            r4.f5499 = r4;
            return r4;
        }
        C1475 r12 = r1.f5497;
        if (r12.f5494 + i <= 8192 && r12.f5495) {
            return r12;
        }
        C1475 r42 = C1497.m3826();
        r12.m3698(r42);
        return r42;
    }

    @Override // ᨨ.AbstractC1473
    /* renamed from: K  reason: contains not printable characters */
    public void m3797(C1492 r9, long j) {
        int i;
        if (r9 == null) {
            throw new IllegalArgumentException("source == null");
        } else if (r9 != this) {
            C1491.m3764(r9.f5529, 0, j);
            while (j > 0) {
                C1475 r0 = r9.f5530;
                int i2 = 0;
                if (j < ((long) (r0.f5494 - r0.f5496))) {
                    C1475 r02 = this.f5530;
                    C1475 r03 = r02 != null ? r02.f5497 : null;
                    if (r03 != null && r03.f5495) {
                        long j2 = ((long) r03.f5494) + j;
                        if (r03.f5500) {
                            i = 0;
                        } else {
                            i = r03.f5496;
                        }
                        if (j2 - ((long) i) <= PlaybackStateCompat.ACTION_PLAY_FROM_URI) {
                            r9.f5530.m3699(r03, (int) j);
                            r9.f5529 -= j;
                            this.f5529 += j;
                            return;
                        }
                    }
                    r9.f5530 = r9.f5530.m3697((int) j);
                }
                C1475 r04 = r9.f5530;
                long j3 = (long) (r04.f5494 - r04.f5496);
                r9.f5530 = r04.m3696();
                C1475 r1 = this.f5530;
                if (r1 == null) {
                    this.f5530 = r04;
                    C1475 r05 = this.f5530;
                    r05.f5497 = r05;
                    r05.f5499 = r05;
                } else {
                    r1.f5497.m3698(r04);
                    C1475 r12 = r04.f5497;
                    if (r12 == r04) {
                        throw new IllegalStateException();
                    } else if (r12.f5495) {
                        int i3 = r04.f5494 - r04.f5496;
                        int i4 = 8192 - r12.f5494;
                        if (!r12.f5500) {
                            i2 = r12.f5496;
                        }
                        if (i3 <= i4 + i2) {
                            r04.m3699(r04.f5497, i3);
                            r04.m3696();
                            C1497.m3827(r04);
                        }
                    }
                }
                r9.f5529 -= j3;
                this.f5529 += j3;
                j -= j3;
            }
        } else {
            throw new IllegalArgumentException("source == this");
        }
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: K  reason: contains not printable characters */
    public long m3780(byte b) {
        return m3781(b, 0, RecyclerView.FOREVER_NS);
    }

    /* renamed from: K  reason: contains not printable characters */
    public long m3781(byte b, long j, long j2) {
        C1475 r7;
        long j3 = 0;
        if (j < 0 || j2 < j) {
            throw new IllegalArgumentException(String.format("size=%s fromIndex=%s toIndex=%s", Long.valueOf(this.f5529), Long.valueOf(j), Long.valueOf(j2)));
        }
        long j4 = this.f5529;
        if (j2 <= j4) {
            j4 = j2;
        }
        if (j == j4 || (r7 = this.f5530) == null) {
            return -1;
        }
        long j5 = this.f5529;
        if (j5 - j >= j) {
            while (true) {
                j5 = j3;
                j3 = ((long) (r7.f5494 - r7.f5496)) + j5;
                if (j3 >= j) {
                    break;
                }
                r7 = r7.f5499;
            }
        } else {
            while (j5 > j) {
                r7 = r7.f5497;
                j5 -= (long) (r7.f5494 - r7.f5496);
            }
        }
        long j6 = j;
        while (j5 < j4) {
            byte[] bArr = r7.f5498;
            int min = (int) Math.min((long) r7.f5494, (((long) r7.f5496) + j4) - j5);
            for (int i = (int) ((((long) r7.f5496) + j6) - j5); i < min; i++) {
                if (bArr[i] == b) {
                    return ((long) (i - r7.f5496)) + j5;
                }
            }
            j6 = ((long) (r7.f5494 - r7.f5496)) + j5;
            r7 = r7.f5499;
            j5 = j6;
        }
        return -1;
    }

    @Override // ᨨ.AbstractC1496
    /* renamed from: K  reason: contains not printable characters */
    public boolean m3799(long j, ByteString byteString) {
        int size = byteString.size();
        if (j < 0 || size < 0 || this.f5529 - j < ((long) size) || byteString.size() - 0 < size) {
            return false;
        }
        for (int i = 0; i < size; i++) {
            if (m3777(((long) i) + j) != byteString.getByte(0 + i)) {
                return false;
            }
        }
        return true;
    }
}
