package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Gf, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC0161Gf implements Iterable, Serializable {
    public static final C0109Ef m = new C0109Ef(AbstractC2418sI.b);
    public static final C0688a6 n;
    private static final long serialVersionUID = 1;
    public int l;

    static {
        n = M2.a() ? new C0688a6(6) : new C0688a6(5);
    }

    public static int b(int i, int i2, int i3) {
        int i4 = i2 - i;
        if ((i | i2 | i4 | (i3 - i2)) >= 0) {
            return i4;
        }
        if (i < 0) {
            throw new IndexOutOfBoundsException(AbstractC0126Ew.k(i, "Beginning index: ", " < 0"));
        }
        if (i2 < i) {
            throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "Beginning index larger than ending index: ", ", "));
        }
        throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i2, i3, "End index: ", " >= "));
    }

    public static C0109Ef c(byte[] bArr, int i, int i2) {
        byte[] bArrCopyOfRange;
        b(i, i + i2, bArr.length);
        switch (n.l) {
            case 5:
                bArrCopyOfRange = Arrays.copyOfRange(bArr, i, i2 + i);
                break;
            default:
                bArrCopyOfRange = new byte[i2];
                System.arraycopy(bArr, i, bArrCopyOfRange, 0, i2);
                break;
        }
        return new C0109Ef(bArrCopyOfRange);
    }

    public abstract byte a(int i);

    public abstract void d(int i, byte[] bArr);

    public abstract byte e(int i);

    public final int hashCode() {
        int i = this.l;
        if (i != 0) {
            return i;
        }
        int size = size();
        C0109Ef c0109Ef = (C0109Ef) this;
        int iF = c0109Ef.f();
        int i2 = size;
        for (int i3 = iF; i3 < iF + size; i3++) {
            i2 = (i2 * 31) + c0109Ef.f106o[i3];
        }
        if (i2 == 0) {
            i2 = 1;
        }
        this.l = i2;
        return i2;
    }

    public abstract int size();

    public final String toString() {
        String string;
        Locale locale = Locale.ROOT;
        String hexString = Integer.toHexString(System.identityHashCode(this));
        int size = size();
        if (size() <= 50) {
            string = Co0.o(this);
        } else {
            StringBuilder sb = new StringBuilder();
            C0109Ef c0109Ef = (C0109Ef) this;
            int iB = b(0, 47, c0109Ef.size());
            sb.append(Co0.o(iB == 0 ? m : new C0057Cf(c0109Ef.f106o, c0109Ef.f(), iB)));
            sb.append("...");
            string = sb.toString();
        }
        StringBuilder sb2 = new StringBuilder("<ByteString@");
        sb2.append(hexString);
        sb2.append(" size=");
        sb2.append(size);
        sb2.append(" contents=\"");
        return AbstractC2462sn.n(sb2, string, "\">");
    }
}
