package g0; import c.d.b.a.a; import d0.z.d.m; import java.io.OutputStream; /* compiled from: JvmOkio.kt */ public final class p implements v { public final OutputStream i; public final y j; public p(OutputStream outputStream, y yVar) { m.checkParameterIsNotNull(outputStream, "out"); m.checkParameterIsNotNull(yVar, "timeout"); this.i = outputStream; this.j = yVar; } @Override // g0.v, java.io.Closeable, java.lang.AutoCloseable public void close() { this.i.close(); } @Override // g0.v, java.io.Flushable public void flush() { this.i.flush(); } @Override // g0.v public y timeout() { return this.j; } @Override // java.lang.Object public String toString() { StringBuilder L = a.L("sink("); L.append(this.i); L.append(')'); return L.toString(); } @Override // g0.v public void write(e eVar, long j) { m.checkParameterIsNotNull(eVar, "source"); c.q.a.k.a.l(eVar.j, 0, j); while (j > 0) { this.j.f(); s sVar = eVar.i; if (sVar == null) { m.throwNpe(); } int min = (int) Math.min(j, (long) (sVar.f2775c - sVar.b)); this.i.write(sVar.a, sVar.b, min); int i = sVar.b + min; sVar.b = i; long j2 = (long) min; j -= j2; eVar.j -= j2; if (i == sVar.f2775c) { eVar.i = sVar.a(); t.a(sVar); } } } }