package o;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.hJ, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public class C1375hJ implements TI, OV {
    public static final /* synthetic */ AtomicReferenceFieldUpdater l = AtomicReferenceFieldUpdater.newUpdater(C1375hJ.class, Object.class, "_state$volatile");
    public static final /* synthetic */ AtomicReferenceFieldUpdater m = AtomicReferenceFieldUpdater.newUpdater(C1375hJ.class, Object.class, "_parentHandle$volatile");
    private volatile /* synthetic */ Object _parentHandle$volatile;
    private volatile /* synthetic */ Object _state$volatile;

    public C1375hJ(boolean z) {
        this._state$volatile = z ? AbstractC2841wm0.i : AbstractC2841wm0.h;
    }

    public static C0163Gh a0(C2707vM c2707vM) {
        while (c2707vM.i()) {
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = C2707vM.m;
            C2707vM c2707vMF = c2707vM.f();
            if (c2707vMF == null) {
                Object obj = atomicReferenceFieldUpdater.get(c2707vM);
                while (true) {
                    c2707vM = (C2707vM) obj;
                    if (!c2707vM.i()) {
                        break;
                    }
                    obj = atomicReferenceFieldUpdater.get(c2707vM);
                }
            } else {
                c2707vM = c2707vMF;
            }
        }
        while (true) {
            c2707vM = c2707vM.h();
            if (!c2707vM.i()) {
                if (c2707vM instanceof C0163Gh) {
                    return (C0163Gh) c2707vM;
                }
                if (c2707vM instanceof C2428sS) {
                    return null;
                }
            }
        }
    }

    public static String h0(Object obj) {
        if (!(obj instanceof C1279gJ)) {
            return obj instanceof WG ? ((WG) obj).b() ? "Active" : "New" : obj instanceof C2075oj ? "Cancelled" : "Completed";
        }
        C1279gJ c1279gJ = (C1279gJ) obj;
        return c1279gJ.e() ? "Cancelling" : C1279gJ.m.get(c1279gJ) != 0 ? "Completing" : "Active";
    }

    public final Object A(InterfaceC0220Im interfaceC0220Im) throws Throwable {
        Object obj;
        do {
            obj = l.get(this);
            if (!(obj instanceof WG)) {
                if (obj instanceof C2075oj) {
                    throw ((C2075oj) obj).a;
                }
                return AbstractC2841wm0.K(obj);
            }
        } while (g0(obj) < 0);
        C1087eJ c1087eJ = new C1087eJ(AbstractC2539te.G(interfaceC0220Im), this);
        c1087eJ.r();
        c1087eJ.x(new C1499ig(2, AbstractC0752ap.Q(this, true, new C2852ws(2, c1087eJ))));
        return c1087eJ.q();
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x003e A[PHI: r0
      0x003e: PHI (r0v1 java.lang.Object) = (r0v0 java.lang.Object), (r0v13 java.lang.Object) binds: [B:3:0x0008, B:16:0x003a] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean B(java.lang.Object r10) {
        /*
            Method dump skipped, instructions count: 270
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C1375hJ.B(java.lang.Object):boolean");
    }

    public void C(CancellationException cancellationException) {
        B(cancellationException);
    }

    public final boolean E(Throwable th) {
        if (W()) {
            return true;
        }
        boolean z = th instanceof CancellationException;
        InterfaceC0137Fh interfaceC0137Fh = (InterfaceC0137Fh) m.get(this);
        return (interfaceC0137Fh == null || interfaceC0137Fh == C2713vS.l) ? z : interfaceC0137Fh.c(th) || z;
    }

    public String F() {
        return "Job was cancelled";
    }

    public boolean G(Throwable th) {
        if (th instanceof CancellationException) {
            return true;
        }
        return B(th) && N();
    }

    public final void H(WG wg, Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = m;
        InterfaceC0137Fh interfaceC0137Fh = (InterfaceC0137Fh) atomicReferenceFieldUpdater.get(this);
        if (interfaceC0137Fh != null) {
            interfaceC0137Fh.a();
            atomicReferenceFieldUpdater.set(this, C2713vS.l);
        }
        C2170pj c2170pj = null;
        C2075oj c2075oj = obj instanceof C2075oj ? (C2075oj) obj : null;
        Throwable th = c2075oj != null ? c2075oj.a : null;
        if (wg instanceof AbstractC0992dJ) {
            try {
                ((AbstractC0992dJ) wg).k(th);
                return;
            } catch (Throwable th2) {
                T(new C2170pj("Exception in completion handler " + wg + " for " + this, th2));
                return;
            }
        }
        C2428sS c2428sSD = wg.d();
        if (c2428sSD != null) {
            c2428sSD.e(new IL(1), 1);
            for (C2707vM c2707vMH = (C2707vM) C2707vM.l.get(c2428sSD); !F3.c(c2707vMH, c2428sSD); c2707vMH = c2707vMH.h()) {
                if (c2707vMH instanceof AbstractC0992dJ) {
                    try {
                        ((AbstractC0992dJ) c2707vMH).k(th);
                    } catch (Throwable th3) {
                        if (c2170pj != null) {
                            C80.i(c2170pj, th3);
                        } else {
                            c2170pj = new C2170pj("Exception in completion handler " + c2707vMH + " for " + this, th3);
                        }
                    }
                }
            }
            if (c2170pj != null) {
                T(c2170pj);
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v11, types: [java.lang.Throwable] */
    /* JADX WARN: Type inference failed for: r2v7, types: [java.lang.Throwable] */
    public final Throwable I(Object obj) {
        CancellationException cancellationExceptionC;
        if (obj == null ? true : obj instanceof Throwable) {
            Throwable th = (Throwable) obj;
            return th == null ? new UI(F(), null, this) : th;
        }
        C1375hJ c1375hJ = (C1375hJ) ((OV) obj);
        c1375hJ.getClass();
        Object obj2 = l.get(c1375hJ);
        if (obj2 instanceof C1279gJ) {
            cancellationExceptionC = ((C1279gJ) obj2).c();
        } else if (obj2 instanceof C2075oj) {
            cancellationExceptionC = ((C2075oj) obj2).a;
        } else {
            if (obj2 instanceof WG) {
                throw new IllegalStateException(("Cannot be cancelling child in this state: " + obj2).toString());
            }
            cancellationExceptionC = null;
        }
        CancellationException cancellationException = cancellationExceptionC instanceof CancellationException ? cancellationExceptionC : null;
        return cancellationException == null ? new UI("Parent job is ".concat(h0(obj2)), cancellationExceptionC, c1375hJ) : cancellationException;
    }

    public final Object J(C1279gJ c1279gJ, Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        Throwable thL;
        C2075oj c2075oj = obj instanceof C2075oj ? (C2075oj) obj : null;
        Throwable th = c2075oj != null ? c2075oj.a : null;
        synchronized (c1279gJ) {
            c1279gJ.e();
            ArrayList arrayListF = c1279gJ.f(th);
            thL = L(c1279gJ, arrayListF);
            if (thL != null && arrayListF.size() > 1) {
                Set setNewSetFromMap = Collections.newSetFromMap(new IdentityHashMap(arrayListF.size()));
                int size = arrayListF.size();
                int i = 0;
                while (i < size) {
                    Object obj2 = arrayListF.get(i);
                    i++;
                    Throwable th2 = (Throwable) obj2;
                    if (th2 != thL && th2 != thL && !(th2 instanceof CancellationException) && setNewSetFromMap.add(th2)) {
                        C80.i(thL, th2);
                    }
                }
            }
        }
        if (thL != null && thL != th) {
            obj = new C2075oj(thL, false);
        }
        if (thL != null && (E(thL) || Q(thL))) {
            C2075oj c2075oj2 = (C2075oj) obj;
            c2075oj2.getClass();
            C2075oj.b.compareAndSet(c2075oj2, 0, 1);
        }
        c0(obj);
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = l;
        Object xg = obj instanceof WG ? new XG((WG) obj) : obj;
        while (!atomicReferenceFieldUpdater.compareAndSet(this, c1279gJ, xg) && atomicReferenceFieldUpdater.get(this) == c1279gJ) {
        }
        H(c1279gJ, obj);
        return obj;
    }

    public final Object K() {
        Object obj = l.get(this);
        if (obj instanceof WG) {
            throw new IllegalStateException("This job has not completed yet");
        }
        if (obj instanceof C2075oj) {
            throw ((C2075oj) obj).a;
        }
        return AbstractC2841wm0.K(obj);
    }

    public final Throwable L(C1279gJ c1279gJ, ArrayList arrayList) {
        Object obj;
        Object obj2 = null;
        if (arrayList.isEmpty()) {
            if (c1279gJ.e()) {
                return new UI(F(), null, this);
            }
            return null;
        }
        int size = arrayList.size();
        int i = 0;
        int i2 = 0;
        while (true) {
            if (i2 >= size) {
                obj = null;
                break;
            }
            obj = arrayList.get(i2);
            i2++;
            if (!(((Throwable) obj) instanceof CancellationException)) {
                break;
            }
        }
        Throwable th = (Throwable) obj;
        if (th != null) {
            return th;
        }
        Throwable th2 = (Throwable) arrayList.get(0);
        if (th2 instanceof Df0) {
            int size2 = arrayList.size();
            while (true) {
                if (i >= size2) {
                    break;
                }
                Object obj3 = arrayList.get(i);
                i++;
                Throwable th3 = (Throwable) obj3;
                if (th3 != th2 && (th3 instanceof Df0)) {
                    obj2 = obj3;
                    break;
                }
            }
            Throwable th4 = (Throwable) obj2;
            if (th4 != null) {
                return th4;
            }
        }
        return th2;
    }

    @Override // o.InterfaceC2747vn
    public final InterfaceC2747vn M(InterfaceC2747vn interfaceC2747vn) {
        return AbstractC2798wI.t(this, interfaceC2747vn);
    }

    public boolean N() {
        return true;
    }

    public boolean O() {
        return this instanceof C1790lj;
    }

    public final C2428sS P(WG wg) {
        C2428sS c2428sSD = wg.d();
        if (c2428sSD != null) {
            return c2428sSD;
        }
        if (wg instanceof C0203Hv) {
            return new C2428sS();
        }
        if (wg instanceof AbstractC0992dJ) {
            f0((AbstractC0992dJ) wg);
            return null;
        }
        throw new IllegalStateException(("State should have list: " + wg).toString());
    }

    public boolean Q(Throwable th) {
        return false;
    }

    @Override // o.InterfaceC2747vn
    public final Object R(Object obj, SC sc) {
        return sc.f(obj, this);
    }

    @Override // o.TI
    public final InterfaceC0137Fh S(C1375hJ c1375hJ) {
        C0163Gh c0163Gh = new C0163Gh(c1375hJ);
        c0163Gh.f489o = this;
        loop0: while (true) {
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = l;
            Object obj = atomicReferenceFieldUpdater.get(this);
            if (obj instanceof C0203Hv) {
                C0203Hv c0203Hv = (C0203Hv) obj;
                if (c0203Hv.l) {
                    while (!atomicReferenceFieldUpdater.compareAndSet(this, obj, c0163Gh)) {
                        if (atomicReferenceFieldUpdater.get(this) != obj) {
                            break;
                        }
                    }
                    break loop0;
                }
                e0(c0203Hv);
            } else {
                boolean z = obj instanceof WG;
                C2713vS c2713vS = C2713vS.l;
                if (!z) {
                    Object obj2 = atomicReferenceFieldUpdater.get(this);
                    C2075oj c2075oj = obj2 instanceof C2075oj ? (C2075oj) obj2 : null;
                    c0163Gh.k(c2075oj != null ? c2075oj.a : null);
                    return c2713vS;
                }
                C2428sS c2428sSD = ((WG) obj).d();
                if (c2428sSD == null) {
                    f0((AbstractC0992dJ) obj);
                } else if (!c2428sSD.e(c0163Gh, 7)) {
                    boolean zE = c2428sSD.e(c0163Gh, 3);
                    Object obj3 = atomicReferenceFieldUpdater.get(this);
                    if (obj3 instanceof C1279gJ) {
                        thC = ((C1279gJ) obj3).c();
                    } else {
                        C2075oj c2075oj2 = obj3 instanceof C2075oj ? (C2075oj) obj3 : null;
                        if (c2075oj2 != null) {
                            thC = c2075oj2.a;
                        }
                    }
                    c0163Gh.k(thC);
                    if (zE) {
                        break loop0;
                    }
                    return c2713vS;
                }
            }
        }
        return c0163Gh;
    }

    public final void U(TI ti) {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = m;
        C2713vS c2713vS = C2713vS.l;
        if (ti == null) {
            atomicReferenceFieldUpdater.set(this, c2713vS);
            return;
        }
        ti.start();
        InterfaceC0137Fh interfaceC0137FhS = ti.S(this);
        atomicReferenceFieldUpdater.set(this, interfaceC0137FhS);
        if (l.get(this) instanceof WG) {
            return;
        }
        interfaceC0137FhS.a();
        atomicReferenceFieldUpdater.set(this, c2713vS);
    }

    public final InterfaceC2567ts V(boolean z, AbstractC0992dJ abstractC0992dJ) {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
        C2713vS c2713vS;
        boolean z2;
        boolean zE;
        abstractC0992dJ.f489o = this;
        loop0: while (true) {
            atomicReferenceFieldUpdater = l;
            Object obj = atomicReferenceFieldUpdater.get(this);
            boolean z3 = obj instanceof C0203Hv;
            c2713vS = C2713vS.l;
            z2 = true;
            if (!z3) {
                if (!(obj instanceof WG)) {
                    z2 = false;
                    break;
                }
                WG wg = (WG) obj;
                C2428sS c2428sSD = wg.d();
                if (c2428sSD == null) {
                    f0((AbstractC0992dJ) obj);
                } else {
                    if (abstractC0992dJ.j()) {
                        C1279gJ c1279gJ = wg instanceof C1279gJ ? (C1279gJ) wg : null;
                        Throwable thC = c1279gJ != null ? c1279gJ.c() : null;
                        if (thC == null) {
                            zE = c2428sSD.e(abstractC0992dJ, 5);
                        } else if (z) {
                            abstractC0992dJ.k(thC);
                            return c2713vS;
                        }
                    } else {
                        zE = c2428sSD.e(abstractC0992dJ, 1);
                    }
                    if (zE) {
                        break;
                    }
                }
            } else {
                C0203Hv c0203Hv = (C0203Hv) obj;
                if (c0203Hv.l) {
                    while (!atomicReferenceFieldUpdater.compareAndSet(this, obj, abstractC0992dJ)) {
                        if (atomicReferenceFieldUpdater.get(this) != obj) {
                            break;
                        }
                    }
                    break loop0;
                }
                e0(c0203Hv);
            }
        }
        if (z2) {
            return abstractC0992dJ;
        }
        if (z) {
            Object obj2 = atomicReferenceFieldUpdater.get(this);
            C2075oj c2075oj = obj2 instanceof C2075oj ? (C2075oj) obj2 : null;
            abstractC0992dJ.k(c2075oj != null ? c2075oj.a : null);
        }
        return c2713vS;
    }

    public boolean W() {
        return this instanceof C0548Vd;
    }

    public final boolean X(Object obj) {
        Object objI0;
        do {
            objI0 = i0(l.get(this), obj);
            if (objI0 == AbstractC2841wm0.c) {
                return false;
            }
            if (objI0 == AbstractC2841wm0.d) {
                return true;
            }
        } while (objI0 == AbstractC2841wm0.e);
        t(objI0);
        return true;
    }

    public final Object Y(Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        Object objI0;
        do {
            objI0 = i0(l.get(this), obj);
            if (objI0 == AbstractC2841wm0.c) {
                String str = "Job " + this + " is already complete or completing, but is being completed with " + obj;
                C2075oj c2075oj = obj instanceof C2075oj ? (C2075oj) obj : null;
                throw new IllegalStateException(str, c2075oj != null ? c2075oj.a : null);
            }
        } while (objI0 == AbstractC2841wm0.e);
        return objI0;
    }

    public String Z() {
        return getClass().getSimpleName();
    }

    @Override // o.TI
    public boolean b() {
        Object obj = l.get(this);
        return (obj instanceof WG) && ((WG) obj).b();
    }

    public final void b0(C2428sS c2428sS, Throwable th) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        c2428sS.e(new IL(4), 4);
        C2170pj c2170pj = null;
        for (C2707vM c2707vMH = (C2707vM) C2707vM.l.get(c2428sS); !F3.c(c2707vMH, c2428sS); c2707vMH = c2707vMH.h()) {
            if ((c2707vMH instanceof AbstractC0992dJ) && ((AbstractC0992dJ) c2707vMH).j()) {
                try {
                    ((AbstractC0992dJ) c2707vMH).k(th);
                } catch (Throwable th2) {
                    if (c2170pj != null) {
                        C80.i(c2170pj, th2);
                    } else {
                        c2170pj = new C2170pj("Exception in completion handler " + c2707vMH + " for " + this, th2);
                    }
                }
            }
        }
        if (c2170pj != null) {
            T(c2170pj);
        }
        E(th);
    }

    @Override // o.TI, o.J00
    public void c(CancellationException cancellationException) {
        if (cancellationException == null) {
            cancellationException = new UI(F(), null, this);
        }
        C(cancellationException);
    }

    @Override // o.TI
    public final InterfaceC2567ts d(OC oc) {
        return V(true, new C2852ws(1, oc));
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v3, types: [o.VG] */
    public final void e0(C0203Hv c0203Hv) {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
        C2428sS c2428sS = new C2428sS();
        if (!c0203Hv.l) {
            c2428sS = new VG(c2428sS);
        }
        do {
            atomicReferenceFieldUpdater = l;
            if (atomicReferenceFieldUpdater.compareAndSet(this, c0203Hv, c2428sS)) {
                return;
            }
        } while (atomicReferenceFieldUpdater.get(this) == c0203Hv);
    }

    public Object f() {
        return K();
    }

    public final void f0(AbstractC0992dJ abstractC0992dJ) {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
        C2428sS c2428sS = new C2428sS();
        abstractC0992dJ.getClass();
        C2707vM.m.set(c2428sS, abstractC0992dJ);
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = C2707vM.l;
        atomicReferenceFieldUpdater2.set(c2428sS, abstractC0992dJ);
        loop0: while (true) {
            if (atomicReferenceFieldUpdater2.get(abstractC0992dJ) == abstractC0992dJ) {
                while (!atomicReferenceFieldUpdater2.compareAndSet(abstractC0992dJ, abstractC0992dJ, c2428sS)) {
                    if (atomicReferenceFieldUpdater2.get(abstractC0992dJ) != abstractC0992dJ) {
                        break;
                    }
                }
                c2428sS.g(abstractC0992dJ);
                break loop0;
            }
            break;
        }
        C2707vM c2707vMH = abstractC0992dJ.h();
        do {
            atomicReferenceFieldUpdater = l;
            if (atomicReferenceFieldUpdater.compareAndSet(this, abstractC0992dJ, c2707vMH)) {
                return;
            }
        } while (atomicReferenceFieldUpdater.get(this) == abstractC0992dJ);
    }

    public final int g0(Object obj) {
        boolean z = obj instanceof C0203Hv;
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = l;
        if (z) {
            if (((C0203Hv) obj).l) {
                return 0;
            }
            C0203Hv c0203Hv = AbstractC2841wm0.i;
            while (!atomicReferenceFieldUpdater.compareAndSet(this, obj, c0203Hv)) {
                if (atomicReferenceFieldUpdater.get(this) != obj) {
                    return -1;
                }
            }
            d0();
            return 1;
        }
        if (!(obj instanceof VG)) {
            return 0;
        }
        C2428sS c2428sS = ((VG) obj).l;
        while (!atomicReferenceFieldUpdater.compareAndSet(this, obj, c2428sS)) {
            if (atomicReferenceFieldUpdater.get(this) != obj) {
                return -1;
            }
        }
        d0();
        return 1;
    }

    @Override // o.InterfaceC2557tn
    public final InterfaceC2652un getKey() {
        return C0669Zu.K;
    }

    public final Object i0(Object obj, Object obj2) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        if (!(obj instanceof WG)) {
            return AbstractC2841wm0.c;
        }
        if (((obj instanceof C0203Hv) || (obj instanceof AbstractC0992dJ)) && !(obj instanceof C0163Gh) && !(obj2 instanceof C2075oj)) {
            WG wg = (WG) obj;
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = l;
            Object xg = obj2 instanceof WG ? new XG((WG) obj2) : obj2;
            while (!atomicReferenceFieldUpdater.compareAndSet(this, wg, xg)) {
                if (atomicReferenceFieldUpdater.get(this) != wg) {
                    return AbstractC2841wm0.e;
                }
            }
            c0(obj2);
            H(wg, obj2);
            return obj2;
        }
        WG wg2 = (WG) obj;
        C2428sS c2428sSP = P(wg2);
        if (c2428sSP == null) {
            return AbstractC2841wm0.e;
        }
        C1279gJ c1279gJ = wg2 instanceof C1279gJ ? (C1279gJ) wg2 : null;
        if (c1279gJ == null) {
            c1279gJ = new C1279gJ(c2428sSP, null);
        }
        synchronized (c1279gJ) {
            AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = C1279gJ.m;
            if (atomicIntegerFieldUpdater.get(c1279gJ) != 0) {
                return AbstractC2841wm0.c;
            }
            atomicIntegerFieldUpdater.set(c1279gJ, 1);
            if (c1279gJ != wg2) {
                AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = l;
                while (!atomicReferenceFieldUpdater2.compareAndSet(this, wg2, c1279gJ)) {
                    if (atomicReferenceFieldUpdater2.get(this) != wg2) {
                        return AbstractC2841wm0.e;
                    }
                }
            }
            boolean zE = c1279gJ.e();
            C2075oj c2075oj = obj2 instanceof C2075oj ? (C2075oj) obj2 : null;
            if (c2075oj != null) {
                c1279gJ.a(c2075oj.a);
            }
            Throwable thC = zE ? null : c1279gJ.c();
            if (thC != null) {
                b0(c2428sSP, thC);
            }
            C0163Gh c0163GhA0 = a0(c2428sSP);
            if (c0163GhA0 != null && j0(c1279gJ, c0163GhA0, obj2)) {
                return AbstractC2841wm0.d;
            }
            c2428sSP.e(new IL(2), 2);
            C0163Gh c0163GhA02 = a0(c2428sSP);
            return (c0163GhA02 == null || !j0(c1279gJ, c0163GhA02, obj2)) ? J(c1279gJ, obj2) : AbstractC2841wm0.d;
        }
    }

    @Override // o.TI
    public final boolean isCancelled() {
        Object obj = l.get(this);
        if (obj instanceof C2075oj) {
            return true;
        }
        return (obj instanceof C1279gJ) && ((C1279gJ) obj).e();
    }

    @Override // o.TI
    public final InterfaceC2567ts j(boolean z, boolean z2, C2200q c2200q) {
        return V(z2, z ? new JI(c2200q) : new C2852ws(1, c2200q));
    }

    public final boolean j0(C1279gJ c1279gJ, C0163Gh c0163Gh, Object obj) {
        while (AbstractC0752ap.Q(c0163Gh.p, false, new C1183fJ(this, c1279gJ, c0163Gh, obj)) == C2713vS.l) {
            c0163Gh = a0(c0163Gh);
            if (c0163Gh == null) {
                return false;
            }
        }
        return true;
    }

    @Override // o.InterfaceC2747vn
    public final InterfaceC2747vn l(InterfaceC2652un interfaceC2652un) {
        return IJ.y(this, interfaceC2652un);
    }

    @Override // o.InterfaceC2747vn
    public final InterfaceC2557tn m(InterfaceC2652un interfaceC2652un) {
        return IJ.m(this, interfaceC2652un);
    }

    public Object q(Sb0 sb0) {
        return A(sb0);
    }

    @Override // o.TI
    public final boolean start() {
        int iG0;
        do {
            iG0 = g0(l.get(this));
            if (iG0 == 0) {
                return false;
            }
        } while (iG0 != 1);
        return true;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(Z() + '{' + h0(l.get(this)) + '}');
        sb.append('@');
        sb.append(AbstractC0249Jp.K(this));
        return sb.toString();
    }

    public void x(Object obj) {
        t(obj);
    }

    @Override // o.TI
    public final Object y(AbstractC0298Lm abstractC0298Lm) {
        Object obj;
        Oh0 oh0;
        do {
            obj = l.get(this);
            boolean z = obj instanceof WG;
            oh0 = Oh0.a;
            if (!z) {
                AbstractC0752ap.F(abstractC0298Lm.h());
                return oh0;
            }
        } while (g0(obj) < 0);
        C2448sg c2448sg = new C2448sg(1, AbstractC2539te.G(abstractC0298Lm));
        c2448sg.r();
        c2448sg.x(new C1499ig(2, AbstractC0752ap.Q(this, true, new C0111Eh(c2448sg, 1))));
        Object objQ = c2448sg.q();
        EnumC0091Dn enumC0091Dn = EnumC0091Dn.l;
        if (objQ != enumC0091Dn) {
            objQ = oh0;
        }
        return objQ == enumC0091Dn ? objQ : oh0;
    }

    @Override // o.TI
    public final CancellationException z() {
        CancellationException cancellationException;
        Object obj = l.get(this);
        if (!(obj instanceof C1279gJ)) {
            if (obj instanceof WG) {
                throw new IllegalStateException(("Job is still new or active: " + this).toString());
            }
            if (!(obj instanceof C2075oj)) {
                return new UI(getClass().getSimpleName().concat(" has completed normally"), null, this);
            }
            Throwable th = ((C2075oj) obj).a;
            cancellationException = th instanceof CancellationException ? (CancellationException) th : null;
            return cancellationException == null ? new UI(F(), th, this) : cancellationException;
        }
        Throwable thC = ((C1279gJ) obj).c();
        if (thC == null) {
            throw new IllegalStateException(("Job is still new or active: " + this).toString());
        }
        String strConcat = getClass().getSimpleName().concat(" is cancelling");
        cancellationException = thC instanceof CancellationException ? (CancellationException) thC : null;
        if (cancellationException != null) {
            return cancellationException;
        }
        if (strConcat == null) {
            strConcat = F();
        }
        return new UI(strConcat, thC, this);
    }

    public void d0() {
    }

    public void T(C2170pj c2170pj) {
        throw c2170pj;
    }

    public void c0(Object obj) {
    }

    public void t(Object obj) {
    }
}
