@flanksource/clicky-ui 0.3.41 → 0.3.42

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 (472) hide show
  1. package/dist/ai.cjs +4 -0
  2. package/dist/ai.cjs.map +1 -1
  3. package/dist/ai.js +4 -0
  4. package/dist/ai.js.map +1 -1
  5. package/dist/comments/CommentCard.cjs +3 -1
  6. package/dist/comments/CommentCard.cjs.map +1 -1
  7. package/dist/comments/CommentCard.d.ts.map +1 -1
  8. package/dist/comments/CommentCard.js +4 -2
  9. package/dist/comments/CommentCard.js.map +1 -1
  10. package/dist/comments/CommentCardParts.cjs +16 -0
  11. package/dist/comments/CommentCardParts.cjs.map +1 -1
  12. package/dist/comments/CommentCardParts.d.ts +4 -1
  13. package/dist/comments/CommentCardParts.d.ts.map +1 -1
  14. package/dist/comments/CommentCardParts.js +16 -0
  15. package/dist/comments/CommentCardParts.js.map +1 -1
  16. package/dist/comments/comment-types.cjs.map +1 -1
  17. package/dist/comments/comment-types.d.ts +4 -0
  18. package/dist/comments/comment-types.d.ts.map +1 -1
  19. package/dist/comments/comment-types.js.map +1 -1
  20. package/dist/components/Combobox.cjs +54 -8
  21. package/dist/components/Combobox.cjs.map +1 -1
  22. package/dist/components/Combobox.d.ts.map +1 -1
  23. package/dist/components/Combobox.js +56 -10
  24. package/dist/components/Combobox.js.map +1 -1
  25. package/dist/components/ComboboxMenu.cjs +139 -113
  26. package/dist/components/ComboboxMenu.cjs.map +1 -1
  27. package/dist/components/ComboboxMenu.d.ts +3 -1
  28. package/dist/components/ComboboxMenu.d.ts.map +1 -1
  29. package/dist/components/ComboboxMenu.js +139 -113
  30. package/dist/components/ComboboxMenu.js.map +1 -1
  31. package/dist/components/ComboboxMenuTrigger.cjs +87 -0
  32. package/dist/components/ComboboxMenuTrigger.cjs.map +1 -0
  33. package/dist/components/ComboboxMenuTrigger.d.ts +23 -0
  34. package/dist/components/ComboboxMenuTrigger.d.ts.map +1 -0
  35. package/dist/components/ComboboxMenuTrigger.js +87 -0
  36. package/dist/components/ComboboxMenuTrigger.js.map +1 -0
  37. package/dist/components/JsonSchemaForm.cjs +30 -7
  38. package/dist/components/JsonSchemaForm.cjs.map +1 -1
  39. package/dist/components/JsonSchemaForm.d.ts.map +1 -1
  40. package/dist/components/JsonSchemaForm.js +30 -7
  41. package/dist/components/JsonSchemaForm.js.map +1 -1
  42. package/dist/components/SegmentedControl.cjs +20 -3
  43. package/dist/components/SegmentedControl.cjs.map +1 -1
  44. package/dist/components/SegmentedControl.d.ts +11 -0
  45. package/dist/components/SegmentedControl.d.ts.map +1 -1
  46. package/dist/components/SegmentedControl.js +21 -4
  47. package/dist/components/SegmentedControl.js.map +1 -1
  48. package/dist/components/combobox-types.d.ts +8 -0
  49. package/dist/components/combobox-types.d.ts.map +1 -1
  50. package/dist/components/json-schema-form-debug-badge.cjs +108 -0
  51. package/dist/components/json-schema-form-debug-badge.cjs.map +1 -0
  52. package/dist/components/json-schema-form-debug-badge.d.ts +10 -0
  53. package/dist/components/json-schema-form-debug-badge.d.ts.map +1 -0
  54. package/dist/components/json-schema-form-debug-badge.js +108 -0
  55. package/dist/components/json-schema-form-debug-badge.js.map +1 -0
  56. package/dist/components/json-schema-form-debug-glyph-map.cjs +129 -0
  57. package/dist/components/json-schema-form-debug-glyph-map.cjs.map +1 -0
  58. package/dist/components/json-schema-form-debug-glyph-map.d.ts +20 -0
  59. package/dist/components/json-schema-form-debug-glyph-map.d.ts.map +1 -0
  60. package/dist/components/json-schema-form-debug-glyph-map.js +129 -0
  61. package/dist/components/json-schema-form-debug-glyph-map.js.map +1 -0
  62. package/dist/components/json-schema-form-debug-glyph.cjs +13 -0
  63. package/dist/components/json-schema-form-debug-glyph.cjs.map +1 -0
  64. package/dist/components/json-schema-form-debug-glyph.d.ts +6 -0
  65. package/dist/components/json-schema-form-debug-glyph.d.ts.map +1 -0
  66. package/dist/components/json-schema-form-debug-glyph.js +13 -0
  67. package/dist/components/json-schema-form-debug-glyph.js.map +1 -0
  68. package/dist/components/json-schema-form-debug-groups.cjs +56 -0
  69. package/dist/components/json-schema-form-debug-groups.cjs.map +1 -0
  70. package/dist/components/json-schema-form-debug-groups.d.ts +8 -0
  71. package/dist/components/json-schema-form-debug-groups.d.ts.map +1 -0
  72. package/dist/components/json-schema-form-debug-groups.js +56 -0
  73. package/dist/components/json-schema-form-debug-groups.js.map +1 -0
  74. package/dist/components/json-schema-form-debug-keywords.cjs +159 -0
  75. package/dist/components/json-schema-form-debug-keywords.cjs.map +1 -0
  76. package/dist/components/json-schema-form-debug-keywords.d.ts +6 -0
  77. package/dist/components/json-schema-form-debug-keywords.d.ts.map +1 -0
  78. package/dist/components/json-schema-form-debug-keywords.js +159 -0
  79. package/dist/components/json-schema-form-debug-keywords.js.map +1 -0
  80. package/dist/components/json-schema-form-debug-listeners.cjs +102 -0
  81. package/dist/components/json-schema-form-debug-listeners.cjs.map +1 -0
  82. package/dist/components/json-schema-form-debug-listeners.d.ts +6 -0
  83. package/dist/components/json-schema-form-debug-listeners.d.ts.map +1 -0
  84. package/dist/components/json-schema-form-debug-listeners.js +102 -0
  85. package/dist/components/json-schema-form-debug-listeners.js.map +1 -0
  86. package/dist/components/json-schema-form-debug.cjs +31 -0
  87. package/dist/components/json-schema-form-debug.cjs.map +1 -0
  88. package/dist/components/json-schema-form-debug.d.ts +11 -0
  89. package/dist/components/json-schema-form-debug.d.ts.map +1 -0
  90. package/dist/components/json-schema-form-debug.js +31 -0
  91. package/dist/components/json-schema-form-debug.js.map +1 -0
  92. package/dist/components/json-schema-form-enum-choice.cjs +114 -0
  93. package/dist/components/json-schema-form-enum-choice.cjs.map +1 -0
  94. package/dist/components/json-schema-form-enum-choice.d.ts +14 -0
  95. package/dist/components/json-schema-form-enum-choice.d.ts.map +1 -0
  96. package/dist/components/json-schema-form-enum-choice.js +114 -0
  97. package/dist/components/json-schema-form-enum-choice.js.map +1 -0
  98. package/dist/components/json-schema-form-fields.cjs +3 -93
  99. package/dist/components/json-schema-form-fields.cjs.map +1 -1
  100. package/dist/components/json-schema-form-fields.d.ts.map +1 -1
  101. package/dist/components/json-schema-form-fields.js +1 -91
  102. package/dist/components/json-schema-form-fields.js.map +1 -1
  103. package/dist/components/json-schema-form-listeners.cjs +7 -1
  104. package/dist/components/json-schema-form-listeners.cjs.map +1 -1
  105. package/dist/components/json-schema-form-listeners.d.ts.map +1 -1
  106. package/dist/components/json-schema-form-listeners.js +7 -1
  107. package/dist/components/json-schema-form-listeners.js.map +1 -1
  108. package/dist/components/json-schema-form-preferences.cjs +1 -0
  109. package/dist/components/json-schema-form-preferences.cjs.map +1 -1
  110. package/dist/components/json-schema-form-preferences.d.ts +1 -0
  111. package/dist/components/json-schema-form-preferences.d.ts.map +1 -1
  112. package/dist/components/json-schema-form-preferences.js +1 -0
  113. package/dist/components/json-schema-form-preferences.js.map +1 -1
  114. package/dist/components/json-schema-form-render.cjs +21 -5
  115. package/dist/components/json-schema-form-render.cjs.map +1 -1
  116. package/dist/components/json-schema-form-render.d.ts.map +1 -1
  117. package/dist/components/json-schema-form-render.js +21 -5
  118. package/dist/components/json-schema-form-render.js.map +1 -1
  119. package/dist/components/json-schema-form-runtime-types.d.ts +1 -0
  120. package/dist/components/json-schema-form-runtime-types.d.ts.map +1 -1
  121. package/dist/components/json-schema-form-tone.cjs +12 -0
  122. package/dist/components/json-schema-form-tone.cjs.map +1 -1
  123. package/dist/components/json-schema-form-tone.js +12 -0
  124. package/dist/components/json-schema-form-tone.js.map +1 -1
  125. package/dist/components/json-schema-form-types.d.ts +1 -0
  126. package/dist/components/json-schema-form-types.d.ts.map +1 -1
  127. package/dist/data/GraphDiagram.cjs +125 -138
  128. package/dist/data/GraphDiagram.cjs.map +1 -1
  129. package/dist/data/GraphDiagram.d.ts +30 -23
  130. package/dist/data/GraphDiagram.d.ts.map +1 -1
  131. package/dist/data/GraphDiagram.js +128 -141
  132. package/dist/data/GraphDiagram.js.map +1 -1
  133. package/dist/data/GraphDiagramEdges.cjs +208 -0
  134. package/dist/data/GraphDiagramEdges.cjs.map +1 -0
  135. package/dist/data/GraphDiagramEdges.d.ts +40 -0
  136. package/dist/data/GraphDiagramEdges.d.ts.map +1 -0
  137. package/dist/data/GraphDiagramEdges.js +208 -0
  138. package/dist/data/GraphDiagramEdges.js.map +1 -0
  139. package/dist/data/GraphDiagramNodes.cjs +142 -0
  140. package/dist/data/GraphDiagramNodes.cjs.map +1 -0
  141. package/dist/data/GraphDiagramNodes.d.ts +22 -0
  142. package/dist/data/GraphDiagramNodes.d.ts.map +1 -0
  143. package/dist/data/GraphDiagramNodes.js +142 -0
  144. package/dist/data/GraphDiagramNodes.js.map +1 -0
  145. package/dist/data/ai/PromptRunEditor/RuntimeRows.cjs +8 -3
  146. package/dist/data/ai/PromptRunEditor/RuntimeRows.cjs.map +1 -1
  147. package/dist/data/ai/PromptRunEditor/RuntimeRows.d.ts.map +1 -1
  148. package/dist/data/ai/PromptRunEditor/RuntimeRows.js +8 -3
  149. package/dist/data/ai/PromptRunEditor/RuntimeRows.js.map +1 -1
  150. package/dist/data/ai/PromptRunEditor/index.cjs +37 -43
  151. package/dist/data/ai/PromptRunEditor/index.cjs.map +1 -1
  152. package/dist/data/ai/PromptRunEditor/index.d.ts +3 -1
  153. package/dist/data/ai/PromptRunEditor/index.d.ts.map +1 -1
  154. package/dist/data/ai/PromptRunEditor/index.js +38 -44
  155. package/dist/data/ai/PromptRunEditor/index.js.map +1 -1
  156. package/dist/data/ai/PromptRunEditor/runtimeActions.cjs +16 -5
  157. package/dist/data/ai/PromptRunEditor/runtimeActions.cjs.map +1 -1
  158. package/dist/data/ai/PromptRunEditor/runtimeActions.d.ts +4 -1
  159. package/dist/data/ai/PromptRunEditor/runtimeActions.d.ts.map +1 -1
  160. package/dist/data/ai/PromptRunEditor/runtimeActions.js +17 -6
  161. package/dist/data/ai/PromptRunEditor/runtimeActions.js.map +1 -1
  162. package/dist/data/ai/SessionInspector.approvals-model.cjs +12 -0
  163. package/dist/data/ai/SessionInspector.approvals-model.cjs.map +1 -1
  164. package/dist/data/ai/SessionInspector.approvals-model.d.ts +11 -2
  165. package/dist/data/ai/SessionInspector.approvals-model.d.ts.map +1 -1
  166. package/dist/data/ai/SessionInspector.approvals-model.js +12 -0
  167. package/dist/data/ai/SessionInspector.approvals-model.js.map +1 -1
  168. package/dist/data/ai/SessionInspector.approvals.cjs +25 -1
  169. package/dist/data/ai/SessionInspector.approvals.cjs.map +1 -1
  170. package/dist/data/ai/SessionInspector.approvals.d.ts.map +1 -1
  171. package/dist/data/ai/SessionInspector.approvals.js +26 -2
  172. package/dist/data/ai/SessionInspector.approvals.js.map +1 -1
  173. package/dist/data/ai/SessionInspector.summary.cjs +9 -3
  174. package/dist/data/ai/SessionInspector.summary.cjs.map +1 -1
  175. package/dist/data/ai/SessionInspector.summary.d.ts.map +1 -1
  176. package/dist/data/ai/SessionInspector.summary.js +9 -3
  177. package/dist/data/ai/SessionInspector.summary.js.map +1 -1
  178. package/dist/data/ai/SessionInspector.transcript.cjs +4 -0
  179. package/dist/data/ai/SessionInspector.transcript.cjs.map +1 -1
  180. package/dist/data/ai/SessionInspector.transcript.d.ts.map +1 -1
  181. package/dist/data/ai/SessionInspector.transcript.js +4 -0
  182. package/dist/data/ai/SessionInspector.transcript.js.map +1 -1
  183. package/dist/data/ai/SessionViewer.approval-body.cjs +146 -0
  184. package/dist/data/ai/SessionViewer.approval-body.cjs.map +1 -0
  185. package/dist/data/ai/SessionViewer.approval-body.d.ts +11 -0
  186. package/dist/data/ai/SessionViewer.approval-body.d.ts.map +1 -0
  187. package/dist/data/ai/SessionViewer.approval-body.js +146 -0
  188. package/dist/data/ai/SessionViewer.approval-body.js.map +1 -0
  189. package/dist/data/ai/SessionViewer.approval-forms.cjs +150 -0
  190. package/dist/data/ai/SessionViewer.approval-forms.cjs.map +1 -0
  191. package/dist/data/ai/SessionViewer.approval-forms.d.ts +23 -0
  192. package/dist/data/ai/SessionViewer.approval-forms.d.ts.map +1 -0
  193. package/dist/data/ai/SessionViewer.approval-forms.js +150 -0
  194. package/dist/data/ai/SessionViewer.approval-forms.js.map +1 -0
  195. package/dist/data/ai/SessionViewer.cjs +57 -20
  196. package/dist/data/ai/SessionViewer.cjs.map +1 -1
  197. package/dist/data/ai/SessionViewer.d.ts +13 -3
  198. package/dist/data/ai/SessionViewer.d.ts.map +1 -1
  199. package/dist/data/ai/SessionViewer.decision-controls.cjs +313 -0
  200. package/dist/data/ai/SessionViewer.decision-controls.cjs.map +1 -0
  201. package/dist/data/ai/SessionViewer.decision-controls.d.ts +43 -0
  202. package/dist/data/ai/SessionViewer.decision-controls.d.ts.map +1 -0
  203. package/dist/data/ai/SessionViewer.decision-controls.js +313 -0
  204. package/dist/data/ai/SessionViewer.decision-controls.js.map +1 -0
  205. package/dist/data/ai/SessionViewer.decision.cjs +21 -0
  206. package/dist/data/ai/SessionViewer.decision.cjs.map +1 -0
  207. package/dist/data/ai/SessionViewer.decision.d.ts +12 -0
  208. package/dist/data/ai/SessionViewer.decision.d.ts.map +1 -0
  209. package/dist/data/ai/SessionViewer.decision.js +21 -0
  210. package/dist/data/ai/SessionViewer.decision.js.map +1 -0
  211. package/dist/data/ai/SessionViewer.input.cjs +14 -0
  212. package/dist/data/ai/SessionViewer.input.cjs.map +1 -1
  213. package/dist/data/ai/SessionViewer.input.d.ts +5 -0
  214. package/dist/data/ai/SessionViewer.input.d.ts.map +1 -1
  215. package/dist/data/ai/SessionViewer.input.js +14 -0
  216. package/dist/data/ai/SessionViewer.input.js.map +1 -1
  217. package/dist/data/ai/SessionViewer.js +58 -21
  218. package/dist/data/ai/SessionViewer.js.map +1 -1
  219. package/dist/data/ai/SessionViewer.model.cjs.map +1 -1
  220. package/dist/data/ai/SessionViewer.model.d.ts +4 -0
  221. package/dist/data/ai/SessionViewer.model.d.ts.map +1 -1
  222. package/dist/data/ai/SessionViewer.model.js.map +1 -1
  223. package/dist/data/ai/SessionViewer.rows.cjs +6 -3
  224. package/dist/data/ai/SessionViewer.rows.cjs.map +1 -1
  225. package/dist/data/ai/SessionViewer.rows.d.ts +2 -1
  226. package/dist/data/ai/SessionViewer.rows.d.ts.map +1 -1
  227. package/dist/data/ai/SessionViewer.rows.js +6 -3
  228. package/dist/data/ai/SessionViewer.rows.js.map +1 -1
  229. package/dist/data/ai/SessionViewer.tool-row.cjs +29 -237
  230. package/dist/data/ai/SessionViewer.tool-row.cjs.map +1 -1
  231. package/dist/data/ai/SessionViewer.tool-row.d.ts.map +1 -1
  232. package/dist/data/ai/SessionViewer.tool-row.js +27 -235
  233. package/dist/data/ai/SessionViewer.tool-row.js.map +1 -1
  234. package/dist/data/ai/SessionViewer.unified.d.ts +4 -0
  235. package/dist/data/ai/SessionViewer.unified.d.ts.map +1 -1
  236. package/dist/data/ai/SessionViewerMenu.cjs +8 -2
  237. package/dist/data/ai/SessionViewerMenu.cjs.map +1 -1
  238. package/dist/data/ai/SessionViewerMenu.d.ts +4 -1
  239. package/dist/data/ai/SessionViewerMenu.d.ts.map +1 -1
  240. package/dist/data/ai/SessionViewerMenu.js +8 -2
  241. package/dist/data/ai/SessionViewerMenu.js.map +1 -1
  242. package/dist/data/ai/SpecRuntimeEditor/CommitSection.cjs +28 -17
  243. package/dist/data/ai/SpecRuntimeEditor/CommitSection.cjs.map +1 -1
  244. package/dist/data/ai/SpecRuntimeEditor/CommitSection.d.ts +10 -2
  245. package/dist/data/ai/SpecRuntimeEditor/CommitSection.d.ts.map +1 -1
  246. package/dist/data/ai/SpecRuntimeEditor/CommitSection.js +29 -18
  247. package/dist/data/ai/SpecRuntimeEditor/CommitSection.js.map +1 -1
  248. package/dist/data/ai/SpecRuntimeEditor/index.cjs +9 -1
  249. package/dist/data/ai/SpecRuntimeEditor/index.cjs.map +1 -1
  250. package/dist/data/ai/SpecRuntimeEditor/index.d.ts +9 -2
  251. package/dist/data/ai/SpecRuntimeEditor/index.d.ts.map +1 -1
  252. package/dist/data/ai/SpecRuntimeEditor/index.js +9 -1
  253. package/dist/data/ai/SpecRuntimeEditor/index.js.map +1 -1
  254. package/dist/data/ai/SpecRuntimeEditor/permission-mode-visuals.cjs +1 -1
  255. package/dist/data/ai/SpecRuntimeEditor/permission-mode-visuals.js +1 -1
  256. package/dist/data/ai/SpecRuntimeEditor/summaries.cjs.map +1 -1
  257. package/dist/data/ai/SpecRuntimeEditor/summaries.d.ts +8 -2
  258. package/dist/data/ai/SpecRuntimeEditor/summaries.d.ts.map +1 -1
  259. package/dist/data/ai/SpecRuntimeEditor/summaries.js.map +1 -1
  260. package/dist/data/ai/SpecRuntimeEditor/update.cjs +14 -6
  261. package/dist/data/ai/SpecRuntimeEditor/update.cjs.map +1 -1
  262. package/dist/data/ai/SpecRuntimeEditor/update.d.ts +1 -0
  263. package/dist/data/ai/SpecRuntimeEditor/update.d.ts.map +1 -1
  264. package/dist/data/ai/SpecRuntimeEditor/update.js +14 -6
  265. package/dist/data/ai/SpecRuntimeEditor/update.js.map +1 -1
  266. package/dist/data/ai/approval-request.cjs +75 -0
  267. package/dist/data/ai/approval-request.cjs.map +1 -0
  268. package/dist/data/ai/approval-request.d.ts +155 -0
  269. package/dist/data/ai/approval-request.d.ts.map +1 -0
  270. package/dist/data/ai/approval-request.js +75 -0
  271. package/dist/data/ai/approval-request.js.map +1 -0
  272. package/dist/data/ai/index.d.ts +3 -0
  273. package/dist/data/ai/index.d.ts.map +1 -1
  274. package/dist/data/ai/runtime-preset-menu/SavePresetDialog.cjs +125 -0
  275. package/dist/data/ai/runtime-preset-menu/SavePresetDialog.cjs.map +1 -0
  276. package/dist/data/ai/runtime-preset-menu/SavePresetDialog.d.ts +11 -0
  277. package/dist/data/ai/runtime-preset-menu/SavePresetDialog.d.ts.map +1 -0
  278. package/dist/data/ai/runtime-preset-menu/SavePresetDialog.js +125 -0
  279. package/dist/data/ai/runtime-preset-menu/SavePresetDialog.js.map +1 -0
  280. package/dist/data/ai/runtime-preset-menu/index.d.ts +3 -0
  281. package/dist/data/ai/runtime-preset-menu/index.d.ts.map +1 -0
  282. package/dist/data/ai/runtime-preset-menu/model.cjs +73 -0
  283. package/dist/data/ai/runtime-preset-menu/model.cjs.map +1 -0
  284. package/dist/data/ai/runtime-preset-menu/model.d.ts +13 -0
  285. package/dist/data/ai/runtime-preset-menu/model.d.ts.map +1 -0
  286. package/dist/data/ai/runtime-preset-menu/model.js +73 -0
  287. package/dist/data/ai/runtime-preset-menu/model.js.map +1 -0
  288. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.cjs +149 -0
  289. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.cjs.map +1 -0
  290. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.d.ts +15 -0
  291. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.d.ts.map +1 -0
  292. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.js +149 -0
  293. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.js.map +1 -0
  294. package/dist/data/ai/runtime-spec-fields.cjs +166 -0
  295. package/dist/data/ai/runtime-spec-fields.cjs.map +1 -0
  296. package/dist/data/ai/runtime-spec-fields.d.ts +13 -0
  297. package/dist/data/ai/runtime-spec-fields.d.ts.map +1 -0
  298. package/dist/data/ai/runtime-spec-fields.js +166 -0
  299. package/dist/data/ai/runtime-spec-fields.js.map +1 -0
  300. package/dist/data/ai/session-categories.cjs +4 -0
  301. package/dist/data/ai/session-categories.cjs.map +1 -1
  302. package/dist/data/ai/session-categories.d.ts +1 -0
  303. package/dist/data/ai/session-categories.d.ts.map +1 -1
  304. package/dist/data/ai/session-categories.js +4 -0
  305. package/dist/data/ai/session-categories.js.map +1 -1
  306. package/dist/data/ai/use-session-scroll.cjs +49 -21
  307. package/dist/data/ai/use-session-scroll.cjs.map +1 -1
  308. package/dist/data/ai/use-session-scroll.d.ts +2 -0
  309. package/dist/data/ai/use-session-scroll.d.ts.map +1 -1
  310. package/dist/data/ai/use-session-scroll.js +49 -21
  311. package/dist/data/ai/use-session-scroll.js.map +1 -1
  312. package/dist/data/chat/Chat.runtime.cjs +1 -1
  313. package/dist/data/chat/Chat.runtime.cjs.map +1 -1
  314. package/dist/data/chat/Chat.runtime.d.ts.map +1 -1
  315. package/dist/data/chat/Chat.runtime.js +1 -1
  316. package/dist/data/chat/Chat.runtime.js.map +1 -1
  317. package/dist/data/graph-columns-layout.cjs +216 -0
  318. package/dist/data/graph-columns-layout.cjs.map +1 -0
  319. package/dist/data/graph-columns-layout.d.ts +56 -0
  320. package/dist/data/graph-columns-layout.d.ts.map +1 -0
  321. package/dist/data/graph-columns-layout.js +216 -0
  322. package/dist/data/graph-columns-layout.js.map +1 -0
  323. package/dist/data/graph-diagram-model.cjs +73 -0
  324. package/dist/data/graph-diagram-model.cjs.map +1 -0
  325. package/dist/data/graph-diagram-model.d.ts +90 -0
  326. package/dist/data/graph-diagram-model.d.ts.map +1 -0
  327. package/dist/data/graph-diagram-model.js +73 -0
  328. package/dist/data/graph-diagram-model.js.map +1 -0
  329. package/dist/data/graph-edge-routing.cjs +235 -0
  330. package/dist/data/graph-edge-routing.cjs.map +1 -0
  331. package/dist/data/graph-edge-routing.d.ts +73 -0
  332. package/dist/data/graph-edge-routing.d.ts.map +1 -0
  333. package/dist/data/graph-edge-routing.js +235 -0
  334. package/dist/data/graph-edge-routing.js.map +1 -0
  335. package/dist/data/graph-layout.cjs +0 -82
  336. package/dist/data/graph-layout.cjs.map +1 -1
  337. package/dist/data/graph-layout.d.ts +1 -28
  338. package/dist/data/graph-layout.d.ts.map +1 -1
  339. package/dist/data/graph-layout.js +1 -83
  340. package/dist/data/graph-layout.js.map +1 -1
  341. package/dist/data/har/HarPanel.cjs +129 -33
  342. package/dist/data/har/HarPanel.cjs.map +1 -1
  343. package/dist/data/har/HarPanel.d.ts +13 -1
  344. package/dist/data/har/HarPanel.d.ts.map +1 -1
  345. package/dist/data/har/HarPanel.js +130 -34
  346. package/dist/data/har/HarPanel.js.map +1 -1
  347. package/dist/data/har/fixtures.d.ts +12 -0
  348. package/dist/data/har/fixtures.d.ts.map +1 -1
  349. package/dist/data/har/types.d.ts +12 -0
  350. package/dist/data/har/types.d.ts.map +1 -1
  351. package/dist/data/runtime/RuntimeBar.cjs +67 -84
  352. package/dist/data/runtime/RuntimeBar.cjs.map +1 -1
  353. package/dist/data/runtime/RuntimeBar.d.ts +4 -5
  354. package/dist/data/runtime/RuntimeBar.d.ts.map +1 -1
  355. package/dist/data/runtime/RuntimeBar.fields.cjs +170 -0
  356. package/dist/data/runtime/RuntimeBar.fields.cjs.map +1 -0
  357. package/dist/data/runtime/RuntimeBar.fields.d.ts +16 -0
  358. package/dist/data/runtime/RuntimeBar.fields.d.ts.map +1 -0
  359. package/dist/data/runtime/RuntimeBar.fields.js +170 -0
  360. package/dist/data/runtime/RuntimeBar.fields.js.map +1 -0
  361. package/dist/data/runtime/RuntimeBar.js +70 -87
  362. package/dist/data/runtime/RuntimeBar.js.map +1 -1
  363. package/dist/data/runtime/RuntimeBar.selection.cjs +56 -0
  364. package/dist/data/runtime/RuntimeBar.selection.cjs.map +1 -0
  365. package/dist/data/runtime/RuntimeBar.selection.d.ts +20 -0
  366. package/dist/data/runtime/RuntimeBar.selection.d.ts.map +1 -0
  367. package/dist/data/runtime/RuntimeBar.selection.js +56 -0
  368. package/dist/data/runtime/RuntimeBar.selection.js.map +1 -0
  369. package/dist/data/runtime/RuntimeBarActions.cjs +10 -6
  370. package/dist/data/runtime/RuntimeBarActions.cjs.map +1 -1
  371. package/dist/data/runtime/RuntimeBarActions.d.ts +8 -1
  372. package/dist/data/runtime/RuntimeBarActions.d.ts.map +1 -1
  373. package/dist/data/runtime/RuntimeBarActions.js +10 -6
  374. package/dist/data/runtime/RuntimeBarActions.js.map +1 -1
  375. package/dist/data/runtime/RuntimeBarIdentity.cjs +166 -0
  376. package/dist/data/runtime/RuntimeBarIdentity.cjs.map +1 -0
  377. package/dist/data/runtime/RuntimeBarIdentity.d.ts +25 -0
  378. package/dist/data/runtime/RuntimeBarIdentity.d.ts.map +1 -0
  379. package/dist/data/runtime/RuntimeBarIdentity.js +166 -0
  380. package/dist/data/runtime/RuntimeBarIdentity.js.map +1 -0
  381. package/dist/data/runtime/RuntimeBarLayout.cjs +95 -0
  382. package/dist/data/runtime/RuntimeBarLayout.cjs.map +1 -0
  383. package/dist/data/runtime/RuntimeBarLayout.d.ts +9 -0
  384. package/dist/data/runtime/RuntimeBarLayout.d.ts.map +1 -0
  385. package/dist/data/runtime/RuntimeBarLayout.js +95 -0
  386. package/dist/data/runtime/RuntimeBarLayout.js.map +1 -0
  387. package/dist/data/runtime/RuntimeBarSegment.cjs +25 -14
  388. package/dist/data/runtime/RuntimeBarSegment.cjs.map +1 -1
  389. package/dist/data/runtime/RuntimeBarSegment.d.ts +4 -0
  390. package/dist/data/runtime/RuntimeBarSegment.d.ts.map +1 -1
  391. package/dist/data/runtime/RuntimeBarSegment.js +25 -14
  392. package/dist/data/runtime/RuntimeBarSegment.js.map +1 -1
  393. package/dist/data/runtime/RuntimeLimitInput.cjs +41 -0
  394. package/dist/data/runtime/RuntimeLimitInput.cjs.map +1 -0
  395. package/dist/data/runtime/RuntimeLimitInput.d.ts +9 -0
  396. package/dist/data/runtime/RuntimeLimitInput.d.ts.map +1 -0
  397. package/dist/data/runtime/RuntimeLimitInput.js +41 -0
  398. package/dist/data/runtime/RuntimeLimitInput.js.map +1 -0
  399. package/dist/data/runtime/use-runtime-bar-overflow.cjs +70 -0
  400. package/dist/data/runtime/use-runtime-bar-overflow.cjs.map +1 -0
  401. package/dist/data/runtime/use-runtime-bar-overflow.d.ts +13 -0
  402. package/dist/data/runtime/use-runtime-bar-overflow.d.ts.map +1 -0
  403. package/dist/data/runtime/use-runtime-bar-overflow.js +70 -0
  404. package/dist/data/runtime/use-runtime-bar-overflow.js.map +1 -0
  405. package/dist/data/use-edge-focus.cjs +20 -0
  406. package/dist/data/use-edge-focus.cjs.map +1 -0
  407. package/dist/data/use-edge-focus.d.ts +23 -0
  408. package/dist/data/use-edge-focus.d.ts.map +1 -0
  409. package/dist/data/use-edge-focus.js +20 -0
  410. package/dist/data/use-edge-focus.js.map +1 -0
  411. package/dist/data/use-pan-zoom.cjs +159 -0
  412. package/dist/data/use-pan-zoom.cjs.map +1 -0
  413. package/dist/data/use-pan-zoom.d.ts +79 -0
  414. package/dist/data/use-pan-zoom.d.ts.map +1 -0
  415. package/dist/data/use-pan-zoom.js +159 -0
  416. package/dist/data/use-pan-zoom.js.map +1 -0
  417. package/dist/data/version-info.cjs +3 -3
  418. package/dist/data/version-info.js +3 -3
  419. package/dist/data.cjs +5 -1
  420. package/dist/data.cjs.map +1 -1
  421. package/dist/data.d.ts +4 -3
  422. package/dist/data.d.ts.map +1 -1
  423. package/dist/data.js +6 -2
  424. package/dist/data.js.map +1 -1
  425. package/dist/index.cjs +5 -1
  426. package/dist/index.cjs.map +1 -1
  427. package/dist/index.js +6 -2
  428. package/dist/index.js.map +1 -1
  429. package/dist/overlay/DropdownMenu.cjs +1 -0
  430. package/dist/overlay/DropdownMenu.cjs.map +1 -1
  431. package/dist/overlay/DropdownMenu.d.ts +4 -0
  432. package/dist/overlay/DropdownMenu.d.ts.map +1 -1
  433. package/dist/overlay/DropdownMenu.js +1 -0
  434. package/dist/overlay/DropdownMenu.js.map +1 -1
  435. package/dist/overlay/DropdownMenuSubmenu.cjs +31 -15
  436. package/dist/overlay/DropdownMenuSubmenu.cjs.map +1 -1
  437. package/dist/overlay/DropdownMenuSubmenu.d.ts.map +1 -1
  438. package/dist/overlay/DropdownMenuSubmenu.js +31 -15
  439. package/dist/overlay/DropdownMenuSubmenu.js.map +1 -1
  440. package/dist/rpc/OperationCatalog.cjs +3 -1
  441. package/dist/rpc/OperationCatalog.cjs.map +1 -1
  442. package/dist/rpc/OperationCatalog.d.ts +3 -1
  443. package/dist/rpc/OperationCatalog.d.ts.map +1 -1
  444. package/dist/rpc/OperationCatalog.js +3 -1
  445. package/dist/rpc/OperationCatalog.js.map +1 -1
  446. package/dist/rpc/useOperationPages.cjs +6 -1
  447. package/dist/rpc/useOperationPages.cjs.map +1 -1
  448. package/dist/rpc/useOperationPages.d.ts +3 -1
  449. package/dist/rpc/useOperationPages.d.ts.map +1 -1
  450. package/dist/rpc/useOperationPages.js +6 -1
  451. package/dist/rpc/useOperationPages.js.map +1 -1
  452. package/dist/styles.css +1 -1
  453. package/package.json +1 -1
  454. package/schemas/json-schema-form.schema.json +5 -0
  455. package/dist/data/runtime/RuntimeBarCombo.cjs +0 -423
  456. package/dist/data/runtime/RuntimeBarCombo.cjs.map +0 -1
  457. package/dist/data/runtime/RuntimeBarCombo.d.ts +0 -33
  458. package/dist/data/runtime/RuntimeBarCombo.d.ts.map +0 -1
  459. package/dist/data/runtime/RuntimeBarCombo.js +0 -423
  460. package/dist/data/runtime/RuntimeBarCombo.js.map +0 -1
  461. package/dist/data/runtime/RuntimeBarLimits.cjs +0 -262
  462. package/dist/data/runtime/RuntimeBarLimits.cjs.map +0 -1
  463. package/dist/data/runtime/RuntimeBarLimits.d.ts +0 -17
  464. package/dist/data/runtime/RuntimeBarLimits.d.ts.map +0 -1
  465. package/dist/data/runtime/RuntimeBarLimits.js +0 -262
  466. package/dist/data/runtime/RuntimeBarLimits.js.map +0 -1
  467. package/dist/data/runtime/RuntimeBarSegments.cjs +0 -346
  468. package/dist/data/runtime/RuntimeBarSegments.cjs.map +0 -1
  469. package/dist/data/runtime/RuntimeBarSegments.d.ts +0 -37
  470. package/dist/data/runtime/RuntimeBarSegments.d.ts.map +0 -1
  471. package/dist/data/runtime/RuntimeBarSegments.js +0 -346
  472. package/dist/data/runtime/RuntimeBarSegments.js.map +0 -1
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const CURVE_OFFSET = 22;
4
+ const MIN_SIDE_REACH = 36;
5
+ const LOOP_BASE_REACH = 24;
6
+ const LOOP_SPAN_RATE = 0.18;
7
+ const MAX_LOOP_REACH = 240;
8
+ const LOOP_GAP_SHARE = 0.6;
9
+ const CUBIC_PEAK = 0.75;
10
+ const PORT_INSET = 12;
11
+ function unorderedPairKey(a, b) {
12
+ return a < b ? `${a}\0${b}` : `${b}\0${a}`;
13
+ }
14
+ function requirePosition(positions, id) {
15
+ const position = positions[id];
16
+ if (!position) {
17
+ throw new Error(`routeEdges: no layout position for node "${id}"`);
18
+ }
19
+ return position;
20
+ }
21
+ function requireEdge(group, index) {
22
+ const edge = group[index];
23
+ if (!edge) {
24
+ throw new Error(`routeEdges: expected an edge at index ${index}`);
25
+ }
26
+ return edge;
27
+ }
28
+ function clipToRect(center, towards, halfW, halfH) {
29
+ const dx = towards.x - center.x;
30
+ const dy = towards.y - center.y;
31
+ if (dx === 0 && dy === 0) return { x: center.x, y: center.y };
32
+ const scaleX = dx !== 0 ? halfW / Math.abs(dx) : Number.POSITIVE_INFINITY;
33
+ const scaleY = dy !== 0 ? halfH / Math.abs(dy) : Number.POSITIVE_INFINITY;
34
+ const scale = Math.min(scaleX, scaleY);
35
+ return { x: center.x + dx * scale, y: center.y + dy * scale };
36
+ }
37
+ function quadraticMidpoint(p0, p1, p2) {
38
+ return {
39
+ x: 0.25 * p0.x + 0.5 * p1.x + 0.25 * p2.x,
40
+ y: 0.25 * p0.y + 0.5 * p1.y + 0.25 * p2.y
41
+ };
42
+ }
43
+ function groupEdgesByPair(edges, positions) {
44
+ const groups = /* @__PURE__ */ new Map();
45
+ for (const edge of edges) {
46
+ if (!(edge.from in positions)) {
47
+ throw new Error(`routeEdges: edge "${edge.id}" references unknown node "${edge.from}"`);
48
+ }
49
+ if (!(edge.to in positions)) {
50
+ throw new Error(`routeEdges: edge "${edge.id}" references unknown node "${edge.to}"`);
51
+ }
52
+ const key = unorderedPairKey(edge.from, edge.to);
53
+ const group = groups.get(key);
54
+ if (group) {
55
+ group.push(edge);
56
+ } else {
57
+ groups.set(key, [edge]);
58
+ }
59
+ }
60
+ return [...groups.values()];
61
+ }
62
+ function routeCenterGroup(group, positions, dimensions, routes) {
63
+ const halfW = dimensions.nodeWidth / 2;
64
+ const halfH = dimensions.nodeHeight / 2;
65
+ const first = requireEdge(group, 0);
66
+ const posA = requirePosition(positions, first.from);
67
+ const posB = requirePosition(positions, first.to);
68
+ const dx = posB.x - posA.x;
69
+ const dy = posB.y - posA.y;
70
+ const len = Math.hypot(dx, dy) || 1;
71
+ const perpX = -dy / len;
72
+ const perpY = dx / len;
73
+ const midX = (posA.x + posB.x) / 2;
74
+ const midY = (posA.y + posB.y) / 2;
75
+ group.forEach((edge, index) => {
76
+ const isCurved = group.length > 1;
77
+ const sign = index % 2 === 0 ? 1 : -1;
78
+ const magnitude = Math.floor(index / 2) + 1;
79
+ const offset = isCurved ? sign * magnitude * CURVE_OFFSET : 0;
80
+ const control = { x: midX + perpX * offset, y: midY + perpY * offset };
81
+ const fromCenter = requirePosition(positions, edge.from);
82
+ const toCenter = requirePosition(positions, edge.to);
83
+ const start = clipToRect(fromCenter, control, halfW, halfH);
84
+ const end = clipToRect(toCenter, control, halfW, halfH);
85
+ const path = isCurved ? `M ${start.x} ${start.y} Q ${control.x} ${control.y} ${end.x} ${end.y}` : `M ${start.x} ${start.y} L ${end.x} ${end.y}`;
86
+ const label = isCurved ? quadraticMidpoint(start, control, end) : { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };
87
+ routes[edge.id] = { path, labelX: label.x, labelY: label.y };
88
+ });
89
+ }
90
+ function pointOnCurve([p0, c1, c2, p3], t) {
91
+ const u = 1 - t;
92
+ const weights = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t];
93
+ return {
94
+ x: weights[0] * p0.x + weights[1] * c1.x + weights[2] * c2.x + weights[3] * p3.x,
95
+ y: weights[0] * p0.y + weights[1] * c1.y + weights[2] * c2.y + weights[3] * p3.y
96
+ };
97
+ }
98
+ function cubicRoute(curve) {
99
+ const [p0, c1, c2, p3] = curve;
100
+ const label = pointOnCurve(curve, 0.5);
101
+ return {
102
+ path: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`,
103
+ labelX: label.x,
104
+ labelY: label.y
105
+ };
106
+ }
107
+ function isLoop(from, to, nodeWidth) {
108
+ return Math.abs(to.x - from.x) < nodeWidth;
109
+ }
110
+ function planLoops(edges, positions, nodeWidth) {
111
+ const attached = /* @__PURE__ */ new Map();
112
+ for (const { x } of Object.values(positions)) attached.set(x, { left: 0, right: 0 });
113
+ const attach = (x, side) => {
114
+ const tally = attached.get(x);
115
+ if (tally) tally[side] += 1;
116
+ };
117
+ for (const edge of edges) {
118
+ const from = requirePosition(positions, edge.from);
119
+ const to = requirePosition(positions, edge.to);
120
+ if (isLoop(from, to, nodeWidth)) continue;
121
+ const forward = to.x > from.x;
122
+ attach(from.x, forward ? "right" : "left");
123
+ attach(to.x, forward ? "left" : "right");
124
+ }
125
+ const columns = [...attached.keys()];
126
+ return new Map(
127
+ columns.map((x) => {
128
+ const tally = attached.get(x) ?? { left: 0, right: 0 };
129
+ const side = tally.left < tally.right ? -1 : 1;
130
+ const gaps = columns.filter((other) => (other - x) * side > 0).map((other) => Math.abs(other - x) - nodeWidth);
131
+ const room = gaps.length === 0 ? Number.POSITIVE_INFINITY : LOOP_GAP_SHARE * Math.min(...gaps) / CUBIC_PEAK;
132
+ return [x, { side, maxReach: Math.min(MAX_LOOP_REACH, Math.max(0, room)) }];
133
+ })
134
+ );
135
+ }
136
+ function loopRoute(from, to, options) {
137
+ const { side, maxReach } = options.plan;
138
+ const halfW = options.dimensions.nodeWidth / 2;
139
+ const spread = options.self ? options.dimensions.nodeHeight / 4 : 0;
140
+ const startY = from.y - spread;
141
+ const endY = to.y + spread;
142
+ const reach = Math.min(maxReach, Math.max(MIN_SIDE_REACH, LOOP_BASE_REACH + LOOP_SPAN_RATE * Math.abs(endY - startY))) + options.index * CURVE_OFFSET;
143
+ const outer = side > 0 ? Math.max(from.x, to.x) : Math.min(from.x, to.x);
144
+ const bulge = outer + side * (halfW + reach);
145
+ return {
146
+ ...cubicRoute([
147
+ { x: from.x + side * halfW, y: startY },
148
+ { x: bulge, y: startY },
149
+ { x: bulge, y: endY },
150
+ { x: to.x + side * halfW, y: endY }
151
+ ]),
152
+ labelAnchor: side > 0 ? "start" : "end"
153
+ };
154
+ }
155
+ function routeSideGroup(group, positions, dimensions, loops, routes) {
156
+ const halfW = dimensions.nodeWidth / 2;
157
+ const step = group.length > 1 ? Math.min(CURVE_OFFSET, (dimensions.nodeHeight - PORT_INSET) / (group.length - 1)) : 0;
158
+ group.forEach((edge, index) => {
159
+ const from = requirePosition(positions, edge.from);
160
+ const to = requirePosition(positions, edge.to);
161
+ if (isLoop(from, to, dimensions.nodeWidth)) {
162
+ const plan = loops.get(from.x);
163
+ if (!plan) throw new Error(`routeEdges: no loop plan for the column of "${edge.from}"`);
164
+ routes[edge.id] = loopRoute(from, to, { self: edge.from === edge.to, index, dimensions, plan });
165
+ return;
166
+ }
167
+ const direction = to.x > from.x ? 1 : -1;
168
+ const shift = (index - (group.length - 1) / 2) * step;
169
+ const start = { x: from.x + direction * halfW, y: from.y + shift };
170
+ const end = { x: to.x - direction * halfW, y: to.y + shift };
171
+ const reach = Math.max(MIN_SIDE_REACH, Math.abs(end.x - start.x) / 2);
172
+ const curve = [
173
+ start,
174
+ { x: start.x + direction * reach, y: start.y },
175
+ { x: end.x - direction * reach, y: end.y },
176
+ end
177
+ ];
178
+ routes[edge.id] = { ...cubicRoute(curve), curve };
179
+ });
180
+ }
181
+ function routeEdges(edges, positions, dimensions, options = {}) {
182
+ const routes = {};
183
+ const groups = groupEdgesByPair(edges, positions);
184
+ if (options.anchor !== "side") {
185
+ for (const group of groups) routeCenterGroup(group, positions, dimensions, routes);
186
+ return routes;
187
+ }
188
+ const loops = planLoops(edges, positions, dimensions.nodeWidth);
189
+ for (const group of groups) routeSideGroup(group, positions, dimensions, loops, routes);
190
+ return routes;
191
+ }
192
+ function loopOverhang(edges, positions, dimensions) {
193
+ const xs = Object.values(positions).map((position) => position.x);
194
+ const loops = Object.values(routeEdges(edges, positions, dimensions, { anchor: "side" })).filter(
195
+ (route) => route.labelAnchor !== void 0
196
+ );
197
+ if (loops.length === 0) return { left: 0, right: 0 };
198
+ const peaks = loops.map((route) => route.labelX);
199
+ const halfW = dimensions.nodeWidth / 2;
200
+ return {
201
+ left: Math.max(0, Math.min(...xs) - halfW - Math.min(...peaks)),
202
+ right: Math.max(0, Math.max(...peaks) - (Math.max(...xs) + halfW))
203
+ };
204
+ }
205
+ function labelLeft(box) {
206
+ if (box.anchor === "start") return box.x;
207
+ return box.anchor === "end" ? box.x - box.width : box.x - box.width / 2;
208
+ }
209
+ function spreadLabels(boxes, gap = 2) {
210
+ const placed = [];
211
+ const ys = {};
212
+ for (const box of [...boxes].sort((a, b) => a.y - b.y)) {
213
+ const left = labelLeft(box);
214
+ const right = left + box.width;
215
+ let y = box.y;
216
+ for (let moved = true; moved; ) {
217
+ moved = false;
218
+ for (const other of placed) {
219
+ const clearance = (box.height + other.height) / 2 + gap;
220
+ if (left < other.right && other.left < right && Math.abs(y - other.y) < clearance) {
221
+ y = other.y + clearance;
222
+ moved = true;
223
+ }
224
+ }
225
+ }
226
+ placed.push({ left, right, y, height: box.height });
227
+ ys[box.id] = y;
228
+ }
229
+ return ys;
230
+ }
231
+ exports.loopOverhang = loopOverhang;
232
+ exports.pointOnCurve = pointOnCurve;
233
+ exports.routeEdges = routeEdges;
234
+ exports.spreadLabels = spreadLabels;
235
+ //# sourceMappingURL=graph-edge-routing.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-edge-routing.cjs","sources":["../../src/data/graph-edge-routing.ts"],"sourcesContent":["// Edge routing and label placement for GraphDiagram: pure math, no React.\n// Split from graph-layout.ts, which owns the position types and `ringLayout`\n// and re-exports this file's API.\n\nimport type { GraphLayoutPosition } from \"./graph-layout\";\n\nexport interface GraphLayoutEdge {\n id: string;\n from: string;\n to: string;\n}\n\n/** Start, two control points and end of a cubic Bézier. */\nexport type CubicCurve = readonly [GraphLayoutPosition, GraphLayoutPosition, GraphLayoutPosition, GraphLayoutPosition];\n\nexport interface EdgeRoute {\n /** SVG path `d` attribute, clipped to the node rectangle boundaries. */\n path: string;\n /** Midpoint of the rendered path, for placing an edge label. */\n labelX: number;\n labelY: number;\n /**\n * Set on a loop, whose midpoint is its outermost point: \"start\" when a label\n * should begin at the point and run right of it, \"end\" when it should end\n * there and run left. A centred label would reach back over the node.\n */\n labelAnchor?: \"start\" | \"end\";\n /** A side-anchored edge between two columns: its curve, for placing a label elsewhere than its midpoint. */\n curve?: CubicCurve;\n}\n\nexport interface RouteEdgesDimensions {\n nodeWidth: number;\n nodeHeight: number;\n}\n\nexport interface RouteEdgesOptions {\n /** Where edges attach: clipped toward the node centre, or at the left/right side middles. Defaults to \"center\". */\n anchor?: \"center\" | \"side\";\n}\n\nconst CURVE_OFFSET = 22;\nconst MIN_SIDE_REACH = 36;\n/** A loop reaches this far plus a share of the height it spans, so a longer loop arcs outside a shorter one. */\nconst LOOP_BASE_REACH = 24;\nconst LOOP_SPAN_RATE = 0.18;\nconst MAX_LOOP_REACH = 240;\n/** The share of the gap to the next column a loop may bulge into. */\nconst LOOP_GAP_SHARE = 0.6;\n/** A cubic whose two control points share an x peaks at 3/4 of their offset. */\nconst CUBIC_PEAK = 0.75;\n/** Vertical margin kept between fanned side anchors and the node's corners. */\nconst PORT_INSET = 12;\n\nfunction unorderedPairKey(a: string, b: string): string {\n return a < b ? `${a}\\0${b}` : `${b}\\0${a}`;\n}\n\nfunction requirePosition(positions: Record<string, GraphLayoutPosition>, id: string): GraphLayoutPosition {\n const position = positions[id];\n if (!position) {\n throw new Error(`routeEdges: no layout position for node \"${id}\"`);\n }\n return position;\n}\n\nfunction requireEdge(group: readonly GraphLayoutEdge[], index: number): GraphLayoutEdge {\n const edge = group[index];\n if (!edge) {\n throw new Error(`routeEdges: expected an edge at index ${index}`);\n }\n return edge;\n}\n\n/** Point on the rectangle (centred at `center`, half-extents `halfW`/`halfH`) where the ray toward `towards` exits. */\nfunction clipToRect(\n center: GraphLayoutPosition,\n towards: GraphLayoutPosition,\n halfW: number,\n halfH: number,\n): GraphLayoutPosition {\n const dx = towards.x - center.x;\n const dy = towards.y - center.y;\n if (dx === 0 && dy === 0) return { x: center.x, y: center.y };\n\n const scaleX = dx !== 0 ? halfW / Math.abs(dx) : Number.POSITIVE_INFINITY;\n const scaleY = dy !== 0 ? halfH / Math.abs(dy) : Number.POSITIVE_INFINITY;\n const scale = Math.min(scaleX, scaleY);\n\n return { x: center.x + dx * scale, y: center.y + dy * scale };\n}\n\n/** Point at t=0.5 on the quadratic Bézier defined by p0 (start), p1 (control), p2 (end). */\nfunction quadraticMidpoint(\n p0: GraphLayoutPosition,\n p1: GraphLayoutPosition,\n p2: GraphLayoutPosition,\n): GraphLayoutPosition {\n return {\n x: 0.25 * p0.x + 0.5 * p1.x + 0.25 * p2.x,\n y: 0.25 * p0.y + 0.5 * p1.y + 0.25 * p2.y,\n };\n}\n\n/** Edges sharing an unordered node pair, in input order; throws on an edge whose node has no position. */\nfunction groupEdgesByPair(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n): GraphLayoutEdge[][] {\n const groups = new Map<string, GraphLayoutEdge[]>();\n for (const edge of edges) {\n if (!(edge.from in positions)) {\n throw new Error(`routeEdges: edge \"${edge.id}\" references unknown node \"${edge.from}\"`);\n }\n if (!(edge.to in positions)) {\n throw new Error(`routeEdges: edge \"${edge.id}\" references unknown node \"${edge.to}\"`);\n }\n const key = unorderedPairKey(edge.from, edge.to);\n const group = groups.get(key);\n if (group) {\n group.push(edge);\n } else {\n groups.set(key, [edge]);\n }\n }\n return [...groups.values()];\n}\n\nfunction routeCenterGroup(\n group: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n routes: Record<string, EdgeRoute>,\n): void {\n const halfW = dimensions.nodeWidth / 2;\n const halfH = dimensions.nodeHeight / 2;\n const first = requireEdge(group, 0);\n const posA = requirePosition(positions, first.from);\n const posB = requirePosition(positions, first.to);\n const dx = posB.x - posA.x;\n const dy = posB.y - posA.y;\n const len = Math.hypot(dx, dy) || 1;\n const perpX = -dy / len;\n const perpY = dx / len;\n const midX = (posA.x + posB.x) / 2;\n const midY = (posA.y + posB.y) / 2;\n\n group.forEach((edge, index) => {\n const isCurved = group.length > 1;\n const sign = index % 2 === 0 ? 1 : -1;\n const magnitude = Math.floor(index / 2) + 1;\n const offset = isCurved ? sign * magnitude * CURVE_OFFSET : 0;\n\n const control = { x: midX + perpX * offset, y: midY + perpY * offset };\n const fromCenter = requirePosition(positions, edge.from);\n const toCenter = requirePosition(positions, edge.to);\n const start = clipToRect(fromCenter, control, halfW, halfH);\n const end = clipToRect(toCenter, control, halfW, halfH);\n\n const path = isCurved\n ? `M ${start.x} ${start.y} Q ${control.x} ${control.y} ${end.x} ${end.y}`\n : `M ${start.x} ${start.y} L ${end.x} ${end.y}`;\n\n const label = isCurved\n ? quadraticMidpoint(start, control, end)\n : { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };\n\n routes[edge.id] = { path, labelX: label.x, labelY: label.y };\n });\n}\n\n/** The point at `t` (0 at the start, 1 at the end) along a cubic Bézier. */\nexport function pointOnCurve([p0, c1, c2, p3]: CubicCurve, t: number): GraphLayoutPosition {\n const u = 1 - t;\n const weights = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t] as const;\n return {\n x: weights[0] * p0.x + weights[1] * c1.x + weights[2] * c2.x + weights[3] * p3.x,\n y: weights[0] * p0.y + weights[1] * c1.y + weights[2] * c2.y + weights[3] * p3.y,\n };\n}\n\nfunction cubicRoute(curve: CubicCurve): EdgeRoute {\n const [p0, c1, c2, p3] = curve;\n const label = pointOnCurve(curve, 0.5);\n return {\n path: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`,\n labelX: label.x,\n labelY: label.y,\n };\n}\n\ninterface LoopPlan {\n /** 1 when the column's loops bulge right of it, -1 when left. */\n side: 1 | -1;\n /** The furthest a loop's control points may sit from the column, so it stays clear of the next one. */\n maxReach: number;\n}\n\nfunction isLoop(from: GraphLayoutPosition, to: GraphLayoutPosition, nodeWidth: number): boolean {\n return Math.abs(to.x - from.x) < nodeWidth;\n}\n\n/**\n * For each column (each distinct node x), where its loops go: the side with\n * fewer edges to other columns attached, the right on a tie, and no further\n * than a share of the gap to the next column on that side.\n */\nfunction planLoops(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n nodeWidth: number,\n): Map<number, LoopPlan> {\n const attached = new Map<number, { left: number; right: number }>();\n for (const { x } of Object.values(positions)) attached.set(x, { left: 0, right: 0 });\n const attach = (x: number, side: \"left\" | \"right\") => {\n const tally = attached.get(x);\n if (tally) tally[side] += 1;\n };\n for (const edge of edges) {\n const from = requirePosition(positions, edge.from);\n const to = requirePosition(positions, edge.to);\n if (isLoop(from, to, nodeWidth)) continue;\n const forward = to.x > from.x;\n attach(from.x, forward ? \"right\" : \"left\");\n attach(to.x, forward ? \"left\" : \"right\");\n }\n const columns = [...attached.keys()];\n return new Map(\n columns.map((x) => {\n const tally = attached.get(x) ?? { left: 0, right: 0 };\n const side = tally.left < tally.right ? -1 : 1;\n const gaps = columns.filter((other) => (other - x) * side > 0).map((other) => Math.abs(other - x) - nodeWidth);\n const room = gaps.length === 0 ? Number.POSITIVE_INFINITY : (LOOP_GAP_SHARE * Math.min(...gaps)) / CUBIC_PEAK;\n return [x, { side, maxReach: Math.min(MAX_LOOP_REACH, Math.max(0, room)) }];\n }),\n );\n}\n\n/** Out of one side of a column and back into it: an edge inside one column, or a self-edge. */\nfunction loopRoute(\n from: GraphLayoutPosition,\n to: GraphLayoutPosition,\n options: { self: boolean; index: number; dimensions: RouteEdgesDimensions; plan: LoopPlan },\n): EdgeRoute {\n const { side, maxReach } = options.plan;\n const halfW = options.dimensions.nodeWidth / 2;\n const spread = options.self ? options.dimensions.nodeHeight / 4 : 0;\n const startY = from.y - spread;\n const endY = to.y + spread;\n const reach =\n Math.min(maxReach, Math.max(MIN_SIDE_REACH, LOOP_BASE_REACH + LOOP_SPAN_RATE * Math.abs(endY - startY))) +\n options.index * CURVE_OFFSET;\n const outer = side > 0 ? Math.max(from.x, to.x) : Math.min(from.x, to.x);\n const bulge = outer + side * (halfW + reach);\n return {\n ...cubicRoute([\n { x: from.x + side * halfW, y: startY },\n { x: bulge, y: startY },\n { x: bulge, y: endY },\n { x: to.x + side * halfW, y: endY },\n ]),\n labelAnchor: side > 0 ? \"start\" : \"end\",\n };\n}\n\nfunction routeSideGroup(\n group: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n loops: ReadonlyMap<number, LoopPlan>,\n routes: Record<string, EdgeRoute>,\n): void {\n const halfW = dimensions.nodeWidth / 2;\n const step =\n group.length > 1\n ? Math.min(CURVE_OFFSET, (dimensions.nodeHeight - PORT_INSET) / (group.length - 1))\n : 0;\n\n group.forEach((edge, index) => {\n const from = requirePosition(positions, edge.from);\n const to = requirePosition(positions, edge.to);\n if (isLoop(from, to, dimensions.nodeWidth)) {\n const plan = loops.get(from.x);\n if (!plan) throw new Error(`routeEdges: no loop plan for the column of \"${edge.from}\"`);\n routes[edge.id] = loopRoute(from, to, { self: edge.from === edge.to, index, dimensions, plan });\n return;\n }\n const direction = to.x > from.x ? 1 : -1;\n const shift = (index - (group.length - 1) / 2) * step;\n const start = { x: from.x + direction * halfW, y: from.y + shift };\n const end = { x: to.x - direction * halfW, y: to.y + shift };\n const reach = Math.max(MIN_SIDE_REACH, Math.abs(end.x - start.x) / 2);\n const curve: CubicCurve = [\n start,\n { x: start.x + direction * reach, y: start.y },\n { x: end.x - direction * reach, y: end.y },\n end,\n ];\n routes[edge.id] = { ...cubicRoute(curve), curve };\n });\n}\n\n/**\n * Routes each edge as an SVG path. Edges sharing an unordered node pair — a\n * reciprocal A→B + B→A, or literal duplicates — are always fanned apart so\n * they never overlap.\n *\n * `anchor: \"center\"` (the default) clips each edge to the source/target node\n * rectangles: a lone edge is a straight line, a fanned one a quadratic curve\n * offset from the line between the two node centres.\n *\n * `anchor: \"side\"` is for column layouts: an edge leaves the side of its\n * source facing the target and enters the facing side of the target as a\n * cubic curve. An edge between two nodes of one column, and a self-edge, is a\n * loop: it arcs out of the column and back on the side with fewer edges to\n * other columns, the further the more height it spans, so loops nest.\n *\n * Throws when an edge references a node id absent from `positions`, naming\n * the edge id, rather than silently dropping or mis-routing it.\n */\nexport function routeEdges(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n options: RouteEdgesOptions = {},\n): Record<string, EdgeRoute> {\n const routes: Record<string, EdgeRoute> = {};\n const groups = groupEdgesByPair(edges, positions);\n if (options.anchor !== \"side\") {\n for (const group of groups) routeCenterGroup(group, positions, dimensions, routes);\n return routes;\n }\n const loops = planLoops(edges, positions, dimensions.nodeWidth);\n for (const group of groups) routeSideGroup(group, positions, dimensions, loops, routes);\n return routes;\n}\n\n/** How far the side-anchored loops of `edges` reach past the outermost columns, on each side. */\nexport function loopOverhang(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n): { left: number; right: number } {\n const xs = Object.values(positions).map((position) => position.x);\n const loops = Object.values(routeEdges(edges, positions, dimensions, { anchor: \"side\" })).filter(\n (route) => route.labelAnchor !== undefined,\n );\n if (loops.length === 0) return { left: 0, right: 0 };\n const peaks = loops.map((route) => route.labelX);\n const halfW = dimensions.nodeWidth / 2;\n return {\n left: Math.max(0, Math.min(...xs) - halfW - Math.min(...peaks)),\n right: Math.max(0, Math.max(...peaks) - (Math.max(...xs) + halfW)),\n };\n}\n\nexport interface EdgeLabelBox {\n id: string;\n /** The label's anchor: its centre, its left edge when `anchor` is \"start\", its right edge when \"end\". */\n x: number;\n y: number;\n width: number;\n height: number;\n anchor?: \"start\" | \"end\";\n}\n\nfunction labelLeft(box: EdgeLabelBox): number {\n if (box.anchor === \"start\") return box.x;\n return box.anchor === \"end\" ? box.x - box.width : box.x - box.width / 2;\n}\n\n/**\n * Resolves the y of each edge label so no two labels cover each other: taken\n * top to bottom, a label that would overlap one already placed drops just\n * below it. Labels keep their x, and a label that overlaps nothing keeps its y.\n */\nexport function spreadLabels(boxes: readonly EdgeLabelBox[], gap = 2): Record<string, number> {\n const placed: { left: number; right: number; y: number; height: number }[] = [];\n const ys: Record<string, number> = {};\n for (const box of [...boxes].sort((a, b) => a.y - b.y)) {\n const left = labelLeft(box);\n const right = left + box.width;\n let y = box.y;\n for (let moved = true; moved; ) {\n moved = false;\n for (const other of placed) {\n const clearance = (box.height + other.height) / 2 + gap;\n if (left < other.right && other.left < right && Math.abs(y - other.y) < clearance) {\n y = other.y + clearance;\n moved = true;\n }\n }\n }\n placed.push({ left, right, y, height: box.height });\n ys[box.id] = y;\n }\n return ys;\n}\n"],"names":[],"mappings":";;AAyCA,MAAM,eAAe;AACrB,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAEvB,MAAM,iBAAiB;AAEvB,MAAM,aAAa;AAEnB,MAAM,aAAa;AAEnB,SAAS,iBAAiB,GAAW,GAAmB;AACtD,SAAO,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC;AAC1C;AAEA,SAAS,gBAAgB,WAAgD,IAAiC;AACxG,QAAM,WAAW,UAAU,EAAE;AAC7B,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,4CAA4C,EAAE,GAAG;AAAA,EACnE;AACA,SAAO;AACT;AAEA,SAAS,YAAY,OAAmC,OAAgC;AACtF,QAAM,OAAO,MAAM,KAAK;AACxB,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,yCAAyC,KAAK,EAAE;AAAA,EAClE;AACA,SAAO;AACT;AAGA,SAAS,WACP,QACA,SACA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out.js';
2
+ export interface GraphLayoutEdge {
3
+ id: string;
4
+ from: string;
5
+ to: string;
6
+ }
7
+ /** Start, two control points and end of a cubic Bézier. */
8
+ export type CubicCurve = readonly [GraphLayoutPosition, GraphLayoutPosition, GraphLayoutPosition, GraphLayoutPosition];
9
+ export interface EdgeRoute {
10
+ /** SVG path `d` attribute, clipped to the node rectangle boundaries. */
11
+ path: string;
12
+ /** Midpoint of the rendered path, for placing an edge label. */
13
+ labelX: number;
14
+ labelY: number;
15
+ /**
16
+ * Set on a loop, whose midpoint is its outermost point: "start" when a label
17
+ * should begin at the point and run right of it, "end" when it should end
18
+ * there and run left. A centred label would reach back over the node.
19
+ */
20
+ labelAnchor?: "start" | "end";
21
+ /** A side-anchored edge between two columns: its curve, for placing a label elsewhere than its midpoint. */
22
+ curve?: CubicCurve;
23
+ }
24
+ export interface RouteEdgesDimensions {
25
+ nodeWidth: number;
26
+ nodeHeight: number;
27
+ }
28
+ export interface RouteEdgesOptions {
29
+ /** Where edges attach: clipped toward the node centre, or at the left/right side middles. Defaults to "center". */
30
+ anchor?: "center" | "side";
31
+ }
32
+ /** The point at `t` (0 at the start, 1 at the end) along a cubic Bézier. */
33
+ export declare function pointOnCurve([p0, c1, c2, p3]: CubicCurve, t: number): GraphLayoutPosition;
34
+ /**
35
+ * Routes each edge as an SVG path. Edges sharing an unordered node pair — a
36
+ * reciprocal A→B + B→A, or literal duplicates — are always fanned apart so
37
+ * they never overlap.
38
+ *
39
+ * `anchor: "center"` (the default) clips each edge to the source/target node
40
+ * rectangles: a lone edge is a straight line, a fanned one a quadratic curve
41
+ * offset from the line between the two node centres.
42
+ *
43
+ * `anchor: "side"` is for column layouts: an edge leaves the side of its
44
+ * source facing the target and enters the facing side of the target as a
45
+ * cubic curve. An edge between two nodes of one column, and a self-edge, is a
46
+ * loop: it arcs out of the column and back on the side with fewer edges to
47
+ * other columns, the further the more height it spans, so loops nest.
48
+ *
49
+ * Throws when an edge references a node id absent from `positions`, naming
50
+ * the edge id, rather than silently dropping or mis-routing it.
51
+ */
52
+ export declare function routeEdges(edges: readonly GraphLayoutEdge[], positions: Record<string, GraphLayoutPosition>, dimensions: RouteEdgesDimensions, options?: RouteEdgesOptions): Record<string, EdgeRoute>;
53
+ /** How far the side-anchored loops of `edges` reach past the outermost columns, on each side. */
54
+ export declare function loopOverhang(edges: readonly GraphLayoutEdge[], positions: Record<string, GraphLayoutPosition>, dimensions: RouteEdgesDimensions): {
55
+ left: number;
56
+ right: number;
57
+ };
58
+ export interface EdgeLabelBox {
59
+ id: string;
60
+ /** The label's anchor: its centre, its left edge when `anchor` is "start", its right edge when "end". */
61
+ x: number;
62
+ y: number;
63
+ width: number;
64
+ height: number;
65
+ anchor?: "start" | "end";
66
+ }
67
+ /**
68
+ * Resolves the y of each edge label so no two labels cover each other: taken
69
+ * top to bottom, a label that would overlap one already placed drops just
70
+ * below it. Labels keep their x, and a label that overlaps nothing keeps its y.
71
+ */
72
+ export declare function spreadLabels(boxes: readonly EdgeLabelBox[], gap?: number): Record<string, number>;
73
+ //# sourceMappingURL=graph-edge-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-edge-routing.d.ts","sourceRoot":"","sources":["../../src/data/graph-edge-routing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;AAEvH,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf;;;;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AAS,YAAY,EAAE,EAAE,GAAG,SAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqB5F"}
@@ -0,0 +1,235 @@
1
+ const CURVE_OFFSET = 22;
2
+ const MIN_SIDE_REACH = 36;
3
+ const LOOP_BASE_REACH = 24;
4
+ const LOOP_SPAN_RATE = 0.18;
5
+ const MAX_LOOP_REACH = 240;
6
+ const LOOP_GAP_SHARE = 0.6;
7
+ const CUBIC_PEAK = 0.75;
8
+ const PORT_INSET = 12;
9
+ function unorderedPairKey(a, b) {
10
+ return a < b ? `${a}\0${b}` : `${b}\0${a}`;
11
+ }
12
+ function requirePosition(positions, id) {
13
+ const position = positions[id];
14
+ if (!position) {
15
+ throw new Error(`routeEdges: no layout position for node "${id}"`);
16
+ }
17
+ return position;
18
+ }
19
+ function requireEdge(group, index) {
20
+ const edge = group[index];
21
+ if (!edge) {
22
+ throw new Error(`routeEdges: expected an edge at index ${index}`);
23
+ }
24
+ return edge;
25
+ }
26
+ function clipToRect(center, towards, halfW, halfH) {
27
+ const dx = towards.x - center.x;
28
+ const dy = towards.y - center.y;
29
+ if (dx === 0 && dy === 0) return { x: center.x, y: center.y };
30
+ const scaleX = dx !== 0 ? halfW / Math.abs(dx) : Number.POSITIVE_INFINITY;
31
+ const scaleY = dy !== 0 ? halfH / Math.abs(dy) : Number.POSITIVE_INFINITY;
32
+ const scale = Math.min(scaleX, scaleY);
33
+ return { x: center.x + dx * scale, y: center.y + dy * scale };
34
+ }
35
+ function quadraticMidpoint(p0, p1, p2) {
36
+ return {
37
+ x: 0.25 * p0.x + 0.5 * p1.x + 0.25 * p2.x,
38
+ y: 0.25 * p0.y + 0.5 * p1.y + 0.25 * p2.y
39
+ };
40
+ }
41
+ function groupEdgesByPair(edges, positions) {
42
+ const groups = /* @__PURE__ */ new Map();
43
+ for (const edge of edges) {
44
+ if (!(edge.from in positions)) {
45
+ throw new Error(`routeEdges: edge "${edge.id}" references unknown node "${edge.from}"`);
46
+ }
47
+ if (!(edge.to in positions)) {
48
+ throw new Error(`routeEdges: edge "${edge.id}" references unknown node "${edge.to}"`);
49
+ }
50
+ const key = unorderedPairKey(edge.from, edge.to);
51
+ const group = groups.get(key);
52
+ if (group) {
53
+ group.push(edge);
54
+ } else {
55
+ groups.set(key, [edge]);
56
+ }
57
+ }
58
+ return [...groups.values()];
59
+ }
60
+ function routeCenterGroup(group, positions, dimensions, routes) {
61
+ const halfW = dimensions.nodeWidth / 2;
62
+ const halfH = dimensions.nodeHeight / 2;
63
+ const first = requireEdge(group, 0);
64
+ const posA = requirePosition(positions, first.from);
65
+ const posB = requirePosition(positions, first.to);
66
+ const dx = posB.x - posA.x;
67
+ const dy = posB.y - posA.y;
68
+ const len = Math.hypot(dx, dy) || 1;
69
+ const perpX = -dy / len;
70
+ const perpY = dx / len;
71
+ const midX = (posA.x + posB.x) / 2;
72
+ const midY = (posA.y + posB.y) / 2;
73
+ group.forEach((edge, index) => {
74
+ const isCurved = group.length > 1;
75
+ const sign = index % 2 === 0 ? 1 : -1;
76
+ const magnitude = Math.floor(index / 2) + 1;
77
+ const offset = isCurved ? sign * magnitude * CURVE_OFFSET : 0;
78
+ const control = { x: midX + perpX * offset, y: midY + perpY * offset };
79
+ const fromCenter = requirePosition(positions, edge.from);
80
+ const toCenter = requirePosition(positions, edge.to);
81
+ const start = clipToRect(fromCenter, control, halfW, halfH);
82
+ const end = clipToRect(toCenter, control, halfW, halfH);
83
+ const path = isCurved ? `M ${start.x} ${start.y} Q ${control.x} ${control.y} ${end.x} ${end.y}` : `M ${start.x} ${start.y} L ${end.x} ${end.y}`;
84
+ const label = isCurved ? quadraticMidpoint(start, control, end) : { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };
85
+ routes[edge.id] = { path, labelX: label.x, labelY: label.y };
86
+ });
87
+ }
88
+ function pointOnCurve([p0, c1, c2, p3], t) {
89
+ const u = 1 - t;
90
+ const weights = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t];
91
+ return {
92
+ x: weights[0] * p0.x + weights[1] * c1.x + weights[2] * c2.x + weights[3] * p3.x,
93
+ y: weights[0] * p0.y + weights[1] * c1.y + weights[2] * c2.y + weights[3] * p3.y
94
+ };
95
+ }
96
+ function cubicRoute(curve) {
97
+ const [p0, c1, c2, p3] = curve;
98
+ const label = pointOnCurve(curve, 0.5);
99
+ return {
100
+ path: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`,
101
+ labelX: label.x,
102
+ labelY: label.y
103
+ };
104
+ }
105
+ function isLoop(from, to, nodeWidth) {
106
+ return Math.abs(to.x - from.x) < nodeWidth;
107
+ }
108
+ function planLoops(edges, positions, nodeWidth) {
109
+ const attached = /* @__PURE__ */ new Map();
110
+ for (const { x } of Object.values(positions)) attached.set(x, { left: 0, right: 0 });
111
+ const attach = (x, side) => {
112
+ const tally = attached.get(x);
113
+ if (tally) tally[side] += 1;
114
+ };
115
+ for (const edge of edges) {
116
+ const from = requirePosition(positions, edge.from);
117
+ const to = requirePosition(positions, edge.to);
118
+ if (isLoop(from, to, nodeWidth)) continue;
119
+ const forward = to.x > from.x;
120
+ attach(from.x, forward ? "right" : "left");
121
+ attach(to.x, forward ? "left" : "right");
122
+ }
123
+ const columns = [...attached.keys()];
124
+ return new Map(
125
+ columns.map((x) => {
126
+ const tally = attached.get(x) ?? { left: 0, right: 0 };
127
+ const side = tally.left < tally.right ? -1 : 1;
128
+ const gaps = columns.filter((other) => (other - x) * side > 0).map((other) => Math.abs(other - x) - nodeWidth);
129
+ const room = gaps.length === 0 ? Number.POSITIVE_INFINITY : LOOP_GAP_SHARE * Math.min(...gaps) / CUBIC_PEAK;
130
+ return [x, { side, maxReach: Math.min(MAX_LOOP_REACH, Math.max(0, room)) }];
131
+ })
132
+ );
133
+ }
134
+ function loopRoute(from, to, options) {
135
+ const { side, maxReach } = options.plan;
136
+ const halfW = options.dimensions.nodeWidth / 2;
137
+ const spread = options.self ? options.dimensions.nodeHeight / 4 : 0;
138
+ const startY = from.y - spread;
139
+ const endY = to.y + spread;
140
+ const reach = Math.min(maxReach, Math.max(MIN_SIDE_REACH, LOOP_BASE_REACH + LOOP_SPAN_RATE * Math.abs(endY - startY))) + options.index * CURVE_OFFSET;
141
+ const outer = side > 0 ? Math.max(from.x, to.x) : Math.min(from.x, to.x);
142
+ const bulge = outer + side * (halfW + reach);
143
+ return {
144
+ ...cubicRoute([
145
+ { x: from.x + side * halfW, y: startY },
146
+ { x: bulge, y: startY },
147
+ { x: bulge, y: endY },
148
+ { x: to.x + side * halfW, y: endY }
149
+ ]),
150
+ labelAnchor: side > 0 ? "start" : "end"
151
+ };
152
+ }
153
+ function routeSideGroup(group, positions, dimensions, loops, routes) {
154
+ const halfW = dimensions.nodeWidth / 2;
155
+ const step = group.length > 1 ? Math.min(CURVE_OFFSET, (dimensions.nodeHeight - PORT_INSET) / (group.length - 1)) : 0;
156
+ group.forEach((edge, index) => {
157
+ const from = requirePosition(positions, edge.from);
158
+ const to = requirePosition(positions, edge.to);
159
+ if (isLoop(from, to, dimensions.nodeWidth)) {
160
+ const plan = loops.get(from.x);
161
+ if (!plan) throw new Error(`routeEdges: no loop plan for the column of "${edge.from}"`);
162
+ routes[edge.id] = loopRoute(from, to, { self: edge.from === edge.to, index, dimensions, plan });
163
+ return;
164
+ }
165
+ const direction = to.x > from.x ? 1 : -1;
166
+ const shift = (index - (group.length - 1) / 2) * step;
167
+ const start = { x: from.x + direction * halfW, y: from.y + shift };
168
+ const end = { x: to.x - direction * halfW, y: to.y + shift };
169
+ const reach = Math.max(MIN_SIDE_REACH, Math.abs(end.x - start.x) / 2);
170
+ const curve = [
171
+ start,
172
+ { x: start.x + direction * reach, y: start.y },
173
+ { x: end.x - direction * reach, y: end.y },
174
+ end
175
+ ];
176
+ routes[edge.id] = { ...cubicRoute(curve), curve };
177
+ });
178
+ }
179
+ function routeEdges(edges, positions, dimensions, options = {}) {
180
+ const routes = {};
181
+ const groups = groupEdgesByPair(edges, positions);
182
+ if (options.anchor !== "side") {
183
+ for (const group of groups) routeCenterGroup(group, positions, dimensions, routes);
184
+ return routes;
185
+ }
186
+ const loops = planLoops(edges, positions, dimensions.nodeWidth);
187
+ for (const group of groups) routeSideGroup(group, positions, dimensions, loops, routes);
188
+ return routes;
189
+ }
190
+ function loopOverhang(edges, positions, dimensions) {
191
+ const xs = Object.values(positions).map((position) => position.x);
192
+ const loops = Object.values(routeEdges(edges, positions, dimensions, { anchor: "side" })).filter(
193
+ (route) => route.labelAnchor !== void 0
194
+ );
195
+ if (loops.length === 0) return { left: 0, right: 0 };
196
+ const peaks = loops.map((route) => route.labelX);
197
+ const halfW = dimensions.nodeWidth / 2;
198
+ return {
199
+ left: Math.max(0, Math.min(...xs) - halfW - Math.min(...peaks)),
200
+ right: Math.max(0, Math.max(...peaks) - (Math.max(...xs) + halfW))
201
+ };
202
+ }
203
+ function labelLeft(box) {
204
+ if (box.anchor === "start") return box.x;
205
+ return box.anchor === "end" ? box.x - box.width : box.x - box.width / 2;
206
+ }
207
+ function spreadLabels(boxes, gap = 2) {
208
+ const placed = [];
209
+ const ys = {};
210
+ for (const box of [...boxes].sort((a, b) => a.y - b.y)) {
211
+ const left = labelLeft(box);
212
+ const right = left + box.width;
213
+ let y = box.y;
214
+ for (let moved = true; moved; ) {
215
+ moved = false;
216
+ for (const other of placed) {
217
+ const clearance = (box.height + other.height) / 2 + gap;
218
+ if (left < other.right && other.left < right && Math.abs(y - other.y) < clearance) {
219
+ y = other.y + clearance;
220
+ moved = true;
221
+ }
222
+ }
223
+ }
224
+ placed.push({ left, right, y, height: box.height });
225
+ ys[box.id] = y;
226
+ }
227
+ return ys;
228
+ }
229
+ export {
230
+ loopOverhang,
231
+ pointOnCurve,
232
+ routeEdges,
233
+ spreadLabels
234
+ };
235
+ //# sourceMappingURL=graph-edge-routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-edge-routing.js","sources":["../../src/data/graph-edge-routing.ts"],"sourcesContent":["// Edge routing and label placement for GraphDiagram: pure math, no React.\n// Split from graph-layout.ts, which owns the position types and `ringLayout`\n// and re-exports this file's API.\n\nimport type { GraphLayoutPosition } from \"./graph-layout\";\n\nexport interface GraphLayoutEdge {\n id: string;\n from: string;\n to: string;\n}\n\n/** Start, two control points and end of a cubic Bézier. */\nexport type CubicCurve = readonly [GraphLayoutPosition, GraphLayoutPosition, GraphLayoutPosition, GraphLayoutPosition];\n\nexport interface EdgeRoute {\n /** SVG path `d` attribute, clipped to the node rectangle boundaries. */\n path: string;\n /** Midpoint of the rendered path, for placing an edge label. */\n labelX: number;\n labelY: number;\n /**\n * Set on a loop, whose midpoint is its outermost point: \"start\" when a label\n * should begin at the point and run right of it, \"end\" when it should end\n * there and run left. A centred label would reach back over the node.\n */\n labelAnchor?: \"start\" | \"end\";\n /** A side-anchored edge between two columns: its curve, for placing a label elsewhere than its midpoint. */\n curve?: CubicCurve;\n}\n\nexport interface RouteEdgesDimensions {\n nodeWidth: number;\n nodeHeight: number;\n}\n\nexport interface RouteEdgesOptions {\n /** Where edges attach: clipped toward the node centre, or at the left/right side middles. Defaults to \"center\". */\n anchor?: \"center\" | \"side\";\n}\n\nconst CURVE_OFFSET = 22;\nconst MIN_SIDE_REACH = 36;\n/** A loop reaches this far plus a share of the height it spans, so a longer loop arcs outside a shorter one. */\nconst LOOP_BASE_REACH = 24;\nconst LOOP_SPAN_RATE = 0.18;\nconst MAX_LOOP_REACH = 240;\n/** The share of the gap to the next column a loop may bulge into. */\nconst LOOP_GAP_SHARE = 0.6;\n/** A cubic whose two control points share an x peaks at 3/4 of their offset. */\nconst CUBIC_PEAK = 0.75;\n/** Vertical margin kept between fanned side anchors and the node's corners. */\nconst PORT_INSET = 12;\n\nfunction unorderedPairKey(a: string, b: string): string {\n return a < b ? `${a}\\0${b}` : `${b}\\0${a}`;\n}\n\nfunction requirePosition(positions: Record<string, GraphLayoutPosition>, id: string): GraphLayoutPosition {\n const position = positions[id];\n if (!position) {\n throw new Error(`routeEdges: no layout position for node \"${id}\"`);\n }\n return position;\n}\n\nfunction requireEdge(group: readonly GraphLayoutEdge[], index: number): GraphLayoutEdge {\n const edge = group[index];\n if (!edge) {\n throw new Error(`routeEdges: expected an edge at index ${index}`);\n }\n return edge;\n}\n\n/** Point on the rectangle (centred at `center`, half-extents `halfW`/`halfH`) where the ray toward `towards` exits. */\nfunction clipToRect(\n center: GraphLayoutPosition,\n towards: GraphLayoutPosition,\n halfW: number,\n halfH: number,\n): GraphLayoutPosition {\n const dx = towards.x - center.x;\n const dy = towards.y - center.y;\n if (dx === 0 && dy === 0) return { x: center.x, y: center.y };\n\n const scaleX = dx !== 0 ? halfW / Math.abs(dx) : Number.POSITIVE_INFINITY;\n const scaleY = dy !== 0 ? halfH / Math.abs(dy) : Number.POSITIVE_INFINITY;\n const scale = Math.min(scaleX, scaleY);\n\n return { x: center.x + dx * scale, y: center.y + dy * scale };\n}\n\n/** Point at t=0.5 on the quadratic Bézier defined by p0 (start), p1 (control), p2 (end). */\nfunction quadraticMidpoint(\n p0: GraphLayoutPosition,\n p1: GraphLayoutPosition,\n p2: GraphLayoutPosition,\n): GraphLayoutPosition {\n return {\n x: 0.25 * p0.x + 0.5 * p1.x + 0.25 * p2.x,\n y: 0.25 * p0.y + 0.5 * p1.y + 0.25 * p2.y,\n };\n}\n\n/** Edges sharing an unordered node pair, in input order; throws on an edge whose node has no position. */\nfunction groupEdgesByPair(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n): GraphLayoutEdge[][] {\n const groups = new Map<string, GraphLayoutEdge[]>();\n for (const edge of edges) {\n if (!(edge.from in positions)) {\n throw new Error(`routeEdges: edge \"${edge.id}\" references unknown node \"${edge.from}\"`);\n }\n if (!(edge.to in positions)) {\n throw new Error(`routeEdges: edge \"${edge.id}\" references unknown node \"${edge.to}\"`);\n }\n const key = unorderedPairKey(edge.from, edge.to);\n const group = groups.get(key);\n if (group) {\n group.push(edge);\n } else {\n groups.set(key, [edge]);\n }\n }\n return [...groups.values()];\n}\n\nfunction routeCenterGroup(\n group: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n routes: Record<string, EdgeRoute>,\n): void {\n const halfW = dimensions.nodeWidth / 2;\n const halfH = dimensions.nodeHeight / 2;\n const first = requireEdge(group, 0);\n const posA = requirePosition(positions, first.from);\n const posB = requirePosition(positions, first.to);\n const dx = posB.x - posA.x;\n const dy = posB.y - posA.y;\n const len = Math.hypot(dx, dy) || 1;\n const perpX = -dy / len;\n const perpY = dx / len;\n const midX = (posA.x + posB.x) / 2;\n const midY = (posA.y + posB.y) / 2;\n\n group.forEach((edge, index) => {\n const isCurved = group.length > 1;\n const sign = index % 2 === 0 ? 1 : -1;\n const magnitude = Math.floor(index / 2) + 1;\n const offset = isCurved ? sign * magnitude * CURVE_OFFSET : 0;\n\n const control = { x: midX + perpX * offset, y: midY + perpY * offset };\n const fromCenter = requirePosition(positions, edge.from);\n const toCenter = requirePosition(positions, edge.to);\n const start = clipToRect(fromCenter, control, halfW, halfH);\n const end = clipToRect(toCenter, control, halfW, halfH);\n\n const path = isCurved\n ? `M ${start.x} ${start.y} Q ${control.x} ${control.y} ${end.x} ${end.y}`\n : `M ${start.x} ${start.y} L ${end.x} ${end.y}`;\n\n const label = isCurved\n ? quadraticMidpoint(start, control, end)\n : { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };\n\n routes[edge.id] = { path, labelX: label.x, labelY: label.y };\n });\n}\n\n/** The point at `t` (0 at the start, 1 at the end) along a cubic Bézier. */\nexport function pointOnCurve([p0, c1, c2, p3]: CubicCurve, t: number): GraphLayoutPosition {\n const u = 1 - t;\n const weights = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t] as const;\n return {\n x: weights[0] * p0.x + weights[1] * c1.x + weights[2] * c2.x + weights[3] * p3.x,\n y: weights[0] * p0.y + weights[1] * c1.y + weights[2] * c2.y + weights[3] * p3.y,\n };\n}\n\nfunction cubicRoute(curve: CubicCurve): EdgeRoute {\n const [p0, c1, c2, p3] = curve;\n const label = pointOnCurve(curve, 0.5);\n return {\n path: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`,\n labelX: label.x,\n labelY: label.y,\n };\n}\n\ninterface LoopPlan {\n /** 1 when the column's loops bulge right of it, -1 when left. */\n side: 1 | -1;\n /** The furthest a loop's control points may sit from the column, so it stays clear of the next one. */\n maxReach: number;\n}\n\nfunction isLoop(from: GraphLayoutPosition, to: GraphLayoutPosition, nodeWidth: number): boolean {\n return Math.abs(to.x - from.x) < nodeWidth;\n}\n\n/**\n * For each column (each distinct node x), where its loops go: the side with\n * fewer edges to other columns attached, the right on a tie, and no further\n * than a share of the gap to the next column on that side.\n */\nfunction planLoops(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n nodeWidth: number,\n): Map<number, LoopPlan> {\n const attached = new Map<number, { left: number; right: number }>();\n for (const { x } of Object.values(positions)) attached.set(x, { left: 0, right: 0 });\n const attach = (x: number, side: \"left\" | \"right\") => {\n const tally = attached.get(x);\n if (tally) tally[side] += 1;\n };\n for (const edge of edges) {\n const from = requirePosition(positions, edge.from);\n const to = requirePosition(positions, edge.to);\n if (isLoop(from, to, nodeWidth)) continue;\n const forward = to.x > from.x;\n attach(from.x, forward ? \"right\" : \"left\");\n attach(to.x, forward ? \"left\" : \"right\");\n }\n const columns = [...attached.keys()];\n return new Map(\n columns.map((x) => {\n const tally = attached.get(x) ?? { left: 0, right: 0 };\n const side = tally.left < tally.right ? -1 : 1;\n const gaps = columns.filter((other) => (other - x) * side > 0).map((other) => Math.abs(other - x) - nodeWidth);\n const room = gaps.length === 0 ? Number.POSITIVE_INFINITY : (LOOP_GAP_SHARE * Math.min(...gaps)) / CUBIC_PEAK;\n return [x, { side, maxReach: Math.min(MAX_LOOP_REACH, Math.max(0, room)) }];\n }),\n );\n}\n\n/** Out of one side of a column and back into it: an edge inside one column, or a self-edge. */\nfunction loopRoute(\n from: GraphLayoutPosition,\n to: GraphLayoutPosition,\n options: { self: boolean; index: number; dimensions: RouteEdgesDimensions; plan: LoopPlan },\n): EdgeRoute {\n const { side, maxReach } = options.plan;\n const halfW = options.dimensions.nodeWidth / 2;\n const spread = options.self ? options.dimensions.nodeHeight / 4 : 0;\n const startY = from.y - spread;\n const endY = to.y + spread;\n const reach =\n Math.min(maxReach, Math.max(MIN_SIDE_REACH, LOOP_BASE_REACH + LOOP_SPAN_RATE * Math.abs(endY - startY))) +\n options.index * CURVE_OFFSET;\n const outer = side > 0 ? Math.max(from.x, to.x) : Math.min(from.x, to.x);\n const bulge = outer + side * (halfW + reach);\n return {\n ...cubicRoute([\n { x: from.x + side * halfW, y: startY },\n { x: bulge, y: startY },\n { x: bulge, y: endY },\n { x: to.x + side * halfW, y: endY },\n ]),\n labelAnchor: side > 0 ? \"start\" : \"end\",\n };\n}\n\nfunction routeSideGroup(\n group: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n loops: ReadonlyMap<number, LoopPlan>,\n routes: Record<string, EdgeRoute>,\n): void {\n const halfW = dimensions.nodeWidth / 2;\n const step =\n group.length > 1\n ? Math.min(CURVE_OFFSET, (dimensions.nodeHeight - PORT_INSET) / (group.length - 1))\n : 0;\n\n group.forEach((edge, index) => {\n const from = requirePosition(positions, edge.from);\n const to = requirePosition(positions, edge.to);\n if (isLoop(from, to, dimensions.nodeWidth)) {\n const plan = loops.get(from.x);\n if (!plan) throw new Error(`routeEdges: no loop plan for the column of \"${edge.from}\"`);\n routes[edge.id] = loopRoute(from, to, { self: edge.from === edge.to, index, dimensions, plan });\n return;\n }\n const direction = to.x > from.x ? 1 : -1;\n const shift = (index - (group.length - 1) / 2) * step;\n const start = { x: from.x + direction * halfW, y: from.y + shift };\n const end = { x: to.x - direction * halfW, y: to.y + shift };\n const reach = Math.max(MIN_SIDE_REACH, Math.abs(end.x - start.x) / 2);\n const curve: CubicCurve = [\n start,\n { x: start.x + direction * reach, y: start.y },\n { x: end.x - direction * reach, y: end.y },\n end,\n ];\n routes[edge.id] = { ...cubicRoute(curve), curve };\n });\n}\n\n/**\n * Routes each edge as an SVG path. Edges sharing an unordered node pair — a\n * reciprocal A→B + B→A, or literal duplicates — are always fanned apart so\n * they never overlap.\n *\n * `anchor: \"center\"` (the default) clips each edge to the source/target node\n * rectangles: a lone edge is a straight line, a fanned one a quadratic curve\n * offset from the line between the two node centres.\n *\n * `anchor: \"side\"` is for column layouts: an edge leaves the side of its\n * source facing the target and enters the facing side of the target as a\n * cubic curve. An edge between two nodes of one column, and a self-edge, is a\n * loop: it arcs out of the column and back on the side with fewer edges to\n * other columns, the further the more height it spans, so loops nest.\n *\n * Throws when an edge references a node id absent from `positions`, naming\n * the edge id, rather than silently dropping or mis-routing it.\n */\nexport function routeEdges(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n options: RouteEdgesOptions = {},\n): Record<string, EdgeRoute> {\n const routes: Record<string, EdgeRoute> = {};\n const groups = groupEdgesByPair(edges, positions);\n if (options.anchor !== \"side\") {\n for (const group of groups) routeCenterGroup(group, positions, dimensions, routes);\n return routes;\n }\n const loops = planLoops(edges, positions, dimensions.nodeWidth);\n for (const group of groups) routeSideGroup(group, positions, dimensions, loops, routes);\n return routes;\n}\n\n/** How far the side-anchored loops of `edges` reach past the outermost columns, on each side. */\nexport function loopOverhang(\n edges: readonly GraphLayoutEdge[],\n positions: Record<string, GraphLayoutPosition>,\n dimensions: RouteEdgesDimensions,\n): { left: number; right: number } {\n const xs = Object.values(positions).map((position) => position.x);\n const loops = Object.values(routeEdges(edges, positions, dimensions, { anchor: \"side\" })).filter(\n (route) => route.labelAnchor !== undefined,\n );\n if (loops.length === 0) return { left: 0, right: 0 };\n const peaks = loops.map((route) => route.labelX);\n const halfW = dimensions.nodeWidth / 2;\n return {\n left: Math.max(0, Math.min(...xs) - halfW - Math.min(...peaks)),\n right: Math.max(0, Math.max(...peaks) - (Math.max(...xs) + halfW)),\n };\n}\n\nexport interface EdgeLabelBox {\n id: string;\n /** The label's anchor: its centre, its left edge when `anchor` is \"start\", its right edge when \"end\". */\n x: number;\n y: number;\n width: number;\n height: number;\n anchor?: \"start\" | \"end\";\n}\n\nfunction labelLeft(box: EdgeLabelBox): number {\n if (box.anchor === \"start\") return box.x;\n return box.anchor === \"end\" ? box.x - box.width : box.x - box.width / 2;\n}\n\n/**\n * Resolves the y of each edge label so no two labels cover each other: taken\n * top to bottom, a label that would overlap one already placed drops just\n * below it. Labels keep their x, and a label that overlaps nothing keeps its y.\n */\nexport function spreadLabels(boxes: readonly EdgeLabelBox[], gap = 2): Record<string, number> {\n const placed: { left: number; right: number; y: number; height: number }[] = [];\n const ys: Record<string, number> = {};\n for (const box of [...boxes].sort((a, b) => a.y - b.y)) {\n const left = labelLeft(box);\n const right = left + box.width;\n let y = box.y;\n for (let moved = true; moved; ) {\n moved = false;\n for (const other of placed) {\n const clearance = (box.height + other.height) / 2 + gap;\n if (left < other.right && other.left < right && Math.abs(y - other.y) < clearance) {\n y = other.y + clearance;\n moved = true;\n }\n }\n }\n placed.push({ left, right, y, height: box.height });\n ys[box.id] = y;\n }\n return ys;\n}\n"],"names":[],"mappings":"AAyCA,MAAM,eAAe;AACrB,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAEvB,MAAM,iBAAiB;AAEvB,MAAM,aAAa;AAEnB,MAAM,aAAa;AAEnB,SAAS,iBAAiB,GAAW,GAAmB;AACtD,SAAO,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC;AAC1C;AAEA,SAAS,gBAAgB,WAAgD,IAAiC;AACxG,QAAM,WAAW,UAAU,EAAE;AAC7B,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,4CAA4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