package com.google.crypto.tink.shaded.protobuf;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Locale;

/* JADX INFO: renamed from: com.google.crypto.tink.shaded.protobuf.i, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC1261i implements Iterable, Serializable {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final C1260h f13790b = new C1260h(A.f13715b);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final C1258f f13791c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f13792a;

    static {
        f13791c = AbstractC1255c.a() ? new C1258f(1) : new C1258f(0);
    }

    public static int g(int i6, int i7, int i8) {
        int i9 = i7 - i6;
        if ((i6 | i7 | i9 | (i8 - i7)) >= 0) {
            return i9;
        }
        if (i6 < 0) {
            throw new IndexOutOfBoundsException(Z0.o.j(i6, "Beginning index: ", " < 0"));
        }
        if (i7 < i6) {
            throw new IndexOutOfBoundsException(com.google.android.recaptcha.internal.a.i(i6, i7, "Beginning index larger than ending index: ", ", "));
        }
        throw new IndexOutOfBoundsException(com.google.android.recaptcha.internal.a.i(i7, i8, "End index: ", " >= "));
    }

    public static C1260h h(byte[] bArr, int i6, int i7) {
        byte[] bArrCopyOfRange;
        g(i6, i6 + i7, bArr.length);
        switch (f13791c.f13779a) {
            case 0:
                bArrCopyOfRange = Arrays.copyOfRange(bArr, i6, i7 + i6);
                break;
            default:
                bArrCopyOfRange = new byte[i7];
                System.arraycopy(bArr, i6, bArrCopyOfRange, 0, i7);
                break;
        }
        return new C1260h(bArrCopyOfRange);
    }

    public abstract byte e(int i6);

    public final int hashCode() {
        int i6 = this.f13792a;
        if (i6 != 0) {
            return i6;
        }
        int size = size();
        C1260h c1260h = (C1260h) this;
        int iL = c1260h.l();
        int i7 = size;
        for (int i8 = iL; i8 < iL + size; i8++) {
            i7 = (i7 * 31) + c1260h.f13788d[i8];
        }
        if (i7 == 0) {
            i7 = 1;
        }
        this.f13792a = i7;
        return i7;
    }

    public abstract void j(byte[] bArr, int i6);

    public final byte[] k() {
        int size = size();
        if (size == 0) {
            return A.f13715b;
        }
        byte[] bArr = new byte[size];
        j(bArr, size);
        return bArr;
    }

    public abstract int size();

    public final String toString() {
        C1260h c1259g;
        String string;
        Locale locale = Locale.ROOT;
        String hexString = Integer.toHexString(System.identityHashCode(this));
        int size = size();
        if (size() <= 50) {
            string = W0.e.n(this);
        } else {
            StringBuilder sb = new StringBuilder();
            C1260h c1260h = (C1260h) this;
            int iG = g(0, 47, c1260h.size());
            if (iG == 0) {
                c1259g = f13790b;
            } else {
                c1259g = new C1259g(c1260h.f13788d, c1260h.l(), iG);
            }
            sb.append(W0.e.n(c1259g));
            sb.append("...");
            string = sb.toString();
        }
        return com.google.android.recaptcha.internal.a.n(Z0.o.s(size, "<ByteString@", hexString, " size=", " contents=\""), string, "\">");
    }
}
