package o;

import java.util.Iterator;
import java.util.NoSuchElementException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public abstract class CW implements Iterator, InterfaceC2989yJ {
    public final AbstractC0833bh0[] l;
    public int m;
    public boolean n = true;

    public CW(C0737ah0 c0737ah0, AbstractC0833bh0[] abstractC0833bh0Arr) {
        this.l = abstractC0833bh0Arr;
        abstractC0833bh0Arr[0].a(c0737ah0.d, Integer.bitCount(c0737ah0.a) * 2, 0);
        this.m = 0;
        a();
    }

    public final void a() {
        int i = this.m;
        AbstractC0833bh0[] abstractC0833bh0Arr = this.l;
        AbstractC0833bh0 abstractC0833bh0 = abstractC0833bh0Arr[i];
        if (abstractC0833bh0.n < abstractC0833bh0.m) {
            return;
        }
        while (-1 < i) {
            int iB = b(i);
            if (iB == -1) {
                AbstractC0833bh0 abstractC0833bh02 = abstractC0833bh0Arr[i];
                int i2 = abstractC0833bh02.n;
                Object[] objArr = abstractC0833bh02.l;
                if (i2 < objArr.length) {
                    int length = objArr.length;
                    abstractC0833bh02.n = i2 + 1;
                    iB = b(i);
                }
            }
            if (iB != -1) {
                this.m = iB;
                return;
            }
            if (i > 0) {
                AbstractC0833bh0 abstractC0833bh03 = abstractC0833bh0Arr[i - 1];
                int i3 = abstractC0833bh03.n;
                int length2 = abstractC0833bh03.l.length;
                abstractC0833bh03.n = i3 + 1;
            }
            abstractC0833bh0Arr[i].a(C0737ah0.e.d, 0, 0);
            i--;
        }
        this.n = false;
    }

    public final int b(int i) {
        AbstractC0833bh0[] abstractC0833bh0Arr = this.l;
        AbstractC0833bh0 abstractC0833bh0 = abstractC0833bh0Arr[i];
        int i2 = abstractC0833bh0.n;
        if (i2 < abstractC0833bh0.m) {
            return i;
        }
        Object[] objArr = abstractC0833bh0.l;
        if (i2 >= objArr.length) {
            return -1;
        }
        int length = objArr.length;
        C0737ah0 c0737ah0 = (C0737ah0) objArr[i2];
        if (i == 6) {
            AbstractC0833bh0 abstractC0833bh02 = abstractC0833bh0Arr[i + 1];
            Object[] objArr2 = c0737ah0.d;
            abstractC0833bh02.a(objArr2, objArr2.length, 0);
        } else {
            abstractC0833bh0Arr[i + 1].a(c0737ah0.d, Integer.bitCount(c0737ah0.a) * 2, 0);
        }
        return b(i + 1);
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        return this.n;
    }

    @Override // java.util.Iterator
    public Object next() {
        if (!this.n) {
            throw new NoSuchElementException();
        }
        Object next = this.l[this.m].next();
        a();
        return next;
    }

    @Override // java.util.Iterator
    public void remove() {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }
}
