import type { CSSProperties, ReactNode } from 'react'; import { cn } from '../../lib/cn'; /** * Indian-grouped rupee figure (lakh/crore). e.g. 20000000 → ₹2,00,00,000. */ export function formatINR(n: number | null | undefined): string { if (n == null || Number.isNaN(n)) return '—'; const neg = n < 0; const s = Math.round(Math.abs(n)).toString(); let last3 = s.slice(-3); let rest = s.slice(0, -3); if (rest) last3 = ',' + last3; rest = rest.replace(/\B(?=(\d{2})+(?!\d))/g, ','); return (neg ? '-' : '') + rest + last3; } export type RupeeSize = 'sm' | 'md' | 'lg' | 'xl' | 'hero'; export type RupeeTone = 'default' | 'accent' | 'navy' | 'muted' | 'onNavy'; export interface RupeeAmountProps { value: number; /** @default "md" */ size?: RupeeSize; /** @default "default" */ tone?: RupeeTone; sub?: ReactNode; className?: string; style?: CSSProperties; } const SIZES: Record = { sm: 16, md: 22, lg: 32, xl: 44, hero: 64 }; const TONES: Record = { default: 'var(--text-strong)', accent: 'var(--sunrise-600)', navy: 'var(--navy-900)', muted: 'var(--text-muted)', onNavy: 'var(--text-on-navy)', }; /** Oversized confident rupee numeral via Inter Tight. */ export function RupeeAmount({ value, size = 'md', tone = 'default', sub, className, style }: RupeeAmountProps) { const fs = SIZES[size]; return ( {formatINR(value)} {sub && {sub}} ); }