package k9; import java.util.ArrayList; import java.util.Collections; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import k9.u1; import kotlinx.coroutines.internal.n; import v8.g; /* loaded from: classes2.dex */ public class c2 implements u1, u, k2 { /* renamed from: a, reason: collision with root package name */ private static final /* synthetic */ AtomicReferenceFieldUpdater f11304a = AtomicReferenceFieldUpdater.newUpdater(c2.class, Object.class, "_state"); private volatile /* synthetic */ Object _parentHandle; private volatile /* synthetic */ Object _state; private static final class a extends n { /* renamed from: i, reason: collision with root package name */ private final c2 f11305i; public a(v8.d dVar, c2 c2Var) { super(dVar, 1); this.f11305i = c2Var; } @Override // k9.n protected String E() { return "AwaitContinuation"; } @Override // k9.n public Throwable u(u1 u1Var) { Throwable f10; Object L = this.f11305i.L(); return (!(L instanceof c) || (f10 = ((c) L).f()) == null) ? L instanceof a0 ? ((a0) L).f11296a : u1Var.S() : f10; } } private static final class b extends b2 { /* renamed from: e, reason: collision with root package name */ private final c2 f11306e; /* renamed from: f, reason: collision with root package name */ private final c f11307f; /* renamed from: g, reason: collision with root package name */ private final t f11308g; /* renamed from: h, reason: collision with root package name */ private final Object f11309h; public b(c2 c2Var, c cVar, t tVar, Object obj) { this.f11306e = c2Var; this.f11307f = cVar; this.f11308g = tVar; this.f11309h = obj; } @Override // c9.l public /* bridge */ /* synthetic */ Object invoke(Object obj) { w((Throwable) obj); return s8.v.f14109a; } @Override // k9.c0 public void w(Throwable th) { this.f11306e.x(this.f11307f, this.f11308g, this.f11309h); } } private static final class c implements p1 { private volatile /* synthetic */ Object _exceptionsHolder = null; private volatile /* synthetic */ int _isCompleting; private volatile /* synthetic */ Object _rootCause; /* renamed from: a, reason: collision with root package name */ private final h2 f11310a; public c(h2 h2Var, boolean z10, Throwable th) { this.f11310a = h2Var; this._isCompleting = z10 ? 1 : 0; this._rootCause = th; } private final ArrayList b() { return new ArrayList(4); } private final Object e() { return this._exceptionsHolder; } private final void l(Object obj) { this._exceptionsHolder = obj; } public final void a(Throwable th) { Throwable f10 = f(); if (f10 == null) { m(th); return; } if (th == f10) { return; } Object e10 = e(); if (e10 == null) { l(th); return; } if (!(e10 instanceof Throwable)) { if (!(e10 instanceof ArrayList)) { throw new IllegalStateException(d9.j.l("State is ", e10).toString()); } ((ArrayList) e10).add(th); } else { if (th == e10) { return; } ArrayList b10 = b(); b10.add(e10); b10.add(th); l(b10); } } @Override // k9.p1 public boolean c() { return f() == null; } @Override // k9.p1 public h2 d() { return this.f11310a; } public final Throwable f() { return (Throwable) this._rootCause; } public final boolean g() { return f() != null; } /* JADX WARN: Type inference failed for: r0v0, types: [boolean, int] */ public final boolean h() { return this._isCompleting; } public final boolean i() { kotlinx.coroutines.internal.y yVar; Object e10 = e(); yVar = d2.f11326e; return e10 == yVar; } public final List j(Throwable th) { ArrayList arrayList; kotlinx.coroutines.internal.y yVar; Object e10 = e(); if (e10 == null) { arrayList = b(); } else if (e10 instanceof Throwable) { ArrayList b10 = b(); b10.add(e10); arrayList = b10; } else { if (!(e10 instanceof ArrayList)) { throw new IllegalStateException(d9.j.l("State is ", e10).toString()); } arrayList = (ArrayList) e10; } Throwable f10 = f(); if (f10 != null) { arrayList.add(0, f10); } if (th != null && !d9.j.a(th, f10)) { arrayList.add(th); } yVar = d2.f11326e; l(yVar); return arrayList; } public final void k(boolean z10) { this._isCompleting = z10 ? 1 : 0; } public final void m(Throwable th) { this._rootCause = th; } public String toString() { return "Finishing[cancelling=" + g() + ", completing=" + h() + ", rootCause=" + f() + ", exceptions=" + e() + ", list=" + d() + ']'; } } public static final class d extends n.a { /* renamed from: d, reason: collision with root package name */ final /* synthetic */ kotlinx.coroutines.internal.n f11311d; /* renamed from: e, reason: collision with root package name */ final /* synthetic */ c2 f11312e; /* renamed from: f, reason: collision with root package name */ final /* synthetic */ Object f11313f; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public d(kotlinx.coroutines.internal.n nVar, c2 c2Var, Object obj) { super(nVar); this.f11311d = nVar; this.f11312e = c2Var; this.f11313f = obj; } @Override // kotlinx.coroutines.internal.c /* renamed from: i, reason: merged with bridge method [inline-methods] */ public Object g(kotlinx.coroutines.internal.n nVar) { if (this.f11312e.L() == this.f11313f) { return null; } return kotlinx.coroutines.internal.m.a(); } } static final class e extends kotlin.coroutines.jvm.internal.k implements c9.p { /* renamed from: b, reason: collision with root package name */ Object f11314b; /* renamed from: c, reason: collision with root package name */ Object f11315c; /* renamed from: d, reason: collision with root package name */ int f11316d; /* renamed from: e, reason: collision with root package name */ private /* synthetic */ Object f11317e; e(v8.d dVar) { super(2, dVar); } @Override // c9.p /* renamed from: c, reason: merged with bridge method [inline-methods] */ public final Object invoke(i9.d dVar, v8.d dVar2) { return ((e) create(dVar, dVar2)).invokeSuspend(s8.v.f14109a); } @Override // kotlin.coroutines.jvm.internal.a public final v8.d create(Object obj, v8.d dVar) { e eVar = c2.this.new e(dVar); eVar.f11317e = obj; return eVar; } /* JADX WARN: Removed duplicated region for block: B:9:0x0067 */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:10:0x0069 -> B:6:0x007f). Please report as a decompilation issue!!! */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:12:0x007c -> B:6:0x007f). Please report as a decompilation issue!!! */ @Override // kotlin.coroutines.jvm.internal.a /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public final java.lang.Object invokeSuspend(java.lang.Object r8) { /* r7 = this; java.lang.Object r0 = w8.b.c() int r1 = r7.f11316d r2 = 2 r3 = 1 if (r1 == 0) goto L2b if (r1 == r3) goto L27 if (r1 != r2) goto L1f java.lang.Object r1 = r7.f11315c kotlinx.coroutines.internal.n r1 = (kotlinx.coroutines.internal.n) r1 java.lang.Object r3 = r7.f11314b kotlinx.coroutines.internal.l r3 = (kotlinx.coroutines.internal.l) r3 java.lang.Object r4 = r7.f11317e i9.d r4 = (i9.d) r4 s8.o.b(r8) r8 = r7 goto L7f L1f: java.lang.IllegalStateException r8 = new java.lang.IllegalStateException java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine" r8.(r0) throw r8 L27: s8.o.b(r8) goto L84 L2b: s8.o.b(r8) java.lang.Object r8 = r7.f11317e i9.d r8 = (i9.d) r8 k9.c2 r1 = k9.c2.this java.lang.Object r1 = r1.L() boolean r4 = r1 instanceof k9.t if (r4 == 0) goto L49 k9.t r1 = (k9.t) r1 k9.u r1 = r1.f11391e r7.f11316d = r3 java.lang.Object r8 = r8.c(r1, r7) if (r8 != r0) goto L84 return r0 L49: boolean r3 = r1 instanceof k9.p1 if (r3 == 0) goto L84 k9.p1 r1 = (k9.p1) r1 k9.h2 r1 = r1.d() if (r1 != 0) goto L56 goto L84 L56: java.lang.Object r3 = r1.l() kotlinx.coroutines.internal.n r3 = (kotlinx.coroutines.internal.n) r3 r4 = r8 r8 = r7 r6 = r3 r3 = r1 r1 = r6 L61: boolean r5 = d9.j.a(r1, r3) if (r5 != 0) goto L84 boolean r5 = r1 instanceof k9.t if (r5 == 0) goto L7f r5 = r1 k9.t r5 = (k9.t) r5 k9.u r5 = r5.f11391e r8.f11317e = r4 r8.f11314b = r3 r8.f11315c = r1 r8.f11316d = r2 java.lang.Object r5 = r4.c(r5, r8) if (r5 != r0) goto L7f return r0 L7f: kotlinx.coroutines.internal.n r1 = r1.m() goto L61 L84: s8.v r8 = s8.v.f14109a return r8 */ throw new UnsupportedOperationException("Method not decompiled: k9.c2.e.invokeSuspend(java.lang.Object):java.lang.Object"); } } public c2(boolean z10) { this._state = z10 ? d2.f11328g : d2.f11327f; this._parentHandle = null; } private final Object A(c cVar, Object obj) { boolean g10; Throwable E; a0 a0Var = obj instanceof a0 ? (a0) obj : null; Throwable th = a0Var == null ? null : a0Var.f11296a; synchronized (cVar) { g10 = cVar.g(); List j10 = cVar.j(th); E = E(cVar, j10); if (E != null) { l(E, j10); } } if (E != null && E != th) { obj = new a0(E, false, 2, null); } if (E != null) { if (t(E) || M(E)) { if (obj == null) { throw new NullPointerException("null cannot be cast to non-null type kotlinx.coroutines.CompletedExceptionally"); } ((a0) obj).b(); } } if (!g10) { h0(E); } i0(obj); androidx.concurrent.futures.b.a(f11304a, this, cVar, d2.g(obj)); w(cVar, obj); return obj; } private final t B(p1 p1Var) { t tVar = p1Var instanceof t ? (t) p1Var : null; if (tVar != null) { return tVar; } h2 d10 = p1Var.d(); if (d10 == null) { return null; } return c0(d10); } private final boolean B0(p1 p1Var, Object obj) { if (!androidx.concurrent.futures.b.a(f11304a, this, p1Var, d2.g(obj))) { return false; } h0(null); i0(obj); w(p1Var, obj); return true; } private final boolean C0(p1 p1Var, Throwable th) { h2 J = J(p1Var); if (J == null) { return false; } if (!androidx.concurrent.futures.b.a(f11304a, this, p1Var, new c(J, false, th))) { return false; } e0(J, th); return true; } private final Throwable D(Object obj) { a0 a0Var = obj instanceof a0 ? (a0) obj : null; if (a0Var == null) { return null; } return a0Var.f11296a; } private final Throwable E(c cVar, List list) { Object obj; Object obj2 = null; if (list.isEmpty()) { if (cVar.g()) { return new v1(u(), null, this); } return null; } List list2 = list; Iterator it = list2.iterator(); while (true) { if (!it.hasNext()) { obj = null; break; } obj = it.next(); if (!(((Throwable) obj) instanceof CancellationException)) { break; } } Throwable th = (Throwable) obj; if (th != null) { return th; } Throwable th2 = (Throwable) list.get(0); if (th2 instanceof w2) { Iterator it2 = list2.iterator(); while (true) { if (!it2.hasNext()) { break; } Object next = it2.next(); Throwable th3 = (Throwable) next; if (th3 != th2 && (th3 instanceof w2)) { obj2 = next; break; } } Throwable th4 = (Throwable) obj2; if (th4 != null) { return th4; } } return th2; } private final Object E0(Object obj, Object obj2) { kotlinx.coroutines.internal.y yVar; kotlinx.coroutines.internal.y yVar2; if (!(obj instanceof p1)) { yVar2 = d2.f11322a; return yVar2; } if ((!(obj instanceof e1) && !(obj instanceof b2)) || (obj instanceof t) || (obj2 instanceof a0)) { return F0((p1) obj, obj2); } if (B0((p1) obj, obj2)) { return obj2; } yVar = d2.f11324c; return yVar; } private final Object F0(p1 p1Var, Object obj) { kotlinx.coroutines.internal.y yVar; kotlinx.coroutines.internal.y yVar2; kotlinx.coroutines.internal.y yVar3; h2 J = J(p1Var); if (J == null) { yVar3 = d2.f11324c; return yVar3; } c cVar = p1Var instanceof c ? (c) p1Var : null; if (cVar == null) { cVar = new c(J, false, null); } synchronized (cVar) { if (cVar.h()) { yVar2 = d2.f11322a; return yVar2; } cVar.k(true); if (cVar != p1Var && !androidx.concurrent.futures.b.a(f11304a, this, p1Var, cVar)) { yVar = d2.f11324c; return yVar; } boolean g10 = cVar.g(); a0 a0Var = obj instanceof a0 ? (a0) obj : null; if (a0Var != null) { cVar.a(a0Var.f11296a); } Throwable f10 = true ^ g10 ? cVar.f() : null; s8.v vVar = s8.v.f14109a; if (f10 != null) { e0(J, f10); } t B = B(p1Var); return (B == null || !G0(cVar, B, obj)) ? A(cVar, obj) : d2.f11323b; } } private final boolean G0(c cVar, t tVar, Object obj) { while (u1.a.d(tVar.f11391e, false, false, new b(this, cVar, tVar, obj), 1, null) == i2.f11356a) { tVar = c0(tVar); if (tVar == null) { return false; } } return true; } private final h2 J(p1 p1Var) { h2 d10 = p1Var.d(); if (d10 != null) { return d10; } if (p1Var instanceof e1) { return new h2(); } if (!(p1Var instanceof b2)) { throw new IllegalStateException(d9.j.l("State should have list: ", p1Var).toString()); } o0((b2) p1Var); return null; } private final boolean U() { Object L; do { L = L(); if (!(L instanceof p1)) { return false; } } while (t0(L) < 0); return true; } private final Object V(v8.d dVar) { v8.d b10; Object c10; Object c11; b10 = w8.c.b(dVar); n nVar = new n(b10, 1); nVar.y(); p.a(nVar, w0(new n2(nVar))); Object v10 = nVar.v(); c10 = w8.d.c(); if (v10 == c10) { kotlin.coroutines.jvm.internal.h.c(dVar); } c11 = w8.d.c(); return v10 == c11 ? v10 : s8.v.f14109a; } private final Object W(Object obj) { kotlinx.coroutines.internal.y yVar; kotlinx.coroutines.internal.y yVar2; kotlinx.coroutines.internal.y yVar3; kotlinx.coroutines.internal.y yVar4; kotlinx.coroutines.internal.y yVar5; kotlinx.coroutines.internal.y yVar6; Throwable th = null; while (true) { Object L = L(); if (L instanceof c) { synchronized (L) { if (((c) L).i()) { yVar2 = d2.f11325d; return yVar2; } boolean g10 = ((c) L).g(); if (obj != null || !g10) { if (th == null) { th = y(obj); } ((c) L).a(th); } Throwable f10 = g10 ^ true ? ((c) L).f() : null; if (f10 != null) { e0(((c) L).d(), f10); } yVar = d2.f11322a; return yVar; } } if (!(L instanceof p1)) { yVar3 = d2.f11325d; return yVar3; } if (th == null) { th = y(obj); } p1 p1Var = (p1) L; if (!p1Var.c()) { Object E0 = E0(L, new a0(th, false, 2, null)); yVar5 = d2.f11322a; if (E0 == yVar5) { throw new IllegalStateException(d9.j.l("Cannot happen in ", L).toString()); } yVar6 = d2.f11324c; if (E0 != yVar6) { return E0; } } else if (C0(p1Var, th)) { yVar4 = d2.f11322a; return yVar4; } } } private final b2 Z(c9.l lVar, boolean z10) { b2 b2Var; if (z10) { b2Var = lVar instanceof w1 ? (w1) lVar : null; if (b2Var == null) { b2Var = new s1(lVar); } } else { b2 b2Var2 = lVar instanceof b2 ? (b2) lVar : null; b2Var = b2Var2 != null ? b2Var2 : null; if (b2Var == null) { b2Var = new t1(lVar); } } b2Var.y(this); return b2Var; } private final t c0(kotlinx.coroutines.internal.n nVar) { while (nVar.q()) { nVar = nVar.n(); } while (true) { nVar = nVar.m(); if (!nVar.q()) { if (nVar instanceof t) { return (t) nVar; } if (nVar instanceof h2) { return null; } } } } private final void e0(h2 h2Var, Throwable th) { d0 d0Var; h0(th); d0 d0Var2 = null; for (kotlinx.coroutines.internal.n nVar = (kotlinx.coroutines.internal.n) h2Var.l(); !d9.j.a(nVar, h2Var); nVar = nVar.m()) { if (nVar instanceof w1) { b2 b2Var = (b2) nVar; try { b2Var.w(th); } catch (Throwable th2) { if (d0Var2 == null) { d0Var = null; } else { s8.b.a(d0Var2, th2); d0Var = d0Var2; } if (d0Var == null) { d0Var2 = new d0("Exception in completion handler " + b2Var + " for " + this, th2); } } } } if (d0Var2 != null) { N(d0Var2); } t(th); } private final void g0(h2 h2Var, Throwable th) { d0 d0Var; d0 d0Var2 = null; for (kotlinx.coroutines.internal.n nVar = (kotlinx.coroutines.internal.n) h2Var.l(); !d9.j.a(nVar, h2Var); nVar = nVar.m()) { if (nVar instanceof b2) { b2 b2Var = (b2) nVar; try { b2Var.w(th); } catch (Throwable th2) { if (d0Var2 == null) { d0Var = null; } else { s8.b.a(d0Var2, th2); d0Var = d0Var2; } if (d0Var == null) { d0Var2 = new d0("Exception in completion handler " + b2Var + " for " + this, th2); } } } } if (d0Var2 == null) { return; } N(d0Var2); } private final boolean k(Object obj, h2 h2Var, b2 b2Var) { int v10; d dVar = new d(b2Var, this, obj); do { v10 = h2Var.n().v(b2Var, h2Var, dVar); if (v10 == 1) { return true; } } while (v10 != 2); return false; } private final void l(Throwable th, List list) { if (list.size() <= 1) { return; } Set newSetFromMap = Collections.newSetFromMap(new IdentityHashMap(list.size())); Iterator it = list.iterator(); while (it.hasNext()) { Throwable th2 = (Throwable) it.next(); if (th2 != th && th2 != th && !(th2 instanceof CancellationException) && newSetFromMap.add(th2)) { s8.b.a(th, th2); } } } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v2, types: [k9.o1] */ private final void l0(e1 e1Var) { h2 h2Var = new h2(); if (!e1Var.c()) { h2Var = new o1(h2Var); } androidx.concurrent.futures.b.a(f11304a, this, e1Var, h2Var); } private final Object o(v8.d dVar) { v8.d b10; Object c10; b10 = w8.c.b(dVar); a aVar = new a(b10, this); aVar.y(); p.a(aVar, w0(new m2(aVar))); Object v10 = aVar.v(); c10 = w8.d.c(); if (v10 == c10) { kotlin.coroutines.jvm.internal.h.c(dVar); } return v10; } private final void o0(b2 b2Var) { b2Var.h(new h2()); androidx.concurrent.futures.b.a(f11304a, this, b2Var, b2Var.m()); } private final Object s(Object obj) { kotlinx.coroutines.internal.y yVar; Object E0; kotlinx.coroutines.internal.y yVar2; do { Object L = L(); if (!(L instanceof p1) || ((L instanceof c) && ((c) L).h())) { yVar = d2.f11322a; return yVar; } E0 = E0(L, new a0(y(obj), false, 2, null)); yVar2 = d2.f11324c; } while (E0 == yVar2); return E0; } private final boolean t(Throwable th) { if (T()) { return true; } boolean z10 = th instanceof CancellationException; s K = K(); return (K == null || K == i2.f11356a) ? z10 : K.b(th) || z10; } private final int t0(Object obj) { e1 e1Var; if (!(obj instanceof e1)) { if (!(obj instanceof o1)) { return 0; } if (!androidx.concurrent.futures.b.a(f11304a, this, obj, ((o1) obj).d())) { return -1; } k0(); return 1; } if (((e1) obj).c()) { return 0; } AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f11304a; e1Var = d2.f11328g; if (!androidx.concurrent.futures.b.a(atomicReferenceFieldUpdater, this, obj, e1Var)) { return -1; } k0(); return 1; } private final String v0(Object obj) { if (!(obj instanceof c)) { return obj instanceof p1 ? ((p1) obj).c() ? "Active" : "New" : obj instanceof a0 ? "Cancelled" : "Completed"; } c cVar = (c) obj; return cVar.g() ? "Cancelling" : cVar.h() ? "Completing" : "Active"; } private final void w(p1 p1Var, Object obj) { s K = K(); if (K != null) { K.e(); s0(i2.f11356a); } a0 a0Var = obj instanceof a0 ? (a0) obj : null; Throwable th = a0Var != null ? a0Var.f11296a : null; if (!(p1Var instanceof b2)) { h2 d10 = p1Var.d(); if (d10 == null) { return; } g0(d10, th); return; } try { ((b2) p1Var).w(th); } catch (Throwable th2) { N(new d0("Exception in completion handler " + p1Var + " for " + this, th2)); } } /* JADX INFO: Access modifiers changed from: private */ public final void x(c cVar, t tVar, Object obj) { t c02 = c0(tVar); if (c02 == null || !G0(cVar, c02, obj)) { m(A(cVar, obj)); } } private final Throwable y(Object obj) { if (obj == null ? true : obj instanceof Throwable) { Throwable th = (Throwable) obj; return th == null ? new v1(u(), null, this) : th; } if (obj != null) { return ((k2) obj).u0(); } throw new NullPointerException("null cannot be cast to non-null type kotlinx.coroutines.ParentJob"); } public static /* synthetic */ CancellationException y0(c2 c2Var, Throwable th, String str, int i10, Object obj) { if (obj != null) { throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: toCancellationException"); } if ((i10 & 1) != 0) { str = null; } return c2Var.x0(th, str); } public final String A0() { return b0() + '{' + v0(L()) + '}'; } public final Object C() { Object L = L(); if (!(!(L instanceof p1))) { throw new IllegalStateException("This job has not completed yet".toString()); } if (L instanceof a0) { throw ((a0) L).f11296a; } return d2.h(L); } public boolean F() { return true; } @Override // k9.u1 public final i9.b G() { i9.b b10; b10 = i9.f.b(new e(null)); return b10; } public boolean H() { return false; } public final Throwable I() { Object L = L(); if (!(L instanceof p1)) { return D(L); } throw new IllegalStateException("This job has not completed yet".toString()); } public final s K() { return (s) this._parentHandle; } public final Object L() { while (true) { Object obj = this._state; if (!(obj instanceof kotlinx.coroutines.internal.u)) { return obj; } ((kotlinx.coroutines.internal.u) obj).c(this); } } protected boolean M(Throwable th) { return false; } @Override // k9.u public final void P(k2 k2Var) { q(k2Var); } protected final void Q(u1 u1Var) { if (u1Var == null) { s0(i2.f11356a); return; } u1Var.start(); s d02 = u1Var.d0(this); s0(d02); if (R()) { d02.e(); s0(i2.f11356a); } } public final boolean R() { return !(L() instanceof p1); } @Override // k9.u1 public final CancellationException S() { Object L = L(); if (!(L instanceof c)) { if (L instanceof p1) { throw new IllegalStateException(d9.j.l("Job is still new or active: ", this).toString()); } return L instanceof a0 ? y0(this, ((a0) L).f11296a, null, 1, null) : new v1(d9.j.l(o0.a(this), " has completed normally"), null, this); } Throwable f10 = ((c) L).f(); CancellationException x02 = f10 != null ? x0(f10, d9.j.l(o0.a(this), " is cancelling")) : null; if (x02 != null) { return x02; } throw new IllegalStateException(d9.j.l("Job is still new or active: ", this).toString()); } protected boolean T() { return false; } public final boolean X(Object obj) { Object E0; kotlinx.coroutines.internal.y yVar; kotlinx.coroutines.internal.y yVar2; do { E0 = E0(L(), obj); yVar = d2.f11322a; if (E0 == yVar) { return false; } if (E0 == d2.f11323b) { return true; } yVar2 = d2.f11324c; } while (E0 == yVar2); m(E0); return true; } public final Object Y(Object obj) { Object E0; kotlinx.coroutines.internal.y yVar; kotlinx.coroutines.internal.y yVar2; do { E0 = E0(L(), obj); yVar = d2.f11322a; if (E0 == yVar) { throw new IllegalStateException("Job " + this + " is already complete or completing, but is being completed with " + obj, D(obj)); } yVar2 = d2.f11324c; } while (E0 == yVar2); return E0; } @Override // k9.u1 public final b1 a0(boolean z10, boolean z11, c9.l lVar) { b2 Z = Z(lVar, z10); while (true) { Object L = L(); if (L instanceof e1) { e1 e1Var = (e1) L; if (!e1Var.c()) { l0(e1Var); } else if (androidx.concurrent.futures.b.a(f11304a, this, L, Z)) { return Z; } } else { if (!(L instanceof p1)) { if (z11) { a0 a0Var = L instanceof a0 ? (a0) L : null; lVar.invoke(a0Var != null ? a0Var.f11296a : null); } return i2.f11356a; } h2 d10 = ((p1) L).d(); if (d10 != null) { b1 b1Var = i2.f11356a; if (z10 && (L instanceof c)) { synchronized (L) { r3 = ((c) L).f(); if (r3 == null || ((lVar instanceof t) && !((c) L).h())) { if (k(L, d10, Z)) { if (r3 == null) { return Z; } b1Var = Z; } } s8.v vVar = s8.v.f14109a; } } if (r3 != null) { if (z11) { lVar.invoke(r3); } return b1Var; } if (k(L, d10, Z)) { return Z; } } else { if (L == null) { throw new NullPointerException("null cannot be cast to non-null type kotlinx.coroutines.JobNode"); } o0((b2) L); } } } } public String b0() { return o0.a(this); } @Override // k9.u1 public boolean c() { Object L = L(); return (L instanceof p1) && ((p1) L).c(); } @Override // k9.u1 public final s d0(u uVar) { return (s) u1.a.d(this, true, false, new t(uVar), 2, null); } @Override // v8.g public Object fold(Object obj, c9.p pVar) { return u1.a.b(this, obj, pVar); } @Override // v8.g.b, v8.g public g.b get(g.c cVar) { return u1.a.c(this, cVar); } @Override // v8.g.b public final g.c getKey() { return u1.T; } protected void h0(Throwable th) { } protected void i0(Object obj) { } protected void k0() { } protected void m(Object obj) { } @Override // v8.g public v8.g minusKey(g.c cVar) { return u1.a.e(this, cVar); } public final Object n(v8.d dVar) { Object L; do { L = L(); if (!(L instanceof p1)) { if (L instanceof a0) { throw ((a0) L).f11296a; } return d2.h(L); } } while (t0(L) < 0); return o(dVar); } public final boolean p(Throwable th) { return q(th); } public final void p0(b2 b2Var) { Object L; AtomicReferenceFieldUpdater atomicReferenceFieldUpdater; e1 e1Var; do { L = L(); if (!(L instanceof b2)) { if (!(L instanceof p1) || ((p1) L).d() == null) { return; } b2Var.r(); return; } if (L != b2Var) { return; } atomicReferenceFieldUpdater = f11304a; e1Var = d2.f11328g; } while (!androidx.concurrent.futures.b.a(atomicReferenceFieldUpdater, this, L, e1Var)); } @Override // v8.g public v8.g plus(v8.g gVar) { return u1.a.f(this, gVar); } public final boolean q(Object obj) { Object obj2; kotlinx.coroutines.internal.y yVar; kotlinx.coroutines.internal.y yVar2; kotlinx.coroutines.internal.y yVar3; obj2 = d2.f11322a; if (H() && (obj2 = s(obj)) == d2.f11323b) { return true; } yVar = d2.f11322a; if (obj2 == yVar) { obj2 = W(obj); } yVar2 = d2.f11322a; if (obj2 == yVar2 || obj2 == d2.f11323b) { return true; } yVar3 = d2.f11325d; if (obj2 == yVar3) { return false; } m(obj2); return true; } @Override // k9.u1 public final Object q0(v8.d dVar) { Object c10; if (!U()) { y1.i(dVar.getContext()); return s8.v.f14109a; } Object V = V(dVar); c10 = w8.d.c(); return V == c10 ? V : s8.v.f14109a; } public void r(Throwable th) { q(th); } public final void s0(s sVar) { this._parentHandle = sVar; } @Override // k9.u1 public final boolean start() { int t02; do { t02 = t0(L()); if (t02 == 0) { return false; } } while (t02 != 1); return true; } public String toString() { return A0() + '@' + o0.b(this); } /* JADX INFO: Access modifiers changed from: protected */ public String u() { return "Job was cancelled"; } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v11, types: [java.lang.Throwable] */ /* JADX WARN: Type inference failed for: r1v7, types: [java.lang.Throwable] */ @Override // k9.k2 public CancellationException u0() { CancellationException cancellationException; Object L = L(); if (L instanceof c) { cancellationException = ((c) L).f(); } else if (L instanceof a0) { cancellationException = ((a0) L).f11296a; } else { if (L instanceof p1) { throw new IllegalStateException(d9.j.l("Cannot be cancelling child in this state: ", L).toString()); } cancellationException = null; } CancellationException cancellationException2 = cancellationException instanceof CancellationException ? cancellationException : null; return cancellationException2 == null ? new v1(d9.j.l("Parent job is ", v0(L)), cancellationException, this) : cancellationException2; } public boolean v(Throwable th) { if (th instanceof CancellationException) { return true; } return q(th) && F(); } @Override // k9.u1 public final b1 w0(c9.l lVar) { return a0(false, true, lVar); } protected final CancellationException x0(Throwable th, String str) { CancellationException cancellationException = th instanceof CancellationException ? (CancellationException) th : null; if (cancellationException == null) { if (str == null) { str = u(); } cancellationException = new v1(str, th, this); } return cancellationException; } @Override // k9.u1 public void z0(CancellationException cancellationException) { if (cancellationException == null) { cancellationException = new v1(u(), null, this); } r(cancellationException); } public void N(Throwable th) { throw th; } }