const units = ["B", "KB", "MB", "GB", "TB"]; export const statusLabels = { queued: "Queued", downloading: "Downloading", extracting: "Extracting", ready: "Ready", moving: "Moving", completed: "Completed", failed: "Failed", cancelled: "Cancelled", }; export function formatBytes(bytes) { let value = Math.max(0, bytes || 0); let unitIndex = 0; while (value >= 1024 && unitIndex < units.length - 1) { value /= 1024; unitIndex += 1; } return `${value.toFixed(unitIndex === 0 ? 0 : 1)} ${units[unitIndex]}`; } export function percentOf(done, total) { if (!total || total <= 0) return null; return Math.min(100, (done / total) * 100); }