// Tiny DOM-builder helper shared by the dashboard and the per-agent UI — // both packages built their own copy independently; this is the merged // canonical version (dashboard's, which had the extra `data-` branch; // functionally identical to the `class`/`html` handling either package // used). // // `el(tag, attrs, ...children)` creates an element, applying `attrs` as // either the `class`/`html` special cases or plain attributes, and // appending `children` (strings become text nodes, `null`/`undefined` // entries are skipped so callers can inline conditional children). // `tag` can be any custom element's tag name too (e.g. `el('hive-btn', // { variant: 'danger' }, 'label')`) — `document.createElement` upgrades // it automatically if the tag is already registered. export const el = (tag, attrs = {}, ...children) => { const e = document.createElement(tag); for (const [k, v] of Object.entries(attrs)) { if (k === 'class') e.className = v; else if (k === 'html') e.innerHTML = v; else e.setAttribute(k, v); } for (const c of children) { if (c == null) continue; e.append(c.nodeType ? c : document.createTextNode(c)); } return e; };