package z4;

import java.util.Iterator;
import java.util.NoSuchElementException;
import r4.AbstractC0983h;
import s4.InterfaceC1015a;

/* JADX INFO: loaded from: classes.dex */
public final class c implements Iterator, InterfaceC1015a {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ int f11092k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final Iterator f11093l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public Object f11095n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final /* synthetic */ h f11096o;

    public c(d dVar) {
        this.f11092k = 0;
        this.f11096o = dVar;
        this.f11093l = dVar.f11097a.iterator();
        this.f11094m = -1;
    }

    public void a() {
        Object next;
        d dVar;
        do {
            Iterator it = this.f11093l;
            if (!it.hasNext()) {
                this.f11094m = 0;
                return;
            } else {
                next = it.next();
                dVar = (d) this.f11096o;
            }
        } while (((Boolean) dVar.f11099c.invoke(next)).booleanValue() != dVar.f11098b);
        this.f11095n = next;
        this.f11094m = 1;
    }

    public boolean b() {
        Iterator it;
        Iterator it2 = (Iterator) this.f11095n;
        if (it2 != null && it2.hasNext()) {
            this.f11094m = 1;
            return true;
        }
        do {
            Iterator it3 = this.f11093l;
            if (!it3.hasNext()) {
                this.f11094m = 2;
                this.f11095n = null;
                return false;
            }
            Object next = it3.next();
            e eVar = (e) this.f11096o;
            it = (Iterator) eVar.f11102c.invoke(eVar.f11101b.invoke(next));
        } while (!it.hasNext());
        this.f11095n = it;
        this.f11094m = 1;
        return true;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        switch (this.f11092k) {
            case 0:
                if (this.f11094m == -1) {
                    a();
                }
                return this.f11094m == 1;
            default:
                int i = this.f11094m;
                if (i == 1) {
                    return true;
                }
                if (i == 2) {
                    return false;
                }
                return b();
        }
    }

    @Override // java.util.Iterator
    public final Object next() {
        switch (this.f11092k) {
            case 0:
                if (this.f11094m == -1) {
                    a();
                }
                if (this.f11094m == 0) {
                    throw new NoSuchElementException();
                }
                Object obj = this.f11095n;
                this.f11095n = null;
                this.f11094m = -1;
                return obj;
            default:
                int i = this.f11094m;
                if (i == 2) {
                    throw new NoSuchElementException();
                }
                if (i == 0 && !b()) {
                    throw new NoSuchElementException();
                }
                this.f11094m = 0;
                Iterator it = (Iterator) this.f11095n;
                AbstractC0983h.b(it);
                return it.next();
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.f11092k) {
            case 0:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            default:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
        }
    }

    public c(e eVar) {
        this.f11092k = 1;
        this.f11096o = eVar;
        this.f11093l = eVar.f11100a.iterator();
    }
}
