package g.a.o2;

import f.l;
import f.m;
import f.t;
import f.w.d;
import f.w.j.c;
import f.z.c.p;
import g.a.n2.h;

/* JADX INFO: compiled from: Cancellable.kt */
/* JADX INFO: loaded from: classes.dex */
public final class a {
    private static final void a(d<?> dVar, Throwable th) throws Throwable {
        l.a aVar = l.f3940b;
        Object objA = m.a(th);
        l.a(objA);
        dVar.resumeWith(objA);
        throw th;
    }

    public static final void b(d<? super t> dVar, d<?> dVar2) throws Throwable {
        try {
            d dVarC = c.c(dVar);
            l.a aVar = l.f3940b;
            t tVar = t.a;
            l.a(tVar);
            h.c(dVarC, tVar, null, 2, null);
        } catch (Throwable th) {
            a(dVar2, th);
            throw null;
        }
    }

    public static final <T> void c(f.z.c.l<? super d<? super T>, ? extends Object> lVar, d<? super T> dVar) throws Throwable {
        try {
            d dVarC = c.c(c.a(lVar, dVar));
            l.a aVar = l.f3940b;
            t tVar = t.a;
            l.a(tVar);
            h.c(dVarC, tVar, null, 2, null);
        } catch (Throwable th) {
            a(dVar, th);
            throw null;
        }
    }

    public static final <R, T> void d(p<? super R, ? super d<? super T>, ? extends Object> pVar, R r, d<? super T> dVar, f.z.c.l<? super Throwable, t> lVar) throws Throwable {
        try {
            d dVarC = c.c(c.b(pVar, r, dVar));
            l.a aVar = l.f3940b;
            t tVar = t.a;
            l.a(tVar);
            h.b(dVarC, tVar, lVar);
        } catch (Throwable th) {
            a(dVar, th);
            throw null;
        }
    }

    public static /* synthetic */ void e(p pVar, Object obj, d dVar, f.z.c.l lVar, int i2, Object obj2) throws Throwable {
        if ((i2 & 4) != 0) {
            lVar = null;
        }
        d(pVar, obj, dVar, lVar);
    }
}
