package N1;

import androidx.recyclerview.widget.RecyclerView;
import java.util.Arrays;

/* JADX INFO: renamed from: N1.z, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0224z {

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

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

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

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

    public C0224z() {
        int iHighestOneBit = Integer.bitCount(8) != 1 ? Integer.highestOneBit(7) << 1 : 8;
        this.f4728d = iHighestOneBit - 1;
        this.f4725a = new int[iHighestOneBit];
    }

    public void a(int i) {
        int[] iArr = this.f4725a;
        int i5 = this.f4727c;
        iArr[i5] = i;
        int i8 = this.f4728d & (i5 + 1);
        this.f4727c = i8;
        int i9 = this.f4726b;
        if (i8 == i9) {
            int length = iArr.length;
            int i10 = length - i9;
            int i11 = length << 1;
            if (i11 < 0) {
                throw new RuntimeException("Max array capacity exceeded");
            }
            int[] iArr2 = new int[i11];
            B6.j.G(0, i9, length, iArr, iArr2);
            B6.j.G(i10, 0, this.f4726b, this.f4725a, iArr2);
            this.f4725a = iArr2;
            this.f4726b = 0;
            this.f4727c = length;
            this.f4728d = i11 - 1;
        }
    }

    public void b(int i, int i5) {
        if (i < 0) {
            throw new IllegalArgumentException("Layout positions must be non-negative");
        }
        if (i5 < 0) {
            throw new IllegalArgumentException("Pixel distance must be non-negative");
        }
        int i8 = this.f4728d;
        int i9 = i8 * 2;
        int[] iArr = this.f4725a;
        if (iArr == null) {
            int[] iArr2 = new int[4];
            this.f4725a = iArr2;
            Arrays.fill(iArr2, -1);
        } else if (i9 >= iArr.length) {
            int[] iArr3 = new int[i8 * 4];
            this.f4725a = iArr3;
            System.arraycopy(iArr, 0, iArr3, 0, iArr.length);
        }
        int[] iArr4 = this.f4725a;
        iArr4[i9] = i;
        iArr4[i9 + 1] = i5;
        this.f4728d++;
    }

    public void c(RecyclerView recyclerView, boolean z8) {
        this.f4728d = 0;
        int[] iArr = this.f4725a;
        if (iArr != null) {
            Arrays.fill(iArr, -1);
        }
        androidx.recyclerview.widget.a aVar = recyclerView.D;
        if (recyclerView.f9019C == null || aVar == null || !aVar.f9122y) {
            return;
        }
        if (z8) {
            if (!recyclerView.f9078u.m()) {
                aVar.u(recyclerView.f9019C.a(), this);
            }
        } else if (!recyclerView.P()) {
            aVar.t(this.f4726b, this.f4727c, recyclerView.f9087y0, this);
        }
        int i = this.f4728d;
        if (i > aVar.f9123z) {
            aVar.f9123z = i;
            aVar.f9110A = z8;
            recyclerView.f9074s.n();
        }
    }

    public int d(int i) {
        if (i < 0 || i >= e()) {
            throw new ArrayIndexOutOfBoundsException();
        }
        return this.f4725a[this.f4728d & (this.f4726b + i)];
    }

    public int e() {
        return (this.f4727c - this.f4726b) & this.f4728d;
    }
}
