package x9; import java.io.EOFException; import java.nio.ByteBuffer; import java.nio.charset.Charset; /* loaded from: classes2.dex */ final class q implements e { /* renamed from: a, reason: collision with root package name */ public final c f15505a = new c(); /* renamed from: b, reason: collision with root package name */ public final v f15506b; /* renamed from: c, reason: collision with root package name */ boolean f15507c; q(v vVar) { if (vVar == null) { throw new NullPointerException("source == null"); } this.f15506b = vVar; } @Override // x9.e public c K() { return this.f15505a; } @Override // x9.e public int X(o oVar) { if (this.f15507c) { throw new IllegalStateException("closed"); } do { int r02 = this.f15505a.r0(oVar, true); if (r02 == -1) { return -1; } if (r02 != -2) { this.f15505a.skip(oVar.f15500a[r02].n()); return r02; } } while (this.f15506b.s0(this.f15505a, 8192L) != -1); return -1; } @Override // x9.e, x9.d public c a() { return this.f15505a; } @Override // x9.v public w b() { return this.f15506b.b(); } public long c(byte b10, long j10, long j11) { if (this.f15507c) { throw new IllegalStateException("closed"); } if (j10 < 0 || j11 < j10) { throw new IllegalArgumentException(String.format("fromIndex=%s toIndex=%s", Long.valueOf(j10), Long.valueOf(j11))); } while (j10 < j11) { long a02 = this.f15505a.a0(b10, j10, j11); if (a02 == -1) { c cVar = this.f15505a; long j12 = cVar.f15468b; if (j12 >= j11 || this.f15506b.s0(cVar, 8192L) == -1) { break; } j10 = Math.max(j10, j12); } else { return a02; } } return -1L; } @Override // x9.v, java.io.Closeable, java.lang.AutoCloseable public void close() { if (this.f15507c) { return; } this.f15507c = true; this.f15506b.close(); this.f15505a.I(); } @Override // x9.e public f d(long j10) { s(j10); return this.f15505a.d(j10); } @Override // x9.e public long e0(u uVar) { if (uVar == null) { throw new IllegalArgumentException("sink == null"); } long j10 = 0; while (this.f15506b.s0(this.f15505a, 8192L) != -1) { long P = this.f15505a.P(); if (P > 0) { j10 += P; uVar.t0(this.f15505a, P); } } if (this.f15505a.u0() <= 0) { return j10; } long u02 = j10 + this.f15505a.u0(); c cVar = this.f15505a; uVar.t0(cVar, cVar.u0()); return u02; } @Override // x9.e public boolean g() { if (this.f15507c) { throw new IllegalStateException("closed"); } return this.f15505a.g() && this.f15506b.s0(this.f15505a, 8192L) == -1; } @Override // x9.e public String i(long j10) { if (j10 < 0) { throw new IllegalArgumentException("limit < 0: " + j10); } long j11 = j10 == Long.MAX_VALUE ? Long.MAX_VALUE : j10 + 1; long c10 = c((byte) 10, 0L, j11); if (c10 != -1) { return this.f15505a.q0(c10); } if (j11 < Long.MAX_VALUE && z(j11) && this.f15505a.Y(j11 - 1) == 13 && z(1 + j11) && this.f15505a.Y(j11) == 10) { return this.f15505a.q0(j11); } c cVar = new c(); c cVar2 = this.f15505a; cVar2.R(cVar, 0L, Math.min(32L, cVar2.u0())); throw new EOFException("\\n not found: limit=" + Math.min(this.f15505a.u0(), j10) + " content=" + cVar.f0().i() + (char) 8230); } @Override // java.nio.channels.Channel public boolean isOpen() { return !this.f15507c; } @Override // x9.e public String k(Charset charset) { if (charset == null) { throw new IllegalArgumentException("charset == null"); } this.f15505a.H0(this.f15506b); return this.f15505a.k(charset); } @Override // x9.e public String n() { return i(Long.MAX_VALUE); } @Override // x9.e public int o() { s(4L); return this.f15505a.o(); } @Override // x9.e public byte[] p(long j10) { s(j10); return this.f15505a.p(j10); } @Override // x9.e public short r() { s(2L); return this.f15505a.r(); } @Override // java.nio.channels.ReadableByteChannel public int read(ByteBuffer byteBuffer) { c cVar = this.f15505a; if (cVar.f15468b == 0 && this.f15506b.s0(cVar, 8192L) == -1) { return -1; } return this.f15505a.read(byteBuffer); } @Override // x9.e public byte readByte() { s(1L); return this.f15505a.readByte(); } @Override // x9.e public void readFully(byte[] bArr) { try { s(bArr.length); this.f15505a.readFully(bArr); } catch (EOFException e10) { int i10 = 0; while (true) { c cVar = this.f15505a; long j10 = cVar.f15468b; if (j10 <= 0) { throw e10; } int read = cVar.read(bArr, i10, (int) j10); if (read == -1) { throw new AssertionError(); } i10 += read; } } } @Override // x9.e public int readInt() { s(4L); return this.f15505a.readInt(); } @Override // x9.e public short readShort() { s(2L); return this.f15505a.readShort(); } @Override // x9.e public void s(long j10) { if (!z(j10)) { throw new EOFException(); } } @Override // x9.v public long s0(c cVar, long j10) { if (cVar == null) { throw new IllegalArgumentException("sink == null"); } if (j10 < 0) { throw new IllegalArgumentException("byteCount < 0: " + j10); } if (this.f15507c) { throw new IllegalStateException("closed"); } c cVar2 = this.f15505a; if (cVar2.f15468b == 0 && this.f15506b.s0(cVar2, 8192L) == -1) { return -1L; } return this.f15505a.s0(cVar, Math.min(j10, this.f15505a.f15468b)); } @Override // x9.e public void skip(long j10) { if (this.f15507c) { throw new IllegalStateException("closed"); } while (j10 > 0) { c cVar = this.f15505a; if (cVar.f15468b == 0 && this.f15506b.s0(cVar, 8192L) == -1) { throw new EOFException(); } long min = Math.min(j10, this.f15505a.u0()); this.f15505a.skip(min); j10 -= min; } } @Override // x9.e public long t(byte b10) { return c(b10, 0L, Long.MAX_VALUE); } public String toString() { return "buffer(" + this.f15506b + ")"; } /* JADX WARN: Code restructure failed: missing block: B:20:0x0032, code lost: if (r1 == 0) goto L21; */ /* JADX WARN: Code restructure failed: missing block: B:22:0x0049, code lost: throw new java.lang.NumberFormatException(java.lang.String.format("Expected leading [0-9a-fA-F] character but was %#x", java.lang.Byte.valueOf(r3))); */ @Override // x9.e /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public long u() { /* r6 = this; r0 = 1 r6.s(r0) r0 = 0 r1 = 0 L7: int r2 = r1 + 1 long r3 = (long) r2 boolean r3 = r6.z(r3) if (r3 == 0) goto L4a x9.c r3 = r6.f15505a long r4 = (long) r1 byte r3 = r3.Y(r4) r4 = 48 if (r3 < r4) goto L1f r4 = 57 if (r3 <= r4) goto L30 L1f: r4 = 97 if (r3 < r4) goto L27 r4 = 102(0x66, float:1.43E-43) if (r3 <= r4) goto L30 L27: r4 = 65 if (r3 < r4) goto L32 r4 = 70 if (r3 <= r4) goto L30 goto L32 L30: r1 = r2 goto L7 L32: if (r1 == 0) goto L35 goto L4a L35: java.lang.NumberFormatException r1 = new java.lang.NumberFormatException r2 = 1 java.lang.Object[] r2 = new java.lang.Object[r2] java.lang.Byte r3 = java.lang.Byte.valueOf(r3) r2[r0] = r3 java.lang.String r0 = "Expected leading [0-9a-fA-F] character but was %#x" java.lang.String r0 = java.lang.String.format(r0, r2) r1.(r0) throw r1 L4a: x9.c r0 = r6.f15505a long r0 = r0.u() return r0 */ throw new UnsupportedOperationException("Method not decompiled: x9.q.u():long"); } public boolean z(long j10) { c cVar; if (j10 < 0) { throw new IllegalArgumentException("byteCount < 0: " + j10); } if (this.f15507c) { throw new IllegalStateException("closed"); } do { cVar = this.f15505a; if (cVar.f15468b >= j10) { return true; } } while (this.f15506b.s0(cVar, 8192L) != -1); return false; } }