@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
@@ -0,0 +1 @@
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/**\n * Segment text and measure every resulting segment with a caller-owned synchronous adapter.\n *\n * @param text - Text to normalize, segment, and measure.\n * @param font - Font descriptor passed through to the measurement adapter.\n * @param adapter - Synchronous measurement adapter used for each segment or grapheme.\n * @param cache - Caller-owned cache keyed by font and segment text.\n * @param stats - Optional cache hit/miss accounting object updated during measurement.\n * @param segmentAdapter - Optional segmentation adapter; defaults to the built-in adapter.\n * @returns A prepared segment list with widths, break kinds, and optional grapheme widths for\n * word-like segments.\n * @example\n * ```ts\n * import { analyzeAndMeasure } from \"@graphrefly/ts/solutions/reactive-layout\";\n *\n * const segments = analyzeAndMeasure(\n * \"Hello world\",\n * \"16px system-ui\",\n * { measureSegment: (segment) => ({ width: segment.length * 8 }) },\n * new Map(),\n * );\n * ```\n * @remarks **Caller-owned adapter:** Measurement stays synchronous and host-injected; browser\n * Canvas, Skia, React Native, or test adapters live outside this helper.\n * @category solutions\n */\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/**\n * Compute greedy single-column line breaks over prepared segments.\n *\n * @param segments - Prepared segments from `analyzeAndMeasure` or a measurement provider.\n * @param maxWidth - Maximum line width in pixels; non-finite or negative values produce no useful\n * width budget.\n * @param opts - Optional hyphen width and segment adapter for grapheme-aware slicing.\n * @returns A `LineBreaksResult` containing ordered layout lines and the line count.\n * @example\n * ```ts\n * import { analyzeAndMeasure, computeLineBreaks } from \"@graphrefly/ts/solutions/reactive-layout\";\n *\n * const segments = analyzeAndMeasure(\n * \"Hello world\",\n * \"16px system-ui\",\n * { measureSegment: (segment) => ({ width: segment.length * 8 }) },\n * new Map(),\n * );\n * const lineBreaks = computeLineBreaks(segments, 64);\n * ```\n * @remarks **Pure helper:** This does not subscribe, schedule, or emit messages; reactive bundles\n * call it from ordinary graph nodes.\n * @category solutions\n */\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/**\n * Compute per-grapheme boxes for already-broken lines.\n *\n * @param lineBreaks - Line break result whose cursors identify the visible grapheme ranges.\n * @param segments - Prepared segments used to produce the line breaks.\n * @param lineHeight - Height assigned to every line box.\n * @param segmentAdapter - Optional segmentation adapter; defaults to the built-in adapter.\n * @returns Character-position boxes in visual order, each with `x`, `y`, `width`, `height`, and\n * zero-based line index.\n * @example\n * ```ts\n * import {\n * analyzeAndMeasure,\n * computeCharPositions,\n * computeLineBreaks,\n * } from \"@graphrefly/ts/solutions/reactive-layout\";\n *\n * const segments = analyzeAndMeasure(\n * \"Hello world\",\n * \"16px system-ui\",\n * { measureSegment: (segment) => ({ width: segment.length * 8 }) },\n * new Map(),\n * );\n * const lineBreaks = computeLineBreaks(segments, 64);\n * const positions = computeCharPositions(lineBreaks, segments, 20);\n * ```\n * @remarks **Already measured:** Widths come from the prepared segments; this helper only maps the\n * line cursors into per-grapheme rectangles.\n * @category solutions\n */\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 * @param opts - Requires a graph and a graph-visible `measurements` node, plus optional\n * `lineHeight`, `maxWidth`, `targetId`, `segmentAdapter`, and bundle `name`.\n * @returns A `ReactiveLayoutBundle` containing input nodes, setters, and graph-visible output\n * nodes for segments, line breaks, height, and character positions.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts\";\n * import {\n * cellTextMeasurements,\n * reactiveLayout,\n * } from \"@graphrefly/ts/solutions/reactive-layout\";\n *\n * const g = graph({ name: \"article\" });\n * const text = g.state(\"Hello GraphReFly\", { name: \"text\" });\n * const font = g.state(\"16px system-ui\", { name: \"font\" });\n * const measurements = cellTextMeasurements({ graph: g, text, font });\n *\n * const layout = reactiveLayout({ graph: g, measurements, maxWidth: 320, lineHeight: 20 });\n * layout.setMaxWidth(280);\n * ```\n * @remarks **Graph-visible:** This creates ordinary state/output nodes only; it does not add\n * protocol behavior, hidden subscriptions, GraphSpec ownership, storage, or platform globals.\n * @category solutions\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 * @param opts - Requires a graph and a graph-visible block `measurements` node, plus optional\n * `gap`, `targetId`, and bundle `name`.\n * @returns A `ReactiveBlockLayoutBundle` containing the gap input, measured block output,\n * positioned block flow, and total height node.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts\";\n * import {\n * blockAdaptersProvider,\n * blockMeasurementProvider,\n * reactiveBlockLayout,\n * type MeasurementAdapter,\n * } from \"@graphrefly/ts/solutions/reactive-layout\";\n *\n * const g = graph({ name: \"cards\" });\n * const blocks = g.state([{ id: \"title\", kind: \"text\", text: \"Hello\" }]);\n * const maxWidth = g.state(320);\n * const text = g.state<MeasurementAdapter>({\n * measureSegment: (segment) => ({ width: segment.length * 8 }),\n * });\n * const measurements = blockMeasurementProvider({\n * graph: g,\n * blocks,\n * maxWidth,\n * adapters: blockAdaptersProvider({ graph: g, text }),\n * });\n *\n * const layout = reactiveBlockLayout({ graph: g, measurements, gap: 12 });\n * layout.setGap(16);\n * ```\n * @remarks **DOM-free:** Image/SVG sizing is explicit or injected; no async image loading or\n * DOM SVG parsing occurs in the core layout bundle.\n * @category solutions\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,M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AI,KAAK,CAAC,CAAC,QAAQ,QAAQ,CAAC,CAAC;AAAA,MAC9B,SAAS,OAAO;AACf,wBAAgB,KAAK,OAAO,sCAAsC;AAAA,MACnE;AAAA,IACD;AAAA,IACA,EAAE,MAAM,WAAW,MAAM,YAAY,EAAE;AAAA,EACxC;AACA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,MACN,YAAY,gBAAgB;AAAA,MAC5B,WAAW,eAAe;AAAA,MAC1B,SAAS,aAAa;AAAA,MACtB,WAAW,eAAe;AAAA,MAC1B;AAAA,IACD;AAAA,IACA,cAAc,YAA0B;AACvC,sBAAgB,IAAI,kBAAkB,YAAY,CAAC,CAAC;AAAA,IACrD;AAAA,IACA,aAAa,WAAgC;AAC5C,qBAAe,IAAI,SAAS;AAAA,IAC7B;AAAA,IACA,WAAW,SAA4B;AACtC,mBAAa,IAAI,OAAO;AAAA,IACzB;AAAA,IACA,aAAa,WAAsC;AAClD,qBAAe,IAAI,SAAS;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":["out","blockMaxWidth","text","endsAtSoftHyphen","explicit","size"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Node,
3
3
  withNodeCore
4
- } from "./chunk-SHZDP2MQ.js";
4
+ } from "./chunk-GXU6WFEJ.js";
5
5
  import {
6
6
  depBatch,
7
7
  depCount,
@@ -551,4 +551,4 @@ export {
551
551
  catchError,
552
552
  valve
553
553
  };
554
- //# sourceMappingURL=chunk-CJIFGJQG.js.map
554
+ //# sourceMappingURL=chunk-54WPEODM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/graph/checkpoint.ts","../src/graph/operators.ts"],"sourcesContent":["/**\n * Graph checkpoint public data shape (D83/D86/D90/D116).\n *\n * Checkpoint is a graph lifecycle snapshot: strict-JSON-compatible data, no storage I/O,\n * no observe-log replay, and no restore runtime in this first TS slice.\n */\n\nimport { type StrictJsonValue, strictJsonCodec } from \"../json/codec.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { NodeVersionJson } from \"../node/versioning.js\";\nimport { SENTINEL } from \"../protocol/messages.js\";\n\nexport const GRAPH_CHECKPOINT_VERSION = \"graphrefly.checkpoint.v1\" as const;\n\nexport type GraphCheckpointVersion = typeof GRAPH_CHECKPOINT_VERSION;\n\nexport type GraphCheckpointJson = StrictJsonValue;\n\nexport type GraphCheckpointValue =\n\t| { kind: \"SENTINEL\" }\n\t| { kind: \"DATA\"; data: GraphCheckpointJson };\n\nexport type GraphCheckpointTerminal =\n\t| { kind: \"none\" }\n\t| { kind: \"COMPLETE\" }\n\t| { kind: \"ERROR\"; error: GraphCheckpointJson };\n\nexport type GraphCheckpointFactory =\n\t| {\n\t\t\tkind: \"registry-ref\";\n\t\t\tref: string;\n\t\t\tconfig?: GraphCheckpointJson;\n\t\t\tconfigVersion?: GraphCheckpointJson;\n\t }\n\t| { kind: \"local-only\"; name: string; reason: string };\n\nexport interface GraphCheckpointNode {\n\tid: string;\n\tname?: string;\n\tfactory: GraphCheckpointFactory;\n\tstatus: string;\n\tdeps: string[];\n\tvalue: GraphCheckpointValue;\n\tbackendState?: GraphCheckpointJson;\n\tversion?: NodeVersionJson;\n\tterminal: GraphCheckpointTerminal;\n\tlifecycle: { activated: boolean; hasCalledFnOnce: boolean };\n\tctxState: { persist: boolean; value: GraphCheckpointValue };\n\tmeta?: { [key: string]: GraphCheckpointJson };\n}\n\nexport interface GraphCheckpointEdge {\n\tfrom: string;\n\tto: string;\n}\n\nexport interface GraphCheckpointMount {\n\tat: string;\n\tcheckpoint: GraphCheckpoint;\n}\n\nexport interface GraphCheckpoint {\n\tversion: GraphCheckpointVersion;\n\tname?: string;\n\tnodes: GraphCheckpointNode[];\n\tedges: GraphCheckpointEdge[];\n\tmounts?: GraphCheckpointMount[];\n}\n\nexport function toCheckpointJson(value: unknown, path = \"$\"): GraphCheckpointJson {\n\ttry {\n\t\treturn strictJsonCodec.decode(strictJsonCodec.encode(value)) as GraphCheckpointJson;\n\t} catch (cause) {\n\t\tthrow new TypeError(`checkpoint: value at ${path} is not strict JSON compatible`, {\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport function checkpointValue(\n\tvalue: unknown,\n\thasData: boolean,\n\tpath: string,\n): GraphCheckpointValue {\n\tif (!hasData || value === SENTINEL) return { kind: \"SENTINEL\" };\n\treturn { kind: \"DATA\", data: toCheckpointJson(value, path) };\n}\n\nexport function checkpointTerminal(value: unknown, path: string): GraphCheckpointTerminal {\n\tif (value === undefined) return { kind: \"none\" };\n\tif (value === true) return { kind: \"COMPLETE\" };\n\treturn { kind: \"ERROR\", error: toCheckpointJson(value, path) };\n}\n\ntype BackendStateContributor = () => unknown;\n\nconst backendStateContributors = new WeakMap<Node<unknown>, BackendStateContributor>();\n\n/** @internal D160: collection-owned backend checkpoint contributor for graph checkpoint. */\nexport function registerBackendStateContributor(\n\tnode: Node<unknown>,\n\tcontributor: BackendStateContributor,\n): void {\n\tbackendStateContributors.set(node, contributor);\n}\n\n/** @internal D160: capture a node's collection backend state when it has a contributor. */\nexport function checkpointBackendStateOfNode(\n\tnode: Node<unknown>,\n\tpath: string,\n): GraphCheckpointJson | undefined {\n\tconst contributor = backendStateContributors.get(node);\n\tif (contributor === undefined) return undefined;\n\treturn toCheckpointJson(contributor(), path);\n}\n","/**\n * Operators as free-standing factory definitions (D43 / D6 / D40 Catalog-first).\n *\n * Operators are `node` sugar (D6), NOT verbs (D4) and NEVER in parity (D24). Each is a\n * pure {@link Operator} spec — `{factory, body, opts}` — built on the bare `node` primitive\n * (NOT the `derived` verb): `body` reads ctx dep slots positionally and emits via\n * `ctx.down`. Two ways to instantiate:\n *\n * - {@link initNode}(op, deps, opts?) — bare, no Graph; returns a working `Node<T>`.\n * - `g.initNode(op, deps, opts?)` — graph-bound; the SAME call, plus inspection registration\n * (the real factory name lands in the graph's `_entries`, so describe/observe/profile\n * show it — D6/R-describe — while the node stays thin, R-node-thin).\n *\n * The D30 throw→ERROR boundary lives once, in the free {@link initNode} (which `g.initNode`\n * funnels through). The pure-ts `operatorOpts/partialOperatorOpts/gatedOperatorOpts` trio is\n * NOT ported: its sole job (`describeKind:\"derived\"`) is dead under D6/D39 (factory = the\n * REAL operator name); only the `partial`/`terminalAsRealInput` flags survive, carried\n * per-operator in `op.opts`.\n *\n * Config is folded into the factory (`map(fn)`, `scan(reducer, seed)`, `take(n)`, `merge()`),\n * so fn params are annotated where the source type can't be inferred (RxJS-pipe cost);\n * dep-type safety is recovered by the typed `g.initNode` overloads.\n */\n\nimport {\n\ttype Ctx,\n\tdepBatch,\n\tdepCount,\n\tdepLatest,\n\tdepTerminal,\n\tisTerminalComplete,\n\tisTerminalError,\n\ttype NodeFn,\n\tterminalErrorValue,\n} from \"../ctx/types.js\";\nimport type { NodeCore } from \"../node/core.js\";\nimport { Node, type NodeOptions, withNodeCore } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\nimport { type GraphCheckpointJson, toCheckpointJson } from \"./checkpoint.js\";\nimport type { GraphRestoreDefinition, GraphRestoreEntry, GraphRestoreRegistry } from \"./restore.js\";\n\n/**\n * A free-standing operator definition (D43). `TIn` = the element type each dep delivers\n * (the operator reads `depLatest(ctx, i) as TIn`); `TOut` = the emitted value type.\n * `__in`/`__out` are phantom-only (never assigned) — they let `g.initNode` infer + check the\n * dep tuple against the operator without an explicit type argument.\n */\nexport interface Operator<TIn = unknown, TOut = unknown> {\n\t/** Real operator name shown in describe (D6/L1.5) — recorded at `_add` by `g.initNode`. */\n\treadonly factory: string;\n\t/** The ctx-body: reads ctx dep slots positionally, emits via `ctx.down`. */\n\treadonly body: (ctx: Ctx) => void;\n\t/** Behavioral node options the operator needs (e.g. `partial:true` for combine-family). */\n\treadonly opts?: Partial<NodeOptions<TOut>>;\n\t/**\n\t * D97/D100 restore metadata derived from a named definition or static built-in config.\n\t * This is semantic metadata only; dispatcher handles stay graph-local runtime state.\n\t */\n\treadonly restore?: {\n\t\tref: string;\n\t\tconfig?: GraphCheckpointJson;\n\t\tconfigVersion?: GraphCheckpointJson;\n\t};\n\t/** @internal phantom — never set; carries the dep element type for `g.initNode` inference. */\n\treadonly __in?: TIn;\n\t/** @internal phantom — never set; carries the output value type. */\n\treadonly __out?: TOut;\n}\n\ntype MutableRestoreRegistry = Map<string, GraphRestoreEntry> | Record<string, GraphRestoreEntry>;\n\nexport type RestoreRegistryEntry = GraphRestoreEntry;\n\nexport interface Definition<S = unknown, T = unknown> extends GraphRestoreDefinition<S, T> {\n\treadonly ref: string;\n\treadonly fn: (v: S) => T;\n}\n\nexport interface DefineOpts {\n\tregistry?: MutableRestoreRegistry;\n}\n\nfunction registryHas(registry: MutableRestoreRegistry, ref: string): boolean {\n\treturn registry instanceof Map ? registry.has(ref) : Object.hasOwn(registry, ref);\n}\n\nfunction registrySet(\n\tregistry: MutableRestoreRegistry,\n\tref: string,\n\tentry: GraphRestoreEntry,\n): void {\n\tif (registryHas(registry, ref)) {\n\t\tthrow new Error(`restoreRegistry: duplicate ref '${ref}'`);\n\t}\n\tif (registry instanceof Map) registry.set(ref, entry);\n\telse registry[ref] = entry;\n}\n\nexport function addToRestoreRegistry(\n\tregistry: MutableRestoreRegistry,\n\tentry: GraphRestoreEntry,\n): void {\n\tregistrySet(registry, entry.ref, entry);\n}\n\nexport function restoreRegistry(\n\tentries: readonly GraphRestoreEntry[] = [],\n\tbase?: GraphRestoreRegistry,\n): Map<string, GraphRestoreEntry> {\n\tconst out = new Map<string, GraphRestoreEntry>();\n\tif (base instanceof Map) {\n\t\tfor (const [ref, entry] of base) registrySet(out, ref, entry);\n\t} else if (base !== undefined) {\n\t\tfor (const [ref, entry] of Object.entries(base)) registrySet(out, ref, entry);\n\t}\n\tfor (const entry of entries) addToRestoreRegistry(out, entry);\n\treturn out;\n}\n\nfunction isDefinition<S, T>(fn: ((v: S) => T) | Definition<S, T>): fn is Definition<S, T> {\n\treturn typeof fn === \"object\" && fn !== null && (fn as Definition<S, T>).kind === \"definition\";\n}\n\nexport function define<S, T>(\n\tref: string,\n\tfn: (v: S) => T,\n\topts: DefineOpts = {},\n): Definition<S, T> {\n\tconst jsonRef = toCheckpointJson(ref, \"define.ref\");\n\tif (typeof jsonRef !== \"string\") throw new TypeError(\"define: ref must be a string\");\n\tconst definition: Definition<S, T> = {\n\t\tkind: \"definition\",\n\t\tref: jsonRef,\n\t\tfn,\n\t};\n\tif (opts.registry !== undefined) addToRestoreRegistry(opts.registry, definition);\n\treturn definition;\n}\n\n/**\n * Instantiate an operator as a bare `Node<T>` — NO Graph required (D43 bare-node path).\n * Wraps `op.body` in the D30 value-throw→ERROR boundary; merges `op.opts` with caller `opts`\n * (caller wins, so `partial`/`pool`/`dispatcher` overrides take effect). The\n * dispatcher defaults to the process-global (D26) unless `opts.dispatcher` is passed.\n *\n * `g.initNode` is the same call PLUS graph registration; graph inspection\n * (describe/observe/profile) requires that path — a node built bare here is not registered in\n * any graph's index.\n */\nexport function initNode<TIn, TOut>(\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut> = {},\n): Node<TOut> {\n\treturn makeInitNode(op, deps, opts);\n}\n\n/** @internal Graph-bound operator instantiation into a graph-local B49 core. */\nexport function initNodeWithCore<TIn, TOut>(\n\tcore: NodeCore,\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut> = {},\n): Node<TOut> {\n\treturn withNodeCore(core, () => makeInitNode(op, deps, opts));\n}\n\nfunction makeInitNode<TIn, TOut>(\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut>,\n): Node<TOut> {\n\tconst body = operatorNodeFn(op);\n\t// D43-reserved / D51: stamp the operator's real factory onto the bare node so a runtime *Map\n\t// inner (created here via fromAny, NOT registered in any graph) is named in describe's\n\t// auto-discovery. A graph-bound g.initNode also records it in `_entries` (entry.factory wins\n\t// there); this field is only read for a node absent from the graph index. Caller opts win.\n\treturn new Node<TOut>([...deps], body, { factory: op.factory, ...op.opts, ...opts });\n}\n\n/** @internal Build the dispatcher body for an Operator spec. */\nexport function operatorNodeFn<TIn, TOut>(op: Operator<TIn, TOut>): NodeFn {\n\treturn (ctx) => {\n\t\ttry {\n\t\t\top.body(ctx);\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"operator threw without a valid error payload\")]]); // D30: value-level throw → ERROR\n\t\t}\n\t};\n}\n\n// ── Slice 1 — single-dep map / take / control (CSP-2.7 catalog re-derive, D40) ──\n// All read dep 0 positionally + emit via ctx.down. Under D49 every occurrence is DATA (no\n// equals-absorption); a body that returns WITHOUT emitting gets a substrate-synthesized undirty\n// RESOLVED (R-resolved-undirty) — so a \"skip this wave\" is a bare `return`. Terminal-emitting\n// operators (reduce/last/find/elementAt) read `depTerminal(ctx, 0)` via the\n// `completeWhenDepsComplete:false + terminalAsRealInput:true` flags (R-deps-terminal): the fn fires\n// on the source's COMPLETE and emits its final value. NOT 1:1 pure-ts ports — the frozen reference\n// (D41) uses a producer + internal `subscribeOr`, the D45-banned describe island; these are\n// declared-dep nodes whose single edge `describe` shows truthfully.\n\n/**\n * Transform each upstream DATA value with a synchronous mapping function.\n *\n * @param fn - Mapping function, or a named `define()` definition for checkpoint restoration.\n * @returns An operator that emits `fn(value)` for each upstream value.\n * @example\n * ```ts\n * import { graph, map } from \"@graphrefly/ts\";\n *\n * const g = graph();\n * const count = g.state(1);\n * const doubled = g.initNode(map((value: number) => value * 2), [count]);\n * ```\n * @remarks **Restorable maps:** Passing a named `define()` registers semantic restore metadata.\n * @category operators\n */\nexport function map<S, T>(fn: ((v: S) => T) | Definition<S, T>): Operator<S, T> {\n\tif (isDefinition(fn)) {\n\t\treturn mapFromFunction(fn.fn, {\n\t\t\tref: \"map\",\n\t\t\tconfig: { fn: toCheckpointJson(fn.ref, `map.fn`) },\n\t\t});\n\t}\n\treturn mapFromFunction(fn);\n}\n\nfunction mapFromFunction<S, T>(\n\tfn: (v: S) => T,\n\trestore?: {\n\t\tref: string;\n\t\tconfig?: GraphCheckpointJson;\n\t\tconfigVersion?: GraphCheckpointJson;\n\t},\n): Operator<S, T> {\n\treturn {\n\t\tfactory: \"map\",\n\t\t...(restore ? { restore } : {}),\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b) ctx.down([[\"DATA\", fn(v as S)]]);\n\t\t},\n\t};\n}\n\n/**\n * Pass through upstream values that satisfy a predicate.\n *\n * @param pred - Predicate evaluated for each upstream DATA value.\n * @returns An operator that emits matching values and stays quiet for non-matches.\n * @example\n * ```ts\n * import { filter, graph } from \"@graphrefly/ts\";\n *\n * const g = graph();\n * const count = g.state(0);\n * const even = g.initNode(filter((value: number) => value % 2 === 0), [count]);\n * ```\n * @category operators\n */\nexport function filter<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"filter\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b) if (pred(v as S)) ctx.down([[\"DATA\", v]]);\n\t\t},\n\t};\n}\n\n/**\n * Accumulate upstream values and emit each intermediate accumulator.\n *\n * @param reducer - Reducer called with the previous accumulator and each upstream value.\n * @param seed - Initial accumulator value.\n * @returns An operator that emits the accumulator after every input value.\n * @example\n * ```ts\n * import { graph, scan } from \"@graphrefly/ts\";\n *\n * const g = graph();\n * const values = g.state(1);\n * const total = g.initNode(scan((sum: number, value: number) => sum + value, 0), [values]);\n * ```\n * @category operators\n */\nexport function scan<S, T>(reducer: (acc: T, v: S) => T, seed: T): Operator<S, T> {\n\treturn {\n\t\tfactory: \"scan\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet acc = ctx.state.get<T>() ?? seed;\n\t\t\tfor (const v of b) {\n\t\t\t\tacc = reducer(acc, v as S);\n\t\t\t\tctx.down([[\"DATA\", acc]]);\n\t\t\t}\n\t\t\tctx.state.set(acc);\n\t\t},\n\t};\n}\n\n/**\n * Emit the first `n` upstream values, then complete.\n *\n * @param n - Number of DATA values to pass before completion.\n * @returns An operator that forwards at most `n` values and then emits COMPLETE.\n * @example\n * ```ts\n * import { graph, take } from \"@graphrefly/ts\";\n *\n * const firstThree = graph().initNode(take<number>(3), [source]);\n * ```\n * @category operators\n */\nexport function take<S>(n: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"take\",\n\t\trestore: { ref: \"take\", config: { n: toCheckpointJson(n, \"take.n\") } },\n\t\tbody: (ctx) => {\n\t\t\tif (n <= 0) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tif (count >= n) return; // already satisfied\n\t\t\tfor (const v of b) {\n\t\t\t\tif (count >= n) break;\n\t\t\t\tcount += 1;\n\t\t\t\tctx.down(count >= n ? [[\"DATA\", v], [\"COMPLETE\"]] : [[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(count);\n\t\t},\n\t};\n}\n\n/**\n * Suppress consecutive duplicate values.\n *\n * @param eq - Equality predicate; defaults to `Object.is`.\n * @returns An operator that emits only when the next value differs from the previous emitted value.\n * @example\n * ```ts\n * import { distinctUntilChanged, graph } from \"@graphrefly/ts\";\n *\n * const stable = graph().initNode(distinctUntilChanged<number>(), [source]);\n * ```\n * @category operators\n */\nexport function distinctUntilChanged<S>(eq: (a: S, b: S) => boolean = Object.is): Operator<S, S> {\n\treturn {\n\t\tfactory: \"distinctUntilChanged\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tconst prev = ctx.state.get<{ v: S }>();\n\t\t\tlet last = prev?.v;\n\t\t\tlet hasLast = prev !== undefined;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (hasLast && eq(last as S, v)) continue;\n\t\t\t\tlast = v;\n\t\t\t\thasLast = true;\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tif (hasLast) ctx.state.set({ v: last as S });\n\t\t},\n\t};\n}\n\n/**\n * merge: interleave several sources — emit each DATA from whichever dep fired. `partial:true`\n * (combine-family): fires on any single dep, not gated on all deps settling.\n *\n * @returns An operator that forwards DATA from any dependency.\n * @example\n * ```ts\n * import { graph, merge } from \"@graphrefly/ts\";\n *\n * const merged = graph().initNode(merge<number>(), [left, right]);\n * ```\n * @category operators\n */\nexport function merge<T>(): Operator<T, T> {\n\treturn {\n\t\tfactory: \"merge\",\n\t\topts: { partial: true },\n\t\tbody: (ctx) => {\n\t\t\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\t\t\tconst b = depBatch(ctx, i);\n\t\t\t\tif (b && b.length > 0) {\n\t\t\t\t\tfor (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * reduce: accumulate over the whole source, emit ONE final value on the source's COMPLETE\n * (RxJS `reduce`). Unlike {@link scan} (which emits every step), reduce stays quiet until the\n * source terminates. `completeWhenDepsComplete:false + terminalAsRealInput:true`: the fn fires on\n * the source COMPLETE (reading `terminal===true`) and emits the accumulator + COMPLETE. An empty\n * source emits the seed (RxJS parity). A source ERROR auto-forwards (errorWhenDepsError default).\n *\n * @param reducer - Reducer called with the accumulator and each upstream DATA value.\n * @param seed - Initial accumulator value emitted if the source completes empty.\n * @returns An operator that emits one accumulated value when the source completes.\n * @example\n * ```ts\n * import { graph, reduce } from \"@graphrefly/ts\";\n *\n * const total = graph().initNode(reduce((sum: number, value: number) => sum + value, 0), [source]);\n * ```\n * @category operators\n */\nexport function reduce<S, T>(reducer: (acc: T, v: S) => T, seed: T): Operator<S, T> {\n\treturn {\n\t\tfactory: \"reduce\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet acc = ctx.state.get<T>() ?? seed;\n\t\t\tif (b) for (const v of b) acc = reducer(acc, v as S);\n\t\t\tctx.state.set(acc);\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"DATA\", acc], [\"COMPLETE\"]]);\n\t\t\t// else (live DATA wave): no emit → substrate-synthesized undirty RESOLVED (D49).\n\t\t},\n\t};\n}\n\n/**\n * pairwise: emit `[previous, current]` for each consecutive pair; the very first value produces no\n * pair (quiet → undirty RESOLVED). Previous value is kept in `ctx.state`.\n */\nexport function pairwise<S>(): Operator<S, readonly [S, S]> {\n\treturn {\n\t\tfactory: \"pairwise\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tconst st = ctx.state.get<{ prev: S }>();\n\t\t\tlet prev = st?.prev;\n\t\t\tlet hasPrev = st !== undefined;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (hasPrev) ctx.down([[\"DATA\", [prev as S, v] as const]]);\n\t\t\t\tprev = v;\n\t\t\t\thasPrev = true;\n\t\t\t}\n\t\t\tif (hasPrev) ctx.state.set({ prev: prev as S });\n\t\t},\n\t};\n}\n\n/** skip: drop the first `n` DATA values, then pass the rest through. */\nexport function skip<S>(n: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"skip\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tfor (const v of b) {\n\t\t\t\tif (count < n) {\n\t\t\t\t\tcount += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(count);\n\t\t},\n\t};\n}\n\n/**\n * takeWhile: emit values while `pred` holds; on the first value that fails `pred`, COMPLETE\n * WITHOUT emitting it (RxJS default, non-inclusive). Terminal-is-forever once it completes.\n */\nexport function takeWhile<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"takeWhile\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (pred(v)) ctx.down([[\"DATA\", v]]);\n\t\t\t\telse {\n\t\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * first: emit the first value matching `pred` (or simply the first value), then COMPLETE. EDGE\n * (RxJS divergence, flagged — same class as last/find/elementAt): if the source COMPLETEs with no\n * matching value, the substrate auto-cascades a bare COMPLETE (no value); RxJS `first()` throws\n * EmptyError. Could align to `[[ERROR, EmptyError]]` (expressible) if strict RxJS parity is wanted.\n */\nexport function first<S>(pred?: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"first\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (!pred || pred(v)) {\n\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// no match in this wave → undirty RESOLVED (await next match)\n\t\t},\n\t};\n}\n\n/**\n * last: emit the last value matching `pred` (or the last value) on the source's COMPLETE.\n * `completeWhenDepsComplete:false + terminalAsRealInput:true`. EDGE (RxJS divergence, flagged):\n * RxJS `last()` throws EmptyError when no value matched; we COMPLETE without a value (no throw) —\n * the clean-slate substrate has no \"complete-or-throw\" terminal and SENTINEL forbids emitting a\n * placeholder.\n */\nexport function last<S>(pred?: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"last\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b) for (const v of b) if (!pred || pred(v as S)) ctx.state.set({ v });\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) {\n\t\t\t\tconst st = ctx.state.get<{ v: S }>();\n\t\t\t\tctx.down(st ? [[\"DATA\", st.v], [\"COMPLETE\"]] : [[\"COMPLETE\"]]);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * find: emit the first value matching `pred`, then COMPLETE. EDGE (RxJS divergence, flagged): RxJS\n * `find` emits `undefined` then COMPLETE when nothing matched — but `undefined` IS the SENTINEL\n * (R-sentinel), so a not-found source COMPLETE here emits a bare COMPLETE (no value).\n */\nexport function find<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"find\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tif (pred(v as S)) {\n\t\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"COMPLETE\"]]); // not found → bare COMPLETE\n\t\t},\n\t};\n}\n\n/**\n * elementAt: emit the value at zero-based `index`, then COMPLETE. EDGE (RxJS divergence, flagged):\n * RxJS throws ArgumentOutOfRangeError if the source completes before `index`; we COMPLETE without\n * a value (no throw), consistent with last/find.\n */\nexport function elementAt<S>(index: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"elementAt\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tif (b) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tif (count === index) {\n\t\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tctx.state.set(count);\n\t\t\t}\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"COMPLETE\"]]); // index out of range → bare COMPLETE\n\t\t},\n\t};\n}\n\n/** Observer object for {@link tap} — lifecycle-aware side effects (RxJS tap observer form). */\nexport interface TapObserver<T> {\n\tdata?: (value: T) => void;\n\terror?: (err: unknown) => void;\n\tcomplete?: () => void;\n}\n\n/**\n * tap: invoke a side effect on each DATA (function form) or on data/error/complete (observer form);\n * values pass through unchanged. The observer form reads source terminals\n * (`completeWhenDepsComplete:false + errorWhenDepsError:false + terminalAsRealInput:true`) so it can\n * call `error`/`complete` then forward the terminal; the function form lets the substrate\n * auto-cascade terminals.\n */\nexport function tap<S>(fnOrObserver: ((v: S) => void) | TapObserver<S>): Operator<S, S> {\n\tif (typeof fnOrObserver === \"function\") {\n\t\tconst fn = fnOrObserver;\n\t\treturn {\n\t\t\tfactory: \"tap\",\n\t\t\tbody: (ctx) => {\n\t\t\t\tconst b = depBatch(ctx, 0);\n\t\t\t\tif (b)\n\t\t\t\t\tfor (const v of b) {\n\t\t\t\t\t\tfn(v as S);\n\t\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\tconst obs = fnOrObserver;\n\treturn {\n\t\tfactory: \"tap\",\n\t\topts: {\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t\tbody: (ctx) => {\n\t\t\tconst terminal = depTerminal(ctx, 0);\n\t\t\tif (isTerminalComplete(terminal)) {\n\t\t\t\tobs.complete?.();\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isTerminalError(terminal)) {\n\t\t\t\tconst err = terminalErrorValue(terminal);\n\t\t\t\tobs.error?.(err);\n\t\t\t\tctx.down([[\"ERROR\", err]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b)\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tobs.data?.(v as S);\n\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * onFirstData (alias `tapFirst`): invoke `fn` exactly once on the first qualifying value (default\n * `where: v => v != null` — null/undefined pass through without counting as \"first\"), then pass all\n * values through unchanged. The one-shot guard is per-node `ctx.state` (NOT a factory closure, so a\n * second instantiation of the same factory re-arms — R-ctx-state).\n */\nexport function onFirstData<S>(\n\tfn: (v: S) => void,\n\topts?: { where?: (v: S) => boolean },\n): Operator<S, S> {\n\tconst where = opts?.where ?? ((v: S) => v != null);\n\treturn {\n\t\tfactory: \"onFirstData\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet fired = ctx.state.get<boolean>() ?? false;\n\t\t\tfor (const v of b) {\n\t\t\t\tif (!fired && where(v as S)) {\n\t\t\t\t\tfired = true;\n\t\t\t\t\tfn(v as S);\n\t\t\t\t}\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(fired);\n\t\t},\n\t};\n}\n\n/** tapFirst: alias of {@link onFirstData} (the one-shot companion to {@link tap}). */\nexport const tapFirst = onFirstData;\n\n/** Options for {@link settle}. */\nexport interface SettleOpts<S> {\n\t/** Consecutive no-change waves before declaring convergence + COMPLETE. */\n\tquietWaves: number;\n\t/** Optional hard cap on total waves before forced COMPLETE. */\n\tmaxWaves?: number;\n\t/** Optional comparator; a DATA equal to the previous one does NOT reset the quiet counter. */\n\tequals?: (a: S, b: S) => boolean;\n}\n\n/** Internal settle accumulator state (per-node, R-ctx-state). */\ninterface SettleState<S> {\n\tlast: S | undefined;\n\thasValue: boolean;\n\tquiet: number;\n\twaves: number;\n\tdone: boolean;\n}\n\n/**\n * settle: forward each DATA unchanged, watch for convergence, COMPLETE once the source has been\n * quiet for `quietWaves` consecutive waves (or `maxWaves` elapsed). \"Wave\" = one fn invocation\n * (a DATA batch OR a bare undirty RESOLVED end-of-wave). No polling (R-no-polling) — the counter\n * advances only on real upstream waves. `settle`'s own `equals` is a body comparator, NOT the\n * removed substrate `equals` (D49).\n */\nexport function settle<S>(opts: SettleOpts<S>): Operator<S, S> {\n\tconst { quietWaves, maxWaves, equals } = opts;\n\tif (!Number.isInteger(quietWaves) || quietWaves < 1) {\n\t\tthrow new RangeError(`settle: quietWaves must be a positive integer (got ${quietWaves})`);\n\t}\n\tif (maxWaves != null && (!Number.isInteger(maxWaves) || maxWaves < 1)) {\n\t\tthrow new RangeError(`settle: maxWaves must be a positive integer when set (got ${maxWaves})`);\n\t}\n\treturn {\n\t\tfactory: \"settle\",\n\t\tbody: (ctx) => {\n\t\t\tconst st: SettleState<S> = ctx.state.get<SettleState<S>>() ?? {\n\t\t\t\tlast: undefined,\n\t\t\t\thasValue: false,\n\t\t\t\tquiet: 0,\n\t\t\t\twaves: 0,\n\t\t\t\tdone: false,\n\t\t\t};\n\t\t\tif (st.done) return;\n\t\t\tst.waves++;\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet sawChange = false;\n\t\t\tif (b && b.length > 0) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tconst next = v as S;\n\t\t\t\t\tconst isChange = !st.hasValue || equals == null || !equals(st.last as S, next);\n\t\t\t\t\tif (isChange) sawChange = true;\n\t\t\t\t\tst.last = next;\n\t\t\t\t\tst.hasValue = true;\n\t\t\t\t\tctx.down([[\"DATA\", next]]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tst.quiet = sawChange ? 0 : st.quiet + 1;\n\t\t\tconst settled = st.hasValue && st.quiet >= quietWaves;\n\t\t\tconst exhausted = maxWaves != null && st.waves >= maxWaves;\n\t\t\tif (settled || exhausted) {\n\t\t\t\tst.done = true;\n\t\t\t\tctx.state.set(st);\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.state.set(st);\n\t\t\t// A no-DATA wave that didn't converge → bare undirty RESOLVED is synthesized by the\n\t\t\t// substrate (D49); nothing to emit here.\n\t\t},\n\t};\n}\n\n// ── Slice 3 — error-handling control (CSP-2.7, D40) ──\n// rescue/catchError ABSORB the source ERROR (errorWhenDepsError:false) and read the error payload\n// from `depTerminal(ctx, 0)` (R-deps-terminal). They set completeWhenDepsComplete:false so a\n// normal source COMPLETE is forwarded explicitly — which ALSO sidesteps B40 (the\n// completeWhenDepsComplete:true × absorbed-errored-dep auto-complete gap): there is no auto-complete\n// to block. valve is a [source, control] gate (state-verb-legitimate control input).\n\n/**\n * rescue (alias `catchError`): replace an upstream ERROR with a recovered value. On source DATA →\n * forward; on source ERROR → emit `recover(err)` as DATA (if `recover` throws, forward THAT as\n * ERROR); on source COMPLETE → COMPLETE. After recovery the source is terminal-errored (dead) so no\n * further values flow — the recovered value is the final cached value (matches the frozen pure-ts\n * reference; it does NOT auto-COMPLETE, RxJS-`catchError(()=>of(x))` divergence, flagged).\n */\nexport function rescue<S>(recover: (err: unknown) => S): Operator<S, S> {\n\treturn {\n\t\tfactory: \"rescue\",\n\t\topts: {\n\t\t\terrorWhenDepsError: false,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tconst terminal = depTerminal(ctx, 0);\n\t\t\tif (b) for (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\tif (isTerminalComplete(terminal)) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t} else if (isTerminalError(terminal)) {\n\t\t\t\t// ERROR payload absorbed → recover.\n\t\t\t\ttry {\n\t\t\t\t\tctx.down([[\"DATA\", recover(terminalErrorValue(terminal))]]);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"rescue threw without a valid error payload\")]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/** catchError: RxJS-named alias of {@link rescue}. */\nexport const catchError = rescue;\n\n/** Options for {@link valve}. */\nexport interface ValveOpts {\n\t/**\n\t * Optional AbortController (or a `() => AbortController | undefined` factory): on the control's\n\t * truthy→falsy edge, `valve` calls `controller.abort()` — cancel an in-flight async boundary\n\t * (LLM/fetch) the caller threaded `controller.signal` into. An external-resource cleanup (like\n\t * `ctx.onDeactivation`), NOT an imperative reactive trigger (R-no-imperative).\n\t */\n\tabortInFlight?: AbortController | (() => AbortController | undefined);\n}\n\n/**\n * valve: forward the source's DATA only while `control` (dep 1) is truthy; when closed, stay quiet\n * (undirty RESOLVED). `[source, control]` declared deps + `partial:true` (the control wave can fire\n * before the source ever delivers). `completeWhenDepsComplete:false` — closing the gate (control\n * terminating) does NOT complete the valve; only the SOURCE's terminal (read via\n * `terminalAsRealInput`) is forwarded. The `state`-verb control input is a legitimate external\n * boundary (D4 / D54), not a forbidden imperative trigger.\n */\nexport function valve<S>(opts?: ValveOpts): Operator<S, S> {\n\tconst abortInFlight = opts?.abortInFlight;\n\treturn {\n\t\tfactory: \"valve\",\n\t\topts: { partial: true, completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst srcBatch = depBatch(ctx, 0);\n\t\t\tconst ctlBatch = depBatch(ctx, 1);\n\t\t\tconst srcTerminal = depTerminal(ctx, 0);\n\t\t\tconst controlValue = depLatest(ctx, 1) as boolean | undefined;\n\n\t\t\tif (abortInFlight != null) {\n\t\t\t\t// Fire abort on the truthy→falsy edge only (never on activation / no prior state).\n\t\t\t\tconst prev = ctx.state.get<{ ctl: boolean | undefined }>();\n\t\t\t\tif (prev?.ctl === true && !controlValue) {\n\t\t\t\t\tconst c = typeof abortInFlight === \"function\" ? abortInFlight() : abortInFlight;\n\t\t\t\t\tc?.abort();\n\t\t\t\t}\n\t\t\t\tctx.state.set({\n\t\t\t\t\tctl: controlValue === true ? true : controlValue == null ? undefined : false,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Source terminal forwarding (control terminal is absorbed by completeWhenDepsComplete:false).\n\t\t\tif (isTerminalComplete(srcTerminal)) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isTerminalError(srcTerminal)) {\n\t\t\t\tctx.down([[\"ERROR\", terminalErrorValue(srcTerminal)]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!controlValue) return; // gate closed → quiet (undirty RESOLVED)\n\n\t\t\tif (srcBatch && srcBatch.length > 0) {\n\t\t\t\tfor (const v of srcBatch) ctx.down([[\"DATA\", v]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Gate just opened this wave (control fired, source didn't): re-emit the last source value.\n\t\t\tconst srcLatest = depLatest(ctx, 0);\n\t\t\tif (ctlBatch && ctlBatch.length > 0 && srcLatest !== undefined) {\n\t\t\t\tctx.down([[\"DATA\", srcLatest as S]]);\n\t\t\t}\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYO,IAAM,2BAA2B;AAyDjC,SAAS,iBAAiB,OAAgB,OAAO,KAA0B;AACjF,MAAI;AACH,WAAO,gBAAgB,OAAO,gBAAgB,OAAO,KAAK,CAAC;AAAA,EAC5D,SAAS,OAAO;AACf,UAAM,IAAI,UAAU,wBAAwB,IAAI,kCAAkC;AAAA,MACjF;AAAA,IACD,CAAC;AAAA,EACF;AACD;AAEO,SAAS,gBACf,OACA,SACA,MACuB;AACvB,MAAI,CAAC,WAAW,UAAU,SAAU,QAAO,EAAE,MAAM,WAAW;AAC9D,SAAO,EAAE,MAAM,QAAQ,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c;AACxC,gBAAM,IAAI,OAAO,kBAAkB,aAAa,cAAc,IAAI;AAClE,aAAG,MAAM;AAAA,QACV;AACA,YAAI,MAAM,IAAI;AAAA,UACb,KAAK,iBAAiB,OAAO,OAAO,gBAAgB,OAAO,SAAY;AAAA,QACxE,CAAC;AAAA,MACF;AAGA,UAAI,mBAAmB,WAAW,GAAG;AACpC,YAAI,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC;AACvB;AAAA,MACD;AACA,UAAI,gBAAgB,WAAW,GAAG;AACjC,YAAI,KAAK,CAAC,CAAC,SAAS,mBAAmB,WAAW,CAAC,CAAC,CAAC;AACrD;AAAA,MACD;AAEA,UAAI,CAAC,aAAc;AAEnB,UAAI,YAAY,SAAS,SAAS,GAAG;AACpC,mBAAW,KAAK,SAAU,KAAI,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChD;AAAA,MACD;AAEA,YAAM,YAAY,UAAU,KAAK,CAAC;AAClC,UAAI,YAAY,SAAS,SAAS,KAAK,cAAc,QAAW;AAC/D,YAAI,KAAK,CAAC,CAAC,QAAQ,SAAc,CAAC,CAAC;AAAA,MACpC;AAAA,IACD;AAAA,EACD;AACD;","names":["last"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  initNode,
3
3
  toCheckpointJson
4
- } from "./chunk-CJIFGJQG.js";
4
+ } from "./chunk-54WPEODM.js";
5
5
  import {
6
6
  errorPayload
7
7
  } from "./chunk-S6HXABGL.js";
@@ -768,4 +768,4 @@ export {
768
768
  firstValueFrom,
769
769
  singleFromAny
770
770
  };
771
- //# sourceMappingURL=chunk-CX6B6PO2.js.map
771
+ //# sourceMappingURL=chunk-DKFWDTVY.js.map