package i9; import java.util.Iterator; import java.util.NoSuchElementException; import s8.n; import s8.o; import s8.v; /* loaded from: classes2.dex */ final class c extends d implements Iterator, v8.d { /* renamed from: a, reason: collision with root package name */ private int f10973a; /* renamed from: b, reason: collision with root package name */ private Object f10974b; /* renamed from: c, reason: collision with root package name */ private Iterator f10975c; /* renamed from: d, reason: collision with root package name */ private v8.d f10976d; private final Throwable d() { int i10 = this.f10973a; if (i10 == 4) { return new NoSuchElementException(); } if (i10 == 5) { return new IllegalStateException("Iterator has failed."); } return new IllegalStateException("Unexpected state of the iterator: " + this.f10973a); } private final Object i() { if (hasNext()) { return next(); } throw new NoSuchElementException(); } @Override // i9.d public Object c(Object obj, v8.d dVar) { Object c10; Object c11; Object c12; this.f10974b = obj; this.f10973a = 3; this.f10976d = dVar; c10 = w8.d.c(); c11 = w8.d.c(); if (c10 == c11) { kotlin.coroutines.jvm.internal.h.c(dVar); } c12 = w8.d.c(); return c10 == c12 ? c10 : v.f14109a; } @Override // v8.d public v8.g getContext() { return v8.h.f14943a; } @Override // java.util.Iterator public boolean hasNext() { while (true) { int i10 = this.f10973a; if (i10 != 0) { if (i10 != 1) { if (i10 == 2 || i10 == 3) { return true; } if (i10 == 4) { return false; } throw d(); } Iterator it = this.f10975c; d9.j.b(it); if (it.hasNext()) { this.f10973a = 2; return true; } this.f10975c = null; } this.f10973a = 5; v8.d dVar = this.f10976d; d9.j.b(dVar); this.f10976d = null; n.a aVar = n.f14096b; dVar.resumeWith(n.b(v.f14109a)); } } public final void j(v8.d dVar) { this.f10976d = dVar; } @Override // java.util.Iterator public Object next() { int i10 = this.f10973a; if (i10 == 0 || i10 == 1) { return i(); } if (i10 == 2) { this.f10973a = 1; Iterator it = this.f10975c; d9.j.b(it); return it.next(); } if (i10 != 3) { throw d(); } this.f10973a = 0; Object obj = this.f10974b; this.f10974b = null; return obj; } @Override // java.util.Iterator public void remove() { throw new UnsupportedOperationException("Operation is not supported for read-only collection"); } @Override // v8.d public void resumeWith(Object obj) { o.b(obj); this.f10973a = 4; } }