@graphrefly/ts 0.0.2 → 0.0.3

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 (210) hide show
  1. package/README.md +197 -117
  2. package/dist/{actions-types-wl9Mgkmr.d.cts → actions-types-CH-XCU9O.d.cts} +4 -4
  3. package/dist/{actions-types-CSC3NMDl.d.ts → actions-types-w2iPQTkv.d.ts} +4 -4
  4. package/dist/adapters/index.cjs.map +1 -1
  5. package/dist/adapters/index.d.cts +10 -10
  6. package/dist/adapters/index.d.ts +10 -10
  7. package/dist/adapters/index.js +7 -7
  8. package/dist/adapters/nestjs/microservices.d.cts +3 -3
  9. package/dist/adapters/nestjs/microservices.d.ts +3 -3
  10. package/dist/adapters/nestjs/native.cjs.map +1 -1
  11. package/dist/adapters/nestjs/native.d.cts +4 -4
  12. package/dist/adapters/nestjs/native.d.ts +4 -4
  13. package/dist/adapters/nestjs/native.js +3 -3
  14. package/dist/adapters/nestjs/websockets.d.cts +3 -3
  15. package/dist/adapters/nestjs/websockets.d.ts +3 -3
  16. package/dist/adapters/nestjs.d.cts +3 -3
  17. package/dist/adapters/nestjs.d.ts +3 -3
  18. package/dist/adapters/observe-storage.d.cts +3 -3
  19. package/dist/adapters/observe-storage.d.ts +3 -3
  20. package/dist/adapters/react.d.cts +2 -2
  21. package/dist/adapters/react.d.ts +2 -2
  22. package/dist/adapters/solid.d.cts +2 -2
  23. package/dist/adapters/solid.d.ts +2 -2
  24. package/dist/adapters/svelte.d.cts +2 -2
  25. package/dist/adapters/svelte.d.ts +2 -2
  26. package/dist/adapters/vue.d.cts +2 -2
  27. package/dist/adapters/vue.d.ts +2 -2
  28. package/dist/{agent-runtime-types-core-hU299uIC.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +1 -1
  29. package/dist/{agent-runtime-types-core-CaXfKNtY.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +1 -1
  30. package/dist/{agent-runtime-types-tool-DninPEzk.d.cts → agent-runtime-types-tool-BLPV3azj.d.cts} +4 -4
  31. package/dist/{agent-runtime-types-tool-BEpSINol.d.ts → agent-runtime-types-tool-hwqvVqNt.d.ts} +4 -4
  32. package/dist/{agentic-memory-retention-BmGX368S.d.ts → agentic-memory-retention-CLwI76JK.d.ts} +2 -2
  33. package/dist/{agentic-memory-retention-Ih1qhX9Z.d.cts → agentic-memory-retention-Cz8GR6ie.d.cts} +2 -2
  34. package/dist/{agentic-memory-types-FnnYlVUs.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +2 -2
  35. package/dist/{agentic-memory-types-CVSUS6XR.d.ts → agentic-memory-types-khYJgzKL.d.ts} +2 -2
  36. package/dist/{capability-admission-lwSecxXs.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
  37. package/dist/{capability-admission-BW2CziT6.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
  38. package/dist/{chunk-SIDJO2T4.js → chunk-3J7UPZL5.js} +6 -6
  39. package/dist/{chunk-ECURQ3HD.js → chunk-3LYI6ADX.js} +4 -4
  40. package/dist/chunk-3LYI6ADX.js.map +1 -0
  41. package/dist/{chunk-M7J6Z4IJ.js → chunk-4M37FH2I.js} +2 -2
  42. package/dist/chunk-4M37FH2I.js.map +1 -0
  43. package/dist/{chunk-CJIFGJQG.js → chunk-54WPEODM.js} +2 -2
  44. package/dist/chunk-54WPEODM.js.map +1 -0
  45. package/dist/{chunk-CX6B6PO2.js → chunk-DKFWDTVY.js} +2 -2
  46. package/dist/chunk-DKFWDTVY.js.map +1 -0
  47. package/dist/{chunk-SHZDP2MQ.js → chunk-GXU6WFEJ.js} +1 -1
  48. package/dist/chunk-GXU6WFEJ.js.map +1 -0
  49. package/dist/{chunk-YDWBXXQZ.js → chunk-KFURM6FM.js} +3 -3
  50. package/dist/{chunk-STXRMPW4.js → chunk-MCOFHMUU.js} +2 -2
  51. package/dist/{chunk-EOKT4QFF.js → chunk-NNDIFUKX.js} +3 -3
  52. package/dist/chunk-NNDIFUKX.js.map +1 -0
  53. package/dist/{chunk-TPND5MJS.js → chunk-PUSRRALM.js} +3 -3
  54. package/dist/{chunk-7HZRJMN6.js → chunk-UEMN5URK.js} +2 -2
  55. package/dist/{chunk-2NJP6GO4.js → chunk-WOS7RJYZ.js} +2 -2
  56. package/dist/composition/index.cjs.map +1 -1
  57. package/dist/composition/index.d.cts +3 -3
  58. package/dist/composition/index.d.ts +3 -3
  59. package/dist/composition/index.js +3 -3
  60. package/dist/core/index.cjs.map +1 -1
  61. package/dist/core/index.d.cts +23 -2
  62. package/dist/core/index.d.ts +23 -2
  63. package/dist/core/index.js +1 -1
  64. package/dist/cqrs/index.d.cts +3 -3
  65. package/dist/cqrs/index.d.ts +3 -3
  66. package/dist/cqrs/messaging.d.cts +4 -4
  67. package/dist/cqrs/messaging.d.ts +4 -4
  68. package/dist/cqrs/work-queue.d.cts +5 -5
  69. package/dist/cqrs/work-queue.d.ts +5 -5
  70. package/dist/data-structures/index.cjs.map +1 -1
  71. package/dist/data-structures/index.d.cts +8 -8
  72. package/dist/data-structures/index.d.ts +8 -8
  73. package/dist/data-structures/index.js +4 -4
  74. package/dist/{describe-CQRrkv-Q.d.cts → describe-BumQ-3_0.d.cts} +1 -1
  75. package/dist/{describe-B_A5fbXH.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
  76. package/dist/executors/tool-provider-adapters.d.cts +7 -7
  77. package/dist/executors/tool-provider-adapters.d.ts +7 -7
  78. package/dist/executors/tool-provider-adapters.js +5 -5
  79. package/dist/executors/tool-provider-runtime.cjs.map +1 -1
  80. package/dist/executors/tool-provider-runtime.d.cts +8 -8
  81. package/dist/executors/tool-provider-runtime.d.ts +8 -8
  82. package/dist/executors/tool-provider-runtime.js +2 -2
  83. package/dist/executors/tool-provider.cjs.map +1 -1
  84. package/dist/executors/tool-provider.d.cts +7 -7
  85. package/dist/executors/tool-provider.d.ts +7 -7
  86. package/dist/executors/tool-provider.js +2 -2
  87. package/dist/executors/work-queue.d.cts +6 -6
  88. package/dist/executors/work-queue.d.ts +6 -6
  89. package/dist/graph/index.cjs.map +1 -1
  90. package/dist/graph/index.d.cts +9 -9
  91. package/dist/graph/index.d.ts +9 -9
  92. package/dist/graph/index.js +7 -7
  93. package/dist/{graph-CWK3HLPB.d.cts → graph-C1C-wb0L.d.cts} +135 -8
  94. package/dist/{graph-ho5sotHP.d.ts → graph-CS0b4V9B.d.ts} +135 -8
  95. package/dist/{index-CQWcE0Dw.d.ts → index-DLrNopda.d.cts} +135 -8
  96. package/dist/{index-DHA1i67c.d.cts → index-DzJni3_6.d.ts} +135 -8
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.cts +12 -12
  99. package/dist/index.d.ts +12 -12
  100. package/dist/index.js +13 -13
  101. package/dist/inspection/boundary.d.cts +4 -4
  102. package/dist/inspection/boundary.d.ts +4 -4
  103. package/dist/{measurements-OMpCeBwh.d.ts → measurements-BWAnochv.d.ts} +139 -9
  104. package/dist/{measurements-C0mAvWU1.d.cts → measurements-B_gJfD8h.d.cts} +139 -9
  105. package/dist/messaging/index.d.cts +5 -5
  106. package/dist/messaging/index.d.ts +5 -5
  107. package/dist/operators/index.cjs.map +1 -1
  108. package/dist/operators/index.d.cts +5 -5
  109. package/dist/operators/index.d.ts +5 -5
  110. package/dist/operators/index.js +4 -4
  111. package/dist/orchestration/index.cjs.map +1 -1
  112. package/dist/orchestration/index.d.cts +12 -12
  113. package/dist/orchestration/index.d.ts +12 -12
  114. package/dist/orchestration/index.js +5 -5
  115. package/dist/orchestration/messaging.d.cts +5 -5
  116. package/dist/orchestration/messaging.d.ts +5 -5
  117. package/dist/orchestration/work-queue.d.cts +8 -8
  118. package/dist/orchestration/work-queue.d.ts +8 -8
  119. package/dist/patterns/event-flow.d.cts +4 -4
  120. package/dist/patterns/event-flow.d.ts +4 -4
  121. package/dist/patterns/index.d.cts +6 -6
  122. package/dist/patterns/index.d.ts +6 -6
  123. package/dist/{process-types-h3uRlzDc.d.cts → process-types-BB7oRhX3.d.cts} +1 -1
  124. package/dist/{process-types-C9uMYz3i.d.ts → process-types-QNhyoYJ8.d.ts} +1 -1
  125. package/dist/{reactive-collection-B9R0Bl1P.d.cts → reactive-collection-BYlWvtnp.d.cts} +3 -3
  126. package/dist/{reactive-collection-BXFrH0U2.d.ts → reactive-collection-efOEdGFN.d.ts} +3 -3
  127. package/dist/{reactive-collection-storage-BLGv8Xp8.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
  128. package/dist/{reactive-collection-storage-a4zD3665.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
  129. package/dist/{reactive-map-jle5dnok.d.ts → reactive-map-BHacbIqz.d.cts} +7 -3
  130. package/dist/{reactive-map-C_8sOfdS.d.cts → reactive-map-DN4Jyqnf.d.ts} +7 -3
  131. package/dist/render/index.d.cts +2 -2
  132. package/dist/render/index.d.ts +2 -2
  133. package/dist/{scheduled-readiness-5rwQlyjV.d.ts → scheduled-readiness-BmqXxnzX.d.ts} +3 -3
  134. package/dist/{scheduled-readiness-DpRY8jI0.d.cts → scheduled-readiness-CYSw7KDE.d.cts} +3 -3
  135. package/dist/{semantic-memory-graph-DlZBD_Eu.d.cts → semantic-memory-graph-B_LwbM-E.d.cts} +2 -2
  136. package/dist/{semantic-memory-graph-C2ZUwIlq.d.ts → semantic-memory-graph-rsFNNhwn.d.ts} +2 -2
  137. package/dist/{semantic-memory-graph-types-BvzdqmkY.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +1 -1
  138. package/dist/{semantic-memory-graph-types-Ci-OtahO.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +1 -1
  139. package/dist/solutions/index.cjs.map +1 -1
  140. package/dist/solutions/index.d.cts +11 -11
  141. package/dist/solutions/index.d.ts +11 -11
  142. package/dist/solutions/index.js +2 -2
  143. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
  144. package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
  145. package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
  146. package/dist/solutions/reactive-layout/browser/index.js +2 -2
  147. package/dist/solutions/reactive-layout/index.cjs.map +1 -1
  148. package/dist/solutions/reactive-layout/index.d.cts +6 -6
  149. package/dist/solutions/reactive-layout/index.d.ts +6 -6
  150. package/dist/solutions/reactive-layout/index.js +2 -2
  151. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
  152. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
  153. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
  154. package/dist/solutions/reactive-layout/node-canvas/index.js +2 -2
  155. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
  156. package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
  157. package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
  158. package/dist/solutions/reactive-layout/react-native/index.js +2 -2
  159. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
  160. package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
  161. package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
  162. package/dist/solutions/reactive-layout/skia/index.js +2 -2
  163. package/dist/solutions/work-item/actions.d.cts +10 -10
  164. package/dist/solutions/work-item/actions.d.ts +10 -10
  165. package/dist/solutions/work-item/scheduling.d.cts +9 -9
  166. package/dist/solutions/work-item/scheduling.d.ts +9 -9
  167. package/dist/solutions/work-item/work-queue.d.cts +7 -7
  168. package/dist/solutions/work-item/work-queue.d.ts +7 -7
  169. package/dist/sources/browser.cjs.map +1 -1
  170. package/dist/sources/browser.d.cts +22 -6
  171. package/dist/sources/browser.d.ts +22 -6
  172. package/dist/sources/browser.js +3 -3
  173. package/dist/sources/browser.js.map +1 -1
  174. package/dist/sources/index.cjs.map +1 -1
  175. package/dist/sources/index.d.cts +4 -4
  176. package/dist/sources/index.d.ts +4 -4
  177. package/dist/sources/index.js +3 -3
  178. package/dist/sources/node.d.cts +3 -3
  179. package/dist/sources/node.d.ts +3 -3
  180. package/dist/storage/index.d.cts +5 -5
  181. package/dist/storage/index.d.ts +5 -5
  182. package/dist/{store-BmtEs9mG.d.ts → store-6_CHF6Ge.d.ts} +1 -1
  183. package/dist/{store-PAAsYvML.d.cts → store-BljX8RkQ.d.cts} +1 -1
  184. package/dist/{types-BhveCMg5.d.cts → types-BAw2QVVE.d.cts} +1 -1
  185. package/dist/{types-XDoqxYO9.d.cts → types-BUbbbh4f.d.cts} +1 -1
  186. package/dist/{types-BWK2ay3e.d.cts → types-CMnzoL54.d.cts} +2 -2
  187. package/dist/{types-BS6CyR-x.d.cts → types-CTN3XoMl.d.cts} +30 -0
  188. package/dist/{types-BXKSAoE1.d.cts → types-CV_ohy5T.d.cts} +2 -2
  189. package/dist/{types-C9NOgNJw.d.ts → types-DChxk1vK.d.ts} +30 -0
  190. package/dist/{types-CTsQ8Ww4.d.ts → types-DRu7SnLV.d.ts} +1 -1
  191. package/dist/{types-DL_05n2M.d.ts → types-DeID_FRl.d.ts} +1 -1
  192. package/dist/{types-BRNKoFHj.d.ts → types-IhKH0hGW.d.ts} +2 -2
  193. package/dist/{types-BaPpZItj.d.ts → types-ePlD2uyT.d.ts} +2 -2
  194. package/dist/{work-item-runtime-types-CHO03AKh.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +2 -2
  195. package/dist/{work-item-runtime-types-BqtWnSCS.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +2 -2
  196. package/dist/work-queue/index.d.cts +6 -6
  197. package/dist/work-queue/index.d.ts +6 -6
  198. package/package.json +9 -1
  199. package/dist/chunk-CJIFGJQG.js.map +0 -1
  200. package/dist/chunk-CX6B6PO2.js.map +0 -1
  201. package/dist/chunk-ECURQ3HD.js.map +0 -1
  202. package/dist/chunk-EOKT4QFF.js.map +0 -1
  203. package/dist/chunk-M7J6Z4IJ.js.map +0 -1
  204. package/dist/chunk-SHZDP2MQ.js.map +0 -1
  205. /package/dist/{chunk-SIDJO2T4.js.map → chunk-3J7UPZL5.js.map} +0 -0
  206. /package/dist/{chunk-YDWBXXQZ.js.map → chunk-KFURM6FM.js.map} +0 -0
  207. /package/dist/{chunk-STXRMPW4.js.map → chunk-MCOFHMUU.js.map} +0 -0
  208. /package/dist/{chunk-TPND5MJS.js.map → chunk-PUSRRALM.js.map} +0 -0
  209. /package/dist/{chunk-7HZRJMN6.js.map → chunk-UEMN5URK.js.map} +0 -0
  210. /package/dist/{chunk-2NJP6GO4.js.map → chunk-WOS7RJYZ.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graph/blueprint.ts","../src/graph/describe.ts","../src/graph/graph-lifecycle.ts","../src/graph/graph-support.ts","../src/graph/graph-topology-group.ts","../src/graph/graph.ts"],"sourcesContent":["/**\n * GraphBlueprint first slice (D173/D177).\n *\n * A blueprint is read-only audit/collaboration evidence over graph.topology(). It is not an\n * authoring spec, checkpoint, restore input, hash owner, or collaboration ownership artifact.\n */\n\nimport {\n\tassertStrictJsonObject,\n\ttype StrictJsonObject,\n\ttype StrictJsonValue,\n\tstableJsonString,\n\tstrictCanonicalJsonBytes,\n} from \"../json/codec.js\";\nimport type { GraphTopologyEdge, GraphTopologySnapshot } from \"./describe.js\";\n\nexport const GRAPH_BLUEPRINT_VERSION = \"graphrefly.blueprint.v1\" as const;\n\nexport type GraphBlueprintJson = StrictJsonValue;\n\nexport type GraphBlueprintProvenance = StrictJsonObject;\n\nexport interface NormalizedGraphTopologyNode {\n\treadonly id: string;\n\treadonly name?: string;\n\treadonly factory: string;\n\treadonly deps: readonly string[];\n\treadonly meta?: Readonly<Record<string, GraphBlueprintJson>>;\n}\n\nexport interface NormalizedGraphTopologySnapshot {\n\treadonly name?: string;\n\treadonly nodes: readonly NormalizedGraphTopologyNode[];\n\treadonly edges: readonly GraphTopologyEdge[];\n\treadonly subgraphs?: readonly NormalizedGraphTopologySnapshot[];\n}\n\nexport type GraphBlueprintDiagnosticCode = \"dangling-dep\" | \"duplicate-node-id\" | \"island-node\";\n\nexport interface GraphBlueprintDiagnosticIssue {\n\treadonly severity: \"warning\" | \"error\";\n\treadonly code: GraphBlueprintDiagnosticCode;\n\treadonly message: string;\n\treadonly nodeId?: string;\n\treadonly from?: string;\n\treadonly to?: string;\n}\n\nexport interface GraphBlueprintDiagnostics {\n\treadonly ok: boolean;\n\treadonly issues: readonly GraphBlueprintDiagnosticIssue[];\n}\n\nexport type GraphBlueprintHashInput = \"strictCanonicalTopologyBytes\";\n\nexport interface GraphBlueprintHash {\n\treadonly kind: \"topology\";\n\treadonly algorithm: string;\n\treadonly input: GraphBlueprintHashInput;\n\treadonly value: string;\n}\n\nexport interface GraphBlueprintHashOptions {\n\treadonly algorithm: string;\n\treadonly hash: (bytes: Uint8Array) => string | Promise<string>;\n}\n\nexport interface GraphBlueprint {\n\treadonly version: typeof GRAPH_BLUEPRINT_VERSION;\n\treadonly topology: NormalizedGraphTopologySnapshot;\n\treadonly diagnostics?: GraphBlueprintDiagnostics;\n\treadonly provenance?: GraphBlueprintProvenance;\n\treadonly hash?: GraphBlueprintHash;\n}\n\nexport interface GraphBlueprintOptions {\n\t/** Include graph-local structural diagnostics over the normalized topology. */\n\treadonly diagnostics?: boolean;\n\t/** Caller-supplied provenance only; environment enrichment stays outside Graph core (D177). */\n\treadonly provenance?: GraphBlueprintProvenance;\n}\n\nexport function normalizeTopologyMeta(\n\tmeta: Record<string, unknown>,\n\tlabel = \"meta\",\n\tkind = \"graph meta\",\n): Readonly<Record<string, GraphBlueprintJson>> {\n\ttry {\n\t\treturn assertStrictJsonObject(meta, label);\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new TypeError(`${label}: ${kind} must be strict JSON-compatible data (D177): ${message}`);\n\t}\n}\n\nexport function normalizeTopology(\n\tsnapshot: GraphTopologySnapshot | NormalizedGraphTopologySnapshot,\n): NormalizedGraphTopologySnapshot {\n\treturn normalizeTopologySnapshot(snapshot as GraphTopologySnapshot, new WeakSet<object>(), \"$\");\n}\n\nfunction normalizeTopologySnapshot(\n\tsnapshot: GraphTopologySnapshot,\n\tseen: WeakSet<object>,\n\tpath: string,\n): NormalizedGraphTopologySnapshot {\n\tif (snapshot === null || typeof snapshot !== \"object\") {\n\t\tthrow new TypeError(`normalizeTopology: snapshot at ${path} must be an object`);\n\t}\n\tif (seen.has(snapshot)) {\n\t\tthrow new TypeError(`normalizeTopology: circular subgraph reference at ${path}`);\n\t}\n\tseen.add(snapshot);\n\ttry {\n\t\tconst nodes = mapDense(snapshot.nodes, `${path}.nodes`, (node, index) => {\n\t\t\tconst nodePath = `${path}.nodes[${index}]`;\n\t\t\tassertTopologyObject(node, nodePath);\n\t\t\tconst id = topologyString(node.id, `${nodePath}.id`);\n\t\t\tconst factory = topologyString(node.factory, `${nodePath}.factory`);\n\t\t\tconst out: NormalizedGraphTopologyNode = {\n\t\t\t\tid,\n\t\t\t\tfactory,\n\t\t\t\tdeps: mapDense(node.deps, `${labelForNode(id)}.deps`, (dep, depIndex) =>\n\t\t\t\t\ttopologyString(dep, `${labelForNode(id)}.deps[${depIndex}]`),\n\t\t\t\t),\n\t\t\t};\n\t\t\tif (node.name !== undefined) {\n\t\t\t\t(out as { name?: string }).name = topologyString(node.name, `${nodePath}.name`);\n\t\t\t}\n\t\t\tif (node.meta !== undefined) {\n\t\t\t\t(out as { meta?: Readonly<Record<string, GraphBlueprintJson>> }).meta =\n\t\t\t\t\tnormalizeTopologyMeta(node.meta, `${labelForNode(id)}.meta`);\n\t\t\t}\n\t\t\treturn out;\n\t\t}).sort(compareNodes);\n\t\tconst out: NormalizedGraphTopologySnapshot = {\n\t\t\tnodes,\n\t\t\tedges: deriveEdges(nodes),\n\t\t};\n\t\tif (snapshot.name !== undefined) {\n\t\t\t(out as { name?: string }).name = topologyString(snapshot.name, `${path}.name`);\n\t\t}\n\t\tif (snapshot.subgraphs !== undefined) {\n\t\t\t(out as { subgraphs?: readonly NormalizedGraphTopologySnapshot[] }).subgraphs = mapDense(\n\t\t\t\tsnapshot.subgraphs,\n\t\t\t\t`${path}.subgraphs`,\n\t\t\t\t(subgraph, index) =>\n\t\t\t\t\tnormalizeTopologySnapshot(subgraph, seen, `${path}.subgraphs[${index}]`),\n\t\t\t).sort(compareTopologies);\n\t\t}\n\t\treturn out;\n\t} finally {\n\t\tseen.delete(snapshot);\n\t}\n}\n\nfunction mapDense<T, U>(\n\tvalues: readonly T[],\n\tpath: string,\n\tmapper: (value: T, index: number) => U,\n): U[] {\n\tif (!Array.isArray(values)) {\n\t\tthrow new TypeError(`normalizeTopology: ${path} must be an array`);\n\t}\n\tconst out: U[] = [];\n\tfor (let i = 0; i < values.length; i += 1) {\n\t\tif (!(i in values)) {\n\t\t\tthrow new TypeError(`normalizeTopology: sparse array hole at ${path}[${i}]`);\n\t\t}\n\t\tout.push(mapper(values[i] as T, i));\n\t}\n\treturn out;\n}\n\nfunction assertTopologyObject(\n\tvalue: unknown,\n\tpath: string,\n): asserts value is Record<string, unknown> {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new TypeError(`normalizeTopology: ${path} must be an object`);\n\t}\n}\n\nfunction topologyString(value: unknown, path: string): string {\n\tif (typeof value !== \"string\") {\n\t\tthrow new TypeError(`normalizeTopology: ${path} must be a string`);\n\t}\n\treturn value;\n}\n\nexport function canonicalTopologyJson(\n\tsnapshot: GraphTopologySnapshot | NormalizedGraphTopologySnapshot,\n): string {\n\treturn stableJsonString(normalizeTopology(snapshot as GraphTopologySnapshot));\n}\n\nexport function canonicalTopologyBytes(\n\tsnapshot: GraphTopologySnapshot | NormalizedGraphTopologySnapshot,\n): Uint8Array {\n\treturn strictCanonicalJsonBytes(normalizeTopology(snapshot as GraphTopologySnapshot));\n}\n\nexport function withBlueprintHash(\n\tblueprint: GraphBlueprint,\n\toptions: GraphBlueprintHashOptions,\n): GraphBlueprint | Promise<GraphBlueprint> {\n\tif (typeof options.algorithm !== \"string\" || options.algorithm.length === 0) {\n\t\tthrow new TypeError(\"withBlueprintHash: algorithm must be a non-empty string\");\n\t}\n\tconst topology = normalizeTopology(blueprint.topology);\n\tconst withHash = (value: string): GraphBlueprint => {\n\t\tif (typeof value !== \"string\" || value.length === 0) {\n\t\t\tthrow new TypeError(\"withBlueprintHash: hash value must be a non-empty string\");\n\t\t}\n\t\treturn {\n\t\t\t...blueprint,\n\t\t\ttopology,\n\t\t\thash: {\n\t\t\t\tkind: \"topology\",\n\t\t\t\talgorithm: options.algorithm,\n\t\t\t\tinput: \"strictCanonicalTopologyBytes\",\n\t\t\t\tvalue,\n\t\t\t},\n\t\t};\n\t};\n\tconst value = options.hash(canonicalTopologyBytes(topology));\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tconst maybeThenable = value as { then?: unknown } | null | undefined;\n\t\tif (\n\t\t\tmaybeThenable === null ||\n\t\t\tmaybeThenable === undefined ||\n\t\t\ttypeof maybeThenable.then !== \"function\"\n\t\t) {\n\t\t\tthrow new TypeError(\"withBlueprintHash: hash value must be a non-empty string\");\n\t\t}\n\t\treturn (value as Promise<string>).then(withHash);\n\t}\n\treturn withHash(value);\n}\n\nexport function withBlueprintProvenance(\n\tblueprint: GraphBlueprint,\n\tprovenance: GraphBlueprintProvenance,\n): GraphBlueprint {\n\treturn {\n\t\t...blueprint,\n\t\tprovenance: normalizeTopologyMeta(provenance, \"graph blueprint provenance\", \"provenance\"),\n\t};\n}\n\nexport function graphBlueprintDiagnostics(\n\ttopology: NormalizedGraphTopologySnapshot,\n): GraphBlueprintDiagnostics {\n\tconst issues: GraphBlueprintDiagnosticIssue[] = [];\n\tcollectDiagnostics(topology, issues);\n\tissues.sort(compareIssues);\n\treturn { ok: !issues.some((issue) => issue.severity === \"error\"), issues };\n}\n\nfunction collectDiagnostics(\n\ttopology: NormalizedGraphTopologySnapshot,\n\tissues: GraphBlueprintDiagnosticIssue[],\n): void {\n\tconst seen = new Set<string>();\n\tconst duplicateIds = new Set<string>();\n\tfor (const node of topology.nodes) {\n\t\tif (seen.has(node.id)) duplicateIds.add(node.id);\n\t\tseen.add(node.id);\n\t}\n\tfor (const id of duplicateIds) {\n\t\tissues.push({\n\t\t\tseverity: \"error\",\n\t\t\tcode: \"duplicate-node-id\",\n\t\t\tnodeId: id,\n\t\t\tmessage: `duplicate topology node id '${id}'`,\n\t\t});\n\t}\n\n\tconst dependents = new Map<string, number>();\n\tfor (const node of topology.nodes) dependents.set(node.id, 0);\n\tfor (const node of topology.nodes) {\n\t\tfor (const dep of node.deps) {\n\t\t\tif (!seen.has(dep)) {\n\t\t\t\tissues.push({\n\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\tcode: \"dangling-dep\",\n\t\t\t\t\tnodeId: node.id,\n\t\t\t\t\tfrom: dep,\n\t\t\t\t\tto: node.id,\n\t\t\t\t\tmessage: `node '${node.id}' depends on missing node '${dep}'`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdependents.set(dep, (dependents.get(dep) ?? 0) + 1);\n\t\t}\n\t}\n\tfor (const node of topology.nodes) {\n\t\tif (node.deps.length === 0 && (dependents.get(node.id) ?? 0) === 0) {\n\t\t\tissues.push({\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tcode: \"island-node\",\n\t\t\t\tnodeId: node.id,\n\t\t\t\tmessage: `node '${node.id}' has no deps and no dependents`,\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const subgraph of topology.subgraphs ?? []) collectDiagnostics(subgraph, issues);\n}\n\nfunction deriveEdges(nodes: readonly NormalizedGraphTopologyNode[]): GraphTopologyEdge[] {\n\tconst seen = new Set<string>();\n\tconst edges: GraphTopologyEdge[] = [];\n\tfor (const node of nodes) {\n\t\tfor (const from of node.deps) {\n\t\t\tconst key = `${from}\\0${node.id}`;\n\t\t\tif (seen.has(key)) continue;\n\t\t\tseen.add(key);\n\t\t\tedges.push({ from, to: node.id });\n\t\t}\n\t}\n\treturn edges.sort(compareEdges);\n}\n\nfunction labelForNode(id: string): string {\n\treturn id === \"\" ? \"node\" : `node '${id}'`;\n}\n\nfunction compareText(a: string, b: string): number {\n\treturn a < b ? -1 : a > b ? 1 : 0;\n}\n\nfunction compareNodes(a: NormalizedGraphTopologyNode, b: NormalizedGraphTopologyNode): number {\n\treturn compareText(a.id, b.id);\n}\n\nfunction compareEdges(a: GraphTopologyEdge, b: GraphTopologyEdge): number {\n\treturn compareText(a.from, b.from) || compareText(a.to, b.to);\n}\n\nfunction compareTopologies(\n\ta: NormalizedGraphTopologySnapshot,\n\tb: NormalizedGraphTopologySnapshot,\n): number {\n\treturn compareText(stableJsonString(a), stableJsonString(b));\n}\n\nfunction compareIssues(a: GraphBlueprintDiagnosticIssue, b: GraphBlueprintDiagnosticIssue): number {\n\treturn (\n\t\tcompareText(a.code, b.code) ||\n\t\tcompareText(a.nodeId ?? \"\", b.nodeId ?? \"\") ||\n\t\tcompareText(a.from ?? \"\", b.from ?? \"\") ||\n\t\tcompareText(a.to ?? \"\", b.to ?? \"\")\n\t);\n}\n","/**\n * topology()/describe() snapshot shapes (R-describe / D39 / D51 / D173).\n *\n * topology() is the current pure-structure snapshot direction (D173). describe()\n * remains the richer developer inspection snapshot over the same live topology\n * truth source, adding runtime status/value/version fields.\n */\n\nimport type { Status } from \"../node/node.js\";\nimport type { NodeVersion } from \"../node/versioning.js\";\n\nexport interface GraphTopologyNode {\n\t/** Stable mount-aware `::` path (auto-numbered when unnamed). Edge key. */\n\tid: string;\n\t/** Optional debug name. */\n\tname?: string;\n\t/** Operator/verb real name (D6/L1.5 — \"map\"/\"state\", not \"derived\"). */\n\tfactory: string;\n\t/** Dep ids (R-edges-derived: edges are a pure fn of live deps). */\n\tdeps: string[];\n\t/** Static annotations attached via g.* opts (R-meta-presentation). */\n\tmeta?: Record<string, unknown>;\n}\n\nexport interface GraphTopologyEdge {\n\tfrom: string;\n\tto: string;\n}\n\nexport interface GraphTopologySnapshot {\n\tname?: string;\n\tnodes: GraphTopologyNode[];\n\tedges: GraphTopologyEdge[];\n\tsubgraphs?: GraphTopologySnapshot[];\n}\n\nexport interface DescribeNode extends GraphTopologyNode {\n\t/** R-status-enum (7). */\n\tstatus: Status;\n\t/** Cache snapshot at call time; field ABSENT = SENTINEL / never-emitted. */\n\tvalue?: unknown;\n\t/** D109 node runtime version metadata; absent when versioning:false. */\n\tversion?: NodeVersion;\n}\n\nexport interface DescribeEdge extends GraphTopologyEdge {}\n\nexport interface DescribeSnapshot extends GraphTopologySnapshot {\n\tname?: string;\n\tnodes: DescribeNode[];\n\tedges: DescribeEdge[];\n\tsubgraphs?: DescribeSnapshot[];\n}\n\nexport interface DescribeOpts {\n\t/** Causal-chain mode: filter to nodes on a path from→to (R-describe). */\n\texplain?: { from: string; to: string };\n}\n\n/** Project a rich describe snapshot into the D173 pure-structure topology shape. */\nexport function topologyFromDescribe(snapshot: DescribeSnapshot): GraphTopologySnapshot {\n\tconst nodes = snapshot.nodes.map((node) => {\n\t\tconst topologyNode: GraphTopologyNode = {\n\t\t\tid: node.id,\n\t\t\tfactory: node.factory,\n\t\t\tdeps: [...node.deps],\n\t\t};\n\t\tif (node.name !== undefined) topologyNode.name = node.name;\n\t\tif (node.meta !== undefined) topologyNode.meta = cloneTopologyMeta(node.meta);\n\t\treturn topologyNode;\n\t});\n\tconst out: GraphTopologySnapshot = {\n\t\tnodes,\n\t\tedges: snapshot.edges.map((edge) => ({ from: edge.from, to: edge.to })),\n\t};\n\tif (snapshot.name !== undefined) out.name = snapshot.name;\n\tif (snapshot.subgraphs !== undefined)\n\t\tout.subgraphs = snapshot.subgraphs.map(topologyFromDescribe);\n\treturn out;\n}\n\nfunction cloneTopologyMeta(meta: Record<string, unknown>): Record<string, unknown> {\n\treturn cloneTopologyValue(meta, new WeakMap()) as Record<string, unknown>;\n}\n\nfunction cloneTopologyValue(value: unknown, seen: WeakMap<object, unknown>): unknown {\n\tif (value === null) return null;\n\tconst kind = typeof value;\n\tif (kind === \"string\" || kind === \"boolean\") return value;\n\tif (kind === \"number\") {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new Error(\"topology(): meta must be finite JSON-compatible data (D39/D173)\");\n\t\t}\n\t\treturn value;\n\t}\n\tif (kind !== \"object\") {\n\t\tthrow new Error(\"topology(): meta must be JSON-compatible data (D39/D173)\");\n\t}\n\tconst objectValue = value as object;\n\tconst cached = seen.get(objectValue);\n\tif (cached !== undefined) return cached;\n\tif (Array.isArray(value)) {\n\t\tconst out = new Array<unknown>(value.length);\n\t\tseen.set(objectValue, out);\n\t\tfor (let i = 0; i < value.length; i += 1) {\n\t\t\tif (!(i in value)) {\n\t\t\t\tthrow new Error(\"topology(): meta arrays must be dense JSON-compatible data (D39/D173)\");\n\t\t\t}\n\t\t\tout[i] = cloneTopologyValue(value[i], seen);\n\t\t}\n\t\treturn out;\n\t}\n\tconst proto = Object.getPrototypeOf(objectValue);\n\tif (proto !== Object.prototype && proto !== null) {\n\t\tthrow new Error(\"topology(): meta must be plain JSON-compatible data (D39/D173)\");\n\t}\n\tconst out: Record<string, unknown> = {};\n\tseen.set(objectValue, out);\n\tfor (const [key, item] of Object.entries(value as Record<string, unknown>))\n\t\tout[key] = cloneTopologyValue(item, seen);\n\treturn out;\n}\n","import type { NodeFn } from \"../ctx/types.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { Graph, StateNode } from \"./graph.js\";\nimport type { SugarOpts } from \"./graph-types.js\";\n\nexport interface GraphRestoreRegistrar {\n\tstateNode<T>(id: string, opts?: SugarOpts<T>): StateNode<T>;\n\tnode<T>(\n\t\tid: string,\n\t\tfactory: string,\n\t\tdeps: readonly Node<unknown>[],\n\t\tfn: NodeFn | null,\n\t\topts?: SugarOpts<T>,\n\t): Node<T>;\n}\n\nexport const restoreRegistrars = new WeakMap<Graph, GraphRestoreRegistrar>();\n\nexport interface GraphLifecycleRegistrar {\n\tassertRegisteredNode(node: Node<unknown>, label: string): void;\n\treleaseNodes(nodes: readonly Node<unknown>[], opts?: { reason?: string }): void;\n}\n\nexport const lifecycleRegistrars = new WeakMap<Graph, GraphLifecycleRegistrar>();\n","import { checkpointStateOfNode, type Node } from \"../node/node.js\";\nimport { type GraphCheckpointFactory, toCheckpointJson } from \"./checkpoint.js\";\nimport type { DescribeSnapshot } from \"./describe.js\";\nimport type { TopologyEvent } from \"./inspect.js\";\n\nexport function isNonAuthoritativeCollectionHelperMeta(\n\tmeta: Record<string, unknown> | undefined,\n): boolean {\n\treturn (\n\t\tmeta?.kind === \"collection_delta\" ||\n\t\tmeta?.kind === \"collection_intent\" ||\n\t\tmeta?.kind === \"collection_policy_apply\" ||\n\t\tmeta?.kind === \"collection_snapshot\" ||\n\t\tmeta?.kind === \"collection_snapshot_prep\"\n\t);\n}\n\nexport function assertCheckpointQuiescentStatus(status: string, id: string, op: string): void {\n\tif (status === \"pending\" || status === \"dirty\") {\n\t\tthrow new Error(\n\t\t\t`${op}: node '${id}' has non-quiescent status '${status}' that cannot be checkpoint-restored yet`,\n\t\t);\n\t}\n}\n\nexport function topologyPathMatches(eventPath: string, path: string): boolean {\n\treturn eventPath === path || eventPath.startsWith(`${path}::`);\n}\n\nexport function prefixTopologyPath(prefix: string, path: string): string {\n\treturn `${prefix}::${path}`;\n}\n\nexport function cloneTopologyEvent(event: TopologyEvent): TopologyEvent {\n\tconst deps = Object.freeze([...event.deps]);\n\tconst prevDeps = event.prevDeps === undefined ? undefined : Object.freeze([...event.prevDeps]);\n\treturn Object.freeze({\n\t\tkind: event.kind,\n\t\tpath: event.path,\n\t\tdeps,\n\t\t...(prevDeps !== undefined ? { prevDeps } : {}),\n\t\t...(event.factory !== undefined ? { factory: event.factory } : {}),\n\t\tseq: event.seq,\n\t});\n}\n\nexport function checkpointFactory(\n\tname: string,\n\tnode: Node<unknown>,\n\tunregistered: boolean,\n\trestore?: { ref: string; config?: unknown; configVersion?: unknown },\n\tmeta?: Record<string, unknown>,\n): GraphCheckpointFactory {\n\tconst state = checkpointStateOfNode(node);\n\tif (unregistered) {\n\t\treturn {\n\t\t\tkind: \"local-only\",\n\t\t\tname,\n\t\t\treason: \"node is an unregistered live dependency auto-discovered from topology\",\n\t\t};\n\t}\n\tif (\n\t\trestore === undefined &&\n\t\ttypeof meta?.kind === \"string\" &&\n\t\tmeta.kind.startsWith(\"collection_\")\n\t) {\n\t\treturn {\n\t\t\tkind: \"local-only\",\n\t\t\tname,\n\t\t\treason: \"collection helper node has no backend checkpoint restore metadata\",\n\t\t};\n\t}\n\tif (restore !== undefined) {\n\t\tconst out: GraphCheckpointFactory = {\n\t\t\tkind: \"registry-ref\",\n\t\t\tref: toCheckpointJson(restore.ref, `${name}.factory.ref`) as string,\n\t\t};\n\t\tif (restore.config !== undefined)\n\t\t\tout.config = toCheckpointJson(restore.config, `${name}.factory.config`);\n\t\tif (restore.configVersion !== undefined)\n\t\t\tout.configVersion = toCheckpointJson(restore.configVersion, `${name}.factory.configVersion`);\n\t\treturn out;\n\t}\n\tif (state.handle !== null) {\n\t\treturn {\n\t\t\tkind: \"local-only\",\n\t\t\tname,\n\t\t\treason: \"node uses a function body; first-cut checkpoints do not serialize local functions\",\n\t\t};\n\t}\n\treturn { kind: \"registry-ref\", ref: name };\n}\n\n/** Filter a snapshot to the causal chain from→to (forward-reachable(from) ∩ back-reachable(to)). */\nexport function explainSubset(\n\tsnap: DescribeSnapshot,\n\tchain: { from: string; to: string },\n): DescribeSnapshot {\n\tconst fwd = new Map<string, string[]>();\n\tconst rev = new Map<string, string[]>();\n\tconst push = (map: Map<string, string[]>, k: string, v: string): void => {\n\t\tconst a = map.get(k);\n\t\tif (a) a.push(v);\n\t\telse map.set(k, [v]);\n\t};\n\tfor (const e of snap.edges) {\n\t\tpush(fwd, e.from, e.to);\n\t\tpush(rev, e.to, e.from);\n\t}\n\tconst reach = (start: string, adj: Map<string, string[]>): Set<string> => {\n\t\tconst seen = new Set<string>([start]);\n\t\tconst stack = [start];\n\t\twhile (stack.length > 0) {\n\t\t\tconst cur = stack.pop() as string;\n\t\t\tfor (const nxt of adj.get(cur) ?? []) {\n\t\t\t\tif (!seen.has(nxt)) {\n\t\t\t\t\tseen.add(nxt);\n\t\t\t\t\tstack.push(nxt);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn seen;\n\t};\n\tconst onPath = new Set([...reach(chain.from, fwd)].filter((id) => reach(chain.to, rev).has(id)));\n\treturn {\n\t\t...(snap.name !== undefined ? { name: snap.name } : {}),\n\t\tnodes: snap.nodes.filter((n) => onPath.has(n.id)),\n\t\tedges: snap.edges.filter((e) => onPath.has(e.from) && onPath.has(e.to)),\n\t};\n}\n","import type { NodeFn } from \"../ctx/types.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { Graph, StateNode } from \"./graph.js\";\nimport { lifecycleRegistrars } from \"./graph-lifecycle.js\";\nimport type { DerivedFn, EffectFn, SugarOpts } from \"./graph-types.js\";\nimport type { Operator } from \"./operators.js\";\n\nexport interface TopologyGroupOptions {\n\t/** Optional inspection/release reason label for this graph-owned topology group. */\n\tname?: string;\n}\n\nexport interface TopologyGroupReleaseOptions {\n\t/** Optional diagnostic reason. No protocol/control messages are synthesized. */\n\treason?: string;\n}\n\n/**\n * Graph-owned D152 release group: a label over ordinary graph-registered nodes.\n * The graph registry remains the source of truth; helper-local membership is only\n * a memo for atomic quiescent release.\n */\nexport interface TopologyGroup {\n\treadonly name?: string;\n\treadonly released: boolean;\n\tadd<T extends Node<unknown>>(node: T): T;\n\tnode<T = unknown>(\n\t\tdeps?: readonly Node<unknown>[],\n\t\tfn?: NodeFn | null,\n\t\topts?: SugarOpts<T>,\n\t): Node<T>;\n\tstate<T>(initial: T, opts?: SugarOpts<T>): StateNode<T>;\n\tproducer<T = unknown>(fn: NodeFn, opts?: SugarOpts<T>): Node<T>;\n\tderived<const D extends readonly Node<unknown>[], T>(\n\t\tdeps: D,\n\t\tfn: DerivedFn<D, T>,\n\t\topts?: SugarOpts<T>,\n\t): Node<T>;\n\teffect<const D extends readonly Node<unknown>[]>(\n\t\tdeps: D,\n\t\tfn: EffectFn<D>,\n\t\topts?: SugarOpts<void>,\n\t): Node<void>;\n\tinitNode<TIn, TOut>(\n\t\top: Operator<TIn, TOut>,\n\t\tdeps: readonly Node<TIn>[],\n\t\topts?: SugarOpts<TOut>,\n\t): Node<TOut>;\n\trelease(opts?: TopologyGroupReleaseOptions): void;\n}\n\nexport class GraphTopologyGroup implements TopologyGroup {\n\treadonly name?: string;\n\tprivate readonly _graph: Graph;\n\tprivate readonly _members: Node<unknown>[] = [];\n\tprivate _released = false;\n\n\tconstructor(graph: Graph, opts: TopologyGroupOptions = {}) {\n\t\tthis._graph = graph;\n\t\tthis.name = opts.name;\n\t}\n\n\tget released(): boolean {\n\t\treturn this._released;\n\t}\n\n\tadd<T extends Node<unknown>>(node: T): T {\n\t\tthis._assertLive();\n\t\tconst lifecycle = lifecycleRegistrars.get(this._graph);\n\t\tif (lifecycle === undefined) throw new Error(\"topologyGroup: graph lifecycle unavailable\");\n\t\tlifecycle.assertRegisteredNode(node, `topology group '${this.name ?? \"group\"}' member`);\n\t\tif (!this._members.includes(node)) this._members.push(node);\n\t\treturn node;\n\t}\n\n\tnode<T = unknown>(\n\t\tdeps: readonly Node<unknown>[] = [],\n\t\tfn: NodeFn | null = null,\n\t\topts: SugarOpts<T> = {},\n\t): Node<T> {\n\t\tthis._assertLive();\n\t\treturn this.add(this._graph.node(deps, fn, opts));\n\t}\n\n\tstate<T>(initial: T, opts: SugarOpts<T> = {}): StateNode<T> {\n\t\tthis._assertLive();\n\t\treturn this.add(this._graph.state(initial, opts));\n\t}\n\n\tproducer<T = unknown>(fn: NodeFn, opts: SugarOpts<T> = {}): Node<T> {\n\t\tthis._assertLive();\n\t\treturn this.add(this._graph.producer(fn, opts));\n\t}\n\n\tderived<const D extends readonly Node<unknown>[], T>(\n\t\tdeps: D,\n\t\tfn: DerivedFn<D, T>,\n\t\topts: SugarOpts<T> = {},\n\t): Node<T> {\n\t\tthis._assertLive();\n\t\treturn this.add(this._graph.derived(deps, fn, opts));\n\t}\n\n\teffect<const D extends readonly Node<unknown>[]>(\n\t\tdeps: D,\n\t\tfn: EffectFn<D>,\n\t\topts: SugarOpts<void> = {},\n\t): Node<void> {\n\t\tthis._assertLive();\n\t\treturn this.add(this._graph.effect(deps, fn, opts));\n\t}\n\n\tinitNode<TIn, TOut>(\n\t\top: Operator<TIn, TOut>,\n\t\tdeps: readonly Node<TIn>[],\n\t\topts: SugarOpts<TOut> = {},\n\t): Node<TOut> {\n\t\tthis._assertLive();\n\t\treturn this.add(this._graph.initNode(op, deps, opts));\n\t}\n\n\trelease(opts: TopologyGroupReleaseOptions = {}): void {\n\t\tif (this._released) return;\n\t\tconst lifecycle = lifecycleRegistrars.get(this._graph);\n\t\tif (lifecycle === undefined) throw new Error(\"topologyGroup: graph lifecycle unavailable\");\n\t\tlifecycle.releaseNodes([...this._members], {\n\t\t\treason: opts.reason ?? this.name,\n\t\t});\n\t\tthis._members.length = 0;\n\t\tthis._released = true;\n\t}\n\n\tprivate _assertLive(): void {\n\t\tif (this._released) {\n\t\t\tthrow new Error(`topology group '${this.name ?? \"group\"}' has been released (D152)`);\n\t\t}\n\t}\n}\n","/**\n * The Graph layer (CSP-2): convenience + inspection entry (D5 / R-graph-role).\n *\n * g.* sugar desugars to dispatcher.register + Node and auto-registers into the graph\n * inspection index (D27: sugar→ctx-fn conversion lives strictly here; the substrate node\n * only ever sees `(ctx)=>void`). The Graph owns naming, describe, mount, and the D30\n * value-level throw→ERROR boundary. The bare node()/dispatcher stay inspection-free\n * (R-node-thin).\n *\n * Canonical authority: ~/src/graphrefly — D3/D5/D27/D30/D36/D37/D39, R-graph-role,\n * R-describe, R-fn-contract, R-edges-derived, R-meta-presentation.\n */\n\nimport { type BatchCtx, batch as batchRun } from \"../batch/batch.js\";\nimport { type Ctx, depCount, depLatest, type NodeFn } from \"../ctx/types.js\";\nimport { type Dispatcher, defaultDispatcher } from \"../dispatcher/index.js\";\nimport { NodeCore } from \"../node/core.js\";\nimport {\n\tcheckpointStateOfNode,\n\tgetNodeOwner,\n\tisNodeActiveForRelease,\n\tisNodeRuntimeQuiescentForRelease,\n\tisNodeRuntimeReleased,\n\tNode,\n\ttype NodeOptions,\n\treleaseRuntimeOfNode,\n\tsetNodeOwner,\n\tsetNodeTopologyDepsChangedObserver,\n\tsubscriberCountOfNode,\n\twithEnvironmentDrivers,\n\twithNodeCore,\n} from \"../node/node.js\";\nimport type { NodeVersioningPolicy } from \"../node/versioning.js\";\nimport { errorPayload, messageTier, SENTINEL } from \"../protocol/messages.js\";\nimport {\n\tGRAPH_BLUEPRINT_VERSION,\n\ttype GraphBlueprint,\n\ttype GraphBlueprintOptions,\n\tgraphBlueprintDiagnostics,\n\tnormalizeTopology,\n\tnormalizeTopologyMeta,\n} from \"./blueprint.js\";\nimport {\n\tcheckpointBackendStateOfNode,\n\tcheckpointTerminal,\n\tcheckpointValue,\n\tGRAPH_CHECKPOINT_VERSION,\n\ttype GraphCheckpoint,\n\ttype GraphCheckpointFactory,\n\ttype GraphCheckpointJson,\n\ttype GraphCheckpointNode,\n\ttoCheckpointJson,\n} from \"./checkpoint.js\";\nimport {\n\ttype DescribeEdge,\n\ttype DescribeNode,\n\ttype DescribeOpts,\n\ttype DescribeSnapshot,\n\ttype GraphTopologySnapshot,\n\ttopologyFromDescribe,\n} from \"./describe.js\";\nimport { EnvironmentDrivers } from \"./environment.js\";\nimport { lifecycleRegistrars, restoreRegistrars } from \"./graph-lifecycle.js\";\nimport {\n\tassertCheckpointQuiescentStatus,\n\tcheckpointFactory,\n\tcloneTopologyEvent,\n\texplainSubset,\n\tisNonAuthoritativeCollectionHelperMeta,\n\tprefixTopologyPath,\n\ttopologyPathMatches,\n} from \"./graph-support.js\";\nimport {\n\tGraphTopologyGroup,\n\ttype TopologyGroup,\n\ttype TopologyGroupOptions,\n} from \"./graph-topology-group.js\";\nimport type { DepValues, DerivedFn, EffectFn, GraphOptions, SugarOpts } from \"./graph-types.js\";\nimport type {\n\tNodeProfile,\n\tObserveStream,\n\tProfile,\n\tTopologyEvent,\n\tTopologyStream,\n} from \"./inspect.js\";\nimport { initNodeWithCore, type Operator } from \"./operators.js\";\n\nexport type {\n\tTopologyGroup,\n\tTopologyGroupOptions,\n\tTopologyGroupReleaseOptions,\n} from \"./graph-topology-group.js\";\nexport type { DerivedFn, EffectFn, GraphOptions, SugarOpts } from \"./graph-types.js\";\n\ninterface Entry {\n\tnode: Node<unknown>;\n\tid: string;\n\tname?: string;\n\tfactory: string;\n\tdeps: readonly Node<unknown>[];\n\tmeta?: Record<string, unknown>;\n\trestore?: { ref: string; config?: unknown; configVersion?: unknown };\n}\n\ninterface TopologyObserver {\n\tpath?: string;\n\tsink(event: TopologyEvent): void;\n}\n\ninterface MountedGraph {\n\tat: string;\n\tgraph: Graph;\n\ttopologyUnsub?: () => void;\n}\n\nfunction nodeOwner(n: Node<unknown>): Graph | undefined {\n\treturn getNodeOwner(n) as Graph | undefined;\n}\n\nexport function assertGraphLocalNode(owner: Graph, n: Node<unknown>, label: string): void {\n\tif (isNodeRuntimeReleased(n)) {\n\t\tthrow new Error(`${label} has been released from its graph lifecycle (D122)`);\n\t}\n\tconst existing = nodeOwner(n);\n\tif (existing !== undefined && existing !== owner) {\n\t\tthrow new Error(\n\t\t\t`${label} belongs to a different graph; cross-graph deps require a wire bridge`,\n\t\t);\n\t}\n}\n\n/**\n * A state node (L4-Q1): a manual source whose `.set(v)` is `node.down([[DATA, v]])` sugar.\n * Extends the substrate Node so it is usable as a dep AND carries the graph-layer `.set`.\n */\nexport class StateNode<T> extends Node<T> {\n\tset(v: T): void {\n\t\tthis.down([[\"DATA\", v]]);\n\t}\n}\n\nexport class Graph {\n\treadonly name?: string;\n\tprivate readonly _dispatcher: Dispatcher;\n\tprivate readonly _versioning: NodeVersioningPolicy | undefined;\n\tprivate readonly _environment: EnvironmentDrivers;\n\tprivate readonly _core = new NodeCore();\n\tprivate readonly _entries = new Map<Node<unknown>, Entry>();\n\tprivate readonly _byId = new Map<string, Node<unknown>>();\n\tprivate readonly _retiredIds = new Set<string>();\n\tprivate readonly _mounts: MountedGraph[] = [];\n\tprivate _seq = 0;\n\tprivate _clock = 0; // graph-local monotonic clock for observe seq (D26)\n\tprivate _topologyObserverSeq = 0;\n\tprivate readonly _topologyObservers = new Map<number, TopologyObserver>();\n\tprivate _topologyDelivering = false;\n\tprivate readonly _topologyQueue: TopologyEvent[] = [];\n\t// D51: stable synthetic ids for unregistered live deps (runtime *Map inners) auto-discovered by\n\t// describe(). WeakMap-cached so successive describes agree + the inner's id is freed when it is.\n\t// A dedicated counter (NOT _seq) so a describe() call never perturbs registered-node id numbering.\n\tprivate _synthSeq = 0;\n\tprivate readonly _synthIds = new WeakMap<Node<unknown>, string>();\n\n\tconstructor(opts: GraphOptions = {}) {\n\t\tthis.name = opts.name;\n\t\tthis._dispatcher = opts.dispatcher ?? defaultDispatcher;\n\t\tthis._versioning = opts.versioning;\n\t\tthis._environment = opts.environment ?? EnvironmentDrivers.empty();\n\t\tif (opts.profile) this._dispatcher.setRecording(true);\n\t\trestoreRegistrars.set(this, {\n\t\t\tstateNode: <T = unknown>(id: string, stateOpts: SugarOpts<T> = {}) => {\n\t\t\t\tconst n = this._construct(() => new StateNode<T>([], null, this._nodeOpts(stateOpts)));\n\t\t\t\tthis._addWithId(n, \"state\", [], stateOpts, id);\n\t\t\t\treturn n;\n\t\t\t},\n\t\t\tnode: <T = unknown>(\n\t\t\t\tid: string,\n\t\t\t\tfactory: string,\n\t\t\t\tdeps: readonly Node<unknown>[],\n\t\t\t\tfn: NodeFn | null,\n\t\t\t\tnodeOpts: SugarOpts<T> = {},\n\t\t\t) => {\n\t\t\t\tthis._assertDepsLocal(deps, `dep of restored '${id}'`);\n\t\t\t\tconst n = this._construct(() => new Node<T>([...deps], fn, this._nodeOpts(nodeOpts)));\n\t\t\t\tthis._addWithId(n, factory, deps, nodeOpts, id);\n\t\t\t\treturn n;\n\t\t\t},\n\t\t});\n\t\tlifecycleRegistrars.set(this, {\n\t\t\tassertRegisteredNode: (node, label) => this._assertRegisteredNode(node, label),\n\t\t\treleaseNodes: (nodes, releaseOpts) => this._releaseNodes(nodes, releaseOpts),\n\t\t});\n\t}\n\n\t// ── registration / inspection index ──\n\n\tprivate _add<T>(\n\t\tn: Node<T>,\n\t\tfactory: string,\n\t\tdeps: readonly Node<unknown>[],\n\t\topts: SugarOpts<T>,\n\t): Node<T> {\n\t\tconst id = opts.name ?? `${factory}#${this._seq++}`;\n\t\treturn this._addWithId(n, factory, deps, opts, id);\n\t}\n\n\tprivate _addWithId<T>(\n\t\tn: Node<T>,\n\t\tfactory: string,\n\t\tdeps: readonly Node<unknown>[],\n\t\topts: SugarOpts<T>,\n\t\tid: string,\n\t): Node<T> {\n\t\tassertGraphLocalNode(this, n as Node<unknown>, `graph node '${opts.name ?? factory}'`);\n\t\tfor (const dep of deps) assertGraphLocalNode(this, dep, `dep of '${opts.name ?? factory}'`);\n\t\tif (this._byId.has(id)) {\n\t\t\tthrow new Error(`graph: duplicate node id '${id}' (checkpoint/describe ids must be unique)`);\n\t\t}\n\t\tif (this._retiredIds.has(id)) {\n\t\t\tthrow new Error(`graph: node id '${id}' was released and cannot be reused (D152/D153)`);\n\t\t}\n\t\tconst meta =\n\t\t\topts.meta === undefined\n\t\t\t\t? undefined\n\t\t\t\t: (normalizeTopologyMeta(opts.meta, `graph node '${id}' meta`) as Record<string, unknown>);\n\t\tthis._entries.set(n as Node<unknown>, {\n\t\t\tnode: n as Node<unknown>,\n\t\t\tid,\n\t\t\tname: opts.name,\n\t\t\tfactory,\n\t\t\tdeps,\n\t\t\tmeta,\n\t\t\trestore: opts.restore,\n\t\t});\n\t\tsetNodeOwner(n as Node<unknown>, this);\n\t\tthis._byId.set(id, n as Node<unknown>);\n\t\tsetNodeTopologyDepsChangedObserver(n as Node<unknown>, (_node, prevDeps, nextDeps) => {\n\t\t\tthis._emitTopologyDepsChanged(n as Node<unknown>, prevDeps, nextDeps);\n\t\t});\n\t\tconst seqMatch = /#(\\d+)$/.exec(id);\n\t\tif (seqMatch) this._seq = Math.max(this._seq, Number(seqMatch[1]) + 1);\n\t\tthis._emitTopologyNodeRegistered(n as Node<unknown>);\n\t\treturn n;\n\t}\n\n\tprivate _assertDepsLocal(deps: readonly Node<unknown>[], label: string): void {\n\t\tfor (const dep of deps) assertGraphLocalNode(this, dep, label);\n\t}\n\n\tprivate _assertRegisteredNode(node: Node<unknown>, label: string): void {\n\t\tassertGraphLocalNode(this, node, label);\n\t\tif (!this._entries.has(node)) {\n\t\t\tthrow new Error(`${label} is not a registered graph node (D152)`);\n\t\t}\n\t}\n\n\tprivate _nodeOpts<T>(opts: SugarOpts<T>): NodeOptions<T> {\n\t\tif (opts.meta !== undefined) {\n\t\t\tnormalizeTopologyMeta(opts.meta, `graph node '${opts.name ?? opts.factory ?? \"node\"}' meta`);\n\t\t}\n\t\t// strip graph-only fields; inject the bound dispatcher\n\t\tconst { name: _n, meta: _m, restore: _r, ...rest } = opts;\n\t\treturn {\n\t\t\t...rest,\n\t\t\tversioning: rest.versioning ?? this._versioning,\n\t\t\tdispatcher: this._dispatcher,\n\t\t};\n\t}\n\n\tprivate _construct<TNode extends Node<unknown>>(create: () => TNode): TNode {\n\t\treturn withEnvironmentDrivers(this._environment, () => withNodeCore(this._core, create));\n\t}\n\n\t/** Look up a registered node by its id. */\n\tfind(id: string): Node<unknown> | undefined {\n\t\tconst local = this._byId.get(id);\n\t\tif (local !== undefined) return local;\n\t\tconst separator = id.indexOf(\"::\");\n\t\tif (separator < 0) return undefined;\n\t\tconst mountPath = id.slice(0, separator);\n\t\tconst childPath = id.slice(separator + 2);\n\t\treturn this._mounts.find((mount) => mount.at === mountPath)?.graph.find(childPath);\n\t}\n\n\tprivate _releaseNodes(nodes: readonly Node<unknown>[], _opts: { reason?: string } = {}): void {\n\t\tconst seen = new Set<Node<unknown>>();\n\t\tconst entries: Array<{ node: Node<unknown>; entry: Entry }> = [];\n\t\tfor (const node of nodes) {\n\t\t\tif (seen.has(node)) continue;\n\t\t\tseen.add(node);\n\t\t\tconst entry = this._entries.get(node);\n\t\t\tif (entry === undefined) continue;\n\t\t\tentries.push({ node, entry });\n\t\t}\n\t\tconst releaseSet = new Set(entries.map(({ node }) => node));\n\t\tconst releaseIds = new Map(entries.map(({ node, entry }) => [node, entry.id] as const));\n\t\tfor (const entry of this._entries.values()) {\n\t\t\tif (releaseSet.has(entry.node)) continue;\n\t\t\tfor (const dep of entry.node.deps) {\n\t\t\t\tif (!releaseSet.has(dep)) continue;\n\t\t\t\tconst depId = releaseIds.get(dep) ?? dep.name ?? dep.factory ?? \"released node\";\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`graph: cannot release node group; '${entry.id}' still depends on '${depId}' (D122)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tfor (const { node, entry } of entries) {\n\t\t\tif (!isNodeRuntimeQuiescentForRelease(node)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`graph: cannot release node group; '${entry.id}' is not runtime-quiescent (D124)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet internalSubscribers = 0;\n\t\t\tfor (const { node: dependent } of entries) {\n\t\t\t\tif (dependent === node || !isNodeActiveForRelease(dependent)) continue;\n\t\t\t\tfor (const dep of dependent.deps) {\n\t\t\t\t\tif (dep === node) internalSubscribers += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (subscriberCountOfNode(node) > internalSubscribers) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`graph: cannot release node group; '${entry.id}' still has live subscribers (D124)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst releasedEvents =\n\t\t\tthis._topologyObservers.size === 0\n\t\t\t\t? []\n\t\t\t\t: entries.map(({ node, entry }) => ({\n\t\t\t\t\t\tpath: entry.id,\n\t\t\t\t\t\tfactory: entry.factory,\n\t\t\t\t\t\tdeps: this._topologyDeps(node.deps),\n\t\t\t\t\t}));\n\t\tfor (const { node, entry } of entries) {\n\t\t\tthis._entries.delete(node);\n\t\t\tthis._byId.delete(entry.id);\n\t\t\tthis._retiredIds.add(entry.id);\n\t\t}\n\t\tlet releaseError: unknown;\n\t\tfor (const { node } of entries) {\n\t\t\ttry {\n\t\t\t\treleaseRuntimeOfNode(node);\n\t\t\t} catch (error) {\n\t\t\t\tif (releaseError === undefined) releaseError = error;\n\t\t\t}\n\t\t}\n\t\tfor (const event of releasedEvents) this._emitTopologyNodeReleased(event);\n\t\tif (releaseError !== undefined) throw releaseError;\n\t}\n\n\t// ── 8 verbs (core: node/state/batch + sugar: producer/derived/effect/mount) ──\n\n\t/** ctx-level power surface: a raw `(ctx)=>void` fn (or a passthrough/state when null). */\n\tnode<T = unknown>(\n\t\tdeps: readonly Node<unknown>[] = [],\n\t\tfn: NodeFn | null = null,\n\t\topts: SugarOpts<T> = {},\n\t): Node<T> {\n\t\tthis._assertDepsLocal(deps, `dep of '${opts.name ?? \"node\"}'`);\n\t\tconst n = this._construct(() => new Node<T>(deps as Node<unknown>[], fn, this._nodeOpts(opts)));\n\t\treturn this._add(n, opts.factory ?? \"node\", deps, opts);\n\t}\n\n\t/** A manual source with `.set(v)` (L4-Q1). */\n\tstate<T>(initial: T, opts: SugarOpts<T> = {}): StateNode<T> {\n\t\tconst n = this._construct(\n\t\t\t() => new StateNode<T>([], null, { ...this._nodeOpts(opts), initial }),\n\t\t);\n\t\tthis._add(n, \"state\", [], opts);\n\t\treturn n;\n\t}\n\n\t/** ctx-level depless source; its fn runs on activation (R-rom-ram). */\n\tproducer<T = unknown>(fn: NodeFn, opts: SugarOpts<T> = {}): Node<T> {\n\t\tconst n = this._construct(() => new Node<T>([], fn, this._nodeOpts(opts)));\n\t\treturn this._add(n, \"producer\", [], opts);\n\t}\n\n\t/** value-level pure transform: deps → value (D27 wrapped; D30 throw→ERROR). */\n\tderived<const D extends readonly Node<unknown>[], T>(\n\t\tdeps: D,\n\t\tfn: DerivedFn<D, T>,\n\t\topts: SugarOpts<T> = {},\n\t): Node<T> {\n\t\tthis._assertDepsLocal(deps, `dep of '${opts.name ?? \"derived\"}'`);\n\t\tconst ctxFn: NodeFn = (ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst args = Array.from({ length: depCount(ctx) }, (_, i) =>\n\t\t\t\t\tdepLatest(ctx, i),\n\t\t\t\t) as DepValues<D>;\n\t\t\t\tconst result = fn(...args);\n\t\t\t\tif (result !== undefined) ctx.down([[\"DATA\", result]]);\n\t\t\t} catch (e) {\n\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"derived threw without a valid error payload\")]]); // D30: value-level throw → graph-layer ERROR\n\t\t\t}\n\t\t};\n\t\tconst n = this._construct(() => new Node<T>([...deps], ctxFn, this._nodeOpts(opts)));\n\t\treturn this._add(n, \"derived\", deps, opts);\n\t}\n\n\t/** value-level sink: deps → effect; return value (a fn) becomes onDeactivation (D28). */\n\teffect<const D extends readonly Node<unknown>[]>(\n\t\tdeps: D,\n\t\tfn: EffectFn<D>,\n\t\topts: SugarOpts<void> = {},\n\t): Node<void> {\n\t\tthis._assertDepsLocal(deps, `dep of '${opts.name ?? \"effect\"}'`);\n\t\t// effect cleanup = deactivation-only (D28 / Flag 3): the LATEST returned cleanup\n\t\t// fires ONCE when the effect deactivates (not between re-runs — onRerun was cut).\n\t\t// R-cleanup-hooks per-run lifecycle (D28 clarification / C-14): the substrate clears\n\t\t// the hook list before EACH fn run, so the effect re-registers its returned cleanup\n\t\t// every run — only the latest run's registration is live (or none, if the latest run\n\t\t// returned void). No st.registered/ctx.state bookkeeping; re-registering every run is\n\t\t// safe (the per-run clear prevents accumulation).\n\t\tconst ctxFn: NodeFn = (ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst args = Array.from({ length: depCount(ctx) }, (_, i) =>\n\t\t\t\t\tdepLatest(ctx, i),\n\t\t\t\t) as DepValues<D>;\n\t\t\t\tconst cleanup = fn(...args);\n\t\t\t\tif (typeof cleanup === \"function\") ctx.onDeactivation(cleanup);\n\t\t\t} catch (e) {\n\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"effect threw without a valid error payload\")]]);\n\t\t\t}\n\t\t};\n\t\tconst n = this._construct(() => new Node<void>([...deps], ctxFn, this._nodeOpts(opts)));\n\t\treturn this._add(n, \"effect\", deps, opts);\n\t}\n\n\t/** Declarative batch (D12): one wave, success→commit / throw→rollback. */\n\tbatch<T>(fn: (bctx: BatchCtx) => T): T {\n\t\treturn batchRun(fn);\n\t}\n\n\t/** Embed a child graph addressable under `at` (R-mount; mount has no deps). */\n\tmount(child: Graph, opts: { at: string }): void {\n\t\tconst mount = { at: opts.at, graph: child };\n\t\tthis._mounts.push(mount);\n\t\tif (this._topologyObservers.size > 0) this._ensureMountedTopologyForwarders();\n\t\tthis._emitTopologyMountChanged(opts.at);\n\t}\n\n\t// ── operator funnel (D43): instantiate any free-standing Operator (node sugar, D6/L1.5) ──\n\t// g.initNode is the single graph-bound entry for the whole operator/source catalog (D40):\n\t// it delegates to the FREE initNode (graph/operators.ts — the D30 throw→ERROR boundary +\n\t// dispatcher binding live there) and records the operator's REAL factory name in the\n\t// inspection index (_add) so describe shows it (D6/R-describe) while the node stays thin\n\t// (R-node-thin). Operators are free-standing factory definitions (graph/operators.ts,\n\t// graph/sources.ts) usable bare via the free initNode(); this funnel is the inspectable\n\t// path. Replaces the per-operator methods.\n\n\t/**\n\t * Instantiate an operator (or source) factory as a registered graph node. `deps` are\n\t * type-checked against the operator's input element type; the output type flows from the\n\t * operator. A source is a depless operator — pass `[]`. Caller `opts` (name/meta/behavioral\n\t * overrides) win over the operator's baked-in `opts`.\n\t */\n\tinitNode<TIn, TOut>(\n\t\top: Operator<TIn, TOut>,\n\t\tdeps: readonly Node<TIn>[],\n\t\topts: SugarOpts<TOut> = {},\n\t): Node<TOut> {\n\t\tconst entryOpts =\n\t\t\top.restore !== undefined && !(\"restore\" in opts) ? { ...opts, restore: op.restore } : opts;\n\t\tfor (const dep of deps as readonly Node<unknown>[])\n\t\t\tassertGraphLocalNode(this, dep, `dep of '${entryOpts.name ?? op.factory}'`);\n\t\t// Node<T> is invariant (T appears in NodeOptions.initial); widen the typed deps to the\n\t\t// erased Node surface the free initNode / _add accept (same cast the old methods used).\n\t\tconst erased = deps as readonly Node<unknown>[];\n\t\tconst n = withEnvironmentDrivers(this._environment, () =>\n\t\t\tinitNodeWithCore(this._core, op, erased, this._nodeOpts(entryOpts)),\n\t\t);\n\t\treturn this._add(n, op.factory, erased, entryOpts);\n\t}\n\n\t/**\n\t * Graph-owned activation root for internal helper nodes. This is the sanctioned keepalive shape:\n\t * a graph, not a helper closure, owns the subscription and returns the release handle.\n\t */\n\tretain<T>(node: Node<T>, opts: { reason?: string } = {}): () => void {\n\t\tassertGraphLocalNode(this, node as Node<unknown>, opts.reason ?? \"retained node\");\n\t\treturn node.subscribe(() => {});\n\t}\n\n\t/**\n\t * D152 graph-owned topology/release group. Members are ordinary registered graph nodes;\n\t * release is quiescent-only and removes ids atomically without synthesizing protocol messages.\n\t */\n\ttopologyGroup(opts: TopologyGroupOptions = {}): TopologyGroup {\n\t\treturn new GraphTopologyGroup(this, opts);\n\t}\n\n\t// ── inspection: describe / observe / profile (D39) ──\n\n\t/** Live point-in-time structure snapshot (R-describe / D39 / D51). `_prefix` carries the mount path. */\n\tdescribe(opts: DescribeOpts = {}, _prefix = \"\"): DescribeSnapshot {\n\t\t// D51: edges derive from each node's CURRENT/LIVE deps (entry.node.deps, NOT the\n\t\t// construction-time entry.deps), so a rewire (C-8 immediate / C-11 *Map deferred) is\n\t\t// reflected and every edge is a real current subscription (D3). A live dep absent from this\n\t\t// graph's index (a runtime *Map inner / bare fromAny node) is AUTO-DISCOVERED as a snapshot\n\t\t// node with a synthesized stable id (B2). B38 extends this to transitive live-reachability:\n\t\t// discovered unregistered nodes are recursively expanded through their own live deps.\n\t\tconst discovered = new Map<Node<unknown>, string>(); // unregistered live dep → synth local id\n\t\tconst localId = (n: Node<unknown>): string => {\n\t\t\tconst e = this._entries.get(n);\n\t\t\tif (e) return `${_prefix}${e.id}`;\n\t\t\t// unregistered: a stable synthetic id, cached so successive describes + both call sites\n\t\t\t// agree; the `~` prefix can't collide with a registered name or `factory#seq`.\n\t\t\tlet sid = this._synthIds.get(n);\n\t\t\tif (sid === undefined) {\n\t\t\t\t// the `~` prefix avoids the registered `name`/`factory#seq` space; guard the\n\t\t\t\t// pathological case of a user node literally named `~factory#n` (bump until free).\n\t\t\t\tdo {\n\t\t\t\t\tsid = `~${n.factory ?? \"?\"}#${this._synthSeq++}`;\n\t\t\t\t} while (this._byId.has(sid));\n\t\t\t\tthis._synthIds.set(n, sid);\n\t\t\t}\n\t\t\tdiscovered.set(n, sid);\n\t\t\treturn `${_prefix}${sid}`;\n\t\t};\n\t\tconst nodes: DescribeNode[] = [];\n\t\tconst edges: DescribeEdge[] = [];\n\t\t// pass 1: registered nodes, reading LIVE deps (localId records any unregistered inner).\n\t\tfor (const entry of this._entries.values()) {\n\t\t\tconst id = `${_prefix}${entry.id}`;\n\t\t\tconst liveIds = entry.node.deps.map(localId);\n\t\t\tconst dnode: DescribeNode = {\n\t\t\t\tid,\n\t\t\t\tfactory: entry.factory,\n\t\t\t\tstatus: entry.node.status,\n\t\t\t\tdeps: liveIds,\n\t\t\t};\n\t\t\tif (entry.name !== undefined) dnode.name = entry.name;\n\t\t\tif (entry.node.cache !== undefined) dnode.value = entry.node.cache; // absent = SENTINEL\n\t\t\tif (entry.node.version !== undefined) dnode.version = entry.node.version;\n\t\t\tif (entry.meta !== undefined) dnode.meta = entry.meta;\n\t\t\tnodes.push(dnode);\n\t\t\tfor (const from of liveIds) edges.push({ from, to: id });\n\t\t}\n\t\t// pass 2: recursively emit auto-discovered unregistered nodes (D51+B38). localId() may add\n\t\t// further unregistered deps to `discovered` while this loop runs; a visited set keeps each\n\t\t// discovered node emitted once (stable ids via _synthIds).\n\t\tconst visited = new Set<Node<unknown>>();\n\t\tconst queue: Node<unknown>[] = [...discovered.keys()];\n\t\tfor (let i = 0; i < queue.length; i += 1) {\n\t\t\tconst inner = queue[i];\n\t\t\tif (visited.has(inner)) continue;\n\t\t\tvisited.add(inner);\n\t\t\tconst sid = discovered.get(inner);\n\t\t\tif (sid === undefined) continue;\n\t\t\tconst liveIds = inner.deps.map(localId);\n\t\t\tfor (const dep of inner.deps) {\n\t\t\t\tif (!this._entries.has(dep) && !visited.has(dep)) queue.push(dep);\n\t\t\t}\n\t\t\tconst dnode: DescribeNode = {\n\t\t\t\tid: `${_prefix}${sid}`,\n\t\t\t\tfactory: inner.factory ?? \"?\",\n\t\t\t\tstatus: inner.status,\n\t\t\t\tdeps: liveIds,\n\t\t\t};\n\t\t\tif (inner.cache !== undefined) dnode.value = inner.cache;\n\t\t\tif (inner.version !== undefined) dnode.version = inner.version;\n\t\t\tnodes.push(dnode);\n\t\t\tfor (const from of liveIds) edges.push({ from, to: dnode.id });\n\t\t}\n\t\tconst snap: DescribeSnapshot = { nodes, edges };\n\t\tif (this.name !== undefined) snap.name = this.name;\n\t\tif (this._mounts.length > 0) {\n\t\t\tsnap.subgraphs = this._mounts.map((m) => m.graph.describe({}, `${_prefix}${m.at}::`));\n\t\t}\n\t\treturn opts.explain ? explainSubset(snap, opts.explain) : snap;\n\t}\n\n\t/**\n\t * D173 pure-structure topology snapshot over the same live truth source as describe().\n\t * Runtime status/value/version remain on describe(); blueprint metadata is a later envelope.\n\t */\n\ttopology(): GraphTopologySnapshot {\n\t\treturn topologyFromDescribe(this.describe());\n\t}\n\n\t/**\n\t * D177 synchronous audit/collaboration envelope over the pure topology snapshot.\n\t * Hashing and environment provenance enrichment stay in pure helpers outside Graph core.\n\t */\n\tblueprint(opts: GraphBlueprintOptions = {}): GraphBlueprint {\n\t\tconst topology = normalizeTopology(this.topology());\n\t\tconst out: GraphBlueprint = {\n\t\t\tversion: GRAPH_BLUEPRINT_VERSION,\n\t\t\ttopology,\n\t\t};\n\t\tif (opts.diagnostics) {\n\t\t\t(out as { diagnostics?: ReturnType<typeof graphBlueprintDiagnostics> }).diagnostics =\n\t\t\t\tgraphBlueprintDiagnostics(topology);\n\t\t}\n\t\tif (opts.provenance !== undefined) {\n\t\t\t(out as { provenance?: GraphBlueprint[\"provenance\"] }).provenance = normalizeTopologyMeta(\n\t\t\t\topts.provenance,\n\t\t\t\t\"graph blueprint provenance\",\n\t\t\t\t\"provenance\",\n\t\t\t);\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate _observeTargets(path?: string): Array<[string, Node<unknown>]> {\n\t\tconst all: Array<[string, Node<unknown>]> = [...this._entries.values()].map((e) => [\n\t\t\te.id,\n\t\t\te.node,\n\t\t]);\n\t\tif (path === undefined) return all; // whole graph\n\t\tconst exact = this._byId.get(path);\n\t\tif (exact) return [[path, exact]]; // single node\n\t\treturn all.filter(([id]) => id.startsWith(`${path}::`)); // subtree (mount-aware :: boundary, QA A-1)\n\t}\n\n\t/**\n\t * observe(path?) = read-only enveloped EGRESS (R-observe / D39). NOT a graph node — it\n\t * taps the target node(s) via subscribe and forwards each Message as an ObserveEvent.\n\t * No path = whole graph; an exact id = a single node; otherwise a `::`-prefix subtree.\n\t */\n\t// NOTE (R-observe/D19): observe is a real, lazily-ACTIVATING subscriber — observing a\n\t// cold node runs its fn (and activates upstream); whole-graph observe() activates the\n\t// graph. \"Read-only\" means it never emits/mutates node state, NOT that it avoids\n\t// activation. Use it knowing inspection of a cold graph wakes it.\n\tobserve(path?: string): ObserveStream {\n\t\tconst targets = this._observeTargets(path);\n\t\treturn {\n\t\t\tsubscribe: (sink) => {\n\t\t\t\tconst unsubs = targets.map(([id, n]) =>\n\t\t\t\t\tn.subscribe((msg) => {\n\t\t\t\t\t\tsink({ path: id, msg, tier: messageTier(msg[0]), seq: this._clock++ });\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tfor (const u of unsubs) u();\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * D145 observeTopology(path?) = read-only graph lifecycle egress over the existing\n\t * graph registry. It is not a graph node, does not subscribe to nodes, and emits no DATA.\n\t */\n\tobserveTopology(path?: string): TopologyStream {\n\t\treturn {\n\t\t\tsubscribe: (sink) => {\n\t\t\t\tconst id = this._topologyObserverSeq++;\n\t\t\t\tthis._topologyObservers.set(id, { path, sink });\n\t\t\t\tthis._ensureMountedTopologyForwarders();\n\t\t\t\treturn () => {\n\t\t\t\t\tthis._topologyObservers.delete(id);\n\t\t\t\t\tif (this._topologyObservers.size === 0) this._releaseMountedTopologyForwarders();\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate _idForTopologyNode(n: Node<unknown>): string {\n\t\tconst e = this._entries.get(n);\n\t\tif (e) return e.id;\n\t\tlet sid = this._synthIds.get(n);\n\t\tif (sid === undefined) {\n\t\t\tdo {\n\t\t\t\tsid = `~${n.factory ?? \"?\"}#${this._synthSeq++}`;\n\t\t\t} while (this._byId.has(sid));\n\t\t\tthis._synthIds.set(n, sid);\n\t\t}\n\t\treturn sid;\n\t}\n\n\tprivate _topologyDeps(deps: readonly Node<unknown>[]): string[] {\n\t\treturn deps.map((dep) => this._idForTopologyNode(dep));\n\t}\n\n\tprivate _emitTopologyNodeRegistered(node: Node<unknown>): void {\n\t\tif (this._topologyObservers.size === 0) return;\n\t\tconst entry = this._entries.get(node);\n\t\tif (entry === undefined) return;\n\t\tthis._emitTopologyEvent({\n\t\t\tkind: \"node-registered\",\n\t\t\tpath: entry.id,\n\t\t\tfactory: entry.factory,\n\t\t\tdeps: this._topologyDeps(node.deps),\n\t\t\tseq: this._clock++,\n\t\t});\n\t}\n\n\tprivate _emitTopologyDepsChanged(\n\t\tnode: Node<unknown>,\n\t\tprevDeps: readonly Node<unknown>[],\n\t\tnextDeps: readonly Node<unknown>[],\n\t): void {\n\t\tif (this._topologyObservers.size === 0) return;\n\t\tconst entry = this._entries.get(node);\n\t\tif (entry === undefined) return;\n\t\tthis._emitTopologyEvent({\n\t\t\tkind: \"deps-changed\",\n\t\t\tpath: entry.id,\n\t\t\tprevDeps: this._topologyDeps(prevDeps),\n\t\t\tdeps: this._topologyDeps(nextDeps),\n\t\t\tseq: this._clock++,\n\t\t});\n\t}\n\n\tprivate _emitTopologyNodeReleased(event: {\n\t\tpath: string;\n\t\tfactory: string;\n\t\tdeps: readonly string[];\n\t}): void {\n\t\tif (this._topologyObservers.size === 0) return;\n\t\tthis._emitTopologyEvent({\n\t\t\tkind: \"node-released\",\n\t\t\tpath: event.path,\n\t\t\tfactory: event.factory,\n\t\t\tdeps: [...event.deps],\n\t\t\tseq: this._clock++,\n\t\t});\n\t}\n\n\tprivate _emitTopologyMountChanged(path: string): void {\n\t\tif (this._topologyObservers.size === 0) return;\n\t\tthis._emitTopologyEvent({\n\t\t\tkind: \"mount-changed\",\n\t\t\tpath,\n\t\t\tfactory: \"mount\",\n\t\t\tdeps: [],\n\t\t\tseq: this._clock++,\n\t\t});\n\t}\n\n\tprivate _ensureMountedTopologyForwarders(): void {\n\t\tif (this._topologyObservers.size === 0) return;\n\t\tfor (const mount of this._mounts) {\n\t\t\tif (mount.topologyUnsub !== undefined) continue;\n\t\t\tconst mountPath = mount.at;\n\t\t\tmount.topologyUnsub = mount.graph.observeTopology().subscribe((event) => {\n\t\t\t\tthis._emitMountedTopologyEvent(mountPath, event);\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate _releaseMountedTopologyForwarders(): void {\n\t\tfor (const mount of this._mounts) {\n\t\t\tmount.topologyUnsub?.();\n\t\t\tmount.topologyUnsub = undefined;\n\t\t}\n\t}\n\n\tprivate _emitMountedTopologyEvent(mountPath: string, event: TopologyEvent): void {\n\t\tif (this._topologyObservers.size === 0) return;\n\t\tthis._emitTopologyEvent({\n\t\t\tkind: event.kind,\n\t\t\tpath: prefixTopologyPath(mountPath, event.path),\n\t\t\tdeps: event.deps.map((dep) => prefixTopologyPath(mountPath, dep)),\n\t\t\t...(event.prevDeps !== undefined\n\t\t\t\t? { prevDeps: event.prevDeps.map((dep) => prefixTopologyPath(mountPath, dep)) }\n\t\t\t\t: {}),\n\t\t\t...(event.factory !== undefined ? { factory: event.factory } : {}),\n\t\t\tseq: this._clock++,\n\t\t});\n\t}\n\n\tprivate _emitTopologyEvent(event: TopologyEvent): void {\n\t\tif (this._topologyDelivering) {\n\t\t\tthis._topologyQueue.push(event);\n\t\t\treturn;\n\t\t}\n\t\tthis._topologyDelivering = true;\n\t\ttry {\n\t\t\tlet current: TopologyEvent | undefined = event;\n\t\t\twhile (current !== undefined) {\n\t\t\t\tconst observers = [...this._topologyObservers.entries()];\n\t\t\t\tfor (const [id, observer] of observers) {\n\t\t\t\t\tif (this._topologyObservers.get(id) !== observer) continue;\n\t\t\t\t\tif (observer.path !== undefined && !topologyPathMatches(current.path, observer.path))\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tobserver.sink(cloneTopologyEvent(current));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// D145 egress is read-only inspection; observer failure must not veto a\n\t\t\t\t\t\t// graph registry/rewire mutation that already committed.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcurrent = this._topologyQueue.shift();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._topologyDelivering = false;\n\t\t}\n\t}\n\n\t/**\n\t * profile() = accumulated-counter snapshot (R-profile / D39). invokes + duration are\n\t * dispatcher-backed (the invoke funnel, F-DISPATCH-ALL) — counters never live on the\n\t * thin node (R-node-thin). Requires `graph({ profile: true })` (opt-in, F-PERF).\n\t */\n\tprofile(): Profile {\n\t\tconst nodes: Record<string, NodeProfile> = {};\n\t\tlet totalInvokes = 0;\n\t\tfor (const e of this._entries.values()) {\n\t\t\tconst h = e.node.handle;\n\t\t\tconst stat = h ? this._dispatcher.statFor(h) : undefined;\n\t\t\tconst invokes = stat?.invokes ?? 0;\n\t\t\tnodes[e.id] = {\n\t\t\t\tinvokes,\n\t\t\t\ttotalDurationNs: stat?.totalDurationNs ?? 0,\n\t\t\t\tlastDurationNs: stat?.lastDurationNs ?? 0,\n\t\t\t\tstatus: e.node.status,\n\t\t\t};\n\t\t\t// graph-scoped (QA D-2): sum THIS graph's nodes, NOT the dispatcher-global\n\t\t\t// counter (which would leak invokes from other graphs sharing the dispatcher).\n\t\t\ttotalInvokes += invokes;\n\t\t}\n\t\treturn { totalInvokes, nodes };\n\t}\n\n\t/** Versioned graph lifecycle checkpoint (R-snapshot / D83 / D90). Pure capture, no storage I/O. */\n\tcheckpoint(): GraphCheckpoint {\n\t\treturn this._checkpoint(\"\", new WeakSet());\n\t}\n\n\tprivate _checkpoint(_prefix: string, stack: WeakSet<Graph>): GraphCheckpoint {\n\t\tif (stack.has(this)) {\n\t\t\tthrow new Error(\"checkpoint: cyclic graph mount detected\");\n\t\t}\n\t\tstack.add(this);\n\t\tconst discovered = new Map<Node<unknown>, string>();\n\t\tconst localId = (n: Node<unknown>): string => {\n\t\t\tconst e = this._entries.get(n);\n\t\t\tif (e) return `${_prefix}${e.id}`;\n\t\t\tlet sid = this._synthIds.get(n);\n\t\t\tif (sid === undefined) {\n\t\t\t\tdo {\n\t\t\t\t\tsid = `~${n.factory ?? \"?\"}#${this._synthSeq++}`;\n\t\t\t\t} while (this._byId.has(sid));\n\t\t\t\tthis._synthIds.set(n, sid);\n\t\t\t}\n\t\t\tdiscovered.set(n, sid);\n\t\t\treturn `${_prefix}${sid}`;\n\t\t};\n\t\tconst nodes: GraphCheckpointNode[] = [];\n\t\tconst edges: DescribeEdge[] = [];\n\t\tfor (const entry of this._entries.values()) {\n\t\t\tconst id = `${_prefix}${entry.id}`;\n\t\t\tconst liveIds = entry.node.deps.map(localId);\n\t\t\tnodes.push(\n\t\t\t\tthis._checkpointNode(entry.node, id, {\n\t\t\t\t\tname: entry.name,\n\t\t\t\t\tfactory: checkpointFactory(entry.factory, entry.node, false, entry.restore, entry.meta),\n\t\t\t\t\tdeps: liveIds,\n\t\t\t\t\tmeta: entry.meta,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tfor (const from of liveIds) edges.push({ from, to: id });\n\t\t}\n\t\tconst visited = new Set<Node<unknown>>();\n\t\tconst queue: Node<unknown>[] = [...discovered.keys()];\n\t\tfor (let i = 0; i < queue.length; i += 1) {\n\t\t\tconst inner = queue[i];\n\t\t\tif (visited.has(inner)) continue;\n\t\t\tvisited.add(inner);\n\t\t\tconst sid = discovered.get(inner);\n\t\t\tif (sid === undefined) continue;\n\t\t\tconst liveIds = inner.deps.map(localId);\n\t\t\tfor (const dep of inner.deps) {\n\t\t\t\tif (!this._entries.has(dep) && !visited.has(dep)) queue.push(dep);\n\t\t\t}\n\t\t\tconst id = `${_prefix}${sid}`;\n\t\t\tnodes.push(\n\t\t\t\tthis._checkpointNode(inner, id, {\n\t\t\t\t\tfactory: checkpointFactory(inner.factory ?? \"?\", inner, true),\n\t\t\t\t\tdeps: liveIds,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tfor (const from of liveIds) edges.push({ from, to: id });\n\t\t}\n\t\tconst checkpoint: GraphCheckpoint = {\n\t\t\tversion: GRAPH_CHECKPOINT_VERSION,\n\t\t\tnodes,\n\t\t\tedges,\n\t\t};\n\t\tif (this.name !== undefined) checkpoint.name = this.name;\n\t\tif (this._mounts.length > 0) {\n\t\t\tcheckpoint.mounts = this._mounts.map((m) => ({\n\t\t\t\tat: m.at,\n\t\t\t\tcheckpoint: m.graph._checkpoint(\"\", stack),\n\t\t\t}));\n\t\t}\n\t\tstack.delete(this);\n\t\treturn toCheckpointJson(checkpoint, \"checkpoint\") as unknown as GraphCheckpoint;\n\t}\n\n\tprivate _checkpointNode(\n\t\tnode: Node<unknown>,\n\t\tid: string,\n\t\topts: {\n\t\t\tname?: string;\n\t\t\tfactory: GraphCheckpointFactory;\n\t\t\tdeps: string[];\n\t\t\tmeta?: Record<string, unknown>;\n\t\t},\n\t): GraphCheckpointNode {\n\t\tconst state = checkpointStateOfNode(node);\n\t\tassertCheckpointQuiescentStatus(node.status, id, \"checkpoint\");\n\t\tconst nonAuthoritativeCollectionHelper = isNonAuthoritativeCollectionHelperMeta(opts.meta);\n\t\tconst out: GraphCheckpointNode = {\n\t\t\tid,\n\t\t\tfactory: opts.factory,\n\t\t\tstatus: node.status,\n\t\t\tdeps: opts.deps,\n\t\t\tvalue: nonAuthoritativeCollectionHelper\n\t\t\t\t? { kind: \"SENTINEL\" }\n\t\t\t\t: checkpointValue(state.cache, state.hasData, `${id}.value`),\n\t\t\tterminal: checkpointTerminal(state.terminal, `${id}.terminal`),\n\t\t\tlifecycle: { activated: state.activated, hasCalledFnOnce: state.hasCalledFnOnce },\n\t\t\tctxState: {\n\t\t\t\tpersist: state.ctxState.persist,\n\t\t\t\tvalue: nonAuthoritativeCollectionHelper\n\t\t\t\t\t? { kind: \"SENTINEL\" }\n\t\t\t\t\t: checkpointValue(\n\t\t\t\t\t\t\tstate.ctxState.value,\n\t\t\t\t\t\t\tstate.ctxState.value !== SENTINEL,\n\t\t\t\t\t\t\t`${id}.ctxState`,\n\t\t\t\t\t\t),\n\t\t\t},\n\t\t};\n\t\tif (opts.name !== undefined) out.name = opts.name;\n\t\tconst backendState = checkpointBackendStateOfNode(node, `${id}.backendState`);\n\t\tif (backendState !== undefined) out.backendState = backendState;\n\t\tif (state.version !== undefined) out.version = state.version;\n\t\tif (opts.meta !== undefined)\n\t\t\tout.meta = toCheckpointJson(opts.meta, `${id}.meta`) as {\n\t\t\t\t[key: string]: GraphCheckpointJson;\n\t\t\t};\n\t\treturn out;\n\t}\n}\n\n/** Construct a Graph (default global dispatcher; L4-Q4). */\nexport function graph(opts: GraphOptions = {}): Graph {\n\treturn new Graph(opts);\n}\n\n/** @internal D122 graph-owned ephemeral node-group release. */\nexport function releaseGraphNodes(\n\tgraph: Graph,\n\tnodes: readonly Node<unknown>[],\n\topts: { reason?: string } = {},\n): void {\n\tconst registrar = lifecycleRegistrars.get(graph);\n\tif (registrar === undefined) throw new Error(\"graph: unknown lifecycle registrar\");\n\tregistrar.releaseNodes(nodes, opts);\n}\n\n/** @internal D94 descriptor path: register a restored state node without widening Graph. */\nexport function restoreStateNodeInGraph<T = unknown>(\n\tgraph: Graph,\n\tid: string,\n\topts: SugarOpts<T> = {},\n): StateNode<T> {\n\tconst registrar = restoreRegistrars.get(graph);\n\tif (registrar === undefined) throw new Error(\"restoreGraph: unknown graph restore registrar\");\n\treturn registrar.stateNode(id, opts);\n}\n\n/** @internal D94 descriptor path: register a restored ctx-level node without widening Graph. */\nexport function restoreNodeInGraph<T = unknown>(\n\tgraph: Graph,\n\tid: string,\n\tfactory: string,\n\tdeps: readonly Node<unknown>[],\n\tfn: NodeFn | null,\n\topts: SugarOpts<T> = {},\n): Node<T> {\n\tconst registrar = restoreRegistrars.get(graph);\n\tif (registrar === undefined) throw new Error(\"restoreGraph: unknown graph restore registrar\");\n\treturn registrar.node(id, factory, deps, fn, opts);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,0BAA0B;AAkEhC,SAAS,sBACf,MACA,QAAQ,QACR,OAAO,cACwC;AAC/C,MAAI;AACH,WAAO,uBAAuB,MAAM,KAAK;AAAA,EAC1C,SAAS,OAAO;AACf,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAM,IAAI,UAAU,GAAG,KAAK,KAAK,IAAI,gDAAgD,OAAO,EAAE;AAAA,EAC/F;AACD;AAEO,SAAS,kBACf,UACkC;AAClC,SAAO,0BAA0B,UAAmC,oBAAI,QAAgB,GAAG,GAAG;AAC/F;AAEA,SAAS,0BACR,UACA,MACA,MACkC;AAClC,MAAI,aAAa,QAAQ,OAAO,aAAa,UAAU;AACtD,UAAM,IAAI,UAAU,kCAAkC,IAAI,oBAAoB;AAAA,EAC/E;AACA,MAAI,KAAK,IAAI,QAAQ,GAAG;AACvB,UAAM,IAAI,UAAU,qDAAqD,IAAI,EAAE;AAAA,EAChF;AACA,OAAK,IAAI,QAAQ;AACjB,MAAI;AACH,UAAM,QAAQ,SAAS,SAAS,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,UAAU;AACxE,YAAM,WAAW,GAAG,IAAI,UAAU,KAAK;AACvC,2BAAqB,MAAM,QAAQ;AACnC,YAAM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AW,OAAM,IAAI,MAAM,+CAA+C;AAC5F,SAAO,UAAU,UAAU,IAAI,IAAI;AACpC;AAGO,SAAS,mBACfA,QACA,IACA,SACA,MACA,IACA,OAAqB,CAAC,GACZ;AACV,QAAM,YAAY,kBAAkB,IAAIA,MAAK;AAC7C,MAAI,cAAc,OAAW,OAAM,IAAI,MAAM,+CAA+C;AAC5F,SAAO,UAAU,KAAK,IAAI,SAAS,MAAM,IAAI,IAAI;AAClD;","names":["out","value","out","graph","graph"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/solutions/reactive-layout/segment.ts","../src/solutions/reactive-layout/utils.ts","../src/solutions/reactive-layout/adapters.ts","../src/solutions/reactive-layout/line.ts","../src/solutions/reactive-layout/types.ts","../src/solutions/reactive-layout/measurements.ts","../src/solutions/reactive-layout/block.ts","../src/solutions/reactive-layout/flow.ts","../src/solutions/reactive-layout/bundles.ts"],"sourcesContent":["import type { SegmentAdapter, SegmentBreakKind, SegmentInfo } from \"./types.js\";\n\nexport const kinsokuStart = /* @__PURE__ */ new Set([\n\t\"\\u3001\",\n\t\"\\u3002\",\n\t\"\\u30FB\",\n\t\"\\uFF09\",\n\t\"\\u3015\",\n\t\"\\u3009\",\n\t\"\\u300B\",\n\t\"\\u300D\",\n\t\"\\u300F\",\n\t\"\\u3011\",\n]);\n\nexport const leftStickyPunctuation = /* @__PURE__ */ new Set([\n\t\".\",\n\t\",\",\n\t\"!\",\n\t\"?\",\n\t\":\",\n\t\";\",\n\t\")\",\n\t\"]\",\n\t\"}\",\n\t\"%\",\n\t'\"',\n\t\"\\u201D\",\n\t\"\\u2019\",\n\t\"\\xBB\",\n\t\"\\u203A\",\n\t\"\\u2026\",\n]);\n\nexport function isCJK(text: string): boolean {\n\tfor (const ch of text) {\n\t\tconst c = ch.codePointAt(0);\n\t\tif (\n\t\t\t(c !== undefined && c >= 19968 && c <= 40959) ||\n\t\t\t(c !== undefined && c >= 13312 && c <= 19903) ||\n\t\t\t(c !== undefined && c >= 12288 && c <= 12351) ||\n\t\t\t(c !== undefined && c >= 12352 && c <= 12447) ||\n\t\t\t(c !== undefined && c >= 44032 && c <= 55215) ||\n\t\t\t(c !== undefined && c >= 65280 && c <= 65519)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nexport function normalizeWhitespace(text: string): string {\n\treturn text.replace(/[\\t\\f ]+/g, \" \").replace(/^ | $/g, \"\");\n}\n\nexport function segmentText(\n\ttext: string,\n\tsegmentAdapter: SegmentAdapter,\n): {\n\treadonly texts: string[];\n\treadonly isWordLike: boolean[];\n\treadonly kinds: SegmentBreakKind[];\n}[] {\n\tconst pieces: {\n\t\ttexts: string[];\n\t\tisWordLike: boolean[];\n\t\tkinds: SegmentBreakKind[];\n\t}[] = [];\n\tfor (const s of segmentAdapter.segmentWords(text)) {\n\t\tconst wordSegment = s.segment;\n\t\tconst rawWordLike = s.isWordLike ?? false;\n\t\tconst pieceTexts: string[] = [];\n\t\tconst pieceWordLikes: boolean[] = [];\n\t\tconst pieceKinds: SegmentBreakKind[] = [];\n\t\tlet currentText = \"\";\n\t\tlet currentKind: SegmentBreakKind | null = null;\n\t\tfor (const ch of wordSegment) {\n\t\t\tlet kind: SegmentBreakKind;\n\t\t\tif (ch === \" \") {\n\t\t\t\tkind = \"space\";\n\t\t\t} else if (ch === \"\\u200B\") {\n\t\t\t\tkind = \"zero-width-break\";\n\t\t\t} else if (ch === \"\\xAD\") {\n\t\t\t\tkind = \"soft-hyphen\";\n\t\t\t} else if (ch === \"\\n\") {\n\t\t\t\tkind = \"hard-break\";\n\t\t\t} else {\n\t\t\t\tkind = \"text\";\n\t\t\t}\n\t\t\tif (currentKind !== null && kind === currentKind) {\n\t\t\t\tcurrentText += ch;\n\t\t\t} else {\n\t\t\t\tif (currentKind !== null) {\n\t\t\t\t\tpieceTexts.push(currentText);\n\t\t\t\t\tpieceWordLikes.push(currentKind === \"text\" && rawWordLike);\n\t\t\t\t\tpieceKinds.push(currentKind);\n\t\t\t\t}\n\t\t\t\tcurrentText = ch;\n\t\t\t\tcurrentKind = kind;\n\t\t\t}\n\t\t}\n\t\tif (currentKind !== null) {\n\t\t\tpieceTexts.push(currentText);\n\t\t\tpieceWordLikes.push(currentKind === \"text\" && rawWordLike);\n\t\t\tpieceKinds.push(currentKind);\n\t\t}\n\t\tpieces.push({ texts: pieceTexts, isWordLike: pieceWordLikes, kinds: pieceKinds });\n\t}\n\treturn pieces;\n}\n\nfunction* fallbackSegmentWords(text: string): Iterable<SegmentInfo> {\n\tlet index = 0;\n\tlet current = \"\";\n\tlet currentIndex = 0;\n\tlet currentWordLike: boolean | null = null;\n\tconst flush = () => {\n\t\tif (current.length === 0 || currentWordLike === null) return undefined;\n\t\tconst out = { segment: current, index: currentIndex, isWordLike: currentWordLike };\n\t\tcurrent = \"\";\n\t\tcurrentWordLike = null;\n\t\treturn out;\n\t};\n\tfor (const ch of text) {\n\t\tconst isWordLike = !/[\\s\\u200B\\u00AD]/u.test(ch);\n\t\tif (currentWordLike !== null && currentWordLike !== isWordLike) {\n\t\t\tconst out = flush();\n\t\t\tif (out) yield out;\n\t\t}\n\t\tif (currentWordLike === null) {\n\t\t\tcurrentWordLike = isWordLike;\n\t\t\tcurrentIndex = index;\n\t\t}\n\t\tcurrent += ch;\n\t\tindex += ch.length;\n\t}\n\tconst out = flush();\n\tif (out) yield out;\n}\n\nfunction* fallbackSegmentGraphemes(text: string): Iterable<SegmentInfo> {\n\tlet index = 0;\n\tfor (const ch of text) {\n\t\tyield { segment: ch, index };\n\t\tindex += ch.length;\n\t}\n}\n\nexport function createDefaultSegmentAdapter(): SegmentAdapter {\n\treturn {\n\t\tsegmentWords(text: string): Iterable<SegmentInfo> {\n\t\t\treturn fallbackSegmentWords(text);\n\t\t},\n\t\tsegmentGraphemes(text: string): Iterable<SegmentInfo> {\n\t\t\treturn fallbackSegmentGraphemes(text);\n\t\t},\n\t};\n}\n\nlet defaultSegmentAdapter: SegmentAdapter | null = null;\n\nexport function getDefaultSegmentAdapter(): SegmentAdapter {\n\tif (defaultSegmentAdapter === null) {\n\t\tdefaultSegmentAdapter = createDefaultSegmentAdapter();\n\t}\n\treturn defaultSegmentAdapter;\n}\n\nexport function measuredWidth(value: number | { readonly width: number }): number {\n\tconst width = typeof value === \"number\" ? value : value.width;\n\treturn Number.isFinite(width) && width >= 0 ? width : 0;\n}\n\nexport function metricKey(text: string, font: string): string {\n\treturn `${font}\\0${text}`;\n}\n","import type { Ctx } from \"../../ctx/types.js\";\nimport { errorPayload } from \"../../protocol/messages.js\";\nimport type { MeasureBlockOptions, MeasurementAdapter, Size } from \"./types.js\";\n\nexport function nonNegativeFinite(value: number, fallback: number): number {\n\treturn Number.isFinite(value) ? Math.max(0, value) : fallback;\n}\n\nexport function finiteNumber(value: number, fallback: number): number {\n\treturn Number.isFinite(value) ? value : fallback;\n}\n\nexport function emitLayoutError(ctx: Ctx, error: unknown, fallback: string): void {\n\tctx.down([[\"ERROR\", errorPayload(error, fallback)]]);\n}\n\nexport function positiveFinite(value: number, fallback: number): number {\n\treturn Number.isFinite(value) && value > 0 ? value : fallback;\n}\n\nexport function clampDimension(value: number | undefined): number {\n\treturn nonNegativeFinite(value ?? 0, 0);\n}\n\nexport function fitSize(size: Size, maxWidth: number): Size {\n\tconst width = nonNegativeFinite(size.width, 0);\n\tconst height = nonNegativeFinite(size.height, 0);\n\tif (width === 0 || maxWidth <= 0 || width <= maxWidth) return { width, height };\n\tconst scale = maxWidth / width;\n\treturn { width: maxWidth, height: height * scale };\n}\n\nexport function blockMaxWidth(blockMaxWidth: number | undefined, maxWidth: number): number {\n\tconst own = blockMaxWidth === undefined ? maxWidth : nonNegativeFinite(blockMaxWidth, maxWidth);\n\tif (maxWidth <= 0) return own;\n\tif (own <= 0) return maxWidth;\n\treturn Math.min(own, maxWidth);\n}\n\nexport function resolveTextAdapter(opts: MeasureBlockOptions): MeasurementAdapter {\n\tconst adapter = opts.adapters?.text ?? opts.adapter;\n\tif (!adapter) throw new Error(\"Text blocks require a MeasurementAdapter\");\n\treturn adapter;\n}\n","import { isCJK, measuredWidth, metricKey } from \"./segment.js\";\nimport type {\n\tCellMeasureAdapterOptions,\n\tImageMeasurer,\n\tImageSizeLookup,\n\tInjectedMeasureAdapterOptions,\n\tMeasureFn,\n\tMeasurementAdapter,\n\tPrecomputedMeasureAdapterOptions,\n\tSize,\n\tSvgMeasurer,\n\tTextMeasureCapability,\n} from \"./types.js\";\nimport { nonNegativeFinite } from \"./utils.js\";\n\n/** Adapter that wraps a caller-owned synchronous measurement function. */\nexport class InjectedMeasureAdapter implements MeasurementAdapter {\n\tprivate readonly measure: MeasureFn;\n\tprivate readonly shouldCache: boolean;\n\tprivate readonly cache = new Map<string, number>();\n\n\tconstructor(measure: MeasureFn, opts: InjectedMeasureAdapterOptions = {}) {\n\t\tthis.measure = measure;\n\t\tthis.shouldCache = opts.cache ?? true;\n\t}\n\n\tmeasureSegment(text: string, font: string): { readonly width: number } {\n\t\tconst key = metricKey(text, font);\n\t\tif (this.shouldCache) {\n\t\t\tconst cached = this.cache.get(key);\n\t\t\tif (cached !== undefined) return { width: cached };\n\t\t}\n\t\tconst width = measuredWidth(this.measure(text, font));\n\t\tif (this.shouldCache) this.cache.set(key, width);\n\t\treturn { width };\n\t}\n\n\tclearCache(): void {\n\t\tthis.cache.clear();\n\t}\n}\n\n/** Deterministic adapter backed by caller-supplied width metrics. */\nexport class PrecomputedMeasureAdapter implements MeasurementAdapter {\n\tprivate readonly metrics: ReadonlyMap<string, number>;\n\tprivate readonly fallback: \"per-char\" | \"error\";\n\tprivate readonly cellWidth: number;\n\n\tconstructor(opts: PrecomputedMeasureAdapterOptions) {\n\t\tthis.metrics =\n\t\t\topts.metrics instanceof Map ? opts.metrics : new Map(Object.entries(opts.metrics));\n\t\tthis.fallback = opts.fallback ?? \"error\";\n\t\tthis.cellWidth = nonNegativeFinite(opts.cellWidth ?? 8, 8);\n\t}\n\n\tmeasureSegment(text: string, font: string): { readonly width: number } {\n\t\tconst fontScoped = this.metrics.get(metricKey(text, font));\n\t\tif (fontScoped !== undefined) return { width: nonNegativeFinite(fontScoped, 0) };\n\t\tconst unscoped = this.metrics.get(text);\n\t\tif (unscoped !== undefined) return { width: nonNegativeFinite(unscoped, 0) };\n\t\tif (this.fallback === \"per-char\") {\n\t\t\treturn { width: Array.from(text).length * this.cellWidth };\n\t\t}\n\t\tthrow new Error(`No precomputed metric for segment ${JSON.stringify(text)}`);\n\t}\n}\n\n/** Fixed-cell adapter for CLI, snapshots, and tests. */\nexport class CellMeasureAdapter implements MeasurementAdapter {\n\tprivate readonly cellWidth: number;\n\tprivate readonly wideCellWidth: number;\n\tprivate readonly tabCells: number;\n\n\tconstructor(opts: CellMeasureAdapterOptions = {}) {\n\t\tthis.cellWidth = nonNegativeFinite(opts.cellWidth ?? 8, 8);\n\t\tthis.wideCellWidth = nonNegativeFinite(\n\t\t\topts.wideCellWidth ?? this.cellWidth * 2,\n\t\t\tthis.cellWidth * 2,\n\t\t);\n\t\tthis.tabCells = Math.max(1, Math.floor(nonNegativeFinite(opts.tabCells ?? 4, 4)));\n\t}\n\n\tmeasureSegment(text: string): { readonly width: number } {\n\t\tlet width = 0;\n\t\tfor (const char of text) {\n\t\t\tif (char === \"\\t\") width += this.cellWidth * this.tabCells;\n\t\t\telse width += isCJK(char) ? this.wideCellWidth : this.cellWidth;\n\t\t}\n\t\treturn { width };\n\t}\n}\n\n/** Adapter over a caller-owned platform capability such as NodeCanvas, Skia, or RN text APIs. */\nexport class CapabilityMeasureAdapter implements MeasurementAdapter {\n\tprivate readonly capability: TextMeasureCapability;\n\n\tconstructor(capability: TextMeasureCapability) {\n\t\tthis.capability = capability;\n\t}\n\n\tmeasureSegment(text: string, font: string): { readonly width: number } {\n\t\treturn { width: measuredWidth(this.capability.measureText(text, font)) };\n\t}\n\n\tclearCache(): void {\n\t\tthis.capability.clearCache?.();\n\t}\n}\n\nfunction stripSvgIgnoredContent(svg: string): string {\n\treturn svg.replace(/<!--[\\s\\S]*?-->/g, \"\").replace(/<!\\[CDATA\\[[\\s\\S]*?\\]\\]>/g, \"\");\n}\n\nfunction readSvgRootTag(svg: string): string | null {\n\treturn /<svg\\b[^>]*>/i.exec(svg)?.[0] ?? null;\n}\n\nfunction readNumericAttr(tag: string, attr: string): number | null {\n\tconst pattern = new RegExp(`(?:^|\\\\s)${attr}\\\\s*=\\\\s*[\"']?(-?\\\\d+(?:\\\\.\\\\d+)?)`, \"i\");\n\tconst match = pattern.exec(tag);\n\tif (!match) return null;\n\tconst value = Number(match[1]);\n\treturn Number.isFinite(value) && value >= 0 ? value : null;\n}\n\nfunction readViewBox(tag: string): Size | null {\n\tconst match =\n\t\t/\\bviewBox\\s*=\\s*[\"']\\s*(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s*[\"']/i.exec(\n\t\t\ttag,\n\t\t);\n\tif (!match) return null;\n\tconst width = Number(match[3]);\n\tconst height = Number(match[4]);\n\tif (!Number.isFinite(width) || !Number.isFinite(height) || width < 0 || height < 0) {\n\t\treturn null;\n\t}\n\treturn { width, height };\n}\n\n/**\n * Minimal string-based SVG bounds reader for explicit width/height or viewBox.\n *\n * This is not a DOM SVG parser and does not resolve external resources.\n */\nexport class SvgBoundsAdapter implements SvgMeasurer {\n\tmeasureSvg(svg: string): Size {\n\t\tconst cleaned = stripSvgIgnoredContent(svg);\n\t\tconst rootTag = readSvgRootTag(cleaned);\n\t\tif (rootTag === null) throw new Error(\"Cannot measure SVG without a root <svg> element\");\n\t\tconst width = readNumericAttr(rootTag, \"width\");\n\t\tconst height = readNumericAttr(rootTag, \"height\");\n\t\tif (width !== null && height !== null) return { width, height };\n\t\tconst viewBox = readViewBox(rootTag);\n\t\tif (viewBox) return viewBox;\n\t\tthrow new Error(\"Cannot measure SVG without width/height or viewBox\");\n\t}\n}\n\n/** Image measurer backed by explicit caller-provided dimensions; it never loads images. */\nexport class ImageSizeAdapter implements ImageMeasurer {\n\tprivate readonly sizes: ImageSizeLookup;\n\n\tconstructor(sizes: ImageSizeLookup | Record<string, Size>) {\n\t\tthis.sizes = isImageSizeLookup(sizes) ? sizes : new Map(Object.entries(sizes));\n\t}\n\n\tmeasureImage(src: string): Size {\n\t\tconst size = this.sizes.get(src);\n\t\tif (!size) throw new Error(`No image size registered for ${JSON.stringify(src)}`);\n\t\treturn size;\n\t}\n}\n\nfunction isImageSizeLookup(value: unknown): value is ImageSizeLookup {\n\tif (value === null) return false;\n\tconst valueType = typeof value;\n\tif (valueType !== \"object\" && valueType !== \"function\") return false;\n\treturn typeof (value as { readonly get?: unknown }).get === \"function\";\n}\n","import {\n\tgetDefaultSegmentAdapter,\n\tisCJK,\n\tkinsokuStart,\n\tleftStickyPunctuation,\n\tnormalizeWhitespace,\n\tsegmentText,\n} from \"./segment.js\";\nimport type {\n\tCharPosition,\n\tInterval,\n\tLayoutCursor,\n\tLayoutLine,\n\tLayoutNextLineContext,\n\tLayoutNextLineResult,\n\tLineBreaksResult,\n\tMeasurementAdapter,\n\tPreparedSegment,\n\tSegmentAdapter,\n\tSegmentBreakKind,\n\tSegmentMeasureStats,\n} from \"./types.js\";\nimport { nonNegativeFinite } from \"./utils.js\";\n\n/** Segment text and measure every resulting segment with a caller-owned synchronous adapter. */\nexport function analyzeAndMeasure(\n\ttext: string,\n\tfont: string,\n\tadapter: MeasurementAdapter,\n\tcache: Map<string, Map<string, number>>,\n\tstats?: SegmentMeasureStats,\n\tsegmentAdapter?: SegmentAdapter,\n): PreparedSegment[] {\n\tconst normalized = normalizeWhitespace(text);\n\tif (normalized.length === 0) {\n\t\treturn [];\n\t}\n\tconst segAdapter = segmentAdapter ?? getDefaultSegmentAdapter();\n\tconst pieces = segmentText(normalized, segAdapter);\n\tconst rawTexts: string[] = [];\n\tconst rawKinds: SegmentBreakKind[] = [];\n\tconst rawWordLike: boolean[] = [];\n\tfor (const piece of pieces) {\n\t\tfor (let i = 0; i < piece.texts.length; i += 1) {\n\t\t\trawTexts.push(piece.texts[i]);\n\t\t\trawKinds.push(piece.kinds[i]);\n\t\t\trawWordLike.push(piece.isWordLike[i]);\n\t\t}\n\t}\n\tconst mergedTexts: string[] = [];\n\tconst mergedKinds: SegmentBreakKind[] = [];\n\tconst mergedWordLike: boolean[] = [];\n\tfor (let i = 0; i < rawTexts.length; i += 1) {\n\t\tconst t = rawTexts[i];\n\t\tconst k = rawKinds[i];\n\t\tconst wl = rawWordLike[i];\n\t\tif (\n\t\t\tk === \"text\" &&\n\t\t\t!wl &&\n\t\t\tmergedTexts.length > 0 &&\n\t\t\tmergedKinds[mergedTexts.length - 1] === \"text\"\n\t\t) {\n\t\t\tconst isSticky = t.length === 1 && (leftStickyPunctuation.has(t) || kinsokuStart.has(t));\n\t\t\tif (isSticky) {\n\t\t\t\tmergedTexts[mergedTexts.length - 1] += t;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tt === \"-\" &&\n\t\t\tmergedTexts.length > 0 &&\n\t\t\tmergedKinds[mergedKinds.length - 1] === \"text\" &&\n\t\t\tmergedWordLike[mergedWordLike.length - 1]\n\t\t) {\n\t\t\tmergedTexts[mergedTexts.length - 1] += t;\n\t\t\tcontinue;\n\t\t}\n\t\tmergedTexts.push(t);\n\t\tmergedKinds.push(k);\n\t\tmergedWordLike.push(wl);\n\t}\n\tconst fontCache = cache.get(font) ?? new Map<string, number>();\n\tif (!cache.has(font)) cache.set(font, fontCache);\n\tfunction measureCached(segment: string): number {\n\t\tconst cached = fontCache.get(segment);\n\t\tif (cached === undefined) {\n\t\t\tif (stats) stats.misses += 1;\n\t\t\tconst measured = adapter.measureSegment(segment, font).width;\n\t\t\tconst width = Number.isFinite(measured) && measured >= 0 ? measured : 0;\n\t\t\tfontCache.set(segment, width);\n\t\t\treturn width;\n\t\t}\n\t\tif (stats) stats.hits += 1;\n\t\treturn cached;\n\t}\n\tconst out: PreparedSegment[] = [];\n\tfor (let i = 0; i < mergedTexts.length; i += 1) {\n\t\tconst t = mergedTexts[i];\n\t\tconst kind = mergedKinds[i];\n\t\tif (kind !== \"text\") {\n\t\t\tout.push({\n\t\t\t\ttext: t,\n\t\t\t\twidth: kind === \"space\" ? measureCached(\" \") * t.length : 0,\n\t\t\t\tkind,\n\t\t\t\tgraphemeWidths: null,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (isCJK(t)) {\n\t\t\tlet unitText = \"\";\n\t\t\tfor (const graphemeSegment of segAdapter.segmentGraphemes(t)) {\n\t\t\t\tconst grapheme = graphemeSegment.segment;\n\t\t\t\tif (unitText.length > 0 && kinsokuStart.has(grapheme)) {\n\t\t\t\t\tunitText += grapheme;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (unitText.length > 0) {\n\t\t\t\t\tout.push({\n\t\t\t\t\t\ttext: unitText,\n\t\t\t\t\t\twidth: measureCached(unitText),\n\t\t\t\t\t\tkind: \"text\",\n\t\t\t\t\t\tgraphemeWidths: null,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tunitText = grapheme;\n\t\t\t}\n\t\t\tif (unitText.length > 0) {\n\t\t\t\tout.push({\n\t\t\t\t\ttext: unitText,\n\t\t\t\t\twidth: measureCached(unitText),\n\t\t\t\t\tkind: \"text\",\n\t\t\t\t\tgraphemeWidths: null,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst textWidth = measureCached(t);\n\t\tlet graphemeWidths: number[] | null = null;\n\t\tif (mergedWordLike[i] && t.length > 1) {\n\t\t\tconst widths = [];\n\t\t\tfor (const grapheme of segAdapter.segmentGraphemes(t)) {\n\t\t\t\twidths.push(measureCached(grapheme.segment));\n\t\t\t}\n\t\t\tif (widths.length > 1) graphemeWidths = widths;\n\t\t}\n\t\tout.push({\n\t\t\ttext: t,\n\t\t\twidth: textWidth,\n\t\t\tkind: \"text\",\n\t\t\tgraphemeWidths,\n\t\t});\n\t}\n\treturn out;\n}\n\n/** Greedy single-column line breaking over prepared segments. */\nexport function computeLineBreaks(\n\tsegments: readonly PreparedSegment[],\n\tmaxWidth: number,\n\topts: { readonly hyphenWidth?: number; readonly segmentAdapter?: SegmentAdapter } = {},\n): LineBreaksResult {\n\tif (segments.length === 0) return { lines: [], lineCount: 0 };\n\tconst segAdapter = opts.segmentAdapter ?? getDefaultSegmentAdapter();\n\tconst lines: LayoutLine[] = [];\n\tlet cursor: LayoutCursor = { segmentIndex: 0, graphemeIndex: 0 };\n\twhile (cursor.segmentIndex < segments.length) {\n\t\tconst next = layoutNextLine(segments, cursor, maxWidth, {\n\t\t\thyphenWidth: opts.hyphenWidth,\n\t\t\tsegmentAdapter: segAdapter,\n\t\t});\n\t\tif (next === null) break;\n\t\tlines.push({\n\t\t\ttext: next.text,\n\t\t\twidth: next.width,\n\t\t\tstartSegment: next.start.segmentIndex,\n\t\t\tstartGrapheme: next.start.graphemeIndex,\n\t\t\tendSegment: next.end.segmentIndex,\n\t\t\tendGrapheme: next.end.graphemeIndex,\n\t\t});\n\t\tif (\n\t\t\tnext.end.segmentIndex === cursor.segmentIndex &&\n\t\t\tnext.end.graphemeIndex === cursor.graphemeIndex\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tcursor = next.end;\n\t}\n\treturn { lines, lineCount: lines.length };\n}\n\nfunction canBreakAfter(kind: SegmentBreakKind): boolean {\n\treturn kind === \"space\" || kind === \"zero-width-break\" || kind === \"soft-hyphen\";\n}\n\nfunction sliceSegmentText(\n\tseg: PreparedSegment,\n\tstartGrapheme: number,\n\tendGrapheme: number,\n\tsegmentAdapter: SegmentAdapter,\n): string {\n\tif (startGrapheme === 0 && endGrapheme < 0) return seg.text;\n\tconst graphemes = [...segmentAdapter.segmentGraphemes(seg.text)].map((g) => g.segment);\n\tconst stop = endGrapheme < 0 ? graphemes.length : endGrapheme;\n\treturn graphemes.slice(startGrapheme, stop).join(\"\");\n}\n\nfunction buildLineText(\n\tsegments: readonly PreparedSegment[],\n\tstartSegment: number,\n\tstartGrapheme: number,\n\tendSegment: number,\n\tendGrapheme: number,\n\tappendHyphen: boolean,\n\tsegmentAdapter: SegmentAdapter,\n): string {\n\tlet text = \"\";\n\tfor (let i = startSegment; i < endSegment; i += 1) {\n\t\tconst seg = segments[i];\n\t\tif (seg.kind === \"soft-hyphen\" || seg.kind === \"hard-break\") continue;\n\t\tif (i === startSegment && startGrapheme > 0) {\n\t\t\ttext += sliceSegmentText(seg, startGrapheme, -1, segmentAdapter);\n\t\t} else {\n\t\t\ttext += seg.text;\n\t\t}\n\t}\n\tif (endGrapheme > 0 && endSegment < segments.length) {\n\t\tconst seg = segments[endSegment];\n\t\tconst from = startSegment === endSegment ? startGrapheme : 0;\n\t\ttext += sliceSegmentText(seg, from, endGrapheme, segmentAdapter);\n\t}\n\tif (appendHyphen) text += \"-\";\n\treturn text;\n}\n\nfunction resolveHyphenWidth(ctx: LayoutNextLineContext | undefined): number {\n\tif (ctx?.hyphenWidth !== undefined) return nonNegativeFinite(ctx.hyphenWidth, 0);\n\tif (ctx?.adapter === undefined || ctx.font === undefined) return 0;\n\tconst cache = ctx.cache;\n\tif (cache) {\n\t\tlet fontCache = cache.get(ctx.font);\n\t\tif (fontCache === undefined) {\n\t\t\tfontCache = new Map();\n\t\t\tcache.set(ctx.font, fontCache);\n\t\t}\n\t\tlet width = fontCache.get(\"-\");\n\t\tif (width === undefined) {\n\t\t\twidth = ctx.adapter.measureSegment(\"-\", ctx.font).width;\n\t\t\tfontCache.set(\"-\", width);\n\t\t}\n\t\treturn width;\n\t}\n\treturn ctx.adapter.measureSegment(\"-\", ctx.font).width;\n}\n\n/** Lay out one line from a cursor, returning the next cursor for continuation. */\nexport function layoutNextLine(\n\tsegments: readonly PreparedSegment[],\n\tcursor: LayoutCursor,\n\tslotWidth: number,\n\tctx?: LayoutNextLineContext,\n): LayoutNextLineResult | null {\n\tlet i = cursor.segmentIndex;\n\tconst initialGrapheme = cursor.graphemeIndex;\n\tconst segmentAdapter = ctx?.segmentAdapter ?? getDefaultSegmentAdapter();\n\tif (i >= segments.length) return null;\n\tif (initialGrapheme === 0) {\n\t\twhile (i < segments.length) {\n\t\t\tconst seg = segments[i];\n\t\t\tif (seg.kind === \"hard-break\") {\n\t\t\t\treturn {\n\t\t\t\t\ttext: \"\",\n\t\t\t\t\twidth: 0,\n\t\t\t\t\tstart: { segmentIndex: cursor.segmentIndex, graphemeIndex: 0 },\n\t\t\t\t\tend: { segmentIndex: i + 1, graphemeIndex: 0 },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (seg.kind === \"space\" || seg.kind === \"zero-width-break\" || seg.kind === \"soft-hyphen\") {\n\t\t\t\ti += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (i >= segments.length) return null;\n\t}\n\tconst hyphenWidth = resolveHyphenWidth(ctx);\n\tconst startSegment = i;\n\tconst startGrapheme = i === cursor.segmentIndex ? initialGrapheme : 0;\n\tlet lineW = 0;\n\tlet lineEndSegment = startSegment;\n\tlet lineEndGrapheme = 0;\n\tlet hasContent = false;\n\tlet pendingBreakSegment = -1;\n\tlet pendingBreakGrapheme = 0;\n\tlet pendingBreakWidth = 0;\n\tlet pendingBreakSoftHyphen = false;\n\tconst recordPending = (\n\t\tsIdx: number,\n\t\tgIdx: number,\n\t\twidth: number,\n\t\tkind: SegmentBreakKind,\n\t): void => {\n\t\tpendingBreakSegment = sIdx;\n\t\tpendingBreakGrapheme = gIdx;\n\t\tpendingBreakWidth = width;\n\t\tpendingBreakSoftHyphen = kind === \"soft-hyphen\";\n\t};\n\tconst consumeBreakable = (segIdx: number, startG: number, widths: readonly number[]): boolean => {\n\t\tfor (let g = startG; g < widths.length; g += 1) {\n\t\t\tconst gw = widths[g];\n\t\t\tif (!hasContent) {\n\t\t\t\tlineW = gw;\n\t\t\t\tlineEndSegment = segIdx;\n\t\t\t\tlineEndGrapheme = g + 1;\n\t\t\t\thasContent = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (lineW + gw > slotWidth + 1e-3) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tlineW += gw;\n\t\t\tlineEndSegment = segIdx;\n\t\t\tlineEndGrapheme = g + 1;\n\t\t}\n\t\tif (lineEndSegment === segIdx && lineEndGrapheme === widths.length) {\n\t\t\tlineEndSegment = segIdx + 1;\n\t\t\tlineEndGrapheme = 0;\n\t\t}\n\t\treturn false;\n\t};\n\tif (startGrapheme > 0 && startSegment < segments.length) {\n\t\tconst seg = segments[startSegment];\n\t\tif (seg.graphemeWidths) {\n\t\t\tconst overflow = consumeBreakable(startSegment, startGrapheme, seg.graphemeWidths);\n\t\t\tif (overflow) {\n\t\t\t\tconst text = buildLineText(\n\t\t\t\t\tsegments,\n\t\t\t\t\tstartSegment,\n\t\t\t\t\tstartGrapheme,\n\t\t\t\t\tlineEndSegment,\n\t\t\t\t\tlineEndGrapheme,\n\t\t\t\t\tfalse,\n\t\t\t\t\tsegmentAdapter,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\ttext,\n\t\t\t\t\twidth: lineW,\n\t\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\t\tend: { segmentIndex: lineEndSegment, graphemeIndex: lineEndGrapheme },\n\t\t\t\t};\n\t\t\t}\n\t\t\ti = lineEndSegment;\n\t\t}\n\t}\n\tfor (; i < segments.length; i += 1) {\n\t\tconst seg = segments[i];\n\t\tif (seg.kind === \"hard-break\") {\n\t\t\tif (hasContent) {\n\t\t\t\tconst endsAtSoftHyphen =\n\t\t\t\t\tlineEndSegment > 0 && segments[lineEndSegment - 1]?.kind === \"soft-hyphen\";\n\t\t\t\tconst text = buildLineText(\n\t\t\t\t\tsegments,\n\t\t\t\t\tstartSegment,\n\t\t\t\t\tstartGrapheme,\n\t\t\t\t\tlineEndSegment,\n\t\t\t\t\tlineEndGrapheme,\n\t\t\t\t\tendsAtSoftHyphen,\n\t\t\t\t\tsegmentAdapter,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\ttext,\n\t\t\t\t\twidth: lineW + (endsAtSoftHyphen ? hyphenWidth : 0),\n\t\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\t\tend: { segmentIndex: i + 1, graphemeIndex: 0 },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttext: \"\",\n\t\t\t\twidth: 0,\n\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\tend: { segmentIndex: i + 1, graphemeIndex: 0 },\n\t\t\t};\n\t\t}\n\t\tconst w = seg.width;\n\t\tif (!hasContent) {\n\t\t\tif (w > slotWidth && seg.graphemeWidths) {\n\t\t\t\tconst overflow = consumeBreakable(i, 0, seg.graphemeWidths);\n\t\t\t\tif (overflow) {\n\t\t\t\t\tconst text = buildLineText(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tstartSegment,\n\t\t\t\t\t\tstartGrapheme,\n\t\t\t\t\t\tlineEndSegment,\n\t\t\t\t\t\tlineEndGrapheme,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tsegmentAdapter,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\twidth: lineW,\n\t\t\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\t\t\tend: { segmentIndex: lineEndSegment, graphemeIndex: lineEndGrapheme },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\ti = lineEndSegment - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlineW = w;\n\t\t\tlineEndSegment = i + 1;\n\t\t\tlineEndGrapheme = 0;\n\t\t\thasContent = true;\n\t\t\tif (canBreakAfter(seg.kind)) {\n\t\t\t\trecordPending(i + 1, 0, seg.kind === \"space\" ? lineW - w : lineW, seg.kind);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst projectedWidth = lineW + w;\n\t\tif (projectedWidth > slotWidth + 1e-3) {\n\t\t\tif (canBreakAfter(seg.kind)) {\n\t\t\t\tlineEndSegment = i + 1;\n\t\t\t\tlineEndGrapheme = 0;\n\t\t\t\tconst endsAtSoftHyphen = seg.kind === \"soft-hyphen\";\n\t\t\t\tconst text = buildLineText(\n\t\t\t\t\tsegments,\n\t\t\t\t\tstartSegment,\n\t\t\t\t\tstartGrapheme,\n\t\t\t\t\tlineEndSegment,\n\t\t\t\t\tlineEndGrapheme,\n\t\t\t\t\tendsAtSoftHyphen,\n\t\t\t\t\tsegmentAdapter,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\ttext,\n\t\t\t\t\twidth: seg.kind === \"space\" ? lineW : lineW + (endsAtSoftHyphen ? hyphenWidth : 0),\n\t\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\t\tend: { segmentIndex: lineEndSegment, graphemeIndex: lineEndGrapheme },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (pendingBreakSegment >= 0) {\n\t\t\t\tconst text = buildLineText(\n\t\t\t\t\tsegments,\n\t\t\t\t\tstartSegment,\n\t\t\t\t\tstartGrapheme,\n\t\t\t\t\tpendingBreakSegment,\n\t\t\t\t\tpendingBreakGrapheme,\n\t\t\t\t\tpendingBreakSoftHyphen,\n\t\t\t\t\tsegmentAdapter,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\ttext,\n\t\t\t\t\twidth: pendingBreakWidth + (pendingBreakSoftHyphen ? hyphenWidth : 0),\n\t\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\t\tend: { segmentIndex: pendingBreakSegment, graphemeIndex: pendingBreakGrapheme },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (w > slotWidth && seg.graphemeWidths) {\n\t\t\t\tconst text = buildLineText(\n\t\t\t\t\tsegments,\n\t\t\t\t\tstartSegment,\n\t\t\t\t\tstartGrapheme,\n\t\t\t\t\tlineEndSegment,\n\t\t\t\t\tlineEndGrapheme,\n\t\t\t\t\tfalse,\n\t\t\t\t\tsegmentAdapter,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\ttext,\n\t\t\t\t\twidth: lineW,\n\t\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\t\tend: { segmentIndex: lineEndSegment, graphemeIndex: lineEndGrapheme },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst text = buildLineText(\n\t\t\t\tsegments,\n\t\t\t\tstartSegment,\n\t\t\t\tstartGrapheme,\n\t\t\t\tlineEndSegment,\n\t\t\t\tlineEndGrapheme,\n\t\t\t\tfalse,\n\t\t\t\tsegmentAdapter,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\ttext,\n\t\t\t\twidth: lineW,\n\t\t\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\t\t\tend: { segmentIndex: lineEndSegment, graphemeIndex: lineEndGrapheme },\n\t\t\t};\n\t\t}\n\t\tlineW = projectedWidth;\n\t\tlineEndSegment = i + 1;\n\t\tlineEndGrapheme = 0;\n\t\tif (canBreakAfter(seg.kind)) {\n\t\t\trecordPending(i + 1, 0, seg.kind === \"space\" ? lineW - w : lineW, seg.kind);\n\t\t}\n\t}\n\tif (!hasContent) return null;\n\tconst endsAtSoftHyphen =\n\t\tlineEndSegment > 0 && segments[lineEndSegment - 1]?.kind === \"soft-hyphen\";\n\tconst text = buildLineText(\n\t\tsegments,\n\t\tstartSegment,\n\t\tstartGrapheme,\n\t\tlineEndSegment,\n\t\tlineEndGrapheme,\n\t\tendsAtSoftHyphen,\n\t\tsegmentAdapter,\n\t);\n\treturn {\n\t\ttext,\n\t\twidth: lineW + (endsAtSoftHyphen ? hyphenWidth : 0),\n\t\tstart: { segmentIndex: startSegment, graphemeIndex: startGrapheme },\n\t\tend: { segmentIndex: lineEndSegment, graphemeIndex: lineEndGrapheme },\n\t};\n}\n\n/** Subtract obstacle intervals from a horizontal text band. */\nexport function carveTextLineSlots(\n\tbase: Interval,\n\tblocked: readonly Interval[],\n\tminSlotWidth = 0,\n): Interval[] {\n\tlet slots: Interval[] = [base];\n\tfor (const block of blocked) {\n\t\tconst next: Interval[] = [];\n\t\tfor (const slot of slots) {\n\t\t\tif (block.right <= slot.left || block.left >= slot.right) {\n\t\t\t\tnext.push(slot);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.left > slot.left) next.push({ left: slot.left, right: block.left });\n\t\t\tif (block.right < slot.right) next.push({ left: block.right, right: slot.right });\n\t\t}\n\t\tslots = next;\n\t}\n\tif (minSlotWidth > 0) return slots.filter((slot) => slot.right - slot.left >= minSlotWidth);\n\treturn slots;\n}\n\n/** Compute per-grapheme boxes for already-broken lines. */\nexport function computeCharPositions(\n\tlineBreaks: LineBreaksResult,\n\tsegments: readonly PreparedSegment[],\n\tlineHeight: number,\n\tsegmentAdapter?: SegmentAdapter,\n): readonly CharPosition[] {\n\tconst positions: CharPosition[] = [];\n\tconst segAdapter = segmentAdapter ?? getDefaultSegmentAdapter();\n\tfor (let lineIdx = 0; lineIdx < lineBreaks.lines.length; lineIdx += 1) {\n\t\tconst line = lineBreaks.lines[lineIdx];\n\t\tconst y = lineIdx * lineHeight;\n\t\tlet x = 0;\n\t\tfor (let si = line.startSegment; si < segments.length; si += 1) {\n\t\t\tconst seg = segments[si];\n\t\t\tif (seg.kind === \"soft-hyphen\" || seg.kind === \"hard-break\") {\n\t\t\t\tif (si >= line.endSegment && line.endGrapheme === 0) break;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst graphemes = [...segAdapter.segmentGraphemes(seg.text)].map((g) => g.segment);\n\t\t\tif (graphemes.length === 0) continue;\n\t\t\tconst startGrapheme = si === line.startSegment ? line.startGrapheme : 0;\n\t\t\tlet endGrapheme: number;\n\t\t\tif (si < line.endSegment) {\n\t\t\t\tendGrapheme = graphemes.length;\n\t\t\t} else if (si === line.endSegment && line.endGrapheme > 0) {\n\t\t\t\tendGrapheme = line.endGrapheme;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (let g = startGrapheme; g < endGrapheme; g += 1) {\n\t\t\t\tconst width = seg.graphemeWidths ? seg.graphemeWidths[g] : seg.width / graphemes.length;\n\t\t\t\tpositions.push({ x, y, width, height: lineHeight, line: lineIdx });\n\t\t\t\tx += width;\n\t\t\t}\n\t\t}\n\t}\n\treturn positions;\n}\n","import type { DataIssue } from \"../../data/index.js\";\nimport type { Graph } from \"../../graph/graph.js\";\nimport type { Node } from \"../../node/node.js\";\n\n/**\n * Synchronous text measurement contract for the D181 reactive-layout solution core.\n *\n * Implementations are injected by the caller; the universal subpath never imports DOM,\n * Canvas, React Native, storage, GraphSpec, or async image loading.\n */\nexport interface MeasurementAdapter {\n\tmeasureSegment(text: string, font: string): { readonly width: number };\n\tclearCache?(): void;\n}\n\n/** Caller-owned platform text capability, for NodeCanvas/Skia/RN-style wrappers. */\nexport interface TextMeasureCapability {\n\tmeasureText(text: string, font: string): number | { readonly width: number };\n\tclearCache?(): void;\n}\n\n/** One text segment returned by a caller-provided segmenter. */\nexport interface SegmentInfo {\n\treadonly segment: string;\n\treadonly index: number;\n\treadonly isWordLike?: boolean;\n}\n\n/** Synchronous word/grapheme segmentation contract for hosts without Intl.Segmenter. */\nexport interface SegmentAdapter {\n\tsegmentWords(text: string): Iterable<SegmentInfo>;\n\tsegmentGraphemes(text: string): Iterable<SegmentInfo>;\n}\n\n/** Layout segment class used by the line breaker. */\nexport type SegmentBreakKind = \"text\" | \"space\" | \"zero-width-break\" | \"soft-hyphen\" | \"hard-break\";\n\n/** Measured text run consumed by pure line/block/flow helpers. */\nexport interface PreparedSegment {\n\treadonly text: string;\n\treadonly width: number;\n\treadonly kind: SegmentBreakKind;\n\treadonly graphemeWidths: readonly number[] | null;\n}\n\n/** One laid-out line with segment/grapheme cursor bounds. */\nexport interface LayoutLine {\n\treadonly text: string;\n\treadonly width: number;\n\treadonly startSegment: number;\n\treadonly startGrapheme: number;\n\treadonly endSegment: number;\n\treadonly endGrapheme: number;\n}\n\n/** Positioned grapheme box for hit testing or custom renderers. */\nexport interface CharPosition {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly width: number;\n\treadonly height: number;\n\treadonly line: number;\n}\n\n/** Result emitted by `reactiveLayout().lineBreaks`. */\nexport interface LineBreaksResult {\n\treadonly lines: readonly LayoutLine[];\n\treadonly lineCount: number;\n}\n\n/** Cursor into a prepared segment array. */\nexport interface LayoutCursor {\n\treadonly segmentIndex: number;\n\treadonly graphemeIndex: number;\n}\n\n/** Pure helper result for one `layoutNextLine` step. */\nexport interface LayoutNextLineResult {\n\treadonly text: string;\n\treadonly width: number;\n\treadonly start: LayoutCursor;\n\treadonly end: LayoutCursor;\n}\n\n/** Horizontal interval used by obstacle carving. */\nexport interface Interval {\n\treadonly left: number;\n\treadonly right: number;\n}\n\nexport const TEXT_SEGMENTS_MEASUREMENT_KIND = \"text-segments\";\nexport const BLOCKS_MEASUREMENT_KIND = \"blocks\";\n/** Measurement kind for standalone readiness facts. */\nexport const READINESS_MEASUREMENT_KIND = \"readiness\";\n/** Measurement kind for standalone image-size facts. */\nexport const IMAGE_SIZE_MEASUREMENT_KIND = \"image-size\";\n/** Measurement kind for standalone SVG-bounds facts. */\nexport const SVG_BOUNDS_MEASUREMENT_KIND = \"svg-bounds\";\n\nexport interface TextSegmentsMeasurement {\n\treadonly segments: readonly PreparedSegment[];\n\treadonly hyphenWidth?: number;\n}\n\nexport interface BlocksMeasurement {\n\treadonly blocks: readonly MeasuredBlock[];\n}\n\nexport interface MeasurementResult<T = unknown> {\n\treadonly kind: \"ok\";\n\treadonly targetId: string;\n\treadonly measurementKind: string;\n\treadonly value: T;\n\treadonly source?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport interface MeasurementIssue extends DataIssue {\n\treadonly subjectId: string;\n\treadonly measurementKind: string;\n}\n\nexport type MeasurementFact<T = unknown> = MeasurementResult<T> | MeasurementIssue;\n\nexport type Measurements = readonly MeasurementFact[];\n\nexport interface MergeMeasurementsOptions {\n\treadonly graph: Graph;\n\treadonly sources: readonly Node<Measurements>[];\n\treadonly name?: string;\n}\n\nexport interface TextMeasurementProviderOptions {\n\treadonly graph: Graph;\n\treadonly text: Node<string>;\n\treadonly font: Node<string>;\n\treadonly adapter: Node<MeasurementAdapter>;\n\treadonly segmentAdapter?: Node<SegmentAdapter>;\n\treadonly targetId?: string;\n\treadonly source?: string;\n\treadonly name?: string;\n}\n\nexport interface InjectedTextMeasurementsOptions\n\textends Omit<TextMeasurementProviderOptions, \"adapter\"> {\n\treadonly measure: MeasureFn;\n\treadonly cache?: boolean;\n}\n\nexport interface PrecomputedTextMeasurementsOptions\n\textends Omit<TextMeasurementProviderOptions, \"adapter\">,\n\t\tPrecomputedMeasureAdapterOptions {}\n\nexport interface CellTextMeasurementsOptions\n\textends Omit<TextMeasurementProviderOptions, \"adapter\">,\n\t\tCellMeasureAdapterOptions {}\n\nexport interface CapabilityTextMeasurementsOptions\n\textends Omit<TextMeasurementProviderOptions, \"adapter\"> {\n\treadonly capability: Node<TextMeasureCapability>;\n}\n\nexport interface MeasurementReadiness {\n\treadonly ready: boolean;\n\treadonly code?: string;\n\treadonly message?: string;\n\treadonly source?: string;\n\treadonly details?: unknown;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Options for projecting readiness into graph-visible measurement facts. */\nexport interface ReadinessMeasurementsOptions {\n\treadonly graph: Graph;\n\treadonly readiness: Node<MeasurementReadiness>;\n\treadonly targetId?: string;\n\treadonly measurementKind?: string;\n\treadonly source?: string;\n\treadonly name?: string;\n}\n\nexport interface ReadinessTextMeasurementsOptions extends TextMeasurementProviderOptions {\n\treadonly readiness: Node<MeasurementReadiness>;\n}\n\n/** Minimal caller-owned lookup for explicit image sizes. */\nexport interface ImageSizeLookup {\n\tget(src: string): Size | undefined;\n}\n\n/** One image-size fact target for `imageSizeMeasurements`. */\nexport interface ImageSizeMeasurementTarget {\n\treadonly id?: string;\n\treadonly src: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Options for projecting image-size facts from a caller-owned synchronous measurer. */\nexport interface ImageSizeMeasurementsOptions {\n\treadonly graph: Graph;\n\treadonly images: Node<readonly ImageSizeMeasurementTarget[]>;\n\treadonly measurer: Node<ImageMeasurer>;\n\treadonly measurementKind?: string;\n\treadonly source?: string;\n\treadonly name?: string;\n}\n\n/** One SVG-bounds fact target for `svgBoundsMeasurements`. */\nexport interface SvgBoundsMeasurementTarget {\n\treadonly id?: string;\n\treadonly svg: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Options for projecting SVG bounds from a caller-owned synchronous measurer. */\nexport interface SvgBoundsMeasurementsOptions {\n\treadonly graph: Graph;\n\treadonly svgs: Node<readonly SvgBoundsMeasurementTarget[]>;\n\treadonly measurer: Node<SvgMeasurer>;\n\treadonly measurementKind?: string;\n\treadonly source?: string;\n\treadonly name?: string;\n}\n\nexport interface BlockMeasurementProviderOptions {\n\treadonly graph: Graph;\n\treadonly blocks: Node<readonly ContentBlock[]>;\n\treadonly maxWidth: Node<number>;\n\treadonly adapters: Node<BlockAdapters>;\n\treadonly segmentAdapter?: Node<SegmentAdapter>;\n\treadonly font?: Node<string>;\n\treadonly lineHeight?: Node<number>;\n\treadonly targetId?: string;\n\treadonly source?: string;\n\treadonly name?: string;\n}\n\nexport interface BlockAdaptersProviderOptions {\n\treadonly graph: Graph;\n\treadonly text?: Node<MeasurementAdapter>;\n\treadonly svg?: Node<SvgMeasurer>;\n\treadonly image?: Node<ImageMeasurer>;\n\treadonly name?: string;\n}\n\n/**\n * Graph-visible bundle returned by `reactiveLayout`.\n *\n * The setters are state-node sugar over real graph inputs; the output nodes are ordinary\n * inspectable nodes visible through `graph.describe()`.\n */\nexport interface ReactiveLayoutBundle {\n\treadonly graph: Graph;\n\treadonly input: {\n\t\treadonly lineHeight: Node<number>;\n\t\treadonly maxWidth: Node<number>;\n\t\treadonly measurements: Node<Measurements>;\n\t};\n\tsetLineHeight(lineHeight: number): void;\n\tsetMaxWidth(maxWidth: number): void;\n\treadonly segments: Node<readonly PreparedSegment[]>;\n\treadonly lineBreaks: Node<LineBreaksResult>;\n\treadonly height: Node<number>;\n\treadonly charPositions: Node<readonly CharPosition[]>;\n}\n\n/** Optional context shared by pure line-breaking helpers. */\nexport interface LayoutNextLineContext {\n\treadonly adapter?: MeasurementAdapter;\n\treadonly font?: string;\n\treadonly cache?: Map<string, Map<string, number>>;\n\treadonly hyphenWidth?: number;\n\treadonly segmentAdapter?: SegmentAdapter;\n}\n\n/** Cache accounting object callers can pass into `analyzeAndMeasure`. */\nexport interface SegmentMeasureStats {\n\thits: number;\n\tmisses: number;\n}\n\n/** Options for the single-column reactive text layout bundle. */\nexport interface ReactiveLayoutOptions {\n\treadonly measurements: Node<Measurements>;\n\treadonly graph: Graph;\n\treadonly segmentAdapter?: SegmentAdapter;\n\treadonly targetId?: string;\n\treadonly name?: string;\n\treadonly lineHeight?: number | Node<number>;\n\treadonly maxWidth?: number | Node<number>;\n}\n\n/** Host text measurement function accepted by `InjectedMeasureAdapter`. */\nexport type MeasureFn = (text: string, font: string) => number | { readonly width: number };\n\n/** Options for caller-injected synchronous measurement. */\nexport interface InjectedMeasureAdapterOptions {\n\treadonly cache?: boolean;\n}\n\n/** Options for deterministic precomputed text metrics. */\nexport interface PrecomputedMeasureAdapterOptions {\n\treadonly metrics: ReadonlyMap<string, number> | Record<string, number>;\n\treadonly fallback?: \"per-char\" | \"error\";\n\treadonly cellWidth?: number;\n}\n\n/** Fixed-cell measurement options for terminal/snapshot rendering. */\nexport interface CellMeasureAdapterOptions {\n\treadonly cellWidth?: number;\n\treadonly wideCellWidth?: number;\n\treadonly tabCells?: number;\n}\n\n/** Width/height pair in CSS-like pixels. */\nexport interface Size {\n\treadonly width: number;\n\treadonly height: number;\n}\n\n/** Synchronous SVG measurement seam; no DOM parser is provided by the core. */\nexport interface SvgMeasurer {\n\tmeasureSvg(svg: string): Size;\n}\n\n/** Synchronous image measurement seam; no loading/fetching is provided by the core. */\nexport interface ImageMeasurer {\n\tmeasureImage(src: string): Size;\n}\n\n/** Optional per-kind block measurement adapters. */\nexport interface BlockAdapters {\n\treadonly text?: MeasurementAdapter;\n\treadonly svg?: SvgMeasurer;\n\treadonly image?: ImageMeasurer;\n}\n\n/** Shared spacing/id fields for block layout inputs. */\nexport interface BaseContentBlock {\n\treadonly id?: string;\n\treadonly marginTop?: number;\n\treadonly marginBottom?: number;\n}\n\n/** Text block input for `measureBlock` and `reactiveBlockLayout`. */\nexport interface TextContentBlock extends BaseContentBlock {\n\treadonly kind: \"text\";\n\treadonly text: string;\n\treadonly font?: string;\n\treadonly lineHeight?: number;\n\treadonly maxWidth?: number;\n}\n\n/** Image block input with explicit dimensions or an injected `ImageMeasurer`. */\nexport interface ImageContentBlock extends BaseContentBlock {\n\treadonly kind: \"image\";\n\treadonly src: string;\n\treadonly width?: number;\n\treadonly height?: number;\n\treadonly maxWidth?: number;\n}\n\n/** SVG block input with explicit dimensions or an injected `SvgMeasurer`. */\nexport interface SvgContentBlock extends BaseContentBlock {\n\treadonly kind: \"svg\";\n\treadonly svg: string;\n\treadonly width?: number;\n\treadonly height?: number;\n\treadonly maxWidth?: number;\n}\n\n/** Heterogeneous block-layout input. */\nexport type ContentBlock = TextContentBlock | ImageContentBlock | SvgContentBlock;\n\n/** Measured block produced by `measureBlock` or `measureBlocks`. */\nexport interface MeasuredBlock {\n\treadonly block: ContentBlock;\n\treadonly kind: ContentBlock[\"kind\"];\n\treadonly id?: string;\n\treadonly width: number;\n\treadonly height: number;\n\treadonly marginTop: number;\n\treadonly marginBottom: number;\n\treadonly segments?: readonly PreparedSegment[];\n\treadonly lineBreaks?: LineBreaksResult;\n\treadonly charPositions?: readonly CharPosition[];\n}\n\n/** Block with vertical-flow coordinates. */\nexport interface PositionedBlock extends MeasuredBlock {\n\treadonly x: number;\n\treadonly y: number;\n}\n\n/** Options for pure block measurement helpers. */\nexport interface MeasureBlockOptions {\n\treadonly adapter?: MeasurementAdapter;\n\treadonly adapters?: BlockAdapters;\n\treadonly font?: string;\n\treadonly lineHeight?: number;\n\treadonly maxWidth?: number;\n\treadonly cache?: Map<string, Map<string, number>>;\n\treadonly hyphenWidth?: number;\n\treadonly segmentAdapter?: SegmentAdapter;\n}\n\n/** Options for the graph-visible block layout bundle. */\nexport interface ReactiveBlockLayoutOptions {\n\treadonly measurements: Node<Measurements>;\n\treadonly graph: Graph;\n\treadonly targetId?: string;\n\treadonly name?: string;\n\treadonly gap?: number | Node<number>;\n}\n\n/** Graph-visible vertical block layout bundle. */\nexport interface ReactiveBlockLayoutBundle {\n\treadonly graph: Graph;\n\treadonly input: {\n\t\treadonly gap: Node<number>;\n\t\treadonly measurements: Node<Measurements>;\n\t};\n\tsetGap(gap: number): void;\n\treadonly measuredBlocks: Node<readonly MeasuredBlock[]>;\n\treadonly blockFlow: Node<readonly PositionedBlock[]>;\n\treadonly totalHeight: Node<number>;\n}\n\n/** Circular obstacle for flow layout slot carving. */\nexport interface CircleObstacle {\n\treadonly kind: \"circle\";\n\treadonly cx: number;\n\treadonly cy: number;\n\treadonly r: number;\n}\n\n/** Rectangular obstacle for flow layout slot carving. */\nexport interface RectObstacle {\n\treadonly kind: \"rect\";\n\treadonly x: number;\n\treadonly y: number;\n\treadonly width: number;\n\treadonly height: number;\n}\n\n/** Obstacle shape accepted by flow layout. */\nexport type Obstacle = CircleObstacle | RectObstacle;\n\n/** Flow container geometry. */\nexport interface FlowContainer {\n\treadonly width: number;\n\treadonly height: number;\n\treadonly paddingX?: number;\n\treadonly paddingY?: number;\n}\n\n/** Optional column geometry for flow layout. */\nexport interface FlowColumns {\n\treadonly count?: number;\n\treadonly gap?: number;\n}\n\n/** Positioned line emitted by `computeFlowLines` / `reactiveFlowLayout`. */\nexport interface PositionedLine extends LayoutLine {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly slotWidth: number;\n\treadonly columnIndex: number;\n}\n\n/** Flow layout result plus the continuation cursor. */\nexport interface FlowLinesResult {\n\treadonly lines: readonly PositionedLine[];\n\treadonly cursor: LayoutCursor;\n\treadonly done: boolean;\n}\n\n/** Options for pure flow layout computation. */\nexport interface ComputeFlowLinesOptions {\n\treadonly container: FlowContainer;\n\treadonly columns?: FlowColumns;\n\treadonly obstacles?: readonly Obstacle[];\n\treadonly lineHeight: number;\n\treadonly minSlotWidth?: number;\n\treadonly hyphenWidth?: number;\n\treadonly segmentAdapter?: SegmentAdapter;\n}\n\n/** Options for the graph-visible flow layout bundle. */\nexport interface ReactiveFlowLayoutOptions {\n\treadonly measurements: Node<Measurements>;\n\treadonly graph: Graph;\n\treadonly segmentAdapter?: SegmentAdapter;\n\treadonly targetId?: string;\n\treadonly name?: string;\n\treadonly lineHeight?: number | Node<number>;\n\treadonly container?: FlowContainer | Node<FlowContainer>;\n\treadonly columns?: FlowColumns | Node<FlowColumns>;\n\treadonly obstacles?: readonly Obstacle[] | Node<readonly Obstacle[]>;\n\treadonly minSlotWidth?: number;\n}\n\n/** Graph-visible multi-column flow layout bundle. */\nexport interface ReactiveFlowLayoutBundle {\n\treadonly graph: Graph;\n\treadonly input: {\n\t\treadonly lineHeight: Node<number>;\n\t\treadonly container: Node<FlowContainer>;\n\t\treadonly columns: Node<FlowColumns>;\n\t\treadonly obstacles: Node<readonly Obstacle[]>;\n\t\treadonly measurements: Node<Measurements>;\n\t};\n\tsetLineHeight(lineHeight: number): void;\n\tsetContainer(container: FlowContainer): void;\n\tsetColumns(columns: FlowColumns): void;\n\tsetObstacles(obstacles: readonly Obstacle[]): void;\n\treadonly segments: Node<readonly PreparedSegment[]>;\n\treadonly flowLines: Node<FlowLinesResult>;\n}\n","import { type Ctx, depLatest } from \"../../ctx/types.js\";\nimport type { DataIssue } from \"../../data/index.js\";\nimport type { Graph, StateNode } from \"../../graph/graph.js\";\nimport { Node } from \"../../node/node.js\";\nimport {\n\tCapabilityMeasureAdapter,\n\tCellMeasureAdapter,\n\tInjectedMeasureAdapter,\n\tPrecomputedMeasureAdapter,\n} from \"./adapters.js\";\nimport { measureBlock } from \"./block.js\";\nimport { analyzeAndMeasure } from \"./line.js\";\nimport { getDefaultSegmentAdapter } from \"./segment.js\";\nimport type {\n\tBlockAdapters,\n\tBlockAdaptersProviderOptions,\n\tBlockMeasurementProviderOptions,\n\tBlocksMeasurement,\n\tCapabilityTextMeasurementsOptions,\n\tCellTextMeasurementsOptions,\n\tContentBlock,\n\tImageMeasurer,\n\tImageSizeMeasurementsOptions,\n\tImageSizeMeasurementTarget,\n\tInjectedTextMeasurementsOptions,\n\tMeasuredBlock,\n\tMeasurementAdapter,\n\tMeasurementFact,\n\tMeasurementIssue,\n\tMeasurementReadiness,\n\tMeasurementResult,\n\tMeasurements,\n\tMergeMeasurementsOptions,\n\tPrecomputedTextMeasurementsOptions,\n\tReadinessMeasurementsOptions,\n\tReadinessTextMeasurementsOptions,\n\tSegmentAdapter,\n\tSize,\n\tSvgBoundsMeasurementsOptions,\n\tSvgBoundsMeasurementTarget,\n\tSvgMeasurer,\n\tTextMeasureCapability,\n\tTextMeasurementProviderOptions,\n\tTextSegmentsMeasurement,\n} from \"./types.js\";\nimport {\n\tBLOCKS_MEASUREMENT_KIND,\n\tIMAGE_SIZE_MEASUREMENT_KIND,\n\tREADINESS_MEASUREMENT_KIND,\n\tSVG_BOUNDS_MEASUREMENT_KIND,\n\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n} from \"./types.js\";\nimport { nonNegativeFinite } from \"./utils.js\";\n\nexport function measurementIssue(\n\tcode: string,\n\tmessage: string,\n\ttargetId: string,\n\tmeasurementKind: string,\n\topts: {\n\t\treadonly source?: string;\n\t\treadonly details?: unknown;\n\t\treadonly metadata?: Record<string, unknown>;\n\t\treadonly severity?: DataIssue[\"severity\"];\n\t} = {},\n): MeasurementIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage,\n\t\tseverity: opts.severity ?? \"warning\",\n\t\tsource: opts.source,\n\t\tsubjectId: targetId,\n\t\tmeasurementKind,\n\t\tdetails: opts.details,\n\t\tmetadata: opts.metadata,\n\t};\n}\n\nexport function measurementOk<T>(\n\ttargetId: string,\n\tmeasurementKind: string,\n\tvalue: T,\n\topts: { readonly source?: string; readonly metadata?: Record<string, unknown> } = {},\n): MeasurementResult<T> {\n\treturn {\n\t\tkind: \"ok\",\n\t\ttargetId,\n\t\tmeasurementKind,\n\t\tvalue,\n\t\tsource: opts.source,\n\t\tmetadata: opts.metadata,\n\t};\n}\n\nexport function latestMeasurementValue<T>(\n\tmeasurements: Measurements,\n\ttargetId: string,\n\tmeasurementKind: string,\n): T | undefined {\n\tlet value: T | undefined;\n\tfor (const fact of measurements) {\n\t\tif (\n\t\t\tfact.kind === \"ok\" &&\n\t\t\tfact.targetId === targetId &&\n\t\t\tfact.measurementKind === measurementKind\n\t\t) {\n\t\t\tvalue = fact.value as T;\n\t\t}\n\t}\n\treturn value;\n}\n\nexport function tryMeasureHyphenWidth(\n\tadapter: MeasurementAdapter,\n\tfont: string,\n): number | undefined {\n\ttry {\n\t\treturn nonNegativeFinite(adapter.measureSegment(\"-\", font).width, 0);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function validMeasurementSize(size: Size, label: string): Size {\n\tif (\n\t\t!Number.isFinite(size.width) ||\n\t\t!Number.isFinite(size.height) ||\n\t\tsize.width < 0 ||\n\t\tsize.height < 0\n\t) {\n\t\tthrow new Error(`Invalid ${label} measurement size`);\n\t}\n\treturn size;\n}\n\nexport function textMeasurementFacts(\n\ttext: string,\n\tfont: string,\n\tadapter: MeasurementAdapter,\n\tcache: Map<string, Map<string, number>>,\n\tsegmentAdapter: SegmentAdapter,\n\ttargetId: string,\n\tsource: string,\n): Measurements {\n\ttry {\n\t\tconst segments = analyzeAndMeasure(text, font, adapter, cache, undefined, segmentAdapter);\n\t\tconst hyphenWidth = tryMeasureHyphenWidth(adapter, font);\n\t\tconst facts: MeasurementFact<TextSegmentsMeasurement>[] = [\n\t\t\tmeasurementOk<TextSegmentsMeasurement>(\n\t\t\t\ttargetId,\n\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\thyphenWidth === undefined ? { segments } : { segments, hyphenWidth },\n\t\t\t\t{ source },\n\t\t\t),\n\t\t];\n\t\tif (hyphenWidth === undefined) {\n\t\t\tfacts.push(\n\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\"measurement.hyphen.failed\",\n\t\t\t\t\t`Hyphen measurement failed for '${targetId}'`,\n\t\t\t\t\ttargetId,\n\t\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t\t{ source, severity: \"warning\" },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn facts;\n\t} catch (error) {\n\t\treturn [\n\t\t\tmeasurementIssue(\n\t\t\t\t\"measurement.failed\",\n\t\t\t\t`Text measurement failed for '${targetId}'`,\n\t\t\t\ttargetId,\n\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t{ source, details: error, severity: \"error\" },\n\t\t\t),\n\t\t];\n\t}\n}\n\nexport function inputNode<T>(\n\tg: Graph,\n\tinput: T | Node<T> | undefined,\n\tfallback: T,\n\tname: string,\n): { readonly node: Node<T>; readonly set: (value: T) => void } {\n\tif (input instanceof Node) {\n\t\treturn {\n\t\t\tnode: input,\n\t\t\tset(value: T): void {\n\t\t\t\tconst maybeState = input as Node<T> & { set?: (next: T) => void };\n\t\t\t\tif (typeof maybeState.set !== \"function\") {\n\t\t\t\t\tthrow new TypeError(`reactive-layout input '${name}' is not a writable state node`);\n\t\t\t\t}\n\t\t\t\tmaybeState.set(value);\n\t\t\t},\n\t\t};\n\t}\n\tconst state: StateNode<T> = g.state(input ?? fallback, { name });\n\treturn { node: state, set: (value: T) => state.set(value) };\n}\n\nexport function scopedName(scope: string, local: string): string {\n\treturn scope === local ? local : `${scope}:${local}`;\n}\n\n/** Generic sync text measurement provider that emits graph-visible measurement facts. */\nexport function textMeasurementProvider(opts: TextMeasurementProviderOptions): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst name = opts.name ?? `${targetId}-measurements`;\n\tconst source = opts.source ?? name;\n\tconst cache = new Map<string, Map<string, number>>();\n\tlet activeAdapter: MeasurementAdapter | null = null;\n\treturn opts.graph.node<Measurements>(\n\t\topts.segmentAdapter\n\t\t\t? [opts.text, opts.font, opts.adapter, opts.segmentAdapter]\n\t\t\t: [opts.text, opts.font, opts.adapter],\n\t\t(ctx: Ctx) => {\n\t\t\tconst flush = () => {\n\t\t\t\tcache.clear();\n\t\t\t\t(depLatest(ctx, 2) as MeasurementAdapter).clearCache?.();\n\t\t\t};\n\t\t\tctx.onDeactivation(flush);\n\t\t\tctx.onInvalidate(flush);\n\t\t\tconst text = depLatest(ctx, 0) as string;\n\t\t\tconst font = depLatest(ctx, 1) as string;\n\t\t\tconst adapter = depLatest(ctx, 2) as MeasurementAdapter;\n\t\t\tif (adapter !== activeAdapter) {\n\t\t\t\tcache.clear();\n\t\t\t\tactiveAdapter = adapter;\n\t\t\t}\n\t\t\tconst segmentAdapter =\n\t\t\t\topts.segmentAdapter === undefined\n\t\t\t\t\t? getDefaultSegmentAdapter()\n\t\t\t\t\t: (depLatest(ctx, 3) as SegmentAdapter);\n\t\t\tctx.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\ttextMeasurementFacts(text, font, adapter, cache, segmentAdapter, targetId, source),\n\t\t\t\t],\n\t\t\t]);\n\t\t},\n\t\t{ name },\n\t);\n}\n\n/** Provider helper for caller-injected synchronous text measurement. */\nexport function injectedTextMeasurements(\n\topts: InjectedTextMeasurementsOptions,\n): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst adapter = opts.graph.state<MeasurementAdapter>(\n\t\tnew InjectedMeasureAdapter(opts.measure, { cache: opts.cache }),\n\t\t{\n\t\t\tname: opts.name\n\t\t\t\t? scopedName(opts.name, \"measure-capability\")\n\t\t\t\t: `${targetId}-measure-capability`,\n\t\t},\n\t);\n\treturn textMeasurementProvider({\n\t\t...opts,\n\t\tadapter,\n\t\tsource: opts.source ?? \"injectedTextMeasurements\",\n\t});\n}\n\n/** Provider helper for deterministic precomputed text metrics. */\nexport function precomputedTextMeasurements(\n\topts: PrecomputedTextMeasurementsOptions,\n): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst adapter = opts.graph.state<MeasurementAdapter>(new PrecomputedMeasureAdapter(opts), {\n\t\tname: opts.name\n\t\t\t? scopedName(opts.name, \"measure-capability\")\n\t\t\t: `${targetId}-measure-capability`,\n\t});\n\treturn textMeasurementProvider({\n\t\t...opts,\n\t\tadapter,\n\t\tsource: opts.source ?? \"precomputedTextMeasurements\",\n\t});\n}\n\n/** Provider helper for fixed-cell terminal/snapshot text measurement. */\nexport function cellTextMeasurements(opts: CellTextMeasurementsOptions): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst adapter = opts.graph.state<MeasurementAdapter>(new CellMeasureAdapter(opts), {\n\t\tname: opts.name\n\t\t\t? scopedName(opts.name, \"measure-capability\")\n\t\t\t: `${targetId}-measure-capability`,\n\t});\n\treturn textMeasurementProvider({\n\t\t...opts,\n\t\tadapter,\n\t\tsource: opts.source ?? \"cellTextMeasurements\",\n\t});\n}\n\n/** Provider helper for caller-injected platform text capability nodes. */\nexport function capabilityTextMeasurements(\n\topts: CapabilityTextMeasurementsOptions,\n): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst adapter = opts.graph.node<MeasurementAdapter>(\n\t\t[opts.capability],\n\t\t(ctx: Ctx) => {\n\t\t\tctx.down([\n\t\t\t\t[\"DATA\", new CapabilityMeasureAdapter(depLatest(ctx, 0) as TextMeasureCapability)],\n\t\t\t]);\n\t\t},\n\t\t{\n\t\t\tname: opts.name\n\t\t\t\t? scopedName(opts.name, \"measure-capability\")\n\t\t\t\t: `${targetId}-measure-capability`,\n\t\t},\n\t);\n\treturn textMeasurementProvider({\n\t\t...opts,\n\t\tadapter,\n\t\tsource: opts.source ?? \"capabilityTextMeasurements\",\n\t});\n}\n\n/** Provider helper that makes readiness facts an explicit measurement dependency. */\nexport function readinessTextMeasurements(\n\topts: ReadinessTextMeasurementsOptions,\n): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst name = opts.name ?? `${targetId}-measurements`;\n\tconst source = opts.source ?? name;\n\tconst cache = new Map<string, Map<string, number>>();\n\tlet activeAdapter: MeasurementAdapter | null = null;\n\tlet activeReadiness: MeasurementReadiness | null = null;\n\tconst deps = opts.segmentAdapter\n\t\t? [opts.text, opts.font, opts.adapter, opts.readiness, opts.segmentAdapter]\n\t\t: [opts.text, opts.font, opts.adapter, opts.readiness];\n\treturn opts.graph.node<Measurements>(\n\t\tdeps,\n\t\t(ctx: Ctx) => {\n\t\t\tconst flush = () => {\n\t\t\t\tcache.clear();\n\t\t\t\t(depLatest(ctx, 2) as MeasurementAdapter).clearCache?.();\n\t\t\t};\n\t\t\tctx.onDeactivation(flush);\n\t\t\tctx.onInvalidate(flush);\n\t\t\tconst text = depLatest(ctx, 0) as string;\n\t\t\tconst font = depLatest(ctx, 1) as string;\n\t\t\tconst adapter = depLatest(ctx, 2) as MeasurementAdapter;\n\t\t\tif (adapter !== activeAdapter) {\n\t\t\t\tcache.clear();\n\t\t\t\tactiveAdapter = adapter;\n\t\t\t}\n\t\t\tconst readiness = depLatest(ctx, 3) as MeasurementReadiness;\n\t\t\tif (readiness !== activeReadiness) {\n\t\t\t\tcache.clear();\n\t\t\t\tactiveReadiness = readiness;\n\t\t\t}\n\t\t\tif (!readiness.ready) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\treadiness.code ?? \"measurement.not-ready\",\n\t\t\t\t\t\t\t\treadiness.message ?? `Measurement readiness blocked '${targetId}'`,\n\t\t\t\t\t\t\t\ttargetId,\n\t\t\t\t\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsource: readiness.source ?? source,\n\t\t\t\t\t\t\t\t\tdetails: readiness.details,\n\t\t\t\t\t\t\t\t\tmetadata: readiness.metadata,\n\t\t\t\t\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst segmentAdapter =\n\t\t\t\topts.segmentAdapter === undefined\n\t\t\t\t\t? getDefaultSegmentAdapter()\n\t\t\t\t\t: (depLatest(ctx, 4) as SegmentAdapter);\n\t\t\tctx.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\ttextMeasurementFacts(text, font, adapter, cache, segmentAdapter, targetId, source),\n\t\t\t\t],\n\t\t\t]);\n\t\t},\n\t\t{ name },\n\t);\n}\n\n/** Provider helper that emits graph-visible readiness facts without measuring layout. */\nexport function readinessMeasurements(opts: ReadinessMeasurementsOptions): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"measurement-readiness\";\n\tconst measurementKind = opts.measurementKind ?? READINESS_MEASUREMENT_KIND;\n\tconst name = opts.name ?? `${targetId}-measurements`;\n\tconst source = opts.source ?? name;\n\treturn opts.graph.node<Measurements>(\n\t\t[opts.readiness],\n\t\t(ctx: Ctx) => {\n\t\t\tconst readiness = depLatest(ctx, 0) as MeasurementReadiness;\n\t\t\tif (!readiness.ready) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\treadiness.code ?? \"measurement.not-ready\",\n\t\t\t\t\t\t\t\treadiness.message ?? `Measurement readiness blocked '${targetId}'`,\n\t\t\t\t\t\t\t\ttargetId,\n\t\t\t\t\t\t\t\tmeasurementKind,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsource: readiness.source ?? source,\n\t\t\t\t\t\t\t\t\tdetails: readiness.details,\n\t\t\t\t\t\t\t\t\tmetadata: readiness.metadata,\n\t\t\t\t\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t[\n\t\t\t\t\t\tmeasurementOk<MeasurementReadiness>(targetId, measurementKind, readiness, {\n\t\t\t\t\t\t\tsource: readiness.source ?? source,\n\t\t\t\t\t\t\tmetadata: readiness.metadata,\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t]);\n\t\t},\n\t\t{ name },\n\t);\n}\n\n/** Provider helper for image-size facts from caller-owned synchronous image measurers. */\nexport function imageSizeMeasurements(opts: ImageSizeMeasurementsOptions): Node<Measurements> {\n\tconst measurementKind = opts.measurementKind ?? IMAGE_SIZE_MEASUREMENT_KIND;\n\tconst name = opts.name ?? \"image-size-measurements\";\n\tconst source = opts.source ?? name;\n\treturn opts.graph.node<Measurements>(\n\t\t[opts.images, opts.measurer],\n\t\t(ctx: Ctx) => {\n\t\t\tconst images = depLatest(ctx, 0) as readonly ImageSizeMeasurementTarget[];\n\t\t\tconst measurer = depLatest(ctx, 1) as ImageMeasurer;\n\t\t\tconst facts: MeasurementFact<Size>[] = [];\n\t\t\tfor (let i = 0; i < images.length; i += 1) {\n\t\t\t\tconst image = (images as readonly (ImageSizeMeasurementTarget | undefined)[])[i];\n\t\t\t\tconst subjectId = image?.id ?? image?.src ?? `image:${i}`;\n\t\t\t\ttry {\n\t\t\t\t\tif (image === undefined) throw new Error(`Missing image target at index ${i}`);\n\t\t\t\t\tfacts.push(\n\t\t\t\t\t\tmeasurementOk<Size>(\n\t\t\t\t\t\t\tsubjectId,\n\t\t\t\t\t\t\tmeasurementKind,\n\t\t\t\t\t\t\tvalidMeasurementSize(measurer.measureImage(image.src), \"image\"),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t\tmetadata: image.metadata,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfacts.push(\n\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\"measurement.image-size.failed\",\n\t\t\t\t\t\t\t`Image size measurement failed for '${subjectId}'`,\n\t\t\t\t\t\t\tsubjectId,\n\t\t\t\t\t\t\tmeasurementKind,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t\tdetails: { error, index: i, src: image?.src },\n\t\t\t\t\t\t\t\tmetadata: image?.metadata,\n\t\t\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.down([[\"DATA\", facts]]);\n\t\t},\n\t\t{ name },\n\t);\n}\n\n/** Provider helper for SVG bounds facts from caller-owned synchronous SVG measurers. */\nexport function svgBoundsMeasurements(opts: SvgBoundsMeasurementsOptions): Node<Measurements> {\n\tconst measurementKind = opts.measurementKind ?? SVG_BOUNDS_MEASUREMENT_KIND;\n\tconst name = opts.name ?? \"svg-bounds-measurements\";\n\tconst source = opts.source ?? name;\n\treturn opts.graph.node<Measurements>(\n\t\t[opts.svgs, opts.measurer],\n\t\t(ctx: Ctx) => {\n\t\t\tconst svgs = depLatest(ctx, 0) as readonly SvgBoundsMeasurementTarget[];\n\t\t\tconst measurer = depLatest(ctx, 1) as SvgMeasurer;\n\t\t\tconst facts: MeasurementFact<Size>[] = [];\n\t\t\tfor (let i = 0; i < svgs.length; i += 1) {\n\t\t\t\tconst svg = (svgs as readonly (SvgBoundsMeasurementTarget | undefined)[])[i];\n\t\t\t\tconst subjectId = svg?.id ?? `svg:${i}`;\n\t\t\t\ttry {\n\t\t\t\t\tif (svg === undefined) throw new Error(`Missing SVG target at index ${i}`);\n\t\t\t\t\tfacts.push(\n\t\t\t\t\t\tmeasurementOk<Size>(\n\t\t\t\t\t\t\tsubjectId,\n\t\t\t\t\t\t\tmeasurementKind,\n\t\t\t\t\t\t\tvalidMeasurementSize(measurer.measureSvg(svg.svg), \"SVG\"),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t\tmetadata: svg.metadata,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfacts.push(\n\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\"measurement.svg-bounds.failed\",\n\t\t\t\t\t\t\t`SVG bounds measurement failed for '${subjectId}'`,\n\t\t\t\t\t\t\tsubjectId,\n\t\t\t\t\t\t\tmeasurementKind,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t\tdetails: { error, index: i },\n\t\t\t\t\t\t\t\tmetadata: svg?.metadata,\n\t\t\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.down([[\"DATA\", facts]]);\n\t\t},\n\t\t{ name },\n\t);\n}\n\n/** Merge provider fact nodes into the single measurements node consumed by layout bundles. */\nexport function mergeMeasurements(opts: MergeMeasurementsOptions): Node<Measurements> {\n\tconst sources = [...opts.sources];\n\treturn opts.graph.node<Measurements>(\n\t\tsources as readonly Node<unknown>[],\n\t\t(ctx: Ctx) => {\n\t\t\tconst facts: MeasurementFact[] = [];\n\t\t\tfor (let i = 0; i < sources.length; i += 1) {\n\t\t\t\tfacts.push(...(depLatest(ctx, i) as Measurements));\n\t\t\t}\n\t\t\tctx.down([[\"DATA\", facts]]);\n\t\t},\n\t\t{ name: opts.name ?? \"measurements\" },\n\t);\n}\n\n/** Compose optional block measurement capability nodes into one graph-visible adapter node. */\nexport function blockAdaptersProvider(opts: BlockAdaptersProviderOptions): Node<BlockAdapters> {\n\tconst deps: Node<unknown>[] = [];\n\tconst positions: { text?: number; svg?: number; image?: number } = {};\n\tif (opts.text) {\n\t\tpositions.text = deps.length;\n\t\tdeps.push(opts.text);\n\t}\n\tif (opts.svg) {\n\t\tpositions.svg = deps.length;\n\t\tdeps.push(opts.svg);\n\t}\n\tif (opts.image) {\n\t\tpositions.image = deps.length;\n\t\tdeps.push(opts.image);\n\t}\n\treturn opts.graph.node<BlockAdapters>(\n\t\tdeps,\n\t\t(ctx: Ctx) => {\n\t\t\tconst adapters: BlockAdapters = {\n\t\t\t\ttext:\n\t\t\t\t\tpositions.text === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: (depLatest(ctx, positions.text) as MeasurementAdapter),\n\t\t\t\tsvg:\n\t\t\t\t\tpositions.svg === undefined ? undefined : (depLatest(ctx, positions.svg) as SvgMeasurer),\n\t\t\t\timage:\n\t\t\t\t\tpositions.image === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: (depLatest(ctx, positions.image) as ImageMeasurer),\n\t\t\t};\n\t\t\tctx.down([[\"DATA\", adapters]]);\n\t\t},\n\t\t{ name: opts.name ?? \"block-adapters\" },\n\t);\n}\n\n/** Provider helper for block measurement facts over declared block/max-width deps. */\nexport function blockMeasurementProvider(\n\topts: BlockMeasurementProviderOptions,\n): Node<Measurements> {\n\tconst targetId = opts.targetId ?? \"blocks\";\n\tconst name = opts.name ?? `${targetId}-measurements`;\n\tconst source = opts.source ?? name;\n\tconst cache = new Map<string, Map<string, number>>();\n\tlet activeTextAdapter: MeasurementAdapter | undefined;\n\tconst deps = [opts.blocks, opts.maxWidth, opts.adapters] as Node<unknown>[];\n\tif (opts.font) deps.push(opts.font);\n\tif (opts.lineHeight) deps.push(opts.lineHeight);\n\tif (opts.segmentAdapter) deps.push(opts.segmentAdapter);\n\treturn opts.graph.node<Measurements>(\n\t\tdeps,\n\t\t(ctx: Ctx) => {\n\t\t\tconst flush = () => {\n\t\t\t\tcache.clear();\n\t\t\t\tconst adapters = depLatest(ctx, 2) as BlockAdapters;\n\t\t\t\tadapters.text?.clearCache?.();\n\t\t\t};\n\t\t\tctx.onDeactivation(flush);\n\t\t\tctx.onInvalidate(flush);\n\t\t\ttry {\n\t\t\t\tconst blocks = depLatest(ctx, 0) as readonly ContentBlock[];\n\t\t\t\tconst maxWidth = nonNegativeFinite(depLatest(ctx, 1) as number, 0);\n\t\t\t\tconst adapters = depLatest(ctx, 2) as BlockAdapters;\n\t\t\t\tif (adapters.text !== activeTextAdapter) {\n\t\t\t\t\tcache.clear();\n\t\t\t\t\tactiveTextAdapter = adapters.text;\n\t\t\t\t}\n\t\t\t\tlet depIndex = 3;\n\t\t\t\tconst font = opts.font ? (depLatest(ctx, depIndex++) as string) : undefined;\n\t\t\t\tconst lineHeight = opts.lineHeight\n\t\t\t\t\t? nonNegativeFinite(depLatest(ctx, depIndex++) as number, 0)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst segmentAdapter = opts.segmentAdapter\n\t\t\t\t\t? (depLatest(ctx, depIndex) as SegmentAdapter)\n\t\t\t\t\t: getDefaultSegmentAdapter();\n\t\t\t\tconst measured: MeasuredBlock[] = [];\n\t\t\t\tconst issues: MeasurementIssue[] = [];\n\t\t\t\tfor (let i = 0; i < blocks.length; i += 1) {\n\t\t\t\t\tconst block = (blocks as readonly (ContentBlock | undefined)[])[i];\n\t\t\t\t\tconst subjectId = block?.id ?? `${targetId}:${i}`;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (block === undefined) {\n\t\t\t\t\t\t\tthrow new Error(`Missing content block at index ${i}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst blockFont =\n\t\t\t\t\t\t\tblock.kind === \"text\" ? (block.font ?? font ?? \"16px sans-serif\") : undefined;\n\t\t\t\t\t\tconst hyphenWidth =\n\t\t\t\t\t\t\tblock.kind === \"text\" && adapters.text\n\t\t\t\t\t\t\t\t? tryMeasureHyphenWidth(adapters.text, blockFont ?? \"16px sans-serif\")\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tmeasured.push(\n\t\t\t\t\t\t\tmeasureBlock(block, {\n\t\t\t\t\t\t\t\tadapters,\n\t\t\t\t\t\t\t\tfont,\n\t\t\t\t\t\t\t\thyphenWidth,\n\t\t\t\t\t\t\t\tlineHeight,\n\t\t\t\t\t\t\t\tmaxWidth,\n\t\t\t\t\t\t\t\tcache,\n\t\t\t\t\t\t\t\tsegmentAdapter,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (block.kind === \"text\" && adapters.text) {\n\t\t\t\t\t\t\tif (hyphenWidth === undefined) {\n\t\t\t\t\t\t\t\tissues.push(\n\t\t\t\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\t\t\t\"measurement.hyphen.failed\",\n\t\t\t\t\t\t\t\t\t\t`Hyphen measurement failed for '${subjectId}'`,\n\t\t\t\t\t\t\t\t\t\tsubjectId,\n\t\t\t\t\t\t\t\t\t\tBLOCKS_MEASUREMENT_KIND,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t\t\t\t\tdetails: { targetId, index: i },\n\t\t\t\t\t\t\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tissues.push(\n\t\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\t\"measurement.block.failed\",\n\t\t\t\t\t\t\t\t`Block measurement failed for '${subjectId}'`,\n\t\t\t\t\t\t\t\tsubjectId,\n\t\t\t\t\t\t\t\tBLOCKS_MEASUREMENT_KIND,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t\t\tdetails: { error, targetId, index: i, blockKind: block?.kind },\n\t\t\t\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tmeasurementOk<BlocksMeasurement>(\n\t\t\t\t\t\t\t\ttargetId,\n\t\t\t\t\t\t\t\tBLOCKS_MEASUREMENT_KIND,\n\t\t\t\t\t\t\t\t{ blocks: measured },\n\t\t\t\t\t\t\t\t{ source },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...issues,\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t} catch (error) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tmeasurementIssue(\n\t\t\t\t\t\t\t\t\"measurement.failed\",\n\t\t\t\t\t\t\t\t`Block measurement failed for '${targetId}'`,\n\t\t\t\t\t\t\t\ttargetId,\n\t\t\t\t\t\t\t\tBLOCKS_MEASUREMENT_KIND,\n\t\t\t\t\t\t\t\t{ source, details: error, severity: \"error\" },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t},\n\t\t{ name },\n\t);\n}\n","import { analyzeAndMeasure, computeCharPositions, computeLineBreaks } from \"./line.js\";\nimport { tryMeasureHyphenWidth } from \"./measurements.js\";\nimport type { ContentBlock, MeasureBlockOptions, MeasuredBlock, PositionedBlock } from \"./types.js\";\nimport {\n\tblockMaxWidth,\n\tclampDimension,\n\tfitSize,\n\tnonNegativeFinite,\n\tpositiveFinite,\n\tresolveTextAdapter,\n} from \"./utils.js\";\n\n/** Measure one text/image/SVG block using only explicit or injected synchronous adapters. */\nexport function measureBlock(block: ContentBlock, opts: MeasureBlockOptions): MeasuredBlock {\n\tconst maxWidth = nonNegativeFinite(opts.maxWidth ?? 800, 800);\n\tconst marginTop = nonNegativeFinite(block.marginTop ?? 0, 0);\n\tconst marginBottom = nonNegativeFinite(block.marginBottom ?? 0, 0);\n\tif (block.kind === \"text\") {\n\t\tconst adapter = resolveTextAdapter(opts);\n\t\tconst font = block.font ?? opts.font ?? \"16px sans-serif\";\n\t\tconst lineHeight = positiveFinite(block.lineHeight ?? opts.lineHeight ?? 20, 20);\n\t\tconst cache = opts.cache ?? new Map<string, Map<string, number>>();\n\t\tconst width = blockMaxWidth(block.maxWidth, maxWidth);\n\t\tconst segments = analyzeAndMeasure(\n\t\t\tblock.text,\n\t\t\tfont,\n\t\t\tadapter,\n\t\t\tcache,\n\t\t\tundefined,\n\t\t\topts.segmentAdapter,\n\t\t);\n\t\tconst hyphenWidth = Object.hasOwn(opts, \"hyphenWidth\")\n\t\t\t? opts.hyphenWidth\n\t\t\t: tryMeasureHyphenWidth(adapter, font);\n\t\tconst lineBreaks = computeLineBreaks(segments, width, {\n\t\t\thyphenWidth,\n\t\t\tsegmentAdapter: opts.segmentAdapter,\n\t\t});\n\t\tconst charPositions = computeCharPositions(\n\t\t\tlineBreaks,\n\t\t\tsegments,\n\t\t\tlineHeight,\n\t\t\topts.segmentAdapter,\n\t\t);\n\t\treturn {\n\t\t\tblock,\n\t\t\tkind: block.kind,\n\t\t\tid: block.id,\n\t\t\twidth: lineBreaks.lines.reduce((acc, line) => Math.max(acc, line.width), 0),\n\t\t\theight: lineBreaks.lineCount * lineHeight,\n\t\t\tmarginTop,\n\t\t\tmarginBottom,\n\t\t\tsegments,\n\t\t\tlineBreaks,\n\t\t\tcharPositions,\n\t\t};\n\t}\n\tif (block.kind === \"image\") {\n\t\tconst explicit =\n\t\t\tblock.width !== undefined && block.height !== undefined\n\t\t\t\t? { width: clampDimension(block.width), height: clampDimension(block.height) }\n\t\t\t\t: opts.adapters?.image?.measureImage(block.src);\n\t\tif (!explicit) throw new Error(\"Image blocks require width/height or an ImageMeasurer\");\n\t\tconst size = fitSize(explicit, blockMaxWidth(block.maxWidth, maxWidth));\n\t\treturn {\n\t\t\tblock,\n\t\t\tkind: block.kind,\n\t\t\tid: block.id,\n\t\t\twidth: size.width,\n\t\t\theight: size.height,\n\t\t\tmarginTop,\n\t\t\tmarginBottom,\n\t\t};\n\t}\n\tconst explicit =\n\t\tblock.width !== undefined && block.height !== undefined\n\t\t\t? { width: clampDimension(block.width), height: clampDimension(block.height) }\n\t\t\t: opts.adapters?.svg?.measureSvg(block.svg);\n\tif (!explicit) throw new Error(\"SVG blocks require width/height or a SvgMeasurer\");\n\tconst size = fitSize(explicit, blockMaxWidth(block.maxWidth, maxWidth));\n\treturn {\n\t\tblock,\n\t\tkind: block.kind,\n\t\tid: block.id,\n\t\twidth: size.width,\n\t\theight: size.height,\n\t\tmarginTop,\n\t\tmarginBottom,\n\t};\n}\n\n/** Measure a block list while sharing a measurement cache across text blocks. */\nexport function measureBlocks(\n\tblocks: readonly ContentBlock[],\n\topts: MeasureBlockOptions,\n): readonly MeasuredBlock[] {\n\tconst cache = opts.cache ?? new Map<string, Map<string, number>>();\n\treturn blocks.map((block) => measureBlock(block, { ...opts, cache }));\n}\n\n/** Stack measured blocks vertically with margins and a fixed gap. */\nexport function computeBlockFlow(\n\tblocks: readonly MeasuredBlock[],\n\tgap = 0,\n): readonly PositionedBlock[] {\n\tconst spacing = nonNegativeFinite(gap, 0);\n\tlet y = 0;\n\treturn blocks.map((block) => {\n\t\ty += block.marginTop;\n\t\tconst positioned: PositionedBlock = { ...block, x: 0, y };\n\t\ty += block.height + block.marginBottom + spacing;\n\t\treturn positioned;\n\t});\n}\n\n/** Compute the bottom edge of a positioned block flow. */\nexport function computeTotalHeight(blocks: readonly PositionedBlock[]): number {\n\tif (blocks.length === 0) return 0;\n\tlet bottom = 0;\n\tfor (const block of blocks) {\n\t\tbottom = Math.max(bottom, block.y + block.height + block.marginBottom);\n\t}\n\treturn bottom;\n}\n","import { carveTextLineSlots, layoutNextLine } from \"./line.js\";\nimport { getDefaultSegmentAdapter } from \"./segment.js\";\nimport type {\n\tCircleObstacle,\n\tComputeFlowLinesOptions,\n\tFlowColumns,\n\tFlowContainer,\n\tFlowLinesResult,\n\tInterval,\n\tLayoutCursor,\n\tObstacle,\n\tPositionedLine,\n\tPreparedSegment,\n\tRectObstacle,\n} from \"./types.js\";\nimport { finiteNumber, nonNegativeFinite, positiveFinite } from \"./utils.js\";\n\nexport function columnGeometry(\n\tcontainer: FlowContainer,\n\tcolumns: FlowColumns | undefined,\n): {\n\treadonly paddingX: number;\n\treadonly paddingY: number;\n\treadonly count: number;\n\treadonly gap: number;\n\treadonly width: number;\n\treadonly height: number;\n\treadonly columnWidth: number;\n} {\n\tconst paddingX = nonNegativeFinite(container.paddingX ?? 0, 0);\n\tconst paddingY = nonNegativeFinite(container.paddingY ?? 0, 0);\n\tconst count = Math.max(1, Math.floor(nonNegativeFinite(columns?.count ?? 1, 1)));\n\tconst gap = nonNegativeFinite(columns?.gap ?? 0, 0);\n\tconst width = nonNegativeFinite(container.width, 0);\n\tconst height = nonNegativeFinite(container.height, 0);\n\tconst innerWidth = Math.max(0, width - paddingX * 2 - gap * (count - 1));\n\tconst columnWidth = count > 0 ? innerWidth / count : 0;\n\treturn { paddingX, paddingY, count, gap, width, height, columnWidth };\n}\n\nexport function sanitizeFlowContainer(container: FlowContainer): FlowContainer {\n\treturn {\n\t\twidth: nonNegativeFinite(container.width, 0),\n\t\theight: nonNegativeFinite(container.height, 0),\n\t\tpaddingX:\n\t\t\tcontainer.paddingX === undefined ? undefined : nonNegativeFinite(container.paddingX, 0),\n\t\tpaddingY:\n\t\t\tcontainer.paddingY === undefined ? undefined : nonNegativeFinite(container.paddingY, 0),\n\t};\n}\n\nexport function sanitizeFlowColumns(columns: FlowColumns): FlowColumns {\n\treturn {\n\t\tcount:\n\t\t\tcolumns.count === undefined\n\t\t\t\t? undefined\n\t\t\t\t: Math.max(1, Math.floor(nonNegativeFinite(columns.count, 1))),\n\t\tgap: columns.gap === undefined ? undefined : nonNegativeFinite(columns.gap, 0),\n\t};\n}\n\nexport function sanitizeObstacles(obstacles: readonly Obstacle[]): readonly Obstacle[] {\n\treturn obstacles.map((obstacle) => {\n\t\tif (obstacle.kind === \"circle\") {\n\t\t\treturn {\n\t\t\t\tkind: obstacle.kind,\n\t\t\t\tcx: finiteNumber(obstacle.cx, 0),\n\t\t\t\tcy: finiteNumber(obstacle.cy, 0),\n\t\t\t\tr: nonNegativeFinite(obstacle.r, 0),\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tkind: obstacle.kind,\n\t\t\tx: finiteNumber(obstacle.x, 0),\n\t\t\ty: finiteNumber(obstacle.y, 0),\n\t\t\twidth: nonNegativeFinite(obstacle.width, 0),\n\t\t\theight: nonNegativeFinite(obstacle.height, 0),\n\t\t};\n\t});\n}\n\n/** Intersect a circle obstacle with a horizontal line band. */\nexport function circleIntervalForBand(\n\tobstacle: CircleObstacle,\n\tbandTop: number,\n\tbandBottom: number,\n): Interval | null {\n\tconst radius = nonNegativeFinite(obstacle.r, 0);\n\tconst centerY = obstacle.cy;\n\tconst nearestY = Math.max(bandTop, Math.min(centerY, bandBottom));\n\tconst dy = nearestY - centerY;\n\tif (Math.abs(dy) > radius) return null;\n\tconst dx = Math.sqrt(Math.max(0, radius * radius - dy * dy));\n\treturn { left: obstacle.cx - dx, right: obstacle.cx + dx };\n}\n\n/** Intersect a rectangle obstacle with a horizontal line band. */\nexport function rectIntervalForBand(\n\tobstacle: RectObstacle,\n\tbandTop: number,\n\tbandBottom: number,\n): Interval | null {\n\tconst left = obstacle.x;\n\tconst right = obstacle.x + nonNegativeFinite(obstacle.width, 0);\n\tconst top = obstacle.y;\n\tconst bottom = obstacle.y + nonNegativeFinite(obstacle.height, 0);\n\tif (bottom <= bandTop || top >= bandBottom || right <= left) return null;\n\treturn { left, right };\n}\n\nexport function blockedIntervalsForBand(\n\tobstacles: readonly Obstacle[],\n\tbandTop: number,\n\tbandBottom: number,\n): Interval[] {\n\tconst intervals: Interval[] = [];\n\tfor (const obstacle of obstacles) {\n\t\tconst interval =\n\t\t\tobstacle.kind === \"circle\"\n\t\t\t\t? circleIntervalForBand(obstacle, bandTop, bandBottom)\n\t\t\t\t: rectIntervalForBand(obstacle, bandTop, bandBottom);\n\t\tif (interval) intervals.push(interval);\n\t}\n\treturn intervals.sort((a, b) => a.left - b.left);\n}\n\n/** Flow prepared text through columns and carved obstacle slots. */\nexport function computeFlowLines(\n\tsegments: readonly PreparedSegment[],\n\topts: ComputeFlowLinesOptions,\n): FlowLinesResult {\n\tconst geometry = columnGeometry(opts.container, opts.columns);\n\tconst lineHeight = positiveFinite(opts.lineHeight, 20);\n\tconst minSlotWidth = nonNegativeFinite(opts.minSlotWidth ?? 0, 0);\n\tconst obstacles = opts.obstacles ?? [];\n\tconst segmentAdapter = opts.segmentAdapter ?? getDefaultSegmentAdapter();\n\tconst lines: PositionedLine[] = [];\n\tlet cursor: LayoutCursor = { segmentIndex: 0, graphemeIndex: 0 };\n\tconst contentBottom = Math.max(geometry.paddingY, geometry.height - geometry.paddingY);\n\tfor (let columnIndex = 0; columnIndex < geometry.count; columnIndex += 1) {\n\t\tconst columnLeft = geometry.paddingX + columnIndex * (geometry.columnWidth + geometry.gap);\n\t\tconst columnRight = columnLeft + geometry.columnWidth;\n\t\tfor (\n\t\t\tlet y = geometry.paddingY;\n\t\t\ty + lineHeight <= contentBottom + 1e-3 && cursor.segmentIndex < segments.length;\n\t\t\ty += lineHeight\n\t\t) {\n\t\t\tconst blocked = blockedIntervalsForBand(obstacles, y, y + lineHeight);\n\t\t\tconst slots = carveTextLineSlots(\n\t\t\t\t{ left: columnLeft, right: columnRight },\n\t\t\t\tblocked,\n\t\t\t\tMath.max(minSlotWidth, 1e-6),\n\t\t\t);\n\t\t\tfor (const slot of slots) {\n\t\t\t\tif (cursor.segmentIndex >= segments.length) break;\n\t\t\t\tconst slotWidth = slot.right - slot.left;\n\t\t\t\tconst next = layoutNextLine(segments, cursor, slotWidth, {\n\t\t\t\t\thyphenWidth: opts.hyphenWidth,\n\t\t\t\t\tsegmentAdapter,\n\t\t\t\t});\n\t\t\t\tif (next === null) {\n\t\t\t\t\tcursor = { segmentIndex: segments.length, graphemeIndex: 0 };\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tnext.end.segmentIndex === cursor.segmentIndex &&\n\t\t\t\t\tnext.end.graphemeIndex === cursor.graphemeIndex\n\t\t\t\t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcursor = next.end;\n\t\t\t\tif (next.text.length === 0 && next.width === 0) break;\n\t\t\t\tlines.push({\n\t\t\t\t\ttext: next.text,\n\t\t\t\t\twidth: next.width,\n\t\t\t\t\tstartSegment: next.start.segmentIndex,\n\t\t\t\t\tstartGrapheme: next.start.graphemeIndex,\n\t\t\t\t\tendSegment: next.end.segmentIndex,\n\t\t\t\t\tendGrapheme: next.end.graphemeIndex,\n\t\t\t\t\tx: slot.left,\n\t\t\t\t\ty,\n\t\t\t\t\tslotWidth,\n\t\t\t\t\tcolumnIndex,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\tlines,\n\t\tcursor,\n\t\tdone: cursor.segmentIndex >= segments.length,\n\t};\n}\n","import { type Ctx, depLatest } from \"../../ctx/types.js\";\nimport { Node } from \"../../node/node.js\";\nimport { computeBlockFlow, computeTotalHeight } from \"./block.js\";\nimport {\n\tcomputeFlowLines,\n\tsanitizeFlowColumns,\n\tsanitizeFlowContainer,\n\tsanitizeObstacles,\n} from \"./flow.js\";\nimport { computeCharPositions, computeLineBreaks } from \"./line.js\";\nimport { inputNode, latestMeasurementValue, scopedName } from \"./measurements.js\";\nimport { getDefaultSegmentAdapter } from \"./segment.js\";\nimport type {\n\tBlocksMeasurement,\n\tCharPosition,\n\tFlowColumns,\n\tFlowContainer,\n\tFlowLinesResult,\n\tLineBreaksResult,\n\tMeasuredBlock,\n\tMeasurements,\n\tObstacle,\n\tPositionedBlock,\n\tPreparedSegment,\n\tReactiveBlockLayoutBundle,\n\tReactiveBlockLayoutOptions,\n\tReactiveFlowLayoutBundle,\n\tReactiveFlowLayoutOptions,\n\tReactiveLayoutBundle,\n\tReactiveLayoutOptions,\n\tTextSegmentsMeasurement,\n} from \"./types.js\";\nimport { BLOCKS_MEASUREMENT_KIND, TEXT_SEGMENTS_MEASUREMENT_KIND } from \"./types.js\";\nimport { emitLayoutError, nonNegativeFinite } from \"./utils.js\";\n\n/**\n * Create a graph-visible single-column text layout bundle.\n *\n * D181: this adds ordinary state/output nodes only; it does not add protocol behavior,\n * hidden subscriptions, GraphSpec ownership, storage, or platform globals.\n */\nexport function reactiveLayout(opts: ReactiveLayoutOptions): ReactiveLayoutBundle {\n\tconst { measurements, segmentAdapter: segmentAdapterOpt, name = \"reactive-layout\" } = opts;\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst segAdapter = segmentAdapterOpt ?? getDefaultSegmentAdapter();\n\tconst g = opts.graph;\n\tconst lineHeightInput = inputNode(\n\t\tg,\n\t\topts.lineHeight instanceof Node\n\t\t\t? opts.lineHeight\n\t\t\t: nonNegativeFinite(opts.lineHeight ?? 20, 20),\n\t\tnonNegativeFinite(20, 20),\n\t\tscopedName(name, \"line-height\"),\n\t);\n\tconst maxWidthInput = inputNode(\n\t\tg,\n\t\topts.maxWidth instanceof Node ? opts.maxWidth : nonNegativeFinite(opts.maxWidth ?? 800, 800),\n\t\tnonNegativeFinite(800, 800),\n\t\tscopedName(name, \"max-width\"),\n\t);\n\tconst segments = g.node<readonly PreparedSegment[]>(\n\t\t[measurements],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst measured = latestMeasurementValue<TextSegmentsMeasurement>(\n\t\t\t\t\tdepLatest(ctx, 0) as Measurements,\n\t\t\t\t\ttargetId,\n\t\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t);\n\t\t\t\tctx.down([[\"DATA\", measured?.segments ?? []]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveLayout segments failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"segments\") },\n\t);\n\tconst lineBreaks = g.node<LineBreaksResult>(\n\t\t[segments, maxWidthInput.node, measurements],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst measured = latestMeasurementValue<TextSegmentsMeasurement>(\n\t\t\t\t\tdepLatest(ctx, 2) as Measurements,\n\t\t\t\t\ttargetId,\n\t\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t);\n\t\t\t\tconst computed = computeLineBreaks(\n\t\t\t\t\tdepLatest(ctx, 0) as readonly PreparedSegment[],\n\t\t\t\t\tnonNegativeFinite(depLatest(ctx, 1) as number, 0),\n\t\t\t\t\t{ hyphenWidth: measured?.hyphenWidth, segmentAdapter: segAdapter },\n\t\t\t\t);\n\t\t\t\tctx.down([[\"DATA\", computed]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveLayout line breaks failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"line-breaks\") },\n\t);\n\tconst height = g.node<number>(\n\t\t[lineBreaks, lineHeightInput.node],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst lines = depLatest(ctx, 0) as LineBreaksResult;\n\t\t\t\tconst lineHeight = nonNegativeFinite(depLatest(ctx, 1) as number, 0);\n\t\t\t\tctx.down([[\"DATA\", lines.lineCount * lineHeight]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveLayout height failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"height\") },\n\t);\n\tconst charPositions = g.node<readonly CharPosition[]>(\n\t\t[lineBreaks, segments, lineHeightInput.node],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst positions = computeCharPositions(\n\t\t\t\t\tdepLatest(ctx, 0) as LineBreaksResult,\n\t\t\t\t\tdepLatest(ctx, 1) as readonly PreparedSegment[],\n\t\t\t\t\tnonNegativeFinite(depLatest(ctx, 2) as number, 0),\n\t\t\t\t\tsegAdapter,\n\t\t\t\t);\n\t\t\t\tctx.down([[\"DATA\", positions]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveLayout char positions failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"char-positions\") },\n\t);\n\treturn {\n\t\tgraph: g,\n\t\tinput: {\n\t\t\tlineHeight: lineHeightInput.node,\n\t\t\tmaxWidth: maxWidthInput.node,\n\t\t\tmeasurements,\n\t\t},\n\t\tsetLineHeight(lineHeight: number): void {\n\t\t\tlineHeightInput.set(nonNegativeFinite(lineHeight, 0));\n\t\t},\n\t\tsetMaxWidth(maxWidth: number): void {\n\t\t\tmaxWidthInput.set(nonNegativeFinite(maxWidth, 0));\n\t\t},\n\t\tsegments,\n\t\tlineBreaks,\n\t\theight,\n\t\tcharPositions,\n\t};\n}\n\n/**\n * Create a graph-visible vertical block layout bundle over the same DOM-free core.\n *\n * Image/SVG sizing is explicit or injected; no async image loading or DOM SVG parsing occurs.\n */\nexport function reactiveBlockLayout(opts: ReactiveBlockLayoutOptions): ReactiveBlockLayoutBundle {\n\tconst { measurements, name = \"reactive-block-layout\" } = opts;\n\tconst targetId = opts.targetId ?? \"blocks\";\n\tconst g = opts.graph;\n\tconst gapInput = inputNode(\n\t\tg,\n\t\topts.gap instanceof Node ? opts.gap : nonNegativeFinite(opts.gap ?? 0, 0),\n\t\tnonNegativeFinite(0, 0),\n\t\tscopedName(name, \"gap\"),\n\t);\n\tconst measuredBlocks = g.node<readonly MeasuredBlock[]>(\n\t\t[measurements],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst measured = latestMeasurementValue<BlocksMeasurement>(\n\t\t\t\t\tdepLatest(ctx, 0) as Measurements,\n\t\t\t\t\ttargetId,\n\t\t\t\t\tBLOCKS_MEASUREMENT_KIND,\n\t\t\t\t);\n\t\t\t\tctx.down([[\"DATA\", measured?.blocks ?? []]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveBlockLayout measured-blocks failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"measured-blocks\") },\n\t);\n\tconst blockFlow = g.node<readonly PositionedBlock[]>(\n\t\t[measuredBlocks, gapInput.node],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst positioned = computeBlockFlow(\n\t\t\t\t\tdepLatest(ctx, 0) as readonly MeasuredBlock[],\n\t\t\t\t\tnonNegativeFinite(depLatest(ctx, 1) as number, 0),\n\t\t\t\t);\n\t\t\t\tctx.down([[\"DATA\", positioned]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveBlockLayout flow failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"block-flow\") },\n\t);\n\tconst totalHeight = g.node<number>(\n\t\t[blockFlow],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tctx.down([[\"DATA\", computeTotalHeight(depLatest(ctx, 0) as readonly PositionedBlock[])]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveBlockLayout total height failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"total-height\") },\n\t);\n\treturn {\n\t\tgraph: g,\n\t\tinput: {\n\t\t\tgap: gapInput.node,\n\t\t\tmeasurements,\n\t\t},\n\t\tsetGap(gap: number): void {\n\t\t\tgapInput.set(nonNegativeFinite(gap, 0));\n\t\t},\n\t\tmeasuredBlocks,\n\t\tblockFlow,\n\t\ttotalHeight,\n\t};\n}\n\n/** Create a graph-visible multi-column flow layout bundle with rectangle/circle obstacles. */\nexport function reactiveFlowLayout(opts: ReactiveFlowLayoutOptions): ReactiveFlowLayoutBundle {\n\tconst { measurements, segmentAdapter: segmentAdapterOpt, name = \"reactive-flow-layout\" } = opts;\n\tconst targetId = opts.targetId ?? \"text\";\n\tconst segAdapter = segmentAdapterOpt ?? getDefaultSegmentAdapter();\n\tconst g = opts.graph;\n\tconst lineHeightInput = inputNode(\n\t\tg,\n\t\topts.lineHeight instanceof Node\n\t\t\t? opts.lineHeight\n\t\t\t: nonNegativeFinite(opts.lineHeight ?? 20, 20),\n\t\tnonNegativeFinite(20, 20),\n\t\tscopedName(name, \"line-height\"),\n\t);\n\tconst containerInput = inputNode(\n\t\tg,\n\t\topts.container,\n\t\t{ width: 800, height: 600 },\n\t\tscopedName(name, \"container\"),\n\t);\n\tconst columnsInput = inputNode(\n\t\tg,\n\t\topts.columns,\n\t\t{ count: 1, gap: 0 },\n\t\tscopedName(name, \"columns\"),\n\t);\n\tconst obstaclesInput = inputNode(g, opts.obstacles, [], scopedName(name, \"obstacles\"));\n\tconst segments = g.node<readonly PreparedSegment[]>(\n\t\t[measurements],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst measured = latestMeasurementValue<TextSegmentsMeasurement>(\n\t\t\t\t\tdepLatest(ctx, 0) as Measurements,\n\t\t\t\t\ttargetId,\n\t\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t);\n\t\t\t\tctx.down([[\"DATA\", measured?.segments ?? []]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveFlowLayout segments failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"segments\") },\n\t);\n\tconst flowLines = g.node<FlowLinesResult>(\n\t\t[\n\t\t\tsegments,\n\t\t\tlineHeightInput.node,\n\t\t\tcontainerInput.node,\n\t\t\tcolumnsInput.node,\n\t\t\tobstaclesInput.node,\n\t\t\tmeasurements,\n\t\t],\n\t\t(ctx: Ctx) => {\n\t\t\ttry {\n\t\t\t\tconst measured = latestMeasurementValue<TextSegmentsMeasurement>(\n\t\t\t\t\tdepLatest(ctx, 5) as Measurements,\n\t\t\t\t\ttargetId,\n\t\t\t\t\tTEXT_SEGMENTS_MEASUREMENT_KIND,\n\t\t\t\t);\n\t\t\t\tconst computed = computeFlowLines(depLatest(ctx, 0) as readonly PreparedSegment[], {\n\t\t\t\t\tlineHeight: nonNegativeFinite(depLatest(ctx, 1) as number, 0),\n\t\t\t\t\tcontainer: sanitizeFlowContainer(depLatest(ctx, 2) as FlowContainer),\n\t\t\t\t\tcolumns: sanitizeFlowColumns(depLatest(ctx, 3) as FlowColumns),\n\t\t\t\t\tobstacles: sanitizeObstacles(depLatest(ctx, 4) as readonly Obstacle[]),\n\t\t\t\t\tminSlotWidth: nonNegativeFinite(opts.minSlotWidth ?? 0, 0),\n\t\t\t\t\thyphenWidth: measured?.hyphenWidth,\n\t\t\t\t\tsegmentAdapter: segAdapter,\n\t\t\t\t});\n\t\t\t\tctx.down([[\"DATA\", computed]]);\n\t\t\t} catch (error) {\n\t\t\t\temitLayoutError(ctx, error, \"reactiveFlowLayout flow lines failed\");\n\t\t\t}\n\t\t},\n\t\t{ name: scopedName(name, \"flow-lines\") },\n\t);\n\treturn {\n\t\tgraph: g,\n\t\tinput: {\n\t\t\tlineHeight: lineHeightInput.node,\n\t\t\tcontainer: containerInput.node,\n\t\t\tcolumns: columnsInput.node,\n\t\t\tobstacles: obstaclesInput.node,\n\t\t\tmeasurements,\n\t\t},\n\t\tsetLineHeight(lineHeight: number): void {\n\t\t\tlineHeightInput.set(nonNegativeFinite(lineHeight, 0));\n\t\t},\n\t\tsetContainer(container: FlowContainer): void {\n\t\t\tcontainerInput.set(container);\n\t\t},\n\t\tsetColumns(columns: FlowColumns): void {\n\t\t\tcolumnsInput.set(columns);\n\t\t},\n\t\tsetObstacles(obstacles: readonly Obstacle[]): void {\n\t\t\tobstaclesInput.set(obstacles);\n\t\t},\n\t\tsegments,\n\t\tflowLines,\n\t};\n}\n"],"mappings":";;;;;;;;;;;AAEO,IAAM,eAA+B,oBAAI,IAAI;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAEM,IAAM,wBAAwC,oBAAI,IAAI;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAEM,SAAS,MAAM,MAAuB;AAC5C,aAAW,MAAM,MAAM;AACtB,UAAM,IAAI,GAAG,YAAY,CAAC;AAC1B,QACE,MAAM,UAAa,KAAK,SAAS,KAAK,SACtC,MAAM,UAAa,KAAK,SAAS,KAAK,SACtC,MAAM,UAAa,KAAK,SAAS,KAAK,SACtC,MAAM,UAAa,KAAK,SAAS,KAAK,SACtC,MAAM,UAAa,KAAK,SAAS,KAAK,SACtC,MAAM,UAAa,KAAK,SAAS,KAAK,OACtC;AACD,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,oBAAoB,MAAsB;AACzD,SAAO,KAAK,QAAQ,aAAa,GAAG,EAAE,QAAQ,UAAU,EAAE;AAC3D;AAEO,SAAS,YACf,MACA,gBAKG;AACH,QAAM,SAIA,CAAC;AACP,aAAW,KAAK,eAAe,aAAa,IAAI,GAAG;AAClD,UAAM,cAAc,EAAE;AACtB,UAAM,cAAc,E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