// The one status glyph used in list rows: a single coloured icon whose tooltip // and accessible name say the state. The pill text badge is deliberately gone. import { h } from "./dom.js"; const NS = "http://www.w3.org/2000/svg"; function iconPath(state) { switch (state) { case "succeeded": return "M5 12.5l4.5 4.5L19 7"; case "failed": return "M6 6l12 12M18 6L6 18"; case "running": return "M12 3a9 9 0 1 0 9 9"; case "canceled": return "M12 3a9 9 0 1 0 0 18M7.5 7.5l9 9"; case "interrupted": return "M9 6v12M15 6v12"; case "waiting": case "queued": return "M12 6v6l4 2"; default: return "M12 8v8M8 12h8"; } } /** `state` is the run status token; `label` is the word a person reads. */ export function statusIcon(state, label = state) { const tone = String(state ?? "").trim().toLowerCase() || "unknown"; const word = String(label ?? tone); const span = h("span", { class: `chip chip-${tone} status-icon status-${tone}`, role: "img", title: word, "aria-label": word, "data-status": tone, }); const svg = document.createElementNS(NS, "svg"); svg.setAttribute("viewBox", "0 0 24 24"); svg.setAttribute("aria-hidden", "true"); svg.setAttribute("focusable", "false"); if (tone === "waiting" || tone === "queued") { const circle = document.createElementNS(NS, "circle"); circle.setAttribute("cx", "12"); circle.setAttribute("cy", "12"); circle.setAttribute("r", "9"); circle.setAttribute("fill", "none"); circle.setAttribute("stroke", "currentColor"); circle.setAttribute("stroke-width", "1.8"); svg.append(circle); } const path = document.createElementNS(NS, "path"); path.setAttribute("d", iconPath(tone)); path.setAttribute("fill", "none"); path.setAttribute("stroke", "currentColor"); path.setAttribute("stroke-width", "2"); path.setAttribute("stroke-linecap", "round"); path.setAttribute("stroke-linejoin", "round"); svg.append(path); span.append(svg); return span; }