package g0; import c.q.a.k.a; import d0.t.j; import d0.z.d.m; import java.io.IOException; import java.io.OutputStream; import java.security.MessageDigest; import okio.ByteString; /* compiled from: SegmentedByteString.kt */ public final class u extends ByteString { public final transient byte[][] m; public final transient int[] n; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public u(byte[][] bArr, int[] iArr) { super(ByteString.i.i()); m.checkParameterIsNotNull(bArr, "segments"); m.checkParameterIsNotNull(iArr, "directory"); this.m = bArr; this.n = iArr; } private final Object writeReplace() { return u(); } @Override // okio.ByteString, java.lang.Object public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof ByteString) { ByteString byteString = (ByteString) obj; if (byteString.j() == j() && n(0, byteString, 0, j())) { return true; } } return false; } @Override // okio.ByteString public String f() { return u().f(); } @Override // okio.ByteString public ByteString g(String str) { m.checkParameterIsNotNull(str, "algorithm"); MessageDigest instance = MessageDigest.getInstance(str); int length = this.m.length; int i = 0; int i2 = 0; while (i < length) { int[] iArr = this.n; int i3 = iArr[length + i]; int i4 = iArr[i]; instance.update(this.m[i], i3, i4 - i2); i++; i2 = i4; } byte[] digest = instance.digest(); m.checkExpressionValueIsNotNull(digest, "digest.digest()"); return new ByteString(digest); } @Override // okio.ByteString, java.lang.Object public int hashCode() { int i = this.k; if (i != 0) { return i; } int length = this.m.length; int i2 = 0; int i3 = 1; int i4 = 0; while (i2 < length) { int[] iArr = this.n; int i5 = iArr[length + i2]; int i6 = iArr[i2]; byte[] bArr = this.m[i2]; int i7 = (i6 - i4) + i5; while (i5 < i7) { i3 = (i3 * 31) + bArr[i5]; i5++; } i2++; i4 = i6; } this.k = i3; return i3; } @Override // okio.ByteString public int j() { return this.n[this.m.length - 1]; } @Override // okio.ByteString public String k() { return u().k(); } @Override // okio.ByteString public byte[] l() { return t(); } @Override // okio.ByteString public byte m(int i) { a.l((long) this.n[this.m.length - 1], (long) i, 1); int O = a.O(this, i); int i2 = O == 0 ? 0 : this.n[O - 1]; int[] iArr = this.n; byte[][] bArr = this.m; return bArr[O][(i - i2) + iArr[bArr.length + O]]; } @Override // okio.ByteString public boolean n(int i, ByteString byteString, int i2, int i3) { m.checkParameterIsNotNull(byteString, "other"); if (i < 0 || i > j() - i3) { return false; } int i4 = i3 + i; int O = a.O(this, i); while (i < i4) { int i5 = O == 0 ? 0 : this.n[O - 1]; int[] iArr = this.n; int i6 = iArr[this.m.length + O]; int min = Math.min(i4, (iArr[O] - i5) + i5) - i; if (!byteString.o(i2, this.m[O], (i - i5) + i6, min)) { return false; } i2 += min; i += min; O++; } return true; } @Override // okio.ByteString public boolean o(int i, byte[] bArr, int i2, int i3) { m.checkParameterIsNotNull(bArr, "other"); if (i < 0 || i > j() - i3 || i2 < 0 || i2 > bArr.length - i3) { return false; } int i4 = i3 + i; int O = a.O(this, i); while (i < i4) { int i5 = O == 0 ? 0 : this.n[O - 1]; int[] iArr = this.n; int i6 = iArr[this.m.length + O]; int min = Math.min(i4, (iArr[O] - i5) + i5) - i; if (!a.e(this.m[O], (i - i5) + i6, bArr, i2, min)) { return false; } i2 += min; i += min; O++; } return true; } @Override // okio.ByteString public ByteString p() { return u().p(); } @Override // okio.ByteString public void r(OutputStream outputStream) throws IOException { m.checkParameterIsNotNull(outputStream, "out"); int length = this.m.length; int i = 0; int i2 = 0; while (i < length) { int[] iArr = this.n; int i3 = iArr[length + i]; int i4 = iArr[i]; outputStream.write(this.m[i], i3, i4 - i2); i++; i2 = i4; } } @Override // okio.ByteString public void s(e eVar, int i, int i2) { m.checkParameterIsNotNull(eVar, "buffer"); int i3 = i2 + i; int O = a.O(this, i); while (i < i3) { int i4 = O == 0 ? 0 : this.n[O - 1]; int[] iArr = this.n; int i5 = iArr[this.m.length + O]; int min = Math.min(i3, (iArr[O] - i4) + i4) - i; int i6 = (i - i4) + i5; s sVar = new s(this.m[O], i6, i6 + min, true, false); s sVar2 = eVar.i; if (sVar2 == null) { sVar.g = sVar; sVar.f = sVar; eVar.i = sVar; } else { s sVar3 = sVar2.g; if (sVar3 == null) { m.throwNpe(); } sVar3.b(sVar); } i += min; O++; } eVar.j += (long) j(); } public byte[] t() { byte[] bArr = new byte[j()]; int length = this.m.length; int i = 0; int i2 = 0; int i3 = 0; while (i < length) { int[] iArr = this.n; int i4 = iArr[length + i]; int i5 = iArr[i]; int i6 = i5 - i2; j.copyInto(this.m[i], bArr, i3, i4, i4 + i6); i3 += i6; i++; i2 = i5; } return bArr; } @Override // okio.ByteString, java.lang.Object public String toString() { return u().toString(); } public final ByteString u() { return new ByteString(t()); } }