using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace AxCopilot.Themes;

public class SymbolToBackgroundConverter : IValueConverter
{
	private static readonly Dictionary<string, SolidColorBrush> SymbolColors = new Dictionary<string, SolidColorBrush>
	{
		{
			"\ue774",
			Brush("#0078D4")
		},
		{
			"\ue8b7",
			Brush("#107C10")
		},
		{
			"\ue756",
			Brush("#1B1B1B")
		},
		{
			"\ue77f",
			Brush("#8764B8")
		},
		{
			"\ue8a1",
			Brush("#C50F1F")
		},
		{
			"\ue82d",
			Brush("#0099BC")
		},
		{
			"\uecca",
			Brush("#C239B3")
		},
		{
			"\uecaa",
			Brush("#4B5EFC")
		},
		{
			"\ue8a5",
			Brush("#605E5C")
		},
		{
			"\ue74e",
			Brush("#107C10")
		},
		{
			"\ue74d",
			Brush("#C50F1F")
		},
		{
			"\ue8ac",
			Brush("#CA5010")
		},
		{
			"\ue72c",
			Brush("#0078D4")
		},
		{
			"\ue946",
			Brush("#4B5EFC")
		},
		{
			"\ue7ba",
			Brush("#CA5010")
		},
		{
			"\uea39",
			Brush("#C50F1F")
		}
	};

	private static readonly SolidColorBrush DefaultBrush = Brush("#4B5EFC");

	public object Convert(object value, Type t, object p, CultureInfo c)
	{
		SolidColorBrush value2;
		return (value is string key && SymbolColors.TryGetValue(key, out value2)) ? value2 : DefaultBrush;
	}

	public object ConvertBack(object v, Type t, object p, CultureInfo c)
	{
		throw new NotImplementedException();
	}

	private static SolidColorBrush Brush(string hex)
	{
		Color color = (Color)ColorConverter.ConvertFromString(hex);
		SolidColorBrush solidColorBrush = new SolidColorBrush(color);
		((Freezable)solidColorBrush).Freeze();
		return solidColorBrush;
	}
}
