package defpackage;

import androidx.media3.container.NalUnitUtil;
import defpackage.fx4;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.BaseContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlinx.coroutines.b;

/* JADX INFO: loaded from: classes3.dex */
@gq4
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b'\u0018\u0000*\u0006\b\u0000\u0010\u0001 \u00002\u00020\u00022\u00020\u00032\b\u0012\u0004\u0012\u00028\u00000\u00042\u00020\u0005¨\u0006\u0006"}, d2 = {"Lbh;", "T", "Lrx4;", "Lfx4;", "Lkotlin/coroutines/Continuation;", "Lak1;", "kotlinx-coroutines-core"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public abstract class bh<T> extends rx4 implements fx4, Continuation<T>, ak1 {
    public final gj1 c;

    public bh(gj1 gj1Var, boolean z, boolean z2) {
        super(z2);
        if (z) {
            bf((fx4) gj1Var.cb(fx4.b.a));
        }
        this.c = gj1Var.bx(this);
    }

    @Override // defpackage.rx4
    public final String aj() {
        return getClass().getSimpleName().concat(" was cancelled");
    }

    @Override // defpackage.rx4
    public final void be(x81 x81Var) {
        b.a(this.c, x81Var);
    }

    @Override // defpackage.rx4
    public final void bt(Object obj) {
        if (!(obj instanceof w81)) {
            ck(obj);
        } else {
            w81 w81Var = (w81) obj;
            cj(w81Var.a, w81.b.get(w81Var) != 0);
        }
    }

    public void cj(Throwable th, boolean z) {
    }

    public void ck(Object obj) {
    }

    public final void cl(dk1 dk1Var, bh bhVar, gr3 gr3Var) {
        Object objInvoke;
        int iOrdinal = dk1Var.ordinal();
        e6a e6aVar = e6a.a;
        if (iOrdinal == 0) {
            try {
                mc2.a(e6aVar, dr4.d(dr4.b(gr3Var, bhVar, this)));
                return;
            } catch (Throwable th) {
                resumeWith(s38.a(th));
                throw th;
            }
        }
        if (iOrdinal != 1) {
            if (iOrdinal == 2) {
                cr4.g(gr3Var, "<this>");
                dr4.d(dr4.b(gr3Var, bhVar, this)).resumeWith(e6aVar);
                return;
            }
            if (iOrdinal != 3) {
                throw new io6();
            }
            Continuation continuationProbeCoroutineCreated = DebugProbesKt.probeCoroutineCreated(this);
            try {
                gj1 c = continuationProbeCoroutineCreated.getB();
                Object objC = wl9.c(c, null);
                try {
                    DebugProbesKt.probeCoroutineResumed(continuationProbeCoroutineCreated);
                    if (gr3Var instanceof BaseContinuationImpl) {
                        hz9.e(2, gr3Var);
                        objInvoke = gr3Var.invoke(bhVar, continuationProbeCoroutineCreated);
                    } else {
                        objInvoke = dr4.e(gr3Var, bhVar, continuationProbeCoroutineCreated);
                    }
                    wl9.a(c, objC);
                    if (objInvoke != ck1.a) {
                        continuationProbeCoroutineCreated.resumeWith(objInvoke);
                    }
                } catch (Throwable th2) {
                    wl9.a(c, objC);
                    throw th2;
                }
            } catch (Throwable th3) {
                continuationProbeCoroutineCreated.resumeWith(s38.a(th3));
            }
        }
    }

    @Override // kotlin.coroutines.Continuation
    /* JADX INFO: renamed from: getContext, reason: from getter */
    public final gj1 getB() {
        return this.c;
    }

    @Override // defpackage.ak1
    /* JADX INFO: renamed from: k */
    public final gj1 getB() {
        return this.c;
    }

    @Override // kotlin.coroutines.Continuation
    public final void resumeWith(Object obj) {
        Throwable thA = q38.a(obj);
        if (thA != null) {
            obj = new w81(thA, false);
        }
        Object objBm = bm(obj);
        if (objBm == wx4.b) {
            return;
        }
        y(objBm);
    }
}
