package rp;

import java.util.Iterator;
import java.util.NoSuchElementException;
import kotlin.jvm.internal.t;

/* loaded from: classes3.dex */
public final class f implements h {

    /* renamed from: a, reason: collision with root package name */
    private final h f35050a;

    /* renamed from: b, reason: collision with root package name */
    private final dn.l f35051b;

    /* renamed from: c, reason: collision with root package name */
    private final dn.l f35052c;

    /* loaded from: classes3.dex */
    public static final class a implements Iterator, en.a {

        /* renamed from: p, reason: collision with root package name */
        private final Iterator f35053p;

        /* renamed from: q, reason: collision with root package name */
        private Iterator f35054q;

        a() {
            this.f35053p = f.this.f35050a.iterator();
        }

        /* JADX WARN: Code restructure failed: missing block: B:17:0x0045, code lost:
        
            return true;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        private final boolean a() {
            Iterator it = this.f35054q;
            if ((it == null || it.hasNext()) ? false : true) {
                this.f35054q = null;
            }
            while (true) {
                if (this.f35054q != null) {
                    break;
                }
                if (!this.f35053p.hasNext()) {
                    return false;
                }
                Iterator it2 = (Iterator) f.this.f35052c.invoke(f.this.f35051b.invoke(this.f35053p.next()));
                if (it2.hasNext()) {
                    this.f35054q = it2;
                    break;
                }
            }
        }

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

        @Override // java.util.Iterator
        public Object next() {
            if (!a()) {
                throw new NoSuchElementException();
            }
            Iterator it = this.f35054q;
            t.d(it);
            return it.next();
        }

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

    public f(h sequence, dn.l transformer, dn.l iterator) {
        t.g(sequence, "sequence");
        t.g(transformer, "transformer");
        t.g(iterator, "iterator");
        this.f35050a = sequence;
        this.f35051b = transformer;
        this.f35052c = iterator;
    }

    @Override // rp.h
    public Iterator iterator() {
        return new a();
    }
}
