package h3;

import com.debridstream.tv.screens.CloudManagerViewModel;
import java.util.Map;
import m3.AbstractC2467b;
import w4.C3137A;
import x4.AbstractC3229F;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public /* synthetic */ Object f17664b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ CloudManagerViewModel f17665c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ String f17666d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ String f17667e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public Z(CloudManagerViewModel cloudManagerViewModel, String str, String str2, A4.d dVar) {
        super(2, dVar);
        this.f17665c = cloudManagerViewModel;
        this.f17666d = str;
        this.f17667e = str2;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        Z z6 = new Z(this.f17665c, this.f17666d, this.f17667e, dVar);
        z6.f17664b = obj;
        return z6;
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f17663a;
        C3137A c3137a = C3137A.f25453a;
        CloudManagerViewModel cloudManagerViewModel = this.f17665c;
        String str = this.f17667e;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                Y4.H h5 = cloudManagerViewModel._uiState;
                U uA = U.a((U) ((Y4.c0) cloudManagerViewModel._uiState).getValue(), null, false, false, null, null, false, true, null, null, null, null, null, null, 8111);
                Y4.c0 c0Var = (Y4.c0) h5;
                c0Var.getClass();
                c0Var.k(null, uA);
                String str2 = this.f17666d;
                this.f17663a = 1;
                if (cloudManagerViewModel.persistProviderKey(str2, str, "", this) == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            objD = c3137a;
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (!(objD instanceof w4.m)) {
            U u6 = (U) ((Y4.c0) cloudManagerViewModel._uiState).getValue();
            Map mapA = AbstractC3229F.A(new w4.k(str, ""), u6.f17445i);
            N2.q.m(mapA);
            Y4.H h6 = cloudManagerViewModel._uiState;
            Map mapA2 = AbstractC3229F.A(new w4.k(str, null), u6.f17446j);
            x4.y yVar = x4.y.f26065a;
            U uA2 = U.a(u6, null, false, false, null, null, false, false, null, mapA, mapA2, AbstractC3229F.A(new w4.k(str, yVar), u6.f17447k), AbstractC3229F.A(new w4.k(str, yVar), u6.l), AbstractC3229F.A(new w4.k(str, x4.z.f26066a), u6.f17448m), 191);
            Y4.c0 c0Var2 = (Y4.c0) h6;
            c0Var2.getClass();
            c0Var2.k(null, uA2);
        }
        Throwable thA = w4.n.a(objD);
        if (thA != null) {
            Y4.H h7 = cloudManagerViewModel._uiState;
            U u7 = (U) ((Y4.c0) cloudManagerViewModel._uiState).getValue();
            String message = thA.getMessage();
            if (message == null) {
                message = "Failed to remove API key.";
            }
            U uA3 = U.a(u7, null, false, false, null, message, false, false, null, null, null, null, null, null, 8111);
            Y4.c0 c0Var3 = (Y4.c0) h7;
            c0Var3.getClass();
            c0Var3.k(null, uA3);
        }
        return c3137a;
    }
}
