@iasiv5/dsh-skills 1.3.7 → 1.3.8
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.
- package/package.json +1 -1
- package/skills/answer-me-with-html/SKILL.md +6 -4
- package/skills/answer-me-with-html/references/codebase.md +2 -2
- package/skills/answer-me-with-html/scripts/am.mjs +715 -309
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +3 -2
- package/skills/impeccable/SKILL.md +1 -1
- package/skills/impeccable/reference/audit.md +2 -2
- package/skills/impeccable/reference/critique.md +3 -3
- package/skills/impeccable/reference/generate.md +1 -1
- package/skills/impeccable/reference/init.md +0 -2
- package/skills/impeccable/reference/live.md +4 -2
- package/skills/impeccable/reference/new-work-comp.md +1 -1
- package/skills/impeccable/reference/new-work-world.md +1 -1
- package/skills/impeccable/scripts/VERSION +1 -1
- package/skills/impeccable/scripts/engine-checksums.txt +5 -5
- package/skills/impeccable/scripts/impeccable +28 -5
- package/skills/impeccable/scripts/impeccable.cmd +11 -2
- package/skills/impeccable/scripts/live-browser.js +10 -6
- package/skills/writing-plans/SKILL.md +1 -0
- package/skills/writing-plans/references/plan-self-review.md +4 -0
|
@@ -33,8 +33,8 @@ import { parseArgs } from "node:util";
|
|
|
33
33
|
import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync6, existsSync as existsSync8, rmSync as rmSync7, statSync as statSync7, chmodSync as chmodSync2, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
|
|
34
34
|
|
|
35
35
|
// src/assets.js
|
|
36
|
-
var VERSION = "0.6.
|
|
37
|
-
var BASE_CSS = `/* Answer me with HTML base \u2014 uses theme variables only, never hard-coded colors (theme tokens and decorations: themes
|
|
36
|
+
var VERSION = "0.6.4";
|
|
37
|
+
var BASE_CSS = `/* Answer me with HTML base \u2014 uses theme variables only, never hard-coded colors (theme tokens and decorations: themes/{name}.js). Exception: the var() fallbacks of diagrams (flow / sequence) equal the blueprint light tokens, guarded by a test. */
|
|
38
38
|
*, *::before, *::after { box-sizing: border-box; }
|
|
39
39
|
html, body { margin: 0; padding: 0; }
|
|
40
40
|
body {
|
|
@@ -73,6 +73,11 @@ code, pre, kbd { font-family: var(--font-mono); }
|
|
|
73
73
|
|
|
74
74
|
/* \u2500\u2500 Header \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
75
75
|
.am-head { margin: 0 0 20px; padding-inline-end: 300px; }
|
|
76
|
+
/* The toolbar is fixed over the top corner, wider than the 300px reserved here. With the page script (src/runtime/page.js) the header drops that
|
|
77
|
+
reservation and floats a spacer of the toolbar's measured size instead: only the lines beside the toolbar get shorter, so the colophon never
|
|
78
|
+
runs under it and a title below it keeps the whole width. Without the script the fixed reservation stays. */
|
|
79
|
+
.am-bar-fit .am-head { padding-inline-end: 0; }
|
|
80
|
+
.am-bar-fit .am-head::before { content: ""; float: inline-end; width: var(--am-bar-w, 0px); height: var(--am-bar-h, 0px); }
|
|
76
81
|
.am-head h1 { margin: 0; font-size: var(--am-fs-title); line-height: 1.25; letter-spacing: -0.01em; }
|
|
77
82
|
.am-sub { margin: 4px 0 0; color: var(--ink-2); }
|
|
78
83
|
.am-head-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: var(--am-fs-small); color: var(--ink-2); }
|
|
@@ -387,6 +392,9 @@ body.am-has-reply-bar { padding-block-end: 72px; }
|
|
|
387
392
|
border: var(--node-width, var(--bw)) solid var(--node-stroke, var(--line)); background: var(--node-fill, var(--paper)); padding: 6px 14px; text-align: center;
|
|
388
393
|
border-radius: var(--node-radius, var(--radius)); font-weight: 600; color: var(--node-text, inherit); filter: var(--node-shadow, none);
|
|
389
394
|
}
|
|
395
|
+
/* A word longer than its column (an IP, an email, a hash) breaks instead of running over the next column. anywhere, not break-word,
|
|
396
|
+
so the column's min-content width shrinks too; the wbr breaks that tree.js adds still give the preferred break points. */
|
|
397
|
+
.am-tree-box, .am-tree-list li { overflow-wrap: anywhere; }
|
|
390
398
|
.am-tree-box small { display: block; font-weight: 400; color: var(--ink-2); font-size: var(--am-fs-small); }
|
|
391
399
|
/* The root box and a highlighted box are emphasis: they take the highlight tokens. With none set the root box keeps its accent tint and a highlighted box looks like any other. */
|
|
392
400
|
.am-tree-box--root, .am-tree-box--hi { border-color: var(--hi-stroke, var(--node-stroke, var(--line))); color: var(--hi-text, var(--node-text, inherit)); }
|
|
@@ -627,6 +635,7 @@ body.am-has-reply-bar { padding-block-end: 72px; }
|
|
|
627
635
|
.am-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
628
636
|
.am-grid > .am-panel { grid-column: auto !important; }
|
|
629
637
|
.am-grid > .am-panel.am-span-wide { grid-column: 1 / -1 !important; }
|
|
638
|
+
.am-grid.am-grid--single { grid-template-columns: minmax(0, 1fr); } /* cols: 1 stays one column */
|
|
630
639
|
}
|
|
631
640
|
@media (max-width: 760px) {
|
|
632
641
|
.am-sheet, .am-doc { padding: 56px 12px 24px; }
|
|
@@ -637,6 +646,7 @@ body.am-has-reply-bar { padding-block-end: 72px; }
|
|
|
637
646
|
.am-toolbar > * { flex: none; }
|
|
638
647
|
.am-toolbar .am-btn:focus-visible, .am-toolbar .am-pick:focus-within { outline-offset: -2px; }
|
|
639
648
|
.am-head { padding-inline-end: 0; }
|
|
649
|
+
.am-bar-fit .am-head::before { display: none; }
|
|
640
650
|
.am-grid { grid-template-columns: minmax(0, 1fr); }
|
|
641
651
|
.am-grid > .am-panel.am-span-wide { grid-column: auto !important; }
|
|
642
652
|
/* The rail hugs the viewport edge inside a strip of its own, so it never covers text and never pushes the body down. */
|
|
@@ -682,6 +692,7 @@ body.am-has-reply-bar { padding-block-end: 72px; }
|
|
|
682
692
|
@media print {
|
|
683
693
|
.am-toolbar, .am-diagram-expand, .am-lightbox, .am-code-copy, .am-toc, .am-comment-btn, .am-comment, .am-reply, .am-reply-bar { display: none !important; }
|
|
684
694
|
.am-btn--export, .am-export { display: none !important; }
|
|
695
|
+
.am-bar-fit .am-head::before { display: none; }
|
|
685
696
|
body { background: var(--paper); }
|
|
686
697
|
.am-panel { break-inside: avoid; box-shadow: none; }
|
|
687
698
|
/* Paper does not scroll: a diagram shrinks to the page again (also below the phone breakpoint, whose rule lifts max-width), and nothing fades. */
|
|
@@ -738,7 +749,7 @@ table.am-mark { background: none; }
|
|
|
738
749
|
.am-remark-kind::before { content: attr(data-n); margin-inline-end: 5px; color: var(--ink-3); font-family: var(--font-mono); font-size: var(--am-fs-label); }
|
|
739
750
|
@media print { .am-remark-pop { display: none !important; } }
|
|
740
751
|
`;
|
|
741
|
-
var RUNTIME_JS = "(() => {\n// How a formula reads in a quote. MathML has no plain text, so src/math.js writes the formula as the draft wrote it, delimiters included, in\n// data-am-tex on the <math> element, and the Remark and Reply scripts read page text through this file. On a page without math there is no\n// such element, so formulaOf is null and every text comes out as it did before.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped (src/runtime/compose.js).\n\nconst TEX = 'data-am-tex';\n\n// The formula that holds a node, or null.\nconst formulaOf = (node) => node.parentElement?.closest(`[${TEX}]`) ?? null;\n\nconst firstText = (el) => {\n for (const child of el.childNodes) {\n const found = child.nodeType === 3 ? child : firstText(child);\n if (found) return found;\n }\n return null;\n};\n\n// What a text node adds to a quote: its data. The first text node of a formula adds the formula, and the others add nothing.\n// (A formula in an error style is plain text with its delimiters, not a <math>, so it comes out once.)\nfunction nodeText(node) {\n const math = formulaOf(node);\n if (!math) return node.data;\n return firstText(math) === node ? math.getAttribute(TEX) : '';\n}\n\n// The text of a node as textContent reads it, but with each formula as written.\nconst textWithMath = (node) => (node.nodeType === 3 ? nodeText(node) : [...node.childNodes].map(textWithMath).join(''));\n\n(() => {\n const root = document.documentElement;\n // A host that serves this page inside its own document leaves the real root without the page's settings. The toolbar keeps a copy;\n // set back what the root lacks, before anything below reads the root. A root's own value, even an empty one, is kept, except a\n // theme or mode that no toolbar option names: that is the host's own setting (the Claude desktop app sets data-theme=\"dark\"), and\n // keeping it would leave the page unstyled.\n const carrier = document.querySelector('.am-toolbar');\n const listFor = { 'data-theme': 'theme', 'data-mode': 'mode' };\n const foreign = (attr, value) => {\n const options = listFor[attr] && document.querySelector(`select[data-am=\"${listFor[attr]}\"]`)?.options;\n return Boolean(value) && options != null && ![...options].some((o) => o.value === value);\n };\n for (const [attr, key] of [['lang', 'data-am-root-lang'], ['dir', 'data-am-root-dir'], ['data-theme', 'data-am-root-theme'], ['data-mode', 'data-am-root-mode'], ['data-style', 'data-am-root-style']]) {\n const own = root.getAttribute(attr);\n if ((own === null || foreign(attr, own)) && carrier?.getAttribute(key) != null) root.setAttribute(attr, carrier.getAttribute(key));\n }\n // Each toolbar list sets one root attribute; its options name the values, so the runtime names no theme or mode.\n for (const [name, attr] of [['theme', 'data-theme'], ['mode', 'data-mode']]) {\n const select = document.querySelector(`select[data-am=\"${name}\"]`);\n if (!select) continue;\n select.value = root.getAttribute(attr);\n select.addEventListener('change', () => root.setAttribute(attr, select.value));\n }\n\n // \u2500\u2500 Text size \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // A\u2212 / A+ set --am-scale on the root; every page size and line (src/themes/type-scale.js) follows it, and the drawing boxes grow\n // with it while their viewBox keeps the units Node measured. The buttons carry the range from SCALE, so this script keeps no\n // second copy of the numbers. A reader's choice is remembered in this browser and wins over the page's own scale; where storage\n // is off (am serve, file://) it lasts for this tab, and the click still works.\n const scaleDown = document.querySelector('[data-am=\"scale-down\"]');\n const scaleUp = document.querySelector('[data-am=\"scale-up\"]');\n if (scaleDown && scaleUp) {\n const min = Number(scaleDown.dataset.min);\n const max = Number(scaleDown.dataset.max);\n const step = Number(scaleDown.dataset.step);\n const storeKey = 'am-scale';\n let value;\n\n const inRange = (n) => Number.isFinite(n) && n >= min && n <= max;\n const savedScale = () => {\n try {\n return Number(localStorage.getItem(storeKey));\n } catch {\n return NaN;\n }\n };\n const saveScale = (n) => {\n try {\n localStorage.setItem(storeKey, String(n));\n } catch {\n // Storage may be off (am serve, file://); the size then lasts until the tab closes.\n }\n };\n\n const updateButtons = () => {\n const setUnavailable = (btn, unavailable) => {\n if (unavailable) btn.setAttribute('aria-disabled', 'true');\n else btn.removeAttribute('aria-disabled');\n };\n setUnavailable(scaleDown, value <= min);\n setUnavailable(scaleUp, value >= max);\n };\n\n // One step is a multiple of `step`: Math.round first, then two decimals, so 1.1500000000000001 becomes 1.15.\n const setScale = (next, remember = false) => {\n value = Math.min(max, Math.max(min, Number((Math.round(next / step) * step).toFixed(2))));\n root.style.setProperty('--am-scale', String(value));\n for (const svg of document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas) > svg[role=\"img\"]')) {\n const box = svg.viewBox?.baseVal;\n if (!box || !(box.width > 0) || !(box.height > 0)) continue;\n svg.setAttribute('width', String(Math.ceil(box.width * value)));\n svg.setAttribute('height', String(Math.ceil(box.height * value)));\n }\n updateButtons();\n if (remember) saveScale(value);\n window.dispatchEvent(new Event('am-scale'));\n };\n\n // A page with no stored choice is left exactly as it was rendered: no inline variable, no svg rewrite, no extra layout pass.\n value = parseFloat(getComputedStyle(root).getPropertyValue('--am-scale')) || 1;\n updateButtons();\n const saved = savedScale();\n if (inRange(saved) && saved !== value) setScale(saved);\n scaleDown.hidden = false;\n scaleUp.hidden = false;\n scaleDown.addEventListener('click', () => {\n if (scaleDown.getAttribute('aria-disabled') === 'true') return;\n setScale(value - step, true);\n });\n scaleUp.addEventListener('click', () => {\n if (scaleUp.getAttribute('aria-disabled') === 'true') return;\n setScale(value + step, true);\n });\n }\n\n // A phone cannot show the whole toolbar. Its end (Reply, Remark, Copy source) is what a phone showed before the text-size\n // buttons, so open at that end: Theme, Mode and A\u2212 / A+ are reached by scrolling toward the start. A reader scroll leaves the\n // position we set, so a later resize does not pull the toolbar back.\n if (carrier) {\n const rtl = getComputedStyle(carrier).direction === 'rtl';\n let lastProgrammatic = null;\n let readerScrolled = false;\n const scrollToEnd = () => {\n if (carrier.scrollWidth <= carrier.clientWidth) return;\n // Chrome keeps a right-to-left box's scrollLeft negative; the browser clamps either value to the real end.\n carrier.scrollTo({ left: rtl ? -carrier.scrollWidth : carrier.scrollWidth });\n lastProgrammatic = carrier.scrollLeft;\n };\n carrier.addEventListener('scroll', () => {\n if (Math.abs(carrier.scrollLeft - lastProgrammatic) > 1) readerScrolled = true;\n });\n scrollToEnd();\n addEventListener('resize', () => {\n if (!readerScrolled) scrollToEnd();\n });\n }\n\n const copyText = async (text) => {\n try {\n await navigator.clipboard.writeText(text);\n } catch {\n const ta = Object.assign(document.createElement('textarea'), { value: text });\n document.body.append(ta);\n ta.select();\n document.execCommand('copy');\n ta.remove();\n }\n };\n // A button reads its label from data-done for a moment after a copy, then comes back to the label it started from. That label is\n // read once, here: a second click inside the moment would otherwise read the copied label off the button and restore that instead,\n // and the label would never come back. The moment starts again on each click: the timer of the previous one is left to fire and\n // does nothing (a token, so this needs no timer bookkeeping the page scripts do not already have).\n const flasher = (btn) => {\n const idle = btn.textContent;\n let clicks = 0;\n return () => {\n btn.textContent = btn.dataset.done;\n const mine = ++clicks;\n setTimeout(() => { if (mine === clicks) btn.textContent = idle; }, 1400);\n };\n };\n\n const copyBtn = document.querySelector('[data-am=\"copy\"]');\n if (copyBtn) {\n const flash = flasher(copyBtn);\n copyBtn.addEventListener('click', async () => {\n const nodes = document.querySelectorAll('#am-source');\n await copyText(nodes[nodes.length - 1]?.value ?? '');\n flash();\n });\n }\n\n // Each code block copies its own lines, without the line numbers.\n for (const btn of document.querySelectorAll('[data-am=\"copy-code\"]')) {\n const flash = flasher(btn);\n btn.addEventListener('click', async () => {\n const lines = btn.closest('.am-codeblock')?.querySelectorAll('.am-ln') ?? [];\n await copyText([...lines].map((l) => l.textContent).join('\\n'));\n flash();\n });\n }\n\n // \u2500\u2500 Sideways scroll cue \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Overlay scrollbars (macOS) show nothing until the reader scrolls, so a wide code block or diagram looked cut off. While a box\n // hides content past its left or right edge it carries am-more-left / am-more-right, and base.css fades that edge. The sides are\n // physical because a box can read in the other direction than the page (code stays left to right on a right-to-left page); there\n // scrollLeft counts down from 0, so the hidden amounts use its size.\n const scrollers = document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas), .am-code, .am-annot-scroll');\n const markMore = (el) => {\n const hidden = el.scrollWidth - el.clientWidth;\n let left = false;\n let right = false;\n if (hidden > 1) {\n const atStart = Math.abs(el.scrollLeft);\n const rtl = getComputedStyle(el).direction === 'rtl';\n [left, right] = rtl ? [atStart < hidden - 1, atStart > 1] : [atStart > 1, atStart < hidden - 1];\n }\n el.classList.toggle('am-more-left', left);\n el.classList.toggle('am-more-right', right);\n };\n if (scrollers.length) {\n const resized = typeof ResizeObserver === 'function' ? new ResizeObserver((entries) => entries.forEach((e) => markMore(e.target))) : null;\n for (const el of scrollers) {\n el.addEventListener('scroll', () => markMore(el), { passive: true });\n resized?.observe(el);\n markMore(el);\n }\n }\n\n // \u2500\u2500 Diagram Lightbox & Pan-Zoom Viewer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const diagrams = document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas)');\n const lb = document.querySelector('.am-lightbox');\n if (diagrams.length && lb) {\n const backdrop = lb.querySelector('.am-lightbox-backdrop');\n const titleText = lb.querySelector('.am-lightbox-title-text');\n const stage = lb.querySelector('.am-lightbox-stage');\n const canvas = lb.querySelector('.am-lightbox-canvas');\n const closeBtn = lb.querySelector('.am-lightbox-close');\n const expandLabel = lb.getAttribute('data-expand') || 'Expand diagram';\n\n let scale = 1, x = 0, y = 0, fitScale = 1, curVw = 800, curVh = 600;\n let isDragging = false, activePointerId = null, startX = 0, startY = 0, origX = 0, origY = 0;\n let lastTrigger = null;\n\n const apply = () => {\n canvas.style.transform = `translate3d(${x.toFixed(2)}px, ${y.toFixed(2)}px, 0) scale(${scale.toFixed(4)})`;\n };\n\n const zoomTo = (newScale, pivotX, pivotY) => {\n newScale = Math.max(0.2, Math.min(6.0, newScale));\n if (Math.abs(newScale - scale) < 0.0001) return;\n const r = newScale / scale;\n x = pivotX - (pivotX - x) * r;\n y = pivotY - (pivotY - y) * r;\n scale = newScale;\n apply();\n };\n\n const open = (diag, trigger) => {\n const svg = [...diag.children].find((el) => el.tagName.toLowerCase() === 'svg');\n if (!svg) return;\n lastTrigger = trigger;\n\n const panel = diag.closest('.am-panel');\n const panelTitle = panel?.querySelector('.am-panel-head h2')?.textContent?.trim() || panel?.querySelector('h2')?.textContent?.trim() || lb.getAttribute('aria-label') || 'Diagram viewer';\n if (titleText) titleText.textContent = panelTitle;\n\n const clone = svg.cloneNode(true);\n const defElements = clone.querySelectorAll('[id]');\n if (defElements.length) {\n const idMap = new Map();\n defElements.forEach((el, i) => {\n const oldId = el.id;\n const newId = `${oldId}-lb-${i}`;\n idMap.set(oldId, newId);\n el.id = newId;\n });\n const urlAttrs = ['marker-start', 'marker-mid', 'marker-end', 'fill', 'stroke', 'filter', 'clip-path', 'mask'];\n clone.querySelectorAll('*').forEach((el) => {\n for (const attr of urlAttrs) {\n const val = el.getAttribute(attr);\n if (val && val.startsWith('url(#')) {\n const id = val.slice(5, -1);\n if (idMap.has(id)) el.setAttribute(attr, `url(#${idMap.get(id)})`);\n }\n }\n const href = el.getAttribute('href') || el.getAttribute('xlink:href');\n if (href && href.startsWith('#')) {\n const id = href.slice(1);\n if (idMap.has(id)) {\n if (el.hasAttribute('href')) el.setAttribute('href', `#${idMap.get(id)}`);\n if (el.hasAttribute('xlink:href')) el.setAttribute('xlink:href', `#${idMap.get(id)}`);\n }\n }\n });\n }\n\n const vb = svg.viewBox?.baseVal;\n curVw = (vb && vb.width > 0) ? vb.width : (parseFloat(svg.getAttribute('width')) || svg.clientWidth || 800);\n curVh = (vb && vb.height > 0) ? vb.height : (parseFloat(svg.getAttribute('height')) || svg.clientHeight || 600);\n // The panel's svg carries the reading floor as min-width (layout-dom.js floorDiagrams); the viewer sizes the clone itself.\n clone.style.minWidth = '';\n clone.style.width = `${curVw}px`;\n clone.style.height = `${curVh}px`;\n canvas.innerHTML = '';\n canvas.append(clone);\n lb.removeAttribute('hidden');\n document.body.style.overflow = 'hidden';\n\n const rect = stage.getBoundingClientRect();\n const pad = 48;\n const availW = Math.max(100, rect.width - pad * 2);\n const availH = Math.max(100, rect.height - pad * 2);\n fitScale = Math.min(availW / curVw, availH / curVh, 1.0);\n scale = fitScale;\n x = (rect.width - curVw * scale) / 2;\n y = (rect.height - curVh * scale) / 2;\n apply();\n closeBtn.focus();\n };\n\n const close = () => {\n if (lb.hasAttribute('hidden')) return;\n lb.setAttribute('hidden', '');\n canvas.innerHTML = '';\n document.body.style.overflow = '';\n lastTrigger?.focus();\n };\n\n stage.addEventListener('wheel', (e) => {\n e.preventDefault();\n const rect = stage.getBoundingClientRect();\n const dy = e.deltaMode === 1 ? e.deltaY * 16 : (e.deltaMode === 2 ? e.deltaY * 400 : e.deltaY);\n const factor = Math.exp(-Math.max(-200, Math.min(200, dy)) * 0.0015);\n zoomTo(scale * factor, e.clientX - rect.left, e.clientY - rect.top);\n }, { passive: false });\n\n stage.addEventListener('pointerdown', (e) => {\n if (e.button !== 0 || isDragging) return;\n isDragging = true;\n activePointerId = e.pointerId;\n startX = e.clientX;\n startY = e.clientY;\n origX = x;\n origY = y;\n stage.setPointerCapture(e.pointerId);\n stage.classList.add('am-panning');\n });\n\n stage.addEventListener('pointermove', (e) => {\n if (!isDragging || e.pointerId !== activePointerId) return;\n x = origX + (e.clientX - startX);\n y = origY + (e.clientY - startY);\n apply();\n });\n\n const endDrag = (e) => {\n if (!isDragging || e.pointerId !== activePointerId) return;\n isDragging = false;\n activePointerId = null;\n stage.classList.remove('am-panning');\n try { stage.releasePointerCapture(e.pointerId); } catch {}\n };\n stage.addEventListener('pointerup', endDrag);\n stage.addEventListener('pointercancel', endDrag);\n\n stage.addEventListener('dblclick', () => {\n const rect = stage.getBoundingClientRect();\n scale = fitScale;\n x = (rect.width - curVw * scale) / 2;\n y = (rect.height - curVh * scale) / 2;\n apply();\n });\n\n closeBtn.addEventListener('click', close);\n backdrop.addEventListener('click', close);\n window.addEventListener('keydown', (e) => {\n if (e.key === 'Escape' && !lb.hasAttribute('hidden')) close();\n });\n\n lb.addEventListener('keydown', (e) => {\n if (e.key !== 'Tab') return;\n const focusables = lb.querySelectorAll('button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])');\n if (!focusables.length) return;\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n });\n\n const expandSvg = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><polyline points=\"15 3 21 3 21 9\"></polyline><polyline points=\"9 21 3 21 3 15\"></polyline><line x1=\"21\" y1=\"3\" x2=\"14\" y2=\"10\"></line><line x1=\"3\" y1=\"21\" x2=\"10\" y2=\"14\"></line></svg>';\n diagrams.forEach((diag) => {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = 'am-diagram-expand';\n btn.title = expandLabel;\n btn.setAttribute('aria-label', expandLabel);\n btn.innerHTML = expandSvg;\n btn.addEventListener('click', () => open(diag, btn));\n diag.prepend(btn);\n });\n }\n})();\n(() => {\n// The reply a reader copies from the page: one Markdown text with the decisions, the panel comments and the block remarks.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped (src/runtime/compose.js).\n// decisions: [{ panel, question, picked: [label], suggested: [label], touched }]; comments: [{ panel, title, text }];\n// remarks: [{ panel, quote, kind, note }], where quote is the start of the marked block and kind is a key of ui.kinds.\n// Comment and remark text is quoted line by line, so text the reader typed cannot pass as part of the structure.\n// rtl: the page reads right to left, so the arrow before each answer points left, the way the text runs.\nfunction replyText({ title, decisions, comments, remarks = [], ui, rtl = false }) {\n const arrow = rtl ? '\u2190' : '\u2192';\n const out = [`# Re: ${title}`];\n if (decisions.length) {\n out.push('', `## ${ui.decisions}`);\n decisions.forEach((d, i) => {\n const answer = d.picked.length ? d.picked.map((l) => `**${l}**`).join(', ') : '**\u2014**';\n // Every option starts unselected, so an ask the reader never clicked has no answer: the reply names the suggestion\n // instead of passing it off as the reader's choice.\n const same = d.picked.length === d.suggested.length && d.picked.every((l) => d.suggested.includes(l));\n const suggested = d.suggested.join(', ') || '\u2014';\n const why = !d.touched ? `${ui.untouched}: ${suggested}` : same ? ui.confirmed : `${ui.was}: ${suggested}`;\n out.push(`${i + 1}. [${d.panel}] ${d.question}`, ` ${arrow} ${answer} _(${why})_`);\n });\n }\n const written = comments.filter((c) => c.text.trim());\n const quoted = (text) => (text.trim() ? text.trim().split('\\n').map((l) => ` > ${l}`) : []);\n if (written.length) {\n out.push('', `## ${ui.comments}`);\n for (const c of written) out.push(`- **${c.panel} \xB7 ${c.title}**`, ...quoted(c.text));\n }\n if (remarks.length) {\n out.push('', `## ${ui.remarks}`);\n for (const r of remarks) {\n const label = [r.panel, ui.kinds?.[r.kind] ?? r.kind].filter(Boolean).join(' \xB7 ');\n out.push(`- **${label}** \"${r.quote}\"`, ...quoted(r.note));\n }\n }\n if (written.length || remarks.some((r) => r.note.trim())) out.push('', `_${ui.typed}_`);\n return `${out.join('\\n')}\\n`;\n}\n\n// A letter of a right-to-left script. One definition for the page builder (src/bidi.js) and for the right-to-left page script\n// (src/runtime/reply-view.js), so the two cannot drift apart. A plain ES module; the page script gets this file in front of\n// reply-view.js, with its `export` keyword dropped and reply-view.js's import of it removed (src/runtime/compose.js).\nconst RTL_LETTER = /[\\p{Script=Hebrew}\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Thaana}\\p{Script=Nko}\\p{Script=Samaritan}\\p{Script=Mandaic}]/u;\n\n// The reply as the reader sees it in the Reply sheet (src/runtime/reply.js): the Markdown that Copy copies, drawn as headings, bold answers\n// and quoted comments instead of raw \"# Re: ...\", \"1. [E] ...\" and \"- **A \xB7 ...**\" lines. Each line gets its own direction, so a\n// Hebrew reader sees Latin answers and paths in place; a line with no right-to-left letter reads left to right, as on any other page.\n// The raw Markdown stays in the sheet under a fold, so the copied text does not change.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped and rtl-letter.js in front of it in place of the\n// import (src/runtime/compose.js).\n\nconst escHtml = (s) => s.replace(/[&<>\"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '\"': '"' })[c]);\n// A line with a right-to-left letter reads right to left; a line without one (an English comment, a path) reads left to right.\nconst dirOf = (s) => (RTL_LETTER.test(s) ? 'rtl' : 'ltr');\n\n// The only inline Markdown src/runtime/reply-text.js writes: **answer**, _(note)_ and the \"quote\" of a remark. Each piece is isolated in its own direction,\n// so a Latin answer inside a Hebrew line keeps its place, and \"A \xB7 title\" still starts with the panel letter.\nconst piece = (tag, text) => `<${tag}><bdi dir=\"${dirOf(text)}\">${text}</bdi></${tag}>`;\nfunction inline(s) {\n return escHtml(s)\n .replace(/\\*\\*(.+?)\\*\\*/g, (_, t) => piece('strong', t))\n .replace(/(^|\\s)_(.+?)_(?=\\s|$)/g, (_, pre, t) => pre + piece('em', t))\n // The quoted start of a marked block (\"- **A \xB7 concern** \"text\"\"): isolated, so Latin text in a Hebrew line keeps its place.\n .replace(/"(.+)"$/, (_, t) => `"<bdi dir=\"${dirOf(t)}\">${t}</bdi>"`);\n}\n\n// The reply text (src/runtime/reply-text.js) as HTML, one block per line.\nfunction replyViewHtml(text) {\n return text\n .replace(/\\n$/, '')\n .split('\\n')\n .map((line) => {\n const dir = dirOf(line);\n let m;\n if (!line.trim()) return '<div class=\"am-rv-gap\"></div>';\n if ((m = line.match(/^(#{1,2}) (.*)$/))) return `<div class=\"am-rv-h${m[1].length}\" dir=\"${dir}\">${inline(m[2])}</div>`;\n if ((m = line.match(/^(\\d+)\\. \\[([^\\]]*)\\] (.*)$/))) {\n return `<div class=\"am-rv-q\" dir=\"${dir}\"><bdi>${m[1]}.</bdi> <bdi class=\"am-rv-tag\">${escHtml(m[2])}</bdi> ${inline(m[3])}</div>`;\n }\n if ((m = line.match(/^ {3}([\u2190\u2192]) (.*)$/))) return `<div class=\"am-rv-a\" dir=\"${dir}\">${m[1]} ${inline(m[2])}</div>`;\n if ((m = line.match(/^- (.*)$/))) return `<div class=\"am-rv-c\" dir=\"${dir}\">${inline(m[1])}</div>`;\n // A comment line is shown exactly as the reader typed it.\n if ((m = line.match(/^ {2}> ?(.*)$/))) return `<div class=\"am-rv-quote\" dir=\"${dirOf(m[1])}\">${escHtml(m[1]) || ' '}</div>`;\n return `<div dir=\"${dir}\">${inline(line)}</div>`;\n })\n .join('');\n}\n\n// Answer on the page: every panel gets a Comment box, and the Reply button collects the ask answers, the comments and the remarks\n// into one Markdown reply (replyText) to copy back to the agent. Answers and comments stay in localStorage across reloads.\n// The remark script (remark.js) adds the blocks the reader marked, through window.__amRemarkData, and tells this script about a change\n// with an \"am-remark-change\" event on the document.\n// The Reply sheet shows the reply drawn (replyViewHtml) with the Markdown that Copy copies under a fold. Once the reader has given any\n// input, a bar at the bottom of the page shows the counts and copies the reply in one click, so there is no trip to the top-right button.\nconst replyBtn = document.querySelector('[data-am=\"reply\"]');\nconst COMMENT_ICON = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"></path></svg>';\nif (replyBtn) {\n const ui = JSON.parse(replyBtn.dataset.ui);\n const storeKey = `am-reply:${location.pathname}`;\n // A page served by `am serve` runs without localStorage and the phone may discard its tab, so it keeps the answers on the\n // server: data-am-save names the write route and data-am-state carries what the server already holds for this page version.\n const serve = (() => {\n const { amSave: save, amState: state } = document.body?.dataset ?? {};\n if (!save) return null;\n try {\n return { save, restored: state ? JSON.parse(state) : null };\n } catch {\n return { save, restored: null };\n }\n })();\n let saveTimer = null;\n let pendingPatch = null;\n const sendSave = (patch) => {\n fetch(serve.save, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(patch), keepalive: true })\n .catch(() => {}); // a page that cannot reach the server keeps its state until it closes, as before\n };\n // Typing must not put one request per keystroke on the server; localStorage is written at once, the network follows.\n const saveSoon = (patch) => {\n clearTimeout(saveTimer);\n pendingPatch = patch;\n saveTimer = setTimeout(() => {\n pendingPatch = null;\n sendSave(patch);\n }, 400);\n };\n // A hidden or closing page sends the change it still holds, before the timer can run.\n const flushSave = () => {\n if (!pendingPatch) return;\n clearTimeout(saveTimer);\n sendSave(pendingPatch);\n pendingPatch = null;\n };\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') flushSave();\n });\n window.addEventListener('pagehide', flushSave);\n // A preview may draw a mock panel; it gets no comment box and cannot shadow the real panel's id.\n const panels = [...document.querySelectorAll('.am-panel')].filter((panel) => !panel.closest('.am-ask-preview'));\n // An ask inside a preview is part of the drawing, not a decision of the page.\n const asks = [...document.querySelectorAll('.am-ask')].filter((a) => !a.closest('.am-ask-preview'));\n // Answers are saved by question text, so they still match after am patch has renumbered the asks.\n // Page text without the word joiners a right-to-left page puts after a Hebrew prefix hyphen (src/bidi.js): the reply and the saved\n // answers hold the text as the draft wrote it, a formula too (src/runtime/math-text.js).\n const WJ = new RegExp(String.fromCharCode(0x2060), 'g');\n const textOf = (el) => el && textWithMath(el).replace(WJ, '').trim();\n const keyOf = (ask) => textOf(ask.querySelector('legend')) ?? ask.dataset.ask;\n const touched = new Set();\n const boxes = new Map();\n // The bar is built below with the sheet; the handlers that change the counts only call this.\n let refreshBar = () => {};\n // The textarea a failed copy keeps selected, so the reader can still use the keyboard shortcut.\n let stuck = null;\n\n const load = () => {\n if (serve?.restored?.reply) return serve.restored.reply;\n try {\n return JSON.parse(localStorage.getItem(storeKey)) || {};\n } catch {\n return {};\n }\n };\n const save = () => {\n const state = {\n asks: Object.fromEntries(asks.map((a) => [keyOf(a), { picked: picked(a), touched: touched.has(a) }])),\n comments: Object.fromEntries([...boxes].map(([id, box]) => [id, box.value]).filter(([, text]) => text.trim())),\n };\n try {\n localStorage.setItem(storeKey, JSON.stringify(state));\n } catch {\n // Storage may be off (private window, file:// policy); answers then last until the page closes.\n }\n if (serve) saveSoon({ reply: state });\n };\n // A preview can hold a mock form; those controls are a picture, not the reader's answer.\n const inputsOf = (ask) => [...ask.querySelectorAll('input')].filter((i) => !i.closest('.am-ask-preview'));\n const picked = (ask) => inputsOf(ask).filter((i) => i.checked).map((i) => i.value);\n const panelOf = (el) => {\n const panel = el.closest('.am-panel');\n return { id: panel?.id.replace(/^panel-/, '') ?? '', title: textOf(panel?.querySelector('.am-panel-head h2')) ?? '' };\n };\n\n const saved = load();\n for (const ask of asks) {\n const inputs = inputsOf(ask);\n const state = saved.asks?.[keyOf(ask)];\n // A saved answer applies only while every picked option still exists on the page, and only if the reader clicked: older versions started\n // with the suggestion selected and saved it untouched, and that state must come back unselected.\n if (state?.touched && Array.isArray(state.picked) && state.picked.every((v) => inputs.some((i) => i.value === v))) {\n for (const input of inputs) input.checked = state.picked.includes(input.value);\n touched.add(ask);\n }\n // A click counts even on the option that is already picked: the reader confirms the suggestion.\n const answer = (e) => {\n if (e?.target?.closest?.('.am-ask-preview')) return;\n touched.add(ask);\n save();\n refreshBar();\n };\n ask.addEventListener('change', answer);\n ask.addEventListener('click', (e) => { if (e.target.matches('input')) answer(e); });\n // In cards the whole card looks clickable, so a click on its preview picks the option too. A control in the drawing is not the answer.\n ask.addEventListener('click', (e) => {\n if (!ask.classList.contains('am-ask--cards')) return;\n if (!e.target.closest?.('.am-ask-preview') || e.target.closest('input, button, a, select, textarea, summary, label')) return;\n const input = e.target.closest('.am-ask-card')?.querySelector('input');\n if (!input) return;\n const wasPicked = input.checked;\n input.click();\n // A radio that is already on sends no change event, and the click still confirms the suggestion.\n if (wasPicked && input.type === 'radio') answer();\n });\n }\n\n for (const panel of panels) {\n const id = panel.id.replace(/^panel-/, '');\n // An icon only: narrow panels have no room for a word next to the title.\n const btn = Object.assign(document.createElement('button'), { type: 'button', className: 'am-comment-btn', title: ui.comment, innerHTML: COMMENT_ICON });\n btn.setAttribute('aria-label', `${ui.comment} ${id}`);\n btn.setAttribute('aria-expanded', 'false');\n const wrap = Object.assign(document.createElement('div'), { className: 'am-comment', hidden: true });\n const box = Object.assign(document.createElement('textarea'), { rows: 3, placeholder: ui.commentHint, value: saved.comments?.[id] ?? '' });\n box.setAttribute('aria-label', `${ui.comment} ${id}`);\n wrap.append(box);\n const show = (open) => {\n wrap.hidden = !open;\n btn.setAttribute('aria-expanded', String(open));\n };\n btn.addEventListener('click', () => {\n show(wrap.hidden);\n if (!wrap.hidden) box.focus();\n });\n box.addEventListener('input', () => {\n btn.classList.toggle('am-comment-btn--on', Boolean(box.value.trim()));\n save();\n refreshBar();\n });\n btn.classList.toggle('am-comment-btn--on', Boolean(box.value.trim()));\n if (box.value.trim()) show(true);\n (panel.querySelector('.am-panel-head') ?? panel).append(btn);\n panel.append(wrap);\n boxes.set(id, box);\n }\n\n const sheet = document.createElement('dialog');\n sheet.className = 'am-reply';\n sheet.setAttribute('aria-label', ui.title);\n sheet.innerHTML = '<div class=\"am-reply-head\"><strong></strong><span></span></div><div class=\"am-reply-view\" tabindex=\"0\"></div><details class=\"am-reply-raw\"><summary></summary><textarea readonly rows=\"10\"></textarea></details><div class=\"am-reply-actions\"><button type=\"button\" class=\"am-btn\" data-act=\"copy\"></button><button type=\"button\" class=\"am-btn\" data-act=\"close\"></button></div>';\n sheet.querySelector('strong').textContent = ui.title;\n sheet.querySelector('span').textContent = ui.hint;\n sheet.querySelector('summary').textContent = ui.raw;\n const view = sheet.querySelector('.am-reply-view');\n const raw = sheet.querySelector('details');\n const text = sheet.querySelector('textarea');\n const copy = sheet.querySelector('[data-act=\"copy\"]');\n const close = sheet.querySelector('[data-act=\"close\"]');\n copy.textContent = ui.copy;\n close.textContent = ui.close;\n document.body.append(sheet);\n\n const compose = () => {\n const decisions = asks.map((ask) => ({\n panel: panelOf(ask).id,\n question: textOf(ask.querySelector('legend')) ?? '',\n picked: picked(ask),\n suggested: inputsOf(ask).filter((i) => i.hasAttribute('data-suggested')).map((i) => i.value),\n touched: touched.has(ask),\n }));\n const comments = [...boxes].map(([id, box]) => ({ panel: id, title: panelOf(box).title, text: box.value }));\n const remarks = window.__amRemarkData?.() ?? [];\n const empty = !decisions.length && !comments.some((c) => c.text.trim()) && !remarks.length;\n const title = textOf(document.querySelector('.am-head h1')) ?? document.title;\n return empty ? '' : replyText({ title, decisions, comments, remarks, ui, rtl: document.documentElement.dir === 'rtl' });\n };\n\n // The text goes through the clipboard API; a page the browser treats as insecure (file://) falls back to selecting a temporary\n // textarea, because the sheet's own textarea can sit inside a closed fold, where it cannot be selected.\n // That fallback reports whether it worked. When it does not, the text stays selected (so Cmd/Ctrl+C still copies it) and the\n // button says what to do instead of showing the \"Copied \u2713\" label the reader cannot trust.\n const copyText = async (str, btn) => {\n stuck?.remove();\n stuck = null;\n try {\n await navigator.clipboard.writeText(str);\n // The close_after_reply script (close-after-reply.js) closes the tab once the reply is on the clipboard.\n document.dispatchEvent(new Event('am-reply-copied'));\n } catch {\n const tmp = Object.assign(document.createElement('textarea'), { value: str });\n tmp.style.cssText = 'position:fixed;top:-100px;opacity:0';\n // Inside the sheet while it is open: while a modal dialog is open the rest of the document cannot take focus, so a textarea\n // in the body can be selected but not focused, and the keyboard shortcut the reader is told to press would copy nothing.\n // The bottom bar copies while the sheet is closed, and a closed dialog is not rendered, so there the textarea goes in the body.\n (sheet.open ? sheet : document.body).append(tmp);\n tmp.select();\n let copied = false;\n try {\n copied = document.execCommand('copy');\n } catch {\n copied = false;\n }\n if (!copied) {\n stuck = tmp;\n btn.textContent = ui.copyFailed;\n setTimeout(() => { btn.textContent = ui.copy; }, 3000);\n return;\n }\n tmp.remove();\n }\n btn.textContent = ui.done;\n setTimeout(() => { btn.textContent = ui.copy; }, 1400);\n };\n\n const open = () => {\n const reply = compose();\n if (reply) view.innerHTML = replyViewHtml(reply);\n else view.textContent = ui.empty;\n view.scrollTop = 0;\n text.value = reply;\n raw.open = false;\n raw.hidden = !reply;\n copy.disabled = !reply;\n if (sheet.showModal) sheet.showModal();\n else sheet.setAttribute('open', '');\n (reply ? copy : close).focus();\n };\n replyBtn.addEventListener('click', open);\n close.addEventListener('click', () => (sheet.close ? sheet.close() : sheet.removeAttribute('open')));\n // A failed copy leaves the text selected for Cmd/Ctrl+C; closing the sheet drops that textarea.\n sheet.addEventListener('close', () => { stuck?.remove(); stuck = null; });\n copy.addEventListener('click', () => copyText(text.value, copy));\n\n const bar = Object.assign(document.createElement('div'), { className: 'am-reply-bar', hidden: true });\n bar.setAttribute('role', 'region');\n bar.setAttribute('aria-label', ui.title);\n const summary = Object.assign(document.createElement('span'), { className: 'am-reply-bar-count' });\n summary.setAttribute('aria-live', 'polite');\n const preview = Object.assign(document.createElement('button'), { type: 'button', className: 'am-btn', textContent: ui.preview });\n const barCopy = Object.assign(document.createElement('button'), { type: 'button', className: 'am-btn am-btn--reply', textContent: ui.copy });\n preview.addEventListener('click', open);\n barCopy.addEventListener('click', () => copyText(compose(), barCopy));\n bar.append(summary, preview, barCopy);\n document.body.append(bar);\n\n // The bar shows only the counts that are above zero, and only once there is any input at all.\n refreshBar = () => {\n const counts = {\n answered: touched.size,\n comments: [...boxes.values()].filter((box) => box.value.trim()).length,\n remarks: (window.__amRemarkData?.() ?? []).length,\n };\n const parts = Object.entries(counts).filter(([, n]) => n > 0).map(([kind, n]) => ui.count[kind].replace('{n}', n));\n summary.textContent = parts.join(' \xB7 ');\n bar.hidden = !parts.length;\n document.body.classList.toggle('am-has-reply-bar', parts.length > 0);\n };\n document.addEventListener('am-remark-change', () => refreshBar());\n // Saved remarks are restored by remark.js, which runs after this script in the same <script> element: its data is not there yet.\n // A microtask runs when that whole element has finished, so the first count includes them.\n queueMicrotask(() => refreshBar());\n}\n})();\n(() => {\n// Text helpers for remark mode (src/runtime/remark.js): how a marked block is named and quoted.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped (src/runtime/compose.js).\n// A block keeps its mark across `am patch` because the key is its panel, its tag and the start of its text, not its position.\n\nconst collapse = (text) => String(text).replace(/\\s+/g, ' ').trim();\n\n// The start of a block's text with whitespace collapsed: the readable identity of the block.\nfunction fingerprint(text, len = 80) {\n return collapse(text).slice(0, len);\n}\n\n// What the reply quotes of a block: the start of its text, with an ellipsis when it is cut.\nfunction quote(text, len = 60) {\n const t = collapse(text);\n return t.length > len ? `${t.slice(0, len).trimEnd()}\u2026` : t;\n}\n\n// Two blocks with the same text (two identical list items) get the same base key. The n-th one in the page gets \"\\t<n>\" added;\n// a tab cannot be in a fingerprint, which has its whitespace collapsed, so the new key never meets another base key.\nfunction occurrenceKeys(bases) {\n const seen = new Map();\n return bases.map((base) => {\n const n = seen.get(base) ?? 0;\n seen.set(base, n + 1);\n return n ? `${base}\\t${n}` : base;\n });\n}\n\n// Remark mode: the reader turns it on, clicks a block, tags it (suggestion, keep, question, concern) and may add a note.\n// A mark shows as a bar and a note chip inside the block, lives in localStorage like panel comments, and the Reply button carries it\n// back to the agent: reply.js calls window.__amRemarkData, and replyText (reply-text.js) writes the Remarks section.\n(() => {\n const btn = document.querySelector('[data-am=\"remark\"]');\n if (!btn) return;\n const ui = JSON.parse(btn.dataset.ui);\n const KINDS = ['suggestion', 'keep', 'question', 'concern'];\n const storeKey = `am-remark:${location.pathname}`;\n // A page served by `am serve` has no localStorage and the phone may discard its tab; it keeps the marks on the server, in the\n // same record as the answers (reply.js), so a re-opened page finds them again.\n const serve = (() => {\n const { amSave: save, amState: state } = document.body?.dataset ?? {};\n if (!save) return null;\n try {\n return { save, restored: state ? JSON.parse(state) : null };\n } catch {\n return { save, restored: null };\n }\n })();\n let saveTimer = null;\n let pendingPatch = null;\n const sendSave = (patch) => {\n fetch(serve.save, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(patch), keepalive: true })\n .catch(() => {});\n };\n const saveSoon = (patch) => {\n clearTimeout(saveTimer);\n pendingPatch = patch;\n saveTimer = setTimeout(() => {\n pendingPatch = null;\n sendSave(patch);\n }, 400);\n };\n // A hidden or closing page sends the change it still holds, before the timer can run.\n const flushSave = () => {\n if (!pendingPatch) return;\n clearTimeout(saveTimer);\n sendSave(pendingPatch);\n pendingPatch = null;\n };\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') flushSave();\n });\n window.addEventListener('pagehide', flushSave);\n // The one definition of a block a reader can mark: the content under <main>. The page and panel titles are left out, because the\n // reply reads them as text; a panel has its Comment button.\n // A $$ block on its own is a div; a $$ formula inside a sentence is a span of its paragraph.\n const BLOCK = 'main :is(h1,h2,h3,h4,h5,h6,p,li,blockquote,pre,table,dd,dt,figure,div.am-math-block):not(.am-head *, .am-panel-head *, .am-toc *)';\n // A click on these does what it always did.\n const LIVE = '.am-remark-pop, .am-toolbar, a, button, input, textarea, select, label';\n const blockAt = (target) => (target.closest(LIVE) ? null : target.closest(BLOCK));\n\n const WJ = new RegExp(String.fromCharCode(0x2060), 'g'); // word joiners of a right-to-left page (src/bidi.js); not part of the draft's text\n // A narrow horizontal timeline shows its date and title inline (src/themes/base.css). They stay parts of their own, so a block key\n // does not change with the width of the window (#194).\n const OWN_BOX = '.am-timeline--h .am-tl-when, .am-timeline--h .am-tl-title';\n const inlineBox = new WeakMap();\n const isInline = (el) => {\n if (!inlineBox.has(el)) inlineBox.set(el, !el.matches(OWN_BOX) && getComputedStyle(el).display.startsWith('inline'));\n return inlineBox.get(el);\n };\n // The text of a block as the reader sees it: separate lines, cells and timeline parts are joined by a space (textContent would run\n // \"2026\" and \"Ship\" together), and the note chip is not part of it. A formula is one box and reads as the TeX the draft wrote\n // (src/runtime/math-text.js), not as the MathML tokens.\n const blockText = (el) => {\n const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);\n let text = '';\n let last = null;\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n if (node.parentElement.closest('.am-mark-note')) continue;\n let box = formulaOf(node) ?? node.parentElement;\n while (box !== el && isInline(box)) box = box.parentElement;\n if (last && box !== last) text += ' ';\n text += nodeText(node).replace(WJ, '');\n last = box;\n }\n return text;\n };\n\n const panelOf = (el) => el.closest('.am-panel')?.id.replace(/^panel-/, '') ?? '';\n // Block keys, in page order. Built when first needed: a page nobody marked pays nothing.\n let keys = null;\n const keyMap = () => {\n if (!keys) {\n const blocks = [...document.querySelectorAll(BLOCK)];\n const ids = occurrenceKeys(blocks.map((el) => `${panelOf(el)}|${el.localName}|${fingerprint(blockText(el))}`));\n keys = new Map(blocks.map((el, i) => [el, ids[i]]));\n }\n return keys;\n };\n\n const load = () => {\n const restored = serve?.restored?.remark;\n if (Array.isArray(restored)) return restored.filter((m) => typeof m?.key === 'string' && KINDS.includes(m.kind));\n try {\n const saved = JSON.parse(localStorage.getItem(storeKey));\n return Array.isArray(saved) ? saved.filter((m) => typeof m?.key === 'string' && KINDS.includes(m.kind)) : [];\n } catch {\n return [];\n }\n };\n // A mark whose block is gone from the page stays stored (it may return with `am patch`); it is neither painted nor sent.\n const marks = new Map(load().map((m) => [m.key, { key: m.key, kind: m.kind, note: String(m.note ?? '') }]));\n // Kind and note of a popover closed without Save, by block key, until the page reloads (see open below).\n const drafts = new Map();\n const clearBtn = document.createElement('button');\n clearBtn.type = 'button';\n clearBtn.className = 'am-btn am-btn--remark-clear';\n clearBtn.textContent = ui.clear;\n // Clear all drops saved marks and drafts, so it shows while either exists.\n const toClear = () => marks.size + drafts.size;\n const showClear = () => { clearBtn.hidden = toClear() === 0; };\n btn.insertAdjacentElement('afterend', clearBtn);\n let clearTimer = null;\n let clearArmed = false;\n const resetClear = () => {\n if (clearTimer !== null) clearTimeout(clearTimer);\n clearTimer = null;\n clearArmed = false;\n clearBtn.classList.remove('is-armed');\n clearBtn.textContent = ui.clear;\n showClear();\n };\n const armClear = () => {\n clearArmed = true;\n clearBtn.classList.add('is-armed');\n clearBtn.textContent = ui.clearConfirm.replace('{n}', toClear());\n clearTimer = setTimeout(resetClear, 4000);\n };\n clearBtn.addEventListener('click', () => {\n if (!clearArmed) {\n armClear();\n return;\n }\n for (const el of document.querySelectorAll('.am-mark')) unpaint(el);\n marks.clear();\n // A draft is a remark the reader has not saved yet; Clear all drops it too, so no block reopens with an old kind.\n drafts.clear();\n try {\n localStorage.removeItem(storeKey);\n } catch {\n // Storage may be off (private window, a sandboxed page); the in-memory marks still clear.\n }\n if (serve) saveSoon({ remark: [] });\n resetClear();\n document.dispatchEvent(new Event('am-remark-change'));\n });\n const save = () => {\n try {\n localStorage.setItem(storeKey, JSON.stringify([...marks.values()]));\n } catch {\n // Storage may be off (private window, a sandboxed page); marks then last until the page closes.\n }\n if (serve) saveSoon({ remark: [...marks.values()] });\n // The reply bar (reply.js) shows the number of marks.\n document.dispatchEvent(new Event('am-remark-change'));\n showClear();\n };\n\n const chip = (el, mark) => {\n const note = document.createElement(el.localName === 'table' ? 'caption' : 'span');\n note.className = 'am-mark-note';\n const kind = document.createElement('b');\n kind.textContent = ui.kinds[mark.kind];\n note.append(kind, mark.note ? ` ${mark.note}` : '');\n return note;\n };\n const clearChip = (el) => el.querySelector(':scope > .am-mark-note')?.remove();\n const paint = (el, mark) => {\n clearChip(el);\n el.classList.add('am-mark');\n el.dataset.kind = mark.kind;\n // Inside the block, so a list item stays a child of its list. A table takes it as its caption; a list item with a sub-list shows\n // it under its own text, before the sub-list.\n const sub = el.querySelector(':scope > ul, :scope > ol');\n if (el.localName === 'table') el.prepend(chip(el, mark));\n else if (sub) sub.before(chip(el, mark));\n else el.append(chip(el, mark));\n };\n const unpaint = (el) => {\n clearChip(el);\n el.classList.remove('am-mark');\n delete el.dataset.kind;\n };\n showClear();\n if (marks.size) for (const [el, key] of keyMap()) if (marks.has(key)) paint(el, marks.get(key));\n\n // The popover edits one block. Save stays off until a kind is picked, and a hint says so. 1\u20134 pick a kind from the keyboard and\n // move to the note; Ctrl / Cmd + Enter saves. A popover closed without Save keeps its kind and note as a draft for that block until the page reloads.\n const pop = document.createElement('div');\n pop.className = 'am-remark-pop';\n pop.hidden = true;\n pop.setAttribute('role', 'dialog');\n pop.setAttribute('aria-label', ui.button);\n document.body.append(pop);\n let opener = null;\n let anchor = null;\n let keepDraft = null;\n const close = (restoreFocus) => {\n if (pop.hidden) return;\n keepDraft?.();\n keepDraft = null;\n pop.hidden = true;\n if (restoreFocus) (opener?.isConnected && opener !== document.body ? opener : btn).focus();\n };\n const place = () => {\n const rect = anchor.getBoundingClientRect();\n const rtl = getComputedStyle(document.documentElement).direction === 'rtl';\n const x = rtl ? rect.right - pop.offsetWidth : rect.left;\n // Under the block; a block taller than the window gets the popover at the bottom of the window instead.\n const y = Math.min(rect.bottom + 6, window.innerHeight - pop.offsetHeight - 8);\n pop.style.left = `${window.scrollX + Math.min(Math.max(8, x), window.innerWidth - pop.offsetWidth - 8)}px`;\n pop.style.top = `${window.scrollY + Math.max(8, y)}px`;\n };\n const make = (tag, props) => Object.assign(document.createElement(tag), props);\n const open = (el) => {\n const key = keyMap().get(el);\n const mark = marks.get(key);\n const draft = drafts.get(key);\n let kind = draft?.kind ?? mark?.kind ?? '';\n opener = document.activeElement;\n anchor = el;\n\n const note = make('textarea', { rows: 2, placeholder: ui.hint, value: draft?.note ?? mark?.note ?? '' });\n note.setAttribute('aria-label', ui.hint);\n const keep = make('button', { type: 'button', className: 'am-btn', textContent: ui.save, disabled: !kind });\n const need = make('span', { className: 'am-remark-need', textContent: ui.need, hidden: Boolean(kind) });\n keepDraft = () => {\n if (kind || note.value.trim()) drafts.set(key, { kind, note: note.value });\n else drafts.delete(key);\n showClear();\n };\n const done = () => { drafts.delete(key); keepDraft = null; showClear(); };\n keep.addEventListener('click', () => {\n done();\n const saved = { key, kind, note: note.value.trim() };\n marks.set(key, saved);\n save();\n paint(el, saved);\n close(true);\n });\n const actions = make('div', { className: 'am-remark-actions' });\n actions.append(keep);\n if (mark) {\n const drop = make('button', { type: 'button', className: 'am-btn', textContent: ui.remove });\n drop.addEventListener('click', () => {\n done();\n marks.delete(key);\n save();\n unpaint(el);\n close(true);\n });\n actions.append(drop);\n }\n const choose = (k) => {\n kind = k;\n for (const other of kindBtns) other.setAttribute('aria-pressed', String(other.dataset.kind === k));\n keep.disabled = false;\n need.hidden = true;\n };\n const kindBtns = KINDS.map((k, i) => {\n const kb = make('button', { type: 'button', className: 'am-remark-kind', textContent: ui.kinds[k] });\n kb.dataset.kind = k;\n kb.dataset.n = i + 1;\n kb.setAttribute('aria-pressed', String(k === kind));\n kb.addEventListener('click', () => choose(k));\n return kb;\n });\n // Ctrl / Cmd + Enter presses Save (nothing while Save waits for a kind). A digit types into the note, so it picks a kind\n // only while the focus is outside the note.\n pop.onkeydown = (e) => {\n if (e.key === 'Enter' && (e.ctrlKey || e.metaKey) && !e.isComposing) {\n e.preventDefault();\n if (!keep.disabled) keep.click();\n return;\n }\n if (e.target === note || e.ctrlKey || e.metaKey || e.altKey || !/^[1-4]$/.test(e.key)) return;\n e.preventDefault();\n choose(KINDS[Number(e.key) - 1]);\n note.focus();\n };\n actions.append(need);\n pop.replaceChildren(make('div', { className: 'am-remark-kinds' }), note, actions);\n pop.firstChild.append(...kindBtns);\n pop.hidden = false;\n place();\n (kindBtns.find((b) => b.dataset.kind === kind) ?? kindBtns[0]).focus({ preventScroll: true });\n };\n\n // Picking works only while remark mode is on. A click on a marked block edits its mark, on a plain block starts one.\n // The block under the pointer gets an outline: the same blockAt decides what is outlined and what a click picks.\n let hover = null;\n const track = (e) => {\n const el = e.type === 'mouseout' && e.relatedTarget === null ? null : blockAt(e.target);\n if (el === hover) return;\n hover?.classList.remove('am-remark-hover');\n hover = el;\n hover?.classList.add('am-remark-hover');\n };\n const pick = (e) => {\n const el = blockAt(e.target);\n if (el) open(el);\n };\n // The keyboard picks too: while the mode is on, every block takes focus with Tab, and Enter or Space opens its popover. A block\n // that already had a tabindex keeps it; only the ones the mode added lose it again.\n const pickKey = (e) => {\n if ((e.key !== 'Enter' && e.key !== ' ') || e.ctrlKey || e.metaKey || e.altKey || !e.target.hasAttribute?.('data-am-pick')) return;\n e.preventDefault();\n open(e.target);\n };\n const focusable = (on) => {\n if (!on && !keys) return; // the mode starts off: a page nobody marked builds no block keys\n for (const el of keyMap().keys()) {\n if (on && !el.hasAttribute('tabindex')) {\n el.tabIndex = 0;\n el.setAttribute('data-am-pick', '');\n } else if (!on && el.hasAttribute('data-am-pick')) {\n el.removeAttribute('tabindex');\n el.removeAttribute('data-am-pick');\n }\n }\n };\n const setMode = (on) => {\n btn.classList.toggle('is-on', on);\n btn.setAttribute('aria-pressed', String(on));\n const toggle = on ? 'addEventListener' : 'removeEventListener';\n document.body[toggle]('click', pick);\n document.body[toggle]('mouseover', track);\n document.body[toggle]('mouseout', track);\n document.body[toggle]('keydown', pickKey);\n focusable(on);\n if (!on) {\n track({ type: 'mouseout', relatedTarget: null });\n close(false);\n }\n };\n btn.addEventListener('click', () => setMode(btn.getAttribute('aria-pressed') !== 'true'));\n document.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') close(true);\n });\n // A click outside the popover closes it; the same click may then start another mark.\n document.addEventListener('click', (e) => {\n if (!pop.hidden && !pop.contains(e.target)) close(false);\n }, true);\n setMode(false);\n\n // What the Reply button reads: the marked blocks that are on the page, in page order.\n window.__amRemarkData = () => {\n if (!marks.size) return [];\n const live = [];\n for (const [el, key] of keyMap()) {\n const mark = marks.get(key);\n if (mark) live.push({ panel: panelOf(el), quote: quote(blockText(el)), kind: mark.kind, note: mark.note });\n }\n return live;\n };\n})();\n})();\n(() => {\n// Pure planner for justified (\"photo wall\") rows on sheet pages. No DOM access.\n//\n// This file must stay inlinable into the page script: top-level declarations only, no imports, and the exports are\n// `planLayout` and the constants the DOM adapter shares (STEP, MAX_SCALE, MIN_SCALE). The page build strips the `export ` keyword,\n// and test/layout-plan.test.js checks that this still works.\n//\n// planLayout({ width, gap, cols, panels }) -> { rows: [{ columns: [{ panels: [index, ...], width }], height }] }\n//\n// Input (all lengths in px):\n// width container width\n// gap space between columns, and between two panels stacked in one column\n// cols most columns in one row (the planner never uses more than MAX_COLUMNS, but spans stay shares of `cols`)\n// panels one entry per panel, in reading order:\n// samples [{ w, h }] panel height at sampled widths, ascending by w (heights between samples are interpolated)\n// minWidth narrowest feasible width (clamped to `width`)\n// maxWidth widest useful width; beyond it the panel only gains empty space (default: no limit)\n// natural natural diagram width for a diagram-only panel (default: none)\n// pad panel width not used by the diagram (padding and border; default 0)\n// span the author's width hint in grid columns (default 1); span >= cols keeps the panel alone in its row\n//\n// Output: { rows, maxScale }. Rows are in reading order; a row is a list of columns (at most `cols`); a column holds one panel or two\n// consecutive panels, stacked. For integer inputs the column widths plus the gaps between them equal `width`.\n// Rows are chosen by dynamic programming over break points; widths by a search in STEP px steps. Cost per row:\n// H = tallest column; waste = sum((H - columnHeight) * columnWidth) + sum over diagrams wider than maxWidth of (w - maxWidth) * h\n// dev = sum(((w - preferred) / oneColumn)^2) + SCALE_WEIGHT * sum over diagrams of (ln(scale) / ln(MAX_SCALE))^2\n// cost = waste / 1000 + PREF_WEIGHT * dev * H\n// Scale band: diagrams on one page stay at similar sizes. With the result's `maxScale` as the diagram size limit, a diagram is\n// shown at scale min(maxScale, (width - pad) / natural). The planner tries a few bands [lo, lo * BAND_RATIO] (lo in BAND_LOS) and\n// keeps the cheapest plan in which no diagram is narrower than scale lo and none is shown above the band's top, so the largest and\n// smallest diagram scale on the page differ by at most BAND_RATIO. A panel wider than its diagram's top size keeps the diagram at\n// that size, and the page script must set the diagram's max-width to natural * maxScale. The band starts no higher than the\n// largest scale the page allows the least roomy diagram, so one wide diagram lowers the band for the others.\n// If no band is feasible the plan is made without a band (maxScale = MAX_SCALE); if no plan fits (or the input is unusable) the\n// result is a single column: one panel per row at the full width.\n\nconst STEP = 10;\nconst MAX_SCALE = 1.25;\nconst MIN_SCALE = 0.75; // the narrowest a diagram is shown, as a share of its natural width\nconst MAX_COLUMNS = 6; // rows with more columns are unreadable, and the search grows steeply with the column count\nconst BAND_RATIO = 1.25; // the largest and smallest diagram scale on a page differ by at most this\nconst BAND_LOS = [MIN_SCALE, 0.85, 0.95, 1]; // lower ends tried for the band; lo * BAND_RATIO is the upper end (1.25 means no upper limit)\nconst SCALE_WEIGHT = 3;\nconst PREF_WEIGHT = 0.15;\n\nfunction heightAt(samples, w) {\n const i = samples.findIndex((s) => s.w >= w);\n if (i === -1) return samples[samples.length - 1].h;\n if (i === 0) return samples[0].h;\n const a = samples[i - 1];\n const b = samples[i];\n return a.h + ((b.h - a.h) * (w - a.w)) / (b.w - a.w);\n}\n\n// Every way to split `len` consecutive panels into columns of 1 or 2 panels, as lists of column sizes.\nfunction splits(len) {\n if (len === 0) return [[]];\n return [1, 2].filter((k) => k <= len).flatMap((k) => splits(len - k).map((rest) => [k, ...rest]));\n}\n\nfunction singleColumn(width, panels) {\n return { rows: panels.map((_, i) => ({ columns: [{ panels: [i], width }], height: 0 })) };\n}\n\nfunction planLayout({ width, gap = 0, cols = 3, panels }) {\n const usable = Number.isFinite(width) && width > 0 && panels.every((p) => Array.isArray(p.samples) && p.samples.length > 0);\n if (!usable) return singleColumn(width, panels);\n\n // `cols` stays the unit of the author's spans; no row gets more than MAX_COLUMNS columns however large `cols` is.\n const maxColumns = Math.min(cols, MAX_COLUMNS);\n const oneColumn = Math.max(1, (width - gap * (cols - 1)) / cols);\n // Per-panel limits. With a band [lo, lo * BAND_RATIO], a diagram is no narrower than scale lo and shown at most at the top of the\n // band: a wider panel keeps it at that size and gains empty space, which the cost counts as waste.\n const prepare = (lo) => panels.map((p) => {\n const pad = p.pad ?? 0;\n const diagram = lo > 0 && p.natural > 0;\n const scaleCap = diagram ? Math.min(MAX_SCALE, lo * BAND_RATIO) : MAX_SCALE;\n return {\n ...p,\n minWidth: Math.min(width, Math.max(Math.ceil(p.minWidth || 0), diagram ? Math.ceil(p.natural * lo + pad) : 0)),\n maxWidth: Math.min(p.maxWidth ?? Infinity, diagram ? p.natural * scaleCap + pad : Infinity),\n scaleCap,\n pad,\n preferred: Math.min(width, (p.span ?? 1) * oneColumn + ((p.span ?? 1) - 1) * gap),\n alone: (p.span ?? 1) >= cols,\n };\n });\n let info = prepare(0);\n // Beyond its maxWidth a panel only gains empty space, so its height stops changing there (matters when a band lowers maxWidth).\n const heightOf = (p, w) => heightAt(p.samples, Math.min(w, p.maxWidth));\n const columnHeight = (col, w) => col.reduce((h, k) => h + heightOf(info[k], w), 0) + gap * (col.length - 1);\n\n function bestColumns(columns) {\n const avail = width - gap * (columns.length - 1);\n const mins = columns.map((c) => Math.max(...c.map((k) => info[k].minWidth)));\n const minsFrom = mins.map((_, n) => mins.slice(n).reduce((s, w) => s + w, 0));\n if (minsFrom[0] > avail) return null;\n let best = null;\n const evaluate = (ws) => {\n const hs = ws.map((w, n) => columnHeight(columns[n], w));\n const H = Math.max(...hs);\n let waste = 0;\n let dev = 0;\n ws.forEach((w, n) => {\n waste += (H - hs[n]) * w;\n for (const k of columns[n]) {\n const p = info[k];\n if (w > p.maxWidth) waste += (w - p.maxWidth) * heightOf(p, w);\n dev += ((w - p.preferred) / oneColumn) ** 2;\n if (p.natural > 0) {\n const scale = Math.min(p.scaleCap, Math.max(w - p.pad, 1) / p.natural);\n dev += SCALE_WEIGHT * (Math.log(scale) / Math.log(MAX_SCALE)) ** 2;\n }\n }\n });\n const cost = waste / 1000 + PREF_WEIGHT * dev * H;\n if (!best || cost < best.cost) best = { cost, ws, height: H, columns };\n };\n const choose = (n, used, ws) => {\n if (n === columns.length - 1) {\n const w = avail - used;\n if (w >= mins[n]) evaluate([...ws, w]);\n return;\n }\n for (let w = mins[n]; used + w + minsFrom[n + 1] <= avail; w += STEP) choose(n + 1, used + w, [...ws, w]);\n };\n choose(0, 0, []);\n return best;\n }\n\n // Best columns for one row of panels i..j.\n function bestRow(i, j) {\n if (j > i && info.slice(i, j + 1).some((p) => p.alone)) return null;\n let best = null;\n for (const split of splits(j - i + 1)) {\n if (split.length > maxColumns) continue;\n let next = i;\n const columns = split.map((size) => Array.from({ length: size }, () => next++));\n const r = bestColumns(columns);\n if (r && (!best || r.cost < best.cost)) best = r;\n }\n return best;\n }\n\n // Row breaks in reading order, for the band set up in `info`. A row holds at most 2 * maxColumns panels. Null if nothing fits.\n function solve() {\n const n = panels.length;\n const total = Array(n + 1).fill(Infinity);\n const from = Array(n + 1).fill(-1);\n const chosen = Array(n + 1).fill(null);\n total[0] = 0;\n for (let j = 1; j <= n; j++) {\n for (let i = Math.max(0, j - 2 * maxColumns); i < j; i++) {\n if (total[i] === Infinity) continue;\n const r = bestRow(i, j - 1);\n if (r && total[i] + r.cost < total[j]) {\n total[j] = total[i] + r.cost;\n from[j] = i;\n chosen[j] = r;\n }\n }\n }\n if (total[n] === Infinity) return null;\n const rows = [];\n for (let j = n; j > 0; j = from[j]) {\n const r = chosen[j];\n rows.unshift({ columns: r.columns.map((panelsInColumn, c) => ({ panels: panelsInColumn, width: r.ws[c] })), height: r.height });\n }\n return { rows, cost: total[n] };\n }\n\n let best = null;\n const diagrams = panels.filter((p) => p.natural > 0);\n if (diagrams.length > 1) {\n // No diagram can be shown larger than the page allows, so the band cannot start above the smallest of those limits.\n const reach = Math.min(...diagrams.map((p) => Math.min(MAX_SCALE, Math.max(width - (p.pad ?? 0), 1) / p.natural)));\n for (const lo of new Set([...BAND_LOS.filter((x) => x < reach), reach])) {\n info = prepare(lo);\n const r = solve();\n if (r && (!best || r.cost < best.cost)) best = { ...r, maxScale: Math.min(MAX_SCALE, lo * BAND_RATIO) };\n }\n info = prepare(0);\n }\n best ??= solve();\n return best ? { rows: best.rows, maxScale: best.maxScale ?? MAX_SCALE } : singleColumn(width, panels);\n}\n\n// DOM adapter for the sheet's justified (\"photo wall\") layout. Not a module: compose.js puts it after src/runtime/layout-plan.js\n// (which defines planLayout and the shared STEP, MAX_SCALE, MIN_SCALE) inside one function scope of the page script.\n//\n// It measures every panel at sampled widths, asks planLayout for rows and column widths, and applies them with flexbox.\n// The rendered HTML keeps the plain CSS grid: with JavaScript off, at the single-column breakpoint, or while printing, the grid is what\n// shows (the planned widths belong to the screen width, so print never gets a mix of the two); after printing the layout comes back.\n\n// A diagram is never drawn under MIN_SCALE of its natural width, the floor the planner keeps: below it the text is too small to read,\n// so its figure scrolls sideways instead. This covers what the planner does not size: the plain grid, a phone, a one-panel page and a\n// panel that holds more than the diagram. The svg width follows the reader's text size (page.js), so the floor follows am-scale;\n// restore() puts it back after resetting the inline styles. Printing drops it (base.css).\nconst floorDiagrams = () => {\n for (const svg of document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas) > svg')) {\n const width = Number(svg.getAttribute('width'));\n if (width > 0) svg.style.minWidth = `${Math.floor(width * MIN_SCALE)}px`;\n }\n};\nfloorDiagrams();\naddEventListener('am-scale', floorDiagrams);\n\nconst grid = document.querySelector('.am-grid');\nconst panels = grid ? [...grid.children].filter((el) => el.classList.contains('am-panel')) : [];\n\nif (panels.length > 1) {\n const SINGLE_COLUMN = '(max-width: 760px)'; // the single-column breakpoint in src/themes/base.css\n const TWO_COLUMNS = '(max-width: 1100px)'; // below this the CSS grid has two columns\n const SAMPLE_STEP = 20; // width sampling step, px; the planner interpolates between samples\n // The width floors are text sizes (px at scale 1). They take the page scale on every pass, so a runtime change of --am-scale re-plans.\n const TEXT_MIN = 260; // text keeps at least about 16 CJK characters per line\n const TABLE_COL_MIN = 96; // per table column, px\n const TABLE_COL_COMFORT = 220; // a table column this wide reads three or four words per line\n const TABLE_WORD_MAX = 160; // a longer word (an id, a path) counts as this wide and may break inside its cell when room is short\n const KV_COL_MIN = 120; // per key-value column, px: a value of two short words stays on one line\n const DIAGRAM_MIN = 160;\n const RESIZE_DELAY = 150;\n const pageScale = () => {\n const scale = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--am-scale'));\n return Number.isFinite(scale) && scale > 0 ? scale : 1;\n };\n const OVERFLOWING = '.am-table-wrap, .am-diagram, .am-annot-scroll, pre';\n\n // The first-row cells of each table carry the column widths fitTables() sets, so restore() resets them too.\n const tables = [...grid.querySelectorAll('.am-table-wrap > table')];\n const headCells = (table) => [...(table.rows[0]?.cells ?? [])];\n const original = new Map([grid, ...panels, ...grid.querySelectorAll('.am-diagram > svg'), ...tables.flatMap(headCells)].map((el) => [el, el.getAttribute('style')]));\n const restoreStyle = (el) => (original.get(el) === null ? el.removeAttribute('style') : el.setAttribute('style', original.get(el)));\n\n // Back to the plain grid markup and styles.\n const restore = () => {\n for (const box of grid.querySelectorAll(':scope > .am-col')) box.replaceWith(...box.children);\n for (const el of original.keys()) restoreStyle(el);\n for (const table of tables) table.classList.remove('am-table-fit');\n floorDiagrams();\n };\n\n // The author's width hint, rendered as data-span only when the author wrote one. The inline grid-column is the no-JavaScript fallback\n // and may hold spans the server added, so it is never read here.\n const spanHint = (el) => Number(el.dataset.span) || 1;\n const diagramOnly = (el) => {\n const body = el.querySelector(':scope > .am-panel-body');\n return body && body.children.length === 1 ? body.querySelector(':scope > .am-diagram > svg') : null;\n };\n const naturalWidth = (svg) => Number(svg.getAttribute('width')) || 0;\n\n // The width each column of a table reads well at: its natural width, but no wider than TABLE_COL_COMFORT unless its longest word\n // needs more. Below it the cells wrap one word per line, so a panel with a table is not planned narrower than the sum, and\n // fitTables() keeps each column at its share (the browser would otherwise give the room to the longest column).\n // A column's floor is its longest word, but no more than TABLE_WORD_MAX: a long id would otherwise hold its column at full width and\n // leave a prose column one word per line. fitTables() lets such a word break (am-table-fit) when the table is short of room.\n const columnWidths = new Map();\n function comfortableWidth(table, scale) {\n const saved = table.getAttribute('style');\n const columns = (width) => {\n table.style.width = width;\n return headCells(table).map((cell) => cell.getBoundingClientRect().width);\n };\n const most = columns('max-content');\n const unbroken = columns('min-content');\n const least = unbroken.map((w) => Math.min(w, TABLE_WORD_MAX * scale));\n if (saved === null) table.removeAttribute('style');\n else table.setAttribute('style', saved);\n // A max-content column comes out a fraction under its text in Chrome, enough to wrap the last word, so it gets one pixel more.\n const want = most.map((w, i) => Math.min(Math.ceil(w) + 1, Math.max(least[i], TABLE_COL_COMFORT * scale)));\n // unbroken: each column's longest word. A column the browser lays out is at least that wide, whatever its min-width, so\n // fitTables() turns am-table-fit on when the columns would not fit at those widths, even if the capped widths do.\n columnWidths.set(table, { least, want, unbroken });\n return want.reduce((sum, w) => sum + w, 0);\n }\n\n // After the layout: each column gets at least its comfortable width, scaled down toward its longest word when the panel came out\n // narrower than planned (a page narrower than the table), so a table scrolls sideways only when even its longest words do not fit.\n function fitTables() {\n for (const [table, { least, want, unbroken }] of columnWidths) {\n // Each width is rounded up to a whole pixel (a column a fraction too narrow wraps its last word), so keep a pixel per column spare.\n const room = table.parentElement.clientWidth - want.length;\n const low = least.reduce((s, w) => s + w, 0);\n const high = want.reduce((s, w) => s + w, 0);\n const k = high > room ? Math.max(0, (room - low) / (high - low || 1)) : 1;\n const widths = want.map((w, i) => Math.ceil(least[i] + (w - least[i]) * k));\n headCells(table).forEach((cell, i) => { cell.style.minWidth = `${widths[i]}px`; });\n // Without am-table-fit a column holds its longest word, so a long id can widen the table past the room the widths left.\n const whole = widths.reduce((s, w, i) => s + Math.max(w, unbroken[i]), 0);\n table.classList.toggle('am-table-fit', high > room || whole > room);\n }\n }\n\n // Height (and, for panels with tables or code, the narrowest width without sideways scrolling) at sampled widths.\n // Only one panel is displayed while it is measured, so each width change lays out that panel alone.\n function measure(width) {\n const scale = pageScale();\n grid.style.display = 'block';\n for (const el of panels) {\n el.style.display = 'none';\n el.style.boxSizing = 'border-box';\n for (const svg of el.querySelectorAll('.am-diagram > svg')) {\n svg.style.width = '100%';\n svg.style.maxWidth = `${naturalWidth(svg) * MAX_SCALE}px`;\n }\n }\n const info = panels.map((el) => {\n const svg = diagramOnly(el);\n const svgs = [...el.querySelectorAll('.am-diagram > svg')];\n const scrollers = el.querySelectorAll(OVERFLOWING);\n const tableCols = Math.max(0, ...[...el.querySelectorAll('table tr:first-child')].map((tr) => tr.children.length));\n el.style.display = '';\n el.style.width = `${width}px`;\n const pad = svg ? el.offsetWidth - svg.parentElement.clientWidth : 0;\n const natural = svg ? naturalWidth(svg) : 0;\n const shrunk = Math.max(0, ...svgs.map((s) => naturalWidth(s) * MIN_SCALE)) + (svg ? pad : 34);\n const tableFloors = [...el.querySelectorAll('.am-table-wrap > table')].map((t) => comfortableWidth(t, scale) + el.offsetWidth - t.parentElement.clientWidth);\n // A key-value grid gets the same care: the room a table gains must not squeeze a neighbouring grid to one word per line.\n const kvs = [...el.querySelectorAll('.am-kv')].map((kv) => (Number(kv.style.getPropertyValue('--kv-cols')) || 1) * KV_COL_MIN * scale + el.offsetWidth - kv.clientWidth);\n const floor = svg ? Math.max(DIAGRAM_MIN * scale, natural * MIN_SCALE + pad) : Math.max(TEXT_MIN * scale, shrunk, tableCols * TABLE_COL_MIN * scale + 34, ...tableFloors, ...kvs);\n const from = Math.min(width, Math.floor(floor / STEP) * STEP);\n const samples = [];\n let fits = null;\n for (let w = from; ; w += SAMPLE_STEP) {\n w = Math.min(w, width);\n el.style.width = `${w}px`;\n if (fits === null && !svg && scrollers.length && ![...scrollers].some((s) => s.scrollWidth > s.clientWidth + 1)) fits = w;\n samples.push({ w, h: el.offsetHeight });\n if (w === width) break;\n }\n el.style.display = 'none';\n return {\n samples,\n minWidth: svg ? floor : Math.max(floor, fits ?? (scrollers.length ? width : 0)),\n maxWidth: svg ? natural * MAX_SCALE + pad : Infinity,\n natural,\n pad,\n span: spanHint(el),\n };\n });\n for (const el of panels) {\n el.style.display = '';\n el.style.width = '';\n }\n return info;\n }\n\n // Each column gets a fixed width. A row adds up to the full width, so flex-wrap breaks rows by itself.\n // Stacked panels go into a column wrapper whose last panel absorbs the extra height.\n function apply(plan, gap) {\n grid.style.display = 'flex';\n grid.style.flexWrap = 'wrap';\n grid.style.alignItems = 'stretch';\n grid.style.gap = `${gap}px`;\n for (const el of panels) {\n el.style.gridColumn = '';\n el.style.gridRow = '';\n el.style.flex = '0 0 auto';\n }\n for (const row of plan.rows) {\n for (const col of row.columns) {\n const width = `${col.width}px`;\n if (col.panels.length === 1) {\n panels[col.panels[0]].style.width = width;\n continue;\n }\n const box = document.createElement('div');\n box.className = 'am-col';\n box.style.cssText = `width:${width};flex:0 0 auto;display:flex;flex-direction:column;gap:${gap}px`;\n panels[col.panels[0]].before(box);\n for (const k of col.panels) {\n panels[k].style.width = '';\n box.append(panels[k]);\n }\n panels[col.panels[col.panels.length - 1]].style.flex = '1 1 auto';\n }\n }\n }\n\n // Diagram-only panels show their diagram at most at the top of the page's scale band; a wider panel gains empty space instead.\n function capDiagrams(maxScale) {\n for (const el of panels) {\n const svg = diagramOnly(el);\n if (svg) svg.style.maxWidth = `${naturalWidth(svg) * maxScale}px`;\n }\n }\n\n const containerWidth = () => Math.floor(grid.getBoundingClientRect().width);\n\n function justify() {\n if (printing || printQuery.matches) return;\n try {\n // A vertical scrollbar can appear or vanish once the rows change height; plan again if the width moved.\n // A later pass plans for the width the previous layout left, not the grid's: restoring the grid first would bring back the\n // grid's scrollbar, so a page whose grid scrolls and whose rows do not (or the reverse) would never settle.\n let planned = -1;\n let laidOut = NaN;\n for (let pass = 0; pass < 3 && planned !== laidOut; pass++) {\n restore();\n if (matchMedia(SINGLE_COLUMN).matches) return;\n planned = pass === 0 ? containerWidth() : laidOut;\n const gap = parseFloat(getComputedStyle(grid).columnGap) || 0;\n const cols = Math.max(1, Number(getComputedStyle(grid).getPropertyValue('--cols')) || 3);\n const plan = planLayout({ width: planned, gap, cols: matchMedia(TWO_COLUMNS).matches ? Math.min(cols, 2) : cols, panels: measure(planned) });\n apply(plan, gap);\n capDiagrams(plan.maxScale);\n fitTables();\n laidOut = containerWidth();\n }\n // The width never settled: columns planned for another width would overflow or leave gaps, so show the plain grid.\n if (planned !== laidOut) restore();\n } catch {\n restore();\n }\n }\n\n // Printing: back to the plain grid (spans and all), and the layout again afterwards. Browsers disagree on which of the\n // `beforeprint` event and the print media query change fires first, or at all, so listen to both; both are idempotent.\n // While `printing` is set (beforeprint to afterprint) justify() does nothing, so a late resize cannot bring flex widths into the print layout.\n let printing = false;\n const printQuery = matchMedia('print');\n let timer = 0;\n const later = () => {\n clearTimeout(timer);\n timer = setTimeout(justify, RESIZE_DELAY);\n };\n const toPrint = () => {\n clearTimeout(timer);\n restore();\n };\n justify();\n addEventListener('resize', later);\n // A reader's text size changes every panel's text widths and heights, so the sheet is planned again like a resize.\n addEventListener('am-scale', later);\n addEventListener('beforeprint', () => {\n printing = true;\n toPrint();\n });\n addEventListener('afterprint', () => {\n printing = false;\n later();\n });\n printQuery.addEventListener('change', (e) => (e.matches ? toPrint() : later()));\n // Late changes to panel heights: web fonts arriving, and images inside the grid finishing their load (load does not bubble, so capture it).\n document.fonts?.ready.then(later);\n grid.addEventListener('load', later, true);\n // Switching theme changes paddings and fonts, hence panel heights.\n document.querySelector('[data-am=\"theme\"]')?.addEventListener('click', later);\n}\n})();\n// The outline rail of a doc page (src/templates/doc.js): the markup already works without a script, <details> opens the list and the\n// links jump. This adds the hover dwell, the open direction, the keys, the tap outside and the marking of the current section.\n(() => {\n const nav = document.querySelector('nav.am-toc');\n const box = nav && nav.querySelector('details.am-outline');\n if (!box) return;\n const sum = box.querySelector('summary');\n const links = Array.from(box.querySelectorAll('.am-outline-list a'));\n const ticks = Array.from(box.querySelectorAll('.am-tick'));\n const LIST_W = 240; // keep in step with .am-outline-list in src/themes/base.css\n const EDGE = 10; // the 6px gap to the rail plus a margin to the viewport edge\n let current = '';\n let byHover = false;\n let dwell = 0;\n let leave = 0;\n\n // Open away from the body when the room outside the rail fits the list; otherwise over the body. Never past the viewport.\n const place = () => {\n const r = sum.getBoundingClientRect();\n const right = r.left + r.width / 2 > innerWidth / 2;\n const room = right ? innerWidth - r.right : r.left;\n nav.dataset.flow = room >= Math.min(LIST_W, innerWidth - 48) + EDGE ? 'out' : 'in';\n };\n const setOpen = (open) => {\n if (open) place();\n box.open = open;\n if (!open) byHover = false;\n };\n const peek = (tick) => ticks.forEach((t) => t.classList.toggle('is-peek', t === tick));\n const currentLink = () => links.find((a) => a.getAttribute('aria-current') === 'true') || links[0];\n\n const mark = (id) => {\n current = id;\n ticks.forEach((t) => t.classList.toggle('is-current', t.dataset.id === id));\n links.forEach((a) => {\n if (a.getAttribute('href') === `#panel-${id}`) a.setAttribute('aria-current', 'true');\n else a.removeAttribute('aria-current');\n });\n };\n const sections = ticks.map((t) => document.getElementById(`panel-${t.dataset.id}`)).filter(Boolean);\n if (sections.length) mark(sections[0].id.slice(6));\n if (sections.length && 'IntersectionObserver' in window) {\n // A thin band a third of the way down the viewport: the section across it is the one being read.\n const seen = new Set();\n const io = new IntersectionObserver((entries) => {\n entries.forEach((e) => (e.isIntersecting ? seen.add(e.target) : seen.delete(e.target)));\n const hit = sections.filter((s) => seen.has(s)).pop();\n if (hit && hit.id.slice(6) !== current) mark(hit.id.slice(6));\n }, { rootMargin: '-30% 0px -65% 0px' });\n sections.forEach((s) => io.observe(s));\n }\n\n place();\n addEventListener('resize', place);\n\n // Mouse: dwelling on the rail opens the list, leaving it closes a list opened that way. A tap or click opens it for good.\n box.addEventListener('pointerenter', (e) => {\n clearTimeout(leave);\n if (e.pointerType !== 'mouse' || box.open) return;\n dwell = setTimeout(() => { setOpen(true); byHover = true; }, 300);\n });\n box.addEventListener('pointerleave', () => {\n clearTimeout(dwell);\n // A link the keyboard moved into keeps the list open; focusout closes it once the focus leaves the nav.\n if (byHover) leave = setTimeout(() => { if (!nav.contains(document.activeElement)) setOpen(false); }, 250);\n });\n sum.addEventListener('click', (e) => {\n clearTimeout(dwell);\n if (box.open && byHover) { e.preventDefault(); byHover = false; return; }\n place();\n });\n box.addEventListener('toggle', () => { if (box.open) peek(null); });\n\n // Keyboard: the summary opens with Enter or Space (native); arrows move through the links; Esc closes and returns to the rail.\n sum.addEventListener('focus', () => {\n if (sum.matches(':focus-visible')) peek(ticks.find((t) => t.dataset.id === current));\n });\n sum.addEventListener('blur', () => peek(null));\n nav.addEventListener('keydown', (e) => {\n if (e.key === 'Escape' && box.open) {\n e.preventDefault();\n setOpen(false);\n sum.focus();\n return;\n }\n if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(e.key)) return;\n const at = links.indexOf(document.activeElement);\n if (at < 0 && e.target !== sum) return;\n e.preventDefault();\n if (!box.open) setOpen(true);\n let next;\n if (e.key === 'Home') next = links[0];\n else if (e.key === 'End') next = links[links.length - 1];\n else if (at < 0) next = e.key === 'ArrowDown' ? currentLink() : links[links.length - 1];\n else next = links[Math.min(links.length - 1, Math.max(0, at + (e.key === 'ArrowDown' ? 1 : -1)))];\n next.focus();\n });\n nav.addEventListener('focusout', (e) => {\n if (box.open && e.relatedTarget && !nav.contains(e.relatedTarget)) setOpen(false);\n });\n\n // Choosing a section or tapping outside closes the list.\n links.forEach((a) => a.addEventListener('click', () => setOpen(false)));\n document.addEventListener('pointerdown', (e) => { if (box.open && !nav.contains(e.target)) setOpen(false); });\n document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && box.open && !nav.contains(e.target)) setOpen(false); });\n})();\n\n// The toolbar's Export menu: Copy as image, Download PNG and Save as PDF. The menu is a native popover that src/render.js writes next to\n// the toolbar (a click on the button, Esc and a click outside open and close it with no script); this script shows the button, moves\n// focus with the arrow keys, says why an item cannot run, and does the work. A browser without popovers gets the same menu from a class\n// toggle instead of losing it.\n//\n// Copy and Download share one rasterizer. An item that cannot run is marked aria-disabled and carries the reason as its muted second\n// line (also its accessible description), never as the toolbar button's text: no rasterizer disables both; a preview frame whose feature\n// policy forbids clipboard-write, or a missing async Clipboard API / secure context, disables only Copy. Chromium and Firefox (as of\n// version 160) can rasterize the page; Safari and unknown browsers keep both items but carry a note that the effect is not guaranteed.\n// A refused copy reports a failure and never falls back to downloading. Save as PDF is the browser's print dialog and always works\n// (the page's print CSS hides the toolbar and the menu).\n//\n// Pipeline: clone the page body \u2192 inline every computed style (CSS variables are resolved there, so a clone keeps theme colours and\n// sizes) and the ::before / ::after decorations \u2192 wrap it in an SVG foreignObject \u2192 draw that image on a canvas \u2192 toBlob('image/png')\n// \u2192 navigator.clipboard.write(new ClipboardItem(...)), passing the blob as a promise so the write keeps the user's click activation,\n// or a download through <a download>.\n(() => {\n const XHTML = 'http://www.w3.org/1999/xhtml';\n const SVG = 'http://www.w3.org/2000/svg';\n const MAX_DIM = 16384; // Chrome refuses a canvas wider or taller than this\n const MAX_AREA = 268435456; // and one with more pixels than this (16384 * 16384)\n\n const btn = document.querySelector('[data-am=\"export\"]');\n const menu = document.getElementById('am-export');\n if (!btn || !menu) return;\n const main = document.querySelector('main.am-sheet, main.am-doc');\n if (!main) return;\n const items = [...menu.querySelectorAll('[data-export]')];\n const item = (kind) => menu.querySelector(`[data-export=\"${kind}\"]`);\n const [copyItem, downloadItem, pdfItem] = ['copy', 'download', 'pdf'].map(item);\n const note = (el) => document.getElementById(el.getAttribute('aria-describedby'));\n const text = menu.dataset;\n\n const canRasterize = typeof XMLSerializer !== 'undefined' && typeof document.createElement('canvas').getContext === 'function';\n const canCopy = window.isSecureContext && typeof ClipboardItem !== 'undefined' && typeof navigator.clipboard?.write === 'function';\n // Chromium (including an embedded Chromium without navigator.userAgentData, whose UA still names Chrome/) and Firefox can rasterize\n // the page. Safari and unknown browsers are not rejected outright: their items stay usable but carry a note that the effect is not\n // guaranteed.\n const brands = navigator.userAgentData?.brands;\n const chromium = brands ? brands.some((b) => /Chromium/.test(b.brand)) : /\\bChrome\\//.test(navigator.userAgent);\n const gecko = /\\bFirefox\\//.test(navigator.userAgent);\n const native = Object.hasOwn(HTMLElement.prototype, 'popover') && typeof menu.showPopover === 'function';\n btn.hidden = false;\n\n const idle = btn.textContent;\n // The button keeps its name (\"Export\") while its text shows progress, so a screen reader hears each result through a hidden live\n // region beside it. aria-live, not\n // role=\"status\": the live-update notice owns role=\"status\" (src/runtime/page.js), and the two must stay apart.\n const status = document.createElement('span');\n status.setAttribute('aria-live', 'polite');\n status.dataset.am = 'export-status';\n status.className = 'am-visually-hidden';\n btn.after(status);\n btn.setAttribute('aria-label', idle);\n // Short feedback on the button itself, restored after a moment; the live region carries the same words.\n const say = (message, restore) => {\n btn.textContent = message;\n status.textContent = message;\n clearTimeout(say.timer);\n if (restore) say.timer = setTimeout(() => { btn.textContent = idle; }, 1800);\n };\n\n // An item that can never run here (aria-disabled, reason as its second line), in the order of the conditions the page can act on.\n const unavailable = new Map();\n if (!canRasterize) {\n unavailable.set(copyItem, text.unavailableBrowser);\n unavailable.set(downloadItem, text.unavailableBrowser);\n } else {\n if (document.featurePolicy && document.featurePolicy.allowsFeature('clipboard-write') === false) unavailable.set(copyItem, text.unavailablePolicy);\n else if (!canCopy) unavailable.set(copyItem, text.unavailableClipboard);\n // Safari and unknown browsers can draw the page often enough to keep the items, but the result is not guaranteed.\n if (!chromium && !gecko) for (const el of [copyItem, downloadItem]) if (!unavailable.has(el)) note(el).textContent = text.unverifiedEffect;\n }\n for (const [el, reason] of unavailable) note(el).textContent = reason;\n\n // A running export blocks the next copy or download (a second full-page rasterization beside the first); Save as PDF stays free.\n let busy = false;\n const sync = () => {\n for (const el of items) {\n const off = unavailable.has(el) || (busy && el !== pdfItem);\n if (off) el.setAttribute('aria-disabled', 'true');\n else el.removeAttribute('aria-disabled');\n }\n if (busy) btn.setAttribute('aria-busy', 'true');\n else btn.removeAttribute('aria-busy');\n };\n sync();\n\n // A stylesheet of only the local font declarations, so a font a theme embeds still draws inside the SVG.\n const fontFaceCss = () => {\n let css = '';\n for (const sheet of document.styleSheets) {\n let rules;\n try { rules = sheet.cssRules; } catch { continue; } // a cross-origin sheet has no readable rules; pages never carry one\n for (const rule of rules) {\n if (rule.type === 5 /* CSSRule.FONT_FACE_RULE */) css += `${rule.cssText}\\n`;\n }\n }\n return css;\n };\n\n // Copy every computed declaration of src onto dst. The clone then needs no page stylesheet: var() is already resolved.\n const inlineStyle = (src, dst) => {\n const cs = getComputedStyle(src);\n let css = '';\n for (let i = 0; i < cs.length; i++) {\n const name = cs[i];\n const value = cs.getPropertyValue(name);\n if (value) css += `${name}:${value};`;\n }\n dst.style.cssText = css;\n };\n\n // A ::before / ::after box exists only while the rule applies, so copy its computed declarations into a rule of its own. Each element\n // that has one gets a data-cp marker; the marker keeps the rule from touching any other node in the picture.\n let cpSeq = 0;\n const pseudoRule = (src, dst, pseudo) => {\n const cs = getComputedStyle(src, pseudo);\n const content = cs.getPropertyValue('content');\n if (!content || content === 'none' || content === 'normal') return '';\n let css = '';\n for (let i = 0; i < cs.length; i++) {\n const name = cs[i];\n const value = cs.getPropertyValue(name);\n if (value) css += `${name}:${value};`;\n }\n if (!css) return '';\n const mark = dst.getAttribute('data-cp') ?? String(++cpSeq);\n dst.setAttribute('data-cp', mark);\n return `[data-cp=\"${mark}\"]${pseudo}{${css}}\\n`;\n };\n\n // The page's chrome means nothing in a picture: remove the controls and the navigational rail from the clone.\n const CHROME = '.am-code-copy, .am-diagram-expand, .am-table-controls, [class*=\"delta-switch\"], .am-toc, .am-remark-hover, .am-mark-note';\n\n function buildSvg(width, height) {\n const clone = main.cloneNode(true);\n // The clone has the same node order as the original, so one index walks both trees.\n const srcNodes = [main, ...main.querySelectorAll('*')];\n const dstNodes = [clone, ...clone.querySelectorAll('*')];\n for (let i = 0; i < srcNodes.length; i++) {\n inlineStyle(srcNodes[i], dstNodes[i]);\n }\n let pseudoCss = '';\n for (let i = 0; i < srcNodes.length; i++) {\n pseudoCss += pseudoRule(srcNodes[i], dstNodes[i], '::before');\n pseudoCss += pseudoRule(srcNodes[i], dstNodes[i], '::after');\n }\n for (const node of clone.querySelectorAll(CHROME)) node.remove();\n // A rasterized image is a static snapshot, not a scrollable viewport. Inlined computed styles turn auto heights\n // into fixed fractional heights on scrolling containers (.am-table-wrap, .am-diagram, .am-annot-scroll, .am-math-block, pre),\n // and subpixel rounding inside the foreignObject can trigger unwanted scrollbars. Reset unconstrained containers to visible and auto.\n // For containers with an author-specified finite max-height, keep inlined height and max-height, and hide overflow.\n for (const scroller of clone.querySelectorAll('.am-table-wrap, .am-diagram, .am-annot-scroll, .am-math-block, pre')) {\n const maxH = parseFloat(scroller.style.maxHeight || scroller.style.getPropertyValue('max-height'));\n if (Number.isFinite(maxH) && maxH >= 0) {\n scroller.style.setProperty('overflow', 'hidden', 'important');\n } else {\n scroller.style.setProperty('overflow', 'visible', 'important');\n scroller.style.setProperty('height', 'auto', 'important');\n scroller.style.setProperty('max-height', 'none', 'important');\n }\n }\n clone.style.margin = '0';\n clone.style.width = `${width}px`;\n clone.style.maxWidth = 'none';\n\n const wrap = document.createElementNS(XHTML, 'div');\n wrap.setAttribute('xmlns', XHTML);\n const body = getComputedStyle(document.body);\n wrap.style.cssText = `width:${width}px;height:${height}px;margin:0;padding:0;box-sizing:border-box;color:${body.color};font-family:${body.fontFamily};font-size:${body.fontSize};line-height:${body.lineHeight};background-color:${body.backgroundColor};background-image:${body.backgroundImage};`;\n\n const style = document.createElementNS(XHTML, 'style');\n style.textContent = `${fontFaceCss()}\\n${pseudoCss}`;\n wrap.append(style, clone);\n\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('xmlns', SVG);\n svg.setAttribute('width', String(width));\n svg.setAttribute('height', String(height));\n svg.setAttribute('viewBox', `0 0 ${width} ${height}`);\n const foreign = document.createElementNS(SVG, 'foreignObject');\n foreign.setAttribute('x', '0');\n foreign.setAttribute('y', '0');\n foreign.setAttribute('width', String(width));\n foreign.setAttribute('height', String(height));\n foreign.append(wrap);\n svg.append(foreign);\n return new XMLSerializer().serializeToString(svg);\n }\n\n // A canvas may not exceed the browser's dimension or area limit: shrink the pixels rather than fail on a long page. No lower bound:\n // one would let a very long page exceed the limits again.\n const pixelScale = (width, height) => {\n const wanted = Math.min(2, window.devicePixelRatio || 1);\n return Math.min(wanted, MAX_DIM / width, MAX_DIM / height, Math.sqrt(MAX_AREA / (width * height)));\n };\n\n async function rasterize() {\n await document.fonts?.ready;\n const rect = main.getBoundingClientRect();\n const width = Math.max(1, Math.ceil(Math.max(rect.width, main.scrollWidth)));\n const height = Math.max(1, Math.ceil(Math.max(rect.height, main.scrollHeight)));\n const svg = buildSvg(width, height);\n const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n const image = new Image();\n image.decoding = 'async';\n await new Promise((resolve, reject) => {\n image.onload = resolve;\n image.onerror = () => reject(new Error('the browser cannot draw the page as an SVG image'));\n image.src = url;\n });\n const scale = pixelScale(width, height);\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, Math.round(width * scale));\n canvas.height = Math.max(1, Math.round(height * scale));\n const ctx = canvas.getContext('2d');\n ctx.drawImage(image, 0, 0, canvas.width, canvas.height);\n const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/png'));\n if (!blob) throw new Error('the browser could not encode the image');\n return blob;\n }\n\n // The PNG is saved under the page title (letters and digits of any script, joined by dashes).\n const fileName = () => {\n const slug = (document.title || '').toLowerCase().replace(/[^\\p{L}\\p{N}]+/gu, '-').slice(0, 40).replace(/^-+|-+$/g, '');\n return `${slug || 'page'}.png`;\n };\n const download = (blob) => {\n const link = document.createElement('a');\n link.href = URL.createObjectURL(blob);\n link.download = fileName();\n document.body.append(link);\n link.click();\n link.remove();\n setTimeout(() => URL.revokeObjectURL(link.href), 4000);\n };\n\n // Start rasterizing, then hand the pending blob to ClipboardItem and write within the same click task so the browser keeps the\n // user's activation. Awaiting the raster first would spend it, and the write would be rejected. The write can be refused at once\n // while the page is still being drawn; wait for both to settle, so a retry cannot start a second rasterization beside the first.\n const copy = async () => {\n const blobPromise = rasterize();\n const written = (async () => {\n await navigator.clipboard.write([new ClipboardItem({ 'image/png': blobPromise })]);\n })();\n const [write] = await Promise.allSettled([written, blobPromise]);\n if (write.status === 'rejected') throw write.reason;\n };\n const save = async () => { download(await rasterize()); };\n\n async function run(work, done) {\n busy = true;\n sync();\n say(text.working, false);\n try {\n await work();\n say(done, true);\n } catch (e) {\n console.error('[am] export failed', e);\n say(text.failed, true);\n } finally {\n busy = false;\n sync();\n }\n }\n\n // The menu. Native: the popover opens and closes itself and tells us through toggle events. Fallback: the same menu toggled by a\n // class, with Esc and a click outside handled here.\n const isOpen = () => (native ? menu.matches(':popover-open') : menu.classList.contains('is-open'));\n // Under the button, aligned to its inline-end edge, and inside the viewport (the toolbar scrolls sideways on a phone, so the button\n // can sit near an edge). On a short viewport the menu is cut to the space below the button and scrolls, so every item stays reachable.\n const place = () => {\n const r = btn.getBoundingClientRect();\n // clientWidth, not 100vw: the viewport width in CSS includes a classic scrollbar, so a menu sized from it can stick out.\n const room = document.documentElement.clientWidth - 16;\n menu.style.maxWidth = `${room}px`;\n menu.style.minWidth = `${Math.min(200, room)}px`;\n const width = menu.offsetWidth;\n const rtl = getComputedStyle(btn).direction === 'rtl';\n const left = Math.max(8, Math.min(rtl ? r.left : r.right - width, document.documentElement.clientWidth - 8 - width));\n const top = r.bottom + 6;\n menu.style.top = `${top}px`;\n menu.style.left = `${left}px`;\n menu.style.maxHeight = `${Math.max(48, document.documentElement.clientHeight - 8 - top)}px`;\n };\n const firstEnabled = () => items.find((el) => el.getAttribute('aria-disabled') !== 'true');\n const opened = () => {\n btn.setAttribute('aria-expanded', 'true');\n place();\n menu.style.visibility = '';\n firstEnabled()?.focus();\n };\n const closed = (restoreFocus) => {\n btn.setAttribute('aria-expanded', 'false');\n if (restoreFocus || menu.contains(document.activeElement)) btn.focus();\n };\n const close = (restoreFocus = true) => {\n if (!isOpen()) return;\n if (native) menu.hidePopover();\n else { menu.classList.remove('is-open'); closed(restoreFocus); }\n };\n\n if (native) {\n // Place the box before it is first drawn, so it never flashes in the wrong spot.\n menu.addEventListener('beforetoggle', (e) => {\n btn.setAttribute('aria-expanded', String(e.newState === 'open'));\n if (e.newState === 'open') menu.style.visibility = 'hidden';\n });\n menu.addEventListener('toggle', (e) => { if (e.newState === 'open') opened(); else closed(false); });\n } else {\n // No popover: the browser must not half-handle the attributes, and the button toggles the class itself.\n menu.removeAttribute('popover');\n btn.removeAttribute('popovertarget');\n btn.addEventListener('click', () => {\n if (isOpen()) close();\n else { menu.classList.add('is-open'); opened(); }\n });\n document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && isOpen()) { e.preventDefault(); close(); } });\n document.addEventListener('pointerdown', (e) => { if (isOpen() && !menu.contains(e.target) && !btn.contains(e.target)) close(false); });\n }\n window.addEventListener('resize', () => { if (isOpen()) place(); });\n\n menu.addEventListener('keydown', (e) => {\n const at = items.indexOf(document.activeElement);\n const to = { ArrowDown: at + 1, ArrowUp: at - 1, Home: 0, End: items.length - 1 }[e.key];\n if (to !== undefined) {\n e.preventDefault();\n items[(to + items.length) % items.length].focus();\n } else if (e.key === 'Tab') {\n close(true); // focus goes back to the button and Tab then moves on from there\n }\n });\n\n menu.addEventListener('click', (e) => {\n const el = e.target.closest('[data-export]');\n if (!el || el.getAttribute('aria-disabled') === 'true') return;\n close();\n if (el === pdfItem) window.print();\n else if (el === copyItem) run(copy, text.copied);\n else run(save, text.saved);\n });\n})();\n})();\n";
|
|
752
|
+
var RUNTIME_JS = "(() => {\n// How a formula reads in a quote. MathML has no plain text, so src/math.js writes the formula as the draft wrote it, delimiters included, in\n// data-am-tex on the <math> element, and the Remark and Reply scripts read page text through this file. On a page without math there is no\n// such element, so formulaOf is null and every text comes out as it did before.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped (src/runtime/compose.js).\n\nconst TEX = 'data-am-tex';\n\n// The formula that holds a node, or null.\nconst formulaOf = (node) => node.parentElement?.closest(`[${TEX}]`) ?? null;\n\nconst firstText = (el) => {\n for (const child of el.childNodes) {\n const found = child.nodeType === 3 ? child : firstText(child);\n if (found) return found;\n }\n return null;\n};\n\n// What a text node adds to a quote: its data. The first text node of a formula adds the formula, and the others add nothing.\n// (A formula in an error style is plain text with its delimiters, not a <math>, so it comes out once.)\nfunction nodeText(node) {\n const math = formulaOf(node);\n if (!math) return node.data;\n return firstText(math) === node ? math.getAttribute(TEX) : '';\n}\n\n// The text of a node as textContent reads it, but with each formula as written.\nconst textWithMath = (node) => (node.nodeType === 3 ? nodeText(node) : [...node.childNodes].map(textWithMath).join(''));\n\n(() => {\n const root = document.documentElement;\n // A host that serves this page inside its own document leaves the real root without the page's settings. The toolbar keeps a copy;\n // set back what the root lacks, before anything below reads the root. A root's own value, even an empty one, is kept, except a\n // theme or mode that no toolbar option names: that is the host's own setting (the Claude desktop app sets data-theme=\"dark\"), and\n // keeping it would leave the page unstyled.\n const carrier = document.querySelector('.am-toolbar');\n const listFor = { 'data-theme': 'theme', 'data-mode': 'mode' };\n const foreign = (attr, value) => {\n const options = listFor[attr] && document.querySelector(`select[data-am=\"${listFor[attr]}\"]`)?.options;\n return Boolean(value) && options != null && ![...options].some((o) => o.value === value);\n };\n for (const [attr, key] of [['lang', 'data-am-root-lang'], ['dir', 'data-am-root-dir'], ['data-theme', 'data-am-root-theme'], ['data-mode', 'data-am-root-mode'], ['data-style', 'data-am-root-style']]) {\n const own = root.getAttribute(attr);\n if ((own === null || foreign(attr, own)) && carrier?.getAttribute(key) != null) root.setAttribute(attr, carrier.getAttribute(key));\n }\n // Each toolbar list sets one root attribute; its options name the values, so the runtime names no theme or mode.\n for (const [name, attr] of [['theme', 'data-theme'], ['mode', 'data-mode']]) {\n const select = document.querySelector(`select[data-am=\"${name}\"]`);\n if (!select) continue;\n select.value = root.getAttribute(attr);\n select.addEventListener('change', () => root.setAttribute(attr, select.value));\n }\n\n // \u2500\u2500 Text size \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // A\u2212 / A+ set --am-scale on the root; every page size and line (src/themes/type-scale.js) follows it, and the drawing boxes grow\n // with it while their viewBox keeps the units Node measured. The buttons carry the range from SCALE, so this script keeps no\n // second copy of the numbers. A reader's choice is remembered in this browser and wins over the page's own scale; where storage\n // is off (am serve, file://) it lasts for this tab, and the click still works.\n const scaleDown = document.querySelector('[data-am=\"scale-down\"]');\n const scaleUp = document.querySelector('[data-am=\"scale-up\"]');\n if (scaleDown && scaleUp) {\n const min = Number(scaleDown.dataset.min);\n const max = Number(scaleDown.dataset.max);\n const step = Number(scaleDown.dataset.step);\n const storeKey = 'am-scale';\n let value;\n\n const inRange = (n) => Number.isFinite(n) && n >= min && n <= max;\n const savedScale = () => {\n try {\n return Number(localStorage.getItem(storeKey));\n } catch {\n return NaN;\n }\n };\n const saveScale = (n) => {\n try {\n localStorage.setItem(storeKey, String(n));\n } catch {\n // Storage may be off (am serve, file://); the size then lasts until the tab closes.\n }\n };\n\n const updateButtons = () => {\n const setUnavailable = (btn, unavailable) => {\n if (unavailable) btn.setAttribute('aria-disabled', 'true');\n else btn.removeAttribute('aria-disabled');\n };\n setUnavailable(scaleDown, value <= min);\n setUnavailable(scaleUp, value >= max);\n };\n\n // One step is a multiple of `step`: Math.round first, then two decimals, so 1.1500000000000001 becomes 1.15.\n const setScale = (next, remember = false) => {\n value = Math.min(max, Math.max(min, Number((Math.round(next / step) * step).toFixed(2))));\n root.style.setProperty('--am-scale', String(value));\n for (const svg of document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas) > svg:is([role=\"img\"], [role=\"group\"])')) {\n const box = svg.viewBox?.baseVal;\n if (!box || !(box.width > 0) || !(box.height > 0)) continue;\n svg.setAttribute('width', String(Math.ceil(box.width * value)));\n svg.setAttribute('height', String(Math.ceil(box.height * value)));\n }\n updateButtons();\n if (remember) saveScale(value);\n window.dispatchEvent(new Event('am-scale'));\n };\n\n // A page with no stored choice is left exactly as it was rendered: no inline variable, no svg rewrite, no extra layout pass.\n value = parseFloat(getComputedStyle(root).getPropertyValue('--am-scale')) || 1;\n updateButtons();\n const saved = savedScale();\n if (inRange(saved) && saved !== value) setScale(saved);\n scaleDown.hidden = false;\n scaleUp.hidden = false;\n scaleDown.addEventListener('click', () => {\n if (scaleDown.getAttribute('aria-disabled') === 'true') return;\n setScale(value - step, true);\n });\n scaleUp.addEventListener('click', () => {\n if (scaleUp.getAttribute('aria-disabled') === 'true') return;\n setScale(value + step, true);\n });\n }\n\n // A phone cannot show the whole toolbar. Its end (Reply, Remark, Copy source) is what a phone showed before the text-size\n // buttons, so open at that end: Theme, Mode and A\u2212 / A+ are reached by scrolling toward the start. A reader scroll leaves the\n // position we set, so a later resize does not pull the toolbar back.\n if (carrier) {\n const rtl = getComputedStyle(carrier).direction === 'rtl';\n let lastProgrammatic = null;\n let readerScrolled = false;\n const scrollToEnd = () => {\n if (carrier.scrollWidth <= carrier.clientWidth) return;\n // Chrome keeps a right-to-left box's scrollLeft negative; the browser clamps either value to the real end.\n carrier.scrollTo({ left: rtl ? -carrier.scrollWidth : carrier.scrollWidth });\n lastProgrammatic = carrier.scrollLeft;\n };\n carrier.addEventListener('scroll', () => {\n if (Math.abs(carrier.scrollLeft - lastProgrammatic) > 1) readerScrolled = true;\n });\n scrollToEnd();\n addEventListener('resize', () => {\n if (!readerScrolled) scrollToEnd();\n });\n }\n\n // The toolbar floats over the top corner, and its width changes (the new-version button, a longer language, a phone). The header keeps\n // its first lines clear of it with a float of the toolbar's own size (base.css, .am-bar-fit .am-head::before): only the lines next to\n // the toolbar get shorter, and a title below it keeps the whole header. The size is measured here and set as --am-bar-w / --am-bar-h;\n // without this script the CSS keeps a fixed 300px reservation instead.\n const head = document.querySelector('.am-head');\n if (carrier && head) {\n const GAP = 12;\n const fit = () => {\n const bar = carrier.getBoundingClientRect();\n const box = head.getBoundingClientRect();\n const toward = getComputedStyle(head).direction === 'rtl' ? bar.right - box.left : box.right - bar.left;\n // The header's top in the page, not in the window, since the toolbar stays in the window while the page scrolls.\n const reach = bar.bottom + GAP / 2 - (box.top + scrollY);\n root.style.setProperty('--am-bar-w', `${toward > 0 && reach > 0 ? Math.ceil(toward + GAP) : 0}px`);\n root.style.setProperty('--am-bar-h', `${Math.max(0, Math.ceil(reach))}px`);\n };\n root.classList.add('am-bar-fit');\n fit();\n new ResizeObserver(fit).observe(carrier);\n addEventListener('resize', fit);\n document.fonts?.ready.then(fit);\n }\n\n // True when the text is on the clipboard, false when both paths failed. The async clipboard API is refused on some origins\n // (a page the browser treats as insecure), so the textarea and execCommand are the fallback, and execCommand reports whether\n // it copied anything. A button that says it copied when nothing did is worse than one that admits the copy failed: the reader\n // pastes whatever the clipboard already held.\n const copyText = async (text) => {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n const ta = Object.assign(document.createElement('textarea'), { value: text });\n document.body.append(ta);\n try {\n ta.select();\n return document.execCommand?.('copy') === true;\n } catch {\n return false; // execCommand can throw instead of returning false: that copy failed too\n } finally {\n ta.remove();\n }\n }\n };\n // A button reads its label from data-done for a moment after a copy, then comes back to the label it started from. That label is\n // read once, here: a second click inside the moment would otherwise read the copied label off the button and restore that instead,\n // and the label would never come back. The moment starts again on each click: the timer of the previous one is left to fire and\n // does nothing (a token, so this needs no timer bookkeeping the page scripts do not already have). A failed copy reads data-failed\n // instead, in the page language.\n const flasher = (btn) => {\n const idle = btn.textContent;\n let clicks = 0;\n return (copied) => {\n btn.textContent = copied ? btn.dataset.done : btn.dataset.failed;\n const mine = ++clicks;\n setTimeout(() => { if (mine === clicks) btn.textContent = idle; }, 1400);\n };\n };\n\n const copyBtn = document.querySelector('[data-am=\"copy\"]');\n if (copyBtn) {\n const flash = flasher(copyBtn);\n copyBtn.addEventListener('click', async () => {\n const nodes = document.querySelectorAll('#am-source');\n flash(await copyText(nodes[nodes.length - 1]?.value ?? ''));\n });\n }\n\n // Each code block copies its own lines, without the line numbers.\n for (const btn of document.querySelectorAll('[data-am=\"copy-code\"]')) {\n const flash = flasher(btn);\n btn.addEventListener('click', async () => {\n const lines = btn.closest('.am-codeblock')?.querySelectorAll('.am-ln') ?? [];\n flash(await copyText([...lines].map((l) => l.textContent).join('\\n')));\n });\n }\n\n // \u2500\u2500 Sideways scroll cue \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Overlay scrollbars (macOS) show nothing until the reader scrolls, so a wide code block or diagram looked cut off. While a box\n // hides content past its left or right edge it carries am-more-left / am-more-right, and base.css fades that edge. The sides are\n // physical because a box can read in the other direction than the page (code stays left to right on a right-to-left page); there\n // scrollLeft counts down from 0, so the hidden amounts use its size.\n const scrollers = document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas), .am-code, .am-annot-scroll');\n const markMore = (el) => {\n const hidden = el.scrollWidth - el.clientWidth;\n let left = false;\n let right = false;\n if (hidden > 1) {\n const atStart = Math.abs(el.scrollLeft);\n const rtl = getComputedStyle(el).direction === 'rtl';\n [left, right] = rtl ? [atStart < hidden - 1, atStart > 1] : [atStart > 1, atStart < hidden - 1];\n }\n el.classList.toggle('am-more-left', left);\n el.classList.toggle('am-more-right', right);\n };\n if (scrollers.length) {\n const resized = typeof ResizeObserver === 'function' ? new ResizeObserver((entries) => entries.forEach((e) => markMore(e.target))) : null;\n for (const el of scrollers) {\n el.addEventListener('scroll', () => markMore(el), { passive: true });\n resized?.observe(el);\n markMore(el);\n }\n }\n\n // \u2500\u2500 Diagram Lightbox & Pan-Zoom Viewer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const diagrams = document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas)');\n const lb = document.querySelector('.am-lightbox');\n if (diagrams.length && lb) {\n const backdrop = lb.querySelector('.am-lightbox-backdrop');\n const titleText = lb.querySelector('.am-lightbox-title-text');\n const stage = lb.querySelector('.am-lightbox-stage');\n const canvas = lb.querySelector('.am-lightbox-canvas');\n const closeBtn = lb.querySelector('.am-lightbox-close');\n const expandLabel = lb.getAttribute('data-expand') || 'Expand diagram';\n\n let scale = 1, x = 0, y = 0, fitScale = 1, curVw = 800, curVh = 600;\n let isDragging = false, activePointerId = null, startX = 0, startY = 0, origX = 0, origY = 0;\n let lastTrigger = null;\n\n const apply = () => {\n canvas.style.transform = `translate3d(${x.toFixed(2)}px, ${y.toFixed(2)}px, 0) scale(${scale.toFixed(4)})`;\n };\n\n const zoomTo = (newScale, pivotX, pivotY) => {\n newScale = Math.max(0.2, Math.min(6.0, newScale));\n if (Math.abs(newScale - scale) < 0.0001) return;\n const r = newScale / scale;\n x = pivotX - (pivotX - x) * r;\n y = pivotY - (pivotY - y) * r;\n scale = newScale;\n apply();\n };\n\n const open = (diag, trigger) => {\n const svg = [...diag.children].find((el) => el.tagName.toLowerCase() === 'svg');\n if (!svg) return;\n lastTrigger = trigger;\n\n const panel = diag.closest('.am-panel');\n const panelTitle = panel?.querySelector('.am-panel-head h2')?.textContent?.trim() || panel?.querySelector('h2')?.textContent?.trim() || lb.getAttribute('aria-label') || 'Diagram viewer';\n if (titleText) titleText.textContent = panelTitle;\n\n const clone = svg.cloneNode(true);\n // A linked diagram (a steps block) is a still picture here: its listeners live on its block, not on the viewer.\n clone.querySelectorAll('[data-link]').forEach((el) => {\n for (const attr of ['data-link', 'tabindex', 'role', 'aria-label']) el.removeAttribute(attr);\n });\n clone.querySelectorAll('[data-ends]').forEach((el) => el.removeAttribute('data-ends'));\n const defElements = clone.querySelectorAll('[id]');\n if (defElements.length) {\n const idMap = new Map();\n defElements.forEach((el, i) => {\n const oldId = el.id;\n const newId = `${oldId}-lb-${i}`;\n idMap.set(oldId, newId);\n el.id = newId;\n });\n const urlAttrs = ['marker-start', 'marker-mid', 'marker-end', 'fill', 'stroke', 'filter', 'clip-path', 'mask'];\n clone.querySelectorAll('*').forEach((el) => {\n for (const attr of urlAttrs) {\n const val = el.getAttribute(attr);\n if (val && val.startsWith('url(#')) {\n const id = val.slice(5, -1);\n if (idMap.has(id)) el.setAttribute(attr, `url(#${idMap.get(id)})`);\n }\n }\n const href = el.getAttribute('href') || el.getAttribute('xlink:href');\n if (href && href.startsWith('#')) {\n const id = href.slice(1);\n if (idMap.has(id)) {\n if (el.hasAttribute('href')) el.setAttribute('href', `#${idMap.get(id)}`);\n if (el.hasAttribute('xlink:href')) el.setAttribute('xlink:href', `#${idMap.get(id)}`);\n }\n }\n });\n }\n\n const vb = svg.viewBox?.baseVal;\n curVw = (vb && vb.width > 0) ? vb.width : (parseFloat(svg.getAttribute('width')) || svg.clientWidth || 800);\n curVh = (vb && vb.height > 0) ? vb.height : (parseFloat(svg.getAttribute('height')) || svg.clientHeight || 600);\n // The panel's svg carries the reading floor as min-width (layout-dom.js floorDiagrams); the viewer sizes the clone itself.\n clone.style.minWidth = '';\n clone.style.width = `${curVw}px`;\n clone.style.height = `${curVh}px`;\n canvas.innerHTML = '';\n canvas.append(clone);\n lb.removeAttribute('hidden');\n document.body.style.overflow = 'hidden';\n\n const rect = stage.getBoundingClientRect();\n const pad = 48;\n const availW = Math.max(100, rect.width - pad * 2);\n const availH = Math.max(100, rect.height - pad * 2);\n fitScale = Math.min(availW / curVw, availH / curVh, 1.0);\n scale = fitScale;\n x = (rect.width - curVw * scale) / 2;\n y = (rect.height - curVh * scale) / 2;\n apply();\n closeBtn.focus();\n };\n\n const close = () => {\n if (lb.hasAttribute('hidden')) return;\n lb.setAttribute('hidden', '');\n canvas.innerHTML = '';\n document.body.style.overflow = '';\n lastTrigger?.focus();\n };\n\n stage.addEventListener('wheel', (e) => {\n e.preventDefault();\n const rect = stage.getBoundingClientRect();\n const dy = e.deltaMode === 1 ? e.deltaY * 16 : (e.deltaMode === 2 ? e.deltaY * 400 : e.deltaY);\n const factor = Math.exp(-Math.max(-200, Math.min(200, dy)) * 0.0015);\n zoomTo(scale * factor, e.clientX - rect.left, e.clientY - rect.top);\n }, { passive: false });\n\n stage.addEventListener('pointerdown', (e) => {\n if (e.button !== 0 || isDragging) return;\n isDragging = true;\n activePointerId = e.pointerId;\n startX = e.clientX;\n startY = e.clientY;\n origX = x;\n origY = y;\n stage.setPointerCapture(e.pointerId);\n stage.classList.add('am-panning');\n });\n\n stage.addEventListener('pointermove', (e) => {\n if (!isDragging || e.pointerId !== activePointerId) return;\n x = origX + (e.clientX - startX);\n y = origY + (e.clientY - startY);\n apply();\n });\n\n const endDrag = (e) => {\n if (!isDragging || e.pointerId !== activePointerId) return;\n isDragging = false;\n activePointerId = null;\n stage.classList.remove('am-panning');\n try { stage.releasePointerCapture(e.pointerId); } catch {}\n };\n stage.addEventListener('pointerup', endDrag);\n stage.addEventListener('pointercancel', endDrag);\n\n stage.addEventListener('dblclick', () => {\n const rect = stage.getBoundingClientRect();\n scale = fitScale;\n x = (rect.width - curVw * scale) / 2;\n y = (rect.height - curVh * scale) / 2;\n apply();\n });\n\n closeBtn.addEventListener('click', close);\n backdrop.addEventListener('click', close);\n window.addEventListener('keydown', (e) => {\n if (e.key === 'Escape' && !lb.hasAttribute('hidden')) close();\n });\n\n lb.addEventListener('keydown', (e) => {\n if (e.key !== 'Tab') return;\n const focusables = lb.querySelectorAll('button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])');\n if (!focusables.length) return;\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n });\n\n const expandSvg = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><polyline points=\"15 3 21 3 21 9\"></polyline><polyline points=\"9 21 3 21 3 15\"></polyline><line x1=\"21\" y1=\"3\" x2=\"14\" y2=\"10\"></line><line x1=\"3\" y1=\"21\" x2=\"10\" y2=\"14\"></line></svg>';\n diagrams.forEach((diag) => {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = 'am-diagram-expand';\n btn.title = expandLabel;\n btn.setAttribute('aria-label', expandLabel);\n btn.innerHTML = expandSvg;\n btn.addEventListener('click', () => open(diag, btn));\n diag.prepend(btn);\n });\n }\n})();\n(() => {\n// The reply a reader copies from the page: one Markdown text with the decisions, the panel comments and the block remarks.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped (src/runtime/compose.js).\n// decisions: [{ panel, question, picked: [label], suggested: [label], touched }]; comments: [{ panel, title, text }];\n// remarks: [{ panel, quote, kind, note }], where quote is the start of the marked block and kind is a key of ui.kinds.\n// Comment and remark text is quoted line by line, so text the reader typed cannot pass as part of the structure.\n// rtl: the page reads right to left, so the arrow before each answer points left, the way the text runs.\nfunction replyText({ title, decisions, comments, remarks = [], ui, rtl = false }) {\n const arrow = rtl ? '\u2190' : '\u2192';\n const out = [`# Re: ${title}`];\n if (decisions.length) {\n out.push('', `## ${ui.decisions}`);\n decisions.forEach((d, i) => {\n const answer = d.picked.length ? d.picked.map((l) => `**${l}**`).join(', ') : '**\u2014**';\n // Every option starts unselected, so an ask the reader never clicked has no answer: the reply names the suggestion\n // instead of passing it off as the reader's choice.\n const same = d.picked.length === d.suggested.length && d.picked.every((l) => d.suggested.includes(l));\n const suggested = d.suggested.join(', ') || '\u2014';\n const why = !d.touched ? `${ui.untouched}: ${suggested}` : same ? ui.confirmed : `${ui.was}: ${suggested}`;\n out.push(`${i + 1}. [${d.panel}] ${d.question}`, ` ${arrow} ${answer} _(${why})_`);\n });\n }\n const written = comments.filter((c) => c.text.trim());\n const quoted = (text) => (text.trim() ? text.trim().split('\\n').map((l) => ` > ${l}`) : []);\n if (written.length) {\n out.push('', `## ${ui.comments}`);\n for (const c of written) out.push(`- **${c.panel} \xB7 ${c.title}**`, ...quoted(c.text));\n }\n if (remarks.length) {\n out.push('', `## ${ui.remarks}`);\n for (const r of remarks) {\n const label = [r.panel, ui.kinds?.[r.kind] ?? r.kind].filter(Boolean).join(' \xB7 ');\n out.push(`- **${label}** \"${r.quote}\"`, ...quoted(r.note));\n }\n }\n if (written.length || remarks.some((r) => r.note.trim())) out.push('', `_${ui.typed}_`);\n return `${out.join('\\n')}\\n`;\n}\n\n// A letter of a right-to-left script. One definition for the page builder (src/bidi.js) and for the right-to-left page script\n// (src/runtime/reply-view.js), so the two cannot drift apart. A plain ES module; the page script gets this file in front of\n// reply-view.js, with its `export` keyword dropped and reply-view.js's import of it removed (src/runtime/compose.js).\nconst RTL_LETTER = /[\\p{Script=Hebrew}\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Thaana}\\p{Script=Nko}\\p{Script=Samaritan}\\p{Script=Mandaic}]/u;\n\n// The reply as the reader sees it in the Reply sheet (src/runtime/reply.js): the Markdown that Copy copies, drawn as headings, bold answers\n// and quoted comments instead of raw \"# Re: ...\", \"1. [E] ...\" and \"- **A \xB7 ...**\" lines. Each line gets its own direction, so a\n// Hebrew reader sees Latin answers and paths in place; a line with no right-to-left letter reads left to right, as on any other page.\n// The raw Markdown stays in the sheet under a fold, so the copied text does not change.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped and rtl-letter.js in front of it in place of the\n// import (src/runtime/compose.js).\n\nconst escHtml = (s) => s.replace(/[&<>\"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '\"': '"' })[c]);\n// A line with a right-to-left letter reads right to left; a line without one (an English comment, a path) reads left to right.\nconst dirOf = (s) => (RTL_LETTER.test(s) ? 'rtl' : 'ltr');\n\n// The only inline Markdown src/runtime/reply-text.js writes: **answer**, _(note)_ and the \"quote\" of a remark. Each piece is isolated in its own direction,\n// so a Latin answer inside a Hebrew line keeps its place, and \"A \xB7 title\" still starts with the panel letter.\nconst piece = (tag, text) => `<${tag}><bdi dir=\"${dirOf(text)}\">${text}</bdi></${tag}>`;\nfunction inline(s) {\n return escHtml(s)\n .replace(/\\*\\*(.+?)\\*\\*/g, (_, t) => piece('strong', t))\n .replace(/(^|\\s)_(.+?)_(?=\\s|$)/g, (_, pre, t) => pre + piece('em', t))\n // The quoted start of a marked block (\"- **A \xB7 concern** \"text\"\"): isolated, so Latin text in a Hebrew line keeps its place.\n .replace(/"(.+)"$/, (_, t) => `"<bdi dir=\"${dirOf(t)}\">${t}</bdi>"`);\n}\n\n// The reply text (src/runtime/reply-text.js) as HTML, one block per line.\nfunction replyViewHtml(text) {\n return text\n .replace(/\\n$/, '')\n .split('\\n')\n .map((line) => {\n const dir = dirOf(line);\n let m;\n if (!line.trim()) return '<div class=\"am-rv-gap\"></div>';\n if ((m = line.match(/^(#{1,2}) (.*)$/))) return `<div class=\"am-rv-h${m[1].length}\" dir=\"${dir}\">${inline(m[2])}</div>`;\n if ((m = line.match(/^(\\d+)\\. \\[([^\\]]*)\\] (.*)$/))) {\n return `<div class=\"am-rv-q\" dir=\"${dir}\"><bdi>${m[1]}.</bdi> <bdi class=\"am-rv-tag\">${escHtml(m[2])}</bdi> ${inline(m[3])}</div>`;\n }\n if ((m = line.match(/^ {3}([\u2190\u2192]) (.*)$/))) return `<div class=\"am-rv-a\" dir=\"${dir}\">${m[1]} ${inline(m[2])}</div>`;\n if ((m = line.match(/^- (.*)$/))) return `<div class=\"am-rv-c\" dir=\"${dir}\">${inline(m[1])}</div>`;\n // A comment line is shown exactly as the reader typed it.\n if ((m = line.match(/^ {2}> ?(.*)$/))) return `<div class=\"am-rv-quote\" dir=\"${dirOf(m[1])}\">${escHtml(m[1]) || ' '}</div>`;\n return `<div dir=\"${dir}\">${inline(line)}</div>`;\n })\n .join('');\n}\n\n// Answer on the page: every panel gets a Comment box, and the Reply button collects the ask answers, the comments and the remarks\n// into one Markdown reply (replyText) to copy back to the agent. Answers and comments stay in localStorage across reloads.\n// The remark script (remark.js) adds the blocks the reader marked, through window.__amRemarkData, and tells this script about a change\n// with an \"am-remark-change\" event on the document.\n// The Reply sheet shows the reply drawn (replyViewHtml) with the Markdown that Copy copies under a fold. Once the reader has given any\n// input, a bar at the bottom of the page shows the counts and copies the reply in one click, so there is no trip to the top-right button.\nconst replyBtn = document.querySelector('[data-am=\"reply\"]');\nconst COMMENT_ICON = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"></path></svg>';\nif (replyBtn) {\n const ui = JSON.parse(replyBtn.dataset.ui);\n const storeKey = `am-reply:${location.pathname}`;\n // A page served by `am serve` runs without localStorage and the phone may discard its tab, so it keeps the answers on the\n // server: data-am-save names the write route and data-am-state carries what the server already holds for this page version.\n const serve = (() => {\n const { amSave: save, amState: state } = document.body?.dataset ?? {};\n if (!save) return null;\n try {\n return { save, restored: state ? JSON.parse(state) : null };\n } catch {\n return { save, restored: null };\n }\n })();\n let saveTimer = null;\n let pendingPatch = null;\n const sendSave = (patch) => {\n fetch(serve.save, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(patch), keepalive: true })\n .catch(() => {}); // a page that cannot reach the server keeps its state until it closes, as before\n };\n // Typing must not put one request per keystroke on the server; localStorage is written at once, the network follows.\n const saveSoon = (patch) => {\n clearTimeout(saveTimer);\n pendingPatch = patch;\n saveTimer = setTimeout(() => {\n pendingPatch = null;\n sendSave(patch);\n }, 400);\n };\n // A hidden or closing page sends the change it still holds, before the timer can run.\n const flushSave = () => {\n if (!pendingPatch) return;\n clearTimeout(saveTimer);\n sendSave(pendingPatch);\n pendingPatch = null;\n };\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') flushSave();\n });\n window.addEventListener('pagehide', flushSave);\n // A preview may draw a mock panel; it gets no comment box and cannot shadow the real panel's id.\n const panels = [...document.querySelectorAll('.am-panel')].filter((panel) => !panel.closest('.am-ask-preview'));\n // An ask inside a preview is part of the drawing, not a decision of the page.\n const asks = [...document.querySelectorAll('.am-ask')].filter((a) => !a.closest('.am-ask-preview'));\n // Answers are saved by question text, so they still match after am patch has renumbered the asks.\n // Page text without the word joiners a right-to-left page puts after a Hebrew prefix hyphen (src/bidi.js): the reply and the saved\n // answers hold the text as the draft wrote it, a formula too (src/runtime/math-text.js).\n const WJ = new RegExp(String.fromCharCode(0x2060), 'g');\n const textOf = (el) => el && textWithMath(el).replace(WJ, '').trim();\n const keyOf = (ask) => textOf(ask.querySelector('legend')) ?? ask.dataset.ask;\n const touched = new Set();\n const boxes = new Map();\n // The bar is built below with the sheet; the handlers that change the counts only call this.\n let refreshBar = () => {};\n // The textarea a failed copy keeps selected, so the reader can still use the keyboard shortcut.\n let stuck = null;\n\n const load = () => {\n if (serve?.restored?.reply) return serve.restored.reply;\n try {\n return JSON.parse(localStorage.getItem(storeKey)) || {};\n } catch {\n return {};\n }\n };\n const save = () => {\n const state = {\n asks: Object.fromEntries(asks.map((a) => [keyOf(a), { picked: picked(a), touched: touched.has(a) }])),\n comments: Object.fromEntries([...boxes].map(([id, box]) => [id, box.value]).filter(([, text]) => text.trim())),\n };\n try {\n localStorage.setItem(storeKey, JSON.stringify(state));\n } catch {\n // Storage may be off (private window, file:// policy); answers then last until the page closes.\n }\n if (serve) saveSoon({ reply: state });\n };\n // A preview can hold a mock form; those controls are a picture, not the reader's answer.\n const inputsOf = (ask) => [...ask.querySelectorAll('input')].filter((i) => !i.closest('.am-ask-preview'));\n const picked = (ask) => inputsOf(ask).filter((i) => i.checked).map((i) => i.value);\n const panelOf = (el) => {\n const panel = el.closest('.am-panel');\n return { id: panel?.id.replace(/^panel-/, '') ?? '', title: textOf(panel?.querySelector('.am-panel-head h2')) ?? '' };\n };\n\n const saved = load();\n for (const ask of asks) {\n const inputs = inputsOf(ask);\n const state = saved.asks?.[keyOf(ask)];\n // A saved answer applies only while every picked option still exists on the page, and only if the reader clicked: older versions started\n // with the suggestion selected and saved it untouched, and that state must come back unselected.\n if (state?.touched && Array.isArray(state.picked) && state.picked.every((v) => inputs.some((i) => i.value === v))) {\n for (const input of inputs) input.checked = state.picked.includes(input.value);\n touched.add(ask);\n }\n // A click counts even on the option that is already picked: the reader confirms the suggestion.\n const answer = (e) => {\n if (e?.target?.closest?.('.am-ask-preview')) return;\n touched.add(ask);\n save();\n refreshBar();\n };\n ask.addEventListener('change', answer);\n ask.addEventListener('click', (e) => { if (e.target.matches('input')) answer(e); });\n // In cards the whole card looks clickable, so a click on its preview picks the option too. A control in the drawing is not the answer.\n ask.addEventListener('click', (e) => {\n if (!ask.classList.contains('am-ask--cards')) return;\n if (!e.target.closest?.('.am-ask-preview') || e.target.closest('input, button, a, select, textarea, summary, label')) return;\n const input = e.target.closest('.am-ask-card')?.querySelector('input');\n if (!input) return;\n const wasPicked = input.checked;\n input.click();\n // A radio that is already on sends no change event, and the click still confirms the suggestion.\n if (wasPicked && input.type === 'radio') answer();\n });\n }\n\n for (const panel of panels) {\n const id = panel.id.replace(/^panel-/, '');\n // An icon only: narrow panels have no room for a word next to the title.\n const btn = Object.assign(document.createElement('button'), { type: 'button', className: 'am-comment-btn', title: ui.comment, innerHTML: COMMENT_ICON });\n btn.setAttribute('aria-label', `${ui.comment} ${id}`);\n btn.setAttribute('aria-expanded', 'false');\n const wrap = Object.assign(document.createElement('div'), { className: 'am-comment', hidden: true });\n const box = Object.assign(document.createElement('textarea'), { rows: 3, placeholder: ui.commentHint, value: saved.comments?.[id] ?? '' });\n box.setAttribute('aria-label', `${ui.comment} ${id}`);\n wrap.append(box);\n const show = (open) => {\n wrap.hidden = !open;\n btn.setAttribute('aria-expanded', String(open));\n };\n btn.addEventListener('click', () => {\n show(wrap.hidden);\n if (!wrap.hidden) box.focus();\n });\n box.addEventListener('input', () => {\n btn.classList.toggle('am-comment-btn--on', Boolean(box.value.trim()));\n save();\n refreshBar();\n });\n btn.classList.toggle('am-comment-btn--on', Boolean(box.value.trim()));\n if (box.value.trim()) show(true);\n (panel.querySelector('.am-panel-head') ?? panel).append(btn);\n panel.append(wrap);\n boxes.set(id, box);\n }\n\n const sheet = document.createElement('dialog');\n sheet.className = 'am-reply';\n sheet.setAttribute('aria-label', ui.title);\n sheet.innerHTML = '<div class=\"am-reply-head\"><strong></strong><span></span></div><div class=\"am-reply-view\" tabindex=\"0\"></div><details class=\"am-reply-raw\"><summary></summary><textarea readonly rows=\"10\"></textarea></details><div class=\"am-reply-actions\"><button type=\"button\" class=\"am-btn\" data-act=\"copy\"></button><button type=\"button\" class=\"am-btn\" data-act=\"close\"></button></div>';\n sheet.querySelector('strong').textContent = ui.title;\n sheet.querySelector('span').textContent = ui.hint;\n sheet.querySelector('summary').textContent = ui.raw;\n const view = sheet.querySelector('.am-reply-view');\n const raw = sheet.querySelector('details');\n const text = sheet.querySelector('textarea');\n const copy = sheet.querySelector('[data-act=\"copy\"]');\n const close = sheet.querySelector('[data-act=\"close\"]');\n copy.textContent = ui.copy;\n close.textContent = ui.close;\n document.body.append(sheet);\n\n const compose = () => {\n const decisions = asks.map((ask) => ({\n panel: panelOf(ask).id,\n question: textOf(ask.querySelector('legend')) ?? '',\n picked: picked(ask),\n suggested: inputsOf(ask).filter((i) => i.hasAttribute('data-suggested')).map((i) => i.value),\n touched: touched.has(ask),\n }));\n const comments = [...boxes].map(([id, box]) => ({ panel: id, title: panelOf(box).title, text: box.value }));\n const remarks = window.__amRemarkData?.() ?? [];\n const empty = !decisions.length && !comments.some((c) => c.text.trim()) && !remarks.length;\n const title = textOf(document.querySelector('.am-head h1')) ?? document.title;\n return empty ? '' : replyText({ title, decisions, comments, remarks, ui, rtl: document.documentElement.dir === 'rtl' });\n };\n\n // The text goes through the clipboard API; a page the browser treats as insecure (file://) falls back to selecting a temporary\n // textarea, because the sheet's own textarea can sit inside a closed fold, where it cannot be selected.\n // That fallback reports whether it worked. When it does not, the text stays selected (so Cmd/Ctrl+C still copies it) and the\n // button says what to do instead of showing the \"Copied \u2713\" label the reader cannot trust.\n const copyText = async (str, btn) => {\n stuck?.remove();\n stuck = null;\n try {\n await navigator.clipboard.writeText(str);\n // The close_after_reply script (close-after-reply.js) closes the tab once the reply is on the clipboard.\n document.dispatchEvent(new Event('am-reply-copied'));\n } catch {\n const tmp = Object.assign(document.createElement('textarea'), { value: str });\n tmp.style.cssText = 'position:fixed;top:-100px;opacity:0';\n // Inside the sheet while it is open: while a modal dialog is open the rest of the document cannot take focus, so a textarea\n // in the body can be selected but not focused, and the keyboard shortcut the reader is told to press would copy nothing.\n // The bottom bar copies while the sheet is closed, and a closed dialog is not rendered, so there the textarea goes in the body.\n (sheet.open ? sheet : document.body).append(tmp);\n tmp.select();\n let copied = false;\n try {\n copied = document.execCommand('copy');\n } catch {\n copied = false;\n }\n if (!copied) {\n stuck = tmp;\n btn.textContent = ui.copyFailed;\n setTimeout(() => { btn.textContent = ui.copy; }, 3000);\n return;\n }\n tmp.remove();\n }\n btn.textContent = ui.done;\n setTimeout(() => { btn.textContent = ui.copy; }, 1400);\n };\n\n const open = () => {\n const reply = compose();\n if (reply) view.innerHTML = replyViewHtml(reply);\n else view.textContent = ui.empty;\n view.scrollTop = 0;\n text.value = reply;\n raw.open = false;\n raw.hidden = !reply;\n copy.disabled = !reply;\n if (sheet.showModal) sheet.showModal();\n else sheet.setAttribute('open', '');\n (reply ? copy : close).focus();\n };\n replyBtn.addEventListener('click', open);\n close.addEventListener('click', () => (sheet.close ? sheet.close() : sheet.removeAttribute('open')));\n // A failed copy leaves the text selected for Cmd/Ctrl+C; closing the sheet drops that textarea.\n sheet.addEventListener('close', () => { stuck?.remove(); stuck = null; });\n copy.addEventListener('click', () => copyText(text.value, copy));\n\n const bar = Object.assign(document.createElement('div'), { className: 'am-reply-bar', hidden: true });\n bar.setAttribute('role', 'region');\n bar.setAttribute('aria-label', ui.title);\n const summary = Object.assign(document.createElement('span'), { className: 'am-reply-bar-count' });\n summary.setAttribute('aria-live', 'polite');\n const preview = Object.assign(document.createElement('button'), { type: 'button', className: 'am-btn', textContent: ui.preview });\n const barCopy = Object.assign(document.createElement('button'), { type: 'button', className: 'am-btn am-btn--reply', textContent: ui.copy });\n preview.addEventListener('click', open);\n barCopy.addEventListener('click', () => copyText(compose(), barCopy));\n bar.append(summary, preview, barCopy);\n document.body.append(bar);\n\n // The bar shows only the counts that are above zero, and only once there is any input at all.\n refreshBar = () => {\n const counts = {\n answered: touched.size,\n comments: [...boxes.values()].filter((box) => box.value.trim()).length,\n remarks: (window.__amRemarkData?.() ?? []).length,\n };\n const parts = Object.entries(counts).filter(([, n]) => n > 0).map(([kind, n]) => ui.count[kind].replace('{n}', n));\n summary.textContent = parts.join(' \xB7 ');\n bar.hidden = !parts.length;\n document.body.classList.toggle('am-has-reply-bar', parts.length > 0);\n };\n document.addEventListener('am-remark-change', () => refreshBar());\n // Saved remarks are restored by remark.js, which runs after this script in the same <script> element: its data is not there yet.\n // A microtask runs when that whole element has finished, so the first count includes them.\n queueMicrotask(() => refreshBar());\n}\n})();\n(() => {\n// Text helpers for remark mode (src/runtime/remark.js): how a marked block is named and quoted.\n// A plain ES module for tests; the page gets it with its `export` keyword dropped (src/runtime/compose.js).\n// A block keeps its mark across `am patch` because the key is its panel, its tag and the start of its text, not its position.\n\nconst collapse = (text) => String(text).replace(/\\s+/g, ' ').trim();\n\n// The start of a block's text with whitespace collapsed: the readable identity of the block.\nfunction fingerprint(text, len = 80) {\n return collapse(text).slice(0, len);\n}\n\n// What the reply quotes of a block: the start of its text, with an ellipsis when it is cut.\nfunction quote(text, len = 60) {\n const t = collapse(text);\n return t.length > len ? `${t.slice(0, len).trimEnd()}\u2026` : t;\n}\n\n// Two blocks with the same text (two identical list items) get the same base key. The n-th one in the page gets \"\\t<n>\" added;\n// a tab cannot be in a fingerprint, which has its whitespace collapsed, so the new key never meets another base key.\nfunction occurrenceKeys(bases) {\n const seen = new Map();\n return bases.map((base) => {\n const n = seen.get(base) ?? 0;\n seen.set(base, n + 1);\n return n ? `${base}\\t${n}` : base;\n });\n}\n\n// Remark mode: the reader turns it on, clicks a block, tags it (suggestion, keep, question, concern) and may add a note.\n// A mark shows as a bar and a note chip inside the block, lives in localStorage like panel comments, and the Reply button carries it\n// back to the agent: reply.js calls window.__amRemarkData, and replyText (reply-text.js) writes the Remarks section.\n(() => {\n const btn = document.querySelector('[data-am=\"remark\"]');\n if (!btn) return;\n const ui = JSON.parse(btn.dataset.ui);\n const KINDS = ['suggestion', 'keep', 'question', 'concern'];\n const storeKey = `am-remark:${location.pathname}`;\n // A page served by `am serve` has no localStorage and the phone may discard its tab; it keeps the marks on the server, in the\n // same record as the answers (reply.js), so a re-opened page finds them again.\n const serve = (() => {\n const { amSave: save, amState: state } = document.body?.dataset ?? {};\n if (!save) return null;\n try {\n return { save, restored: state ? JSON.parse(state) : null };\n } catch {\n return { save, restored: null };\n }\n })();\n let saveTimer = null;\n let pendingPatch = null;\n const sendSave = (patch) => {\n fetch(serve.save, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(patch), keepalive: true })\n .catch(() => {});\n };\n const saveSoon = (patch) => {\n clearTimeout(saveTimer);\n pendingPatch = patch;\n saveTimer = setTimeout(() => {\n pendingPatch = null;\n sendSave(patch);\n }, 400);\n };\n // A hidden or closing page sends the change it still holds, before the timer can run.\n const flushSave = () => {\n if (!pendingPatch) return;\n clearTimeout(saveTimer);\n sendSave(pendingPatch);\n pendingPatch = null;\n };\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') flushSave();\n });\n window.addEventListener('pagehide', flushSave);\n // The one definition of a block a reader can mark: the content under <main>. The page and panel titles are left out, because the\n // reply reads them as text; a panel has its Comment button.\n // A $$ block on its own is a div; a $$ formula inside a sentence is a span of its paragraph.\n const BLOCK = 'main :is(h1,h2,h3,h4,h5,h6,p,li,blockquote,pre,table,dd,dt,figure,div.am-math-block):not(.am-head *, .am-panel-head *, .am-toc *)';\n // A click on these does what it always did.\n const LIVE = '.am-remark-pop, .am-toolbar, a, button, input, textarea, select, label';\n const blockAt = (target) => (target.closest(LIVE) ? null : target.closest(BLOCK));\n\n const WJ = new RegExp(String.fromCharCode(0x2060), 'g'); // word joiners of a right-to-left page (src/bidi.js); not part of the draft's text\n // A narrow horizontal timeline shows its date and title inline (src/themes/base.css). They stay parts of their own, so a block key\n // does not change with the width of the window (#194).\n const OWN_BOX = '.am-timeline--h .am-tl-when, .am-timeline--h .am-tl-title';\n const inlineBox = new WeakMap();\n const isInline = (el) => {\n if (!inlineBox.has(el)) inlineBox.set(el, !el.matches(OWN_BOX) && getComputedStyle(el).display.startsWith('inline'));\n return inlineBox.get(el);\n };\n // The text of a block as the reader sees it: separate lines, cells and timeline parts are joined by a space (textContent would run\n // \"2026\" and \"Ship\" together), and the note chip is not part of it. A formula is one box and reads as the TeX the draft wrote\n // (src/runtime/math-text.js), not as the MathML tokens.\n const blockText = (el) => {\n const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);\n let text = '';\n let last = null;\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n if (node.parentElement.closest('.am-mark-note')) continue;\n let box = formulaOf(node) ?? node.parentElement;\n while (box !== el && isInline(box)) box = box.parentElement;\n if (last && box !== last) text += ' ';\n text += nodeText(node).replace(WJ, '');\n last = box;\n }\n return text;\n };\n\n const panelOf = (el) => el.closest('.am-panel')?.id.replace(/^panel-/, '') ?? '';\n // Block keys, in page order. Built when first needed: a page nobody marked pays nothing.\n let keys = null;\n const keyMap = () => {\n if (!keys) {\n const blocks = [...document.querySelectorAll(BLOCK)];\n const ids = occurrenceKeys(blocks.map((el) => `${panelOf(el)}|${el.localName}|${fingerprint(blockText(el))}`));\n keys = new Map(blocks.map((el, i) => [el, ids[i]]));\n }\n return keys;\n };\n\n const load = () => {\n const restored = serve?.restored?.remark;\n if (Array.isArray(restored)) return restored.filter((m) => typeof m?.key === 'string' && KINDS.includes(m.kind));\n try {\n const saved = JSON.parse(localStorage.getItem(storeKey));\n return Array.isArray(saved) ? saved.filter((m) => typeof m?.key === 'string' && KINDS.includes(m.kind)) : [];\n } catch {\n return [];\n }\n };\n // A mark whose block is gone from the page stays stored (it may return with `am patch`); it is neither painted nor sent.\n const marks = new Map(load().map((m) => [m.key, { key: m.key, kind: m.kind, note: String(m.note ?? '') }]));\n // Kind and note of a popover closed without Save, by block key, until the page reloads (see open below).\n const drafts = new Map();\n const clearBtn = document.createElement('button');\n clearBtn.type = 'button';\n clearBtn.className = 'am-btn am-btn--remark-clear';\n clearBtn.textContent = ui.clear;\n // Clear all drops saved marks and drafts, so it shows while either exists.\n const toClear = () => marks.size + drafts.size;\n const showClear = () => { clearBtn.hidden = toClear() === 0; };\n btn.insertAdjacentElement('afterend', clearBtn);\n let clearTimer = null;\n let clearArmed = false;\n const resetClear = () => {\n if (clearTimer !== null) clearTimeout(clearTimer);\n clearTimer = null;\n clearArmed = false;\n clearBtn.classList.remove('is-armed');\n clearBtn.textContent = ui.clear;\n showClear();\n };\n const armClear = () => {\n clearArmed = true;\n clearBtn.classList.add('is-armed');\n clearBtn.textContent = ui.clearConfirm.replace('{n}', toClear());\n clearTimer = setTimeout(resetClear, 4000);\n };\n clearBtn.addEventListener('click', () => {\n if (!clearArmed) {\n armClear();\n return;\n }\n for (const el of document.querySelectorAll('.am-mark')) unpaint(el);\n marks.clear();\n // A draft is a remark the reader has not saved yet; Clear all drops it too, so no block reopens with an old kind.\n drafts.clear();\n try {\n localStorage.removeItem(storeKey);\n } catch {\n // Storage may be off (private window, a sandboxed page); the in-memory marks still clear.\n }\n if (serve) saveSoon({ remark: [] });\n resetClear();\n document.dispatchEvent(new Event('am-remark-change'));\n });\n const save = () => {\n try {\n localStorage.setItem(storeKey, JSON.stringify([...marks.values()]));\n } catch {\n // Storage may be off (private window, a sandboxed page); marks then last until the page closes.\n }\n if (serve) saveSoon({ remark: [...marks.values()] });\n // The reply bar (reply.js) shows the number of marks.\n document.dispatchEvent(new Event('am-remark-change'));\n showClear();\n };\n\n const chip = (el, mark) => {\n const note = document.createElement(el.localName === 'table' ? 'caption' : 'span');\n note.className = 'am-mark-note';\n const kind = document.createElement('b');\n kind.textContent = ui.kinds[mark.kind];\n note.append(kind, mark.note ? ` ${mark.note}` : '');\n return note;\n };\n const clearChip = (el) => el.querySelector(':scope > .am-mark-note')?.remove();\n const paint = (el, mark) => {\n clearChip(el);\n el.classList.add('am-mark');\n el.dataset.kind = mark.kind;\n // Inside the block, so a list item stays a child of its list. A table takes it as its caption; a list item with a sub-list shows\n // it under its own text, before the sub-list.\n const sub = el.querySelector(':scope > ul, :scope > ol');\n if (el.localName === 'table') el.prepend(chip(el, mark));\n else if (sub) sub.before(chip(el, mark));\n else el.append(chip(el, mark));\n };\n const unpaint = (el) => {\n clearChip(el);\n el.classList.remove('am-mark');\n delete el.dataset.kind;\n };\n showClear();\n if (marks.size) for (const [el, key] of keyMap()) if (marks.has(key)) paint(el, marks.get(key));\n\n // The popover edits one block. Save stays off until a kind is picked, and a hint says so. 1\u20134 pick a kind from the keyboard and\n // move to the note; Ctrl / Cmd + Enter saves. A popover closed without Save keeps its kind and note as a draft for that block until the page reloads.\n const pop = document.createElement('div');\n pop.className = 'am-remark-pop';\n pop.hidden = true;\n pop.setAttribute('role', 'dialog');\n pop.setAttribute('aria-label', ui.button);\n document.body.append(pop);\n let opener = null;\n let anchor = null;\n let keepDraft = null;\n const close = (restoreFocus) => {\n if (pop.hidden) return;\n keepDraft?.();\n keepDraft = null;\n pop.hidden = true;\n if (restoreFocus) (opener?.isConnected && opener !== document.body ? opener : btn).focus();\n };\n const place = () => {\n const rect = anchor.getBoundingClientRect();\n const rtl = getComputedStyle(document.documentElement).direction === 'rtl';\n const x = rtl ? rect.right - pop.offsetWidth : rect.left;\n // Under the block; a block taller than the window gets the popover at the bottom of the window instead.\n const y = Math.min(rect.bottom + 6, window.innerHeight - pop.offsetHeight - 8);\n pop.style.left = `${window.scrollX + Math.min(Math.max(8, x), window.innerWidth - pop.offsetWidth - 8)}px`;\n pop.style.top = `${window.scrollY + Math.max(8, y)}px`;\n };\n const make = (tag, props) => Object.assign(document.createElement(tag), props);\n const open = (el) => {\n const key = keyMap().get(el);\n const mark = marks.get(key);\n const draft = drafts.get(key);\n let kind = draft?.kind ?? mark?.kind ?? '';\n opener = document.activeElement;\n anchor = el;\n\n const note = make('textarea', { rows: 2, placeholder: ui.hint, value: draft?.note ?? mark?.note ?? '' });\n note.setAttribute('aria-label', ui.hint);\n const keep = make('button', { type: 'button', className: 'am-btn', textContent: ui.save, disabled: !kind });\n const need = make('span', { className: 'am-remark-need', textContent: ui.need, hidden: Boolean(kind) });\n keepDraft = () => {\n if (kind || note.value.trim()) drafts.set(key, { kind, note: note.value });\n else drafts.delete(key);\n showClear();\n };\n const done = () => { drafts.delete(key); keepDraft = null; showClear(); };\n keep.addEventListener('click', () => {\n done();\n const saved = { key, kind, note: note.value.trim() };\n marks.set(key, saved);\n save();\n paint(el, saved);\n close(true);\n });\n const actions = make('div', { className: 'am-remark-actions' });\n actions.append(keep);\n if (mark) {\n const drop = make('button', { type: 'button', className: 'am-btn', textContent: ui.remove });\n drop.addEventListener('click', () => {\n done();\n marks.delete(key);\n save();\n unpaint(el);\n close(true);\n });\n actions.append(drop);\n }\n const choose = (k) => {\n kind = k;\n for (const other of kindBtns) other.setAttribute('aria-pressed', String(other.dataset.kind === k));\n keep.disabled = false;\n need.hidden = true;\n };\n const kindBtns = KINDS.map((k, i) => {\n const kb = make('button', { type: 'button', className: 'am-remark-kind', textContent: ui.kinds[k] });\n kb.dataset.kind = k;\n kb.dataset.n = i + 1;\n kb.setAttribute('aria-pressed', String(k === kind));\n kb.addEventListener('click', () => choose(k));\n return kb;\n });\n // Ctrl / Cmd + Enter presses Save (nothing while Save waits for a kind). A digit types into the note, so it picks a kind\n // only while the focus is outside the note.\n pop.onkeydown = (e) => {\n if (e.key === 'Enter' && (e.ctrlKey || e.metaKey) && !e.isComposing) {\n e.preventDefault();\n if (!keep.disabled) keep.click();\n return;\n }\n if (e.target === note || e.ctrlKey || e.metaKey || e.altKey || !/^[1-4]$/.test(e.key)) return;\n e.preventDefault();\n choose(KINDS[Number(e.key) - 1]);\n note.focus();\n };\n actions.append(need);\n pop.replaceChildren(make('div', { className: 'am-remark-kinds' }), note, actions);\n pop.firstChild.append(...kindBtns);\n pop.hidden = false;\n place();\n (kindBtns.find((b) => b.dataset.kind === kind) ?? kindBtns[0]).focus({ preventScroll: true });\n };\n\n // Picking works only while remark mode is on. A click on a marked block edits its mark, on a plain block starts one.\n // The block under the pointer gets an outline: the same blockAt decides what is outlined and what a click picks.\n let hover = null;\n const track = (e) => {\n const el = e.type === 'mouseout' && e.relatedTarget === null ? null : blockAt(e.target);\n if (el === hover) return;\n hover?.classList.remove('am-remark-hover');\n hover = el;\n hover?.classList.add('am-remark-hover');\n };\n const pick = (e) => {\n const el = blockAt(e.target);\n if (el) open(el);\n };\n // The keyboard picks too: while the mode is on, every block takes focus with Tab, and Enter or Space opens its popover. A block\n // that already had a tabindex keeps it; only the ones the mode added lose it again.\n const pickKey = (e) => {\n if ((e.key !== 'Enter' && e.key !== ' ') || e.ctrlKey || e.metaKey || e.altKey || !e.target.hasAttribute?.('data-am-pick')) return;\n e.preventDefault();\n open(e.target);\n };\n const focusable = (on) => {\n if (!on && !keys) return; // the mode starts off: a page nobody marked builds no block keys\n for (const el of keyMap().keys()) {\n if (on && !el.hasAttribute('tabindex')) {\n el.tabIndex = 0;\n el.setAttribute('data-am-pick', '');\n } else if (!on && el.hasAttribute('data-am-pick')) {\n el.removeAttribute('tabindex');\n el.removeAttribute('data-am-pick');\n }\n }\n };\n const setMode = (on) => {\n btn.classList.toggle('is-on', on);\n btn.setAttribute('aria-pressed', String(on));\n const toggle = on ? 'addEventListener' : 'removeEventListener';\n document.body[toggle]('click', pick);\n document.body[toggle]('mouseover', track);\n document.body[toggle]('mouseout', track);\n document.body[toggle]('keydown', pickKey);\n focusable(on);\n if (!on) {\n track({ type: 'mouseout', relatedTarget: null });\n close(false);\n }\n };\n btn.addEventListener('click', () => setMode(btn.getAttribute('aria-pressed') !== 'true'));\n document.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') close(true);\n });\n // A click outside the popover closes it; the same click may then start another mark.\n document.addEventListener('click', (e) => {\n if (!pop.hidden && !pop.contains(e.target)) close(false);\n }, true);\n setMode(false);\n\n // What the Reply button reads: the marked blocks that are on the page, in page order.\n window.__amRemarkData = () => {\n if (!marks.size) return [];\n const live = [];\n for (const [el, key] of keyMap()) {\n const mark = marks.get(key);\n if (mark) live.push({ panel: panelOf(el), quote: quote(blockText(el)), kind: mark.kind, note: mark.note });\n }\n return live;\n };\n})();\n})();\n(() => {\n// Pure planner for justified (\"photo wall\") rows on sheet pages. No DOM access.\n//\n// This file must stay inlinable into the page script: top-level declarations only, no imports, and the exports are\n// `planLayout` and the constants the DOM adapter shares (STEP, MAX_SCALE, MIN_SCALE). The page build strips the `export ` keyword,\n// and test/layout-plan.test.js checks that this still works.\n//\n// planLayout({ width, gap, cols, panels }) -> { rows: [{ columns: [{ panels: [index, ...], width }], height }] }\n//\n// Input (all lengths in px):\n// width container width\n// gap space between columns, and between two panels stacked in one column\n// cols most columns in one row (the planner never uses more than MAX_COLUMNS, but spans stay shares of `cols`)\n// panels one entry per panel, in reading order:\n// samples [{ w, h }] panel height at sampled widths, ascending by w (heights between samples are interpolated)\n// minWidth narrowest feasible width (clamped to `width`)\n// maxWidth widest useful width; beyond it the panel only gains empty space (default: no limit)\n// natural natural diagram width for a diagram-only panel (default: none)\n// pad panel width not used by the diagram (padding and border; default 0)\n// span the author's width hint in grid columns (default 1); span >= cols keeps the panel alone in its row\n//\n// Output: { rows, maxScale }. Rows are in reading order; a row is a list of columns (at most `cols`); a column holds one panel or two\n// consecutive panels, stacked. For integer inputs the column widths plus the gaps between them equal `width`.\n// Rows are chosen by dynamic programming over break points; widths by a search in STEP px steps. Cost per row:\n// H = tallest column; waste = sum((H - columnHeight) * columnWidth) + sum over diagrams wider than maxWidth of (w - maxWidth) * h\n// dev = sum(((w - preferred) / oneColumn)^2) + SCALE_WEIGHT * sum over diagrams of (ln(scale) / ln(MAX_SCALE))^2\n// cost = waste / 1000 + PREF_WEIGHT * dev * H\n// Scale band: diagrams on one page stay at similar sizes. With the result's `maxScale` as the diagram size limit, a diagram is\n// shown at scale min(maxScale, (width - pad) / natural). The planner tries a few bands [lo, lo * BAND_RATIO] (lo in BAND_LOS) and\n// keeps the cheapest plan in which no diagram is narrower than scale lo and none is shown above the band's top, so the largest and\n// smallest diagram scale on the page differ by at most BAND_RATIO. A panel wider than its diagram's top size keeps the diagram at\n// that size, and the page script must set the diagram's max-width to natural * maxScale. The band starts no higher than the\n// largest scale the page allows the least roomy diagram, so one wide diagram lowers the band for the others.\n// If no band is feasible the plan is made without a band (maxScale = MAX_SCALE); if no plan fits (or the input is unusable) the\n// result is a single column: one panel per row at the full width.\n\nconst STEP = 10;\nconst MAX_SCALE = 1.25;\nconst MIN_SCALE = 0.75; // the narrowest a diagram is shown, as a share of its natural width\nconst MAX_COLUMNS = 6; // rows with more columns are unreadable, and the search grows steeply with the column count\nconst BAND_RATIO = 1.25; // the largest and smallest diagram scale on a page differ by at most this\nconst BAND_LOS = [MIN_SCALE, 0.85, 0.95, 1]; // lower ends tried for the band; lo * BAND_RATIO is the upper end (1.25 means no upper limit)\nconst SCALE_WEIGHT = 3;\nconst PREF_WEIGHT = 0.15;\n\nfunction heightAt(samples, w) {\n const i = samples.findIndex((s) => s.w >= w);\n if (i === -1) return samples[samples.length - 1].h;\n if (i === 0) return samples[0].h;\n const a = samples[i - 1];\n const b = samples[i];\n return a.h + ((b.h - a.h) * (w - a.w)) / (b.w - a.w);\n}\n\n// Every way to split `len` consecutive panels into columns of 1 or 2 panels, as lists of column sizes.\nfunction splits(len) {\n if (len === 0) return [[]];\n return [1, 2].filter((k) => k <= len).flatMap((k) => splits(len - k).map((rest) => [k, ...rest]));\n}\n\nfunction singleColumn(width, panels) {\n return { rows: panels.map((_, i) => ({ columns: [{ panels: [i], width }], height: 0 })) };\n}\n\nfunction planLayout({ width, gap = 0, cols = 3, panels }) {\n const usable = Number.isFinite(width) && width > 0 && panels.every((p) => Array.isArray(p.samples) && p.samples.length > 0);\n if (!usable) return singleColumn(width, panels);\n\n // `cols` stays the unit of the author's spans; no row gets more than MAX_COLUMNS columns however large `cols` is.\n const maxColumns = Math.min(cols, MAX_COLUMNS);\n const oneColumn = Math.max(1, (width - gap * (cols - 1)) / cols);\n // Per-panel limits. With a band [lo, lo * BAND_RATIO], a diagram is no narrower than scale lo and shown at most at the top of the\n // band: a wider panel keeps it at that size and gains empty space, which the cost counts as waste.\n const prepare = (lo) => panels.map((p) => {\n const pad = p.pad ?? 0;\n const diagram = lo > 0 && p.natural > 0;\n const scaleCap = diagram ? Math.min(MAX_SCALE, lo * BAND_RATIO) : MAX_SCALE;\n return {\n ...p,\n minWidth: Math.min(width, Math.max(Math.ceil(p.minWidth || 0), diagram ? Math.ceil(p.natural * lo + pad) : 0)),\n maxWidth: Math.min(p.maxWidth ?? Infinity, diagram ? p.natural * scaleCap + pad : Infinity),\n scaleCap,\n pad,\n preferred: Math.min(width, (p.span ?? 1) * oneColumn + ((p.span ?? 1) - 1) * gap),\n alone: (p.span ?? 1) >= cols,\n };\n });\n let info = prepare(0);\n // Beyond its maxWidth a panel only gains empty space, so its height stops changing there (matters when a band lowers maxWidth).\n const heightOf = (p, w) => heightAt(p.samples, Math.min(w, p.maxWidth));\n const columnHeight = (col, w) => col.reduce((h, k) => h + heightOf(info[k], w), 0) + gap * (col.length - 1);\n\n function bestColumns(columns) {\n const avail = width - gap * (columns.length - 1);\n const mins = columns.map((c) => Math.max(...c.map((k) => info[k].minWidth)));\n const minsFrom = mins.map((_, n) => mins.slice(n).reduce((s, w) => s + w, 0));\n if (minsFrom[0] > avail) return null;\n let best = null;\n const evaluate = (ws) => {\n const hs = ws.map((w, n) => columnHeight(columns[n], w));\n const H = Math.max(...hs);\n let waste = 0;\n let dev = 0;\n ws.forEach((w, n) => {\n waste += (H - hs[n]) * w;\n for (const k of columns[n]) {\n const p = info[k];\n if (w > p.maxWidth) waste += (w - p.maxWidth) * heightOf(p, w);\n dev += ((w - p.preferred) / oneColumn) ** 2;\n if (p.natural > 0) {\n const scale = Math.min(p.scaleCap, Math.max(w - p.pad, 1) / p.natural);\n dev += SCALE_WEIGHT * (Math.log(scale) / Math.log(MAX_SCALE)) ** 2;\n }\n }\n });\n const cost = waste / 1000 + PREF_WEIGHT * dev * H;\n if (!best || cost < best.cost) best = { cost, ws, height: H, columns };\n };\n const choose = (n, used, ws) => {\n if (n === columns.length - 1) {\n const w = avail - used;\n if (w >= mins[n]) evaluate([...ws, w]);\n return;\n }\n for (let w = mins[n]; used + w + minsFrom[n + 1] <= avail; w += STEP) choose(n + 1, used + w, [...ws, w]);\n };\n choose(0, 0, []);\n return best;\n }\n\n // Best columns for one row of panels i..j.\n function bestRow(i, j) {\n if (j > i && info.slice(i, j + 1).some((p) => p.alone)) return null;\n let best = null;\n for (const split of splits(j - i + 1)) {\n if (split.length > maxColumns) continue;\n let next = i;\n const columns = split.map((size) => Array.from({ length: size }, () => next++));\n const r = bestColumns(columns);\n if (r && (!best || r.cost < best.cost)) best = r;\n }\n return best;\n }\n\n // Row breaks in reading order, for the band set up in `info`. A row holds at most 2 * maxColumns panels. Null if nothing fits.\n function solve() {\n const n = panels.length;\n const total = Array(n + 1).fill(Infinity);\n const from = Array(n + 1).fill(-1);\n const chosen = Array(n + 1).fill(null);\n total[0] = 0;\n for (let j = 1; j <= n; j++) {\n for (let i = Math.max(0, j - 2 * maxColumns); i < j; i++) {\n if (total[i] === Infinity) continue;\n const r = bestRow(i, j - 1);\n if (r && total[i] + r.cost < total[j]) {\n total[j] = total[i] + r.cost;\n from[j] = i;\n chosen[j] = r;\n }\n }\n }\n if (total[n] === Infinity) return null;\n const rows = [];\n for (let j = n; j > 0; j = from[j]) {\n const r = chosen[j];\n rows.unshift({ columns: r.columns.map((panelsInColumn, c) => ({ panels: panelsInColumn, width: r.ws[c] })), height: r.height });\n }\n return { rows, cost: total[n] };\n }\n\n let best = null;\n const diagrams = panels.filter((p) => p.natural > 0);\n if (diagrams.length > 1) {\n // No diagram can be shown larger than the page allows, so the band cannot start above the smallest of those limits.\n const reach = Math.min(...diagrams.map((p) => Math.min(MAX_SCALE, Math.max(width - (p.pad ?? 0), 1) / p.natural)));\n for (const lo of new Set([...BAND_LOS.filter((x) => x < reach), reach])) {\n info = prepare(lo);\n const r = solve();\n if (r && (!best || r.cost < best.cost)) best = { ...r, maxScale: Math.min(MAX_SCALE, lo * BAND_RATIO) };\n }\n info = prepare(0);\n }\n best ??= solve();\n return best ? { rows: best.rows, maxScale: best.maxScale ?? MAX_SCALE } : singleColumn(width, panels);\n}\n\n// DOM adapter for the sheet's justified (\"photo wall\") layout. Not a module: compose.js puts it after src/runtime/layout-plan.js\n// (which defines planLayout and the shared STEP, MAX_SCALE, MIN_SCALE) inside one function scope of the page script.\n//\n// It measures every panel at sampled widths, asks planLayout for rows and column widths, and applies them with flexbox.\n// The rendered HTML keeps the plain CSS grid: with JavaScript off, at the single-column breakpoint, or while printing, the grid is what\n// shows (the planned widths belong to the screen width, so print never gets a mix of the two); after printing the layout comes back.\n\n// A diagram is never drawn under MIN_SCALE of its natural width, the floor the planner keeps: below it the text is too small to read,\n// so its figure scrolls sideways instead. This covers what the planner does not size: the plain grid, a phone, a one-panel page and a\n// panel that holds more than the diagram. The svg width follows the reader's text size (page.js), so the floor follows am-scale;\n// restore() puts it back after resetting the inline styles. Printing drops it (base.css).\nconst floorDiagrams = () => {\n for (const svg of document.querySelectorAll('.am-diagram:not(.am-lightbox-canvas) > svg')) {\n const width = Number(svg.getAttribute('width'));\n if (width > 0) svg.style.minWidth = `${Math.floor(width * MIN_SCALE)}px`;\n }\n};\nfloorDiagrams();\naddEventListener('am-scale', floorDiagrams);\n\nconst grid = document.querySelector('.am-grid');\nconst panels = grid ? [...grid.children].filter((el) => el.classList.contains('am-panel')) : [];\n\nif (panels.length > 1) {\n const SINGLE_COLUMN = '(max-width: 760px)'; // the single-column breakpoint in src/themes/base.css\n const TWO_COLUMNS = '(max-width: 1100px)'; // below this the CSS grid has two columns\n const SAMPLE_STEP = 20; // width sampling step, px; the planner interpolates between samples\n // The width floors are text sizes (px at scale 1). They take the page scale on every pass, so a runtime change of --am-scale re-plans.\n const TEXT_MIN = 260; // text keeps at least about 16 CJK characters per line\n const TABLE_COL_MIN = 96; // per table column, px\n const TABLE_COL_COMFORT = 220; // a table column this wide reads three or four words per line\n const TABLE_WORD_MAX = 160; // a longer word (an id, a path) counts as this wide and may break inside its cell when room is short\n const KV_COL_MIN = 120; // per key-value column, px: a value of two short words stays on one line\n const DIAGRAM_MIN = 160;\n const RESIZE_DELAY = 150;\n const pageScale = () => {\n const scale = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--am-scale'));\n return Number.isFinite(scale) && scale > 0 ? scale : 1;\n };\n const OVERFLOWING = '.am-table-wrap, .am-diagram, .am-annot-scroll, pre';\n\n // The first-row cells of each table carry the column widths fitTables() sets, so restore() resets them too.\n const tables = [...grid.querySelectorAll('.am-table-wrap > table')];\n const headCells = (table) => [...(table.rows[0]?.cells ?? [])];\n const original = new Map([grid, ...panels, ...grid.querySelectorAll('.am-diagram > svg'), ...tables.flatMap(headCells)].map((el) => [el, el.getAttribute('style')]));\n const restoreStyle = (el) => (original.get(el) === null ? el.removeAttribute('style') : el.setAttribute('style', original.get(el)));\n\n // Back to the plain grid markup and styles.\n const restore = () => {\n for (const box of grid.querySelectorAll(':scope > .am-col')) box.replaceWith(...box.children);\n for (const el of original.keys()) restoreStyle(el);\n for (const table of tables) table.classList.remove('am-table-fit');\n floorDiagrams();\n };\n\n // The author's width hint, rendered as data-span only when the author wrote one. The inline grid-column is the no-JavaScript fallback\n // and may hold spans the server added, so it is never read here.\n const spanHint = (el) => Number(el.dataset.span) || 1;\n const diagramOnly = (el) => {\n const body = el.querySelector(':scope > .am-panel-body');\n return body && body.children.length === 1 ? body.querySelector(':scope > .am-diagram > svg') : null;\n };\n const naturalWidth = (svg) => Number(svg.getAttribute('width')) || 0;\n\n // The width each column of a table reads well at: its natural width, but no wider than TABLE_COL_COMFORT unless its longest word\n // needs more. Below it the cells wrap one word per line, so a panel with a table is not planned narrower than the sum, and\n // fitTables() keeps each column at its share (the browser would otherwise give the room to the longest column).\n // A column's floor is its longest word, but no more than TABLE_WORD_MAX: a long id would otherwise hold its column at full width and\n // leave a prose column one word per line. fitTables() lets such a word break (am-table-fit) when the table is short of room.\n const columnWidths = new Map();\n function comfortableWidth(table, scale) {\n const saved = table.getAttribute('style');\n const columns = (width) => {\n table.style.width = width;\n return headCells(table).map((cell) => cell.getBoundingClientRect().width);\n };\n const most = columns('max-content');\n const unbroken = columns('min-content');\n const least = unbroken.map((w) => Math.min(w, TABLE_WORD_MAX * scale));\n if (saved === null) table.removeAttribute('style');\n else table.setAttribute('style', saved);\n // A max-content column comes out a fraction under its text in Chrome, enough to wrap the last word, so it gets one pixel more.\n const want = most.map((w, i) => Math.min(Math.ceil(w) + 1, Math.max(least[i], TABLE_COL_COMFORT * scale)));\n // unbroken: each column's longest word. A column the browser lays out is at least that wide, whatever its min-width, so\n // fitTables() turns am-table-fit on when the columns would not fit at those widths, even if the capped widths do.\n columnWidths.set(table, { least, want, unbroken });\n return want.reduce((sum, w) => sum + w, 0);\n }\n\n // After the layout: each column gets at least its comfortable width, scaled down toward its longest word when the panel came out\n // narrower than planned (a page narrower than the table), so a table scrolls sideways only when even its longest words do not fit.\n function fitTables() {\n for (const [table, { least, want, unbroken }] of columnWidths) {\n // Each width is rounded up to a whole pixel (a column a fraction too narrow wraps its last word), so keep a pixel per column spare.\n const room = table.parentElement.clientWidth - want.length;\n const low = least.reduce((s, w) => s + w, 0);\n const high = want.reduce((s, w) => s + w, 0);\n const k = high > room ? Math.max(0, (room - low) / (high - low || 1)) : 1;\n const widths = want.map((w, i) => Math.ceil(least[i] + (w - least[i]) * k));\n headCells(table).forEach((cell, i) => { cell.style.minWidth = `${widths[i]}px`; });\n // Without am-table-fit a column holds its longest word, so a long id can widen the table past the room the widths left.\n const whole = widths.reduce((s, w, i) => s + Math.max(w, unbroken[i]), 0);\n table.classList.toggle('am-table-fit', high > room || whole > room);\n }\n }\n\n // Height (and, for panels with tables or code, the narrowest width without sideways scrolling) at sampled widths.\n // Only one panel is displayed while it is measured, so each width change lays out that panel alone.\n function measure(width) {\n const scale = pageScale();\n grid.style.display = 'block';\n for (const el of panels) {\n el.style.display = 'none';\n el.style.boxSizing = 'border-box';\n for (const svg of el.querySelectorAll('.am-diagram > svg')) {\n svg.style.width = '100%';\n svg.style.maxWidth = `${naturalWidth(svg) * MAX_SCALE}px`;\n }\n }\n const info = panels.map((el) => {\n const svg = diagramOnly(el);\n const svgs = [...el.querySelectorAll('.am-diagram > svg')];\n const scrollers = el.querySelectorAll(OVERFLOWING);\n const tableCols = Math.max(0, ...[...el.querySelectorAll('table tr:first-child')].map((tr) => tr.children.length));\n el.style.display = '';\n el.style.width = `${width}px`;\n const pad = svg ? el.offsetWidth - svg.parentElement.clientWidth : 0;\n const natural = svg ? naturalWidth(svg) : 0;\n const shrunk = Math.max(0, ...svgs.map((s) => naturalWidth(s) * MIN_SCALE)) + (svg ? pad : 34);\n const tableFloors = [...el.querySelectorAll('.am-table-wrap > table')].map((t) => comfortableWidth(t, scale) + el.offsetWidth - t.parentElement.clientWidth);\n // A key-value grid gets the same care: the room a table gains must not squeeze a neighbouring grid to one word per line.\n const kvs = [...el.querySelectorAll('.am-kv')].map((kv) => (Number(kv.style.getPropertyValue('--kv-cols')) || 1) * KV_COL_MIN * scale + el.offsetWidth - kv.clientWidth);\n const floor = svg ? Math.max(DIAGRAM_MIN * scale, natural * MIN_SCALE + pad) : Math.max(TEXT_MIN * scale, shrunk, tableCols * TABLE_COL_MIN * scale + 34, ...tableFloors, ...kvs);\n const from = Math.min(width, Math.floor(floor / STEP) * STEP);\n const samples = [];\n let fits = null;\n for (let w = from; ; w += SAMPLE_STEP) {\n w = Math.min(w, width);\n el.style.width = `${w}px`;\n if (fits === null && !svg && scrollers.length && ![...scrollers].some((s) => s.scrollWidth > s.clientWidth + 1)) fits = w;\n samples.push({ w, h: el.offsetHeight });\n if (w === width) break;\n }\n el.style.display = 'none';\n return {\n samples,\n minWidth: svg ? floor : Math.max(floor, fits ?? (scrollers.length ? width : 0)),\n maxWidth: svg ? natural * MAX_SCALE + pad : Infinity,\n natural,\n pad,\n span: spanHint(el),\n };\n });\n for (const el of panels) {\n el.style.display = '';\n el.style.width = '';\n }\n return info;\n }\n\n // Each column gets a fixed width. A row adds up to the full width, so flex-wrap breaks rows by itself.\n // Stacked panels go into a column wrapper whose last panel absorbs the extra height.\n function apply(plan, gap) {\n grid.style.display = 'flex';\n grid.style.flexWrap = 'wrap';\n grid.style.alignItems = 'stretch';\n grid.style.gap = `${gap}px`;\n for (const el of panels) {\n el.style.gridColumn = '';\n el.style.gridRow = '';\n el.style.flex = '0 0 auto';\n }\n for (const row of plan.rows) {\n for (const col of row.columns) {\n const width = `${col.width}px`;\n if (col.panels.length === 1) {\n panels[col.panels[0]].style.width = width;\n continue;\n }\n const box = document.createElement('div');\n box.className = 'am-col';\n box.style.cssText = `width:${width};flex:0 0 auto;display:flex;flex-direction:column;gap:${gap}px`;\n panels[col.panels[0]].before(box);\n for (const k of col.panels) {\n panels[k].style.width = '';\n box.append(panels[k]);\n }\n panels[col.panels[col.panels.length - 1]].style.flex = '1 1 auto';\n }\n }\n }\n\n // Diagram-only panels show their diagram at most at the top of the page's scale band; a wider panel gains empty space instead.\n function capDiagrams(maxScale) {\n for (const el of panels) {\n const svg = diagramOnly(el);\n if (svg) svg.style.maxWidth = `${naturalWidth(svg) * maxScale}px`;\n }\n }\n\n const containerWidth = () => Math.floor(grid.getBoundingClientRect().width);\n\n function justify() {\n if (printing || printQuery.matches) return;\n try {\n // A vertical scrollbar can appear or vanish once the rows change height; plan again if the width moved.\n // A later pass plans for the width the previous layout left, not the grid's: restoring the grid first would bring back the\n // grid's scrollbar, so a page whose grid scrolls and whose rows do not (or the reverse) would never settle.\n let planned = -1;\n let laidOut = NaN;\n for (let pass = 0; pass < 3 && planned !== laidOut; pass++) {\n restore();\n if (matchMedia(SINGLE_COLUMN).matches) return;\n planned = pass === 0 ? containerWidth() : laidOut;\n const gap = parseFloat(getComputedStyle(grid).columnGap) || 0;\n const cols = Math.max(1, Number(getComputedStyle(grid).getPropertyValue('--cols')) || 3);\n const plan = planLayout({ width: planned, gap, cols: matchMedia(TWO_COLUMNS).matches ? Math.min(cols, 2) : cols, panels: measure(planned) });\n apply(plan, gap);\n capDiagrams(plan.maxScale);\n fitTables();\n laidOut = containerWidth();\n }\n // The width never settled: columns planned for another width would overflow or leave gaps, so show the plain grid.\n if (planned !== laidOut) restore();\n } catch {\n restore();\n }\n }\n\n // Printing: back to the plain grid (spans and all), and the layout again afterwards. Browsers disagree on which of the\n // `beforeprint` event and the print media query change fires first, or at all, so listen to both; both are idempotent.\n // While `printing` is set (beforeprint to afterprint) justify() does nothing, so a late resize cannot bring flex widths into the print layout.\n let printing = false;\n const printQuery = matchMedia('print');\n let timer = 0;\n const later = () => {\n clearTimeout(timer);\n timer = setTimeout(justify, RESIZE_DELAY);\n };\n const toPrint = () => {\n clearTimeout(timer);\n restore();\n };\n justify();\n addEventListener('resize', later);\n // A reader's text size changes every panel's text widths and heights, so the sheet is planned again like a resize.\n addEventListener('am-scale', later);\n addEventListener('beforeprint', () => {\n printing = true;\n toPrint();\n });\n addEventListener('afterprint', () => {\n printing = false;\n later();\n });\n printQuery.addEventListener('change', (e) => (e.matches ? toPrint() : later()));\n // Late changes to panel heights: web fonts arriving, and images inside the grid finishing their load (load does not bubble, so capture it).\n document.fonts?.ready.then(later);\n grid.addEventListener('load', later, true);\n // Switching theme changes paddings and fonts, hence panel heights.\n document.querySelector('[data-am=\"theme\"]')?.addEventListener('click', later);\n}\n})();\n// The outline rail of a doc page (src/templates/doc.js): the markup already works without a script, <details> opens the list and the\n// links jump. This adds the hover dwell, the open direction, the keys, the tap outside and the marking of the current section.\n(() => {\n const nav = document.querySelector('nav.am-toc');\n const box = nav && nav.querySelector('details.am-outline');\n if (!box) return;\n const sum = box.querySelector('summary');\n const links = Array.from(box.querySelectorAll('.am-outline-list a'));\n const ticks = Array.from(box.querySelectorAll('.am-tick'));\n const LIST_W = 240; // keep in step with .am-outline-list in src/themes/base.css\n const EDGE = 10; // the 6px gap to the rail plus a margin to the viewport edge\n let current = '';\n let byHover = false;\n let dwell = 0;\n let leave = 0;\n\n // Open away from the body when the room outside the rail fits the list; otherwise over the body. Never past the viewport.\n const place = () => {\n const r = sum.getBoundingClientRect();\n const right = r.left + r.width / 2 > innerWidth / 2;\n const room = right ? innerWidth - r.right : r.left;\n nav.dataset.flow = room >= Math.min(LIST_W, innerWidth - 48) + EDGE ? 'out' : 'in';\n };\n const setOpen = (open) => {\n if (open) place();\n box.open = open;\n if (!open) byHover = false;\n };\n const peek = (tick) => ticks.forEach((t) => t.classList.toggle('is-peek', t === tick));\n const currentLink = () => links.find((a) => a.getAttribute('aria-current') === 'true') || links[0];\n\n const mark = (id) => {\n current = id;\n ticks.forEach((t) => t.classList.toggle('is-current', t.dataset.id === id));\n links.forEach((a) => {\n if (a.getAttribute('href') === `#panel-${id}`) a.setAttribute('aria-current', 'true');\n else a.removeAttribute('aria-current');\n });\n };\n const sections = ticks.map((t) => document.getElementById(`panel-${t.dataset.id}`)).filter(Boolean);\n if (sections.length) mark(sections[0].id.slice(6));\n if (sections.length && 'IntersectionObserver' in window) {\n // A thin band a third of the way down the viewport: the section across it is the one being read.\n const seen = new Set();\n const io = new IntersectionObserver((entries) => {\n entries.forEach((e) => (e.isIntersecting ? seen.add(e.target) : seen.delete(e.target)));\n const hit = sections.filter((s) => seen.has(s)).pop();\n if (hit && hit.id.slice(6) !== current) mark(hit.id.slice(6));\n }, { rootMargin: '-30% 0px -65% 0px' });\n sections.forEach((s) => io.observe(s));\n }\n\n place();\n addEventListener('resize', place);\n\n // Mouse: dwelling on the rail opens the list, leaving it closes a list opened that way. A tap or click opens it for good.\n box.addEventListener('pointerenter', (e) => {\n clearTimeout(leave);\n if (e.pointerType !== 'mouse' || box.open) return;\n dwell = setTimeout(() => { setOpen(true); byHover = true; }, 300);\n });\n box.addEventListener('pointerleave', () => {\n clearTimeout(dwell);\n // A link the keyboard moved into keeps the list open; focusout closes it once the focus leaves the nav.\n if (byHover) leave = setTimeout(() => { if (!nav.contains(document.activeElement)) setOpen(false); }, 250);\n });\n sum.addEventListener('click', (e) => {\n clearTimeout(dwell);\n if (box.open && byHover) { e.preventDefault(); byHover = false; return; }\n place();\n });\n box.addEventListener('toggle', () => { if (box.open) peek(null); });\n\n // Keyboard: the summary opens with Enter or Space (native); arrows move through the links; Esc closes and returns to the rail.\n sum.addEventListener('focus', () => {\n if (sum.matches(':focus-visible')) peek(ticks.find((t) => t.dataset.id === current));\n });\n sum.addEventListener('blur', () => peek(null));\n nav.addEventListener('keydown', (e) => {\n if (e.key === 'Escape' && box.open) {\n e.preventDefault();\n setOpen(false);\n sum.focus();\n return;\n }\n if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(e.key)) return;\n const at = links.indexOf(document.activeElement);\n if (at < 0 && e.target !== sum) return;\n e.preventDefault();\n if (!box.open) setOpen(true);\n let next;\n if (e.key === 'Home') next = links[0];\n else if (e.key === 'End') next = links[links.length - 1];\n else if (at < 0) next = e.key === 'ArrowDown' ? currentLink() : links[links.length - 1];\n else next = links[Math.min(links.length - 1, Math.max(0, at + (e.key === 'ArrowDown' ? 1 : -1)))];\n next.focus();\n });\n nav.addEventListener('focusout', (e) => {\n if (box.open && e.relatedTarget && !nav.contains(e.relatedTarget)) setOpen(false);\n });\n\n // Choosing a section or tapping outside closes the list.\n links.forEach((a) => a.addEventListener('click', () => setOpen(false)));\n document.addEventListener('pointerdown', (e) => { if (box.open && !nav.contains(e.target)) setOpen(false); });\n document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && box.open && !nav.contains(e.target)) setOpen(false); });\n})();\n\n// The toolbar's Export menu: Copy as image, Download PNG and Save as PDF. The menu is a native popover that src/render.js writes next to\n// the toolbar (a click on the button, Esc and a click outside open and close it with no script); this script shows the button, moves\n// focus with the arrow keys, says why an item cannot run, and does the work. A browser without popovers gets the same menu from a class\n// toggle instead of losing it.\n//\n// Copy and Download share one rasterizer. An item that cannot run is marked aria-disabled and carries the reason as its muted second\n// line (also its accessible description), never as the toolbar button's text: no rasterizer disables both; a preview frame whose feature\n// policy forbids clipboard-write, or a missing async Clipboard API / secure context, disables only Copy. Chromium and Firefox (as of\n// version 160) can rasterize the page; Safari and unknown browsers keep both items but carry a note that the effect is not guaranteed.\n// A refused copy reports a failure and never falls back to downloading. Save as PDF is the browser's print dialog and always works\n// (the page's print CSS hides the toolbar and the menu).\n//\n// Pipeline: clone the page body \u2192 inline every computed style (CSS variables are resolved there, so a clone keeps theme colours and\n// sizes) and the ::before / ::after decorations \u2192 wrap it in an SVG foreignObject \u2192 draw that image on a canvas \u2192 toBlob('image/png')\n// \u2192 navigator.clipboard.write(new ClipboardItem(...)), passing the blob as a promise so the write keeps the user's click activation,\n// or a download through <a download>.\n(() => {\n const XHTML = 'http://www.w3.org/1999/xhtml';\n const SVG = 'http://www.w3.org/2000/svg';\n const MAX_DIM = 16384; // Chrome refuses a canvas wider or taller than this\n const MAX_AREA = 268435456; // and one with more pixels than this (16384 * 16384)\n\n const btn = document.querySelector('[data-am=\"export\"]');\n const menu = document.getElementById('am-export');\n if (!btn || !menu) return;\n const main = document.querySelector('main.am-sheet, main.am-doc');\n if (!main) return;\n const items = [...menu.querySelectorAll('[data-export]')];\n const item = (kind) => menu.querySelector(`[data-export=\"${kind}\"]`);\n const [copyItem, downloadItem, pdfItem] = ['copy', 'download', 'pdf'].map(item);\n const note = (el) => document.getElementById(el.getAttribute('aria-describedby'));\n const text = menu.dataset;\n\n const canRasterize = typeof XMLSerializer !== 'undefined' && typeof document.createElement('canvas').getContext === 'function';\n const canCopy = window.isSecureContext && typeof ClipboardItem !== 'undefined' && typeof navigator.clipboard?.write === 'function';\n // Chromium (including an embedded Chromium without navigator.userAgentData, whose UA still names Chrome/) and Firefox can rasterize\n // the page. Safari and unknown browsers are not rejected outright: their items stay usable but carry a note that the effect is not\n // guaranteed.\n const brands = navigator.userAgentData?.brands;\n const chromium = brands ? brands.some((b) => /Chromium/.test(b.brand)) : /\\bChrome\\//.test(navigator.userAgent);\n const gecko = /\\bFirefox\\//.test(navigator.userAgent);\n const native = Object.hasOwn(HTMLElement.prototype, 'popover') && typeof menu.showPopover === 'function';\n btn.hidden = false;\n\n const idle = btn.textContent;\n // The button keeps its name (\"Export\") while its text shows progress, so a screen reader hears each result through a hidden live\n // region beside it. aria-live, not\n // role=\"status\": the live-update notice owns role=\"status\" (src/runtime/page.js), and the two must stay apart.\n const status = document.createElement('span');\n status.setAttribute('aria-live', 'polite');\n status.dataset.am = 'export-status';\n status.className = 'am-visually-hidden';\n btn.after(status);\n btn.setAttribute('aria-label', idle);\n // Short feedback on the button itself, restored after a moment; the live region carries the same words.\n const say = (message, restore) => {\n btn.textContent = message;\n status.textContent = message;\n clearTimeout(say.timer);\n if (restore) say.timer = setTimeout(() => { btn.textContent = idle; }, 1800);\n };\n\n // An item that can never run here (aria-disabled, reason as its second line), in the order of the conditions the page can act on.\n const unavailable = new Map();\n if (!canRasterize) {\n unavailable.set(copyItem, text.unavailableBrowser);\n unavailable.set(downloadItem, text.unavailableBrowser);\n } else {\n if (document.featurePolicy && document.featurePolicy.allowsFeature('clipboard-write') === false) unavailable.set(copyItem, text.unavailablePolicy);\n else if (!canCopy) unavailable.set(copyItem, text.unavailableClipboard);\n // Safari and unknown browsers can draw the page often enough to keep the items, but the result is not guaranteed.\n if (!chromium && !gecko) for (const el of [copyItem, downloadItem]) if (!unavailable.has(el)) note(el).textContent = text.unverifiedEffect;\n }\n for (const [el, reason] of unavailable) note(el).textContent = reason;\n\n // A running export blocks the next copy or download (a second full-page rasterization beside the first); Save as PDF stays free.\n let busy = false;\n const sync = () => {\n for (const el of items) {\n const off = unavailable.has(el) || (busy && el !== pdfItem);\n if (off) el.setAttribute('aria-disabled', 'true');\n else el.removeAttribute('aria-disabled');\n }\n if (busy) btn.setAttribute('aria-busy', 'true');\n else btn.removeAttribute('aria-busy');\n };\n sync();\n\n // A stylesheet of only the local font declarations, so a font a theme embeds still draws inside the SVG.\n const fontFaceCss = () => {\n let css = '';\n for (const sheet of document.styleSheets) {\n let rules;\n try { rules = sheet.cssRules; } catch { continue; } // a cross-origin sheet has no readable rules; pages never carry one\n for (const rule of rules) {\n if (rule.type === 5 /* CSSRule.FONT_FACE_RULE */) css += `${rule.cssText}\\n`;\n }\n }\n return css;\n };\n\n // Copy every computed declaration of src onto dst. The clone then needs no page stylesheet: var() is already resolved.\n const inlineStyle = (src, dst) => {\n const cs = getComputedStyle(src);\n let css = '';\n for (let i = 0; i < cs.length; i++) {\n const name = cs[i];\n const value = cs.getPropertyValue(name);\n if (value) css += `${name}:${value};`;\n }\n dst.style.cssText = css;\n };\n\n // A ::before / ::after box exists only while the rule applies, so copy its computed declarations into a rule of its own. Each element\n // that has one gets a data-cp marker; the marker keeps the rule from touching any other node in the picture.\n let cpSeq = 0;\n const pseudoRule = (src, dst, pseudo) => {\n // The header's spacer keeps text clear of the toolbar (base.css); a picture has no toolbar, so it has no spacer.\n if (pseudo === '::before' && src.classList.contains('am-head')) return '';\n const cs = getComputedStyle(src, pseudo);\n const content = cs.getPropertyValue('content');\n if (!content || content === 'none' || content === 'normal') return '';\n let css = '';\n for (let i = 0; i < cs.length; i++) {\n const name = cs[i];\n const value = cs.getPropertyValue(name);\n if (value) css += `${name}:${value};`;\n }\n if (!css) return '';\n const mark = dst.getAttribute('data-cp') ?? String(++cpSeq);\n dst.setAttribute('data-cp', mark);\n return `[data-cp=\"${mark}\"]${pseudo}{${css}}\\n`;\n };\n\n // The page's chrome means nothing in a picture: remove the controls and the navigational rail from the clone; a runtime-made control opts out with data-export-skip.\n const CHROME = '.am-code-copy, .am-diagram-expand, .am-table-controls, [class*=\"delta-switch\"], .am-toc, .am-remark-hover, .am-mark-note, [data-export-skip]';\n\n function buildSvg(width, height) {\n const clone = main.cloneNode(true);\n // The clone has the same node order as the original, so one index walks both trees.\n const srcNodes = [main, ...main.querySelectorAll('*')];\n const dstNodes = [clone, ...clone.querySelectorAll('*')];\n for (let i = 0; i < srcNodes.length; i++) {\n inlineStyle(srcNodes[i], dstNodes[i]);\n }\n let pseudoCss = '';\n for (let i = 0; i < srcNodes.length; i++) {\n pseudoCss += pseudoRule(srcNodes[i], dstNodes[i], '::before');\n pseudoCss += pseudoRule(srcNodes[i], dstNodes[i], '::after');\n }\n for (const node of clone.querySelectorAll(CHROME)) node.remove();\n // A rasterized image is a static snapshot, not a scrollable viewport. Inlined computed styles turn auto heights\n // into fixed fractional heights on scrolling containers (.am-table-wrap, .am-diagram, .am-annot-scroll, .am-math-block, pre),\n // and subpixel rounding inside the foreignObject can trigger unwanted scrollbars. Reset unconstrained containers to visible and auto.\n // For containers with an author-specified finite max-height, keep inlined height and max-height, and hide overflow.\n for (const scroller of clone.querySelectorAll('.am-table-wrap, .am-diagram, .am-annot-scroll, .am-math-block, pre')) {\n const maxH = parseFloat(scroller.style.maxHeight || scroller.style.getPropertyValue('max-height'));\n if (Number.isFinite(maxH) && maxH >= 0) {\n scroller.style.setProperty('overflow', 'hidden', 'important');\n } else {\n scroller.style.setProperty('overflow', 'visible', 'important');\n scroller.style.setProperty('height', 'auto', 'important');\n scroller.style.setProperty('max-height', 'none', 'important');\n }\n }\n clone.style.margin = '0';\n clone.style.width = `${width}px`;\n clone.style.maxWidth = 'none';\n\n const wrap = document.createElementNS(XHTML, 'div');\n wrap.setAttribute('xmlns', XHTML);\n const body = getComputedStyle(document.body);\n wrap.style.cssText = `width:${width}px;height:${height}px;margin:0;padding:0;box-sizing:border-box;color:${body.color};font-family:${body.fontFamily};font-size:${body.fontSize};line-height:${body.lineHeight};background-color:${body.backgroundColor};background-image:${body.backgroundImage};`;\n\n const style = document.createElementNS(XHTML, 'style');\n style.textContent = `${fontFaceCss()}\\n${pseudoCss}`;\n wrap.append(style, clone);\n\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('xmlns', SVG);\n svg.setAttribute('width', String(width));\n svg.setAttribute('height', String(height));\n svg.setAttribute('viewBox', `0 0 ${width} ${height}`);\n const foreign = document.createElementNS(SVG, 'foreignObject');\n foreign.setAttribute('x', '0');\n foreign.setAttribute('y', '0');\n foreign.setAttribute('width', String(width));\n foreign.setAttribute('height', String(height));\n foreign.append(wrap);\n svg.append(foreign);\n return new XMLSerializer().serializeToString(svg);\n }\n\n // A canvas may not exceed the browser's dimension or area limit: shrink the pixels rather than fail on a long page. No lower bound:\n // one would let a very long page exceed the limits again.\n const pixelScale = (width, height) => {\n const wanted = Math.min(2, window.devicePixelRatio || 1);\n return Math.min(wanted, MAX_DIM / width, MAX_DIM / height, Math.sqrt(MAX_AREA / (width * height)));\n };\n\n async function rasterize() {\n await document.fonts?.ready;\n // A steps block that is live on screen shows its static look in a picture, not the reader's selection (src/export.js does the same\n // for image export); the page goes live again right after.\n const live = [...document.querySelectorAll('.am-steps--live')];\n for (const el of live) el.classList.remove('am-steps--live');\n let width;\n let height;\n let svg;\n try {\n const rect = main.getBoundingClientRect();\n width = Math.max(1, Math.ceil(Math.max(rect.width, main.scrollWidth)));\n height = Math.max(1, Math.ceil(Math.max(rect.height, main.scrollHeight)));\n svg = buildSvg(width, height);\n } finally {\n for (const el of live) el.classList.add('am-steps--live');\n }\n const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n const image = new Image();\n image.decoding = 'async';\n await new Promise((resolve, reject) => {\n image.onload = resolve;\n image.onerror = () => reject(new Error('the browser cannot draw the page as an SVG image'));\n image.src = url;\n });\n const scale = pixelScale(width, height);\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, Math.round(width * scale));\n canvas.height = Math.max(1, Math.round(height * scale));\n const ctx = canvas.getContext('2d');\n ctx.drawImage(image, 0, 0, canvas.width, canvas.height);\n const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/png'));\n if (!blob) throw new Error('the browser could not encode the image');\n return blob;\n }\n\n // The PNG is saved under the page title (letters and digits of any script, joined by dashes).\n const fileName = () => {\n const slug = (document.title || '').toLowerCase().replace(/[^\\p{L}\\p{N}]+/gu, '-').slice(0, 40).replace(/^-+|-+$/g, '');\n return `${slug || 'page'}.png`;\n };\n const download = (blob) => {\n const link = document.createElement('a');\n link.href = URL.createObjectURL(blob);\n link.download = fileName();\n document.body.append(link);\n link.click();\n link.remove();\n setTimeout(() => URL.revokeObjectURL(link.href), 4000);\n };\n\n // Start rasterizing, then hand the pending blob to ClipboardItem and write within the same click task so the browser keeps the\n // user's activation. Awaiting the raster first would spend it, and the write would be rejected. The write can be refused at once\n // while the page is still being drawn; wait for both to settle, so a retry cannot start a second rasterization beside the first.\n const copy = async () => {\n const blobPromise = rasterize();\n const written = (async () => {\n await navigator.clipboard.write([new ClipboardItem({ 'image/png': blobPromise })]);\n })();\n const [write] = await Promise.allSettled([written, blobPromise]);\n if (write.status === 'rejected') throw write.reason;\n };\n const save = async () => { download(await rasterize()); };\n\n async function run(work, done) {\n busy = true;\n sync();\n say(text.working, false);\n try {\n await work();\n say(done, true);\n } catch (e) {\n console.error('[am] export failed', e);\n say(text.failed, true);\n } finally {\n busy = false;\n sync();\n }\n }\n\n // The menu. Native: the popover opens and closes itself and tells us through toggle events. Fallback: the same menu toggled by a\n // class, with Esc and a click outside handled here.\n const isOpen = () => (native ? menu.matches(':popover-open') : menu.classList.contains('is-open'));\n // Under the button, aligned to its inline-end edge, and inside the viewport (the toolbar scrolls sideways on a phone, so the button\n // can sit near an edge). On a short viewport the menu is cut to the space below the button and scrolls, so every item stays reachable.\n const place = () => {\n const r = btn.getBoundingClientRect();\n // clientWidth, not 100vw: the viewport width in CSS includes a classic scrollbar, so a menu sized from it can stick out.\n const room = document.documentElement.clientWidth - 16;\n menu.style.maxWidth = `${room}px`;\n menu.style.minWidth = `${Math.min(200, room)}px`;\n const width = menu.offsetWidth;\n const rtl = getComputedStyle(btn).direction === 'rtl';\n const left = Math.max(8, Math.min(rtl ? r.left : r.right - width, document.documentElement.clientWidth - 8 - width));\n const top = r.bottom + 6;\n menu.style.top = `${top}px`;\n menu.style.left = `${left}px`;\n menu.style.maxHeight = `${Math.max(48, document.documentElement.clientHeight - 8 - top)}px`;\n };\n const firstEnabled = () => items.find((el) => el.getAttribute('aria-disabled') !== 'true');\n const opened = () => {\n btn.setAttribute('aria-expanded', 'true');\n place();\n menu.style.visibility = '';\n firstEnabled()?.focus();\n };\n const closed = (restoreFocus) => {\n btn.setAttribute('aria-expanded', 'false');\n if (restoreFocus || menu.contains(document.activeElement)) btn.focus();\n };\n const close = (restoreFocus = true) => {\n if (!isOpen()) return;\n if (native) menu.hidePopover();\n else { menu.classList.remove('is-open'); closed(restoreFocus); }\n };\n\n if (native) {\n // Place the box before it is first drawn, so it never flashes in the wrong spot.\n menu.addEventListener('beforetoggle', (e) => {\n btn.setAttribute('aria-expanded', String(e.newState === 'open'));\n if (e.newState === 'open') menu.style.visibility = 'hidden';\n });\n menu.addEventListener('toggle', (e) => { if (e.newState === 'open') opened(); else closed(false); });\n } else {\n // No popover: the browser must not half-handle the attributes, and the button toggles the class itself.\n menu.removeAttribute('popover');\n btn.removeAttribute('popovertarget');\n btn.addEventListener('click', () => {\n if (isOpen()) close();\n else { menu.classList.add('is-open'); opened(); }\n });\n document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && isOpen()) { e.preventDefault(); close(); } });\n document.addEventListener('pointerdown', (e) => { if (isOpen() && !menu.contains(e.target) && !btn.contains(e.target)) close(false); });\n }\n window.addEventListener('resize', () => { if (isOpen()) place(); });\n\n menu.addEventListener('keydown', (e) => {\n const at = items.indexOf(document.activeElement);\n const to = { ArrowDown: at + 1, ArrowUp: at - 1, Home: 0, End: items.length - 1 }[e.key];\n if (to !== undefined) {\n e.preventDefault();\n items[(to + items.length) % items.length].focus();\n } else if (e.key === 'Tab') {\n close(true); // focus goes back to the button and Tab then moves on from there\n }\n });\n\n menu.addEventListener('click', (e) => {\n const el = e.target.closest('[data-export]');\n if (!el || el.getAttribute('aria-disabled') === 'true') return;\n close();\n if (el === pdfItem) window.print();\n else if (el === copyItem) run(copy, text.copied);\n else run(save, text.saved);\n });\n})();\n})();\n";
|
|
742
753
|
var TABLE_JS = "(() => {\n const NUMBER = /^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?$/i;\n const FORMATTED_NUMBER = /^[+-]?\\$?(?:(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d*)?|\\.\\d+)%?$/;\n const INTEGER = /^[+-]?\\d+$/;\n const ZERO_FRACTION = /^[+-]?\\d+\\.0*$/;\n const DATE = /^\\d{4}-\\d{2}-\\d{2}(?:[T ]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?(?:Z|[+-]\\d{2}:?\\d{2})?)?$/;\n const INTERACTIVE = 'a, button, input, select, textarea, details, audio[controls], video[controls], [contenteditable], [tabindex]';\n const validDate = (text) => {\n if (!DATE.test(text)) return false;\n const [year, month, day] = text.slice(0, 10).split('-').map(Number);\n const date = new Date(0);\n date.setUTCHours(0, 0, 0, 0);\n date.setUTCFullYear(year, month - 1, day);\n return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day && Number.isFinite(Date.parse(text));\n };\n const numberValue = (text) => {\n let normalized = text;\n if (FORMATTED_NUMBER.test(text)) normalized = text.replace(/[$,%]/g, '');\n else if (!NUMBER.test(text)) return null;\n if (INTEGER.test(normalized)) return BigInt(normalized);\n if (ZERO_FRACTION.test(normalized)) return BigInt(normalized.slice(0, normalized.indexOf('.')));\n const value = Number(normalized);\n return Number.isFinite(value) ? value : null;\n };\n const typedValue = (text) => {\n const number = numberValue(text);\n if (number !== null) return number;\n return validDate(text) ? Date.parse(text) : null;\n };\n const relayout = () => window.dispatchEvent(new Event('resize'));\n\n for (const table of document.querySelectorAll('table[data-am-table]')) {\n const options = new Set(table.dataset.amTable.split(/\\s+/));\n const body = table.tBodies[0];\n if (!body) continue;\n\n if (options.has('filter')) {\n const controls = table.parentElement.previousElementSibling;\n const input = controls?.classList.contains('am-table-controls') ? controls.querySelector('[data-am-table-filter]') : null;\n if (input) {\n controls.hidden = false;\n input.addEventListener('input', () => {\n const query = input.value.trim().toLocaleLowerCase();\n for (const row of body.rows) row.hidden = Boolean(query) && !row.textContent.toLocaleLowerCase().includes(query);\n relayout();\n });\n }\n }\n\n if (!options.has('sort')) continue;\n const headers = [...(table.tHead?.rows[0]?.cells ?? [])];\n headers.forEach((head, column) => {\n const button = document.createElement('button');\n button.type = 'button';\n button.className = 'am-table-sort';\n button.setAttribute('aria-label', head.textContent.trim());\n const moved = [...head.childNodes].filter((child) => !(child.nodeType === 1 && (child.matches(INTERACTIVE) || child.querySelector(INTERACTIVE))));\n head.insertBefore(button, moved[0] ?? null);\n button.append(...moved);\n button.addEventListener('click', () => {\n const direction = head.getAttribute('aria-sort') === 'ascending' ? 'descending' : 'ascending';\n for (const cell of headers) cell.removeAttribute('aria-sort');\n head.setAttribute('aria-sort', direction);\n const rows = [...body.rows];\n const texts = rows.map((row) => row.cells[column]?.textContent.trim() ?? '');\n const numeric = texts.every((text) => numberValue(text) !== null);\n const dates = texts.every(validDate);\n const byValue = head.getAttribute('align') === 'right' || numeric || dates;\n const sorted = rows.map((row, index) => ({ row, index, text: texts[index], value: byValue ? typedValue(texts[index]) : null }));\n sorted.sort((a, b) => {\n let compared;\n if (byValue && (a.value !== null || b.value !== null)) {\n if (a.value === null) compared = 1;\n else if (b.value === null) compared = -1;\n else compared = a.value < b.value ? -1 : a.value > b.value ? 1 : 0;\n }\n compared ??= a.text.localeCompare(b.text);\n return compared === 0 ? a.index - b.index : direction === 'ascending' ? compared : -compared;\n });\n body.append(...sorted.map(({ row }) => row));\n relayout();\n });\n });\n }\n})();\n";
|
|
743
754
|
var TABLE_CSS = `.am-table-controls { margin: 0 0 8px; }
|
|
744
755
|
.am-table-filter { display: flex; align-items: center; gap: 8px; font-size: var(--am-fs-small); color: var(--ink-2); }
|
|
@@ -884,11 +895,7 @@ var DELTA_CSS = `/* Change markers (only on pages that have one). Only the Chang
|
|
|
884
895
|
`;
|
|
885
896
|
var RTL_CSS = '/* Right-to-left pages (html[dir="rtl"]: Hebrew, Arabic, Persian, Urdu, Yiddish). base.css uses logical properties, so the layout\n mirrors by itself; this file holds only what logical properties cannot say. A left-to-right page never carries it. */\n\n/* Code, diffs and paths read left to right in every language. Inline code is isolated, so the text around it keeps its order. */\nhtml[dir="rtl"] .am-codeblock, html[dir="rtl"] .am-code, html[dir="rtl"] pre { direction: ltr; text-align: left; }\nhtml[dir="rtl"] :not(pre) > code { direction: ltr; unicode-bidi: isolate; }\n\n/* Small labels use the monospace font. No common monospace font has Hebrew or Arabic letters, so the browser borrows a fixed-width\n fallback that spaces the letters apart; letter spacing and capitals also break these scripts. Labels use the sans font instead. */\nhtml[dir="rtl"] .am-md th, html[dir="rtl"] .am-kv dt, html[dir="rtl"] .am-head-meta b, html[dir="rtl"] .am-panel-meta,\nhtml[dir="rtl"] .am-annot-meta, html[dir="rtl"] .am-tree-tag, html[dir="rtl"] .am-timeline--v .am-tl-when,\nhtml[dir="rtl"] .am-diagram .am-cluster-label, html[dir="rtl"] .am-delta-bar, html[dir="rtl"] .am-lim-val,\nhtml[dir="rtl"] .am-colophon, html[dir="rtl"] .am-reply textarea {\n font-family: var(--font-sans); letter-spacing: normal; text-transform: none;\n}\nhtml[dir="rtl"] .am-head h1 { letter-spacing: normal; }\n/* The annotated sentence is set in the sans font too; src/components/annot.js measures the placement of its notes in that font. */\nhtml[dir="rtl"] .am-annot-line { font-family: var(--font-sans); }\n\n/* Diagram text: the drawing is already mirrored (src/components/flow.js, sequence.js); the text inside reads right to left. */\nhtml[dir="rtl"] .am-diagram svg { direction: rtl; }\n\n/* Limits scale: the ticks are placed from the right (src/components/limits.js), so each one centres on its point from that side. */\nhtml[dir="rtl"] .am-lim-ticks span { transform: translateX(50%); }\nhtml[dir="rtl"] .am-lim-ticks span:first-child { transform: none; }\n\n/* The limits value is written in the page language (src/languages/he.js: "420 of 1000 KB" in Hebrew words), so it reads right to left\n like the label. The label, its note and the value are isolated from each other: "Redis" at the end of a label and "70%" at the\n start of its note would otherwise run together as one left-to-right piece. */\nhtml[dir="rtl"] .am-lim-head > span, html[dir="rtl"] .am-lim-note, html[dir="rtl"] .am-lim-val { unicode-bidi: isolate; }\n\n/* Horizontal timeline: a date written the Hebrew way (15.11.2026) is wider than a year, and in a narrow panel the dates of\n neighbouring items ran into each other ("1.12.202615.11.2026"). The date shrinks to fit its column, never above its usual 15px. */\nhtml[dir="rtl"] .am-timeline--h .am-tl-when { font-size: min(var(--am-fs-heading), calc(100cqi / var(--n, 1) / 6.2)); white-space: nowrap; }\n@container (max-width: 560px) {\n html[dir="rtl"] .am-timeline--h .am-tl-when { font-size: var(--am-fs-heading); }\n}\n\n/* Video player (src/video/render.js): the scenes lay out right to left like a page, and what video.css places with left / right mirrors here.\n A theme mirrors its own placements with video.rtlCss. The controls row stays left to right, as in common video players: the play\n button on the left, then the clock, the progress bar with its chapter ticks, the speed and the export button. */\nhtml[dir="rtl"][data-video] .amv-ruler--top span + span, html[dir="rtl"][data-video] .amv-ruler--bottom span + span { border-left: 0; border-right: 1px solid var(--line); }\nhtml[dir="rtl"][data-video] .amv-titleblock { text-align: right; }\n/* The title block labels and the scene header numbers use the monospace font in video.css: sans here, as for the small page labels above. */\nhtml[dir="rtl"][data-video] .amv-titleblock b, html[dir="rtl"][data-video] .amv-scene-meta { font-family: var(--font-sans); letter-spacing: normal; }\nhtml[dir="rtl"][data-video] .amv-titleblock div + div { border-left: 0; border-right: 1px solid var(--line); }\nhtml[dir="rtl"][data-video] .amv-controls { direction: ltr; }\n\n/* Remark mode: a note inside a code block reads in the page direction, not in the left-to-right direction of the code. */\nhtml[dir="rtl"] pre .am-mark-note { direction: rtl; }\n/* A code block reads left to right, so its inline start is its left edge; the mark bar goes to the right like the other marks. */\nhtml[dir="rtl"] pre.am-mark { border-inline-start: 0; padding-inline-start: 0; border-inline-end: 3px solid var(--mark); }\n';
|
|
886
897
|
var CHART_CSS = '/* Charts (src/components/chart.js). Only a page with a chart carries this file, the way only a page with math carries the math styles.\n Series colors are the diagram tokens --series-1 to --series-6 (docs/reference.md, "Diagram tokens"): a theme that sets one wins, and\n the fallbacks are the fixed palette below (Tableau 10 style), a set for light and a set for dark. Bars carry their value, the legend names\n the series and the data table holds the numbers, so a color is never the only way to read a bar. The axis, grid and labels read the usual\n tokens, so a theme that sets nothing still gets a chart in its own colors. */\nhtml {\n --am-ch-1: #4e79a7; --am-ch-2: #f28e2b; --am-ch-3: #e15759; --am-ch-4: #76b7b2; --am-ch-5: #59a14f; --am-ch-6: #b07aa1;\n}\nhtml[data-mode="dark"] {\n --am-ch-1: #7aa6d6; --am-ch-2: #f5a55a; --am-ch-3: #ef7f80; --am-ch-4: #8fd0cb; --am-ch-5: #7cc472; --am-ch-6: #c99bbd;\n}\n@media (prefers-color-scheme: dark) {\n html[data-mode="auto"] {\n --am-ch-1: #7aa6d6; --am-ch-2: #f5a55a; --am-ch-3: #ef7f80; --am-ch-4: #8fd0cb; --am-ch-5: #7cc472; --am-ch-6: #c99bbd;\n }\n}\n\n.am-ch-s1 { fill: var(--series-1, var(--am-ch-1)); }\n.am-ch-s2 { fill: var(--series-2, var(--am-ch-2)); }\n.am-ch-s3 { fill: var(--series-3, var(--am-ch-3)); }\n.am-ch-s4 { fill: var(--series-4, var(--am-ch-4)); }\n.am-ch-s5 { fill: var(--series-5, var(--am-ch-5)); }\n.am-ch-s6 { fill: var(--series-6, var(--am-ch-6)); }\n/* A highlighted row of a single series takes the accent color; in a chart with a highlight the other rows are gray (a line is never gray). */\n.am-ch-hi { fill: var(--accent, #1d5fbf); }\n.am-ch-row.is-dim .am-ch-bar, .am-ch-row.is-dim .am-ch-slice, .am-ch-row.is-dim .am-ch-sw { fill: var(--line-2, #d6dae1); fill: color-mix(in oklch, var(--ink-3, #8b929e) 40%, var(--paper, #ffffff)); }\n\n/* A line: a stroke in the series color, a dot on each point; the dot has an outline in the paper color where lines cross. A pie slice has\n the same outline, which is the gap between slices. */\n.am-ch-line { fill: none; stroke-width: 2.5; stroke-linecap: round; }\n.am-ch-line.am-ch-s1 { stroke: var(--series-1, var(--am-ch-1)); }\n.am-ch-line.am-ch-s2 { stroke: var(--series-2, var(--am-ch-2)); }\n.am-ch-line.am-ch-s3 { stroke: var(--series-3, var(--am-ch-3)); }\n.am-ch-line.am-ch-s4 { stroke: var(--series-4, var(--am-ch-4)); }\n.am-ch-line.am-ch-s5 { stroke: var(--series-5, var(--am-ch-5)); }\n.am-ch-line.am-ch-s6 { stroke: var(--series-6, var(--am-ch-6)); }\n.am-ch-dot, .am-ch-slice { stroke: var(--paper, #ffffff); stroke-width: 1.5; }\n.am-ch-slice { stroke-width: 2; stroke-linejoin: round; }\n.am-ch-guide { stroke: var(--ink-3, #8b929e); stroke-width: 1; stroke-dasharray: 3 3; }\n\n.am-ch-grid { stroke: var(--line-2, #d6dae1); stroke-width: 1; }\n.am-ch-zero { stroke: var(--ink-3, #8b929e); stroke-width: 1; }\n.am-diagram .am-ch-cat, .am-diagram .am-ch-leg { fill: var(--ink-2, #4b5260); font-size: var(--am-fs-d-chartCat); }\n.am-diagram .am-ch-tick, .am-diagram .am-ch-val { fill: var(--ink-2, #4b5260); font-size: var(--am-fs-d-chartTick); }\n/* The value labels of a highlighted row in a chart with several series take the color of their series, in a heavier weight to read on it. */\n.am-diagram .am-ch-val.am-ch-s1, .am-diagram .am-ch-val.am-ch-s2, .am-diagram .am-ch-val.am-ch-s3, .am-diagram .am-ch-val.am-ch-s4, .am-diagram .am-ch-val.am-ch-s5, .am-diagram .am-ch-val.am-ch-s6 { font-weight: 600; }\n.am-diagram .am-ch-val.am-ch-s1 { fill: var(--series-1, var(--am-ch-1)); }\n.am-diagram .am-ch-val.am-ch-s2 { fill: var(--series-2, var(--am-ch-2)); }\n.am-diagram .am-ch-val.am-ch-s3 { fill: var(--series-3, var(--am-ch-3)); }\n.am-diagram .am-ch-val.am-ch-s4 { fill: var(--series-4, var(--am-ch-4)); }\n.am-diagram .am-ch-val.am-ch-s5 { fill: var(--series-5, var(--am-ch-5)); }\n.am-diagram .am-ch-val.am-ch-s6 { fill: var(--series-6, var(--am-ch-6)); }\n/* A value label may sit over a line or a guide: a halo in the paper color keeps it readable. */\n.am-diagram .am-ch-val { paint-order: stroke; stroke: var(--paper, #ffffff); stroke-width: 3px; stroke-linejoin: round; }\n.am-diagram .am-ch-num { fill: var(--ink-2, #4b5260); font-size: var(--am-fs-d-chartCat); font-variant-numeric: tabular-nums; }\n.am-diagram .am-ch-total { fill: var(--ink, #1a1d23); font-weight: 600; }\n\n/* The data table under the chart: collapsed, for a screen reader and for a reader who wants the numbers. It looks like a Markdown table. */\n.am-ch-data { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line-2); text-align: start; font-size: var(--am-fs-text); }\n.am-ch-data summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; font: var(--am-fs-label)/1.3 var(--font-mono); color: var(--ink-3); letter-spacing: .04em; }\n.am-ch-data summary::-webkit-details-marker { display: none; }\n.am-ch-data summary::before { content: ""; width: 0; height: 0; border-block: 4px solid transparent; border-inline-start: 6px solid currentColor; transition: transform .15s; }\n.am-ch-data[open] summary::before { transform: rotate(90deg); }\n/* The triangle points to the end side, which is the left on a right-to-left page: it turns the other way to point down. */\nhtml[dir="rtl"] .am-ch-data[open] summary::before { transform: rotate(-90deg); }\n@media (prefers-reduced-motion: reduce) { .am-ch-data summary::before { transition: none; } }\n.am-ch-data summary:hover { color: var(--ink); }\n.am-ch-data table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: var(--am-fs-text); }\n.am-ch-data thead th { font: var(--am-fs-label)/1.3 var(--font-mono); color: var(--ink-2); font-weight: 400; padding: 6px 10px; border-bottom: 1px solid var(--line); }\n.am-ch-data thead th::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; }\n.am-ch-data thead th:nth-child(2)::before { background: var(--series-1, var(--am-ch-1)); }\n.am-ch-data thead th:nth-child(3)::before { background: var(--series-2, var(--am-ch-2)); }\n.am-ch-data thead th:nth-child(4)::before { background: var(--series-3, var(--am-ch-3)); }\n.am-ch-data thead th:nth-child(5)::before { background: var(--series-4, var(--am-ch-4)); }\n.am-ch-data thead th:nth-child(6)::before { background: var(--series-5, var(--am-ch-5)); }\n.am-ch-data thead th:nth-child(7)::before { background: var(--series-6, var(--am-ch-6)); }\n.am-ch-data--pie thead th::before { content: none; }\n.am-ch-data th, .am-ch-data td { padding: 7px 10px; font-variant-numeric: tabular-nums; }\n.am-ch-data th[scope="row"] { text-align: start; font-weight: 400; }\n/* Numbers read left to right in every language and line up on their right edge, under the series name. */\n.am-ch-data td, .am-ch-data thead th { text-align: right; }\n.am-ch-data tbody tr:nth-child(even) > * { background: var(--fill); }\n';
|
|
887
|
-
var MATH_CSS =
|
|
888
|
-
Temml.woff2 is a clone of KaTeX_Script-Regular, except that the code points
|
|
889
|
-
have been changed from ASCII to Unicode Mathematical Alphanumeric Symbols Script capitals,
|
|
890
|
-
Unicode range 1D49C to 1D4B5.
|
|
891
|
-
*/
|
|
898
|
+
var MATH_CSS = `
|
|
892
899
|
|
|
893
900
|
@font-face {
|
|
894
901
|
font-family: 'Temml';
|
|
@@ -908,7 +915,7 @@ math {
|
|
|
908
915
|
letter-spacing: normal;
|
|
909
916
|
word-wrap: normal;
|
|
910
917
|
direction: ltr;
|
|
911
|
-
|
|
918
|
+
|
|
912
919
|
font-feature-settings: "dtls" off;
|
|
913
920
|
}
|
|
914
921
|
|
|
@@ -916,15 +923,14 @@ math * {
|
|
|
916
923
|
border-color: currentColor;
|
|
917
924
|
}
|
|
918
925
|
|
|
919
|
-
|
|
920
|
-
* Not in Chromium, which recognizes display: "block math" written inline. */
|
|
926
|
+
|
|
921
927
|
math.tml-display {
|
|
922
928
|
display: block;
|
|
923
929
|
width: 100%;
|
|
924
930
|
}
|
|
925
931
|
|
|
926
932
|
*.mathcal {
|
|
927
|
-
|
|
933
|
+
|
|
928
934
|
font-feature-settings: 'ss01';
|
|
929
935
|
}
|
|
930
936
|
|
|
@@ -936,7 +942,7 @@ mo.tml-prime {
|
|
|
936
942
|
font-family: Temml;
|
|
937
943
|
}
|
|
938
944
|
|
|
939
|
-
|
|
945
|
+
|
|
940
946
|
mfrac > :nth-child(2),
|
|
941
947
|
msqrt,
|
|
942
948
|
mover > :first-child {
|
|
@@ -955,9 +961,9 @@ mover > :first-child {
|
|
|
955
961
|
left: 0;
|
|
956
962
|
padding: 0.5ex 0ex;
|
|
957
963
|
background-color: currentColor;
|
|
958
|
-
|
|
959
|
-
-webkit-mask-image: url("data:image/svg+xml
|
|
960
|
-
mask-image: url("data:image/svg+xml
|
|
964
|
+
|
|
965
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cmarker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'%3E%3Cpath fill='black' d='m0 0 7 2.5L0 5z'/%3E%3C/marker%3E%3C/defs%3E%3Cline x2='100%25' y1='100%25' stroke='black' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
|
|
966
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cmarker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'%3E%3Cpath fill='black' d='m0 0 7 2.5L0 5z'/%3E%3C/marker%3E%3C/defs%3E%3Cline x2='100%25' y1='100%25' stroke='black' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
|
|
961
967
|
-webkit-mask-repeat: no-repeat;
|
|
962
968
|
mask-repeat: no-repeat;
|
|
963
969
|
-webkit-mask-size: 100% 100%;
|
|
@@ -967,18 +973,18 @@ mover > :first-child {
|
|
|
967
973
|
}
|
|
968
974
|
|
|
969
975
|
@supports (-moz-appearance: none) {
|
|
970
|
-
|
|
976
|
+
|
|
971
977
|
.tml-vec {
|
|
972
978
|
transform: scale(0.75)
|
|
973
979
|
}
|
|
974
|
-
|
|
980
|
+
|
|
975
981
|
.ff-narrow {
|
|
976
982
|
width: 0em;
|
|
977
983
|
}
|
|
978
984
|
.ff-nudge-left {
|
|
979
985
|
margin-left: -0.2em;
|
|
980
986
|
}
|
|
981
|
-
|
|
987
|
+
|
|
982
988
|
.ff-squash mtd {
|
|
983
989
|
display: block;
|
|
984
990
|
height: 0;
|
|
@@ -986,12 +992,12 @@ mover > :first-child {
|
|
|
986
992
|
}
|
|
987
993
|
|
|
988
994
|
@supports (not (-moz-appearance: none)) {
|
|
989
|
-
|
|
990
|
-
|
|
995
|
+
|
|
996
|
+
|
|
991
997
|
mo.tml-prime {
|
|
992
998
|
font-family: Temml;
|
|
993
999
|
}
|
|
994
|
-
|
|
1000
|
+
|
|
995
1001
|
.tml-sml-pad {
|
|
996
1002
|
padding-left: 0.05em;
|
|
997
1003
|
}
|
|
@@ -1004,9 +1010,9 @@ mover > :first-child {
|
|
|
1004
1010
|
}
|
|
1005
1011
|
|
|
1006
1012
|
@supports (-webkit-backdrop-filter: blur(1px)) {
|
|
1007
|
-
|
|
1013
|
+
|
|
1008
1014
|
.wbk-acc {
|
|
1009
|
-
|
|
1015
|
+
|
|
1010
1016
|
transform: translate(0em, 0.431em);
|
|
1011
1017
|
}
|
|
1012
1018
|
.wbk-sml {
|
|
@@ -1038,13 +1044,13 @@ mover > :first-child {
|
|
|
1038
1044
|
}
|
|
1039
1045
|
}
|
|
1040
1046
|
|
|
1041
|
-
|
|
1047
|
+
|
|
1042
1048
|
menclose {
|
|
1043
|
-
-webkit-print-color-adjust: exact;
|
|
1049
|
+
-webkit-print-color-adjust: exact;
|
|
1044
1050
|
print-color-adjust: exact;
|
|
1045
1051
|
}
|
|
1046
1052
|
|
|
1047
|
-
|
|
1053
|
+
|
|
1048
1054
|
.tml-right {
|
|
1049
1055
|
text-align: right;
|
|
1050
1056
|
}
|
|
@@ -1052,12 +1058,12 @@ menclose {
|
|
|
1052
1058
|
text-align: left;
|
|
1053
1059
|
}
|
|
1054
1060
|
|
|
1055
|
-
|
|
1061
|
+
|
|
1056
1062
|
.tml-shift-left { margin-left:-200% }
|
|
1057
1063
|
|
|
1058
|
-
|
|
1064
|
+
|
|
1059
1065
|
@supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
|
|
1060
|
-
|
|
1066
|
+
|
|
1061
1067
|
.chr-sml {
|
|
1062
1068
|
transform: translate(0.07em, 0)
|
|
1063
1069
|
}
|
|
@@ -1077,11 +1083,11 @@ menclose {
|
|
|
1077
1083
|
transform: scale(0.75) translate(0.21em, 0)
|
|
1078
1084
|
}
|
|
1079
1085
|
|
|
1080
|
-
|
|
1086
|
+
|
|
1081
1087
|
.tml-shift-left { margin-left:-100% }
|
|
1082
1088
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1089
|
+
|
|
1090
|
+
|
|
1085
1091
|
menclose {
|
|
1086
1092
|
position: relative;
|
|
1087
1093
|
padding: 0.5ex 0ex;
|
|
@@ -1179,7 +1185,7 @@ menclose {
|
|
|
1179
1185
|
margin-right: 0.03889em;
|
|
1180
1186
|
}
|
|
1181
1187
|
|
|
1182
|
-
|
|
1188
|
+
|
|
1183
1189
|
.tml-tilde-2 {
|
|
1184
1190
|
transform: scale(2.0, 1.1)
|
|
1185
1191
|
}
|
|
@@ -1189,7 +1195,7 @@ menclose {
|
|
|
1189
1195
|
.tml-tilde-4 {
|
|
1190
1196
|
transform: scale(4.0, 1.1)
|
|
1191
1197
|
}
|
|
1192
|
-
|
|
1198
|
+
|
|
1193
1199
|
.tml-hat-1 {
|
|
1194
1200
|
transform: scale(1.9, 1.0)
|
|
1195
1201
|
}
|
|
@@ -1203,7 +1209,7 @@ menclose {
|
|
|
1203
1209
|
transform: scale(7.8, 1.0)
|
|
1204
1210
|
}
|
|
1205
1211
|
|
|
1206
|
-
|
|
1212
|
+
|
|
1207
1213
|
.tml-right {
|
|
1208
1214
|
text-align: -webkit-right;
|
|
1209
1215
|
}
|
|
@@ -1216,7 +1222,7 @@ menclose {
|
|
|
1216
1222
|
font-family: 'STIX TWO', 'Times New Roman', Times, Tinos, serif;
|
|
1217
1223
|
}
|
|
1218
1224
|
|
|
1219
|
-
|
|
1225
|
+
|
|
1220
1226
|
math {
|
|
1221
1227
|
display: inline-flex;
|
|
1222
1228
|
flex-wrap: wrap;
|
|
@@ -1226,8 +1232,8 @@ math > mrow {
|
|
|
1226
1232
|
padding: 0.5ex 0ex;
|
|
1227
1233
|
}
|
|
1228
1234
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1235
|
+
|
|
1236
|
+
|
|
1231
1237
|
mtable.tml-jot > mtr > mtd {
|
|
1232
1238
|
padding-top: 0.7ex;
|
|
1233
1239
|
padding-bottom: 0.7ex;
|
|
@@ -1237,17 +1243,17 @@ mtable.tml-small mtd {
|
|
|
1237
1243
|
padding-bottom: 0.35ex;
|
|
1238
1244
|
}
|
|
1239
1245
|
|
|
1240
|
-
|
|
1246
|
+
|
|
1241
1247
|
@-moz-document url-prefix() {
|
|
1242
|
-
|
|
1248
|
+
|
|
1243
1249
|
math { display: inline; }
|
|
1244
1250
|
math > mrow { padding: 0 }
|
|
1245
|
-
|
|
1251
|
+
|
|
1246
1252
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
1247
1253
|
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
1248
1254
|
}
|
|
1249
1255
|
|
|
1250
|
-
|
|
1256
|
+
|
|
1251
1257
|
.tml-eqn::before {
|
|
1252
1258
|
counter-increment: tmlEqnNo;
|
|
1253
1259
|
content: "(" counter(tmlEqnNo) ")";
|
|
@@ -1271,6 +1277,114 @@ math:not(.tml-display) { max-width: 100%; overflow-x: auto; overflow-y: hidden;
|
|
|
1271
1277
|
`;
|
|
1272
1278
|
var FONT_CSS = { "bangers": '/* Bangers, Copyright 2010 The Bangers Project Authors (https://github.com/googlefonts/bangers), SIL Open Font License 1.1 (https://openfontlicense.org) */\n@font-face {\n font-family: "Bangers";\n font-style: normal;\n font-weight: 400 900;\n src: url(data:font/woff2;base64,d09GMgABAAAAAFvoABEAAAAA0NgAAFuFAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGoEMG8UKHIUoBmAAhQAITAmcDBEICoKYBIHvNguDZgABNgIkA4dIBCAFhEIHhxMMgTIbfLk1eM7wHtAdHOUKmseZkQhh4wDmHsQZhfRs8nWR/f8nJaghYzyzY7CV0yrNJ8KlR2TUyEqbPEdV2gvLzL4zMyFXWWXIRAbDODilexP/wMkzWuM5ekfesiy6RRnup/mDCy64OF/B0t3nz3btyKVdURQkdPnnNui3ORvKy4ep1ttgPEbc9sdoS1pPjdJgq1/7AG8Zdiz7n1dZXFZvxS/nJbcucJyXqon787TN9/8dRwyxcnrGjMZKLLSHjEVhVKyLZZSRWFi4SleJ/73vss459973PviC3m5oY+WRMWYcCFrSOgolCDnERBqtCbsYt8ZFscLZINs0W6Jore8ja/a9c+jOHitAhWSBWRhiIc8y/C8MOmJhCBu+j3t+5+zuA/weYEIJRDVNKoF4fOER1n5vd/7NYajZSsNjIDSTBgjo9xcADpyDEMJUb5KAAJR/zX0aVXeuQlYiawIHNL6+vhIVo6oiDtAnCO2+BUwuORjg59Yv36Legm1vVYxYU/EWTYxtRG+M6AHSwlEGqKdgJShGY10kxkX9Uy/a/BetXtX07+Z/k/de5ET8JEhCaGidEtreEIYnrPd5jRVXRPu3M9AOz7phhpUsC15obj+gXTPYGKP7U///3Pz/vU8UiNiJIFFCQoA0SMUPpc6Tvn5Rn0zun03axfXRO2azoIUr45BAduObE2VPxNnMu1Tdp2lOiua1EtHZ8JIA/v+HOi1zuz4gbEh7YVvT1V4ddio7iEoUUxhPugcLbSkXlcMKjLIBuguQAfVkBG1Q8p+/qL+o1VUjmS0VnZ3WptLhpdc75W/ZTp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XaDQk746W1zPp02ZNJTT1hPsbItGOOkI40tebKWK/kT4HM6G3pb0+XzmJ0hyNtoXroq1i5Ppob4DhOYddxlRyJ6QfAeoJXSfdqMRP1pWXN0sRzQFqH/LEYlKA0Ru1aQzdoFzpBmPqLmaFpz/wP+tfkf+ZuIRhcEx3+wr58TtsEJxZLfkZ842SytneQ9JJU5Ue/8sPPUCoGFTZGx6yrPhfMOCL1yH+LbHshU3/MENvhTL8UUaSgi+s91pk/LP8qFyq6fhN8JNwtuN3KWkl1c/8gv//mfv36bjUd+FtgC82AAA=) format("woff2");\n}' };
|
|
1273
1279
|
var DELTA_JS = "\n// \u2500\u2500 Change markers: the Before / Changes / After switch \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// The switch starts hidden because it needs this script. It swaps the am-view-* class of its diagram; the delta styles show the colors and badges only in\n// the Changes view and hide the items that do not exist in the view.\n(() => {\n const VIEWS = ['before', 'changes', 'after'];\n const setView = (el, view) => {\n el.classList.remove(...VIEWS.map((v) => `am-view-${v}`));\n el.classList.add(`am-view-${view}`);\n };\n for (const bar of document.querySelectorAll('.am-delta-bar')) {\n const view = bar.parentElement;\n const group = bar.querySelector('.am-delta-switch');\n if (!group) continue;\n group.hidden = false;\n group.addEventListener('click', (e) => {\n const btn = e.target.closest('button[data-view]');\n if (!btn) return;\n setView(view, btn.dataset.view);\n for (const b of group.querySelectorAll('button')) b.setAttribute('aria-pressed', String(b === btn));\n });\n }\n // The expand button copies only the drawing into the viewer; the viewer shows the view the diagram is in.\n document.addEventListener('click', (e) => {\n const host = e.target.closest?.('.am-diagram-expand')?.parentElement;\n const canvas = document.querySelector('.am-lightbox-canvas');\n const view = host && VIEWS.find((v) => host.classList.contains(`am-view-${v}`));\n if (view && canvas) setView(canvas, view);\n });\n})();\n";
|
|
1280
|
+
var STEPS_CSS = `/* Steps block (only on pages that have one): a diagram and a code block (or, in explain mode, a list of explanations) linked by numbered steps (src/steps.js).
|
|
1281
|
+
The default look is the static one that print, an image export and a page with no JavaScript show: every step is numbered on its
|
|
1282
|
+
diagram item (a badge) and beside its first line (a gutter number), and a numbered list of the steps follows the pair.
|
|
1283
|
+
The page runtime (src/runtime/steps.js) adds the class am-steps--live; only then, and only on screen, the numbers and the list give way
|
|
1284
|
+
to the bar, the boxes and the note. The layout follows the block's own width, not the window's. */
|
|
1285
|
+
.am-steps { container-type: inline-size; margin: 10px 0; --steps-pad: 24px; }
|
|
1286
|
+
.am-steps-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
|
|
1287
|
+
.am-steps-pair > * { margin: 0; min-width: 0; }
|
|
1288
|
+
.am-steps:focus { outline: none; }
|
|
1289
|
+
.am-steps .am-diagram svg { max-width: 100%; height: auto; }
|
|
1290
|
+
/* The pair is in the order of the draft. Stacked, the diagram always comes first; side by side the order of the draft shows. */
|
|
1291
|
+
.am-steps-pair > .am-steps-diagram { order: -1; }
|
|
1292
|
+
/* Side by side from about 720px of block width: the diagram takes what it needs, up to 45%; a walkthrough (no diagram) stays one column. */
|
|
1293
|
+
@container (min-width: 720px) {
|
|
1294
|
+
.am-steps-pair > .am-steps-diagram { order: 0; }
|
|
1295
|
+
.am-steps-pair:has(> .am-steps-diagram:first-child) { grid-template-columns: fit-content(45%) minmax(0, 1fr); }
|
|
1296
|
+
.am-steps-pair:has(> .am-steps-diagram:last-child) { grid-template-columns: minmax(0, 1fr) fit-content(45%); }
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/* A long line wraps under its own text, so the linked code never scrolls sideways; the number stays in the gutter (a hanging indent). */
|
|
1300
|
+
.am-steps .am-code code { min-width: 0; }
|
|
1301
|
+
.am-steps .am-ln {
|
|
1302
|
+
white-space: pre-wrap; overflow-wrap: anywhere;
|
|
1303
|
+
padding-inline-start: calc(var(--steps-pad) + 3.5ch + 12px); text-indent: calc(-3.5ch - 12px);
|
|
1304
|
+
}
|
|
1305
|
+
.am-steps .am-code--num .am-ln::before { text-indent: 0; }
|
|
1306
|
+
.am-steps .am-ln[data-sn] { position: relative; }
|
|
1307
|
+
.am-steps .am-ln[data-sn]::after {
|
|
1308
|
+
content: attr(data-sn); position: absolute; inset-inline-start: 3px; top: 0.75em; transform: translateY(-50%); text-indent: 0; white-space: normal;
|
|
1309
|
+
box-sizing: border-box; min-width: var(--am-ln-treeBadge); height: var(--am-ln-treeBadge); padding: 0 3px; border-radius: 50%;
|
|
1310
|
+
background: var(--ink); color: var(--paper); font: 600 var(--am-fs-label)/var(--am-ln-treeBadge) var(--font-sans); text-align: center;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
/* The numbers on the diagram: a disc on an svg item, a tag on a tree entry. */
|
|
1314
|
+
g.am-step-badge circle { fill: var(--ink); stroke: var(--paper); stroke-width: 1.5; }
|
|
1315
|
+
g.am-step-badge text { fill: var(--paper); font: 600 var(--am-fs-d-badge) var(--font-sans, sans-serif); }
|
|
1316
|
+
.am-steps .am-tree-box { position: relative; }
|
|
1317
|
+
span.am-step-badge {
|
|
1318
|
+
display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; flex: none; min-width: var(--am-ln-treeBadge); height: var(--am-ln-treeBadge);
|
|
1319
|
+
border-radius: 50%; background: var(--ink); color: var(--paper); font: 600 var(--am-fs-label)/1 var(--font-sans); text-indent: 0;
|
|
1320
|
+
}
|
|
1321
|
+
.am-tree-box > span.am-step-badge { position: absolute; top: -8px; inset-inline-start: -8px; }
|
|
1322
|
+
.am-tree-label > span.am-step-badge { margin-inline-end: 6px; vertical-align: 1px; }
|
|
1323
|
+
|
|
1324
|
+
/* The list under the pair. */
|
|
1325
|
+
.am-steps-list { margin: 12px 0 0; padding-inline-start: 1.8em; font-size: var(--am-fs-text); color: var(--ink-2); }
|
|
1326
|
+
.am-steps-list li { margin: 3px 0; }
|
|
1327
|
+
.am-steps-item { font-weight: 600; color: var(--ink); }
|
|
1328
|
+
.am-steps-lines { font: var(--am-fs-small) var(--font-mono); color: var(--ink-3); margin-inline: 4px; }
|
|
1329
|
+
|
|
1330
|
+
/* Explain mode (no code block): the list is the other side of the pair. Its numbers are text ("1. Item"), so it has no markers. */
|
|
1331
|
+
.am-steps-list--explain { list-style: none; margin: 0; padding: 0; }
|
|
1332
|
+
.am-steps-list--explain li { margin: 2px 0; }
|
|
1333
|
+
.am-steps-entry { padding: 6px 10px; border-inline-start: 3px solid transparent; border-radius: var(--radius); }
|
|
1334
|
+
|
|
1335
|
+
/* The bar and the note are for the live page on screen: a page with no script has none, and a picture or print never shows them. */
|
|
1336
|
+
.am-steps-bar, .am-steps-note { display: none; }
|
|
1337
|
+
|
|
1338
|
+
/* The hint is the first thing to go when the block is narrow: it would wrap under the buttons. */
|
|
1339
|
+
@container (max-width: 560px) { .am-steps-hint { display: none; } }
|
|
1340
|
+
|
|
1341
|
+
/* Live: on screen only. */
|
|
1342
|
+
@media screen {
|
|
1343
|
+
.am-steps--live .am-step-badge, .am-steps--live .am-ln[data-sn]::after, .am-steps--live:not([data-mode="explain"]) .am-steps-list { display: none; }
|
|
1344
|
+
.am-steps--live .am-steps-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; font: var(--am-fs-small)/1.3 var(--font-sans); color: var(--ink-2); }
|
|
1345
|
+
.am-steps-bar .am-btn { padding: 5px 9px; }
|
|
1346
|
+
.am-steps-bar .am-btn:disabled { opacity: .5; cursor: default; }
|
|
1347
|
+
.am-steps-count { min-width: 7em; text-align: center; font-variant-numeric: tabular-nums; }
|
|
1348
|
+
.am-steps-hint { font-size: var(--am-fs-label); color: var(--ink-3); }
|
|
1349
|
+
|
|
1350
|
+
/* The lines of the selected step: a box, with its note above the first line. */
|
|
1351
|
+
.am-steps--live .am-ln[data-link]::before { cursor: pointer; }
|
|
1352
|
+
.am-steps--live .am-ln[data-link]:hover::before { color: var(--accent); }
|
|
1353
|
+
.am-steps--live .am-ln.am-step-on { background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
|
|
1354
|
+
.am-steps--live .am-ln.am-step-first { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent), inset 0 2px 0 var(--accent); }
|
|
1355
|
+
.am-steps--live .am-ln.am-step-last { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent), inset 0 -2px 0 var(--accent); }
|
|
1356
|
+
.am-steps--live .am-ln.am-step-first.am-step-last { box-shadow: inset 0 0 0 2px var(--accent); }
|
|
1357
|
+
.am-steps--live .am-steps-note {
|
|
1358
|
+
display: block; box-sizing: border-box; margin: 6px 8px 4px; padding: 6px 10px; border-radius: var(--radius); text-indent: 0; white-space: normal;
|
|
1359
|
+
background: var(--accent); color: var(--paper); font: var(--am-fs-small)/1.45 var(--font-sans); user-select: none;
|
|
1360
|
+
}
|
|
1361
|
+
.am-steps--live .am-steps-note strong { margin-inline-end: 0.35em; }
|
|
1362
|
+
.am-steps--live .am-steps-note code { background: transparent; color: inherit; }
|
|
1363
|
+
|
|
1364
|
+
/* Explain mode, live: the entries of the list are buttons; the current one has an accent edge and tint, and its text the full ink colour so it keeps its contrast on the tint. */
|
|
1365
|
+
.am-steps--live .am-steps-entry { cursor: pointer; }
|
|
1366
|
+
.am-steps--live .am-steps-entry:hover { background: var(--accent-bg); color: var(--ink); }
|
|
1367
|
+
.am-steps--live .am-steps-entry:focus { outline: none; }
|
|
1368
|
+
.am-steps--live .am-steps-entry:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
1369
|
+
.am-steps--live .am-steps-entry.am-step-current { border-inline-start-color: var(--accent); background: var(--accent-bg); color: var(--ink); }
|
|
1370
|
+
|
|
1371
|
+
/* The items of the diagram a step names are buttons. */
|
|
1372
|
+
.am-steps--live .am-node[data-link], .am-steps--live .am-tree-box[data-link], .am-steps--live .am-tree-label[data-link] { cursor: pointer; }
|
|
1373
|
+
.am-steps--live .am-node[data-link]:hover .am-node-shape { stroke: var(--accent); }
|
|
1374
|
+
.am-steps--live .am-node[data-link]:focus { outline: none; }
|
|
1375
|
+
.am-steps--live .am-node[data-link]:focus-visible .am-node-shape { stroke: var(--accent); stroke-width: 3; }
|
|
1376
|
+
.am-steps--live .am-tree-box[data-link]:hover { border-color: var(--accent); }
|
|
1377
|
+
.am-steps--live .am-tree-box[data-link]:focus-visible, .am-steps--live .am-tree-label[data-link]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
1378
|
+
.am-steps--live .am-node.am-step-sel .am-node-shape { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 2.5; }
|
|
1379
|
+
.am-steps--live .am-node.am-step-sel .am-node-text { fill: var(--accent); font-weight: 600; }
|
|
1380
|
+
.am-steps--live .am-tree-box.am-step-sel { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
|
|
1381
|
+
.am-steps--live .am-tree-label.am-step-sel { color: var(--accent); font-weight: 600; }
|
|
1382
|
+
.am-steps--live .am-edge.am-step-edge { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; animation: am-step-flow 0.9s linear infinite; }
|
|
1383
|
+
@media (prefers-reduced-motion: reduce) { .am-steps--live .am-edge.am-step-edge { animation: none; } }
|
|
1384
|
+
}
|
|
1385
|
+
@keyframes am-step-flow { to { stroke-dashoffset: -20; } }
|
|
1386
|
+
`;
|
|
1387
|
+
var STEPS_JS = "// \u2500\u2500 Steps block: the bar, the boxes and the clicks \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// The markup already carries every step (a number on its item and its first line, a list under the pair), so a page with no script still reads.\n// This script makes the block live: a bar with Previous, Next and the step count; a click on an item or on a line number boxes the lines of its\n// step and shows the note above them; the arrow keys move and Esc clears. The css hides the static numbers and the list while am-steps--live is on,\n// on screen only, so print and image export show the numbers. The block can take focus (tabindex -1), so a click on a line number leaves the keys working.\n// Explain mode (data-mode=\"explain\", no code): the list stays on the page and is the other side of the pair. Its entries become buttons, the\n// selected step marks its entry (aria-current=\"step\"), and there is no note. The page is not scrolled to the entry; focus() scrolls it when a key moved the focus.\n(() => {\n const reduced = () => matchMedia('(prefers-reduced-motion: reduce)').matches;\n const fill = (text, values) => text.replace(/\\{(\\w+)\\}/g, (m, key) => (key in values ? String(values[key]) : m));\n\n for (const root of document.querySelectorAll('.am-steps')) {\n const total = Number(root.dataset.steps);\n const linked = [...root.querySelectorAll('[data-link]')].filter((el) => !el.closest('.am-steps-list'));\n const lines = linked.filter((el) => el.classList.contains('am-ln'));\n const items = linked.filter((el) => !el.classList.contains('am-ln'));\n const entries = [...root.querySelectorAll('.am-steps-entry[data-link]')];\n for (const entry of entries) {\n entry.setAttribute('role', 'button');\n entry.tabIndex = 0;\n }\n const groups = [...root.querySelectorAll('g[data-ends]')].map((g) => ({ ends: g.dataset.ends.split(' '), edge: g.querySelector('.am-edge') }));\n\n const button = (kind, label) => {\n const b = document.createElement('button');\n b.type = 'button';\n b.className = 'am-btn';\n b.dataset.steps = kind;\n b.textContent = label;\n b.setAttribute('aria-label', label.replace(/[\u2190\u2192]/g, '').trim());\n return b;\n };\n const bar = document.createElement('div');\n bar.className = 'am-steps-bar';\n bar.dataset.exportSkip = '';\n const prev = button('prev', root.dataset.prev);\n const next = button('next', root.dataset.next);\n const count = document.createElement('span');\n count.className = 'am-steps-count';\n count.setAttribute('aria-live', 'polite');\n const hint = document.createElement('span');\n hint.className = 'am-steps-hint';\n hint.textContent = root.dataset.hint;\n bar.setAttribute('role', 'group');\n bar.setAttribute('aria-label', root.dataset.bar);\n bar.append(prev, count, next, hint);\n root.tabIndex = -1;\n root.prepend(bar);\n root.classList.add('am-steps--live');\n\n let current = -1;\n let note = null;\n const of = (list, i) => list.filter((el) => el.dataset.link === String(i));\n const listed = (i, part) => root.querySelector(`.am-steps-list [data-link=\"${i}\"] .am-steps-${part}`);\n\n // A button that has the focus keeps the keys of the block only while it is enabled: the browser moves the focus of a disabled one out of the block.\n const enable = (button, on) => {\n if (!on && document.activeElement === button) root.focus({ preventScroll: true });\n button.disabled = !on;\n };\n\n function select(i, { scroll = true } = {}) {\n for (const el of root.querySelectorAll('.am-step-on')) el.classList.remove('am-step-on', 'am-step-first', 'am-step-last');\n for (const el of items) el.classList.remove('am-step-sel');\n for (const el of entries) {\n el.classList.remove('am-step-current');\n el.removeAttribute('aria-current');\n }\n for (const { edge } of groups) edge?.classList.remove('am-step-edge');\n note?.remove();\n note = null;\n current = i;\n enable(prev, i > 0);\n enable(next, i < total - 1);\n if (i < 0) {\n count.textContent = root.dataset.idle;\n return;\n }\n count.textContent = fill(root.dataset.count, { n: i + 1, m: total, item: listed(i, 'item')?.textContent ?? '' });\n const boxed = of(lines, i);\n for (const l of boxed) l.classList.add('am-step-on');\n boxed[0]?.classList.add('am-step-first');\n boxed.at(-1)?.classList.add('am-step-last');\n for (const el of of(items, i)) el.classList.add('am-step-sel');\n for (const el of of(entries, i)) {\n el.classList.add('am-step-current');\n el.setAttribute('aria-current', 'step');\n }\n for (const { ends, edge } of groups) if (ends.includes(String(i))) edge?.classList.add('am-step-edge');\n if (boxed[0]) {\n note = document.createElement('span');\n note.className = 'am-steps-note';\n note.dataset.exportSkip = '';\n const head = document.createElement('strong');\n head.append(`${i + 1}. `, ...listed(i, 'item').cloneNode(true).childNodes);\n note.append(head);\n const text = listed(i, 'text');\n if (text) note.append(' ', ...text.cloneNode(true).childNodes);\n boxed[0].before(note);\n }\n if (scroll) (note ?? boxed[0] ?? of(entries, i)[0])?.scrollIntoView({ block: 'nearest', behavior: reduced() ? 'auto' : 'smooth' });\n }\n const step = (by) => { if (by > 0 || current >= 0) select(Math.min(total - 1, Math.max(0, current + by))); };\n\n // The number sits in the start padding of its line; a click on the code text is left to text selection.\n const inGutter = (line, e) => {\n const style = getComputedStyle(line);\n const rect = line.getBoundingClientRect();\n const x = style.direction === 'rtl' ? rect.right - e.clientX : e.clientX - rect.left;\n return x <= parseFloat(style.paddingInlineStart) - 6;\n };\n\n root.addEventListener('click', (e) => {\n const pressed = e.target.closest('.am-steps-bar button');\n if (pressed) return step(pressed.dataset.steps === 'next' ? 1 : -1);\n const el = e.target.closest('[data-link]');\n if (!el || (el.closest('.am-steps-list') && !el.classList.contains('am-steps-entry')) || e.target.closest('a')) return;\n const isLine = el.classList.contains('am-ln');\n if (isLine && !inGutter(el, e)) return;\n select(Number(el.dataset.link), { scroll: !isLine });\n if (isLine) root.focus({ preventScroll: true });\n });\n root.addEventListener('keydown', (e) => {\n if (e.target.closest('input, textarea, select') || e.altKey || e.ctrlKey || e.metaKey) return;\n const el = e.target.closest('[data-link]');\n const pickable = el && !el.classList.contains('am-ln') && (!el.closest('.am-steps-list') || el.classList.contains('am-steps-entry'));\n const item = pickable && !e.target.closest('a') ? el : null;\n if (item && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n select(Number(item.dataset.link));\n } else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {\n e.preventDefault();\n const rtl = getComputedStyle(root).direction === 'rtl';\n step((e.key === 'ArrowRight') !== rtl ? 1 : -1);\n if (item) (item.classList.contains('am-steps-entry') ? of(entries, current) : of(items, current))[0]?.focus();\n } else if (e.key === 'Escape') {\n select(-1);\n }\n });\n select(-1);\n }\n})();\n";
|
|
1274
1388
|
var UPDATE_CSS = "/* New-version button and popover (src/render.js adds this file only to a page that has the button). The popover sits under the\n toolbar and stays hidden unless open, so a browser without native popovers never shows it. */\n.am-btn--update { color: var(--ok); border-color: var(--ok); white-space: nowrap; }\n.am-update { display: none; }\n.am-update:popover-open {\n display: block; position: fixed; inset-block: 52px auto; inset-inline: auto 12px; margin: 0; width: min(380px, calc(100vw - 24px));\n padding: 14px 16px; font-size: var(--am-fs-text); color: var(--ink); background: var(--paper);\n border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.25);\n}\n.am-update p { margin: 0 0 8px; }\n.am-update-title { font-weight: 600; color: var(--ok); }\n.am-update-label { color: var(--ink-2); font-size: var(--am-fs-small); }\n.am-update-notes { margin: 0 0 12px; padding-inline-start: 18px; }\n.am-update-notes li { margin: 2px 0; }\n.am-update-notes code { font-size: var(--am-fs-small); }\n.am-update-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }\n.am-update-row > :first-child {\n flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: var(--am-fs-small); padding: 6px 8px;\n background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);\n}\n.am-update a { color: var(--accent); font-size: var(--am-fs-small); }\n/* A phone has no room for the words: the button keeps only its dot, and its aria-label still names the version. */\n@media (max-width: 760px) {\n .am-btn--update .am-update-text { display: none; }\n}\n@media print {\n .am-update { display: none !important; }\n}\n";
|
|
1275
1389
|
var UPDATE_JS = `// Pages with a new-version button only: src/render.js adds this script after the page script.
|
|
1276
1390
|
// The button shows where the browser has native popovers (they open and close the popover with no script). A page that am serve
|
|
@@ -1347,7 +1461,7 @@ var CLOSE_AFTER_JS = `// Pages made with the close_after_reply setting only: src
|
|
|
1347
1461
|
})();
|
|
1348
1462
|
`;
|
|
1349
1463
|
var VIDEO_CSS = `/* Video player: the 1920\xD71080 stage scales to the window. All colors come from theme variables.
|
|
1350
|
-
Theme-specific video tokens and decorations live in each theme's definition (themes
|
|
1464
|
+
Theme-specific video tokens and decorations live in each theme's definition (themes/{name}.js). */
|
|
1351
1465
|
html[data-video] {
|
|
1352
1466
|
/* Player controls stay out of the picture and ignore the theme: one fixed set of dark tokens */
|
|
1353
1467
|
--v-ctl-bg: #0b0d11; --v-ctl-line: #1d2330; --v-ctl-fg: #c9d1dc; --v-ctl-muted: #5b6576;
|
|
@@ -1555,6 +1669,7 @@ var zh_default = {
|
|
|
1555
1669
|
},
|
|
1556
1670
|
copy: "\u590D\u5236\u6E90\u7A3F",
|
|
1557
1671
|
done: "\u5DF2\u590D\u5236 \u2713",
|
|
1672
|
+
failed: "\u590D\u5236\u5931\u8D25",
|
|
1558
1673
|
copyCode: "\u590D\u5236",
|
|
1559
1674
|
update: { button: "\u65B0\u7248\u672C {version}", current: "\u5F53\u524D {current}\u3002\u751F\u6210\u6B64\u9875\u65F6\u68C0\u6D4B\u5230\u65B0\u7248\u672C\u3002", whatsNew: "\u8FD9\u6B21\u66F4\u65B0\uFF1A", run: "\u5728\u7EC8\u7AEF\u8FD0\u884C\uFF1A", agent: "\u6216\u8005\u544A\u8BC9 Agent\uFF1A", agentText: "\u66F4\u65B0 answer-me-with-html", notes: "\u67E5\u770B\u66F4\u65B0\u5185\u5BB9" },
|
|
1560
1675
|
live: { updated: "\u9875\u9762\u5DF2\u66F4\u65B0", reload: "\u5237\u65B0" },
|
|
@@ -1596,7 +1711,8 @@ var zh_default = {
|
|
|
1596
1711
|
limits: { value: "{value} / max {limit}", limit: "max {limit}" },
|
|
1597
1712
|
chart: { name: "\u56FE\u8868", data: "\u6570\u636E", value: "\u6570\u503C", share: "\u5360\u6BD4" },
|
|
1598
1713
|
api: { path: "\u8DEF\u5F84\u53C2\u6570", query: "\u67E5\u8BE2\u53C2\u6570", headers: "\u8BF7\u6C42\u5934", request: "\u8BF7\u6C42", response: "\u54CD\u5E94", field: "\u5B57\u6BB5", type: "\u7C7B\u578B", description: "\u8BF4\u660E", requirement: "\u5FC5\u586B\u6027", required: "\u5FC5\u586B", optional: "\u53EF\u9009" },
|
|
1599
|
-
table: { filter: "\u7B5B\u9009\u8868\u683C" }
|
|
1714
|
+
table: { filter: "\u7B5B\u9009\u8868\u683C" },
|
|
1715
|
+
steps: { prev: "\u2190 \u4E0A\u4E00\u6B65", next: "\u4E0B\u4E00\u6B65 \u2192", count: "\u7B2C {n} \u6B65\uFF0C\u5171 {m} \u6B65\uFF1A{item}", hint: "\u70B9\u8282\u70B9\u6216\u884C\u53F7\uFF1B\u2190 \u2192 \u5207\u6362\uFF0CEsc \u53D6\u6D88", hintExplain: "\u70B9\u8282\u70B9\u6216\u8BB2\u89E3\uFF1B\u2190 \u2192 \u5207\u6362\uFF0CEsc \u53D6\u6D88", bar: "\u6B65\u9AA4\u63A7\u5236", idle: "\u5171 {m} \u6B65", node: "\u7B2C {n} \u6B65\uFF1A{item}", list: "\u6B65\u9AA4", line: "\u7B2C {n} \u884C", lines: "\u7B2C {from}-{to} \u884C" }
|
|
1600
1716
|
},
|
|
1601
1717
|
videoUi: {
|
|
1602
1718
|
play: "\u64AD\u653E",
|
|
@@ -1655,6 +1771,7 @@ var zh_Hant_default = {
|
|
|
1655
1771
|
},
|
|
1656
1772
|
copy: "\u8907\u88FD\u6E90\u7A3F",
|
|
1657
1773
|
done: "\u5DF2\u8907\u88FD \u2713",
|
|
1774
|
+
failed: "\u8907\u88FD\u5931\u6557",
|
|
1658
1775
|
copyCode: "\u8907\u88FD",
|
|
1659
1776
|
update: { button: "\u65B0\u7248\u672C {version}", current: "\u76EE\u524D {current}\u3002\u7522\u751F\u6B64\u9801\u6642\u5075\u6E2C\u5230\u65B0\u7248\u672C\u3002", whatsNew: "\u9019\u6B21\u66F4\u65B0\uFF1A", run: "\u5728\u7D42\u7AEF\u6A5F\u57F7\u884C\uFF1A", agent: "\u6216\u8005\u544A\u8A34 Agent\uFF1A", agentText: "\u66F4\u65B0 answer-me-with-html", notes: "\u67E5\u770B\u66F4\u65B0\u5167\u5BB9" },
|
|
1660
1777
|
live: { updated: "\u9801\u9762\u5DF2\u66F4\u65B0", reload: "\u91CD\u65B0\u6574\u7406" },
|
|
@@ -1696,7 +1813,8 @@ var zh_Hant_default = {
|
|
|
1696
1813
|
limits: { value: "{value} / max {limit}", limit: "max {limit}" },
|
|
1697
1814
|
chart: { name: "\u5716\u8868", data: "\u8CC7\u6599", value: "\u6578\u503C", share: "\u5360\u6BD4" },
|
|
1698
1815
|
api: { path: "\u8DEF\u5F91\u53C3\u6578", query: "\u67E5\u8A62\u53C3\u6578", headers: "\u8ACB\u6C42\u6A19\u982D", request: "\u8ACB\u6C42", response: "\u56DE\u61C9", field: "\u6B04\u4F4D", type: "\u578B\u5225", description: "\u8AAA\u660E", requirement: "\u5FC5\u586B\u6027", required: "\u5FC5\u586B", optional: "\u9078\u586B" },
|
|
1699
|
-
table: { filter: "\u7BE9\u9078\u8868\u683C" }
|
|
1816
|
+
table: { filter: "\u7BE9\u9078\u8868\u683C" },
|
|
1817
|
+
steps: { prev: "\u2190 \u4E0A\u4E00\u6B65", next: "\u4E0B\u4E00\u6B65 \u2192", count: "\u7B2C {n} \u6B65\uFF0C\u5171 {m} \u6B65\uFF1A{item}", hint: "\u9EDE\u7BC0\u9EDE\u6216\u884C\u865F\uFF1B\u2190 \u2192 \u5207\u63DB\uFF0CEsc \u53D6\u6D88", hintExplain: "\u9EDE\u7BC0\u9EDE\u6216\u8B1B\u89E3\uFF1B\u2190 \u2192 \u5207\u63DB\uFF0CEsc \u53D6\u6D88", bar: "\u6B65\u9A5F\u63A7\u5236", idle: "\u5171 {m} \u6B65", node: "\u7B2C {n} \u6B65\uFF1A{item}", list: "\u6B65\u9A5F", line: "\u7B2C {n} \u884C", lines: "\u7B2C {from}-{to} \u884C" }
|
|
1700
1818
|
},
|
|
1701
1819
|
videoUi: {
|
|
1702
1820
|
play: "\u64AD\u653E",
|
|
@@ -1749,6 +1867,7 @@ var en_default = {
|
|
|
1749
1867
|
},
|
|
1750
1868
|
copy: "Copy source",
|
|
1751
1869
|
done: "Copied \u2713",
|
|
1870
|
+
failed: "Copy failed",
|
|
1752
1871
|
copyCode: "Copy",
|
|
1753
1872
|
update: { button: "New version {version}", current: "You have {current}. Found when this page was made.", whatsNew: "What's new:", run: "Run in a terminal:", agent: "Or tell your agent:", agentText: "Update answer-me-with-html", notes: "See what's new" },
|
|
1754
1873
|
live: { updated: "Page updated", reload: "Reload" },
|
|
@@ -1790,7 +1909,8 @@ var en_default = {
|
|
|
1790
1909
|
limits: { value: "{value} / max {limit}", limit: "max {limit}" },
|
|
1791
1910
|
chart: { name: "Chart", data: "Data", value: "Value", share: "Share" },
|
|
1792
1911
|
api: { path: "Path parameters", query: "Query parameters", headers: "Headers", request: "Request", response: "Response", field: "Field", type: "Type", description: "Description", requirement: "Requirement", required: "Required", optional: "Optional" },
|
|
1793
|
-
table: { filter: "Filter table" }
|
|
1912
|
+
table: { filter: "Filter table" },
|
|
1913
|
+
steps: { prev: "\u2190 Previous", next: "Next \u2192", count: "Step {n} of {m}: {item}", hint: "Click an item or a line number; \u2190 \u2192 to move, Esc to clear", hintExplain: "Click an item or a step; \u2190 \u2192 to move, Esc to clear", bar: "Step controls", idle: "{m} steps", node: "Step {n}: {item}", list: "Steps", line: "Line {n}", lines: "Lines {from}-{to}" }
|
|
1794
1914
|
},
|
|
1795
1915
|
// Player labels. drawn..duration are the title block cells; sheet is the scene header, with {n} and {total} the zero-padded numbers.
|
|
1796
1916
|
videoUi: {
|
|
@@ -1849,6 +1969,7 @@ var ja_default = {
|
|
|
1849
1969
|
},
|
|
1850
1970
|
copy: "\u539F\u7A3F\u3092\u30B3\u30D4\u30FC",
|
|
1851
1971
|
done: "\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F \u2713",
|
|
1972
|
+
failed: "\u30B3\u30D4\u30FC\u3067\u304D\u307E\u305B\u3093",
|
|
1852
1973
|
copyCode: "\u30B3\u30D4\u30FC",
|
|
1853
1974
|
update: { button: "\u65B0\u30D0\u30FC\u30B8\u30E7\u30F3 {version}", current: "\u73FE\u5728\u306F {current}\u3002\u3053\u306E\u30DA\u30FC\u30B8\u306E\u4F5C\u6210\u6642\u306B\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u3002", whatsNew: "\u4ECA\u56DE\u306E\u66F4\u65B0\uFF1A", run: "\u30BF\u30FC\u30DF\u30CA\u30EB\u3067\u5B9F\u884C\uFF1A", agent: "\u307E\u305F\u306F Agent \u306B\u4F1D\u3048\u308B\uFF1A", agentText: "answer-me-with-html \u3092\u66F4\u65B0\u3057\u3066", notes: "\u66F4\u65B0\u5185\u5BB9\u3092\u898B\u308B" },
|
|
1854
1975
|
live: { updated: "\u30DA\u30FC\u30B8\u304C\u66F4\u65B0\u3055\u308C\u307E\u3057\u305F", reload: "\u518D\u8AAD\u307F\u8FBC\u307F" },
|
|
@@ -1890,7 +2011,8 @@ var ja_default = {
|
|
|
1890
2011
|
limits: { value: "{value} / max {limit}", limit: "max {limit}" },
|
|
1891
2012
|
chart: { name: "\u30B0\u30E9\u30D5", data: "\u30C7\u30FC\u30BF", value: "\u5024", share: "\u5272\u5408" },
|
|
1892
2013
|
api: { path: "\u30D1\u30B9\u30D1\u30E9\u30E1\u30FC\u30BF\u30FC", query: "\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u30FC", headers: "\u30D8\u30C3\u30C0\u30FC", request: "\u30EA\u30AF\u30A8\u30B9\u30C8", response: "\u30EC\u30B9\u30DD\u30F3\u30B9", field: "\u30D5\u30A3\u30FC\u30EB\u30C9", type: "\u578B", description: "\u8AAC\u660E", requirement: "\u5FC5\u9808\u30FB\u4EFB\u610F", required: "\u5FC5\u9808", optional: "\u4EFB\u610F" },
|
|
1893
|
-
table: { filter: "\u8868\u3092\u7D5E\u308A\u8FBC\u3080" }
|
|
2014
|
+
table: { filter: "\u8868\u3092\u7D5E\u308A\u8FBC\u3080" },
|
|
2015
|
+
steps: { prev: "\u2190 \u524D\u3078", next: "\u6B21\u3078 \u2192", count: "\u30B9\u30C6\u30C3\u30D7 {n} / {m}\uFF1A{item}", hint: "\u9805\u76EE\u304B\u884C\u756A\u53F7\u3092\u30AF\u30EA\u30C3\u30AF\u3002\u2190 \u2192 \u3067\u79FB\u52D5\u3001Esc \u3067\u89E3\u9664", hintExplain: "\u9805\u76EE\u304B\u89E3\u8AAC\u3092\u30AF\u30EA\u30C3\u30AF\u3002\u2190 \u2192 \u3067\u79FB\u52D5\u3001Esc \u3067\u89E3\u9664", bar: "\u30B9\u30C6\u30C3\u30D7\u306E\u64CD\u4F5C", idle: "\u5168 {m} \u30B9\u30C6\u30C3\u30D7", node: "\u30B9\u30C6\u30C3\u30D7 {n}\uFF1A{item}", list: "\u30B9\u30C6\u30C3\u30D7", line: "{n} \u884C\u76EE", lines: "{from}-{to} \u884C\u76EE" }
|
|
1894
2016
|
},
|
|
1895
2017
|
videoUi: {
|
|
1896
2018
|
play: "\u518D\u751F",
|
|
@@ -1947,6 +2069,7 @@ var he_default = {
|
|
|
1947
2069
|
},
|
|
1948
2070
|
copy: "\u05D4\u05E2\u05EA\u05E7\u05EA \u05D4\u05DE\u05E7\u05D5\u05E8",
|
|
1949
2071
|
done: "\u05D4\u05D5\u05E2\u05EA\u05E7 \u2713",
|
|
2072
|
+
failed: "\u05D4\u05D4\u05E2\u05EA\u05E7\u05D4 \u05E0\u05DB\u05E9\u05DC\u05D4",
|
|
1950
2073
|
copyCode: "\u05D4\u05E2\u05EA\u05E7\u05D4",
|
|
1951
2074
|
update: { button: "\u05D2\u05E8\u05E1\u05D4 \u05D7\u05D3\u05E9\u05D4 {version}", current: "\u05D4\u05D2\u05E8\u05E1\u05D4 \u05E9\u05DC\u05DB\u05DD {current}. \u05D4\u05D2\u05E8\u05E1\u05D4 \u05D4\u05D7\u05D3\u05E9\u05D4 \u05E0\u05DE\u05E6\u05D0\u05D4 \u05DB\u05E9\u05D4\u05D3\u05E3 \u05E0\u05D5\u05E6\u05E8.", whatsNew: "\u05DE\u05D4 \u05D7\u05D3\u05E9 \u05D1\u05D2\u05E8\u05E1\u05D4:", run: "\u05D4\u05E8\u05D9\u05E6\u05D5 \u05D1\u05D8\u05E8\u05DE\u05D9\u05E0\u05DC:", agent: "\u05D0\u05D5 \u05D1\u05E7\u05E9\u05D5 \u05DE\u05D4-Agent:", agentText: "\u05E2\u05D3\u05DB\u05DF \u05D0\u05EA answer-me-with-html", notes: "\u05DE\u05D4 \u05D7\u05D3\u05E9" },
|
|
1952
2075
|
live: { updated: "\u05D4\u05D3\u05E3 \u05E2\u05D5\u05D3\u05DB\u05DF", reload: "\u05E8\u05E2\u05E0\u05D5\u05DF" },
|
|
@@ -1988,7 +2111,8 @@ var he_default = {
|
|
|
1988
2111
|
limits: { value: "{value} \u05DE\u05EA\u05D5\u05DA {limit}", limit: "\u05E2\u05D3 {limit}" },
|
|
1989
2112
|
chart: { name: "\u05EA\u05E8\u05E9\u05D9\u05DD", data: "\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD", value: "\u05E2\u05E8\u05DA", share: "\u05D7\u05DC\u05E7" },
|
|
1990
2113
|
api: { path: "\u05E4\u05E8\u05DE\u05D8\u05E8\u05D9\u05DD \u05D1\u05E0\u05EA\u05D9\u05D1", query: "\u05E4\u05E8\u05DE\u05D8\u05E8\u05D9\u05DD \u05D1\u05E9\u05D0\u05D9\u05DC\u05EA\u05D4", headers: "\u05DB\u05D5\u05EA\u05E8\u05D5\u05EA", request: "\u05D1\u05E7\u05E9\u05D4", response: "\u05EA\u05D2\u05D5\u05D1\u05D4", field: "\u05E9\u05D3\u05D4", type: "\u05D8\u05D9\u05E4\u05D5\u05E1", description: "\u05EA\u05D9\u05D0\u05D5\u05E8", requirement: "\u05D3\u05E8\u05D9\u05E9\u05D4", required: "\u05D7\u05D5\u05D1\u05D4", optional: "\u05E8\u05E9\u05D5\u05EA" },
|
|
1991
|
-
table: { filter: "\u05E1\u05D9\u05E0\u05D5\u05DF \u05D4\u05D8\u05D1\u05DC\u05D4" }
|
|
2114
|
+
table: { filter: "\u05E1\u05D9\u05E0\u05D5\u05DF \u05D4\u05D8\u05D1\u05DC\u05D4" },
|
|
2115
|
+
steps: { prev: "\u2192 \u05D4\u05E7\u05D5\u05D3\u05DD", next: "\u05D4\u05D1\u05D0 \u2190", count: "\u05E9\u05DC\u05D1 {n} \u05DE\u05EA\u05D5\u05DA {m}: {item}", hint: "\u05DC\u05D7\u05E6\u05D5 \u05E2\u05DC \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D5 \u05E2\u05DC \u05DE\u05E1\u05E4\u05E8 \u05E9\u05D5\u05E8\u05D4; \u2190 \u2192 \u05DC\u05DE\u05E2\u05D1\u05E8, Esc \u05DC\u05D1\u05D9\u05D8\u05D5\u05DC", hintExplain: "\u05DC\u05D7\u05E6\u05D5 \u05E2\u05DC \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D5 \u05E2\u05DC \u05E9\u05DC\u05D1; \u2190 \u2192 \u05DC\u05DE\u05E2\u05D1\u05E8, Esc \u05DC\u05D1\u05D9\u05D8\u05D5\u05DC", bar: "\u05D1\u05E7\u05E8\u05EA \u05E9\u05DC\u05D1\u05D9\u05DD", idle: "{m} \u05E9\u05DC\u05D1\u05D9\u05DD", node: "\u05E9\u05DC\u05D1 {n}: {item}", list: "\u05E9\u05DC\u05D1\u05D9\u05DD", line: "\u05E9\u05D5\u05E8\u05D4 {n}", lines: "\u05E9\u05D5\u05E8\u05D5\u05EA {from}-{to}" }
|
|
1992
2116
|
},
|
|
1993
2117
|
// Names for the frontmatter keys an agent writes most (`author: …`), shown under the title. Other keys show as written.
|
|
1994
2118
|
metaKeys: {
|
|
@@ -2057,6 +2181,7 @@ var tr_default = {
|
|
|
2057
2181
|
scale: { down: "Daha k\xFC\xE7\xFCk yaz\u0131", up: "Daha b\xFCy\xFCk yaz\u0131" },
|
|
2058
2182
|
copy: "Kayna\u011F\u0131 kopyala",
|
|
2059
2183
|
done: "Kopyaland\u0131 \u2713",
|
|
2184
|
+
failed: "Kopyalanamad\u0131",
|
|
2060
2185
|
copyCode: "Kopyala",
|
|
2061
2186
|
update: { button: "Yeni s\xFCr\xFCm {version}", current: "Sizdeki s\xFCr\xFCm {current}. Yeni s\xFCr\xFCm bu sayfa olu\u015Fturulurken bulundu.", whatsNew: "Yenilikler:", run: "Terminalde \xE7al\u0131\u015Ft\u0131r\u0131n:", agent: "Ya da Agent\u2019a s\xF6yleyin:", agentText: "answer-me-with-html\u2019i g\xFCncelle", notes: "Yenilikleri g\xF6r" },
|
|
2062
2187
|
live: { updated: "Sayfa g\xFCncellendi", reload: "Yeniden y\xFCkle" },
|
|
@@ -2099,6 +2224,7 @@ var tr_default = {
|
|
|
2099
2224
|
chart: { name: "Grafik", data: "Veri", value: "De\u011Fer", share: "Pay" },
|
|
2100
2225
|
api: { path: "Yol parametreleri", query: "Sorgu parametreleri", headers: "Ba\u015Fl\u0131klar", request: "\u0130stek", response: "Yan\u0131t", field: "Alan", type: "T\xFCr", description: "A\xE7\u0131klama", requirement: "Gereklilik", required: "Zorunlu", optional: "\u0130ste\u011Fe ba\u011Fl\u0131" },
|
|
2101
2226
|
table: { filter: "Tabloyu filtrele" },
|
|
2227
|
+
steps: { prev: "\u2190 \xD6nceki", next: "Sonraki \u2192", count: "Ad\u0131m {n} / {m}: {item}", hint: "Bir \xF6\u011Feye veya sat\u0131r numaras\u0131na t\u0131klay\u0131n; \u2190 \u2192 ile gezin, Esc ile temizleyin", hintExplain: "Bir \xF6\u011Feye veya ad\u0131ma t\u0131klay\u0131n; \u2190 \u2192 ile gezin, Esc ile temizleyin", bar: "Ad\u0131m denetimleri", idle: "{m} ad\u0131m", node: "Ad\u0131m {n}: {item}", list: "Ad\u0131mlar", line: "Sat\u0131r {n}", lines: "Sat\u0131r {from}-{to}" },
|
|
2102
2228
|
export: {
|
|
2103
2229
|
button: "D\u0131\u015Fa aktar",
|
|
2104
2230
|
copy: "G\xF6rsel olarak kopyala",
|
|
@@ -5112,9 +5238,9 @@ function innerMarkMessage(component, names2, mark, text2, escape = "", link = na
|
|
|
5112
5238
|
const head = `${component}: "${first}" has a change marker inside the line, so "${inner[0].m.mark} " would become part of the name and draw a second box.`;
|
|
5113
5239
|
if (marks.size > 1) return `${head} A marker starts the line and marks the whole line; write one line per marker`;
|
|
5114
5240
|
if ([...marks][0] === "~" && link) return `${head} ~ marks a node, not a link: write it on a line of its own: "~ ${inner[0].m.text}"`;
|
|
5115
|
-
const
|
|
5241
|
+
const quote2 = (name2) => name2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5116
5242
|
let fixed2 = text2;
|
|
5117
|
-
for (const { name: name2, m } of inner) fixed2 = fixed2.replace(new RegExp(`(?<!\\[)${
|
|
5243
|
+
for (const { name: name2, m } of inner) fixed2 = fixed2.replace(new RegExp(`(?<!\\[)${quote2(name2)}(?!\\])`), m.text);
|
|
5118
5244
|
const plain = !/^[*[({]/.test(inner[0].m.text);
|
|
5119
5245
|
return `${head} A marker starts the line and marks the whole line. Write: "${[...marks][0]} ${fixed2}".${escape && plain ? ` ${escape.replace("NAME", first)}` : ""}`;
|
|
5120
5246
|
}
|
|
@@ -5136,180 +5262,6 @@ function withDelta(html, states, { ui, video = false } = {}) {
|
|
|
5136
5262
|
return `${html.slice(0, open - 1)} am-view-changes"${html.slice(open, close)}<div class="am-delta-bar">${counts}${switcher}</div>${html.slice(close)}`;
|
|
5137
5263
|
}
|
|
5138
5264
|
|
|
5139
|
-
// src/components/tree.js
|
|
5140
|
-
var tree_default = {
|
|
5141
|
-
name: "tree",
|
|
5142
|
-
summary: "Hierarchy tree (org chart / indented list)",
|
|
5143
|
-
syntax: `\`\`\`tree [list]
|
|
5144
|
-
Root | subtitle
|
|
5145
|
-
Child
|
|
5146
|
-
Grandchild | one-line note
|
|
5147
|
-
*Highlighted child
|
|
5148
|
-
\`\`\`
|
|
5149
|
-
- Indentation (spaces or tabs) sets the level; "label | note" adds a gray note.
|
|
5150
|
-
- One root with 2 to 4 children \u2192 org chart; more children or the list argument \u2192 indented list; several roots \u2192 side by side.
|
|
5151
|
-
- Labels support inline Markdown, such as \`Section 1\` Words.
|
|
5152
|
-
- Change markers show what a plan adds, removes and changes. A line can start with + (added), - (removed) or ~ (changed), followed by a space, after the indentation:
|
|
5153
|
-
\`\`\`tree list
|
|
5154
|
-
src/
|
|
5155
|
-
components/
|
|
5156
|
-
+ delta.js | parses change markers
|
|
5157
|
-
~ flow.js
|
|
5158
|
-
~ tree.js
|
|
5159
|
-
- legacy/
|
|
5160
|
-
old-flow.js
|
|
5161
|
-
\`\`\`
|
|
5162
|
-
- Indentation still sets the level. The children of a + or - node inherit it; a child that carries a different marker is an error. ~ marks one node and is not inherited.
|
|
5163
|
-
- The Changes view draws added in the theme's ok color, removed faded with a struck-through label, changed with a warn outline, and each marked node with a +, \u2212 or ~ badge. A count row and a Before / Changes / After switch sit under the tree: Before and After show the tree as it was and as it will be, plain and without the items that are not in that view.
|
|
5164
|
-
- A line that starts with a marker and a space is always read as a marker. To keep a label that starts with "- ", write \\- item.`,
|
|
5165
|
-
example: "```tree\nASD-STE100 | Simplified Technical English\n Part 1: Writing rules\n `Section 1` Words\n Part 2: Dictionary\n Approved words | one word, one meaning\n```",
|
|
5166
|
-
render(text2, { args, ui, video }) {
|
|
5167
|
-
const roots = buildTree(text2);
|
|
5168
|
-
if (!roots.length) throw new ComponentError("tree needs at least one node", 1);
|
|
5169
|
-
return withDelta(treeHtml(roots, /\blist\b/.test(args), ui), statesOf(roots), { ui, video });
|
|
5170
|
-
}
|
|
5171
|
-
};
|
|
5172
|
-
function treeHtml(roots, listMode, ui) {
|
|
5173
|
-
if (roots.length === 1) {
|
|
5174
|
-
const [root] = roots;
|
|
5175
|
-
const n = root.children.length;
|
|
5176
|
-
if (!listMode && n >= 2 && n <= 4) return orgHtml(root, ui);
|
|
5177
|
-
return `<div class="am-tree">${rootBox(root, ui, true)}${listHtml(root.children, ui)}</div>`;
|
|
5178
|
-
}
|
|
5179
|
-
if (!listMode && roots.length <= 4) {
|
|
5180
|
-
return `<div class="am-tree"><div class="am-tree-cols am-tree-cols--free" style="--n: ${roots.length}">${colsHtml(roots, ui)}</div></div>`;
|
|
5181
|
-
}
|
|
5182
|
-
return `<div class="am-tree">${listHtml(roots, ui)}</div>`;
|
|
5183
|
-
}
|
|
5184
|
-
var statesOf = (nodes) => nodes.flatMap((n) => [n.state, ...statesOf(n.children)]);
|
|
5185
|
-
function buildTree(text2) {
|
|
5186
|
-
const roots = [];
|
|
5187
|
-
const stack = [];
|
|
5188
|
-
let step = 0;
|
|
5189
|
-
String(text2).split("\n").forEach((raw, i) => {
|
|
5190
|
-
if (!raw.trim()) return;
|
|
5191
|
-
const indent = raw.replace(/\t/g, " ").match(/^ */)[0].length;
|
|
5192
|
-
const node = { ...parseLabel(raw.trim()), indent, step: step++, line: i + 1, children: [] };
|
|
5193
|
-
while (stack.length && stack.at(-1).indent >= indent) stack.pop();
|
|
5194
|
-
(stack.length ? stack.at(-1).children : roots).push(node);
|
|
5195
|
-
stack.push(node);
|
|
5196
|
-
});
|
|
5197
|
-
return roots.map((root) => settle(root, null));
|
|
5198
|
-
}
|
|
5199
|
-
function settle(node, inherited) {
|
|
5200
|
-
const own = markState(node.mark);
|
|
5201
|
-
if (inherited && own && own !== inherited) {
|
|
5202
|
-
throw new ComponentError(`tree: "${node.mark}" under a ${inherited} node contradicts it. The children of a ${inherited} node are ${inherited} too; remove the marker or move the node`, node.line);
|
|
5203
|
-
}
|
|
5204
|
-
const state = inherited ?? own;
|
|
5205
|
-
const below = state === "added" || state === "removed" ? state : null;
|
|
5206
|
-
return { ...node, state, children: node.children.map((child) => settle(child, below)) };
|
|
5207
|
-
}
|
|
5208
|
-
function parseLabel(t) {
|
|
5209
|
-
const escaped = /^\\[+\-~] /.test(t);
|
|
5210
|
-
const { mark, text: text2 } = escaped ? { mark: null, text: t.slice(1) } : splitMarker(t);
|
|
5211
|
-
const hi = text2.startsWith("*");
|
|
5212
|
-
const [label, sub = ""] = fields(hi ? text2.slice(1) : text2);
|
|
5213
|
-
return { label, sub, hi, mark };
|
|
5214
|
-
}
|
|
5215
|
-
var labelHtml = (label) => mdInline(label).replace(/^<code>([^<]*)<\/code>(?=\s*\S)/, '<span class="am-tree-tag">$1</span>');
|
|
5216
|
-
var vattrs = (n) => ` data-key="${esc(n.label)}" data-step="${n.step}"${deltaAttr(n.state)}`;
|
|
5217
|
-
var HIDDEN_IN = { before: "added", after: "removed" };
|
|
5218
|
-
function lineAttrs(siblings, i, cols) {
|
|
5219
|
-
const n = siblings.length;
|
|
5220
|
-
return Object.entries(HIDDEN_IN).map(([view, hidden]) => {
|
|
5221
|
-
const shown2 = siblings.map((x2) => x2.state !== hidden);
|
|
5222
|
-
const first = shown2.indexOf(true);
|
|
5223
|
-
const last = shown2.lastIndexOf(true);
|
|
5224
|
-
const natural = cols ? n === 1 ? "none" : i === 0 ? "start" : i === n - 1 ? "end" : "full" : i < n - 1 ? "full" : "short";
|
|
5225
|
-
const kind2 = cols ? first === last || i < first || i > last ? "none" : i === first ? "start" : i === last ? "end" : "full" : i < last ? "full" : i === last ? "short" : "none";
|
|
5226
|
-
return kind2 === natural ? "" : ` data-line-${view}="${kind2}"`;
|
|
5227
|
-
}).join("");
|
|
5228
|
-
}
|
|
5229
|
-
var dropAttrs = (children) => Object.entries(HIDDEN_IN).map(([view, hidden]) => children.every((c) => c.state === hidden) ? ` data-line-${view}="none"` : "").join("");
|
|
5230
|
-
var boxInner = (n, ui) => `${deltaBadge(n.state, ui)}${labelHtml(n.label)}${n.sub ? `<small>${mdInline(n.sub)}</small>` : ""}`;
|
|
5231
|
-
function rootBox(root, ui, solo = false) {
|
|
5232
|
-
const drop = solo ? "" : dropAttrs(root.children);
|
|
5233
|
-
return `<div class="am-tree-root${solo ? " am-tree-root--solo" : ""}"${deltaAttr(root.state)}${drop}><div class="am-tree-box am-tree-box--root"${vattrs(root)}>${boxInner(root, ui)}</div></div>`;
|
|
5234
|
-
}
|
|
5235
|
-
function colHtml(node, ui, siblings, i) {
|
|
5236
|
-
const children = node.children.length ? listHtml(node.children, ui) : "";
|
|
5237
|
-
return `<div class="am-tree-col"${deltaAttr(node.state)}${lineAttrs(siblings, i, true)}><div class="am-tree-box${node.hi ? " am-tree-box--hi" : ""}"${vattrs(node)}>${boxInner(node, ui)}</div>${children}</div>`;
|
|
5238
|
-
}
|
|
5239
|
-
var colsHtml = (nodes, ui) => nodes.map((n, i) => colHtml(n, ui, nodes, i)).join("");
|
|
5240
|
-
function orgHtml(root, ui) {
|
|
5241
|
-
return `<div class="am-tree">${rootBox(root, ui)}<div class="am-tree-cols" style="--n: ${root.children.length}">${colsHtml(root.children, ui)}</div></div>`;
|
|
5242
|
-
}
|
|
5243
|
-
function listHtml(nodes, ui) {
|
|
5244
|
-
return `<ul class="am-tree-list">${nodes.map((n, i) => liHtml(n, ui, nodes, i)).join("")}</ul>`;
|
|
5245
|
-
}
|
|
5246
|
-
function liHtml(n, ui, siblings, i) {
|
|
5247
|
-
const sub = n.sub ? `<span class="am-tree-sub">${mdInline(n.sub)}</span>` : "";
|
|
5248
|
-
const kids = n.children.length ? `<ul>${n.children.map((c, k) => liHtml(c, ui, n.children, k)).join("")}</ul>` : "";
|
|
5249
|
-
return `<li${n.hi ? ' class="am-tree-hi"' : ""}${vattrs(n)}${lineAttrs(siblings, i, false)}><span class="am-tree-label">${deltaBadge(n.state, ui)}${labelHtml(n.label)}</span>${sub}${kids}</li>`;
|
|
5250
|
-
}
|
|
5251
|
-
|
|
5252
|
-
// src/components/limits.js
|
|
5253
|
-
var NICE_MAX = [1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10];
|
|
5254
|
-
var NICE_STEP = [1, 2, 2.5, 5, 10];
|
|
5255
|
-
function niceScale(peak) {
|
|
5256
|
-
if (!Number.isFinite(peak) || peak <= 0) return { max: 1, step: 1 };
|
|
5257
|
-
const target = peak * 1.4;
|
|
5258
|
-
const pow = 10 ** Math.floor(Math.log10(target));
|
|
5259
|
-
const integral = Number.isInteger(peak);
|
|
5260
|
-
const nice = NICE_MAX.map((m) => m * pow).find((m) => m >= target - 1e-9) ?? 10 * pow;
|
|
5261
|
-
const max = integral ? Math.ceil(nice) : nice;
|
|
5262
|
-
const stepPow = 10 ** Math.floor(Math.log10(max));
|
|
5263
|
-
const step = [...NICE_STEP.map((s) => s * stepPow / 10), ...NICE_STEP.map((s) => s * stepPow)].find((s) => max / s <= 7 && Number.isInteger(round(max / s)) && (integral ? s >= 1 : true)) ?? max;
|
|
5264
|
-
return { max: round(max), step: round(step) };
|
|
5265
|
-
}
|
|
5266
|
-
var round = (n) => Math.round(n * 1e3) / 1e3;
|
|
5267
|
-
var pct = (v, max) => `${Math.round(v / max * 1e4) / 100}%`;
|
|
5268
|
-
var NUM = /^(?:max\s+)?(-?\d+(?:\.\d+)?)$/i;
|
|
5269
|
-
var limits_default = {
|
|
5270
|
-
name: "limits",
|
|
5271
|
-
summary: "Value vs limit bars",
|
|
5272
|
-
syntax: `\`\`\`limits
|
|
5273
|
-
label | value / limit | unit (optional) | note (optional)
|
|
5274
|
-
label | limit | unit \u2190 limit only: the bar fills to the limit
|
|
5275
|
-
\`\`\`
|
|
5276
|
-
- A row turns red when the value is over the limit. The limit may be written as "max 20".`,
|
|
5277
|
-
example: "```limits\nProcedural sentence | 13 / 20 | words\nDescriptive sentence | max 25 | words\nNoun cluster | 4 / 3 | words | over\n```",
|
|
5278
|
-
render(text2, { dir = "ltr", ui } = {}) {
|
|
5279
|
-
const rows = contentLines(text2).map(({ text: t, line }) => parseRow(t, line));
|
|
5280
|
-
if (!rows.length) throw new ComponentError("limits needs at least one line", 1);
|
|
5281
|
-
const words3 = { ...EN_WORDS, ...ui?.limits };
|
|
5282
|
-
return `<div class="am-limits">${rows.map((row) => rowHtml(row, dir === "rtl" ? "right" : "left", words3)).join("")}</div>`;
|
|
5283
|
-
}
|
|
5284
|
-
};
|
|
5285
|
-
function parseRow(t, line) {
|
|
5286
|
-
const [label, spec = "", unit = "", note2 = ""] = fields(t);
|
|
5287
|
-
const [a, b] = spec.split("/").map((s) => s.trim());
|
|
5288
|
-
const nums = (b === void 0 ? [a] : [a, b]).map((s) => s?.match(NUM)?.[1]);
|
|
5289
|
-
if (!spec || nums.some((n) => n === void 0)) {
|
|
5290
|
-
throw new ComponentError(`limits line must be label | value / limit | unit: "${t}"`, line);
|
|
5291
|
-
}
|
|
5292
|
-
const [value, limit] = b === void 0 ? [null, Number(nums[0])] : nums.map(Number);
|
|
5293
|
-
return { label, value, limit, unit, note: note2 };
|
|
5294
|
-
}
|
|
5295
|
-
var EN_WORDS = { value: "{value} / max {limit}", limit: "max {limit}" };
|
|
5296
|
-
var fill = (template, value, limit) => template.replace("{value}", value).replace("{limit}", limit);
|
|
5297
|
-
function rowHtml({ label, value, limit, unit, note: note2 }, side = "left", words3 = EN_WORDS) {
|
|
5298
|
-
const { max, step } = niceScale(Math.max(limit, value ?? 0));
|
|
5299
|
-
const shown2 = value ?? limit;
|
|
5300
|
-
const over2 = value !== null && value > limit;
|
|
5301
|
-
const valText = `${value !== null ? fill(words3.value, value, limit) : fill(words3.limit, value, limit)}${unit ? ` ${unit}` : ""}`;
|
|
5302
|
-
const ticks = [];
|
|
5303
|
-
if (step > 0 && max > 0) {
|
|
5304
|
-
for (let v = 0; v <= max + 1e-9; v += step) ticks.push(`<span style="${side}: ${pct(round(v), max)}">${round(v)}</span>`);
|
|
5305
|
-
}
|
|
5306
|
-
return `<div class="am-lim${over2 ? " is-over" : ""}">
|
|
5307
|
-
<div class="am-lim-head"><span>${esc(label)}${note2 ? `<span class="am-lim-note">${esc(note2)}</span>` : ""}</span><span class="am-lim-val">${esc(valText)}</span></div>
|
|
5308
|
-
<div class="am-lim-track"><div class="am-lim-fill" style="width: ${pct(shown2, max)}"></div><div class="am-lim-mark" style="${side}: ${pct(limit, max)}"></div></div>
|
|
5309
|
-
<div class="am-lim-ticks" aria-hidden="true">${ticks.join("")}</div>
|
|
5310
|
-
</div>`;
|
|
5311
|
-
}
|
|
5312
|
-
|
|
5313
5265
|
// src/runtime/rtl-letter.js
|
|
5314
5266
|
var RTL_LETTER = /[\p{Script=Hebrew}\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Samaritan}\p{Script=Mandaic}]/u;
|
|
5315
5267
|
|
|
@@ -5518,6 +5470,282 @@ function mirrorLayout(g) {
|
|
|
5518
5470
|
}
|
|
5519
5471
|
}
|
|
5520
5472
|
|
|
5473
|
+
// src/steps.js
|
|
5474
|
+
var FORM = "<item> <line or range>: <note>";
|
|
5475
|
+
var EXPLAIN_FORM = "<item>: <explanation>";
|
|
5476
|
+
var IMAGE = /!\[[^\]]*\]\(|<img\b/i;
|
|
5477
|
+
var noImage = (text2, line) => {
|
|
5478
|
+
if (IMAGE.test(text2.replace(/`[^`]*`/g, ""))) throw new ComponentError("steps: a step holds text, not an image; show the picture in its own block", line);
|
|
5479
|
+
};
|
|
5480
|
+
function parseStep(text2, line) {
|
|
5481
|
+
noImage(text2, line);
|
|
5482
|
+
const colon = text2.indexOf(":");
|
|
5483
|
+
if (colon < 0) throw new ComponentError(`steps: write each step as ${FORM}, for example "Start 10-12: Begin here."`, line);
|
|
5484
|
+
const head = text2.slice(0, colon).trim();
|
|
5485
|
+
const at3 = head.match(/(?:^|\s)(\d+)(?:\s*-\s*(\d+))?$/);
|
|
5486
|
+
if (!at3) throw new ComponentError(`steps: "${head}" has no line number before the colon; write ${FORM}`, line);
|
|
5487
|
+
const item = head.slice(0, at3.index).trim();
|
|
5488
|
+
if (!item) throw new ComponentError(`steps: write the item before its lines; ${FORM}`, line);
|
|
5489
|
+
if (item.endsWith("-")) throw new ComponentError(`steps: an item cannot end with "-", which reads as a range; write the item, then the lines as N or N-M`, line);
|
|
5490
|
+
const from = Number(at3[1]);
|
|
5491
|
+
const to = at3[2] === void 0 ? from : Number(at3[2]);
|
|
5492
|
+
if (from < 1) throw new ComponentError(`steps: line numbers start at 1; write 1 or more, not ${from}`, line);
|
|
5493
|
+
if (to < from) throw new ComponentError(`steps: the range ${from}-${to} ends before it starts; the first line must not be after the last`, line);
|
|
5494
|
+
return { item, head, from, to, note: text2.slice(colon + 1).trim(), line };
|
|
5495
|
+
}
|
|
5496
|
+
function parseExplained(text2, line) {
|
|
5497
|
+
noImage(text2, line);
|
|
5498
|
+
const colon = text2.indexOf(":");
|
|
5499
|
+
if (colon < 0) throw new ComponentError(`steps: write each step as ${EXPLAIN_FORM}, for example "Start: Begin here."`, line);
|
|
5500
|
+
const item = text2.slice(0, colon).trim();
|
|
5501
|
+
if (!item) throw new ComponentError(`steps: write the item before its explanation; ${EXPLAIN_FORM}`, line);
|
|
5502
|
+
return { item, head: item, note: text2.slice(colon + 1).trim(), line };
|
|
5503
|
+
}
|
|
5504
|
+
function parseSteps(text2, mode = "code") {
|
|
5505
|
+
const parse = mode === "explain" ? parseExplained : parseStep;
|
|
5506
|
+
const steps2 = contentLines(text2).map((l3) => parse(l3.text, l3.line));
|
|
5507
|
+
if (!steps2.length) throw new ComponentError(`steps: write at least one step, as ${mode === "explain" ? EXPLAIN_FORM : FORM}`, 1);
|
|
5508
|
+
return steps2;
|
|
5509
|
+
}
|
|
5510
|
+
var normalize = (text2) => String(text2).replace(/`/g, "").replace(/\s+/g, " ").trim();
|
|
5511
|
+
var labels = (ui) => ui?.steps ?? en_default.ui.steps;
|
|
5512
|
+
var fill = (text2, values) => text2.replace(/\{(\w+)\}/g, (m, key) => key in values ? String(values[key]) : m);
|
|
5513
|
+
function makeLink(steps2, ui) {
|
|
5514
|
+
const t = labels(ui);
|
|
5515
|
+
const keys = steps2.map((s) => normalize(s.item));
|
|
5516
|
+
const matches = steps2.map(() => 0);
|
|
5517
|
+
const seen = [];
|
|
5518
|
+
const index = (label) => label == null ? -1 : keys.indexOf(normalize(label));
|
|
5519
|
+
return {
|
|
5520
|
+
matches,
|
|
5521
|
+
seen,
|
|
5522
|
+
node(label) {
|
|
5523
|
+
seen.push(label);
|
|
5524
|
+
const i = index(label);
|
|
5525
|
+
if (i < 0) return null;
|
|
5526
|
+
matches[i] += 1;
|
|
5527
|
+
const name2 = fill(t.node, { n: i + 1, item: steps2[i].item });
|
|
5528
|
+
return { n: i + 1, attrs: ` data-link="${i}" tabindex="0" role="button" aria-label="${esc(name2)}"` };
|
|
5529
|
+
},
|
|
5530
|
+
ends(from, to) {
|
|
5531
|
+
const [a, b] = [index(from), index(to)];
|
|
5532
|
+
return a < 0 && b < 0 ? "" : ` data-ends="${a < 0 ? "-" : a} ${b < 0 ? "-" : b}"`;
|
|
5533
|
+
}
|
|
5534
|
+
};
|
|
5535
|
+
}
|
|
5536
|
+
var groupSvg = (html) => html.replace(/(<svg [^>]*?) role="img"/, '$1 role="group"');
|
|
5537
|
+
var stepBadgeSvg = (n, x2, y2) => `<g class="am-step-badge" transform="translate(${f(x2)},${f(y2)})"><circle r="8"/><text text-anchor="middle" dominant-baseline="central">${n}</text></g>`;
|
|
5538
|
+
var stepBadgeHtml = (n) => `<span class="am-step-badge" aria-hidden="true">${n}</span>`;
|
|
5539
|
+
function markCodeLines(html, steps2) {
|
|
5540
|
+
return html.replace(/<span class="am-ln([^"]*)" data-n="(\d+)">/g, (whole, cls, n) => {
|
|
5541
|
+
const line = Number(n);
|
|
5542
|
+
const i = steps2.findLastIndex((s) => line >= s.from && line <= s.to);
|
|
5543
|
+
return i < 0 ? whole : `<span class="am-ln${cls}" data-n="${n}" data-link="${i}"${line === steps2[i].from ? ` data-sn="${i + 1}"` : ""}>`;
|
|
5544
|
+
});
|
|
5545
|
+
}
|
|
5546
|
+
var linesText = (s, t) => s.from === s.to ? fill(t.line, { n: s.from }) : fill(t.lines, { from: s.from, to: s.to });
|
|
5547
|
+
function stepsList(steps2, ui) {
|
|
5548
|
+
const t = labels(ui);
|
|
5549
|
+
const items = steps2.map((s, i) => `<li data-link="${i}"><span class="am-steps-item">${mdInline(s.item)}</span> <span class="am-steps-lines">${esc(linesText(s, t))}</span>${s.note ? ` <span class="am-steps-text">${mdInline(s.note)}</span>` : ""}</li>`);
|
|
5550
|
+
return `<ol class="am-steps-list" aria-label="${esc(t.list)}">${items.join("")}</ol>`;
|
|
5551
|
+
}
|
|
5552
|
+
function explainList(steps2, ui) {
|
|
5553
|
+
const t = labels(ui);
|
|
5554
|
+
const items = steps2.map((s, i) => `<li><div class="am-steps-entry" data-link="${i}"><strong class="am-steps-lead">${i + 1}. <span class="am-steps-item">${mdInline(s.item)}</span></strong>${s.note ? ` <span class="am-steps-text">${mdInline(s.note)}</span>` : ""}</div></li>`);
|
|
5555
|
+
return `<ol class="am-steps-list am-steps-list--explain" aria-label="${esc(t.list)}">${items.join("")}</ol>`;
|
|
5556
|
+
}
|
|
5557
|
+
function stepsBlock(pair, steps2, ui, mode = "code") {
|
|
5558
|
+
const t = labels(ui);
|
|
5559
|
+
const m = steps2.length;
|
|
5560
|
+
const explain = mode === "explain";
|
|
5561
|
+
const hint = explain ? t.hintExplain ?? en_default.ui.steps.hintExplain : t.hint;
|
|
5562
|
+
const after = explain ? "" : stepsList(steps2, ui);
|
|
5563
|
+
return `<div class="am-steps"${explain ? ' data-mode="explain"' : ""} data-steps="${m}" data-count="${esc(t.count)}" data-idle="${esc(fill(t.idle, { m }))}" data-prev="${esc(t.prev)}" data-next="${esc(t.next)}" data-hint="${esc(hint)}" data-bar="${esc(t.bar)}"><div class="am-steps-pair">${pair}</div>${after}</div>`;
|
|
5564
|
+
}
|
|
5565
|
+
var linesName = (s) => s.from === s.to ? `line ${s.from}` : `lines ${s.from}-${s.to}`;
|
|
5566
|
+
|
|
5567
|
+
// src/components/tree.js
|
|
5568
|
+
var tree_default = {
|
|
5569
|
+
name: "tree",
|
|
5570
|
+
summary: "Hierarchy tree (org chart / indented list)",
|
|
5571
|
+
syntax: `\`\`\`tree [list]
|
|
5572
|
+
Root | subtitle
|
|
5573
|
+
Child
|
|
5574
|
+
Grandchild | one-line note
|
|
5575
|
+
*Highlighted child
|
|
5576
|
+
\`\`\`
|
|
5577
|
+
- Indentation (spaces or tabs) sets the level; "label | note" adds a gray note.
|
|
5578
|
+
- One root with 2 to 4 children \u2192 org chart; more children or the list argument \u2192 indented list; several roots \u2192 side by side.
|
|
5579
|
+
- Labels support inline Markdown, such as \`Section 1\` Words.
|
|
5580
|
+
- Change markers show what a plan adds, removes and changes. A line can start with + (added), - (removed) or ~ (changed), followed by a space, after the indentation:
|
|
5581
|
+
\`\`\`tree list
|
|
5582
|
+
src/
|
|
5583
|
+
components/
|
|
5584
|
+
+ delta.js | parses change markers
|
|
5585
|
+
~ flow.js
|
|
5586
|
+
~ tree.js
|
|
5587
|
+
- legacy/
|
|
5588
|
+
old-flow.js
|
|
5589
|
+
\`\`\`
|
|
5590
|
+
- Indentation still sets the level. The children of a + or - node inherit it; a child that carries a different marker is an error. ~ marks one node and is not inherited.
|
|
5591
|
+
- The Changes view draws added in the theme's ok color, removed faded with a struck-through label, changed with a warn outline, and each marked node with a +, \u2212 or ~ badge. A count row and a Before / Changes / After switch sit under the tree: Before and After show the tree as it was and as it will be, plain and without the items that are not in that view.
|
|
5592
|
+
- A line that starts with a marker and a space is always read as a marker. To keep a label that starts with "- ", write \\- item.`,
|
|
5593
|
+
example: "```tree\nASD-STE100 | Simplified Technical English\n Part 1: Writing rules\n `Section 1` Words\n Part 2: Dictionary\n Approved words | one word, one meaning\n```",
|
|
5594
|
+
render(text2, { args, ui, video, link }) {
|
|
5595
|
+
const roots = buildTree(text2);
|
|
5596
|
+
if (!roots.length) throw new ComponentError("tree needs at least one node", 1);
|
|
5597
|
+
return withDelta(treeHtml(roots, /\blist\b/.test(args), ui, link), statesOf(roots), { ui, video });
|
|
5598
|
+
}
|
|
5599
|
+
};
|
|
5600
|
+
function treeHtml(roots, listMode, ui, link) {
|
|
5601
|
+
if (roots.length === 1) {
|
|
5602
|
+
const [root] = roots;
|
|
5603
|
+
const n = root.children.length;
|
|
5604
|
+
if (!listMode && n >= 2 && n <= 4) return orgHtml(root, ui, link);
|
|
5605
|
+
return `<div class="am-tree">${rootBox(root, ui, link, true)}${listHtml(root.children, ui, link)}</div>`;
|
|
5606
|
+
}
|
|
5607
|
+
if (!listMode && roots.length <= 4) {
|
|
5608
|
+
return `<div class="am-tree"><div class="am-tree-cols am-tree-cols--free" style="--n: ${roots.length}">${colsHtml(roots, ui, link)}</div></div>`;
|
|
5609
|
+
}
|
|
5610
|
+
return `<div class="am-tree">${listHtml(roots, ui, link)}</div>`;
|
|
5611
|
+
}
|
|
5612
|
+
var statesOf = (nodes) => nodes.flatMap((n) => [n.state, ...statesOf(n.children)]);
|
|
5613
|
+
function buildTree(text2) {
|
|
5614
|
+
const roots = [];
|
|
5615
|
+
const stack = [];
|
|
5616
|
+
let step = 0;
|
|
5617
|
+
String(text2).split("\n").forEach((raw, i) => {
|
|
5618
|
+
if (!raw.trim()) return;
|
|
5619
|
+
const indent = raw.replace(/\t/g, " ").match(/^ */)[0].length;
|
|
5620
|
+
const node = { ...parseLabel(raw.trim()), indent, step: step++, line: i + 1, children: [] };
|
|
5621
|
+
while (stack.length && stack.at(-1).indent >= indent) stack.pop();
|
|
5622
|
+
(stack.length ? stack.at(-1).children : roots).push(node);
|
|
5623
|
+
stack.push(node);
|
|
5624
|
+
});
|
|
5625
|
+
return roots.map((root) => settle(root, null));
|
|
5626
|
+
}
|
|
5627
|
+
function settle(node, inherited) {
|
|
5628
|
+
const own = markState(node.mark);
|
|
5629
|
+
if (inherited && own && own !== inherited) {
|
|
5630
|
+
throw new ComponentError(`tree: "${node.mark}" under a ${inherited} node contradicts it. The children of a ${inherited} node are ${inherited} too; remove the marker or move the node`, node.line);
|
|
5631
|
+
}
|
|
5632
|
+
const state = inherited ?? own;
|
|
5633
|
+
const below = state === "added" || state === "removed" ? state : null;
|
|
5634
|
+
return { ...node, state, children: node.children.map((child) => settle(child, below)) };
|
|
5635
|
+
}
|
|
5636
|
+
function parseLabel(t) {
|
|
5637
|
+
const escaped = /^\\[+\-~] /.test(t);
|
|
5638
|
+
const { mark, text: text2 } = escaped ? { mark: null, text: t.slice(1) } : splitMarker(t);
|
|
5639
|
+
const hi = text2.startsWith("*");
|
|
5640
|
+
const [label, sub = ""] = fields(hi ? text2.slice(1) : text2);
|
|
5641
|
+
return { label, sub, hi, mark };
|
|
5642
|
+
}
|
|
5643
|
+
var softBreaks = (html) => html.replace(/(<(?:[^>"']|"[^"]*"|'[^']*')*>)|([^<]+)/g, (_2, tag, text2) => tag ?? text2.replace(/\S{12,}/g, (word) => word.replace(/[.@/_:]+(?=[^.@/_:])/g, "$&<wbr>")));
|
|
5644
|
+
var labelHtml = (label) => softBreaks(mdInline(label).replace(/^<code>([^<]*)<\/code>(?=\s*\S)/, '<span class="am-tree-tag">$1</span>'));
|
|
5645
|
+
var vattrs = (n) => ` data-key="${esc(n.label)}" data-step="${n.step}"${deltaAttr(n.state)}`;
|
|
5646
|
+
var HIDDEN_IN = { before: "added", after: "removed" };
|
|
5647
|
+
function lineAttrs(siblings, i, cols) {
|
|
5648
|
+
const n = siblings.length;
|
|
5649
|
+
return Object.entries(HIDDEN_IN).map(([view, hidden]) => {
|
|
5650
|
+
const shown2 = siblings.map((x2) => x2.state !== hidden);
|
|
5651
|
+
const first = shown2.indexOf(true);
|
|
5652
|
+
const last = shown2.lastIndexOf(true);
|
|
5653
|
+
const natural = cols ? n === 1 ? "none" : i === 0 ? "start" : i === n - 1 ? "end" : "full" : i < n - 1 ? "full" : "short";
|
|
5654
|
+
const kind2 = cols ? first === last || i < first || i > last ? "none" : i === first ? "start" : i === last ? "end" : "full" : i < last ? "full" : i === last ? "short" : "none";
|
|
5655
|
+
return kind2 === natural ? "" : ` data-line-${view}="${kind2}"`;
|
|
5656
|
+
}).join("");
|
|
5657
|
+
}
|
|
5658
|
+
var dropAttrs = (children) => Object.entries(HIDDEN_IN).map(([view, hidden]) => children.every((c) => c.state === hidden) ? ` data-line-${view}="none"` : "").join("");
|
|
5659
|
+
var stepOf = (n, link) => {
|
|
5660
|
+
const step = link?.node(n.label);
|
|
5661
|
+
return { attrs: step?.attrs ?? "", badge: step ? stepBadgeHtml(step.n) : "" };
|
|
5662
|
+
};
|
|
5663
|
+
var boxInner = (n, ui, badge = "") => `${badge}${deltaBadge(n.state, ui)}${labelHtml(n.label)}${n.sub ? `<small>${softBreaks(mdInline(n.sub))}</small>` : ""}`;
|
|
5664
|
+
function rootBox(root, ui, link, solo = false) {
|
|
5665
|
+
const drop = solo ? "" : dropAttrs(root.children);
|
|
5666
|
+
const step = stepOf(root, link);
|
|
5667
|
+
return `<div class="am-tree-root${solo ? " am-tree-root--solo" : ""}"${deltaAttr(root.state)}${drop}><div class="am-tree-box am-tree-box--root"${vattrs(root)}${step.attrs}>${boxInner(root, ui, step.badge)}</div></div>`;
|
|
5668
|
+
}
|
|
5669
|
+
function colHtml(node, ui, link, siblings, i) {
|
|
5670
|
+
const children = node.children.length ? listHtml(node.children, ui, link) : "";
|
|
5671
|
+
const step = stepOf(node, link);
|
|
5672
|
+
return `<div class="am-tree-col"${deltaAttr(node.state)}${lineAttrs(siblings, i, true)}><div class="am-tree-box${node.hi ? " am-tree-box--hi" : ""}"${vattrs(node)}${step.attrs}>${boxInner(node, ui, step.badge)}</div>${children}</div>`;
|
|
5673
|
+
}
|
|
5674
|
+
var colsHtml = (nodes, ui, link) => nodes.map((n, i) => colHtml(n, ui, link, nodes, i)).join("");
|
|
5675
|
+
function orgHtml(root, ui, link) {
|
|
5676
|
+
return `<div class="am-tree">${rootBox(root, ui, link)}<div class="am-tree-cols" style="--n: ${root.children.length}">${colsHtml(root.children, ui, link)}</div></div>`;
|
|
5677
|
+
}
|
|
5678
|
+
function listHtml(nodes, ui, link) {
|
|
5679
|
+
return `<ul class="am-tree-list">${nodes.map((n, i) => liHtml(n, ui, link, nodes, i)).join("")}</ul>`;
|
|
5680
|
+
}
|
|
5681
|
+
function liHtml(n, ui, link, siblings, i) {
|
|
5682
|
+
const step = stepOf(n, link);
|
|
5683
|
+
const sub = n.sub ? `<span class="am-tree-sub">${softBreaks(mdInline(n.sub))}</span>` : "";
|
|
5684
|
+
const kids = n.children.length ? `<ul>${n.children.map((c, k) => liHtml(c, ui, link, n.children, k)).join("")}</ul>` : "";
|
|
5685
|
+
return `<li${n.hi ? ' class="am-tree-hi"' : ""}${vattrs(n)}${lineAttrs(siblings, i, false)}><span class="am-tree-label"${step.attrs}>${step.badge}${deltaBadge(n.state, ui)}${labelHtml(n.label)}</span>${sub}${kids}</li>`;
|
|
5686
|
+
}
|
|
5687
|
+
|
|
5688
|
+
// src/components/limits.js
|
|
5689
|
+
var NICE_MAX = [1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10];
|
|
5690
|
+
var NICE_STEP = [1, 2, 2.5, 5, 10];
|
|
5691
|
+
function niceScale(peak) {
|
|
5692
|
+
if (!Number.isFinite(peak) || peak <= 0) return { max: 1, step: 1 };
|
|
5693
|
+
const target = peak * 1.4;
|
|
5694
|
+
const pow = 10 ** Math.floor(Math.log10(target));
|
|
5695
|
+
const integral = Number.isInteger(peak);
|
|
5696
|
+
const nice = NICE_MAX.map((m) => m * pow).find((m) => m >= target - 1e-9) ?? 10 * pow;
|
|
5697
|
+
const max = integral ? Math.ceil(nice) : nice;
|
|
5698
|
+
const stepPow = 10 ** Math.floor(Math.log10(max));
|
|
5699
|
+
const step = [...NICE_STEP.map((s) => s * stepPow / 10), ...NICE_STEP.map((s) => s * stepPow)].find((s) => max / s <= 7 && Number.isInteger(round(max / s)) && (integral ? s >= 1 : true)) ?? max;
|
|
5700
|
+
return { max: round(max), step: round(step) };
|
|
5701
|
+
}
|
|
5702
|
+
var round = (n) => Math.round(n * 1e3) / 1e3;
|
|
5703
|
+
var pct = (v, max) => `${Math.round(v / max * 1e4) / 100}%`;
|
|
5704
|
+
var NUM = /^(?:max\s+)?(-?\d+(?:\.\d+)?)$/i;
|
|
5705
|
+
var limits_default = {
|
|
5706
|
+
name: "limits",
|
|
5707
|
+
summary: "Value vs limit bars",
|
|
5708
|
+
syntax: `\`\`\`limits
|
|
5709
|
+
label | value / limit | unit (optional) | note (optional)
|
|
5710
|
+
label | limit | unit \u2190 limit only: the bar fills to the limit
|
|
5711
|
+
\`\`\`
|
|
5712
|
+
- A row turns red when the value is over the limit. The limit may be written as "max 20".`,
|
|
5713
|
+
example: "```limits\nProcedural sentence | 13 / 20 | words\nDescriptive sentence | max 25 | words\nNoun cluster | 4 / 3 | words | over\n```",
|
|
5714
|
+
render(text2, { dir = "ltr", ui } = {}) {
|
|
5715
|
+
const rows = contentLines(text2).map(({ text: t, line }) => parseRow(t, line));
|
|
5716
|
+
if (!rows.length) throw new ComponentError("limits needs at least one line", 1);
|
|
5717
|
+
const words3 = { ...EN_WORDS, ...ui?.limits };
|
|
5718
|
+
return `<div class="am-limits">${rows.map((row) => rowHtml(row, dir === "rtl" ? "right" : "left", words3)).join("")}</div>`;
|
|
5719
|
+
}
|
|
5720
|
+
};
|
|
5721
|
+
function parseRow(t, line) {
|
|
5722
|
+
const [label, spec = "", unit = "", note2 = ""] = fields(t);
|
|
5723
|
+
const [a, b] = spec.split("/").map((s) => s.trim());
|
|
5724
|
+
const nums = (b === void 0 ? [a] : [a, b]).map((s) => s?.match(NUM)?.[1]);
|
|
5725
|
+
if (!spec || nums.some((n) => n === void 0)) {
|
|
5726
|
+
throw new ComponentError(`limits line must be label | value / limit | unit: "${t}"`, line);
|
|
5727
|
+
}
|
|
5728
|
+
const [value, limit] = b === void 0 ? [null, Number(nums[0])] : nums.map(Number);
|
|
5729
|
+
return { label, value, limit, unit, note: note2 };
|
|
5730
|
+
}
|
|
5731
|
+
var EN_WORDS = { value: "{value} / max {limit}", limit: "max {limit}" };
|
|
5732
|
+
var fill2 = (template, value, limit) => template.replace("{value}", value).replace("{limit}", limit);
|
|
5733
|
+
function rowHtml({ label, value, limit, unit, note: note2 }, side = "left", words3 = EN_WORDS) {
|
|
5734
|
+
const { max, step } = niceScale(Math.max(limit, value ?? 0));
|
|
5735
|
+
const shown2 = value ?? limit;
|
|
5736
|
+
const over2 = value !== null && value > limit;
|
|
5737
|
+
const valText = `${value !== null ? fill2(words3.value, value, limit) : fill2(words3.limit, value, limit)}${unit ? ` ${unit}` : ""}`;
|
|
5738
|
+
const ticks = [];
|
|
5739
|
+
if (step > 0 && max > 0) {
|
|
5740
|
+
for (let v = 0; v <= max + 1e-9; v += step) ticks.push(`<span style="${side}: ${pct(round(v), max)}">${round(v)}</span>`);
|
|
5741
|
+
}
|
|
5742
|
+
return `<div class="am-lim${over2 ? " is-over" : ""}">
|
|
5743
|
+
<div class="am-lim-head"><span>${esc(label)}${note2 ? `<span class="am-lim-note">${esc(note2)}</span>` : ""}</span><span class="am-lim-val">${esc(valText)}</span></div>
|
|
5744
|
+
<div class="am-lim-track"><div class="am-lim-fill" style="width: ${pct(shown2, max)}"></div><div class="am-lim-mark" style="${side}: ${pct(limit, max)}"></div></div>
|
|
5745
|
+
<div class="am-lim-ticks" aria-hidden="true">${ticks.join("")}</div>
|
|
5746
|
+
</div>`;
|
|
5747
|
+
}
|
|
5748
|
+
|
|
5521
5749
|
// src/components/sequence.js
|
|
5522
5750
|
var FS = DRAWING.node;
|
|
5523
5751
|
var NOTE_FS = DRAWING.note;
|
|
@@ -7626,10 +7854,10 @@ var around = ({ x: x2, y: y2 }, { width, height }) => [x2 - width / 2, y2 - heig
|
|
|
7626
7854
|
var inset = ([x0, y0, x1, y1], d) => [x0 + d, y0 + d, x1 - d, y1 - d];
|
|
7627
7855
|
var runsThrough = (curve, box) => curve.slice(1).some((p, k) => segmentHits(curve[k], p, box));
|
|
7628
7856
|
var name = (e) => `${e.from} -> ${e.to}`;
|
|
7629
|
-
function crossings({ g, key, sizes, labels }, { nodes, edges }) {
|
|
7857
|
+
function crossings({ g, key, sizes, labels: labels2 }, { nodes, edges }) {
|
|
7630
7858
|
const drawn = edges.map((e, i) => g.edge({ v: key.get(e.from), w: key.get(e.to), name: `e${i}` }));
|
|
7631
7859
|
const nodeBoxes = [...nodes.keys()].map((id) => [id, inset(around(g.node(key.get(id)), sizes.get(id)), NODE_INSET)]);
|
|
7632
|
-
const labelBoxes = edges.map((e, i) =>
|
|
7860
|
+
const labelBoxes = edges.map((e, i) => labels2[i] ? inset(around(drawn[i], labels2[i]), LABEL_INSET) : null);
|
|
7633
7861
|
return edges.flatMap((edge, i) => {
|
|
7634
7862
|
const curve = curvePoints(drawn[i].points);
|
|
7635
7863
|
const node = nodeBoxes.find(([id, box]) => id !== edge.from && id !== edge.to && runsThrough(curve, box));
|
|
@@ -7713,11 +7941,11 @@ Client -> Gateway
|
|
|
7713
7941
|
- The Changes view draws added in the theme's ok color, removed faded with a struck-through label, changed with a warn outline, and each marked node with a +, \u2212 or ~ badge. A count row and a Before / Changes / After switch sit under the diagram: Before and After show the diagram as it was and as it will be, plain and without the items that are not in that view.
|
|
7714
7942
|
- A line that starts with a marker and a space is always read as a marker. A marker inside the line, before a node ("A -> + B"), is an error: write it at the start, "+ A -> B". To keep a node name that starts with "- ", write it in brackets: [- Gateway].`,
|
|
7715
7943
|
example: "```flow LR\n(User) -> Gateway: HTTPS\nGateway -> Auth & *Service\nService -> [(Database)]\ngroup Backend: Auth, Service\n```",
|
|
7716
|
-
render(text2, { args, uid, ui, warn, video, dir: pageDir = "ltr" }) {
|
|
7944
|
+
render(text2, { args, uid, ui, warn, video, link, dir: pageDir = "ltr" }) {
|
|
7717
7945
|
const model = parseFlow(text2);
|
|
7718
7946
|
model.warnings.forEach((w2) => warn?.(w2));
|
|
7719
7947
|
const flowDir = (args.match(/\b(TB|LR|BT|RL)\b/i)?.[1] ?? "TB").toUpperCase();
|
|
7720
|
-
const html = `<figure class="am-diagram am-flow">${layout2(model, DIRS.has(flowDir) ? flowDir : "TB", uid(), ui, pageDir, video ? void 0 : warn)}</figure>`;
|
|
7948
|
+
const html = `<figure class="am-diagram am-flow">${layout2(model, DIRS.has(flowDir) ? flowDir : "TB", uid(), ui, pageDir, video ? void 0 : warn, link)}</figure>`;
|
|
7721
7949
|
return withDelta(html, [...model.nodes.values(), ...model.edges, ...model.groups].map((x2) => x2.state ?? null), { ui, video });
|
|
7722
7950
|
}
|
|
7723
7951
|
};
|
|
@@ -7924,9 +8152,9 @@ function runLayout({ nodes, edges, groups }, rankdir, rtl, widths, reserve) {
|
|
|
7924
8152
|
});
|
|
7925
8153
|
});
|
|
7926
8154
|
});
|
|
7927
|
-
const
|
|
8155
|
+
const labels2 = edges.map((e) => e.label ? edgeText(e.label) : null);
|
|
7928
8156
|
edges.forEach((e, i) => {
|
|
7929
|
-
const size =
|
|
8157
|
+
const size = labels2[i];
|
|
7930
8158
|
const label = size ? { label: e.label, width: size.width + 2, height: size.height, labelpos: "c" } : {};
|
|
7931
8159
|
g.setEdge(key.get(e.from), key.get(e.to), label, `e${i}`);
|
|
7932
8160
|
});
|
|
@@ -7939,7 +8167,7 @@ function runLayout({ nodes, edges, groups }, rankdir, rtl, widths, reserve) {
|
|
|
7939
8167
|
}
|
|
7940
8168
|
}
|
|
7941
8169
|
fitEdges(g);
|
|
7942
|
-
return { g, key, sizes, labels };
|
|
8170
|
+
return { g, key, sizes, labels: labels2 };
|
|
7943
8171
|
}
|
|
7944
8172
|
function fitEdges(g) {
|
|
7945
8173
|
const graph = g.graph();
|
|
@@ -8040,7 +8268,7 @@ function reservedLayout(model, rankdir, rtl, widths) {
|
|
|
8040
8268
|
}
|
|
8041
8269
|
return { run: run2, spots, reserve };
|
|
8042
8270
|
}
|
|
8043
|
-
function layout2(model, rankdir, id, ui, pageDir = "ltr", warn) {
|
|
8271
|
+
function layout2(model, rankdir, id, ui, pageDir = "ltr", warn, link) {
|
|
8044
8272
|
const { nodes, edges, groups } = model;
|
|
8045
8273
|
const rtl = pageDir === "rtl";
|
|
8046
8274
|
const widths = groups.map((grp) => labelWidth(grp.name, pageDir));
|
|
@@ -8056,13 +8284,14 @@ function layout2(model, rankdir, id, ui, pageDir = "ltr", warn) {
|
|
|
8056
8284
|
const [labelX, labelY] = spots[i] ?? [rtl ? x2 + c.width - 8 : x2 + 8, y2 + 14];
|
|
8057
8285
|
return `<rect class="am-cluster"${mark} x="${f(x2)}" y="${f(y2)}" width="${f(c.width)}" height="${f(c.height)}" rx="4"/><text class="am-cluster-label"${mark} x="${f(labelX)}" y="${f(labelY)}">${esc(svgLine(grp.name, pageDir))}</text>${badgeSvg(grp.state, badgeX, y2)}`;
|
|
8058
8286
|
});
|
|
8059
|
-
const
|
|
8287
|
+
const stepOf2 = new Map([.../* @__PURE__ */ new Set([...[...nodes.values()].map((n) => n.line), ...edges.map((e) => e.line)])].sort((a, b) => a - b).map((l3, k) => [l3, k]));
|
|
8060
8288
|
const edgeSvg = edges.map((e, i) => {
|
|
8061
8289
|
const data = g.edge({ v: key.get(e.from), w: key.get(e.to), name: `e${i}` });
|
|
8062
8290
|
const pts = clipEnds(data.points, g.node(key.get(e.from)), nodes.get(e.from).shape, g.node(key.get(e.to)), nodes.get(e.to).shape);
|
|
8063
8291
|
const head = e.state ? `${id}-arrow-${e.state}` : `${id}-arrow`;
|
|
8064
8292
|
const path = `<path class="am-edge${e.dashed ? " am-edge--dashed" : ""}" d="${smoothPath(pts)}" marker-end="url(#${head})"/>`;
|
|
8065
|
-
const
|
|
8293
|
+
const ends = link ? link.ends(nodes.get(e.from).label, nodes.get(e.to).label) : "";
|
|
8294
|
+
const open = `<g data-step="${stepOf2.get(e.line)}"${deltaAttr(e.state)}${ends}>`;
|
|
8066
8295
|
if (!e.label) return `${open}${path}</g>`;
|
|
8067
8296
|
const { lines, width: w2, height: h2 } = edgeText(e.label);
|
|
8068
8297
|
return `${open}${path}<g class="am-edge-label"><rect x="${f(data.x - w2 / 2)}" y="${f(data.y - h2 / 2)}" width="${f(w2)}" height="${f(h2)}" rx="3"/>${textLines(lines, data.x, data.y, LH2, "", pageDir)}</g></g>`;
|
|
@@ -8071,7 +8300,9 @@ function layout2(model, rankdir, id, ui, pageDir = "ltr", warn) {
|
|
|
8071
8300
|
const { x: x2, y: y2 } = g.node(key.get(n.id));
|
|
8072
8301
|
const { width: w2, height: h2, lines } = sizes.get(n.id);
|
|
8073
8302
|
const badge = badgeSvg(n.state, ...badgePoint(n.shape, x2, y2, w2, h2, rtl));
|
|
8074
|
-
|
|
8303
|
+
const step = link?.node(n.label);
|
|
8304
|
+
const number = step ? stepBadgeSvg(step.n, ...badgePoint(n.shape, x2, y2, w2, h2, !rtl)) : "";
|
|
8305
|
+
return `<g class="am-node am-node--${n.shape}${n.hi ? " am-node--hi" : ""}" data-key="${esc(n.label)}" data-step="${stepOf2.get(n.line)}"${deltaAttr(n.state)}${step?.attrs ?? ""}>${shapeSvg(n.shape, x2, y2, w2, h2)}${textLines(lines, x2, y2 + (n.shape === "db" ? 4 : 0), LH2, ' class="am-node-text"', pageDir)}${badge}${number}</g>`;
|
|
8075
8306
|
});
|
|
8076
8307
|
const { width, height } = g.graph();
|
|
8077
8308
|
const label = diagramLabel(ui, "flow", [...nodes.keys()].slice(0, 8));
|
|
@@ -8202,10 +8433,10 @@ Polling -> Open: reply
|
|
|
8202
8433
|
- The Changes view draws added in the theme's ok color, removed faded with a struck-through label, changed with a warn outline, and each marked state with a +, \u2212 or ~ badge. A count row and a Before / Changes / After switch sit under the diagram.
|
|
8203
8434
|
- A line that starts with a marker and a space is always read as a marker. A marker inside the line, before a state ("A -> + B"), is an error: write it at the start, "+ A -> B".`,
|
|
8204
8435
|
example: "```state LR\n[*] -> Idle\nIdle -> Connecting: connect()\nConnecting -> Open: SYN-ACK\nConnecting -> Closed: RST\nOpen -> Open: retransmit\nOpen -> Closed: close()\nClosed -> [*]\n```",
|
|
8205
|
-
render(text2, { args, uid, ui, video, dir: pageDir = "ltr" }) {
|
|
8436
|
+
render(text2, { args, uid, ui, video, link, dir: pageDir = "ltr" }) {
|
|
8206
8437
|
const model = parseState(text2);
|
|
8207
8438
|
const dir = (args.match(/\b(TB|LR|BT|RL)\b/i)?.[1] ?? "TB").toUpperCase();
|
|
8208
|
-
const html = `<figure class="am-diagram am-state">${layout3(model, DIRS2.has(dir) ? dir : "TB", uid(), ui, pageDir, video)}</figure>`;
|
|
8439
|
+
const html = `<figure class="am-diagram am-state">${layout3(model, DIRS2.has(dir) ? dir : "TB", uid(), ui, pageDir, video, link)}</figure>`;
|
|
8209
8440
|
return withDelta(html, [...model.nodes.values(), ...model.edges].map((x2) => x2.state ?? null), { ui, video });
|
|
8210
8441
|
}
|
|
8211
8442
|
};
|
|
@@ -8287,7 +8518,7 @@ function checkTransitions(edges, nodes) {
|
|
|
8287
8518
|
}
|
|
8288
8519
|
}
|
|
8289
8520
|
}
|
|
8290
|
-
function layout3(model, rankdir, id, ui, pageDir = "ltr", video = false) {
|
|
8521
|
+
function layout3(model, rankdir, id, ui, pageDir = "ltr", video = false, link) {
|
|
8291
8522
|
const { nodes, edges, lines } = model;
|
|
8292
8523
|
const rtl = pageDir === "rtl";
|
|
8293
8524
|
const side = rtl ? -1 : 1;
|
|
@@ -8327,16 +8558,21 @@ function layout3(model, rankdir, id, ui, pageDir = "ltr", video = false) {
|
|
|
8327
8558
|
const extra = room.get(nodeId) ?? {};
|
|
8328
8559
|
return { x: x2 - side * (extra.x ?? 0) / 2, y: y2 - (extra.y ?? 0) / 2 };
|
|
8329
8560
|
};
|
|
8330
|
-
const
|
|
8561
|
+
const stepOf2 = new Map(lines.map((line, i) => [line, i]));
|
|
8331
8562
|
const drawn = straight.map((e, i) => {
|
|
8332
8563
|
const data = g.edge({ v: key.get(e.from), w: key.get(e.to), name: `e${i}` });
|
|
8333
8564
|
return { e, data, points: clipEnds2(data.points, e, centre, boxes, room, nodes) };
|
|
8334
8565
|
});
|
|
8566
|
+
const endsOf = (e) => {
|
|
8567
|
+
if (!link) return "";
|
|
8568
|
+
const label2 = (id2) => nodes.get(id2).kind === "state" ? nodes.get(id2).label : null;
|
|
8569
|
+
return link.ends(label2(e.from), label2(e.to));
|
|
8570
|
+
};
|
|
8335
8571
|
const edgeSvg = drawn.map(({ e, data, points }) => {
|
|
8336
8572
|
const head = e.state ? `${id}-arrow-${e.state}` : `${id}-arrow`;
|
|
8337
8573
|
const path = `<path class="am-edge" d="${smoothPath(points)}" marker-end="url(#${head})"/>`;
|
|
8338
8574
|
const text2 = e.label ? edgeLabelSvg(e.label, data.x, data.y, pageDir) : "";
|
|
8339
|
-
return `<g data-step="${
|
|
8575
|
+
return `<g data-step="${stepOf2.get(e.line)}"${deltaAttr(e.state)}${endsOf(e)}>${path}${text2}</g>`;
|
|
8340
8576
|
});
|
|
8341
8577
|
const seen = /* @__PURE__ */ new Map();
|
|
8342
8578
|
const loopSpecs = loops.map((e) => {
|
|
@@ -8355,18 +8591,20 @@ function layout3(model, rankdir, id, ui, pageDir = "ltr", video = false) {
|
|
|
8355
8591
|
const head = e.state ? `${id}-arrow-${e.state}` : `${id}-arrow`;
|
|
8356
8592
|
const path = `<path class="am-edge" d="${loopPath(spec)}" marker-end="url(#${head})"/>`;
|
|
8357
8593
|
const text2 = e.label && spec.label ? edgeLabelSvg(e.label, spec.label.x, spec.label.y, pageDir) : "";
|
|
8358
|
-
return `<g data-step="${
|
|
8594
|
+
return `<g data-step="${stepOf2.get(e.line)}"${deltaAttr(e.state)}${endsOf(e)}>${path}${text2}</g>`;
|
|
8359
8595
|
});
|
|
8360
8596
|
const nodeSvg = [...nodes.values()].map((n) => {
|
|
8361
8597
|
const { x: x2, y: y2 } = centre(n.id);
|
|
8362
8598
|
const box = boxes.get(n.id);
|
|
8363
|
-
const badgeStep = n.state === "changed" ?
|
|
8599
|
+
const badgeStep = n.state === "changed" ? stepOf2.get(n.tildeLine ?? n.line) : void 0;
|
|
8364
8600
|
const badge = badgeSvg(n.state, rtl ? x2 - box.width / 2 : x2 + box.width / 2, y2 - box.height / 2, badgeStep);
|
|
8365
8601
|
const keyAttr = n.kind === "state" ? ` data-key="${esc(n.label)}"` : "";
|
|
8366
|
-
const
|
|
8602
|
+
const step = n.kind === "state" ? link?.node(n.label) : null;
|
|
8603
|
+
const open = `<g class="am-node am-node--state${n.kind === "state" ? "" : ` am-node--${n.kind}`}"${keyAttr} data-step="${stepOf2.get(n.line)}"${deltaAttr(n.state)}${step?.attrs ?? ""}>`;
|
|
8604
|
+
const number = step ? stepBadgeSvg(step.n, rtl ? x2 + box.width / 2 : x2 - box.width / 2, y2 - box.height / 2) : "";
|
|
8367
8605
|
if (n.kind === "initial") return `${open}<circle class="am-state-dot" cx="${f(x2)}" cy="${f(y2)}" r="${DOT_R}"/>${badge}</g>`;
|
|
8368
8606
|
if (n.kind === "final") return `${open}<circle class="am-state-ring" cx="${f(x2)}" cy="${f(y2)}" r="${DOT_R}"/><circle class="am-state-core" cx="${f(x2)}" cy="${f(y2)}" r="2.8"/>${badge}</g>`;
|
|
8369
|
-
return `${open}<rect class="am-node-shape" x="${f(x2 - box.width / 2)}" y="${f(y2 - box.height / 2)}" width="${f(box.width)}" height="${f(box.height)}" rx="8"/>${textLines(box.lines, x2, y2, LH3, ' class="am-node-text"', pageDir)}${badge}</g>`;
|
|
8607
|
+
return `${open}<rect class="am-node-shape" x="${f(x2 - box.width / 2)}" y="${f(y2 - box.height / 2)}" width="${f(box.width)}" height="${f(box.height)}" rx="8"/>${textLines(box.lines, x2, y2, LH3, ' class="am-node-text"', pageDir)}${badge}${number}</g>`;
|
|
8370
8608
|
});
|
|
8371
8609
|
const xs = [];
|
|
8372
8610
|
const ys = [];
|
|
@@ -8406,12 +8644,12 @@ function layout3(model, rankdir, id, ui, pageDir = "ltr", video = false) {
|
|
|
8406
8644
|
const label = diagramLabel(ui, "state", names2);
|
|
8407
8645
|
const heads = ["added", "removed"].filter((s) => edges.some((e) => e.state === s));
|
|
8408
8646
|
const used = /* @__PURE__ */ new Set([
|
|
8409
|
-
...straight.map((e) =>
|
|
8410
|
-
...loops.map((e) =>
|
|
8411
|
-
...[...nodes.values()].map((n) =>
|
|
8412
|
-
...[...nodes.values()].filter((n) => n.state === "changed").map((n) =>
|
|
8647
|
+
...straight.map((e) => stepOf2.get(e.line)),
|
|
8648
|
+
...loops.map((e) => stepOf2.get(e.line)),
|
|
8649
|
+
...[...nodes.values()].map((n) => stepOf2.get(n.line)),
|
|
8650
|
+
...[...nodes.values()].filter((n) => n.state === "changed").map((n) => stepOf2.get(n.tildeLine ?? n.line))
|
|
8413
8651
|
]);
|
|
8414
|
-
const empty = video ? lines.map((line) => used.has(
|
|
8652
|
+
const empty = video ? lines.map((line) => used.has(stepOf2.get(line)) ? "" : `<g data-step="${stepOf2.get(line)}"></g>`).join("") : "";
|
|
8415
8653
|
return `${svgOpen(width, height, label, pageDir)}${arrowDefs(id, heads)}<g${shift}><g>${edgeSvg.join("")}</g><g>${loopsSvg.join("")}</g><g>${nodeSvg.join("")}</g>${empty}</g></svg>`;
|
|
8416
8654
|
}
|
|
8417
8655
|
function edgeLabelSvg(label, x2, y2, pageDir) {
|
|
@@ -8656,7 +8894,7 @@ function layout4(model, rankdir, ui, pageDir = "ltr") {
|
|
|
8656
8894
|
const rtl = pageDir === "rtl";
|
|
8657
8895
|
if (rtl) mirrorLayout(g);
|
|
8658
8896
|
const steps2 = [.../* @__PURE__ */ new Set([...[...entities.values()].map((e) => e.line), ...rels.map((r) => r.line)])].sort((a, b) => a - b);
|
|
8659
|
-
const
|
|
8897
|
+
const stepOf2 = new Map(steps2.map((line, i) => [line, i]));
|
|
8660
8898
|
const straight = rels.filter((rel) => rel.from !== rel.to).map((rel, i) => {
|
|
8661
8899
|
const data = g.edge({ v: key.get(rel.from), w: key.get(rel.to), name: `e${i}` });
|
|
8662
8900
|
const points = data.points.map((p) => ({ ...p }));
|
|
@@ -8666,12 +8904,12 @@ function layout4(model, rankdir, ui, pageDir = "ltr") {
|
|
|
8666
8904
|
});
|
|
8667
8905
|
const edgeSvg = straight.map(({ rel, data, points }) => {
|
|
8668
8906
|
const label2 = rel.label ? labelSvg(rel.label, data.x, data.y, pageDir) : "";
|
|
8669
|
-
return `<g data-step="${
|
|
8907
|
+
return `<g data-step="${stepOf2.get(rel.line)}"${deltaAttr(rel.state)}><path class="am-edge" d="${smoothPath(points)}"/>${endsSvg(points, rel)}${label2}</g>`;
|
|
8670
8908
|
});
|
|
8671
8909
|
const nodeSvg = [...entities.values()].map((entity) => {
|
|
8672
8910
|
const { x: x2, y: y2 } = centre(entity.name);
|
|
8673
8911
|
const size = sizes.get(entity.name);
|
|
8674
|
-
return nodeSvgOf(entity, x2, y2, size,
|
|
8912
|
+
return nodeSvgOf(entity, x2, y2, size, stepOf2.get(entity.line), pageDir);
|
|
8675
8913
|
});
|
|
8676
8914
|
const s = rtl ? -1 : 1;
|
|
8677
8915
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -8684,7 +8922,7 @@ function layout4(model, rankdir, ui, pageDir = "ltr") {
|
|
|
8684
8922
|
const spec = below ? loopBelow({ x: x2, y: y2, height: size.height, depth, side: s, labelWidth: lw }) : loopBeside({ x: x2, y: y2, width: size.width, nth, side: s, labelWidth: lw });
|
|
8685
8923
|
return { rel, ...spec };
|
|
8686
8924
|
});
|
|
8687
|
-
const loopsSvg = loopSpecs.map((spec) => loopSvg(spec,
|
|
8925
|
+
const loopsSvg = loopSpecs.map((spec) => loopSvg(spec, stepOf2.get(spec.rel.line), pageDir));
|
|
8688
8926
|
const xs = [];
|
|
8689
8927
|
const ys = [];
|
|
8690
8928
|
const at3 = (x2, y2) => {
|
|
@@ -9076,6 +9314,7 @@ var ask_default = {
|
|
|
9076
9314
|
name: "ask",
|
|
9077
9315
|
summary: "A decision the reader makes on the page (collected by Reply)",
|
|
9078
9316
|
pageOnly: true,
|
|
9317
|
+
pageOnlyReason: "a video cannot take answers",
|
|
9079
9318
|
panelOnly: true,
|
|
9080
9319
|
// Preview blocks are rendered with the page's scale, so the ask output must not take the factor again.
|
|
9081
9320
|
scalesOwnSvg: true,
|
|
@@ -9293,18 +9532,18 @@ function drawBars(data, { horizontal = false, unit = "", dir = "ltr", label }) {
|
|
|
9293
9532
|
var barClass = (m, row, k) => `am-ch-bar ${row.hi && m.count === 1 ? "am-ch-hi" : `am-ch-s${k + 1}`}`;
|
|
9294
9533
|
var rowClass = (m, row) => `am-ch-row${m.anyHi ? row.hi ? " is-hi" : " is-dim" : ""}`;
|
|
9295
9534
|
var rowGroup = (m, row, i, title, inner) => stepGroup(i, rowClass(m, row), title, inner);
|
|
9296
|
-
function planCategories(
|
|
9535
|
+
function planCategories(labels2, from, to) {
|
|
9297
9536
|
for (let slot = from; slot <= to; slot += 6) {
|
|
9298
|
-
const lines =
|
|
9537
|
+
const lines = labels2.map((l3) => wrap(l3, slot - 8, FS4.cat));
|
|
9299
9538
|
if (lines.every((ls) => ls.length <= 2 && ls.every((l3) => measure(l3, FS4.cat) <= slot - 8 + 0.5))) return { slot, lines };
|
|
9300
9539
|
}
|
|
9301
|
-
return { slot: from, lines: null, shown:
|
|
9540
|
+
return { slot: from, lines: null, shown: labels2.map((l3) => shorten(l3, SLANT_MAX, FS4.cat)) };
|
|
9302
9541
|
}
|
|
9303
9542
|
function verticalBars(m) {
|
|
9304
|
-
const { rows, count: count2, range, labels, rtl, dir } = m;
|
|
9543
|
+
const { rows, count: count2, range, labels: labels2, rtl, dir } = m;
|
|
9305
9544
|
const n = rows.length;
|
|
9306
|
-
const valueW =
|
|
9307
|
-
const barMax = Math.min(64, Math.max(BAR_W[count2],
|
|
9545
|
+
const valueW = labels2 ? Math.max(...rows.flatMap((r) => r.values.map((v) => measure(m.tick(v), FS4.val)))) : 0;
|
|
9546
|
+
const barMax = Math.min(64, Math.max(BAR_W[count2], labels2 ? Math.ceil(valueW) + 4 : 0));
|
|
9308
9547
|
const budget = Math.floor(MAX_WIDTH / n);
|
|
9309
9548
|
const natural = Math.min(budget, count2 * barMax + (count2 - 1) * GAP + GUTTER);
|
|
9310
9549
|
const plan = planCategories(rows.map((r) => r.label), natural, Math.max(natural, Math.min(budget, SLOT_MAX)));
|
|
@@ -9315,9 +9554,9 @@ function verticalBars(m) {
|
|
|
9315
9554
|
const axisX = PAD3 + Math.max(0, reach) + tickW + 6;
|
|
9316
9555
|
const legend = legendLayout(m.names, Math.max(n * slot + tickW, 240));
|
|
9317
9556
|
const W3 = Math.ceil(Math.max(axisX + n * slot + PAD3, (legend.width ?? 0) + 2 * PAD3));
|
|
9318
|
-
const plotTop = PAD3 + legend.height + (
|
|
9557
|
+
const plotTop = PAD3 + legend.height + (labels2 ? 16 : 6);
|
|
9319
9558
|
const plotBottom = plotTop + PLOT_H;
|
|
9320
|
-
const negLabels =
|
|
9559
|
+
const negLabels = labels2 && range.min < 0;
|
|
9321
9560
|
const catTop = plotBottom + (negLabels ? 18 : 8);
|
|
9322
9561
|
const catH = plan.lines ? Math.max(...plan.lines.map((ls) => ls.length)) * LH5 + 4 : Math.max(...plan.shown.map((l3) => measure(l3, FS4.cat))) * SIN + 12;
|
|
9323
9562
|
const height = catTop + catH + PAD3;
|
|
@@ -9336,7 +9575,7 @@ function verticalBars(m) {
|
|
|
9336
9575
|
const h2 = Math.max(Math.abs(y2(v) - y0), v === 0 ? 0 : 1);
|
|
9337
9576
|
const top2 = v >= 0 ? y0 - h2 : y0;
|
|
9338
9577
|
const bar = `<rect class="${barClass(m, row, k)}" x="${f(rectX(x2, bw))}" y="${f(top2)}" width="${bw}" height="${f(h2)}" rx="2"/>`;
|
|
9339
|
-
if (!
|
|
9578
|
+
if (!labels2) return bar;
|
|
9340
9579
|
const at3 = v >= 0 ? top2 - 4 : top2 + h2 + FS4.val + 1;
|
|
9341
9580
|
return bar + text("am-ch-val", X3(x2 + bw / 2), at3, m.tick(v), dir, ' text-anchor="middle"');
|
|
9342
9581
|
});
|
|
@@ -9346,16 +9585,16 @@ function verticalBars(m) {
|
|
|
9346
9585
|
return { width: W3, height, body };
|
|
9347
9586
|
}
|
|
9348
9587
|
function horizontalBars(m) {
|
|
9349
|
-
const { rows, count: count2, range, labels, rtl, dir } = m;
|
|
9588
|
+
const { rows, count: count2, range, labels: labels2, rtl, dir } = m;
|
|
9350
9589
|
const n = rows.length;
|
|
9351
9590
|
const lines = rows.map((r) => fitLines(r.label, CAT_WIDTH, 3, FS4.cat));
|
|
9352
9591
|
const catW = Math.max(...lines.flat().map((l3) => measure(l3, FS4.cat)));
|
|
9353
9592
|
const bh = BAR_H[count2];
|
|
9354
9593
|
const rowH = Math.max(count2 * bh + (count2 - 1) * GAP + 12, Math.max(...lines.map((ls) => ls.length)) * LH5 + 6);
|
|
9355
9594
|
const rel = (v) => (v - range.min) / (range.max - range.min) * PLOT_W;
|
|
9356
|
-
const widths = rows.map((r) => r.values.map((v) =>
|
|
9357
|
-
const after =
|
|
9358
|
-
const before =
|
|
9595
|
+
const widths = rows.map((r) => r.values.map((v) => labels2 ? measure(m.tick(v), FS4.val) : 0));
|
|
9596
|
+
const after = labels2 ? Math.max(0, ...rows.flatMap((r, i) => r.values.map((v, k) => v >= 0 ? rel(v) + 4 + widths[i][k] - PLOT_W : 0))) : 0;
|
|
9597
|
+
const before = labels2 ? Math.max(0, ...rows.flatMap((r, i) => r.values.map((v, k) => v < 0 ? widths[i][k] + 4 - rel(v) : 0))) : 0;
|
|
9359
9598
|
const tickHalf = Math.max(...range.ticks.map((t) => measure(m.tick(t), FS4.tick))) / 2;
|
|
9360
9599
|
const catX = PAD3 + catW;
|
|
9361
9600
|
const axisX = Math.max(catX + 8 + before, PAD3 + tickHalf);
|
|
@@ -9381,7 +9620,7 @@ function horizontalBars(m) {
|
|
|
9381
9620
|
const [from, to] = [Math.min(x0, x2(v)), Math.max(x0, x2(v))];
|
|
9382
9621
|
const w2 = Math.max(to - from, v === 0 ? 0 : 1);
|
|
9383
9622
|
const bar = `<rect class="${barClass(m, row, k)}" x="${f(rtl ? W3 - from - w2 : from)}" y="${f(by)}" width="${f(w2)}" height="${bh}" rx="2"/>`;
|
|
9384
|
-
if (!
|
|
9623
|
+
if (!labels2) return bar;
|
|
9385
9624
|
const end = v >= 0 ? x2(v) + 4 : x2(v) - 4;
|
|
9386
9625
|
return bar + text("am-ch-val", X3(end), by + bh / 2, m.tick(v), dir, ` text-anchor="${v >= 0 ? "start" : "end"}" dominant-baseline="central"`);
|
|
9387
9626
|
});
|
|
@@ -9424,15 +9663,15 @@ function shownRows(rows, step) {
|
|
|
9424
9663
|
return rows.map((r, i) => his.includes(i) ? true : i % step === 0 && his.every((h2) => Math.abs(h2 - i) >= step));
|
|
9425
9664
|
}
|
|
9426
9665
|
function planAxis(rows, slot) {
|
|
9427
|
-
const
|
|
9666
|
+
const labels2 = rows.map((r) => r.label);
|
|
9428
9667
|
for (let step = 1; step <= Math.max(1, Math.floor(rows.length / 4)); step++) {
|
|
9429
9668
|
const show2 = shownRows(rows, step);
|
|
9430
9669
|
const room = step * slot - 8;
|
|
9431
|
-
const lines =
|
|
9670
|
+
const lines = labels2.map((l3, i) => show2[i] ? wrap(l3, room, FS4.cat) : null);
|
|
9432
9671
|
if (lines.every((ls) => !ls || ls.length <= 2 && ls.every((l3) => measure(l3, FS4.cat) <= room + 0.5))) return { show: show2, lines, widths: lines.map((ls) => ls ? Math.max(...ls.map((l3) => measure(l3, FS4.cat))) : 0) };
|
|
9433
9672
|
}
|
|
9434
9673
|
const show = shownRows(rows, Math.max(1, Math.ceil((LH5 + 1) / (slot * SIN))));
|
|
9435
|
-
const shown2 =
|
|
9674
|
+
const shown2 = labels2.map((l3) => shorten(l3, SLANT_MAX, FS4.cat));
|
|
9436
9675
|
return { show, lines: null, shown: shown2, widths: shown2.map((l3) => measure(l3, FS4.cat)) };
|
|
9437
9676
|
}
|
|
9438
9677
|
function valueLabels(m, X3, x2, values, ys, { valleys, end, bottom }) {
|
|
@@ -9679,8 +9918,47 @@ function dataTable({ series, rows }, { type, unit }, words3) {
|
|
|
9679
9918
|
return `<details class="am-ch-data${pie ? " am-ch-data--pie" : ""}"><summary>${esc(words3.data)}</summary><div class="am-table-wrap"><table>${head}<tbody>${body.join("")}</tbody></table></div></details>`;
|
|
9680
9919
|
}
|
|
9681
9920
|
|
|
9921
|
+
// src/components/steps.js
|
|
9922
|
+
var steps_default = {
|
|
9923
|
+
name: "steps",
|
|
9924
|
+
summary: "Link a diagram to a code block, or walk through it step by step with an explanation per step",
|
|
9925
|
+
syntax: `\`\`\`steps
|
|
9926
|
+
<item> <line or range>: <note>
|
|
9927
|
+
\`\`\`
|
|
9928
|
+
- Two modes. With a code block in the panel, a step links an item to lines of the code (below). With a diagram and no code block, a step is an item and its explanation (explain mode, at the end). The block draws nothing itself: it ties the pieces together, and they take the place of whichever of them you wrote first.
|
|
9929
|
+
- Code mode: put it in a panel with one code block and, optionally, one flow, state or tree diagram. <item> is the text of an item in the diagram, exactly as the diagram writes it (a flow node, a state, a tree entry). The lines are the last number or the range before the colon, N or N-M. The note is one short sentence. The first colon ends the item, so an item cannot hold a colon: to link a tree entry such as "Part 1: Writing rules", rename that entry in the diagram so it has no colon. Spaces around the dash of a range are fine (1 - 2).
|
|
9930
|
+
- Line numbers are the ones the code block shows: the file's own numbers with src= and lines=, the numbers from start=, else from 1. A linked code block always shows its line numbers.
|
|
9931
|
+
- The steps run in the order you write them. A diagram item with no step stays a plain item. Write no diagram, and the block is a step-by-step walkthrough of the code: the items are then just names for the steps.
|
|
9932
|
+
- On the page a click on an item boxes its lines, shows its note above them and marks its edges; a click on a line number picks the step that covers the line; the bar above the pair has Previous, Next and the step count; the arrow keys move and Esc clears. Side by side from about 720px of width, stacked below it.
|
|
9933
|
+
- In print, in a PNG or PDF and with no script, the page shows no bar and no boxes. Every step is numbered on its item and beside its first line, and a numbered list of the steps follows the pair.
|
|
9934
|
+
- Explain mode: put it in a panel with one flow, state or tree diagram and no code block, and write each step as <item>: <explanation>. The item is everything before the first colon, with no line numbers, so it may end in a number ("Step 2: ..."). The explanation is one short sentence of inline Markdown, and may be empty. The pair is the diagram and a numbered list of the steps, in the order you wrote the diagram and the steps block. Explain mode example:
|
|
9935
|
+
|
|
9936
|
+
\`\`\`flow LR
|
|
9937
|
+
Order -> Pay -> Ship
|
|
9938
|
+
\`\`\`
|
|
9939
|
+
|
|
9940
|
+
\`\`\`steps
|
|
9941
|
+
Order: The customer places the order.
|
|
9942
|
+
Pay: The payment is taken.
|
|
9943
|
+
Ship: The warehouse sends the parcel.
|
|
9944
|
+
\`\`\`
|
|
9945
|
+
|
|
9946
|
+
- Explain mode on the page: the list stays beside the diagram; a click on an item or on a list entry, Enter or Space on either, the arrow keys, Previous and Next pick a step, which lights the item and its edges and marks its entry in the list. Esc clears. There is no note bar, because the list carries the explanation. Print, PNG, PDF and no script show the numbered badges on the diagram and the numbered list.
|
|
9947
|
+
- \`am render\` reports, with the draft line: an item that is not in the diagram or that matches more than one, the same item in two steps, a range outside the code block, two steps whose lines overlap, a panel with neither a code block nor a diagram, a panel with more than one code block or diagram, a second steps block, an image in a step, an item that ends with "-" (code mode), an item whose diagram entry holds a colon, a steps block inside an ask option, a diagram type that is not linked yet (er, class, sequence, timeline and chart), and a diff block. In explain mode a step written with lines ("Item 3-4: ...") is an item that is not in the diagram, and the message says that a step has no line numbers there.`,
|
|
9948
|
+
example: "```steps\nUser 1-2: The user starts the request.\nGateway 3: The gateway checks it.\nService 4-5: The service does the work.\n```",
|
|
9949
|
+
// A whole panel for am help steps and the docs: a code block, a diagram and the steps that link them.
|
|
9950
|
+
specimen: "```js start=1\nconst request = receive(input);\nconst user = authenticate(request);\nconst result = await service.run(user);\nrespond(result);\n```\n\n```flow LR\nGateway -> Auth -> Service\n```\n\n```steps\nGateway 1: The request comes in.\nAuth 2: The user is checked.\nService 3-4: The service runs, then the answer goes back.\n```",
|
|
9951
|
+
panelOnly: true,
|
|
9952
|
+
pageOnly: true,
|
|
9953
|
+
pageOnlyReason: "a video cannot click through steps",
|
|
9954
|
+
// The pair is made by src/steps-panel.js. A steps block that reaches this point stands where no pair can be made (an ask option).
|
|
9955
|
+
render() {
|
|
9956
|
+
throw new ComponentError("steps: a steps block links the code block and the diagram of its own panel; it cannot go inside another block such as an ask option", 0);
|
|
9957
|
+
}
|
|
9958
|
+
};
|
|
9959
|
+
|
|
9682
9960
|
// src/components/index.js
|
|
9683
|
-
var ALL2 = [callout_default, kv_default, timeline_default, annot_default, tree_default, limits_default, chart_default, sequence_default, flow_default, state_default, er_default, class_default, api_default, ask_default];
|
|
9961
|
+
var ALL2 = [callout_default, kv_default, timeline_default, annot_default, tree_default, limits_default, chart_default, sequence_default, flow_default, state_default, er_default, class_default, api_default, ask_default, steps_default];
|
|
9684
9962
|
var COMPONENTS = new Map(ALL2.map((c) => [c.name, c]));
|
|
9685
9963
|
var RAW_LANGS = /* @__PURE__ */ new Set(["html", "svg"]);
|
|
9686
9964
|
|
|
@@ -9747,7 +10025,7 @@ function parseDocLoose(source, { defaults: defaults2 = {}, choices = {} } = {})
|
|
|
9747
10025
|
const { meta, bodyStart } = parseFrontmatter(lines, { ...DEFAULT_META, ...defaults2 }, { ...CHOICES, ...choices });
|
|
9748
10026
|
const errors = [];
|
|
9749
10027
|
const sections = splitSections(lines, bodyStart, errors);
|
|
9750
|
-
const intro = extractTitle(sections.intro, meta);
|
|
10028
|
+
const intro = dropLeadLabel(extractTitle(sections.intro, meta));
|
|
9751
10029
|
const panels = assignIds(sections.panels);
|
|
9752
10030
|
return { doc: { meta, intro, panels }, errors };
|
|
9753
10031
|
}
|
|
@@ -9969,6 +10247,13 @@ function extractTitle(intro, meta) {
|
|
|
9969
10247
|
if (!remaining.some((l3) => l3.trim())) return rest;
|
|
9970
10248
|
return [{ ...first, text: remaining.join("\n"), line: first.line + idx + 1 }, ...rest];
|
|
9971
10249
|
}
|
|
10250
|
+
var LEAD_LABEL = /^((?:[ \t]*\n)*)[ \t]{0,3}(?:\*\*lead[ \t]*[::]\*\*|\*\*lead\*\*[ \t]*[::]|lead[ \t]*[::])[ \t]*/i;
|
|
10251
|
+
function dropLeadLabel(intro) {
|
|
10252
|
+
const [first, ...rest] = intro;
|
|
10253
|
+
if (first?.type !== "md" || !LEAD_LABEL.test(first.text)) return intro;
|
|
10254
|
+
const text2 = first.text.replace(LEAD_LABEL, "$1");
|
|
10255
|
+
return text2.trim() ? [{ ...first, text: text2 }, ...rest] : rest;
|
|
10256
|
+
}
|
|
9972
10257
|
function assignIds(panels) {
|
|
9973
10258
|
const used = /* @__PURE__ */ new Set();
|
|
9974
10259
|
const firstById = /* @__PURE__ */ new Map();
|
|
@@ -9996,15 +10281,15 @@ function assignIds(panels) {
|
|
|
9996
10281
|
return panels.map((p) => p.id ? p : { ...p, id: nextFree() });
|
|
9997
10282
|
}
|
|
9998
10283
|
function stripLineComment(line) {
|
|
9999
|
-
let
|
|
10284
|
+
let quote2 = "";
|
|
10000
10285
|
for (let i = 0; i < line.length; i++) {
|
|
10001
10286
|
const c = line[i];
|
|
10002
|
-
if (
|
|
10003
|
-
if (c ===
|
|
10287
|
+
if (quote2) {
|
|
10288
|
+
if (c === quote2) quote2 = "";
|
|
10004
10289
|
continue;
|
|
10005
10290
|
}
|
|
10006
10291
|
if (c === '"' || c === "'") {
|
|
10007
|
-
|
|
10292
|
+
quote2 = c;
|
|
10008
10293
|
continue;
|
|
10009
10294
|
}
|
|
10010
10295
|
if (c === "#" && (i === 0 || /\s/.test(line[i - 1]))) return line.slice(0, i);
|
|
@@ -10051,7 +10336,7 @@ function headHtml(meta, introHtml, language = {}) {
|
|
|
10051
10336
|
}
|
|
10052
10337
|
|
|
10053
10338
|
// src/templates/sheet.js
|
|
10054
|
-
var ruler = (side,
|
|
10339
|
+
var ruler = (side, labels2) => `<div class="am-ruler am-ruler--${side}" aria-hidden="true">${labels2.map((l3) => `<span>${l3}</span>`).join("")}</div>`;
|
|
10055
10340
|
function fillRows(panels, cols) {
|
|
10056
10341
|
const spans = panels.map((p) => Math.max(1, Math.min(Number(p.attrs.span) || 1, cols)));
|
|
10057
10342
|
if (panels.some((p) => Number(p.attrs.rows) > 1)) return spans;
|
|
@@ -10060,9 +10345,9 @@ function fillRows(panels, cols) {
|
|
|
10060
10345
|
if (used + span > cols) used = 0;
|
|
10061
10346
|
used += span;
|
|
10062
10347
|
const next = spans[i + 1];
|
|
10063
|
-
const
|
|
10064
|
-
used =
|
|
10065
|
-
return span +
|
|
10348
|
+
const fill3 = next === void 0 || used + next > cols ? cols - used : 0;
|
|
10349
|
+
used = fill3 || used === cols ? 0 : used;
|
|
10350
|
+
return span + fill3;
|
|
10066
10351
|
});
|
|
10067
10352
|
}
|
|
10068
10353
|
var WIDE_TABLE_COLS = 4;
|
|
@@ -10095,7 +10380,7 @@ function sheet({ meta, introHtml, panels, language }) {
|
|
|
10095
10380
|
${headHtml(meta, introHtml, language)}
|
|
10096
10381
|
<div class="am-frame">
|
|
10097
10382
|
${ruler("top", nums)}${ruler("bottom", nums)}${ruler("left", letters)}${ruler("right", letters)}
|
|
10098
|
-
<div class="am-grid" style="--cols: ${cols}">
|
|
10383
|
+
<div class="am-grid${cols === 1 ? " am-grid--single" : ""}" style="--cols: ${cols}">
|
|
10099
10384
|
${placed.map((p, i) => panelHtml(p, { cols, hints: { span: panels[i].attrs.span } })).join("\n")}
|
|
10100
10385
|
</div>
|
|
10101
10386
|
</div>
|
|
@@ -10150,11 +10435,11 @@ var videoSel = (t) => `html[data-video][data-theme="${t.name}"]`;
|
|
|
10150
10435
|
var scoped = (css, sel) => css.replace(/&/g, sel);
|
|
10151
10436
|
var languageFontCss = () => fontLanguages().map((l3) => block(langSelector(l3, "html", "[data-theme][data-mode]"), { "--font-sans": l3.fonts.sans }));
|
|
10152
10437
|
var ownLanguageFont = (t) => fontLanguages().map((l3) => block(langSelector(l3, "html", `[data-theme="${t.name}"][data-mode]`), { "--font-sans": t.tokens.common["--font-sans"] }));
|
|
10153
|
-
function pageCss(list2 = themes("page"), { diff = false, delta = false, rtl = false, math: math2 = false, chart = false, table = false, update: update2 = false, closeAfter = false, fonts = true, scale = 1 } = {}) {
|
|
10438
|
+
function pageCss(list2 = themes("page"), { diff = false, delta = false, rtl = false, math: math2 = false, chart = false, steps: steps2 = false, table = false, update: update2 = false, closeAfter = false, fonts = true, scale = 1 } = {}) {
|
|
10154
10439
|
const decorations = list2.filter((t) => t.css).map((t) => scoped(t.css, pageSel(t)));
|
|
10155
10440
|
const fontFaces = fonts ? [...new Set(list2.map((t) => t.font).filter((f2) => f2 && FONT_CSS[f2]))].map((f2) => FONT_CSS[f2]) : [];
|
|
10156
10441
|
const ownFonts = list2.filter((t) => t.ownFont).flatMap(ownLanguageFont);
|
|
10157
|
-
return [list2.map((t) => tokenCss(pageSel(t), t.tokens, t.mode)).join("\n\n"), ...languageFontCss(), ...ownFonts, typeScaleCss(), ...scale === 1 ? [] : [`html { --am-scale: ${scale}; }`], BASE_CSS, ...math2 ? [MATH_CSS] : [], ...chart ? [CHART_CSS] : [], ...table ? [TABLE_CSS] : [], ...diff ? [DIFF_CSS] : [], ...delta ? [DELTA_CSS] : [], ...update2 ? [UPDATE_CSS] : [], ...closeAfter ? [CLOSE_AFTER_CSS] : [], ...rtl ? [RTL_CSS] : [], ...fontFaces, ...decorations].join("\n\n");
|
|
10442
|
+
return [list2.map((t) => tokenCss(pageSel(t), t.tokens, t.mode)).join("\n\n"), ...languageFontCss(), ...ownFonts, typeScaleCss(), ...scale === 1 ? [] : [`html { --am-scale: ${scale}; }`], BASE_CSS, ...math2 ? [MATH_CSS] : [], ...chart ? [CHART_CSS] : [], ...table ? [TABLE_CSS] : [], ...diff ? [DIFF_CSS] : [], ...delta ? [DELTA_CSS] : [], ...steps2 ? [STEPS_CSS] : [], ...update2 ? [UPDATE_CSS] : [], ...closeAfter ? [CLOSE_AFTER_CSS] : [], ...rtl ? [RTL_CSS] : [], ...fontFaces, ...decorations].join("\n\n");
|
|
10158
10443
|
}
|
|
10159
10444
|
function videoCss(list2 = themes("video"), { diff = false, delta = false, rtl = false, chart = false } = {}) {
|
|
10160
10445
|
const parts = list2.filter((t) => t.video).flatMap((t) => [
|
|
@@ -10515,7 +10800,7 @@ function resolveLanguage({ declared, previous, text: text2 = "" }) {
|
|
|
10515
10800
|
const tag = declaredTag ?? canonicalTag(previous) ?? detectLang(text2);
|
|
10516
10801
|
const locale = new Intl.Locale(tag).maximize();
|
|
10517
10802
|
const entry = findLanguage(locale.language, locale.script);
|
|
10518
|
-
const
|
|
10803
|
+
const labels2 = entry ?? FALLBACK;
|
|
10519
10804
|
return Object.freeze({
|
|
10520
10805
|
tag,
|
|
10521
10806
|
declared: declaredTag !== null,
|
|
@@ -10523,11 +10808,11 @@ function resolveLanguage({ declared, previous, text: text2 = "" }) {
|
|
|
10523
10808
|
script: locale.script,
|
|
10524
10809
|
dir: directionOf(locale),
|
|
10525
10810
|
supported: Boolean(entry),
|
|
10526
|
-
labelKey:
|
|
10527
|
-
ui:
|
|
10528
|
-
videoUi:
|
|
10529
|
-
metaKeys:
|
|
10530
|
-
dateOrder:
|
|
10811
|
+
labelKey: labels2.id,
|
|
10812
|
+
ui: labels2.deltaCounts ? { ...labels2.ui, delta: { ...labels2.ui.delta, counts: labels2.deltaCounts } } : labels2.ui,
|
|
10813
|
+
videoUi: labels2.videoUi,
|
|
10814
|
+
metaKeys: labels2.metaKeys ?? {},
|
|
10815
|
+
dateOrder: labels2.dateOrder ?? "ymd"
|
|
10531
10816
|
});
|
|
10532
10817
|
}
|
|
10533
10818
|
|
|
@@ -10736,7 +11021,7 @@ function readEmbeddedCode(html) {
|
|
|
10736
11021
|
[...inner.matchAll(LINE_SPAN)].map((m) => unescapeHtml(m[1]))
|
|
10737
11022
|
]));
|
|
10738
11023
|
}
|
|
10739
|
-
function renderCode({ lang, args, text: text2 }, { baseDir = process.cwd(), known = /* @__PURE__ */ new Map(), ui = {}, copy = true } = {}) {
|
|
11024
|
+
function renderCode({ lang, args, text: text2, linked = false }, { baseDir = process.cwd(), known = /* @__PURE__ */ new Map(), ui = {}, copy = true } = {}) {
|
|
10740
11025
|
const isDiff = lang === "diff";
|
|
10741
11026
|
const opts = parseCodeArgs(args, isDiff);
|
|
10742
11027
|
if (isDiff && opts.src) throw new CodeError("a diff block takes the diff you paste; src= is not supported for it yet, so paste the diff into the block", 0, DIFF_EXAMPLE);
|
|
@@ -10759,7 +11044,7 @@ function renderCode({ lang, args, text: text2 }, { baseDir = process.cwd(), know
|
|
|
10759
11044
|
if (body.length > MAX_CODE_LINES) throw new CodeError(`the block has ${body.length} lines; quote ${MAX_CODE_LINES} lines at most, and pick the lines that make the point`);
|
|
10760
11045
|
const slice = body.join("\n");
|
|
10761
11046
|
if (SECRET_TEXT.test(slice)) throw new CodeError(`${opts.src ? `"${opts.src}"` : "the block"} looks like it holds a key or a token; it is not embedded. Quote other lines or write a sketch`);
|
|
10762
|
-
const copyButton = copy ? `<button class="am-code-copy" type="button" data-am="copy-code" data-done="${esc(ui.done ?? "Copied \u2713")}">${esc(ui.copyCode ?? "Copy")}</button>` : "";
|
|
11047
|
+
const copyButton = copy ? `<button class="am-code-copy" type="button" data-am="copy-code" data-done="${esc(ui.done ?? "Copied \u2713")}" data-failed="${esc(ui.failed ?? "Copy failed")}">${esc(ui.copyCode ?? "Copy")}</button>` : "";
|
|
10763
11048
|
const long = body.length > LONG_CODE_LINES ? [{ rule: "code-length", message: `the block has ${body.length} lines; readers skim past long code. Pick the 10 to ${LONG_CODE_LINES} lines that make the point` }] : [];
|
|
10764
11049
|
if (isDiff) return renderDiff(text2, opts, { copyButton, long });
|
|
10765
11050
|
const last = first + body.length - 1;
|
|
@@ -10767,7 +11052,7 @@ function renderCode({ lang, args, text: text2 }, { baseDir = process.cwd(), know
|
|
|
10767
11052
|
const outside = [...hl].find((n) => n < first || n > last);
|
|
10768
11053
|
if (outside !== void 0) throw new CodeError(`hl=${opts.hl}: line ${outside} is not in the block (lines ${first}-${last})`);
|
|
10769
11054
|
const shownLang = lang || (opts.src ? extname(opts.src).slice(1).toLowerCase() : "");
|
|
10770
|
-
const numbered = Boolean(opts.src || opts.start);
|
|
11055
|
+
const numbered = Boolean(opts.src || opts.start || linked);
|
|
10771
11056
|
const where = opts.src ? `${opts.src}${range ? `:${range.from === range.to ? range.from : `${range.from}-${range.to}`}` : ""}` : "";
|
|
10772
11057
|
const title = opts.title ?? where;
|
|
10773
11058
|
const lines = body.map((l3, i) => {
|
|
@@ -11063,6 +11348,121 @@ function cspMeta(scripts, { live = false } = {}) {
|
|
|
11063
11348
|
return `<meta http-equiv="Content-Security-Policy" content="${policy}">`;
|
|
11064
11349
|
}
|
|
11065
11350
|
|
|
11351
|
+
// src/steps-panel.js
|
|
11352
|
+
var isFence = (b, lang) => b.type === "fence" && b.lang === lang;
|
|
11353
|
+
var isCode = (b) => b.type === "fence" && !COMPONENTS.has(b.lang) && !RAW_LANGS.has(b.lang);
|
|
11354
|
+
var DIAGRAMS = /* @__PURE__ */ new Set(["flow", "state", "tree", "er", "class", "sequence", "timeline", "chart"]);
|
|
11355
|
+
var LINKED = ["flow", "state", "tree"];
|
|
11356
|
+
var article = (word) => /^[aeiou]/.test(word) ? "an" : "a";
|
|
11357
|
+
var quote = (labels2) => [...new Set(labels2.map((l3) => String(l3).replace(/`/g, "")).filter((l3) => !l3.includes(":")))].slice(0, 8).join(", ");
|
|
11358
|
+
function pickBlocks(rest, first, problem) {
|
|
11359
|
+
const codes = rest.filter(isCode);
|
|
11360
|
+
const diagrams = rest.filter((b) => b.type === "fence" && DIAGRAMS.has(b.lang));
|
|
11361
|
+
if (codes.length === 0 && diagrams.length === 0) return problem("steps: needs a code block or a diagram in the same panel; add the code the steps walk through, or the diagram they explain", first.line);
|
|
11362
|
+
if (codes.length > 1) return problem(`steps: link one code block, not ${codes.length}; give each code block its own panel and steps block`, first.line);
|
|
11363
|
+
if (diagrams.length > 1) return problem(`steps: link one diagram, not ${diagrams.length}; give each diagram its own panel and steps block`, first.line);
|
|
11364
|
+
const [code] = codes;
|
|
11365
|
+
const [diagram] = diagrams;
|
|
11366
|
+
if (code?.lang === "diff") return problem("steps: a diff block is not linked; link a code block, which shows its own line numbers", first.line);
|
|
11367
|
+
if (diagram && !LINKED.includes(diagram.lang)) {
|
|
11368
|
+
return problem(`steps: ${article(diagram.lang)} ${diagram.lang} diagram is not linked yet; steps links flow, state and tree diagrams`, first.line);
|
|
11369
|
+
}
|
|
11370
|
+
return { code, diagram };
|
|
11371
|
+
}
|
|
11372
|
+
var EXPLAIN_EXAMPLE = "```flow\nCart -> Pay -> Ship\n```\n\n```steps\nCart: The customer fills the cart.\nPay: The payment goes through.\nShip: The warehouse sends the parcel.\n```";
|
|
11373
|
+
function renderPanel(blocks, ctx, host) {
|
|
11374
|
+
const { renderBlocks: renderBlocks2, RenderError: RenderError2 } = host;
|
|
11375
|
+
const [first, ...extra] = blocks.filter((b) => isFence(b, "steps"));
|
|
11376
|
+
if (!first || ctx.video) return renderBlocks2(blocks, ctx);
|
|
11377
|
+
const rest = blocks.filter((b) => !isFence(b, "steps"));
|
|
11378
|
+
const explain = !rest.some(isCode) && rest.some((b) => b.type === "fence" && DIAGRAMS.has(b.lang));
|
|
11379
|
+
const example = explain ? EXPLAIN_EXAMPLE : COMPONENTS.get("steps").example;
|
|
11380
|
+
const problem = (message, line) => {
|
|
11381
|
+
const err = new RenderError2(message, { line, component: "steps", example });
|
|
11382
|
+
if (!ctx.errors) throw err;
|
|
11383
|
+
ctx.errors.push(err);
|
|
11384
|
+
return null;
|
|
11385
|
+
};
|
|
11386
|
+
ctx.stats.components.steps = (ctx.stats.components.steps ?? 0) + 1;
|
|
11387
|
+
for (const b of extra) problem("steps: one steps block per panel; put the second one under its own ## heading, with its own code block", b.line);
|
|
11388
|
+
const picked = pickBlocks(rest, first, problem);
|
|
11389
|
+
if (!picked) return renderBlocks2(rest, ctx);
|
|
11390
|
+
let steps2;
|
|
11391
|
+
try {
|
|
11392
|
+
steps2 = parseSteps(first.text, picked.code ? "code" : "explain");
|
|
11393
|
+
} catch (err) {
|
|
11394
|
+
if (!(err instanceof ComponentError)) throw err;
|
|
11395
|
+
problem(err.message, first.line + (err.line || 0));
|
|
11396
|
+
return renderBlocks2(rest, ctx);
|
|
11397
|
+
}
|
|
11398
|
+
return assemble({ blocks, rest, ...picked, steps: steps2, first }, ctx, host, problem);
|
|
11399
|
+
}
|
|
11400
|
+
function assemble({ blocks, rest, code, diagram, steps: steps2, first }, ctx, host, problem) {
|
|
11401
|
+
const { renderBlocks: renderBlocks2, renderBlock: renderBlock2, RenderError: RenderError2 } = host;
|
|
11402
|
+
const attempt = (draw2) => {
|
|
11403
|
+
try {
|
|
11404
|
+
return draw2();
|
|
11405
|
+
} catch (err) {
|
|
11406
|
+
if (!(err instanceof RenderError2) || !ctx.errors) throw err;
|
|
11407
|
+
ctx.errors.push(err);
|
|
11408
|
+
return null;
|
|
11409
|
+
}
|
|
11410
|
+
};
|
|
11411
|
+
const codeHtml = code ? attempt(() => renderBlock2({ ...code, linked: true }, ctx)) : null;
|
|
11412
|
+
if (code && codeHtml === null) return renderBlocks2(rest.filter((b) => b !== code), ctx);
|
|
11413
|
+
const link = makeLink(steps2, ctx.ui);
|
|
11414
|
+
const diagramHtml = diagram ? attempt(() => renderBlock2({ ...diagram, link }, ctx)) : "";
|
|
11415
|
+
if (diagramHtml === null) return renderBlocks2(rest.filter((b) => b !== diagram), ctx);
|
|
11416
|
+
checkSteps(steps2, { link, hasDiagram: Boolean(diagram), codeHtml }, (message, step) => problem(message, first.line + step.line));
|
|
11417
|
+
const diagramPart = diagram ? `<div class="am-steps-diagram">${groupSvg(diagramHtml)}</div>` : "";
|
|
11418
|
+
const second = code ? markCodeLines(codeHtml, steps2) : explainList(steps2, ctx.ui);
|
|
11419
|
+
const secondFirst = blocks.indexOf(code ?? first) < blocks.indexOf(diagram);
|
|
11420
|
+
const pair = diagram && secondFirst ? `${second}${diagramPart}` : `${diagramPart}${second}`;
|
|
11421
|
+
const block2 = stepsBlock(pair, steps2, ctx.ui, code ? "code" : "explain");
|
|
11422
|
+
const members = new Set([diagram, code ?? first].filter(Boolean));
|
|
11423
|
+
const at3 = blocks.map((b, i) => members.has(b) ? i : -1).filter((i) => i >= 0);
|
|
11424
|
+
const [head, tail] = [Math.min(...at3), Math.max(...at3)];
|
|
11425
|
+
const part = (list2) => list2.length ? renderBlocks2(list2, ctx) : "";
|
|
11426
|
+
const others = (from, to) => blocks.slice(from, to).filter((b) => !members.has(b) && !isFence(b, "steps"));
|
|
11427
|
+
return [part(others(0, head)), block2, part(others(head, tail)), part(others(tail))].filter(Boolean).join("\n");
|
|
11428
|
+
}
|
|
11429
|
+
function shownLines(codeHtml) {
|
|
11430
|
+
const numbers = [...codeHtml.matchAll(/ data-n="(\d+)"/g)].map((m) => Number(m[1]));
|
|
11431
|
+
return { from: Math.min(...numbers), to: Math.max(...numbers) };
|
|
11432
|
+
}
|
|
11433
|
+
function colonLabel(step, labels2) {
|
|
11434
|
+
const starts = [step.item, step.head].map((t) => `${normalize(t)}:`);
|
|
11435
|
+
return labels2.map(normalize).find((l3) => starts.some((prefix) => l3.startsWith(prefix)));
|
|
11436
|
+
}
|
|
11437
|
+
var LINES_HINT = "; with no code block, a step has no line numbers";
|
|
11438
|
+
var endsInNumber = (text2) => /\s\d+(?:\s*-\s*\d+)?$/.test(text2);
|
|
11439
|
+
function checkSteps(steps2, { link, hasDiagram, codeHtml }, report) {
|
|
11440
|
+
const shown2 = codeHtml === null ? null : shownLines(codeHtml);
|
|
11441
|
+
const taken = /* @__PURE__ */ new Map();
|
|
11442
|
+
steps2.forEach((step, i) => {
|
|
11443
|
+
if (hasDiagram) {
|
|
11444
|
+
const same = steps2.findIndex((s) => normalize(s.item) === normalize(step.item));
|
|
11445
|
+
if (same < i) return report(`steps: "${step.item}" is already step ${same + 1}; give each item one step`, step);
|
|
11446
|
+
const count2 = link.matches[i];
|
|
11447
|
+
if (count2 === 0) {
|
|
11448
|
+
const withColon = colonLabel(step, link.seen);
|
|
11449
|
+
if (withColon) return report(`steps: a linked item cannot contain a colon, because the first colon ends the item; rename the diagram entry "${withColon}" so it has no colon`, step);
|
|
11450
|
+
const hint = !shown2 && endsInNumber(step.item) ? LINES_HINT : "";
|
|
11451
|
+
return report(`steps: "${step.item}" is not an item of the diagram; write the text of an item exactly as the diagram does${quote(link.seen) ? ` (${quote(link.seen)})` : ""}${hint}`, step);
|
|
11452
|
+
}
|
|
11453
|
+
if (count2 > 1) return report(`steps: "${step.item}" matches ${count2} items of the diagram; give those items different text`, step);
|
|
11454
|
+
}
|
|
11455
|
+
if (!shown2) return;
|
|
11456
|
+
if (step.from < shown2.from || step.to > shown2.to) {
|
|
11457
|
+
const where = step.from === step.to ? `${linesName(step)} is not in` : `${linesName(step)} are not all in`;
|
|
11458
|
+
return report(`steps: ${where} the code block (lines ${shown2.from}-${shown2.to})`, step);
|
|
11459
|
+
}
|
|
11460
|
+
const clash = [...taken].find(([, other]) => step.from <= other.to && other.from <= step.to);
|
|
11461
|
+
if (clash) return report(`steps: step ${i + 1} overlaps step ${clash[0] + 1} (${linesName(clash[1])}); give each step its own lines`, step);
|
|
11462
|
+
taken.set(i, step);
|
|
11463
|
+
});
|
|
11464
|
+
}
|
|
11465
|
+
|
|
11066
11466
|
// src/render.js
|
|
11067
11467
|
var RenderError = class extends Error {
|
|
11068
11468
|
constructor(message, { line, component, example } = {}) {
|
|
@@ -11103,7 +11503,8 @@ function renderDoc(source, overrides = {}, defaults2 = {}, { themes: themes2 = B
|
|
|
11103
11503
|
errors.push(new RenderError(`${b.lang} belongs in a panel: put it under the ## heading of the panel the answer changes`, { line: b.line, component: b.lang, example: COMPONENTS.get(b.lang).example }));
|
|
11104
11504
|
}
|
|
11105
11505
|
const introHtml = renderBlocks(doc2.intro.filter((b) => !loose.includes(b)), ctx);
|
|
11106
|
-
const
|
|
11506
|
+
const host = { renderBlocks, renderBlock, RenderError };
|
|
11507
|
+
const panels = doc2.panels.map((p) => ({ ...p, html: renderPanel(p.blocks, ctx, host) }));
|
|
11107
11508
|
raiseAll(errors);
|
|
11108
11509
|
const page = TEMPLATES[doc2.meta.template]({ meta: doc2.meta, introHtml, panels, ui, language });
|
|
11109
11510
|
const body = language.dir === "rtl" ? isolateLtrRuns(page) : page;
|
|
@@ -11194,7 +11595,7 @@ function renderFence(block2, ctx) {
|
|
|
11194
11595
|
}
|
|
11195
11596
|
const comp = COMPONENTS.get(lang);
|
|
11196
11597
|
if (!comp) return codeBlock(block2, ctx);
|
|
11197
|
-
if (comp.pageOnly && ctx.video) throw new RenderError(`${lang} works on a page only; a video cannot
|
|
11598
|
+
if (comp.pageOnly && ctx.video) throw new RenderError(`${lang} works on a page only; ${comp.pageOnlyReason ?? "a video cannot show it"}`, { line, component: lang, example: comp.example });
|
|
11198
11599
|
ctx.stats.components[lang] = (ctx.stats.components[lang] ?? 0) + 1;
|
|
11199
11600
|
try {
|
|
11200
11601
|
const warn = ({ line: at3 = 0, message }) => ctx.stats.componentWarnings?.push({ line: line + at3, component: lang, message });
|
|
@@ -11206,7 +11607,8 @@ function renderFence(block2, ctx) {
|
|
|
11206
11607
|
video: ctx.video,
|
|
11207
11608
|
warn,
|
|
11208
11609
|
line,
|
|
11209
|
-
render: (blocks) => renderBlocks(blocks, ctx)
|
|
11610
|
+
render: (blocks) => renderBlocks(blocks, ctx),
|
|
11611
|
+
link: block2.link
|
|
11210
11612
|
});
|
|
11211
11613
|
return ctx.video || comp.scalesOwnSvg ? html : scaleSvgBoxes(html, ctx.scale ?? 1);
|
|
11212
11614
|
} catch (err) {
|
|
@@ -11253,14 +11655,14 @@ function updateNotice(ui, update2, labelKey) {
|
|
|
11253
11655
|
<ul class="am-update-notes">${lines.map((l3) => `<li>${esc(l3).replace(/`([^`]+)`/g, "<code>$1</code>")}</li>`).join("")}</ul>
|
|
11254
11656
|
` : "";
|
|
11255
11657
|
const plain = t.button.replace("{version}", update2.latest);
|
|
11256
|
-
const
|
|
11658
|
+
const fill3 = (s) => esc(s).replace("{version}", `<bdi>${esc(update2.latest)}</bdi>`).replace("{current}", `<bdi>${esc(update2.current)}</bdi>`);
|
|
11257
11659
|
const row = (text2, code) => `<div class="am-update-row">${code ? `<code dir="ltr">${esc(text2)}</code>` : `<span>${esc(text2)}</span>`}<button class="am-btn" type="button" data-am="copy-text" data-text="${esc(text2)}" data-done="${esc(ui.done)}">${esc(ui.copyCode)}</button></div>`;
|
|
11258
11660
|
return {
|
|
11259
|
-
button: `<button class="am-btn am-btn--update" type="button" data-am="update" popovertarget="am-update" aria-label="${esc(plain)}" hidden>\u25CF <span class="am-update-text">${
|
|
11661
|
+
button: `<button class="am-btn am-btn--update" type="button" data-am="update" popovertarget="am-update" aria-label="${esc(plain)}" hidden>\u25CF <span class="am-update-text">${fill3(t.button)}</span></button>
|
|
11260
11662
|
`,
|
|
11261
11663
|
popover: `<div class="am-update" id="am-update" popover>
|
|
11262
|
-
<p class="am-update-title">${
|
|
11263
|
-
<p>${
|
|
11664
|
+
<p class="am-update-title">${fill3(t.button)}</p>
|
|
11665
|
+
<p>${fill3(t.current)}</p>
|
|
11264
11666
|
${notes}<p class="am-update-label">${esc(t.run)}</p>
|
|
11265
11667
|
${row(update2.command, true)}
|
|
11266
11668
|
<p class="am-update-label">${esc(t.agent)}</p>
|
|
@@ -11273,10 +11675,10 @@ ${row(t.agentText, false)}
|
|
|
11273
11675
|
function exportMenu(ui) {
|
|
11274
11676
|
const t = ui.export;
|
|
11275
11677
|
const item = (kind2, label) => `<button class="am-export-item" type="button" role="menuitem" data-export="${kind2}" aria-describedby="am-export-${kind2}-note"><span>${esc(label)}</span><small class="am-export-note" id="am-export-${kind2}-note" aria-hidden="true"></small></button>`;
|
|
11276
|
-
const
|
|
11678
|
+
const labels2 = [["working", t.working], ["copied", t.copied], ["saved", t.saved], ["failed", t.failed], ["unavailable-browser", t.unavailableBrowser], ["unavailable-clipboard", t.unavailableClipboard], ["unavailable-policy", t.unavailablePolicy], ["unverified-effect", t.unverifiedEffect]].map(([key, text2]) => `data-${key}="${esc(text2)}"`).join(" ");
|
|
11277
11679
|
return {
|
|
11278
11680
|
button: `<button class="am-btn am-btn--export" type="button" data-am="export" popovertarget="am-export" aria-haspopup="menu" aria-expanded="false" aria-controls="am-export" hidden>${esc(t.button)}</button>`,
|
|
11279
|
-
menu: `<div class="am-export" id="am-export" popover role="menu" aria-label="${esc(t.button)}" ${
|
|
11681
|
+
menu: `<div class="am-export" id="am-export" popover role="menu" aria-label="${esc(t.button)}" ${labels2}>
|
|
11280
11682
|
${item("copy", t.copy)}
|
|
11281
11683
|
${item("download", t.download)}
|
|
11282
11684
|
${item("pdf", t.pdf)}
|
|
@@ -11288,6 +11690,7 @@ function withoutUpdateNotice(html) {
|
|
|
11288
11690
|
return html.replace(/<button class="am-btn am-btn--update"[^]*?<\/button>\n/, "").replace(/<div class="am-update" id="am-update" popover>[^]*?\n<\/div>\n/, "");
|
|
11289
11691
|
}
|
|
11290
11692
|
var hasDelta = (html) => html.includes('class="am-delta-bar"');
|
|
11693
|
+
var hasSteps = (html) => html.includes('class="am-steps"');
|
|
11291
11694
|
var hasChart = (html) => html.includes('class="am-diagram am-chart"');
|
|
11292
11695
|
function lightboxShell(ui, hasDiagrams) {
|
|
11293
11696
|
if (!hasDiagrams) return "";
|
|
@@ -11322,7 +11725,7 @@ function shell({ meta, language, body, source, embedded, update: update2, closeA
|
|
|
11322
11725
|
const root = { lang: language.htmlLang, dir: language.dir, theme: meta.theme, mode: meta.mode, style: meta.style, scale };
|
|
11323
11726
|
const interactiveTable = body.includes("<table data-am-table=");
|
|
11324
11727
|
const script = `
|
|
11325
|
-
${RUNTIME_JS}${interactiveTable ? TABLE_JS : ""}${hasDelta(body) ? DELTA_JS : ""}${update2 ? UPDATE_JS : ""}${closeAfter ? CLOSE_AFTER_JS : ""}`;
|
|
11728
|
+
${RUNTIME_JS}${interactiveTable ? TABLE_JS : ""}${hasDelta(body) ? DELTA_JS : ""}${hasSteps(body) ? STEPS_JS : ""}${update2 ? UPDATE_JS : ""}${closeAfter ? CLOSE_AFTER_JS : ""}`;
|
|
11326
11729
|
return `<!doctype html>
|
|
11327
11730
|
${rootTag(root)}
|
|
11328
11731
|
<head>
|
|
@@ -11332,7 +11735,7 @@ ${cspMeta([script], { live: true })}
|
|
|
11332
11735
|
<meta name="generator" content="Answer me with HTML ${VERSION}">
|
|
11333
11736
|
<title>${esc(meta.title || "Answer me with HTML")}</title>
|
|
11334
11737
|
<style>
|
|
11335
|
-
${pageCss(embedded, { diff: body.includes('class="am-codeblock am-codeblock--diff"'), delta: hasDelta(body), rtl: language.dir === "rtl", math: hasMath(body), chart: hasChart(body), table: interactiveTable, update: Boolean(update2), closeAfter, scale })}
|
|
11738
|
+
${pageCss(embedded, { diff: body.includes('class="am-codeblock am-codeblock--diff"'), delta: hasDelta(body), rtl: language.dir === "rtl", math: hasMath(body), chart: hasChart(body), steps: hasSteps(body), table: interactiveTable, update: Boolean(update2), closeAfter, scale })}
|
|
11336
11739
|
</style>
|
|
11337
11740
|
</head>
|
|
11338
11741
|
<body>
|
|
@@ -11342,7 +11745,7 @@ ${pick("mode", ui.modeLabel, Object.entries(ui.mode), meta.mode)}
|
|
|
11342
11745
|
${scaleButtons(ui)}
|
|
11343
11746
|
<button class="am-btn am-btn--reply" type="button" data-am="reply" data-ui="${esc(JSON.stringify({ ...ui.reply, done: ui.done, remarks: ui.remark.section, kinds: ui.remark.kinds, ...closeAfter ? { closeAfter: { seconds: CLOSE_AFTER_SECONDS, ...ui.closeAfter } } : {} }))}">${esc(ui.reply.button)}</button>
|
|
11344
11747
|
<button class="am-btn am-btn--remark" type="button" data-am="remark" data-ui="${esc(JSON.stringify(ui.remark))}">${esc(ui.remark.button)}</button>
|
|
11345
|
-
<button class="am-btn" type="button" data-am="copy" data-done="${esc(ui.done)}">${esc(ui.copy)}</button>
|
|
11748
|
+
<button class="am-btn" type="button" data-am="copy" data-done="${esc(ui.done)}" data-failed="${esc(ui.failed)}">${esc(ui.copy)}</button>
|
|
11346
11749
|
${exporter.button}
|
|
11347
11750
|
</div>
|
|
11348
11751
|
${notice.popover}${exporter.menu}${colophon2 ? withColophon(body, language) : body}
|
|
@@ -12735,7 +13138,7 @@ function scene(s, i, total, body, ui) {
|
|
|
12735
13138
|
</section>`;
|
|
12736
13139
|
}
|
|
12737
13140
|
function sheetFrame() {
|
|
12738
|
-
const ruler2 = (side,
|
|
13141
|
+
const ruler2 = (side, labels2) => `<div class="amv-ruler amv-ruler--${side}">${labels2.map((l3) => `<span>${l3}</span>`).join("")}</div>`;
|
|
12739
13142
|
const nums = [1, 2, 3, 4, 5, 6, 7, 8];
|
|
12740
13143
|
const letters = ["A", "B", "C", "D"];
|
|
12741
13144
|
return `<div class="amv-sheet" aria-hidden="true">${ruler2("top", nums)}${ruler2("bottom", nums)}${ruler2("left", letters)}${ruler2("right", letters)}</div>`;
|
|
@@ -13117,7 +13520,8 @@ var CHROME_CSS = `.am-toolbar, .am-reply, .am-reply-bar, .am-comment, .am-commen
|
|
|
13117
13520
|
.am-update, .am-btn--update, .am-btn--export, .am-export, .am-lightbox, .am-code-copy, .am-diagram-expand, .am-toc, .am-delta-switch, .am-table-controls {
|
|
13118
13521
|
display: none !important;
|
|
13119
13522
|
}
|
|
13120
|
-
.am-table-sort::after { content: none !important; }
|
|
13523
|
+
.am-table-sort::after { content: none !important; }
|
|
13524
|
+
.am-head::before { display: none !important; }`;
|
|
13121
13525
|
function slicePoints(pageHeight, boxes = [], maxHeight = MAX_SLICE) {
|
|
13122
13526
|
const limit = Math.floor(maxHeight);
|
|
13123
13527
|
if (!(limit > 0)) throw new RangeError("maxHeight must be greater than 0");
|
|
@@ -13240,6 +13644,8 @@ async function writePngSlices(page, htmlFile, folder, onWarn = () => {
|
|
|
13240
13644
|
await page.page("Emulation.setEmulatedMedia", { media: "screen" });
|
|
13241
13645
|
await settle2(page);
|
|
13242
13646
|
const layout5 = await page.evaluate(`(async () => {
|
|
13647
|
+
// A steps block in a picture shows its numbers and its list, not the bar and the boxes of a reader's selection.
|
|
13648
|
+
for (const el of document.querySelectorAll('.am-steps--live')) el.classList.remove('am-steps--live');
|
|
13243
13649
|
await document.fonts.ready;
|
|
13244
13650
|
await new Promise((r) => setTimeout(r, ${SETTLE_MS}));
|
|
13245
13651
|
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
|
|
@@ -15226,7 +15632,7 @@ function cmdList({ print, fail, themes: themes2 }) {
|
|
|
15226
15632
|
}
|
|
15227
15633
|
function specimenDraft(name2, mode) {
|
|
15228
15634
|
const sections = [...COMPONENTS.values()].map((c) => `## ${c.name}
|
|
15229
|
-
${c.example}`);
|
|
15635
|
+
${c.specimen ?? c.example}`);
|
|
15230
15636
|
const table = "## table\n| Check | Status |\n|---|---|\n| Approved | ok passes |\n| Rejected | no fails |\n| Pending | warn needs a look |";
|
|
15231
15637
|
return `---
|
|
15232
15638
|
title: Theme ${name2} (${mode})
|
|
@@ -15297,7 +15703,7 @@ function cmdHelp(name2, { print, fail }) {
|
|
|
15297
15703
|
${comp.syntax}
|
|
15298
15704
|
|
|
15299
15705
|
Example:
|
|
15300
|
-
${comp.example}`);
|
|
15706
|
+
${comp.specimen ?? comp.example}`);
|
|
15301
15707
|
return 0;
|
|
15302
15708
|
}
|
|
15303
15709
|
function slug(title) {
|