package z;

import l1.i;
import tp.b1;
import tp.u1;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class t extends i.c {
    private d0.l C;
    private d0.d D;
    private final boolean E;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        int f53059p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ d0.l f53060q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ d0.i f53061r;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ b1 f53062s;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(d0.l lVar, d0.i iVar, b1 b1Var, vm.d dVar) {
            super(2, dVar);
            this.f53060q = lVar;
            this.f53061r = iVar;
            this.f53062s = b1Var;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new a(this.f53060q, this.f53061r, this.f53062s, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f53059p;
            if (i10 == 0) {
                rm.y.b(obj);
                d0.l lVar = this.f53060q;
                d0.i iVar = this.f53061r;
                this.f53059p = 1;
                if (lVar.c(iVar, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            b1 b1Var = this.f53062s;
            if (b1Var != null) {
                b1Var.a();
            }
            return rm.n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(tp.m0 m0Var, vm.d dVar) {
            return ((a) create(m0Var, dVar)).invokeSuspend(rm.n0.f34904a);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class b extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ d0.l f53063p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ d0.i f53064q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(d0.l lVar, d0.i iVar) {
            super(1);
            this.f53063p = lVar;
            this.f53064q = iVar;
        }

        public final void a(Throwable th2) {
            this.f53063p.b(this.f53064q);
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((Throwable) obj);
            return rm.n0.f34904a;
        }
    }

    public t(d0.l lVar) {
        this.C = lVar;
    }

    private final void h2() {
        d0.d dVar;
        d0.l lVar = this.C;
        if (lVar != null && (dVar = this.D) != null) {
            lVar.b(new d0.e(dVar));
        }
        this.D = null;
    }

    private final void i2(d0.l lVar, d0.i iVar) {
        if (!O1()) {
            lVar.b(iVar);
        } else {
            u1 u1Var = (u1) H1().getCoroutineContext().d(u1.f36592j);
            tp.k.d(H1(), null, null, new a(lVar, iVar, u1Var != null ? u1Var.T(new b(lVar, iVar)) : null, null), 3, null);
        }
    }

    @Override // l1.i.c
    public boolean M1() {
        return this.E;
    }

    public final void j2(boolean z10) {
        d0.l lVar = this.C;
        if (lVar != null) {
            if (!z10) {
                d0.d dVar = this.D;
                if (dVar != null) {
                    i2(lVar, new d0.e(dVar));
                    this.D = null;
                    return;
                }
                return;
            }
            d0.d dVar2 = this.D;
            if (dVar2 != null) {
                i2(lVar, new d0.e(dVar2));
                this.D = null;
            }
            d0.d dVar3 = new d0.d();
            i2(lVar, dVar3);
            this.D = dVar3;
        }
    }

    public final void k2(d0.l lVar) {
        if (kotlin.jvm.internal.t.b(this.C, lVar)) {
            return;
        }
        h2();
        this.C = lVar;
    }
}
