package okio;

/* JADX INFO: renamed from: okio.SegmentedByteString, reason: case insensitive filesystem */
/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000Z\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0007\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\u0005\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\t\n\u0002\u0010\u0000\n\u0002\b\r\b\u0000\u0018\u00002\u00020\u0001B\u001f\b\u0000\u0012\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00030\u0002\u0012\u0006\u0010\u0006\u001a\u00020\u0005¢\u0006\u0004\b\u0007\u0010\bJ\u000f\u0010\t\u001a\u00020\u0001H\u0002¢\u0006\u0004\b\t\u0010\nJ\u000f\u0010\f\u001a\u00020\u000bH\u0002¢\u0006\u0004\b\f\u0010\rJ\u000f\u0010\u000f\u001a\u00020\u000eH\u0016¢\u0006\u0004\b\u000f\u0010\u0010J\u000f\u0010\u0011\u001a\u00020\u000eH\u0016¢\u0006\u0004\b\u0011\u0010\u0010J\u000f\u0010\u0012\u001a\u00020\u0001H\u0016¢\u0006\u0004\b\u0012\u0010\nJ\u0017\u0010\u0014\u001a\u00020\u00012\u0006\u0010\u0013\u001a\u00020\u000eH\u0010¢\u0006\u0004\b\u0014\u0010\u0015J\u001f\u0010\u0019\u001a\u00020\u00012\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u0018\u001a\u00020\u0016H\u0016¢\u0006\u0004\b\u0019\u0010\u001aJ\u0017\u0010\u001d\u001a\u00020\u001c2\u0006\u0010\u001b\u001a\u00020\u0016H\u0010¢\u0006\u0004\b\u001d\u0010\u001eJ\u000f\u0010\u001f\u001a\u00020\u0016H\u0010¢\u0006\u0004\b\u001f\u0010 J\u000f\u0010!\u001a\u00020\u0003H\u0016¢\u0006\u0004\b!\u0010\"J'\u0010(\u001a\u00020'2\u0006\u0010$\u001a\u00020#2\u0006\u0010%\u001a\u00020\u00162\u0006\u0010&\u001a\u00020\u0016H\u0010¢\u0006\u0004\b(\u0010)J/\u0010-\u001a\u00020,2\u0006\u0010%\u001a\u00020\u00162\u0006\u0010*\u001a\u00020\u00012\u0006\u0010+\u001a\u00020\u00162\u0006\u0010&\u001a\u00020\u0016H\u0016¢\u0006\u0004\b-\u0010.J/\u0010/\u001a\u00020,2\u0006\u0010%\u001a\u00020\u00162\u0006\u0010*\u001a\u00020\u00032\u0006\u0010+\u001a\u00020\u00162\u0006\u0010&\u001a\u00020\u0016H\u0016¢\u0006\u0004\b/\u00100J\u001f\u00102\u001a\u00020\u00162\u0006\u0010*\u001a\u00020\u00032\u0006\u00101\u001a\u00020\u0016H\u0016¢\u0006\u0004\b2\u00103J\u001f\u00104\u001a\u00020\u00162\u0006\u0010*\u001a\u00020\u00032\u0006\u00101\u001a\u00020\u0016H\u0016¢\u0006\u0004\b4\u00103J\u000f\u00105\u001a\u00020\u0003H\u0010¢\u0006\u0004\b5\u0010\"J\u001a\u00107\u001a\u00020,2\b\u0010*\u001a\u0004\u0018\u000106H\u0096\u0002¢\u0006\u0004\b7\u00108J\u000f\u00109\u001a\u00020\u0016H\u0016¢\u0006\u0004\b9\u0010 J\u000f\u0010:\u001a\u00020\u000eH\u0016¢\u0006\u0004\b:\u0010\u0010R \u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00030\u00028\u0000X\u0080\u0004¢\u0006\f\n\u0004\b;\u0010<\u001a\u0004\b=\u0010>R\u001a\u0010\u0006\u001a\u00020\u00058\u0000X\u0080\u0004¢\u0006\f\n\u0004\b?\u0010@\u001a\u0004\bA\u0010B¨\u0006C"}, d2 = {"Lokio/SegmentedByteString;", "Lokio/ByteString;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "segments", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "directory", "<init>", "([[B[I)V", "M", "()Lokio/ByteString;", "Ljava/lang/Object;", "writeReplace", "()Ljava/lang/Object;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "a", "()Ljava/lang/String;", "k", "G", "algorithm", "c", "(Ljava/lang/String;)Lokio/ByteString;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "beginIndex", "endIndex", "D", "(II)Lokio/ByteString;", "pos", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "p", "(I)B", "i", "()I", "L", "()[B", "Lokio/Buffer;", "buffer", "offset", "byteCount", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "I", "(Lokio/Buffer;II)V", "other", "otherOffset", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "u", "(ILokio/ByteString;II)Z", "w", "(I[BII)Z", "fromIndex", "m", "([BI)I", "r", "o", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "equals", "(Ljava/lang/Object;)Z", "hashCode", "toString", "f", "[[B", "K", "()[[B", "g", "[I", "J", "()[I", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class C0004SegmentedByteString extends okio.ByteString {

    /* JADX INFO: renamed from: f, reason: from kotlin metadata */
    private final transient byte[][] segments;

    /* JADX INFO: renamed from: g, reason: from kotlin metadata */
    private final transient int[] directory;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0004SegmentedByteString(byte[][] bArr, int[] iArr) {
        super(okio.ByteString.e.getData());
        kotlin.jvm.internal.Intrinsics.l(bArr, "segments");
        kotlin.jvm.internal.Intrinsics.l(iArr, "directory");
        this.segments = bArr;
        this.directory = iArr;
    }

    private final okio.ByteString M() {
        return new okio.ByteString(L());
    }

    private final java.lang.Object writeReplace() {
        okio.ByteString byteStringM = M();
        kotlin.jvm.internal.Intrinsics.j(byteStringM, "null cannot be cast to non-null type java.lang.Object");
        return byteStringM;
    }

    @Override // okio.ByteString
    public okio.ByteString D(int beginIndex, int endIndex) {
        int iE = okio.SegmentedByteString.e(this, endIndex);
        if (beginIndex < 0) {
            throw new java.lang.IllegalArgumentException(("beginIndex=" + beginIndex + " < 0").toString());
        }
        if (iE > B()) {
            throw new java.lang.IllegalArgumentException(("endIndex=" + iE + " > length(" + B() + ')').toString());
        }
        int i = iE - beginIndex;
        if (i < 0) {
            throw new java.lang.IllegalArgumentException(("endIndex=" + iE + " < beginIndex=" + beginIndex).toString());
        }
        if (beginIndex == 0 && iE == B()) {
            return this;
        }
        if (beginIndex == iE) {
            return okio.ByteString.e;
        }
        int iB = okio.internal.SegmentedByteString.b(this, beginIndex);
        int iB2 = okio.internal.SegmentedByteString.b(this, iE - 1);
        byte[][] bArr = (byte[][]) kotlin.collections.ArraysKt.y(getSegments(), iB, iB2 + 1);
        int[] iArr = new int[bArr.length * 2];
        if (iB <= iB2) {
            int i2 = iB;
            int i5 = 0;
            while (true) {
                iArr[i5] = java.lang.Math.min(getDirectory()[i2] - beginIndex, i);
                int i6 = i5 + 1;
                iArr[i5 + bArr.length] = getDirectory()[getSegments().length + i2];
                if (i2 == iB2) {
                    break;
                }
                i2++;
                i5 = i6;
            }
        }
        int i7 = iB != 0 ? getDirectory()[iB - 1] : 0;
        int length = bArr.length;
        iArr[length] = iArr[length] + (beginIndex - i7);
        return new okio.C0004SegmentedByteString(bArr, iArr);
    }

    @Override // okio.ByteString
    public okio.ByteString G() {
        return M().G();
    }

    @Override // okio.ByteString
    public void I(okio.Buffer buffer, int offset, int byteCount) {
        kotlin.jvm.internal.Intrinsics.l(buffer, "buffer");
        int i = offset + byteCount;
        int iB = okio.internal.SegmentedByteString.b(this, offset);
        while (offset < i) {
            int i2 = iB == 0 ? 0 : getDirectory()[iB - 1];
            int i5 = getDirectory()[iB] - i2;
            int i6 = getDirectory()[getSegments().length + iB];
            int iMin = java.lang.Math.min(i, i5 + i2) - offset;
            int i7 = i6 + (offset - i2);
            okio.Segment segment = new okio.Segment(getSegments()[iB], i7, i7 + iMin, true, false);
            okio.Segment segment2 = buffer.head;
            if (segment2 == null) {
                segment.prev = segment;
                segment.next = segment;
                buffer.head = segment;
            } else {
                kotlin.jvm.internal.Intrinsics.i(segment2);
                okio.Segment segment3 = segment2.prev;
                kotlin.jvm.internal.Intrinsics.i(segment3);
                segment3.c(segment);
            }
            offset += iMin;
            iB++;
        }
        buffer.n0(buffer.getSize() + ((long) byteCount));
    }

    /* JADX INFO: renamed from: J, reason: from getter */
    public final int[] getDirectory() {
        return this.directory;
    }

    /* JADX INFO: renamed from: K, reason: from getter */
    public final byte[][] getSegments() {
        return this.segments;
    }

    public byte[] L() {
        byte[] bArr = new byte[B()];
        int length = getSegments().length;
        int i = 0;
        int i2 = 0;
        int i5 = 0;
        while (i < length) {
            int i6 = getDirectory()[length + i];
            int i7 = getDirectory()[i];
            int i8 = i7 - i2;
            kotlin.collections.ArraysKt.j(getSegments()[i], bArr, i5, i6, i6 + i8);
            i5 += i8;
            i++;
            i2 = i7;
        }
        return bArr;
    }

    @Override // okio.ByteString
    public java.lang.String a() {
        return M().a();
    }

    @Override // okio.ByteString
    public okio.ByteString c(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException {
        kotlin.jvm.internal.Intrinsics.l(algorithm, "algorithm");
        java.security.MessageDigest messageDigest = java.security.MessageDigest.getInstance(algorithm);
        int length = getSegments().length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int i5 = getDirectory()[length + i];
            int i6 = getDirectory()[i];
            messageDigest.update(getSegments()[i], i5, i6 - i2);
            i++;
            i2 = i6;
        }
        byte[] bArrDigest = messageDigest.digest();
        kotlin.jvm.internal.Intrinsics.i(bArrDigest);
        return new okio.ByteString(bArrDigest);
    }

    @Override // okio.ByteString
    public boolean equals(java.lang.Object other) {
        if (other == this) {
            return true;
        }
        if (other instanceof okio.ByteString) {
            okio.ByteString byteString = (okio.ByteString) other;
            if (byteString.B() == B() && u(0, byteString, 0, B())) {
                return true;
            }
        }
        return false;
    }

    @Override // okio.ByteString
    public int hashCode() {
        int hashCode = getHashCode();
        if (hashCode != 0) {
            return hashCode;
        }
        int length = getSegments().length;
        int i = 0;
        int i2 = 1;
        int i5 = 0;
        while (i < length) {
            int i6 = getDirectory()[length + i];
            int i7 = getDirectory()[i];
            byte[] bArr = getSegments()[i];
            int i8 = (i7 - i5) + i6;
            while (i6 < i8) {
                i2 = (i2 * 31) + bArr[i6];
                i6++;
            }
            i++;
            i5 = i7;
        }
        x(i2);
        return i2;
    }

    @Override // okio.ByteString
    public int i() {
        return getDirectory()[getSegments().length - 1];
    }

    @Override // okio.ByteString
    public java.lang.String k() {
        return M().k();
    }

    @Override // okio.ByteString
    public int m(byte[] other, int fromIndex) {
        kotlin.jvm.internal.Intrinsics.l(other, "other");
        return M().m(other, fromIndex);
    }

    @Override // okio.ByteString
    public byte[] o() {
        return L();
    }

    @Override // okio.ByteString
    public byte p(int pos) {
        okio.SegmentedByteString.b(getDirectory()[getSegments().length - 1], pos, 1L);
        int iB = okio.internal.SegmentedByteString.b(this, pos);
        return getSegments()[iB][(pos - (iB == 0 ? 0 : getDirectory()[iB - 1])) + getDirectory()[getSegments().length + iB]];
    }

    @Override // okio.ByteString
    public int r(byte[] other, int fromIndex) {
        kotlin.jvm.internal.Intrinsics.l(other, "other");
        return M().r(other, fromIndex);
    }

    @Override // okio.ByteString
    public java.lang.String toString() {
        return M().toString();
    }

    @Override // okio.ByteString
    public boolean u(int offset, okio.ByteString other, int otherOffset, int byteCount) {
        kotlin.jvm.internal.Intrinsics.l(other, "other");
        if (offset < 0 || offset > B() - byteCount) {
            return false;
        }
        int i = byteCount + offset;
        int iB = okio.internal.SegmentedByteString.b(this, offset);
        while (offset < i) {
            int i2 = iB == 0 ? 0 : getDirectory()[iB - 1];
            int i5 = getDirectory()[iB] - i2;
            int i6 = getDirectory()[getSegments().length + iB];
            int iMin = java.lang.Math.min(i, i5 + i2) - offset;
            if (!other.w(otherOffset, getSegments()[iB], i6 + (offset - i2), iMin)) {
                return false;
            }
            otherOffset += iMin;
            offset += iMin;
            iB++;
        }
        return true;
    }

    @Override // okio.ByteString
    public boolean w(int offset, byte[] other, int otherOffset, int byteCount) {
        kotlin.jvm.internal.Intrinsics.l(other, "other");
        if (offset < 0 || offset > B() - byteCount || otherOffset < 0 || otherOffset > other.length - byteCount) {
            return false;
        }
        int i = byteCount + offset;
        int iB = okio.internal.SegmentedByteString.b(this, offset);
        while (offset < i) {
            int i2 = iB == 0 ? 0 : getDirectory()[iB - 1];
            int i5 = getDirectory()[iB] - i2;
            int i6 = getDirectory()[getSegments().length + iB];
            int iMin = java.lang.Math.min(i, i5 + i2) - offset;
            if (!okio.SegmentedByteString.a(getSegments()[iB], i6 + (offset - i2), other, otherOffset, iMin)) {
                return false;
            }
            otherOffset += iMin;
            offset += iMin;
            iB++;
        }
        return true;
    }
}
