// Shared presentation helpers have no feature state. export function number(value) { return Number.isFinite(value) ? value.toLocaleString() : "-"; } export function money(value) { const amount = Number(value || 0); return "$" + (Number.isFinite(amount) ? amount : 0).toFixed(4); } export function localDateTimeValue(value) { if (!value) return ""; const date = new Date(value); const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000); return local.toISOString().slice(0, 19); } export function isCompactEndpoint(value) { const path = String(value || "").replace(/^\s*(GET|POST|PUT|PATCH|DELETE)\s+/i, "").split("?", 1)[0].replace(/\/+$/, ""); return path.endsWith("/responses/compact"); } export function endpoint(value) { const path = String(value || "").replace(/^\s*(GET|POST|PUT|PATCH|DELETE)\s+/i, ""); if (isCompactEndpoint(path)) return "compact"; if (path.endsWith("/chat/completions")) return "chat"; if (path.endsWith("/responses")) return "responses"; return path.replace(/^\/v1\//, "") || "-"; } export function result(record) { if (record.outcome === "canceled") return "已取消"; if (record.outcome === "rejected") return "已拒绝"; if (record.failed || record.outcome === "failed") return record.status_code ? `失败 (${record.status_code})` : "失败"; return "成功"; } export function option(value, label, selected = false) { const node = document.createElement("option"); node.value = value; node.textContent = label; node.selected = selected; return node; }