using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;
using ClaudeDo.Data.Models;

namespace ClaudeDo.Ui.Converters;

public sealed class WorktreeStateColorConverter : IValueConverter
{
    public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
        value is WorktreeState state
            ? state switch
            {
                WorktreeState.Active    => new SolidColorBrush(Color.Parse("#42A5F5")),
                WorktreeState.Merged    => new SolidColorBrush(Color.Parse("#66BB6A")),
                WorktreeState.Discarded => new SolidColorBrush(Color.Parse("#9E9E9E")),
                WorktreeState.Kept      => new SolidColorBrush(Color.Parse("#FFA726")),
                _                       => new SolidColorBrush(Colors.Gray),
            }
            : new SolidColorBrush(Colors.Gray);

    public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        => throw new NotSupportedException();
}
