package J0;

import androidx.compose.runtime.snapshots.Snapshot;
import java.util.concurrent.CancellationException;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class D0 extends C4.j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public X4.v f2807a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public X4.b f2808b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f2809c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ X4.e f2810d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public D0(X4.e eVar, A4.d dVar) {
        super(2, dVar);
        this.f2810d = eVar;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new D0(this.f2810d, dVar);
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((D0) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0033 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x003c A[Catch: all -> 0x0012, TRY_LEAVE, TryCatch #0 {all -> 0x0012, blocks: (B:6:0x000e, B:17:0x0034, B:19:0x003c, B:14:0x0027, B:13:0x0021), top: B:32:0x0006 }] */
    /* JADX WARN: Removed duplicated region for block: B:21:0x004e  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:15:0x0031 -> B:17:0x0034). Please report as a decompilation issue!!! */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        X4.b bVar;
        X4.v vVar;
        X4.v vVar2;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f2809c;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                X4.e eVar = this.f2810d;
                bVar = new X4.b(eVar);
                vVar = eVar;
                this.f2807a = vVar;
                this.f2808b = bVar;
                this.f2809c = 1;
                obj = bVar.b(this);
                vVar2 = vVar;
                if (obj == aVar) {
                }
                if (((Boolean) obj).booleanValue()) {
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                bVar = this.f2808b;
                X4.v vVar3 = this.f2807a;
                AbstractC2467b.l(obj);
                vVar2 = vVar3;
                if (((Boolean) obj).booleanValue()) {
                    E0.f2815b.set(false);
                    Snapshot.Companion.sendApplyNotifications();
                    vVar = vVar2;
                    this.f2807a = vVar;
                    this.f2808b = bVar;
                    this.f2809c = 1;
                    obj = bVar.b(this);
                    vVar2 = vVar;
                    if (obj == aVar) {
                        return aVar;
                    }
                    if (((Boolean) obj).booleanValue()) {
                        vVar2.cancel(null);
                        return C3137A.f25453a;
                    }
                }
            }
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                CancellationException cancellationExceptionA = th instanceof CancellationException ? th : null;
                if (cancellationExceptionA == null) {
                    cancellationExceptionA = V4.E.a("Channel was consumed, consumer had failed", th);
                }
                vVar2.cancel(cancellationExceptionA);
                throw th2;
            }
        }
    }
}
