export function cn(...parts: Array): string { return parts.filter(Boolean).join(" "); } export function formatDate(value?: string | null): string { if (!value) return "—"; return new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format( new Date(value), ); } export function colorToHex(color?: { red: number; green: number; blue: number }): string { if (!color) return "#5660ff"; return `#${[color.red, color.green, color.blue] .map((part) => part.toString(16).padStart(2, "0")) .join("")}`; } export function hexToColor(hex: string): { red: number; green: number; blue: number } { const value = hex.replace("#", ""); return { red: Number.parseInt(value.slice(0, 2), 16), green: Number.parseInt(value.slice(2, 4), 16), blue: Number.parseInt(value.slice(4, 6), 16), }; } export function formValue(data: FormData, key: string): string { const value = data.get(key); return typeof value === "string" ? value : ""; }