package d2;

import d2.z0;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlinx.coroutines.internal.o;
import n1.f;

/* JADX INFO: compiled from: JobSupport.kt */
/* JADX INFO: loaded from: classes.dex */
public class f1 implements z0, l, l1 {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private static final /* synthetic */ AtomicReferenceFieldUpdater f4476e = AtomicReferenceFieldUpdater.newUpdater(f1.class, Object.class, "_state");
    private volatile /* synthetic */ Object _parentHandle;
    private volatile /* synthetic */ Object _state;

    /* JADX INFO: compiled from: JobSupport.kt */
    private static final class a extends e1 {

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        private final f1 f4477i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        private final b f4478j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        private final k f4479k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        private final Object f4480l;

        public a(f1 f1Var, b bVar, k kVar, Object obj) {
            this.f4477i = f1Var;
            this.f4478j = bVar;
            this.f4479k = kVar;
            this.f4480l = obj;
        }

        @Override // v1.l
        public /* bridge */ /* synthetic */ k1.o e(Throwable th) {
            s(th);
            return k1.o.f5171a;
        }

        @Override // d2.p
        public void s(Throwable th) {
            this.f4477i.A(this.f4478j, this.f4479k, this.f4480l);
        }
    }

    /* JADX INFO: compiled from: JobSupport.kt */
    private static final class b implements v0 {
        private volatile /* synthetic */ Object _exceptionsHolder = null;
        private volatile /* synthetic */ int _isCompleting;
        private volatile /* synthetic */ Object _rootCause;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private final i1 f4481e;

        public b(i1 i1Var, boolean z2, Throwable th) {
            this.f4481e = i1Var;
            this._isCompleting = z2 ? 1 : 0;
            this._rootCause = th;
        }

        private final ArrayList<Throwable> d() {
            return new ArrayList<>(4);
        }

        private final Object e() {
            return this._exceptionsHolder;
        }

        private final void l(Object obj) {
            this._exceptionsHolder = obj;
        }

        @Override // d2.v0
        public boolean a() {
            return f() == null;
        }

        public final void b(Throwable th) {
            Throwable thF = f();
            if (thF == null) {
                m(th);
                return;
            }
            if (th == thF) {
                return;
            }
            Object objE = e();
            if (objE == null) {
                l(th);
                return;
            }
            if (!(objE instanceof Throwable)) {
                if (!(objE instanceof ArrayList)) {
                    throw new IllegalStateException(w1.g.j("State is ", objE).toString());
                }
                ((ArrayList) objE).add(th);
            } else {
                if (th == objE) {
                    return;
                }
                ArrayList<Throwable> arrayListD = d();
                arrayListD.add(objE);
                arrayListD.add(th);
                l(arrayListD);
            }
        }

        @Override // d2.v0
        public i1 c() {
            return this.f4481e;
        }

        public final Throwable f() {
            return (Throwable) this._rootCause;
        }

        public final boolean g() {
            return f() != null;
        }

        /* JADX WARN: Type inference failed for: r0v1, types: [boolean, int] */
        public final boolean h() {
            return this._isCompleting;
        }

        public final boolean i() {
            return e() == g1.f4488e;
        }

        public final List<Throwable> j(Throwable th) {
            ArrayList<Throwable> arrayListD;
            Object objE = e();
            if (objE == null) {
                arrayListD = d();
            } else if (objE instanceof Throwable) {
                ArrayList<Throwable> arrayListD2 = d();
                arrayListD2.add(objE);
                arrayListD = arrayListD2;
            } else {
                if (!(objE instanceof ArrayList)) {
                    throw new IllegalStateException(w1.g.j("State is ", objE).toString());
                }
                arrayListD = (ArrayList) objE;
            }
            Throwable thF = f();
            if (thF != null) {
                arrayListD.add(0, thF);
            }
            if (th != null && !w1.g.a(th, thF)) {
                arrayListD.add(th);
            }
            l(g1.f4488e);
            return arrayListD;
        }

        public final void k(boolean z2) {
            this._isCompleting = z2 ? 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=" + c() + ']';
        }
    }

    /* JADX INFO: compiled from: LockFreeLinkedList.kt */
    public static final class c extends o.a {

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        final /* synthetic */ f1 f4482d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final /* synthetic */ Object f4483e;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public c(kotlinx.coroutines.internal.o oVar, f1 f1Var, Object obj) {
            super(oVar);
            this.f4482d = f1Var;
            this.f4483e = obj;
        }

        @Override // kotlinx.coroutines.internal.c
        /* JADX INFO: renamed from: i, reason: merged with bridge method [inline-methods] */
        public Object g(kotlinx.coroutines.internal.o oVar) {
            if (this.f4482d.K() == this.f4483e) {
                return null;
            }
            return kotlinx.coroutines.internal.n.a();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void A(b bVar, k kVar, Object obj) {
        if (c0.a()) {
            if (!(K() == bVar)) {
                throw new AssertionError();
            }
        }
        k kVarS = S(kVar);
        if (kVarS == null || !j0(bVar, kVarS, obj)) {
            s(C(bVar, obj));
        }
    }

    private final Throwable B(Object obj) {
        if (obj == null ? true : obj instanceof Throwable) {
            Throwable th = (Throwable) obj;
            return th == null ? new a1(x(), null, this) : th;
        }
        Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.ParentJob");
        return ((l1) obj).e();
    }

    private final Object C(b bVar, Object obj) throws Throwable {
        boolean zG;
        Throwable thF;
        boolean z2 = true;
        if (c0.a()) {
            if (!(K() == bVar)) {
                throw new AssertionError();
            }
        }
        if (c0.a() && !(!bVar.i())) {
            throw new AssertionError();
        }
        if (c0.a() && !bVar.h()) {
            throw new AssertionError();
        }
        n nVar = obj instanceof n ? (n) obj : null;
        Throwable th = nVar == null ? null : nVar.f4508a;
        synchronized (bVar) {
            zG = bVar.g();
            List<Throwable> listJ = bVar.j(th);
            thF = F(bVar, listJ);
            if (thF != null) {
                r(thF, listJ);
            }
        }
        if (thF != null && thF != th) {
            obj = new n(thF, false, 2, null);
        }
        if (thF != null) {
            if (!w(thF) && !L(thF)) {
                z2 = false;
            }
            if (z2) {
                Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.CompletedExceptionally");
                ((n) obj).b();
            }
        }
        if (!zG) {
            V(thF);
        }
        W(obj);
        boolean zCompareAndSet = f4476e.compareAndSet(this, bVar, g1.f(obj));
        if (c0.a() && !zCompareAndSet) {
            throw new AssertionError();
        }
        z(bVar, obj);
        return obj;
    }

    private final k D(v0 v0Var) {
        k kVar = v0Var instanceof k ? (k) v0Var : null;
        if (kVar != null) {
            return kVar;
        }
        i1 i1VarC = v0Var.c();
        if (i1VarC == null) {
            return null;
        }
        return S(i1VarC);
    }

    private final Throwable E(Object obj) {
        n nVar = obj instanceof n ? (n) obj : null;
        if (nVar == null) {
            return null;
        }
        return nVar.f4508a;
    }

    private final Throwable F(b bVar, List<? extends Throwable> list) {
        Object obj = null;
        if (list.isEmpty()) {
            if (bVar.g()) {
                return new a1(x(), null, this);
            }
            return null;
        }
        Iterator<T> it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Object next = it.next();
            if (!(((Throwable) next) instanceof CancellationException)) {
                obj = next;
                break;
            }
        }
        Throwable th = (Throwable) obj;
        return th != null ? th : list.get(0);
    }

    private final i1 I(v0 v0Var) {
        i1 i1VarC = v0Var.c();
        if (i1VarC != null) {
            return i1VarC;
        }
        if (v0Var instanceof n0) {
            return new i1();
        }
        if (!(v0Var instanceof e1)) {
            throw new IllegalStateException(w1.g.j("State should have list: ", v0Var).toString());
        }
        Y((e1) v0Var);
        return null;
    }

    private final Object O(Object obj) throws Throwable {
        Throwable thB = null;
        while (true) {
            Object objK = K();
            if (objK instanceof b) {
                synchronized (objK) {
                    if (((b) objK).i()) {
                        return g1.f4487d;
                    }
                    boolean zG = ((b) objK).g();
                    if (obj != null || !zG) {
                        if (thB == null) {
                            thB = B(obj);
                        }
                        ((b) objK).b(thB);
                    }
                    Throwable thF = zG ^ true ? ((b) objK).f() : null;
                    if (thF != null) {
                        T(((b) objK).c(), thF);
                    }
                    return g1.f4484a;
                }
            }
            if (!(objK instanceof v0)) {
                return g1.f4487d;
            }
            if (thB == null) {
                thB = B(obj);
            }
            v0 v0Var = (v0) objK;
            if (!v0Var.a()) {
                Object objH0 = h0(objK, new n(thB, false, 2, null));
                if (objH0 == g1.f4484a) {
                    throw new IllegalStateException(w1.g.j("Cannot happen in ", objK).toString());
                }
                if (objH0 != g1.f4486c) {
                    return objH0;
                }
            } else if (g0(v0Var, thB)) {
                return g1.f4484a;
            }
        }
    }

    private final e1 Q(v1.l<? super Throwable, k1.o> lVar, boolean z2) {
        if (z2) {
            y0Var = lVar instanceof b1 ? (b1) lVar : null;
            if (y0Var == null) {
                y0Var = new x0(lVar);
            }
        } else {
            e1 e1Var = lVar instanceof e1 ? (e1) lVar : null;
            if (e1Var != null) {
                if (c0.a() && !(!(e1Var instanceof b1))) {
                    throw new AssertionError();
                }
                y0Var = e1Var;
            }
            if (y0Var == null) {
                y0Var = new y0(lVar);
            }
        }
        y0Var.u(this);
        return y0Var;
    }

    private final k S(kotlinx.coroutines.internal.o oVar) {
        while (oVar.n()) {
            oVar = oVar.m();
        }
        while (true) {
            oVar = oVar.l();
            if (!oVar.n()) {
                if (oVar instanceof k) {
                    return (k) oVar;
                }
                if (oVar instanceof i1) {
                    return null;
                }
            }
        }
    }

    private final void T(i1 i1Var, Throwable th) throws Throwable {
        q qVar;
        V(th);
        q qVar2 = null;
        for (kotlinx.coroutines.internal.o oVarL = (kotlinx.coroutines.internal.o) i1Var.k(); !w1.g.a(oVarL, i1Var); oVarL = oVarL.l()) {
            if (oVarL instanceof b1) {
                e1 e1Var = (e1) oVarL;
                try {
                    e1Var.s(th);
                } catch (Throwable th2) {
                    if (qVar2 == null) {
                        qVar = null;
                    } else {
                        k1.b.a(qVar2, th2);
                        qVar = qVar2;
                    }
                    if (qVar == null) {
                        qVar2 = new q("Exception in completion handler " + e1Var + " for " + this, th2);
                    }
                }
            }
        }
        if (qVar2 != null) {
            M(qVar2);
        }
        w(th);
    }

    private final void U(i1 i1Var, Throwable th) throws Throwable {
        q qVar;
        q qVar2 = null;
        for (kotlinx.coroutines.internal.o oVarL = (kotlinx.coroutines.internal.o) i1Var.k(); !w1.g.a(oVarL, i1Var); oVarL = oVarL.l()) {
            if (oVarL instanceof e1) {
                e1 e1Var = (e1) oVarL;
                try {
                    e1Var.s(th);
                } catch (Throwable th2) {
                    if (qVar2 == null) {
                        qVar = null;
                    } else {
                        k1.b.a(qVar2, th2);
                        qVar = qVar2;
                    }
                    if (qVar == null) {
                        qVar2 = new q("Exception in completion handler " + e1Var + " for " + this, th2);
                    }
                }
            }
        }
        if (qVar2 == null) {
            return;
        }
        M(qVar2);
    }

    private final void X(n0 n0Var) {
        i1 i1Var = new i1();
        Object u0Var = i1Var;
        if (!n0Var.a()) {
            u0Var = new u0(i1Var);
        }
        f4476e.compareAndSet(this, n0Var, u0Var);
    }

    private final void Y(e1 e1Var) {
        e1Var.g(new i1());
        f4476e.compareAndSet(this, e1Var, e1Var.l());
    }

    private final String b0(Object obj) {
        if (!(obj instanceof b)) {
            return obj instanceof v0 ? ((v0) obj).a() ? "Active" : "New" : obj instanceof n ? "Cancelled" : "Completed";
        }
        b bVar = (b) obj;
        return bVar.g() ? "Cancelling" : bVar.h() ? "Completing" : "Active";
    }

    public static /* synthetic */ CancellationException d0(f1 f1Var, Throwable th, String str, int i3, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: toCancellationException");
        }
        if ((i3 & 1) != 0) {
            str = null;
        }
        return f1Var.c0(th, str);
    }

    private final boolean f0(v0 v0Var, Object obj) throws Throwable {
        if (c0.a()) {
            if (!((v0Var instanceof n0) || (v0Var instanceof e1))) {
                throw new AssertionError();
            }
        }
        if (c0.a() && !(!(obj instanceof n))) {
            throw new AssertionError();
        }
        if (!f4476e.compareAndSet(this, v0Var, g1.f(obj))) {
            return false;
        }
        V(null);
        W(obj);
        z(v0Var, obj);
        return true;
    }

    private final boolean g0(v0 v0Var, Throwable th) throws Throwable {
        if (c0.a() && !(!(v0Var instanceof b))) {
            throw new AssertionError();
        }
        if (c0.a() && !v0Var.a()) {
            throw new AssertionError();
        }
        i1 i1VarI = I(v0Var);
        if (i1VarI == null) {
            return false;
        }
        if (!f4476e.compareAndSet(this, v0Var, new b(i1VarI, false, th))) {
            return false;
        }
        T(i1VarI, th);
        return true;
    }

    private final Object h0(Object obj, Object obj2) {
        return !(obj instanceof v0) ? g1.f4484a : ((!(obj instanceof n0) && !(obj instanceof e1)) || (obj instanceof k) || (obj2 instanceof n)) ? i0((v0) obj, obj2) : f0((v0) obj, obj2) ? obj2 : g1.f4486c;
    }

    private final Object i0(v0 v0Var, Object obj) throws Throwable {
        i1 i1VarI = I(v0Var);
        if (i1VarI == null) {
            return g1.f4486c;
        }
        b bVar = v0Var instanceof b ? (b) v0Var : null;
        if (bVar == null) {
            bVar = new b(i1VarI, false, null);
        }
        synchronized (bVar) {
            if (bVar.h()) {
                return g1.f4484a;
            }
            bVar.k(true);
            if (bVar != v0Var && !f4476e.compareAndSet(this, v0Var, bVar)) {
                return g1.f4486c;
            }
            if (c0.a() && !(!bVar.i())) {
                throw new AssertionError();
            }
            boolean zG = bVar.g();
            n nVar = obj instanceof n ? (n) obj : null;
            if (nVar != null) {
                bVar.b(nVar.f4508a);
            }
            Throwable thF = true ^ zG ? bVar.f() : null;
            k1.o oVar = k1.o.f5171a;
            if (thF != null) {
                T(i1VarI, thF);
            }
            k kVarD = D(v0Var);
            return (kVarD == null || !j0(bVar, kVarD, obj)) ? C(bVar, obj) : g1.f4485b;
        }
    }

    private final boolean j0(b bVar, k kVar, Object obj) {
        while (z0.a.c(kVar.f4500i, false, false, new a(this, bVar, kVar, obj), 1, null) == j1.f4499e) {
            kVar = S(kVar);
            if (kVar == null) {
                return false;
            }
        }
        return true;
    }

    private final boolean q(Object obj, i1 i1Var, e1 e1Var) {
        int iR;
        c cVar = new c(e1Var, this, obj);
        do {
            iR = i1Var.m().r(e1Var, i1Var, cVar);
            if (iR == 1) {
                return true;
            }
        } while (iR != 2);
        return false;
    }

    private final void r(Throwable th, List<? extends Throwable> list) {
        if (list.size() <= 1) {
            return;
        }
        Set setNewSetFromMap = Collections.newSetFromMap(new IdentityHashMap(list.size()));
        Throwable thL = !c0.c() ? th : kotlinx.coroutines.internal.a0.l(th);
        for (Throwable thL2 : list) {
            if (c0.c()) {
                thL2 = kotlinx.coroutines.internal.a0.l(thL2);
            }
            if (thL2 != th && thL2 != thL && !(thL2 instanceof CancellationException) && setNewSetFromMap.add(thL2)) {
                k1.b.a(th, thL2);
            }
        }
    }

    private final Object v(Object obj) {
        Object objH0;
        do {
            Object objK = K();
            if (!(objK instanceof v0) || ((objK instanceof b) && ((b) objK).h())) {
                return g1.f4484a;
            }
            objH0 = h0(objK, new n(B(obj), false, 2, null));
        } while (objH0 == g1.f4486c);
        return objH0;
    }

    private final boolean w(Throwable th) {
        if (N()) {
            return true;
        }
        boolean z2 = th instanceof CancellationException;
        j jVarJ = J();
        return (jVarJ == null || jVarJ == j1.f4499e) ? z2 : jVarJ.d(th) || z2;
    }

    private final void z(v0 v0Var, Object obj) throws Throwable {
        j jVarJ = J();
        if (jVarJ != null) {
            jVarJ.b();
            a0(j1.f4499e);
        }
        n nVar = obj instanceof n ? (n) obj : null;
        Throwable th = nVar != null ? nVar.f4508a : null;
        if (!(v0Var instanceof e1)) {
            i1 i1VarC = v0Var.c();
            if (i1VarC == null) {
                return;
            }
            U(i1VarC, th);
            return;
        }
        try {
            ((e1) v0Var).s(th);
        } catch (Throwable th2) {
            M(new q("Exception in completion handler " + v0Var + " for " + this, th2));
        }
    }

    public boolean G() {
        return true;
    }

    public boolean H() {
        return false;
    }

    public final j J() {
        return (j) this._parentHandle;
    }

    public final Object K() {
        while (true) {
            Object obj = this._state;
            if (!(obj instanceof kotlinx.coroutines.internal.w)) {
                return obj;
            }
            ((kotlinx.coroutines.internal.w) obj).c(this);
        }
    }

    protected boolean L(Throwable th) {
        return false;
    }

    public void M(Throwable th) throws Throwable {
        throw th;
    }

    protected boolean N() {
        return false;
    }

    public final Object P(Object obj) {
        Object objH0;
        do {
            objH0 = h0(K(), obj);
            if (objH0 == g1.f4484a) {
                throw new IllegalStateException("Job " + this + " is already complete or completing, but is being completed with " + obj, E(obj));
            }
        } while (objH0 == g1.f4486c);
        return objH0;
    }

    public String R() {
        return d0.a(this);
    }

    protected void V(Throwable th) {
    }

    protected void W(Object obj) {
    }

    public final void Z(e1 e1Var) {
        Object objK;
        do {
            objK = K();
            if (!(objK instanceof e1)) {
                if (!(objK instanceof v0) || ((v0) objK).c() == null) {
                    return;
                }
                e1Var.o();
                return;
            }
            if (objK != e1Var) {
                return;
            }
        } while (!f4476e.compareAndSet(this, objK, g1.f4489f));
    }

    @Override // d2.z0
    public boolean a() {
        Object objK = K();
        return (objK instanceof v0) && ((v0) objK).a();
    }

    public final void a0(j jVar) {
        this._parentHandle = jVar;
    }

    @Override // d2.z0
    public final m0 c(boolean z2, boolean z3, v1.l<? super Throwable, k1.o> lVar) {
        e1 e1VarQ = Q(lVar, z2);
        while (true) {
            Object objK = K();
            if (objK instanceof n0) {
                n0 n0Var = (n0) objK;
                if (!n0Var.a()) {
                    X(n0Var);
                } else if (f4476e.compareAndSet(this, objK, e1VarQ)) {
                    return e1VarQ;
                }
            } else {
                if (!(objK instanceof v0)) {
                    if (z3) {
                        n nVar = objK instanceof n ? (n) objK : null;
                        lVar.e(nVar != null ? nVar.f4508a : null);
                    }
                    return j1.f4499e;
                }
                i1 i1VarC = ((v0) objK).c();
                if (i1VarC == null) {
                    Objects.requireNonNull(objK, "null cannot be cast to non-null type kotlinx.coroutines.JobNode");
                    Y((e1) objK);
                } else {
                    m0 m0Var = j1.f4499e;
                    if (z2 && (objK instanceof b)) {
                        synchronized (objK) {
                            thF = ((b) objK).f();
                            if (thF == null || ((lVar instanceof k) && !((b) objK).h())) {
                                if (q(objK, i1VarC, e1VarQ)) {
                                    if (thF == null) {
                                        return e1VarQ;
                                    }
                                    m0Var = e1VarQ;
                                }
                            }
                            k1.o oVar = k1.o.f5171a;
                        }
                    }
                    if (thF != null) {
                        if (z3) {
                            lVar.e(thF);
                        }
                        return m0Var;
                    }
                    if (q(objK, i1VarC, e1VarQ)) {
                        return e1VarQ;
                    }
                }
            }
        }
    }

    protected final CancellationException c0(Throwable th, String str) {
        CancellationException a1Var = th instanceof CancellationException ? (CancellationException) th : null;
        if (a1Var == null) {
            if (str == null) {
                str = x();
            }
            a1Var = new a1(str, th, this);
        }
        return a1Var;
    }

    @Override // d2.l1
    public CancellationException e() {
        Throwable thF;
        Object objK = K();
        if (objK instanceof b) {
            thF = ((b) objK).f();
        } else if (objK instanceof n) {
            thF = ((n) objK).f4508a;
        } else {
            if (objK instanceof v0) {
                throw new IllegalStateException(w1.g.j("Cannot be cancelling child in this state: ", objK).toString());
            }
            thF = null;
        }
        CancellationException cancellationException = thF instanceof CancellationException ? (CancellationException) thF : null;
        return cancellationException == null ? new a1(w1.g.j("Parent job is ", b0(objK)), thF, this) : cancellationException;
    }

    public final String e0() {
        return R() + '{' + b0(K()) + '}';
    }

    @Override // d2.z0
    public final CancellationException f() {
        Object objK = K();
        if (!(objK instanceof b)) {
            if (objK instanceof v0) {
                throw new IllegalStateException(w1.g.j("Job is still new or active: ", this).toString());
            }
            return objK instanceof n ? d0(this, ((n) objK).f4508a, null, 1, null) : new a1(w1.g.j(d0.a(this), " has completed normally"), null, this);
        }
        Throwable thF = ((b) objK).f();
        CancellationException cancellationExceptionC0 = thF != null ? c0(thF, w1.g.j(d0.a(this), " is cancelling")) : null;
        if (cancellationExceptionC0 != null) {
            return cancellationExceptionC0;
        }
        throw new IllegalStateException(w1.g.j("Job is still new or active: ", this).toString());
    }

    @Override // n1.f
    public <R> R fold(R r2, v1.p<? super R, ? super f.b, ? extends R> pVar) {
        return (R) z0.a.a(this, r2, pVar);
    }

    @Override // n1.f.b, n1.f
    public <E extends f.b> E get(f.c<E> cVar) {
        return (E) z0.a.b(this, cVar);
    }

    @Override // n1.f.b
    public final f.c<?> getKey() {
        return z0.f4542c;
    }

    @Override // d2.l
    public final void h(l1 l1Var) throws Throwable {
        t(l1Var);
    }

    @Override // d2.z0
    public void k(CancellationException cancellationException) throws Throwable {
        if (cancellationException == null) {
            cancellationException = new a1(x(), null, this);
        }
        u(cancellationException);
    }

    @Override // n1.f
    public n1.f minusKey(f.c<?> cVar) {
        return z0.a.d(this, cVar);
    }

    protected void s(Object obj) {
    }

    public final boolean t(Object obj) throws Throwable {
        Object objO = g1.f4484a;
        if (H() && (objO = v(obj)) == g1.f4485b) {
            return true;
        }
        if (objO == g1.f4484a) {
            objO = O(obj);
        }
        if (objO == g1.f4484a || objO == g1.f4485b) {
            return true;
        }
        if (objO == g1.f4487d) {
            return false;
        }
        s(objO);
        return true;
    }

    public String toString() {
        return e0() + '@' + d0.b(this);
    }

    public void u(Throwable th) throws Throwable {
        t(th);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public String x() {
        return "Job was cancelled";
    }

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