using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace ClaudeDo.Ui.ViewModels.Modals;

public enum UnfinishedPlanningModalResult
{
    Cancel,
    Resume,
    FinalizeNow,
    Discard,
}

public sealed partial class UnfinishedPlanningModalViewModel : ViewModelBase
{
    [ObservableProperty] private string _taskTitle = "";
    [ObservableProperty] private int _draftCount;

    public TaskCompletionSource<UnfinishedPlanningModalResult> Result { get; } = new();
    public Action? CloseAction { get; set; }

    [RelayCommand] private void Resume()      { Result.TrySetResult(UnfinishedPlanningModalResult.Resume);      CloseAction?.Invoke(); }
    [RelayCommand] private void FinalizeNow() { Result.TrySetResult(UnfinishedPlanningModalResult.FinalizeNow); CloseAction?.Invoke(); }
    [RelayCommand] private void Discard()     { Result.TrySetResult(UnfinishedPlanningModalResult.Discard);     CloseAction?.Invoke(); }
    [RelayCommand] private void Cancel()      { Result.TrySetResult(UnfinishedPlanningModalResult.Cancel);      CloseAction?.Invoke(); }
}
