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

namespace ClaudeDo.Ui.Converters;

public class DotBrushConverter : IValueConverter
{
    public static DotBrushConverter Instance { get; } = new();

    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        var key = value?.ToString();
        if (string.IsNullOrEmpty(key)) key = "Moss";
        var resourceKey = $"{key}Brush";
        if (Application.Current?.TryGetResource(resourceKey, null, out var res) == true)
            return res as IBrush;
        return Brushes.Transparent;
    }

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