package P2;

import C4.j;
import J4.f;
import P4.g;
import V4.C;
import V4.E;
import V4.H;
import V4.N;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import m3.AbstractC2467b;
import w4.C3137A;
import x4.AbstractC3226C;
import x4.AbstractC3253s;
import x4.y;

/* JADX INFO: loaded from: classes.dex */
public final class b extends j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Iterator f5644a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public /* synthetic */ Object f5646c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ List f5647d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ j f5649f;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public b(List list, int i6, f fVar, A4.d dVar) {
        super(2, dVar);
        this.f5647d = list;
        this.f5648e = i6;
        this.f5649f = (j) fVar;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [C4.j, J4.f] */
    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        b bVar = new b(this.f5647d, this.f5648e, this.f5649f, dVar);
        bVar.f5646c = obj;
        return bVar;
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((b) create((C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Type inference failed for: r9v0, types: [C4.j, J4.f] */
    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Iterator it;
        Object[] objArr;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f5645b;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            C c6 = (C) this.f5646c;
            List list = this.f5647d;
            if (list.isEmpty()) {
                return y.f26065a;
            }
            int i7 = this.f5648e;
            int iMin = i7 > 0 ? Math.min(i7, list.size()) : list.size();
            int size = list.size();
            Object[] objArr2 = new Object[size];
            for (int i8 = 0; i8 < size; i8++) {
                objArr2[i8] = null;
            }
            AtomicInteger atomicInteger = new AtomicInteger(0);
            g gVarL0 = L4.a.l0(0, iMin);
            ArrayList arrayList = new ArrayList(AbstractC3253s.G(gVarL0, 10));
            Iterator it2 = gVarL0.iterator();
            while (((P4.f) it2).f5681c) {
                ((AbstractC3226C) it2).a();
                c5.e eVar = N.f8259a;
                arrayList.add(E.e(c6, c5.d.f13466b, new a(atomicInteger, this.f5647d, objArr2, this.f5649f, null), 2));
            }
            it = arrayList.iterator();
            objArr = objArr2;
        } else {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            it = this.f5644a;
            objArr = (Object[]) this.f5646c;
            AbstractC2467b.l(obj);
        }
        while (it.hasNext()) {
            H h5 = (H) it.next();
            this.f5646c = objArr;
            this.f5644a = it;
            this.f5645b = 1;
            if (h5.await(this) == aVar) {
                return aVar;
            }
        }
        ArrayList arrayList2 = new ArrayList(objArr.length);
        for (Object obj2 : objArr) {
            arrayList2.add(obj2);
        }
        return arrayList2;
    }
}
