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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CausalPlayground-Cd7Sok3F.js","names":["_Fragment","_Fragment","_Fragment","_Fragment","parseCause","evaluateDecision","getVariable","ModelError","evaluate","formatValue","coerceToDomain","valuesEqual","blame","authorYearEn","DEFAULT_URL","watermarkLine","authorYear","DATA_LICENSE","parsePdo","parseDo","formatPdo","formatDo","LocaleScope","useMessages","messagesFor","solve","priorWithSliders","sliderVariables","defaultSliders","useModel","fixed","degreeText","normalityLine","actualGroups","originSources","originCitations","MathProse","Formula","Rich","assignmentText","readingText","DigitsScope","probText","defaultTheories","sameAssignment","useCaseOrDoc","witnessNow","CaseGate","casesOf","pathReason","dsepView","pathText","deltaText","cfText","nodeSliders","sliderTargets","SliderList","EquationPanel","GraphBox","Tip","Segmented","DocProblems","ExpectedUtility","priorOf","decisionProblem","problem","Fragment$1","param","name","hash","embedFragment","parts","d","state","p","o","readEmbedState","embedSrc","url","src","locale","from","escapeAttr","text","escapeText","embedCode","m","origins","title","height","embedHome","search","fallback","origin","endogenous","out","id","value","a","v","c","fitEmbedState","interventions","stochastic","observed","heightAtInitialBlock","root","panels","was","initial","i","euText","s","eu","int","frac","grouped","DecisionBars","t","prior","raw","result","b","actText","all","lo","hi","span","at","zero","seen","done","rows","eus","theory","choice","best","rest","ch","by","lit","utilityLines","r","line","left","width","DsepLine","ids","view","shown","known","pair","defaultBlameTheories","degreeNumber","x","blameView","given","spec","own","theories","results","PlaygroundBlame","causeText","cause","effect","row","cell","NONE","decisionFor","decision","sliderStart","sliders","settable","checkVerdicts","verdicts","isPair","dsep","dsepPairs","pairs","y","checkTrack","track","activeQuery","actual","size","queries","q","presetButtons","presets","hold","PlaygroundVerdicts","query","active","groups","g","onShow","trailEntry","values","world","trailText","steps","trail","e","dropped","useTrail","startTrail","setTrail","useState","setting","entries","CausalPlayground","props","PlaygroundBody","resolved","doc","PlaygroundFor","base","NO_TRACK","startPrior","start","useMemo","sliderValues","setSliderValues","focused","focusSliders","hidden","allSliders","setAllSliders","reading","setReading","initialInterventions","defaultNotation","switchReading","next","kept","setObserved","useRef","hoverNode","setHoverNode","hoverSlider","setHoverSlider","litNodes","litSliders","setSlider","now","moved","resetSliders","restartTrail","sliderId","useId","embedded","setDo","held","setHeld","soft","buttons","prob","defaults","normality","pairAt","setPairAt","dsepNow","blamed","shownQuery","setShownQuery","holding","stepIndex","setStepIndex","step","required","applyPreset","within","part","holds","pressedSize","pressed","embedUrl","caseId","blocks","setNotation","initialBlock","embed","exportUrl","openPanel","EmbedCredit","noSubscription","home","useSyncExternalStore"],"sources":["../../src/components/export/embed.ts","../../src/components/shared/tab-height.ts","../../src/components/playground/DecisionBars.tsx","../../src/components/playground/DsepLine.tsx","../../src/components/playground/blame-view.ts","../../src/components/playground/PlaygroundBlame.tsx","../../src/components/playground/playground-options.ts","../../src/components/playground/PlaygroundVerdicts.tsx","../../src/components/playground/trail.ts","../../src/components/playground/use-trail.ts","../../src/components/playground/CausalPlayground.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Value } from '../../engine/index.ts'\nimport { coerceToDomain } from '../../engine/index.ts'\nimport { DATA_LICENSE, DEFAULT_URL, authorYear, authorYearEn } from './cite.ts'\nimport { formatDo, formatPdo, parseDo, parsePdo } from './url-state.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { messagesFor } from '../i18n/messages.ts'\nimport { solve } from '../model/model-state.ts'\nimport type { Stochastic } from '../model/assignments.ts'\n\n/**\n * An embedded figure's state in its address: `#do=<id>:<value>,…&pdo=<id>:<p>,…&obs=<id>:<value>,…`,\n * the same encoding as the editor's `do=` and `pdo=`.\n */\nexport interface EmbedState {\n readonly interventions: Assignment\n readonly stochastic: Stochastic\n readonly observed: Assignment\n}\n\n/** Where a bundled case's embed page lives by default: `<base>case/<id>/`. */\nexport const DEFAULT_EMBED_BASE = 'https://wayneh.tw/causal/embed/'\n\nfunction param(hash: string, name: string): string | undefined {\n return new RegExp(`[#?&]${name}=([^&]*)`).exec(hash)?.[1]\n}\n\n/** The state part of an embed address, without `#`; '' when nothing is set. */\nexport function embedFragment(state: EmbedState): string {\n const parts: string[] = []\n const d = formatDo(state.interventions)\n const p = formatPdo(state.stochastic)\n const o = formatDo(state.observed)\n if (d !== '') parts.push(`do=${d}`)\n if (p !== '') parts.push(`pdo=${p}`)\n if (o !== '') parts.push(`obs=${o}`)\n return parts.join('&')\n}\n\n/** Reads `embedFragment`'s text from a hash; numerals become numbers (coerced to each domain by the reader). */\nexport function readEmbedState(hash: string): EmbedState {\n const d = param(hash, 'do')\n const p = param(hash, 'pdo')\n const o = param(hash, 'obs')\n return {\n interventions: d === undefined ? {} : parseDo(d),\n stochastic: p === undefined ? {} : parsePdo(p),\n observed: o === undefined ? {} : parseDo(o),\n }\n}\n\n/**\n * The embed page's address: `src`, with `lang=en` for an English figure, `from` (the page the figure\n * was copied from) and the state.\n */\nexport function embedSrc(src: string, state: EmbedState, from?: string, locale?: Locale): string {\n const url = new URL(src)\n if (locale === 'en') url.searchParams.set('lang', 'en')\n if (from !== undefined && from !== '') url.searchParams.set('from', from)\n const fragment = embedFragment(state)\n url.hash = fragment\n return url.toString()\n}\n\nfunction escapeAttr(text: string): string {\n return text.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>')\n}\n\nfunction escapeText(text: string): string {\n return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')\n}\n\nexport interface EmbedCodeOptions {\n readonly src: string\n readonly title: string\n readonly height: number\n readonly locale: Locale\n /** Link in the citation. Default: the project repository. */\n readonly url?: string\n /** Full citations of the case's origin sources, cited after the project. */\n readonly origins?: readonly string[]\n}\n\n/**\n * What a reader pastes to embed the figure: the iframe, then the citation as it is given for the\n * academic image (author-year, licence, the case's own sources), so the credit stays beside it.\n */\nexport function embedCode({ src, title, height, locale, url = DEFAULT_URL, origins = [] }: EmbedCodeOptions): string {\n const m = messagesFor(locale).export\n const cite = locale === 'en' ? authorYearEn(url) : authorYear(url)\n const parts = [cite, m.embedLicence(DATA_LICENSE), ...(origins.length === 0 ? [] : [m.embedSources(origins)])]\n return [\n `<iframe src=\"${escapeAttr(src)}\" title=\"${escapeAttr(m.embedTitle(title))}\" width=\"100%\" height=\"${Math.round(height)}\" style=\"border:0;max-width:100%\" loading=\"lazy\"></iframe>`,\n `<p>${escapeText(parts.join(' '))}</p>`,\n ].join('\\n')\n}\n\n/**\n * Where an embedded figure's credit links: `from` when it is a path on the embed page's own site\n * (the page the figure was copied from), else the project page.\n */\nexport function embedHome(search: string, origin: string, fallback: string = 'https://wayneh.tw/causal/'): string {\n const from = new URLSearchParams(search).get('from')\n if (from === null || !from.startsWith('/') || from.startsWith('//')) return fallback\n return `${origin}${from}`\n}\n\nfunction endogenous(c: LoadedCase, a: Assignment): Assignment {\n const out: Record<string, Value> = {}\n for (const [id, value] of Object.entries(a)) {\n const v = c.model.byId.get(id)\n if (v === undefined || v.kind === 'exogenous') continue\n try {\n out[id] = coerceToDomain(v, value)\n } catch {\n try {\n // A numeral read from the address may name a text value, e.g. '2'.\n if (typeof value === 'number') out[id] = coerceToDomain(v, String(value))\n } catch {\n // dropped: not a value of this variable\n }\n }\n }\n return out\n}\n\n/**\n * The part of an embed address's state that fits the case: endogenous variables with values in\n * their domains; stochastic interventions and observations only when the case is drawn with\n * probabilities, on nodes not set otherwise; observations dropped when they cannot happen.\n */\nexport function fitEmbedState(c: LoadedCase, state: EmbedState): EmbedState {\n const interventions = endogenous(c, state.interventions)\n if (c.context !== undefined) return { interventions, stochastic: {}, observed: {} }\n const stochastic: Record<string, number> = {}\n for (const [id, p] of Object.entries(state.stochastic)) {\n const v = c.model.byId.get(id)\n if (v === undefined || v.kind === 'exogenous' || v.domain.kind !== 'boolean' || id in interventions || !(p > 0 && p < 1)) continue\n stochastic[id] = p\n }\n const observed: Record<string, Value> = {}\n for (const [id, value] of Object.entries(endogenous(c, state.observed))) {\n if (!(id in interventions) && !(id in stochastic)) observed[id] = value\n }\n if (Object.keys(observed).length > 0 && !((solve(c, interventions, stochastic, observed).evidence ?? 1) > 0)) {\n return { interventions, stochastic, observed: {} }\n }\n return { interventions, stochastic, observed }\n}\n","/**\n * The height of `root` as an embed page draws it: with only the `initial` block open (none when\n * undefined), whatever the reader has open now. Panels are unhidden and hidden again in the same\n * task, so nothing is painted in between.\n */\nexport function heightAtInitialBlock(root: HTMLElement | null, initial: string | undefined, fallback: number): number {\n if (root === null) return fallback\n const panels = [...root.querySelectorAll<HTMLElement>('[data-tab-panel]')]\n const was = panels.map((p) => p.hidden)\n for (const p of panels) p.hidden = p.dataset.tabPanel !== initial\n const height = root.offsetHeight\n panels.forEach((p, i) => {\n p.hidden = was[i]\n })\n return height\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, DecisionProblem, Value } from '../../engine/index.ts'\nimport { evaluateDecision, formatValue, getVariable, valuesEqual } from '../../engine/index.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { Formula, Rich } from '../text/typeset.tsx'\nimport { ExpectedUtility } from '../text/ExpectedUtility.tsx'\nimport { fixed } from '../model/wording.ts'\n\nexport interface DecisionBarsProps {\n readonly c: LoadedCase\n readonly problem: DecisionProblem\n /** The act observed lights its evidential bar; the act set by do() its causal bar. */\n readonly observed: Assignment\n readonly interventions: Assignment\n}\n\n/** An expected utility as the bars write it: two decimals, a true minus, thousands grouped from 1,000. */\nfunction euText(eu: number): string {\n const s = fixed(eu, 2)\n const [int, frac] = s.replace('-', '').split('.')\n const grouped = Math.abs(eu) >= 1000 ? int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',') : int\n return `${eu < 0 && s !== '-0.00' ? '−' : ''}${grouped}.${frac}`\n}\n\n/**\n * Expected utility of each act, one row per theory (evidential, causal) and one bar per act on a\n * shared zero, with the act each picks and by how much. Observing the act lights its evidential\n * bar (its weights are what the graph now shows); do() on it lights its causal bar.\n */\nexport function DecisionBars({ c, problem, observed, interventions }: DecisionBarsProps) {\n const t = useMessages()\n const prior = c.prior\n if (prior === undefined) throw new Error(`${c.data.id}: decision needs probabilities`)\n const raw = evaluateDecision(c.model, prior, problem)\n // A boolean act reads 1 first, as the nodes do; listed acts keep their order.\n const boolAct = problem.acts === undefined && getVariable(c.model, problem.act).domain.kind === 'boolean'\n const result = boolAct ? { ...raw, acts: [...raw.acts].sort((a, b) => Number(b.act === true) - Number(a.act === true)) } : raw\n const actText = (a: Value): string => `${problem.act}=${formatValue(a)}`\n const all = result.acts.flatMap((a) => [a.cdt.eu, ...(a.edt === undefined ? [] : [a.edt.eu])])\n const lo = Math.min(0, ...all)\n const hi = Math.max(0, ...all)\n const span = hi - lo > 0 ? hi - lo : 1\n const at = (v: number): number => ((v - lo) / span) * 100\n const zero = at(0)\n const seen = observed[problem.act]\n const done = interventions[problem.act]\n const rows = (['edt', 'cdt'] as const).map((theory) => {\n const eus = result.acts.map((a) => (theory === 'edt' ? a.edt?.eu : a.cdt.eu))\n const choice = theory === 'edt' ? result.edtChoice : result.cdtChoice\n const best = Math.max(...eus.filter((e): e is number => e !== undefined))\n const rest = eus.filter((e, i): e is number => e !== undefined && !choice.some((ch) => valuesEqual(ch, result.acts[i].act)))\n const by = choice.length === 1 && rest.length > 0 ? euText(best - Math.max(...rest)) : undefined\n const lit = theory === 'edt' ? seen : done\n return { theory, eus, choice: t.ev.choose(t.list(choice.map(actText)), by), lit }\n })\n const utilityLines = problem.utility.rows.map(\n (r) => `U(${problem.utility.variables.map((id, i) => `${id}=${formatValue(r.when[i])}`).join(', ')}) = ${fixed(r.utility, 2).replace(/\\.00$/, '')}`,\n )\n return (\n <div className=\"ca-ev\" style={{ ['--ca-ev-acts' as string]: result.acts.length }}>\n <p className=\"ca-ev-head\">\n <span className=\"ca-pg-now-kicker\">{t.ev.title}</span>{' '}\n <Tip\n label={t.moreInfo}\n tip={\n <>\n {utilityLines.map((line, i) => <span key={line}>{i > 0 && t.clauses(['', ''])}<Formula text={line} /></span>)}\n <br />\n <ExpectedUtility theory=\"EDT\" />{t.eu.edt}\n <br />\n <ExpectedUtility theory=\"CDT\" />{t.eu.cdt}\n </>\n }\n />\n </p>\n <div className=\"ca-ev-grid\" role=\"table\" aria-label={t.ev.title}>\n <div className=\"ca-ev-row ca-ev-acts\" role=\"row\">\n <span role=\"columnheader\" />\n {result.acts.map((a) => (\n <span key={String(a.act)} role=\"columnheader\" className=\"ca-ev-act ca-mono\">\n <Rich text={actText(a.act)} ids={c.model.byId} />\n </span>\n ))}\n <span role=\"columnheader\" />\n </div>\n {rows.map((r) => (\n <div key={r.theory} className=\"ca-ev-row\" role=\"row\" data-ev-row={r.theory}>\n <span role=\"rowheader\" className=\"ca-ev-name\">\n {t.ev[r.theory]}\n </span>\n {result.acts.map((a, i) => {\n const v = r.eus[i]\n const lit = r.lit !== undefined && valuesEqual(r.lit, a.act)\n const left = v === undefined ? zero : Math.min(zero, at(v))\n const width = v === undefined ? 0 : Math.abs(at(v) - zero)\n return (\n <span key={String(a.act)} role=\"cell\" className=\"ca-ev-cell\" data-ev-act={formatValue(a.act)} data-lit={lit ? 'true' : undefined}>\n <span\n className=\"ca-ev-num ca-mono\"\n data-ev-value={v === undefined ? '—' : fixed(v, 2)}\n style={{ left: `${left}%`, width: `${width}%`, textAlign: v !== undefined && v < 0 ? 'right' : 'left' }}\n >\n {v === undefined ? '—' : euText(v)}\n </span>\n <span className=\"ca-ev-track\">\n <span className=\"ca-ev-zero\" style={{ left: `${zero}%` }} />\n {v !== undefined && <span className=\"ca-ev-bar\" style={{ left: `${left}%`, width: `${width}%` }} />}\n </span>\n </span>\n )\n })}\n <span role=\"cell\" className=\"ca-ev-choice\">\n <Rich text={r.choice} ids={c.model.byId} />\n </span>\n </div>\n ))}\n </div>\n </div>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment } from '../../engine/index.ts'\nimport type { DsepPair, DsepView } from '../model/dsep-view.ts'\nimport { MAX_PATHS, deltaText, pathReason, pathText } from '../model/dsep-view.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { Formula, MathProse, Rich } from '../text/typeset.tsx'\n\n/** The line under the graph: the pair, what is known, open or blocked, δ, and up to three paths with why. */\nexport function DsepLine({ c, pair, observed, view }: { readonly c: LoadedCase; readonly pair: DsepPair; readonly observed: Assignment; readonly view: DsepView }) {\n const t = useMessages()\n const d = t.dsep\n const ids = c.model.byId\n const { result } = view\n const shown = result.paths.slice(0, MAX_PATHS)\n const known = Object.keys(observed)\n return (\n <div className=\"ca-dsep-line\" data-dsep={result.separated ? 'blocked' : 'open'}>\n <p className=\"ca-dsep-head\">\n <span className=\"ca-pg-now-kicker\"><Rich text={d.pair(pair[0], pair[1])} ids={ids} /></span>{' '}\n <Rich text={d.known(known)} ids={ids} /> → <strong>{result.separated ? d.blocked : d.open}</strong>\n{' '}\n <span className=\"ca-dsep-delta ca-mono\">{d.delta(deltaText(view.delta))}</span> <Tip tip={<MathProse text={d.tip} math={{ '|P(x,y|z) − P(x|z)P(y|z)|': '\\\\left|P(x,y\\\\mid z)-P(x\\\\mid z)P(y\\\\mid z)\\\\right|' }} />} label={t.moreInfo} />\n </p>\n <ul className=\"ca-dsep-paths\">\n {result.paths.length === 0 && <li>{d.noPath}</li>}\n {shown.map((p) => (\n <li key={p.nodes.join('-')} data-path-open={p.open ? 'true' : 'false'}>\n <Formula text={pathText(p)} ids={ids} />\n {d.pathSep}\n <Rich text={pathReason(t, p)} ids={ids} />\n </li>\n ))}\n {result.paths.length > MAX_PATHS && <li>{d.more(result.paths.length - MAX_PATHS)}</li>}\n </ul>\n </div>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport { priorOf } from '../../data/load.ts'\nimport type { ModelDoc } from '../../data/schema.ts'\nimport type { BlameResult, LocalizedText, Prior, ResponsibilityTheory } from '../../engine/index.ts'\nimport { blame, ModelError, parseCause, problem } from '../../engine/index.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { cfText } from '../probability/cf-steps.ts'\n\n/** Pure helpers for the playground's 責備 block: Halpern's degree of blame (2016, Def. 6.2.1) per epistemic state and standard. */\n\n/** One epistemic state: the probabilities the agent has (a model document's `priors`), and what has been observed since. */\nexport interface BlameState {\n /** What the state is called in the table; default `文件裡的機率` / \"The document's probabilities\". */\n readonly label?: string | LocalizedText\n /** The state's probabilities in the model document's `priors` format; default the document's own. */\n readonly prior?: NonNullable<ModelDoc['priors']>\n /** An observation that narrows the state, e.g. `D=1` (the outcome seen after acting). */\n readonly given?: string\n}\n\n/** `blame={{ cause: 'T=1', effect: 'D=1', states: [...] }}` on `CausalPlayground`. */\nexport interface BlameSpec {\n /** A single event X=x. */\n readonly cause: string\n /** The outcome φ. */\n readonly effect: string\n /** The Halpern–Pearl standards to compute under; default the three HP definitions, and HP with normality when the model has defaults. */\n readonly theories?: readonly ResponsibilityTheory[]\n /** The epistemic states, one row each; default one, the document's own `priors`. */\n readonly states?: readonly BlameState[]\n}\n\nexport interface BlameStateView {\n /** The row's name, in the table's language; undefined for the document's own probabilities. */\n readonly label?: string\n readonly given?: string\n /** Backgrounds of the state (positive probability, `cause` holding). */\n readonly contexts: number\n readonly results: Readonly<Record<ResponsibilityTheory, BlameResult>>\n}\n\nexport interface BlameView {\n readonly theories: readonly ResponsibilityTheory[]\n readonly states: readonly BlameStateView[]\n}\n\n/** The standards blame is computed under by default for this case. */\nexport function defaultBlameTheories(c: LoadedCase): ResponsibilityTheory[] {\n const out: ResponsibilityTheory[] = ['hp-original', 'hp-updated', 'hp-modified']\n if (c.normality !== undefined) out.push('hp-normality')\n return out\n}\n\n/** A degree of blame or responsibility: `0`, `1`, or at most four decimals, at least two. */\nexport function degreeNumber(x: number): string {\n return x === 0 ? '0' : x === 1 ? '1' : cfText(x)\n}\n\n/**\n * The blame of `spec.cause` for `spec.effect` in each epistemic state under each standard. Throws\n * when the document has no `priors` and no state gives one, and with the engine's own errors (a\n * cause that is not a single event, a standard that is not an HP definition, a search past its budget).\n */\nexport function blameView(c: LoadedCase, spec: BlameSpec, locale: Locale): BlameView {\n const given: readonly BlameState[] = spec.states ?? [{}]\n if (given.length === 0) throw new Error(`${c.data.id}: blame needs at least one state`)\n parseCause(c.model, spec.cause)\n const own: Prior | undefined = c.data.priors === undefined ? undefined : c.prior\n const theories = spec.theories ?? defaultBlameTheories(c)\n if (theories.length === 0) throw new ModelError(problem('blame-no-theories', {}))\n const states = given.map((state): BlameStateView => {\n const prior = state.prior === undefined ? own : priorOf(state.prior, c.model)\n if (prior === undefined) throw new Error(`${c.data.id}: blame needs priors, in the document or in each state`)\n const results = Object.fromEntries(\n theories.map((theory) => [\n theory,\n blame(c.model, prior, { cause: spec.cause, effect: spec.effect, given: state.given }, theory, { normality: c.normality }),\n ]),\n ) as Record<ResponsibilityTheory, BlameResult>\n const label = state.label === undefined ? undefined : typeof state.label === 'string' ? state.label : state.label[locale]\n return { label, given: state.given, contexts: results[theories[0]]?.rows.length ?? 0, results }\n })\n return { theories, states }\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { degreeText } from '../model/verdict-rows.ts'\nimport { assignmentText } from '../model/wording.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { Formula, Rich } from '../text/typeset.tsx'\nimport type { BlameView } from './blame-view.ts'\nimport { degreeNumber } from './blame-view.ts'\n\nexport interface PlaygroundBlameProps {\n readonly c: LoadedCase\n readonly cause: string\n readonly effect: string\n readonly view: BlameView\n}\n\n/**\n * Under a playground's graph: the degree of blame (Halpern 2016, Def. 6.2.1) of one event for an\n * outcome, one row per epistemic state and one column per standard; each state's backgrounds, their\n * probabilities and the responsibility in each, behind a fold.\n */\nexport function PlaygroundBlame({ c, cause, effect, view }: PlaygroundBlameProps) {\n const t = useMessages()\n const ids = c.model.byId\n const causeText = cause.replace(/\\s+and\\s+/g, ' ∧ ')\n const name = (i: number): string => view.states[i].label ?? t.blame.documentState\n return (\n <div className=\"ca-pg-blame\" data-blame-block=\"\">\n <p className=\"ca-pg-question\">\n <Rich text={t.blame.question(causeText, effect)} ids={ids} /> <Tip tip={<Rich text={t.blame.tip(causeText)} ids={ids} />} label={t.moreInfo} />\n </p>\n <div className=\"ca-scroll-x\">\n <table className=\"ca-cf-table ca-blame-table\" data-testid=\"blame-table\">\n <thead>\n <tr>\n <th scope=\"col\">{t.blame.state}</th>\n {view.theories.map((theory) => (\n <th key={theory} scope=\"col\">\n {t.theory[theory]}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {view.states.map((state, i) => (\n <tr key={i} data-state={i}>\n <th scope=\"row\">\n {name(i)}\n {state.given !== undefined && (\n <>\n {' · '}\n <Rich text={t.blame.given(state.given)} ids={ids} />\n </>\n )}\n <span className=\"ca-muted ca-small ca-blame-count\"> · {t.blame.contexts(state.contexts)}</span>\n </th>\n {view.theories.map((theory) => (\n <td key={theory} className=\"ca-mono\" data-blame={theory} data-degree={state.results[theory].degree.toFixed(6)}>\n {degreeNumber(state.results[theory].degree)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {view.states.map((state, i) => (\n <details key={i} className=\"ca-blame-fold\" data-fold={i}>\n <summary>\n {name(i)} · {t.blame.fold(state.contexts)}\n </summary>\n <div className=\"ca-blame-fold-table\">\n <table className=\"ca-cf-table\">\n <thead>\n <tr>\n <th scope=\"col\"><Rich text={t.blame.background(c.model.exogenous)} ids={ids} /></th>\n <th scope=\"col\">{t.blame.probability}</th>\n {view.theories.map((theory) => (\n <th key={theory} scope=\"col\">\n {t.blame.responsibility(t.theory[theory])}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {state.results[view.theories[0]].rows.map((row, r) => (\n <tr key={assignmentText(row.context)} data-background={assignmentText(row.context)}>\n <th scope=\"row\">\n <Formula text={assignmentText(row.context)} />\n </th>\n <td className=\"ca-mono\">{degreeNumber(row.p)}</td>\n {view.theories.map((theory) => {\n const cell = state.results[theory].rows[r]\n return (\n <td key={theory} className=\"ca-mono\" data-responsibility={degreeText({ degree: cell.responsibility, k: cell.k })}>\n {degreeText({ degree: cell.responsibility, k: cell.k })}\n </td>\n )\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </details>\n ))}\n </div>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport { decisionProblem } from '../../data/load.ts'\nimport type { CaseDecision } from '../../data/schema.ts'\nimport type { Assignment, DecisionProblem, LocalizedText } from '../../engine/index.ts'\nimport { coerceToDomain, evaluate, getVariable, parseCause, valuesEqual } from '../../engine/index.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport type { DsepPair } from '../model/dsep-view.ts'\nimport { defaultSliders, sliderVariables } from '../model/probability-view.ts'\nimport type { VerdictQuery } from '../model/verdict-rows.ts'\n\n/**\n * CausalPlayground's props read against the case: the presets as buttons, the slider start values,\n * the decision problem, the dsep pairs and the query in force. A prop the case cannot take throws\n * here, with the message the playground has always thrown.\n */\n\nexport const NONE: Assignment = {}\n\n/**\n * A step button under the graph: one press sets these do()s and observations (and nothing else).\n * A bundled case brings its own (do() only); a document takes a list.\n */\nexport interface PlaygroundPreset {\n readonly label: string | LocalizedText\n /** do() to set. */\n readonly interventions?: Assignment\n /** Observations to set; probability graphs only (a graph with values throws). */\n readonly observed?: Assignment\n /**\n * Variables an HP witness holds fixed: set by do() like `interventions`, but drawn in the amber\n * hull (固定) instead of with a clamp.\n */\n readonly hold?: Assignment\n /** Name of this step’s test (defaults to the button label). */\n readonly test?: string | LocalizedText\n /** Required outcome on a graph with values. After a click, compare each entry with the solved world. */\n readonly expect?: Assignment\n}\n\n/** A step button: its text and what one press sets. */\nexport interface PresetButton {\n readonly text: string\n readonly test?: string\n readonly expect?: Assignment\n /** Every do(), the held variables included. */\n readonly interventions: Assignment\n readonly observed: Assignment\n readonly hold: Assignment\n}\n\n/** The decision problem the bars show: the case's own for `true`. */\nexport function decisionFor(c: LoadedCase, decision: true | CaseDecision | undefined): DecisionProblem | undefined {\n if (decision === undefined) return undefined\n if (c.context !== undefined || c.prior === undefined) throw new Error(`${c.data.id}: decision needs a probability graph (priors, no context)`)\n if (decision !== true) return decisionProblem(decision)\n if (c.decision === undefined) throw new Error(`${c.data.id}: decision={true} needs the case's own decision; give one instead`)\n return c.decision\n}\n\n/** The sliders' and `prior`'s start values; throws on a variable no slider can set. */\nexport function sliderStart(c: LoadedCase, sliders: readonly string[], prior: Readonly<Record<string, number>> | undefined): Record<string, number> {\n const ids = [...sliders, ...Object.keys(prior ?? {})]\n if (ids.length === 0) return {}\n if (c.context !== undefined || c.prior === undefined) throw new Error(`${c.data.id}: sliders and prior need a probability graph (priors, no context)`)\n const settable = new Set(sliderVariables(c))\n for (const id of ids) {\n getVariable(c.model, id)\n if (!settable.has(id)) throw new Error(`${c.data.id}: no slider can set ${id} (a boolean or two-valued exogenous variable, independent prior)`)\n }\n for (const [id, p] of Object.entries(prior ?? {})) {\n if (!(p >= 0 && p <= 1)) throw new Error(`${c.data.id}: prior ${id} = ${p} is not a probability`)\n }\n const own = defaultSliders(c)\n return Object.fromEntries(ids.map((id) => [id, prior?.[id] ?? own[id]]))\n}\n\n/** Throws when `verdicts` are given for a graph without values (no actual context). */\nexport function checkVerdicts(c: LoadedCase, verdicts: readonly VerdictQuery[] | undefined): void {\n if (verdicts !== undefined && c.context === undefined) throw new Error(`${c.data.id}: verdicts need a graph with values (an actual context)`)\n}\n\nfunction isPair(dsep: DsepPair | readonly DsepPair[]): dsep is DsepPair {\n return typeof dsep[0] === 'string'\n}\n\n/** The dsep pairs as a list; throws unless the graph has probabilities and both ends of each are its variables. */\nexport function dsepPairs(c: LoadedCase, dsep: DsepPair | readonly DsepPair[] | undefined): readonly DsepPair[] {\n const pairs: readonly DsepPair[] = dsep === undefined ? [] : isPair(dsep) ? [dsep] : dsep\n if (pairs.length > 0 && (c.context !== undefined || c.prior === undefined)) throw new Error(`${c.data.id}: dsep needs a probability graph (priors, no context)`)\n for (const [x, y] of pairs) {\n getVariable(c.model, x)\n getVariable(c.model, y)\n }\n return pairs\n}\n\n/** Throws on a tracked id that names no variable. */\nexport function checkTrack(c: LoadedCase, track: readonly string[]): void {\n for (const id of track) getVariable(c.model, id)\n}\n\n/** The most specific cause set by these non-held interventions, not all at actual values; else the first. */\nexport function activeQuery(c: LoadedCase, queries: readonly VerdictQuery[], interventions: Assignment): number {\n const actual = c.context === undefined ? NONE : evaluate(c.model, c.context).values\n let best = 0\n let size = 0\n queries.forEach((q, i) => {\n const cause = parseCause(c.model, q.cause)\n const ids = Object.keys(cause)\n if (ids.length > size && ids.every((id) => id in interventions) && ids.some((id) => !valuesEqual(interventions[id], actual[id]))) {\n best = i\n size = ids.length\n }\n })\n return best\n}\n\n/** The step buttons: a bundled case's own showcase for `true`, the given list, or none; held variables are set by do() too. */\nexport function presetButtons(c: LoadedCase, presets: boolean | readonly PlaygroundPreset[], locale: Locale): PresetButton[] {\n if (presets === false) return []\n const list: readonly PlaygroundPreset[] = presets === true ? c.data.showcase : presets\n return list.map((s) => {\n const text = typeof s.label === 'string' ? s.label : s.label[locale]\n const observed = s.observed ?? NONE\n if (c.context !== undefined && Object.keys(observed).length > 0) {\n throw new Error(`preset \"${text}\": observed needs probabilities, and ${c.data.id} has an actual context`)\n }\n const hold = s.hold ?? NONE\n if (s.expect !== undefined) {\n if (c.context === undefined || Object.keys(s.expect).length === 0) throw new Error(`preset \"${text}\": expect needs an outcome and an actual context`)\n for (const [id, value] of Object.entries(s.expect)) coerceToDomain(getVariable(c.model, id), value)\n }\n return { text, test: typeof s.test === 'string' ? s.test : s.test?.[locale], expect: s.expect, interventions: { ...(s.interventions ?? NONE), ...hold }, observed, hold }\n })\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, CausalTheory } from '../../engine/index.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { MathProse, Rich } from '../text/typeset.tsx'\nimport type { ActualGroup, ActualRow, VerdictQuery } from '../model/verdict-rows.ts'\nimport { degreeText, witnessNow } from '../model/verdict-rows.ts'\n\nexport interface PlaygroundVerdictsProps {\n readonly c: LoadedCase\n readonly groups: readonly ActualGroup[]\n readonly queries: readonly VerdictQuery[]\n readonly theories: readonly (readonly CausalTheory[])[]\n /** The query the 目前的世界 line answers. */\n readonly active: number\n readonly interventions: Assignment\n /** 在圖上看: set the witness, the cause at x⃗′ and W⃗ held at w⃗. */\n readonly onShow: (row: ActualRow, query: number) => void\n}\n\n/**\n * Under a playground's graph: for each query one row of verdicts, a standard per cell, each with\n * 在圖上看 when the engine found a witness; then whether the world on the graph is a witness.\n */\nexport function PlaygroundVerdicts({ c, groups, queries, theories, active, interventions, onShow }: PlaygroundVerdictsProps) {\n const t = useMessages()\n const ids = c.model.byId\n const query = queries[active]\n return (\n <div className=\"ca-pg-verdicts\">\n {groups.map((g) => (\n <section key={`${g.cause}⇒${g.effect}`} className=\"ca-pg-verdict-group\" data-query={`${g.cause}⇒${g.effect}`}>\n <p className=\"ca-pg-question\">\n <Rich text={t.witness.question(g.cause.replace(/\\s+and\\s+/g, ' ∧ '), g.effect)} ids={ids} />\n </p>\n <ul className=\"ca-pg-cells\">\n {g.rows.map((r) => (\n <li key={r.theory} className={`ca-pg-cell is-${r.verdict}`} data-verdict-cell={r.theory} data-verdict={r.verdict}>\n <span className=\"ca-pg-theory\">{t.theory[r.theory]}</span>\n <span className=\"ca-pg-answer\">\n <strong>{t.witness.answer[r.verdict]}</strong>\n {r.verdict === 'cause' && r.show !== undefined && (\n <>\n {' · '}\n <button type=\"button\" className=\"ca-link\" onClick={() => onShow(r, queries.findIndex((q) => q.cause === g.cause && q.effect === g.effect && (q.theories === undefined || q.theories.includes(r.theory))))}>\n {t.showOnGraph}\n </button>\n </>\n )}\n </span>\n {r.responsibility !== undefined && (\n <span className=\"ca-pg-resp\" data-responsibility={degreeText(r.responsibility)}>\n <MathProse text={t.resp.cell(degreeText(r.responsibility))} math={{ [degreeText(r.responsibility)]: degreeText(r.responsibility) }} />{' '}\n <Tip\n tip={\n r.responsibility.k === undefined\n ? t.resp.tipZero\n : <MathProse\n text={t.resp.tip(r.responsibility.k, r.responsibility.held ?? '', r.responsibility.cause ?? '', r.theory === 'hp-normality')}\n math={{ '1/k': '1/k', [`k = ${r.responsibility.k}`]: `k=${r.responsibility.k}`, k: 'k' }}\n ids={ids}\n />\n }\n label={t.moreInfo}\n />\n </span>\n )}\n </li>\n ))}\n </ul>\n </section>\n ))}\n {query !== undefined && (\n <div className=\"ca-pg-now\" data-witness-now=\"\">\n <span className=\"ca-pg-now-kicker\">{t.witness.now}</span>{' '}\n <Rich text={Object.keys(interventions).length === 0 ? t.witness.untouched : witnessNow(t, c, query, theories[active] ?? [], interventions, groups.find((g) => g.cause === query.cause && g.effect === query.effect)?.rows ?? [])} ids={ids} />\n <details className=\"ca-witness-help\">\n <summary className=\"ca-link\">ⓘ {t.moreInfo}</summary>\n <Rich text={t.witness.tip} ids={ids} narrative />\n </details>\n </div>\n )}\n </div>\n )\n}\n","import type { Assignment } 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 trail under a playground graph: the tracked nodes' readings after each change of what is set. */\n\n/** One reading of a trail: what was set (`settingText`, '' for nothing) and each tracked node's number or value. */\nexport interface TrailEntry {\n readonly setting: string\n readonly values: Readonly<Record<string, string>>\n}\n\n/** Entries a trail keeps; older ones give way to `…`. */\nexport const TRAIL_LENGTH = 5\n\n/** The tracked nodes' numbers (a probability graph) or values in `world`, as text. */\nexport function trailEntry(world: { readonly probs?: Readonly<Record<string, number>>; readonly values?: Assignment }, ids: readonly string[], setting: string): TrailEntry {\n const values: Record<string, string> = {}\n for (const id of ids) {\n const p = world.probs?.[id]\n const v = world.values?.[id]\n values[id] = p !== undefined ? probText(p) : v !== undefined ? formatValue(v) : '—'\n }\n return { setting, values }\n}\n\n/** `Y:0.50 → 0.67(Z=1)→ 0.50(Z=1, X=1)`, with `…` first when older readings were dropped. */\nexport function trailText(t: Messages, id: string, trail: readonly TrailEntry[], dropped: boolean): string {\n const steps = trail.map((e) => t.trailStep(e.values[id] ?? '—', e.setting))\n return t.trailLine(id, steps, dropped)\n}\n","import { useState } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment } from '../../engine/index.ts'\nimport { solve } from '../model/model-state.ts'\nimport type { TrailEntry } from './trail.ts'\nimport { TRAIL_LENGTH, trailEntry } from './trail.ts'\n\n/** The trail of the tracked nodes: the last readings, and whether older ones gave way. */\nexport interface Trail {\n readonly entries: readonly TrailEntry[]\n /** Older readings gave way to the last TRAIL_LENGTH. */\n readonly dropped: boolean\n}\n\n/**\n * The trail under the graph: a reading of the tracked nodes is added, during render, whenever what\n * is set (`setting`) changes; `restart` starts it again from the case with nothing set.\n */\nexport function useTrail(\n c: LoadedCase,\n track: readonly string[],\n world: { readonly probs?: Readonly<Record<string, number>>; readonly values?: Assignment },\n setting: string,\n): readonly [Trail, () => void] {\n const startTrail = (): Trail => ({ entries: [trailEntry(solve(c, {}), track, '')], dropped: false })\n const [trail, setTrail] = useState<Trail>(startTrail)\n if (track.length > 0 && trail.entries[trail.entries.length - 1]?.setting !== setting) {\n const entries = [...trail.entries, trailEntry(world, track, setting)]\n setTrail({ entries: entries.slice(-TRAIL_LENGTH), dropped: trail.dropped || entries.length > TRAIL_LENGTH })\n }\n return [trail, () => setTrail(startTrail())]\n}\n","import { useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { CaseDecision, ModelDoc } from '../../data/schema.ts'\nimport type { Assignment } from '../../engine/index.ts'\nimport { valuesEqual } from '../../engine/index.ts'\nimport { DEFAULT_URL, watermarkLine } from '../export/cite.ts'\nimport { DEFAULT_EMBED_BASE, embedCode, embedHome, embedSrc, fitEmbedState, readEmbedState } from '../export/embed.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { LocaleScope, useMessages } from '../i18n/messages.ts'\nimport { DigitsScope } from '../shared/digits.ts'\nimport { sameAssignment } from '../model/assignments.ts'\nimport { CaseGate } from '../model/CaseGate.tsx'\nimport { casesOf } from '../model/cases-of.ts'\nimport { useCaseOrDoc } from '../model/doc-case.ts'\nimport type { DsepPair } from '../model/dsep-view.ts'\nimport { dsepView } from '../model/dsep-view.ts'\nimport type { Reading } from '../model/model-state.ts'\nimport { useModel } from '../model/model-state.ts'\nimport { normalityLine } from '../model/normality-view.ts'\nimport type { UiNotation } from '../model/notation.ts'\nimport { priorWithSliders } from '../model/probability-view.ts'\nimport { nodeSliders, sliderTargets } from '../model/slider-groups.ts'\nimport type { VerdictQuery } from '../model/verdict-rows.ts'\nimport { actualGroups, defaultTheories, originCitations, originSources } from '../model/verdict-rows.ts'\nimport { assignmentText, readingText } from '../model/wording.ts'\nimport { EquationPanel } from '../panels/EquationBox.tsx'\nimport { GraphBox } from '../panels/GraphBox.tsx'\nimport { SliderList } from '../panels/SliderList.tsx'\nimport type { FigureBlock } from '../shared/FigureTabs.tsx'\nimport { heightAtInitialBlock } from '../shared/tab-height.ts'\nimport { DocProblems, Segmented, Tip } from '../shared/parts.tsx'\nimport { Rich } from '../text/typeset.tsx'\nimport { DecisionBars } from './DecisionBars.tsx'\nimport { DsepLine } from './DsepLine.tsx'\nimport type { PlaygroundPreset, PresetButton } from './playground-options.ts'\nimport type { BlameSpec } from './blame-view.ts'\nimport { blameView } from './blame-view.ts'\nimport { PlaygroundBlame } from './PlaygroundBlame.tsx'\nimport { NONE, activeQuery, checkTrack, checkVerdicts, decisionFor, dsepPairs, presetButtons, sliderStart } from './playground-options.ts'\nimport { PlaygroundVerdicts } from './PlaygroundVerdicts.tsx'\nimport { trailText } from './trail.ts'\nimport { useTrail } from './use-trail.ts'\n\nexport type { PlaygroundPreset } from './playground-options.ts'\nexport type { BlameSpec, BlameState } from './blame-view.ts'\n\nexport type CausalPlaygroundProps = CausalPlaygroundSource & CausalPlaygroundOptions\n\n/** What to draw: a bundled case by id, or a model document (a `modelDocSchema` value) such as one built in the editor. */\nexport type CausalPlaygroundSource =\n | {\n /** A bundled case id, e.g. `rock-throwing`. */\n readonly caseId: string\n readonly doc?: undefined\n }\n | {\n /**\n * A model document drawn on its own: graph, notation toggle, do() and export, no editor chrome.\n * A document that does not validate or build shows its problem codes instead of throwing.\n * The export credits a case source only when `doc.from` is a bundled case with the same model.\n */\n readonly doc: ModelDoc\n readonly caseId?: undefined\n }\n\nexport interface CausalPlaygroundOptions {\n /** Notation the equations start in; the reader can still switch. Default 'propositional'. */\n readonly defaultNotation?: UiNotation\n /** do() applied at the start. */\n readonly initialInterventions?: Assignment\n /**\n * Preset interventions as buttons. `true` (default) shows a bundled case's own; pass a list for\n * a document (it has none of its own); `false` hides them.\n */\n readonly presets?: boolean | readonly PlaygroundPreset[]\n /** Link in exported images' watermark. Default https://github.com/wayne930242/logic-atlas. */\n readonly exportUrl?: string\n /**\n * Decimals of the probability under each node (and a stochastic do()'s tag, a bar chart's top\n * value and the 原本 notes): a whole number from 1 to 6, default 2. Set it to the digits the\n * text quotes, e.g. 3 for 0.175; a number within 10^-digits of 0 or 1 still gets two significant\n * digits of its distance from that end. Equation, table and slider numbers keep their own\n * precision. The embed code does not record it.\n */\n readonly digits?: number\n /** Interface language. Default: the surrounding LocaleProvider's, else zh-TW. */\n readonly locale?: Locale\n /**\n * The page that shows this figure alone, for the export menu's embed code (an iframe and the\n * citation). Default for a bundled case: https://wayneh.tw/causal/embed/case/<id>/; a document\n * has none unless given. `false` offers no embed code.\n */\n readonly embedUrl?: string | false\n /**\n * Drawn as an embed page: the state comes from the address (`#do=…&pdo=…&obs=…`, see\n * `embedFragment`) and a credit line with the licence, the case's sources and a link back to the\n * page it was copied from (`?from=`) sits under it.\n */\n readonly embedded?: boolean\n /**\n * Nodes whose number (or value) is followed under the graph: one line per node with its reading\n * after each change of what is set, `Y:0.50 → 0.67(Z=1)→ 0.50(Z=1, X=1)`, the last five.\n * 「回到原本」 and the step buttons start it again.\n */\n readonly track?: readonly string[]\n /**\n * Actual-cause questions for a graph with values: per query a row of verdicts (but-for, the three\n * HP definitions, HP with normality when the model has defaults; or `theories`), each with\n * 在圖上看 for its witness, and a line saying whether the world on the graph is a witness. Only a preset's hold or the shown witness's W is drawn held.\n * The status follows the clicked witness or the most specific matching cause.\n */\n readonly verdicts?: readonly VerdictQuery[]\n /**\n * The degree of blame (Halpern 2016, Def. 6.2.1) of one event for an outcome: a 責備 tab under\n * the graph with one row per epistemic state and one column per Halpern–Pearl standard, and each\n * state's backgrounds with their probabilities and responsibilities behind a fold. `states` are\n * `{ label?, prior?, given? }`: `prior` in the model document's `priors` format (default the\n * document's own, which a document without `priors` must then supply in every state), `given` an\n * observation that narrows the state, e.g. the outcome seen after acting. Without `states` there\n * is one, the document's `priors` (the sliders move it). Halpern's blame conditions on the cause\n * holding, so the probabilities are conditioned on it. Throws when no priors are available.\n */\n readonly blame?: BlameSpec\n /**\n * The model's default values (`normality`), shown on a graph with values: a node off its default\n * says 偏離(預設 v), a line under the graph compares this world's deviations with the actual\n * world's (更正常/一樣正常/較不正常/無法比較), each equation says 預設 v. On by default when the\n * model has defaults; `false` hides them.\n */\n readonly normality?: boolean\n /**\n * A pair of variables, or several (a switch in the head picks one), on a probability graph: every\n * path between the two in the graph after do() is lit when open and dashed when blocked, the\n * known set being what is observed, and a line under the graph gives the verdict, δ (lesson 04's\n * dependence, given the observed values) and up to three paths with why.\n */\n readonly dsep?: DsepPair | readonly DsepPair[]\n /**\n * Exogenous variables with a slider under the graph (boolean or two-valued ones, on a probability\n * graph): P(id = 1, or its first value). Dragging recomputes everything drawn with the new prior;\n * 「回到原本的機率」 puts the sliders back. The embed code does not record them.\n */\n readonly sliders?: readonly string[]\n /** Start values P(id = 1, or its first value) of exogenous variables, slider or not; the rest keep the case's prior. */\n readonly prior?: Readonly<Record<string, number>>\n /**\n * Expected-utility bars under the graph (a probability graph): one row per theory (evidential,\n * causal), one bar per act, the act each picks and by how much; the utilities sit in its ⓘ.\n * `true` takes the case's own `decision`; or give one in the case-file format\n * (`{ variable, acts?, utility: { variables, rows: [[...values, utility]] } }`). Observing the act\n * lights its evidential bar, do() on it the causal one; the sliders move both rows.\n */\n readonly decision?: true | CaseDecision\n /**\n * The block under the graph that is open at load: 'probabilities' (機率, the sliders), 'equations'\n * (式子), or a figure block ('verdicts', 'ev', 'dsep', 'blame'). Default: the figure's own block\n * (verdicts, expected utility, paths, blame), else none. A block the figure does not offer counts as\n * the default. The embed code keeps the default.\n */\n readonly openPanel?: PlaygroundPanel\n /**\n * The sliders the 機率 tab shows at first, of those in `sliders`; the others wait behind a button\n * that shows them (and hides them again). Default, or when none of them is a slider: every slider.\n */\n readonly focusSliders?: readonly string[]\n}\n\n/** The blocks under a playground's graph, by the id `openPanel` names them with. */\nexport type PlaygroundPanel = 'verdicts' | 'ev' | 'dsep' | 'blame' | 'probabilities' | 'equations'\n\n/** One case's graph and equations; click a node to observe it (probabilities) or set do() on it (values). */\nexport function CausalPlayground({ locale, digits, ...props }: CausalPlaygroundProps) {\n return (\n <LocaleScope locale={locale}>\n <DigitsScope digits={digits}>\n <CaseGate ids={casesOf(props.caseId, [props.doc])}>\n <PlaygroundBody {...props} />\n </CaseGate>\n </DigitsScope>\n </LocaleScope>\n )\n}\n\nfunction PlaygroundBody({ doc, ...props }: Omit<CausalPlaygroundProps, 'locale' | 'digits'>) {\n const resolved = useCaseOrDoc(props.caseId, doc)\n return resolved.ok ? <PlaygroundFor c={resolved.c} {...props} /> : <DocProblems problems={resolved.problems} />\n}\n\nfunction PlaygroundFor({\n c: base,\n caseId,\n initialInterventions,\n presets = true,\n exportUrl,\n defaultNotation,\n embedUrl,\n embedded = false,\n track = NO_TRACK,\n verdicts,\n blame,\n normality = true,\n dsep,\n sliders = NO_TRACK,\n prior: startPrior,\n decision,\n openPanel,\n focusSliders,\n}: Omit<CausalPlaygroundOptions, 'locale' | 'digits'> & { readonly c: LoadedCase; readonly caseId?: string }) {\n const t = useMessages()\n const start = useMemo(() => sliderStart(base, sliders, startPrior), [base, sliders, startPrior])\n const [sliderValues, setSliderValues] = useState(start)\n // `focusSliders`: the rows shown at first; the rest behind 顯示其他 n 個機率.\n const focused = useMemo(() => sliders.filter((id) => focusSliders?.includes(id) === true), [sliders, focusSliders])\n const hidden = focused.length > 0 ? sliders.filter((id) => !focused.includes(id)) : NO_TRACK\n const [allSliders, setAllSliders] = useState(false)\n const problem = useMemo(() => decisionFor(base, decision), [base, decision])\n // Everything below reads the case with the slider prior; an embed page reads its state from `base`.\n const c = useMemo(\n () => (Object.keys(sliderValues).length === 0 ? base : { ...base, prior: priorWithSliders(base, sliderValues) }),\n [base, sliderValues],\n )\n checkVerdicts(c, verdicts)\n const [reading, setReading] = useState<Reading>('interventional')\n const { interventions, stochastic, observed, setDo, setObserved, notation, setNotation, world } = useModel(\n c,\n initialInterventions,\n defaultNotation,\n reading,\n )\n /** Switch the reading, keeping what is set; back to interventional, a node keeps only its do(). */\n const switchReading = (next: Reading): void => {\n if (next === 'interventional') {\n const kept = Object.fromEntries(Object.entries(observed).filter(([id]) => !(id in interventions) && !(id in stochastic)))\n if (Object.keys(kept).length !== Object.keys(observed).length) setObserved(kept)\n }\n setReading(next)\n }\n const root = useRef<HTMLDivElement>(null)\n // A hovered node lights its sliders; a hovered slider lights the nodes it moves.\n const [hoverNode, setHoverNode] = useState<string | undefined>(undefined)\n const [hoverSlider, setHoverSlider] = useState<string | undefined>(undefined)\n const litNodes = useMemo(() => (hoverSlider === undefined ? NO_TRACK : sliderTargets(c.model, world.shown, hoverSlider)), [c.model, world.shown, hoverSlider])\n const litSliders = useMemo(\n () => (hoverNode !== undefined ? nodeSliders(c.model, world.shown, sliders, hoverNode) : hoverSlider !== undefined ? [hoverSlider] : NO_TRACK),\n [c.model, world.shown, sliders, hoverNode, hoverSlider],\n )\n const setSlider = (id: string, p: number): void => setSliderValues((now) => ({ ...now, [id]: p }))\n /** The sliders among `ids` moved from where they started. */\n const moved = (ids: readonly string[]): boolean => ids.some((id) => sliderValues[id] !== start[id])\n /** Put the sliders `ids` back where they started. */\n const resetSliders = (ids: readonly string[]): void => {\n setSliderValues((now) => ({ ...now, ...Object.fromEntries(ids.map((id) => [id, start[id]])) }))\n restartTrail()\n }\n const sliderId = useId().replace(/[^a-zA-Z0-9_-]/g, '')\n // An embed page takes its state from the address once mounted (the server has no address hash).\n useEffect(() => {\n if (!embedded) return\n const state = fitEmbedState(base, readEmbedState(window.location.hash))\n setDo({ interventions: state.interventions, stochastic: state.stochastic })\n setObserved(state.observed)\n // Read once per case: later clicks are the reader's own.\n }, [base, embedded, setDo, setObserved])\n const [held, setHeld] = useState<Assignment>(NONE)\n const soft = Object.keys(stochastic).length > 0\n const buttons = presetButtons(c, presets, t.locale)\n const prob = world.probs !== undefined\n const defaults = normality && c.context !== undefined ? c.normality : undefined\n const pairs = dsepPairs(c, dsep)\n const [pairAt, setPairAt] = useState(0)\n const pair = pairs[Math.min(pairAt, pairs.length - 1)]\n const dsepNow = pair === undefined || !prob ? undefined : dsepView(c, pair, observed, interventions, stochastic)\n const groups = useMemo(() => (verdicts === undefined ? [] : actualGroups(t, c, verdicts)), [t, c, verdicts])\n const theories = useMemo(() => (verdicts ?? []).map((q) => q.theories ?? defaultTheories(c)), [c, verdicts])\n const blamed = useMemo(() => (blame === undefined ? undefined : blameView(c, blame, t.locale)), [c, blame, t.locale])\n const [shownQuery, setShownQuery] = useState<number>()\n const holding = Object.fromEntries(\n Object.entries(interventions).filter(([id, v]) => id in held && valuesEqual(held[id], v)),\n )\n const active = verdicts === undefined ? -1 : shownQuery ?? activeQuery(c, verdicts, Object.fromEntries(Object.entries(interventions).filter(([id]) => !(id in holding))))\n checkTrack(c, track)\n const setting = readingText(t, reading === 'counterfactual' && prob, interventions, stochastic, observed)\n const [trail, restartTrail] = useTrail(c, track, world, setting)\n const [stepIndex, setStepIndex] = useState<number>()\n const step = stepIndex === undefined ? undefined : buttons[stepIndex]\n const required = step?.expect\n const result = required && world.values ? Object.fromEntries(Object.keys(required).map((id) => [id, world.values![id]])) : undefined\n const applyPreset = (s: PresetButton, query?: number): void => {\n setStepIndex(buttons.indexOf(s))\n setShownQuery(query)\n setDo({ interventions: s.interventions, stochastic: {} })\n setObserved(s.observed)\n setHeld(s.hold)\n restartTrail()\n }\n // A step stays pressed while everything it set still holds, even after the reader sets more; of the\n // steps that still hold, only the ones that set the most are pressed (so an empty step 1 does not light\n // up next to step 2).\n const within = (state: Assignment, part: Assignment): boolean =>\n sameAssignment(Object.fromEntries(Object.keys(part).filter((id) => id in state).map((id) => [id, state[id]])), part)\n const holds = (s: PresetButton): boolean =>\n within(observed, s.observed) && within(interventions, s.interventions) && within(holding, s.hold)\n const size = (s: PresetButton): number =>\n Object.keys(s.observed).length + Object.keys(s.interventions).length + Object.keys(s.hold).length\n const pressedSize = soft ? -1 : Math.max(-1, ...buttons.filter(holds).map(size))\n const pressed = (s: PresetButton): boolean => !soft && holds(s) && size(s) === pressedSize\n const src = embedded || embedUrl === false ? undefined : (embedUrl ?? (caseId === undefined ? undefined : `${DEFAULT_EMBED_BASE}case/${encodeURIComponent(caseId)}/`))\n // Under the graph, one block at a time: the figure's own (verdicts, expected utility, paths) open at first, the equations closed.\n const blocks: FigureBlock[] = []\n if (verdicts !== undefined) {\n blocks.push({\n id: 'verdicts',\n label: t.tab.verdicts,\n children: (\n <PlaygroundVerdicts\n c={c}\n groups={groups}\n queries={verdicts}\n theories={theories}\n active={active}\n interventions={interventions}\n onShow={(row, query) => {\n const hold = row.fixed ?? NONE\n applyPreset({ text: '', interventions: row.show ?? NONE, observed: NONE, hold }, query)\n }}\n />\n ),\n })\n }\n if (problem !== undefined) {\n blocks.push({ id: 'ev', label: t.ev.title, children: <DecisionBars c={c} problem={problem} observed={observed} interventions={interventions} /> })\n }\n if (dsepNow !== undefined && pair !== undefined) {\n blocks.push({ id: 'dsep', label: t.tab.dsep, children: <DsepLine c={c} pair={pair} observed={observed} view={dsepNow} /> })\n }\n if (blame !== undefined && blamed !== undefined) {\n blocks.push({ id: 'blame', label: t.tab.blame, children: <PlaygroundBlame c={c} cause={blame.cause} effect={blame.effect} view={blamed} /> })\n }\n if (sliders.length > 0) {\n // Every slider, grouped by the node it moves (sliders that move no drawn node last), closed at first:\n // a node's own sliders are also in its menu.\n blocks.push({\n id: 'probabilities',\n label: t.probabilities,\n children: (\n <div className=\"ca-slider-tab\">\n <SliderList\n c={c}\n ids={hidden.length > 0 && !allSliders ? focused : sliders}\n values={sliderValues}\n onChange={setSlider}\n idPrefix={`ca-pg-slider-${sliderId}`}\n shown={world.shown}\n lit={litSliders}\n onHover={setHoverSlider}\n />\n {hidden.length > 0 && (\n <button type=\"button\" className=\"ca-link ca-slider-more\" aria-expanded={allSliders} onClick={() => setAllSliders((x) => !x)}>\n {allSliders ? t.fewerSliders : t.moreSliders(hidden.length)}\n </button>\n )}\n {moved(sliders) && (\n <button type=\"button\" className=\"ca-btn ca-btn-outline ca-slider-reset\" onClick={() => resetSliders(sliders)}>\n {t.backToPrior}\n </button>\n )}\n </div>\n ),\n })\n }\n blocks.push({\n id: 'equations',\n label: t.equations,\n children: <EquationPanel c={c} world={world} interventions={interventions} stochastic={stochastic} observed={observed} reading={reading} notation={notation} onNotation={setNotation} defaults={defaults} />,\n })\n const initialBlock = blocks.find((b) => b.id !== 'equations' && b.id !== 'probabilities')?.id\n const embed =\n src === undefined\n ? undefined\n : (): string =>\n embedCode({\n src: embedSrc(src, { interventions, stochastic, observed }, window.location.pathname, t.locale),\n title: c.data.title[t.locale],\n // The figure as it stands, plus the credit line the embed page adds under it.\n // The embed page starts with the figure's own block open, whatever is open here.\n height: heightAtInitialBlock(root.current, initialBlock, 640) + 72,\n locale: t.locale,\n url: exportUrl,\n origins: originCitations(c),\n })\n return (\n <div className=\"ca-root not-prose ca-playground\" data-case={c.data.id} lang={t.locale} ref={root}>\n <div className=\"ca-panel\">\n <GraphBox\n c={c}\n world={world}\n interventions={interventions}\n stochastic={stochastic}\n onDo={(next) => {\n setStepIndex(undefined)\n setShownQuery(undefined)\n setHeld(Object.fromEntries(Object.entries(holding).filter(([id, v]) => valuesEqual(v, next.interventions[id]))))\n setDo(next)\n }}\n observed={observed}\n onObserve={setObserved}\n witness={Object.keys(holding).length > 0 ? holding : undefined}\n holdNotes\n defaults={defaults}\n menuHelp={`${reading === 'counterfactual' && prob ? t.cfHintMore : t.playgroundHintMore(prob)}${sliders.length > 0 ? ` ${t.sliderEmbed.trim()}` : ''}`}\n exportUrl={exportUrl}\n embedCode={embed}\n moved={moved(sliders)}\n onReset={() => {\n setSliderValues(start)\n restartTrail()\n }}\n reading={reading}\n paths={dsepNow?.marks}\n lit={litNodes}\n onHover={sliders.length > 0 ? setHoverNode : undefined}\n menuExtra={\n sliders.length === 0\n ? undefined\n : (id) => {\n const own = nodeSliders(c.model, world.shown, sliders, id)\n return own.length === 0 ? undefined : (\n <>\n <SliderList c={c} ids={own} values={sliderValues} onChange={setSlider} idPrefix={`ca-pg-menu-slider-${sliderId}`} />\n {moved(own) && (\n <button type=\"button\" className=\"ca-btn ca-btn-outline ca-slider-reset\" data-node-reset={id} onClick={() => resetSliders(own)}>\n {t.nodeBackToPrior}\n </button>\n )}\n </>\n )\n }\n }\n actions={\n prob ? (\n <>\n {pairs.length > 1 && (\n <Segmented\n label={t.dsep.pairs}\n options={pairs.map((p, i) => ({ value: String(i), label: t.dsep.pair(p[0], p[1]) }))}\n value={String(Math.min(pairAt, pairs.length - 1))}\n onChange={(v) => setPairAt(Number(v))}\n />\n )}\n <div className=\"ca-reading-box\">\n <div className=\"ca-reading-row\">\n <span className=\"ca-reading-label\" aria-hidden=\"true\">\n {t.readingLabel}\n </span>\n <Segmented\n className=\"ca-reading\"\n label={t.readingLabel}\n options={[\n { value: 'interventional', label: t.reading.interventional },\n { value: 'counterfactual', label: t.reading.counterfactual },\n ]}\n value={reading}\n onChange={switchReading}\n />\n </div>\n <p className=\"ca-reading-hint\" aria-live=\"polite\">\n {reading === 'interventional' && Object.keys(interventions).length + Object.keys(stochastic).length === 0 ? '' : t.readingHint[reading]}\n </p>\n </div>\n </>\n ) : undefined\n }\n foot={\n <div className=\"ca-playground-foot\">\n {defaults !== undefined && world.values !== undefined && world.original !== undefined && (\n <p className=\"ca-norm-line\" data-normality=\"\">\n <span className=\"ca-pg-now-kicker\">{t.normality.kicker}</span>{' '}\n <Rich\n text={normalityLine(t, c.model, world.values, world.original, defaults, !sameAssignment(world.values, world.original))}\n ids={c.model.byId}\n />{' '}\n <Tip tip={t.normality.tip} label={t.moreInfo} />\n </p>\n )}\n {track.length > 0 && (\n <ul className=\"ca-trail\" aria-label={t.trail}>\n {track.map((id) => {\n const text = trailText(t, id, trail.entries, trail.dropped)\n return (\n <li key={id} data-trail={id} data-text={text}>\n <span className=\"ca-trail-kicker\">{t.trail}</span> <Rich text={text} ids={c.model.byId} />\n </li>\n )\n })}\n </ul>\n )}\n {step && (step.test !== undefined || required !== undefined) && !soft && sameAssignment(step.interventions, interventions) && sameAssignment(step.hold, holding) && sameAssignment(step.observed, observed) && (\n <p role=\"status\" data-step-result=\"\">{required && result\n ? t.witness.step(step.test ?? step.text, assignmentText(required), assignmentText(result), sameAssignment(required, result))\n : t.witness.testName(step.test ?? step.text)}</p>\n )}\n {buttons.length > 0 && (\n <div className=\"ca-presets\" role=\"group\" aria-label={t.presets}>\n {buttons.map((s) => (\n <button key={s.text} type=\"button\" className=\"ca-btn ca-btn-outline\" aria-pressed={pressed(s)} onClick={() => applyPreset(s)}>\n {s.text}\n </button>\n ))}\n </div>\n )}\n </div>\n }\n blocks={blocks}\n initialBlock={openPanel !== undefined && blocks.some((b) => b.id === openPanel) ? openPanel : initialBlock}\n />\n </div>\n {embedded && <EmbedCredit c={c} url={exportUrl ?? DEFAULT_URL} />}\n </div>\n )\n}\n\nconst noSubscription = (): (() => void) => () => {}\n\n/** The credit under an embedded figure: author, project, licence and link; the case's sources; the page it came from. */\nfunction EmbedCredit({ c, url }: { readonly c: LoadedCase; readonly url: string }) {\n const t = useMessages()\n // The address never changes under an embed page: read it on the client, the project page on the server.\n const home = useSyncExternalStore(\n noSubscription,\n () => embedHome(window.location.search, window.location.origin, url),\n () => url,\n )\n const origins = originCitations(c)\n return (\n <footer className=\"ca-embed-credit ca-small\">\n <p>{watermarkLine(url, t.locale)}</p>\n {origins.length > 0 && <p>{t.export.caseSource(originSources(t, c))}</p>}\n <p>\n <a href={home} target=\"_blank\" rel=\"noopener\">\n {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EAAA,UACE,kBAAC,KAAD;IAAG,MAAM0L;IAAM,QAAO;IAAS,KAAI;IAChC,UAAAxK,EAAE,OAAO;GACT,CAAA,EACF,CAAA;EACG;;AAEZ;AAEA,IAAMmG,IAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"CausalPlayground-D93D0ceE.js","names":["_Fragment","_Fragment","_Fragment","_Fragment","parseCause","evaluateDecision","getVariable","ModelError","evaluate","formatValue","coerceToDomain","valuesEqual","blame","authorYearEn","DEFAULT_URL","watermarkLine","authorYear","DATA_LICENSE","parsePdo","parseDo","formatPdo","formatDo","LocaleScope","useMessages","messagesFor","solve","priorWithSliders","sliderVariables","defaultSliders","useModel","fixed","degreeText","normalityLine","actualGroups","originSources","originCitations","MathProse","Formula","Rich","assignmentText","readingText","DigitsScope","probText","defaultTheories","sameAssignment","useCaseOrDoc","witnessNow","CaseGate","casesOf","pathReason","dsepView","pathText","deltaText","cfText","nodeSliders","sliderTargets","SliderList","EquationPanel","GraphBox","Tip","Segmented","DocProblems","ExpectedUtility","priorOf","decisionProblem","problem","Fragment$1","param","name","hash","embedFragment","parts","d","state","p","o","readEmbedState","embedSrc","url","src","locale","from","escapeAttr","text","escapeText","embedCode","m","origins","title","height","embedHome","search","fallback","origin","endogenous","out","id","value","a","v","c","fitEmbedState","interventions","stochastic","observed","heightAtInitialBlock","root","panels","was","initial","i","euText","s","eu","int","frac","grouped","DecisionBars","t","prior","raw","result","b","actText","all","lo","hi","span","at","zero","seen","done","rows","eus","theory","choice","best","rest","ch","by","lit","utilityLines","r","line","left","width","DsepLine","ids","view","shown","known","pair","defaultBlameTheories","degreeNumber","x","blameView","given","spec","own","theories","results","PlaygroundBlame","causeText","cause","effect","row","cell","NONE","decisionFor","decision","sliderStart","sliders","settable","checkVerdicts","verdicts","isPair","dsep","dsepPairs","pairs","y","checkTrack","track","activeQuery","actual","size","queries","q","presetButtons","presets","hold","PlaygroundVerdicts","query","active","groups","g","onShow","trailEntry","values","world","trailText","steps","trail","e","dropped","useTrail","startTrail","setTrail","useState","setting","entries","CausalPlayground","props","PlaygroundBody","resolved","doc","PlaygroundFor","base","NO_TRACK","startPrior","start","useMemo","sliderValues","setSliderValues","focused","focusSliders","hidden","allSliders","setAllSliders","reading","setReading","initialInterventions","defaultNotation","switchReading","next","kept","setObserved","useRef","hoverNode","setHoverNode","hoverSlider","setHoverSlider","litNodes","litSliders","setSlider","now","moved","resetSliders","restartTrail","sliderId","useId","embedded","setDo","held","setHeld","soft","buttons","prob","defaults","normality","pairAt","setPairAt","dsepNow","blamed","shownQuery","setShownQuery","holding","stepIndex","setStepIndex","step","required","applyPreset","within","part","holds","pressedSize","pressed","embedUrl","caseId","blocks","setNotation","initialBlock","embed","exportUrl","openPanel","EmbedCredit","noSubscription","home","useSyncExternalStore"],"sources":["../../src/components/export/embed.ts","../../src/components/shared/tab-height.ts","../../src/components/playground/DecisionBars.tsx","../../src/components/playground/DsepLine.tsx","../../src/components/playground/blame-view.ts","../../src/components/playground/PlaygroundBlame.tsx","../../src/components/playground/playground-options.ts","../../src/components/playground/PlaygroundVerdicts.tsx","../../src/components/playground/trail.ts","../../src/components/playground/use-trail.ts","../../src/components/playground/CausalPlayground.tsx"],"sourcesContent":["import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, Value } from '../../engine/index.ts'\nimport { coerceToDomain } from '../../engine/index.ts'\nimport { DATA_LICENSE, DEFAULT_URL, authorYear, authorYearEn } from './cite.ts'\nimport { formatDo, formatPdo, parseDo, parsePdo } from './url-state.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { messagesFor } from '../i18n/messages.ts'\nimport { solve } from '../model/model-state.ts'\nimport type { Stochastic } from '../model/assignments.ts'\n\n/**\n * An embedded figure's state in its address: `#do=<id>:<value>,…&pdo=<id>:<p>,…&obs=<id>:<value>,…`,\n * the same encoding as the editor's `do=` and `pdo=`.\n */\nexport interface EmbedState {\n readonly interventions: Assignment\n readonly stochastic: Stochastic\n readonly observed: Assignment\n}\n\n/** Where a bundled case's embed page lives by default: `<base>case/<id>/`. */\nexport const DEFAULT_EMBED_BASE = 'https://wayneh.tw/causal/embed/'\n\nfunction param(hash: string, name: string): string | undefined {\n return new RegExp(`[#?&]${name}=([^&]*)`).exec(hash)?.[1]\n}\n\n/** The state part of an embed address, without `#`; '' when nothing is set. */\nexport function embedFragment(state: EmbedState): string {\n const parts: string[] = []\n const d = formatDo(state.interventions)\n const p = formatPdo(state.stochastic)\n const o = formatDo(state.observed)\n if (d !== '') parts.push(`do=${d}`)\n if (p !== '') parts.push(`pdo=${p}`)\n if (o !== '') parts.push(`obs=${o}`)\n return parts.join('&')\n}\n\n/** Reads `embedFragment`'s text from a hash; numerals become numbers (coerced to each domain by the reader). */\nexport function readEmbedState(hash: string): EmbedState {\n const d = param(hash, 'do')\n const p = param(hash, 'pdo')\n const o = param(hash, 'obs')\n return {\n interventions: d === undefined ? {} : parseDo(d),\n stochastic: p === undefined ? {} : parsePdo(p),\n observed: o === undefined ? {} : parseDo(o),\n }\n}\n\n/**\n * The embed page's address: `src`, with `lang=en` for an English figure, `from` (the page the figure\n * was copied from) and the state.\n */\nexport function embedSrc(src: string, state: EmbedState, from?: string, locale?: Locale): string {\n const url = new URL(src)\n if (locale === 'en') url.searchParams.set('lang', 'en')\n if (from !== undefined && from !== '') url.searchParams.set('from', from)\n const fragment = embedFragment(state)\n url.hash = fragment\n return url.toString()\n}\n\nfunction escapeAttr(text: string): string {\n return text.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>')\n}\n\nfunction escapeText(text: string): string {\n return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')\n}\n\nexport interface EmbedCodeOptions {\n readonly src: string\n readonly title: string\n readonly height: number\n readonly locale: Locale\n /** Link in the citation. Default: the project repository. */\n readonly url?: string\n /** Full citations of the case's origin sources, cited after the project. */\n readonly origins?: readonly string[]\n}\n\n/**\n * What a reader pastes to embed the figure: the iframe, then the citation as it is given for the\n * academic image (author-year, licence, the case's own sources), so the credit stays beside it.\n */\nexport function embedCode({ src, title, height, locale, url = DEFAULT_URL, origins = [] }: EmbedCodeOptions): string {\n const m = messagesFor(locale).export\n const cite = locale === 'en' ? authorYearEn(url) : authorYear(url)\n const parts = [cite, m.embedLicence(DATA_LICENSE), ...(origins.length === 0 ? [] : [m.embedSources(origins)])]\n return [\n `<iframe src=\"${escapeAttr(src)}\" title=\"${escapeAttr(m.embedTitle(title))}\" width=\"100%\" height=\"${Math.round(height)}\" style=\"border:0;max-width:100%\" loading=\"lazy\"></iframe>`,\n `<p>${escapeText(parts.join(' '))}</p>`,\n ].join('\\n')\n}\n\n/**\n * Where an embedded figure's credit links: `from` when it is a path on the embed page's own site\n * (the page the figure was copied from), else the project page.\n */\nexport function embedHome(search: string, origin: string, fallback: string = 'https://wayneh.tw/causal/'): string {\n const from = new URLSearchParams(search).get('from')\n if (from === null || !from.startsWith('/') || from.startsWith('//')) return fallback\n return `${origin}${from}`\n}\n\nfunction endogenous(c: LoadedCase, a: Assignment): Assignment {\n const out: Record<string, Value> = {}\n for (const [id, value] of Object.entries(a)) {\n const v = c.model.byId.get(id)\n if (v === undefined || v.kind === 'exogenous') continue\n try {\n out[id] = coerceToDomain(v, value)\n } catch {\n try {\n // A numeral read from the address may name a text value, e.g. '2'.\n if (typeof value === 'number') out[id] = coerceToDomain(v, String(value))\n } catch {\n // dropped: not a value of this variable\n }\n }\n }\n return out\n}\n\n/**\n * The part of an embed address's state that fits the case: endogenous variables with values in\n * their domains; stochastic interventions and observations only when the case is drawn with\n * probabilities, on nodes not set otherwise; observations dropped when they cannot happen.\n */\nexport function fitEmbedState(c: LoadedCase, state: EmbedState): EmbedState {\n const interventions = endogenous(c, state.interventions)\n if (c.context !== undefined) return { interventions, stochastic: {}, observed: {} }\n const stochastic: Record<string, number> = {}\n for (const [id, p] of Object.entries(state.stochastic)) {\n const v = c.model.byId.get(id)\n if (v === undefined || v.kind === 'exogenous' || v.domain.kind !== 'boolean' || id in interventions || !(p > 0 && p < 1)) continue\n stochastic[id] = p\n }\n const observed: Record<string, Value> = {}\n for (const [id, value] of Object.entries(endogenous(c, state.observed))) {\n if (!(id in interventions) && !(id in stochastic)) observed[id] = value\n }\n if (Object.keys(observed).length > 0 && !((solve(c, interventions, stochastic, observed).evidence ?? 1) > 0)) {\n return { interventions, stochastic, observed: {} }\n }\n return { interventions, stochastic, observed }\n}\n","/**\n * The height of `root` as an embed page draws it: with only the `initial` block open (none when\n * undefined), whatever the reader has open now. Panels are unhidden and hidden again in the same\n * task, so nothing is painted in between.\n */\nexport function heightAtInitialBlock(root: HTMLElement | null, initial: string | undefined, fallback: number): number {\n if (root === null) return fallback\n const panels = [...root.querySelectorAll<HTMLElement>('[data-tab-panel]')]\n const was = panels.map((p) => p.hidden)\n for (const p of panels) p.hidden = p.dataset.tabPanel !== initial\n const height = root.offsetHeight\n panels.forEach((p, i) => {\n p.hidden = was[i]\n })\n return height\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, DecisionProblem, Value } from '../../engine/index.ts'\nimport { evaluateDecision, formatValue, getVariable, valuesEqual } from '../../engine/index.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { Formula, Rich } from '../text/typeset.tsx'\nimport { ExpectedUtility } from '../text/ExpectedUtility.tsx'\nimport { fixed } from '../model/wording.ts'\n\nexport interface DecisionBarsProps {\n readonly c: LoadedCase\n readonly problem: DecisionProblem\n /** The act observed lights its evidential bar; the act set by do() its causal bar. */\n readonly observed: Assignment\n readonly interventions: Assignment\n}\n\n/** An expected utility as the bars write it: two decimals, a true minus, thousands grouped from 1,000. */\nfunction euText(eu: number): string {\n const s = fixed(eu, 2)\n const [int, frac] = s.replace('-', '').split('.')\n const grouped = Math.abs(eu) >= 1000 ? int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',') : int\n return `${eu < 0 && s !== '-0.00' ? '−' : ''}${grouped}.${frac}`\n}\n\n/**\n * Expected utility of each act, one row per theory (evidential, causal) and one bar per act on a\n * shared zero, with the act each picks and by how much. Observing the act lights its evidential\n * bar (its weights are what the graph now shows); do() on it lights its causal bar.\n */\nexport function DecisionBars({ c, problem, observed, interventions }: DecisionBarsProps) {\n const t = useMessages()\n const prior = c.prior\n if (prior === undefined) throw new Error(`${c.data.id}: decision needs probabilities`)\n const raw = evaluateDecision(c.model, prior, problem)\n // A boolean act reads 1 first, as the nodes do; listed acts keep their order.\n const boolAct = problem.acts === undefined && getVariable(c.model, problem.act).domain.kind === 'boolean'\n const result = boolAct ? { ...raw, acts: [...raw.acts].sort((a, b) => Number(b.act === true) - Number(a.act === true)) } : raw\n const actText = (a: Value): string => `${problem.act}=${formatValue(a)}`\n const all = result.acts.flatMap((a) => [a.cdt.eu, ...(a.edt === undefined ? [] : [a.edt.eu])])\n const lo = Math.min(0, ...all)\n const hi = Math.max(0, ...all)\n const span = hi - lo > 0 ? hi - lo : 1\n const at = (v: number): number => ((v - lo) / span) * 100\n const zero = at(0)\n const seen = observed[problem.act]\n const done = interventions[problem.act]\n const rows = (['edt', 'cdt'] as const).map((theory) => {\n const eus = result.acts.map((a) => (theory === 'edt' ? a.edt?.eu : a.cdt.eu))\n const choice = theory === 'edt' ? result.edtChoice : result.cdtChoice\n const best = Math.max(...eus.filter((e): e is number => e !== undefined))\n const rest = eus.filter((e, i): e is number => e !== undefined && !choice.some((ch) => valuesEqual(ch, result.acts[i].act)))\n const by = choice.length === 1 && rest.length > 0 ? euText(best - Math.max(...rest)) : undefined\n const lit = theory === 'edt' ? seen : done\n return { theory, eus, choice: t.ev.choose(t.list(choice.map(actText)), by), lit }\n })\n const utilityLines = problem.utility.rows.map(\n (r) => `U(${problem.utility.variables.map((id, i) => `${id}=${formatValue(r.when[i])}`).join(', ')}) = ${fixed(r.utility, 2).replace(/\\.00$/, '')}`,\n )\n return (\n <div className=\"ca-ev\" style={{ ['--ca-ev-acts' as string]: result.acts.length }}>\n <p className=\"ca-ev-head\">\n <span className=\"ca-pg-now-kicker\">{t.ev.title}</span>{' '}\n <Tip\n label={t.moreInfo}\n tip={\n <>\n {utilityLines.map((line, i) => <span key={line}>{i > 0 && t.clauses(['', ''])}<Formula text={line} /></span>)}\n <br />\n <ExpectedUtility theory=\"EDT\" />{t.eu.edt}\n <br />\n <ExpectedUtility theory=\"CDT\" />{t.eu.cdt}\n </>\n }\n />\n </p>\n <div className=\"ca-ev-grid\" role=\"table\" aria-label={t.ev.title}>\n <div className=\"ca-ev-row ca-ev-acts\" role=\"row\">\n <span role=\"columnheader\" />\n {result.acts.map((a) => (\n <span key={String(a.act)} role=\"columnheader\" className=\"ca-ev-act ca-mono\">\n <Rich text={actText(a.act)} ids={c.model.byId} />\n </span>\n ))}\n <span role=\"columnheader\" />\n </div>\n {rows.map((r) => (\n <div key={r.theory} className=\"ca-ev-row\" role=\"row\" data-ev-row={r.theory}>\n <span role=\"rowheader\" className=\"ca-ev-name\">\n {t.ev[r.theory]}\n </span>\n {result.acts.map((a, i) => {\n const v = r.eus[i]\n const lit = r.lit !== undefined && valuesEqual(r.lit, a.act)\n const left = v === undefined ? zero : Math.min(zero, at(v))\n const width = v === undefined ? 0 : Math.abs(at(v) - zero)\n return (\n <span key={String(a.act)} role=\"cell\" className=\"ca-ev-cell\" data-ev-act={formatValue(a.act)} data-lit={lit ? 'true' : undefined}>\n <span\n className=\"ca-ev-num ca-mono\"\n data-ev-value={v === undefined ? '—' : fixed(v, 2)}\n style={{ left: `${left}%`, width: `${width}%`, textAlign: v !== undefined && v < 0 ? 'right' : 'left' }}\n >\n {v === undefined ? '—' : euText(v)}\n </span>\n <span className=\"ca-ev-track\">\n <span className=\"ca-ev-zero\" style={{ left: `${zero}%` }} />\n {v !== undefined && <span className=\"ca-ev-bar\" style={{ left: `${left}%`, width: `${width}%` }} />}\n </span>\n </span>\n )\n })}\n <span role=\"cell\" className=\"ca-ev-choice\">\n <Rich text={r.choice} ids={c.model.byId} />\n </span>\n </div>\n ))}\n </div>\n </div>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment } from '../../engine/index.ts'\nimport type { DsepPair, DsepView } from '../model/dsep-view.ts'\nimport { MAX_PATHS, deltaText, pathReason, pathText } from '../model/dsep-view.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { Formula, MathProse, Rich } from '../text/typeset.tsx'\n\n/** The line under the graph: the pair, what is known, open or blocked, δ, and up to three paths with why. */\nexport function DsepLine({ c, pair, observed, view }: { readonly c: LoadedCase; readonly pair: DsepPair; readonly observed: Assignment; readonly view: DsepView }) {\n const t = useMessages()\n const d = t.dsep\n const ids = c.model.byId\n const { result } = view\n const shown = result.paths.slice(0, MAX_PATHS)\n const known = Object.keys(observed)\n return (\n <div className=\"ca-dsep-line\" data-dsep={result.separated ? 'blocked' : 'open'}>\n <p className=\"ca-dsep-head\">\n <span className=\"ca-pg-now-kicker\"><Rich text={d.pair(pair[0], pair[1])} ids={ids} /></span>{' '}\n <Rich text={d.known(known)} ids={ids} /> → <strong>{result.separated ? d.blocked : d.open}</strong>\n{' '}\n <span className=\"ca-dsep-delta ca-mono\">{d.delta(deltaText(view.delta))}</span> <Tip tip={<MathProse text={d.tip} math={{ '|P(x,y|z) − P(x|z)P(y|z)|': '\\\\left|P(x,y\\\\mid z)-P(x\\\\mid z)P(y\\\\mid z)\\\\right|' }} />} label={t.moreInfo} />\n </p>\n <ul className=\"ca-dsep-paths\">\n {result.paths.length === 0 && <li>{d.noPath}</li>}\n {shown.map((p) => (\n <li key={p.nodes.join('-')} data-path-open={p.open ? 'true' : 'false'}>\n <Formula text={pathText(p)} ids={ids} />\n {d.pathSep}\n <Rich text={pathReason(t, p)} ids={ids} />\n </li>\n ))}\n {result.paths.length > MAX_PATHS && <li>{d.more(result.paths.length - MAX_PATHS)}</li>}\n </ul>\n </div>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport { priorOf } from '../../data/load.ts'\nimport type { ModelDoc } from '../../data/schema.ts'\nimport type { BlameResult, LocalizedText, Prior, ResponsibilityTheory } from '../../engine/index.ts'\nimport { blame, ModelError, parseCause, problem } from '../../engine/index.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { cfText } from '../probability/cf-steps.ts'\n\n/** Pure helpers for the playground's 責備 block: Halpern's degree of blame (2016, Def. 6.2.1) per epistemic state and standard. */\n\n/** One epistemic state: the probabilities the agent has (a model document's `priors`), and what has been observed since. */\nexport interface BlameState {\n /** What the state is called in the table; default `文件裡的機率` / \"The document's probabilities\". */\n readonly label?: string | LocalizedText\n /** The state's probabilities in the model document's `priors` format; default the document's own. */\n readonly prior?: NonNullable<ModelDoc['priors']>\n /** An observation that narrows the state, e.g. `D=1` (the outcome seen after acting). */\n readonly given?: string\n}\n\n/** `blame={{ cause: 'T=1', effect: 'D=1', states: [...] }}` on `CausalPlayground`. */\nexport interface BlameSpec {\n /** A single event X=x. */\n readonly cause: string\n /** The outcome φ. */\n readonly effect: string\n /** The Halpern–Pearl standards to compute under; default the three HP definitions, and HP with normality when the model has defaults. */\n readonly theories?: readonly ResponsibilityTheory[]\n /** The epistemic states, one row each; default one, the document's own `priors`. */\n readonly states?: readonly BlameState[]\n}\n\nexport interface BlameStateView {\n /** The row's name, in the table's language; undefined for the document's own probabilities. */\n readonly label?: string\n readonly given?: string\n /** Backgrounds of the state (positive probability, `cause` holding). */\n readonly contexts: number\n readonly results: Readonly<Record<ResponsibilityTheory, BlameResult>>\n}\n\nexport interface BlameView {\n readonly theories: readonly ResponsibilityTheory[]\n readonly states: readonly BlameStateView[]\n}\n\n/** The standards blame is computed under by default for this case. */\nexport function defaultBlameTheories(c: LoadedCase): ResponsibilityTheory[] {\n const out: ResponsibilityTheory[] = ['hp-original', 'hp-updated', 'hp-modified']\n if (c.normality !== undefined) out.push('hp-normality')\n return out\n}\n\n/** A degree of blame or responsibility: `0`, `1`, or at most four decimals, at least two. */\nexport function degreeNumber(x: number): string {\n return x === 0 ? '0' : x === 1 ? '1' : cfText(x)\n}\n\n/**\n * The blame of `spec.cause` for `spec.effect` in each epistemic state under each standard. Throws\n * when the document has no `priors` and no state gives one, and with the engine's own errors (a\n * cause that is not a single event, a standard that is not an HP definition, a search past its budget).\n */\nexport function blameView(c: LoadedCase, spec: BlameSpec, locale: Locale): BlameView {\n const given: readonly BlameState[] = spec.states ?? [{}]\n if (given.length === 0) throw new Error(`${c.data.id}: blame needs at least one state`)\n parseCause(c.model, spec.cause)\n const own: Prior | undefined = c.data.priors === undefined ? undefined : c.prior\n const theories = spec.theories ?? defaultBlameTheories(c)\n if (theories.length === 0) throw new ModelError(problem('blame-no-theories', {}))\n const states = given.map((state): BlameStateView => {\n const prior = state.prior === undefined ? own : priorOf(state.prior, c.model)\n if (prior === undefined) throw new Error(`${c.data.id}: blame needs priors, in the document or in each state`)\n const results = Object.fromEntries(\n theories.map((theory) => [\n theory,\n blame(c.model, prior, { cause: spec.cause, effect: spec.effect, given: state.given }, theory, { normality: c.normality }),\n ]),\n ) as Record<ResponsibilityTheory, BlameResult>\n const label = state.label === undefined ? undefined : typeof state.label === 'string' ? state.label : state.label[locale]\n return { label, given: state.given, contexts: results[theories[0]]?.rows.length ?? 0, results }\n })\n return { theories, states }\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { degreeText } from '../model/verdict-rows.ts'\nimport { assignmentText } from '../model/wording.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { Formula, Rich } from '../text/typeset.tsx'\nimport type { BlameView } from './blame-view.ts'\nimport { degreeNumber } from './blame-view.ts'\n\nexport interface PlaygroundBlameProps {\n readonly c: LoadedCase\n readonly cause: string\n readonly effect: string\n readonly view: BlameView\n}\n\n/**\n * Under a playground's graph: the degree of blame (Halpern 2016, Def. 6.2.1) of one event for an\n * outcome, one row per epistemic state and one column per standard; each state's backgrounds, their\n * probabilities and the responsibility in each, behind a fold.\n */\nexport function PlaygroundBlame({ c, cause, effect, view }: PlaygroundBlameProps) {\n const t = useMessages()\n const ids = c.model.byId\n const causeText = cause.replace(/\\s+and\\s+/g, ' ∧ ')\n const name = (i: number): string => view.states[i].label ?? t.blame.documentState\n return (\n <div className=\"ca-pg-blame\" data-blame-block=\"\">\n <p className=\"ca-pg-question\">\n <Rich text={t.blame.question(causeText, effect)} ids={ids} /> <Tip tip={<Rich text={t.blame.tip(causeText)} ids={ids} />} label={t.moreInfo} />\n </p>\n <div className=\"ca-scroll-x\">\n <table className=\"ca-cf-table ca-blame-table\" data-testid=\"blame-table\">\n <thead>\n <tr>\n <th scope=\"col\">{t.blame.state}</th>\n {view.theories.map((theory) => (\n <th key={theory} scope=\"col\">\n {t.theory[theory]}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {view.states.map((state, i) => (\n <tr key={i} data-state={i}>\n <th scope=\"row\">\n {name(i)}\n {state.given !== undefined && (\n <>\n {' · '}\n <Rich text={t.blame.given(state.given)} ids={ids} />\n </>\n )}\n <span className=\"ca-muted ca-small ca-blame-count\"> · {t.blame.contexts(state.contexts)}</span>\n </th>\n {view.theories.map((theory) => (\n <td key={theory} className=\"ca-mono\" data-blame={theory} data-degree={state.results[theory].degree.toFixed(6)}>\n {degreeNumber(state.results[theory].degree)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {view.states.map((state, i) => (\n <details key={i} className=\"ca-blame-fold\" data-fold={i}>\n <summary>\n {name(i)} · {t.blame.fold(state.contexts)}\n </summary>\n <div className=\"ca-blame-fold-table\">\n <table className=\"ca-cf-table\">\n <thead>\n <tr>\n <th scope=\"col\"><Rich text={t.blame.background(c.model.exogenous)} ids={ids} /></th>\n <th scope=\"col\">{t.blame.probability}</th>\n {view.theories.map((theory) => (\n <th key={theory} scope=\"col\">\n {t.blame.responsibility(t.theory[theory])}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {state.results[view.theories[0]].rows.map((row, r) => (\n <tr key={assignmentText(row.context)} data-background={assignmentText(row.context)}>\n <th scope=\"row\">\n <Formula text={assignmentText(row.context)} />\n </th>\n <td className=\"ca-mono\">{degreeNumber(row.p)}</td>\n {view.theories.map((theory) => {\n const cell = state.results[theory].rows[r]\n return (\n <td key={theory} className=\"ca-mono\" data-responsibility={degreeText({ degree: cell.responsibility, k: cell.k })}>\n {degreeText({ degree: cell.responsibility, k: cell.k })}\n </td>\n )\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </details>\n ))}\n </div>\n )\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport { decisionProblem } from '../../data/load.ts'\nimport type { CaseDecision } from '../../data/schema.ts'\nimport type { Assignment, DecisionProblem, LocalizedText } from '../../engine/index.ts'\nimport { coerceToDomain, evaluate, getVariable, parseCause, valuesEqual } from '../../engine/index.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport type { DsepPair } from '../model/dsep-view.ts'\nimport { defaultSliders, sliderVariables } from '../model/probability-view.ts'\nimport type { VerdictQuery } from '../model/verdict-rows.ts'\n\n/**\n * CausalPlayground's props read against the case: the presets as buttons, the slider start values,\n * the decision problem, the dsep pairs and the query in force. A prop the case cannot take throws\n * here, with the message the playground has always thrown.\n */\n\nexport const NONE: Assignment = {}\n\n/**\n * A step button under the graph: one press sets these do()s and observations (and nothing else).\n * A bundled case brings its own (do() only); a document takes a list.\n */\nexport interface PlaygroundPreset {\n readonly label: string | LocalizedText\n /** do() to set. */\n readonly interventions?: Assignment\n /** Observations to set; probability graphs only (a graph with values throws). */\n readonly observed?: Assignment\n /**\n * Variables an HP witness holds fixed: set by do() like `interventions`, but drawn in the amber\n * hull (固定) instead of with a clamp.\n */\n readonly hold?: Assignment\n /** Name of this step’s test (defaults to the button label). */\n readonly test?: string | LocalizedText\n /** Required outcome on a graph with values. After a click, compare each entry with the solved world. */\n readonly expect?: Assignment\n}\n\n/** A step button: its text and what one press sets. */\nexport interface PresetButton {\n readonly text: string\n readonly test?: string\n readonly expect?: Assignment\n /** Every do(), the held variables included. */\n readonly interventions: Assignment\n readonly observed: Assignment\n readonly hold: Assignment\n}\n\n/** The decision problem the bars show: the case's own for `true`. */\nexport function decisionFor(c: LoadedCase, decision: true | CaseDecision | undefined): DecisionProblem | undefined {\n if (decision === undefined) return undefined\n if (c.context !== undefined || c.prior === undefined) throw new Error(`${c.data.id}: decision needs a probability graph (priors, no context)`)\n if (decision !== true) return decisionProblem(decision)\n if (c.decision === undefined) throw new Error(`${c.data.id}: decision={true} needs the case's own decision; give one instead`)\n return c.decision\n}\n\n/** The sliders' and `prior`'s start values; throws on a variable no slider can set. */\nexport function sliderStart(c: LoadedCase, sliders: readonly string[], prior: Readonly<Record<string, number>> | undefined): Record<string, number> {\n const ids = [...sliders, ...Object.keys(prior ?? {})]\n if (ids.length === 0) return {}\n if (c.context !== undefined || c.prior === undefined) throw new Error(`${c.data.id}: sliders and prior need a probability graph (priors, no context)`)\n const settable = new Set(sliderVariables(c))\n for (const id of ids) {\n getVariable(c.model, id)\n if (!settable.has(id)) throw new Error(`${c.data.id}: no slider can set ${id} (a boolean or two-valued exogenous variable, independent prior)`)\n }\n for (const [id, p] of Object.entries(prior ?? {})) {\n if (!(p >= 0 && p <= 1)) throw new Error(`${c.data.id}: prior ${id} = ${p} is not a probability`)\n }\n const own = defaultSliders(c)\n return Object.fromEntries(ids.map((id) => [id, prior?.[id] ?? own[id]]))\n}\n\n/** Throws when `verdicts` are given for a graph without values (no actual context). */\nexport function checkVerdicts(c: LoadedCase, verdicts: readonly VerdictQuery[] | undefined): void {\n if (verdicts !== undefined && c.context === undefined) throw new Error(`${c.data.id}: verdicts need a graph with values (an actual context)`)\n}\n\nfunction isPair(dsep: DsepPair | readonly DsepPair[]): dsep is DsepPair {\n return typeof dsep[0] === 'string'\n}\n\n/** The dsep pairs as a list; throws unless the graph has probabilities and both ends of each are its variables. */\nexport function dsepPairs(c: LoadedCase, dsep: DsepPair | readonly DsepPair[] | undefined): readonly DsepPair[] {\n const pairs: readonly DsepPair[] = dsep === undefined ? [] : isPair(dsep) ? [dsep] : dsep\n if (pairs.length > 0 && (c.context !== undefined || c.prior === undefined)) throw new Error(`${c.data.id}: dsep needs a probability graph (priors, no context)`)\n for (const [x, y] of pairs) {\n getVariable(c.model, x)\n getVariable(c.model, y)\n }\n return pairs\n}\n\n/** Throws on a tracked id that names no variable. */\nexport function checkTrack(c: LoadedCase, track: readonly string[]): void {\n for (const id of track) getVariable(c.model, id)\n}\n\n/** The most specific cause set by these non-held interventions, not all at actual values; else the first. */\nexport function activeQuery(c: LoadedCase, queries: readonly VerdictQuery[], interventions: Assignment): number {\n const actual = c.context === undefined ? NONE : evaluate(c.model, c.context).values\n let best = 0\n let size = 0\n queries.forEach((q, i) => {\n const cause = parseCause(c.model, q.cause)\n const ids = Object.keys(cause)\n if (ids.length > size && ids.every((id) => id in interventions) && ids.some((id) => !valuesEqual(interventions[id], actual[id]))) {\n best = i\n size = ids.length\n }\n })\n return best\n}\n\n/** The step buttons: a bundled case's own showcase for `true`, the given list, or none; held variables are set by do() too. */\nexport function presetButtons(c: LoadedCase, presets: boolean | readonly PlaygroundPreset[], locale: Locale): PresetButton[] {\n if (presets === false) return []\n const list: readonly PlaygroundPreset[] = presets === true ? c.data.showcase : presets\n return list.map((s) => {\n const text = typeof s.label === 'string' ? s.label : s.label[locale]\n const observed = s.observed ?? NONE\n if (c.context !== undefined && Object.keys(observed).length > 0) {\n throw new Error(`preset \"${text}\": observed needs probabilities, and ${c.data.id} has an actual context`)\n }\n const hold = s.hold ?? NONE\n if (s.expect !== undefined) {\n if (c.context === undefined || Object.keys(s.expect).length === 0) throw new Error(`preset \"${text}\": expect needs an outcome and an actual context`)\n for (const [id, value] of Object.entries(s.expect)) coerceToDomain(getVariable(c.model, id), value)\n }\n return { text, test: typeof s.test === 'string' ? s.test : s.test?.[locale], expect: s.expect, interventions: { ...(s.interventions ?? NONE), ...hold }, observed, hold }\n })\n}\n","import type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment, CausalTheory } from '../../engine/index.ts'\nimport { useMessages } from '../i18n/messages.ts'\nimport { Tip } from '../shared/parts.tsx'\nimport { MathProse, Rich } from '../text/typeset.tsx'\nimport type { ActualGroup, ActualRow, VerdictQuery } from '../model/verdict-rows.ts'\nimport { degreeText, witnessNow } from '../model/verdict-rows.ts'\n\nexport interface PlaygroundVerdictsProps {\n readonly c: LoadedCase\n readonly groups: readonly ActualGroup[]\n readonly queries: readonly VerdictQuery[]\n readonly theories: readonly (readonly CausalTheory[])[]\n /** The query the 目前的世界 line answers. */\n readonly active: number\n readonly interventions: Assignment\n /** 在圖上看: set the witness, the cause at x⃗′ and W⃗ held at w⃗. */\n readonly onShow: (row: ActualRow, query: number) => void\n}\n\n/**\n * Under a playground's graph: for each query one row of verdicts, a standard per cell, each with\n * 在圖上看 when the engine found a witness; then whether the world on the graph is a witness.\n */\nexport function PlaygroundVerdicts({ c, groups, queries, theories, active, interventions, onShow }: PlaygroundVerdictsProps) {\n const t = useMessages()\n const ids = c.model.byId\n const query = queries[active]\n return (\n <div className=\"ca-pg-verdicts\">\n {groups.map((g) => (\n <section key={`${g.cause}⇒${g.effect}`} className=\"ca-pg-verdict-group\" data-query={`${g.cause}⇒${g.effect}`}>\n <p className=\"ca-pg-question\">\n <Rich text={t.witness.question(g.cause.replace(/\\s+and\\s+/g, ' ∧ '), g.effect)} ids={ids} />\n </p>\n <ul className=\"ca-pg-cells\">\n {g.rows.map((r) => (\n <li key={r.theory} className={`ca-pg-cell is-${r.verdict}`} data-verdict-cell={r.theory} data-verdict={r.verdict}>\n <span className=\"ca-pg-theory\">{t.theory[r.theory]}</span>\n <span className=\"ca-pg-answer\">\n <strong>{t.witness.answer[r.verdict]}</strong>\n {r.verdict === 'cause' && r.show !== undefined && (\n <>\n {' · '}\n <button type=\"button\" className=\"ca-link\" onClick={() => onShow(r, queries.findIndex((q) => q.cause === g.cause && q.effect === g.effect && (q.theories === undefined || q.theories.includes(r.theory))))}>\n {t.showOnGraph}\n </button>\n </>\n )}\n </span>\n {r.responsibility !== undefined && (\n <span className=\"ca-pg-resp\" data-responsibility={degreeText(r.responsibility)}>\n <MathProse text={t.resp.cell(degreeText(r.responsibility))} math={{ [degreeText(r.responsibility)]: degreeText(r.responsibility) }} />{' '}\n <Tip\n tip={\n r.responsibility.k === undefined\n ? t.resp.tipZero\n : <MathProse\n text={t.resp.tip(r.responsibility.k, r.responsibility.held ?? '', r.responsibility.cause ?? '', r.theory === 'hp-normality')}\n math={{ '1/k': '1/k', [`k = ${r.responsibility.k}`]: `k=${r.responsibility.k}`, k: 'k' }}\n ids={ids}\n />\n }\n label={t.moreInfo}\n />\n </span>\n )}\n </li>\n ))}\n </ul>\n </section>\n ))}\n {query !== undefined && (\n <div className=\"ca-pg-now\" data-witness-now=\"\">\n <span className=\"ca-pg-now-kicker\">{t.witness.now}</span>{' '}\n <Rich text={Object.keys(interventions).length === 0 ? t.witness.untouched : witnessNow(t, c, query, theories[active] ?? [], interventions, groups.find((g) => g.cause === query.cause && g.effect === query.effect)?.rows ?? [])} ids={ids} />\n <details className=\"ca-witness-help\">\n <summary className=\"ca-link\">ⓘ {t.moreInfo}</summary>\n <Rich text={t.witness.tip} ids={ids} narrative />\n </details>\n </div>\n )}\n </div>\n )\n}\n","import type { Assignment } 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 trail under a playground graph: the tracked nodes' readings after each change of what is set. */\n\n/** One reading of a trail: what was set (`settingText`, '' for nothing) and each tracked node's number or value. */\nexport interface TrailEntry {\n readonly setting: string\n readonly values: Readonly<Record<string, string>>\n}\n\n/** Entries a trail keeps; older ones give way to `…`. */\nexport const TRAIL_LENGTH = 5\n\n/** The tracked nodes' numbers (a probability graph) or values in `world`, as text. */\nexport function trailEntry(world: { readonly probs?: Readonly<Record<string, number>>; readonly values?: Assignment }, ids: readonly string[], setting: string): TrailEntry {\n const values: Record<string, string> = {}\n for (const id of ids) {\n const p = world.probs?.[id]\n const v = world.values?.[id]\n values[id] = p !== undefined ? probText(p) : v !== undefined ? formatValue(v) : '—'\n }\n return { setting, values }\n}\n\n/** `Y:0.50 → 0.67(Z=1)→ 0.50(Z=1, X=1)`, with `…` first when older readings were dropped. */\nexport function trailText(t: Messages, id: string, trail: readonly TrailEntry[], dropped: boolean): string {\n const steps = trail.map((e) => t.trailStep(e.values[id] ?? '—', e.setting))\n return t.trailLine(id, steps, dropped)\n}\n","import { useState } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { Assignment } from '../../engine/index.ts'\nimport { solve } from '../model/model-state.ts'\nimport type { TrailEntry } from './trail.ts'\nimport { TRAIL_LENGTH, trailEntry } from './trail.ts'\n\n/** The trail of the tracked nodes: the last readings, and whether older ones gave way. */\nexport interface Trail {\n readonly entries: readonly TrailEntry[]\n /** Older readings gave way to the last TRAIL_LENGTH. */\n readonly dropped: boolean\n}\n\n/**\n * The trail under the graph: a reading of the tracked nodes is added, during render, whenever what\n * is set (`setting`) changes; `restart` starts it again from the case with nothing set.\n */\nexport function useTrail(\n c: LoadedCase,\n track: readonly string[],\n world: { readonly probs?: Readonly<Record<string, number>>; readonly values?: Assignment },\n setting: string,\n): readonly [Trail, () => void] {\n const startTrail = (): Trail => ({ entries: [trailEntry(solve(c, {}), track, '')], dropped: false })\n const [trail, setTrail] = useState<Trail>(startTrail)\n if (track.length > 0 && trail.entries[trail.entries.length - 1]?.setting !== setting) {\n const entries = [...trail.entries, trailEntry(world, track, setting)]\n setTrail({ entries: entries.slice(-TRAIL_LENGTH), dropped: trail.dropped || entries.length > TRAIL_LENGTH })\n }\n return [trail, () => setTrail(startTrail())]\n}\n","import { useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from 'react'\nimport type { LoadedCase } from '../../data/load.ts'\nimport type { CaseDecision, ModelDoc } from '../../data/schema.ts'\nimport type { Assignment } from '../../engine/index.ts'\nimport { valuesEqual } from '../../engine/index.ts'\nimport { DEFAULT_URL, watermarkLine } from '../export/cite.ts'\nimport { DEFAULT_EMBED_BASE, embedCode, embedHome, embedSrc, fitEmbedState, readEmbedState } from '../export/embed.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { LocaleScope, useMessages } from '../i18n/messages.ts'\nimport { DigitsScope } from '../shared/digits.ts'\nimport { sameAssignment } from '../model/assignments.ts'\nimport { CaseGate } from '../model/CaseGate.tsx'\nimport { casesOf } from '../model/cases-of.ts'\nimport { useCaseOrDoc } from '../model/doc-case.ts'\nimport type { DsepPair } from '../model/dsep-view.ts'\nimport { dsepView } from '../model/dsep-view.ts'\nimport type { Reading } from '../model/model-state.ts'\nimport { useModel } from '../model/model-state.ts'\nimport { normalityLine } from '../model/normality-view.ts'\nimport type { UiNotation } from '../model/notation.ts'\nimport { priorWithSliders } from '../model/probability-view.ts'\nimport { nodeSliders, sliderTargets } from '../model/slider-groups.ts'\nimport type { VerdictQuery } from '../model/verdict-rows.ts'\nimport { actualGroups, defaultTheories, originCitations, originSources } from '../model/verdict-rows.ts'\nimport { assignmentText, readingText } from '../model/wording.ts'\nimport { EquationPanel } from '../panels/EquationBox.tsx'\nimport { GraphBox } from '../panels/GraphBox.tsx'\nimport { SliderList } from '../panels/SliderList.tsx'\nimport type { FigureBlock } from '../shared/FigureTabs.tsx'\nimport { heightAtInitialBlock } from '../shared/tab-height.ts'\nimport { DocProblems, Segmented, Tip } from '../shared/parts.tsx'\nimport { Rich } from '../text/typeset.tsx'\nimport { DecisionBars } from './DecisionBars.tsx'\nimport { DsepLine } from './DsepLine.tsx'\nimport type { PlaygroundPreset, PresetButton } from './playground-options.ts'\nimport type { BlameSpec } from './blame-view.ts'\nimport { blameView } from './blame-view.ts'\nimport { PlaygroundBlame } from './PlaygroundBlame.tsx'\nimport { NONE, activeQuery, checkTrack, checkVerdicts, decisionFor, dsepPairs, presetButtons, sliderStart } from './playground-options.ts'\nimport { PlaygroundVerdicts } from './PlaygroundVerdicts.tsx'\nimport { trailText } from './trail.ts'\nimport { useTrail } from './use-trail.ts'\n\nexport type { PlaygroundPreset } from './playground-options.ts'\nexport type { BlameSpec, BlameState } from './blame-view.ts'\n\nexport type CausalPlaygroundProps = CausalPlaygroundSource & CausalPlaygroundOptions\n\n/** What to draw: a bundled case by id, or a model document (a `modelDocSchema` value) such as one built in the editor. */\nexport type CausalPlaygroundSource =\n | {\n /** A bundled case id, e.g. `rock-throwing`. */\n readonly caseId: string\n readonly doc?: undefined\n }\n | {\n /**\n * A model document drawn on its own: graph, notation toggle, do() and export, no editor chrome.\n * A document that does not validate or build shows its problem codes instead of throwing.\n * The export credits a case source only when `doc.from` is a bundled case with the same model.\n */\n readonly doc: ModelDoc\n readonly caseId?: undefined\n }\n\nexport interface CausalPlaygroundOptions {\n /** Notation the equations start in; the reader can still switch. Default 'propositional'. */\n readonly defaultNotation?: UiNotation\n /** do() applied at the start. */\n readonly initialInterventions?: Assignment\n /**\n * Preset interventions as buttons. `true` (default) shows a bundled case's own; pass a list for\n * a document (it has none of its own); `false` hides them.\n */\n readonly presets?: boolean | readonly PlaygroundPreset[]\n /** Link in exported images' watermark. Default https://github.com/wayne930242/logic-atlas. */\n readonly exportUrl?: string\n /**\n * Decimals of the probability under each node (and a stochastic do()'s tag, a bar chart's top\n * value and the 原本 notes): a whole number from 1 to 6, default 2. Set it to the digits the\n * text quotes, e.g. 3 for 0.175; a number within 10^-digits of 0 or 1 still gets two significant\n * digits of its distance from that end. Equation, table and slider numbers keep their own\n * precision. The embed code does not record it.\n */\n readonly digits?: number\n /** Interface language. Default: the surrounding LocaleProvider's, else zh-TW. */\n readonly locale?: Locale\n /**\n * The page that shows this figure alone, for the export menu's embed code (an iframe and the\n * citation). Default for a bundled case: https://wayneh.tw/causal/embed/case/<id>/; a document\n * has none unless given. `false` offers no embed code.\n */\n readonly embedUrl?: string | false\n /**\n * Drawn as an embed page: the state comes from the address (`#do=…&pdo=…&obs=…`, see\n * `embedFragment`) and a credit line with the licence, the case's sources and a link back to the\n * page it was copied from (`?from=`) sits under it.\n */\n readonly embedded?: boolean\n /**\n * Nodes whose number (or value) is followed under the graph: one line per node with its reading\n * after each change of what is set, `Y:0.50 → 0.67(Z=1)→ 0.50(Z=1, X=1)`, the last five.\n * 「回到原本」 and the step buttons start it again.\n */\n readonly track?: readonly string[]\n /**\n * Actual-cause questions for a graph with values: per query a row of verdicts (but-for, the three\n * HP definitions, HP with normality when the model has defaults; or `theories`), each with\n * 在圖上看 for its witness, and a line saying whether the world on the graph is a witness. Only a preset's hold or the shown witness's W is drawn held.\n * The status follows the clicked witness or the most specific matching cause.\n */\n readonly verdicts?: readonly VerdictQuery[]\n /**\n * The degree of blame (Halpern 2016, Def. 6.2.1) of one event for an outcome: a 責備 tab under\n * the graph with one row per epistemic state and one column per Halpern–Pearl standard, and each\n * state's backgrounds with their probabilities and responsibilities behind a fold. `states` are\n * `{ label?, prior?, given? }`: `prior` in the model document's `priors` format (default the\n * document's own, which a document without `priors` must then supply in every state), `given` an\n * observation that narrows the state, e.g. the outcome seen after acting. Without `states` there\n * is one, the document's `priors` (the sliders move it). Halpern's blame conditions on the cause\n * holding, so the probabilities are conditioned on it. Throws when no priors are available.\n */\n readonly blame?: BlameSpec\n /**\n * The model's default values (`normality`), shown on a graph with values: a node off its default\n * says 偏離(預設 v), a line under the graph compares this world's deviations with the actual\n * world's (更正常/一樣正常/較不正常/無法比較), each equation says 預設 v. On by default when the\n * model has defaults; `false` hides them.\n */\n readonly normality?: boolean\n /**\n * A pair of variables, or several (a switch in the head picks one), on a probability graph: every\n * path between the two in the graph after do() is lit when open and dashed when blocked, the\n * known set being what is observed, and a line under the graph gives the verdict, δ (lesson 04's\n * dependence, given the observed values) and up to three paths with why.\n */\n readonly dsep?: DsepPair | readonly DsepPair[]\n /**\n * Exogenous variables with a slider under the graph (boolean or two-valued ones, on a probability\n * graph): P(id = 1, or its first value). Dragging recomputes everything drawn with the new prior;\n * 「回到原本的機率」 puts the sliders back. The embed code does not record them.\n */\n readonly sliders?: readonly string[]\n /** Start values P(id = 1, or its first value) of exogenous variables, slider or not; the rest keep the case's prior. */\n readonly prior?: Readonly<Record<string, number>>\n /**\n * Expected-utility bars under the graph (a probability graph): one row per theory (evidential,\n * causal), one bar per act, the act each picks and by how much; the utilities sit in its ⓘ.\n * `true` takes the case's own `decision`; or give one in the case-file format\n * (`{ variable, acts?, utility: { variables, rows: [[...values, utility]] } }`). Observing the act\n * lights its evidential bar, do() on it the causal one; the sliders move both rows.\n */\n readonly decision?: true | CaseDecision\n /**\n * The block under the graph that is open at load: 'probabilities' (機率, the sliders), 'equations'\n * (式子), or a figure block ('verdicts', 'ev', 'dsep', 'blame'). Default: the figure's own block\n * (verdicts, expected utility, paths, blame), else none. A block the figure does not offer counts as\n * the default. The embed code keeps the default.\n */\n readonly openPanel?: PlaygroundPanel\n /**\n * The sliders the 機率 tab shows at first, of those in `sliders`; the others wait behind a button\n * that shows them (and hides them again). Default, or when none of them is a slider: every slider.\n */\n readonly focusSliders?: readonly string[]\n}\n\n/** The blocks under a playground's graph, by the id `openPanel` names them with. */\nexport type PlaygroundPanel = 'verdicts' | 'ev' | 'dsep' | 'blame' | 'probabilities' | 'equations'\n\n/** One case's graph and equations; click a node to observe it (probabilities) or set do() on it (values). */\nexport function CausalPlayground({ locale, digits, ...props }: CausalPlaygroundProps) {\n return (\n <LocaleScope locale={locale}>\n <DigitsScope digits={digits}>\n <CaseGate ids={casesOf(props.caseId, [props.doc])}>\n <PlaygroundBody {...props} />\n </CaseGate>\n </DigitsScope>\n </LocaleScope>\n )\n}\n\nfunction PlaygroundBody({ doc, ...props }: Omit<CausalPlaygroundProps, 'locale' | 'digits'>) {\n const resolved = useCaseOrDoc(props.caseId, doc)\n return resolved.ok ? <PlaygroundFor c={resolved.c} {...props} /> : <DocProblems problems={resolved.problems} />\n}\n\nfunction PlaygroundFor({\n c: base,\n caseId,\n initialInterventions,\n presets = true,\n exportUrl,\n defaultNotation,\n embedUrl,\n embedded = false,\n track = NO_TRACK,\n verdicts,\n blame,\n normality = true,\n dsep,\n sliders = NO_TRACK,\n prior: startPrior,\n decision,\n openPanel,\n focusSliders,\n}: Omit<CausalPlaygroundOptions, 'locale' | 'digits'> & { readonly c: LoadedCase; readonly caseId?: string }) {\n const t = useMessages()\n const start = useMemo(() => sliderStart(base, sliders, startPrior), [base, sliders, startPrior])\n const [sliderValues, setSliderValues] = useState(start)\n // `focusSliders`: the rows shown at first; the rest behind 顯示其他 n 個機率.\n const focused = useMemo(() => sliders.filter((id) => focusSliders?.includes(id) === true), [sliders, focusSliders])\n const hidden = focused.length > 0 ? sliders.filter((id) => !focused.includes(id)) : NO_TRACK\n const [allSliders, setAllSliders] = useState(false)\n const problem = useMemo(() => decisionFor(base, decision), [base, decision])\n // Everything below reads the case with the slider prior; an embed page reads its state from `base`.\n const c = useMemo(\n () => (Object.keys(sliderValues).length === 0 ? base : { ...base, prior: priorWithSliders(base, sliderValues) }),\n [base, sliderValues],\n )\n checkVerdicts(c, verdicts)\n const [reading, setReading] = useState<Reading>('interventional')\n const { interventions, stochastic, observed, setDo, setObserved, notation, setNotation, world } = useModel(\n c,\n initialInterventions,\n defaultNotation,\n reading,\n )\n /** Switch the reading, keeping what is set; back to interventional, a node keeps only its do(). */\n const switchReading = (next: Reading): void => {\n if (next === 'interventional') {\n const kept = Object.fromEntries(Object.entries(observed).filter(([id]) => !(id in interventions) && !(id in stochastic)))\n if (Object.keys(kept).length !== Object.keys(observed).length) setObserved(kept)\n }\n setReading(next)\n }\n const root = useRef<HTMLDivElement>(null)\n // A hovered node lights its sliders; a hovered slider lights the nodes it moves.\n const [hoverNode, setHoverNode] = useState<string | undefined>(undefined)\n const [hoverSlider, setHoverSlider] = useState<string | undefined>(undefined)\n const litNodes = useMemo(() => (hoverSlider === undefined ? NO_TRACK : sliderTargets(c.model, world.shown, hoverSlider)), [c.model, world.shown, hoverSlider])\n const litSliders = useMemo(\n () => (hoverNode !== undefined ? nodeSliders(c.model, world.shown, sliders, hoverNode) : hoverSlider !== undefined ? [hoverSlider] : NO_TRACK),\n [c.model, world.shown, sliders, hoverNode, hoverSlider],\n )\n const setSlider = (id: string, p: number): void => setSliderValues((now) => ({ ...now, [id]: p }))\n /** The sliders among `ids` moved from where they started. */\n const moved = (ids: readonly string[]): boolean => ids.some((id) => sliderValues[id] !== start[id])\n /** Put the sliders `ids` back where they started. */\n const resetSliders = (ids: readonly string[]): void => {\n setSliderValues((now) => ({ ...now, ...Object.fromEntries(ids.map((id) => [id, start[id]])) }))\n restartTrail()\n }\n const sliderId = useId().replace(/[^a-zA-Z0-9_-]/g, '')\n // An embed page takes its state from the address once mounted (the server has no address hash).\n useEffect(() => {\n if (!embedded) return\n const state = fitEmbedState(base, readEmbedState(window.location.hash))\n setDo({ interventions: state.interventions, stochastic: state.stochastic })\n setObserved(state.observed)\n // Read once per case: later clicks are the reader's own.\n }, [base, embedded, setDo, setObserved])\n const [held, setHeld] = useState<Assignment>(NONE)\n const soft = Object.keys(stochastic).length > 0\n const buttons = presetButtons(c, presets, t.locale)\n const prob = world.probs !== undefined\n const defaults = normality && c.context !== undefined ? c.normality : undefined\n const pairs = dsepPairs(c, dsep)\n const [pairAt, setPairAt] = useState(0)\n const pair = pairs[Math.min(pairAt, pairs.length - 1)]\n const dsepNow = pair === undefined || !prob ? undefined : dsepView(c, pair, observed, interventions, stochastic)\n const groups = useMemo(() => (verdicts === undefined ? [] : actualGroups(t, c, verdicts)), [t, c, verdicts])\n const theories = useMemo(() => (verdicts ?? []).map((q) => q.theories ?? defaultTheories(c)), [c, verdicts])\n const blamed = useMemo(() => (blame === undefined ? undefined : blameView(c, blame, t.locale)), [c, blame, t.locale])\n const [shownQuery, setShownQuery] = useState<number>()\n const holding = Object.fromEntries(\n Object.entries(interventions).filter(([id, v]) => id in held && valuesEqual(held[id], v)),\n )\n const active = verdicts === undefined ? -1 : shownQuery ?? activeQuery(c, verdicts, Object.fromEntries(Object.entries(interventions).filter(([id]) => !(id in holding))))\n checkTrack(c, track)\n const setting = readingText(t, reading === 'counterfactual' && prob, interventions, stochastic, observed)\n const [trail, restartTrail] = useTrail(c, track, world, setting)\n const [stepIndex, setStepIndex] = useState<number>()\n const step = stepIndex === undefined ? undefined : buttons[stepIndex]\n const required = step?.expect\n const result = required && world.values ? Object.fromEntries(Object.keys(required).map((id) => [id, world.values![id]])) : undefined\n const applyPreset = (s: PresetButton, query?: number): void => {\n setStepIndex(buttons.indexOf(s))\n setShownQuery(query)\n setDo({ interventions: s.interventions, stochastic: {} })\n setObserved(s.observed)\n setHeld(s.hold)\n restartTrail()\n }\n // A step stays pressed while everything it set still holds, even after the reader sets more; of the\n // steps that still hold, only the ones that set the most are pressed (so an empty step 1 does not light\n // up next to step 2).\n const within = (state: Assignment, part: Assignment): boolean =>\n sameAssignment(Object.fromEntries(Object.keys(part).filter((id) => id in state).map((id) => [id, state[id]])), part)\n const holds = (s: PresetButton): boolean =>\n within(observed, s.observed) && within(interventions, s.interventions) && within(holding, s.hold)\n const size = (s: PresetButton): number =>\n Object.keys(s.observed).length + Object.keys(s.interventions).length + Object.keys(s.hold).length\n const pressedSize = soft ? -1 : Math.max(-1, ...buttons.filter(holds).map(size))\n const pressed = (s: PresetButton): boolean => !soft && holds(s) && size(s) === pressedSize\n const src = embedded || embedUrl === false ? undefined : (embedUrl ?? (caseId === undefined ? undefined : `${DEFAULT_EMBED_BASE}case/${encodeURIComponent(caseId)}/`))\n // Under the graph, one block at a time: the figure's own (verdicts, expected utility, paths) open at first, the equations closed.\n const blocks: FigureBlock[] = []\n if (verdicts !== undefined) {\n blocks.push({\n id: 'verdicts',\n label: t.tab.verdicts,\n children: (\n <PlaygroundVerdicts\n c={c}\n groups={groups}\n queries={verdicts}\n theories={theories}\n active={active}\n interventions={interventions}\n onShow={(row, query) => {\n const hold = row.fixed ?? NONE\n applyPreset({ text: '', interventions: row.show ?? NONE, observed: NONE, hold }, query)\n }}\n />\n ),\n })\n }\n if (problem !== undefined) {\n blocks.push({ id: 'ev', label: t.ev.title, children: <DecisionBars c={c} problem={problem} observed={observed} interventions={interventions} /> })\n }\n if (dsepNow !== undefined && pair !== undefined) {\n blocks.push({ id: 'dsep', label: t.tab.dsep, children: <DsepLine c={c} pair={pair} observed={observed} view={dsepNow} /> })\n }\n if (blame !== undefined && blamed !== undefined) {\n blocks.push({ id: 'blame', label: t.tab.blame, children: <PlaygroundBlame c={c} cause={blame.cause} effect={blame.effect} view={blamed} /> })\n }\n if (sliders.length > 0) {\n // Every slider, grouped by the node it moves (sliders that move no drawn node last), closed at first:\n // a node's own sliders are also in its menu.\n blocks.push({\n id: 'probabilities',\n label: t.probabilities,\n children: (\n <div className=\"ca-slider-tab\">\n <SliderList\n c={c}\n ids={hidden.length > 0 && !allSliders ? focused : sliders}\n values={sliderValues}\n onChange={setSlider}\n idPrefix={`ca-pg-slider-${sliderId}`}\n shown={world.shown}\n lit={litSliders}\n onHover={setHoverSlider}\n />\n {hidden.length > 0 && (\n <button type=\"button\" className=\"ca-link ca-slider-more\" aria-expanded={allSliders} onClick={() => setAllSliders((x) => !x)}>\n {allSliders ? t.fewerSliders : t.moreSliders(hidden.length)}\n </button>\n )}\n {moved(sliders) && (\n <button type=\"button\" className=\"ca-btn ca-btn-outline ca-slider-reset\" onClick={() => resetSliders(sliders)}>\n {t.backToPrior}\n </button>\n )}\n </div>\n ),\n })\n }\n blocks.push({\n id: 'equations',\n label: t.equations,\n children: <EquationPanel c={c} world={world} interventions={interventions} stochastic={stochastic} observed={observed} reading={reading} notation={notation} onNotation={setNotation} defaults={defaults} />,\n })\n const initialBlock = blocks.find((b) => b.id !== 'equations' && b.id !== 'probabilities')?.id\n const embed =\n src === undefined\n ? undefined\n : (): string =>\n embedCode({\n src: embedSrc(src, { interventions, stochastic, observed }, window.location.pathname, t.locale),\n title: c.data.title[t.locale],\n // The figure as it stands, plus the credit line the embed page adds under it.\n // The embed page starts with the figure's own block open, whatever is open here.\n height: heightAtInitialBlock(root.current, initialBlock, 640) + 72,\n locale: t.locale,\n url: exportUrl,\n origins: originCitations(c),\n })\n return (\n <div className=\"ca-root not-prose ca-playground\" data-case={c.data.id} lang={t.locale} ref={root}>\n <div className=\"ca-panel\">\n <GraphBox\n c={c}\n world={world}\n interventions={interventions}\n stochastic={stochastic}\n onDo={(next) => {\n setStepIndex(undefined)\n setShownQuery(undefined)\n setHeld(Object.fromEntries(Object.entries(holding).filter(([id, v]) => valuesEqual(v, next.interventions[id]))))\n setDo(next)\n }}\n observed={observed}\n onObserve={setObserved}\n witness={Object.keys(holding).length > 0 ? holding : undefined}\n holdNotes\n defaults={defaults}\n menuHelp={`${reading === 'counterfactual' && prob ? t.cfHintMore : t.playgroundHintMore(prob)}${sliders.length > 0 ? ` ${t.sliderEmbed.trim()}` : ''}`}\n exportUrl={exportUrl}\n embedCode={embed}\n moved={moved(sliders)}\n onReset={() => {\n setSliderValues(start)\n restartTrail()\n }}\n reading={reading}\n paths={dsepNow?.marks}\n lit={litNodes}\n onHover={sliders.length > 0 ? setHoverNode : undefined}\n menuExtra={\n sliders.length === 0\n ? undefined\n : (id) => {\n const own = nodeSliders(c.model, world.shown, sliders, id)\n return own.length === 0 ? undefined : (\n <>\n <SliderList c={c} ids={own} values={sliderValues} onChange={setSlider} idPrefix={`ca-pg-menu-slider-${sliderId}`} />\n {moved(own) && (\n <button type=\"button\" className=\"ca-btn ca-btn-outline ca-slider-reset\" data-node-reset={id} onClick={() => resetSliders(own)}>\n {t.nodeBackToPrior}\n </button>\n )}\n </>\n )\n }\n }\n actions={\n prob ? (\n <>\n {pairs.length > 1 && (\n <Segmented\n label={t.dsep.pairs}\n options={pairs.map((p, i) => ({ value: String(i), label: t.dsep.pair(p[0], p[1]) }))}\n value={String(Math.min(pairAt, pairs.length - 1))}\n onChange={(v) => setPairAt(Number(v))}\n />\n )}\n <div className=\"ca-reading-box\">\n <div className=\"ca-reading-row\">\n <span className=\"ca-reading-label\" aria-hidden=\"true\">\n {t.readingLabel}\n </span>\n <Segmented\n className=\"ca-reading\"\n label={t.readingLabel}\n options={[\n { value: 'interventional', label: t.reading.interventional },\n { value: 'counterfactual', label: t.reading.counterfactual },\n ]}\n value={reading}\n onChange={switchReading}\n />\n </div>\n <p className=\"ca-reading-hint\" aria-live=\"polite\">\n {reading === 'interventional' && Object.keys(interventions).length + Object.keys(stochastic).length === 0 ? '' : t.readingHint[reading]}\n </p>\n </div>\n </>\n ) : undefined\n }\n foot={\n <div className=\"ca-playground-foot\">\n {defaults !== undefined && world.values !== undefined && world.original !== undefined && (\n <p className=\"ca-norm-line\" data-normality=\"\">\n <span className=\"ca-pg-now-kicker\">{t.normality.kicker}</span>{' '}\n <Rich\n text={normalityLine(t, c.model, world.values, world.original, defaults, !sameAssignment(world.values, world.original))}\n ids={c.model.byId}\n />{' '}\n <Tip tip={t.normality.tip} label={t.moreInfo} />\n </p>\n )}\n {track.length > 0 && (\n <ul className=\"ca-trail\" aria-label={t.trail}>\n {track.map((id) => {\n const text = trailText(t, id, trail.entries, trail.dropped)\n return (\n <li key={id} data-trail={id} data-text={text}>\n <span className=\"ca-trail-kicker\">{t.trail}</span> <Rich text={text} ids={c.model.byId} />\n </li>\n )\n })}\n </ul>\n )}\n {step && (step.test !== undefined || required !== undefined) && !soft && sameAssignment(step.interventions, interventions) && sameAssignment(step.hold, holding) && sameAssignment(step.observed, observed) && (\n <p role=\"status\" data-step-result=\"\">{required && result\n ? t.witness.step(step.test ?? step.text, assignmentText(required), assignmentText(result), sameAssignment(required, result))\n : t.witness.testName(step.test ?? step.text)}</p>\n )}\n {buttons.length > 0 && (\n <div className=\"ca-presets\" role=\"group\" aria-label={t.presets}>\n {buttons.map((s) => (\n <button key={s.text} type=\"button\" className=\"ca-btn ca-btn-outline\" aria-pressed={pressed(s)} onClick={() => applyPreset(s)}>\n {s.text}\n </button>\n ))}\n </div>\n )}\n </div>\n }\n blocks={blocks}\n initialBlock={openPanel !== undefined && blocks.some((b) => b.id === openPanel) ? openPanel : initialBlock}\n />\n </div>\n {embedded && <EmbedCredit c={c} url={exportUrl ?? DEFAULT_URL} />}\n </div>\n )\n}\n\nconst noSubscription = (): (() => void) => () => {}\n\n/** The credit under an embedded figure: author, project, licence and link; the case's sources; the page it came from. */\nfunction EmbedCredit({ c, url }: { readonly c: LoadedCase; readonly url: string }) {\n const t = useMessages()\n // The address never changes under an embed page: read it on the client, the project page on the server.\n const home = useSyncExternalStore(\n noSubscription,\n () => embedHome(window.location.search, window.location.origin, url),\n () => url,\n )\n const origins = originCitations(c)\n return (\n <footer className=\"ca-embed-credit ca-small\">\n <p>{watermarkLine(url, t.locale)}</p>\n {origins.length > 0 && <p>{t.export.caseSource(originSources(t, c))}</p>}\n <p>\n <a href={home} target=\"_blank\" rel=\"noopener\">\n {t.export.embedOpen}\n </a>\n </p>\n </footer>\n )\n}\n\nconst NO_TRACK: readonly string[] = []\n\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,SAASmE,GAAM,GAAc,GAAkC;CAC7D,OAAW,OAAO,QAAQC,EAAK,SAAS,CAAC,CAAC,KAAKC,CAAI,CAAC,GAAG;AACzD;AAGA,SAAgBC,GAAc,GAA2B;CACvD,IAAMC,IAAkB,CAAC,GACnBC,IAAInD,EAASoD,EAAM,aAAa,GAChCC,IAAItD,EAAUqD,EAAM,UAAU,GAC9BE,IAAItD,EAASoD,EAAM,QAAQ;CAIjC,OAHID,MAAM,MAAID,EAAM,KAAK,MAAMC,GAAG,GAC9BE,MAAM,MAAIH,EAAM,KAAK,OAAOG,GAAG,GAC/BC,MAAM,MAAIJ,EAAM,KAAK,OAAOI,GAAG,GAC5BJ,EAAM,KAAK,GAAG;AACvB;AAGA,SAAgBK,GAAe,GAA0B;CACvD,IAAMJ,IAAIL,GAAME,GAAM,IAAI,GACpBK,IAAIP,GAAME,GAAM,KAAK,GACrBM,IAAIR,GAAME,GAAM,KAAK;CAC3B,OAAO;EACL,eAAeG,MAAM,KAAA,IAAY,CAAC,IAAIrD,EAAQqD,CAAC;EAC/C,YAAYE,MAAM,KAAA,IAAY,CAAC,IAAIxD,EAASwD,CAAC;EAC7C,UAAUC,MAAM,KAAA,IAAY,CAAC,IAAIx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OC,EACXF,UACMnM,EAAU,OAAO,SAAS,QAAQ,OAAO,SAAS,QAAQZ,CAAG,SAC7DA,CACR,GACMS,IAAUpD,GAAgBiE,CAAC;CACjC,OACE,kBAAC,UAAD;EAAQ,WAAU;EAAlB,UAAA;GACE,kBAAC,KAAD,EAAA,UAAIrF,EAAc+D,GAAKwC,EAAE,MAAM,EAAK,CAAA;GACnC/B,EAAQ,SAAS,KAAK,kBAAC,KAAD,EAAA,UAAI+B,EAAE,OAAO,WAAWpF,GAAcoF,GAAGlB,CAAC,CAAC,EAAK,CAAA;GACvE,kBAAC,KAAD,EAAA,UACE,kBAAC,KAAD;IAAG,MAAM0L;IAAM,QAAO;IAAS,KAAI;IAChC,UAAAxK,EAAE,OAAO;GACT,CAAA,EACF,CAAA;EACG;;AAEZ;AAEA,IAAMmG,IAA8B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./cite-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./cite-QzNc24r2.js";
|
|
2
2
|
import { i as a, l as o } from "./messages-ZiFmPfDY.js";
|
|
3
3
|
import { n as s } from "./parts-8cUsl2jJ.js";
|
|
4
4
|
import { useState as c } from "react";
|
|
@@ -58,4 +58,4 @@ function f({ url: n }) {
|
|
|
58
58
|
}
|
|
59
59
|
export { d as t };
|
|
60
60
|
|
|
61
|
-
//# sourceMappingURL=CiteBlock-
|
|
61
|
+
//# sourceMappingURL=CiteBlock-DMFqM7ZM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CiteBlock-
|
|
1
|
+
{"version":3,"file":"CiteBlock-DMFqM7ZM.js","names":["bibtex","authorYearEn","DATA_LICENSE","LocaleScope","useMessages","Disclosure","CiteBlock","DEFAULT_URL","CiteBody","t","copied","setCopied","useState","bib","url","copy","zh","authorYear","en"],"sources":["../../src/components/export/CiteBlock.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { DATA_LICENSE, DEFAULT_URL, authorYear, authorYearEn, bibtex } from './cite.ts'\nimport type { Locale } from '../i18n/messages.ts'\nimport { LocaleScope, useMessages } from '../i18n/messages.ts'\nimport { Disclosure } from '../shared/parts.tsx'\n\nexport interface CiteBlockProps {\n /** Where the project lives; goes into every citation form. Default https://github.com/wayne930242/logic-atlas. */\n readonly url?: string\n /** Interface language. Default: the surrounding LocaleProvider's, else zh-TW. */\n readonly locale?: Locale\n}\n\n/**\n * How to cite logic-atlas: author-year in both languages (the page's language first), BibTeX\n * behind a disclosure, licences.\n */\nexport function CiteBlock({ url = DEFAULT_URL, locale }: CiteBlockProps) {\n return (\n <LocaleScope locale={locale}>\n <CiteBody url={url} />\n </LocaleScope>\n )\n}\n\nfunction CiteBody({ url }: { readonly url: string }) {\n const t = useMessages()\n const [copied, setCopied] = useState(false)\n const bib = bibtex(url)\n const copy = (): void => {\n void navigator.clipboard?.writeText(bib).then(() => setCopied(true))\n }\n const zh = (\n <p className=\"ca-cite-entry\" lang=\"zh-TW\" key=\"zh\">\n {authorYear(url)}\n </p>\n )\n const en = (\n <p className=\"ca-cite-entry\" lang=\"en\" key=\"en\">\n {authorYearEn(url)}\n </p>\n )\n return (\n <section className=\"ca-root not-prose ca-cite\" aria-label={t.cite.heading} lang={t.locale}>\n <h2 className=\"ca-h3\">{t.cite.heading}</h2>\n <p className=\"ca-cite-lead\">{t.cite.lead}</p>\n {t.locale === 'en' ? [en, zh] : [zh, en]}\n <Disclosure kicker=\"\" title=\"BibTeX\">\n <pre className=\"ca-cite-bib ca-mono\">{bib}</pre>\n <button type=\"button\" className=\"ca-btn ca-btn-outline\" onClick={copy}>\n {copied ? t.cite.copied : t.cite.copyBibtex}\n </button>\n </Disclosure>\n <p className=\"ca-muted ca-small\">{t.cite.licence(DATA_LICENSE)}</p>\n </section>\n )\n}\n"],"mappings":";;;;;;AAiBA,SAAgBM,EAAU,EAAE,SAAMC,GAAa,aAA0B;CACvE,OACE,kBAACJ,GAAD;EAAqB;EACnB,UAAA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
2
|
+
import { t as a } from "./SignalGraph-CWPf_sG8.js";
|
|
3
3
|
import { i as o, l as s, o as c } from "./messages-ZiFmPfDY.js";
|
|
4
4
|
import { n as l, t as u } from "./cases-of-DpCMbUyl.js";
|
|
5
5
|
import { D as d, Q as f, W as p, Y as m, n as h, st as g, ut as ee } from "./doc-case-YauWsu0F.js";
|
|
@@ -409,4 +409,4 @@ function R(e, t) {
|
|
|
409
409
|
var z = [];
|
|
410
410
|
export { N as t };
|
|
411
411
|
|
|
412
|
-
//# sourceMappingURL=ConservativeExtension-
|
|
412
|
+
//# sourceMappingURL=ConservativeExtension-Cofe92ak.js.map
|