using System.Windows;

namespace ClaudeDo.Installer.Views;

public enum SelfUpdateChoice { Update, Continue, Cancel }

public partial class SelfUpdatePromptWindow : Window
{
    public SelfUpdateChoice Choice { get; private set; } = SelfUpdateChoice.Cancel;

    public SelfUpdatePromptWindow(string currentVersion, string latestVersion)
    {
        InitializeComponent();
        DetailText.Text = $"Installer v{latestVersion} is available (you are running v{currentVersion}). Update before continuing?";
    }

    public void ShowProgress(string text)
    {
        ProgressText.Text = text;
        ProgressText.Visibility = Visibility.Visible;
        UpdateBtn.IsEnabled = false;
        ContinueBtn.IsEnabled = false;
    }

    private void UpdateBtn_Click(object sender, RoutedEventArgs e)
    {
        Choice = SelfUpdateChoice.Update;
        DialogResult = true;
    }

    private void ContinueBtn_Click(object sender, RoutedEventArgs e)
    {
        Choice = SelfUpdateChoice.Continue;
        DialogResult = true;
    }

    private void CancelBtn_Click(object sender, RoutedEventArgs e)
    {
        Choice = SelfUpdateChoice.Cancel;
        DialogResult = false;
    }
}
