package com.google.protobuf;

import java.nio.charset.Charset;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/* JADX INFO: renamed from: com.google.protobuf.h, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C1308h extends AbstractC1300d implements Q, RandomAccess, C0 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final C1308h f14274d = new C1308h(new boolean[0], 0, false);

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

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

    public C1308h(boolean[] zArr, int i6, boolean z6) {
        super(z6);
        this.f14275b = zArr;
        this.f14276c = i6;
    }

    @Override // com.google.protobuf.Y
    public final Y a(int i6) {
        if (i6 >= this.f14276c) {
            return new C1308h(Arrays.copyOf(this.f14275b, i6), this.f14276c, true);
        }
        throw new IllegalArgumentException();
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i6, Object obj) {
        int i7;
        boolean zBooleanValue = ((Boolean) obj).booleanValue();
        e();
        if (i6 < 0 || i6 > (i7 = this.f14276c)) {
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
            sbR.append(this.f14276c);
            throw new IndexOutOfBoundsException(sbR.toString());
        }
        boolean[] zArr = this.f14275b;
        if (i7 < zArr.length) {
            System.arraycopy(zArr, i6, zArr, i6 + 1, i7 - i6);
        } else {
            boolean[] zArr2 = new boolean[Z0.o.A(i7, 3, 2, 1)];
            System.arraycopy(zArr, 0, zArr2, 0, i6);
            System.arraycopy(this.f14275b, i6, zArr2, i6 + 1, this.f14276c - i6);
            this.f14275b = zArr2;
        }
        this.f14275b[i6] = zBooleanValue;
        this.f14276c++;
        ((AbstractList) this).modCount++;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        e();
        Charset charset = Z.f14234a;
        collection.getClass();
        if (!(collection instanceof C1308h)) {
            return super.addAll(collection);
        }
        C1308h c1308h = (C1308h) collection;
        int i6 = c1308h.f14276c;
        if (i6 == 0) {
            return false;
        }
        int i7 = this.f14276c;
        if (Integer.MAX_VALUE - i7 < i6) {
            throw new OutOfMemoryError();
        }
        int i8 = i7 + i6;
        boolean[] zArr = this.f14275b;
        if (i8 > zArr.length) {
            this.f14275b = Arrays.copyOf(zArr, i8);
        }
        System.arraycopy(c1308h.f14275b, 0, this.f14275b, this.f14276c, c1308h.f14276c);
        this.f14276c = i8;
        ((AbstractList) this).modCount++;
        return true;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean contains(Object obj) {
        return indexOf(obj) != -1;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C1308h)) {
            return super.equals(obj);
        }
        C1308h c1308h = (C1308h) obj;
        if (this.f14276c != c1308h.f14276c) {
            return false;
        }
        boolean[] zArr = c1308h.f14275b;
        for (int i6 = 0; i6 < this.f14276c; i6++) {
            if (this.f14275b[i6] != zArr[i6]) {
                return false;
            }
        }
        return true;
    }

    public final void g(boolean z6) {
        e();
        int i6 = this.f14276c;
        boolean[] zArr = this.f14275b;
        if (i6 == zArr.length) {
            boolean[] zArr2 = new boolean[Z0.o.A(i6, 3, 2, 1)];
            System.arraycopy(zArr, 0, zArr2, 0, i6);
            this.f14275b = zArr2;
        }
        boolean[] zArr3 = this.f14275b;
        int i7 = this.f14276c;
        this.f14276c = i7 + 1;
        zArr3[i7] = z6;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object get(int i6) {
        h(i6);
        return Boolean.valueOf(this.f14275b[i6]);
    }

    public final void h(int i6) {
        if (i6 < 0 || i6 >= this.f14276c) {
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
            sbR.append(this.f14276c);
            throw new IndexOutOfBoundsException(sbR.toString());
        }
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int i6 = 1;
        for (int i7 = 0; i7 < this.f14276c; i7++) {
            int i8 = i6 * 31;
            boolean z6 = this.f14275b[i7];
            Charset charset = Z.f14234a;
            i6 = i8 + (z6 ? 1231 : 1237);
        }
        return i6;
    }

    @Override // java.util.AbstractList, java.util.List
    public final int indexOf(Object obj) {
        if (!(obj instanceof Boolean)) {
            return -1;
        }
        boolean zBooleanValue = ((Boolean) obj).booleanValue();
        int i6 = this.f14276c;
        for (int i7 = 0; i7 < i6; i7++) {
            if (this.f14275b[i7] == zBooleanValue) {
                return i7;
            }
        }
        return -1;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.List
    public final Object remove(int i6) {
        e();
        h(i6);
        boolean[] zArr = this.f14275b;
        boolean z6 = zArr[i6];
        if (i6 < this.f14276c - 1) {
            System.arraycopy(zArr, i6 + 1, zArr, i6, (r2 - i6) - 1);
        }
        this.f14276c--;
        ((AbstractList) this).modCount++;
        return Boolean.valueOf(z6);
    }

    @Override // java.util.AbstractList
    public final void removeRange(int i6, int i7) {
        e();
        if (i7 < i6) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        boolean[] zArr = this.f14275b;
        System.arraycopy(zArr, i7, zArr, i6, this.f14276c - i7);
        this.f14276c -= i7 - i6;
        ((AbstractList) this).modCount++;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i6, Object obj) {
        boolean zBooleanValue = ((Boolean) obj).booleanValue();
        e();
        h(i6);
        boolean[] zArr = this.f14275b;
        boolean z6 = zArr[i6];
        zArr[i6] = zBooleanValue;
        return Boolean.valueOf(z6);
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final int size() {
        return this.f14276c;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean add(Object obj) {
        g(((Boolean) obj).booleanValue());
        return true;
    }
}
