import { BRAND, MONOGRAM } from '@/components/provider-glyphs'; import { PROVIDER_MAP } from '@/lib/providers'; import type { LLMProvider } from '@/types'; /** * Two-letter fallback for a provider with no brand glyph. * * Derived from the provider's catalog label rather than hardcoded, because the * catalog is far larger than the set of marks we can legally inline — most * providers reach this path. `MONOGRAM` overrides it only where the derivation * would be meaningless or would collide with another provider. */ function monogram(provider: LLMProvider): string { const explicit = MONOGRAM[provider]; if (explicit) return explicit; // Parentheticals are disambiguators, not part of the name: "xAI (Grok)" must // read XA, not X(. const label = PROVIDER_MAP[provider]?.label.replace(/\(.*?\)/g, '').trim(); if (!label) return '?'; const words = label.split(/\s+/).filter(Boolean); if (words.length === 0) return '?'; const initials = words.length >= 2 ? words[0][0] + words[1][0] : words[0].slice(0, 2); return initials.toUpperCase(); } interface ProviderIconProps { provider: LLMProvider; className?: string; } /** Inline, brand-colored logo for a BYOK provider. Decorative. */ export function ProviderIcon({ provider, className }: ProviderIconProps) { const brand = BRAND[provider]; if (brand) { const gradient = brand.gradient; // Duplicate ids across instances are fine: every definition is identical. const gradientId = `provider-gradient-${provider}`; return ( {gradient && ( {gradient.map((color, i) => ( ))} )} {brand.d.map((d, i) => ( ))} ); } const mono = monogram(provider); return ( 2 ? 7 : 9} fontWeight={700} fill="currentColor" fontFamily="ui-monospace, SFMono-Regular, monospace" > {mono} ); } export default ProviderIcon;