compasso 0.1.0 → 0.3.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/README.md +126 -8
- package/dist/chunk-F47C6ZEB.js +1041 -0
- package/dist/chunk-F47C6ZEB.js.map +1 -0
- package/dist/chunk-JP4N42AY.js +497 -0
- package/dist/chunk-JP4N42AY.js.map +1 -0
- package/dist/chunk-LRHHUJFZ.js +703 -0
- package/dist/chunk-LRHHUJFZ.js.map +1 -0
- package/dist/{chunk-E456YKAJ.js → chunk-O3BT2O42.js} +69 -10
- package/dist/chunk-O3BT2O42.js.map +1 -0
- package/dist/{chunk-L5CYESBI.js → chunk-Q6DVTCXD.js} +9 -24
- package/dist/chunk-Q6DVTCXD.js.map +1 -0
- package/dist/{chunk-5RRRE2GF.js → chunk-RWPGGWO5.js} +9 -28
- package/dist/chunk-RWPGGWO5.js.map +1 -0
- package/dist/chunk-ZBDABVIO.js +252 -0
- package/dist/chunk-ZBDABVIO.js.map +1 -0
- package/dist/core/index.cjs +74 -7
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +33 -29
- package/dist/core/index.d.ts +33 -29
- package/dist/core/index.js +1 -1
- package/dist/ecomap/index.cjs +43 -28
- package/dist/ecomap/index.cjs.map +1 -1
- package/dist/ecomap/index.js +2 -2
- package/dist/fault-tree/index.cjs +782 -0
- package/dist/fault-tree/index.cjs.map +1 -0
- package/dist/fault-tree/index.d.cts +148 -0
- package/dist/fault-tree/index.d.ts +148 -0
- package/dist/fault-tree/index.js +4 -0
- package/dist/fault-tree/index.js.map +1 -0
- package/dist/fishbone/index.cjs +314 -0
- package/dist/fishbone/index.cjs.map +1 -0
- package/dist/fishbone/index.d.cts +91 -0
- package/dist/fishbone/index.d.ts +91 -0
- package/dist/fishbone/index.js +4 -0
- package/dist/fishbone/index.js.map +1 -0
- package/dist/genogram/index.cjs +47 -32
- package/dist/genogram/index.cjs.map +1 -1
- package/dist/genogram/index.d.cts +7 -4
- package/dist/genogram/index.d.ts +7 -4
- package/dist/genogram/index.js +2 -2
- package/dist/index.cjs +2622 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +7 -3
- package/dist/kinship-DqEklrDN.d.ts +51 -0
- package/dist/kinship-Dy_ijjJV.d.cts +51 -0
- package/dist/labels-CBQ_3Ec9.d.cts +123 -0
- package/dist/labels-CYbM5XV7.d.cts +83 -0
- package/dist/labels-CYbM5XV7.d.ts +83 -0
- package/dist/labels-DNqRkWuI.d.ts +123 -0
- package/dist/labels-iZjijjtK.d.cts +64 -0
- package/dist/labels-iZjijjtK.d.ts +64 -0
- package/dist/locales/pt-br.cjs +94 -0
- package/dist/locales/pt-br.cjs.map +1 -1
- package/dist/locales/pt-br.d.cts +14 -2
- package/dist/locales/pt-br.d.ts +14 -2
- package/dist/locales/pt-br.js +88 -1
- package/dist/locales/pt-br.js.map +1 -1
- package/dist/pedigree/index.cjs +1151 -0
- package/dist/pedigree/index.cjs.map +1 -0
- package/dist/pedigree/index.d.cts +155 -0
- package/dist/pedigree/index.d.ts +155 -0
- package/dist/pedigree/index.js +4 -0
- package/dist/pedigree/index.js.map +1 -0
- package/dist/phylo/index.cjs +553 -0
- package/dist/phylo/index.cjs.map +1 -0
- package/dist/phylo/index.d.cts +158 -0
- package/dist/phylo/index.d.ts +158 -0
- package/dist/phylo/index.js +4 -0
- package/dist/phylo/index.js.map +1 -0
- package/dist/text-DuO_PwYw.d.cts +45 -0
- package/dist/text-DuO_PwYw.d.ts +45 -0
- package/dist/types-BnMG7TCd.d.cts +66 -0
- package/dist/types-BnMG7TCd.d.ts +66 -0
- package/dist/xml-DDae1eUr.d.cts +4 -0
- package/dist/xml-DDae1eUr.d.ts +4 -0
- package/package.json +100 -26
- package/dist/chunk-5RRRE2GF.js.map +0 -1
- package/dist/chunk-E456YKAJ.js.map +0 -1
- package/dist/chunk-L5CYESBI.js.map +0 -1
- package/dist/kinship-BARO5-qz.d.cts +0 -115
- package/dist/kinship-Bkf87Jhu.d.ts +0 -115
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fault-tree/types.ts","../src/fault-tree/labels.ts","../src/fault-tree/validate.ts","../src/fault-tree/layout.ts","../src/fault-tree/svg.ts","../src/fault-tree/render.ts"],"names":["lines","last","round","pts"],"mappings":";;;AAiBO,IAAM,sBAAA,GAAyB;AAAA,EACpC,cAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF;AAuBO,IAAM,aAAa,CAAC,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,WAAW,MAAM;;;AC/BzD,IAAM,0BAAA,GAAmD;AAAA,EAC9D,KAAA,EAAO;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL,EAAA,EAAI,SAAA;AAAA,IACJ,GAAA,EAAK,mBAAA;AAAA,IACL,OAAA,EAAS,cAAA;AAAA,IACT,IAAA,EAAM;AAAA,GACR;AAAA,EACA,SAAA,EAAW;AACb;AASO,IAAM,wBAAA,GAA+C;AAAA,EAC1D,MAAA,EAAQ;AAAA,IACN,YAAA,EAAc,oBAAA;AAAA,IACd,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa,mBAAA;AAAA,IACb,KAAA,EAAO,kCAAA;AAAA,IACP,YAAA,EAAc,oBAAA;AAAA,IACd,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,KAAA,EAAO;AAAA,IACL,GAAA,EAAK,uBAAA;AAAA,IACL,EAAA,EAAI,qBAAA;AAAA,IACJ,GAAA,EAAK,uCAAA;AAAA,IACL,OAAA,EAAS,sCAAA;AAAA,IACT,IAAA,EAAM;AAAA,GACR;AAAA,EACA,SAAA,EAAW;AACb;;;ACiBO,IAAM,wBAAA,GAAN,cAAuC,KAAA,CAAM;AAAA,EACzC,MAAA;AAAA,EAET,YAAY,MAAA,EAAmC;AAC7C,IA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Aa,CAAC,CAAA,yBAAA,EAA4B,SAAA,CAAU,OAAO,SAAS,CAAC,OAChJ,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA,GACb,CAAA,MAAA,CAAA;AAEJ;;;ACnMO,SAAS,YAAA,CAAa,KAAA,EAAuB,IAAA,GAA+B,EAAC,EAA0B;AAC5G,EAAA,MAAM,MAAA,GAAS,uBAAuB,KAAA,EAAO;AAAA,IAC3C,GAAI,KAAK,aAAA,KAAkB,MAAA,GAAY,EAAE,aAAA,EAAe,IAAA,CAAK,aAAA,EAAc,GAAI,EAAC;AAAA,IAChF,GAAI,KAAK,WAAA,KAAgB,MAAA,GAAY,EAAE,WAAA,EAAa,IAAA,CAAK,WAAA,EAAY,GAAI;AAAC,GAC3E,CAAA;AACD,EAAA,MAAM,GAAA,GAAM,mBAAmB,MAAA,EAAQ;AAAA,IACrC,GAAI,KAAK,MAAA,KAAW,KAAA,GAAQ,EAAE,MAAA,EAAQ,KAAA,KAAU,EAAC;AAAA,IACjD,GAAI,KAAK,SAAA,KAAc,MAAA,GAAY,EAAE,MAAA,EAAQ,IAAA,CAAK,SAAA,EAAU,GAAI;AAAC,GAClE,CAAA;AACD,EAAA,OAAO,EAAE,KAAK,MAAA,EAAO;AACvB","file":"chunk-LRHHUJFZ.js","sourcesContent":["// Fault-tree input model — declared facts only. compasso draws EXACTLY what the\n// caller declares: every event carries its declared kind (the standard symbol is a\n// semantic claim only the author may make), gates are first-class rows with a declared\n// type and a declared left-to-right input order, and the top event is DECLARED, never\n// derived. Symbol lineage: NUREG-0492 (Fault Tree Handbook, US NRC 1981) distinctive\n// shapes, as permitted by IEC 61025:2006 — the rectangular IEC 60617 family is\n// rejected because its gates would be visually indistinguishable from event rectangles.\n\n/**\n * CLOSED event-kind vocabulary (NUREG-0492 Fig. IV-1):\n * - \"intermediate\": fault event from a logic combination → rectangle (incl. the top);\n * - \"basic\": basic initiating fault, no further development → circle;\n * - \"undeveloped\": not developed further (insufficient consequence/info) → diamond;\n * - \"house\": event normally expected to occur (external/boundary) → house;\n * - \"conditioning\": condition/restriction on an INHIBIT gate → oval (never a tree node);\n * - \"transfer\": transfer-in, subtree developed elsewhere → triangle (a leaf).\n */\nexport const FAULT_TREE_EVENT_KINDS = [\n \"intermediate\",\n \"basic\",\n \"undeveloped\",\n \"house\",\n \"conditioning\",\n \"transfer\",\n] as const;\nexport type FaultTreeEventKind = (typeof FAULT_TREE_EVENT_KINDS)[number];\n\n/**\n * A declared fault-tree event. `label` is verbatim (always kept in the <title>);\n * `code` is a short identifier drawn inside primary-event glyphs (null = none) —\n * matching FTA practice, where primary-event symbols carry identifiers and the\n * descriptions live beside them.\n */\nexport interface FaultTreeEvent {\n id: number;\n kind: FaultTreeEventKind;\n label: string;\n code: string | null;\n /** Optional verbatim <title> override (defaults to \"code · label\"). */\n title?: string;\n}\n\n/**\n * CLOSED gate vocabulary. NOT/NAND/NOR and PRIORITY-AND are deliberately\n * unrepresentable — an unsupported gate is a compile error, never a silent visual\n * fallback (the NOT bubble-triangle would also collide with the transfer triangle).\n */\nexport const GATE_TYPES = [\"and\", \"or\", \"xor\", \"inhibit\", \"vote\"] as const;\nexport type GateType = (typeof GATE_TYPES)[number];\n\ninterface FaultTreeGateBase {\n id: number;\n /** The intermediate event this gate resolves (drawn directly above the gate). */\n eventId: number;\n /** Declared left-to-right reading order — presentation data, honored as given. */\n inputIds: number[];\n}\n\nexport interface AndGate extends FaultTreeGateBase {\n type: \"and\";\n}\nexport interface OrGate extends FaultTreeGateBase {\n type: \"or\";\n}\nexport interface XorGate extends FaultTreeGateBase {\n type: \"xor\";\n}\nexport interface InhibitGate extends FaultTreeGateBase {\n type: \"inhibit\";\n /** Must reference a kind:\"conditioning\" event (drawn as the side oval). */\n conditionId: number;\n}\nexport interface VoteGate extends FaultTreeGateBase {\n type: \"vote\";\n /** Output occurs if ≥ k of the n inputs occur; 1 ≤ k ≤ inputIds.length. */\n k: number;\n}\nexport type FaultTreeGate = AndGate | OrGate | XorGate | InhibitGate | VoteGate;\n\n/** Input to the fault-tree render pipeline. */\nexport interface FaultTreeInput {\n /** Declared top event (must be kind \"intermediate\", never a gate input). */\n topId: number;\n events: FaultTreeEvent[];\n gates: FaultTreeGate[];\n}\n","// Display vocabularies — every human-readable string the fault tree emits, gathered\n// in overridable packs so the diagram localizes without touching the engine. English\n// defaults here; `compasso/locales/pt-br` ships a Brazilian Portuguese pack.\n//\n// Gate titles carry the standard gate NAME only (a vote title appends its declared\n// \"k/n\") — the gate's semantics belong to the standard's text, not the SVG.\n\nimport type { FaultTreeEventKind, GateType } from \"./types\";\n\n/** Labels woven into element <title>s by the LAYOUT (verbatim-preserving). */\nexport interface FaultTreeTitleLabels {\n gates: Record<GateType, string>;\n /** Title of the inhibit-gate → conditioning-oval attachment line. */\n condition: string;\n}\n\nexport const FAULT_TREE_TITLE_LABELS_EN: FaultTreeTitleLabels = {\n gates: {\n and: \"AND gate\",\n or: \"OR gate\",\n xor: \"Exclusive-OR gate\",\n inhibit: \"Inhibit gate\",\n vote: \"Voting gate\",\n },\n condition: \"condition\",\n};\n\n/** Labels drawn by the SVG EMITTER (legend entries, accessibility text). */\nexport interface FaultTreeSvgLabels {\n events: Record<FaultTreeEventKind, string>;\n gates: Record<GateType, string>;\n ariaLabel: string;\n}\n\nexport const FAULT_TREE_SVG_LABELS_EN: FaultTreeSvgLabels = {\n events: {\n intermediate: \"Intermediate event\",\n basic: \"Basic event\",\n undeveloped: \"Undeveloped event\",\n house: \"External event (normally occurs)\",\n conditioning: \"Conditioning event\",\n transfer: \"Transfer (developed elsewhere)\",\n },\n gates: {\n and: \"AND gate (all inputs)\",\n or: \"OR gate (any input)\",\n xor: \"Exclusive-OR gate (exactly one input)\",\n inhibit: \"INHIBIT gate (input under condition)\",\n vote: \"Voting gate (k of n)\",\n },\n ariaLabel: \"Fault tree\",\n};\n","// Fault-tree validation — REJECT, never repair. The genogram silently filters\n// dangling references because a family map is elicited incrementally; a fault tree is\n// a safety artifact whose meaning lives in its logic structure, so drawing a\n// structurally invalid tree (or silently altering its logic) is worse than refusing.\n// The standard itself has a notation for \"honestly incomplete\" — the diamond\n// (undeveloped event) and the transfer triangle — and the error messages point there.\n//\n// Every problem is reported, not just the first: issues are aggregated, deduplicated\n// and sorted deterministically (by code, then message), each carrying a STABLE\n// kebab-case machine-readable `code`. Validation runs in THREE phases, each gated on\n// the previous being clean ENOUGH for the next to be meaningful — not on \"zero issues\n// so far\", so a defect in one phase never silently hides an honest issue from a later\n// one (the throw must carry ALL real issues, not just the first phase's):\n// (0) duplicate ids. The lookup maps are first-occurrence-wins, so EVERY reference\n// rule below would validate whichever duplicate row was declared first — making\n// the issue list depend on array order, violating this function's documented\n// order-invariance. When any duplicate-id issue exists we report ONLY those and\n// stop (the duplicate already forces a throw, present in every permutation).\n// (1) reference / semantic rules (R2–R7, R10–R14): top, per-gate references, arity,\n// vote threshold, gate ownership. Always evaluated once ids are unambiguous.\n// (2) graph rules (R8 reachability, R9 cycles) — gated ONLY on the reference-INTEGRITY\n// subset that genuinely makes traversal meaningless, NOT on every phase-1 issue.\n// The traversal walks `gateOf(eventId)` → gate.inputIds (+ inhibit conditionId)\n// seeded at topId, so it is corrupted by: duplicate-id (ambiguous first-wins\n// node), unknown-input (walks a phantom node), gate-on-non-intermediate /\n// transfer-with-gate (attaches a gate to a leaf, fabricating descent),\n// event-with-two-gates (gateOf's first-match silently picks one), inhibit-\n// condition (a non-conditioning conditionId is queued as a phantom node), and\n// top-not-intermediate (the BFS frontier is rooted at a non-node). Defects that\n// do NOT impair traversal — vote-threshold, gate-arity (k/arity are never read),\n// top-as-input, conditioning-as-input, event-without-gate, intermediate-reused\n// (all reference real, walkable nodes) — do NOT suppress the graph phase, so e.g.\n// a bad vote k alongside an unreachable event reports BOTH in one throw.\n//\n// Tolerated, by design (drawn as declared, never converted):\n// - repeated LEAF events (basic/undeveloped/house/transfer) in several gates' inputs\n// — that IS the standard repeated-event notation (drawn once per reference; hooks\n// are disambiguated with data-instance, see ./layout.ts);\n// - a conditioning event attached to more than one inhibit gate (one oval per gate);\n// - vote gates with k=1 or k=n (logically OR/AND — converting would be interpretation);\n// - empty labels (drawn empty; the <title> is still present).\n\nimport type { FaultTreeEvent, FaultTreeGate, FaultTreeInput } from \"./types\";\n\n/** Stable machine-readable issue codes (kebab-case; part of the public contract). */\nexport type FaultTreeIssueCode =\n | \"duplicate-id\"\n | \"top-not-intermediate\"\n | \"top-as-input\"\n | \"gate-on-non-intermediate\"\n | \"transfer-with-gate\"\n | \"event-with-two-gates\"\n | \"event-without-gate\"\n | \"intermediate-reused\"\n | \"unknown-input\"\n | \"conditioning-as-input\"\n | \"inhibit-condition\"\n | \"gate-arity\"\n | \"vote-threshold\"\n | \"unreachable-event\"\n | \"cycle\";\n\nexport interface FaultTreeIssue {\n code: FaultTreeIssueCode;\n message: string;\n}\n\n/** Thrown by computeFaultTreeLayout / faultTreeSvg on a structurally invalid tree. */\nexport class FaultTreeValidationError extends Error {\n readonly issues: readonly FaultTreeIssue[];\n\n constructor(issues: readonly FaultTreeIssue[]) {\n super(`invalid fault tree: ${issues.map((i) => i.message).join(\"; \")}`);\n this.name = \"FaultTreeValidationError\";\n this.issues = issues;\n }\n}\n\n/** \"1 and 3\" / \"1, 2 and 3\" — deterministic listing for issue messages. */\nfunction listIds(ids: readonly number[]): string {\n if (ids.length === 1) return String(ids[0]);\n return `${ids.slice(0, -1).join(\", \")} and ${ids[ids.length - 1]}`;\n}\n\n/**\n * Deduplicate + deterministic order: by code, then message (byte comparison — stable\n * across engines; no locale-dependent collation). Shared by every phase that returns.\n */\nfunction sortIssues(issues: readonly FaultTreeIssue[]): readonly FaultTreeIssue[] {\n const unique = new Map<string, FaultTreeIssue>();\n for (const issue of issues) unique.set(`${issue.code} ${issue.message}`, issue);\n return [...unique.values()].sort((a, b) =>\n a.code !== b.code ? (a.code < b.code ? -1 : 1) : a.message < b.message ? -1 : a.message > b.message ? 1 : 0,\n );\n}\n\n/**\n * Computes ALL validation issues for the input, deduplicated and deterministically\n * sorted (code, then message) — array order of `events`/`gates` never changes the\n * result. Empty input (no events AND no gates) is valid by definition (the renderer's\n * empty-but-valid SVG case) and reports no issues.\n */\nexport function faultTreeIssues(input: FaultTreeInput): readonly FaultTreeIssue[] {\n if (input.events.length === 0 && input.gates.length === 0) return [];\n\n const issues: FaultTreeIssue[] = [];\n const push = (code: FaultTreeIssueCode, message: string): void => {\n issues.push({ code, message });\n };\n\n // ── R1: duplicate ids (per namespace — hooks must be unique). Any duplicate makes\n // the structure ambiguous, so this is phase 0 and short-circuits the rest (below). ─\n const eventById = new Map<number, FaultTreeEvent>();\n const dupEventIds = new Set<number>();\n for (const e of input.events) {\n if (eventById.has(e.id)) dupEventIds.add(e.id);\n else eventById.set(e.id, e);\n }\n for (const id of [...dupEventIds].sort((a, b) => a - b)) {\n push(\"duplicate-id\", `duplicate event id ${id}`);\n }\n const gateById = new Map<number, FaultTreeGate>();\n const dupGateIds = new Set<number>();\n for (const g of input.gates) {\n if (gateById.has(g.id)) dupGateIds.add(g.id);\n else gateById.set(g.id, g);\n }\n for (const id of [...dupGateIds].sort((a, b) => a - b)) {\n push(\"duplicate-id\", `duplicate gate id ${id}`);\n }\n\n // ── Phase 0: duplicate ids short-circuit everything else. The lookup maps below are\n // first-occurrence-wins, so every downstream reference rule would validate whichever\n // duplicate row happened to be declared first — making the issue list depend on the\n // `events`/`gates` ARRAY ORDER, in direct violation of this function's documented\n // order-invariance. Rules evaluated over an ambiguous first-wins structure are as\n // meaningless as the graph rules over dangling references, so we report ONLY the\n // duplicate-id issues and stop (the structural defect already forces a throw). This\n // extends the existing phase doctrine one level up: duplicate ids → reference rules →\n // graph rules, each phase gated on the prior being clean enough to be meaningful. ──\n if (issues.length > 0) {\n return sortIssues(issues);\n }\n\n const gates = [...gateById.values()].sort((a, b) => a.id - b.id);\n\n // ── R2: the declared top must be an existing intermediate event. ─────────────────\n const top = eventById.get(input.topId);\n if (top === undefined || top.kind !== \"intermediate\") {\n push(\"top-not-intermediate\", `topId ${input.topId} is not an intermediate event`);\n }\n\n // ── Per-gate reference/arity rules (R3, R4, R10–R14). ───────────────────────────\n const conditioningAsInput = new Set<number>();\n for (const g of gates) {\n const out = eventById.get(g.eventId);\n if (out !== undefined && out.kind === \"transfer\") {\n // R13 — transfer-in marks \"developed elsewhere\": a leaf by definition.\n push(\"transfer-with-gate\", `transfer event ${g.eventId} cannot have a gate`);\n } else if (out === undefined || out.kind !== \"intermediate\") {\n // R4 — only rectangles are developed through a gate.\n push(\"gate-on-non-intermediate\", `gate ${g.id} resolves non-intermediate event ${g.eventId}`);\n }\n\n // R10 — a gate IS a logic combination; INHIBIT is single-input-plus-condition.\n if (g.type === \"inhibit\") {\n if (g.inputIds.length !== 1) push(\"gate-arity\", `inhibit gate ${g.id} needs exactly 1 input`);\n } else if (g.inputIds.length < 2) {\n push(\"gate-arity\", `${g.type} gate ${g.id} needs ≥2 inputs`);\n }\n\n // R12 — a voting threshold outside the integers 1..n is meaningless. Number.isInteger\n // also rejects NaN/±Infinity and fractional k (k is a plain `number`, so JSON can\n // carry those) — drawing \"NaN/2\" or \"1.5/2\" would repair a meaningless threshold by\n // rendering it, which the reject-never-repair doctrine forbids.\n if (g.type === \"vote\" && (!Number.isInteger(g.k) || g.k < 1 || g.k > g.inputIds.length)) {\n push(\"vote-threshold\", `vote gate ${g.id}: k=${g.k} of ${g.inputIds.length}`);\n }\n\n // R11a — the oval attaches to a gate; inhibit must reference a conditioning event.\n if (g.type === \"inhibit\") {\n const cond = eventById.get(g.conditionId);\n if (cond === undefined || cond.kind !== \"conditioning\") {\n push(\"inhibit-condition\", `inhibit gate ${g.id} conditionId ${g.conditionId} is not a conditioning event`);\n }\n }\n\n for (const inputId of g.inputIds) {\n const child = eventById.get(inputId);\n if (child === undefined) {\n // Dangling input — silently dropping it would alter the declared logic.\n push(\"unknown-input\", `gate ${g.id} input ${inputId} is not a declared event`);\n continue;\n }\n // R3 — the top is the tree apex, never an input.\n if (inputId === input.topId) push(\"top-as-input\", `top event ${input.topId} is used as a gate input`);\n // R11b — a conditioning event is never a tree node (NUREG-0492: it restricts a gate).\n if (child.kind === \"conditioning\") conditioningAsInput.add(inputId);\n }\n }\n for (const id of [...conditioningAsInput].sort((a, b) => a - b)) {\n push(\"conditioning-as-input\", `conditioning event ${id} used as a gate input`);\n }\n\n // ── R5/R6: exactly one gate per intermediate event. ─────────────────────────────\n const gatesByEvent = new Map<number, number[]>();\n for (const g of gates) {\n const arr = gatesByEvent.get(g.eventId) ?? [];\n arr.push(g.id);\n gatesByEvent.set(g.eventId, arr);\n }\n for (const [eventId, gateIds] of [...gatesByEvent.entries()].sort((a, b) => a[0] - b[0])) {\n if (gateIds.length > 1) {\n push(\"event-with-two-gates\", `event ${eventId} is resolved by gates ${listIds(gateIds.sort((a, b) => a - b))}`);\n }\n }\n for (const e of [...eventById.values()].sort((a, b) => a.id - b.id)) {\n if (e.kind === \"intermediate\" && !gatesByEvent.has(e.id)) {\n // R6 — a rectangle without a gate falsely claims development; the diamond\n // (undeveloped) is the standard's own symbol for \"not developed further\".\n push(\"event-without-gate\", `intermediate event ${e.id} has no gate — declare it kind \"undeveloped\" instead`);\n }\n }\n\n // ── R7: an intermediate may feed only ONE gate input — duplicating whole subtrees\n // silently is synthesis; the standard's answer is the transfer triangle. ───────\n const intermediateRefs = new Map<number, number[]>(); // event id → referencing gate ids\n for (const g of gates) {\n for (const inputId of g.inputIds) {\n if (eventById.get(inputId)?.kind !== \"intermediate\") continue;\n const arr = intermediateRefs.get(inputId) ?? [];\n arr.push(g.id);\n intermediateRefs.set(inputId, arr);\n }\n }\n for (const [eventId, gateIds] of [...intermediateRefs.entries()].sort((a, b) => a[0] - b[0])) {\n if (gateIds.length > 1) {\n push(\n \"intermediate-reused\",\n `intermediate event ${eventId} feeds gates ${listIds(gateIds.sort((a, b) => a - b))} — repeat it via a \"transfer\" event`,\n );\n }\n }\n\n // ── Graph rules (R8 reachability, R9 cycles) — phase 2. Gated ONLY on the reference-\n // INTEGRITY codes that corrupt the traversal itself (see the module header for the\n // per-code justification), NOT on every phase-1 issue: a meaningless vote k or wrong\n // arity leaves the graph fully walkable, so suppressing R8/R9 for them would hide an\n // honest issue and break the \"throw with ALL issues\" doctrine. ─────────────────────\n const GRAPH_BLOCKING: ReadonlySet<FaultTreeIssueCode> = new Set([\n \"duplicate-id\",\n \"unknown-input\",\n \"gate-on-non-intermediate\",\n \"transfer-with-gate\",\n \"event-with-two-gates\",\n \"inhibit-condition\",\n \"top-not-intermediate\",\n ]);\n if (!issues.some((i) => GRAPH_BLOCKING.has(i.code))) {\n const gateOf = (eventId: number): FaultTreeGate | undefined => gates.find((g) => g.eventId === eventId);\n\n // R8 — every declared event must be reachable from the top (silently dropping\n // declared data violates honesty). Conditioning events reach through their gate.\n const reachable = new Set<number>();\n const queue: number[] = [input.topId];\n while (queue.length > 0) {\n const id = queue.shift()!;\n if (reachable.has(id)) continue;\n reachable.add(id);\n const g = gateOf(id);\n if (g === undefined) continue;\n queue.push(...g.inputIds);\n if (g.type === \"inhibit\") queue.push(g.conditionId);\n }\n for (const e of [...eventById.values()].sort((a, b) => a.id - b.id)) {\n if (!reachable.has(e.id)) push(\"unreachable-event\", `event ${e.id} is declared but unreachable from the top`);\n }\n\n // R9 — cycle detection over the whole event graph (event → its gate's inputs).\n // Iterative coloring DFS, start nodes ascending, children in declared order; each\n // distinct cycle is reported once, rotated to start at its smallest event id so\n // the message is identical for any array order of the same input.\n const color = new Map<number, 0 | 1 | 2>(); // 0/absent=white, 1=gray, 2=black\n const seenCycles = new Set<string>();\n const dfs = (start: number): void => {\n const stack: { id: number; nextChild: number }[] = [{ id: start, nextChild: 0 }];\n color.set(start, 1);\n while (stack.length > 0) {\n const frame = stack[stack.length - 1]!;\n const children = gateOf(frame.id)?.inputIds ?? [];\n if (frame.nextChild >= children.length) {\n color.set(frame.id, 2);\n stack.pop();\n continue;\n }\n const child = children[frame.nextChild]!;\n frame.nextChild += 1;\n const c = color.get(child) ?? 0;\n if (c === 1) {\n // Back edge: the cycle is the stack slice from `child` down to the current frame.\n const from = stack.findIndex((f) => f.id === child);\n const cycle = stack.slice(from).map((f) => f.id);\n const minIdx = cycle.indexOf(Math.min(...cycle));\n const rotated = [...cycle.slice(minIdx), ...cycle.slice(0, minIdx)];\n const key = rotated.join(\">\");\n if (!seenCycles.has(key)) {\n seenCycles.add(key);\n push(\"cycle\", `cycle: ${[...rotated, rotated[0]!].join(\" → \")}`);\n }\n } else if (c === 0) {\n color.set(child, 1);\n stack.push({ id: child, nextChild: 0 });\n }\n }\n };\n for (const e of [...eventById.values()].sort((a, b) => a.id - b.id)) {\n if ((color.get(e.id) ?? 0) === 0) dfs(e.id);\n }\n }\n\n return sortIssues(issues);\n}\n\n/** Throws FaultTreeValidationError (carrying ALL issues) when the input is invalid. */\nexport function validateFaultTree(input: FaultTreeInput): void {\n const issues = faultTreeIssues(input);\n if (issues.length > 0) throw new FaultTreeValidationError(issues);\n}\n","// PURE fault-tree layout — the single source of truth for positioning and connector\n// routing. The emitter (./svg.ts) draws EXACTLY what this computes, so any number of\n// surfaces (web, PDF, image pipelines) can never drift from each other.\n//\n// It is deliberately PURE — no DOM, no Node APIs, no clock, no randomness — so the\n// same input always yields the same layout, byte for byte.\n//\n// HONESTY RULE: this module only POSITIONS what the caller declared. Validation\n// (./validate.ts) THROWS on a structurally invalid tree instead of repairing it —\n// a fault tree is a safety artifact and silently altering its logic is synthesis.\n// Tolerated repetition is the standard's own notation: a repeated LEAF event\n// (basic/undeveloped/house/transfer in several gates' inputs) is drawn once per\n// reference, exactly as hand-drawn FTA repeats the same circle at each site; hooks\n// are disambiguated with a 0-based `instance` index in deterministic DFS pre-order\n// (event, then inhibit condition, then inputs in declared order). This is also the\n// forward answer for DAG-shaped trees: model the shared subtree as a `transfer` leaf.\n//\n// LAYOUT — top-down levels, exactly as every NUREG-0492 / IEC 61025 figure draws it:\n// event rectangle, short stem, gate beneath, orthogonal connector rake to children.\n// Horizontal placement is NAIVE SUBTREE-SPAN PACKING (not Reingold–Tilford contours):\n// every node carries asymmetric half-extents {spanL, spanR} covering its ENTIRE\n// subtree drawing (glyphs, labels, gate, conditioning oval, its own buses); siblings\n// are placed with disjoint intervals H_GAP apart, and the recursion makes the\n// guarantee global — a 5-line inductive overlap proof, re-verified by the test\n// harness, at the cost of some width on unbalanced trees. Label widths reserve real\n// space because nodeW comes from estimateTextWidth over the wrapped lines and the\n// emitter draws with the same core metrics: what is proven is what is drawn.\n//\n// GATE-CLEARANCE INVARIANT (directly asserted in test/fault-tree/layout.test.ts):\n// every gate glyph bottom at depth d sits strictly ABOVE the child bus y, because\n// rowTop(d+1) = rowTop(d) + rowH(d) + gateZone(d) + CORRIDOR reserves the full gate\n// zone and busY = rowTop(d+1) − CORRIDOR/2 leaves CORRIDOR/2 of air below it.\n\nimport { CHAR_W, clampLabel, estimateTextWidth, wrapLabel, wrapLabelBalanced, type Point } from \"../core\";\nimport { FAULT_TREE_TITLE_LABELS_EN, type FaultTreeTitleLabels } from \"./labels\";\nimport { validateFaultTree } from \"./validate\";\nimport type { FaultTreeEvent, FaultTreeEventKind, FaultTreeGate, FaultTreeInput, GateType } from \"./types\";\n\nexport { FaultTreeValidationError, faultTreeIssues, validateFaultTree, type FaultTreeIssue, type FaultTreeIssueCode } from \"./validate\";\n// Re-exported so the overlap harness (and decorating callers) measure with the EXACT\n// metrics the layout reserved space with — the shared-metrics contract.\nexport { estimateTextWidth };\nexport type { Point };\n\n// ── Type metrics (shared by layout AND the emitter, so geometry == render) ──────\n/** Node label font size (px). */\nexport const FT_LABEL_FONT = 12;\n/** Line height for stacked label lines (px). */\nexport const FT_LABEL_LINE_H = 14;\n/** Short-code font size (px) — drawn inside primary-event glyphs. */\nexport const CODE_FONT = 10;\n/** Gap from a leaf glyph's bottom to the top of its first label line. */\nexport const LABEL_GAP = 6;\n\n// ── Geometry constants ───────────────────────────────────────────────────────────\nconst PADDING = 32;\n/** Min horizontal air between two sibling subtree intervals. */\nconst H_GAP = 28;\n/** Vertical band between a row's gate zone and the next row (the bus lives mid-way). */\nconst CORRIDOR = 30;\n/** Vertical stem from an event's bottom edge to its gate's top. */\nconst STEM = 10;\n/** Horizontal gap between an inhibit gate's right vertex and its conditioning node. */\nconst COND_GAP = 14;\n\n// Gate glyph boxes (NUREG-0492 distinctive shapes, drawn pointing up).\nconst GATE_W = 44;\nconst GATE_H = 36;\n/** XOR = the OR shape + a detached concave arc 5px below the base (ANSI/IEEE 91). */\nconst XOR_H = GATE_H + 5;\nconst INHIBIT_W = 36;\nconst INHIBIT_H = 46;\n/** Y of the inhibit hexagon's side-vertex midpoint (the condition line's anchor). */\nconst INHIBIT_CY = 23;\n\n// ── Namespaced element ids (one element kind per numeric block, extending the\n// genogram convention) — every data-edge-id stays traceable to its source row. ──\nexport const FT_STEM_ID_BASE = 1_000_000; // + gate id\nexport const FT_DROP_ID_BASE = 2_000_000; // + gate id\nexport const FT_BUS_ID_BASE = 3_000_000; // + gate id\nexport const FT_RISER_ID_BASE = 4_000_000; // + child event id\nexport const FT_CONDITION_ID_BASE = 5_000_000; // + gate id\n\nconst round = (n: number): number => Math.round(n * 100) / 100;\n\n// ── Positioned layout ─────────────────────────────────────────────────────────────\n\nexport interface FaultTreeNode {\n eventId: number;\n kind: FaultTreeEventKind;\n /** 0-based DFS pre-order instance index; null when the event is drawn once. */\n instance: number | null;\n /** Glyph center x. */\n cx: number;\n /** Glyph top y (leaf labels hang below the glyph; the rect IS the glyph). */\n top: number;\n /** Full node box (glyph + label block) — the packing reserved exactly this. */\n nodeW: number;\n nodeH: number;\n glyphW: number;\n glyphH: number;\n /** Wrapped display lines — inside the rect (intermediate) or below the glyph. */\n labelLines: string[];\n /** Top of the first label line's box; null when the label sits inside the rect. */\n labelTop: number | null;\n /** Clamped display code drawn inside a non-rect glyph; null = none. */\n code: string | null;\n /** Depth of the row this node lives in (a conditioning node: its gate's row). */\n depth: number;\n /** Verbatim <title> text (event.title ?? \"code · label\" ?? label). */\n title: string;\n}\n\nexport interface FaultTreeGateNode {\n gateId: number;\n type: GateType;\n cx: number;\n /** Glyph top y (all gates of a row are top-aligned at rowBottom + STEM). */\n top: number;\n glyphW: number;\n /** Full glyph height incl. the XOR's detached arc — top + glyphH = connector bottom. */\n glyphH: number;\n /** Localized gate name (vote: name + \" k/n\"). */\n title: string;\n /** \"k/n\" drawn inside a vote gate; null otherwise. */\n voteText: string | null;\n}\n\nexport type FaultTreeElementKind = \"stem\" | \"drop\" | \"bus\" | \"riser\" | \"condition\";\n\nexport interface FaultTreeElement {\n /** Namespaced id (FT_*_ID_BASE + gate id / child event id). */\n edgeId: number;\n kind: FaultTreeElementKind;\n /** Two waypoints, always axis-aligned (H or V). */\n points: Point[];\n /** Riser into a repeated-leaf instance: that instance index; else null. */\n instance: number | null;\n /** Localized gate name (condition elements: titleLabels.condition). */\n title: string;\n}\n\nexport interface FaultTreeLayout {\n width: number;\n height: number;\n /** DFS pre-order (event, condition, inputs) — repeated leaves appear per instance. */\n nodes: FaultTreeNode[];\n gates: FaultTreeGateNode[];\n elements: FaultTreeElement[];\n}\n\nexport interface FaultTreeLayoutOptions {\n /** Cap each node's DISPLAY label (compact preview); verbatim text stays in `title`. */\n maxLabelChars?: number;\n /** Locale pack for gate/condition <title>s — English default; see locale packs. */\n titleLabels?: FaultTreeTitleLabels;\n}\n\n// ── Measurement ───────────────────────────────────────────────────────────────────\n\ninterface Measured {\n nodeW: number;\n nodeH: number;\n glyphW: number;\n glyphH: number;\n labelLines: string[];\n code: string | null;\n}\n\n/** Leaf-label wrap: tighter budget than the rect's (glyphs don't grow with text). */\nfunction wrapLeafLabel(displayLabel: string): string[] {\n const perLine = Math.min(20, Math.max(12, Math.ceil(displayLabel.length / 2) + 2));\n return wrapLabel(displayLabel, perLine);\n}\n\n// ── Per-glyph code-char clamp — guarantees the code sits INSIDE its fixed-size\n// glyph (the design doc's \"code drawn inside the glyph\" claim), DERIVED from THIS\n// module's own metrics rather than eyeballed. Only the conditioning OVAL is\n// excluded: it GROWS to the measured code width (`rx = max(30, codeW/2 + 8)`), so\n// it never clamps — see measureEvent. The full verbatim code always survives in\n// the <title> (eventTitle), so clamping is presentation-only, never data loss.\n//\n// Geometry. The emitter (svg.ts) draws the code centered at `cx`, `text-anchor\n// \"middle\"`, its baseline (the literal `<text y>`, i.e. the code's ACTUAL drawn\n// y-position) at `top + glyphH/2 + CODE_FONT*0.32`. N chars span ±estimateTextWidth\n// (N)/2 = ±(N·CODE_FONT·CHAR_W)/2 about cx. The clamp keeps that half-span inside\n// the glyph's half-width AT THAT BASELINE Y (`codeBaselineHalfWidth` below), with a\n// couple px margin AND real-font headroom: real Helvetica caps run wider than the\n// deliberately-light CHAR_W=0.6 estimate at these small extremes (the review\n// measured ~20.3px real vs 18px estimated for a 6-char code, ≈1.13×), so we reserve\n// CODE_REAL_HEADROOM on top of the estimate. Solving for the largest integer N in\n// N·(CODE_FONT·CHAR_W·CODE_REAL_HEADROOM)/2 + CODE_MARGIN ≤ half(baseline)\n// yields (recomputed by maxCodeChars, not hand-copied): basic 5, undeveloped 5,\n// house 5, transfer 3 — the apex-up triangle is narrowest at the code's height.\nconst CODE_REAL_HEADROOM = 1.15;\nconst CODE_MARGIN = 2;\n\n/** Glyph half-width at vertical offset `y` below the glyph top, per non-rect kind. */\nfunction codeGlyphHalfAt(kind: Exclude<FaultTreeEventKind, \"intermediate\" | \"conditioning\">, y: number): number {\n if (kind === \"basic\") {\n // circle r 22, center at top+22\n const dy = y - 22;\n return Math.sqrt(Math.max(0, 22 * 22 - dy * dy));\n }\n if (kind === \"undeveloped\") {\n // diamond half 24, center at top+24, linear taper to the apex/bottom\n return 24 * Math.max(0, 1 - Math.abs(y - 24) / 24);\n }\n if (kind === \"house\") {\n // walls ±22 below the eave (top+16); roof tapers linearly above it to the apex\n return y >= 16 ? 22 : (22 * y) / 16;\n }\n // transfer — apex-up triangle, base ±22 at top+35; half grows linearly from the apex\n return (22 * Math.max(0, Math.min(35, y))) / 35;\n}\n\n/** Glyph half-width at the code text's baseline (its actual drawn `<text y>`). */\nfunction codeBaselineHalfWidth(\n kind: Exclude<FaultTreeEventKind, \"intermediate\" | \"conditioning\">,\n glyphH: number,\n): number {\n return codeGlyphHalfAt(kind, glyphH / 2 + CODE_FONT * 0.32);\n}\n\n/** Largest code length that, drawn, stays inside the glyph (estimator + headroom + margin). */\nexport function maxCodeChars(\n kind: Exclude<FaultTreeEventKind, \"intermediate\" | \"conditioning\">,\n glyphH: number,\n): number {\n const half = codeBaselineHalfWidth(kind, glyphH);\n const perChar = (CODE_FONT * CHAR_W * CODE_REAL_HEADROOM) / 2; // half-advance with headroom\n return Math.max(1, Math.floor((half - CODE_MARGIN) / perChar));\n}\n\nfunction measureEvent(event: FaultTreeEvent, maxLabelChars: number | undefined): Measured {\n if (event.kind === \"intermediate\") {\n // The rectangle IS a text panel (the standard writes the description inside it).\n const lines = event.label === \"\" ? [] : wrapLabelBalanced(clampLabel(event.label, maxLabelChars), 3);\n const maxLineW = lines.reduce((m, l) => Math.max(m, estimateTextWidth(l, FT_LABEL_FONT)), 0);\n const w = Math.max(96, maxLineW + 24);\n const h = lines.length * FT_LABEL_LINE_H + 18;\n return { nodeW: w, nodeH: h, glyphW: w, glyphH: h, labelLines: lines, code: null };\n }\n const rawCode = event.code === null || event.code === \"\" ? null : event.code;\n const lines = event.label === \"\" ? [] : wrapLeafLabel(clampLabel(event.label, maxLabelChars));\n const labelW = lines.reduce((m, l) => Math.max(m, estimateTextWidth(l, FT_LABEL_FONT)), 0);\n let glyphW: number;\n let glyphH: number;\n // Fixed-size glyphs clamp the code to what their outline can hold (CODE_MAX_CHARS,\n // derived above); the conditioning OVAL instead grows to the measured code width.\n let code = rawCode;\n if (event.kind === \"basic\") {\n glyphW = 44; // circle r 22\n glyphH = 44;\n code = rawCode === null ? null : clampLabel(rawCode, maxCodeChars(\"basic\", glyphH));\n } else if (event.kind === \"undeveloped\") {\n glyphW = 48; // rotated square, half 24\n glyphH = 48;\n code = rawCode === null ? null : clampLabel(rawCode, maxCodeChars(\"undeveloped\", glyphH));\n } else if (event.kind === \"house\") {\n glyphW = 44; // pentagon: 24px walls + 16px roof\n glyphH = 40;\n code = rawCode === null ? null : clampLabel(rawCode, maxCodeChars(\"house\", glyphH));\n } else if (event.kind === \"conditioning\") {\n // The oval reserves the FULL (only globally-capped) code width — no glyph clamp.\n code = rawCode === null ? null : clampLabel(rawCode, 6);\n const rx = Math.max(30, estimateTextWidth(code ?? \"\", CODE_FONT) / 2 + 8);\n glyphW = rx * 2;\n glyphH = 32; // ellipse ry 16\n } else {\n glyphW = 44; // transfer triangle, apex up\n glyphH = 35;\n code = rawCode === null ? null : clampLabel(rawCode, maxCodeChars(\"transfer\", glyphH));\n }\n const nodeW = Math.max(glyphW, labelW);\n const nodeH = glyphH + (lines.length > 0 ? LABEL_GAP + lines.length * FT_LABEL_LINE_H : 0);\n return { nodeW, nodeH, glyphW, glyphH, labelLines: lines, code };\n}\n\nfunction eventTitle(event: FaultTreeEvent): string {\n if (event.title !== undefined) return event.title;\n return event.code !== null && event.code !== \"\" ? `${event.code} · ${event.label}` : event.label;\n}\n\n// ── Internal working tree (one node per drawn INSTANCE) ───────────────────────────\n\ninterface Inst {\n event: FaultTreeEvent;\n gate: FaultTreeGate | null;\n children: Inst[];\n /** Conditioning instance attached to an inhibit gate; positioned in the gate zone. */\n cond: Inst | null;\n depth: number;\n m: Measured;\n title: string;\n /** Per-event-id DFS pre-order sequence (becomes `instance` when the event repeats). */\n seq: number;\n // Subtree half-extents (cover the ENTIRE subtree drawing) and resolved positions.\n spanL: number;\n spanR: number;\n /** Center offset relative to the parent's center (root: unused). */\n offset: number;\n cx: number;\n}\n\n/**\n * Deterministic, overlap-proof fault-tree layout (pure function of the inputs).\n * Validates first and THROWS FaultTreeValidationError on a structurally invalid\n * tree — never sanitizes. Empty input (no events, no gates) yields an empty,\n * padded layout; `topId` is ignored in that one case.\n */\nexport function computeFaultTreeLayout(\n input: FaultTreeInput,\n opts: FaultTreeLayoutOptions = {},\n): FaultTreeLayout {\n if (input.events.length === 0 && input.gates.length === 0) {\n return { width: PADDING * 2, height: PADDING * 2, nodes: [], gates: [], elements: [] };\n }\n validateFaultTree(input);\n\n const titleLabels = opts.titleLabels ?? FAULT_TREE_TITLE_LABELS_EN;\n const eventById = new Map(input.events.map((e) => [e.id, e]));\n const gateByEvent = new Map(input.gates.map((g) => [g.eventId, g]));\n\n // ── Build the instance tree by DFS from the top (event → condition → inputs in\n // declared order). Validation guarantees: intermediates form a tree, leaves may\n // repeat, conditioning events never have gates or children. ───────────────────\n const allInsts: Inst[] = [];\n const seqByEvent = new Map<number, number>();\n const newInst = (event: FaultTreeEvent, gate: FaultTreeGate | null, depth: number): Inst => {\n const seq = seqByEvent.get(event.id) ?? 0;\n seqByEvent.set(event.id, seq + 1);\n const inst: Inst = {\n event,\n gate,\n children: [],\n cond: null,\n depth,\n m: measureEvent(event, opts.maxLabelChars),\n title: eventTitle(event),\n seq,\n spanL: 0,\n spanR: 0,\n offset: 0,\n cx: 0,\n };\n allInsts.push(inst);\n return inst;\n };\n const build = (eventId: number, depth: number): Inst => {\n const event = eventById.get(eventId)!;\n const gate = gateByEvent.get(eventId) ?? null;\n const inst = newInst(event, gate, depth);\n if (gate !== null) {\n if (gate.type === \"inhibit\") {\n inst.cond = newInst(eventById.get(gate.conditionId)!, null, depth);\n }\n for (const childId of gate.inputIds) inst.children.push(build(childId, depth + 1));\n }\n return inst;\n };\n const root = build(input.topId, 0);\n\n // ── Horizontal: subtree-span packing (post-order). The conditioning oval reserves\n // REAL width on the right of an inhibit-developed node — never overlaps a sibling.\n const pack = (inst: Inst): void => {\n for (const c of inst.children) pack(c);\n const condW = inst.cond !== null ? COND_GAP + inst.cond.m.nodeW : 0;\n const selfL = inst.m.nodeW / 2;\n const selfR = inst.m.nodeW / 2 + condW;\n if (inst.children.length === 0) {\n inst.spanL = selfL;\n inst.spanR = selfR;\n return;\n }\n const xs: number[] = [0];\n for (let i = 1; i < inst.children.length; i++) {\n xs.push(xs[i - 1]! + inst.children[i - 1]!.spanR + H_GAP + inst.children[i]!.spanL);\n }\n const first = inst.children[0]!;\n const last = inst.children[inst.children.length - 1]!;\n const px = (xs[0]! + xs[xs.length - 1]!) / 2;\n inst.children.forEach((c, i) => (c.offset = xs[i]! - px));\n inst.spanL = Math.max(selfL, px - (xs[0]! - first.spanL));\n inst.spanR = Math.max(selfR, xs[xs.length - 1]! + last.spanR - px);\n };\n pack(root);\n\n // Absolute centers, top-down; the root's left extent sits at PADDING.\n root.cx = PADDING + root.spanL;\n const placeX = (inst: Inst): void => {\n for (const c of inst.children) {\n c.cx = inst.cx + c.offset;\n placeX(c);\n }\n };\n placeX(root);\n\n // ── Vertical: rows by depth (per drawn instance), top-aligned; each row reserves\n // a gate zone sized to its tallest gate assembly (incl. conditioning nodes). ───\n const rowInsts: Inst[][] = [];\n const visitRows = (inst: Inst): void => {\n (rowInsts[inst.depth] ??= []).push(inst);\n for (const c of inst.children) visitRows(c);\n };\n visitRows(root);\n const depthCount = rowInsts.length;\n\n /** Vertical extent of a gate assembly below the gate's top (glyph and/or oval+label). */\n const gateExtent = (inst: Inst): number => {\n const g = inst.gate!;\n if (g.type === \"xor\") return XOR_H;\n if (g.type === \"inhibit\") {\n // Oval vertically centered on the hexagon's side vertex (INHIBIT_CY); the\n // condition node's label may extend below the hexagon bottom.\n const condBottom = INHIBIT_CY - 16 + inst.cond!.m.nodeH;\n return Math.max(INHIBIT_H, condBottom);\n }\n return GATE_H;\n };\n const rowH: number[] = [];\n const gateZone: number[] = [];\n for (let d = 0; d < depthCount; d++) {\n const insts = rowInsts[d]!;\n rowH.push(insts.reduce((m, i) => Math.max(m, i.m.nodeH), 0));\n const gated = insts.filter((i) => i.gate !== null);\n gateZone.push(gated.length === 0 ? 0 : STEM + gated.reduce((m, i) => Math.max(m, gateExtent(i)), 0));\n }\n const rowTop: number[] = [PADDING];\n for (let d = 0; d < depthCount - 1; d++) {\n rowTop.push(rowTop[d]! + rowH[d]! + gateZone[d]! + CORRIDOR);\n }\n const busY = (d: number): number => rowTop[d + 1]! - CORRIDOR / 2;\n\n const width = Math.ceil(PADDING * 2 + root.spanL + root.spanR);\n const last = depthCount - 1;\n const height = Math.ceil(rowTop[last]! + rowH[last]! + gateZone[last]! + PADDING);\n\n // ── Instance finalization: only events drawn more than once carry an index. ──────\n const instanceOf = (inst: Inst): number | null =>\n (seqByEvent.get(inst.event.id) ?? 0) > 1 ? inst.seq : null;\n\n // ── Emit nodes / gates / elements in DFS order. ───────────────────────────────────\n const nodes: FaultTreeNode[] = [];\n const gates: FaultTreeGateNode[] = [];\n const elements: FaultTreeElement[] = [];\n\n const gateTitle = (g: FaultTreeGate): string =>\n g.type === \"vote\" ? `${titleLabels.gates.vote} ${g.k}/${g.inputIds.length}` : titleLabels.gates[g.type];\n\n const pushNode = (inst: Inst, top: number): void => {\n const isRect = inst.event.kind === \"intermediate\";\n const labelTop = !isRect && inst.m.labelLines.length > 0 ? top + inst.m.glyphH + LABEL_GAP : null;\n nodes.push({\n eventId: inst.event.id,\n kind: inst.event.kind,\n instance: instanceOf(inst),\n cx: round(inst.cx),\n top: round(top),\n nodeW: round(inst.m.nodeW),\n nodeH: round(inst.m.nodeH),\n glyphW: round(inst.m.glyphW),\n glyphH: round(inst.m.glyphH),\n labelLines: inst.m.labelLines,\n labelTop: labelTop === null ? null : round(labelTop),\n code: inst.m.code,\n depth: inst.depth,\n title: inst.title,\n });\n };\n\n const emit = (inst: Inst): void => {\n const d = inst.depth;\n pushNode(inst, rowTop[d]!);\n const g = inst.gate;\n if (g === null) return;\n\n const gateTop = rowTop[d]! + rowH[d]! + STEM;\n const glyphW = g.type === \"inhibit\" ? INHIBIT_W : GATE_W;\n const glyphH = g.type === \"xor\" ? XOR_H : g.type === \"inhibit\" ? INHIBIT_H : GATE_H;\n const title = gateTitle(g);\n gates.push({\n gateId: g.id,\n type: g.type,\n cx: round(inst.cx),\n top: round(gateTop),\n glyphW,\n glyphH,\n title,\n voteText: g.type === \"vote\" ? `${g.k}/${g.inputIds.length}` : null,\n });\n\n // Conditioning node: oval centered on the hexagon's side vertex, the whole node\n // box starting COND_GAP right of the vertex so the label can never reach the gate.\n if (inst.cond !== null) {\n const cond = inst.cond;\n const nodeLeft = inst.cx + INHIBIT_W / 2 + COND_GAP;\n cond.cx = nodeLeft + cond.m.nodeW / 2;\n const condTop = gateTop + INHIBIT_CY - 16;\n pushNode(cond, condTop);\n const ovalLeft = cond.cx - cond.m.glyphW / 2;\n elements.push({\n edgeId: FT_CONDITION_ID_BASE + g.id,\n kind: \"condition\",\n points: [\n { x: round(inst.cx + INHIBIT_W / 2), y: round(gateTop + INHIBIT_CY) },\n { x: round(ovalLeft), y: round(gateTop + INHIBIT_CY) },\n ],\n instance: null,\n title: titleLabels.condition,\n });\n }\n\n // Output stem: event bottom → gate top (longer than STEM when the event is\n // shorter than its row — rows are top-aligned).\n elements.push({\n edgeId: FT_STEM_ID_BASE + g.id,\n kind: \"stem\",\n points: [\n { x: round(inst.cx), y: round(rowTop[d]! + inst.m.nodeH) },\n { x: round(inst.cx), y: round(gateTop) },\n ],\n instance: null,\n title,\n });\n // Gate drop: gate connector bottom → bus.\n const by = busY(d);\n elements.push({\n edgeId: FT_DROP_ID_BASE + g.id,\n kind: \"drop\",\n points: [\n { x: round(inst.cx), y: round(gateTop + glyphH) },\n { x: round(inst.cx), y: round(by) },\n ],\n instance: null,\n title,\n });\n // Bus: spans min→max child centers; a single-input gate degenerates to the\n // straight drop + riser (no bus element).\n if (inst.children.length > 1) {\n const xs = inst.children.map((c) => c.cx);\n elements.push({\n edgeId: FT_BUS_ID_BASE + g.id,\n kind: \"bus\",\n points: [\n { x: round(Math.min(...xs)), y: round(by) },\n { x: round(Math.max(...xs)), y: round(by) },\n ],\n instance: null,\n title,\n });\n }\n // One riser per child: bus → child glyph top (the transfer triangle's apex IS\n // its glyph top). Risers into a repeated leaf carry that instance index, since\n // their edge id (FT_RISER_ID_BASE + child event id) repeats with the leaf.\n for (const c of inst.children) {\n elements.push({\n edgeId: FT_RISER_ID_BASE + c.event.id,\n kind: \"riser\",\n points: [\n { x: round(c.cx), y: round(by) },\n { x: round(c.cx), y: round(rowTop[d + 1]!) },\n ],\n instance: instanceOf(c),\n title,\n });\n }\n for (const c of inst.children) emit(c);\n };\n emit(root);\n\n return { width, height, nodes, gates, elements };\n}\n","// Fault-tree SVG emitter — turns a computed FaultTreeLayout (./layout.ts) into a\n// SELF-CONTAINED SVG string. Pure (layout in, string out) and deterministic; it draws\n// EXACTLY what the layout computed (the overlap harness proves the layout; this\n// emitter is pinned to it).\n//\n// Hard requirements (house rules):\n// - XML-ESCAPING of EVERY interpolated text — labels/codes/titles are\n// author-controlled and the SVG may be injected via innerHTML or embedded in PDFs;\n// - LITERAL presentation attributes only (hex colors, explicit font-family): a\n// standalone SVG has no stylesheet, no currentColor, no <defs>/<marker>;\n// - every coordinate goes through round() — 2-decimal, byte-deterministic output.\n//\n// Symbol fidelity (NUREG-0492 distinctive shapes): rectangle / circle / diamond /\n// house / oval / transfer-triangle events; AND dome, OR shield, XOR (OR + detached\n// second input curve — the ANSI/IEEE 91 distinctive shape; the legend entry\n// disambiguates), INHIBIT hexagon, VOTE (OR shield with \"k/n\" inside). Gates carry no\n// label text — the shape IS the semantics; the localized gate name rides the <title>.\n//\n// Hooks: `<g data-node-id=\"e<id>\">` per event instance and `<g data-node-id=\"g<id>\">`\n// per gate (direct-child verbatim <title>); `<g data-edge-id=\"<n>\">` per connector\n// element (namespaced ids, see ./layout.ts). Repeated-leaf instances (and their\n// risers) carry `data-instance=\"k\"` so every hook stays unambiguous.\n\nimport { FONT_FAMILY, legendBlock, xmlEscape, LEGEND_SWATCH_W, type LegendEntry } from \"../core\";\nimport { FT_LABEL_FONT, FT_LABEL_LINE_H, CODE_FONT, type FaultTreeElement, type FaultTreeGateNode, type FaultTreeLayout, type FaultTreeNode } from \"./layout\";\nimport { FAULT_TREE_SVG_LABELS_EN, type FaultTreeSvgLabels } from \"./labels\";\nimport { FAULT_TREE_EVENT_KINDS, GATE_TYPES, type FaultTreeEventKind, type GateType } from \"./types\";\n\n// Literal ink colors (zinc ramp on white — matches the genogram/ecomap emitters).\nconst GLYPH_STROKE = \"#52525b\";\nconst LABEL_FILL = \"#3f3f46\";\nconst EDGE_INK = \"#71717a\";\nconst GLYPH_ATTRS = `fill=\"transparent\" stroke=\"${GLYPH_STROKE}\" stroke-width=\"2\"`;\n\nconst round = (n: number): number => Math.round(n * 100) / 100;\n\nexport interface FaultTreeSvgOptions {\n /** Set false to suppress the legend (compact preview); default true. */\n legend?: boolean;\n /** Display vocabulary (legend/accessibility) — English default; see locale packs. */\n labels?: FaultTreeSvgLabels;\n}\n\n// ── Event glyphs ──────────────────────────────────────────────────────────────────\n\nfunction eventGlyph(n: FaultTreeNode): string {\n const cx = n.cx;\n const top = n.top;\n if (n.kind === \"intermediate\") {\n return `<rect x=\"${round(cx - n.nodeW / 2)}\" y=\"${top}\" width=\"${n.nodeW}\" height=\"${n.nodeH}\" rx=\"2\" ${GLYPH_ATTRS}/>`;\n }\n if (n.kind === \"basic\") {\n return `<circle cx=\"${cx}\" cy=\"${round(top + 22)}\" r=\"22\" ${GLYPH_ATTRS}/>`;\n }\n if (n.kind === \"undeveloped\") {\n const pts = `${cx},${top} ${round(cx + 24)},${round(top + 24)} ${cx},${round(top + 48)} ${round(cx - 24)},${round(top + 24)}`;\n return `<polygon points=\"${pts}\" ${GLYPH_ATTRS}/>`;\n }\n if (n.kind === \"house\") {\n const yB = round(top + 40);\n const eave = round(top + 16);\n const pts = `${round(cx - 22)},${yB} ${round(cx - 22)},${eave} ${cx},${top} ${round(cx + 22)},${eave} ${round(cx + 22)},${yB}`;\n return `<polygon points=\"${pts}\" ${GLYPH_ATTRS}/>`;\n }\n if (n.kind === \"conditioning\") {\n return `<ellipse cx=\"${cx}\" cy=\"${round(top + 16)}\" rx=\"${round(n.glyphW / 2)}\" ry=\"16\" ${GLYPH_ATTRS}/>`;\n }\n // transfer — triangle, line-to-apex (the riser ends exactly at the apex).\n const pts = `${cx},${top} ${round(cx + 22)},${round(top + 35)} ${round(cx - 22)},${round(top + 35)}`;\n return `<polygon points=\"${pts}\" ${GLYPH_ATTRS}/>`;\n}\n\nfunction nodeSvg(n: FaultTreeNode): string {\n const pieces: string[] = [`<title>${xmlEscape(n.title)}</title>`, eventGlyph(n)];\n if (n.code !== null && n.kind !== \"intermediate\") {\n pieces.push(\n `<text x=\"${n.cx}\" y=\"${round(n.top + n.glyphH / 2 + CODE_FONT * 0.32)}\" text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"${CODE_FONT}\" fill=\"${LABEL_FILL}\">${xmlEscape(n.code)}</text>`,\n );\n }\n if (n.labelLines.length > 0) {\n // Inside the rect (vertically centered block) or below the glyph (labelTop).\n const firstBaseline = n.labelTop === null ? round(n.top + 19) : round(n.labelTop + 10);\n const tspans = n.labelLines\n .map((line, i) => `<tspan x=\"${n.cx}\" y=\"${round(firstBaseline + i * FT_LABEL_LINE_H)}\">${xmlEscape(line)}</tspan>`)\n .join(\"\");\n pieces.push(\n `<text text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"${FT_LABEL_FONT}\" fill=\"${LABEL_FILL}\">${tspans}</text>`,\n );\n }\n const instance = n.instance === null ? \"\" : ` data-instance=\"${n.instance}\"`;\n return `<g data-node-id=\"e${n.eventId}\"${instance}>${pieces.join(\"\")}</g>`;\n}\n\n// ── Gate glyphs (distinctive shapes, drawn pointing up — output on top) ───────────\n\nfunction orBodyPath(cx: number, top: number, yB: number): string {\n return `M ${round(cx - 22)} ${yB} Q ${cx} ${round(yB - 14)} ${round(cx + 22)} ${yB} Q ${round(cx + 22)} ${round(top + 14)} ${cx} ${top} Q ${round(cx - 22)} ${round(top + 14)} ${round(cx - 22)} ${yB} Z`;\n}\n\nfunction gateGlyph(g: FaultTreeGateNode): string {\n const cx = g.cx;\n const top = g.top;\n const yB = round(top + 36);\n if (g.type === \"and\") {\n const d = `M ${round(cx - 22)} ${yB} L ${round(cx - 22)} ${round(yB - 14)} A 22 22 0 0 1 ${round(cx + 22)} ${round(yB - 14)} L ${round(cx + 22)} ${yB} Z`;\n return `<path d=\"${d}\" ${GLYPH_ATTRS}/>`;\n }\n if (g.type === \"or\") {\n return `<path d=\"${orBodyPath(cx, top, yB)}\" ${GLYPH_ATTRS}/>`;\n }\n if (g.type === \"xor\") {\n const arc = `M ${round(cx - 22)} ${round(yB + 5)} Q ${cx} ${round(yB - 9)} ${round(cx + 22)} ${round(yB + 5)}`;\n return `<path d=\"${orBodyPath(cx, top, yB)}\" ${GLYPH_ATTRS}/><path d=\"${arc}\" ${GLYPH_ATTRS}/>`;\n }\n if (g.type === \"inhibit\") {\n const pts = `${cx},${top} ${round(cx + 18)},${round(top + 12)} ${round(cx + 18)},${round(top + 34)} ${cx},${round(top + 46)} ${round(cx - 18)},${round(top + 34)} ${round(cx - 18)},${round(top + 12)}`;\n return `<polygon points=\"${pts}\" ${GLYPH_ATTRS}/>`;\n }\n // vote — the OR distinctive shape with the declared \"k/n\" written inside.\n return (\n `<path d=\"${orBodyPath(cx, top, yB)}\" ${GLYPH_ATTRS}/>` +\n `<text x=\"${cx}\" y=\"${round(yB - 10)}\" text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"9\" fill=\"${LABEL_FILL}\">${xmlEscape(g.voteText ?? \"\")}</text>`\n );\n}\n\nfunction gateSvg(g: FaultTreeGateNode): string {\n return `<g data-node-id=\"g${g.gateId}\"><title>${xmlEscape(g.title)}</title>${gateGlyph(g)}</g>`;\n}\n\n// ── Connector elements ─────────────────────────────────────────────────────────────\n\nfunction elementSvg(el: FaultTreeElement): string {\n const a = el.points[0]!;\n const b = el.points[1]!;\n const instance = el.instance === null ? \"\" : ` data-instance=\"${el.instance}\"`;\n return (\n `<g data-edge-id=\"${el.edgeId}\"${instance}><title>${xmlEscape(el.title)}</title>` +\n `<line x1=\"${a.x}\" y1=\"${a.y}\" x2=\"${b.x}\" y2=\"${b.y}\" stroke=\"${EDGE_INK}\" stroke-width=\"1.5\" stroke-opacity=\"0.75\"/></g>`\n );\n}\n\n// ── Legend mini-glyph swatches (scaled into the 22px swatch box) ──────────────────\n\nconst MINI_ATTRS = `fill=\"transparent\" stroke=\"${GLYPH_STROKE}\" stroke-width=\"1.5\"`;\n\nfunction miniEventSwatch(kind: FaultTreeEventKind, x: number, y: number): string {\n const cx = round(x + LEGEND_SWATCH_W / 2);\n if (kind === \"intermediate\") {\n return `<rect x=\"${round(cx - 7)}\" y=\"${round(y - 4.5)}\" width=\"14\" height=\"9\" rx=\"1\" ${MINI_ATTRS}/>`;\n }\n if (kind === \"basic\") return `<circle cx=\"${cx}\" cy=\"${y}\" r=\"6\" ${MINI_ATTRS}/>`;\n if (kind === \"undeveloped\") {\n return `<polygon points=\"${cx},${round(y - 7)} ${round(cx + 7)},${y} ${cx},${round(y + 7)} ${round(cx - 7)},${y}\" ${MINI_ATTRS}/>`;\n }\n if (kind === \"house\") {\n return `<polygon points=\"${round(cx - 6)},${round(y + 5.5)} ${round(cx - 6)},${round(y - 1)} ${cx},${round(y - 5.5)} ${round(cx + 6)},${round(y - 1)} ${round(cx + 6)},${round(y + 5.5)}\" ${MINI_ATTRS}/>`;\n }\n if (kind === \"conditioning\") return `<ellipse cx=\"${cx}\" cy=\"${y}\" rx=\"9\" ry=\"5.5\" ${MINI_ATTRS}/>`;\n return `<polygon points=\"${cx},${round(y - 5)} ${round(cx + 6)},${round(y + 5)} ${round(cx - 6)},${round(y + 5)}\" ${MINI_ATTRS}/>`;\n}\n\nfunction miniOrPath(cx: number, y: number): string {\n return `M ${round(cx - 7)} ${round(y + 5.5)} Q ${cx} ${round(y + 1)} ${round(cx + 7)} ${round(y + 5.5)} Q ${round(cx + 7)} ${round(y - 1.5)} ${cx} ${round(y - 5.5)} Q ${round(cx - 7)} ${round(y - 1.5)} ${round(cx - 7)} ${round(y + 5.5)} Z`;\n}\n\nfunction miniGateSwatch(type: GateType, x: number, y: number): string {\n const cx = round(x + LEGEND_SWATCH_W / 2);\n if (type === \"and\") {\n const d = `M ${round(cx - 7)} ${round(y + 5.5)} L ${round(cx - 7)} ${round(y + 1.5)} A 7 7 0 0 1 ${round(cx + 7)} ${round(y + 1.5)} L ${round(cx + 7)} ${round(y + 5.5)} Z`;\n return `<path d=\"${d}\" ${MINI_ATTRS}/>`;\n }\n if (type === \"xor\") {\n return `<path d=\"${miniOrPath(cx, y)}\" ${MINI_ATTRS}/><path d=\"M ${round(cx - 7)} ${round(y + 7.5)} Q ${cx} ${round(y + 3)} ${round(cx + 7)} ${round(y + 7.5)}\" ${MINI_ATTRS}/>`;\n }\n if (type === \"inhibit\") {\n return `<polygon points=\"${cx},${round(y - 5.5)} ${round(cx + 4.5)},${round(y - 2.5)} ${round(cx + 4.5)},${round(y + 2.5)} ${cx},${round(y + 5.5)} ${round(cx - 4.5)},${round(y + 2.5)} ${round(cx - 4.5)},${round(y - 2.5)}\" ${MINI_ATTRS}/>`;\n }\n // or / vote share the OR shield mini — the legend label disambiguates the vote.\n return `<path d=\"${miniOrPath(cx, y)}\" ${MINI_ATTRS}/>`;\n}\n\n/**\n * Emits a self-contained SVG for a computed fault-tree layout. Pure + deterministic.\n * Coordinates come straight from the layout; all interpolated text is XML-escaped;\n * all presentation attributes are literal. The legend lists ONLY the event kinds and\n * gate types actually present, in canonical declaration order.\n */\nexport function faultTreeLayoutSvg(layout: FaultTreeLayout, opts: FaultTreeSvgOptions = {}): string {\n const labels = opts.labels ?? FAULT_TREE_SVG_LABELS_EN;\n const parts: string[] = [];\n\n // Connectors first, then gates, then event nodes — nodes sit on top.\n for (const el of layout.elements) parts.push(elementSvg(el));\n for (const g of layout.gates) parts.push(gateSvg(g));\n for (const n of layout.nodes) parts.push(nodeSvg(n));\n\n // ── Used-keys-only legend (core legendBlock; `legend:false` suppresses). ─────────\n let width = layout.width;\n let height = layout.height;\n if (opts.legend !== false && layout.nodes.length > 0) {\n const kindsUsed = new Set(layout.nodes.map((n) => n.kind));\n const typesUsed = new Set(layout.gates.map((g) => g.type));\n const entries: LegendEntry[] = [];\n for (const kind of FAULT_TREE_EVENT_KINDS) {\n if (!kindsUsed.has(kind)) continue;\n entries.push({ swatch: (x, y) => miniEventSwatch(kind, x, y), label: labels.events[kind] });\n }\n for (const type of GATE_TYPES) {\n if (!typesUsed.has(type)) continue;\n entries.push({ swatch: (x, y) => miniGateSwatch(type, x, y), label: labels.gates[type] });\n }\n const block = legendBlock(entries, layout.height);\n if (block.svg !== \"\") {\n parts.push(block.svg);\n width = Math.max(width, block.width);\n height = block.height;\n }\n }\n\n const w = Math.ceil(width);\n const h = Math.ceil(height);\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${w} ${h}\" width=\"${w}\" height=\"${h}\" role=\"img\" aria-label=\"${xmlEscape(labels.ariaLabel)}\">` +\n parts.join(\"\") +\n `</svg>`\n );\n}\n","// One-call fault-tree render: input → { svg, layout }. Thin, honest wiring: validate\n// (throw on a structurally invalid tree — never repair), compute the pure layout,\n// emit. Callers needing finer control use computeFaultTreeLayout + faultTreeLayoutSvg\n// directly (the layout result supports hit-testing / decorating the diagram).\n\nimport { computeFaultTreeLayout, type FaultTreeLayout, type FaultTreeLayoutOptions } from \"./layout\";\nimport { faultTreeLayoutSvg } from \"./svg\";\nimport type { FaultTreeSvgLabels } from \"./labels\";\nimport type { FaultTreeInput } from \"./types\";\n\nexport interface FaultTreeRenderOptions extends FaultTreeLayoutOptions {\n /** Set false to suppress the legend (compact preview); default true. */\n legend?: boolean;\n /** Display vocabulary for the emitter (legend/accessibility) — English default. */\n svgLabels?: FaultTreeSvgLabels;\n}\n\nexport interface FaultTreeRenderResult {\n /** Self-contained SVG (numeric width/height + matching viewBox — PDF-embedder safe). */\n svg: string;\n /** The computed layout, for callers that decorate or hit-test the diagram. */\n layout: FaultTreeLayout;\n}\n\n/**\n * Renders a fault-tree input to a self-contained SVG string. Deterministic: same\n * data → same SVG (array order never matters; a gate's `inputIds` order is honored\n * as the declared left-to-right reading order). Throws FaultTreeValidationError —\n * carrying EVERY issue, deterministically sorted — on a structurally invalid tree.\n * Empty input yields an empty-but-valid SVG; callers decide their own empty state.\n */\nexport function faultTreeSvg(input: FaultTreeInput, opts: FaultTreeRenderOptions = {}): FaultTreeRenderResult {\n const layout = computeFaultTreeLayout(input, {\n ...(opts.maxLabelChars !== undefined ? { maxLabelChars: opts.maxLabelChars } : {}),\n ...(opts.titleLabels !== undefined ? { titleLabels: opts.titleLabels } : {}),\n });\n const svg = faultTreeLayoutSvg(layout, {\n ...(opts.legend === false ? { legend: false } : {}),\n ...(opts.svgLabels !== undefined ? { labels: opts.svgLabels } : {}),\n });\n return { svg, layout };\n}\n"]}
|
|
@@ -3,6 +3,35 @@ function xmlEscape(text) {
|
|
|
3
3
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
// src/core/roman.ts
|
|
7
|
+
var ROMAN_TABLE = [
|
|
8
|
+
[1e3, "M"],
|
|
9
|
+
[900, "CM"],
|
|
10
|
+
[500, "D"],
|
|
11
|
+
[400, "CD"],
|
|
12
|
+
[100, "C"],
|
|
13
|
+
[90, "XC"],
|
|
14
|
+
[50, "L"],
|
|
15
|
+
[40, "XL"],
|
|
16
|
+
[10, "X"],
|
|
17
|
+
[9, "IX"],
|
|
18
|
+
[5, "V"],
|
|
19
|
+
[4, "IV"],
|
|
20
|
+
[1, "I"]
|
|
21
|
+
];
|
|
22
|
+
function romanNumeral(n) {
|
|
23
|
+
if (!Number.isInteger(n) || n < 1 || n > 3999) return String(n);
|
|
24
|
+
let remaining = n;
|
|
25
|
+
let out = "";
|
|
26
|
+
for (const [value, symbol] of ROMAN_TABLE) {
|
|
27
|
+
while (remaining >= value) {
|
|
28
|
+
out += symbol;
|
|
29
|
+
remaining -= value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
6
35
|
// src/core/geometry.ts
|
|
7
36
|
function pathData(points) {
|
|
8
37
|
return points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
|
|
@@ -13,19 +42,27 @@ var CHAR_W = 0.6;
|
|
|
13
42
|
function estimateTextWidth(text, fontPx) {
|
|
14
43
|
return text.length * fontPx * CHAR_W;
|
|
15
44
|
}
|
|
16
|
-
function wrapLabel(label, perLine) {
|
|
45
|
+
function wrapLabel(label, perLine, maxLines = 2) {
|
|
17
46
|
if (label.length <= perLine) return [label];
|
|
18
47
|
const cap = (s) => s.length > perLine ? s.slice(0, Math.max(1, perLine - 1)) + "\u2026" : s;
|
|
19
|
-
|
|
20
|
-
let line2 = "";
|
|
48
|
+
const lines = [""];
|
|
21
49
|
for (const word of label.split(/\s+/)) {
|
|
22
|
-
|
|
23
|
-
|
|
50
|
+
const last = lines.length - 1;
|
|
51
|
+
const current = lines[last];
|
|
52
|
+
if (current === "" || (current + " " + word).length <= perLine) {
|
|
53
|
+
lines[last] = current === "" ? word : `${current} ${word}`;
|
|
54
|
+
} else if (lines.length < maxLines) {
|
|
55
|
+
lines.push(word);
|
|
24
56
|
} else {
|
|
25
|
-
|
|
57
|
+
lines[last] = `${current} ${word}`;
|
|
26
58
|
}
|
|
27
59
|
}
|
|
28
|
-
|
|
60
|
+
if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
|
|
61
|
+
return lines.map(cap);
|
|
62
|
+
}
|
|
63
|
+
function wrapLabelBalanced(label, maxLines) {
|
|
64
|
+
const perLine = Math.min(26, Math.max(14, Math.ceil(label.length / 2) + 2));
|
|
65
|
+
return wrapLabel(label, perLine, maxLines);
|
|
29
66
|
}
|
|
30
67
|
function clampLabel(label, maxChars) {
|
|
31
68
|
if (maxChars === void 0 || label.length <= maxChars) return label;
|
|
@@ -33,6 +70,28 @@ function clampLabel(label, maxChars) {
|
|
|
33
70
|
}
|
|
34
71
|
var FONT_FAMILY = "Helvetica, Arial, sans-serif";
|
|
35
72
|
|
|
73
|
+
// src/core/legend.ts
|
|
74
|
+
var LEGEND_ROW_H = 18;
|
|
75
|
+
var LEGEND_PAD = 16;
|
|
76
|
+
var LEGEND_SWATCH_W = 22;
|
|
77
|
+
var LEGEND_GAP = 14;
|
|
78
|
+
var LEGEND_FONT = 11;
|
|
79
|
+
var LEGEND_TEXT_FILL = "#52525b";
|
|
80
|
+
function legendBlock(entries, startY) {
|
|
81
|
+
if (entries.length === 0) return { svg: "", width: 0, height: startY };
|
|
82
|
+
const rows = entries.map((entry, i) => {
|
|
83
|
+
const rowCenterY = startY + i * LEGEND_ROW_H + LEGEND_ROW_H / 2;
|
|
84
|
+
const textX = LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP;
|
|
85
|
+
return entry.swatch(LEGEND_PAD, rowCenterY) + `<text x="${textX}" y="${rowCenterY + LEGEND_FONT * 0.32}" font-family="${FONT_FAMILY}" font-size="${LEGEND_FONT}" fill="${LEGEND_TEXT_FILL}">${xmlEscape(entry.label)}</text>`;
|
|
86
|
+
});
|
|
87
|
+
const widestLabel = entries.reduce((m, e) => Math.max(m, estimateTextWidth(e.label, LEGEND_FONT)), 0);
|
|
88
|
+
return {
|
|
89
|
+
svg: `<g data-compasso-legend="true">${rows.join("")}</g>`,
|
|
90
|
+
width: LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP + widestLabel + LEGEND_PAD,
|
|
91
|
+
height: startY + entries.length * LEGEND_ROW_H + LEGEND_PAD / 2
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
36
95
|
// src/core/stroke.ts
|
|
37
96
|
var EDGE_STROKE = {
|
|
38
97
|
plain: { width: 1.5, dash: null, opacity: 0.6 },
|
|
@@ -81,6 +140,6 @@ function qualityLineStyle(quality, lexicon = QUALITY_LEXICON_EN) {
|
|
|
81
140
|
return matched.length === 1 ? matched[0] : "plain";
|
|
82
141
|
}
|
|
83
142
|
|
|
84
|
-
export { CHAR_W, EDGE_STROKE, FONT_FAMILY, QUALITY_LEXICON_EN, clampLabel, estimateTextWidth, normalizeText, pathData, qualityLineStyle, wrapLabel, xmlEscape };
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
export { CHAR_W, EDGE_STROKE, FONT_FAMILY, LEGEND_FONT, LEGEND_GAP, LEGEND_PAD, LEGEND_ROW_H, LEGEND_SWATCH_W, QUALITY_LEXICON_EN, clampLabel, estimateTextWidth, legendBlock, normalizeText, pathData, qualityLineStyle, romanNumeral, wrapLabel, wrapLabelBalanced, xmlEscape };
|
|
144
|
+
//# sourceMappingURL=chunk-O3BT2O42.js.map
|
|
145
|
+
//# sourceMappingURL=chunk-O3BT2O42.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/xml.ts","../src/core/roman.ts","../src/core/geometry.ts","../src/core/text.ts","../src/core/legend.ts","../src/core/stroke.ts"],"names":[],"mappings":";AAMO,SAAS,UAAU,IAAA,EAAsB;AAC9C,EAAA,OAAO,KACJ,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA,CACrB,OAAA,CAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,IAAA,EAAM,MAAM,EACpB,OAAA,CAAQ,IAAA,EAAM,QAAQ,CAAA,CACtB,OAAA,CAAQ,MAAM,QAAQ,CAAA;AAC3B;;;ACPA,IAAM,WAAA,GAAwD;AAAA,EAC5D,CAAC,KAAM,GAAG,CAAA;AAAA,EACV,CAAC,KAAK,IAAI,CAAA;AAAA,EACV,CAAC,KAAK,GAAG,CAAA;AAAA,EACT,CAAC,KAAK,IAAI,CAAA;AAAA,EACV,CAAC,KAAK,GAAG,CAAA;AAAA,EACT,CAAC,IAAI,IAAI,CAAA;AAAA,EACT,CAAC,IAAI,GAAG,CAAA;AAAA,EACR,CAAC,IAAI,IAAI,CAAA;AAAA,EACT,CAAC,IAAI,GAAG,CAAA;AA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F,IAAA,IAAI,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA,EAAG,OAAO,OAAA;AAAA,EACtC;AAEA,EAAA,MAAM,UAA2B,EAAC;AAClC,EAAA,KAAA,MAAW,EAAE,KAAA,EAAO,OAAA,EAAQ,IAAK,QAAQ,OAAA,EAAS;AAChD,IAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,QAAA,CAAS,QAAA,CAAS,CAAC,CAAC,CAAA,EAAG,OAAA,CAAQ,IAAA,CAAK,KAAK,CAAA;AAAA,EACnE;AACA,EAAA,OAAO,OAAA,CAAQ,MAAA,KAAW,CAAA,GAAI,OAAA,CAAQ,CAAC,CAAA,GAAK,OAAA;AAC9C","file":"chunk-O3BT2O42.js","sourcesContent":["// XML/SVG escaping — every interpolated text in an emitted SVG MUST pass through\n// this. Diagram labels are typically user/author-controlled, and the SVG string may\n// be injected via innerHTML in a browser or embedded as vectors in a PDF — an\n// unescaped label is an XSS / `</svg>`-breakout vector on every surface at once.\n\n/** Escapes a string for use in SVG/XML text content AND attribute values. */\nexport function xmlEscape(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n","// Roman numeral formatting for level/generation labels (pedigree generation rows\n// I, II, III…; any leveled diagram). Standard subtractive notation, valid for\n// integers 1..3999. A renderer must NEVER crash on a weird generation index, so\n// out-of-range / non-integer inputs fall back to the Arabic number as a string\n// rather than throwing or emitting nonsense like \"MMMM…\". Pure + deterministic.\n\nconst ROMAN_TABLE: ReadonlyArray<readonly [number, string]> = [\n [1000, \"M\"],\n [900, \"CM\"],\n [500, \"D\"],\n [400, \"CD\"],\n [100, \"C\"],\n [90, \"XC\"],\n [50, \"L\"],\n [40, \"XL\"],\n [10, \"X\"],\n [9, \"IX\"],\n [5, \"V\"],\n [4, \"IV\"],\n [1, \"I\"],\n];\n\n/** Uppercase Roman numeral for an integer in 1..3999 (1→\"I\", 4→\"IV\", 1990→\"MCMXC\").\n * Out of range or non-integer → the Arabic number as a string (graceful fallback). */\nexport function romanNumeral(n: number): string {\n if (!Number.isInteger(n) || n < 1 || n > 3999) return String(n);\n let remaining = n;\n let out = \"\";\n for (const [value, symbol] of ROMAN_TABLE) {\n while (remaining >= value) {\n out += symbol;\n remaining -= value;\n }\n }\n return out;\n}\n","// Shared geometry primitives.\n\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** \"M x y L x y …\" path data from a polyline. */\nexport function pathData(points: Point[]): string {\n return points.map((p, i) => `${i === 0 ? \"M\" : \"L\"} ${p.x} ${p.y}`).join(\" \");\n}\n","// Pure, deterministic text metrics — no DOM, no canvas, no font files. Every layout\n// in this library reserves space from these estimates and every emitter draws with\n// the same constants, so what is proven collision-free is what is drawn.\n\n/**\n * Conservative per-character advance, as a fraction of the font size. The pure module\n * can't measure real glyphs (no DOM/canvas), so it estimates width = chars * font *\n * CHAR_W. It is deliberately a touch WIDER than Helvetica's ~0.5 average advance: a\n * layout reserves slightly more room than the text needs, so the real render always\n * fits inside its reserved box.\n */\nexport const CHAR_W = 0.6;\n\n/** Pure, deterministic width estimate for a single line of text at `fontPx`. */\nexport function estimateTextWidth(text: string, fontPx: number): number {\n return text.length * fontPx * CHAR_W;\n}\n\n/**\n * Wraps a label onto up to `maxLines` lines (default 2) so long labels don't sprawl.\n * Greedy word fill; each line capped at `perLine` chars (…-truncated only if a line\n * still overflows). The LAST allowed line absorbs every remaining word before the cap\n * applies — words are never dropped mid-label, only visibly elided. Pure + shared so\n * every renderer wraps identically. The full text is always kept elsewhere (the\n * node's `label`, an SVG <title>, or a side list), so nothing is silently lost.\n *\n * INVARIANT: with the default `maxLines` the output is byte-identical to the\n * historical two-line implementation (pinned by test/core/text.test.ts) — both\n * shipped renderers wrap through here.\n */\nexport function wrapLabel(label: string, perLine: number, maxLines = 2): string[] {\n if (label.length <= perLine) return [label];\n const cap = (s: string): string =>\n s.length > perLine ? s.slice(0, Math.max(1, perLine - 1)) + \"…\" : s;\n const lines: string[] = [\"\"];\n for (const word of label.split(/\\s+/)) {\n const last = lines.length - 1;\n const current = lines[last]!;\n if (current === \"\" || (current + \" \" + word).length <= perLine) {\n lines[last] = current === \"\" ? word : `${current} ${word}`;\n } else if (lines.length < maxLines) {\n lines.push(word);\n } else {\n lines[last] = `${current} ${word}`;\n }\n }\n // A trailing-whitespace \"word\" (\"a b \".split(/\\s+/) → [\"a\",\"b\",\"\"]) may open a line\n // it never fills; the historical code dropped that empty line, so this does too.\n if (lines.length > 1 && lines[lines.length - 1] === \"\") lines.pop();\n return lines.map(cap);\n}\n\n/**\n * House \"balanced\" wrap policy (extracted verbatim from the ecomap's tie-label wrap,\n * itself mirroring the genogram's): per-line budget `min(26, max(14, ceil(len/2)+2))`\n * splits a medium label into two roughly even lines instead of one long + one short,\n * then the greedy `wrapLabel` fill (and its `maxLines` semantics) applies. The shipped\n * renderers keep their local copies for now — new modules consume this one; migrating\n * them is a separate provably-zero-change refactor.\n */\nexport function wrapLabelBalanced(label: string, maxLines?: number): string[] {\n const perLine = Math.min(26, Math.max(14, Math.ceil(label.length / 2) + 2));\n return wrapLabel(label, perLine, maxLines);\n}\n\n/** Caps a verbatim label for a COMPACT render (preview); full text kept by the caller. */\nexport function clampLabel(label: string, maxChars: number | undefined): string {\n if (maxChars === undefined || label.length <= maxChars) return label;\n return label.slice(0, Math.max(1, maxChars - 1)) + \"…\";\n}\n\n/** Font stack shared by every emitter; PDF embedders typically map it onto Helvetica. */\nexport const FONT_FAMILY = \"Helvetica, Arial, sans-serif\";\n","// Shared legend machinery — the exact row format the genogram and ecomap emitters\n// currently duplicate character-for-character (`<g data-compasso-legend=\"true\">` with\n// swatch-closure rows). Extracted so new diagram modules don't add a third copy;\n// the two shipped emitters keep their local blocks for now (migrating them is a\n// separate, provably-zero-change refactor — pinned byte-for-byte against the ecomap's\n// emitted legend in test/core/legend.test.ts).\n//\n// The caller stays in charge of the HONESTY RULE half: it decides WHICH entries exist\n// (used-keys-only) and what each swatch draws; this module only owns the row geometry,\n// the text emission (xmlEscape — labels may come from caller-supplied packs), and the\n// width/height bookkeeping both renderers compute identically.\n\nimport { FONT_FAMILY, estimateTextWidth } from \"./text\";\nimport { xmlEscape } from \"./xml\";\n\n// Row metrics shared by every legend in the library. Exported because swatch builders\n// need them (a line swatch spans LEGEND_SWATCH_W; a glyph swatch centers on it).\nexport const LEGEND_ROW_H = 18;\nexport const LEGEND_PAD = 16;\nexport const LEGEND_SWATCH_W = 22;\nexport const LEGEND_GAP = 14;\nexport const LEGEND_FONT = 11;\n\n// Legend text ink — the zinc glyph stroke both shipped emitters use for legend labels.\nconst LEGEND_TEXT_FILL = \"#52525b\";\n\nexport interface LegendEntry {\n /**\n * Swatch markup builder, called with the swatch's left x and the row's center y.\n * The builder owns its own escaping/rounding (it typically reuses the module's\n * glyph/line emitters); it should draw within LEGEND_SWATCH_W of x.\n */\n swatch: (x: number, yCenter: number) => string;\n /** Display label (escaped here; verbatim pack text in, escaped SVG out). */\n label: string;\n}\n\nexport interface LegendBlock {\n /** `<g data-compasso-legend=\"true\">…</g>` — empty string when there are no entries. */\n svg: string;\n /** Minimum canvas width the legend needs; callers take `max(width, block.width)`. */\n width: number;\n /** New total canvas height including the legend; callers assign it directly. */\n height: number;\n}\n\n/**\n * Emits the legend group for the given entries below `startY` (the diagram's current\n * height). Pure + deterministic; coordinates are interpolated exactly as the shipped\n * emitters do. Zero entries (used-keys-only found nothing) → no markup, zero width\n * contribution, height unchanged — safe to call unconditionally.\n */\nexport function legendBlock(entries: readonly LegendEntry[], startY: number): LegendBlock {\n if (entries.length === 0) return { svg: \"\", width: 0, height: startY };\n const rows = entries.map((entry, i) => {\n const rowCenterY = startY + i * LEGEND_ROW_H + LEGEND_ROW_H / 2;\n const textX = LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP;\n return (\n entry.swatch(LEGEND_PAD, rowCenterY) +\n `<text x=\"${textX}\" y=\"${rowCenterY + LEGEND_FONT * 0.32}\" font-family=\"${FONT_FAMILY}\" font-size=\"${LEGEND_FONT}\" fill=\"${LEGEND_TEXT_FILL}\">${xmlEscape(entry.label)}</text>`\n );\n });\n const widestLabel = entries.reduce((m, e) => Math.max(m, estimateTextWidth(e.label, LEGEND_FONT)), 0);\n return {\n svg: `<g data-compasso-legend=\"true\">${rows.join(\"\")}</g>`,\n width: LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP + widestLabel + LEGEND_PAD,\n height: startY + entries.length * LEGEND_ROW_H + LEGEND_PAD / 2,\n };\n}\n","// Edge line styles — a neutral, presentation-only style for a relationship line.\n// NOT a judgment: a deterministic, lexical hint derived from the author's own quality\n// word. The literal word always rides the element's <title>, so a style never replaces\n// what was said. Unknown/ambiguous quality → \"plain\".\n\nexport type EdgeLineStyle = \"plain\" | \"close\" | \"distant\" | \"conflict\" | \"cutoff\";\n\n/** Stroke attributes per style — shared by every renderer so SVG and PDF match. */\nexport interface EdgeStroke {\n width: number;\n /** SVG dash array / PDF dash pattern as [dash, gap]; null = solid. */\n dash: [number, number] | null;\n opacity: number;\n}\n\nexport const EDGE_STROKE: Record<EdgeLineStyle, EdgeStroke> = {\n plain: { width: 1.5, dash: null, opacity: 0.6 },\n close: { width: 3, dash: null, opacity: 0.85 },\n distant: { width: 1.5, dash: [4, 4], opacity: 0.55 },\n conflict: { width: 2, dash: [2, 2], opacity: 0.75 },\n cutoff: { width: 1.5, dash: [6, 5], opacity: 0.4 },\n};\n\n/**\n * A pluggable lexicon mapping free-text quality words onto line styles. Needles are\n * diacritic-free, lowercase substrings of the author's own words; `negations` are\n * whole words that flip the meaning of the very word a needle would match (\"not\n * close\"), so their presence makes the matcher abstain to \"plain\" rather than risk\n * an inverted visual. Locale packs (e.g. `compasso/locales/pt-br`) ship alternates.\n */\nexport interface QualityLexicon {\n buckets: readonly { style: Exclude<EdgeLineStyle, \"plain\">; needles: readonly string[] }[];\n negations: readonly string[];\n}\n\n// English default. Conservative stems: each needle is a substring match on the\n// normalized text, and the SINGLE-BUCKET rule below keeps competing signals honest.\n// \"no\" alone is deliberately NOT a negation: \"no contact\" is a genuine cutoff signal.\nexport const QUALITY_LEXICON_EN: QualityLexicon = {\n buckets: [\n {\n style: \"close\",\n needles: [\"close\", \"warm\", \"support\", \"lov\", \"affection\", \"caring\", \"tight\", \"harmon\", \"healthy\"],\n },\n {\n style: \"distant\",\n needles: [\"distant\", \"detach\", \"absent\", \"cold\", \"drift\"],\n },\n {\n style: \"conflict\",\n needles: [\"conflict\", \"fight\", \"tens\", \"difficult\", \"hostil\", \"violen\", \"abus\", \"aggress\", \"complicat\", \"toxic\", \"argu\"],\n },\n {\n style: \"cutoff\",\n needles: [\"estrang\", \"cut off\", \"cutoff\", \"no contact\", \"broken off\", \"sever\"],\n },\n ],\n negations: [\"not\", \"never\", \"no longer\", \"hardly\"],\n};\n\n/** Lowercase + strip diacritics so matching ignores accents. */\nexport function normalizeText(text: string): string {\n return text.normalize(\"NFD\").replace(/[̀-ͯ]/g, \"\").toLowerCase();\n}\n\nconst escapeRegExp = (s: string): string => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/**\n * Maps a free-text relationship quality to a neutral line style. Deterministic and\n * conservative: returns a specific style ONLY when exactly one lexical bucket matches;\n * null/empty/ambiguous/negated/unknown all fall back to \"plain\". The caller still\n * keeps the verbatim quality word, so nothing the author said is ever lost.\n */\nexport function qualityLineStyle(\n quality: string | null,\n lexicon: QualityLexicon = QUALITY_LEXICON_EN,\n): EdgeLineStyle {\n if (quality === null) return \"plain\";\n const haystack = normalizeText(quality);\n if (haystack.trim() === \"\") return \"plain\";\n\n if (lexicon.negations.length > 0) {\n const negation = new RegExp(`\\\\b(${lexicon.negations.map(escapeRegExp).join(\"|\")})\\\\b`);\n if (negation.test(haystack)) return \"plain\";\n }\n\n const matched: EdgeLineStyle[] = [];\n for (const { style, needles } of lexicon.buckets) {\n if (needles.some((n) => haystack.includes(n))) matched.push(style);\n }\n return matched.length === 1 ? matched[0]! : \"plain\";\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clampLabel, estimateTextWidth, qualityLineStyle, EDGE_STROKE, xmlEscape, FONT_FAMILY,
|
|
1
|
+
import { wrapLabelBalanced, clampLabel, estimateTextWidth, qualityLineStyle, EDGE_STROKE, xmlEscape, FONT_FAMILY, LEGEND_SWATCH_W, legendBlock } from './chunk-O3BT2O42.js';
|
|
2
2
|
|
|
3
3
|
// src/ecomap/render.ts
|
|
4
4
|
var ECOMAP_LABELS_EN = {
|
|
@@ -25,16 +25,7 @@ var SINGLE_RING_MAX = 8;
|
|
|
25
25
|
var NODE_STROKE = "#52525b";
|
|
26
26
|
var LABEL_FILL = "#3f3f46";
|
|
27
27
|
var EDGE_INK = "#71717a";
|
|
28
|
-
var LEGEND_ROW_H = 18;
|
|
29
|
-
var LEGEND_PAD = 16;
|
|
30
|
-
var LEGEND_SWATCH_W = 22;
|
|
31
|
-
var LEGEND_GAP = 14;
|
|
32
|
-
var LEGEND_FONT = 11;
|
|
33
28
|
var round = (n) => Math.round(n * 100) / 100;
|
|
34
|
-
function wrapTieLabel(displayLabel) {
|
|
35
|
-
const perLine = Math.min(26, Math.max(14, Math.ceil(displayLabel.length / 2) + 2));
|
|
36
|
-
return wrapLabel(displayLabel, perLine);
|
|
37
|
-
}
|
|
38
29
|
function arrowHead(tipX, tipY, ux, uy, opacity) {
|
|
39
30
|
const LEN = 9;
|
|
40
31
|
const HALF_W = 4.5;
|
|
@@ -53,7 +44,7 @@ function ecomapSvg(input, opts = {}) {
|
|
|
53
44
|
const fontSize = opts.fontSize ?? 12;
|
|
54
45
|
const labels = opts.labels ?? ECOMAP_LABELS_EN;
|
|
55
46
|
const sats = [...input.ties].sort((a, b) => a.id - b.id).map((tie) => {
|
|
56
|
-
const lines =
|
|
47
|
+
const lines = wrapLabelBalanced(clampLabel(tie.label, opts.maxLabelChars));
|
|
57
48
|
const w2 = Math.max(...lines.map((l) => estimateTextWidth(l, fontSize))) + NODE_PAD_X * 2;
|
|
58
49
|
const h2 = lines.length * LINE_H + NODE_PAD_Y * 2;
|
|
59
50
|
return {
|
|
@@ -67,7 +58,7 @@ function ecomapSvg(input, opts = {}) {
|
|
|
67
58
|
style: qualityLineStyle(tie.quality, opts.qualityLexicon)
|
|
68
59
|
};
|
|
69
60
|
});
|
|
70
|
-
const centerLines =
|
|
61
|
+
const centerLines = wrapLabelBalanced(input.centerLabel);
|
|
71
62
|
const centerR = Math.max(
|
|
72
63
|
CENTER_MIN_R,
|
|
73
64
|
Math.max(...centerLines.map((l) => estimateTextWidth(l, fontSize))) / 2 + 12,
|
|
@@ -186,16 +177,10 @@ function ecomapSvg(input, opts = {}) {
|
|
|
186
177
|
});
|
|
187
178
|
}
|
|
188
179
|
if (entries.length > 0) {
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return entry.swatch(LEGEND_PAD, rowCenterY) + `<text x="${textX}" y="${rowCenterY + LEGEND_FONT * 0.32}" font-family="${FONT_FAMILY}" font-size="${LEGEND_FONT}" fill="${NODE_STROKE}">${xmlEscape(entry.label)}</text>`;
|
|
194
|
-
});
|
|
195
|
-
parts.push(`<g data-compasso-legend="true">${rows.join("")}</g>`);
|
|
196
|
-
const widestLabel = entries.reduce((m, e) => Math.max(m, estimateTextWidth(e.label, LEGEND_FONT)), 0);
|
|
197
|
-
width = Math.max(width, LEGEND_PAD + LEGEND_SWATCH_W + LEGEND_GAP + widestLabel + LEGEND_PAD);
|
|
198
|
-
height = startY + entries.length * LEGEND_ROW_H + LEGEND_PAD / 2;
|
|
180
|
+
const block = legendBlock(entries, height);
|
|
181
|
+
parts.push(block.svg);
|
|
182
|
+
width = Math.max(width, block.width);
|
|
183
|
+
height = block.height;
|
|
199
184
|
}
|
|
200
185
|
}
|
|
201
186
|
const w = Math.ceil(width);
|
|
@@ -204,5 +189,5 @@ function ecomapSvg(input, opts = {}) {
|
|
|
204
189
|
}
|
|
205
190
|
|
|
206
191
|
export { ECOMAP_LABELS_EN, ecomapSvg };
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-Q6DVTCXD.js.map
|
|
193
|
+
//# sourceMappingURL=chunk-Q6DVTCXD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ecomap/render.ts"],"names":["w","h"],"mappings":";;;AAuEO,IAAM,gBAAA,GAAiC;AAAA,EAC5C,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,OAAA;AAAA,IACP,OAAA,EAAS,SAAA;AAAA,IACT,QAAA,EAAU,aAAA;AAAA,IACV,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,UAAA,EAAY,cAAA;AAAA,EACZ,SAAA,EAAW,+BAAA;AAAA,EACX,SAAA,EAAW;AACb;AAiBA,IAAM,OAAA,GAAU,EAAA;AAChB,IAAM,MAAA,GAAS,EAAA;AACf,IAAM,UAAA,GAAa,EAAA;AACnB,IAAM,UAAA,GAAa,CAAA;AACnB,IAAM,YAAA,GAAe,EAAA;AACrB,IAAM,UAAA,GAAa,GAAA;AAEnB,IAAM,QAAA,GAAW,EAAA;AAEjB,IAAM,UAAA,GAAa,EAAA;AAEnB,IAAM,QAAA,GAAW,EAAA;AAEjB,IAAM,eAAA,GAAkB,CAAA;AAGxB,IAAM,WAAA,GAAc,SAAA;AACpB,IAAM,UAAA,GAAa,SAAA;AACnB,IAAM,QAAA,GAAW,SAAA;AAIjB,IAAM,QAAQ,CAAC,CAAA,KAAsB,KAAK,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA,GAAI,GAAA;AAiB3D,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAc,EAAA,EAAY,IAAY,OAAA,EAAyB;AAC9F,EAAA,MAAM,GAAA,GAAM,CAAA;AACZ,EAAA,MAAM,MAAA,GAAS,GAAA;AACf,EAAA,MA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AAQ,CAAA,4CAAA,CAAA,GACvF,SAAA,CAAU,IAAI,eAAA,EAAiB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,IAAI,CAAA;AAAA,QAC9C,OAAO,MAAA,CAAO;AAAA,OACf,CAAA;AAAA,IACH;AAEA,IAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AACtB,MAAA,MAAM,KAAA,GAAQ,WAAA,CAAY,OAAA,EAAS,MAAM,CAAA;AACzC,MAAA,KAAA,CAAM,IAAA,CAAK,MAAM,GAAG,CAAA;AACpB,MAAA,KAAA,GAAQ,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,KAAA,CAAM,KAAK,CAAA;AACnC,MAAA,MAAA,GAAS,KAAA,CAAM,MAAA;AAAA,IACjB;AAAA,EACF;AAEA,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA;AACzB,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AAC1B,EAAA,OACE,wDAAwD,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,SAAA,EAAY,CAAC,CAAA,UAAA,EAAa,CAAC,CAAA,yBAAA,EAA4B,SAAA,CAAU,OAAO,SAAS,CAAC,OAChJ,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA,GACb,CAAA,MAAA,CAAA;AAEJ","file":"chunk-Q6DVTCXD.js","sourcesContent":["// Radial ecomap renderer — center node + declared external ties on 1–2 concentric\n// rings, as a SELF-CONTAINED SVG string. Pure (data in, string out), deterministic\n// (same input → same SVG), no DOM, no dependencies.\n//\n// HONESTY RULE: the diagram presents ONLY what the caller declared. A tie's line style\n// is a conservative lexical hint from the author's own quality word (ambiguous/null →\n// neutral solid line, never a synthesized value); an arrowhead appears ONLY when a\n// direction was declared (null = no arrow, never a default). The verbatim text always\n// rides the element's <title>, so a style never replaces what was said.\n//\n// Ring assignment is a deterministic PRESENTATION rule — by input order (sorted by id),\n// alternating rings when the set is large — never by any reading of the tie's content.\n//\n// Every interpolated text passes xmlEscape (labels are author-controlled; the SVG may\n// be inlined via innerHTML or embedded in a PDF). All presentation attributes are\n// literal: a standalone SVG has no stylesheet. Arrowheads are explicit polygons, NOT\n// <marker> defs — marker support is unreliable in SVG-to-PDF embedders, and inline\n// polygons also avoid def-id collisions when several SVGs share one document.\n\nimport {\n EDGE_STROKE,\n FONT_FAMILY,\n LEGEND_SWATCH_W,\n clampLabel,\n estimateTextWidth,\n legendBlock,\n qualityLineStyle,\n wrapLabelBalanced,\n xmlEscape,\n type EdgeLineStyle,\n type LegendEntry,\n type QualityLexicon,\n} from \"../core\";\n\n// ── Input model ───────────────────────────────────────────────────────────────\n\n/** Declared flow of the tie, relative to the CENTER: \"in\" = toward the center. */\nexport type EcomapDirection = \"in\" | \"out\" | \"both\";\n\n/**\n * One declared tie between the center (person/household) and an external system\n * (work, faith, friends, healthcare…). `label` is the author's own naming, kept\n * verbatim. `quality` is the author's verbatim wording about the tie (null = not\n * declared = neutral line). `direction` follows the same doctrine: null = no arrow.\n */\nexport interface EcomapTie {\n id: number;\n label: string;\n quality: string | null;\n direction: EcomapDirection | null;\n /** Optional verbatim <title> override (defaults to \"label · quality\"). */\n title?: string;\n}\n\nexport interface EcomapInput {\n /** Center node label (e.g. the person or household the map is about). */\n centerLabel: string;\n ties: EcomapTie[];\n}\n\n// ── Display vocabulary ────────────────────────────────────────────────────────\n\nexport interface EcomapLabels {\n bondStyles: Record<Exclude<EdgeLineStyle, \"plain\">, string>;\n /** Legend label for the neutral solid line (a declared tie with no styled quality). */\n neutralTie: string;\n /** Legend label for the arrowhead (declared direction of the tie). */\n direction: string;\n ariaLabel: string;\n}\n\nexport const ECOMAP_LABELS_EN: EcomapLabels = {\n bondStyles: {\n close: \"Close\",\n distant: \"Distant\",\n conflict: \"Conflictual\",\n cutoff: \"Cut off (no contact)\",\n },\n neutralTie: \"Declared tie\",\n direction: \"Declared direction of the tie\",\n ariaLabel: \"Ecomap\",\n};\n\nexport interface EcomapSvgOptions {\n /** Display clamp per tie label (verbatim text stays in the <title>). */\n maxLabelChars?: number;\n /** Node label font size (px); default 12. */\n fontSize?: number;\n /** Set false to suppress the legend (compact preview); default true. */\n legend?: boolean;\n /** Quality-word lexicon — English default; see `compasso/locales/pt-br`. */\n qualityLexicon?: QualityLexicon;\n /** Display vocabulary — English default; see locale packs. */\n labels?: EcomapLabels;\n}\n\n// ── Geometry constants ────────────────────────────────────────────────────────\n\nconst PADDING = 32;\nconst LINE_H = 14;\nconst NODE_PAD_X = 14;\nconst NODE_PAD_Y = 9;\nconst CENTER_MIN_R = 36;\nconst RING_MIN_R = 150;\n/** Min gap between two adjacent node boxes on the same ring. */\nconst NODE_GAP = 24;\n/** Radial gap between the center circle and the inner ring's nearest box edge. */\nconst RADIAL_GAP = 40;\n/** Radial gap between the two rings when the set is large enough to split. */\nconst RING_GAP = 26;\n/** Above this many ties the layout alternates between two rings. */\nconst SINGLE_RING_MAX = 8;\n\n// Ink (zinc ramp on white — matches the genogram emitter).\nconst NODE_STROKE = \"#52525b\";\nconst LABEL_FILL = \"#3f3f46\";\nconst EDGE_INK = \"#71717a\";\n// Legend row geometry + the swatch span both live in ../core (LEGEND_SWATCH_W imported\n// above for the swatch closures); the row/text/width/height bookkeeping is legendBlock.\n\nconst round = (n: number): number => Math.round(n * 100) / 100;\n\n// ── Internal shapes ───────────────────────────────────────────────────────────\n\ninterface SatNode {\n tie: EcomapTie;\n lines: string[];\n rx: number;\n ry: number;\n /** Filled once ring radii are known. */\n x: number;\n y: number;\n angle: number;\n style: EdgeLineStyle;\n}\n\n/** Arrowhead polygon: tip at (tipX,tipY), pointing along the unit vector (ux,uy). */\nfunction arrowHead(tipX: number, tipY: number, ux: number, uy: number, opacity: number): string {\n const LEN = 9;\n const HALF_W = 4.5;\n const bx = tipX - ux * LEN;\n const by = tipY - uy * LEN;\n const px = -uy;\n const py = ux;\n const points = [\n `${round(tipX)},${round(tipY)}`,\n `${round(bx + px * HALF_W)},${round(by + py * HALF_W)}`,\n `${round(bx - px * HALF_W)},${round(by - py * HALF_W)}`,\n ].join(\" \");\n return `<polygon points=\"${points}\" fill=\"${EDGE_INK}\" fill-opacity=\"${opacity}\"/>`;\n}\n\n/**\n * Renders a declared ecomap to a self-contained SVG string. Deterministic: same data →\n * same SVG. Zero ties yield a valid center-only SVG; callers decide their own empty\n * state before calling. The root keeps numeric width/height attributes plus a matching\n * viewBox (PDF-embedder contract).\n */\nexport function ecomapSvg(input: EcomapInput, opts: EcomapSvgOptions = {}): string {\n const fontSize = opts.fontSize ?? 12;\n const labels = opts.labels ?? ECOMAP_LABELS_EN;\n\n // ── Measure every satellite box (deterministic order: by tie id). ───────────\n const sats: SatNode[] = [...input.ties]\n .sort((a, b) => a.id - b.id)\n .map((tie) => {\n const lines = wrapLabelBalanced(clampLabel(tie.label, opts.maxLabelChars));\n const w = Math.max(...lines.map((l) => estimateTextWidth(l, fontSize))) + NODE_PAD_X * 2;\n const h = lines.length * LINE_H + NODE_PAD_Y * 2;\n return {\n tie,\n lines,\n rx: Math.max(40, w / 2),\n ry: Math.max(20, h / 2),\n x: 0,\n y: 0,\n angle: 0,\n style: qualityLineStyle(tie.quality, opts.qualityLexicon),\n };\n });\n\n const centerLines = wrapLabelBalanced(input.centerLabel);\n const centerR = Math.max(\n CENTER_MIN_R,\n Math.max(...centerLines.map((l) => estimateTextWidth(l, fontSize))) / 2 + 12,\n (centerLines.length * LINE_H) / 2 + 12,\n );\n\n // ── Ring radii: wide enough that NO two node boxes can ever touch. The safe\n // center-to-center distance is the diagonal of the worst-case box pair: if the\n // euclidean distance is ≥ hypot(width-sum, height-sum), the axis-aligned boxes\n // cannot overlap in both axes at once. Overlap-proof by construction, not by luck.\n const n = sats.length;\n const maxRx = n > 0 ? Math.max(...sats.map((s) => s.rx)) : 0;\n const maxRy = n > 0 ? Math.max(...sats.map((s) => s.ry)) : 0;\n const twoRings = n > SINGLE_RING_MAX;\n const stepAngle = n > 0 ? (Math.PI * 2) / n : Math.PI;\n const safeDist = Math.hypot(2 * maxRx + NODE_GAP, 2 * maxRy + NODE_GAP);\n /** Min radius so two nodes `steps` angular steps apart on the SAME ring clear safeDist. */\n const sameRingRadius = (steps: number): number => {\n const theta = steps * stepAngle;\n if (n <= 1 || theta >= Math.PI) return 0; // ≤2 nodes on the ring: no chord constraint\n return safeDist / (2 * Math.sin(theta / 2));\n };\n const ringStep = maxRy * 2 + RING_GAP;\n let innerR = Math.max(\n RING_MIN_R,\n centerR + RADIAL_GAP + maxRy,\n sameRingRadius(twoRings ? 2 : 1),\n );\n if (twoRings) {\n // Cross-ring neighbors sit 1 step apart at radii r and r+ringStep. Their distance\n // sqrt(r² + (r+s)² − 2r(r+s)cosΔ) grows monotonically with r — widen the inner ring\n // in fixed increments until it clears safeDist (deterministic, always terminates).\n const crossDist = (r: number): number =>\n Math.sqrt(r * r + (r + ringStep) ** 2 - 2 * r * (r + ringStep) * Math.cos(stepAngle));\n while (crossDist(innerR) < safeDist) innerR += 8;\n }\n const outerR = innerR + ringStep;\n\n for (let i = 0; i < n; i++) {\n const s = sats[i]!;\n s.angle = -Math.PI / 2 + (i * Math.PI * 2) / n;\n const r = twoRings && i % 2 === 1 ? outerR : innerR;\n s.x = r * Math.cos(s.angle);\n s.y = r * Math.sin(s.angle);\n }\n\n // ── Canvas bounds (center at origin until here), then shift positive. ───────\n let minX = -centerR;\n let minY = -centerR;\n let maxX = centerR;\n let maxY = centerR;\n for (const s of sats) {\n minX = Math.min(minX, s.x - s.rx);\n minY = Math.min(minY, s.y - s.ry);\n maxX = Math.max(maxX, s.x + s.rx);\n maxY = Math.max(maxY, s.y + s.ry);\n }\n const dx = PADDING - minX;\n const dy = PADDING - minY;\n const cx = dx;\n const cy = dy;\n for (const s of sats) {\n s.x += dx;\n s.y += dy;\n }\n let width = maxX - minX + PADDING * 2;\n let height = maxY - minY + PADDING * 2;\n\n const parts: string[] = [];\n\n // ── Tie lines first (nodes sit on top), one group per declared tie. ─────────\n for (const s of sats) {\n const ux = (cx - s.x) / Math.hypot(cx - s.x, cy - s.y);\n const uy = (cy - s.y) / Math.hypot(cx - s.x, cy - s.y);\n // Node-edge endpoint: ellipse boundary along the unit vector toward the center.\n const scale = 1 / Math.hypot(ux / s.rx, uy / s.ry);\n const x1 = s.x + ux * scale;\n const y1 = s.y + uy * scale;\n // Center-edge endpoint: circle boundary along the same direction.\n const x2 = cx - ux * centerR;\n const y2 = cy - uy * centerR;\n\n const ink = EDGE_STROKE[s.style];\n const dashAttr = ink.dash === null ? \"\" : ` stroke-dasharray=\"${ink.dash[0]} ${ink.dash[1]}\"`;\n const title = s.tie.title ?? (s.tie.quality !== null ? `${s.tie.label} · ${s.tie.quality}` : s.tie.label);\n const body: string[] = [\n `<line x1=\"${round(x1)}\" y1=\"${round(y1)}\" x2=\"${round(x2)}\" y2=\"${round(y2)}\" stroke=\"${EDGE_INK}\" stroke-width=\"${ink.width}\" stroke-opacity=\"${ink.opacity}\"${dashAttr}/>`,\n ];\n // Arrowheads ONLY for a declared direction. \"in\" points at the center, \"out\" at\n // the external system, \"both\" draws both. Tips back off the boundary so the\n // triangle never pokes into the shape.\n if (s.tie.direction === \"in\" || s.tie.direction === \"both\") {\n body.push(arrowHead(x2, y2, ux, uy, ink.opacity)); // tip at the center edge\n }\n if (s.tie.direction === \"out\" || s.tie.direction === \"both\") {\n body.push(arrowHead(x1, y1, -ux, -uy, ink.opacity)); // tip at the system edge\n }\n parts.push(`<g data-edge-id=\"${s.tie.id}\"><title>${xmlEscape(title)}</title>${body.join(\"\")}</g>`);\n }\n\n // ── Center node. ─────────────────────────────────────────────────────────────\n {\n const tspans = centerLines\n .map(\n (line, i) =>\n `<tspan x=\"${round(cx)}\" y=\"${round(cy - ((centerLines.length - 1) * LINE_H) / 2 + i * LINE_H + fontSize * 0.32)}\">${xmlEscape(line)}</tspan>`,\n )\n .join(\"\");\n parts.push(\n `<g data-individual-id=\"center\"><title>${xmlEscape(input.centerLabel)}</title>` +\n `<circle cx=\"${round(cx)}\" cy=\"${round(cy)}\" r=\"${round(centerR)}\" fill=\"transparent\" stroke=\"${NODE_STROKE}\" stroke-width=\"2\"/>` +\n `<text text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"${fontSize}\" fill=\"${LABEL_FILL}\">${tspans}</text></g>`,\n );\n }\n\n // ── Satellite nodes. ─────────────────────────────────────────────────────────\n for (const s of sats) {\n const tspans = s.lines\n .map(\n (line, i) =>\n `<tspan x=\"${round(s.x)}\" y=\"${round(s.y - ((s.lines.length - 1) * LINE_H) / 2 + i * LINE_H + fontSize * 0.32)}\">${xmlEscape(line)}</tspan>`,\n )\n .join(\"\");\n parts.push(\n `<g data-individual-id=\"e${s.tie.id}\"><title>${xmlEscape(s.tie.label)}</title>` +\n `<ellipse cx=\"${round(s.x)}\" cy=\"${round(s.y)}\" rx=\"${round(s.rx)}\" ry=\"${round(s.ry)}\" fill=\"transparent\" stroke=\"${NODE_STROKE}\" stroke-width=\"1.5\"/>` +\n `<text text-anchor=\"middle\" font-family=\"${FONT_FAMILY}\" font-size=\"${fontSize}\" fill=\"${LABEL_FILL}\">${tspans}</text></g>`,\n );\n }\n\n // ── Minimal legend: only entries actually used. ──────────────────────────────\n if (opts.legend !== false && sats.length > 0) {\n const entries: LegendEntry[] = [];\n\n if (sats.some((s) => s.style === \"plain\")) {\n entries.push({\n swatch: (x, y) =>\n `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + LEGEND_SWATCH_W}\" y2=\"${y}\" stroke=\"${EDGE_INK}\" stroke-width=\"${EDGE_STROKE.plain.width}\" stroke-opacity=\"${EDGE_STROKE.plain.opacity}\"/>`,\n label: labels.neutralTie,\n });\n }\n const stylesUsed = new Set(sats.map((s) => s.style));\n for (const style of [\"close\", \"distant\", \"conflict\", \"cutoff\"] as const) {\n if (!stylesUsed.has(style)) continue;\n const ink = EDGE_STROKE[style];\n const dashAttr = ink.dash === null ? \"\" : ` stroke-dasharray=\"${ink.dash[0]} ${ink.dash[1]}\"`;\n entries.push({\n swatch: (x, y) =>\n `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + LEGEND_SWATCH_W}\" y2=\"${y}\" stroke=\"${EDGE_INK}\" stroke-width=\"${ink.width}\" stroke-opacity=\"${ink.opacity}\"${dashAttr}/>`,\n label: labels.bondStyles[style],\n });\n }\n if (sats.some((s) => s.tie.direction !== null)) {\n entries.push({\n swatch: (x, y) =>\n `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + LEGEND_SWATCH_W - 8}\" y2=\"${y}\" stroke=\"${EDGE_INK}\" stroke-width=\"1.5\" stroke-opacity=\"0.75\"/>` +\n arrowHead(x + LEGEND_SWATCH_W, y, 1, 0, 0.75),\n label: labels.direction,\n });\n }\n\n if (entries.length > 0) {\n const block = legendBlock(entries, height);\n parts.push(block.svg);\n width = Math.max(width, block.width);\n height = block.height;\n }\n }\n\n const w = Math.ceil(width);\n const h = Math.ceil(height);\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${w} ${h}\" width=\"${w}\" height=\"${h}\" role=\"img\" aria-label=\"${xmlEscape(labels.ariaLabel)}\">` +\n parts.join(\"\") +\n `</svg>`\n );\n}\n"]}
|