package androidx.datastore.preferences.protobuf;

import java.util.Arrays;

/* JADX INFO: loaded from: classes.dex */
public final class h1 {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final h1 f2075f = new h1(0, new int[0], new Object[0], false);

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int[] f2077b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object[] f2078c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f2079d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f2080e;

    public h1(int i10, int[] iArr, Object[] objArr, boolean z10) {
        this.f2076a = i10;
        this.f2077b = iArr;
        this.f2078c = objArr;
        this.f2080e = z10;
    }

    public final void a(int i10) {
        int[] iArr = this.f2077b;
        if (i10 > iArr.length) {
            int i11 = this.f2076a;
            int i12 = (i11 / 2) + i11;
            if (i12 >= i10) {
                i10 = i12;
            }
            if (i10 < 8) {
                i10 = 8;
            }
            this.f2077b = Arrays.copyOf(iArr, i10);
            this.f2078c = Arrays.copyOf(this.f2078c, i10);
        }
    }

    public final int b() {
        int iB;
        int i10 = this.f2079d;
        if (i10 != -1) {
            return i10;
        }
        int iB2 = 0;
        for (int i11 = 0; i11 < this.f2076a; i11++) {
            int i12 = this.f2077b[i11];
            int i13 = i12 >>> 3;
            int i14 = i12 & 7;
            if (i14 == 0) {
                iB = n.B(i13, ((Long) this.f2078c[i11]).longValue());
            } else if (i14 == 1) {
                ((Long) this.f2078c[i11]).longValue();
                iB = n.n(i13);
            } else if (i14 == 2) {
                iB = n.j(i13, (ByteString) this.f2078c[i11]);
            } else if (i14 == 3) {
                iB2 = ((h1) this.f2078c[i11]).b() + (n.y(i13) * 2) + iB2;
            } else {
                if (i14 != 5) {
                    throw new IllegalStateException(InvalidProtocolBufferException.c());
                }
                ((Integer) this.f2078c[i11]).intValue();
                iB = n.m(i13);
            }
            iB2 = iB + iB2;
        }
        this.f2079d = iB2;
        return iB2;
    }

    public final void c(int i10, Object obj) {
        if (!this.f2080e) {
            throw new UnsupportedOperationException();
        }
        a(this.f2076a + 1);
        int[] iArr = this.f2077b;
        int i11 = this.f2076a;
        iArr[i11] = i10;
        this.f2078c[i11] = obj;
        this.f2076a = i11 + 1;
    }

    public final void d(xyz.stream.utils.j0 j0Var) {
        if (this.f2076a == 0) {
            return;
        }
        j0Var.getClass();
        for (int i10 = 0; i10 < this.f2076a; i10++) {
            int i11 = this.f2077b[i10];
            Object obj = this.f2078c[i10];
            int i12 = i11 >>> 3;
            int i13 = i11 & 7;
            if (i13 == 0) {
                j0Var.Q(i12, ((Long) obj).longValue());
            } else if (i13 == 1) {
                j0Var.F(i12, ((Long) obj).longValue());
            } else if (i13 == 2) {
                j0Var.t(i12, (ByteString) obj);
            } else if (i13 == 3) {
                int i14 = j0Var.f36153a;
                switch (i14) {
                    case 6:
                        ((n) j0Var.f36154b).T(i12, 3);
                        break;
                    default:
                        ((com.google.crypto.tink.shaded.protobuf.n) j0Var.f36154b).D0(i12, 3);
                        break;
                }
                ((h1) obj).d(j0Var);
                switch (i14) {
                    case 6:
                        ((n) j0Var.f36154b).T(i12, 4);
                        break;
                    default:
                        ((com.google.crypto.tink.shaded.protobuf.n) j0Var.f36154b).D0(i12, 4);
                        break;
                }
            } else {
                if (i13 != 5) {
                    throw new RuntimeException(InvalidProtocolBufferException.c());
                }
                j0Var.C(i12, ((Integer) obj).intValue());
            }
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof h1)) {
            return false;
        }
        h1 h1Var = (h1) obj;
        int i10 = this.f2076a;
        if (i10 == h1Var.f2076a) {
            int[] iArr = this.f2077b;
            int[] iArr2 = h1Var.f2077b;
            int i11 = 0;
            while (true) {
                if (i11 >= i10) {
                    Object[] objArr = this.f2078c;
                    Object[] objArr2 = h1Var.f2078c;
                    int i12 = this.f2076a;
                    for (int i13 = 0; i13 < i12; i13++) {
                        if (objArr[i13].equals(objArr2[i13])) {
                        }
                    }
                    return true;
                }
                if (iArr[i11] != iArr2[i11]) {
                    break;
                }
                i11++;
            }
        }
        return false;
    }

    public final int hashCode() {
        int i10 = this.f2076a;
        int i11 = (527 + i10) * 31;
        int[] iArr = this.f2077b;
        int iHashCode = 17;
        int i12 = 17;
        for (int i13 = 0; i13 < i10; i13++) {
            i12 = (i12 * 31) + iArr[i13];
        }
        int i14 = (i11 + i12) * 31;
        Object[] objArr = this.f2078c;
        int i15 = this.f2076a;
        for (int i16 = 0; i16 < i15; i16++) {
            iHashCode = (iHashCode * 31) + objArr[i16].hashCode();
        }
        return i14 + iHashCode;
    }
}
