namespace HellionChat.Ui; // Pure string resolver logic with no Dalamud dependency, kept in its own // file so tests (HellionChat.Tests, no Dalamud reference) can call it directly. // Used in the settings UI glyph picker and indirectly via TabIconMapping.Resolve. internal static class TabIconGlyphResolver { // Single source of truth for the glyph set; order matches the settings combobox. public static readonly IReadOnlyList PickerOptions = [ "comment", "comments", "cog", "users", "user-friends", "link", "envelope", "clock", "hashtag", "star", "heart", "bell", "bookmark", "flag", "fire", ]; // Derived from PickerOptions -- never maintain this manually. private static readonly HashSet KnownGlyphs = new( PickerOptions, StringComparer.OrdinalIgnoreCase ); // Tab.Name is localised, so we match against a pool of DE/EN synonyms. private static readonly Dictionary NameDefaults = new( StringComparer.OrdinalIgnoreCase ) { ["allgemein"] = "comment", ["general"] = "comment", ["system"] = "cog", ["free company"] = "users", ["fc"] = "users", ["gruppe"] = "user-friends", ["group"] = "user-friends", ["party"] = "user-friends", ["linkshell"] = "link", ["ls"] = "link", ["cwls"] = "link", ["tells"] = "envelope", ["tell"] = "envelope", }; // Resolves the glyph name for a tab. Priority order: // 1. Tab.Icon override (if set): known glyph -> use it, unknown -> "hashtag" // 2. Auto-tell tab -> autoTellGlyph if provided, else "clock" // 3. Name default lookup // 4. Fallback "hashtag" public static string ResolveGlyphName(Tab tab, string? autoTellGlyph = null) { if (!string.IsNullOrWhiteSpace(tab.Icon)) return KnownGlyphs.Contains(tab.Icon) ? tab.Icon : "hashtag"; if (tab.IsTempTab) return autoTellGlyph ?? "clock"; if (tab.Name is { } name && NameDefaults.TryGetValue(name, out var byName)) return byName; return "hashtag"; } }