export function formatBytes(n: number): string { if (n >= 1e9) return `${(n / 1e9).toFixed(2)} GB`; if (n >= 1e6) return `${Math.round(n / 1e6)} MB`; if (n >= 1e3) return `${Math.round(n / 1e3)} KB`; return `${n} B`; } export function formatDate(iso: string | null): string { if (!iso) return "—"; return new Date(iso).toLocaleDateString(undefined, { day: "2-digit", month: "short", year: "numeric" }); } /** Zero-padded two-digit number: 6 → "06". */ export const pad2 = (n: number) => String(n).padStart(2, "0"); /** FNV-1a string hash → uint32; seeds placeholder colours. */ export function hash(str: string): number { let h = 0x811c9dc5; for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 0x01000193); } return h >>> 0; } /** Short tag for a base model folder: "MOSS-Image" → "MOSS", "Krea2" → "Krea2". */ export const modelLabel = (id: string) => id.split("-")[0];