compasso 0.4.0 → 0.4.1

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.
Files changed (63) hide show
  1. package/README.md +29 -0
  2. package/dist/{chunk-RWPGGWO5.js → chunk-FYBABYC7.js} +34 -10
  3. package/dist/chunk-FYBABYC7.js.map +1 -0
  4. package/dist/{chunk-F47C6ZEB.js → chunk-IPE7JZO5.js} +3 -3
  5. package/dist/{chunk-F47C6ZEB.js.map → chunk-IPE7JZO5.js.map} +1 -1
  6. package/dist/{chunk-Q6DVTCXD.js → chunk-LR7BXUWM.js} +18 -6
  7. package/dist/chunk-LR7BXUWM.js.map +1 -0
  8. package/dist/{chunk-LRHHUJFZ.js → chunk-M4WA6ME7.js} +3 -3
  9. package/dist/{chunk-LRHHUJFZ.js.map → chunk-M4WA6ME7.js.map} +1 -1
  10. package/dist/{chunk-JP4N42AY.js → chunk-PGUMLTIM.js} +3 -3
  11. package/dist/{chunk-JP4N42AY.js.map → chunk-PGUMLTIM.js.map} +1 -1
  12. package/dist/{chunk-O3BT2O42.js → chunk-SD4NTRBM.js} +29 -3
  13. package/dist/chunk-SD4NTRBM.js.map +1 -0
  14. package/dist/{chunk-UJVU7B44.js → chunk-TAE2UB7D.js} +30 -14
  15. package/dist/chunk-TAE2UB7D.js.map +1 -0
  16. package/dist/{chunk-ZBDABVIO.js → chunk-WJYYBGZW.js} +3 -3
  17. package/dist/{chunk-ZBDABVIO.js.map → chunk-WJYYBGZW.js.map} +1 -1
  18. package/dist/core/index.cjs +30 -0
  19. package/dist/core/index.cjs.map +1 -1
  20. package/dist/core/index.d.cts +18 -2
  21. package/dist/core/index.d.ts +18 -2
  22. package/dist/core/index.js +1 -1
  23. package/dist/ecomap/index.cjs +34 -11
  24. package/dist/ecomap/index.cjs.map +1 -1
  25. package/dist/ecomap/index.d.cts +12 -0
  26. package/dist/ecomap/index.d.ts +12 -0
  27. package/dist/ecomap/index.js +2 -2
  28. package/dist/fault-tree/index.js +2 -2
  29. package/dist/fishbone/index.js +2 -2
  30. package/dist/genogram/index.cjs +57 -7
  31. package/dist/genogram/index.cjs.map +1 -1
  32. package/dist/genogram/index.d.cts +20 -4
  33. package/dist/genogram/index.d.ts +20 -4
  34. package/dist/genogram/index.js +2 -2
  35. package/dist/index.cjs +325 -243
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +5 -5
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +8 -8
  40. package/dist/{kinship-DqEklrDN.d.ts → kinship-BF90HyyS.d.ts} +1 -1
  41. package/dist/{kinship-Dy_ijjJV.d.cts → kinship-BOUss5cT.d.cts} +1 -1
  42. package/dist/{labels-RtFw9tX1.d.cts → labels-B0aOMbHy.d.cts} +12 -0
  43. package/dist/{labels-RtFw9tX1.d.ts → labels-B0aOMbHy.d.ts} +12 -0
  44. package/dist/{labels-DNqRkWuI.d.ts → labels-CuLbFyrz.d.ts} +1 -1
  45. package/dist/{labels-CBQ_3Ec9.d.cts → labels-DhQe7I8m.d.cts} +1 -1
  46. package/dist/locales/pt-br.d.cts +4 -4
  47. package/dist/locales/pt-br.d.ts +4 -4
  48. package/dist/org-chart/index.cjs +100 -58
  49. package/dist/org-chart/index.cjs.map +1 -1
  50. package/dist/org-chart/index.d.cts +19 -2
  51. package/dist/org-chart/index.d.ts +19 -2
  52. package/dist/org-chart/index.js +2 -2
  53. package/dist/pedigree/index.d.cts +4 -4
  54. package/dist/pedigree/index.d.ts +4 -4
  55. package/dist/pedigree/index.js +2 -2
  56. package/dist/phylo/index.js +2 -2
  57. package/dist/{types-BnMG7TCd.d.cts → types-jE2fdM1t.d.cts} +8 -0
  58. package/dist/{types-BnMG7TCd.d.ts → types-jE2fdM1t.d.ts} +8 -0
  59. package/package.json +1 -1
  60. package/dist/chunk-O3BT2O42.js.map +0 -1
  61. package/dist/chunk-Q6DVTCXD.js.map +0 -1
  62. package/dist/chunk-RWPGGWO5.js.map +0 -1
  63. package/dist/chunk-UJVU7B44.js.map +0 -1
@@ -1 +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,IAAA,KAAA,CAAM,CAAA,oBAAA,EAAuB,MAAA,CAAO,GAAA,CAAI,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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"]}
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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AA;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;;;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-M4WA6ME7.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"]}
@@ -1,4 +1,4 @@
1
- import { estimateTextWidth, clampLabel, legendBlock, xmlEscape, FONT_FAMILY, LEGEND_SWATCH_W } from './chunk-O3BT2O42.js';
1
+ import { estimateTextWidth, clampLabel, legendBlock, xmlEscape, FONT_FAMILY, LEGEND_SWATCH_W } from './chunk-SD4NTRBM.js';
2
2
 
3
3
  // src/phylo/labels.ts
4
4
  var PHYLO_TITLE_LABELS_EN = {
@@ -493,5 +493,5 @@ function phyloSvg(input, opts = {}) {
493
493
  }
494
494
 
495
495
  export { PHYLO_BRANCH_ID_BASE, PHYLO_CLADEBAR_ID_BASE, PHYLO_EXTENSION_ID_BASE, PHYLO_LABEL_FONT, PHYLO_LABEL_GAP, PHYLO_ROOTSTUB_ID_BASE, PHYLO_ROW_SLOT, PHYLO_SCALEBAR_ID, PHYLO_SUPPORT_FONT, PHYLO_SVG_LABELS_EN, PHYLO_TITLE_LABELS_EN, PhyloValidationError, computePhyloLayout, niceScaleStep, phyloIssues, phyloLayoutSvg, phyloSvg, validatePhylo };
496
- //# sourceMappingURL=chunk-JP4N42AY.js.map
497
- //# sourceMappingURL=chunk-JP4N42AY.js.map
496
+ //# sourceMappingURL=chunk-PGUMLTIM.js.map
497
+ //# sourceMappingURL=chunk-PGUMLTIM.js.map