using System.Globalization;
using System.Windows.Data;
using TeamsISO.Engine.Domain;

namespace TeamsISO.App.Converters;

/// <summary>
/// Renders engine enum values into operator-friendly strings.
/// </summary>
public sealed class EnumDescriptionConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value switch
    {
        TargetFramerate fr => fr switch
        {
            TargetFramerate.Fps23_976 => "23.976 fps",
            TargetFramerate.Fps24     => "24 fps",
            TargetFramerate.Fps25     => "25 fps",
            TargetFramerate.Fps29_97  => "29.97 fps",
            TargetFramerate.Fps30     => "30 fps",
            TargetFramerate.Fps50     => "50 fps",
            TargetFramerate.Fps59_94  => "59.94 fps",
            TargetFramerate.Fps60     => "60 fps",
            _ => fr.ToString()
        },
        TargetResolution r => r switch
        {
            TargetResolution.R720p  => "720p",
            TargetResolution.R1080p => "1080p",
            TargetResolution.R4K    => "4K",
            _ => r.ToString()
        },
        AspectMode a => a switch
        {
            AspectMode.Pillarbox => "Pillarbox",
            AspectMode.Letterbox => "Letterbox",
            AspectMode.Stretch   => "Stretch",
            _ => a.ToString()
        },
        AudioMode m => m switch
        {
            AudioMode.Auto     => "Auto (isolated → mixed fallback)",
            AudioMode.Isolated => "Isolated",
            AudioMode.Mixed    => "Mixed",
            _ => m.ToString()
        },
        _ => value
    };

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