@wildwinter/app-shell 0.54.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tooltip.ts","../src/icons.ts","../src/dom.ts","../src/value-control.ts","../src/value-rows.ts"],"names":["el","show","tip","active","valueProblems","pickChoices","defaultOf","n"],"mappings":";;;;;;;AA6BA,SAAS,SAAA,CAAU,MAAmB,IAAA,EAAoB;AACxD,EAAA,IAAA,CAAK,WAAA,GAAc,EAAA;AACnB,EAAA,MAAM,EAAA,GAAK,2BAAA;AACX,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,CAAA;AACJ,EAAA,OAAA,CAAQ,CAAA,GAAI,EAAA,CAAG,IAAA,CAAK,IAAI,OAAO,IAAA,EAAM;AACnC,IAAA,IAAI,CAAA,CAAE,KAAA,GAAQ,IAAA,EAAM,IAAA,CAAK,MAAA,CAAO,KAAK,KAAA,CAAM,IAAA,EAAM,CAAA,CAAE,KAAK,CAAC,CAAA;AACzD,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,IAAA,MAAA,CAAO,WAAA,GAAc,CAAA,CAAE,CAAC,CAAA,IAAK,EAAA;AAC7B,IAAA,IAAA,CAAK,OAAO,MAAM,CAAA;AAClB,IAAA,IAAA,GAAO,CAAA,CAAE,KAAA,GAAQ,CAAA,CAAE,CAAC,CAAA,CAAE,MAAA;AAAA,EACxB;AACA,EAAA,IAAI,IAAA,GAAO,KAAK,MAAA,EAAQ,IAAA,CAAK,OAAO,IAAA,CAAK,KAAA,CAAM,IAAI,CAAC,CAAA;AACtD;AAQA,IAAI,MAAA,GAAS,KAAA;AACb,IAAI,OAAA,GAAU,KAAA;AACd,IAAI,UAAA;AACJ,IAAM,UAAA,GAAa,GAAA;AACnB,IAAM,IAAA,GAAO,CAAA;AACb,IAAM,GAAA,GAAM,CAAA;A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S,IAAA,CAAK,KAAK,IAAA,EAAM;AACtC,QAAA,GAAA,CAAI,IAAA,GAAO,IAAA;AACX,QAAA,aAAA,CAAc,MAAA,CAAO,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AAClC,QAAA,GAAA,CAAI,MAAA,CAAO,OAAO,IAAI,CAAA;AACtB,QAAA,aAAA,CAAc,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AACnC,QAAA,OAAO,IAAI,MAAA,CAAO,EAAA;AAAA,MACpB;AACA,MAAA,MAAM,MAAA,GAAS,SAAS,IAAI,CAAA;AAC5B,MAAA,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,EAAE,MAAA,EAAQ,IAAA,EAAM,KAAK,IAAA,CAAK,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,CAAA;AAC1D,MAAA,OAAO,MAAA,CAAO,EAAA;AAAA,IAChB,CAAA;AAAA,IACA,KAAA,GAAQ;AACN,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,IAAA,EAAM;AAAE,QAAA,IAAI,CAAC,KAAA,CAAM,IAAA,EAAM,IAAA,CAAK,OAAO,GAAG,CAAA;AAAA,mBAAc,IAAA,GAAO,KAAA;AAAA,MAAO;AAAA,IACjG;AAAA,GACF;AACF","file":"value-rows.cjs","sourcesContent":["// ---------------------------------------------------------------------------\n// A single themed tooltip the family controls, replacing native `title`\n// rollovers: those are unstyled OS chrome and appear on the platform's slow\n// (~1s) delay, which is exactly the seam design-language section 4 (\"coherent\n// to the edges\") says not to leave showing.\n//\n// ONE floating bubble, document-DELEGATED: any element carrying a `data-tip`\n// attribute gets it, so a caller just sets `data-tip=\"...\"` anywhere and wires\n// nothing. The bubble anchors above the element (flipping below near the top\n// edge), uses our own snappy delay and the shared panel-enter motion.\n// `initTooltips()` is idempotent, so it is safe to call from more than one\n// place in an app that has several entry points.\n//\n// Lifted from Patterpad's patterpad-surface/web/tooltip.ts, which proved it,\n// with the one app-specific rule (suppressed in Writing View) generalised into\n// the `suppressed` option so the shell knows nothing about either app's modes.\n// ---------------------------------------------------------------------------\n\n// Bold markers: a producer wraps a span in these PRIVATE control chars (U+0002 STX / U+0003 ETX,\n// never present in user text) and the renderer turns it into a <strong>. Lets a data-tip bold part\n// of itself (a name, a \"VO:\" prefix) without any HTML, and each segment is still set via\n// textContent, so there is no injection risk from user content.\nconst B_OPEN = \"\\u0002\";\nconst B_CLOSE = \"\\u0003\";\n\n/** Wrap `s` so it renders bold inside a tooltip (see the marker note above). */\nexport function tipBold(s: string): string { return `${B_OPEN}${s}${B_CLOSE}`; }\n\n/** Render `text` into `host`, turning `\\u0002…\\u0003`-marked spans into <strong>; all set as text (safe). */\nfunction renderTip(host: HTMLElement, text: string): void {\n host.textContent = \"\";\n const re = /\\u0002([^\\u0003]*)\\u0003/g;\n let last = 0;\n let m: RegExpExecArray | null;\n while ((m = re.exec(text)) !== null) {\n if (m.index > last) host.append(text.slice(last, m.index));\n const strong = document.createElement(\"strong\");\n strong.textContent = m[1] ?? \"\";\n host.append(strong);\n last = m.index + m[0].length;\n }\n if (last < text.length) host.append(text.slice(last));\n}\n\nexport interface TooltipOptions {\n /** Called before every show: return true to keep the bubble down. For a mode\n * that wants no chrome at all (Patterpad's Writing View). */\n suppressed?: () => boolean;\n}\n\nlet inited = false;\nlet checked = false; // the one-shot no-host warning below has been scheduled\nlet suppressed: (() => boolean) | undefined;\nconst SHOW_DELAY = 350; // ms - snappier than the OS title delay, slow enough not to flicker on pass-through\nconst EDGE = 6; // viewport inset so the bubble never touches the window edge\nconst GAP = 7; // px between the anchor and the bubble\n\nlet tip: HTMLDivElement | null = null;\nlet timer = 0;\nlet active: HTMLElement | null = null;\n/** The subject of a rect-anchored tip (see `tipAt`), when there is one. */\nlet activeKey: string | null = null;\n\nfunction ensureEl(): HTMLDivElement {\n if (tip) return tip;\n const el = document.createElement(\"div\");\n el.className = \"tooltip\";\n el.setAttribute(\"role\", \"tooltip\");\n el.hidden = true;\n document.body.appendChild(el);\n tip = el;\n return el;\n}\n\n/** A rectangle in VIEWPORT coordinates, for anchoring a tip to something that is\n * not a DOM element: a shape on a canvas, a run of text inside one. */\nexport interface TipRect { left: number; top: number; width: number; height: number }\n\nconst rectOf = (anchor: HTMLElement | TipRect): TipRect =>\n (anchor instanceof HTMLElement ? anchor.getBoundingClientRect() : anchor);\n\n/** Anchor the (already-visible, so measurable) bubble above the anchor, flipping below near the top. */\nfunction place(anchor: HTMLElement | TipRect): void {\n const t = ensureEl();\n const r = rectOf(anchor);\n const tr = t.getBoundingClientRect();\n let top = r.top - tr.height - GAP;\n if (top < EDGE) top = r.top + r.height + GAP; // not enough room above -> below\n let left = r.left + r.width / 2 - tr.width / 2;\n left = Math.max(EDGE, Math.min(left, window.innerWidth - tr.width - EDGE));\n t.style.left = `${Math.round(left)}px`;\n t.style.top = `${Math.round(top)}px`;\n}\n\nfunction show(anchor: HTMLElement): void {\n const text = anchor.dataset[\"tip\"];\n if (!text) return;\n paint(anchor, text);\n}\n\n/** Fill, place and reveal the bubble. The one path: both the delegated\n * `data-tip` route and `tipAt` end up here, so a canvas tip and a button tip\n * are the same bubble with the same look and the same motion. */\nfunction paint(anchor: HTMLElement | TipRect, text: string): void {\n if (suppressed?.()) return;\n const t = ensureEl();\n // A modal <dialog> (settings, a confirm) renders in the browser TOP LAYER, above every normal-flow\n // element whatever its z-index. If the anchor is inside one, move the bubble into that dialog so it\n // shares the top layer; otherwise keep it on <body>. Re-parenting per show also moves it back out\n // once the modal closes.\n const host: HTMLElement = (anchor instanceof HTMLElement ? anchor.closest<HTMLElement>(\"dialog[open]\") : null)\n ?? document.body;\n if (t.parentElement !== host) host.appendChild(t);\n active = anchor instanceof HTMLElement ? anchor : null;\n renderTip(t, text);\n t.hidden = false;\n t.classList.remove(\"show\"); void t.offsetWidth; // restart the enter animation\n place(anchor); // measure + position now it has content + is visible\n t.classList.add(\"show\");\n}\n\nfunction hide(): void {\n if (timer) { window.clearTimeout(timer); timer = 0; }\n active = null;\n activeKey = null;\n if (tip) { tip.hidden = true; tip.classList.remove(\"show\"); }\n}\n\nfunction schedule(anchor: HTMLElement): void {\n if (anchor === active) return;\n if (timer) window.clearTimeout(timer);\n timer = window.setTimeout(() => show(anchor), SHOW_DELAY);\n}\n\n/**\n * Show a tip for something that has no DOM node of its own: a card on a canvas,\n * a zone, a pin. The caller says WHERE (a viewport rectangle) and WHAT, and\n * identifies the subject with `key`.\n *\n * The key is what makes this usable from a canvas. Re-calling with the same key\n * re-places the bubble WITHOUT restarting the delay, so a tip can follow its\n * shape while the camera moves; calling with a different key starts the wait\n * again, so sweeping the pointer across a dense board does not strobe.\n *\n * The bubble is ordinary DOM, so it holds its size whatever the canvas is\n * zoomed to. That is the point of it: the label it stands in for is the one\n * thing on a canvas that must not shrink with everything else.\n */\nexport function tipAt(key: string, rect: TipRect, text: string): void {\n if (key === activeKey) {\n // Already up for this subject: move it, do not re-animate it.\n if (tip && !tip.hidden) { renderTip(tip, text); place(rect); }\n return;\n }\n // A different subject: down first, then wait again. Leaving the old bubble up\n // during the wait would put one card's name over another card, which is worse\n // than no name at all - and it matches the delegated route, where leaving an\n // element hides the tip before the next one is scheduled.\n hide();\n activeKey = key;\n timer = window.setTimeout(() => { timer = 0; paint(rect, text); }, SHOW_DELAY);\n}\n\n/** Take any tip down: the pointer has left, or a gesture has started. */\nexport function hideTip(): void { hide(); }\n\n/**\n * Mount the renderer because something is about to speak the grammar.\n *\n * The themed tooltip is not a feature a host turns on; it is the renderer for a grammar the shell's own\n * components already speak, and `data-tip` with nothing listening draws NOTHING - not the themed\n * bubble, not the platform one. That silence cost Patterpad two releases of a pin with no tooltip, and\n * cost it again when a `title` was converted to `data-tip` in a window that had never mounted this.\n *\n * So `el` calls this whenever it sets a tip. Mounting a delegated listener is the same class of act as\n * `confirmDialog` appending to `document.body`, which this package has always done.\n */\nexport function ensureTooltipHost(): void { initTooltips(); }\n\n/**\n * One deferred check that an app writing `data-tip` ITSELF has a host, warning if not.\n *\n * `ensureTooltipHost` covers anything built through `el`. It cannot cover a `data-tip` written straight\n * into markup or set by hand, which is the case that leaves a whole window of dead tips with no shell\n * component involved - so that one gets a warning rather than silence. Scheduled once, after the\n * current task, so it sees a rendered document rather than an empty one.\n */\nexport function checkTooltipHost(): void {\n if (checked) return;\n checked = true;\n setTimeout(() => {\n if (inited || typeof document === \"undefined\") return;\n if (document.querySelector(\"[data-tip]\")) {\n console.warn(\"app-shell: something set `data-tip` but no tooltip host is mounted, so those rollovers will not draw. Call initTooltips() once per window.\");\n }\n }, 0);\n}\n\nconst tipAncestor = (n: EventTarget | null): HTMLElement | null =>\n (n instanceof Element ? n.closest<HTMLElement>(\"[data-tip]\") : null);\n\n/**\n * Wire the one delegated controller. Mounting happens once; OPTIONS do not.\n *\n * An explicit call is always authoritative about its options, even after something else has already\n * mounted the listener. That ordering is not hypothetical, and Storyletter caught it before it shipped:\n * once components self-mount (see `ensureTooltipHost`), a host's own\n * `initTooltips({ suppressed })` could land second and be dropped by an early return, silently taking\n * a rule like \"no tooltips in Writing View\" with it. Nothing would fail and nothing would show.\n *\n * Components therefore call this with NO arguments: they mount the renderer without claiming the\n * options, and the host keeps the last word on behaviour.\n */\nexport function initTooltips(opts: TooltipOptions = {}): void {\n if (opts.suppressed !== undefined) suppressed = opts.suppressed; // an explicit call always wins\n if (inited) return;\n inited = true;\n\n document.addEventListener(\"pointerover\", (e) => {\n const el = tipAncestor(e.target);\n if (el) schedule(el);\n });\n document.addEventListener(\"pointerout\", (e) => {\n const el = tipAncestor(e.target);\n if (!el) return;\n const to = (e as PointerEvent).relatedTarget;\n if (to instanceof Node && el.contains(to)) return; // still inside the same anchor\n hide();\n });\n // Keyboard parity: reveal on focus, dismiss on blur.\n document.addEventListener(\"focusin\", (e) => { const el = tipAncestor(e.target); if (el) schedule(el); });\n document.addEventListener(\"focusout\", () => hide());\n // It's ANCHORED (not cursor-following), so anything that moves the layout or context dismisses it.\n document.addEventListener(\"pointerdown\", () => hide(), true);\n document.addEventListener(\"scroll\", () => { if (active) hide(); }, true);\n document.addEventListener(\"keydown\", (e) => { if (e.key === \"Escape\") hide(); });\n window.addEventListener(\"blur\", () => hide());\n}\n","// ---------------------------------------------------------------------------\n// The family's icon vocabulary.\n//\n// An icon is a WORD. Two apps in one suite spelling \"close\" differently is the\n// same fault as calling one thing a scene here and a chapter there, and it is\n// harder to notice because nobody reads glyphs, they just feel wrong. This\n// module exists so that no app ever types a codepoint again: it asks for\n// `iconNode(\"close\")` and gets whatever the family has agreed that means.\n//\n// The evidence that it was needed, gathered 2026-08-09 across both apps:\n// Patterpad spelled close as a cross twelve times, Storyletter used the same\n// cross once and a multiplication sign twice, in one window, and a comment\n// bubble had just been invented from scratch with nothing to check it against.\n//\n// DRAWN, not typed (design-language.md section 4, \"Icons are drawn, and so are\n// separators\", 2026-09-16). The first cut of this table was Unicode glyphs,\n// which render from whatever symbol font the OS has, so weight, baseline and\n// optical size drifted per character and per platform. The vocabulary is now\n// one drawn set: Lucide, vendored below as inline SVG strings on one 24-unit\n// grid at one stroke weight. The words did not change; what they draw did.\n//\n// Lucide 1.46.0 (lucide-static), ISC licence.\n// https://lucide.dev / https://cdn.jsdelivr.net/npm/lucide-static@1.46.0/icons/<name>.svg\n// Fetched 2026-09-16. The chosen decision record is\n// patterkit/design/ui-review-2026-09/07c-track-c-icon-sets-notes.md.\n//\n// STROKE. The family draws icons at 14px inside its small square buttons and\n// wants a 1.5px rendered stroke against Inter at that size (Inter Regular's\n// stems are about 1.3px there). Lucide's native stroke is 2 on a 24 grid,\n// which is 2 x 14/24 = 1.17px at 14px, a shade light. So the root of every\n// stroke icon carries stroke-width=\"2.571\": 2.571 x 14/24 = 1.5. A caller\n// drawing at another size gets the proportional weight (12px: 1.29px; 16px:\n// 1.71px), which is what one drawn set means. Filled shapes (the discs) carry\n// fill=\"currentColor\" and no stroke at all.\n//\n// Every icon is `currentColor`, so it takes the colour of the button it sits\n// in, and none of the strings carries width/height: the size is the caller's\n// (`iconNode(name, size)`), so an icon can never be the wrong size somewhere\n// because a CSS rule failed to reach it.\n//\n// Adding one: it needs a MEANING, not a picture. \"A downward chevron\" is not an\n// entry; \"expand this\" is. If two callers want the same picture for two\n// meanings, that is two entries, and one of them will be wrong later.\n// ---------------------------------------------------------------------------\n//\n// Lucide licence (the icons vendored in this file):\n//\n// ISC License\n// Copyright (c) 2026 Lucide Icons and Contributors\n//\n// Permission to use, copy, modify, and/or distribute this software for any\n// purpose with or without fee is hereby granted, provided that the above\n// copyright notice and this permission notice appear in all copies.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n//\n// Portions of Lucide (among those used here: arrow-down, arrow-left,\n// arrow-right, arrow-up, check, chevron-down, chevron-left, chevron-right,\n// circle, lock, plus, search, x) derive from Feather, MIT,\n// Copyright (c) 2013-present Cole Bemis. See LICENSES.md.\n// ---------------------------------------------------------------------------\n\n/**\n * The typed glyphs the vocabulary used to draw.\n *\n * @deprecated Since the move to drawn icons (design-language.md, \"Icons are\n * drawn\"). Kept byte-for-byte so a consumer still doing\n * `textContent = icon.close` keeps working while each app moves; a new call\n * site uses `iconNode(name)` (a node to append) or `iconHtml(name)` (for an\n * innerHTML build). The names are the same in all three. Removed once both\n * apps have moved.\n */\nexport const icon = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. Patterpad's, twelve times over. */\n close: \"✕\",\n /** The overflow menu on a document or a row: \"more about this\". */\n more: \"⋯\",\n /** Collapsed disclosure, pointing at what would open. */\n collapsed: \"▸\",\n /** Expanded disclosure. */\n expanded: \"▾\",\n /** A dropdown's affordance, where it is not a real <select>. */\n dropdown: \"▾\",\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. */\n back: \"‹\",\n /** Forward / next. */\n forward: \"›\",\n /** Up one, in a list. */\n up: \"↑\",\n /** Down one. */\n down: \"↓\",\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. */\n tick: \"✓\",\n /** Somebody else holds this: the version-control lock. */\n locked: \"⊘\",\n /** Read-only on disk with no other holder: the resting state of everything\n * in a lock-based working copy that nobody has checked out yet. */\n readOnly: \"○\",\n /** YOU hold this one: checked out / opened by the current user, still yours to\n * edit. Shares its glyph with `note`, which the table permits: an entry is a\n * MEANING, and two meanings may draw the same shape. */\n checkedOut: \"✎\",\n /** Tracked, with local changes not yet committed. */\n modified: \"●\",\n /** Not in version control yet: new since the last commit. */\n untracked: \"+\",\n /** Something needs attention but is not fatal. */\n warning: \"‼\",\n /** A live thing: the running position, an active marker. */\n dot: \"●\",\n /** Play, in the sense of \"run this\". */\n play: \"▶\",\n /** Start the thing again from the top: a play session, a sweep. Named for the\n * act, not the arrow, which is the table's rule. */\n restart: \"⟲\",\n /** The three ways a collection can be shown. Named by what you get rather than\n * by the glyph, so a second app can pick the same three without copying\n * somebody's taste in symbols. */\n viewCards: \"▦\",\n viewTable: \"☰\",\n viewNode: \"◈\",\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. */\n grip: \"⠿\",\n /** Add one of whatever this list holds. */\n add: \"+\",\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: the pencil. Both apps had chosen it independently,\n * which is the happiest way for a vocabulary entry to arrive. */\n note: \"✎\",\n /** A comment thread. Speech, not a pencil: documentation states the reason,\n * comments are the conversation, and the two must never look alike. */\n comment: \"❝\",\n} as const;\n\n/**\n * Every word in the vocabulary. The 26 the glyph table had, plus the seven the\n * 2026-09 review found the apps drawing by hand with nothing to check against,\n * and the two the 2026-10 Patterpad review found the same way (`copy`,\n * `speaker`).\n */\nexport type IconName =\n | keyof typeof icon\n /** History back, the topbar's quiet arrow pair (nav-history.ts). An ARROW,\n * not a chevron: a chevron says structure, an arrow says time (the author's\n * ruling, 2026-08-28). Added beside `arrowRight` so the pair share a set. */\n | \"arrowLeft\"\n /** History forward; also the one honest \"go there\" arrow where a link used\n * to carry a typed one. */\n | \"arrowRight\"\n /** Connect to a server, a live link, a running game. */\n | \"connect\"\n /** Search. */\n | \"search\"\n /** Keep this window on top (tool-window-web.ts). */\n | \"pin\"\n /** Settings. */\n | \"settings\"\n /** Record. The icon is the DISC; painting it in the danger colour while\n * recording is the caller's job, through the button's own colour. */\n | \"record\"\n /** Copy this to the clipboard. The confirmation is `tick`, shown by the\n * caller while `copyWithFeedback` holds `.copied` on the button. */\n | \"copy\"\n /** Sound: play with audio, a table read. The act of hearing, not a volume\n * control. */\n | \"speaker\";\n\n// The two roots every drawing shares. Kept as constants so the table below is\n// the inner elements only, which is what a reader compares against lucide.dev.\nconst STROKE = '<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.571\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">';\nconst FILL = '<svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">';\nconst stroked = (inner: string): string => `${STROKE}${inner}</svg>`;\nconst filled = (inner: string): string => `${FILL}${inner}</svg>`;\n\n// The three discs are the one drawing in the table that is not Lucide's own\n// element as shipped: Lucide's `circle` is an r=10 outline that fills its box,\n// which at badge size beside a row title is a blot, so the disc is drawn at a\n// smaller radius with the fill forced (the same amount of hand-drawing as the\n// legacy noteFilled below, and the decision record's stated cost). `modified`\n// and `dot` share it, as their glyphs did; `record` is larger because a record\n// button is meant to fill more of its box.\nconst DISC = filled('<circle cx=\"12\" cy=\"12\" r=\"6\"/>');\nconst DISC_LARGE = filled('<circle cx=\"12\" cy=\"12\" r=\"9\"/>');\n\n/**\n * The drawings, by word. Each is a complete `<svg viewBox=\"0 0 24 24\" …>`\n * string with no width/height (see `iconNode` / `iconHtml`, which size it).\n * The Lucide name each derives from is on the entry, so a reviewer can put\n * the two side by side.\n */\nconst DRAWN: Record<IconName, string> = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. (x) */\n close: stroked('<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>'),\n /** The overflow menu on a document or a row: \"more about this\". (ellipsis) */\n more: stroked('<circle cx=\"12\" cy=\"12\" r=\"1\"/><circle cx=\"19\" cy=\"12\" r=\"1\"/><circle cx=\"5\" cy=\"12\" r=\"1\"/>'),\n /** Collapsed disclosure, pointing at what would open. (chevron-right) */\n collapsed: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Expanded disclosure. (chevron-down) */\n expanded: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n /** A dropdown's affordance, where it is not a real <select>. (chevron-down) */\n dropdown: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. (chevron-left) */\n back: stroked('<path d=\"m15 18-6-6 6-6\"/>'),\n /** Forward / next. (chevron-right) */\n forward: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Up one, in a list. (arrow-up) */\n up: stroked('<path d=\"m5 12 7-7 7 7\"/><path d=\"M12 19V5\"/>'),\n /** Down one. (arrow-down) */\n down: stroked('<path d=\"M12 5v14\"/><path d=\"m19 12-7 7-7-7\"/>'),\n /** History back. (arrow-left) */\n arrowLeft: stroked('<path d=\"m12 19-7-7 7-7\"/><path d=\"M19 12H5\"/>'),\n /** History forward; \"go there\". (arrow-right) */\n arrowRight: stroked('<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>'),\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. (check) */\n tick: stroked('<path d=\"M20 6 9 17l-5-5\"/>'),\n /** Somebody else holds this: the version-control lock. (lock) */\n locked: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/>'),\n /** Read-only on disk with no other holder. (lock-open) An open lock rather\n * than a struck-out eye: this state is not a prohibition. Nobody holds the\n * file, saving checks it out, and it is the resting state of everything the\n * author has not touched yet under a lock-based VCS. eye-off would say \"you\n * cannot\", which is false here; the open lock says \"not held\", beside\n * `locked`, which is the shut one, so the two read as a pair. */\n readOnly: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 9.9-1\"/>'),\n /** YOU hold this one: checked out, still yours to edit. (pencil) */\n checkedOut: stroked('<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\"/><path d=\"m15 5 4 4\"/>'),\n /** Tracked, with local changes not yet committed. (a disc; see DISC) */\n modified: DISC,\n /** Not in version control yet: new since the last commit. (plus) */\n untracked: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Something needs attention but is not fatal. (triangle-alert) */\n warning: stroked('<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/>'),\n /** A live thing: the running position, an active marker. (a disc) */\n dot: DISC,\n /** Play, in the sense of \"run this\". (play) */\n play: stroked('<path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\"/>'),\n /** Start the thing again from the top: a play session, a sweep. (rotate-ccw) */\n restart: stroked('<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/>'),\n /** The three ways a collection can be shown, named by what you get. */\n /** Cards. (layout-grid) */\n viewCards: stroked('<rect width=\"7\" height=\"7\" x=\"3\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"14\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"3\" y=\"14\" rx=\"1\"/>'),\n /** A table. (rows-3: a ruled box, which is a table. `list` is bullets, and\n * the view is not a list.) */\n viewTable: stroked('<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"/><path d=\"M21 9H3\"/><path d=\"M21 15H3\"/>'),\n /** A node graph. (waypoints: four nodes on edges reads as a graph.\n * `git-fork` reads as version control, which this family also draws, and\n * a picture that means two things is the fault this table exists to\n * prevent.) */\n viewNode: stroked('<path d=\"m10.586 5.414-5.172 5.172\"/><path d=\"m18.586 13.414-5.172 5.172\"/><path d=\"M6 12h12\"/><circle cx=\"12\" cy=\"20\" r=\"2\"/><circle cx=\"12\" cy=\"4\" r=\"2\"/><circle cx=\"20\" cy=\"12\" r=\"2\"/><circle cx=\"4\" cy=\"12\" r=\"2\"/>'),\n /** Record: the disc, in whatever colour the button is. (a disc; see DISC_LARGE) */\n record: DISC_LARGE,\n /** Sound: play with audio. (volume-2: the cone and two waves. Patterpad's\n * hand-drawn one had a single wave, which at 14px reads as quiet rather\n * than as sound.) */\n speaker: stroked('<path d=\"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z\"/><path d=\"M16 9a5 5 0 0 1 0 6\"/><path d=\"M19.364 18.364a9 9 0 0 0 0-12.728\"/>'),\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. (grip-vertical) */\n grip: stroked('<circle cx=\"9\" cy=\"12\" r=\"1\"/><circle cx=\"9\" cy=\"5\" r=\"1\"/><circle cx=\"9\" cy=\"19\" r=\"1\"/><circle cx=\"15\" cy=\"12\" r=\"1\"/><circle cx=\"15\" cy=\"5\" r=\"1\"/><circle cx=\"15\" cy=\"19\" r=\"1\"/>'),\n /** Add one of whatever this list holds. (plus) */\n add: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Copy this to the clipboard. (copy: the front sheet whole, the back\n * sheet showing round two of its sides) */\n copy: stroked('<rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/>'),\n /** Connect: to a server, a live link, a running game. (plug) */\n connect: stroked('<path d=\"M12 22v-5\"/><path d=\"M15 8V2\"/><path d=\"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z\"/><path d=\"M9 8V2\"/>'),\n /** Search. (search) */\n search: stroked('<path d=\"m21 21-4.34-4.34\"/><circle cx=\"11\" cy=\"11\" r=\"8\"/>'),\n /** Keep this window on top. (pin) */\n pin: stroked('<path d=\"M12 17v5\"/><path d=\"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z\"/>'),\n /** Settings. (settings) */\n settings: stroked('<path d=\"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/>'),\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: a document with lines on it. (file-text) The glyph\n * table drew a pencil and shared it with `checkedOut`; the drawn set gives\n * the two meanings two shapes, and notes get the document, which is what\n * the shell's own noteFilled/noteOutline pair had always drawn. */\n note: stroked('<path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\"/><path d=\"M14 2v5a1 1 0 0 0 1 1h5\"/><path d=\"M10 9H8\"/><path d=\"M16 13H8\"/><path d=\"M16 17H8\"/>'),\n /** A comment thread. Speech, not a document: documentation states the\n * reason, comments are the conversation, and the two must never look\n * alike. (message-square) */\n comment: stroked('<path d=\"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\"/>'),\n};\n\n/**\n * The drawings as strings, by word, for a caller that builds markup itself.\n * Prefer `iconHtml(name, size)`, which sizes it; these carry no width/height.\n *\n * Two legacy entries ride along unchanged: `noteFilled` and `noteOutline`, the\n * has-notes / no-notes pair Patterpad drew on a 16-unit grid before the set\n * existed. They are sized in the markup (13px) and on their own grid, so they\n * are NOT part of the vocabulary above and `iconNode` does not know them; no\n * app uses them today. They stay until a 24-grid pair replaces them, because\n * their two-state meaning (there are notes / there are none) has no Lucide\n * shape, and re-weighting the 16-grid drawing to the family stroke merges its\n * text lines.\n */\nexport const iconSvg = {\n ...DRAWN,\n /** A document with lines: notes exist on this thing. (legacy, 16 grid) */\n noteFilled: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"currentColor\" fill-rule=\"evenodd\" aria-hidden=\"true\"><path d=\"M3.4 1.4h5.3L12.6 5.3v8.1a1.2 1.2 0 0 1-1.2 1.2H3.4a1.2 1.2 0 0 1-1.2-1.2V2.6A1.2 1.2 0 0 1 3.4 1.4ZM4.9 6.8h6.2v1.1H4.9Zm0 2.1h6.2v1.1H4.9Zm0 2.1h3.7v1.1H4.9Z\"/></svg>',\n /** The same document, empty: nothing written here yet. (legacy, 16 grid) */\n noteOutline: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.1\" stroke-linejoin=\"round\" stroke-linecap=\"round\" aria-hidden=\"true\"><path d=\"M3.4 2h4.9l3.9 3.9v7.5a1 1 0 0 1-1 1H3.4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z\"/><path d=\"M8.3 2.2v3.8h3.8\"/><path d=\"M4.9 8h6.2M4.9 10h6.2M4.9 12h3.7\" stroke-width=\"0.95\"/></svg>',\n} as const;\n\nexport type IconSvgName = keyof typeof iconSvg;\n\n/** Every word, in table order, for a test or a gallery to walk. */\nexport const ICON_NAMES = Object.keys(DRAWN) as IconName[];\n\n/** The default size: 14px, the family's icon inside its small square button. */\nexport const ICON_SIZE = 14;\n\n/**\n * The drawing as markup with its size set, for a caller building innerHTML.\n * `data-icon` carries the word, so a stylesheet or a test can find it.\n */\nexport function iconHtml(name: IconName, size = ICON_SIZE): string {\n return DRAWN[name].replace(\"<svg \", `<svg width=\"${size}\" height=\"${size}\" data-icon=\"${name}\" `);\n}\n\n// One parsed template per word, filled on first use; every call clones it, so\n// the string is parsed once per window and each caller gets its own node.\nconst templates = new Map<IconName, SVGSVGElement>();\n\n/**\n * The drawing as a fresh SVG node, sized. Append it where the glyph used to be\n * set as text; it is `aria-hidden`, so the button's accessible name stays the\n * button's (`aria-label` / `data-tip`), as it always had to.\n */\nexport function iconNode(name: IconName, size = ICON_SIZE): SVGSVGElement {\n let tpl = templates.get(name);\n if (!tpl) {\n const holder = document.createElement(\"template\");\n holder.innerHTML = DRAWN[name];\n tpl = holder.content.firstElementChild as SVGSVGElement;\n tpl.setAttribute(\"data-icon\", name);\n templates.set(name, tpl);\n }\n const node = tpl.cloneNode(true) as SVGSVGElement;\n node.setAttribute(\"width\", String(size));\n node.setAttribute(\"height\", String(size));\n return node;\n}\n\n// The glyph table, reversed, so a legacy call site that still hands the shell\n// a typed character (\"✕\", \"↑\") draws the word it stood for. Where two words\n// shared a glyph the first in table order wins, which is fine: the picture was\n// the same either way. Goes when `icon` does.\nconst BY_GLYPH = new Map<string, IconName>();\nfor (const [name, glyph] of Object.entries(icon) as [IconName, string][]) {\n if (!BY_GLYPH.has(glyph)) BY_GLYPH.set(glyph, name);\n}\n\n/** The word a deprecated glyph stood for, or undefined for any other string. */\nexport function iconNameOfGlyph(glyph: string): IconName | undefined {\n return BY_GLYPH.get(glyph);\n}\n\n/** Whether a string is a word in the vocabulary. */\nexport function isIconName(s: string): s is IconName {\n return Object.prototype.hasOwnProperty.call(DRAWN, s);\n}\n","// ---------------------------------------------------------------------------\n// `el`: the tiny tag-typed element factory both apps build their imperative,\n// idempotent views with.\n//\n// A SUPERSET of the two apps' prior signatures, so neither rewrites call sites:\n// - Patterpad: el(tag, cls?, text?) (positional)\n// - Storylet Studio: el(tag, { className, text, ... }, ...kids) (options bag)\n// A string second argument is the className; an object is the props bag; string\n// children become text nodes. So `el(\"div\", \"c\", \"t\")` and\n// `el(\"div\", { className: \"c\" }, \"t\")` produce identical DOM.\n// ---------------------------------------------------------------------------\n\nimport { ensureTooltipHost, checkTooltipHost } from \"./tooltip.js\";\nimport { iconNode, iconNameOfGlyph, isIconName, type IconName } from \"./icons.js\";\n\nexport type Child = Node | string | null | undefined;\n\nexport interface ElProps {\n className?: string;\n text?: string;\n /** A NATIVE rollover. Prefer `tip`: `title` is OS chrome on the platform's own\n * slow delay, which is the seam the themed tooltip exists to close. */\n title?: string;\n /** A themed rollover (`data-tip`, picked up by the delegated controller that\n * `initTooltips()` wires). Also the accessible name, since the elements that\n * want one are usually icon buttons with no text of their own. */\n tip?: string;\n onClick?: (event: MouseEvent) => void;\n}\n\nexport function el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n classNameOrProps?: string | ElProps,\n ...children: Child[]\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n const props: ElProps = typeof classNameOrProps === \"string\"\n ? { className: classNameOrProps }\n : classNameOrProps ?? {};\n if (props.className) node.className = props.className;\n if (props.text !== undefined && props.text !== null) node.textContent = props.text;\n if (props.title !== undefined) node.title = props.title;\n if (props.tip !== undefined) {\n node.dataset[\"tip\"] = props.tip;\n node.setAttribute(\"aria-label\", props.tip);\n // Setting a tip mounts the renderer. Without this, `data-tip` draws nothing at all in a window whose\n // host never called `initTooltips()`, which is a silent failure rather than a degraded one. No\n // options passed: the host stays authoritative about behaviour (see tooltip.ts).\n ensureTooltipHost();\n }\n if (props.onClick) node.addEventListener(\"click\", props.onClick as EventListener);\n for (const child of children) {\n if (child === null || child === undefined) continue;\n node.append(child);\n }\n checkTooltipHost(); // one-shot: warns if the APP wrote data-tip and nothing mounted a host\n return node;\n}\n\n/** A small square icon button (the move/delete controls list editors share).\n * Its rollover is the THEMED one (`data-tip`), so an app that has called\n * `initTooltips()` gets our bubble rather than the platform's.\n *\n * `name` is a word from the vocabulary (\"up\", \"close\"), drawn at 14px. A\n * typed glyph from the deprecated `icon` table (\"↑\", \"✕\") is accepted for\n * now and drawn as the word it stood for, so an app that has not moved its\n * call sites yet still gets the drawn set; any other string is set as text,\n * which is the old behaviour and on its way out. */\nexport function iconBtn(name: IconName | (string & {}), title: string, onClick: () => void, disabled = false, danger = false): HTMLButtonElement {\n const b = el(\"button\", `shell-icon${danger ? \" danger\" : \"\"}`);\n b.type = \"button\"; b.dataset[\"tip\"] = title; b.setAttribute(\"aria-label\", title);\n const word = isIconName(name) ? name : iconNameOfGlyph(name);\n if (word) b.append(iconNode(word)); else b.textContent = name;\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n}\n\n/** The sentence under a settings row: plain text, or nodes when it carries\n * markup (a `code` for a file name, a `b` for an option's name). */\nexport type FieldHint = string | Node | Array<string | Node>;\n\n/**\n * A captioned field, the family's settings row (the 2026-10 review, ruling C):\n * the caption on the left and the control inline beside it,\n * `<label class=\"shell-labelled\"><span class=\"shell-fieldcap\">…</span>control</label>`.\n *\n * The label is pointed at the field it captions, EXPLICITLY, and never at a button. A `<label>` with no\n * `for` forwards a click to its first labelable descendant, and buttons are labelable - so a caption\n * wrapped around a control containing buttons (`tagChips`, whose every chip carries a remove button)\n * turns every click on the row's dead space into a press of the FIRST button in it. That shipped:\n * patterkit/patter#44, where clicking a Game Data list value anywhere but its ✕ deleted the first value\n * in the list. Reported as \"clicking a value removes the wrong one\", which is not a wrong-index bug at\n * all - the click never reached the chip. The same rule makes a control GROUP safe to caption: a field\n * with its own Choose… or Import… button beside it (`.shell-inline`) captions the field, and the button\n * stays a button.\n *\n * When the control holds no labelable field (a chips editor with the add input removed, say), this is a\n * plain `<div>`: no caption behaviour is better than a caption that presses something.\n *\n * With a `hint`, the row and the sentence under it come back together in a `.shell-field`, the hint as\n * the field's description (`aria-describedby`) rather than inside the label, where it would become part\n * of the field's NAME and be read out every time it takes focus. Without one, the row is exactly what it\n * always was.\n */\nexport function labelled(label: string, control: HTMLElement, hint?: FieldHint): HTMLElement {\n const target = control.matches(\"input, select, textarea\")\n ? control\n : control.querySelector<HTMLElement>(\"input:not([type=button]):not([type=submit]), select, textarea\");\n const w = el(target ? \"label\" : \"div\", \"shell-labelled\");\n w.append(el(\"span\", \"shell-fieldcap\", label), control);\n if (target) {\n if (!target.id) target.id = uid();\n (w as HTMLLabelElement).htmlFor = target.id;\n }\n if (hint === undefined) return w;\n const note = el(\"p\", \"shell-fieldhint\");\n note.append(...(Array.isArray(hint) ? hint : [hint]));\n note.id = uid();\n if (target) {\n const by = target.getAttribute(\"aria-describedby\");\n target.setAttribute(\"aria-describedby\", by ? `${by} ${note.id}` : note.id);\n }\n return el(\"div\", \"shell-field\", w, note);\n}\n\nconst uid = (): string => `shell-f-${Math.random().toString(36).slice(2, 9)}`;\n\nexport interface LabelledToggleOptions {\n checked?: boolean;\n /** The sentence under the row: what turning it on does. */\n hint?: FieldHint;\n /** An option that only means something while the row above it is set (Patterpad's \"Embed source\n * language for debug\" under an IDs-only build): indented under that row with a rule, so it reads as\n * belonging to it rather than as a peer. */\n sub?: boolean;\n disabled?: boolean;\n /** Fired on every flip, with the new state. The input is handed back too, for a caller that reads it\n * on Save instead. */\n onChange?: (checked: boolean) => void;\n}\n\n/**\n * The settings toggle, `labelled`'s partner (ruling C): the caption on the left, the checkbox beside it\n * where any other row has its control, and the optional hint under the row. One shape in both apps, so\n * a switch in one app's settings looks like a switch in the other's. Clicking the caption flips it, as\n * the label is the checkbox's.\n *\n * Returns the outermost row (to append, hide, or indent) and the input (to read or listen to).\n */\nexport function labelledToggle(label: string, opts: LabelledToggleOptions = {}): { row: HTMLElement; input: HTMLInputElement } {\n const input = el(\"input\", \"shell-toggle-input\");\n input.type = \"checkbox\";\n input.checked = opts.checked ?? false;\n input.disabled = opts.disabled ?? false;\n const { onChange } = opts;\n if (onChange) input.addEventListener(\"change\", () => onChange(input.checked));\n const row = labelled(label, input, opts.hint);\n // On the caption-and-box line itself, whether or not a hint wraps it.\n (row.matches(\".shell-labelled\") ? row : row.querySelector(\".shell-labelled\"))?.classList.add(\"shell-toggle\");\n if (opts.sub) row.classList.add(\"shell-suboption\");\n return { row, input };\n}\n\n/** Swap item `i` with its neighbour `i + delta` IN PLACE (the up/down reorder list editors share);\n * a no-op when the target is out of range. Returns whether anything moved. */\nexport function moveItem<T>(arr: T[], i: number, delta: number): boolean {\n const j = i + delta;\n if (j < 0 || j >= arr.length) return false;\n [arr[i], arr[j]] = [arr[j]!, arr[i]!];\n return true;\n}\n\n/** The icon size inside a chip's remove / move buttons: the chip is set at\n * 0.76rem, so its controls draw smaller than a toolbar button's 14px. */\nconst CHIP_ICON = 10;\n\n/** A tag-style editor for a string-list field (an enum's allowed values / flags): removable chips + an\n * add input (Enter or \",\" commits; blank / duplicate ignored). Mutates `holder.values` in place (read\n * back on save). `onChange` fires after any add / remove so callers can refresh a dependent control. */\nexport function tagChips(holder: { values?: string[] }, onChange?: () => void): HTMLElement {\n const wrap = el(\"div\", \"shell-tags\");\n const input = el(\"input\", \"shell-tag-input\");\n // Sentence-cased like every other hint (the microcopy ruling, 2026-08-28):\n // lowercase fragments read as adrift, and a placeholder is a hint speaking.\n input.type = \"text\"; input.placeholder = \"Add value\"; input.spellcheck = false;\n const makeChip = (v: string): HTMLElement => {\n const chip = el(\"span\", \"shell-tag\", v);\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.values = (holder.values ?? []).filter((o) => o !== v); chip.remove(); onChange?.(); });\n chip.append(x);\n return chip;\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.values ?? []).includes(v)) { (holder.values ??= []).push(v); wrap.insertBefore(makeChip(v), input); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n for (const v of holder.values ?? []) wrap.append(makeChip(v));\n wrap.append(input);\n return wrap;\n}\n\n/** What `stageChips` tells its caller beyond \"something changed\". */\nexport interface StageChipsOptions {\n /**\n * A stage was renamed in place, `from` to `to`. Given, a rename calls this\n * INSTEAD of `onChange`: values are stored by stage name, so whoever knows\n * where those values live has to carry them, and doing it as one edit is\n * theirs to arrange. Absent, a rename is an ordinary change.\n */\n onRename?: (from: string, to: string) => void;\n /** The stages were reordered (after `onChange`): the one edit that changes\n * what every ordering gate means without changing any value. */\n onReorder?: () => void;\n}\n\n/**\n * An ORDERED chips editor for a string-list field whose order means something\n * (a quality's stages: `advance()` walks them, so 2 comes after 1): numbered\n * chips, each with move-earlier / move-later / remove, plus an add input\n * (Enter or \",\" commits; blank / duplicate ignored). A stage's name renames\n * in place when clicked (Enter or blur commits, Escape cancels; blank, the same\n * name or another stage's is ignored). Mutates `holder.stages` in place;\n * `onChange` fires after any add / move / remove, and after a rename unless\n * `opts.onRename` takes it.\n *\n * Patterpad's, lifted (ui-review-2026-09, finding 3); Storyletter had been\n * faking it with `tagChips` over a `values` holder, which loses the order\n * controls. Same class family as `tagChips` (`.shell-tags`), so it is styled by\n * settings.css already.\n */\nexport function stageChips(holder: { stages?: string[] }, onChange?: () => void, opts: StageChipsOptions = {}): HTMLElement {\n const wrap = el(\"div\", \"shell-tags shell-stages\");\n const input = el(\"input\", \"shell-tag-input\");\n input.type = \"text\"; input.placeholder = \"Add stage\"; input.spellcheck = false;\n const control = (name: IconName, tip: string, disabled: boolean, onClick: () => void): HTMLButtonElement => {\n const b = el(\"button\", \"shell-tag-x shell-tag-move\", iconNode(name, CHIP_ICON));\n b.type = \"button\"; b.dataset[\"tip\"] = tip; b.setAttribute(\"aria-label\", tip);\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n };\n // The name, editable in place. A span with a button's role rather than a\n // <button>, so the chip's own controls stay its only buttons.\n const nameLabel = (chip: HTMLElement, v: string, i: number): HTMLElement => {\n const label = el(\"span\", \"shell-tag-label\", `${i + 1}. ${v}`);\n label.setAttribute(\"role\", \"button\"); label.tabIndex = 0;\n label.dataset[\"tip\"] = `Rename ${v}`;\n const edit = (): void => {\n const field = el(\"input\", \"shell-tag-input shell-stage-rename\");\n field.type = \"text\"; field.value = v; field.spellcheck = false;\n field.setAttribute(\"aria-label\", `Rename ${v}`);\n let done = false;\n const finish = (keep: boolean): void => {\n if (done) return;\n done = true;\n const to = field.value.trim();\n const stages = holder.stages ?? [];\n if (keep && to !== \"\" && to !== v && !stages.includes(to)) {\n stages[stages.indexOf(v)] = to;\n rebuild();\n if (opts.onRename) opts.onRename(v, to); else onChange?.();\n } else {\n rebuild();\n }\n };\n field.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\") { e.preventDefault(); finish(true); }\n else if (e.key === \"Escape\") { e.preventDefault(); e.stopPropagation(); finish(false); }\n });\n field.addEventListener(\"blur\", () => finish(true));\n label.replaceWith(field);\n chip.classList.add(\"editing\");\n field.focus(); field.select();\n };\n // The chips usually sit inside a <label> for the add input (`labelled`),\n // whose activation would move focus there and close the rename at once.\n label.addEventListener(\"click\", (e) => { e.preventDefault(); edit(); });\n label.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); edit(); } });\n return label;\n };\n const moved = (): void => { rebuild(); onChange?.(); opts.onReorder?.(); };\n const rebuild = (): void => {\n for (const c of Array.from(wrap.children)) if (c !== input) c.remove();\n const stages = holder.stages ?? [];\n stages.forEach((v, i) => {\n const chip = el(\"span\", \"shell-tag\");\n chip.dataset[\"stage\"] = v;\n chip.append(\n nameLabel(chip, v, i),\n control(\"back\", `Move ${v} earlier`, i === 0, () => { if (moveItem(stages, i, -1)) moved(); }),\n control(\"forward\", `Move ${v} later`, i === stages.length - 1, () => { if (moveItem(stages, i, 1)) moved(); }),\n );\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.stages = (holder.stages ?? []).filter((o) => o !== v); rebuild(); onChange?.(); });\n chip.append(x);\n wrap.insertBefore(chip, input);\n });\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.stages ?? []).includes(v)) { (holder.stages ??= []).push(v); rebuild(); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n wrap.append(input);\n rebuild();\n return wrap;\n}\n\n// --- drag-to-reorder ---------------------------------------------------------\n// One drag at a time per window, shared across every wired list, so the\n// midpoint test knows what is being carried without a dataTransfer round trip.\nlet reorderDragId: string | null = null;\nconst clearDropMarks = (host: ParentNode): void =>\n host.querySelectorAll(\".drop-before, .drop-after\").forEach((e) => e.classList.remove(\"drop-before\", \"drop-after\"));\n\n/**\n * Make `el` a drag source and a drop target for HTML5 drag-to-reorder among\n * its siblings. While carried it wears `.dragging`; a hovered target wears\n * `.drop-before` or `.drop-after` by the midpoint test on `axis` (\"y\" for\n * rows, \"x\" for a wrapping grid); a drop calls `onMove(draggedId, before,\n * targetId)` and the caller reorders its model and re-renders.\n *\n * Storyletter's `wireCardDrag`, lifted (ui-review-2026-09, finding 30);\n * Patterpad's `wireSceneDrag` is the same idea fixed on \"y\". The marks are\n * classes only: the app draws them (Patterpad's `box-shadow: 0 -2px 0 0\n * var(--accent)` pair is the family's look).\n */\nexport function wireReorder(el: HTMLElement, id: string, axis: \"x\" | \"y\", onMove: (id: string, before: boolean, targetId: string) => void): void {\n el.draggable = true;\n el.dataset[\"reorderId\"] = id;\n const host = (): ParentNode => el.parentElement ?? el;\n el.addEventListener(\"dragstart\", (e) => {\n reorderDragId = id; el.classList.add(\"dragging\");\n if (e.dataTransfer) { e.dataTransfer.effectAllowed = \"move\"; e.dataTransfer.setData(\"text/plain\", id); }\n });\n el.addEventListener(\"dragend\", () => { reorderDragId = null; el.classList.remove(\"dragging\"); clearDropMarks(host()); });\n el.addEventListener(\"dragover\", (e) => {\n if (!reorderDragId || reorderDragId === id) return;\n e.preventDefault();\n if (e.dataTransfer) e.dataTransfer.dropEffect = \"move\";\n const r = el.getBoundingClientRect();\n const before = axis === \"y\" ? e.clientY < r.top + r.height / 2 : e.clientX < r.left + r.width / 2;\n clearDropMarks(host());\n el.classList.add(before ? \"drop-before\" : \"drop-after\");\n });\n el.addEventListener(\"dragleave\", () => el.classList.remove(\"drop-before\", \"drop-after\"));\n el.addEventListener(\"drop\", (e) => {\n e.preventDefault();\n const before = el.classList.contains(\"drop-before\");\n clearDropMarks(host());\n if (reorderDragId && reorderDragId !== id) onMove(reorderDragId, before, id);\n });\n}\n\n// --- metadata and breadcrumbs ---------------------------------------------------\n// \"Icons are drawn, and so are separators\" (design-language.md section 4,\n// 2026-09-16): metadata is never joined with \"·\" and a breadcrumb is never a\n// string with \"›\" in it. Both apps had been building exactly those strings\n// (ui-review-2026-09, marker A); these two helpers make the same lines as DOM,\n// with the separator drawn by CSS (controls.css) or by the icon vocabulary.\n\n/**\n * A metadata line: `parts` as spans in a flex row, separated by a drawn\n * 3px disc (a `::before` on every part after the first, in controls.css),\n * so `metaLine([\"6 runs\", \"200 max steps\", \"seed 4\"])` is what\n * \"6 runs · 200 max steps · seed 4\" used to be, without the typed dot.\n * Empty, null and undefined parts are skipped, so a caller can pass an\n * optional segment without branching.\n */\nexport function metaLine(parts: (string | Node | null | undefined)[]): HTMLElement {\n const row = el(\"span\", \"shell-meta\");\n for (const part of parts) {\n if (part === null || part === undefined || part === \"\") continue;\n const seg = el(\"span\", \"shell-meta-part\");\n seg.append(part);\n row.append(seg);\n }\n return row;\n}\n\nexport interface Crumb {\n label: string;\n /** Makes the crumb a button. Ignored on the last crumb, which is where the\n * reader already is. */\n onClick?: (event: MouseEvent) => void;\n}\n\n/**\n * A breadcrumb trail: each crumb a span, or a button when it carries\n * `onClick` and is not the last, with `iconNode(\"forward\", 12)` drawn between\n * them. `breadcrumb([\"Box\", \"Deck\", \"Card\"])` is what \"Box › Deck › Card\"\n * used to be; the chevrons are the family's own drawing, not a symbol-font\n * character.\n */\nexport function breadcrumb(parts: (string | Crumb)[]): HTMLElement {\n const trail = el(\"nav\", \"shell-crumbs\");\n trail.setAttribute(\"aria-label\", \"Where this is\");\n parts.forEach((part, i) => {\n const crumb: Crumb = typeof part === \"string\" ? { label: part } : part;\n const last = i === parts.length - 1;\n if (i > 0) {\n const sep = iconNode(\"forward\", 12);\n sep.classList.add(\"shell-crumb-sep\");\n trail.append(sep);\n }\n if (crumb.onClick && !last) {\n const b = el(\"button\", { className: \"shell-crumb shell-crumb-link\", text: crumb.label, onClick: crumb.onClick });\n b.type = \"button\";\n trail.append(b);\n } else {\n const s = el(\"span\", \"shell-crumb\", crumb.label);\n if (last) s.setAttribute(\"aria-current\", \"location\");\n trail.append(s);\n }\n });\n return trail;\n}\n","// ---------------------------------------------------------------------------\n// Typed value controls: how both apps show and set a value of a declared type.\n//\n// The first is the quality's. A quality is a step on a ladder, so its value is\n// shown as the LADDER, with the current rung marked, rather than a dropdown that\n// shows one name and hides where it stands (patterkit design/proposals/\n// patter-qualities.md section 4). Storyletter's Board drew it this way first;\n// it lives here so Storyletter's Fields tab, Patterpad's play panel and Game\n// Data rows, and the play inspectors all draw the same strip.\n//\n// An UNSET value (a field or game-data value the node leaves out) names what it\n// falls back to, \"default (x)\", by the family's one rule: the declaration's own\n// default, else the type's (a quality's first stage). A value that is no longer\n// a stage (a deleted one) is shown as such, so it can be put back on the ladder.\n//\n// No Electron, no app state: this module is DOM only, and is its own entry point\n// (`@wildwinter/app-shell/value-control`) so a play inspector outside the apps\n// can take it.\n// ---------------------------------------------------------------------------\n\nimport { el, tagChips } from \"./dom.js\";\n\n/** A declaration as these controls read it: a property's, a field's or a game-data field's. */\nexport interface ValueDeclLike {\n type: string;\n default?: unknown;\n /** enum / flags */\n values?: readonly string[];\n /** quality: the ladder, in order */\n stages?: readonly string[];\n}\n\n/**\n * What an unset value of `decl` falls back to, as the words a control shows: its own default where it has\n * one, else its type's (False, 0, the first value, no flags, the first stage, empty text). The kernel's\n * `defaultFor`, in words; a host reads the same value from the bundle.\n */\nexport function fallbackText(decl: ValueDeclLike): string {\n const d = decl.default;\n if (d !== undefined && d !== null) {\n if (typeof d === \"boolean\") return d ? \"True\" : \"False\";\n if (Array.isArray(d)) return d.length === 0 ? \"none\" : d.join(\", \");\n return d === \"\" ? \"none\" : String(d);\n }\n switch (decl.type) {\n case \"boolean\": return \"False\";\n case \"number\": return \"0\";\n case \"enum\": return decl.values?.[0] ?? \"none\";\n case \"quality\": return decl.stages?.[0] ?? \"first stage\";\n case \"flags\": return \"none\";\n default: return \"empty\";\n }\n}\n\n/** The label an unset value shows: \"default (x)\", naming what it falls back to. */\nexport const defaultLabel = (decl: ValueDeclLike): string => `default (${fallbackText(decl)})`;\n\n/**\n * The quiet line under a ladder that has just been reordered: how many gates order against it. A reorder\n * changes no value, and is the one edit that changes what a gate MEANS without saying so (patter-qualities.md\n * section 2), so the editor says so. Empty when no gate orders the quality.\n */\nexport function stageGateNote(gates: number): string {\n if (gates <= 0) return \"\";\n return gates === 1\n ? \"1 gate compares against this ladder, and it now reads the new order.\"\n : `${gates} gates compare against this ladder, and each now reads the new order.`;\n}\n\nexport interface RungStripOptions {\n /** The ladder, in order. */\n stages: readonly string[];\n /** The value held, or undefined when unset: a field or game-data value the node leaves out. */\n value: string | undefined;\n /** The declaration, for what an unset value falls back to (its default, else the first stage). */\n decl?: ValueDeclLike;\n /** Pick a stage. Absent: the strip is read-only. */\n onPick?: (stage: string) => void;\n /** Clear back to unset. With it, the strip leads with \"default (x)\", which clears the value. */\n onClear?: () => void;\n /** The rollover on a rung that is not the current one (default: `Set to \"x\"`). */\n pickTip?: (stage: string) => string;\n /**\n * The document to build in, for a host outside the apps (a play inspector in a page or a frame of its\n * own). Given, rollovers are plain `title`s and the family's themed tooltips are not mounted; the host\n * styles `.seg`, `.seg-opt` and `.shell-rung` itself. Absent: the apps' document and themed rollovers.\n */\n doc?: Document;\n}\n\n/**\n * A quality's value as its ladder: one rung per stage, in order, the current one marked (`on`). Unset, the\n * rung it falls back to is marked as the fallback (`fallback`), and with `onClear` a leading \"default (x)\"\n * option is the current choice. A value that is not a stage (a deleted one) is shown after the ladder,\n * marked `stray`, until a rung is picked.\n */\nexport function rungStrip(opts: RungStripOptions): HTMLElement {\n const make = opts.doc === undefined ? el : (tag: \"span\" | \"button\", props: { className: string; text?: string; tip?: string; onClick?: () => void }) => {\n const node = opts.doc!.createElement(tag);\n node.className = props.className;\n if (props.text !== undefined) node.textContent = props.text;\n if (props.tip !== undefined) { node.title = props.tip; node.setAttribute(\"aria-label\", props.tip); }\n if (props.onClick) node.addEventListener(\"click\", props.onClick);\n if (tag === \"button\") (node as HTMLButtonElement).type = \"button\";\n return node;\n };\n const strip = make(\"span\", { className: \"seg shell-rungs\" });\n const decl: ValueDeclLike = opts.decl ?? { type: \"quality\", stages: opts.stages };\n const unset = opts.value === undefined;\n const fallback = typeof decl.default === \"string\" && opts.stages.includes(decl.default) ? decl.default : opts.stages[0];\n const readOnly = opts.onPick === undefined;\n if (opts.onClear) {\n strip.append(make(\"button\", {\n className: `seg-opt shell-rung shell-rung-default${unset ? \" on\" : \"\"}`, text: defaultLabel(decl),\n tip: unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n onClick: () => { if (!unset) opts.onClear!(); },\n }));\n }\n for (const stage of opts.stages) {\n const current = opts.value === stage;\n const falls = unset && stage === fallback;\n const rung = make(readOnly ? \"span\" : \"button\", {\n className: `seg-opt shell-rung${current ? \" on\" : \"\"}${falls ? \" fallback\" : \"\"}`, text: stage,\n tip: current ? \"The current stage\" : falls ? \"The stage it falls back to\" : readOnly ? stage : (opts.pickTip?.(stage) ?? `Set to \"${stage}\"`),\n ...(readOnly ? {} : { onClick: () => { if (!current) opts.onPick!(stage); } }),\n });\n strip.append(rung);\n }\n if (!unset && !opts.stages.includes(opts.value!)) {\n strip.append(make(\"span\", {\n className: \"seg-opt shell-rung stray on\", text: opts.value!,\n tip: `\"${opts.value}\" is not one of the stages: pick the one it belongs at now`,\n }));\n }\n return strip;\n}\n\n// ---------------------------------------------------------------------------\n// The field row: ONE control for a node's value of a declared field, driven by\n// the declared type, for the family's seven types (text, multiline, number,\n// boolean, enum, flags, quality). Storyletter's card and outcome Fields and\n// Patterpad's Game Data rows both draw it, which settles the disagreements the\n// parity review found (patterkit design/family-parity-2026-10.md item 10):\n//\n// - the declared purpose is shown, under the control, not hidden in a rollover;\n// - unset says what it falls back to, \"default (x)\", by `defaultLabel`;\n// - flags are a picker of the declared values, not comma-separated text;\n// - multiline is a text area;\n// - a value the declaration refuses (not a number, not one of the values, not\n// a stage) is said under the control, and the app may add its own message;\n// - text commits as typed, and Escape puts back what the field held when it\n// took focus (the family's field rule).\n//\n// Committing as typed means a host that redraws on every change (Patterpad's\n// inspector rebuilds its whole stack) would drop the focus at every keystroke.\n// `fieldRows()` is the answer: it hands back the SAME element for the same key\n// across a redraw, updated in place, and gives the focus (and the caret) back\n// to it once the redraw has put it in the page again.\n// ---------------------------------------------------------------------------\n\n/** A value a field row commits: a flags value is the list of names set. */\nexport type FieldValue = string | number | boolean | string[];\n\n/** A field's declaration as the row reads it: a card field's, an outcome field's or a game-data field's. */\nexport interface FieldDeclLike extends ValueDeclLike {\n name: string;\n /** What the field is for, shown under the control. */\n purpose?: string;\n /** A sentence about each value (an enum's values, the flags, a quality's stages), as an extension's manifest\n * gives them: the chosen value's is shown under the control, and each chosen flag's. */\n valueHelp?: Readonly<Record<string, string>>;\n}\n\n/**\n * The help for what `decl` holds: the chosen enum value's or stage's (the one it falls back to, when unset), or\n * each chosen flag's, \"name: sentence\" a line each. Empty when the declaration describes none of them.\n */\nexport function valueHelpText(decl: FieldDeclLike, value: unknown): string {\n const help = decl.valueHelp;\n if (help === undefined) return \"\";\n const said = (v: string): string | undefined => (Object.prototype.hasOwnProperty.call(help, v) ? help[v] : undefined);\n if (decl.type === \"enum\" || decl.type === \"quality\") {\n const held = typeof value === \"string\" && value !== \"\" ? value\n : typeof decl.default === \"string\" && decl.default !== \"\" ? decl.default\n : decl.type === \"enum\" ? decl.values?.[0] : decl.stages?.[0];\n return held === undefined ? \"\" : said(held) ?? \"\";\n }\n if (decl.type === \"flags\") {\n const held = Array.isArray(value) ? value.map(String) : Array.isArray(decl.default) ? decl.default.map(String) : [];\n return held.flatMap((v) => { const h = said(v); return h === undefined ? [] : [`${v}: ${h}`]; }).join(\"\\n\");\n }\n return \"\";\n}\n\nexport interface FieldRowOptions {\n decl: FieldDeclLike;\n /** The node's own value, typed (a flags value is a string list), or undefined where the node sets none. */\n value: unknown;\n /** Commit a value; `undefined` clears it, back to the default. Absent: the row is read-only. */\n onCommit?: (value: FieldValue | undefined) => void;\n /** Drawn but not editable, as when there is no node to write to. */\n disabled?: boolean;\n /** A message of the app's own about this value (a check the row cannot make), shown under the control. */\n problem?: string;\n /** The app's own sentence INSTEAD of the row's (a renamed stage said better than \"not one of the stages\").\n * Given, it is the whole message; `problem` is ignored. */\n replaceProblem?: string;\n /** The caption; default the field's name. */\n label?: string | Node;\n /** Added to the row and its caption, so a row sits in its app's layout. */\n className?: string;\n labelClassName?: string;\n /** The app's class for a text field or select, used instead of the shell's `.field`. */\n controlClassName?: string;\n}\n\nexport interface FieldRowHandle {\n /** The row: its caption, then the control with the purpose and any message under it. */\n readonly el: HTMLElement;\n /** Redraw for a new value, declaration or message, keeping the element. A field being typed in keeps its\n * text: what the author is typing is newer than what the app last stored. */\n update(opts: FieldRowOptions): void;\n}\n\n/** The type's fallback as a value, for a flags picker to start from when the node sets none. */\nconst fallbackFlags = (decl: ValueDeclLike): string[] => (Array.isArray(decl.default) ? decl.default.filter((v): v is string => typeof v === \"string\") : []);\n\n/** What the row says about a value the declaration refuses, or \"\" when it fits. */\nexport function fieldValueProblem(decl: ValueDeclLike, value: unknown): string {\n if (value === undefined || value === null || value === \"\") return \"\";\n switch (decl.type) {\n case \"number\":\n return typeof value === \"number\" && Number.isFinite(value) ? \"\" : \"Not a number.\";\n case \"boolean\":\n return typeof value === \"boolean\" ? \"\" : \"Not True or False.\";\n case \"enum\":\n return decl.values && !decl.values.includes(String(value)) ? `\"${String(value)}\" is not one of the values.` : \"\";\n case \"quality\":\n return decl.stages && !decl.stages.includes(String(value)) ? `\"${String(value)}\" is not one of the stages.` : \"\";\n case \"flags\": {\n if (!Array.isArray(value)) return \"Not a list of flags.\";\n const strays = decl.values ? value.filter((v) => !decl.values!.includes(String(v))) : [];\n if (strays.length === 0) return \"\";\n return strays.length === 1 ? `\"${String(strays[0])}\" is not one of the values.` : `${strays.map((s) => `\"${String(s)}\"`).join(\", \")} are not among the values.`;\n }\n default:\n return \"\";\n }\n}\n\nconst isTextual = (type: string): boolean => type !== \"boolean\" && type !== \"enum\" && type !== \"flags\" && type !== \"quality\";\n\n/** Everything that decides which control is drawn: a change here rebuilds it, anything else updates it. */\nconst controlShape = (o: FieldRowOptions): string => JSON.stringify([\n o.decl.type, o.decl.values ?? null, o.decl.stages ?? null, o.decl.default ?? null,\n o.onCommit === undefined, o.disabled === true, o.controlClassName ?? \"\",\n o.decl.type === \"quality\" && (o.decl.stages?.length ?? 0) === 0,\n]);\n\n/**\n * One declared field's value as a row: the caption, then the control the declared type calls for, with the\n * purpose and any message under it. See the section comment above for the rules it carries.\n */\nexport function fieldRow(initial: FieldRowOptions): FieldRowHandle {\n let opts = initial;\n const row = el(\"div\", `shell-fieldrow${opts.className ? ` ${opts.className}` : \"\"}`);\n const caption = el(\"span\", `shell-fieldrow-label${opts.labelClassName ? ` ${opts.labelClassName}` : \"\"}`);\n caption.id = `shell-fr-${Math.random().toString(36).slice(2, 9)}`;\n const body = el(\"div\", \"shell-fieldrow-body\");\n const purpose = el(\"p\", \"shell-fieldrow-purpose\");\n const valueHelp = el(\"p\", \"shell-fieldrow-purpose shell-fieldrow-valuehelp\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n row.append(caption, body);\n\n let shape = \"\";\n /** Redraw the control for the current value; set by whichever control is built. */\n let show: (value: unknown) => void = () => {};\n /** A local problem the control found while typing (a number that is not one yet). */\n let typing = \"\";\n\n const commit = (v: FieldValue | undefined): void => { opts.onCommit?.(v); };\n const editable = (): boolean => opts.onCommit !== undefined && opts.disabled !== true;\n // An app's own field class replaces the shell's `.field`, so its controls look like its other fields.\n const ctl = (base: string): string => (opts.controlClassName ? `${base.replace(/^field /, \"\")} ${opts.controlClassName}` : base);\n const labelledBy = (node: HTMLElement): void => {\n node.setAttribute(\"aria-labelledby\", caption.id);\n const described = [purpose.id, problem.id].filter(Boolean).join(\" \");\n if (described) node.setAttribute(\"aria-describedby\", described);\n };\n purpose.id = `${caption.id}-p`; problem.id = `${caption.id}-m`;\n\n const sayProblem = (): void => {\n // The chosen value's own help travels with every change of value, as the message does.\n const help = valueHelpText(opts.decl, opts.value);\n valueHelp.textContent = help;\n valueHelp.hidden = help === \"\";\n const words = opts.replaceProblem !== undefined\n ? [opts.replaceProblem].filter((w) => w !== \"\")\n : [typing || fieldValueProblem(opts.decl, opts.value), opts.problem ?? \"\"].filter((w) => w !== \"\");\n problem.textContent = words.join(\" \");\n problem.hidden = words.length === 0;\n row.classList.toggle(\"has-problem\", words.length > 0);\n row.classList.toggle(\"shell-fieldrow-textual\", isTextual(opts.decl.type));\n };\n\n const build = (): HTMLElement => {\n const decl = opts.decl;\n typing = \"\";\n if (decl.type === \"quality\" && (decl.stages?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-fieldrow-rungs\");\n show = (value) => {\n holder.replaceChildren(rungStrip({\n stages: decl.stages!, value: typeof value === \"string\" && value !== \"\" ? value : undefined, decl,\n ...(editable() ? { onPick: (stage: string) => { opts = { ...opts, value: stage }; show(stage); sayProblem(); commit(stage); }, onClear: () => { opts = { ...opts, value: undefined }; show(undefined); sayProblem(); commit(undefined); } } : {}),\n }));\n const strip = holder.firstElementChild as HTMLElement | null;\n if (strip) { strip.setAttribute(\"role\", \"group\"); labelledBy(strip); }\n };\n return holder;\n }\n if (decl.type === \"boolean\" || decl.type === \"enum\") {\n const sel = el(\"select\", ctl(\"field shell-fieldrow-select\"));\n labelledBy(sel);\n sel.disabled = !editable();\n const choices: Array<[string, string]> = decl.type === \"boolean\"\n ? [[\"true\", \"True\"], [\"false\", \"False\"]]\n : (decl.values ?? []).map((v): [string, string] => [v, v]);\n show = (value) => {\n const current = value === undefined || value === null || value === \"\" ? \"\" : String(value);\n sel.replaceChildren();\n const add = (v: string, label: string): void => { const o = el(\"option\", undefined, label); o.value = v; sel.append(o); };\n add(\"\", defaultLabel(decl));\n for (const [v, label] of choices) add(v, label);\n // A value the declaration no longer offers stays visible, so the author sees what is held.\n if (current !== \"\" && !choices.some(([v]) => v === current)) add(current, current);\n sel.value = current;\n };\n sel.addEventListener(\"change\", () => {\n const raw = sel.value;\n const v: FieldValue | undefined = raw === \"\" ? undefined : decl.type === \"boolean\" ? raw === \"true\" : raw;\n opts = { ...opts, value: v }; sayProblem(); commit(v);\n });\n return sel;\n }\n if (decl.type === \"flags\" && (decl.values?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-flags\");\n holder.setAttribute(\"role\", \"group\");\n labelledBy(holder);\n show = (value) => {\n const unset = !Array.isArray(value);\n const held = unset ? fallbackFlags(decl) : (value as unknown[]).map(String);\n holder.replaceChildren();\n const chip = (text: string, cls: string, pressed: boolean | undefined, tip: string, onClick?: () => void): void => {\n const b = el(onClick && editable() ? \"button\" : \"span\", { className: `shell-flag${cls}`, text, tip });\n b.setAttribute(\"aria-label\", `${text}: ${tip}`); // the tip alone would hide the value's name\n if (b instanceof HTMLButtonElement) { b.type = \"button\"; b.addEventListener(\"click\", onClick!); }\n if (pressed !== undefined) b.setAttribute(\"aria-pressed\", String(pressed));\n holder.append(b);\n };\n const set = (next: string[] | undefined): void => { opts = { ...opts, value: next }; show(next); sayProblem(); commit(next); };\n chip(defaultLabel(decl), ` shell-flag-default${unset ? \" on\" : \"\"}`, undefined,\n unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n unset ? undefined : () => set(undefined));\n for (const v of decl.values!) {\n const on = held.includes(v);\n chip(v, `${on ? \" on\" : \"\"}${on && unset ? \" fallback\" : \"\"}`, on, on ? `Unset ${v}` : `Set ${v}`,\n () => set(on ? held.filter((x) => x !== v) : decl.values!.filter((x) => x === v || held.includes(x)).concat(held.filter((x) => !decl.values!.includes(x)))));\n }\n // A held value the declaration does not offer: shown, struck, and a click drops it.\n for (const v of held.filter((x) => !decl.values!.includes(x))) {\n chip(v, \" stray on\", true, `\"${v}\" is not one of the values: click to drop it`, () => set(held.filter((x) => x !== v)));\n }\n };\n return holder;\n }\n if (decl.type === \"flags\") {\n // No values declared to pick from: the shell's chip editor, each name typed.\n const holder = el(\"span\", \"shell-fieldrow-chips\");\n show = (value) => {\n const box = { values: Array.isArray(value) ? (value as unknown[]).map(String) : [] };\n const chips = tagChips(box, () => {\n const next = box.values.length > 0 ? [...box.values] : undefined;\n opts = { ...opts, value: next }; sayProblem(); commit(next);\n });\n const input = chips.querySelector(\"input\");\n if (input) { labelledBy(input); input.placeholder = Array.isArray(value) ? \"Add value\" : defaultLabel(decl); input.disabled = !editable(); }\n chips.querySelectorAll(\"button\").forEach((b) => { (b as HTMLButtonElement).disabled = !editable(); });\n holder.replaceChildren(chips);\n };\n return holder;\n }\n // text, multiline, number, and any type the row does not know: typed, committed as typed.\n const multiline = decl.type === \"multiline\";\n const field = multiline ? el(\"textarea\", ctl(\"field shell-fieldrow-text\")) : el(\"input\", ctl(\"field shell-fieldrow-text\"));\n if (field instanceof HTMLInputElement) {\n field.type = \"text\";\n if (decl.type === \"number\") field.inputMode = \"decimal\";\n } else field.rows = 3;\n labelledBy(field);\n field.placeholder = defaultLabel(decl);\n field.disabled = !editable();\n const asText = (value: unknown): string =>\n value === undefined || value === null ? \"\" : Array.isArray(value) ? value.join(\", \") : String(value);\n const read = (raw: string): { value?: FieldValue; bad?: string } => {\n if (raw.trim() === \"\") return {};\n if (decl.type !== \"number\") return { value: raw };\n const n = Number(raw.trim());\n return Number.isFinite(n) ? { value: n } : { bad: \"Not a number.\" };\n };\n let atFocus = \"\";\n show = (value) => {\n // What the author is typing is newer than the stored value, so a focused field keeps its text.\n // So does one the author was in when a redraw took the row out of the page, until they leave it.\n if (field.ownerDocument.activeElement === field || keeper.restoring(field) || keeper.holds(row)) return;\n field.value = asText(value);\n };\n const take = (): void => {\n const r = read(field.value);\n typing = r.bad ?? \"\";\n if (r.bad === undefined) opts = { ...opts, value: r.value };\n sayProblem();\n if (r.bad === undefined) commit(r.value);\n };\n field.addEventListener(\"focus\", () => { if (!keeper.restoring(field)) atFocus = field.value; });\n field.addEventListener(\"input\", take);\n field.addEventListener(\"keydown\", (e) => {\n if ((e as KeyboardEvent).key !== \"Escape\" || field.value === atFocus) return;\n field.value = atFocus;\n take();\n });\n return field;\n };\n\n const draw = (next: FieldRowOptions): void => {\n const decl = next.decl;\n const label = next.label ?? decl.name;\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n caption.className = `shell-fieldrow-label${next.labelClassName ? ` ${next.labelClassName}` : \"\"}`;\n row.className = `shell-fieldrow${next.className ? ` ${next.className}` : \"\"}`;\n const nextShape = controlShape(next);\n opts = next;\n if (nextShape !== shape) {\n shape = nextShape;\n body.replaceChildren(build());\n }\n show(next.value);\n purpose.textContent = decl.purpose ?? \"\";\n if (decl.purpose) body.append(purpose); else purpose.remove();\n body.append(valueHelp, problem);\n sayProblem();\n };\n\n draw(initial);\n keeper.watch(row);\n return { el: row, update: draw };\n}\n\n// --- keeping the focus across a redraw -------------------------------------\n//\n// A host that rebuilds its view takes the row out of the page and puts it back.\n// Taking a focused element out drops its focus, which is the same thing as\n// the author losing their place mid-word. So a row remembers whether the\n// author was in it, and where the caret was, and the cache gives both back\n// once the row is in the page again (a microtask: after the host's redraw).\n\ninterface FocusMemo { field: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement; start: number | null; end: number | null }\n\nconst keeper = (() => {\n const memos = new WeakMap<HTMLElement, FocusMemo>();\n const restoringNow = new WeakSet<Element>();\n /** When each row was last handed back by the cache, to tell a move's late blur from the author's. */\n const redrawn = new WeakMap<HTMLElement, number>();\n const put = (row: HTMLElement): void => {\n const memo = memos.get(row);\n if (!memo) return;\n const doc = row.ownerDocument;\n const active = doc.activeElement;\n if (!row.isConnected || !memo.field.isConnected || !row.contains(memo.field)) return;\n if (active && active !== doc.body && !row.contains(active)) { memos.delete(row); return; }\n if (active === memo.field && memo.field.matches(\":focus\")) return;\n restoringNow.add(memo.field);\n try {\n memo.field.focus({ preventScroll: true });\n if (!(memo.field instanceof HTMLSelectElement) && memo.start !== null) memo.field.setSelectionRange(memo.start, memo.end ?? memo.start);\n } finally { restoringNow.delete(memo.field); }\n };\n return {\n watch(row: HTMLElement): void {\n const note = (e: Event): void => {\n const t = e.target;\n if (!(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement)) return;\n const text = !(t instanceof HTMLSelectElement);\n memos.set(row, { field: t, start: text ? (t as HTMLInputElement).selectionStart : null, end: text ? (t as HTMLInputElement).selectionEnd : null });\n };\n row.addEventListener(\"focusin\", note);\n row.addEventListener(\"input\", note);\n row.addEventListener(\"keyup\", note);\n row.addEventListener(\"mouseup\", note);\n // A blur the author made (the row still in the page) forgets; one caused by the row leaving the page\n // does not, and is what the cache puts back. Chromium drops the focus of a moved element LATE: the\n // blur arrives after the redraw, the row already back in the page, so a blur to nowhere just after a\n // redraw is the move's, and the focus goes straight back.\n // Chromium may also fire that blur synchronously, as the host clears its view and before the cache\n // has handed the row back: so the decision waits for the microtask, by which time a row the redraw\n // asked for again is marked as redrawn since the blur.\n row.addEventListener(\"focusout\", (e) => {\n const at = performance.now();\n const late = (e as FocusEvent).relatedTarget === null && at - (redrawn.get(row) ?? -Infinity) < 250;\n if (late && memos.has(row)) { queueMicrotask(() => put(row)); return; }\n queueMicrotask(() => {\n if ((redrawn.get(row) ?? -Infinity) >= at) { put(row); return; }\n if (row.isConnected && !row.contains(row.ownerDocument.activeElement)) memos.delete(row);\n });\n });\n },\n /** Give the focus back to the row, if the author was in it and has not gone anywhere else since. */\n restore(row: HTMLElement): void {\n if (!memos.has(row)) return;\n redrawn.set(row, performance.now());\n // At the microtask, not now: the event that caused the redraw may still note the caret.\n queueMicrotask(() => put(row));\n },\n restoring: (field: Element): boolean => restoringNow.has(field),\n /** Forget the row's focus if the author has since gone somewhere else (before the row is redrawn). */\n settle(row: HTMLElement): void {\n const active = row.ownerDocument.activeElement;\n if (active && active !== row.ownerDocument.body && !row.contains(active)) memos.delete(row);\n },\n /** The row the author is in (before a redraw takes it out). */\n holds: (row: HTMLElement): boolean => memos.has(row),\n };\n})();\n\n/**\n * The focus keeping `fieldRows` does, for a host (or a structured row) that keeps row elements itself: call\n * `settle` before it updates a row and `restore` once the row is back in the page.\n */\nexport const fieldRowFocus = {\n settle: (row: HTMLElement): void => keeper.settle(row),\n restore: (row: HTMLElement): void => keeper.restore(row),\n};\n\nexport interface FieldRows {\n /**\n * The row for `key` (a node and a field, say `${nodeId}:${field}`): the same element as last time when\n * there was one, updated for these options, else a new one. A row the author was typing in gets its focus\n * and caret back once the redraw has put it in the page.\n */\n row(key: string, opts: FieldRowOptions): HTMLElement;\n /** Forget every row not asked for since the last sweep (call at the end of a redraw). */\n sweep(): void;\n}\n\n/** A cache of field rows for a host that redraws its whole view on every change. */\nexport function fieldRows(): FieldRows {\n const rows = new Map<string, { handle: FieldRowHandle; used: boolean }>();\n return {\n row(key, opts) {\n const had = rows.get(key);\n if (had) {\n had.used = true;\n keeper.settle(had.handle.el);\n had.handle.update(opts);\n keeper.restore(had.handle.el);\n return had.handle.el;\n }\n const handle = fieldRow(opts);\n rows.set(key, { handle, used: true });\n return handle.el;\n },\n sweep() {\n for (const [key, entry] of rows) { if (!entry.used) rows.delete(key); else entry.used = false; }\n },\n };\n}\n","// ---------------------------------------------------------------------------\n// Rows for a value of ANY declared type: the seven scalars through the field\n// row, and the types an extension's fields add (patterkit design/proposals/\n// patter-storylet-extensions.md, \"Tier 1: fields\"): a `reference` to one of the\n// host's nodes, a `pick` of one choice from the sources its manifest names, a\n// `record` of named fields, a `map` keyed by a reference or by text, and a `list`\n// with ids or without.\n//\n// A structured value is drawn as its parts, each part a row of its own, so the\n// family's field rules hold all the way down: commit as typed, Escape restores,\n// the unset state names what it falls back to, a value the declaration refuses\n// is said under it, and a row keeps its element (and its focus) across a redraw.\n// The checks are `@wildwinter/toolkit/extensions`' (`valueProblems`), the same\n// ones the command lines run, so the editor and validation never disagree.\n//\n// The host supplies what only it knows through an adapter: which nodes there are\n// of a kind (a map keyed by tag offers the tags, a reference to a card the\n// cards), and the lists of text on the extension's project node a pick offers.\n// No Electron, no app state: DOM only.\n//\n// Its own entry (`@wildwinter/app-shell/value-rows`) rather than part of\n// value-control, because it needs `@wildwinter/toolkit/extensions` (an optional\n// peer, toolkit 0.2.5 or later) and the scalar row does not: a host that draws\n// only the family's seven types takes nothing new.\n// ---------------------------------------------------------------------------\n\nimport { defaultOf, pickChoices, valueProblems } from \"@wildwinter/toolkit/extensions\";\nimport type { PickSource, TypeDecl, ValueContext } from \"@wildwinter/toolkit/extensions\";\nimport { el, iconBtn, moveItem } from \"./dom.js\";\nimport { fieldRow, fieldRowFocus } from \"./value-control.js\";\nimport type { FieldDeclLike, FieldRowHandle, FieldValue } from \"./value-control.js\";\n\n/** A declaration of any type, as an extension's manifest writes it. */\nexport interface ValueDecl extends FieldDeclLike {\n /** The caption; the name when absent. */\n label?: string;\n /** A sentence or two shown under the control (an extension's `help`, a field's `purpose`). */\n help?: string;\n /** A reference's node kind. */\n to?: string;\n /** A pick's sources, in the order its choices are shown: fixed words, a node kind, a project list. */\n from?: readonly PickSource[];\n /** A record's fields. */\n fields?: ValueDecl[];\n /** A map's key: text, or a reference to a node kind. */\n key?: { type: string; to?: string };\n /** A map's or a list's value type. */\n of?: Omit<ValueDecl, \"name\"> & { name?: string };\n /** A list's id field: the text field of its records that keys each item. */\n id?: string;\n min?: number;\n max?: number;\n required?: boolean;\n}\n\n/** One node the host offers, by id, with the name the author knows it by. */\nexport interface ValueNode { id: string; label: string }\n\n/** What only the host knows: the nodes of a kind (`card`, `tag`, `cast`...), for references, map keys and picks,\n * and the lists of text on the extension's own project node, for picks. */\nexport interface ValueAdapter {\n nodes(kind: string): readonly ValueNode[];\n /**\n * The entries of a list of text on the extension's own project node, by field name, for a pick's `list` source\n * (the toolkit's `pickLists` reads them off the project entry). A host scopes it to the extension whose rows it\n * draws. Absent: a pick offers no list entries, and doesn't check against them.\n */\n list?(name: string): readonly string[] | undefined;\n /**\n * The name of a node by kind and id, for a value that holds one `nodes` does not offer (a node outside the\n * choices, say): undefined when there is no such node, which is then shown as gone. Absent: a held id `nodes`\n * does not list is taken to be gone.\n */\n label?(kind: string, id: string): string | undefined;\n}\n\n/** A node's name: from the choices, else the host's `label`; undefined when the host says there is none. */\nfunction nodeLabel(adapter: ValueAdapter, kind: string, id: string): string | undefined {\n return adapter.nodes(kind).find((n) => n.id === id)?.label ?? adapter.label?.(kind, id);\n}\n\nexport interface ValueRowOptions {\n decl: ValueDecl;\n /** The node's own value, or undefined where it sets none. */\n value: unknown;\n /** Commit a value; undefined clears it, back to the default. Absent: read-only. */\n onCommit?: (value: unknown) => void;\n /** The host's nodes, for references and map keys. Absent: a reference is typed as an id. */\n adapter?: ValueAdapter;\n disabled?: boolean;\n /** A message of the app's own about this value, shown under it. */\n problem?: string;\n /** The app's own sentence instead of the row's own checks, as the field row's `replaceProblem`. */\n replaceProblem?: string;\n /** The caption; default the declaration's label, else its name. */\n label?: string | Node;\n className?: string;\n labelClassName?: string;\n controlClassName?: string;\n}\n\nexport interface ValueRowHandle {\n readonly el: HTMLElement;\n update(opts: ValueRowOptions): void;\n}\n\nconst SCALARS = new Set([\"text\", \"multiline\", \"number\", \"boolean\", \"enum\", \"flags\", \"quality\", \"string\"]);\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null && !Array.isArray(v);\nconst nameOf = (decl: ValueDecl): string => decl.label ?? decl.name;\nconst asDecl = (d: Omit<ValueDecl, \"name\"> & { name?: string }, name: string): ValueDecl => ({ ...d, name: d.name ?? name });\n\n/** The toolkit's checks for this value, as words for the row itself (the parts say their own). */\nfunction ownProblems(decl: ValueDecl, value: unknown, adapter: ValueAdapter | undefined): string {\n if (value === undefined) return \"\";\n return valueProblems(decl as unknown as TypeDecl, value, contextOf(adapter))\n .filter((p) => p.path === \"\" && (p.severity === \"error\" || p.code === \"pick-ambiguous\") && p.code !== \"not-a-value\" && p.code !== \"not-a-stage\")\n .map((p) => `${p.message.replace(/^the value/, \"The value\")}.`)\n .join(\" \");\n}\n\n/** The adapter as the toolkit's checks take it: whether a node exists, and a project list's entries. */\nfunction contextOf(adapter: ValueAdapter | undefined): ValueContext {\n if (!adapter) return {};\n return {\n exists: (kind: string, id: string) => nodeLabel(adapter, kind, id) !== undefined,\n ...(adapter.list ? { list: (name: string) => adapter.list!(name) } : {}),\n };\n}\n\n/**\n * A row for a value of `decl`'s type, whatever it is: a scalar as the field row, a reference as a choice of\n * the host's nodes, and a record, map or list as its parts, each a row of its own. Keeps its element, and its\n * parts' elements, across `update`, so a host that redraws on every change keeps the author's place.\n */\nexport function valueRow(initial: ValueRowOptions): ValueRowHandle {\n const decl = initial.decl;\n if (SCALARS.has(decl.type)) return scalarRow(initial);\n if (decl.type === \"reference\") return referenceRow(initial);\n if (decl.type === \"pick\") return pickRow(initial);\n return structuredRow(initial);\n}\n\n/** The field row, with an extension's help as its purpose and the toolkit's range checks. */\nfunction scalarRow(initial: ValueRowOptions): ValueRowHandle {\n const map = (o: ValueRowOptions) => {\n const range = ownProblems(o.decl, o.value, o.adapter);\n const problem = [range, o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n return {\n decl: { ...o.decl, ...(o.decl.help !== undefined && o.decl.purpose === undefined ? { purpose: o.decl.help } : {}) },\n value: o.value,\n ...(o.onCommit ? { onCommit: (v: FieldValue | undefined) => o.onCommit!(v) } : {}),\n ...(o.disabled !== undefined ? { disabled: o.disabled } : {}),\n ...(problem !== \"\" ? { problem } : {}),\n ...(o.replaceProblem !== undefined ? { replaceProblem: o.replaceProblem } : {}),\n label: o.label ?? nameOf(o.decl),\n ...(o.className !== undefined ? { className: o.className } : {}),\n ...(o.labelClassName !== undefined ? { labelClassName: o.labelClassName } : {}),\n ...(o.controlClassName !== undefined ? { controlClassName: o.controlClassName } : {}),\n };\n };\n const handle: FieldRowHandle = fieldRow(map(initial));\n return { el: handle.el, update: (o) => handle.update(map(o)) };\n}\n\n/** A reference: a choice of the host's nodes of its kind, \"default (none)\" first; a node that has gone stays\n * visible as what is held. Without an adapter, the id is typed. */\nfunction referenceRow(initial: ValueRowOptions): ValueRowHandle {\n let opts = initial;\n if (!opts.adapter) {\n const inner = scalarRow({ ...opts, decl: { ...opts.decl, type: \"text\" } });\n return { el: inner.el, update: (o) => { opts = o; inner.update({ ...o, decl: { ...o.decl, type: \"text\" } }); } };\n }\n const row = el(\"div\", \"shell-fieldrow shell-valuerow-ref\");\n const caption = el(\"span\", \"shell-fieldrow-label\");\n const body = el(\"div\", \"shell-fieldrow-body\");\n const sel = el(\"select\", \"field shell-fieldrow-select\");\n const help = el(\"p\", \"shell-fieldrow-purpose\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n body.append(sel, help, problem);\n row.append(caption, body);\n sel.addEventListener(\"change\", () => {\n const v = sel.value === \"\" ? undefined : sel.value;\n opts = { ...opts, value: v };\n draw(opts);\n opts.onCommit?.(v);\n });\n const draw = (o: ValueRowOptions): void => {\n opts = o;\n row.className = `shell-fieldrow shell-valuerow-ref${o.className ? ` ${o.className}` : \"\"}`;\n const label = o.label ?? nameOf(o.decl);\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n if (o.controlClassName) sel.className = `shell-fieldrow-select ${o.controlClassName}`;\n const nodes = o.adapter!.nodes(o.decl.to ?? \"\");\n const held = typeof o.value === \"string\" ? o.value : \"\";\n sel.replaceChildren();\n const add = (v: string, text: string): void => { const opt = el(\"option\", undefined, text); opt.value = v; sel.append(opt); };\n add(\"\", \"default (none)\");\n for (const n of nodes) add(n.id, n.label);\n if (held !== \"\" && !nodes.some((n) => n.id === held)) {\n // A node outside the choices keeps its name; only one the host says does not exist reads as gone.\n const name = o.adapter!.label?.(o.decl.to ?? \"\", held);\n add(held, name ?? `${held} (gone)`);\n }\n sel.value = held;\n sel.disabled = o.onCommit === undefined || o.disabled === true;\n help.textContent = o.decl.help ?? o.decl.purpose ?? \"\";\n help.hidden = help.textContent === \"\";\n const words = o.replaceProblem ?? [ownProblems(o.decl, o.value, o.adapter), o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n problem.textContent = words;\n problem.hidden = words === \"\";\n row.classList.toggle(\"has-problem\", words !== \"\");\n };\n draw(initial);\n return { el: row, update: draw };\n}\n\n/**\n * A pick: one choice, \"auto\" (empty) first, then each source's choices in the declared order, a node kind's and a\n * project list's under their names. A value no source holds stays visible as what is held, marked missing; a\n * name two sources hold is said under it. Without an adapter, a pick of fixed words alone is still a choice of\n * them, and one with other sources is typed as text.\n */\nfunction pickRow(initial: ValueRowOptions): ValueRowHandle {\n let opts = initial;\n if (!opts.adapter && (opts.decl.from ?? []).some((s) => !(\"words\" in s))) {\n const inner = scalarRow({ ...opts, decl: { ...opts.decl, type: \"text\" } });\n return { el: inner.el, update: (o) => { opts = o; inner.update({ ...o, decl: { ...o.decl, type: \"text\" } }); } };\n }\n const row = el(\"div\", \"shell-fieldrow shell-valuerow-pick\");\n const caption = el(\"span\", \"shell-fieldrow-label\");\n const body = el(\"div\", \"shell-fieldrow-body\");\n const sel = el(\"select\", \"field shell-fieldrow-select\");\n const help = el(\"p\", \"shell-fieldrow-purpose\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n body.append(sel, help, problem);\n row.append(caption, body);\n sel.addEventListener(\"change\", () => {\n const v = sel.value === \"\" ? undefined : sel.value;\n opts = { ...opts, value: v };\n draw(opts);\n opts.onCommit?.(v);\n });\n const groupName = (s: PickSource): string | undefined =>\n \"to\" in s ? (s.to === \"cast\" ? \"Cast\" : s.to.charAt(0).toUpperCase() + s.to.slice(1)) : \"list\" in s ? s.list : undefined;\n const draw = (o: ValueRowOptions): void => {\n opts = o;\n row.className = `shell-fieldrow shell-valuerow-pick${o.className ? ` ${o.className}` : \"\"}`;\n const label = o.label ?? nameOf(o.decl);\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n if (o.controlClassName) sel.className = `shell-fieldrow-select ${o.controlClassName}`;\n const adapter = o.adapter;\n const choices = pickChoices(o.decl as unknown as TypeDecl, {\n ...(adapter ? { nodes: (kind: string) => adapter.nodes(kind) } : {}),\n ...(adapter?.list ? { list: (name: string) => adapter.list!(name) } : {}),\n });\n const held = typeof o.value === \"string\" ? o.value : \"\";\n sel.replaceChildren();\n const option = (v: string, text: string): HTMLOptionElement => { const opt = el(\"option\", undefined, text); opt.value = v; return opt; };\n sel.append(option(\"\", \"auto\"));\n // One group per source, in order; a value two sources hold is offered by the first only, so the select\n // shows one choice for what it holds (the row says the name is ambiguous).\n const offered = new Set<string>();\n let group: { source: PickSource; el: HTMLElement } | undefined;\n for (const c of choices) {\n if (offered.has(c.value)) continue;\n offered.add(c.value);\n const name = groupName(c.source);\n if (name === undefined) { group = undefined; sel.append(option(c.value, c.label)); continue; }\n if (group?.source !== c.source) {\n const og = el(\"optgroup\");\n og.setAttribute(\"label\", name);\n sel.append(og);\n group = { source: c.source, el: og };\n }\n group.el.append(option(c.value, c.label));\n }\n if (held !== \"\" && !offered.has(held)) {\n // A node outside the choices keeps its name (as a reference's does); anything else is missing.\n const named = (o.decl.from ?? []).map((s) => (\"to\" in s && adapter ? adapter.label?.(s.to, held) : undefined)).find((n) => n !== undefined);\n sel.append(option(held, named ?? `${held} (missing)`));\n }\n sel.value = held;\n sel.disabled = o.onCommit === undefined || o.disabled === true;\n help.textContent = o.decl.help ?? o.decl.purpose ?? \"\";\n help.hidden = help.textContent === \"\";\n const words = o.replaceProblem ?? [ownProblems(o.decl, o.value, o.adapter), o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n problem.textContent = words;\n problem.hidden = words === \"\";\n row.classList.toggle(\"has-problem\", words !== \"\");\n };\n draw(initial);\n return { el: row, update: draw };\n}\n\n/** A part of a structured value: a row, keyed so it is the same element next time. */\ninterface Part { key: string; handle: ValueRowHandle; holder: HTMLElement; tools: HTMLElement }\n\n/** A record, a map or a list: a caption, then its parts, each a row of its own, with the controls the type\n * calls for (add and remove for a map; add, remove and move for a list). */\nfunction structuredRow(initial: ValueRowOptions): ValueRowHandle {\n let opts = initial;\n const row = el(\"div\", \"shell-fieldrow shell-valuerow\");\n const caption = el(\"span\", \"shell-fieldrow-label\");\n const body = el(\"div\", \"shell-fieldrow-body shell-valuerow-parts\");\n const help = el(\"p\", \"shell-fieldrow-purpose\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n const adder = el(\"div\", \"shell-valuerow-add\");\n row.append(caption, body);\n const parts = new Map<string, Part>();\n /** The parts kept from the last draw, whose focus goes back to them once they are in the page again. */\n let kept: HTMLElement[] = [];\n let addKey = \"\";\n\n const editable = (): boolean => opts.onCommit !== undefined && opts.disabled !== true;\n const commit = (v: unknown): void => { opts = { ...opts, value: v }; draw(opts); opts.onCommit?.(v); };\n\n /** The row for one part, the same element as last time for the same key. */\n const part = (key: string, o: ValueRowOptions, controls: HTMLElement[] = []): HTMLElement => {\n const had = parts.get(key);\n if (had && had.handle.el.dataset[\"type\"] === o.decl.type) {\n fieldRowFocus.settle(had.handle.el);\n had.handle.update(o);\n // Its own slot, not the first one inside it: a structured part has slots of its own further down.\n had.tools.replaceChildren(...controls);\n kept.push(had.handle.el);\n return had.holder;\n }\n const handle = valueRow(o);\n handle.el.dataset[\"type\"] = o.decl.type;\n const holder = el(\"div\", \"shell-valuerow-part\");\n const tools = el(\"span\", \"shell-valuerow-controls\");\n tools.append(...controls);\n holder.append(handle.el, tools);\n parts.set(key, { key, handle, holder, tools });\n return holder;\n };\n\n const draw = (o: ValueRowOptions): void => {\n opts = o;\n kept = [];\n const decl = o.decl;\n row.className = `shell-fieldrow shell-valuerow shell-valuerow-${decl.type}${o.className ? ` ${o.className}` : \"\"}`;\n const label = o.label ?? nameOf(decl);\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n const used = new Set<string>();\n const rows: HTMLElement[] = [];\n const child = (key: string, childDecl: ValueDecl, value: unknown, onCommit: (v: unknown) => void, controls?: HTMLElement[], childLabel?: string, extraProblem?: string): void => {\n used.add(key);\n rows.push(part(key, {\n decl: childDecl, value,\n ...(editable() ? { onCommit } : {}),\n ...(o.adapter ? { adapter: o.adapter } : {}),\n ...(o.disabled !== undefined ? { disabled: o.disabled } : {}),\n ...(childLabel !== undefined ? { label: childLabel } : {}),\n ...(extraProblem ? { problem: extraProblem } : {}),\n ...(o.controlClassName !== undefined ? { controlClassName: o.controlClassName } : {}),\n }, controls));\n };\n\n if (decl.type === \"record\") {\n const value = isObject(o.value) ? o.value : undefined;\n const required = value === undefined ? [] : valueProblems(decl as unknown as TypeDecl, value).filter((p) => p.code === \"required\");\n for (const f of decl.fields ?? []) {\n const missing = required.find((p) => p.path === f.name);\n child(`f:${f.name}`, f, value?.[f.name], (v) => {\n const next: Record<string, unknown> = { ...(isObject(opts.value) ? opts.value : {}) };\n if (v === undefined) delete next[f.name]; else next[f.name] = v;\n commit(Object.keys(next).length > 0 ? next : undefined);\n }, undefined, undefined, missing ? \"Required.\" : undefined);\n }\n } else if (decl.type === \"map\" && decl.of) {\n const value = isObject(o.value) ? o.value : {};\n const keyNodes = decl.key?.type === \"reference\" && o.adapter ? o.adapter.nodes(decl.key.to ?? \"\") : undefined;\n const keyKind = decl.key?.to ?? \"\";\n const keyLabel = (k: string): string => (o.adapter && keyNodes !== undefined ? nodeLabel(o.adapter, keyKind, k) : undefined) ?? k;\n for (const k of Object.keys(value)) {\n const remove = editable() ? [iconBtn(\"close\", `Remove ${keyLabel(k)}`, () => {\n const next = { ...(isObject(opts.value) ? opts.value : {}) };\n delete next[k];\n commit(Object.keys(next).length > 0 ? next : undefined);\n })] : [];\n const gone = keyNodes !== undefined && o.adapter && nodeLabel(o.adapter, keyKind, k) === undefined ? `${k} is not here any more.` : undefined;\n child(`k:${k}`, asDecl(decl.of, k), value[k], (v) => {\n const next = { ...(isObject(opts.value) ? opts.value : {}) };\n next[k] = v === undefined ? defaultOf(decl.of as unknown as TypeDecl) : v;\n commit(next);\n }, remove, keyLabel(k), gone);\n }\n adder.replaceChildren();\n if (editable()) {\n const add = (k: string): void => {\n if (k === \"\" || Object.prototype.hasOwnProperty.call(value, k)) return;\n commit({ ...value, [k]: defaultOf(decl.of as unknown as TypeDecl) });\n };\n if (keyNodes !== undefined) {\n const pick = el(\"select\", \"field shell-valuerow-key\");\n const first = el(\"option\", undefined, \"Add...\"); first.value = \"\"; pick.append(first);\n for (const n of keyNodes.filter((n) => !Object.prototype.hasOwnProperty.call(value, n.id))) {\n const opt = el(\"option\", undefined, n.label); opt.value = n.id; pick.append(opt);\n }\n pick.addEventListener(\"change\", () => add(pick.value));\n adder.append(pick);\n } else {\n const input = el(\"input\", \"field shell-valuerow-key\");\n input.type = \"text\"; input.placeholder = \"New key\"; input.value = addKey;\n input.addEventListener(\"input\", () => { addKey = input.value; });\n const go = (): void => { const k = input.value.trim(); addKey = \"\"; add(k); };\n input.addEventListener(\"keydown\", (e) => { if ((e as KeyboardEvent).key === \"Enter\") go(); });\n adder.append(input, iconBtn(\"add\", \"Add\", go));\n }\n }\n } else if (decl.type === \"list\" && decl.of) {\n const value = Array.isArray(o.value) ? o.value : [];\n const idOf = (item: unknown, i: number): string =>\n decl.id !== undefined && isObject(item) && typeof item[decl.id] === \"string\" ? `id:${item[decl.id] as string}` : `i:${i}`;\n value.forEach((item, i) => {\n const set = (next: unknown[]): void => commit(next.length > 0 ? next : undefined);\n const controls = editable() ? [\n iconBtn(\"up\", \"Move up\", () => { const next = [...value]; if (moveItem(next, i, -1)) set(next); }, i === 0),\n iconBtn(\"down\", \"Move down\", () => { const next = [...value]; if (moveItem(next, i, 1)) set(next); }, i === value.length - 1),\n iconBtn(\"close\", \"Remove\", () => set(value.filter((_, j) => j !== i)), false, true),\n ] : [];\n const itemLabel = decl.id !== undefined && isObject(item) && typeof item[decl.id] === \"string\" ? item[decl.id] as string : `${i + 1}`;\n child(idOf(item, i), asDecl(decl.of!, itemLabel), item, (v) => {\n const next = [...(Array.isArray(opts.value) ? opts.value : [])];\n next[i] = v === undefined ? defaultOf(decl.of as unknown as TypeDecl) : v;\n set(next);\n }, controls, itemLabel);\n });\n adder.replaceChildren();\n if (editable()) {\n adder.append(iconBtn(\"add\", \"Add\", () => {\n const fresh = defaultOf(decl.of as unknown as TypeDecl);\n if (decl.id !== undefined && isObject(fresh)) {\n const taken = new Set(value.map((x) => (isObject(x) ? x[decl.id!] : undefined)));\n let n = value.length + 1;\n while (taken.has(`item-${n}`)) n++;\n fresh[decl.id] = `item-${n}`;\n }\n commit([...value, fresh]);\n }));\n }\n }\n\n for (const key of [...parts.keys()]) if (!used.has(key)) parts.delete(key);\n body.replaceChildren(...rows);\n if (decl.type !== \"record\" && editable()) body.append(adder);\n help.textContent = decl.help ?? decl.purpose ?? \"\";\n if (help.textContent !== \"\") body.append(help);\n const words = o.replaceProblem ?? [ownProblems(decl, o.value, o.adapter), o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n problem.textContent = words;\n problem.hidden = words === \"\";\n body.append(problem);\n row.classList.toggle(\"has-problem\", words !== \"\");\n for (const k of kept) fieldRowFocus.restore(k);\n };\n draw(initial);\n return { el: row, update: draw };\n}\n\n/** A cache of value rows for a host that redraws its whole view (as `fieldRows` is for the scalar row). */\nexport interface ValueRows {\n row(key: string, opts: ValueRowOptions): HTMLElement;\n sweep(): void;\n}\n\nexport function valueRows(): ValueRows {\n const rows = new Map<string, { handle: ValueRowHandle; type: string; used: boolean }>();\n return {\n row(key, opts) {\n const had = rows.get(key);\n if (had && had.type === opts.decl.type) {\n had.used = true;\n fieldRowFocus.settle(had.handle.el);\n had.handle.update(opts);\n fieldRowFocus.restore(had.handle.el);\n return had.handle.el;\n }\n const handle = valueRow(opts);\n rows.set(key, { handle, type: opts.decl.type, used: true });\n return handle.el;\n },\n sweep() {\n for (const [key, entry] of rows) { if (!entry.used) rows.delete(key); else entry.used = false; }\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/tooltip.ts","../src/icons.ts","../src/dom.ts","../src/value-control.ts","../src/value-fold.ts","../src/value-rows.ts"],"names":["el","show","tip","active","stableStringify","defaultOf","isObject","valueProblems","pickChoices","n"],"mappings":";;;;;;;AA6BA,SAAS,SAAA,CAAU,MAAmB,IAAA,EAAoB;AACxD,EAAA,IAAA,CAAK,WAAA,GAAc,EAAA;AACnB,EAAA,MAAM,EAAA,GAAK,2BAAA;AACX,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,CAAA;AACJ,EAAA,OAAA,CAAQ,CAAA,GAAI,EAAA,CAAG,IAAA,CAAK,IAAI,OAAO,IAAA,EAAM;AACnC,IAAA,IAAI,CAAA,CAAE,KAAA,GAAQ,IAAA,EAAM,IAAA,CAAK,MAAA,CAAO,KAAK,KAAA,CAAM,IAAA,EAAM,CAAA,CAAE,KAAK,CAAC,CAAA;AACzD,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,IAAA,MAAA,CAAO,WAAA,GAAc,CAAA,CAAE,CAAC,CAAA,IAAK,EAAA;AAC7B,IAAA,IAAA,CAAK,OAAO,MAAM,CAAA;AAClB,IAAA,IAAA,GAAO,CAAA,CAAE,KAAA,GAAQ,CAAA,CAAE,CAAC,CAAA,CAAE,MAAA;AAAA,EACxB;AACA,EAAA,IAAI,IAAA,GAAO,KAAK,MAAA,EAAQ,IAAA,CAAK,OAAO,IAAA,CAAK,KAAA,CAAM,IAAI,CAAC,CAAA;AACtD;AAQA,IAAI,MAAA,GAAS,KAAA;AACb,IAAI,OAAA,GAAU,KAAA;AACd,IAAI,UAAA;AACJ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uB;AACrC,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAqE;AACtF,EAAA,OAAO;AAAA,IACL,GAAA,CAAI,KAAK,IAAA,EAAM;AACb,MAAA,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AACxB,MAAA,IAAI,GAAA,IAAO,GAAA,CAAI,IAAA,KAAS,IAAA,CAAK,KAAK,IAAA,EAAM;AACtC,QAAA,GAAA,CAAI,IAAA,GAAO,IAAA;AACX,QAAA,aAAA,CAAc,MAAA,CAAO,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AAClC,QAAA,GAAA,CAAI,MAAA,CAAO,OAAO,IAAI,CAAA;AACtB,QAAA,aAAA,CAAc,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AACnC,QAAA,OAAO,IAAI,MAAA,CAAO,EAAA;AAAA,MACpB;AACA,MAAA,MAAM,MAAA,GAAS,SAAS,IAAI,CAAA;AAC5B,MAAA,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,EAAE,MAAA,EAAQ,IAAA,EAAM,KAAK,IAAA,CAAK,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,CAAA;AAC1D,MAAA,OAAO,MAAA,CAAO,EAAA;AAAA,IAChB,CAAA;AAAA,IACA,KAAA,GAAQ;AACN,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,IAAA,EAAM;AAAE,QAAA,IAAI,CAAC,KAAA,CAAM,IAAA,EAAM,IAAA,CAAK,OAAO,GAAG,CAAA;AAAA,mBAAc,IAAA,GAAO,KAAA;AAAA,MAAO;AAAA,IACjG;AAAA,GACF;AACF","file":"value-rows.cjs","sourcesContent":["// ---------------------------------------------------------------------------\n// A single themed tooltip the family controls, replacing native `title`\n// rollovers: those are unstyled OS chrome and appear on the platform's slow\n// (~1s) delay, which is exactly the seam design-language section 4 (\"coherent\n// to the edges\") says not to leave showing.\n//\n// ONE floating bubble, document-DELEGATED: any element carrying a `data-tip`\n// attribute gets it, so a caller just sets `data-tip=\"...\"` anywhere and wires\n// nothing. The bubble anchors above the element (flipping below near the top\n// edge), uses our own snappy delay and the shared panel-enter motion.\n// `initTooltips()` is idempotent, so it is safe to call from more than one\n// place in an app that has several entry points.\n//\n// Lifted from Patterpad's patterpad-surface/web/tooltip.ts, which proved it,\n// with the one app-specific rule (suppressed in Writing View) generalised into\n// the `suppressed` option so the shell knows nothing about either app's modes.\n// ---------------------------------------------------------------------------\n\n// Bold markers: a producer wraps a span in these PRIVATE control chars (U+0002 STX / U+0003 ETX,\n// never present in user text) and the renderer turns it into a <strong>. Lets a data-tip bold part\n// of itself (a name, a \"VO:\" prefix) without any HTML, and each segment is still set via\n// textContent, so there is no injection risk from user content.\nconst B_OPEN = \"\\u0002\";\nconst B_CLOSE = \"\\u0003\";\n\n/** Wrap `s` so it renders bold inside a tooltip (see the marker note above). */\nexport function tipBold(s: string): string { return `${B_OPEN}${s}${B_CLOSE}`; }\n\n/** Render `text` into `host`, turning `\\u0002…\\u0003`-marked spans into <strong>; all set as text (safe). */\nfunction renderTip(host: HTMLElement, text: string): void {\n host.textContent = \"\";\n const re = /\\u0002([^\\u0003]*)\\u0003/g;\n let last = 0;\n let m: RegExpExecArray | null;\n while ((m = re.exec(text)) !== null) {\n if (m.index > last) host.append(text.slice(last, m.index));\n const strong = document.createElement(\"strong\");\n strong.textContent = m[1] ?? \"\";\n host.append(strong);\n last = m.index + m[0].length;\n }\n if (last < text.length) host.append(text.slice(last));\n}\n\nexport interface TooltipOptions {\n /** Called before every show: return true to keep the bubble down. For a mode\n * that wants no chrome at all (Patterpad's Writing View). */\n suppressed?: () => boolean;\n}\n\nlet inited = false;\nlet checked = false; // the one-shot no-host warning below has been scheduled\nlet suppressed: (() => boolean) | undefined;\nconst SHOW_DELAY = 350; // ms - snappier than the OS title delay, slow enough not to flicker on pass-through\nconst EDGE = 6; // viewport inset so the bubble never touches the window edge\nconst GAP = 7; // px between the anchor and the bubble\n\nlet tip: HTMLDivElement | null = null;\nlet timer = 0;\nlet active: HTMLElement | null = null;\n/** The subject of a rect-anchored tip (see `tipAt`), when there is one. */\nlet activeKey: string | null = null;\n\nfunction ensureEl(): HTMLDivElement {\n if (tip) return tip;\n const el = document.createElement(\"div\");\n el.className = \"tooltip\";\n el.setAttribute(\"role\", \"tooltip\");\n el.hidden = true;\n document.body.appendChild(el);\n tip = el;\n return el;\n}\n\n/** A rectangle in VIEWPORT coordinates, for anchoring a tip to something that is\n * not a DOM element: a shape on a canvas, a run of text inside one. */\nexport interface TipRect { left: number; top: number; width: number; height: number }\n\nconst rectOf = (anchor: HTMLElement | TipRect): TipRect =>\n (anchor instanceof HTMLElement ? anchor.getBoundingClientRect() : anchor);\n\n/** Anchor the (already-visible, so measurable) bubble above the anchor, flipping below near the top. */\nfunction place(anchor: HTMLElement | TipRect): void {\n const t = ensureEl();\n const r = rectOf(anchor);\n const tr = t.getBoundingClientRect();\n let top = r.top - tr.height - GAP;\n if (top < EDGE) top = r.top + r.height + GAP; // not enough room above -> below\n let left = r.left + r.width / 2 - tr.width / 2;\n left = Math.max(EDGE, Math.min(left, window.innerWidth - tr.width - EDGE));\n t.style.left = `${Math.round(left)}px`;\n t.style.top = `${Math.round(top)}px`;\n}\n\nfunction show(anchor: HTMLElement): void {\n const text = anchor.dataset[\"tip\"];\n if (!text) return;\n paint(anchor, text);\n}\n\n/** Fill, place and reveal the bubble. The one path: both the delegated\n * `data-tip` route and `tipAt` end up here, so a canvas tip and a button tip\n * are the same bubble with the same look and the same motion. */\nfunction paint(anchor: HTMLElement | TipRect, text: string): void {\n if (suppressed?.()) return;\n const t = ensureEl();\n // A modal <dialog> (settings, a confirm) renders in the browser TOP LAYER, above every normal-flow\n // element whatever its z-index. If the anchor is inside one, move the bubble into that dialog so it\n // shares the top layer; otherwise keep it on <body>. Re-parenting per show also moves it back out\n // once the modal closes.\n const host: HTMLElement = (anchor instanceof HTMLElement ? anchor.closest<HTMLElement>(\"dialog[open]\") : null)\n ?? document.body;\n if (t.parentElement !== host) host.appendChild(t);\n active = anchor instanceof HTMLElement ? anchor : null;\n renderTip(t, text);\n t.hidden = false;\n t.classList.remove(\"show\"); void t.offsetWidth; // restart the enter animation\n place(anchor); // measure + position now it has content + is visible\n t.classList.add(\"show\");\n}\n\nfunction hide(): void {\n if (timer) { window.clearTimeout(timer); timer = 0; }\n active = null;\n activeKey = null;\n if (tip) { tip.hidden = true; tip.classList.remove(\"show\"); }\n}\n\nfunction schedule(anchor: HTMLElement): void {\n if (anchor === active) return;\n if (timer) window.clearTimeout(timer);\n timer = window.setTimeout(() => show(anchor), SHOW_DELAY);\n}\n\n/**\n * Show a tip for something that has no DOM node of its own: a card on a canvas,\n * a zone, a pin. The caller says WHERE (a viewport rectangle) and WHAT, and\n * identifies the subject with `key`.\n *\n * The key is what makes this usable from a canvas. Re-calling with the same key\n * re-places the bubble WITHOUT restarting the delay, so a tip can follow its\n * shape while the camera moves; calling with a different key starts the wait\n * again, so sweeping the pointer across a dense board does not strobe.\n *\n * The bubble is ordinary DOM, so it holds its size whatever the canvas is\n * zoomed to. That is the point of it: the label it stands in for is the one\n * thing on a canvas that must not shrink with everything else.\n */\nexport function tipAt(key: string, rect: TipRect, text: string): void {\n if (key === activeKey) {\n // Already up for this subject: move it, do not re-animate it.\n if (tip && !tip.hidden) { renderTip(tip, text); place(rect); }\n return;\n }\n // A different subject: down first, then wait again. Leaving the old bubble up\n // during the wait would put one card's name over another card, which is worse\n // than no name at all - and it matches the delegated route, where leaving an\n // element hides the tip before the next one is scheduled.\n hide();\n activeKey = key;\n timer = window.setTimeout(() => { timer = 0; paint(rect, text); }, SHOW_DELAY);\n}\n\n/** Take any tip down: the pointer has left, or a gesture has started. */\nexport function hideTip(): void { hide(); }\n\n/**\n * Mount the renderer because something is about to speak the grammar.\n *\n * The themed tooltip is not a feature a host turns on; it is the renderer for a grammar the shell's own\n * components already speak, and `data-tip` with nothing listening draws NOTHING - not the themed\n * bubble, not the platform one. That silence cost Patterpad two releases of a pin with no tooltip, and\n * cost it again when a `title` was converted to `data-tip` in a window that had never mounted this.\n *\n * So `el` calls this whenever it sets a tip. Mounting a delegated listener is the same class of act as\n * `confirmDialog` appending to `document.body`, which this package has always done.\n */\nexport function ensureTooltipHost(): void { initTooltips(); }\n\n/**\n * One deferred check that an app writing `data-tip` ITSELF has a host, warning if not.\n *\n * `ensureTooltipHost` covers anything built through `el`. It cannot cover a `data-tip` written straight\n * into markup or set by hand, which is the case that leaves a whole window of dead tips with no shell\n * component involved - so that one gets a warning rather than silence. Scheduled once, after the\n * current task, so it sees a rendered document rather than an empty one.\n */\nexport function checkTooltipHost(): void {\n if (checked) return;\n checked = true;\n setTimeout(() => {\n if (inited || typeof document === \"undefined\") return;\n if (document.querySelector(\"[data-tip]\")) {\n console.warn(\"app-shell: something set `data-tip` but no tooltip host is mounted, so those rollovers will not draw. Call initTooltips() once per window.\");\n }\n }, 0);\n}\n\nconst tipAncestor = (n: EventTarget | null): HTMLElement | null =>\n (n instanceof Element ? n.closest<HTMLElement>(\"[data-tip]\") : null);\n\n/**\n * Wire the one delegated controller. Mounting happens once; OPTIONS do not.\n *\n * An explicit call is always authoritative about its options, even after something else has already\n * mounted the listener. That ordering is not hypothetical, and Storyletter caught it before it shipped:\n * once components self-mount (see `ensureTooltipHost`), a host's own\n * `initTooltips({ suppressed })` could land second and be dropped by an early return, silently taking\n * a rule like \"no tooltips in Writing View\" with it. Nothing would fail and nothing would show.\n *\n * Components therefore call this with NO arguments: they mount the renderer without claiming the\n * options, and the host keeps the last word on behaviour.\n */\nexport function initTooltips(opts: TooltipOptions = {}): void {\n if (opts.suppressed !== undefined) suppressed = opts.suppressed; // an explicit call always wins\n if (inited) return;\n inited = true;\n\n document.addEventListener(\"pointerover\", (e) => {\n const el = tipAncestor(e.target);\n if (el) schedule(el);\n });\n document.addEventListener(\"pointerout\", (e) => {\n const el = tipAncestor(e.target);\n if (!el) return;\n const to = (e as PointerEvent).relatedTarget;\n if (to instanceof Node && el.contains(to)) return; // still inside the same anchor\n hide();\n });\n // Keyboard parity: reveal on focus, dismiss on blur.\n document.addEventListener(\"focusin\", (e) => { const el = tipAncestor(e.target); if (el) schedule(el); });\n document.addEventListener(\"focusout\", () => hide());\n // It's ANCHORED (not cursor-following), so anything that moves the layout or context dismisses it.\n document.addEventListener(\"pointerdown\", () => hide(), true);\n document.addEventListener(\"scroll\", () => { if (active) hide(); }, true);\n document.addEventListener(\"keydown\", (e) => { if (e.key === \"Escape\") hide(); });\n window.addEventListener(\"blur\", () => hide());\n}\n","// ---------------------------------------------------------------------------\n// The family's icon vocabulary.\n//\n// An icon is a WORD. Two apps in one suite spelling \"close\" differently is the\n// same fault as calling one thing a scene here and a chapter there, and it is\n// harder to notice because nobody reads glyphs, they just feel wrong. This\n// module exists so that no app ever types a codepoint again: it asks for\n// `iconNode(\"close\")` and gets whatever the family has agreed that means.\n//\n// The evidence that it was needed, gathered 2026-08-09 across both apps:\n// Patterpad spelled close as a cross twelve times, Storyletter used the same\n// cross once and a multiplication sign twice, in one window, and a comment\n// bubble had just been invented from scratch with nothing to check it against.\n//\n// DRAWN, not typed (design-language.md section 4, \"Icons are drawn, and so are\n// separators\", 2026-09-16). The first cut of this table was Unicode glyphs,\n// which render from whatever symbol font the OS has, so weight, baseline and\n// optical size drifted per character and per platform. The vocabulary is now\n// one drawn set: Lucide, vendored below as inline SVG strings on one 24-unit\n// grid at one stroke weight. The words did not change; what they draw did.\n//\n// Lucide 1.46.0 (lucide-static), ISC licence.\n// https://lucide.dev / https://cdn.jsdelivr.net/npm/lucide-static@1.46.0/icons/<name>.svg\n// Fetched 2026-09-16. The chosen decision record is\n// patterkit/design/ui-review-2026-09/07c-track-c-icon-sets-notes.md.\n//\n// STROKE. The family draws icons at 14px inside its small square buttons and\n// wants a 1.5px rendered stroke against Inter at that size (Inter Regular's\n// stems are about 1.3px there). Lucide's native stroke is 2 on a 24 grid,\n// which is 2 x 14/24 = 1.17px at 14px, a shade light. So the root of every\n// stroke icon carries stroke-width=\"2.571\": 2.571 x 14/24 = 1.5. A caller\n// drawing at another size gets the proportional weight (12px: 1.29px; 16px:\n// 1.71px), which is what one drawn set means. Filled shapes (the discs) carry\n// fill=\"currentColor\" and no stroke at all.\n//\n// Every icon is `currentColor`, so it takes the colour of the button it sits\n// in, and none of the strings carries width/height: the size is the caller's\n// (`iconNode(name, size)`), so an icon can never be the wrong size somewhere\n// because a CSS rule failed to reach it.\n//\n// Adding one: it needs a MEANING, not a picture. \"A downward chevron\" is not an\n// entry; \"expand this\" is. If two callers want the same picture for two\n// meanings, that is two entries, and one of them will be wrong later.\n// ---------------------------------------------------------------------------\n//\n// Lucide licence (the icons vendored in this file):\n//\n// ISC License\n// Copyright (c) 2026 Lucide Icons and Contributors\n//\n// Permission to use, copy, modify, and/or distribute this software for any\n// purpose with or without fee is hereby granted, provided that the above\n// copyright notice and this permission notice appear in all copies.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n//\n// Portions of Lucide (among those used here: arrow-down, arrow-left,\n// arrow-right, arrow-up, check, chevron-down, chevron-left, chevron-right,\n// circle, lock, plus, search, x) derive from Feather, MIT,\n// Copyright (c) 2013-present Cole Bemis. See LICENSES.md.\n// ---------------------------------------------------------------------------\n\n/**\n * The typed glyphs the vocabulary used to draw.\n *\n * @deprecated Since the move to drawn icons (design-language.md, \"Icons are\n * drawn\"). Kept byte-for-byte so a consumer still doing\n * `textContent = icon.close` keeps working while each app moves; a new call\n * site uses `iconNode(name)` (a node to append) or `iconHtml(name)` (for an\n * innerHTML build). The names are the same in all three. Removed once both\n * apps have moved.\n */\nexport const icon = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. Patterpad's, twelve times over. */\n close: \"✕\",\n /** The overflow menu on a document or a row: \"more about this\". */\n more: \"⋯\",\n /** Collapsed disclosure, pointing at what would open. */\n collapsed: \"▸\",\n /** Expanded disclosure. */\n expanded: \"▾\",\n /** A dropdown's affordance, where it is not a real <select>. */\n dropdown: \"▾\",\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. */\n back: \"‹\",\n /** Forward / next. */\n forward: \"›\",\n /** Up one, in a list. */\n up: \"↑\",\n /** Down one. */\n down: \"↓\",\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. */\n tick: \"✓\",\n /** Somebody else holds this: the version-control lock. */\n locked: \"⊘\",\n /** Read-only on disk with no other holder: the resting state of everything\n * in a lock-based working copy that nobody has checked out yet. */\n readOnly: \"○\",\n /** YOU hold this one: checked out / opened by the current user, still yours to\n * edit. Shares its glyph with `note`, which the table permits: an entry is a\n * MEANING, and two meanings may draw the same shape. */\n checkedOut: \"✎\",\n /** Tracked, with local changes not yet committed. */\n modified: \"●\",\n /** Not in version control yet: new since the last commit. */\n untracked: \"+\",\n /** Something needs attention but is not fatal. */\n warning: \"‼\",\n /** A live thing: the running position, an active marker. */\n dot: \"●\",\n /** Play, in the sense of \"run this\". */\n play: \"▶\",\n /** Start the thing again from the top: a play session, a sweep. Named for the\n * act, not the arrow, which is the table's rule. */\n restart: \"⟲\",\n /** The three ways a collection can be shown. Named by what you get rather than\n * by the glyph, so a second app can pick the same three without copying\n * somebody's taste in symbols. */\n viewCards: \"▦\",\n viewTable: \"☰\",\n viewNode: \"◈\",\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. */\n grip: \"⠿\",\n /** Add one of whatever this list holds. */\n add: \"+\",\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: the pencil. Both apps had chosen it independently,\n * which is the happiest way for a vocabulary entry to arrive. */\n note: \"✎\",\n /** A comment thread. Speech, not a pencil: documentation states the reason,\n * comments are the conversation, and the two must never look alike. */\n comment: \"❝\",\n} as const;\n\n/**\n * Every word in the vocabulary. The 26 the glyph table had, plus the seven the\n * 2026-09 review found the apps drawing by hand with nothing to check against,\n * and the two the 2026-10 Patterpad review found the same way (`copy`,\n * `speaker`).\n */\nexport type IconName =\n | keyof typeof icon\n /** History back, the topbar's quiet arrow pair (nav-history.ts). An ARROW,\n * not a chevron: a chevron says structure, an arrow says time (the author's\n * ruling, 2026-08-28). Added beside `arrowRight` so the pair share a set. */\n | \"arrowLeft\"\n /** History forward; also the one honest \"go there\" arrow where a link used\n * to carry a typed one. */\n | \"arrowRight\"\n /** Connect to a server, a live link, a running game. */\n | \"connect\"\n /** Search. */\n | \"search\"\n /** Keep this window on top (tool-window-web.ts). */\n | \"pin\"\n /** Settings. */\n | \"settings\"\n /** Record. The icon is the DISC; painting it in the danger colour while\n * recording is the caller's job, through the button's own colour. */\n | \"record\"\n /** Copy this to the clipboard. The confirmation is `tick`, shown by the\n * caller while `copyWithFeedback` holds `.copied` on the button. */\n | \"copy\"\n /** Sound: play with audio, a table read. The act of hearing, not a volume\n * control. */\n | \"speaker\";\n\n// The two roots every drawing shares. Kept as constants so the table below is\n// the inner elements only, which is what a reader compares against lucide.dev.\nconst STROKE = '<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.571\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">';\nconst FILL = '<svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">';\nconst stroked = (inner: string): string => `${STROKE}${inner}</svg>`;\nconst filled = (inner: string): string => `${FILL}${inner}</svg>`;\n\n// The three discs are the one drawing in the table that is not Lucide's own\n// element as shipped: Lucide's `circle` is an r=10 outline that fills its box,\n// which at badge size beside a row title is a blot, so the disc is drawn at a\n// smaller radius with the fill forced (the same amount of hand-drawing as the\n// legacy noteFilled below, and the decision record's stated cost). `modified`\n// and `dot` share it, as their glyphs did; `record` is larger because a record\n// button is meant to fill more of its box.\nconst DISC = filled('<circle cx=\"12\" cy=\"12\" r=\"6\"/>');\nconst DISC_LARGE = filled('<circle cx=\"12\" cy=\"12\" r=\"9\"/>');\n\n/**\n * The drawings, by word. Each is a complete `<svg viewBox=\"0 0 24 24\" …>`\n * string with no width/height (see `iconNode` / `iconHtml`, which size it).\n * The Lucide name each derives from is on the entry, so a reviewer can put\n * the two side by side.\n */\nconst DRAWN: Record<IconName, string> = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. (x) */\n close: stroked('<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>'),\n /** The overflow menu on a document or a row: \"more about this\". (ellipsis) */\n more: stroked('<circle cx=\"12\" cy=\"12\" r=\"1\"/><circle cx=\"19\" cy=\"12\" r=\"1\"/><circle cx=\"5\" cy=\"12\" r=\"1\"/>'),\n /** Collapsed disclosure, pointing at what would open. (chevron-right) */\n collapsed: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Expanded disclosure. (chevron-down) */\n expanded: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n /** A dropdown's affordance, where it is not a real <select>. (chevron-down) */\n dropdown: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. (chevron-left) */\n back: stroked('<path d=\"m15 18-6-6 6-6\"/>'),\n /** Forward / next. (chevron-right) */\n forward: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Up one, in a list. (arrow-up) */\n up: stroked('<path d=\"m5 12 7-7 7 7\"/><path d=\"M12 19V5\"/>'),\n /** Down one. (arrow-down) */\n down: stroked('<path d=\"M12 5v14\"/><path d=\"m19 12-7 7-7-7\"/>'),\n /** History back. (arrow-left) */\n arrowLeft: stroked('<path d=\"m12 19-7-7 7-7\"/><path d=\"M19 12H5\"/>'),\n /** History forward; \"go there\". (arrow-right) */\n arrowRight: stroked('<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>'),\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. (check) */\n tick: stroked('<path d=\"M20 6 9 17l-5-5\"/>'),\n /** Somebody else holds this: the version-control lock. (lock) */\n locked: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/>'),\n /** Read-only on disk with no other holder. (lock-open) An open lock rather\n * than a struck-out eye: this state is not a prohibition. Nobody holds the\n * file, saving checks it out, and it is the resting state of everything the\n * author has not touched yet under a lock-based VCS. eye-off would say \"you\n * cannot\", which is false here; the open lock says \"not held\", beside\n * `locked`, which is the shut one, so the two read as a pair. */\n readOnly: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 9.9-1\"/>'),\n /** YOU hold this one: checked out, still yours to edit. (pencil) */\n checkedOut: stroked('<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\"/><path d=\"m15 5 4 4\"/>'),\n /** Tracked, with local changes not yet committed. (a disc; see DISC) */\n modified: DISC,\n /** Not in version control yet: new since the last commit. (plus) */\n untracked: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Something needs attention but is not fatal. (triangle-alert) */\n warning: stroked('<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/>'),\n /** A live thing: the running position, an active marker. (a disc) */\n dot: DISC,\n /** Play, in the sense of \"run this\". (play) */\n play: stroked('<path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\"/>'),\n /** Start the thing again from the top: a play session, a sweep. (rotate-ccw) */\n restart: stroked('<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/>'),\n /** The three ways a collection can be shown, named by what you get. */\n /** Cards. (layout-grid) */\n viewCards: stroked('<rect width=\"7\" height=\"7\" x=\"3\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"14\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"3\" y=\"14\" rx=\"1\"/>'),\n /** A table. (rows-3: a ruled box, which is a table. `list` is bullets, and\n * the view is not a list.) */\n viewTable: stroked('<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"/><path d=\"M21 9H3\"/><path d=\"M21 15H3\"/>'),\n /** A node graph. (waypoints: four nodes on edges reads as a graph.\n * `git-fork` reads as version control, which this family also draws, and\n * a picture that means two things is the fault this table exists to\n * prevent.) */\n viewNode: stroked('<path d=\"m10.586 5.414-5.172 5.172\"/><path d=\"m18.586 13.414-5.172 5.172\"/><path d=\"M6 12h12\"/><circle cx=\"12\" cy=\"20\" r=\"2\"/><circle cx=\"12\" cy=\"4\" r=\"2\"/><circle cx=\"20\" cy=\"12\" r=\"2\"/><circle cx=\"4\" cy=\"12\" r=\"2\"/>'),\n /** Record: the disc, in whatever colour the button is. (a disc; see DISC_LARGE) */\n record: DISC_LARGE,\n /** Sound: play with audio. (volume-2: the cone and two waves. Patterpad's\n * hand-drawn one had a single wave, which at 14px reads as quiet rather\n * than as sound.) */\n speaker: stroked('<path d=\"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z\"/><path d=\"M16 9a5 5 0 0 1 0 6\"/><path d=\"M19.364 18.364a9 9 0 0 0 0-12.728\"/>'),\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. (grip-vertical) */\n grip: stroked('<circle cx=\"9\" cy=\"12\" r=\"1\"/><circle cx=\"9\" cy=\"5\" r=\"1\"/><circle cx=\"9\" cy=\"19\" r=\"1\"/><circle cx=\"15\" cy=\"12\" r=\"1\"/><circle cx=\"15\" cy=\"5\" r=\"1\"/><circle cx=\"15\" cy=\"19\" r=\"1\"/>'),\n /** Add one of whatever this list holds. (plus) */\n add: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Copy this to the clipboard. (copy: the front sheet whole, the back\n * sheet showing round two of its sides) */\n copy: stroked('<rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/>'),\n /** Connect: to a server, a live link, a running game. (plug) */\n connect: stroked('<path d=\"M12 22v-5\"/><path d=\"M15 8V2\"/><path d=\"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z\"/><path d=\"M9 8V2\"/>'),\n /** Search. (search) */\n search: stroked('<path d=\"m21 21-4.34-4.34\"/><circle cx=\"11\" cy=\"11\" r=\"8\"/>'),\n /** Keep this window on top. (pin) */\n pin: stroked('<path d=\"M12 17v5\"/><path d=\"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z\"/>'),\n /** Settings. (settings) */\n settings: stroked('<path d=\"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/>'),\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: a document with lines on it. (file-text) The glyph\n * table drew a pencil and shared it with `checkedOut`; the drawn set gives\n * the two meanings two shapes, and notes get the document, which is what\n * the shell's own noteFilled/noteOutline pair had always drawn. */\n note: stroked('<path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\"/><path d=\"M14 2v5a1 1 0 0 0 1 1h5\"/><path d=\"M10 9H8\"/><path d=\"M16 13H8\"/><path d=\"M16 17H8\"/>'),\n /** A comment thread. Speech, not a document: documentation states the\n * reason, comments are the conversation, and the two must never look\n * alike. (message-square) */\n comment: stroked('<path d=\"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\"/>'),\n};\n\n/**\n * The drawings as strings, by word, for a caller that builds markup itself.\n * Prefer `iconHtml(name, size)`, which sizes it; these carry no width/height.\n *\n * Two legacy entries ride along unchanged: `noteFilled` and `noteOutline`, the\n * has-notes / no-notes pair Patterpad drew on a 16-unit grid before the set\n * existed. They are sized in the markup (13px) and on their own grid, so they\n * are NOT part of the vocabulary above and `iconNode` does not know them; no\n * app uses them today. They stay until a 24-grid pair replaces them, because\n * their two-state meaning (there are notes / there are none) has no Lucide\n * shape, and re-weighting the 16-grid drawing to the family stroke merges its\n * text lines.\n */\nexport const iconSvg = {\n ...DRAWN,\n /** A document with lines: notes exist on this thing. (legacy, 16 grid) */\n noteFilled: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"currentColor\" fill-rule=\"evenodd\" aria-hidden=\"true\"><path d=\"M3.4 1.4h5.3L12.6 5.3v8.1a1.2 1.2 0 0 1-1.2 1.2H3.4a1.2 1.2 0 0 1-1.2-1.2V2.6A1.2 1.2 0 0 1 3.4 1.4ZM4.9 6.8h6.2v1.1H4.9Zm0 2.1h6.2v1.1H4.9Zm0 2.1h3.7v1.1H4.9Z\"/></svg>',\n /** The same document, empty: nothing written here yet. (legacy, 16 grid) */\n noteOutline: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.1\" stroke-linejoin=\"round\" stroke-linecap=\"round\" aria-hidden=\"true\"><path d=\"M3.4 2h4.9l3.9 3.9v7.5a1 1 0 0 1-1 1H3.4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z\"/><path d=\"M8.3 2.2v3.8h3.8\"/><path d=\"M4.9 8h6.2M4.9 10h6.2M4.9 12h3.7\" stroke-width=\"0.95\"/></svg>',\n} as const;\n\nexport type IconSvgName = keyof typeof iconSvg;\n\n/** Every word, in table order, for a test or a gallery to walk. */\nexport const ICON_NAMES = Object.keys(DRAWN) as IconName[];\n\n/** The default size: 14px, the family's icon inside its small square button. */\nexport const ICON_SIZE = 14;\n\n/**\n * The drawing as markup with its size set, for a caller building innerHTML.\n * `data-icon` carries the word, so a stylesheet or a test can find it.\n */\nexport function iconHtml(name: IconName, size = ICON_SIZE): string {\n return DRAWN[name].replace(\"<svg \", `<svg width=\"${size}\" height=\"${size}\" data-icon=\"${name}\" `);\n}\n\n// One parsed template per word, filled on first use; every call clones it, so\n// the string is parsed once per window and each caller gets its own node.\nconst templates = new Map<IconName, SVGSVGElement>();\n\n/**\n * The drawing as a fresh SVG node, sized. Append it where the glyph used to be\n * set as text; it is `aria-hidden`, so the button's accessible name stays the\n * button's (`aria-label` / `data-tip`), as it always had to.\n */\nexport function iconNode(name: IconName, size = ICON_SIZE): SVGSVGElement {\n let tpl = templates.get(name);\n if (!tpl) {\n const holder = document.createElement(\"template\");\n holder.innerHTML = DRAWN[name];\n tpl = holder.content.firstElementChild as SVGSVGElement;\n tpl.setAttribute(\"data-icon\", name);\n templates.set(name, tpl);\n }\n const node = tpl.cloneNode(true) as SVGSVGElement;\n node.setAttribute(\"width\", String(size));\n node.setAttribute(\"height\", String(size));\n return node;\n}\n\n// The glyph table, reversed, so a legacy call site that still hands the shell\n// a typed character (\"✕\", \"↑\") draws the word it stood for. Where two words\n// shared a glyph the first in table order wins, which is fine: the picture was\n// the same either way. Goes when `icon` does.\nconst BY_GLYPH = new Map<string, IconName>();\nfor (const [name, glyph] of Object.entries(icon) as [IconName, string][]) {\n if (!BY_GLYPH.has(glyph)) BY_GLYPH.set(glyph, name);\n}\n\n/** The word a deprecated glyph stood for, or undefined for any other string. */\nexport function iconNameOfGlyph(glyph: string): IconName | undefined {\n return BY_GLYPH.get(glyph);\n}\n\n/** Whether a string is a word in the vocabulary. */\nexport function isIconName(s: string): s is IconName {\n return Object.prototype.hasOwnProperty.call(DRAWN, s);\n}\n","// ---------------------------------------------------------------------------\n// `el`: the tiny tag-typed element factory both apps build their imperative,\n// idempotent views with.\n//\n// A SUPERSET of the two apps' prior signatures, so neither rewrites call sites:\n// - Patterpad: el(tag, cls?, text?) (positional)\n// - Storylet Studio: el(tag, { className, text, ... }, ...kids) (options bag)\n// A string second argument is the className; an object is the props bag; string\n// children become text nodes. So `el(\"div\", \"c\", \"t\")` and\n// `el(\"div\", { className: \"c\" }, \"t\")` produce identical DOM.\n// ---------------------------------------------------------------------------\n\nimport { ensureTooltipHost, checkTooltipHost } from \"./tooltip.js\";\nimport { iconNode, iconNameOfGlyph, isIconName, type IconName } from \"./icons.js\";\n\nexport type Child = Node | string | null | undefined;\n\nexport interface ElProps {\n className?: string;\n text?: string;\n /** A NATIVE rollover. Prefer `tip`: `title` is OS chrome on the platform's own\n * slow delay, which is the seam the themed tooltip exists to close. */\n title?: string;\n /** A themed rollover (`data-tip`, picked up by the delegated controller that\n * `initTooltips()` wires). Also the accessible name, since the elements that\n * want one are usually icon buttons with no text of their own. */\n tip?: string;\n onClick?: (event: MouseEvent) => void;\n}\n\nexport function el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n classNameOrProps?: string | ElProps,\n ...children: Child[]\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n const props: ElProps = typeof classNameOrProps === \"string\"\n ? { className: classNameOrProps }\n : classNameOrProps ?? {};\n if (props.className) node.className = props.className;\n if (props.text !== undefined && props.text !== null) node.textContent = props.text;\n if (props.title !== undefined) node.title = props.title;\n if (props.tip !== undefined) {\n node.dataset[\"tip\"] = props.tip;\n node.setAttribute(\"aria-label\", props.tip);\n // Setting a tip mounts the renderer. Without this, `data-tip` draws nothing at all in a window whose\n // host never called `initTooltips()`, which is a silent failure rather than a degraded one. No\n // options passed: the host stays authoritative about behaviour (see tooltip.ts).\n ensureTooltipHost();\n }\n if (props.onClick) node.addEventListener(\"click\", props.onClick as EventListener);\n for (const child of children) {\n if (child === null || child === undefined) continue;\n node.append(child);\n }\n checkTooltipHost(); // one-shot: warns if the APP wrote data-tip and nothing mounted a host\n return node;\n}\n\n/** A small square icon button (the move/delete controls list editors share).\n * Its rollover is the THEMED one (`data-tip`), so an app that has called\n * `initTooltips()` gets our bubble rather than the platform's.\n *\n * `name` is a word from the vocabulary (\"up\", \"close\"), drawn at 14px. A\n * typed glyph from the deprecated `icon` table (\"↑\", \"✕\") is accepted for\n * now and drawn as the word it stood for, so an app that has not moved its\n * call sites yet still gets the drawn set; any other string is set as text,\n * which is the old behaviour and on its way out. */\nexport function iconBtn(name: IconName | (string & {}), title: string, onClick: () => void, disabled = false, danger = false): HTMLButtonElement {\n const b = el(\"button\", `shell-icon${danger ? \" danger\" : \"\"}`);\n b.type = \"button\"; b.dataset[\"tip\"] = title; b.setAttribute(\"aria-label\", title);\n const word = isIconName(name) ? name : iconNameOfGlyph(name);\n if (word) b.append(iconNode(word)); else b.textContent = name;\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n}\n\n/** The sentence under a settings row: plain text, or nodes when it carries\n * markup (a `code` for a file name, a `b` for an option's name). */\nexport type FieldHint = string | Node | Array<string | Node>;\n\n/**\n * A captioned field, the family's settings row (the 2026-10 review, ruling C):\n * the caption on the left and the control inline beside it,\n * `<label class=\"shell-labelled\"><span class=\"shell-fieldcap\">…</span>control</label>`.\n *\n * The label is pointed at the field it captions, EXPLICITLY, and never at a button. A `<label>` with no\n * `for` forwards a click to its first labelable descendant, and buttons are labelable - so a caption\n * wrapped around a control containing buttons (`tagChips`, whose every chip carries a remove button)\n * turns every click on the row's dead space into a press of the FIRST button in it. That shipped:\n * patterkit/patter#44, where clicking a Game Data list value anywhere but its ✕ deleted the first value\n * in the list. Reported as \"clicking a value removes the wrong one\", which is not a wrong-index bug at\n * all - the click never reached the chip. The same rule makes a control GROUP safe to caption: a field\n * with its own Choose… or Import… button beside it (`.shell-inline`) captions the field, and the button\n * stays a button.\n *\n * When the control holds no labelable field (a chips editor with the add input removed, say), this is a\n * plain `<div>`: no caption behaviour is better than a caption that presses something.\n *\n * With a `hint`, the row and the sentence under it come back together in a `.shell-field`, the hint as\n * the field's description (`aria-describedby`) rather than inside the label, where it would become part\n * of the field's NAME and be read out every time it takes focus. Without one, the row is exactly what it\n * always was.\n */\nexport function labelled(label: string, control: HTMLElement, hint?: FieldHint): HTMLElement {\n const target = control.matches(\"input, select, textarea\")\n ? control\n : control.querySelector<HTMLElement>(\"input:not([type=button]):not([type=submit]), select, textarea\");\n const w = el(target ? \"label\" : \"div\", \"shell-labelled\");\n w.append(el(\"span\", \"shell-fieldcap\", label), control);\n if (target) {\n if (!target.id) target.id = uid();\n (w as HTMLLabelElement).htmlFor = target.id;\n }\n if (hint === undefined) return w;\n const note = el(\"p\", \"shell-fieldhint\");\n note.append(...(Array.isArray(hint) ? hint : [hint]));\n note.id = uid();\n if (target) {\n const by = target.getAttribute(\"aria-describedby\");\n target.setAttribute(\"aria-describedby\", by ? `${by} ${note.id}` : note.id);\n }\n return el(\"div\", \"shell-field\", w, note);\n}\n\nconst uid = (): string => `shell-f-${Math.random().toString(36).slice(2, 9)}`;\n\nexport interface LabelledToggleOptions {\n checked?: boolean;\n /** The sentence under the row: what turning it on does. */\n hint?: FieldHint;\n /** An option that only means something while the row above it is set (Patterpad's \"Embed source\n * language for debug\" under an IDs-only build): indented under that row with a rule, so it reads as\n * belonging to it rather than as a peer. */\n sub?: boolean;\n disabled?: boolean;\n /** Fired on every flip, with the new state. The input is handed back too, for a caller that reads it\n * on Save instead. */\n onChange?: (checked: boolean) => void;\n}\n\n/**\n * The settings toggle, `labelled`'s partner (ruling C): the caption on the left, the checkbox beside it\n * where any other row has its control, and the optional hint under the row. One shape in both apps, so\n * a switch in one app's settings looks like a switch in the other's. Clicking the caption flips it, as\n * the label is the checkbox's.\n *\n * Returns the outermost row (to append, hide, or indent) and the input (to read or listen to).\n */\nexport function labelledToggle(label: string, opts: LabelledToggleOptions = {}): { row: HTMLElement; input: HTMLInputElement } {\n const input = el(\"input\", \"shell-toggle-input\");\n input.type = \"checkbox\";\n input.checked = opts.checked ?? false;\n input.disabled = opts.disabled ?? false;\n const { onChange } = opts;\n if (onChange) input.addEventListener(\"change\", () => onChange(input.checked));\n const row = labelled(label, input, opts.hint);\n // On the caption-and-box line itself, whether or not a hint wraps it.\n (row.matches(\".shell-labelled\") ? row : row.querySelector(\".shell-labelled\"))?.classList.add(\"shell-toggle\");\n if (opts.sub) row.classList.add(\"shell-suboption\");\n return { row, input };\n}\n\n/** Swap item `i` with its neighbour `i + delta` IN PLACE (the up/down reorder list editors share);\n * a no-op when the target is out of range. Returns whether anything moved. */\nexport function moveItem<T>(arr: T[], i: number, delta: number): boolean {\n const j = i + delta;\n if (j < 0 || j >= arr.length) return false;\n [arr[i], arr[j]] = [arr[j]!, arr[i]!];\n return true;\n}\n\n/** The icon size inside a chip's remove / move buttons: the chip is set at\n * 0.76rem, so its controls draw smaller than a toolbar button's 14px. */\nconst CHIP_ICON = 10;\n\n/** A tag-style editor for a string-list field (an enum's allowed values / flags): removable chips + an\n * add input (Enter or \",\" commits; blank / duplicate ignored). Mutates `holder.values` in place (read\n * back on save). `onChange` fires after any add / remove so callers can refresh a dependent control. */\nexport function tagChips(holder: { values?: string[] }, onChange?: () => void): HTMLElement {\n const wrap = el(\"div\", \"shell-tags\");\n const input = el(\"input\", \"shell-tag-input\");\n // Sentence-cased like every other hint (the microcopy ruling, 2026-08-28):\n // lowercase fragments read as adrift, and a placeholder is a hint speaking.\n input.type = \"text\"; input.placeholder = \"Add value\"; input.spellcheck = false;\n const makeChip = (v: string): HTMLElement => {\n const chip = el(\"span\", \"shell-tag\", v);\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.values = (holder.values ?? []).filter((o) => o !== v); chip.remove(); onChange?.(); });\n chip.append(x);\n return chip;\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.values ?? []).includes(v)) { (holder.values ??= []).push(v); wrap.insertBefore(makeChip(v), input); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n for (const v of holder.values ?? []) wrap.append(makeChip(v));\n wrap.append(input);\n return wrap;\n}\n\n/** What `stageChips` tells its caller beyond \"something changed\". */\nexport interface StageChipsOptions {\n /**\n * A stage was renamed in place, `from` to `to`. Given, a rename calls this\n * INSTEAD of `onChange`: values are stored by stage name, so whoever knows\n * where those values live has to carry them, and doing it as one edit is\n * theirs to arrange. Absent, a rename is an ordinary change.\n */\n onRename?: (from: string, to: string) => void;\n /** The stages were reordered (after `onChange`): the one edit that changes\n * what every ordering gate means without changing any value. */\n onReorder?: () => void;\n}\n\n/**\n * An ORDERED chips editor for a string-list field whose order means something\n * (a quality's stages: `advance()` walks them, so 2 comes after 1): numbered\n * chips, each with move-earlier / move-later / remove, plus an add input\n * (Enter or \",\" commits; blank / duplicate ignored). A stage's name renames\n * in place when clicked (Enter or blur commits, Escape cancels; blank, the same\n * name or another stage's is ignored). Mutates `holder.stages` in place;\n * `onChange` fires after any add / move / remove, and after a rename unless\n * `opts.onRename` takes it.\n *\n * Patterpad's, lifted (ui-review-2026-09, finding 3); Storyletter had been\n * faking it with `tagChips` over a `values` holder, which loses the order\n * controls. Same class family as `tagChips` (`.shell-tags`), so it is styled by\n * settings.css already.\n */\nexport function stageChips(holder: { stages?: string[] }, onChange?: () => void, opts: StageChipsOptions = {}): HTMLElement {\n const wrap = el(\"div\", \"shell-tags shell-stages\");\n const input = el(\"input\", \"shell-tag-input\");\n input.type = \"text\"; input.placeholder = \"Add stage\"; input.spellcheck = false;\n const control = (name: IconName, tip: string, disabled: boolean, onClick: () => void): HTMLButtonElement => {\n const b = el(\"button\", \"shell-tag-x shell-tag-move\", iconNode(name, CHIP_ICON));\n b.type = \"button\"; b.dataset[\"tip\"] = tip; b.setAttribute(\"aria-label\", tip);\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n };\n // The name, editable in place. A span with a button's role rather than a\n // <button>, so the chip's own controls stay its only buttons.\n const nameLabel = (chip: HTMLElement, v: string, i: number): HTMLElement => {\n const label = el(\"span\", \"shell-tag-label\", `${i + 1}. ${v}`);\n label.setAttribute(\"role\", \"button\"); label.tabIndex = 0;\n label.dataset[\"tip\"] = `Rename ${v}`;\n const edit = (): void => {\n const field = el(\"input\", \"shell-tag-input shell-stage-rename\");\n field.type = \"text\"; field.value = v; field.spellcheck = false;\n field.setAttribute(\"aria-label\", `Rename ${v}`);\n let done = false;\n const finish = (keep: boolean): void => {\n if (done) return;\n done = true;\n const to = field.value.trim();\n const stages = holder.stages ?? [];\n if (keep && to !== \"\" && to !== v && !stages.includes(to)) {\n stages[stages.indexOf(v)] = to;\n rebuild();\n if (opts.onRename) opts.onRename(v, to); else onChange?.();\n } else {\n rebuild();\n }\n };\n field.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\") { e.preventDefault(); finish(true); }\n else if (e.key === \"Escape\") { e.preventDefault(); e.stopPropagation(); finish(false); }\n });\n field.addEventListener(\"blur\", () => finish(true));\n label.replaceWith(field);\n chip.classList.add(\"editing\");\n field.focus(); field.select();\n };\n // The chips usually sit inside a <label> for the add input (`labelled`),\n // whose activation would move focus there and close the rename at once.\n label.addEventListener(\"click\", (e) => { e.preventDefault(); edit(); });\n label.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); edit(); } });\n return label;\n };\n const moved = (): void => { rebuild(); onChange?.(); opts.onReorder?.(); };\n const rebuild = (): void => {\n for (const c of Array.from(wrap.children)) if (c !== input) c.remove();\n const stages = holder.stages ?? [];\n stages.forEach((v, i) => {\n const chip = el(\"span\", \"shell-tag\");\n chip.dataset[\"stage\"] = v;\n chip.append(\n nameLabel(chip, v, i),\n control(\"back\", `Move ${v} earlier`, i === 0, () => { if (moveItem(stages, i, -1)) moved(); }),\n control(\"forward\", `Move ${v} later`, i === stages.length - 1, () => { if (moveItem(stages, i, 1)) moved(); }),\n );\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.stages = (holder.stages ?? []).filter((o) => o !== v); rebuild(); onChange?.(); });\n chip.append(x);\n wrap.insertBefore(chip, input);\n });\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.stages ?? []).includes(v)) { (holder.stages ??= []).push(v); rebuild(); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n wrap.append(input);\n rebuild();\n return wrap;\n}\n\n// --- drag-to-reorder ---------------------------------------------------------\n// One drag at a time per window, shared across every wired list, so the\n// midpoint test knows what is being carried without a dataTransfer round trip.\nlet reorderDragId: string | null = null;\nconst clearDropMarks = (host: ParentNode): void =>\n host.querySelectorAll(\".drop-before, .drop-after\").forEach((e) => e.classList.remove(\"drop-before\", \"drop-after\"));\n\n/**\n * Make `el` a drag source and a drop target for HTML5 drag-to-reorder among\n * its siblings. While carried it wears `.dragging`; a hovered target wears\n * `.drop-before` or `.drop-after` by the midpoint test on `axis` (\"y\" for\n * rows, \"x\" for a wrapping grid); a drop calls `onMove(draggedId, before,\n * targetId)` and the caller reorders its model and re-renders.\n *\n * Storyletter's `wireCardDrag`, lifted (ui-review-2026-09, finding 30);\n * Patterpad's `wireSceneDrag` is the same idea fixed on \"y\". The marks are\n * classes only: the app draws them (Patterpad's `box-shadow: 0 -2px 0 0\n * var(--accent)` pair is the family's look).\n */\nexport function wireReorder(el: HTMLElement, id: string, axis: \"x\" | \"y\", onMove: (id: string, before: boolean, targetId: string) => void): void {\n el.draggable = true;\n el.dataset[\"reorderId\"] = id;\n const host = (): ParentNode => el.parentElement ?? el;\n el.addEventListener(\"dragstart\", (e) => {\n reorderDragId = id; el.classList.add(\"dragging\");\n if (e.dataTransfer) { e.dataTransfer.effectAllowed = \"move\"; e.dataTransfer.setData(\"text/plain\", id); }\n });\n el.addEventListener(\"dragend\", () => { reorderDragId = null; el.classList.remove(\"dragging\"); clearDropMarks(host()); });\n el.addEventListener(\"dragover\", (e) => {\n if (!reorderDragId || reorderDragId === id) return;\n e.preventDefault();\n if (e.dataTransfer) e.dataTransfer.dropEffect = \"move\";\n const r = el.getBoundingClientRect();\n const before = axis === \"y\" ? e.clientY < r.top + r.height / 2 : e.clientX < r.left + r.width / 2;\n clearDropMarks(host());\n el.classList.add(before ? \"drop-before\" : \"drop-after\");\n });\n el.addEventListener(\"dragleave\", () => el.classList.remove(\"drop-before\", \"drop-after\"));\n el.addEventListener(\"drop\", (e) => {\n e.preventDefault();\n const before = el.classList.contains(\"drop-before\");\n clearDropMarks(host());\n if (reorderDragId && reorderDragId !== id) onMove(reorderDragId, before, id);\n });\n}\n\n// --- metadata and breadcrumbs ---------------------------------------------------\n// \"Icons are drawn, and so are separators\" (design-language.md section 4,\n// 2026-09-16): metadata is never joined with \"·\" and a breadcrumb is never a\n// string with \"›\" in it. Both apps had been building exactly those strings\n// (ui-review-2026-09, marker A); these two helpers make the same lines as DOM,\n// with the separator drawn by CSS (controls.css) or by the icon vocabulary.\n\n/**\n * A metadata line: `parts` as spans in a flex row, separated by a drawn\n * 3px disc (a `::before` on every part after the first, in controls.css),\n * so `metaLine([\"6 runs\", \"200 max steps\", \"seed 4\"])` is what\n * \"6 runs · 200 max steps · seed 4\" used to be, without the typed dot.\n * Empty, null and undefined parts are skipped, so a caller can pass an\n * optional segment without branching.\n */\nexport function metaLine(parts: (string | Node | null | undefined)[]): HTMLElement {\n const row = el(\"span\", \"shell-meta\");\n for (const part of parts) {\n if (part === null || part === undefined || part === \"\") continue;\n const seg = el(\"span\", \"shell-meta-part\");\n seg.append(part);\n row.append(seg);\n }\n return row;\n}\n\nexport interface Crumb {\n label: string;\n /** Makes the crumb a button. Ignored on the last crumb, which is where the\n * reader already is. */\n onClick?: (event: MouseEvent) => void;\n}\n\n/**\n * A breadcrumb trail: each crumb a span, or a button when it carries\n * `onClick` and is not the last, with `iconNode(\"forward\", 12)` drawn between\n * them. `breadcrumb([\"Box\", \"Deck\", \"Card\"])` is what \"Box › Deck › Card\"\n * used to be; the chevrons are the family's own drawing, not a symbol-font\n * character.\n */\nexport function breadcrumb(parts: (string | Crumb)[]): HTMLElement {\n const trail = el(\"nav\", \"shell-crumbs\");\n trail.setAttribute(\"aria-label\", \"Where this is\");\n parts.forEach((part, i) => {\n const crumb: Crumb = typeof part === \"string\" ? { label: part } : part;\n const last = i === parts.length - 1;\n if (i > 0) {\n const sep = iconNode(\"forward\", 12);\n sep.classList.add(\"shell-crumb-sep\");\n trail.append(sep);\n }\n if (crumb.onClick && !last) {\n const b = el(\"button\", { className: \"shell-crumb shell-crumb-link\", text: crumb.label, onClick: crumb.onClick });\n b.type = \"button\";\n trail.append(b);\n } else {\n const s = el(\"span\", \"shell-crumb\", crumb.label);\n if (last) s.setAttribute(\"aria-current\", \"location\");\n trail.append(s);\n }\n });\n return trail;\n}\n","// ---------------------------------------------------------------------------\n// Typed value controls: how both apps show and set a value of a declared type.\n//\n// The first is the quality's. A quality is a step on a ladder, so its value is\n// shown as the LADDER, with the current rung marked, rather than a dropdown that\n// shows one name and hides where it stands (patterkit design/proposals/\n// patter-qualities.md section 4). Storyletter's Board drew it this way first;\n// it lives here so Storyletter's Fields tab, Patterpad's play panel and Game\n// Data rows, and the play inspectors all draw the same strip.\n//\n// An UNSET value (a field or game-data value the node leaves out) names what it\n// falls back to, \"default (x)\", by the family's one rule: the declaration's own\n// default, else the type's (a quality's first stage). A value that is no longer\n// a stage (a deleted one) is shown as such, so it can be put back on the ladder.\n//\n// No Electron, no app state: this module is DOM only, and is its own entry point\n// (`@wildwinter/app-shell/value-control`) so a play inspector outside the apps\n// can take it.\n// ---------------------------------------------------------------------------\n\nimport { el, tagChips } from \"./dom.js\";\n\n/** A declaration as these controls read it: a property's, a field's or a game-data field's. */\nexport interface ValueDeclLike {\n type: string;\n default?: unknown;\n /** enum / flags */\n values?: readonly string[];\n /** quality: the ladder, in order */\n stages?: readonly string[];\n}\n\n/**\n * What an unset value of `decl` falls back to, as the words a control shows: its own default where it has\n * one, else its type's (False, 0, the first value, no flags, the first stage, empty text). The kernel's\n * `defaultFor`, in words; a host reads the same value from the bundle.\n */\nexport function fallbackText(decl: ValueDeclLike): string {\n const d = decl.default;\n if (d !== undefined && d !== null) {\n if (typeof d === \"boolean\") return d ? \"True\" : \"False\";\n if (Array.isArray(d)) return d.length === 0 ? \"none\" : d.join(\", \");\n return d === \"\" ? \"none\" : String(d);\n }\n switch (decl.type) {\n case \"boolean\": return \"False\";\n case \"number\": return \"0\";\n case \"enum\": return decl.values?.[0] ?? \"none\";\n case \"quality\": return decl.stages?.[0] ?? \"first stage\";\n case \"flags\": return \"none\";\n default: return \"empty\";\n }\n}\n\n/** The label an unset value shows: \"default (x)\", naming what it falls back to. */\nexport const defaultLabel = (decl: ValueDeclLike): string => `default (${fallbackText(decl)})`;\n\n/**\n * The quiet line under a ladder that has just been reordered: how many gates order against it. A reorder\n * changes no value, and is the one edit that changes what a gate MEANS without saying so (patter-qualities.md\n * section 2), so the editor says so. Empty when no gate orders the quality.\n */\nexport function stageGateNote(gates: number): string {\n if (gates <= 0) return \"\";\n return gates === 1\n ? \"1 gate compares against this ladder, and it now reads the new order.\"\n : `${gates} gates compare against this ladder, and each now reads the new order.`;\n}\n\nexport interface RungStripOptions {\n /** The ladder, in order. */\n stages: readonly string[];\n /** The value held, or undefined when unset: a field or game-data value the node leaves out. */\n value: string | undefined;\n /** The declaration, for what an unset value falls back to (its default, else the first stage). */\n decl?: ValueDeclLike;\n /** Pick a stage. Absent: the strip is read-only. */\n onPick?: (stage: string) => void;\n /** Clear back to unset. With it, the strip leads with \"default (x)\", which clears the value. */\n onClear?: () => void;\n /** The rollover on a rung that is not the current one (default: `Set to \"x\"`). */\n pickTip?: (stage: string) => string;\n /**\n * The document to build in, for a host outside the apps (a play inspector in a page or a frame of its\n * own). Given, rollovers are plain `title`s and the family's themed tooltips are not mounted; the host\n * styles `.seg`, `.seg-opt` and `.shell-rung` itself. Absent: the apps' document and themed rollovers.\n */\n doc?: Document;\n}\n\n/**\n * A quality's value as its ladder: one rung per stage, in order, the current one marked (`on`). Unset, the\n * rung it falls back to is marked as the fallback (`fallback`), and with `onClear` a leading \"default (x)\"\n * option is the current choice. A value that is not a stage (a deleted one) is shown after the ladder,\n * marked `stray`, until a rung is picked.\n */\nexport function rungStrip(opts: RungStripOptions): HTMLElement {\n const make = opts.doc === undefined ? el : (tag: \"span\" | \"button\", props: { className: string; text?: string; tip?: string; onClick?: () => void }) => {\n const node = opts.doc!.createElement(tag);\n node.className = props.className;\n if (props.text !== undefined) node.textContent = props.text;\n if (props.tip !== undefined) { node.title = props.tip; node.setAttribute(\"aria-label\", props.tip); }\n if (props.onClick) node.addEventListener(\"click\", props.onClick);\n if (tag === \"button\") (node as HTMLButtonElement).type = \"button\";\n return node;\n };\n const strip = make(\"span\", { className: \"seg shell-rungs\" });\n const decl: ValueDeclLike = opts.decl ?? { type: \"quality\", stages: opts.stages };\n const unset = opts.value === undefined;\n const fallback = typeof decl.default === \"string\" && opts.stages.includes(decl.default) ? decl.default : opts.stages[0];\n const readOnly = opts.onPick === undefined;\n if (opts.onClear) {\n strip.append(make(\"button\", {\n className: `seg-opt shell-rung shell-rung-default${unset ? \" on\" : \"\"}`, text: defaultLabel(decl),\n tip: unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n onClick: () => { if (!unset) opts.onClear!(); },\n }));\n }\n for (const stage of opts.stages) {\n const current = opts.value === stage;\n const falls = unset && stage === fallback;\n const rung = make(readOnly ? \"span\" : \"button\", {\n className: `seg-opt shell-rung${current ? \" on\" : \"\"}${falls ? \" fallback\" : \"\"}`, text: stage,\n tip: current ? \"The current stage\" : falls ? \"The stage it falls back to\" : readOnly ? stage : (opts.pickTip?.(stage) ?? `Set to \"${stage}\"`),\n ...(readOnly ? {} : { onClick: () => { if (!current) opts.onPick!(stage); } }),\n });\n strip.append(rung);\n }\n if (!unset && !opts.stages.includes(opts.value!)) {\n strip.append(make(\"span\", {\n className: \"seg-opt shell-rung stray on\", text: opts.value!,\n tip: `\"${opts.value}\" is not one of the stages: pick the one it belongs at now`,\n }));\n }\n return strip;\n}\n\n// ---------------------------------------------------------------------------\n// The field row: ONE control for a node's value of a declared field, driven by\n// the declared type, for the family's seven types (text, multiline, number,\n// boolean, enum, flags, quality). Storyletter's card and outcome Fields and\n// Patterpad's Game Data rows both draw it, which settles the disagreements the\n// parity review found (patterkit design/family-parity-2026-10.md item 10):\n//\n// - the declared purpose is shown, under the control, not hidden in a rollover;\n// - unset says what it falls back to, \"default (x)\", by `defaultLabel`;\n// - flags are a picker of the declared values, not comma-separated text;\n// - multiline is a text area;\n// - a value the declaration refuses (not a number, not one of the values, not\n// a stage) is said under the control, and the app may add its own message;\n// - text commits as typed, and Escape puts back what the field held when it\n// took focus (the family's field rule).\n//\n// Committing as typed means a host that redraws on every change (Patterpad's\n// inspector rebuilds its whole stack) would drop the focus at every keystroke.\n// `fieldRows()` is the answer: it hands back the SAME element for the same key\n// across a redraw, updated in place, and gives the focus (and the caret) back\n// to it once the redraw has put it in the page again.\n// ---------------------------------------------------------------------------\n\n/** A value a field row commits: a flags value is the list of names set. */\nexport type FieldValue = string | number | boolean | string[];\n\n/** A field's declaration as the row reads it: a card field's, an outcome field's or a game-data field's. */\nexport interface FieldDeclLike extends ValueDeclLike {\n name: string;\n /** What the field is for, shown under the control. */\n purpose?: string;\n /** A sentence about each value (an enum's values, the flags, a quality's stages), as an extension's manifest\n * gives them: the chosen value's is shown under the control, and each chosen flag's. */\n valueHelp?: Readonly<Record<string, string>>;\n}\n\n/**\n * The help for what `decl` holds: the chosen enum value's or stage's (the one it falls back to, when unset), or\n * each chosen flag's, \"name: sentence\" a line each. Empty when the declaration describes none of them.\n */\nexport function valueHelpText(decl: FieldDeclLike, value: unknown): string {\n const help = decl.valueHelp;\n if (help === undefined) return \"\";\n const said = (v: string): string | undefined => (Object.prototype.hasOwnProperty.call(help, v) ? help[v] : undefined);\n if (decl.type === \"enum\" || decl.type === \"quality\") {\n const held = typeof value === \"string\" && value !== \"\" ? value\n : typeof decl.default === \"string\" && decl.default !== \"\" ? decl.default\n : decl.type === \"enum\" ? decl.values?.[0] : decl.stages?.[0];\n return held === undefined ? \"\" : said(held) ?? \"\";\n }\n if (decl.type === \"flags\") {\n const held = Array.isArray(value) ? value.map(String) : Array.isArray(decl.default) ? decl.default.map(String) : [];\n return held.flatMap((v) => { const h = said(v); return h === undefined ? [] : [`${v}: ${h}`]; }).join(\"\\n\");\n }\n return \"\";\n}\n\nexport interface FieldRowOptions {\n decl: FieldDeclLike;\n /** The node's own value, typed (a flags value is a string list), or undefined where the node sets none. */\n value: unknown;\n /** Commit a value; `undefined` clears it, back to the default. Absent: the row is read-only. */\n onCommit?: (value: FieldValue | undefined) => void;\n /** Drawn but not editable, as when there is no node to write to. */\n disabled?: boolean;\n /** A message of the app's own about this value (a check the row cannot make), shown under the control. */\n problem?: string;\n /** The app's own sentence INSTEAD of the row's (a renamed stage said better than \"not one of the stages\").\n * Given, it is the whole message; `problem` is ignored. */\n replaceProblem?: string;\n /** The caption; default the field's name. */\n label?: string | Node;\n /** Added to the row and its caption, so a row sits in its app's layout. */\n className?: string;\n labelClassName?: string;\n /** The app's class for a text field or select, used instead of the shell's `.field`. */\n controlClassName?: string;\n}\n\nexport interface FieldRowHandle {\n /** The row: its caption, then the control with the purpose and any message under it. */\n readonly el: HTMLElement;\n /** Redraw for a new value, declaration or message, keeping the element. A field being typed in keeps its\n * text: what the author is typing is newer than what the app last stored. */\n update(opts: FieldRowOptions): void;\n}\n\n/** The type's fallback as a value, for a flags picker to start from when the node sets none. */\nconst fallbackFlags = (decl: ValueDeclLike): string[] => (Array.isArray(decl.default) ? decl.default.filter((v): v is string => typeof v === \"string\") : []);\n\n/** What the row says about a value the declaration refuses, or \"\" when it fits. */\nexport function fieldValueProblem(decl: ValueDeclLike, value: unknown): string {\n if (value === undefined || value === null || value === \"\") return \"\";\n switch (decl.type) {\n case \"number\":\n return typeof value === \"number\" && Number.isFinite(value) ? \"\" : \"Not a number.\";\n case \"boolean\":\n return typeof value === \"boolean\" ? \"\" : \"Not True or False.\";\n case \"enum\":\n return decl.values && !decl.values.includes(String(value)) ? `\"${String(value)}\" is not one of the values.` : \"\";\n case \"quality\":\n return decl.stages && !decl.stages.includes(String(value)) ? `\"${String(value)}\" is not one of the stages.` : \"\";\n case \"flags\": {\n if (!Array.isArray(value)) return \"Not a list of flags.\";\n const strays = decl.values ? value.filter((v) => !decl.values!.includes(String(v))) : [];\n if (strays.length === 0) return \"\";\n return strays.length === 1 ? `\"${String(strays[0])}\" is not one of the values.` : `${strays.map((s) => `\"${String(s)}\"`).join(\", \")} are not among the values.`;\n }\n default:\n return \"\";\n }\n}\n\nconst isTextual = (type: string): boolean => type !== \"boolean\" && type !== \"enum\" && type !== \"flags\" && type !== \"quality\";\n\n/** Everything that decides which control is drawn: a change here rebuilds it, anything else updates it. */\nconst controlShape = (o: FieldRowOptions): string => JSON.stringify([\n o.decl.type, o.decl.values ?? null, o.decl.stages ?? null, o.decl.default ?? null,\n o.onCommit === undefined, o.disabled === true, o.controlClassName ?? \"\",\n o.decl.type === \"quality\" && (o.decl.stages?.length ?? 0) === 0,\n]);\n\n/**\n * One declared field's value as a row: the caption, then the control the declared type calls for, with the\n * purpose and any message under it. See the section comment above for the rules it carries.\n */\nexport function fieldRow(initial: FieldRowOptions): FieldRowHandle {\n let opts = initial;\n const row = el(\"div\", `shell-fieldrow${opts.className ? ` ${opts.className}` : \"\"}`);\n const caption = el(\"span\", `shell-fieldrow-label${opts.labelClassName ? ` ${opts.labelClassName}` : \"\"}`);\n caption.id = `shell-fr-${Math.random().toString(36).slice(2, 9)}`;\n const body = el(\"div\", \"shell-fieldrow-body\");\n const purpose = el(\"p\", \"shell-fieldrow-purpose\");\n const valueHelp = el(\"p\", \"shell-fieldrow-purpose shell-fieldrow-valuehelp\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n row.append(caption, body);\n\n let shape = \"\";\n /** Redraw the control for the current value; set by whichever control is built. */\n let show: (value: unknown) => void = () => {};\n /** A local problem the control found while typing (a number that is not one yet). */\n let typing = \"\";\n\n const commit = (v: FieldValue | undefined): void => { opts.onCommit?.(v); };\n const editable = (): boolean => opts.onCommit !== undefined && opts.disabled !== true;\n // An app's own field class replaces the shell's `.field`, so its controls look like its other fields.\n const ctl = (base: string): string => (opts.controlClassName ? `${base.replace(/^field /, \"\")} ${opts.controlClassName}` : base);\n const labelledBy = (node: HTMLElement): void => {\n node.setAttribute(\"aria-labelledby\", caption.id);\n const described = [purpose.id, problem.id].filter(Boolean).join(\" \");\n if (described) node.setAttribute(\"aria-describedby\", described);\n };\n purpose.id = `${caption.id}-p`; problem.id = `${caption.id}-m`;\n\n const sayProblem = (): void => {\n // The chosen value's own help travels with every change of value, as the message does.\n const help = valueHelpText(opts.decl, opts.value);\n valueHelp.textContent = help;\n valueHelp.hidden = help === \"\";\n const words = opts.replaceProblem !== undefined\n ? [opts.replaceProblem].filter((w) => w !== \"\")\n : [typing || fieldValueProblem(opts.decl, opts.value), opts.problem ?? \"\"].filter((w) => w !== \"\");\n problem.textContent = words.join(\" \");\n problem.hidden = words.length === 0;\n row.classList.toggle(\"has-problem\", words.length > 0);\n row.classList.toggle(\"shell-fieldrow-textual\", isTextual(opts.decl.type));\n };\n\n const build = (): HTMLElement => {\n const decl = opts.decl;\n typing = \"\";\n if (decl.type === \"quality\" && (decl.stages?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-fieldrow-rungs\");\n show = (value) => {\n holder.replaceChildren(rungStrip({\n stages: decl.stages!, value: typeof value === \"string\" && value !== \"\" ? value : undefined, decl,\n ...(editable() ? { onPick: (stage: string) => { opts = { ...opts, value: stage }; show(stage); sayProblem(); commit(stage); }, onClear: () => { opts = { ...opts, value: undefined }; show(undefined); sayProblem(); commit(undefined); } } : {}),\n }));\n const strip = holder.firstElementChild as HTMLElement | null;\n if (strip) { strip.setAttribute(\"role\", \"group\"); labelledBy(strip); }\n };\n return holder;\n }\n if (decl.type === \"boolean\" || decl.type === \"enum\") {\n const sel = el(\"select\", ctl(\"field shell-fieldrow-select\"));\n labelledBy(sel);\n sel.disabled = !editable();\n const choices: Array<[string, string]> = decl.type === \"boolean\"\n ? [[\"true\", \"True\"], [\"false\", \"False\"]]\n : (decl.values ?? []).map((v): [string, string] => [v, v]);\n show = (value) => {\n const current = value === undefined || value === null || value === \"\" ? \"\" : String(value);\n sel.replaceChildren();\n const add = (v: string, label: string): void => { const o = el(\"option\", undefined, label); o.value = v; sel.append(o); };\n add(\"\", defaultLabel(decl));\n for (const [v, label] of choices) add(v, label);\n // A value the declaration no longer offers stays visible, so the author sees what is held.\n if (current !== \"\" && !choices.some(([v]) => v === current)) add(current, current);\n sel.value = current;\n };\n sel.addEventListener(\"change\", () => {\n const raw = sel.value;\n const v: FieldValue | undefined = raw === \"\" ? undefined : decl.type === \"boolean\" ? raw === \"true\" : raw;\n opts = { ...opts, value: v }; sayProblem(); commit(v);\n });\n return sel;\n }\n if (decl.type === \"flags\" && (decl.values?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-flags\");\n holder.setAttribute(\"role\", \"group\");\n labelledBy(holder);\n show = (value) => {\n const unset = !Array.isArray(value);\n const held = unset ? fallbackFlags(decl) : (value as unknown[]).map(String);\n holder.replaceChildren();\n const chip = (text: string, cls: string, pressed: boolean | undefined, tip: string, onClick?: () => void): void => {\n const b = el(onClick && editable() ? \"button\" : \"span\", { className: `shell-flag${cls}`, text, tip });\n b.setAttribute(\"aria-label\", `${text}: ${tip}`); // the tip alone would hide the value's name\n if (b instanceof HTMLButtonElement) { b.type = \"button\"; b.addEventListener(\"click\", onClick!); }\n if (pressed !== undefined) b.setAttribute(\"aria-pressed\", String(pressed));\n holder.append(b);\n };\n const set = (next: string[] | undefined): void => { opts = { ...opts, value: next }; show(next); sayProblem(); commit(next); };\n chip(defaultLabel(decl), ` shell-flag-default${unset ? \" on\" : \"\"}`, undefined,\n unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n unset ? undefined : () => set(undefined));\n for (const v of decl.values!) {\n const on = held.includes(v);\n chip(v, `${on ? \" on\" : \"\"}${on && unset ? \" fallback\" : \"\"}`, on, on ? `Unset ${v}` : `Set ${v}`,\n () => set(on ? held.filter((x) => x !== v) : decl.values!.filter((x) => x === v || held.includes(x)).concat(held.filter((x) => !decl.values!.includes(x)))));\n }\n // A held value the declaration does not offer: shown, struck, and a click drops it.\n for (const v of held.filter((x) => !decl.values!.includes(x))) {\n chip(v, \" stray on\", true, `\"${v}\" is not one of the values: click to drop it`, () => set(held.filter((x) => x !== v)));\n }\n };\n return holder;\n }\n if (decl.type === \"flags\") {\n // No values declared to pick from: the shell's chip editor, each name typed.\n const holder = el(\"span\", \"shell-fieldrow-chips\");\n show = (value) => {\n const box = { values: Array.isArray(value) ? (value as unknown[]).map(String) : [] };\n const chips = tagChips(box, () => {\n const next = box.values.length > 0 ? [...box.values] : undefined;\n opts = { ...opts, value: next }; sayProblem(); commit(next);\n });\n const input = chips.querySelector(\"input\");\n if (input) { labelledBy(input); input.placeholder = Array.isArray(value) ? \"Add value\" : defaultLabel(decl); input.disabled = !editable(); }\n chips.querySelectorAll(\"button\").forEach((b) => { (b as HTMLButtonElement).disabled = !editable(); });\n holder.replaceChildren(chips);\n };\n return holder;\n }\n // text, multiline, number, and any type the row does not know: typed, committed as typed.\n const multiline = decl.type === \"multiline\";\n const field = multiline ? el(\"textarea\", ctl(\"field shell-fieldrow-text\")) : el(\"input\", ctl(\"field shell-fieldrow-text\"));\n if (field instanceof HTMLInputElement) {\n field.type = \"text\";\n if (decl.type === \"number\") field.inputMode = \"decimal\";\n } else field.rows = 3;\n labelledBy(field);\n field.placeholder = defaultLabel(decl);\n field.disabled = !editable();\n const asText = (value: unknown): string =>\n value === undefined || value === null ? \"\" : Array.isArray(value) ? value.join(\", \") : String(value);\n const read = (raw: string): { value?: FieldValue; bad?: string } => {\n if (raw.trim() === \"\") return {};\n if (decl.type !== \"number\") return { value: raw };\n const n = Number(raw.trim());\n return Number.isFinite(n) ? { value: n } : { bad: \"Not a number.\" };\n };\n let atFocus = \"\";\n show = (value) => {\n // What the author is typing is newer than the stored value, so a focused field keeps its text.\n // So does one the author was in when a redraw took the row out of the page, until they leave it.\n if (field.ownerDocument.activeElement === field || keeper.restoring(field) || keeper.holds(row)) return;\n field.value = asText(value);\n };\n const take = (): void => {\n const r = read(field.value);\n typing = r.bad ?? \"\";\n if (r.bad === undefined) opts = { ...opts, value: r.value };\n sayProblem();\n if (r.bad === undefined) commit(r.value);\n };\n field.addEventListener(\"focus\", () => { if (!keeper.restoring(field)) atFocus = field.value; });\n field.addEventListener(\"input\", take);\n field.addEventListener(\"keydown\", (e) => {\n if ((e as KeyboardEvent).key !== \"Escape\" || field.value === atFocus) return;\n field.value = atFocus;\n take();\n });\n return field;\n };\n\n const draw = (next: FieldRowOptions): void => {\n const decl = next.decl;\n const label = next.label ?? decl.name;\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n caption.className = `shell-fieldrow-label${next.labelClassName ? ` ${next.labelClassName}` : \"\"}`;\n row.className = `shell-fieldrow${next.className ? ` ${next.className}` : \"\"}`;\n const nextShape = controlShape(next);\n opts = next;\n if (nextShape !== shape) {\n shape = nextShape;\n body.replaceChildren(build());\n }\n show(next.value);\n purpose.textContent = decl.purpose ?? \"\";\n if (decl.purpose) body.append(purpose); else purpose.remove();\n body.append(valueHelp, problem);\n sayProblem();\n };\n\n draw(initial);\n keeper.watch(row);\n return { el: row, update: draw };\n}\n\n// --- keeping the focus across a redraw -------------------------------------\n//\n// A host that rebuilds its view takes the row out of the page and puts it back.\n// Taking a focused element out drops its focus, which is the same thing as\n// the author losing their place mid-word. So a row remembers whether the\n// author was in it, and where the caret was, and the cache gives both back\n// once the row is in the page again (a microtask: after the host's redraw).\n\ninterface FocusMemo { field: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement; start: number | null; end: number | null }\n\nconst keeper = (() => {\n const memos = new WeakMap<HTMLElement, FocusMemo>();\n const restoringNow = new WeakSet<Element>();\n /** When each row was last handed back by the cache, to tell a move's late blur from the author's. */\n const redrawn = new WeakMap<HTMLElement, number>();\n const put = (row: HTMLElement): void => {\n const memo = memos.get(row);\n if (!memo) return;\n const doc = row.ownerDocument;\n const active = doc.activeElement;\n if (!row.isConnected || !memo.field.isConnected || !row.contains(memo.field)) return;\n if (active && active !== doc.body && !row.contains(active)) { memos.delete(row); return; }\n if (active === memo.field && memo.field.matches(\":focus\")) return;\n restoringNow.add(memo.field);\n try {\n memo.field.focus({ preventScroll: true });\n if (!(memo.field instanceof HTMLSelectElement) && memo.start !== null) memo.field.setSelectionRange(memo.start, memo.end ?? memo.start);\n } finally { restoringNow.delete(memo.field); }\n };\n return {\n watch(row: HTMLElement): void {\n const note = (e: Event): void => {\n const t = e.target;\n if (!(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement)) return;\n const text = !(t instanceof HTMLSelectElement);\n memos.set(row, { field: t, start: text ? (t as HTMLInputElement).selectionStart : null, end: text ? (t as HTMLInputElement).selectionEnd : null });\n };\n row.addEventListener(\"focusin\", note);\n row.addEventListener(\"input\", note);\n row.addEventListener(\"keyup\", note);\n row.addEventListener(\"mouseup\", note);\n // A blur the author made (the row still in the page) forgets; one caused by the row leaving the page\n // does not, and is what the cache puts back. Chromium drops the focus of a moved element LATE: the\n // blur arrives after the redraw, the row already back in the page, so a blur to nowhere just after a\n // redraw is the move's, and the focus goes straight back.\n // Chromium may also fire that blur synchronously, as the host clears its view and before the cache\n // has handed the row back: so the decision waits for the microtask, by which time a row the redraw\n // asked for again is marked as redrawn since the blur.\n row.addEventListener(\"focusout\", (e) => {\n const at = performance.now();\n const late = (e as FocusEvent).relatedTarget === null && at - (redrawn.get(row) ?? -Infinity) < 250;\n if (late && memos.has(row)) { queueMicrotask(() => put(row)); return; }\n queueMicrotask(() => {\n if ((redrawn.get(row) ?? -Infinity) >= at) { put(row); return; }\n if (row.isConnected && !row.contains(row.ownerDocument.activeElement)) memos.delete(row);\n });\n });\n },\n /** Give the focus back to the row, if the author was in it and has not gone anywhere else since. */\n restore(row: HTMLElement): void {\n if (!memos.has(row)) return;\n redrawn.set(row, performance.now());\n // At the microtask, not now: the event that caused the redraw may still note the caret.\n queueMicrotask(() => put(row));\n },\n restoring: (field: Element): boolean => restoringNow.has(field),\n /** Forget the row's focus if the author has since gone somewhere else (before the row is redrawn). */\n settle(row: HTMLElement): void {\n const active = row.ownerDocument.activeElement;\n if (active && active !== row.ownerDocument.body && !row.contains(active)) memos.delete(row);\n },\n /** The row the author is in (before a redraw takes it out). */\n holds: (row: HTMLElement): boolean => memos.has(row),\n };\n})();\n\n/**\n * The focus keeping `fieldRows` does, for a host (or a structured row) that keeps row elements itself: call\n * `settle` before it updates a row and `restore` once the row is back in the page.\n */\nexport const fieldRowFocus = {\n settle: (row: HTMLElement): void => keeper.settle(row),\n restore: (row: HTMLElement): void => keeper.restore(row),\n};\n\nexport interface FieldRows {\n /**\n * The row for `key` (a node and a field, say `${nodeId}:${field}`): the same element as last time when\n * there was one, updated for these options, else a new one. A row the author was typing in gets its focus\n * and caret back once the redraw has put it in the page.\n */\n row(key: string, opts: FieldRowOptions): HTMLElement;\n /** Forget every row not asked for since the last sweep (call at the end of a redraw). */\n sweep(): void;\n}\n\n/** A cache of field rows for a host that redraws its whole view on every change. */\nexport function fieldRows(): FieldRows {\n const rows = new Map<string, { handle: FieldRowHandle; used: boolean }>();\n return {\n row(key, opts) {\n const had = rows.get(key);\n if (had) {\n had.used = true;\n keeper.settle(had.handle.el);\n had.handle.update(opts);\n keeper.restore(had.handle.el);\n return had.handle.el;\n }\n const handle = fieldRow(opts);\n rows.set(key, { handle, used: true });\n return handle.el;\n },\n sweep() {\n for (const [key, entry] of rows) { if (!entry.used) rows.delete(key); else entry.used = false; }\n },\n };\n}\n","// ---------------------------------------------------------------------------\n// An extension's fields folded to the ones a node sets (Pattershot's brief,\n// \"extension fields folded\", rulings F1 to F9, 2026-10-20). An extension meant\n// to be left alone on most nodes drew every field on every node, nearly all\n// empty. Folded, its section is the caption, with a disclosure and a count,\n// and only the fields set; unfolded, every field, as before.\n//\n// One rule for the family, so Patterpad and Storyletter fold alike:\n// - set means the node holds a value that differs from the toolkit's\n// `defaultOf`, compared deeply (`isSet`); a field is set or not as a whole;\n// - the fold is per extension, and stays as left while the author moves\n// between nodes (for the session: it isn't stored);\n// - a value cleared while folded keeps its row until the author leaves the\n// node (a redraw that doesn't draw it, then `sweep`), so a row never vanishes\n// under the cursor;\n// - keys the extension doesn't declare, and the host's lead (a lock line),\n// always show.\n//\n// The host draws each row (its own cache, classes and problems); this draws\n// the section around them. Project Settings doesn't fold: it's where an\n// author goes to set things, and draws its rows directly.\n// ---------------------------------------------------------------------------\n\nimport { defaultOf, stableStringify } from \"@wildwinter/toolkit/extensions\";\nimport type { TypeDecl } from \"@wildwinter/toolkit/extensions\";\nimport { el } from \"./dom.js\";\nimport { iconNode } from \"./icons.js\";\nimport type { ValueDecl } from \"./value-rows.js\";\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/**\n * Whether a node's value for `decl` is set: held, and not the declaration's default. A record counts as its\n * default when each of its fields does and it holds no other key, so `{}` and a record of defaults are both\n * unset; anything else is compared with `defaultOf`, deeply and regardless of key order.\n */\nexport function isSet(decl: ValueDecl, value: unknown): boolean {\n if (value === undefined) return false;\n if (decl.type === \"record\" && decl.default === undefined && isObject(value)) {\n const fields = decl.fields ?? [];\n const declared = new Set(fields.map((f) => f.name));\n if (Object.entries(value).some(([k, v]) => !declared.has(k) && v !== undefined)) return true;\n return fields.some((f) => isSet(f, value[f.name]));\n }\n return stableStringify(value) !== stableStringify(defaultOf(decl as unknown as TypeDecl));\n}\n\nexport interface FoldSectionOptions {\n /** The extension's id: the fold is remembered by it. */\n extension: string;\n /** The extension's name, the caption. */\n caption: string;\n /** The node the section is for, by any key unique to it: a row cleared while folded stays while the host\n * keeps drawing this node. */\n node: string;\n /** The extension's fields for the node's kind, in the manifest's order. */\n fields: readonly ValueDecl[];\n /** The node's values for the extension, or undefined where it holds none. */\n entry: Record<string, unknown> | undefined;\n /** One field's row, drawn by the host. */\n row: (decl: ValueDecl) => HTMLElement;\n /** A heading above the first shown field of a group. */\n group: (name: string) => HTMLElement;\n /** Shown above the rows, folded or not (a lock line). */\n lead?: readonly HTMLElement[];\n /** Shown after the rows, folded or not (keys the extension doesn't declare). */\n tail?: readonly HTMLElement[];\n /** The section's own class, beside `shell-fold`. */\n className?: string;\n /** The caption's class, beside `shell-fold-cap`. */\n captionClassName?: string;\n}\n\nexport interface ExtensionFold {\n /** Draw one extension's section for one node: the caption and disclosure, then the rows the fold shows. */\n section(o: FoldSectionOptions): HTMLElement;\n /** Whether an extension's section is open (every field). Folded until opened. */\n isOpen(extension: string): boolean;\n setOpen(extension: string, open: boolean): void;\n /** After a redraw: forget the rows kept for nodes it didn't draw, so leaving a node and coming back shows\n * only what is set. A host that redraws its whole view calls it at the end of each, as a row cache's. */\n sweep(): void;\n}\n\n/** The caption's words: the name, and the count when anything is set. */\nexport function foldCaption(name: string, set: number): string {\n return set > 0 ? `${name} (${set} set)` : name;\n}\n\n/**\n * The fold for a host's inspector: one per host, kept across its redraws, so the fold stays as left from node\n * to node.\n */\nexport function extensionFold(): ExtensionFold {\n const open = new Set<string>();\n // Per extension and node: the fields shown while folded, so a value cleared there keeps its row until the\n // author moves on. An inspector shows several nodes at once (a line, its block, its scene), so each keeps\n // its own; `sweep` drops the ones a redraw didn't draw.\n const shown = new Map<string, { fields: Set<string>; used: boolean }>();\n const keyOf = (o: FoldSectionOptions): string => `${o.extension}\\u0000${o.node}`;\n\n const visible = (o: FoldSectionOptions, setNames: ReadonlySet<string>): Set<string> => {\n const was = shown.get(keyOf(o));\n const fields = was ? new Set([...was.fields, ...setNames]) : new Set(setNames);\n shown.set(keyOf(o), { fields, used: true });\n return fields;\n };\n\n const fold: ExtensionFold = {\n isOpen: (extension) => open.has(extension),\n setOpen(extension, on) {\n if (on) open.add(extension); else open.delete(extension);\n // Folding again starts from what is set now.\n for (const key of shown.keys()) if (key.startsWith(`${extension}\\u0000`)) shown.delete(key);\n },\n sweep() {\n for (const [key, entry] of shown) { if (!entry.used) shown.delete(key); else entry.used = false; }\n },\n section(o) {\n const sec = el(\"div\", `shell-fold${o.className ? ` ${o.className}` : \"\"}`);\n sec.dataset[\"extension\"] = o.extension;\n const cap = el(\"button\", `shell-fold-cap${o.captionClassName ? ` ${o.captionClassName}` : \"\"}`);\n cap.type = \"button\";\n const body = el(\"div\", \"shell-fold-body\");\n sec.append(cap, body);\n\n const draw = (): void => {\n const isOpen = open.has(o.extension);\n const setNames = new Set(o.fields.filter((f) => isSet(f, o.entry?.[f.name])).map((f) => f.name));\n const show = isOpen ? undefined : visible(o, setNames);\n cap.replaceChildren(iconNode(isOpen ? \"expanded\" : \"collapsed\"), el(\"span\", \"shell-fold-name\", foldCaption(o.caption, setNames.size)));\n cap.setAttribute(\"aria-expanded\", String(isOpen));\n cap.dataset[\"tip\"] = isOpen ? `Show only the fields set here` : `Show every ${o.caption} field`;\n sec.classList.toggle(\"shell-fold-open\", isOpen);\n const rows: HTMLElement[] = [...(o.lead ?? [])];\n let group: string | undefined;\n for (const decl of o.fields) {\n if (show && !show.has(decl.name)) continue;\n const g = (decl as { group?: string }).group;\n if (g !== undefined && g !== group) { group = g; rows.push(o.group(g)); }\n rows.push(o.row(decl));\n }\n rows.push(...(o.tail ?? []));\n body.replaceChildren(...rows);\n };\n cap.addEventListener(\"click\", () => { fold.setOpen(o.extension, !open.has(o.extension)); draw(); });\n draw();\n return sec;\n },\n };\n return fold;\n}\n","// ---------------------------------------------------------------------------\n// Rows for a value of ANY declared type: the seven scalars through the field\n// row, and the types an extension's fields add (patterkit design/proposals/\n// patter-storylet-extensions.md, \"Tier 1: fields\"): a `reference` to one of the\n// host's nodes, a `pick` of one choice from the sources its manifest names, a\n// `record` of named fields, a `map` keyed by a reference or by text, and a `list`\n// with ids or without.\n//\n// A structured value is drawn as its parts, each part a row of its own, so the\n// family's field rules hold all the way down: commit as typed, Escape restores,\n// the unset state names what it falls back to, a value the declaration refuses\n// is said under it, and a row keeps its element (and its focus) across a redraw.\n// The checks are `@wildwinter/toolkit/extensions`' (`valueProblems`), the same\n// ones the command lines run, so the editor and validation never disagree.\n//\n// The host supplies what only it knows through an adapter: which nodes there are\n// of a kind (a map keyed by tag offers the tags, a reference to a card the\n// cards), and the lists of text on the extension's project node a pick offers.\n// No Electron, no app state: DOM only.\n//\n// Its own entry (`@wildwinter/app-shell/value-rows`) rather than part of\n// value-control, because it needs `@wildwinter/toolkit/extensions` (an optional\n// peer, toolkit 0.2.5 or later) and the scalar row does not: a host that draws\n// only the family's seven types takes nothing new.\n// ---------------------------------------------------------------------------\n\nimport { defaultOf, pickChoices, valueProblems } from \"@wildwinter/toolkit/extensions\";\nimport type { PickSource, TypeDecl, ValueContext } from \"@wildwinter/toolkit/extensions\";\nimport { el, iconBtn, moveItem } from \"./dom.js\";\nimport { fieldRow, fieldRowFocus } from \"./value-control.js\";\nimport type { FieldDeclLike, FieldRowHandle, FieldValue } from \"./value-control.js\";\n\n/** A declaration of any type, as an extension's manifest writes it. */\nexport interface ValueDecl extends FieldDeclLike {\n /** The caption; the name when absent. */\n label?: string;\n /** A sentence or two shown under the control (an extension's `help`, a field's `purpose`). */\n help?: string;\n /** A reference's node kind. */\n to?: string;\n /** A pick's sources, in the order its choices are shown: fixed words, a node kind, a project list. */\n from?: readonly PickSource[];\n /** A record's fields. */\n fields?: ValueDecl[];\n /** A map's key: text, or a reference to a node kind. */\n key?: { type: string; to?: string };\n /** A map's or a list's value type. */\n of?: Omit<ValueDecl, \"name\"> & { name?: string };\n /** A list's id field: the text field of its records that keys each item. */\n id?: string;\n min?: number;\n max?: number;\n required?: boolean;\n}\n\n/** One node the host offers, by id, with the name the author knows it by. */\nexport interface ValueNode { id: string; label: string }\n\n/** What only the host knows: the nodes of a kind (`card`, `tag`, `cast`...), for references, map keys and picks,\n * and the lists of text on the extension's own project node, for picks. */\nexport interface ValueAdapter {\n nodes(kind: string): readonly ValueNode[];\n /**\n * The entries of a list of text on the extension's own project node, by field name, for a pick's `list` source\n * (the toolkit's `pickLists` reads them off the project entry). A host scopes it to the extension whose rows it\n * draws. Absent: a pick offers no list entries, and doesn't check against them.\n */\n list?(name: string): readonly string[] | undefined;\n /**\n * The name of a node by kind and id, for a value that holds one `nodes` does not offer (a node outside the\n * choices, say): undefined when there is no such node, which is then shown as gone. Absent: a held id `nodes`\n * does not list is taken to be gone.\n */\n label?(kind: string, id: string): string | undefined;\n}\n\n/** A node's name: from the choices, else the host's `label`; undefined when the host says there is none. */\nfunction nodeLabel(adapter: ValueAdapter, kind: string, id: string): string | undefined {\n return adapter.nodes(kind).find((n) => n.id === id)?.label ?? adapter.label?.(kind, id);\n}\n\nexport interface ValueRowOptions {\n decl: ValueDecl;\n /** The node's own value, or undefined where it sets none. */\n value: unknown;\n /** Commit a value; undefined clears it, back to the default. Absent: read-only. */\n onCommit?: (value: unknown) => void;\n /** The host's nodes, for references and map keys. Absent: a reference is typed as an id. */\n adapter?: ValueAdapter;\n disabled?: boolean;\n /** A message of the app's own about this value, shown under it. */\n problem?: string;\n /** The app's own sentence instead of the row's own checks, as the field row's `replaceProblem`. */\n replaceProblem?: string;\n /** The caption; default the declaration's label, else its name. */\n label?: string | Node;\n className?: string;\n labelClassName?: string;\n controlClassName?: string;\n}\n\nexport interface ValueRowHandle {\n readonly el: HTMLElement;\n update(opts: ValueRowOptions): void;\n}\n\nconst SCALARS = new Set([\"text\", \"multiline\", \"number\", \"boolean\", \"enum\", \"flags\", \"quality\", \"string\"]);\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null && !Array.isArray(v);\nconst nameOf = (decl: ValueDecl): string => decl.label ?? decl.name;\nconst asDecl = (d: Omit<ValueDecl, \"name\"> & { name?: string }, name: string): ValueDecl => ({ ...d, name: d.name ?? name });\n\n/** The toolkit's checks for this value, as words for the row itself (the parts say their own). */\nfunction ownProblems(decl: ValueDecl, value: unknown, adapter: ValueAdapter | undefined): string {\n if (value === undefined) return \"\";\n return valueProblems(decl as unknown as TypeDecl, value, contextOf(adapter))\n .filter((p) => p.path === \"\" && (p.severity === \"error\" || p.code === \"pick-ambiguous\") && p.code !== \"not-a-value\" && p.code !== \"not-a-stage\")\n .map((p) => `${p.message.replace(/^the value/, \"The value\")}.`)\n .join(\" \");\n}\n\n/** The adapter as the toolkit's checks take it: whether a node exists, and a project list's entries. */\nfunction contextOf(adapter: ValueAdapter | undefined): ValueContext {\n if (!adapter) return {};\n return {\n exists: (kind: string, id: string) => nodeLabel(adapter, kind, id) !== undefined,\n ...(adapter.list ? { list: (name: string) => adapter.list!(name) } : {}),\n };\n}\n\n/**\n * A row for a value of `decl`'s type, whatever it is: a scalar as the field row, a reference as a choice of\n * the host's nodes, and a record, map or list as its parts, each a row of its own. Keeps its element, and its\n * parts' elements, across `update`, so a host that redraws on every change keeps the author's place.\n */\nexport function valueRow(initial: ValueRowOptions): ValueRowHandle {\n const decl = initial.decl;\n if (SCALARS.has(decl.type)) return scalarRow(initial);\n if (decl.type === \"reference\") return referenceRow(initial);\n if (decl.type === \"pick\") return pickRow(initial);\n return structuredRow(initial);\n}\n\n/** The field row, with an extension's help as its purpose and the toolkit's range checks. */\nfunction scalarRow(initial: ValueRowOptions): ValueRowHandle {\n const map = (o: ValueRowOptions) => {\n const range = ownProblems(o.decl, o.value, o.adapter);\n const problem = [range, o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n return {\n decl: { ...o.decl, ...(o.decl.help !== undefined && o.decl.purpose === undefined ? { purpose: o.decl.help } : {}) },\n value: o.value,\n ...(o.onCommit ? { onCommit: (v: FieldValue | undefined) => o.onCommit!(v) } : {}),\n ...(o.disabled !== undefined ? { disabled: o.disabled } : {}),\n ...(problem !== \"\" ? { problem } : {}),\n ...(o.replaceProblem !== undefined ? { replaceProblem: o.replaceProblem } : {}),\n label: o.label ?? nameOf(o.decl),\n ...(o.className !== undefined ? { className: o.className } : {}),\n ...(o.labelClassName !== undefined ? { labelClassName: o.labelClassName } : {}),\n ...(o.controlClassName !== undefined ? { controlClassName: o.controlClassName } : {}),\n };\n };\n const handle: FieldRowHandle = fieldRow(map(initial));\n return { el: handle.el, update: (o) => handle.update(map(o)) };\n}\n\n/** A reference: a choice of the host's nodes of its kind, \"default (none)\" first; a node that has gone stays\n * visible as what is held. Without an adapter, the id is typed. */\nfunction referenceRow(initial: ValueRowOptions): ValueRowHandle {\n let opts = initial;\n if (!opts.adapter) {\n const inner = scalarRow({ ...opts, decl: { ...opts.decl, type: \"text\" } });\n return { el: inner.el, update: (o) => { opts = o; inner.update({ ...o, decl: { ...o.decl, type: \"text\" } }); } };\n }\n const row = el(\"div\", \"shell-fieldrow shell-valuerow-ref\");\n const caption = el(\"span\", \"shell-fieldrow-label\");\n const body = el(\"div\", \"shell-fieldrow-body\");\n const sel = el(\"select\", \"field shell-fieldrow-select\");\n const help = el(\"p\", \"shell-fieldrow-purpose\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n body.append(sel, help, problem);\n row.append(caption, body);\n sel.addEventListener(\"change\", () => {\n const v = sel.value === \"\" ? undefined : sel.value;\n opts = { ...opts, value: v };\n draw(opts);\n opts.onCommit?.(v);\n });\n const draw = (o: ValueRowOptions): void => {\n opts = o;\n row.className = `shell-fieldrow shell-valuerow-ref${o.className ? ` ${o.className}` : \"\"}`;\n const label = o.label ?? nameOf(o.decl);\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n if (o.controlClassName) sel.className = `shell-fieldrow-select ${o.controlClassName}`;\n const nodes = o.adapter!.nodes(o.decl.to ?? \"\");\n const held = typeof o.value === \"string\" ? o.value : \"\";\n sel.replaceChildren();\n const add = (v: string, text: string): void => { const opt = el(\"option\", undefined, text); opt.value = v; sel.append(opt); };\n add(\"\", \"default (none)\");\n for (const n of nodes) add(n.id, n.label);\n if (held !== \"\" && !nodes.some((n) => n.id === held)) {\n // A node outside the choices keeps its name; only one the host says does not exist reads as gone.\n const name = o.adapter!.label?.(o.decl.to ?? \"\", held);\n add(held, name ?? `${held} (gone)`);\n }\n sel.value = held;\n sel.disabled = o.onCommit === undefined || o.disabled === true;\n help.textContent = o.decl.help ?? o.decl.purpose ?? \"\";\n help.hidden = help.textContent === \"\";\n const words = o.replaceProblem ?? [ownProblems(o.decl, o.value, o.adapter), o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n problem.textContent = words;\n problem.hidden = words === \"\";\n row.classList.toggle(\"has-problem\", words !== \"\");\n };\n draw(initial);\n return { el: row, update: draw };\n}\n\n/**\n * A pick: one choice, \"auto\" (empty) first, then each source's choices in the declared order, a node kind's and a\n * project list's under their names. A value no source holds stays visible as what is held, marked missing; a\n * name two sources hold is said under it. Without an adapter, a pick of fixed words alone is still a choice of\n * them, and one with other sources is typed as text.\n */\nfunction pickRow(initial: ValueRowOptions): ValueRowHandle {\n let opts = initial;\n if (!opts.adapter && (opts.decl.from ?? []).some((s) => !(\"words\" in s))) {\n const inner = scalarRow({ ...opts, decl: { ...opts.decl, type: \"text\" } });\n return { el: inner.el, update: (o) => { opts = o; inner.update({ ...o, decl: { ...o.decl, type: \"text\" } }); } };\n }\n const row = el(\"div\", \"shell-fieldrow shell-valuerow-pick\");\n const caption = el(\"span\", \"shell-fieldrow-label\");\n const body = el(\"div\", \"shell-fieldrow-body\");\n const sel = el(\"select\", \"field shell-fieldrow-select\");\n const help = el(\"p\", \"shell-fieldrow-purpose\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n body.append(sel, help, problem);\n row.append(caption, body);\n sel.addEventListener(\"change\", () => {\n const v = sel.value === \"\" ? undefined : sel.value;\n opts = { ...opts, value: v };\n draw(opts);\n opts.onCommit?.(v);\n });\n const groupName = (s: PickSource): string | undefined =>\n \"to\" in s ? (s.to === \"cast\" ? \"Cast\" : s.to.charAt(0).toUpperCase() + s.to.slice(1)) : \"list\" in s ? s.list : undefined;\n const draw = (o: ValueRowOptions): void => {\n opts = o;\n row.className = `shell-fieldrow shell-valuerow-pick${o.className ? ` ${o.className}` : \"\"}`;\n const label = o.label ?? nameOf(o.decl);\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n if (o.controlClassName) sel.className = `shell-fieldrow-select ${o.controlClassName}`;\n const adapter = o.adapter;\n const choices = pickChoices(o.decl as unknown as TypeDecl, {\n ...(adapter ? { nodes: (kind: string) => adapter.nodes(kind) } : {}),\n ...(adapter?.list ? { list: (name: string) => adapter.list!(name) } : {}),\n });\n const held = typeof o.value === \"string\" ? o.value : \"\";\n sel.replaceChildren();\n const option = (v: string, text: string): HTMLOptionElement => { const opt = el(\"option\", undefined, text); opt.value = v; return opt; };\n sel.append(option(\"\", \"auto\"));\n // One group per source, in order; a value two sources hold is offered by the first only, so the select\n // shows one choice for what it holds (the row says the name is ambiguous).\n const offered = new Set<string>();\n let group: { source: PickSource; el: HTMLElement } | undefined;\n for (const c of choices) {\n if (offered.has(c.value)) continue;\n offered.add(c.value);\n const name = groupName(c.source);\n if (name === undefined) { group = undefined; sel.append(option(c.value, c.label)); continue; }\n if (group?.source !== c.source) {\n const og = el(\"optgroup\");\n og.setAttribute(\"label\", name);\n sel.append(og);\n group = { source: c.source, el: og };\n }\n group.el.append(option(c.value, c.label));\n }\n if (held !== \"\" && !offered.has(held)) {\n // A node outside the choices keeps its name (as a reference's does); anything else is missing.\n const named = (o.decl.from ?? []).map((s) => (\"to\" in s && adapter ? adapter.label?.(s.to, held) : undefined)).find((n) => n !== undefined);\n sel.append(option(held, named ?? `${held} (missing)`));\n }\n sel.value = held;\n sel.disabled = o.onCommit === undefined || o.disabled === true;\n help.textContent = o.decl.help ?? o.decl.purpose ?? \"\";\n help.hidden = help.textContent === \"\";\n const words = o.replaceProblem ?? [ownProblems(o.decl, o.value, o.adapter), o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n problem.textContent = words;\n problem.hidden = words === \"\";\n row.classList.toggle(\"has-problem\", words !== \"\");\n };\n draw(initial);\n return { el: row, update: draw };\n}\n\n/** A part of a structured value: a row, keyed so it is the same element next time. */\ninterface Part { key: string; handle: ValueRowHandle; holder: HTMLElement; tools: HTMLElement }\n\n/** A record, a map or a list: a caption, then its parts, each a row of its own, with the controls the type\n * calls for (add and remove for a map; add, remove and move for a list). */\nfunction structuredRow(initial: ValueRowOptions): ValueRowHandle {\n let opts = initial;\n const row = el(\"div\", \"shell-fieldrow shell-valuerow\");\n const caption = el(\"span\", \"shell-fieldrow-label\");\n const body = el(\"div\", \"shell-fieldrow-body shell-valuerow-parts\");\n const help = el(\"p\", \"shell-fieldrow-purpose\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n const adder = el(\"div\", \"shell-valuerow-add\");\n row.append(caption, body);\n const parts = new Map<string, Part>();\n /** The parts kept from the last draw, whose focus goes back to them once they are in the page again. */\n let kept: HTMLElement[] = [];\n let addKey = \"\";\n\n const editable = (): boolean => opts.onCommit !== undefined && opts.disabled !== true;\n const commit = (v: unknown): void => { opts = { ...opts, value: v }; draw(opts); opts.onCommit?.(v); };\n\n /** The row for one part, the same element as last time for the same key. */\n const part = (key: string, o: ValueRowOptions, controls: HTMLElement[] = []): HTMLElement => {\n const had = parts.get(key);\n if (had && had.handle.el.dataset[\"type\"] === o.decl.type) {\n fieldRowFocus.settle(had.handle.el);\n had.handle.update(o);\n // Its own slot, not the first one inside it: a structured part has slots of its own further down.\n had.tools.replaceChildren(...controls);\n kept.push(had.handle.el);\n return had.holder;\n }\n const handle = valueRow(o);\n handle.el.dataset[\"type\"] = o.decl.type;\n const holder = el(\"div\", \"shell-valuerow-part\");\n const tools = el(\"span\", \"shell-valuerow-controls\");\n tools.append(...controls);\n holder.append(handle.el, tools);\n parts.set(key, { key, handle, holder, tools });\n return holder;\n };\n\n const draw = (o: ValueRowOptions): void => {\n opts = o;\n kept = [];\n const decl = o.decl;\n row.className = `shell-fieldrow shell-valuerow shell-valuerow-${decl.type}${o.className ? ` ${o.className}` : \"\"}`;\n const label = o.label ?? nameOf(decl);\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n const used = new Set<string>();\n const rows: HTMLElement[] = [];\n const child = (key: string, childDecl: ValueDecl, value: unknown, onCommit: (v: unknown) => void, controls?: HTMLElement[], childLabel?: string, extraProblem?: string): void => {\n used.add(key);\n rows.push(part(key, {\n decl: childDecl, value,\n ...(editable() ? { onCommit } : {}),\n ...(o.adapter ? { adapter: o.adapter } : {}),\n ...(o.disabled !== undefined ? { disabled: o.disabled } : {}),\n ...(childLabel !== undefined ? { label: childLabel } : {}),\n ...(extraProblem ? { problem: extraProblem } : {}),\n ...(o.controlClassName !== undefined ? { controlClassName: o.controlClassName } : {}),\n }, controls));\n };\n\n if (decl.type === \"record\") {\n const value = isObject(o.value) ? o.value : undefined;\n const required = value === undefined ? [] : valueProblems(decl as unknown as TypeDecl, value).filter((p) => p.code === \"required\");\n for (const f of decl.fields ?? []) {\n const missing = required.find((p) => p.path === f.name);\n child(`f:${f.name}`, f, value?.[f.name], (v) => {\n const next: Record<string, unknown> = { ...(isObject(opts.value) ? opts.value : {}) };\n if (v === undefined) delete next[f.name]; else next[f.name] = v;\n commit(Object.keys(next).length > 0 ? next : undefined);\n }, undefined, undefined, missing ? \"Required.\" : undefined);\n }\n } else if (decl.type === \"map\" && decl.of) {\n const value = isObject(o.value) ? o.value : {};\n const keyNodes = decl.key?.type === \"reference\" && o.adapter ? o.adapter.nodes(decl.key.to ?? \"\") : undefined;\n const keyKind = decl.key?.to ?? \"\";\n const keyLabel = (k: string): string => (o.adapter && keyNodes !== undefined ? nodeLabel(o.adapter, keyKind, k) : undefined) ?? k;\n for (const k of Object.keys(value)) {\n const remove = editable() ? [iconBtn(\"close\", `Remove ${keyLabel(k)}`, () => {\n const next = { ...(isObject(opts.value) ? opts.value : {}) };\n delete next[k];\n commit(Object.keys(next).length > 0 ? next : undefined);\n })] : [];\n const gone = keyNodes !== undefined && o.adapter && nodeLabel(o.adapter, keyKind, k) === undefined ? `${k} is not here any more.` : undefined;\n child(`k:${k}`, asDecl(decl.of, k), value[k], (v) => {\n const next = { ...(isObject(opts.value) ? opts.value : {}) };\n next[k] = v === undefined ? defaultOf(decl.of as unknown as TypeDecl) : v;\n commit(next);\n }, remove, keyLabel(k), gone);\n }\n adder.replaceChildren();\n if (editable()) {\n const add = (k: string): void => {\n if (k === \"\" || Object.prototype.hasOwnProperty.call(value, k)) return;\n commit({ ...value, [k]: defaultOf(decl.of as unknown as TypeDecl) });\n };\n if (keyNodes !== undefined) {\n const pick = el(\"select\", \"field shell-valuerow-key\");\n const first = el(\"option\", undefined, \"Add...\"); first.value = \"\"; pick.append(first);\n for (const n of keyNodes.filter((n) => !Object.prototype.hasOwnProperty.call(value, n.id))) {\n const opt = el(\"option\", undefined, n.label); opt.value = n.id; pick.append(opt);\n }\n pick.addEventListener(\"change\", () => add(pick.value));\n adder.append(pick);\n } else {\n const input = el(\"input\", \"field shell-valuerow-key\");\n input.type = \"text\"; input.placeholder = \"New key\"; input.value = addKey;\n input.addEventListener(\"input\", () => { addKey = input.value; });\n const go = (): void => { const k = input.value.trim(); addKey = \"\"; add(k); };\n input.addEventListener(\"keydown\", (e) => { if ((e as KeyboardEvent).key === \"Enter\") go(); });\n adder.append(input, iconBtn(\"add\", \"Add\", go));\n }\n }\n } else if (decl.type === \"list\" && decl.of) {\n const value = Array.isArray(o.value) ? o.value : [];\n const idOf = (item: unknown, i: number): string =>\n decl.id !== undefined && isObject(item) && typeof item[decl.id] === \"string\" ? `id:${item[decl.id] as string}` : `i:${i}`;\n value.forEach((item, i) => {\n const set = (next: unknown[]): void => commit(next.length > 0 ? next : undefined);\n const controls = editable() ? [\n iconBtn(\"up\", \"Move up\", () => { const next = [...value]; if (moveItem(next, i, -1)) set(next); }, i === 0),\n iconBtn(\"down\", \"Move down\", () => { const next = [...value]; if (moveItem(next, i, 1)) set(next); }, i === value.length - 1),\n iconBtn(\"close\", \"Remove\", () => set(value.filter((_, j) => j !== i)), false, true),\n ] : [];\n const itemLabel = decl.id !== undefined && isObject(item) && typeof item[decl.id] === \"string\" ? item[decl.id] as string : `${i + 1}`;\n child(idOf(item, i), asDecl(decl.of!, itemLabel), item, (v) => {\n const next = [...(Array.isArray(opts.value) ? opts.value : [])];\n next[i] = v === undefined ? defaultOf(decl.of as unknown as TypeDecl) : v;\n set(next);\n }, controls, itemLabel);\n });\n adder.replaceChildren();\n if (editable()) {\n adder.append(iconBtn(\"add\", \"Add\", () => {\n const fresh = defaultOf(decl.of as unknown as TypeDecl);\n if (decl.id !== undefined && isObject(fresh)) {\n const taken = new Set(value.map((x) => (isObject(x) ? x[decl.id!] : undefined)));\n let n = value.length + 1;\n while (taken.has(`item-${n}`)) n++;\n fresh[decl.id] = `item-${n}`;\n }\n commit([...value, fresh]);\n }));\n }\n }\n\n for (const key of [...parts.keys()]) if (!used.has(key)) parts.delete(key);\n body.replaceChildren(...rows);\n if (decl.type !== \"record\" && editable()) body.append(adder);\n help.textContent = decl.help ?? decl.purpose ?? \"\";\n if (help.textContent !== \"\") body.append(help);\n const words = o.replaceProblem ?? [ownProblems(decl, o.value, o.adapter), o.problem ?? \"\"].filter((w) => w !== \"\").join(\" \");\n problem.textContent = words;\n problem.hidden = words === \"\";\n body.append(problem);\n row.classList.toggle(\"has-problem\", words !== \"\");\n for (const k of kept) fieldRowFocus.restore(k);\n };\n draw(initial);\n return { el: row, update: draw };\n}\n\n/** A cache of value rows for a host that redraws its whole view (as `fieldRows` is for the scalar row). */\nexport interface ValueRows {\n row(key: string, opts: ValueRowOptions): HTMLElement;\n sweep(): void;\n}\n\nexport function valueRows(): ValueRows {\n const rows = new Map<string, { handle: ValueRowHandle; type: string; used: boolean }>();\n return {\n row(key, opts) {\n const had = rows.get(key);\n if (had && had.type === opts.decl.type) {\n had.used = true;\n fieldRowFocus.settle(had.handle.el);\n had.handle.update(opts);\n fieldRowFocus.restore(had.handle.el);\n return had.handle.el;\n }\n const handle = valueRow(opts);\n rows.set(key, { handle, type: opts.decl.type, used: true });\n return handle.el;\n },\n sweep() {\n for (const [key, entry] of rows) { if (!entry.used) rows.delete(key); else entry.used = false; }\n },\n };\n}\n\n// An extension's section folded to the fields a node sets (value-fold.ts), under this entry so a host takes\n// the rows and the fold together.\nexport { isSet, extensionFold, foldCaption } from \"./value-fold.js\";\nexport type { ExtensionFold, FoldSectionOptions } from \"./value-fold.js\";\n"]}