import { type ClassValue, clsx } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } export function formatDate(date: Date | string): string { const d = new Date(date) return new Intl.DateTimeFormat('pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric', }).format(d) } export function formatDateTime(date: Date | string): string { const d = new Date(date) return new Intl.DateTimeFormat('pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', }).format(d) } export function formatRelativeTime(date: Date | string): string { const d = new Date(date) const now = new Date() const diff = now.getTime() - d.getTime() const seconds = Math.floor(diff / 1000) const minutes = Math.floor(seconds / 60) const hours = Math.floor(minutes / 60) const days = Math.floor(hours / 24) if (days > 7) { return formatDate(d) } else if (days > 0) { return `${days}d atrás` } else if (hours > 0) { return `${hours}h atrás` } else if (minutes > 0) { return `${minutes}min atrás` } else { return 'agora' } } export function truncate(str: string, length: number): string { if (str.length <= length) return str return str.slice(0, length) + '...' }