namespace ytLive.Models;
/// A colour the border picker offers: its hex value and the plain-English
/// name shown next to it (TASK 60).
/// The hex value, e.g. #e94560.
/// The name the creator reads, e.g. Crimson.
public readonly record struct NamedColor(string Hex, string Name);
/// The colours the webcam's border-colour drop-down offers — the SINGLE
/// source of truth for the list and for the names.
///
/// TASK 60 (the creator, 2026-10-21): *"in the drop down box, the #hex values are
/// good, but add a corresponding color name/label next to the value."* The list used to
/// be a hard-coded array in the click handler, which is why a name could not be added
/// to it without touching the UI code.
///
public static class BorderColorPalette
{
/// The offered colours, in menu order.
public static IReadOnlyList All { get; } = new NamedColor[]
{
new("#FFFFFF", "White"),
new("#000000", "Black"),
new("#FF0000", "Red"),
new("#00FF00", "Lime"),
new("#0000FF", "Blue"),
new("#FFFF00", "Yellow"),
new("#FF00FF", "Magenta"),
new("#00FFFF", "Cyan"),
new("#FF8800", "Orange"),
new("#8800FF", "Violet"),
new("#e94560", "Crimson"),
new("#22c55e", "Emerald"),
new("#3b82f6", "Azure"),
new("#f59e0b", "Amber"),
};
/// The name of a hex value (case-insensitive). A colour that is not in
/// the palette keeps its hex — there is no name to give it.
public static string NameOf(string hex)
{
if (string.IsNullOrWhiteSpace(hex)) return string.Empty;
var trimmed = hex.Trim();
foreach (var colour in All)
if (string.Equals(colour.Hex, trimmed, StringComparison.OrdinalIgnoreCase))
return colour.Name;
return trimmed;
}
}