| 82 | * Components should never see 'default' - it's resolved during theme building |
| 83 | */ |
| 84 | const resolveThemeColors = (theme: ChatTheme, mode: 'dark' | 'light'): void => { |
| 85 | const defaultFallback = mode === 'dark' ? '#ffffff' : '#000000' |
| 86 | |
| 87 | const resolve = (value: string, fallback: string = defaultFallback): string => { |
| 88 | if (typeof value === 'string') { |
| 89 | const normalized = value.trim().toLowerCase() |
| 90 | if (normalized === 'default' || normalized.length === 0) { |
| 91 | return fallback |
| 92 | } |
| 93 | return value |
| 94 | } |
| 95 | return fallback |
| 96 | } |
| 97 | |
| 98 | // Resolve all ThemeColor properties to actual colors |
| 99 | theme.foreground = resolve(theme.foreground) |
| 100 | theme.muted = resolve(theme.muted) |
| 101 | theme.inputFg = resolve(theme.inputFg) |
| 102 | theme.inputFocusedFg = resolve(theme.inputFocusedFg) |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Build a complete theme by applying custom colors and plugins |