package kotlinx.coroutines;

import kotlin.NoWhenBranchMatchedException;
import kotlin.Result;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function2;

/* JADX INFO: loaded from: classes.dex */
public abstract class a extends g1 implements Continuation, x {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final kotlin.coroutines.h f29289c;

    public a(kotlin.coroutines.h hVar, boolean z10) {
        super(z10);
        K((y0) hVar.m(u.f29565b));
        this.f29289c = hVar.p(this);
    }

    @Override // kotlinx.coroutines.g1
    public final void J(CompletionHandlerException completionHandlerException) {
        hb.a.g0(this.f29289c, completionHandlerException);
    }

    @Override // kotlinx.coroutines.g1
    public String P() {
        return super.P();
    }

    @Override // kotlinx.coroutines.g1
    public final void S(Object obj) {
        if (!(obj instanceof q)) {
            Z(obj);
            return;
        }
        q qVar = (q) obj;
        Throwable th = qVar.f29523a;
        qVar.getClass();
        Y(th, q.f29522b.get(qVar) != 0);
    }

    public void Y(Throwable th, boolean z10) {
    }

    public void Z(Object obj) {
    }

    public final void a0(CoroutineStart coroutineStart, a aVar, Function2 function2) {
        int iOrdinal = coroutineStart.ordinal();
        if (iOrdinal == 0) {
            kotlinx.coroutines.flow.h.N(function2, aVar, this);
            return;
        }
        if (iOrdinal != 1) {
            if (iOrdinal == 2) {
                nb.g.F(nb.g.q(aVar, this, function2)).resumeWith(kd.e.f29109a);
            } else {
                if (iOrdinal != 3) {
                    throw new NoWhenBranchMatchedException();
                }
                y.b0(aVar, this, function2);
            }
        }
    }

    @Override // kotlin.coroutines.Continuation
    public final kotlin.coroutines.h getContext() {
        return this.f29289c;
    }

    @Override // kotlinx.coroutines.x
    public final kotlin.coroutines.h getCoroutineContext() {
        return this.f29289c;
    }

    @Override // kotlinx.coroutines.g1, kotlinx.coroutines.y0
    public boolean isActive() {
        return super.isActive();
    }

    @Override // kotlin.coroutines.Continuation
    public final void resumeWith(Object obj) {
        Throwable thA = Result.a(obj);
        if (thA != null) {
            obj = new q(thA, false);
        }
        Object objO = O(obj);
        if (objO == y.f29586m) {
            return;
        }
        o(objO);
    }

    @Override // kotlinx.coroutines.g1
    public final String t() {
        return getClass().getSimpleName().concat(" was cancelled");
    }
}
