package V2;

import com.debridstream.tv.AuthViewModel;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import m3.AbstractC2467b;
import w4.C3137A;

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public H0(AuthViewModel authViewModel, A4.d dVar) {
        super(2, dVar);
        this.f7345c = authViewModel;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        H0 h0 = new H0(this.f7345c, dVar);
        h0.f7344b = obj;
        return h0;
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Y4.c0 c0Var;
        Object value;
        C0745z0 c0745z0;
        String message;
        Y4.c0 c0Var2;
        Object value2;
        Y4.c0 c0Var3;
        Object value3;
        Object objH;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7343a;
        AuthViewModel authViewModel = this.f7345c;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                Y4.H h5 = authViewModel._uiState;
                do {
                    c0Var3 = (Y4.c0) h5;
                    value3 = c0Var3.getValue();
                } while (!c0Var3.i(value3, C0745z0.a((C0745z0) value3, null, null, false, false, false, null, null, null, true, 0, 575)));
                FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
                if (currentUser == null) {
                    throw new IllegalStateException("Not signed in");
                }
                Task<Void> taskSendEmailVerification = currentUser.sendEmailVerification();
                kotlin.jvm.internal.o.g(taskSendEmailVerification, "sendEmailVerification(...)");
                this.f7343a = 1;
                objH = W0.e.h(taskSendEmailVerification, this);
                if (objH == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                objH = obj;
            }
            objD = (Void) objH;
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (!(objD instanceof w4.m)) {
            Y4.H h6 = authViewModel._uiState;
            do {
                c0Var2 = (Y4.c0) h6;
                value2 = c0Var2.getValue();
            } while (!c0Var2.i(value2, C0745z0.a((C0745z0) value2, null, null, false, false, false, null, null, "Verification email sent. Check your inbox and spam folder.", false, 0, 639)));
        }
        Throwable thA = w4.n.a(objD);
        if (thA != null) {
            Y4.H h7 = authViewModel._uiState;
            do {
                c0Var = (Y4.c0) h7;
                value = c0Var.getValue();
                c0745z0 = (C0745z0) value;
                message = thA.getMessage();
                if (message == null) {
                    message = "Could not send verification email";
                }
            } while (!c0Var.i(value, C0745z0.a(c0745z0, null, null, false, false, false, null, message, null, false, 0, 703)));
        }
        return C3137A.f25453a;
    }
}
package V2;

import com.debridstream.tv.AuthViewModel;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import m3.AbstractC2467b;
import w4.C3137A;
import w4.m;
import w4.n;

/*
 * This class (H0) is a Kotlin coroutine lambda implementation that handles sending a verification email
 * to the currently authenticated Firebase user.
 *
 * It is instantiated with an AuthViewModel and a lambda (A4.d) that will be invoked after the email
 * is sent. The class manages the coroutine state (f7343a) and updates the UI state (_uiState) in the
 * AuthViewModel with appropriate messages (e.g., "Verification email sent..." or error messages).
 *
 * The logic flow:
 * 1. Check if the user is signed in; throw IllegalStateException if not.
 * 2. Call currentUser.sendEmailVerification().
 * 3. Await the Task completion via the coroutine mechanism.
 * 4. On success, update UI state with a success message.
 * 5. On failure, extract the exception message and update UI state with an error message.
 */

public final class H0 extends C4.j implements J4.e {

    // State variable for coroutine suspension points (0 = initial, 1 = after sending email)
    public int f7343a;

    // Holds the lambda passed to the constructor (renamed from b)
    public /* synthetic */ Object f7344b;

    // Reference to the AuthViewModel instance (renamed from c)
    public final /* synthetic */ AuthViewModel f7345c;

    /**
     * Constructor.
     * @param authViewModel The AuthViewModel instance to update with UI state.
     * @param dVar The lambda to invoke after the email is sent.
     */
    public H0(AuthViewModel authViewModel, A4.d dVar) {
        super(2, dVar);
        this.f7345c = authViewModel;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        // Create a new instance of this class, passing the stored AuthViewModel and the new lambda.
        H0 h0 = new H0(this.f7345c, dVar);
        // Store the original lambda (obj) in the synthetic field for later use.
        h0.f7344b = obj;
        return h0;
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        // Delegate to the coroutine invokeSuspend method, passing the lambda and the continuation.
        return ((H0) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Y4.c0 c0Var;
        Object value;
        C0745z0 c0745z0;
        String message;
        Y4.c0 c0Var2;
        Object value2;
        Y4.c0 c0Var3;
        Object value3;
        Object objH;

        // Get the lambda to invoke after the email is sent.
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7343a;
        AuthViewModel authViewModel = this.f7345c;

        try {
            if (i6 == 0) {
                // Initial invocation: verify the user is signed in and send the email.
                AbstractC2467b.l(obj);
                Y4.H h5 = authViewModel._uiState;
                // Update UI state to loading or processing.
                do {
                    c0Var3 = (Y4.c0) h5;
                    value3 = c0Var3.getValue();
                } while (!c0Var3.i(value3, C0745z0.a((C0745z0) value3, null, null, false, false, false, null, null, null, true, 0, 575)));

                // Get the current Firebase user.
                FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
                if (currentUser == null) {
                    throw new IllegalStateException("Not signed in");
                }

                // Send the verification email.
                Task<Void> taskSendEmailVerification = currentUser.sendEmailVerification();
                kotlin.jvm.internal.o.g(taskSendEmailVerification, "sendEmailVerification(...)";

                // Mark that we have moved past the sending step.
                this.f7343a = 1;
                objH = W0.e.h(taskSendEmailVerification, this);
                if (objH == aVar) {
                    return aVar;
                }
            } else {
                // Resume invocation: the email has already been sent; just resume.
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                objH = obj;
            }
            objD = (Void) objH;
        } catch (Throwable th) {
            // Handle any exception during email sending.
            objD = AbstractC2467b.d(th);
        }

        // If the result is not a successful continuation (w4.m), update UI state with a success message.
        if (!(objD instanceof w4.m)) {
            Y4.H h6 = authViewModel._uiState;
            do {
                c0Var2 = (Y4.c0) h6;
                value2 = c0Var2.getValue();
            } while (!c0Var2.i(value2, C0745z0.a((C0745z0) value2, null, null, false, false, false, null, null, "Verification email sent. Check your inbox and spam folder.", false, 0, 639)));
        }

        // Extract any exception from the result.
        Throwable thA = w4.n.a(objD);
        if (thA != null) {
            // Update UI state with an error message.
            Y4.H h7 = authViewModel._uiState;
            do {
                c0Var = (Y4.c0) h7;
                value = c0Var.getValue();
                c0745z0 = (C0745z0) value;
                message = thA.getMessage();
                if (message == null) {
                    message = "Could not send verification email";
                }
            } while (!c0Var.i(value, C0745z0.a(c0745z0, null, null, false, false, false, null, message, null, false, 0, 703)));
        }

        return C3137A.f25453a;
    }
}
package V2;

import com.debridstream.tv.AuthViewModel;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import m3.AbstractC2467b;
import w4.C3137A;
import w4.m;
import w4.n;

/**
 * This class (H0) is a Kotlin coroutine lambda implementation that handles sending a verification email
 * to the currently authenticated Firebase user.
 *
 * It is instantiated with an AuthViewModel and a lambda (A4.d) that will be invoked after the email
 * is sent. The class manages the coroutine state (f7343a) and updates the UI state (_uiState) in the
 * AuthViewModel with appropriate messages (e.g., "Verification email sent..." or error messages).
 *
 * The logic flow:
 * 1. Check if the user is signed in; throw IllegalStateException if not.
 * 2. Call currentUser.sendEmailVerification().
 * 3. Await the Task completion via the coroutine mechanism.
 * 4. On success, update UI state with a success message.
 * 5. On failure, extract the exception message and update UI state with an error message.
 */

public final class H0 extends C4.j implements J4.e {

    /**
     * State variable for coroutine suspension points.
     * 0 = initial state before sending email.
     * 1 = resumed state after sending email.
     */
    public int f7343a;

    /**
     * Holds the lambda passed to the constructor (synthetic field).
     * Renamed from 'b' for readability.
     */
    public /* synthetic */ Object f7344b;

    /**
     * Reference to the AuthViewModel instance used to update UI state.
     * Renamed from 'c' for readability.
     */
    public final /* synthetic */ AuthViewModel f7345c;

    /**
     * Constructor.
     *
     * @param authViewModel The AuthViewModel instance to update with UI state.
     * @param dVar          The lambda to invoke after the email is sent.
     */
    public H0(AuthViewModel authViewModel, A4.d dVar) {
        super(2, dVar);
        this.f7345c = authViewModel;
    }

    /**
     * Creates a new instance of this coroutine lambda with the provided continuation.
     *
     * @param obj  The original lambda object to store.
     * @param dVar The continuation lambda.
     * @return A new H0 instance configured with the given parameters.
     */
    @Override
    public final A4.d create(Object obj, A4.d dVar) {
        // Create a new instance of this class, passing the stored AuthViewModel and the new lambda.
        H0 h0 = new H0(this.f7345c, dVar);
        // Store the original lambda (obj) in the synthetic field for later use.
        h0.f7344b = obj;
        return h0;
    }

    /**
     * Invokes the coroutine by delegating to invokeSuspend.
     *
     * @param obj   The lambda argument.
     * @param obj2  The continuation argument.
     * @return The result of the coroutine execution.
     */
    @Override
    public final Object invoke(Object obj, Object obj2) {
        // Delegate to the coroutine invokeSuspend method, passing the lambda and the continuation.
        return ((H0) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /**
     * The main coroutine logic for sending a verification email.
     *
     * @param obj The suspended result from the previous coroutine step.
     * @return The result of the coroutine execution (COROUTINE_SUSPENDED or completion value).
     */
    @Override
    public final Object invokeSuspend(Object obj) {
        Object resultValue;
        Y4.c0 uiStateObserver;
        Object previousUiState;
        C0745z0 currentUiState;
        String errorMessage;
        Y4.c0 uiStateObserver2;
        Object previousUiState2;
        Y4.c0 uiStateObserver3;
        Object previousUiState3;
        Object emailTaskResult;

        // Sentinel value indicating coroutine suspension.
        B4.a coroutineSuspendedSentinel = B4.a.f492a;

        // Retrieve the current coroutine state and AuthViewModel reference.
        int currentState = this.f7343a;
        AuthViewModel authViewModel = this.f7345c;

        try {
            if (currentState == 0) {
                // Initial invocation: verify the user is signed in and send the email.
                AbstractC2467b.l(obj);

                // Get the UI state holder from the AuthViewModel.
                Y4.H uiStateHolder = authViewModel._uiState;

                // Update UI state to indicate loading/processing.
                do {
                    uiStateObserver3 = (Y4.c0) uiStateHolder;
                    previousUiState3 = uiStateObserver3.getValue();
                } while (!uiStateObserver3.i(previousUiState3, C0745z0.a((C0745z0) previousUiState3, null, null, false, false, false, null, null, null, true, 0, 575)));

                // Get the current Firebase user.
                FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
                if (currentUser == null) {
                    throw new IllegalStateException("Not signed in");
                }

                // Send the verification email.
                Task<Void> taskSendEmailVerification = currentUser.sendEmailVerification();
                kotlin.jvm.internal.o.g(taskSendEmailVerification, "sendEmailVerification(...)");

                // Mark that we have moved past the sending step.
                this.f7343a = 1;

                // Await the Task completion via the coroutine mechanism.
                emailTaskResult = W0.e.h(taskSendEmailVerification, this);

                // If the coroutine is suspended, return the sentinel value.
                if (emailTaskResult == coroutineSuspendedSentinel) {
                    return coroutineSuspendedSentinel;
                }
            } else {
                // Resume invocation: the email has already been sent; just resume.
                if (currentState != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                emailTaskResult = obj;
            }

            // Cast the result to Void (successful completion of the email task).
            resultValue = (Void) emailTaskResult;
        } catch (Throwable throwable) {
            // Handle any exception during email sending.
            resultValue = AbstractC2467b.d(throwable);
        }

        // If the result is not a successful continuation (w4.m), update UI state with a success message.
        if (!(resultValue instanceof w4.m)) {
            Y4.H uiStateHolder2 = authViewModel._uiState;
            do {
                uiStateObserver2 = (Y4.c0) uiStateHolder2;
                previousUiState2 = uiStateObserver2.getValue();
            } while (!uiStateObserver2.i(previousUiState2, C0745z0.a((C0745z0) previousUiState2, null, null, false, false, false, null, null, "Verification email sent. Check your inbox and spam folder.", false, 0, 639)));
        }

        // Extract any exception from the result.
        Throwable exception = w4.n.a(resultValue);
        if (exception != null) {
            // Update UI state with an error message.
            Y4.H uiStateHolder3 = authViewModel._uiState;
            do {
                uiStateObserver = (Y4.c0) uiStateHolder3;
                previousUiState = uiStateObserver.getValue();
                currentUiState = (C0745z0) previousUiState;
                errorMessage = exception.getMessage();
                if (errorMessage == null) {
                    errorMessage = "Could not send verification email";
                }
            } while (!uiStateObserver.i(previousUiState, C0745z0.a(currentUiState, null, null, false, false, false, null, errorMessage, null, false, 0, 703)));
        }

        return C3137A.f25453a;
    }
}
