package H1;

import F1.C0143y;
import F1.v0;
import kotlin.coroutines.jvm.internal.h;
import kotlin.jvm.internal.z;
import kotlinx.coroutines.internal.q;
import kotlinx.coroutines.internal.v;
import n1.l;
import n1.m;
import q1.d;
import q1.g;
import r1.AbstractC0707b;
import y1.l;
import y1.p;

/* JADX INFO: loaded from: classes.dex */
public abstract class b {
    public static final void a(l lVar, d dVar) {
        d dVarA = h.a(dVar);
        try {
            g context = dVar.getContext();
            Object objC = v.c(context, null);
            try {
                if (lVar == null) {
                    throw new NullPointerException("null cannot be cast to non-null type (kotlin.coroutines.Continuation<T>) -> kotlin.Any?");
                }
                Object objInvoke = ((l) z.b(lVar, 1)).invoke(dVarA);
                if (objInvoke != AbstractC0707b.d()) {
                    dVarA.resumeWith(n1.l.b(objInvoke));
                }
            } finally {
                v.a(context, objC);
            }
        } catch (Throwable th) {
            l.a aVar = n1.l.f5861g;
            dVarA.resumeWith(n1.l.b(m.a(th)));
        }
    }

    public static final void b(p pVar, Object obj, d dVar) {
        d dVarA = h.a(dVar);
        try {
            g context = dVar.getContext();
            Object objC = v.c(context, null);
            try {
                if (pVar == null) {
                    throw new NullPointerException("null cannot be cast to non-null type (R, kotlin.coroutines.Continuation<T>) -> kotlin.Any?");
                }
                Object objInvoke = ((p) z.b(pVar, 2)).invoke(obj, dVarA);
                if (objInvoke != AbstractC0707b.d()) {
                    dVarA.resumeWith(n1.l.b(objInvoke));
                }
            } finally {
                v.a(context, objC);
            }
        } catch (Throwable th) {
            l.a aVar = n1.l.f5861g;
            dVarA.resumeWith(n1.l.b(m.a(th)));
        }
    }

    public static final Object c(q qVar, Object obj, p pVar) throws Throwable {
        Object c0143y;
        Object objV;
        try {
        } catch (Throwable th) {
            c0143y = new C0143y(th, false, 2, null);
        }
        if (pVar == null) {
            throw new NullPointerException("null cannot be cast to non-null type (R, kotlin.coroutines.Continuation<T>) -> kotlin.Any?");
        }
        c0143y = ((p) z.b(pVar, 2)).invoke(obj, qVar);
        if (c0143y != AbstractC0707b.d() && (objV = qVar.V(c0143y)) != v0.f653b) {
            if (objV instanceof C0143y) {
                throw ((C0143y) objV).f667a;
            }
            return v0.h(objV);
        }
        return AbstractC0707b.d();
    }
}
