import { clsx, type ClassValue } from 'clsx'; import { twMerge } from 'tailwind-merge'; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } export function formatNumber(n: number): string { if (n >= 1_000_000) return (n / 1_000_000).toFixed(1) + 'M'; if (n >= 1_000) return (n / 1_000).toFixed(1) + 'K'; return String(n); } export function formatRelativeTime(iso: string | null): string { if (!iso) return 'never'; const then = new Date(iso).getTime(); if (isNaN(then)) return 'unknown'; const diff = Date.now() - then; const minutes = Math.floor(diff / 60_000); if (minutes < 1) return 'just now'; if (minutes < 60) return `${minutes}m ago`; const hours = Math.floor(minutes / 60); if (hours < 24) return `${hours}h ago`; const days = Math.floor(hours / 24); return `${days}d ago`; } export function agentColor(type: string | null): string { const map: Record = { gpt: '#10a37f', claude: '#a855f7', google: '#ea4335', perplexity: '#20b2aa', bing: '#008ad8', xai: '#1d9bf0', deepseek: '#4b6bfb', mistral: '#ff7000', meta: '#0866ff', apple: '#a6a6a6', amazon: '#ff9900', bytedance: '#25f4ee', cohere: '#39c5ac', other: '#6b7280', human: '#3b82f6', }; return map[type || 'other'] || '#6b7280'; }