export const FILE_PICKER_ICONS = { folder: 'M4 7h6l2 2h8v10H4z', file: 'M14 3v5h5M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z', lock: 'M7 11V8a5 5 0 0 1 10 0v3M5 11h14v10H5z', } export function formatBytes(bytes: number | null): string { if (bytes === null) return '—' const units = ['B', 'KB', 'MB', 'GB', 'TB'] let value = bytes let unit = 0 while (value >= 1024 && unit < units.length - 1) { value /= 1024 unit += 1 } const rounded = value >= 100 || unit === 0 ? Math.round(value) : Number(value.toFixed(1)) return `${rounded} ${units[unit]}` } const pad = (value: number) => String(value).padStart(2, '0') /** Compact local timestamp for a fixed-width mono column: `MM-DD HH:mm`, or `YYYY-MM-DD` outside this year. */ export function formatModified(value: string | null | undefined, now = new Date()): string { const date = value ? new Date(value) : null if (!date || Number.isNaN(date.getTime())) return '' const day = `${pad(date.getMonth() + 1)}-${pad(date.getDate())}` return date.getFullYear() === now.getFullYear() ? `${day} ${pad(date.getHours())}:${pad(date.getMinutes())}` : `${date.getFullYear()}-${day}` }