export const formatNumber = ( n: number | null | undefined, decimals = 0 ): string => { if (n == null) return '0'; return Number(n).toLocaleString('en-US', { minimumFractionDigits: decimals, maximumFractionDigits: decimals, }); }; export const formatPercentage = (n: number | null | undefined): string => { if (n == null) return '0%'; return Number(n).toFixed(1) + '%'; }; export const formatDateTime = (iso: string | null | undefined): string => { if (!iso) return '-'; const d = new Date(iso); return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', }); }; export const formatIntentScore = (score: number | null | undefined): string => { if (score == null) return '-'; return (score * 100).toFixed(0) + '%'; }; export const getDateRangeFromPreset = ( preset: string ): { start: string; end: string } => { const today = new Date(); const end = today.toISOString().split('T')[0]; let start: string; switch (preset) { case 'today': start = end; break; case '7d': { const d = new Date(today); d.setDate(d.getDate() - 6); start = d.toISOString().split('T')[0]; break; } case '30d': { const d = new Date(today); d.setDate(d.getDate() - 29); start = d.toISOString().split('T')[0]; break; } default: start = end; } return { start, end }; }; export const RECOMAZE_COLORS = { primary: '#B7007C', dark: '#92005E', light: '#ffeef8', lighter: '#fff5fb', accent1: '#d946a8', accent2: '#f0abdb', accent3: '#ff6b9d', } as const; export const CHART_PALETTE = [ '#B7007C', '#92005E', '#d946a8', '#f0abdb', '#ff6b9d', '#6366f1', '#8b5cf6', '#ec4899', '#14b8a6', '#f59e0b', ] as const;