package com.google.android.gms.internal.play_billing;

import Z0.o;
import java.util.Arrays;

/* JADX INFO: loaded from: classes3.dex */
public final class zzhi {
    private static final zzhi zza = new zzhi(0, new int[0], new Object[0], false);
    private int zzb;
    private int[] zzc;
    private Object[] zzd;
    private int zze;
    private boolean zzf;

    private zzhi(int i6, int[] iArr, Object[] objArr, boolean z6) {
        this.zze = -1;
        this.zzb = i6;
        this.zzc = iArr;
        this.zzd = objArr;
        this.zzf = z6;
    }

    public static zzhi zzc() {
        return zza;
    }

    public static zzhi zze(zzhi zzhiVar, zzhi zzhiVar2) {
        int i6 = zzhiVar.zzb + zzhiVar2.zzb;
        int[] iArrCopyOf = Arrays.copyOf(zzhiVar.zzc, i6);
        System.arraycopy(zzhiVar2.zzc, 0, iArrCopyOf, zzhiVar.zzb, zzhiVar2.zzb);
        Object[] objArrCopyOf = Arrays.copyOf(zzhiVar.zzd, i6);
        System.arraycopy(zzhiVar2.zzd, 0, objArrCopyOf, zzhiVar.zzb, zzhiVar2.zzb);
        return new zzhi(i6, iArrCopyOf, objArrCopyOf, true);
    }

    public static zzhi zzf() {
        return new zzhi(0, new int[8], new Object[8], true);
    }

    private final void zzm(int i6) {
        int[] iArr = this.zzc;
        if (i6 > iArr.length) {
            int i7 = this.zzb;
            int i8 = (i7 / 2) + i7;
            if (i8 >= i6) {
                i6 = i8;
            }
            if (i6 < 8) {
                i6 = 8;
            }
            this.zzc = Arrays.copyOf(iArr, i6);
            this.zzd = Arrays.copyOf(this.zzd, i6);
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof zzhi)) {
            return false;
        }
        zzhi zzhiVar = (zzhi) obj;
        int i6 = this.zzb;
        if (i6 == zzhiVar.zzb) {
            int[] iArr = this.zzc;
            int[] iArr2 = zzhiVar.zzc;
            int i7 = 0;
            while (true) {
                if (i7 >= i6) {
                    Object[] objArr = this.zzd;
                    Object[] objArr2 = zzhiVar.zzd;
                    int i8 = this.zzb;
                    for (int i9 = 0; i9 < i8; i9++) {
                        if (objArr[i9].equals(objArr2[i9])) {
                        }
                    }
                    return true;
                }
                if (iArr[i7] != iArr2[i7]) {
                    break;
                }
                i7++;
            }
        }
        return false;
    }

    public final int hashCode() {
        int i6 = this.zzb;
        int i7 = i6 + 527;
        int[] iArr = this.zzc;
        int iHashCode = 17;
        int i8 = 17;
        for (int i9 = 0; i9 < i6; i9++) {
            i8 = (i8 * 31) + iArr[i9];
        }
        int i10 = ((i7 * 31) + i8) * 31;
        Object[] objArr = this.zzd;
        int i11 = this.zzb;
        for (int i12 = 0; i12 < i11; i12++) {
            iHashCode = (iHashCode * 31) + objArr[i12].hashCode();
        }
        return i10 + iHashCode;
    }

    public final int zza() {
        int iZzC;
        int iZzD;
        int iZzC2;
        int i6 = this.zze;
        if (i6 != -1) {
            return i6;
        }
        int iZzC3 = 0;
        for (int i7 = 0; i7 < this.zzb; i7++) {
            int i8 = this.zzc[i7];
            int i9 = i8 >>> 3;
            int i10 = i8 & 7;
            if (i10 != 0) {
                if (i10 == 1) {
                    ((Long) this.zzd[i7]).getClass();
                    iZzC2 = zzep.zzC(i9 << 3) + 8;
                } else if (i10 == 2) {
                    int i11 = i9 << 3;
                    zzei zzeiVar = (zzei) this.zzd[i7];
                    int iZzC4 = zzep.zzC(i11);
                    int iZzd = zzeiVar.zzd();
                    iZzC3 = zzep.zzC(iZzd) + iZzd + iZzC4 + iZzC3;
                } else if (i10 == 3) {
                    int iZzC5 = zzep.zzC(i9 << 3);
                    iZzC = iZzC5 + iZzC5;
                    iZzD = ((zzhi) this.zzd[i7]).zza();
                } else {
                    if (i10 != 5) {
                        throw new IllegalStateException(new zzfp("Protocol message tag had invalid wire type."));
                    }
                    ((Integer) this.zzd[i7]).getClass();
                    iZzC2 = zzep.zzC(i9 << 3) + 4;
                }
                iZzC3 = iZzC2 + iZzC3;
            } else {
                int i12 = i9 << 3;
                long jLongValue = ((Long) this.zzd[i7]).longValue();
                iZzC = zzep.zzC(i12);
                iZzD = zzep.zzD(jLongValue);
            }
            iZzC3 = iZzD + iZzC + iZzC3;
        }
        this.zze = iZzC3;
        return iZzC3;
    }

    public final int zzb() {
        int i6 = this.zze;
        if (i6 != -1) {
            return i6;
        }
        int iZ = 0;
        for (int i7 = 0; i7 < this.zzb; i7++) {
            int i8 = this.zzc[i7] >>> 3;
            zzei zzeiVar = (zzei) this.zzd[i7];
            int iZzC = zzep.zzC(8);
            int iZzC2 = zzep.zzC(i8) + zzep.zzC(16);
            int iZzC3 = zzep.zzC(24);
            int iZzd = zzeiVar.zzd();
            iZ += iZzC + iZzC + iZzC2 + o.z(iZzd, iZzd, iZzC3);
        }
        this.zze = iZ;
        return iZ;
    }

    public final zzhi zzd(zzhi zzhiVar) {
        if (zzhiVar.equals(zza)) {
            return this;
        }
        zzg();
        int i6 = this.zzb + zzhiVar.zzb;
        zzm(i6);
        System.arraycopy(zzhiVar.zzc, 0, this.zzc, this.zzb, zzhiVar.zzb);
        System.arraycopy(zzhiVar.zzd, 0, this.zzd, this.zzb, zzhiVar.zzb);
        this.zzb = i6;
        return this;
    }

    public final void zzg() {
        if (!this.zzf) {
            throw new UnsupportedOperationException();
        }
    }

    public final void zzh() {
        if (this.zzf) {
            this.zzf = false;
        }
    }

    public final void zzi(StringBuilder sb, int i6) {
        for (int i7 = 0; i7 < this.zzb; i7++) {
            zzgn.zzb(sb, i6, String.valueOf(this.zzc[i7] >>> 3), this.zzd[i7]);
        }
    }

    public final void zzj(int i6, Object obj) {
        zzg();
        zzm(this.zzb + 1);
        int[] iArr = this.zzc;
        int i7 = this.zzb;
        iArr[i7] = i6;
        this.zzd[i7] = obj;
        this.zzb = i7 + 1;
    }

    public final void zzk(zzhu zzhuVar) {
        for (int i6 = 0; i6 < this.zzb; i6++) {
            zzhuVar.zzw(this.zzc[i6] >>> 3, this.zzd[i6]);
        }
    }

    public final void zzl(zzhu zzhuVar) {
        if (this.zzb != 0) {
            for (int i6 = 0; i6 < this.zzb; i6++) {
                int i7 = this.zzc[i6];
                Object obj = this.zzd[i6];
                int i8 = i7 & 7;
                int i9 = i7 >>> 3;
                if (i8 == 0) {
                    zzhuVar.zzt(i9, ((Long) obj).longValue());
                } else if (i8 == 1) {
                    zzhuVar.zzm(i9, ((Long) obj).longValue());
                } else if (i8 == 2) {
                    zzhuVar.zzd(i9, (zzei) obj);
                } else if (i8 == 3) {
                    zzhuVar.zzF(i9);
                    ((zzhi) obj).zzl(zzhuVar);
                    zzhuVar.zzh(i9);
                } else {
                    if (i8 != 5) {
                        throw new RuntimeException(new zzfp("Protocol message tag had invalid wire type."));
                    }
                    zzhuVar.zzk(i9, ((Integer) obj).intValue());
                }
            }
        }
    }

    private zzhi() {
        this(0, new int[8], new Object[8], true);
    }
}
