package h5; import java.io.EOFException; import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Inflater; /* loaded from: classes2.dex */ public final class c0 implements o0 { /* renamed from: a, reason: collision with root package name */ private final f f10008a; /* renamed from: b, reason: collision with root package name */ private final Inflater f10009b; /* renamed from: c, reason: collision with root package name */ private int f10010c; /* renamed from: d, reason: collision with root package name */ private boolean f10011d; c0(f fVar, Inflater inflater) { if (fVar == null) { throw new IllegalArgumentException("source == null"); } if (inflater == null) { throw new IllegalArgumentException("inflater == null"); } this.f10008a = fVar; this.f10009b = inflater; } private void c() { int i10 = this.f10010c; if (i10 == 0) { return; } int remaining = i10 - this.f10009b.getRemaining(); this.f10010c -= remaining; this.f10008a.skip(remaining); } @Override // h5.o0 public long H(d dVar, long j10) { boolean z10; if (j10 < 0) { throw new IllegalArgumentException("byteCount < 0: " + j10); } if (this.f10011d) { throw new IllegalStateException("closed"); } if (j10 == 0) { return 0L; } do { z10 = z(); try { v0 I = dVar.I(1); int inflate = this.f10009b.inflate(I.f10309a, I.f10311c, (int) Math.min(j10, 8192 - I.f10311c)); if (inflate > 0) { I.f10311c += inflate; long j11 = inflate; dVar.f10014b += j11; return j11; } if (!this.f10009b.finished() && !this.f10009b.needsDictionary()) { } c(); if (I.f10310b != I.f10311c) { return -1L; } dVar.f10013a = I.e(); w0.b(I); return -1L; } catch (DataFormatException e10) { throw new IOException(e10); } } while (!z10); throw new EOFException("source exhausted prematurely"); } @Override // h5.o0 public p0 b() { return this.f10008a.b(); } @Override // h5.o0, java.io.Closeable, java.lang.AutoCloseable public void close() { if (this.f10011d) { return; } this.f10009b.end(); this.f10011d = true; this.f10008a.close(); } public final boolean z() { if (!this.f10009b.needsInput()) { return false; } c(); if (this.f10009b.getRemaining() != 0) { throw new IllegalStateException("?"); } if (this.f10008a.g()) { return true; } v0 v0Var = this.f10008a.a().f10013a; int i10 = v0Var.f10311c; int i11 = v0Var.f10310b; int i12 = i10 - i11; this.f10010c = i12; this.f10009b.setInput(v0Var.f10309a, i11, i12); return false; } }