import { type ClassValue, clsx } from 'clsx' import { twMerge } from 'tailwind-merge' export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } export function formatNumber(num: number): string { return new Intl.NumberFormat('en-US').format(num) } export function formatBytes(bytes: number): string { if (bytes === 0) return '0 Bytes' const k = 1024 const sizes = ['Bytes', 'KB', 'MB', 'GB'] const i = Math.floor(Math.log(bytes) / Math.log(k)) return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i] } export function slugify(str: string): string { return str .toLowerCase() .replace(/[^\w\s-]/g, '') .replace(/\s+/g, '-') .replace(/-+/g, '-') .trim() } export function truncate(str: string, length: number): string { if (str.length <= length) return str return str.slice(0, length) + '...' } export function debounce any>( func: T, wait: number ): (...args: Parameters) => void { let timeout: NodeJS.Timeout | null = null return (...args: Parameters) => { if (timeout) clearTimeout(timeout) timeout = setTimeout(() => func(...args), wait) } }