export function formatBytes(bytes) {
if (!bytes) return "0 B";
const units = ["B", "KB", "MB", "GB"];
let size = bytes;
let unit = 0;
while (size >= 1024 && unit < units.length - 1) {
size /= 1024;
unit += 1;
}
return `${size.toFixed(unit === 0 ? 0 : 1)} ${units[unit]}`;
}
export function valueText(value) {
return value ?? "";
}
export function formatTimestamp(value) {
if (!value) return "";
const d = new Date(value);
if (isNaN(d)) return value;
const pad = (n) => String(n).padStart(2, "0");
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;
}
export const SOURCE_ICONS = {
youtube: ``,
x: ``,
instagram: ``,
facebook: ``,
tiktok: ``,
reddit: ``,
snapchat: ``,
local: ``,
web: ``,
other: ``,
};
export function sourceIconSvg(kind) {
return SOURCE_ICONS[kind] ?? SOURCE_ICONS.other;
}