logic-atlas 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +2 -2
- package/README.md +8 -4
- package/dist/case.js +1 -1
- package/dist/chunks/{CasePage-R2k_0lls.js → CasePage-CbCDu1FO.js} +3 -3
- package/dist/chunks/{CasePage-R2k_0lls.js.map → CasePage-CbCDu1FO.js.map} +1 -1
- package/dist/chunks/{CausalPlayground-Cd7Sok3F.js → CausalPlayground-D93D0ceE.js} +5 -5
- package/dist/chunks/{CausalPlayground-Cd7Sok3F.js.map → CausalPlayground-D93D0ceE.js.map} +1 -1
- package/dist/chunks/{CiteBlock-irdT1sjg.js → CiteBlock-DMFqM7ZM.js} +2 -2
- package/dist/chunks/{CiteBlock-irdT1sjg.js.map → CiteBlock-DMFqM7ZM.js.map} +1 -1
- package/dist/chunks/{ConservativeExtension-BX4EtG16.js → ConservativeExtension-Cofe92ak.js} +2 -2
- package/dist/chunks/{ConservativeExtension-BX4EtG16.js.map → ConservativeExtension-Cofe92ak.js.map} +1 -1
- package/dist/chunks/{ExportMenu-B5HoqaQl.js → ExportMenu-DaLZ5rBJ.js} +3 -3
- package/dist/chunks/{ExportMenu-B5HoqaQl.js.map → ExportMenu-DaLZ5rBJ.js.map} +1 -1
- package/dist/chunks/{GraphBox-Tg3kDWNT.js → GraphBox-DjjoWUU0.js} +3 -3
- package/dist/chunks/{GraphBox-Tg3kDWNT.js.map → GraphBox-DjjoWUU0.js.map} +1 -1
- package/dist/chunks/{IdentifyPanel-BVmZsWGN.js → IdentifyPanel-CoPC-Okk.js} +3 -3
- package/dist/chunks/{IdentifyPanel-BVmZsWGN.js.map → IdentifyPanel-CoPC-Okk.js.map} +1 -1
- package/dist/chunks/{ModelEditor-oAvvVqX5.js → ModelEditor-A6kk6Si5.js} +2 -2
- package/dist/chunks/{ModelEditor-oAvvVqX5.js.map → ModelEditor-A6kk6Si5.js.map} +1 -1
- package/dist/chunks/{ProbabilityPanel-8-cC68rq.js → ProbabilityPanel-DKTFYU-j.js} +5 -5
- package/dist/chunks/{ProbabilityPanel-8-cC68rq.js.map → ProbabilityPanel-DKTFYU-j.js.map} +1 -1
- package/dist/chunks/{RulesPanel-Cr6R9xCK.js → RulesPanel-B6X9O0he.js} +3 -3
- package/dist/chunks/{RulesPanel-Cr6R9xCK.js.map → RulesPanel-B6X9O0he.js.map} +1 -1
- package/dist/chunks/SignalGraph-CWPf_sG8.js +1412 -0
- package/dist/chunks/SignalGraph-CWPf_sG8.js.map +1 -0
- package/dist/chunks/{SliderList-BrILQCA4.js → SliderList-DmDURTeF.js} +2 -2
- package/dist/chunks/{SliderList-BrILQCA4.js.map → SliderList-DmDURTeF.js.map} +1 -1
- package/dist/chunks/{WorldLanes-kxYTRnB5.js → WorldLanes-DDtJZqcA.js} +2 -2
- package/dist/chunks/{WorldLanes-kxYTRnB5.js.map → WorldLanes-DDtJZqcA.js.map} +1 -1
- package/dist/chunks/{cite-B6emUIEW.js → cite-QzNc24r2.js} +2 -2
- package/dist/chunks/{cite-B6emUIEW.js.map → cite-QzNc24r2.js.map} +1 -1
- package/dist/chunks/{export-image-IsI6PVd9.js → export-image-BBHOXOis.js} +3 -3
- package/dist/chunks/{export-image-IsI6PVd9.js.map → export-image-BBHOXOis.js.map} +1 -1
- package/dist/cite.js +1 -1
- package/dist/editor.js +1 -1
- package/dist/extension.js +1 -1
- package/dist/ground-cases.js +767 -0
- package/dist/ground-cases.js.map +1 -0
- package/dist/ground.css +2 -0
- package/dist/ground.js +3829 -0
- package/dist/ground.js.map +1 -0
- package/dist/identify.js +1 -1
- package/dist/index.js +8 -8
- package/dist/lanes.js +1 -1
- package/dist/playground.js +1 -1
- package/dist/probability.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/ground/cases/index.d.ts +7 -0
- package/dist/types/ground/components/DiscernibilityPanel.d.ts +35 -0
- package/dist/types/ground/components/GroundChecker.d.ts +16 -0
- package/dist/types/ground/components/ProposalTable.d.ts +20 -0
- package/dist/types/ground/components/StructureView.d.ts +21 -0
- package/dist/types/ground/components/case-text.d.ts +32 -0
- package/dist/types/ground/components/parts.d.ts +59 -0
- package/dist/types/ground/components/structure-layout.d.ts +59 -0
- package/dist/types/ground/components/use-premises.d.ts +21 -0
- package/dist/types/ground/data/analyze.d.ts +41 -0
- package/dist/types/ground/data/case.d.ts +52 -0
- package/dist/types/ground/data/load.d.ts +30 -0
- package/dist/types/ground/data/presets.d.ts +32 -0
- package/dist/types/ground/data/schema.d.ts +303 -0
- package/dist/types/ground/engine/closure.d.ts +34 -0
- package/dist/types/ground/engine/discern.d.ts +84 -0
- package/dist/types/ground/engine/errors.d.ts +142 -0
- package/dist/types/ground/engine/evaluate.d.ts +25 -0
- package/dist/types/ground/engine/facts.d.ts +61 -0
- package/dist/types/ground/engine/formula.d.ts +100 -0
- package/dist/types/ground/engine/index.d.ts +26 -0
- package/dist/types/ground/engine/premises.d.ts +58 -0
- package/dist/types/ground/engine/print.d.ts +29 -0
- package/dist/types/ground/engine/proposals.d.ts +56 -0
- package/dist/types/ground/engine/resolve.d.ts +46 -0
- package/dist/types/ground/engine/syntax.d.ts +55 -0
- package/dist/types/ground/i18n/en.d.ts +2 -0
- package/dist/types/ground/i18n/messages.d.ts +14 -0
- package/dist/types/ground/i18n/zh.d.ts +95 -0
- package/dist/types/ground/index.d.ts +22 -0
- package/dist/types/logic/structure.d.ts +72 -0
- package/package.json +12 -3
- package/dist/chunks/SignalGraph-yoGcj7jf.js +0 -1405
- package/dist/chunks/SignalGraph-yoGcj7jf.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SignalGraph-yoGcj7jf.js","names":["_Fragment","getVariable","dependence","formatValue","valuesEqual","dSeparation","useMessages","fixed","sub","Rich","assignmentText","segmentHitsBox","barLayout","graphSpacing","planArcs","idWithName","shownEdges","useDigits","rectBox","intersects","arcCurve","probText","gridLayout","firstClear","edgeLive","shortLabel","around","edgePolarity","latentArcs","shifted","textWidth","textBox","Tip","Fragment$1","dsepView","c","x","y","pair","cut","interventions","stochastic","result","observed","delta","key","open","p","k","deltaText","pathText","i","id","acc","pathReason","d","t","opened","o","pathSentence","pathTipSentence","e","path","at","fork","colliders","middles","why","edgeTipText","through","marks","onPath","named","parts","focusVisible","el","SNAP","numberWidth","digits","nodeReadout","forced","seen","readoutWidth","r","blockAt","labelY","top","lines","wrapped","label","label2Y","labelBox","cx","boxes","numberY","noteY","x0","baseline","note2Y","last","readout","chartTop","blockOptions","size","probe","height","b","minX","maxX","below","above","beside","right","left","one","spots","two","noteSpots","block","bottom","spot","anchor","w","under","outer","across","snap","v","unit","dx","a","dy","exoDash","unitLength","EXO_INSET","arrowHead","len","ux","uy","bx","tip","by","clampPath","BarChart","layout","labels","known","dist","max","ok","h","edge","text","barText","wrapName","name","ch","words","best","bestW","first","second","SWITCH_SPOTS","placeSwitches","drawn","switches","shown","grid","px","g","col","row","edges","near","q","box","target","tp","clear","other","dc","dr","layoutSignalGraph","input","prob","probs","COL","ROW","compact","PAD_X","cells","minCol","maxCol","minRow","maxRow","width","hasWitness","witness","barred","layoutHeight","pos","off","drag","removedEdges","nameOf","edgeLine","from","kind","end","doTag","soft","observedValues","evidence","before","original","reset","holdNotes","tagText","holdNote","now","values","deviantNote","normal","defaults","placedBoxes","blocks","labelOptions","labelLines","wasNotes","tagBoxes","tag","endCut","via","clamped","arcPlans","arcSegments","strokes","heads","head","past","base","line","mx","x1","x2","my","y1","y2","plan","curve","crossings","padded","radius","ambiguous","hull","away","own","cost","hard","rest","local","crossed","placed","all","splits","heldWas","variable","settledRead","was","note","probNotes","noteW","deviant","dists","maxW","isSwitch","labelW","split","options","costs","j","columns","group","others","side","wrap","taken","chosen","fit","tagged","discs","onLine","pt","abs","hitsNode","obstacles","arcLabelW","arcs","candidates","nx","ny","offEdges","cand","claim","edgeMarks","slash","cy","cutCandidates","cutLabel","live","paths","cls","inhibitCandidates","admissible","previous","bestScore","band","score","inhibitLabel","pts","pad","tags","held","hold","ARROWS","useNodeGestures","setDrag","useState","suppressUntil","useRef","toSvg","ctm","svgRef","inv","startDrag","onMove","moved","dCol","dRow","activate","event","step","SignalGraph","props","uid","useId","hoverHandlers","onHover","testClamped","R","viewW","edgePointer","tipProps","onEdgeTip","edgeTip","pathTip","hit","inF","hedge","blockX","edgeEls","cutFrom","cutTo","marked","arcEls","edgeKeys","structural","nodeEls","aria","nodeNotes","onOpen","nodeHandlers","intervened","boolean","filled","changed","who","pv","bars","state","forcedText","opens","onPick","observable","picks","pickable","interactive","toggle","hint","pickHint","exo","inner","level","lit","fresh","moveDrag","endDrag","cancelDrag"],"sources":["../../src/components/model/dsep-view.ts","../../src/components/shared/focus-visible.ts","../../src/components/graph/signal-shapes.ts","../../src/components/graph/BarChart.tsx","../../src/components/graph/signal-geometry.ts","../../src/components/graph/use-node-gestures.ts","../../src/components/graph/SignalGraph.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, DPath, DSeparationResult } from '../../engine/index.ts'\nimport { dSeparation, dependence } from '../../engine/index.ts'\nimport type { Messages } from '../i18n/messages.ts'\nimport type { Stochastic } from './assignments.ts'\nimport { fixed } from './wording.ts'\n\n/** Pure helpers for the playground's d-separation line. */\n\n/** A pair of variables whose paths the playground lights. */\nexport type DsepPair = readonly [string, string]\n\n/** At most this many paths are listed under the graph; the rest are counted. */\nexport const MAX_PATHS = 3\n\n/** What the graph draws for a pair: each edge on an open path, each on a blocked one, the two ends, and the marked paths. */\nexport interface PathMarks {\n readonly open: ReadonlySet<string>\n readonly blocked: ReadonlySet<string>\n readonly ends: readonly string[]\n /** The paths whose edges are marked, so an edge's tip can name them. */\n readonly paths: readonly DPath[]\n}\n\n/** At most this many paths are named in an edge's tip; the rest are counted. */\nexport const TIP_PATHS = 2\n\nexport interface DsepView {\n readonly result: DSeparationResult\n /** δ given the observed values, after do(). */\n readonly delta: number\n readonly marks: PathMarks\n}\n\n/** The pair's paths in the graph after do(), with the observations as the known set, and δ. */\nexport function dsepView(c: LoadedCase, pair: DsepPair, observed: Assignment, interventions: Assignment, stochastic: Stochastic): DsepView {\n if (c.prior === undefined) throw new Error(`${c.data.id}: dsep needs probabilities`)\n const [x, y] = pair\n const cut = [...Object.keys(interventions), ...Object.keys(stochastic)]\n const result = dSeparation(c.model, x, y, Object.keys(observed), cut)\n const delta = dependence(c.model, c.prior, x, y, observed, interventions, stochastic)\n const key = (e: { from: string; to: string }): string => `${e.from}>${e.to}`\n const open = new Set(result.paths.filter((p) => p.open).flatMap((p) => p.edges.map(key)))\n const blocked = new Set(result.paths.filter((p) => !p.open).flatMap((p) => p.edges.map(key)).filter((k) => !open.has(k)))\n return { result, delta, marks: { open, blocked, ends: [x, y], paths: result.paths } }\n}\n\n/** δ as the lesson writes it: 0.000 for none, else up to four decimals (0.12, 0.1225). */\nexport function deltaText(delta: number): string {\n if (Number.isNaN(delta)) return '—'\n if (delta < 1e-12) return '0.000'\n return fixed(delta, 4).replace(/(\\.\\d\\d\\d*?)0+$/, '$1')\n}\n\n/** `G→A←M`: the path with each edge's own direction. */\nexport function pathText(p: DPath): string {\n return p.nodes.reduce((acc, id, i) => (i === 0 ? id : `${acc}${p.edges[i - 1].from === p.nodes[i - 1] ? '→' : '←'}${id}`), '')\n}\n\n\n/** Why a path is open or blocked, in the dsep line's words. */\nexport function pathReason(t: Messages, p: DPath): string {\n const d = t.dsep\n if (!p.open) return p.kind === 'collider' ? d.colliderUnknown(p.blockedBy ?? '') : d.middleKnown(p.blockedBy ?? '')\n const opened = p.opened ?? []\n if (opened.length === 0) return p.nodes.length === 2 ? d.adjacent : d.middlesUnknown\n return t.list(opened.map((o) => (o.by === o.collider ? d.colliderKnown(o.collider) : d.descendantKnown(o.collider, o.by))))\n}\n\n/** `S → W ← R`: the path with each edge's own direction, spaced for a sentence. */\nexport function pathSentence(p: DPath): string {\n return p.nodes.reduce((acc, id, i) => (i === 0 ? id : `${acc} ${p.edges[i - 1].from === p.nodes[i - 1] ? '→' : '←'} ${id}`), '')\n}\n\n/** One path in an edge's tip: where and why it is blocked, or why it is open, in the lesson's words (chain, fork, collider). */\nexport function pathTipSentence(t: Messages, p: DPath): string {\n const e = t.edgeTip\n const path = pathSentence(p)\n if (!p.open) {\n const at = p.blockedBy ?? ''\n if (p.kind === 'collider') return e.pathBlocked(path, at, e.colliderUnknown(at, p.descendants ?? []))\n const i = p.nodes.indexOf(at)\n const fork = i > 0 && p.edges[i - 1].from === at && p.edges[i].from === at\n return e.pathBlocked(path, at, fork ? e.forkKnown(at) : e.chainKnown(at))\n }\n if (p.nodes.length === 2) return e.pathOpen(path, e.adjacent)\n const opened = p.opened ?? []\n const colliders = new Set(opened.map((o) => o.collider))\n const middles = p.nodes.slice(1, -1).filter((id) => !colliders.has(id))\n const why = [\n ...opened.map((o) => (o.by === o.collider ? e.colliderKnown(o.collider) : e.descendantKnown(o.collider, o.by))),\n ...(middles.length === 0 ? [] : [e.middlesUnknown(middles)]),\n ]\n return e.pathOpen(path, t.list(why))\n}\n\n/** The tip of a marked edge: the marked paths through it in its own state, at most {@link TIP_PATHS}, then how many in all. */\nexport function edgeTipText(t: Messages, marks: PathMarks, key: string, onPath: 'open' | 'blocked'): string {\n const through = marks.paths.filter((p) => p.open === (onPath === 'open') && p.edges.some((e) => `${e.from}>${e.to}` === key))\n const named = through.slice(0, TIP_PATHS).map((p) => pathTipSentence(t, p))\n const parts = through.length > TIP_PATHS ? [...named, t.edgeTip.more(through.length)] : named\n return onPath === 'open' ? t.edgeTip.open(parts) : t.edgeTip.blocked(parts)\n}\n","/** Whether `el` has focus the browser would draw a ring for (a keyboard, not a click); true where `:focus-visible` is unknown. */\nexport function focusVisible(el: Element): boolean {\n try {\n return el.matches(':focus-visible')\n } catch {\n return true\n }\n}\n","import type { Anchor, Box, Placed } from './graph-labels.ts'\nimport { rectBox, textBox } from './graph-labels.ts'\nimport { textWidth } from '../text/text-measure.ts'\nimport type { Value } from '../../engine/index.ts'\nimport { formatValue } from '../../engine/values.ts'\nimport type { Messages } from '../i18n/messages.ts'\nimport { probText } from '../model/wording.ts'\n\n/** The shapes a signal graph draws with: a node's label block and its readout, and the path strings of arrowheads, clamps and dashed rings. Pure. */\n\nconst SNAP = 0.25\n/** Per-value bars: tallest bar, the gap to the label above them, and the value label size. */\nexport const BAR_H = 24\nexport const BAR_GAP = 10\nexport const BAR_LABEL = 11\n\n/** What sits under a node's label: nothing, one number, or one bar per value (with the largest probability). */\nexport type Readout =\n | { readonly kind: 'none'; readonly noteW?: number; readonly note2W?: number }\n | { readonly kind: 'number'; readonly noteW?: number; readonly numberW?: number }\n | { readonly kind: 'bars'; readonly width: number; readonly maxW: number; readonly noteW?: number }\n\n/** Where a label block sits round its node: under or over the disc, beside it, or off one of its corners. */\nexport type BlockSide = 'below' | 'above' | 'right' | 'left' | 'below-right' | 'below-left' | 'above-right' | 'above-left'\n\n/** A node's label and its readout as one block, in offsets from the node's centre. */\nexport interface Block {\n readonly side: BlockSide\n /** The block's middle line: every text in it is centred on `cx`. */\n readonly cx: number\n /** Whether the label is wrapped onto two lines; the second has its baseline at `label2Y`. */\n readonly wrapped: boolean\n /** Baselines of the label (and of its second line), the number and the note (and a second note line). */\n readonly labelY: number\n readonly label2Y: number\n readonly numberY: number\n readonly noteY: number\n readonly note2Y: number\n /** Bars: left edge and the baseline the bars stand on. */\n readonly x0: number\n readonly baseline: number\n readonly boxes: readonly Box[]\n}\n\n/** The width a node's number reserves under its label: a probability of `digits` decimals at 16 px. */\nexport function numberWidth(digits = 2): number {\n return textWidth(`0.${'0'.repeat(digits)}`, 16) + 4\n}\n\n/** What a probability node shows as its number: a small prefix and the text. `settled` nodes (observed or do()) carry no 原本 note. */\nexport interface NodeReadout {\n readonly prefix: string\n readonly text: string\n readonly settled: boolean\n}\n\nexport function nodeReadout(\n t: Messages,\n digits: number,\n p: number | undefined,\n forced: Value | undefined,\n seen: Value | undefined,\n): NodeReadout {\n if (forced !== undefined) return { prefix: '', text: t.nodeReadout.intervened(formatValue(forced)), settled: true }\n if (seen !== undefined) return { prefix: '', text: t.nodeReadout.observed(formatValue(seen)), settled: true }\n return { prefix: `${t.nodeReadout.unknown} `, text: probText(p ?? Number.NaN, digits), settled: false }\n}\n\n/** The width a readout reserves: the number at 16 px, or the settled text at 14 px, after its prefix at 11 px. */\nexport function readoutWidth(r: NodeReadout, digits: number): number {\n const prefixW = r.prefix === '' ? 0 : textWidth(r.prefix, 11)\n return prefixW + (r.settled ? textWidth(r.text, 14) + 4 : numberWidth(digits))\n}\n\n/** A label's width on one line, and on two when it can be wrapped. */\nexport interface LabelSize {\n readonly width: number\n readonly lines?: readonly [number, number]\n}\n\n/** Between the baselines of a wrapped label's two lines, in px. */\nexport const LABEL_LEADING = 17\n\n/** The block with its top edge at `top`, centred on `cx`; its label on two lines when `wrapped`. */\nfunction blockAt(top: number, side: BlockSide, label: LabelSize, readout: Readout, cx = 0, wrapped = false): Block {\n const labelY = top + 12\n const lines = wrapped ? label.lines : undefined\n // A wrapped label claims one box over both its lines, as wide as the longer one.\n const label2Y = lines === undefined ? labelY : labelY + LABEL_LEADING\n const labelBox = textBox(cx, labelY, 'middle', lines === undefined ? label.width : Math.max(...lines), 14)\n const boxes: Box[] = [{ ...labelBox, y1: labelBox.y1 + label2Y - labelY }]\n let numberY = label2Y\n let noteY = label2Y\n let x0 = cx\n let baseline = label2Y\n let note2Y = label2Y\n const last = label2Y\n if (readout.kind === 'none' && (readout.noteW !== undefined || readout.note2W !== undefined)) {\n noteY = last + 17\n note2Y = readout.noteW === undefined ? noteY : noteY + 18\n if (readout.noteW !== undefined) boxes.push(textBox(cx, noteY, 'middle', readout.noteW, 12))\n if (readout.note2W !== undefined) boxes.push(textBox(cx, note2Y, 'middle', readout.note2W + 8, 14))\n } else if (readout.kind === 'number') {\n numberY = last + 22\n noteY = numberY + 19\n boxes.push(textBox(cx, numberY, 'middle', readout.numberW ?? numberWidth(), 16))\n if (readout.noteW !== undefined) boxes.push(textBox(cx, noteY, 'middle', readout.noteW, 12))\n } else if (readout.kind === 'bars') {\n const chartTop = last + BAR_GAP\n x0 = cx - readout.width / 2\n baseline = chartTop + BAR_H\n noteY = baseline + BAR_LABEL + 16\n boxes.push(rectBox(x0, chartTop, readout.width, BAR_H + BAR_LABEL + 6))\n boxes.push(textBox(x0 - 5, chartTop + 8, 'end', readout.maxW, 11))\n if (readout.noteW !== undefined) boxes.push(textBox(cx, noteY, 'middle', readout.noteW, 12))\n }\n return { side, cx, wrapped: lines !== undefined, labelY, label2Y, numberY, noteY, note2Y, x0, baseline, boxes }\n}\n\n/**\n * Where a node of radius `r` may put its label block, best first: under the disc, over it, beside\n * it on the right and on the left (level with its centre), then off each of the disc's four\n * corners, last because a block there may read as its neighbour's. Each spot is followed by the\n * same spot with the label on two lines, when it can be wrapped, so a long label wraps where it is\n * before it moves to another side.\n */\nexport function blockOptions(r: number, label: number | LabelSize, readout: Readout): readonly Block[] {\n const size: LabelSize = typeof label === 'number' ? { width: label } : label\n const at = (wrapped: boolean): { readonly sides: Block[]; readonly corners: Block[] } => {\n const probe = blockAt(0, 'below', size, readout, 0, wrapped)\n const height = Math.max(...probe.boxes.map((b) => b.y1))\n const minX = Math.min(...probe.boxes.map((b) => b.x0))\n const maxX = Math.max(...probe.boxes.map((b) => b.x1))\n const below = r + 12\n const above = -r - 10 - height\n // Beside the disc: the label's line level with the node's centre, the block's near edge 10 px off the rim.\n const beside = -Math.max(8, height / 2)\n const right = r + 10 - minX\n const left = -r - 10 - maxX\n // Off a corner: the block's near corner just past the square round the disc.\n const d = r + 4\n return {\n sides: [\n blockAt(below, 'below', size, readout, 0, wrapped),\n blockAt(above, 'above', size, readout, 0, wrapped),\n blockAt(beside, 'right', size, readout, right, wrapped),\n blockAt(beside, 'left', size, readout, left, wrapped),\n ],\n corners: [\n blockAt(d, 'below-right', size, readout, d - minX, wrapped),\n blockAt(d, 'below-left', size, readout, -d - maxX, wrapped),\n blockAt(-d - height, 'above-right', size, readout, d - minX, wrapped),\n blockAt(-d - height, 'above-left', size, readout, -d - maxX, wrapped),\n ],\n }\n }\n const one = at(false)\n const spots = [...one.sides, ...one.corners]\n if (size.lines === undefined) return spots\n const two = at(true)\n const wrapped = [...two.sides, ...two.corners]\n return spots.flatMap((b, i) => [b, wrapped[i]])\n}\n\n/**\n * Where a small 12 px note of width `w` (原本 v) may go beside a node of radius `r` with label block\n * `block`, best first, in offsets from the node's centre: right past the block's far edge from the\n * disc (under a block beside the disc), on the label's own line after or before it, beside the\n * disc, then on the disc's other side.\n */\nexport function noteSpots(block: Block, r: number, w: number): readonly (Placed & { readonly box: Box })[] {\n const top = Math.min(...block.boxes.map((b) => b.y0))\n const bottom = Math.max(...block.boxes.map((b) => b.y1))\n const label = block.boxes[0]\n const spot = (x: number, y: number, anchor: Anchor) => ({ x, y, anchor, box: textBox(x, y, anchor, w, 12) })\n const under = block.side === 'below' || block.side.startsWith('below-') || block.side === 'right' || block.side === 'left'\n const outer = under ? spot(block.cx, bottom + 13, 'middle') : spot(block.cx, top - 5, 'middle')\n const across = under ? spot(0, -r - 8, 'middle') : spot(0, r + 17, 'middle')\n return [\n outer,\n spot(label.x1 + 6, block.labelY, 'start'),\n spot(label.x0 - 6, block.labelY, 'end'),\n spot(r + 8, 4, 'start'),\n spot(-r - 8, 4, 'end'),\n across,\n ]\n}\n\nexport function snap(v: number): number {\n return Math.round(v / SNAP) * SNAP\n}\n\n\nexport interface Point {\n readonly x: number\n readonly y: number\n}\n\nexport function unit(a: Point, b: Point): { ux: number; uy: number; d: number } {\n const dx = b.x - a.x\n const dy = b.y - a.y\n const d = Math.hypot(dx, dy) || 1\n return { ux: dx / d, uy: dy / d, d }\n}\n\n/**\n * The dashes of an exogenous node's outline: whole dashes round the circle, so the ring has no\n * seam. (Dashes in px, not `pathLength`, so a viewer that ignores that attribute still draws them.)\n */\nexport function exoDash(r: number): string {\n const c = 2 * Math.PI * r\n const unitLength = c / Math.max(6, Math.round(c / 11))\n return `${(unitLength * 0.6).toFixed(2)} ${(unitLength * 0.4).toFixed(2)}`\n}\n\n/** How far an exogenous node's fill sits inside its dashed outline, in px. */\nexport const EXO_INSET = 4.5\n\n/** An arrowhead with its tip at `tip`, pointing along (`dx`, `dy`). */\nexport function arrowHead(tip: Point, dx: number, dy: number): string {\n const len = Math.hypot(dx, dy) || 1\n const ux = dx / len\n const uy = dy / len\n const bx = tip.x - 9 * ux\n const by = tip.y - 9 * uy\n return `M${tip.x} ${tip.y}L${bx - 3.6 * uy} ${by + 3.6 * ux}L${bx + 3.6 * uy} ${by - 3.6 * ux}z`\n}\n\nexport function clampPath(r: number): string {\n const o = r + 8\n const s = 14\n return `M${-o} ${-o + s}v${-s}h${s}M${o - s} ${-o}h${s}v${s}M${o} ${o - s}v${s}h${-s}M${-o + s} ${o}h${-s}v${-s}`\n}\n","import type { ReactNode } from 'react'\nimport { useMessages } from '../i18n/messages.ts'\nimport { probText } from '../model/wording.ts'\nimport { useDigits } from '../shared/digits.ts'\nimport { barLayout } from '../text/text-measure.ts'\nimport type { Block } from './signal-shapes.ts'\nimport { BAR_H, BAR_LABEL } from './signal-shapes.ts'\n\nexport interface BarChartProps {\n readonly id: string\n /** Each value as text, in domain order. */\n readonly labels: readonly string[]\n /** P(id = value) per value; NaN where it cannot be computed. */\n readonly dist: readonly number[] | undefined\n /** The node's label block: the bars stand on its baseline from its left edge. */\n readonly block: Block\n /** Each bar's tooltip, `P(X=v)=0.25`. */\n readonly barText: (i: number) => string\n}\n\n/** One bar per value, scaled so the most likely value fills the chart's height; that probability is written beside it. */\nexport function BarChart({ id, labels, dist, block, barText }: BarChartProps): ReactNode {\n const t = useMessages()\n const digits = useDigits()\n const layout = barLayout(labels, BAR_LABEL)\n const known = (dist ?? []).filter((x) => !Number.isNaN(x))\n const max = known.length === 0 ? Number.NaN : Math.max(...known)\n return (\n <g className=\"ca-bars\" data-bars={id} transform={`translate(${block.x0} ${block.baseline})`}>\n <line x1={0} x2={layout.width} y1={0} y2={0} className=\"ca-hair\" />\n {!Number.isNaN(max) && (\n <text x={-5} y={-BAR_H + 8} textAnchor=\"end\" className=\"ca-mono ca-svg-tiny ca-fill-muted\" data-max={max.toFixed(4)}>\n {t.barMax(probText(max, digits))}\n </text>\n )}\n {labels.map((text, i) => {\n const p = dist?.[i]\n const ok = p !== undefined && !Number.isNaN(p)\n const h = ok && max > 0 && p > 0 ? Math.max(1, (p / max) * BAR_H) : 0\n const cx = i * layout.pitch + layout.pitch / 2\n const edge = i === 0 || i === labels.length - 1\n return (\n <g key={text} data-bar={text} data-p={ok ? p.toFixed(4) : ''}>\n <title>{barText(i)}</title>\n <rect x={cx - layout.barW / 2} y={-h} width={layout.barW} height={h} className=\"ca-fill-fg\" />\n {(layout.labelsFit || edge) && (\n <text x={cx} y={BAR_LABEL + 2} textAnchor=\"middle\" className=\"ca-mono ca-svg-tiny ca-fill-muted\">\n {text}\n </text>\n )}\n </g>\n )\n })}\n </g>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Edge, Hedge, Value } from '../../engine/index.ts'\nimport { getVariable } from '../../engine/index.ts'\nimport { formatValue, valuesEqual } from '../../engine/values.ts'\nimport type { Messages } from '../i18n/messages.ts'\nimport type { Stochastic } from '../model/assignments.ts'\nimport type { PathMarks } from '../model/dsep-view.ts'\nimport { assignmentText, idWithName, probText, shortLabel } from '../model/wording.ts'\nimport { barLayout, textWidth } from '../text/text-measure.ts'\nimport type { ArcPlan, Pt } from './graph-layout.ts'\nimport {\n arcCurve,\n edgeLive,\n edgePolarity,\n graphSpacing,\n gridLayout,\n latentArcs,\n planArcs,\n shownEdges,\n} from './graph-layout.ts'\nimport type { Anchor, Box, Placed } from './graph-labels.ts'\nimport { around, firstClear, intersects, rectBox, segmentHitsBox, shifted, textBox } from './graph-labels.ts'\nimport type { Block, Point, Readout } from './signal-shapes.ts'\nimport { BAR_LABEL, blockOptions, nodeReadout, noteSpots, readoutWidth, unit } from './signal-shapes.ts'\n\n/**\n * Where everything in a signal graph goes, computed apart from drawing it: node positions, each\n * node's label block (below it, or round it where that crosses less), the do() tags, the latent arcs\n * and their labels, every edge with its cut or inhibit label, the witness hull and the view box.\n * Labels claim space in one shared obstacle list, in this order: node blocks, arc labels, then\n * cut and inhibit labels edge by edge.\n */\n\n/** What the layout reads: `SignalGraphProps` without the handlers, the defaults filled in, and a drag in progress. */\nexport interface SignalGraphInput {\n readonly c: LoadedCase\n readonly shown: readonly string[]\n readonly structural?: boolean\n readonly values?: Assignment\n readonly original?: Assignment\n readonly probs?: Readonly<Record<string, number>>\n /** Value mode: a P(V = 1) number under these nodes only. */\n readonly probe?: Readonly<Record<string, number>>\n readonly dists?: Readonly<Record<string, readonly number[]>>\n readonly probNotes?: Readonly<Record<string, string>>\n readonly observedValues: Assignment\n readonly evidence: boolean\n readonly interventions: Assignment\n /** The text of a do() tag in place of `X←1`, per variable (a mediator held at its natural value, `Z←Z(X=0)`). */\n readonly tagText?: Readonly<Record<string, string>>\n readonly stochastic: Stochastic\n readonly removedEdges: readonly Edge[]\n readonly witness?: Assignment\n readonly hedge?: Hedge\n readonly holdNotes: boolean\n readonly defaults?: Assignment\n readonly paths?: PathMarks\n readonly clamped: readonly string[]\n /** Intervention switch nodes (`F_Z`), drawn as small squares beside the variable they point into. */\n readonly switches?: readonly string[]\n readonly compact: boolean\n /** The node being dragged and how far it has moved, in px. */\n readonly drag?: { readonly id: string; readonly dx: number; readonly dy: number }\n /** Decimals of every probability written (default 2). */\n readonly digits?: number\n}\n\n/** The tag beside a set node: `X←1` for do(), `P(X=1)=0.30` for a stochastic do(), `X=1` observed (`seen`). */\nexport interface DoTag {\n readonly text: string\n readonly box: Box\n readonly left: boolean\n readonly seen: boolean\n readonly reset: boolean\n}\n\n/** An edge as drawn, from the rim of its source (`x1`, `y1`) to the end of its line (`x2`, `y2`). */\nexport type EdgeMark =\n | {\n readonly kind: 'cut'\n readonly key: string\n readonly x1: number\n readonly y1: number\n readonly x2: number\n readonly y2: number\n /** The middle of the gap, and the edge's direction. */\n readonly mx: number\n readonly my: number\n readonly ux: number\n readonly uy: number\n /** The two slashes across the gap, as a path. */\n readonly slash: string\n readonly label: Placed\n }\n | {\n readonly kind: 'inhibit'\n readonly key: string\n readonly x1: number\n readonly y1: number\n readonly x2: number\n readonly y2: number\n readonly ux: number\n readonly uy: number\n readonly live: boolean\n readonly onPath?: 'open' | 'blocked'\n readonly cls: string\n /** ¬X, and where it sits. */\n readonly text: string\n readonly label: Placed\n }\n | {\n readonly kind: 'plain'\n readonly key: string\n readonly x1: number\n readonly y1: number\n readonly x2: number\n readonly y2: number\n readonly live: boolean\n readonly onPath?: 'open' | 'blocked'\n readonly cls: string\n }\n\n/** A latent arc: its plan, the curve sampled at 41 points, and its short label. */\nexport interface ArcMark {\n readonly plan: ArcPlan\n readonly curve: Pt[]\n readonly label: Placed\n}\n\n/** The amber hull round the variables a witness holds, with its 見證 tag text. */\nexport interface Hull {\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n readonly text: string\n}\n\nexport interface SignalLayout {\n readonly prob: boolean\n /** Node radius, column width and row height, in px. */\n readonly r: number\n readonly col: number\n readonly row: number\n readonly pos: ReadonlyMap<string, Point>\n readonly blocks: ReadonlyMap<string, Block>\n /** Every spot each node's block was weighed at, best first; `blocks` holds the one taken. */\n readonly labelOptions: ReadonlyMap<string, readonly Block[]>\n /** A wrapped label's name in its two parts (the id goes before the first), per node whose block wraps it. */\n readonly labelLines: ReadonlyMap<string, readonly [string, string]>\n readonly tags: ReadonlyMap<string, DoTag>\n /** 固定為 w(實際 v) or 固定(實際值) per held variable, when `holdNotes`. */\n readonly holdNotes: ReadonlyMap<string, string>\n /** 偏離(預設 v) per node off its default. */\n readonly deviantNotes: ReadonlyMap<string, string>\n /** 原本 v per node whose value differs from the world before do(), placed from the node's centre. */\n readonly wasNotes: ReadonlyMap<string, Placed & { readonly text: string }>\n readonly edges: readonly EdgeMark[]\n readonly arcs: readonly ArcMark[]\n readonly hull?: Hull\n /** The view box. */\n readonly left: number\n readonly top: number\n readonly width: number\n readonly height: number\n}\n\n/**\n * A name in two parts for a label on two lines: split at the space that makes the id with the\n * first part and the rest nearest in width, never right after an abbreviation (`Mr.`, `St.`), which\n * stays with the word it belongs to. A Chinese name stays whole: its spaces only set off a digit or\n * a letter inside a phrase (第 1 位投給 B 先生), and splitting there would break the phrase.\n */\nexport function wrapName(id: string, name: string): readonly [string, string] | undefined {\n if ([...name].some((ch) => (ch.codePointAt(0) ?? 0) > 0x2e7f)) return undefined\n const words = name.split(' ').filter((w) => w !== '')\n let best: readonly [string, string] | undefined\n let bestW = Infinity\n for (let i = 1; i < words.length; i++) {\n if (/^[A-Za-z]{1,3}\\.$/.test(words[i - 1])) continue\n const first = words.slice(0, i).join(' ')\n const second = words.slice(i).join(' ')\n const w = Math.max(textWidth(idWithName(id, first), 14), textWidth(second, 14))\n if (w < bestW) {\n best = [first, second]\n bestW = w\n }\n }\n return best\n}\n\n/** How much nearer (edge to edge) a label block must be to its own disc than to any other, in px. */\nexport const LABEL_MARGIN = 12\n/** The least gap between two nodes' label blocks, in px, so they never read as one stack. */\nexport const BLOCK_GAP = 10\n\n/** Half the side of a switch node's square, in px. */\nexport const SWITCH_HALF = 9\n\n/** Where a switch may sit, in grid cells from the variable it points into: up-left first, then round it. */\nconst SWITCH_SPOTS: readonly (readonly [number, number])[] = [\n [-0.55, -0.55],\n [-0.55, 0.55],\n [0, -0.7],\n [-0.7, 0],\n [0.55, -0.55],\n [0.55, 0.55],\n [0, 0.7],\n [0.7, 0],\n]\n\n/**\n * The grid with each switch (`F_Z`, its one arrow into `Z`) placed beside its variable, at the\n * first spot clear of the other nodes and of the edges, whose own arrow passes no other node. The\n * other nodes keep their cells.\n */\nfunction placeSwitches(\n c: LoadedCase,\n shown: readonly string[],\n switches: readonly string[],\n grid: Map<string, { col: number; row: number }>,\n col: number,\n row: number,\n r: number,\n): Map<string, { col: number; row: number }> {\n const drawn = switches.filter((id) => shown.includes(id))\n if (drawn.length === 0) return grid\n const px = (g: { col: number; row: number }): Point => ({ x: g.col * col, y: g.row * row })\n const edges = shownEdges(c.model.edges, shown).filter((e) => !switches.includes(e.from))\n const near = (p: Point, q: Point, d: number): boolean => Math.hypot(p.x - q.x, p.y - q.y) < d\n const box = (p: Point, d: number): Box => ({ x0: p.x - d, y0: p.y - d, x1: p.x + d, y1: p.y + d })\n for (const id of drawn) {\n const target = c.model.edges.find((e) => e.from === id)?.to\n const at = target === undefined ? undefined : grid.get(target)\n if (target === undefined || at === undefined) throw new Error(`logic-atlas: ${c.data.id}: switch ${id} points into no drawn variable`)\n const tp = px(at)\n const clear = (spot: { col: number; row: number }): boolean => {\n const p = px(spot)\n for (const [other, g] of grid) {\n if (other === target) continue\n const q = px(g)\n if (near(p, q, 2 * r + 8)) return false\n if (segmentHitsBox(p, tp, box(q, r + 4))) return false\n }\n return edges.every((e) => {\n const a = grid.get(e.from)\n const b = grid.get(e.to)\n return a === undefined || b === undefined || !segmentHitsBox(px(a), px(b), box(p, SWITCH_HALF + 10))\n })\n }\n const spots = SWITCH_SPOTS.map(([dc, dr]) => ({ col: at.col + dc, row: at.row + dr }))\n grid.set(id, spots.find(clear) ?? spots[0])\n }\n return grid\n}\n\nexport function layoutSignalGraph(input: SignalGraphInput, t: Messages): SignalLayout {\n const {\n c,\n shown,\n values,\n original,\n probs,\n probe = {},\n dists,\n probNotes,\n interventions,\n tagText,\n stochastic,\n removedEdges,\n witness,\n observedValues,\n evidence,\n holdNotes,\n defaults,\n paths,\n clamped,\n switches = [],\n compact,\n drag,\n digits = 2,\n } = input\n const prob = probs !== undefined\n const { r, col: COL, row: ROW } = graphSpacing(prob, compact)\n const R = input.structural === true ? 19 : r\n const PAD_X = compact ? 60 : 96\n const PAD_Y = 72\n const grid = placeSwitches(c, shown, switches, gridLayout(c, shown.filter((id) => !switches.includes(id))), COL, ROW, R)\n const cells = [...grid.values()]\n const minCol = Math.min(...cells.map((p) => p.col))\n const maxCol = Math.max(...cells.map((p) => p.col))\n const minRow = Math.min(...cells.map((p) => p.row))\n const maxRow = Math.max(...cells.map((p) => p.row))\n const width = PAD_X * 2 + (maxCol - minCol) * COL\n const hasWitness = witness !== undefined && Object.keys(witness).length > 0\n const barred = (id: string): boolean => prob && getVariable(c.model, id).domain.kind === 'finite'\n const layoutHeight = PAD_Y * 2 + (maxRow - minRow) * ROW + (hasWitness ? 40 : 0)\n const pos = new Map<string, Point>()\n for (const [id, p] of grid) {\n const off = drag?.id === id ? drag : undefined\n pos.set(id, { x: PAD_X + (p.col - minCol) * COL + (off?.dx ?? 0), y: PAD_Y + (p.row - minRow) * ROW + (off?.dy ?? 0) })\n }\n const cut = new Set(removedEdges.map((e) => `${e.from}>${e.to}`))\n const edges = shownEdges(c.model.edges, shown)\n const nameOf = (id: string): string => shortLabel(c.model, id, t.locale)\n /** An edge's line as drawn: from its source's rim (a switch's side) to the start of its head. */\n const edgeLine = (e: Edge) => {\n const a = pos.get(e.from)\n const b = pos.get(e.to)\n if (a === undefined || b === undefined) return undefined\n const { ux, uy } = unit(a, b)\n // A switch's square: the arrow leaves its side, not a circle's rim.\n const from = switches.includes(e.from) ? SWITCH_HALF / Math.max(Math.abs(ux), Math.abs(uy)) : R\n const key = `${e.from}>${e.to}`\n const kind: EdgeMark['kind'] = cut.has(key) ? 'cut' : edgePolarity(c.model, e.from, e.to) === 'inhibit' ? 'inhibit' : 'plain'\n const end = kind === 'inhibit' ? R + 7 : R + 2\n return { kind, key, a, b, ux, uy, x1: a.x + from * ux, y1: a.y + from * uy, x2: b.x - end * ux, y2: b.y - end * uy }\n }\n\n // The tag beside a set node: `X←1` for do(), `P(X=1)=0.30` for a stochastic do(), `X=1` observed.\n const doTag = (id: string): DoTag | undefined => {\n const forced = interventions[id]\n const soft = stochastic[id]\n const seen = observedValues[id]\n if (forced === undefined && soft === undefined && (seen === undefined || evidence)) return undefined\n if (witness !== undefined && id in witness) return undefined\n const before = original?.[id]\n const reset = holdNotes && forced !== undefined && before !== undefined && valuesEqual(forced, before)\n const text =\n forced !== undefined ? (tagText?.[id] ?? (reset ? t.witness.resetTag(id, formatValue(forced)) : `${id}←${formatValue(forced)}`)) : soft !== undefined ? `P(${id}=1)=${probText(soft, digits)}` : `${id}=${formatValue(seen as Value)}`\n const w = textWidth(text, 12) + 18\n const left = (grid.get(id)?.col ?? 0) === maxCol\n return { text, left, reset, seen: forced === undefined && soft === undefined, box: rectBox(left ? -R - 12 - w : R + 12, -R - 10, w, 22) }\n }\n\n /** 固定為 w(實際 v) or 固定(實際值) for a held variable, when `holdNotes`. */\n const holdNote = (id: string): string | undefined => {\n if (!holdNotes || witness === undefined || !(id in witness)) return undefined\n // A probability graph has no actual world to compare with.\n if (prob) return t.witness.heldPlain\n const before = original?.[id]\n const now = values?.[id] ?? witness[id]\n return before === undefined || valuesEqual(before, now) ? t.witness.heldActual : t.witness.held(formatValue(now), formatValue(before))\n }\n\n /** 偏離(預設 v) for a node of a graph with values off its default. */\n const deviantNote = (id: string): string | undefined => {\n const normal = defaults?.[id]\n const now = values?.[id]\n if (prob || normal === undefined || now === undefined || valuesEqual(now, normal)) return undefined\n return t.normality.deviant(formatValue(normal))\n }\n\n // Each node's label and readout form one block right under it; only when that block meets a disc,\n // a do tag or an earlier block, or crosses a drawn line (edge, arc or head), does the whole block\n // move: above the node, beside it, or off a corner, to the spot that crosses least.\n const placedBoxes: Box[] = []\n const blocks = new Map<string, Block>()\n const labelOptions = new Map<string, readonly Block[]>()\n const labelLines = new Map<string, readonly [string, string]>()\n const wasNotes = new Map<string, Placed & { readonly text: string }>()\n const fixed: Box[] = []\n const tagBoxes: Box[] = []\n for (const id of shown) {\n const p = pos.get(id)\n if (p === undefined) continue\n fixed.push(around(p.x, p.y, (switches.includes(id) ? SWITCH_HALF : R) + 3))\n const tag = doTag(id)\n if (tag !== undefined) {\n fixed.push(shifted(tag.box, p.x, p.y))\n tagBoxes.push(shifted(tag.box, p.x, p.y))\n }\n }\n // An arc ends where its child is cut: do() on a child (or a cut edge from the latent cause) removes\n // that end, so the arc is gone (Pearl's G with the arrows into X removed).\n const endCut = (via: string, id: string): boolean => cut.has(`${via}>${id}`) || id in interventions || id in stochastic || clamped.includes(id)\n const arcPlans = planArcs(\n latentArcs(c, shown).filter((a) => !endCut(a.via, a.a) && !endCut(a.via, a.b)),\n pos,\n edges,\n R,\n tagBoxes,\n )\n const arcSegments = arcPlans.map((a) => arcCurve(a.start, a.control, a.end, 12))\n // The lines as drawn, which a node's label must not cross: each edge from rim to tip (a cut one\n // in its two halves), each arc's curve, and every head (arrow or ¬ circle) widened to its width.\n const strokes: [Point, Point][] = []\n const heads: Box[] = []\n const head = (tip: Point, ux: number, uy: number, past: number): void => {\n const end = { x: tip.x + past * ux, y: tip.y + past * uy }\n const base = { x: tip.x - 10 * ux, y: tip.y - 10 * uy }\n heads.push({ x0: Math.min(end.x, base.x) - 5, y0: Math.min(end.y, base.y) - 5, x1: Math.max(end.x, base.x) + 5, y1: Math.max(end.y, base.y) + 5 })\n }\n for (const e of edges) {\n const line = edgeLine(e)\n if (line === undefined) continue\n const { x1, y1, x2, y2, ux, uy } = line\n if (line.kind === 'cut') {\n const mx = (x1 + x2) / 2\n const my = (y1 + y2) / 2\n strokes.push([{ x: x1, y: y1 }, { x: mx - 10 * ux, y: my - 10 * uy }], [{ x: mx + 10 * ux, y: my + 10 * uy }, { x: x2, y: y2 }])\n continue\n }\n strokes.push([{ x: x1, y: y1 }, { x: x2, y: y2 }])\n head({ x: x2, y: y2 }, ux, uy, line.kind === 'inhibit' ? 10 : 0)\n }\n for (const plan of arcPlans) {\n const curve = arcCurve(plan.start, plan.control, plan.end, 40)\n for (let i = 0; i + 1 < curve.length; i++) strokes.push([curve[i], curve[i + 1]])\n for (const [tip, from] of [[plan.start, plan.control], [plan.end, plan.control]] as const) {\n const { ux, uy } = unit(from, tip)\n head(tip, ux, uy, 0)\n }\n }\n /** How many drawn lines and heads `box` crosses. */\n const crossings = (box: Box): number => {\n const padded = { x0: box.x0 - 1, y0: box.y0 - 1, x1: box.x1 + 1, y1: box.y1 + 1 }\n return strokes.filter(([a, b]) => segmentHitsBox(a, b, padded)).length + heads.filter((h) => intersects(padded, h, 0)).length\n }\n /** A disc's radius: a switch's half side, else the node radius. */\n const radius = (id: string): number => (switches.includes(id) ? SWITCH_HALF : R)\n /**\n * Whether boxes placed for `id`'s block would read as another node's: some other disc is not at\n * least LABEL_MARGIN farther from them (edge to edge) than `id`'s own.\n */\n const ambiguous = (id: string, boxes: readonly Box[]): boolean => {\n const hull = { x0: Math.min(...boxes.map((b) => b.x0)), y0: Math.min(...boxes.map((b) => b.y0)), x1: Math.max(...boxes.map((b) => b.x1)), y1: Math.max(...boxes.map((b) => b.y1)) }\n const away = (q: Point, r: number): number => Math.hypot(Math.max(hull.x0 - q.x, 0, q.x - hull.x1), Math.max(hull.y0 - q.y, 0, q.y - hull.y1)) - r\n const own = away(pos.get(id) ?? { x: 0, y: 0 }, radius(id))\n return shown.some((other) => {\n const q = pos.get(other)\n return other !== id && q !== undefined && away(q, radius(other)) < own + LABEL_MARGIN\n })\n }\n // What a spot costs `id`, compared in turn: the discs and do tags it meets, the other blocks\n // (`placed`) it comes within BLOCK_GAP of, and whether it reads as another node's (see\n // `ambiguous`); the lines its label crosses, the lines the rest of the block crosses, and how far\n // it reaches past the graph's margins (in steps of 48 px, so a little overhang does not outweigh\n // the order), a corner counting one step more, since a block there sits farther from its node.\n const cost = (id: string, b: Block, placed: readonly Box[]): readonly number[] => {\n const p = pos.get(id) ?? { x: 0, y: 0 }\n let hard = 0\n let label = 0\n let rest = 0\n b.boxes.forEach((local, i) => {\n const box = shifted(local, p.x, p.y)\n const crossed = crossings(box)\n if (i === 0) label += crossed\n else rest += crossed\n for (const o of fixed) if (intersects(box, o, 0)) hard += 1\n for (const o of placed) if (intersects(box, o, BLOCK_GAP)) hard += 1\n })\n const all = b.boxes.map((local) => shifted(local, p.x, p.y))\n if (ambiguous(id, all)) hard += 1\n const past =\n Math.max(0, -Math.min(...all.map((x) => x.x0))) +\n Math.max(0, Math.max(...all.map((x) => x.x1)) - width) +\n Math.max(0, -Math.min(...all.map((x) => x.y0))) +\n Math.max(0, Math.max(...all.map((x) => x.y1)) - layoutHeight)\n return [hard, label, rest, Math.floor(past / 48) + (b.side.includes('-') ? 1 : 0)]\n }\n const clear = (k: readonly number[]): boolean => k[0] === 0 && k[1] === 0 && k[2] === 0\n const splits = new Map<string, readonly [string, string]>()\n const heldWas = new Map<string, { readonly text: string; readonly w: number }>()\n for (const id of shown) {\n const p = pos.get(id)\n if (p === undefined) continue\n const variable = getVariable(c.model, id)\n const settledRead = prob ? nodeReadout(t, digits, probs?.[id], interventions[id], evidence ? undefined : observedValues[id]) : undefined\n const before = original?.[id]\n const now = values?.[id]\n // With hold notes, 原本 v is a line of the label block (where 固定 notes go); otherwise it is placed after every block.\n const was = holdNotes && !prob && before !== undefined && now !== undefined && !valuesEqual(before, now) ? t.was(formatValue(before)) : undefined\n const note = holdNote(id) ?? was ?? (settledRead?.settled === true && !evidence ? undefined : probNotes?.[id])\n const noteW = note === undefined ? undefined : textWidth(note, 12)\n const deviant = deviantNote(id)\n let readout: Readout = { kind: 'none', noteW, note2W: deviant === undefined ? undefined : textWidth(deviant, 11) }\n if (barred(id) && variable.domain.kind === 'finite') {\n const known = (dists?.[id] ?? []).filter((x) => !Number.isNaN(x))\n const maxW = known.length === 0 ? 0 : textWidth(t.barMax(probText(Math.max(...known), digits)), 11)\n readout = { kind: 'bars', width: barLayout(variable.domain.values.map(formatValue), BAR_LABEL).width, maxW, noteW }\n } else if (prob) readout = { kind: 'number', noteW, numberW: readoutWidth(settledRead ?? nodeReadout(t, digits, undefined, undefined, undefined), digits) }\n else if (id in probe) readout = { kind: 'number', noteW, numberW: readoutWidth(nodeReadout(t, digits, probe[id], undefined, undefined), digits) }\n // A switch is labelled by its id alone (F_Z), right by its square.\n const isSwitch = switches.includes(id)\n const labelW = textWidth(isSwitch ? id : idWithName(id, nameOf(id)), 14)\n // A long name may go on two lines, split at the space that makes them nearest in width.\n const split = isSwitch ? undefined : wrapName(id, nameOf(id))\n const lines = split === undefined ? undefined : ([textWidth(idWithName(id, split[0]), 14), textWidth(split[1], 14)] as const)\n const options = blockOptions(isSwitch ? SWITCH_HALF : R + (input.hedge?.fPrime.includes(id) === true ? 16 : input.hedge?.f.includes(id) === true ? 9 : 0), { width: labelW, lines }, readout)\n labelOptions.set(id, options)\n // Under the node unless something is there; then the spot that costs least, earlier ones on a tie.\n const costs = options.map((o) => cost(id, o, placedBoxes))\n let best = 0\n if (!clear(costs[0])) {\n for (let i = 1; i < options.length; i++) {\n const diff = costs[i].map((v, j) => v - costs[best][j]).find((v) => v !== 0) ?? 0\n if (diff < 0) best = i\n }\n }\n const block = options[best]\n blocks.set(id, block)\n if (split !== undefined) splits.set(id, split)\n if (was !== undefined && noteW !== undefined && holdNote(id) === undefined) heldWas.set(id, { text: was, w: noteW })\n for (const b of block.boxes) placedBoxes.push(shifted(b, p.x, p.y))\n }\n // A column of three or more nodes reads best with every label on the same side of its disc. When\n // a column's labels went to different sides, they all move to one side (below, above, right or\n // left), all on one line or all on two (a name that cannot wrap stays on one), where each of them\n // is clear: off every disc, tag, line and other block, and its own. Of such ways, the one reaching\n // least past the margins wins, the earlier on a tie; with none, the labels stay where they went.\n const columns = new Map<number, string[]>()\n for (const id of shown) {\n const p = pos.get(id)\n if (p === undefined || switches.includes(id)) continue\n columns.set(Math.round(p.x), [...(columns.get(Math.round(p.x)) ?? []), id])\n }\n for (const group of columns.values()) {\n if (group.length < 3 || new Set(group.map((id) => blocks.get(id)?.side)).size === 1) continue\n const others = shown\n .filter((id) => !group.includes(id))\n .flatMap((id) => {\n const q = pos.get(id)\n return q === undefined ? [] : (blocks.get(id)?.boxes ?? []).map((b) => shifted(b, q.x, q.y))\n })\n let best: { readonly chosen: Map<string, Block>; readonly past: number } | undefined\n for (const [side, wrap] of (['below', 'above', 'right', 'left'] as const).flatMap((side) => [[side, false], [side, true]] as const)) {\n const taken = [...others]\n const chosen = new Map<string, Block>()\n let past = 0\n for (const id of group) {\n const q = pos.get(id) ?? { x: 0, y: 0 }\n const own = (labelOptions.get(id) ?? []).filter((o) => o.side === side)\n const fit = own.find((o) => o.wrapped === wrap) ?? own[0]\n if (fit === undefined || !clear(cost(id, fit, taken))) break\n chosen.set(id, fit)\n past += cost(id, fit, taken)[3]\n taken.push(...fit.boxes.map((b) => shifted(b, q.x, q.y)))\n }\n if (chosen.size === group.length && (best === undefined || past < best.past)) best = { chosen, past }\n }\n for (const [id, b] of best?.chosen ?? []) blocks.set(id, b)\n }\n placedBoxes.length = 0\n for (const id of shown) {\n const p = pos.get(id)\n const block = blocks.get(id)\n if (p === undefined || block === undefined) continue\n for (const b of block.boxes) placedBoxes.push(shifted(b, p.x, p.y))\n const split = splits.get(id)\n if (block.wrapped && split !== undefined) labelLines.set(id, split)\n const was = heldWas.get(id)\n if (was !== undefined) wasNotes.set(id, { text: was.text, x: block.cx, y: block.noteY, anchor: 'middle', box: textBox(block.cx, block.noteY, 'middle', was.w, 12) })\n }\n\n // 原本 v (without hold notes) goes where it clears every disc, do tag, label block and earlier\n // note: under or over its own block first, then on its label's line, then beside its disc;\n // a spot off every edge and arc wins over one on them.\n if (!holdNotes && !prob) {\n const tagged = shown.flatMap((id) => {\n const p = pos.get(id)\n const tag = doTag(id)\n return p === undefined || tag === undefined ? [] : [shifted(tag.box, p.x, p.y)]\n })\n const hard: Box[] = [...placedBoxes, ...tagged]\n const discs = shown.flatMap((id) => {\n const p = pos.get(id)\n return p === undefined ? [] : [around(p.x, p.y, (switches.includes(id) ? SWITCH_HALF : R) + 3)]\n })\n const onLine = (box: Box): boolean =>\n edges.some((e) => {\n const a = pos.get(e.from)\n const q = pos.get(e.to)\n return a !== undefined && q !== undefined && segmentHitsBox(a, q, box)\n }) || arcSegments.some((curve) => curve.some((pt, i) => i + 1 < curve.length && segmentHitsBox(pt, curve[i + 1], box)))\n for (const id of shown) {\n const p = pos.get(id)\n const block = blocks.get(id)\n const before = original?.[id]\n const now = values?.[id]\n if (p === undefined || block === undefined || before === undefined || now === undefined || valuesEqual(before, now)) continue\n const text = t.was(formatValue(before))\n const spots = noteSpots(block, R, textWidth(text, 12)).map((spot) => ({ ...spot, abs: shifted(spot.box, p.x, p.y) }))\n const clear = spots.filter(({ abs }) => !hard.some((o) => intersects(abs, o)) && !discs.some((o) => intersects(abs, o, 0)))\n const spot = clear.find(({ abs }) => !onLine(abs)) ?? clear[0] ?? spots[0]\n wasNotes.set(id, { text, x: spot.x, y: spot.y, anchor: spot.anchor, box: spot.box })\n hard.push(spot.abs)\n placedBoxes.push(spot.abs)\n }\n }\n\n // What a floating edge label must stay clear of: every node, its label block, its do tag; and\n // the edge labels already placed.\n const hitsNode = (box: Box): boolean => shown.some((id) => {\n const p = pos.get(id)\n if (!p) return false\n if (switches.includes(id)) return intersects(box, around(p.x, p.y, SWITCH_HALF), 0)\n const dx = Math.max(box.x0 - p.x, 0, p.x - box.x1)\n const dy = Math.max(box.y0 - p.y, 0, p.y - box.y1)\n return dx * dx + dy * dy <= R * R\n })\n const obstacles: Box[] = [...placedBoxes]\n for (const id of shown) {\n const p = pos.get(id)\n if (p === undefined) continue\n const local: Box[] = [around(0, 0, (switches.includes(id) ? SWITCH_HALF : R) + 6)]\n const tag = doTag(id)\n if (tag !== undefined) local.push(tag.box)\n for (const b of local) obstacles.push(shifted(b, p.x, p.y))\n }\n // Each arc says what it is in one short label by its middle, off the nodes, their labels and the edges;\n // the longer explanation is its tooltip.\n const arcLabelW = textWidth(t.arc.label, 12)\n const arcs = arcPlans.map((plan) => {\n const curve = arcCurve(plan.start, plan.control, plan.end, 40)\n const candidates: Placed[] = []\n for (const side of [1, -1]) {\n for (const i of [20, 16, 24, 12, 28]) {\n const q = curve[i]\n const nx = plan.bulge.x * side\n const ny = plan.bulge.y * side\n const away = 8 + Math.abs(nx) * (arcLabelW / 2) + Math.abs(ny) * 7\n const x = q.x + nx * away\n const y = q.y + ny * away + 4\n candidates.push({ x, y, anchor: 'middle', box: textBox(x, y, 'middle', arcLabelW, 12) })\n }\n }\n const offEdges = candidates.filter((cand) =>\n edges.every((e) => {\n const p = pos.get(e.from)\n const q = pos.get(e.to)\n return p === undefined || q === undefined || !segmentHitsBox(p, q, cand.box)\n }),\n )\n const label = firstClear(offEdges.length > 0 ? offEdges : candidates, obstacles)\n obstacles.push(label.box)\n return { plan, curve, label }\n })\n // Edge labels placed later keep off the arcs too.\n for (const { curve } of arcs) {\n for (let i = 0; i + 1 < curve.length; i += 2) {\n const [p, q] = [curve[i], curve[Math.min(i + 2, curve.length - 1)]]\n obstacles.push({ x0: Math.min(p.x, q.x) - 2, y0: Math.min(p.y, q.y) - 2, x1: Math.max(p.x, q.x) + 2, y1: Math.max(p.y, q.y) + 2 })\n }\n }\n // The drawing grows to hold every block: above the top row, below the bottom one, and past the\n // sides when a wide one (bars with their largest probability) reaches beyond the margin.\n let top = 0\n let bottom = layoutHeight\n let left = 0\n let right = width\n for (const id of shown) {\n const p = pos.get(id)\n const block = blocks.get(id)\n if (p === undefined || block === undefined) continue\n for (const b of block.boxes) {\n top = Math.min(top, p.y + b.y0 - 8)\n bottom = Math.max(bottom, p.y + b.y1 + 12)\n left = Math.min(left, p.x + b.x0 - 8)\n right = Math.max(right, p.x + b.x1 + 8)\n }\n }\n for (const [id, note] of wasNotes) {\n const p = pos.get(id)\n if (p === undefined) continue\n top = Math.min(top, p.y + note.box.y0 - 8)\n bottom = Math.max(bottom, p.y + note.box.y1 + 12)\n left = Math.min(left, p.x + note.box.x0 - 8)\n right = Math.max(right, p.x + note.box.x1 + 8)\n }\n for (const { curve, label } of arcs) {\n for (const q of curve) {\n top = Math.min(top, q.y - 8)\n bottom = Math.max(bottom, q.y + 12)\n left = Math.min(left, q.x - 8)\n right = Math.max(right, q.x + 8)\n }\n top = Math.min(top, label.box.y0 - 6)\n bottom = Math.max(bottom, label.box.y1 + 8)\n left = Math.min(left, label.box.x0 - 8)\n right = Math.max(right, label.box.x1 + 8)\n }\n top = Math.floor(top)\n left = Math.floor(left)\n const claim = (placed: Placed): Placed => {\n obstacles.push(placed.box)\n return placed\n }\n\n const edgeMarks: EdgeMark[] = []\n for (const e of edges) {\n const line = edgeLine(e)\n if (line === undefined) continue\n const { a, b, ux, uy, x1, y1, x2, y2, key } = line\n if (line.kind === 'cut') {\n const mx = (x1 + x2) / 2\n const my = (y1 + y2) / 2\n const nx = -uy\n const ny = ux\n const slash = (cx: number, cy: number): string =>\n `M${cx - 10 * nx - 3 * ux} ${cy - 10 * ny - 3 * uy}L${cx + 10 * nx + 3 * ux} ${cy + 10 * ny + 3 * uy}`\n // 切斷 goes beside the gap, on the side (and distance) where nothing else is.\n const cutCandidates: Placed[] = []\n for (const dist of [18, 28]) {\n for (const side of [1, -1]) {\n const x = mx + side * dist * uy\n const y = my - side * dist * ux + 4\n const anchor: Anchor = side * uy > 0.3 ? 'start' : side * uy < -0.3 ? 'end' : 'middle'\n cutCandidates.push({ x, y, anchor, box: textBox(x, y, anchor, textWidth(t.cut, 12), 12) })\n }\n }\n // Nor on an edge still drawn, so the mark is read on the edge it cuts.\n const offEdges = cutCandidates.filter((cand) =>\n edges.every((o) => {\n const p = pos.get(o.from)\n const q = pos.get(o.to)\n return cut.has(`${o.from}>${o.to}`) || p === undefined || q === undefined || !segmentHitsBox(p, q, cand.box)\n }),\n )\n const cutLabel = claim(firstClear(offEdges.length > 0 ? offEdges : cutCandidates, obstacles))\n edgeMarks.push({ kind: 'cut', key, x1, y1, x2, y2, mx, my, ux, uy, slash: slash(mx - 4 * ux, my - 4 * uy) + slash(mx + 4 * ux, my + 4 * uy), label: cutLabel })\n continue\n }\n const live = edgeLive(values, e.from)\n const onPath = paths?.open.has(key) === true ? 'open' : paths?.blocked.has(key) === true ? 'blocked' : undefined\n const cls = `${live ? 'ca-stroke-live' : 'ca-stroke-idle'}${onPath === undefined ? '' : ` ca-path-${onPath}`}`\n if (line.kind === 'inhibit') {\n // ¬X sits by the line; when that spot is taken it slides along the edge or switches sides.\n const text = `¬${e.from}`\n const width = textWidth(text, 12)\n const inhibitCandidates: Placed[] = []\n {\n const x = a.x + (b.x - a.x) * 0.55 + 14 * Math.abs(uy) + 4\n const y = a.y + (b.y - a.y) * 0.55 - 12 * Math.abs(ux)\n inhibitCandidates.push({ x, y, anchor: 'start', box: textBox(x, y, 'start', width, 12) })\n }\n for (const t of [0.55, 0.45, 0.65, 0.35, 0.72, 0.28]) {\n for (const side of [1, -1]) {\n const nx = -uy * side\n const ny = ux * side\n const away = 8 + Math.abs(nx) * (width / 2) + Math.abs(ny) * 7\n const cx = a.x + (b.x - a.x) * t + nx * away\n const cy = a.y + (b.y - a.y) * t + ny * away\n const x = cx - width / 2\n const y = cy + 4\n inhibitCandidates.push({ x, y, anchor: 'start', box: textBox(x, y, 'start', width, 12) })\n }\n }\n // Never trade a collision with the stroke or a node for a clearer label block.\n // Preserve candidate order on ties. If the entire neighbourhood is occupied,\n // search successively wider bands until at least one position is admissible.\n const admissible = (cand: Placed): boolean => !segmentHitsBox({ x: x1, y: y1 }, { x: x2, y: y2 }, cand.box) && !hitsNode(cand.box)\n const previous = firstClear(inhibitCandidates, obstacles)\n let best: Placed | undefined = admissible(previous) ? previous : undefined\n let bestScore = Infinity\n for (let band = 0; best === undefined; band++) {\n for (const dy of band === 0 ? [0] : [-24 * band, 24 * band]) {\n for (const base of inhibitCandidates) {\n const cand = dy === 0 ? base : { ...base, y: base.y + dy, box: shifted(base.box, 0, dy) }\n if (!admissible(cand)) continue\n const score = obstacles.filter((o) => intersects(cand.box, o)).length\n if (score < bestScore) { best = cand; bestScore = score }\n if (score === 0) break\n }\n if (bestScore === 0) break\n }\n }\n const inhibitLabel = claim(best)\n if (best !== previous) {\n left = Math.min(left, Math.floor(best.box.x0))\n right = Math.max(right, best.box.x1)\n top = Math.min(top, Math.floor(best.box.y0))\n bottom = Math.max(bottom, best.box.y1)\n }\n edgeMarks.push({ kind: 'inhibit', key, x1, y1, x2, y2, ux, uy, live, onPath, cls, text, label: inhibitLabel })\n continue\n }\n edgeMarks.push({ kind: 'plain', key, x1, y1, x2, y2, live, onPath, cls })\n }\n\n let hull: Hull | undefined\n if (witness !== undefined && Object.keys(witness).length > 0) {\n const pts = Object.keys(witness)\n .map((id) => pos.get(id))\n .filter((p): p is Point => p !== undefined)\n if (pts.length > 0) {\n const pad = R + 14\n const boxes = holdNotes ? Object.keys(witness).flatMap((id) => {\n const p = pos.get(id)\n return p === undefined ? [] : (blocks.get(id)?.boxes ?? []).map((b) => shifted(b, p.x, p.y))\n }) : []\n const x = Math.min(...pts.map((p) => p.x - pad - 20), ...boxes.map((b) => b.x0 - 5))\n const y = Math.min(...pts.map((p) => p.y - pad), ...boxes.map((b) => b.y0 - 5))\n hull = {\n x,\n y,\n w: Math.max(...pts.map((p) => p.x + pad + 20), ...boxes.map((b) => b.x1 + 5)) - x,\n // Include the label under the node, and its 固定 note.\n h: Math.max(...pts.map((p) => p.y + R + (holdNotes ? 10 : 34)), ...boxes.map((b) => b.y1 + 5)) - y,\n text: t.witnessHold(assignmentText(witness)),\n }\n }\n }\n\n const tags = new Map<string, DoTag>()\n const held = new Map<string, string>()\n const deviant = new Map<string, string>()\n for (const id of shown) {\n const tag = doTag(id)\n if (tag !== undefined) tags.set(id, tag)\n const hold = holdNote(id)\n if (hold !== undefined) held.set(id, hold)\n const off = deviantNote(id)\n if (off !== undefined) deviant.set(id, off)\n }\n return {\n prob,\n r: R,\n col: COL,\n row: ROW,\n pos,\n blocks,\n labelOptions,\n labelLines,\n tags,\n holdNotes: held,\n deviantNotes: deviant,\n wasNotes,\n edges: edgeMarks,\n arcs,\n hull,\n left,\n top,\n width: Math.ceil(right - left),\n height: Math.ceil(bottom - top),\n }\n}\n","import type { KeyboardEvent, PointerEvent, RefObject } from 'react'\nimport { useRef, useState } from 'react'\nimport type { Point } from './signal-shapes.ts'\nimport { snap } from './signal-shapes.ts'\n\n/**\n * The pointer and keyboard gestures on a signal graph's nodes: a click (or Enter, Space) that\n * activates a node, dragging a node (reported in grid steps), the click a drag leaves behind\n * (ignored), and the arrow keys that move a node.\n */\n\n/** A node being dragged: the pointer, where it went down (in svg px) and how far it has moved. */\nexport interface Drag {\n readonly id: string\n readonly pointer: number\n readonly x0: number\n readonly y0: number\n readonly dx: number\n readonly dy: number\n readonly moved: boolean\n}\n\n/** Arrow keys move a node by half a grid step. */\nconst ARROWS: Readonly<Record<string, readonly [number, number]>> = { ArrowLeft: [-0.5, 0], ArrowRight: [0.5, 0], ArrowUp: [0, -0.5], ArrowDown: [0, 0.5] }\n\nexport function useNodeGestures(svgRef: RefObject<SVGSVGElement | null>, onMove: ((id: string, dCol: number, dRow: number) => void) | undefined) {\n const [drag, setDrag] = useState<Drag | undefined>(undefined)\n // After a drag, the browser may still send a click to the node: ignore clicks until this time.\n const suppressUntil = useRef(0)\n const toSvg = (e: PointerEvent): Point => {\n const ctm = svgRef.current?.getScreenCTM?.()\n if (ctm === null || ctm === undefined) return { x: e.clientX, y: e.clientY }\n const inv = ctm.inverse()\n return { x: inv.a * e.clientX + inv.c * e.clientY + inv.e, y: inv.b * e.clientX + inv.d * e.clientY + inv.f }\n }\n const startDrag = (id: string, e: PointerEvent<SVGGElement>): void => {\n if (onMove === undefined || e.button !== 0) return\n const at = toSvg(e)\n setDrag({ id, pointer: e.pointerId, x0: at.x, y0: at.y, dx: 0, dy: 0, moved: false })\n }\n const moveDrag = (e: PointerEvent<SVGSVGElement>): void => {\n if (drag === undefined || e.pointerId !== drag.pointer) return\n const at = toSvg(e)\n const dx = at.x - drag.x0\n const dy = at.y - drag.y0\n const moved = drag.moved || Math.hypot(dx, dy) > 4\n // Capture only once it is a drag, so a plain press-release stays a click on the node.\n if (moved && !drag.moved) svgRef.current?.setPointerCapture?.(e.pointerId)\n setDrag({ ...drag, dx, dy, moved })\n }\n /** Ends a drag and reports the move in grid steps of `col` × `row` px. */\n const endDrag = (e: PointerEvent<SVGSVGElement>, col: number, row: number): void => {\n if (drag === undefined || e.pointerId !== drag.pointer) return\n setDrag(undefined)\n if (!drag.moved) return\n suppressUntil.current = Date.now() + 400\n const dCol = snap(drag.dx / col)\n const dRow = snap(drag.dy / row)\n if (dCol !== 0 || dRow !== 0) onMove?.(drag.id, dCol, dRow)\n }\n const cancelDrag = (): void => setDrag(undefined)\n\n /** The handlers of node `id`; `activate` runs on a click, Enter or Space. */\n const nodeHandlers = (id: string, activate: () => void) => {\n const onKey = (event: KeyboardEvent<SVGGElement>): void => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n activate()\n return\n }\n const step = ARROWS[event.key]\n if (onMove !== undefined && step !== undefined) {\n event.preventDefault()\n onMove(id, step[0], step[1])\n }\n }\n const onClick = (): void => {\n if (Date.now() < suppressUntil.current) return\n activate()\n }\n return { onClick, onKeyDown: onKey, onPointerDown: (e: PointerEvent<SVGGElement>) => startDrag(id, e) }\n }\n\n return { drag, moveDrag, endDrag, cancelDrag, nodeHandlers }\n}\n","import type { FocusEvent, PointerEvent } from 'react'\nimport { useId, useRef } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Edge, Hedge } from '../../engine/index.ts'\nimport { getVariable } from '../../engine/index.ts'\nimport { formatValue, valuesEqual } from '../../engine/values.ts'\nimport type { NodeToggle } from '../i18n/messages.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport type { Stochastic } from '../model/assignments.ts'\nimport type { PathMarks } from '../model/dsep-view.ts'\nimport { edgeTipText } from '../model/dsep-view.ts'\nimport { idWithName, probText, shortLabel } from '../model/wording.ts'\nimport { useDigits } from '../shared/digits.ts'\nimport { focusVisible } from '../shared/focus-visible.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { sub } from '../text/svg-text.tsx'\nimport { textWidth } from '../text/text-measure.ts'\nimport { Rich } from '../text/typeset.tsx'\nimport { BarChart } from './BarChart.tsx'\nimport { SWITCH_HALF, layoutSignalGraph } from './signal-geometry.ts'\nimport { EXO_INSET, arrowHead, clampPath, exoDash, nodeReadout } from './signal-shapes.ts'\nimport type { Block } from './signal-shapes.ts'\nimport { useNodeGestures } from './use-node-gestures.ts'\n\nexport interface SignalGraphProps {\n readonly c: LoadedCase\n readonly shown: readonly string[]\n /** Structural graph: show variable ids rather than readings and name arcs without a specific latent. */\n readonly structural?: boolean\n /** Identification failure: rings for F and F′, with the edges in F highlighted. */\n readonly hedge?: Hedge\n /** Deterministic world to draw (after any do). Omit in probability mode. */\n readonly values?: Assignment\n /** The world before do(), to note changed values. */\n readonly original?: Assignment\n /** Probability mode: P(V = 1) per variable. */\n readonly probs?: Readonly<Record<string, number>>\n /** Value mode: P(V = 1) under these nodes only (the do-calculus view's prediction); NaN when it is undefined. */\n readonly probe?: Readonly<Record<string, number>>\n /** Probability mode: P(V = value) in domain order for each non-boolean variable; drawn as one bar per value. */\n readonly dists?: Readonly<Record<string, readonly number[]>>\n /** Probability mode: a short note under each number. */\n readonly probNotes?: Readonly<Record<string, string>>\n /** Observed variables (drawn with a second ring). */\n readonly observed?: readonly string[]\n /** The observed values, written in a tag beside each observed node. */\n readonly observedValues?: Assignment\n /** The observations are counterfactual evidence: ringed, with no tag (a 實際 v note says it instead). */\n readonly evidence?: boolean\n readonly interventions: Assignment\n /** The text of a do() tag in place of `X←1`, per intervened variable: a mediator held at its natural value reads `Z←Z(X=0)`. */\n readonly tagText?: Readonly<Record<string, string>>\n /** Stochastic interventions: P*(X=1) of a boolean node, 0 < p < 1 (drawn like a do(), with that probability). */\n readonly stochastic?: Stochastic\n readonly removedEdges: readonly Edge[]\n /** Variables a witness holds fixed: an amber hull. */\n readonly witness?: Assignment\n /**\n * Each held variable says 固定為 w(實際 v) beside it when held away from its actual value, else\n * 固定(實際值), instead of the hull's 見證 tag (the playground: what is held need not be a witness).\n */\n readonly holdNotes?: boolean\n /** Default values (the model's normality): a node off its default says 偏離(預設 v) under its label. Graphs with values only. */\n readonly defaults?: Assignment\n /** d-separation: edges on an open path between the pair lit, edges only on blocked ones dashed, the two ends ringed. */\n readonly paths?: PathMarks\n /** Nodes drawn with the do() clamp but no value tag: the arrows into them are cut in a graph without numbers (do-calculus). */\n readonly clamped?: readonly string[]\n /** Nodes drawn with a dashed clamp: the arrows into them are cut for a test only, not by a do() of the expression (do-calculus rule 3). */\n readonly testClamped?: readonly string[]\n /**\n * Intervention switch nodes (`F_Z`, Pearl's regime indicator): each a small square labelled by its\n * id, beside the variable its one arrow points into. They must be in `c` and `shown`.\n */\n readonly switches?: readonly string[]\n /** Words read after a node's state in its label, e.g. its roles in a do-calculus step; not drawn. */\n readonly nodeNotes?: Readonly<Record<string, string>>\n /** A click (or Enter) on a variable picks it without opening a menu. */\n readonly onPick?: (id: string) => void\n /** With `onPick`, only these variables can be picked; the others are drawn as plain images. Default every variable. */\n readonly pickable?: readonly string[]\n /** With `onPick`, the hint a pickable node's label ends with, in place of the known-set one. */\n readonly pickHint?: string\n /** New variables (only in a conservative extension): a green ring around each. */\n readonly fresh?: readonly string[]\n /** A click (or Enter, Space) on a node or switch opens its menu, drawn by the caller. */\n readonly onOpen?: (id: string) => void\n /** The menu observes: an exogenous node, which do() cannot set, opens one only then. */\n readonly observable?: boolean\n /** The node whose menu is open (its `aria-expanded`). */\n readonly open?: string\n /** Nodes drawn with a soft halo: the ones a hovered slider feeds. */\n readonly lit?: readonly string[]\n /** The pointer (a mouse or pen) is over a node, or the keyboard focus is on it; undefined when it leaves. */\n readonly onHover?: (id: string | undefined) => void\n /** The marked edge (on a d-separation path, or cut by do()) whose explanation is shown, by key. */\n readonly edgeTip?: string\n /** A marked edge is hovered, focused or tapped: its explanation, or undefined to hide it. */\n readonly onEdgeTip?: (tip: EdgeTip | undefined) => void\n readonly title: string\n /** Narrower columns, for two graphs side by side. */\n readonly compact?: boolean\n /** Lets nodes be dragged (or moved with arrow keys); reports the move in grid columns and rows. */\n readonly onMove?: (id: string, dCol: number, dRow: number) => void\n}\n\n/** The explanation of a marked edge, shown by the caller beside `[data-edge=\"key\"]`. */\nexport interface EdgeTip {\n readonly key: string\n readonly text: string\n}\n\n/** Direction 1 「訊號圖」: value nodes, signal edges, do() clamps and cut edges. */\nexport function SignalGraph(props: SignalGraphProps) {\n const {\n c,\n shown,\n structural = false,\n hedge,\n values,\n original,\n probs,\n probe = {},\n dists,\n probNotes,\n observed = [],\n interventions,\n tagText,\n stochastic = {},\n removedEdges,\n witness,\n onMove,\n observedValues = {},\n evidence = false,\n holdNotes = false,\n defaults,\n paths,\n clamped = [],\n testClamped = [],\n switches = [],\n nodeNotes = {},\n onPick,\n pickable,\n pickHint,\n fresh = [],\n onOpen,\n observable = false,\n open,\n lit = [],\n onHover,\n edgeTip,\n onEdgeTip,\n } = props\n const t = useMessages()\n const digits = useDigits()\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, '')\n const svgRef = useRef<SVGSVGElement>(null)\n const { drag, moveDrag, endDrag, cancelDrag, nodeHandlers } = useNodeGestures(svgRef, onMove)\n /** Hover from a mouse or pen only: a tap is a click. */\n const hoverHandlers = (id: string) =>\n onHover === undefined\n ? {}\n : {\n onPointerEnter: (e: PointerEvent<SVGGElement>) => e.pointerType !== 'touch' && onHover(id),\n onPointerLeave: (e: PointerEvent<SVGGElement>) => e.pointerType !== 'touch' && onHover(undefined),\n onFocus: (e: FocusEvent<SVGGElement>) => focusVisible(e.currentTarget) && onHover(id),\n onBlur: () => onHover(undefined),\n }\n const layout = layoutSignalGraph(\n {\n c,\n shown,\n structural,\n values,\n original,\n probs,\n probe,\n dists,\n probNotes,\n observedValues,\n evidence,\n interventions,\n tagText,\n stochastic,\n removedEdges,\n witness,\n hedge,\n holdNotes,\n defaults,\n paths,\n clamped: [...clamped, ...testClamped],\n switches,\n compact: props.compact === true,\n drag,\n digits,\n },\n t,\n )\n const { prob, r: R, col: COL, row: ROW, pos, blocks, arcs, hull, left, top, width: viewW, height } = layout\n const barred = (id: string): boolean => prob && getVariable(c.model, id).domain.kind === 'finite'\n\n const nameOf = (id: string): string => shortLabel(c.model, id, t.locale)\n\n /** The pointer that pressed an edge last: a tap toggles its explanation, a mouse click only shows it. */\n const edgePointer = useRef<string>('mouse')\n /** A marked edge explains itself: on hover (mouse, pen) and keyboard focus, and on a tap, which toggles it. */\n const tipProps = (key: string, text: string | undefined) =>\n text === undefined || onEdgeTip === undefined\n ? {}\n : {\n tabIndex: 0,\n role: 'img',\n 'aria-label': text,\n 'data-tip': edgeTip === key ? 'open' : undefined,\n onPointerEnter: (e: PointerEvent<SVGGElement>) => e.pointerType !== 'touch' && onEdgeTip({ key, text }),\n onPointerLeave: (e: PointerEvent<SVGGElement>) => e.pointerType !== 'touch' && onEdgeTip(undefined),\n onPointerDown: (e: PointerEvent<SVGGElement>) => {\n edgePointer.current = e.pointerType\n },\n // A press focuses the edge too; only keyboard focus shows the tip, so a tap's click can toggle it.\n onFocus: (e: FocusEvent<SVGGElement>) => focusVisible(e.currentTarget) && onEdgeTip({ key, text }),\n onBlur: () => onEdgeTip(undefined),\n onClick: () => onEdgeTip(edgePointer.current === 'touch' && edgeTip === key ? undefined : { key, text }),\n }\n const pathTip = (key: string, onPath: 'open' | 'blocked' | undefined): string | undefined =>\n onPath === undefined || paths === undefined ? undefined : edgeTipText(t, paths, key, onPath)\n /** An invisible wide stroke over a marked edge, so a finger or pointer finds it. */\n const hit = (key: string, x1: number, y1: number, x2: number, y2: number, text: string | undefined) =>\n text === undefined || onEdgeTip === undefined ? null : <line key={`${key}-hit`} x1={x1} y1={y1} x2={x2} y2={y2} className=\"ca-edge-hit\" />\n\n const inF = (id: string): boolean => hedge?.f.includes(id) === true\n /** A block's texts sit on its middle line; one under or over its node writes no x. */\n const blockX = (block: Block): number | undefined => (block.cx === 0 ? undefined : block.cx)\n const edgeEls = layout.edges.map((edge) => {\n if (edge.kind === 'cut') {\n const { key, x1, y1, x2, y2, mx, my, ux, uy, label: cutLabel } = edge\n const [cutFrom = '', cutTo = ''] = edge.key.split('>')\n const tip = t.edgeTip.cut(cutFrom, cutTo)\n return (\n <g key={key} className=\"ca-edge ca-edge-cut\" data-edge={key} data-state=\"cut\" {...tipProps(key, tip)}>\n {hit(key, x1, y1, x2, y2, tip)}\n <line x1={x1} y1={y1} x2={mx - 10 * ux} y2={my - 10 * uy} className=\"ca-stroke-cut\" />\n <line x1={mx + 10 * ux} y1={my + 10 * uy} x2={x2} y2={y2} className=\"ca-stroke-cut\" />\n <path d={edge.slash} className=\"ca-stroke-slash\" />\n <text x={cutLabel.x} y={cutLabel.y} className=\"ca-svg-small ca-svg-bold\" textAnchor={cutLabel.anchor}>\n {t.cut}\n </text>\n </g>\n )\n }\n const { key, x1, y1, x2, y2, live, onPath, cls } = edge\n if (edge.kind === 'inhibit') {\n const { ux, uy, text, label: inhibitLabel } = edge\n const tip = pathTip(key, onPath)\n return (\n <g key={key} className=\"ca-edge\" data-edge={key} data-state={live ? 'live' : 'idle'} data-path={onPath} {...tipProps(key, tip)}>\n {hit(key, x1, y1, x2, y2, tip)}\n <line x1={x1} y1={y1} x2={x2} y2={y2} className={cls} />\n <circle cx={x2 + 5 * ux} cy={y2 + 5 * uy} r={5} className={`ca-inhibit ${live ? 'is-live' : ''}`} />\n <text x={inhibitLabel.x} y={inhibitLabel.y} className={`ca-svg-small ca-svg-bold ca-mono ${live ? '' : 'ca-fill-muted'}`}>\n {sub(text)}\n </text>\n </g>\n )\n }\n const tip = pathTip(key, onPath)\n const marked = key.split('>').every(inF)\n return (\n <g key={key} className=\"ca-edge\" data-edge={key} data-state={live ? 'live' : 'idle'} data-path={onPath} data-hedge-edge={marked ? '' : undefined} {...tipProps(key, tip)}>\n {hit(key, x1, y1, x2, y2, tip)}\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n className={cls}\n markerEnd={`url(#${uid}-${marked ? 'hedge' : onPath === 'open' ? 'open' : live ? 'live' : 'idle'})`}\n />\n </g>\n )\n })\n\n const arcEls = arcs.map(({ plan, label }) => {\n const key = `${plan.via}:${plan.a}-${plan.b}`\n const edgeKeys = [`${plan.via}>${plan.a}`, `${plan.via}>${plan.b}`]\n const onPath = edgeKeys.every((k) => paths?.open.has(k) === true)\n ? 'open'\n : edgeKeys.every((k) => paths?.open.has(k) === true || paths?.blocked.has(k) === true)\n ? 'blocked'\n : undefined\n const cls = `ca-stroke-arc${onPath === undefined ? '' : ` ca-path-${onPath}`}`\n const box = label.box\n return (\n <g key={key} className=\"ca-arc\" data-arc={key} data-path={onPath} data-hedge-edge={inF(plan.a) && inF(plan.b) ? '' : undefined}>\n <path d={`M${plan.start.x} ${plan.start.y}Q${plan.control.x} ${plan.control.y} ${plan.end.x} ${plan.end.y}`} className={cls} />\n <path d={arrowHead(plan.start, plan.start.x - plan.control.x, plan.start.y - plan.control.y)} className=\"ca-arc-head ca-fill-fg\" />\n <path d={arrowHead(plan.end, plan.end.x - plan.control.x, plan.end.y - plan.control.y)} className=\"ca-arc-head ca-fill-fg\" />\n <text x={label.x} y={label.y} textAnchor=\"middle\" className=\"ca-svg-small ca-fill-muted\" aria-hidden=\"true\">\n {t.arc.label}\n </text>\n <foreignObject className=\"ca-arc-tip-box\" x={box.x0} y={box.y0} width={box.x1 - box.x0} height={box.y1 - box.y0}>\n <Tip tip={structural ? t.identify.arc : <Rich text={t.arc.tip(plan.via, plan.a, plan.b)} ids={c.model.byId} />} className=\"ca-arc-tip\">\n <span className=\"ca-arc-hit\">{t.arc.label}</span>\n </Tip>\n </foreignObject>\n </g>\n )\n })\n\n const nodeEls = shown.map((id) => {\n const p = pos.get(id)\n const block = blocks.get(id)\n if (p === undefined || block === undefined) return null\n if (switches.includes(id)) {\n const aria = t.withHint(idWithName(id, nameOf(id)), nodeNotes[id] ?? '')\n const S = SWITCH_HALF\n return (\n <g\n key={id}\n className={`ca-node ca-switch${onOpen !== undefined ? ' is-interactive' : ''}`}\n data-node={id}\n data-switch=\"true\"\n data-block={block.side}\n transform={`translate(${p.x} ${p.y})`}\n {...(onOpen !== undefined\n ? { role: 'button', tabIndex: 0, 'aria-haspopup': 'dialog', 'aria-expanded': open === id, 'aria-label': t.withHint(aria, t.nodeHint('switch', false)), ...nodeHandlers(id, () => onOpen(id)) }\n : { role: 'img', 'aria-label': aria })}\n {...hoverHandlers(id)}\n >\n <circle r={S + 12} className=\"ca-focus-ring\" />\n {open === id && <circle r={S + 12} className=\"ca-open-ring\" />}\n {observed.includes(id) && <rect x={-S - 4} y={-S - 4} width={2 * S + 8} height={2 * S + 8} className=\"ca-ring\" />}\n {paths?.ends.includes(id) === true && <circle r={S + 8 + (observed.includes(id) ? 4 : 0)} className=\"ca-dsep-ring\" data-dsep-end={id} />}\n <rect x={-S} y={-S} width={2 * S} height={2 * S} className=\"ca-switch-box\" />\n <text x={blockX(block)} y={block.labelY} textAnchor=\"middle\" className=\"ca-svg-label\">\n <tspan className=\"ca-mono ca-svg-bold\">{sub(id)}</tspan>\n </text>\n </g>\n )\n }\n const variable = getVariable(c.model, id)\n const v = values?.[id]\n const forced = interventions[id]\n const soft = stochastic[id]\n const intervened = forced !== undefined || soft !== undefined\n const held = witness !== undefined && id in witness\n const boolean = variable.domain.kind === 'boolean'\n const filled = !prob && v === true\n const text = v === undefined ? '' : formatValue(v)\n const before = original?.[id]\n const changed = !prob && before !== undefined && v !== undefined && !valuesEqual(before, v)\n const name = nameOf(id)\n const who = idWithName(id, name)\n const pv = probs?.[id]\n // A non-boolean node shows one bar per value, so each value gets its own number.\n const bars = barred(id) && variable.domain.kind === 'finite' ? variable.domain.values : undefined\n const dist = dists?.[id]\n const barText = (i: number): string => `P(${id}=${formatValue((bars ?? [])[i])})=${probText(dist?.[i] ?? Number.NaN, digits)}`\n const state = prob\n ? bars !== undefined\n ? bars.map((_, i) => barText(i)).join(', ')\n : `P(${id}=1) ${probText(pv ?? Number.NaN, digits)}`\n : id in probe\n ? `P(${id}=1) ${probText(probe[id], digits)}`\n : t.nodeValue(text)\n const readout = id in probe && !prob ? nodeReadout(t, digits, probe[id], undefined, undefined) : nodeReadout(t, digits, pv, forced, evidence ? undefined : observedValues[id])\n const forcedText = forced !== undefined ? (tagText?.[id] ?? formatValue(forced)) : soft !== undefined ? `P(${id}=1)=${probText(soft, digits)}` : undefined\n const seen = observedValues[id]\n const aria = t.withHint(\n t.nodeAria(who, state, forcedText, changed ? formatValue(before) : undefined, seen === undefined ? undefined : formatValue(seen)),\n nodeNotes[id] ?? '',\n )\n // An exogenous node is the context: it can be observed, never set by do().\n const opens = onPick === undefined && onOpen !== undefined && (variable.kind === 'endogenous' || observable)\n const picks = onPick !== undefined && (pickable === undefined || pickable.includes(id))\n const interactive = opens || onMove !== undefined || picks\n const activate = (): void => {\n if (onPick !== undefined) {\n if (picks) onPick(id)\n } else onOpen?.(id)\n }\n const toggle: NodeToggle | undefined = picks ? 'pick' : !opens ? undefined : observable ? (variable.kind === 'exogenous' ? 'observe' : 'observeOrDo') : 'do'\n const hint = picks && pickHint !== undefined ? t.withHint(pickHint, onMove !== undefined ? t.nodeHint(undefined, true) : '') : t.nodeHint(toggle, onMove !== undefined)\n // An exogenous node is a dashed ring with its value or fill a little inside it.\n const exo = variable.kind === 'exogenous'\n const inner = exo ? R - EXO_INSET : R\n const level = prob && pv !== undefined && !Number.isNaN(pv) ? 2 * inner * pv : 0\n const tag = layout.tags.get(id)\n const hold = layout.holdNotes.get(id)\n // A long name the layout wrapped: its first part beside the id, the rest on a second line.\n const lines = layout.labelLines.get(id)\n const deviant = layout.deviantNotes.get(id)\n const was = layout.wasNotes.get(id)\n return (\n <g\n key={id}\n className={`ca-node${interactive ? ' is-interactive' : ''}${onMove !== undefined ? ' is-movable' : ''}`}\n data-node={id}\n data-value={text}\n data-intervened={intervened ? 'true' : 'false'}\n data-observed={seen === undefined ? undefined : formatValue(seen)}\n data-do-p={soft === undefined ? undefined : soft.toFixed(2)}\n data-block={block.side}\n transform={`translate(${p.x} ${p.y})`}\n {...(interactive\n ? {\n role: 'button',\n tabIndex: 0,\n 'aria-haspopup': opens ? 'dialog' : undefined,\n 'aria-expanded': opens ? open === id : undefined,\n 'aria-label': t.withHint(aria, hint),\n ...nodeHandlers(id, activate),\n }\n : { role: 'img', 'aria-label': aria })}\n {...hoverHandlers(id)}\n >\n {inF(id) && <circle r={R + 9} className=\"ca-hedge-ring\" data-hedge=\"f\" data-member={id} />}\n {hedge?.fPrime.includes(id) === true && <circle r={R + 16} className=\"ca-hedge-inner\" data-hedge=\"f-prime\" data-member={id} />}\n {lit.includes(id) && <circle r={R + 14} className=\"ca-lit-ring\" data-lit={id} />}\n {fresh.includes(id) && <circle r={R + 7} className=\"ca-new-ring\" data-new={id} />}\n <circle r={R + 12} className=\"ca-focus-ring\" />\n {open === id && <circle r={R + 12} className=\"ca-open-ring\" />}\n {observed.includes(id) && <circle r={R + 5} className=\"ca-ring\" />}\n {paths?.ends.includes(id) === true && <circle r={R + 9} className=\"ca-dsep-ring\" data-dsep-end={id} />}\n {prob ? (\n <>\n <clipPath id={`${uid}-cp-${id}`}>\n <circle r={inner} />\n </clipPath>\n <circle r={R} className=\"ca-fill-bg\" />\n {bars === undefined && (\n <rect\n x={-inner}\n y={inner - level}\n width={2 * inner}\n height={level}\n className=\"ca-fill-fg\"\n clipPath={`url(#${uid}-cp-${id})`}\n data-level={pv === undefined ? '' : pv.toFixed(4)}\n />\n )}\n <circle r={R} className={`ca-node-outline${exo ? ' ca-exo' : ''}`} strokeDasharray={exo ? exoDash(R) : undefined} />\n </>\n ) : (\n <>\n {exo ? (\n <>\n <circle r={R} className=\"ca-node-off ca-exo\" strokeDasharray={exoDash(R)} />\n {filled && <circle r={inner} className=\"ca-fill-fg ca-exo-core\" />}\n </>\n ) : (\n <circle r={R} className={filled ? 'ca-node-on' : 'ca-node-off'} />\n )}\n <text\n y={boolean ? 7.5 : 5}\n textAnchor=\"middle\"\n className={`ca-mono ca-svg-bold ${filled ? 'ca-fill-bg-text' : ''}`}\n fontSize={structural ? 14 : boolean || text.length <= 2 ? 21 : 13}\n >\n {structural ? sub(id) : text}\n </text>\n </>\n )}\n {!intervened && testClamped.includes(id) && <path d={clampPath(R)} className=\"ca-stroke-clamp ca-clamp-test\" data-clamp=\"test\" />}\n {((intervened && !held) || (!intervened && clamped.includes(id))) && (\n <>\n <path d={clampPath(R)} className={tag?.reset ? 'ca-stroke-reset' : 'ca-stroke-clamp'} />\n {intervened && tag !== undefined && (\n <g transform={`translate(${tag.box.x0} ${tag.box.y0})`}>\n <rect width={tag.box.x1 - tag.box.x0} height={22} className={tag.reset ? 'ca-fill-reset' : 'ca-fill-accent'} />\n <text\n x={(tag.box.x1 - tag.box.x0) / 2}\n y={15.5}\n textAnchor=\"middle\"\n className=\"ca-mono ca-svg-small ca-svg-bold ca-fill-on-accent\"\n >\n {sub(tag.text)}\n </text>\n </g>\n )}\n </>\n )}\n {!intervened && tag !== undefined && tag.seen && (\n <g transform={`translate(${tag.box.x0} ${tag.box.y0})`} className=\"ca-seen-tag\">\n <rect width={tag.box.x1 - tag.box.x0} height={22} className=\"ca-seen-tag-box\" />\n <text x={(tag.box.x1 - tag.box.x0) / 2} y={15.5} textAnchor=\"middle\" className=\"ca-mono ca-svg-small ca-svg-bold\">\n {sub(tag.text)}\n </text>\n </g>\n )}\n {hold !== undefined ? (\n <text x={blockX(block)} y={block.noteY} textAnchor=\"middle\" className=\"ca-svg-small ca-svg-bold ca-fill-amber\" data-held={id}>\n {hold}\n </text>\n ) : (\n was !== undefined && (\n <text x={was.x} y={was.y} textAnchor={was.anchor} className=\"ca-svg-small ca-fill-muted\">\n {was.text}\n </text>\n )\n )}\n {deviant !== undefined && (\n <g className=\"ca-deviant\" data-deviant={id}>\n <rect\n x={block.cx - (textWidth(deviant ?? '', 11) + 8) / 2}\n y={block.note2Y - 11}\n width={textWidth(deviant ?? '', 11) + 8}\n height={15}\n className=\"ca-deviant-box\"\n />\n <text x={blockX(block)} y={block.note2Y} textAnchor=\"middle\" className=\"ca-svg-tiny ca-svg-bold\">\n {deviant}\n </text>\n </g>\n )}\n <text x={blockX(block)} y={block.labelY} textAnchor=\"middle\" className=\"ca-svg-label\">\n {!structural && <tspan className=\"ca-mono ca-svg-bold\">{sub(id)}</tspan>}\n {lines !== undefined ? (\n <>\n {structural ? lines[0] : ` ${lines[0]}`}\n <tspan x={block.cx} y={block.label2Y}>\n {lines[1]}\n </tspan>\n </>\n ) : name === '' ? null : structural ? name : ` ${name}`}\n </text>\n {bars !== undefined\n ? <BarChart id={id} labels={bars.map(formatValue)} dist={dist} block={block} barText={barText} />\n : (prob || id in probe) && (\n <text x={blockX(block)} y={block.numberY} textAnchor=\"middle\" className=\"ca-mono ca-svg-num\">\n {readout.prefix !== '' && <tspan className=\"ca-svg-small ca-fill-muted\">{readout.prefix}</tspan>}\n <tspan data-readout={id} fontSize={readout.settled ? 14 : undefined}>\n {readout.text}\n </tspan>\n </text>\n )}\n {prob && (!readout.settled || evidence) && probNotes?.[id] !== undefined && hold === undefined && (\n <text x={blockX(block)} y={block.noteY} textAnchor=\"middle\" className=\"ca-svg-small ca-fill-muted\" data-note={id}>\n {probNotes[id]}\n </text>\n )}\n </g>\n )\n })\n\n return (\n <svg\n ref={svgRef}\n onPointerMove={onMove === undefined ? undefined : moveDrag}\n onPointerUp={onMove === undefined ? undefined : (e) => endDrag(e, COL, ROW)}\n onPointerCancel={onMove === undefined ? undefined : cancelDrag}\n className=\"ca-graph\"\n viewBox={`${left} ${top} ${viewW} ${height}`}\n width={viewW}\n height={height}\n role=\"group\"\n aria-label={props.title}\n data-mode={prob ? 'probability' : 'value'}\n >\n <defs>\n <marker id={`${uid}-live`} viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"6.5\" markerHeight=\"6.5\" orient=\"auto\">\n <path d=\"M0 0.5L10 5L0 9.5z\" className=\"ca-fill-fg\" />\n </marker>\n <marker id={`${uid}-open`} viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"6.5\" markerHeight=\"6.5\" orient=\"auto\">\n <path d=\"M0 0.5L10 5L0 9.5z\" className=\"ca-fill-accent\" />\n </marker>\n {hedge !== undefined && <marker id={`${uid}-hedge`} viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"6.5\" markerHeight=\"6.5\" orient=\"auto\">\n <path d=\"M0 0.5L10 5L0 9.5z\" className=\"ca-hedge-arrow\" />\n </marker>}\n <marker id={`${uid}-idle`} viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\">\n <path d=\"M0 0.5L10 5L0 9.5z\" className=\"ca-fill-idle\" />\n </marker>\n </defs>\n {hull !== undefined && (\n <g className=\"ca-witness\" data-witness={Object.keys(witness ?? {}).join(',')}>\n <rect x={hull.x} y={hull.y} width={hull.w} height={hull.h} className=\"ca-hull\" />\n {!holdNotes && (\n <g transform={`translate(${hull.x} ${hull.y + hull.h + 6})`}>\n <rect width={textWidth(hull.text, 12) + 18} height={22} className=\"ca-amber-tag\" />\n <text x={8} y={15.5} className=\"ca-svg-small ca-svg-bold ca-fill-amber\">\n {sub(hull.text)}\n </text>\n </g>\n )}\n </g>\n )}\n {edgeEls}\n {arcEls}\n {nodeEls}\n </svg>\n )\n}\n"],"mappings":";;;;;;AAmCA,SAAgBkC,EAAS,GAAe,GAAgB,GAAsB,GAA2B,GAAkC;CACzI,IAAIC,EAAE,UAAU,KAAA,GAAW,MAAU,MAAM,GAAGA,EAAE,KAAK,GAAG,2BAA2B;CACnF,IAAM,CAACC,GAAGC,KAAKC,GACTC,IAAM,CAAC,GAAG,OAAO,KAAKC,CAAa,GAAG,GAAG,OAAO,KAAKC,CAAU,CAAC,GAChEC,IAASrC,EAAY8B,EAAE,OAAOC,GAAGC,GAAG,OAAO,KAAKM,CAAQ,GAAGJ,CAAG,GAC9DK,IAAQ1C,EAAWiC,EAAE,OAAOA,EAAE,OAAOC,GAAGC,GAAGM,GAAUH,GAAeC,CAAU,GAC9EI,KAAO,MAA4C,GAAG,EAAE,KAAK,GAAG,EAAE,MAClEC,IAAO,IAAI,IAAIJ,EAAO,MAAM,QAAQ,MAAMK,EAAE,IAAI,CAAC,CAAC,SAAS,MAAMA,EAAE,MAAM,IAAIF,CAAG,CAAC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