package g0; import d0.g0.c; import d0.t.j; import d0.z.d.m; import java.io.Closeable; 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 java.util.Arrays; import java.util.Objects; import okio.BufferedSink; import okio.ByteString; /* compiled from: Buffer.kt */ public final class e implements g, BufferedSink, Cloneable, ByteChannel { public s i; public long j; /* compiled from: Buffer.kt */ public static final class a implements Closeable { public e i; public boolean j; public s k; public long l = -1; public byte[] m; public int n = -1; public int o = -1; public final long a(long j) { e eVar = this.i; if (eVar == null) { throw new IllegalStateException("not attached to a buffer".toString()); } else if (this.j) { long j2 = eVar.j; int i = 1; int i2 = (j > j2 ? 1 : (j == j2 ? 0 : -1)); if (i2 <= 0) { if (j >= 0) { long j3 = j2 - j; while (true) { if (j3 > 0) { s sVar = eVar.i; if (sVar == null) { m.throwNpe(); } s sVar2 = sVar.g; if (sVar2 == null) { m.throwNpe(); } int i3 = sVar2.f2787c; long j4 = (long) (i3 - sVar2.b); if (j4 > j3) { sVar2.f2787c = i3 - ((int) j3); break; } eVar.i = sVar2.a(); t.a(sVar2); j3 -= j4; } else { break; } } this.k = null; this.l = j; this.m = null; this.n = -1; this.o = -1; } else { throw new IllegalArgumentException(c.d.b.a.a.p("newSize < 0: ", j).toString()); } } else if (i2 > 0) { long j5 = j - j2; boolean z2 = true; while (j5 > 0) { s N = eVar.N(i); int min = (int) Math.min(j5, (long) (8192 - N.f2787c)); int i4 = N.f2787c + min; N.f2787c = i4; j5 -= (long) min; if (z2) { this.k = N; this.l = j2; this.m = N.a; this.n = i4 - min; this.o = i4; z2 = false; } i = 1; } } eVar.j = j; return j2; } else { throw new IllegalStateException("resizeBuffer() only permitted for read/write buffers".toString()); } } public final int b(long j) { long j2; s sVar; e eVar = this.i; if (eVar != null) { if (j >= ((long) -1)) { long j3 = eVar.j; if (j <= j3) { if (j == -1 || j == j3) { this.k = null; this.l = j; this.m = null; this.n = -1; this.o = -1; return -1; } s sVar2 = eVar.i; s sVar3 = this.k; if (sVar3 != null) { long j4 = this.l; int i = this.n; if (sVar3 == null) { m.throwNpe(); } j2 = j4 - ((long) (i - sVar3.b)); if (j2 > j) { sVar = sVar2; sVar2 = this.k; j3 = j2; j2 = 0; } else { sVar = this.k; } } else { j2 = 0; sVar = sVar2; } if (j3 - j > j - j2) { while (true) { if (sVar == null) { m.throwNpe(); } int i2 = sVar.f2787c; int i3 = sVar.b; if (j < ((long) (i2 - i3)) + j2) { break; } j2 += (long) (i2 - i3); sVar = sVar.f; } } else { while (j3 > j) { if (sVar2 == null) { m.throwNpe(); } sVar2 = sVar2.g; if (sVar2 == null) { m.throwNpe(); } j3 -= (long) (sVar2.f2787c - sVar2.b); } sVar = sVar2; j2 = j3; } if (this.j) { if (sVar == null) { m.throwNpe(); } if (sVar.d) { byte[] bArr = sVar.a; byte[] copyOf = Arrays.copyOf(bArr, bArr.length); m.checkExpressionValueIsNotNull(copyOf, "java.util.Arrays.copyOf(this, size)"); s sVar4 = new s(copyOf, sVar.b, sVar.f2787c, false, true); if (eVar.i == sVar) { eVar.i = sVar4; } sVar.b(sVar4); s sVar5 = sVar4.g; if (sVar5 == null) { m.throwNpe(); } sVar5.a(); sVar = sVar4; } } this.k = sVar; this.l = j; if (sVar == null) { m.throwNpe(); } this.m = sVar.a; int i4 = sVar.b + ((int) (j - j2)); this.n = i4; int i5 = sVar.f2787c; this.o = i5; return i5 - i4; } } String format = String.format("offset=%s > size=%s", Arrays.copyOf(new Object[]{Long.valueOf(j), Long.valueOf(eVar.j)}, 2)); m.checkExpressionValueIsNotNull(format, "java.lang.String.format(format, *args)"); throw new ArrayIndexOutOfBoundsException(format); } throw new IllegalStateException("not attached to a buffer".toString()); } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() { if (this.i != null) { this.i = null; this.k = null; this.l = -1; this.m = null; this.n = -1; this.o = -1; return; } throw new IllegalStateException("not attached to a buffer".toString()); } } /* compiled from: Buffer.kt */ public static final class b extends InputStream { public final /* synthetic */ e i; public b(e eVar) { this.i = eVar; } @Override // java.io.InputStream public int available() { return (int) Math.min(this.i.j, (long) Integer.MAX_VALUE); } @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable public void close() { } @Override // java.io.InputStream public int read() { e eVar = this.i; if (eVar.j > 0) { return eVar.readByte() & 255; } return -1; } @Override // java.io.InputStream public int read(byte[] bArr, int i, int i2) { m.checkParameterIsNotNull(bArr, "sink"); return this.i.read(bArr, i, i2); } @Override // java.lang.Object public String toString() { return this.i + ".inputStream()"; } } @Override // g0.g public void A(e eVar, long j) throws EOFException { m.checkParameterIsNotNull(eVar, "sink"); long j2 = this.j; if (j2 >= j) { eVar.write(this, j); } else { eVar.write(this, j2); throw new EOFException(); } } public String C(long j, Charset charset) throws EOFException { m.checkParameterIsNotNull(charset, "charset"); int i = (j > 0 ? 1 : (j == 0 ? 0 : -1)); if (!(i >= 0 && j <= ((long) Integer.MAX_VALUE))) { throw new IllegalArgumentException(c.d.b.a.a.p("byteCount: ", j).toString()); } else if (this.j < j) { throw new EOFException(); } else if (i == 0) { return ""; } else { s sVar = this.i; if (sVar == null) { m.throwNpe(); } int i2 = sVar.b; if (((long) i2) + j > ((long) sVar.f2787c)) { return new String(Y(j), charset); } int i3 = (int) j; String str = new String(sVar.a, i2, i3, charset); int i4 = sVar.b + i3; sVar.b = i4; this.j -= j; if (i4 == sVar.f2787c) { this.i = sVar.a(); t.a(sVar); } return str; } } @Override // g0.g public long D(ByteString byteString) { m.checkParameterIsNotNull(byteString, "targetBytes"); return t(byteString, 0); } @Override // okio.BufferedSink public BufferedSink E() { return this; } @Override // g0.g public String F(long j) throws EOFException { if (j >= 0) { long j2 = Long.MAX_VALUE; if (j != Long.MAX_VALUE) { j2 = j + 1; } byte b2 = (byte) 10; long s2 = s(b2, 0, j2); if (s2 != -1) { return g0.z.a.a(this, s2); } if (j2 < this.j && r(j2 - 1) == ((byte) 13) && r(j2) == b2) { return g0.z.a.a(this, j2); } e eVar = new e(); p(eVar, 0, Math.min((long) 32, this.j)); throw new EOFException("\\n not found: limit=" + Math.min(this.j, j) + " content=" + eVar.x().k() + (char) 8230); } throw new IllegalArgumentException(c.d.b.a.a.p("limit < 0: ", j).toString()); } public String G() { return C(this.j, c.a); } public String H(long j) throws EOFException { return C(j, c.a); } public int I() throws EOFException { int i; int i2; int i3; if (this.j != 0) { byte r = r(0); if ((r & 128) == 0) { i3 = r & Byte.MAX_VALUE; i2 = 1; i = 0; } else if ((r & 224) == 192) { i3 = r & 31; i2 = 2; i = 128; } else if ((r & 240) == 224) { i3 = r & 15; i2 = 3; i = 2048; } else if ((r & 248) == 240) { i3 = r & 7; i2 = 4; i = 65536; } else { skip(1); return 65533; } long j = (long) i2; if (this.j >= j) { for (int i4 = 1; i4 < i2; i4++) { long j2 = (long) i4; byte r2 = r(j2); if ((r2 & 192) == 128) { i3 = (i3 << 6) | (r2 & 63); } else { skip(j2); return 65533; } } skip(j); if (i3 > 1114111) { return 65533; } if ((55296 <= i3 && 57343 >= i3) || i3 < i) { return 65533; } return i3; } StringBuilder M = c.d.b.a.a.M("size < ", i2, ": "); M.append(this.j); M.append(" (to read code point prefixed 0x"); M.append(c.q.a.k.a.e0(r)); M.append(')'); throw new EOFException(M.toString()); } throw new EOFException(); } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink J(String str) { b0(str); return this; } @Override // g0.g public String L(Charset charset) { m.checkParameterIsNotNull(charset, "charset"); return C(this.j, charset); } public final ByteString M(int i) { if (i == 0) { return ByteString.i; } c.q.a.k.a.l(this.j, 0, (long) i); s sVar = this.i; int i2 = 0; int i3 = 0; int i4 = 0; while (i3 < i) { if (sVar == null) { m.throwNpe(); } int i5 = sVar.f2787c; int i6 = sVar.b; if (i5 != i6) { i3 += i5 - i6; i4++; sVar = sVar.f; } else { throw new AssertionError("s.limit == s.pos"); } } byte[][] bArr = new byte[i4][]; int[] iArr = new int[(i4 * 2)]; s sVar2 = this.i; int i7 = 0; while (i2 < i) { if (sVar2 == null) { m.throwNpe(); } bArr[i7] = sVar2.a; i2 += sVar2.f2787c - sVar2.b; iArr[i7] = Math.min(i2, i); iArr[i7 + i4] = sVar2.b; sVar2.d = true; i7++; sVar2 = sVar2.f; } return new u(bArr, iArr); } public final s N(int i) { boolean z2 = true; if (i < 1 || i > 8192) { z2 = false; } if (z2) { s sVar = this.i; if (sVar == null) { s b2 = t.b(); this.i = b2; b2.g = b2; b2.f = b2; return b2; } if (sVar == null) { m.throwNpe(); } s sVar2 = sVar.g; if (sVar2 == null) { m.throwNpe(); } if (sVar2.f2787c + i <= 8192 && sVar2.e) { return sVar2; } s b3 = t.b(); sVar2.b(b3); return b3; } throw new IllegalArgumentException("unexpected capacity".toString()); } @Override // okio.BufferedSink public long O(x xVar) throws IOException { m.checkParameterIsNotNull(xVar, "source"); long j = 0; while (true) { long h02 = xVar.h0(this, (long) 8192); if (h02 == -1) { return j; } j += h02; } } public e Q(ByteString byteString) { m.checkParameterIsNotNull(byteString, "byteString"); byteString.s(this, 0, byteString.j()); return this; } public e R(byte[] bArr) { m.checkParameterIsNotNull(bArr, "source"); S(bArr, 0, bArr.length); return this; } public e S(byte[] bArr, int i, int i2) { m.checkParameterIsNotNull(bArr, "source"); long j = (long) i2; c.q.a.k.a.l((long) bArr.length, (long) i, j); int i3 = i2 + i; while (i < i3) { s N = N(1); int min = Math.min(i3 - i, 8192 - N.f2787c); int i4 = i + min; j.copyInto(bArr, N.a, N.f2787c, i, i4); N.f2787c += min; i = i4; } this.j += j; return this; } public e T(int i) { s N = N(1); byte[] bArr = N.a; int i2 = N.f2787c; N.f2787c = i2 + 1; bArr[i2] = (byte) i; this.j++; return this; } /* renamed from: U */ public e p0(long j) { int i = (j > 0 ? 1 : (j == 0 ? 0 : -1)); if (i == 0) { T(48); } else { boolean z2 = false; int i2 = 1; if (i < 0) { j = -j; if (j < 0) { b0("-9223372036854775808"); } else { z2 = true; } } if (j >= 100000000) { i2 = j < 1000000000000L ? 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 (z2) { i2++; } s N = N(i2); byte[] bArr = N.a; int i3 = N.f2787c + i2; while (j != 0) { long j2 = (long) 10; i3--; bArr[i3] = g0.z.a.a[(int) (j % j2)]; j /= j2; } if (z2) { bArr[i3 - 1] = (byte) 45; } N.f2787c += i2; this.j += (long) i2; } return this; } /* renamed from: V */ public e P(long j) { if (j == 0) { T(48); } else { long j2 = (j >>> 1) | j; long j3 = j2 | (j2 >>> 2); long j4 = j3 | (j3 >>> 4); long j5 = j4 | (j4 >>> 8); long j6 = j5 | (j5 >>> 16); long j7 = j6 | (j6 >>> 32); long j8 = j7 - ((j7 >>> 1) & 6148914691236517205L); long j9 = ((j8 >>> 2) & 3689348814741910323L) + (j8 & 3689348814741910323L); long j10 = ((j9 >>> 4) + j9) & 1085102592571150095L; long j11 = j10 + (j10 >>> 8); long j12 = j11 + (j11 >>> 16); int i = (int) ((((j12 & 63) + ((j12 >>> 32) & 63)) + ((long) 3)) / ((long) 4)); s N = N(i); byte[] bArr = N.a; int i2 = N.f2787c; for (int i3 = (i2 + i) - 1; i3 >= i2; i3--) { bArr[i3] = g0.z.a.a[(int) (15 & j)]; j >>>= 4; } N.f2787c += i; this.j += (long) i; } return this; } public e W(int i) { s N = N(4); byte[] bArr = N.a; int i2 = N.f2787c; int i3 = i2 + 1; bArr[i2] = (byte) ((i >>> 24) & 255); int i4 = i3 + 1; bArr[i3] = (byte) ((i >>> 16) & 255); int i5 = i4 + 1; bArr[i4] = (byte) ((i >>> 8) & 255); bArr[i5] = (byte) (i & 255); N.f2787c = i5 + 1; this.j += 4; return this; } @Override // g0.g public String X() throws EOFException { return F(Long.MAX_VALUE); } @Override // g0.g public byte[] Y(long j) throws EOFException { if (!(j >= 0 && j <= ((long) Integer.MAX_VALUE))) { throw new IllegalArgumentException(c.d.b.a.a.p("byteCount: ", j).toString()); } else if (this.j >= j) { byte[] bArr = new byte[((int) j)]; readFully(bArr); return bArr; } else { throw new EOFException(); } } public e a0(int i) { s N = N(2); byte[] bArr = N.a; int i2 = N.f2787c; int i3 = i2 + 1; bArr[i2] = (byte) ((i >>> 8) & 255); bArr[i3] = (byte) (i & 255); N.f2787c = i3 + 1; this.j += 2; return this; } /* renamed from: b */ public e clone() { e eVar = new e(); if (this.j != 0) { s sVar = this.i; if (sVar == null) { m.throwNpe(); } s c2 = sVar.c(); eVar.i = c2; c2.g = c2; c2.f = c2; for (s sVar2 = sVar.f; sVar2 != sVar; sVar2 = sVar2.f) { s sVar3 = c2.g; if (sVar3 == null) { m.throwNpe(); } if (sVar2 == null) { m.throwNpe(); } sVar3.b(sVar2.c()); } eVar.j = this.j; } return eVar; } public e b0(String str) { m.checkParameterIsNotNull(str, "string"); c0(str, 0, str.length()); return this; } public e c0(String str, int i, int i2) { char charAt; m.checkParameterIsNotNull(str, "string"); if (i >= 0) { if (i2 >= i) { if (i2 <= str.length()) { while (i < i2) { char charAt2 = str.charAt(i); if (charAt2 < 128) { s N = N(1); byte[] bArr = N.a; int i3 = N.f2787c - 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) { break; } i4 = i + 1; bArr[i + i3] = (byte) charAt; } int i5 = N.f2787c; int i6 = (i3 + i) - i5; N.f2787c = i5 + i6; this.j += (long) i6; } else { if (charAt2 < 2048) { s N2 = N(2); byte[] bArr2 = N2.a; int i7 = N2.f2787c; bArr2[i7] = (byte) ((charAt2 >> 6) | 192); bArr2[i7 + 1] = (byte) ((charAt2 & '?') | 128); N2.f2787c = i7 + 2; this.j += 2; } else if (charAt2 < 55296 || charAt2 > 57343) { s N3 = N(3); byte[] bArr3 = N3.a; int i8 = N3.f2787c; bArr3[i8] = (byte) ((charAt2 >> '\f') | 224); bArr3[i8 + 1] = (byte) ((63 & (charAt2 >> 6)) | 128); bArr3[i8 + 2] = (byte) ((charAt2 & '?') | 128); N3.f2787c = i8 + 3; this.j += 3; } else { int i9 = i + 1; char charAt3 = i9 < i2 ? str.charAt(i9) : 0; if (charAt2 > 56319 || 56320 > charAt3 || 57343 < charAt3) { T(63); i = i9; } else { int i10 = (((charAt2 & 1023) << 10) | (charAt3 & 1023)) + 65536; s N4 = N(4); byte[] bArr4 = N4.a; int i11 = N4.f2787c; bArr4[i11] = (byte) ((i10 >> 18) | 240); bArr4[i11 + 1] = (byte) (((i10 >> 12) & 63) | 128); bArr4[i11 + 2] = (byte) (((i10 >> 6) & 63) | 128); bArr4[i11 + 3] = (byte) ((i10 & 63) | 128); N4.f2787c = i11 + 4; this.j += 4; i += 2; } } i++; } } return this; } StringBuilder M = c.d.b.a.a.M("endIndex > string.length: ", i2, " > "); M.append(str.length()); throw new IllegalArgumentException(M.toString().toString()); } throw new IllegalArgumentException(c.d.b.a.a.n("endIndex < beginIndex: ", i2, " < ", i).toString()); } throw new IllegalArgumentException(c.d.b.a.a.k("beginIndex < 0: ", i).toString()); } @Override // g0.x, java.io.Closeable, java.lang.AutoCloseable public void close() { } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink d0(ByteString byteString) { Q(byteString); return this; } public e e0(int i) { String str; if (i < 128) { T(i); } else if (i < 2048) { s N = N(2); byte[] bArr = N.a; int i2 = N.f2787c; bArr[i2] = (byte) ((i >> 6) | 192); bArr[i2 + 1] = (byte) ((i & 63) | 128); N.f2787c = i2 + 2; this.j += 2; } else if (55296 <= i && 57343 >= i) { T(63); } else if (i < 65536) { s N2 = N(3); byte[] bArr2 = N2.a; int i3 = N2.f2787c; bArr2[i3] = (byte) ((i >> 12) | 224); bArr2[i3 + 1] = (byte) (((i >> 6) & 63) | 128); bArr2[i3 + 2] = (byte) ((i & 63) | 128); N2.f2787c = i3 + 3; this.j += 3; } else if (i <= 1114111) { s N3 = N(4); byte[] bArr3 = N3.a; int i4 = N3.f2787c; bArr3[i4] = (byte) ((i >> 18) | 240); bArr3[i4 + 1] = (byte) (((i >> 12) & 63) | 128); bArr3[i4 + 2] = (byte) (((i >> 6) & 63) | 128); bArr3[i4 + 3] = (byte) ((i & 63) | 128); N3.f2787c = i4 + 4; this.j += 4; } else { StringBuilder L = c.d.b.a.a.L("Unexpected code point: 0x"); if (i != 0) { char[] cArr = g0.z.b.a; int i5 = 0; char[] cArr2 = {cArr[(i >> 28) & 15], cArr[(i >> 24) & 15], cArr[(i >> 20) & 15], cArr[(i >> 16) & 15], cArr[(i >> 12) & 15], cArr[(i >> 8) & 15], cArr[(i >> 4) & 15], cArr[i & 15]}; while (i5 < 8 && cArr2[i5] == '0') { i5++; } str = new String(cArr2, i5, 8 - i5); } else { str = "0"; } L.append(str); throw new IllegalArgumentException(L.toString()); } return this; } @Override // java.lang.Object public boolean equals(Object obj) { if (this != obj) { if (!(obj instanceof e)) { return false; } long j = this.j; e eVar = (e) obj; if (j != eVar.j) { return false; } if (j != 0) { s sVar = this.i; if (sVar == null) { m.throwNpe(); } s sVar2 = eVar.i; if (sVar2 == null) { m.throwNpe(); } int i = sVar.b; int i2 = sVar2.b; long j2 = 0; while (j2 < this.j) { long min = (long) Math.min(sVar.f2787c - i, sVar2.f2787c - i2); long j3 = 0; while (j3 < min) { int i3 = i + 1; int i4 = i2 + 1; if (sVar.a[i] != sVar2.a[i2]) { return false; } j3++; i = i3; i2 = i4; } if (i == sVar.f2787c) { sVar = sVar.f; if (sVar == null) { m.throwNpe(); } i = sVar.b; } if (i2 == sVar2.f2787c) { sVar2 = sVar2.f; if (sVar2 == null) { m.throwNpe(); } i2 = sVar2.b; } j2 += min; } } } return true; } public final long f() { long j = this.j; if (j == 0) { return 0; } s sVar = this.i; if (sVar == null) { m.throwNpe(); } s sVar2 = sVar.g; if (sVar2 == null) { m.throwNpe(); } int i = sVar2.f2787c; if (i < 8192 && sVar2.e) { j -= (long) (i - sVar2.b); } return j; } @Override // okio.BufferedSink, g0.v, java.io.Flushable public void flush() { } @Override // g0.g, okio.BufferedSink public e g() { return this; } @Override // g0.x public long h0(e eVar, long j) { m.checkParameterIsNotNull(eVar, "sink"); if (j >= 0) { long j2 = this.j; if (j2 == 0) { return -1; } if (j > j2) { j = j2; } eVar.write(this, j); return j; } throw new IllegalArgumentException(c.d.b.a.a.p("byteCount < 0: ", j).toString()); } @Override // java.lang.Object public int hashCode() { s sVar = this.i; if (sVar == null) { return 0; } int i = 1; do { int i2 = sVar.f2787c; for (int i3 = sVar.b; i3 < i2; i3++) { i = (i * 31) + sVar.a[i3]; } sVar = sVar.f; if (sVar == null) { m.throwNpe(); } } while (sVar != this.i); return i; } @Override // java.nio.channels.Channel public boolean isOpen() { return true; } @Override // g0.g public boolean j(long j) { return this.j >= j; } @Override // g0.g public long j0(v vVar) throws IOException { m.checkParameterIsNotNull(vVar, "sink"); long j = this.j; if (j > 0) { vVar.write(this, j); } return j; } @Override // g0.g public ByteString n(long j) throws EOFException { if (!(j >= 0 && j <= ((long) Integer.MAX_VALUE))) { throw new IllegalArgumentException(c.d.b.a.a.p("byteCount: ", j).toString()); } else if (this.j < j) { throw new EOFException(); } else if (j < ((long) 4096)) { return new ByteString(Y(j)); } else { ByteString M = M((int) j); skip(j); return M; } } @Override // okio.BufferedSink public BufferedSink o() { return this; } @Override // g0.g public void o0(long j) throws EOFException { if (this.j < j) { throw new EOFException(); } } public final e p(e eVar, long j, long j2) { m.checkParameterIsNotNull(eVar, "out"); c.q.a.k.a.l(this.j, j, j2); if (j2 != 0) { eVar.j += j2; s sVar = this.i; while (true) { if (sVar == null) { m.throwNpe(); } int i = sVar.f2787c; int i2 = sVar.b; if (j < ((long) (i - i2))) { break; } j -= (long) (i - i2); sVar = sVar.f; } while (j2 > 0) { if (sVar == null) { m.throwNpe(); } s c2 = sVar.c(); int i3 = c2.b + ((int) j); c2.b = i3; c2.f2787c = Math.min(i3 + ((int) j2), c2.f2787c); s sVar2 = eVar.i; if (sVar2 == null) { c2.g = c2; c2.f = c2; eVar.i = c2; } else { if (sVar2 == null) { m.throwNpe(); } s sVar3 = sVar2.g; if (sVar3 == null) { m.throwNpe(); } sVar3.b(c2); } j2 -= (long) (c2.f2787c - c2.b); sVar = sVar.f; j = 0; } } return this; } public final byte r(long j) { c.q.a.k.a.l(this.j, j, 1); s sVar = this.i; if (sVar != null) { long j2 = this.j; if (j2 - j < j) { while (j2 > j) { sVar = sVar.g; if (sVar == null) { m.throwNpe(); } j2 -= (long) (sVar.f2787c - sVar.b); } return sVar.a[(int) ((((long) sVar.b) + j) - j2)]; } long j3 = 0; while (true) { int i = sVar.f2787c; int i2 = sVar.b; long j4 = ((long) (i - i2)) + j3; if (j4 > j) { return sVar.a[(int) ((((long) i2) + j) - j3)]; } sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j3 = j4; } } else { m.throwNpe(); throw null; } } @Override // g0.g public long r0() throws EOFException { byte b2; int i; if (this.j != 0) { int i2 = 0; boolean z2 = false; long j = 0; do { s sVar = this.i; if (sVar == null) { m.throwNpe(); } byte[] bArr = sVar.a; int i3 = sVar.b; int i4 = sVar.f2787c; while (true) { if (i3 >= i4) { break; } b2 = bArr[i3]; byte b3 = (byte) 48; if (b2 < b3 || b2 > ((byte) 57)) { byte b4 = (byte) 97; if ((b2 < b4 || b2 > ((byte) 102)) && (b2 < (b4 = (byte) 65) || b2 > ((byte) 70))) { break; } i = (b2 - b4) + 10; } else { i = b2 - b3; } if ((-1152921504606846976L & j) == 0) { j = (j << 4) | ((long) i); i3++; i2++; } else { e eVar = new e(); eVar.P(j); eVar.T(b2); StringBuilder L = c.d.b.a.a.L("Number too large: "); L.append(eVar.G()); throw new NumberFormatException(L.toString()); } } if (i2 != 0) { z2 = true; if (i3 == i4) { this.i = sVar.a(); t.a(sVar); } else { sVar.b = i3; } if (z2) { break; } } else { StringBuilder L2 = c.d.b.a.a.L("Expected leading [0-9a-fA-F] character but was 0x"); L2.append(c.q.a.k.a.e0(b2)); throw new NumberFormatException(L2.toString()); } } while (this.i != null); this.j -= (long) i2; return j; } throw new EOFException(); } @Override // java.nio.channels.ReadableByteChannel public int read(ByteBuffer byteBuffer) throws IOException { m.checkParameterIsNotNull(byteBuffer, "sink"); s sVar = this.i; if (sVar == null) { return -1; } int min = Math.min(byteBuffer.remaining(), sVar.f2787c - sVar.b); byteBuffer.put(sVar.a, sVar.b, min); int i = sVar.b + min; sVar.b = i; this.j -= (long) min; if (i == sVar.f2787c) { this.i = sVar.a(); t.a(sVar); } return min; } public int read(byte[] bArr, int i, int i2) { m.checkParameterIsNotNull(bArr, "sink"); c.q.a.k.a.l((long) bArr.length, (long) i, (long) i2); s sVar = this.i; if (sVar == null) { return -1; } int min = Math.min(i2, sVar.f2787c - sVar.b); byte[] bArr2 = sVar.a; int i3 = sVar.b; j.copyInto(bArr2, bArr, i, i3, i3 + min); int i4 = sVar.b + min; sVar.b = i4; this.j -= (long) min; if (i4 != sVar.f2787c) { return min; } this.i = sVar.a(); t.a(sVar); return min; } @Override // g0.g public byte readByte() throws EOFException { if (this.j != 0) { s sVar = this.i; if (sVar == null) { m.throwNpe(); } int i = sVar.b; int i2 = sVar.f2787c; int i3 = i + 1; byte b2 = sVar.a[i]; this.j--; if (i3 == i2) { this.i = sVar.a(); t.a(sVar); } else { sVar.b = i3; } return b2; } throw new EOFException(); } @Override // g0.g public void readFully(byte[] bArr) throws EOFException { m.checkParameterIsNotNull(bArr, "sink"); int i = 0; while (i < bArr.length) { int read = read(bArr, i, bArr.length - i); if (read != -1) { i += read; } else { throw new EOFException(); } } } @Override // g0.g public int readInt() throws EOFException { if (this.j >= 4) { s sVar = this.i; if (sVar == null) { m.throwNpe(); } int i = sVar.b; int i2 = sVar.f2787c; if (((long) (i2 - i)) < 4) { return ((readByte() & 255) << 24) | ((readByte() & 255) << 16) | ((readByte() & 255) << 8) | (readByte() & 255); } byte[] bArr = sVar.a; 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.j -= 4; if (i8 == i2) { this.i = sVar.a(); t.a(sVar); } else { sVar.b = i8; } return i9; } throw new EOFException(); } @Override // g0.g public long readLong() throws EOFException { if (this.j >= 8) { s sVar = this.i; if (sVar == null) { m.throwNpe(); } int i = sVar.b; int i2 = sVar.f2787c; if (((long) (i2 - i)) < 8) { return ((((long) readInt()) & 4294967295L) << 32) | (4294967295L & ((long) readInt())); } byte[] bArr = sVar.a; int i3 = i + 1; int i4 = i3 + 1; int i5 = i4 + 1; long j = ((((long) bArr[i]) & 255) << 56) | ((((long) bArr[i3]) & 255) << 48) | ((((long) bArr[i4]) & 255) << 40); int i6 = i5 + 1; long j2 = ((((long) bArr[i5]) & 255) << 32) | j; int i7 = i6 + 1; int i8 = i7 + 1; long j3 = j2 | ((((long) bArr[i6]) & 255) << 24) | ((((long) bArr[i7]) & 255) << 16); int i9 = i8 + 1; int i10 = i9 + 1; long j4 = j3 | ((((long) bArr[i8]) & 255) << 8) | (((long) bArr[i9]) & 255); this.j -= 8; if (i10 == i2) { this.i = sVar.a(); t.a(sVar); } else { sVar.b = i10; } return j4; } throw new EOFException(); } @Override // g0.g public short readShort() throws EOFException { if (this.j >= 2) { s sVar = this.i; if (sVar == null) { m.throwNpe(); } int i = sVar.b; int i2 = sVar.f2787c; if (i2 - i < 2) { return (short) (((readByte() & 255) << 8) | (readByte() & 255)); } byte[] bArr = sVar.a; int i3 = i + 1; int i4 = i3 + 1; int i5 = ((bArr[i] & 255) << 8) | (bArr[i3] & 255); this.j -= 2; if (i4 == i2) { this.i = sVar.a(); t.a(sVar); } else { sVar.b = i4; } return (short) i5; } throw new EOFException(); } public long s(byte b2, long j, long j2) { s sVar; long j3 = 0; if (0 <= j && j2 >= j) { long j4 = this.j; if (j2 > j4) { j2 = j4; } if (!(j == j2 || (sVar = this.i) == null)) { if (j4 - j < j) { while (j4 > j) { sVar = sVar.g; if (sVar == null) { m.throwNpe(); } j4 -= (long) (sVar.f2787c - sVar.b); } while (j4 < j2) { byte[] bArr = sVar.a; int min = (int) Math.min((long) sVar.f2787c, (((long) sVar.b) + j2) - j4); for (int i = (int) ((((long) sVar.b) + j) - j4); i < min; i++) { if (bArr[i] == b2) { return ((long) (i - sVar.b)) + j4; } } j4 += (long) (sVar.f2787c - sVar.b); sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j = j4; } } else { while (true) { long j5 = ((long) (sVar.f2787c - sVar.b)) + j3; if (j5 > j) { break; } sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j3 = j5; } while (j3 < j2) { byte[] bArr2 = sVar.a; int min2 = (int) Math.min((long) sVar.f2787c, (((long) sVar.b) + j2) - j3); for (int i2 = (int) ((((long) sVar.b) + j) - j3); i2 < min2; i2++) { if (bArr2[i2] == b2) { return ((long) (i2 - sVar.b)) + j3; } } j3 += (long) (sVar.f2787c - sVar.b); sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j = j3; } } } return -1; } StringBuilder L = c.d.b.a.a.L("size="); L.append(this.j); L.append(" fromIndex="); L.append(j); L.append(" toIndex="); L.append(j2); throw new IllegalArgumentException(L.toString().toString()); } @Override // g0.g public void skip(long j) throws EOFException { while (j > 0) { s sVar = this.i; if (sVar != null) { int min = (int) Math.min(j, (long) (sVar.f2787c - sVar.b)); long j2 = (long) min; this.j -= j2; j -= j2; int i = sVar.b + min; sVar.b = i; if (i == sVar.f2787c) { this.i = sVar.a(); t.a(sVar); } } else { throw new EOFException(); } } } public long t(ByteString byteString, long j) { int i; int i2; int i3; int i4; long j2 = j; m.checkParameterIsNotNull(byteString, "targetBytes"); long j3 = 0; if (j2 >= 0) { s sVar = this.i; if (sVar == null) { return -1; } long j4 = this.j; if (j4 - j2 < j2) { while (j4 > j2) { sVar = sVar.g; if (sVar == null) { m.throwNpe(); } j4 -= (long) (sVar.f2787c - sVar.b); } if (byteString.j() == 2) { byte m = byteString.m(0); byte m2 = byteString.m(1); while (j4 < this.j) { byte[] bArr = sVar.a; i3 = (int) ((((long) sVar.b) + j2) - j4); int i5 = sVar.f2787c; while (i3 < i5) { byte b2 = bArr[i3]; if (b2 == m || b2 == m2) { i4 = sVar.b; } else { i3++; } } j4 += (long) (sVar.f2787c - sVar.b); sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j2 = j4; } return -1; } byte[] l = byteString.l(); while (j4 < this.j) { byte[] bArr2 = sVar.a; i3 = (int) ((((long) sVar.b) + j2) - j4); int i6 = sVar.f2787c; while (i3 < i6) { byte b3 = bArr2[i3]; for (byte b4 : l) { if (b3 == b4) { i4 = sVar.b; } } i3++; } j4 += (long) (sVar.f2787c - sVar.b); sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j2 = j4; } return -1; return ((long) (i3 - i4)) + j4; } while (true) { long j5 = ((long) (sVar.f2787c - sVar.b)) + j3; if (j5 > j2) { break; } sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j3 = j5; } if (byteString.j() == 2) { byte m3 = byteString.m(0); byte m4 = byteString.m(1); while (j3 < this.j) { byte[] bArr3 = sVar.a; i = (int) ((((long) sVar.b) + j2) - j3); int i7 = sVar.f2787c; while (i < i7) { byte b5 = bArr3[i]; if (b5 == m3 || b5 == m4) { i2 = sVar.b; } else { i++; } } j3 += (long) (sVar.f2787c - sVar.b); sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j2 = j3; } return -1; } byte[] l2 = byteString.l(); while (j3 < this.j) { byte[] bArr4 = sVar.a; i = (int) ((((long) sVar.b) + j2) - j3); int i8 = sVar.f2787c; while (i < i8) { byte b6 = bArr4[i]; for (byte b7 : l2) { if (b6 == b7) { i2 = sVar.b; } } i++; } j3 += (long) (sVar.f2787c - sVar.b); sVar = sVar.f; if (sVar == null) { m.throwNpe(); } j2 = j3; } return -1; return ((long) (i - i2)) + j3; } throw new IllegalArgumentException(c.d.b.a.a.p("fromIndex < 0: ", j2).toString()); } @Override // g0.g public InputStream t0() { return new b(this); } @Override // g0.x public y timeout() { return y.a; } @Override // java.lang.Object public String toString() { long j = this.j; if (j <= ((long) Integer.MAX_VALUE)) { return M((int) j).toString(); } StringBuilder L = c.d.b.a.a.L("size > Int.MAX_VALUE: "); L.append(this.j); throw new IllegalStateException(L.toString().toString()); } @Override // g0.g public int u0(o oVar) { m.checkParameterIsNotNull(oVar, "options"); int b2 = g0.z.a.b(this, oVar, false); if (b2 == -1) { return -1; } skip((long) oVar.k[b2].j()); return b2; } @Override // g0.g public boolean v() { return this.j == 0; } public final a w(a aVar) { m.checkParameterIsNotNull(aVar, "unsafeCursor"); if (aVar.i == null) { aVar.i = this; aVar.j = true; return aVar; } throw new IllegalStateException("already attached to a buffer".toString()); } @Override // java.nio.channels.WritableByteChannel public int write(ByteBuffer byteBuffer) throws IOException { m.checkParameterIsNotNull(byteBuffer, "source"); int remaining = byteBuffer.remaining(); int i = remaining; while (i > 0) { s N = N(1); int min = Math.min(i, 8192 - N.f2787c); byteBuffer.get(N.a, N.f2787c, min); i -= min; N.f2787c += min; } this.j += (long) remaining; return remaining; } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink write(byte[] bArr) { R(bArr); return this; } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink write(byte[] bArr, int i, int i2) { S(bArr, i, i2); return this; } @Override // g0.v public void write(e eVar, long j) { int i; s sVar; s sVar2; m.checkParameterIsNotNull(eVar, "source"); if (eVar != this) { c.q.a.k.a.l(eVar.j, 0, j); long j2 = j; while (j2 > 0) { s sVar3 = eVar.i; if (sVar3 == null) { m.throwNpe(); } int i2 = sVar3.f2787c; s sVar4 = eVar.i; if (sVar4 == null) { m.throwNpe(); } if (j2 < ((long) (i2 - sVar4.b))) { s sVar5 = this.i; if (sVar5 != null) { if (sVar5 == null) { m.throwNpe(); } sVar = sVar5.g; } else { sVar = null; } if (sVar != null && sVar.e) { if ((((long) sVar.f2787c) + j2) - ((long) (sVar.d ? 0 : sVar.b)) <= ((long) 8192)) { s sVar6 = eVar.i; if (sVar6 == null) { m.throwNpe(); } sVar6.d(sVar, (int) j2); eVar.j -= j2; this.j += j2; return; } } s sVar7 = eVar.i; if (sVar7 == null) { m.throwNpe(); } int i3 = (int) j2; Objects.requireNonNull(sVar7); if (i3 > 0 && i3 <= sVar7.f2787c - sVar7.b) { if (i3 >= 1024) { sVar2 = sVar7.c(); } else { sVar2 = t.b(); byte[] bArr = sVar7.a; byte[] bArr2 = sVar2.a; int i4 = sVar7.b; j.copyInto$default(bArr, bArr2, 0, i4, i4 + i3, 2, (Object) null); } sVar2.f2787c = sVar2.b + i3; sVar7.b += i3; s sVar8 = sVar7.g; if (sVar8 == null) { m.throwNpe(); } sVar8.b(sVar2); eVar.i = sVar2; } else { throw new IllegalArgumentException("byteCount out of range".toString()); } } s sVar9 = eVar.i; if (sVar9 == null) { m.throwNpe(); } long j3 = (long) (sVar9.f2787c - sVar9.b); eVar.i = sVar9.a(); s sVar10 = this.i; if (sVar10 == null) { this.i = sVar9; sVar9.g = sVar9; sVar9.f = sVar9; } else { if (sVar10 == null) { m.throwNpe(); } s sVar11 = sVar10.g; if (sVar11 == null) { m.throwNpe(); } sVar11.b(sVar9); s sVar12 = sVar9.g; if (sVar12 != sVar9) { if (sVar12 == null) { m.throwNpe(); } if (sVar12.e) { int i5 = sVar9.f2787c - sVar9.b; s sVar13 = sVar9.g; if (sVar13 == null) { m.throwNpe(); } int i6 = 8192 - sVar13.f2787c; s sVar14 = sVar9.g; if (sVar14 == null) { m.throwNpe(); } if (sVar14.d) { i = 0; } else { s sVar15 = sVar9.g; if (sVar15 == null) { m.throwNpe(); } i = sVar15.b; } if (i5 <= i6 + i) { s sVar16 = sVar9.g; if (sVar16 == null) { m.throwNpe(); } sVar9.d(sVar16, i5); sVar9.a(); t.a(sVar9); } } } else { throw new IllegalStateException("cannot compact".toString()); } } eVar.j -= j3; this.j += j3; j2 -= j3; } return; } throw new IllegalArgumentException("source == this".toString()); } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink writeByte(int i) { T(i); return this; } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink writeInt(int i) { W(i); return this; } @Override // okio.BufferedSink public /* bridge */ /* synthetic */ BufferedSink writeShort(int i) { a0(i); return this; } public ByteString x() { return n(this.j); } public short z() throws EOFException { int readShort = readShort() & 65535; return (short) (((readShort & 255) << 8) | ((65280 & readShort) >>> 8)); } }