package tp;

import java.util.concurrent.CancellationException;

/* loaded from: classes3.dex */
public abstract class n0 {
    public static final m0 a(vm.g gVar) {
        if (gVar.d(u1.f36592j) == null) {
            gVar = gVar.h(y1.b(null, 1, null));
        }
        return new zp.f(gVar);
    }

    public static final m0 b() {
        return new zp.f(r2.b(null, 1, null).h(a1.c()));
    }

    public static final void c(m0 m0Var, String str, Throwable th2) {
        d(m0Var, j1.a(str, th2));
    }

    public static final void d(m0 m0Var, CancellationException cancellationException) {
        u1 u1Var = (u1) m0Var.getCoroutineContext().d(u1.f36592j);
        if (u1Var != null) {
            u1Var.c(cancellationException);
            return;
        }
        throw new IllegalStateException(("Scope cannot be cancelled because it does not have a job: " + m0Var).toString());
    }

    public static /* synthetic */ void e(m0 m0Var, CancellationException cancellationException, int i10, Object obj) {
        if ((i10 & 1) != 0) {
            cancellationException = null;
        }
        d(m0Var, cancellationException);
    }

    public static final Object f(dn.p pVar, vm.d dVar) {
        Object f10;
        zp.d0 d0Var = new zp.d0(dVar.getContext(), dVar);
        Object c10 = aq.b.c(d0Var, d0Var, pVar);
        f10 = wm.d.f();
        if (c10 == f10) {
            kotlin.coroutines.jvm.internal.h.c(dVar);
        }
        return c10;
    }

    public static final void g(m0 m0Var) {
        y1.j(m0Var.getCoroutineContext());
    }

    public static final boolean h(m0 m0Var) {
        u1 u1Var = (u1) m0Var.getCoroutineContext().d(u1.f36592j);
        if (u1Var != null) {
            return u1Var.b();
        }
        return true;
    }

    public static final m0 i(m0 m0Var, vm.g gVar) {
        return new zp.f(m0Var.getCoroutineContext().h(gVar));
    }
}
