@alepha/ui 0.27.1 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (630) hide show
  1. package/README.md +31 -2
  2. package/dist/components/account/account-connections.d.ts.map +1 -1
  3. package/dist/components/account/account-connections.js +4 -1
  4. package/dist/components/account/account-connections.js.map +1 -1
  5. package/dist/components/account/account-delete-dialog.d.ts.map +1 -1
  6. package/dist/components/account/account-delete-dialog.js +12 -15
  7. package/dist/components/account/account-delete-dialog.js.map +1 -1
  8. package/dist/components/account/account-keys.d.ts.map +1 -1
  9. package/dist/components/account/account-keys.js +22 -28
  10. package/dist/components/account/account-keys.js.map +1 -1
  11. package/dist/components/account/account-layout.d.ts.map +1 -1
  12. package/dist/components/account/account-layout.js +8 -2
  13. package/dist/components/account/account-layout.js.map +1 -1
  14. package/dist/components/account/account-mfa-dialog.js +1 -4
  15. package/dist/components/account/account-mfa-dialog.js.map +1 -1
  16. package/dist/components/account/account-password-dialog.d.ts.map +1 -1
  17. package/dist/components/account/account-password-dialog.js +11 -14
  18. package/dist/components/account/account-password-dialog.js.map +1 -1
  19. package/dist/components/account/account-profile.js +3 -2
  20. package/dist/components/account/account-profile.js.map +1 -1
  21. package/dist/components/account/account-router-options.d.ts +38 -0
  22. package/dist/components/account/account-router-options.d.ts.map +1 -1
  23. package/dist/components/account/account-router-options.js.map +1 -1
  24. package/dist/components/account/account-router-page.d.ts +11 -1
  25. package/dist/components/account/account-router-page.d.ts.map +1 -1
  26. package/dist/components/account/account-router-page.js +11 -1
  27. package/dist/components/account/account-router-page.js.map +1 -1
  28. package/dist/components/account/account-router.d.ts +11 -0
  29. package/dist/components/account/account-router.d.ts.map +1 -1
  30. package/dist/components/account/account-router.js +16 -5
  31. package/dist/components/account/account-router.js.map +1 -1
  32. package/dist/components/admin/admin-analytics.d.ts +34 -5
  33. package/dist/components/admin/admin-analytics.d.ts.map +1 -1
  34. package/dist/components/admin/admin-analytics.js +69 -51
  35. package/dist/components/admin/admin-analytics.js.map +1 -1
  36. package/dist/components/admin/admin-audits.d.ts +14 -0
  37. package/dist/components/admin/admin-audits.d.ts.map +1 -1
  38. package/dist/components/admin/admin-audits.js +121 -37
  39. package/dist/components/admin/admin-audits.js.map +1 -1
  40. package/dist/components/admin/admin-files.d.ts.map +1 -1
  41. package/dist/components/admin/admin-files.js +8 -18
  42. package/dist/components/admin/admin-files.js.map +1 -1
  43. package/dist/components/admin/admin-jobs-executions-panel.d.ts.map +1 -1
  44. package/dist/components/admin/admin-jobs-executions-panel.js +40 -9
  45. package/dist/components/admin/admin-jobs-executions-panel.js.map +1 -1
  46. package/dist/components/admin/admin-jobs-payload-dialog.d.ts +19 -0
  47. package/dist/components/admin/admin-jobs-payload-dialog.d.ts.map +1 -0
  48. package/dist/components/admin/admin-jobs-payload-dialog.js +33 -0
  49. package/dist/components/admin/admin-jobs-payload-dialog.js.map +1 -0
  50. package/dist/components/admin/admin-jobs.js +1 -1
  51. package/dist/components/admin/admin-keys.d.ts.map +1 -1
  52. package/dist/components/admin/admin-keys.js +7 -5
  53. package/dist/components/admin/admin-keys.js.map +1 -1
  54. package/dist/components/admin/admin-notifications-channel-label.d.ts +14 -0
  55. package/dist/components/admin/admin-notifications-channel-label.d.ts.map +1 -0
  56. package/dist/components/admin/admin-notifications-channel-label.js +26 -0
  57. package/dist/components/admin/admin-notifications-channel-label.js.map +1 -0
  58. package/dist/components/admin/admin-notifications-preview-body.d.ts.map +1 -1
  59. package/dist/components/admin/admin-notifications-preview-body.js +23 -13
  60. package/dist/components/admin/admin-notifications-preview-body.js.map +1 -1
  61. package/dist/components/admin/admin-notifications.d.ts.map +1 -1
  62. package/dist/components/admin/admin-notifications.js +12 -13
  63. package/dist/components/admin/admin-notifications.js.map +1 -1
  64. package/dist/components/admin/admin-parameters.d.ts.map +1 -1
  65. package/dist/components/admin/admin-parameters.js +108 -14
  66. package/dist/components/admin/admin-parameters.js.map +1 -1
  67. package/dist/components/admin/admin-payments.d.ts.map +1 -1
  68. package/dist/components/admin/admin-payments.js +10 -8
  69. package/dist/components/admin/admin-payments.js.map +1 -1
  70. package/dist/components/admin/admin-router-options.d.ts +12 -0
  71. package/dist/components/admin/admin-router-options.d.ts.map +1 -1
  72. package/dist/components/admin/admin-router-options.js.map +1 -1
  73. package/dist/components/admin/admin-router.d.ts +5 -8
  74. package/dist/components/admin/admin-router.d.ts.map +1 -1
  75. package/dist/components/admin/admin-router.js +6 -29
  76. package/dist/components/admin/admin-router.js.map +1 -1
  77. package/dist/components/admin/admin-sessions.d.ts.map +1 -1
  78. package/dist/components/admin/admin-sessions.js +135 -11
  79. package/dist/components/admin/admin-sessions.js.map +1 -1
  80. package/dist/components/admin/admin-user-avatar-control.d.ts +24 -0
  81. package/dist/components/admin/admin-user-avatar-control.d.ts.map +1 -0
  82. package/dist/components/admin/admin-user-avatar-control.js +84 -0
  83. package/dist/components/admin/admin-user-avatar-control.js.map +1 -0
  84. package/dist/components/admin/admin-user-detail-audits-tab.d.ts.map +1 -1
  85. package/dist/components/admin/admin-user-detail-audits-tab.js +5 -4
  86. package/dist/components/admin/admin-user-detail-audits-tab.js.map +1 -1
  87. package/dist/components/admin/admin-user-detail-sessions-tab.d.ts.map +1 -1
  88. package/dist/components/admin/admin-user-detail-sessions-tab.js +7 -5
  89. package/dist/components/admin/admin-user-detail-sessions-tab.js.map +1 -1
  90. package/dist/components/admin/admin-user-detail.d.ts.map +1 -1
  91. package/dist/components/admin/admin-user-detail.js +16 -4
  92. package/dist/components/admin/admin-user-detail.js.map +1 -1
  93. package/dist/components/admin/admin-users-roles-picker.d.ts.map +1 -1
  94. package/dist/components/admin/admin-users-roles-picker.js.map +1 -1
  95. package/dist/components/admin/admin-users.d.ts.map +1 -1
  96. package/dist/components/admin/admin-users.js +7 -5
  97. package/dist/components/admin/admin-users.js.map +1 -1
  98. package/dist/components/admin/analytics/AdvancedSection.d.ts +26 -0
  99. package/dist/components/admin/analytics/AdvancedSection.d.ts.map +1 -0
  100. package/dist/components/admin/analytics/AdvancedSection.js +143 -0
  101. package/dist/components/admin/analytics/AdvancedSection.js.map +1 -0
  102. package/dist/components/admin/analytics/AnalyticsChart.d.ts +20 -0
  103. package/dist/components/admin/analytics/AnalyticsChart.d.ts.map +1 -0
  104. package/dist/components/admin/analytics/AnalyticsChart.js +60 -0
  105. package/dist/components/admin/analytics/AnalyticsChart.js.map +1 -0
  106. package/dist/components/admin/analytics/AnalyticsChartBars.d.ts +19 -0
  107. package/dist/components/admin/analytics/AnalyticsChartBars.d.ts.map +1 -0
  108. package/dist/components/admin/analytics/AnalyticsChartBars.js +43 -0
  109. package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -0
  110. package/dist/components/admin/analytics/AnalyticsChartDonut.d.ts +11 -0
  111. package/dist/components/admin/analytics/AnalyticsChartDonut.d.ts.map +1 -0
  112. package/dist/components/admin/analytics/AnalyticsChartDonut.js +78 -0
  113. package/dist/components/admin/analytics/AnalyticsChartDonut.js.map +1 -0
  114. package/dist/components/admin/analytics/AnalyticsChartHeader.d.ts +20 -0
  115. package/dist/components/admin/analytics/AnalyticsChartHeader.d.ts.map +1 -0
  116. package/dist/components/admin/analytics/AnalyticsChartHeader.js +105 -0
  117. package/dist/components/admin/analytics/AnalyticsChartHeader.js.map +1 -0
  118. package/dist/components/admin/analytics/AnalyticsChartHeat.d.ts +10 -0
  119. package/dist/components/admin/analytics/AnalyticsChartHeat.d.ts.map +1 -0
  120. package/dist/components/admin/analytics/AnalyticsChartHeat.js +58 -0
  121. package/dist/components/admin/analytics/AnalyticsChartHeat.js.map +1 -0
  122. package/dist/components/admin/analytics/AnalyticsChartLegend.d.ts +9 -0
  123. package/dist/components/admin/analytics/AnalyticsChartLegend.d.ts.map +1 -0
  124. package/dist/components/admin/analytics/AnalyticsChartLegend.js +21 -0
  125. package/dist/components/admin/analytics/AnalyticsChartLegend.js.map +1 -0
  126. package/dist/components/admin/analytics/AnalyticsChartLine.d.ts +13 -0
  127. package/dist/components/admin/analytics/AnalyticsChartLine.d.ts.map +1 -0
  128. package/dist/components/admin/analytics/AnalyticsChartLine.js +36 -0
  129. package/dist/components/admin/analytics/AnalyticsChartLine.js.map +1 -0
  130. package/dist/components/admin/analytics/AnalyticsChartRank.d.ts +13 -0
  131. package/dist/components/admin/analytics/AnalyticsChartRank.d.ts.map +1 -0
  132. package/dist/components/admin/analytics/AnalyticsChartRank.js +41 -0
  133. package/dist/components/admin/analytics/AnalyticsChartRank.js.map +1 -0
  134. package/dist/components/admin/analytics/AnalyticsChartTicks.d.ts +13 -0
  135. package/dist/components/admin/analytics/AnalyticsChartTicks.d.ts.map +1 -0
  136. package/dist/components/admin/analytics/AnalyticsChartTicks.js +26 -0
  137. package/dist/components/admin/analytics/AnalyticsChartTicks.js.map +1 -0
  138. package/dist/components/admin/analytics/AnalyticsEmpty.d.ts +16 -0
  139. package/dist/components/admin/analytics/AnalyticsEmpty.d.ts.map +1 -0
  140. package/dist/components/admin/analytics/AnalyticsEmpty.js +32 -0
  141. package/dist/components/admin/analytics/AnalyticsEmpty.js.map +1 -0
  142. package/dist/components/admin/analytics/ClauseLabel.d.ts +15 -0
  143. package/dist/components/admin/analytics/ClauseLabel.d.ts.map +1 -0
  144. package/dist/components/admin/analytics/ClauseLabel.js +19 -0
  145. package/dist/components/admin/analytics/ClauseLabel.js.map +1 -0
  146. package/dist/components/admin/analytics/CompareNote.d.ts +16 -0
  147. package/dist/components/admin/analytics/CompareNote.d.ts.map +1 -0
  148. package/dist/components/admin/analytics/CompareNote.js +33 -0
  149. package/dist/components/admin/analytics/CompareNote.js.map +1 -0
  150. package/dist/components/admin/analytics/DatasetSelect.d.ts +20 -0
  151. package/dist/components/admin/analytics/DatasetSelect.d.ts.map +1 -0
  152. package/dist/components/admin/analytics/DatasetSelect.js +63 -0
  153. package/dist/components/admin/analytics/DatasetSelect.js.map +1 -0
  154. package/dist/components/admin/analytics/FilterEditor.d.ts +24 -0
  155. package/dist/components/admin/analytics/FilterEditor.d.ts.map +1 -0
  156. package/dist/components/admin/analytics/FilterEditor.js +129 -0
  157. package/dist/components/admin/analytics/FilterEditor.js.map +1 -0
  158. package/dist/components/admin/analytics/FilterValuePicker.d.ts +19 -0
  159. package/dist/components/admin/analytics/FilterValuePicker.d.ts.map +1 -0
  160. package/dist/components/admin/analytics/FilterValuePicker.js +131 -0
  161. package/dist/components/admin/analytics/FilterValuePicker.js.map +1 -0
  162. package/dist/components/admin/analytics/GroupByChips.d.ts +26 -0
  163. package/dist/components/admin/analytics/GroupByChips.d.ts.map +1 -0
  164. package/dist/components/admin/analytics/GroupByChips.js +71 -0
  165. package/dist/components/admin/analytics/GroupByChips.js.map +1 -0
  166. package/dist/components/admin/analytics/MeasureChips.d.ts +18 -0
  167. package/dist/components/admin/analytics/MeasureChips.d.ts.map +1 -0
  168. package/dist/components/admin/analytics/MeasureChips.js +46 -0
  169. package/dist/components/admin/analytics/MeasureChips.js.map +1 -0
  170. package/dist/components/admin/analytics/QueryPanel.d.ts +27 -0
  171. package/dist/components/admin/analytics/QueryPanel.d.ts.map +1 -0
  172. package/dist/components/admin/analytics/QueryPanel.js +92 -0
  173. package/dist/components/admin/analytics/QueryPanel.js.map +1 -0
  174. package/dist/components/admin/analytics/RangeControl.d.ts +17 -0
  175. package/dist/components/admin/analytics/RangeControl.d.ts.map +1 -0
  176. package/dist/components/admin/analytics/RangeControl.js +43 -0
  177. package/dist/components/admin/analytics/RangeControl.js.map +1 -0
  178. package/dist/components/admin/analytics/RequestDialog.d.ts +24 -0
  179. package/dist/components/admin/analytics/RequestDialog.d.ts.map +1 -0
  180. package/dist/components/admin/analytics/RequestDialog.js +67 -0
  181. package/dist/components/admin/analytics/RequestDialog.js.map +1 -0
  182. package/dist/components/admin/analytics/ResultsPane.d.ts +15 -0
  183. package/dist/components/admin/analytics/ResultsPane.d.ts.map +1 -0
  184. package/dist/components/admin/analytics/ResultsPane.js +161 -0
  185. package/dist/components/admin/analytics/ResultsPane.js.map +1 -0
  186. package/dist/components/admin/analytics/ResultsTable.d.ts +17 -0
  187. package/dist/components/admin/analytics/ResultsTable.d.ts.map +1 -0
  188. package/dist/components/admin/analytics/ResultsTable.js +113 -0
  189. package/dist/components/admin/analytics/ResultsTable.js.map +1 -0
  190. package/dist/components/admin/analytics/RunFooter.d.ts +18 -0
  191. package/dist/components/admin/analytics/RunFooter.d.ts.map +1 -0
  192. package/dist/components/admin/analytics/RunFooter.js +78 -0
  193. package/dist/components/admin/analytics/RunFooter.js.map +1 -0
  194. package/dist/components/admin/analytics/SamplingBadge.d.ts +18 -0
  195. package/dist/components/admin/analytics/SamplingBadge.d.ts.map +1 -0
  196. package/dist/components/admin/analytics/SamplingBadge.js +35 -0
  197. package/dist/components/admin/analytics/SamplingBadge.js.map +1 -0
  198. package/dist/components/admin/analytics/ToggleChip.d.ts +28 -0
  199. package/dist/components/admin/analytics/ToggleChip.d.ts.map +1 -0
  200. package/dist/components/admin/analytics/ToggleChip.js +35 -0
  201. package/dist/components/admin/analytics/ToggleChip.js.map +1 -0
  202. package/dist/components/admin/analytics/TotalsCards.d.ts +19 -0
  203. package/dist/components/admin/analytics/TotalsCards.d.ts.map +1 -0
  204. package/dist/components/admin/analytics/TotalsCards.js +75 -0
  205. package/dist/components/admin/analytics/TotalsCards.js.map +1 -0
  206. package/dist/components/admin/analytics/TruncationBanner.d.ts +15 -0
  207. package/dist/components/admin/analytics/TruncationBanner.d.ts.map +1 -0
  208. package/dist/components/admin/analytics/TruncationBanner.js +52 -0
  209. package/dist/components/admin/analytics/TruncationBanner.js.map +1 -0
  210. package/dist/components/admin/analytics/analyticsModel.d.ts +98 -0
  211. package/dist/components/admin/analytics/analyticsModel.d.ts.map +1 -0
  212. package/dist/components/admin/analytics/analyticsModel.js +184 -0
  213. package/dist/components/admin/analytics/analyticsModel.js.map +1 -0
  214. package/dist/components/admin/analytics/analyticsTypes.d.ts +116 -0
  215. package/dist/components/admin/analytics/analyticsTypes.d.ts.map +1 -0
  216. package/dist/components/admin/analytics/analyticsTypes.js +0 -0
  217. package/dist/components/admin/analytics/chartModel.d.ts +149 -0
  218. package/dist/components/admin/analytics/chartModel.d.ts.map +1 -0
  219. package/dist/components/admin/analytics/chartModel.js +278 -0
  220. package/dist/components/admin/analytics/chartModel.js.map +1 -0
  221. package/dist/components/admin/analytics/useAnalyticsQuery.d.ts +62 -0
  222. package/dist/components/admin/analytics/useAnalyticsQuery.d.ts.map +1 -0
  223. package/dist/components/admin/analytics/useAnalyticsQuery.js +257 -0
  224. package/dist/components/admin/analytics/useAnalyticsQuery.js.map +1 -0
  225. package/dist/components/admin/analytics/useDismissable.d.ts +18 -0
  226. package/dist/components/admin/analytics/useDismissable.d.ts.map +1 -0
  227. package/dist/components/admin/analytics/useDismissable.js +37 -0
  228. package/dist/components/admin/analytics/useDismissable.js.map +1 -0
  229. package/dist/components/admin/analytics/useFilterValues.d.ts +37 -0
  230. package/dist/components/admin/analytics/useFilterValues.d.ts.map +1 -0
  231. package/dist/components/admin/analytics/useFilterValues.js +78 -0
  232. package/dist/components/admin/analytics/useFilterValues.js.map +1 -0
  233. package/dist/components/admin/analytics/usePanelWidth.d.ts +26 -0
  234. package/dist/components/admin/analytics/usePanelWidth.d.ts.map +1 -0
  235. package/dist/components/admin/analytics/usePanelWidth.js +61 -0
  236. package/dist/components/admin/analytics/usePanelWidth.js.map +1 -0
  237. package/dist/components/admin/analytics/useShapeLabels.d.ts +24 -0
  238. package/dist/components/admin/analytics/useShapeLabels.d.ts.map +1 -0
  239. package/dist/components/admin/analytics/useShapeLabels.js +41 -0
  240. package/dist/components/admin/analytics/useShapeLabels.js.map +1 -0
  241. package/dist/components/admin/parameter-history-item.d.ts.map +1 -1
  242. package/dist/components/admin/parameter-history-item.js +3 -2
  243. package/dist/components/admin/parameter-history-item.js.map +1 -1
  244. package/dist/components/alepha-table/alepha-table-bulk-menu.d.ts +22 -0
  245. package/dist/components/alepha-table/alepha-table-bulk-menu.d.ts.map +1 -0
  246. package/dist/components/alepha-table/alepha-table-bulk-menu.js +118 -0
  247. package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -0
  248. package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts +60 -0
  249. package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts.map +1 -0
  250. package/dist/components/alepha-table/alepha-table-filter-dialog.js +88 -0
  251. package/dist/components/alepha-table/alepha-table-filter-dialog.js.map +1 -0
  252. package/dist/components/alepha-table/alepha-table-filter-menu.d.ts +35 -0
  253. package/dist/components/alepha-table/alepha-table-filter-menu.d.ts.map +1 -0
  254. package/dist/components/alepha-table/alepha-table-filter-menu.js +54 -0
  255. package/dist/components/alepha-table/alepha-table-filter-menu.js.map +1 -0
  256. package/dist/components/alepha-table/alepha-table.d.ts +336 -16
  257. package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
  258. package/dist/components/alepha-table/alepha-table.js +630 -174
  259. package/dist/components/alepha-table/alepha-table.js.map +1 -1
  260. package/dist/components/alepha-table/query-filters.d.ts +73 -0
  261. package/dist/components/alepha-table/query-filters.d.ts.map +1 -0
  262. package/dist/components/alepha-table/query-filters.js +118 -0
  263. package/dist/components/alepha-table/query-filters.js.map +1 -0
  264. package/dist/components/app-actions/app-actions.d.ts +21 -0
  265. package/dist/components/app-actions/app-actions.d.ts.map +1 -1
  266. package/dist/components/app-actions/app-actions.js +11 -5
  267. package/dist/components/app-actions/app-actions.js.map +1 -1
  268. package/dist/components/app-shell/app-shell.d.ts +75 -11
  269. package/dist/components/app-shell/app-shell.d.ts.map +1 -1
  270. package/dist/components/app-shell/app-shell.js +194 -83
  271. package/dist/components/app-shell/app-shell.js.map +1 -1
  272. package/dist/components/app-shell/navigation-progress.d.ts +40 -0
  273. package/dist/components/app-shell/navigation-progress.d.ts.map +1 -0
  274. package/dist/components/app-shell/navigation-progress.js +86 -0
  275. package/dist/components/app-shell/navigation-progress.js.map +1 -0
  276. package/dist/components/auth/auth-register.d.ts +35 -0
  277. package/dist/components/auth/auth-register.d.ts.map +1 -1
  278. package/dist/components/auth/auth-register.js +43 -38
  279. package/dist/components/auth/auth-register.js.map +1 -1
  280. package/dist/components/auto-form/auto-form.d.ts.map +1 -1
  281. package/dist/components/auto-form/auto-form.js +69 -28
  282. package/dist/components/auto-form/auto-form.js.map +1 -1
  283. package/dist/components/button-dark/button-dark.d.ts.map +1 -1
  284. package/dist/components/button-dark/button-dark.js +39 -8
  285. package/dist/components/button-dark/button-dark.js.map +1 -1
  286. package/dist/components/button-inbox/button-inbox.d.ts +66 -0
  287. package/dist/components/button-inbox/button-inbox.d.ts.map +1 -0
  288. package/dist/components/button-inbox/button-inbox.js +167 -0
  289. package/dist/components/button-inbox/button-inbox.js.map +1 -0
  290. package/dist/components/button-inbox/inbox-unread-atom.d.ts +22 -0
  291. package/dist/components/button-inbox/inbox-unread-atom.d.ts.map +1 -0
  292. package/dist/components/button-inbox/inbox-unread-atom.js +29 -0
  293. package/dist/components/button-inbox/inbox-unread-atom.js.map +1 -0
  294. package/dist/components/button-theme/button-theme.d.ts +4 -3
  295. package/dist/components/button-theme/button-theme.d.ts.map +1 -1
  296. package/dist/components/button-theme/button-theme.js +8 -25
  297. package/dist/components/button-theme/button-theme.js.map +1 -1
  298. package/dist/components/button-user/button-user.d.ts +19 -0
  299. package/dist/components/button-user/button-user.d.ts.map +1 -1
  300. package/dist/components/button-user/button-user.js +1 -1
  301. package/dist/components/button-user/button-user.js.map +1 -1
  302. package/dist/components/control/control.d.ts +90 -10
  303. package/dist/components/control/control.d.ts.map +1 -1
  304. package/dist/components/control/control.js +58 -8
  305. package/dist/components/control/control.js.map +1 -1
  306. package/dist/components/control-array/control-array.js +2 -1
  307. package/dist/components/control-array/control-array.js.map +1 -1
  308. package/dist/components/control-date/control-date.d.ts +35 -0
  309. package/dist/components/control-date/control-date.d.ts.map +1 -1
  310. package/dist/components/control-date/control-date.js +38 -26
  311. package/dist/components/control-date/control-date.js.map +1 -1
  312. package/dist/components/control-date/date-only.d.ts +18 -0
  313. package/dist/components/control-date/date-only.d.ts.map +1 -0
  314. package/dist/components/control-date/date-only.js +29 -0
  315. package/dist/components/control-date/date-only.js.map +1 -0
  316. package/dist/components/control-date-range/control-date-range.d.ts +56 -0
  317. package/dist/components/control-date-range/control-date-range.d.ts.map +1 -0
  318. package/dist/components/control-date-range/control-date-range.js +148 -0
  319. package/dist/components/control-date-range/control-date-range.js.map +1 -0
  320. package/dist/components/control-object/control-object.js +2 -1
  321. package/dist/components/control-object/control-object.js.map +1 -1
  322. package/dist/components/control-select/control-select.d.ts +57 -6
  323. package/dist/components/control-select/control-select.d.ts.map +1 -1
  324. package/dist/components/control-select/control-select.js +275 -55
  325. package/dist/components/control-select/control-select.js.map +1 -1
  326. package/dist/components/control-upload/control-upload.d.ts.map +1 -1
  327. package/dist/components/control-upload/control-upload.js +1 -11
  328. package/dist/components/control-upload/control-upload.js.map +1 -1
  329. package/dist/components/detail/detail-aside.d.ts.map +1 -1
  330. package/dist/components/detail/detail-aside.js +4 -3
  331. package/dist/components/detail/detail-aside.js.map +1 -1
  332. package/dist/components/detail/detail-layout.d.ts.map +1 -1
  333. package/dist/components/detail/detail-layout.js +9 -6
  334. package/dist/components/detail/detail-layout.js.map +1 -1
  335. package/dist/components/file-image/file-image.js +2 -1
  336. package/dist/components/file-image/file-image.js.map +1 -1
  337. package/dist/components/markdown-view/SpoilerSpan.d.ts +28 -0
  338. package/dist/components/markdown-view/SpoilerSpan.d.ts.map +1 -0
  339. package/dist/components/markdown-view/SpoilerSpan.js +53 -0
  340. package/dist/components/markdown-view/SpoilerSpan.js.map +1 -0
  341. package/dist/components/markdown-view/diagram/MermaidFence.d.ts.map +1 -1
  342. package/dist/components/markdown-view/diagram/MermaidFence.js +1 -15
  343. package/dist/components/markdown-view/diagram/MermaidFence.js.map +1 -1
  344. package/dist/components/markdown-view/diagram/diagramKind.d.ts +18 -0
  345. package/dist/components/markdown-view/diagram/diagramKind.d.ts.map +1 -0
  346. package/dist/components/markdown-view/diagram/diagramKind.js +27 -0
  347. package/dist/components/markdown-view/diagram/diagramKind.js.map +1 -0
  348. package/dist/components/markdown-view/diagram/layoutSequence.js +13 -23
  349. package/dist/components/markdown-view/diagram/layoutSequence.js.map +1 -1
  350. package/dist/components/markdown-view/diagram/textMetrics.js +2 -2
  351. package/dist/components/markdown-view/diagram/textMetrics.js.map +1 -1
  352. package/dist/components/markdown-view/markdown-view.css +44 -0
  353. package/dist/components/markdown-view/markdown-view.d.ts +12 -0
  354. package/dist/components/markdown-view/markdown-view.d.ts.map +1 -1
  355. package/dist/components/markdown-view/markdown-view.js +22 -1
  356. package/dist/components/markdown-view/markdown-view.js.map +1 -1
  357. package/dist/components/markdown-view/remarkSpoiler.d.ts +17 -0
  358. package/dist/components/markdown-view/remarkSpoiler.d.ts.map +1 -0
  359. package/dist/components/markdown-view/remarkSpoiler.js +117 -0
  360. package/dist/components/markdown-view/remarkSpoiler.js.map +1 -0
  361. package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts +34 -0
  362. package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts.map +1 -0
  363. package/dist/components/permission-matrix/permission-matrix-group-rows.js +109 -0
  364. package/dist/components/permission-matrix/permission-matrix-group-rows.js.map +1 -0
  365. package/dist/components/permission-matrix/permission-matrix.d.ts +145 -0
  366. package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
  367. package/dist/components/permission-matrix/permission-matrix.js +113 -0
  368. package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
  369. package/dist/components/plate-layout/plate-layout.d.ts +55 -0
  370. package/dist/components/plate-layout/plate-layout.d.ts.map +1 -0
  371. package/dist/components/plate-layout/plate-layout.js +38 -0
  372. package/dist/components/plate-layout/plate-layout.js.map +1 -0
  373. package/dist/components/plate-layout/plate-tab-bar.d.ts +65 -0
  374. package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -0
  375. package/dist/components/plate-layout/plate-tab-bar.js +52 -0
  376. package/dist/components/plate-layout/plate-tab-bar.js.map +1 -0
  377. package/dist/components/settings/settings-nav.js +2 -1
  378. package/dist/components/settings/settings-nav.js.map +1 -1
  379. package/dist/components/time-ago/time-ago.d.ts +57 -0
  380. package/dist/components/time-ago/time-ago.d.ts.map +1 -0
  381. package/dist/components/time-ago/time-ago.js +60 -0
  382. package/dist/components/time-ago/time-ago.js.map +1 -0
  383. package/dist/components/tree-view/tree-model.d.ts +128 -0
  384. package/dist/components/tree-view/tree-model.d.ts.map +1 -0
  385. package/dist/components/tree-view/tree-model.js +226 -0
  386. package/dist/components/tree-view/tree-model.js.map +1 -0
  387. package/dist/components/tree-view/tree-view-rename-input.d.ts +31 -0
  388. package/dist/components/tree-view/tree-view-rename-input.d.ts.map +1 -0
  389. package/dist/components/tree-view/tree-view-rename-input.js +68 -0
  390. package/dist/components/tree-view/tree-view-rename-input.js.map +1 -0
  391. package/dist/components/tree-view/tree-view-resizer.d.ts +38 -0
  392. package/dist/components/tree-view/tree-view-resizer.d.ts.map +1 -0
  393. package/dist/components/tree-view/tree-view-resizer.js +73 -0
  394. package/dist/components/tree-view/tree-view-resizer.js.map +1 -0
  395. package/dist/components/tree-view/tree-view-row.d.ts +177 -0
  396. package/dist/components/tree-view/tree-view-row.d.ts.map +1 -0
  397. package/dist/components/tree-view/tree-view-row.js +241 -0
  398. package/dist/components/tree-view/tree-view-row.js.map +1 -0
  399. package/dist/components/tree-view/tree-view.d.ts +186 -0
  400. package/dist/components/tree-view/tree-view.d.ts.map +1 -0
  401. package/dist/components/tree-view/tree-view.js +112 -0
  402. package/dist/components/tree-view/tree-view.js.map +1 -0
  403. package/dist/components/tree-view/use-tree-state.d.ts +79 -0
  404. package/dist/components/tree-view/use-tree-state.d.ts.map +1 -0
  405. package/dist/components/tree-view/use-tree-state.js +93 -0
  406. package/dist/components/tree-view/use-tree-state.js.map +1 -0
  407. package/dist/components/ui/button.d.ts.map +1 -1
  408. package/dist/components/ui/button.js +2 -2
  409. package/dist/components/ui/button.js.map +1 -1
  410. package/dist/components/ui/dropdown-menu.js.map +1 -1
  411. package/dist/components/ui/select.d.ts +7 -0
  412. package/dist/components/ui/select.d.ts.map +1 -1
  413. package/dist/components/ui/select.js +7 -0
  414. package/dist/components/ui/select.js.map +1 -1
  415. package/dist/components/ui/sidebar.js +1 -1
  416. package/dist/components/ui/sidebar.js.map +1 -1
  417. package/dist/components/ui/table.js.map +1 -1
  418. package/dist/components/ui/tooltip.js.map +1 -1
  419. package/dist/components/use-dialog/use-dialog.d.ts +7 -0
  420. package/dist/components/use-dialog/use-dialog.d.ts.map +1 -1
  421. package/dist/components/use-dialog/use-dialog.js +10 -1
  422. package/dist/components/use-dialog/use-dialog.js.map +1 -1
  423. package/dist/lib/i18n-fr.d.ts.map +1 -1
  424. package/dist/lib/i18n-fr.js +141 -54
  425. package/dist/lib/i18n-fr.js.map +1 -1
  426. package/dist/lib/utils.d.ts +22 -2
  427. package/dist/lib/utils.d.ts.map +1 -1
  428. package/dist/lib/utils.js +29 -5
  429. package/dist/lib/utils.js.map +1 -1
  430. package/dist/styles.css +300 -21
  431. package/package.json +16 -16
  432. package/src/components/account/__tests__/account-layout.browser.spec.tsx +127 -0
  433. package/src/components/account/__tests__/account-router.spec.ts +95 -0
  434. package/src/components/account/account-connections.tsx +14 -1
  435. package/src/components/account/account-delete-dialog.tsx +3 -2
  436. package/src/components/account/account-keys.tsx +11 -4
  437. package/src/components/account/account-layout.tsx +32 -2
  438. package/src/components/account/account-mfa-dialog.tsx +1 -1
  439. package/src/components/account/account-password-dialog.tsx +3 -2
  440. package/src/components/account/account-profile.tsx +1 -1
  441. package/src/components/account/account-router-options.tsx +45 -0
  442. package/src/components/account/account-router-page.tsx +11 -1
  443. package/src/components/account/account-router.tsx +23 -6
  444. package/src/components/admin/__tests__/admin-audits-action-filter.browser.spec.tsx +53 -0
  445. package/src/components/admin/__tests__/admin-jobs-payload-dialog.browser.spec.tsx +68 -0
  446. package/src/components/admin/__tests__/admin-notifications-preview-body.browser.spec.tsx +20 -4
  447. package/src/components/admin/__tests__/admin-status-labels.browser.spec.tsx +0 -31
  448. package/src/components/admin/admin-analytics.tsx +97 -83
  449. package/src/components/admin/admin-audits.tsx +149 -13
  450. package/src/components/admin/admin-files.tsx +10 -16
  451. package/src/components/admin/admin-jobs-executions-panel.tsx +152 -114
  452. package/src/components/admin/admin-jobs-payload-dialog.tsx +57 -0
  453. package/src/components/admin/admin-keys.tsx +9 -4
  454. package/src/components/admin/admin-notifications-channel-label.ts +18 -0
  455. package/src/components/admin/admin-notifications-preview-body.tsx +7 -2
  456. package/src/components/admin/admin-notifications.tsx +19 -8
  457. package/src/components/admin/admin-parameters.tsx +165 -12
  458. package/src/components/admin/admin-payments.tsx +7 -4
  459. package/src/components/admin/admin-router-options.tsx +12 -0
  460. package/src/components/admin/admin-router.tsx +5 -27
  461. package/src/components/admin/admin-sessions.tsx +174 -10
  462. package/src/components/admin/admin-user-avatar-control.tsx +130 -0
  463. package/src/components/admin/admin-user-detail-audits-tab.tsx +7 -4
  464. package/src/components/admin/admin-user-detail-sessions-tab.tsx +7 -4
  465. package/src/components/admin/admin-user-detail.tsx +25 -3
  466. package/src/components/admin/admin-users-roles-picker.tsx +4 -0
  467. package/src/components/admin/admin-users.tsx +6 -3
  468. package/src/components/admin/analytics/AdvancedSection.tsx +162 -0
  469. package/src/components/admin/analytics/AnalyticsChart.tsx +69 -0
  470. package/src/components/admin/analytics/AnalyticsChartBars.tsx +86 -0
  471. package/src/components/admin/analytics/AnalyticsChartDonut.tsx +78 -0
  472. package/src/components/admin/analytics/AnalyticsChartHeader.tsx +135 -0
  473. package/src/components/admin/analytics/AnalyticsChartHeat.tsx +57 -0
  474. package/src/components/admin/analytics/AnalyticsChartLegend.tsx +26 -0
  475. package/src/components/admin/analytics/AnalyticsChartLine.tsx +37 -0
  476. package/src/components/admin/analytics/AnalyticsChartRank.tsx +43 -0
  477. package/src/components/admin/analytics/AnalyticsChartTicks.tsx +38 -0
  478. package/src/components/admin/analytics/AnalyticsEmpty.tsx +37 -0
  479. package/src/components/admin/analytics/ClauseLabel.tsx +26 -0
  480. package/src/components/admin/analytics/CompareNote.tsx +50 -0
  481. package/src/components/admin/analytics/DatasetSelect.tsx +79 -0
  482. package/src/components/admin/analytics/FilterEditor.tsx +173 -0
  483. package/src/components/admin/analytics/FilterValuePicker.tsx +154 -0
  484. package/src/components/admin/analytics/GroupByChips.tsx +82 -0
  485. package/src/components/admin/analytics/MeasureChips.tsx +53 -0
  486. package/src/components/admin/analytics/QueryPanel.tsx +113 -0
  487. package/src/components/admin/analytics/RangeControl.tsx +42 -0
  488. package/src/components/admin/analytics/RequestDialog.tsx +91 -0
  489. package/src/components/admin/analytics/ResultsPane.tsx +224 -0
  490. package/src/components/admin/analytics/ResultsTable.tsx +176 -0
  491. package/src/components/admin/analytics/RunFooter.tsx +90 -0
  492. package/src/components/admin/analytics/SamplingBadge.tsx +46 -0
  493. package/src/components/admin/analytics/ToggleChip.tsx +57 -0
  494. package/src/components/admin/analytics/TotalsCards.tsx +79 -0
  495. package/src/components/admin/analytics/TruncationBanner.tsx +60 -0
  496. package/src/components/admin/analytics/analyticsModel.spec.ts +266 -0
  497. package/src/components/admin/analytics/analyticsModel.ts +263 -0
  498. package/src/components/admin/analytics/analyticsTypes.ts +139 -0
  499. package/src/components/admin/analytics/chartModel.spec.ts +240 -0
  500. package/src/components/admin/analytics/chartModel.ts +427 -0
  501. package/src/components/admin/analytics/useAnalyticsQuery.ts +401 -0
  502. package/src/components/admin/analytics/useDismissable.ts +48 -0
  503. package/src/components/admin/analytics/useFilterValues.ts +113 -0
  504. package/src/components/admin/analytics/usePanelWidth.ts +85 -0
  505. package/src/components/admin/analytics/useShapeLabels.ts +73 -0
  506. package/src/components/admin/parameter-history-item.tsx +4 -2
  507. package/src/components/alepha-table/__tests__/alepha-table-actions.browser.spec.tsx +117 -0
  508. package/src/components/alepha-table/__tests__/alepha-table-bulk-menu.browser.spec.tsx +177 -0
  509. package/src/components/alepha-table/__tests__/alepha-table-bulk-visible.browser.spec.tsx +125 -0
  510. package/src/components/alepha-table/__tests__/alepha-table-default-hidden.browser.spec.tsx +108 -0
  511. package/src/components/alepha-table/__tests__/alepha-table-empty-state.browser.spec.tsx +233 -0
  512. package/src/components/alepha-table/__tests__/alepha-table-persist-facets.browser.spec.tsx +177 -0
  513. package/src/components/alepha-table/__tests__/alepha-table-persisted-filters.browser.spec.tsx +182 -0
  514. package/src/components/alepha-table/__tests__/alepha-table-query-seed.browser.spec.tsx +170 -0
  515. package/src/components/alepha-table/__tests__/alepha-table-row-action-checked.browser.spec.tsx +210 -0
  516. package/src/components/alepha-table/__tests__/alepha-table-row-action-group.browser.spec.tsx +202 -0
  517. package/src/components/alepha-table/__tests__/alepha-table-scope.browser.spec.tsx +161 -0
  518. package/src/components/alepha-table/__tests__/alepha-table-share-filters.browser.spec.tsx +309 -0
  519. package/src/components/alepha-table/__tests__/query-filters.spec.ts +212 -0
  520. package/src/components/alepha-table/alepha-table-bulk-menu.tsx +170 -0
  521. package/src/components/alepha-table/alepha-table-filter-dialog.tsx +162 -0
  522. package/src/components/alepha-table/alepha-table-filter-menu.tsx +77 -0
  523. package/src/components/alepha-table/alepha-table.tsx +1375 -230
  524. package/src/components/alepha-table/query-filters.ts +159 -0
  525. package/src/components/app-actions/app-actions.tsx +32 -3
  526. package/src/components/app-shell/__tests__/navigation-progress.browser.spec.tsx +122 -0
  527. package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
  528. package/src/components/app-shell/__tests__/sidebar-nav-auto-close.browser.spec.tsx +170 -0
  529. package/src/components/app-shell/app-shell.tsx +390 -122
  530. package/src/components/app-shell/navigation-progress.tsx +110 -0
  531. package/src/components/auth/auth-register.tsx +72 -9
  532. package/src/components/auto-form/__tests__/auto-form-fill-groups.browser.spec.tsx +104 -0
  533. package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
  534. package/src/components/auto-form/auto-form.tsx +111 -33
  535. package/src/components/button-dark/button-dark.tsx +47 -8
  536. package/src/components/button-inbox/__tests__/button-inbox.browser.spec.tsx +247 -0
  537. package/src/components/button-inbox/button-inbox.tsx +303 -0
  538. package/src/components/button-inbox/inbox-unread-atom.ts +27 -0
  539. package/src/components/button-theme/button-theme.tsx +16 -29
  540. package/src/components/button-user/__tests__/button-user-avatar.browser.spec.tsx +88 -0
  541. package/src/components/button-user/button-user.tsx +24 -1
  542. package/src/components/control/__tests__/control-date-range.browser.spec.tsx +177 -0
  543. package/src/components/control/control.tsx +182 -26
  544. package/src/components/control-date/control-date.tsx +170 -36
  545. package/src/components/control-date/date-only.ts +26 -0
  546. package/src/components/control-date-range/control-date-range.tsx +250 -0
  547. package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +129 -15
  548. package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +27 -6
  549. package/src/components/control-select/__tests__/control-select-multi.browser.spec.tsx +399 -0
  550. package/src/components/control-select/__tests__/control-select-searchable.browser.spec.tsx +5 -1
  551. package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +195 -0
  552. package/src/components/control-select/__tests__/control-select-trigger-props.browser.spec.tsx +89 -0
  553. package/src/components/control-select/control-select.tsx +554 -123
  554. package/src/components/control-upload/control-upload.tsx +1 -10
  555. package/src/components/detail/__tests__/detail-layout.browser.spec.tsx +46 -0
  556. package/src/components/detail/detail-aside.tsx +30 -6
  557. package/src/components/detail/detail-layout.tsx +37 -7
  558. package/src/components/markdown-view/SpoilerSpan.tsx +66 -0
  559. package/src/components/markdown-view/__tests__/markdown-view-spoiler.browser.spec.tsx +165 -0
  560. package/src/components/markdown-view/diagram/MermaidFence.tsx +1 -23
  561. package/src/components/markdown-view/diagram/diagramKind.ts +31 -0
  562. package/src/components/markdown-view/diagram/textMetrics.spec.ts +1 -1
  563. package/src/components/markdown-view/diagram/textMetrics.ts +2 -2
  564. package/src/components/markdown-view/markdown-view.css +44 -0
  565. package/src/components/markdown-view/markdown-view.tsx +37 -1
  566. package/src/components/markdown-view/remarkSpoiler.ts +150 -0
  567. package/src/components/permission-matrix/__tests__/permission-matrix.browser.spec.tsx +237 -0
  568. package/src/components/permission-matrix/permission-matrix-group-rows.tsx +240 -0
  569. package/src/components/permission-matrix/permission-matrix.tsx +286 -0
  570. package/src/components/plate-layout/__tests__/plate-layout.browser.spec.tsx +189 -0
  571. package/src/components/plate-layout/plate-layout.tsx +84 -0
  572. package/src/components/plate-layout/plate-tab-bar.tsx +148 -0
  573. package/src/components/time-ago/time-ago.browser.spec.tsx +110 -0
  574. package/src/components/time-ago/time-ago.tsx +80 -0
  575. package/src/components/tree-view/__tests__/tree-model.spec.ts +441 -0
  576. package/src/components/tree-view/__tests__/tree-view-drag.browser.spec.tsx +295 -0
  577. package/src/components/tree-view/__tests__/tree-view-rename.browser.spec.tsx +278 -0
  578. package/src/components/tree-view/__tests__/tree-view-resizer.browser.spec.tsx +112 -0
  579. package/src/components/tree-view/__tests__/tree-view.browser.spec.tsx +260 -0
  580. package/src/components/tree-view/__tests__/use-tree-state.browser.spec.tsx +238 -0
  581. package/src/components/tree-view/tree-model.ts +369 -0
  582. package/src/components/tree-view/tree-view-rename-input.tsx +95 -0
  583. package/src/components/tree-view/tree-view-resizer.tsx +83 -0
  584. package/src/components/tree-view/tree-view-row.tsx +414 -0
  585. package/src/components/tree-view/tree-view.tsx +300 -0
  586. package/src/components/tree-view/use-tree-state.ts +184 -0
  587. package/src/components/ui/button.tsx +80 -2
  588. package/src/components/ui/dropdown-menu.tsx +1 -1
  589. package/src/components/ui/select.tsx +7 -0
  590. package/src/components/ui/table.tsx +1 -1
  591. package/src/components/ui/tooltip.tsx +1 -1
  592. package/src/components/use-dialog/use-dialog.tsx +10 -0
  593. package/src/lib/i18n-fr.ts +155 -58
  594. package/src/lib/utils.ts +32 -4
  595. package/src/styles.css +300 -21
  596. package/dist/components/admin/admin-analytics-query-panel.d.ts +0 -16
  597. package/dist/components/admin/admin-analytics-query-panel.d.ts.map +0 -1
  598. package/dist/components/admin/admin-analytics-query-panel.js +0 -117
  599. package/dist/components/admin/admin-analytics-query-panel.js.map +0 -1
  600. package/dist/components/admin/admin-analytics-results.d.ts +0 -15
  601. package/dist/components/admin/admin-analytics-results.d.ts.map +0 -1
  602. package/dist/components/admin/admin-analytics-results.js +0 -56
  603. package/dist/components/admin/admin-analytics-results.js.map +0 -1
  604. package/dist/components/admin/admin-workflows-execution-sheet.d.ts +0 -11
  605. package/dist/components/admin/admin-workflows-execution-sheet.d.ts.map +0 -1
  606. package/dist/components/admin/admin-workflows-execution-sheet.js +0 -190
  607. package/dist/components/admin/admin-workflows-execution-sheet.js.map +0 -1
  608. package/dist/components/admin/admin-workflows-executions-panel.d.ts +0 -9
  609. package/dist/components/admin/admin-workflows-executions-panel.d.ts.map +0 -1
  610. package/dist/components/admin/admin-workflows-executions-panel.js +0 -121
  611. package/dist/components/admin/admin-workflows-executions-panel.js.map +0 -1
  612. package/dist/components/admin/admin-workflows-status-badge.d.ts +0 -12
  613. package/dist/components/admin/admin-workflows-status-badge.d.ts.map +0 -1
  614. package/dist/components/admin/admin-workflows-status-badge.js +0 -30
  615. package/dist/components/admin/admin-workflows-status-badge.js.map +0 -1
  616. package/dist/components/admin/admin-workflows-status-labels.d.ts +0 -19
  617. package/dist/components/admin/admin-workflows-status-labels.d.ts.map +0 -1
  618. package/dist/components/admin/admin-workflows-status-labels.js +0 -48
  619. package/dist/components/admin/admin-workflows-status-labels.js.map +0 -1
  620. package/dist/components/admin/admin-workflows.d.ts +0 -4
  621. package/dist/components/admin/admin-workflows.d.ts.map +0 -1
  622. package/dist/components/admin/admin-workflows.js +0 -145
  623. package/dist/components/admin/admin-workflows.js.map +0 -1
  624. package/src/components/admin/admin-analytics-query-panel.tsx +0 -150
  625. package/src/components/admin/admin-analytics-results.tsx +0 -95
  626. package/src/components/admin/admin-workflows-execution-sheet.tsx +0 -285
  627. package/src/components/admin/admin-workflows-executions-panel.tsx +0 -169
  628. package/src/components/admin/admin-workflows-status-badge.tsx +0 -41
  629. package/src/components/admin/admin-workflows-status-labels.ts +0 -51
  630. package/src/components/admin/admin-workflows.tsx +0 -209
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ export interface SpoilerSpanProps {
3
+ children?: React.ReactNode;
4
+ }
5
+ /**
6
+ * A `||spoiler||`, hidden until the reader asks for it.
7
+ *
8
+ * ## ⚠️ It is not a security feature
9
+ *
10
+ * The text is in the DOM from the first paint - hidden by a colour, not by an
11
+ * absence. It is also in the raw markdown, in a folio export, in `folio_get`
12
+ * over MCP and in any search snippet. It hides a plot point from a reader's
13
+ * eye and nothing more, and must never be described as a way to store a
14
+ * secret.
15
+ *
16
+ * ## Reachable without a mouse
17
+ *
18
+ * `role="button"` with a `tabIndex`, Enter and Space, and an `aria-label`
19
+ * naming what it is: a screen reader that met a bare `<span>` here would
20
+ * simply read the hidden text aloud, which is not a failure of privacy (see
21
+ * above) but is a failure to say that the author meant it to be covered.
22
+ *
23
+ * Once revealed it stays revealed. Re-hiding on blur would make the thing
24
+ * unreadable with a keyboard, since moving on to read what is around it is
25
+ * exactly what a reader does next.
26
+ */
27
+ export declare const SpoilerSpan: (props: SpoilerSpanProps) => React.JSX.Element;
28
+ //# sourceMappingURL=SpoilerSpan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpoilerSpan.d.ts","sourceRoot":"","sources":["../../../src/components/markdown-view/SpoilerSpan.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,UAAW,gBAAgB,sBAiClD,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/components/markdown-view/SpoilerSpan.tsx
4
+ /**
5
+ * A `||spoiler||`, hidden until the reader asks for it.
6
+ *
7
+ * ## ⚠️ It is not a security feature
8
+ *
9
+ * The text is in the DOM from the first paint - hidden by a colour, not by an
10
+ * absence. It is also in the raw markdown, in a folio export, in `folio_get`
11
+ * over MCP and in any search snippet. It hides a plot point from a reader's
12
+ * eye and nothing more, and must never be described as a way to store a
13
+ * secret.
14
+ *
15
+ * ## Reachable without a mouse
16
+ *
17
+ * `role="button"` with a `tabIndex`, Enter and Space, and an `aria-label`
18
+ * naming what it is: a screen reader that met a bare `<span>` here would
19
+ * simply read the hidden text aloud, which is not a failure of privacy (see
20
+ * above) but is a failure to say that the author meant it to be covered.
21
+ *
22
+ * Once revealed it stays revealed. Re-hiding on blur would make the thing
23
+ * unreadable with a keyboard, since moving on to read what is around it is
24
+ * exactly what a reader does next.
25
+ */
26
+ const SpoilerSpan = (props) => {
27
+ const [revealed, setRevealed] = useState(false);
28
+ if (revealed) return /* @__PURE__ */ jsx("span", {
29
+ "data-spoiler": "revealed",
30
+ className: "rounded-[3px] px-0.5",
31
+ children: props.children
32
+ });
33
+ return /* @__PURE__ */ jsx("span", {
34
+ "data-spoiler": "hidden",
35
+ role: "button",
36
+ tabIndex: 0,
37
+ "aria-expanded": false,
38
+ "aria-label": "Hidden text, activate to reveal",
39
+ className: "rounded-[3px] px-0.5",
40
+ onClick: () => setRevealed(true),
41
+ onKeyDown: (event) => {
42
+ if (event.key === "Enter" || event.key === " ") {
43
+ event.preventDefault();
44
+ setRevealed(true);
45
+ }
46
+ },
47
+ children: props.children
48
+ });
49
+ };
50
+ //#endregion
51
+ export { SpoilerSpan };
52
+
53
+ //# sourceMappingURL=SpoilerSpan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpoilerSpan.js","names":[],"sources":["../../../src/components/markdown-view/SpoilerSpan.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useState } from \"react\";\n\nexport interface SpoilerSpanProps {\n children?: React.ReactNode;\n}\n\n/**\n * A `||spoiler||`, hidden until the reader asks for it.\n *\n * ## ⚠️ It is not a security feature\n *\n * The text is in the DOM from the first paint - hidden by a colour, not by an\n * absence. It is also in the raw markdown, in a folio export, in `folio_get`\n * over MCP and in any search snippet. It hides a plot point from a reader's\n * eye and nothing more, and must never be described as a way to store a\n * secret.\n *\n * ## Reachable without a mouse\n *\n * `role=\"button\"` with a `tabIndex`, Enter and Space, and an `aria-label`\n * naming what it is: a screen reader that met a bare `<span>` here would\n * simply read the hidden text aloud, which is not a failure of privacy (see\n * above) but is a failure to say that the author meant it to be covered.\n *\n * Once revealed it stays revealed. Re-hiding on blur would make the thing\n * unreadable with a keyboard, since moving on to read what is around it is\n * exactly what a reader does next.\n */\nexport const SpoilerSpan = (props: SpoilerSpanProps) => {\n const [revealed, setRevealed] = useState(false);\n\n if (revealed) {\n return (\n <span data-spoiler=\"revealed\" className=\"rounded-[3px] px-0.5\">\n {props.children}\n </span>\n );\n }\n\n return (\n <span\n data-spoiler=\"hidden\"\n role=\"button\"\n tabIndex={0}\n aria-expanded={false}\n aria-label=\"Hidden text, activate to reveal\"\n className=\"rounded-[3px] px-0.5\"\n onClick={() => setRevealed(true)}\n onKeyDown={(event) => {\n // Enter and Space, because `role=\"button\"` promises both and a `span`\n // delivers neither on its own. `preventDefault` on Space stops the\n // page scrolling out from under the reader who just pressed it.\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n setRevealed(true);\n }\n }}\n >\n {props.children}\n </span>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,eAAe,UAA4B;CACtD,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAE9C,IAAI,UACF,OACE,oBAAC,QAAD;EAAM,gBAAa;EAAW,WAAU;EACrC,UAAA,MAAM;CACH,CAAA;CAIV,OACE,oBAAC,QAAD;EACE,gBAAa;EACb,MAAK;EACL,UAAU;EACV,iBAAe;EACf,cAAW;EACX,WAAU;EACV,eAAe,YAAY,IAAI;EAC/B,YAAY,UAAU;GAIpB,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;IAC9C,MAAM,eAAe;IACrB,YAAY,IAAI;GAClB;EACF;EAEC,UAAA,MAAM;CACH,CAAA;AAEV"}
@@ -1 +1 @@
1
- {"version":3,"file":"MermaidFence.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown-view/diagram/MermaidFence.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAoBpD,CAAC;eA2Ba,YAAY"}
1
+ {"version":3,"file":"MermaidFence.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown-view/diagram/MermaidFence.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAoBpD,CAAC;eAIa,YAAY"}
@@ -1,4 +1,5 @@
1
1
  import { FlowchartDiagram } from "./FlowchartDiagram.js";
2
+ import { diagramKind } from "./diagramKind.js";
2
3
  import { parseFlowchart } from "./flowchartParser.js";
3
4
  import { layoutFlowchart } from "./layoutFlowchart.js";
4
5
  import { layoutSequence } from "./layoutSequence.js";
@@ -44,21 +45,6 @@ const MermaidFence = (props) => {
44
45
  }
45
46
  return /* @__PURE__ */ jsx(Fragment$1, { children: props.fallback });
46
47
  };
47
- /**
48
- * Which pipeline a fence belongs to, from its header line.
49
- *
50
- * The header is the first line that is not YAML frontmatter, a
51
- * `%%{init: …}%%` directive or a `%%` comment - mermaid allows all three
52
- * above it. Both parsers check their own header again, because both are
53
- * independently callable; this exists so an unsupported diagram type never
54
- * enters a parser at all.
55
- */
56
- const diagramKind = (source) => {
57
- const header = source.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\r?\n/, "").replace(/%%\{[\s\S]*?\}%%/g, "").split(/\r?\n/).map((line) => line.replace(/%%.*$/, "").trim()).find(Boolean);
58
- if (!header) return void 0;
59
- if (/^sequenceDiagram\b/i.test(header)) return "sequence";
60
- if (/^(?:flowchart|graph)\b/i.test(header)) return "flowchart";
61
- };
62
48
  //#endregion
63
49
  export { MermaidFence, MermaidFence as default };
64
50
 
@@ -1 +1 @@
1
- {"version":3,"file":"MermaidFence.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/MermaidFence.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { ReactNode } from \"react\";\n\nimport { FlowchartDiagram } from \"./FlowchartDiagram.tsx\";\nimport { parseFlowchart } from \"./flowchartParser.ts\";\nimport { layoutFlowchart } from \"./layoutFlowchart.ts\";\nimport { layoutSequence } from \"./layoutSequence.ts\";\nimport { SequenceDiagram } from \"./SequenceDiagram.tsx\";\nimport { parseSequence } from \"./sequenceParser.ts\";\n\nexport interface MermaidFenceProps {\n /**\n * The raw text between the fence markers.\n */\n source: string;\n /**\n * What to render when the source is not a diagram we can draw. Always the\n * code block the fence would otherwise have produced.\n */\n fallback: ReactNode;\n}\n\n/**\n * The lazy chunk's entry point, and the dispatcher between the two\n * pipelines: read the header, parse, lay out, draw - or hand back the fence\n * untouched.\n *\n * This is the ONLY module that pulls in either parser, `graphre` and either\n * emitter, and it is imported through `lazy()` from `markdown-view.tsx`.\n * That is the whole constraint the diagram layer lives under: a document\n * with no diagram must pay nothing at all.\n *\n * **The two pipelines are parallel, not shared.** A flowchart ranks a node\n * graph and needs a layout library; a sequence diagram has both axes\n * decided by source order and needs none. Lifelines, ordered messages and\n * fragment boxes have essentially nothing in common with nodes, edges and\n * clusters, so one model type for both would make both halves worse. What\n * they do share is the text metrics, the theming, the marker namespacing,\n * the error boundary and the policy below.\n *\n * **Failure is always the code block, silently.** A parse failure, a\n * refused construct, a diagram past its cap, and a `classDiagram` all land\n * here identically. Agents write invalid mermaid, and a red error box in\n * the middle of a folio is worse than a grey fence.\n */\nexport const MermaidFence = (props: MermaidFenceProps) => {\n const kind = diagramKind(props.source);\n\n if (kind === \"sequence\") {\n const model = parseSequence(props.source);\n const diagram = model ? layoutSequence(model) : undefined;\n return diagram ? (\n <SequenceDiagram diagram={diagram} />\n ) : (\n <>{props.fallback}</>\n );\n }\n\n if (kind === \"flowchart\") {\n const model = parseFlowchart(props.source);\n const graph = model ? layoutFlowchart(model) : undefined;\n return graph ? <FlowchartDiagram graph={graph} /> : <>{props.fallback}</>;\n }\n\n return <>{props.fallback}</>;\n};\n\n/**\n * Which pipeline a fence belongs to, from its header line.\n *\n * The header is the first line that is not YAML frontmatter, a\n * `%%{init: …}%%` directive or a `%%` comment - mermaid allows all three\n * above it. Both parsers check their own header again, because both are\n * independently callable; this exists so an unsupported diagram type never\n * enters a parser at all.\n */\nconst diagramKind = (source: string): \"sequence\" | \"flowchart\" | undefined => {\n const header = source\n .replace(/^\\s*---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n/, \"\")\n .replace(/%%\\{[\\s\\S]*?\\}%%/g, \"\")\n .split(/\\r?\\n/)\n .map((line) => line.replace(/%%.*$/, \"\").trim())\n .find(Boolean);\n\n if (!header) return undefined;\n if (/^sequenceDiagram\\b/i.test(header)) return \"sequence\";\n if (/^(?:flowchart|graph)\\b/i.test(header)) return \"flowchart\";\n return undefined;\n};\n\n// Default export as well, so the `lazy()` call site stays a bare\n// `import(...)` with no `.then(m => ({ default: m.X }))` wrapper.\nexport default MermaidFence;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,gBAAgB,UAA6B;CACxD,MAAM,OAAO,YAAY,MAAM,MAAM;CAErC,IAAI,SAAS,YAAY;EACvB,MAAM,QAAQ,cAAc,MAAM,MAAM;EACxC,MAAM,UAAU,QAAQ,eAAe,KAAK,IAAI,KAAA;EAChD,OAAO,UACL,oBAAC,iBAAD,EAA0B,QAAU,CAAA,IAEpC,oBAAA,YAAA,EAAA,UAAG,MAAM,SAAW,CAAA;CAExB;CAEA,IAAI,SAAS,aAAa;EACxB,MAAM,QAAQ,eAAe,MAAM,MAAM;EACzC,MAAM,QAAQ,QAAQ,gBAAgB,KAAK,IAAI,KAAA;EAC/C,OAAO,QAAQ,oBAAC,kBAAD,EAAyB,MAAQ,CAAA,IAAI,oBAAA,YAAA,EAAA,UAAG,MAAM,SAAW,CAAA;CAC1E;CAEA,OAAO,oBAAA,YAAA,EAAA,UAAG,MAAM,SAAW,CAAA;AAC7B;;;;;;;;;;AAWA,MAAM,eAAe,WAAyD;CAC5E,MAAM,SAAS,OACZ,QAAQ,qCAAqC,EAAE,CAAC,CAChD,QAAQ,qBAAqB,EAAE,CAAC,CAChC,MAAM,OAAO,CAAC,CACd,KAAK,SAAS,KAAK,QAAQ,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAC/C,KAAK,OAAO;CAEf,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,sBAAsB,KAAK,MAAM,GAAG,OAAO;CAC/C,IAAI,0BAA0B,KAAK,MAAM,GAAG,OAAO;AAErD"}
1
+ {"version":3,"file":"MermaidFence.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/MermaidFence.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { ReactNode } from \"react\";\n\nimport { diagramKind } from \"./diagramKind.ts\";\nimport { FlowchartDiagram } from \"./FlowchartDiagram.tsx\";\nimport { parseFlowchart } from \"./flowchartParser.ts\";\nimport { layoutFlowchart } from \"./layoutFlowchart.ts\";\nimport { layoutSequence } from \"./layoutSequence.ts\";\nimport { SequenceDiagram } from \"./SequenceDiagram.tsx\";\nimport { parseSequence } from \"./sequenceParser.ts\";\n\nexport interface MermaidFenceProps {\n /**\n * The raw text between the fence markers.\n */\n source: string;\n /**\n * What to render when the source is not a diagram we can draw. Always the\n * code block the fence would otherwise have produced.\n */\n fallback: ReactNode;\n}\n\n/**\n * The lazy chunk's entry point, and the dispatcher between the two\n * pipelines: read the header, parse, lay out, draw - or hand back the fence\n * untouched.\n *\n * This is the ONLY module that pulls in either parser, `graphre` and either\n * emitter, and it is imported through `lazy()` from `markdown-view.tsx`.\n * That is the whole constraint the diagram layer lives under: a document\n * with no diagram must pay nothing at all.\n *\n * **The two pipelines are parallel, not shared.** A flowchart ranks a node\n * graph and needs a layout library; a sequence diagram has both axes\n * decided by source order and needs none. Lifelines, ordered messages and\n * fragment boxes have essentially nothing in common with nodes, edges and\n * clusters, so one model type for both would make both halves worse. What\n * they do share is the text metrics, the theming, the marker namespacing,\n * the error boundary and the policy below.\n *\n * **Failure is always the code block, silently.** A parse failure, a\n * refused construct, a diagram past its cap, and a `classDiagram` all land\n * here identically. Agents write invalid mermaid, and a red error box in\n * the middle of a folio is worse than a grey fence.\n */\nexport const MermaidFence = (props: MermaidFenceProps) => {\n const kind = diagramKind(props.source);\n\n if (kind === \"sequence\") {\n const model = parseSequence(props.source);\n const diagram = model ? layoutSequence(model) : undefined;\n return diagram ? (\n <SequenceDiagram diagram={diagram} />\n ) : (\n <>{props.fallback}</>\n );\n }\n\n if (kind === \"flowchart\") {\n const model = parseFlowchart(props.source);\n const graph = model ? layoutFlowchart(model) : undefined;\n return graph ? <FlowchartDiagram graph={graph} /> : <>{props.fallback}</>;\n }\n\n return <>{props.fallback}</>;\n};\n\n// Default export as well, so the `lazy()` call site stays a bare\n// `import(...)` with no `.then(m => ({ default: m.X }))` wrapper.\nexport default MermaidFence;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAa,gBAAgB,UAA6B;CACxD,MAAM,OAAO,YAAY,MAAM,MAAM;CAErC,IAAI,SAAS,YAAY;EACvB,MAAM,QAAQ,cAAc,MAAM,MAAM;EACxC,MAAM,UAAU,QAAQ,eAAe,KAAK,IAAI,KAAA;EAChD,OAAO,UACL,oBAAC,iBAAD,EAA0B,QAAU,CAAA,IAEpC,oBAAA,YAAA,EAAA,UAAG,MAAM,SAAW,CAAA;CAExB;CAEA,IAAI,SAAS,aAAa;EACxB,MAAM,QAAQ,eAAe,MAAM,MAAM;EACzC,MAAM,QAAQ,QAAQ,gBAAgB,KAAK,IAAI,KAAA;EAC/C,OAAO,QAAQ,oBAAC,kBAAD,EAAyB,MAAQ,CAAA,IAAI,oBAAA,YAAA,EAAA,UAAG,MAAM,SAAW,CAAA;CAC1E;CAEA,OAAO,oBAAA,YAAA,EAAA,UAAG,MAAM,SAAW,CAAA;AAC7B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Which pipeline a ` ```mermaid ` fence belongs to, from its header line.
3
+ *
4
+ * The header is the first line that is not YAML frontmatter, a
5
+ * `%%{init: …}%%` directive or a `%%` comment - mermaid allows all three
6
+ * above it. Both parsers check their own header again, because both are
7
+ * independently callable; this exists so an unsupported diagram type never
8
+ * enters a parser at all.
9
+ *
10
+ * ⚠️ **Pure, and in its own file so it can be called from a server.** The
11
+ * renderer is not the only caller any more: Lore checks the fences an agent
12
+ * writes over MCP and warns in the tool result, which happens in a Worker
13
+ * with no DOM and no React. Both sides have to agree on what "supported"
14
+ * means, or the warning describes a different renderer than the one that
15
+ * runs - so there is one function, not two.
16
+ */
17
+ export declare const diagramKind: (source: string) => "sequence" | "flowchart" | undefined;
18
+ //# sourceMappingURL=diagramKind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagramKind.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown-view/diagram/diagramKind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,WACd,MAAM,KACb,UAAU,GAAG,WAAW,GAAG,SAY7B,CAAC"}
@@ -0,0 +1,27 @@
1
+ //#region src/components/markdown-view/diagram/diagramKind.ts
2
+ /**
3
+ * Which pipeline a ` ```mermaid ` fence belongs to, from its header line.
4
+ *
5
+ * The header is the first line that is not YAML frontmatter, a
6
+ * `%%{init: …}%%` directive or a `%%` comment - mermaid allows all three
7
+ * above it. Both parsers check their own header again, because both are
8
+ * independently callable; this exists so an unsupported diagram type never
9
+ * enters a parser at all.
10
+ *
11
+ * ⚠️ **Pure, and in its own file so it can be called from a server.** The
12
+ * renderer is not the only caller any more: Lore checks the fences an agent
13
+ * writes over MCP and warns in the tool result, which happens in a Worker
14
+ * with no DOM and no React. Both sides have to agree on what "supported"
15
+ * means, or the warning describes a different renderer than the one that
16
+ * runs - so there is one function, not two.
17
+ */
18
+ const diagramKind = (source) => {
19
+ const header = source.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\r?\n/, "").replace(/%%\{[\s\S]*?\}%%/g, "").split(/\r?\n/).map((line) => line.replace(/%%.*$/, "").trim()).find(Boolean);
20
+ if (!header) return void 0;
21
+ if (/^sequenceDiagram\b/i.test(header)) return "sequence";
22
+ if (/^(?:flowchart|graph)\b/i.test(header)) return "flowchart";
23
+ };
24
+ //#endregion
25
+ export { diagramKind };
26
+
27
+ //# sourceMappingURL=diagramKind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagramKind.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/diagramKind.ts"],"sourcesContent":["/**\n * Which pipeline a ` ```mermaid ` fence belongs to, from its header line.\n *\n * The header is the first line that is not YAML frontmatter, a\n * `%%{init: …}%%` directive or a `%%` comment - mermaid allows all three\n * above it. Both parsers check their own header again, because both are\n * independently callable; this exists so an unsupported diagram type never\n * enters a parser at all.\n *\n * ⚠️ **Pure, and in its own file so it can be called from a server.** The\n * renderer is not the only caller any more: Lore checks the fences an agent\n * writes over MCP and warns in the tool result, which happens in a Worker\n * with no DOM and no React. Both sides have to agree on what \"supported\"\n * means, or the warning describes a different renderer than the one that\n * runs - so there is one function, not two.\n */\nexport const diagramKind = (\n source: string,\n): \"sequence\" | \"flowchart\" | undefined => {\n const header = source\n .replace(/^\\s*---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n/, \"\")\n .replace(/%%\\{[\\s\\S]*?\\}%%/g, \"\")\n .split(/\\r?\\n/)\n .map((line) => line.replace(/%%.*$/, \"\").trim())\n .find(Boolean);\n\n if (!header) return undefined;\n if (/^sequenceDiagram\\b/i.test(header)) return \"sequence\";\n if (/^(?:flowchart|graph)\\b/i.test(header)) return \"flowchart\";\n return undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,WACyC;CACzC,MAAM,SAAS,OACZ,QAAQ,qCAAqC,EAAE,CAAC,CAChD,QAAQ,qBAAqB,EAAE,CAAC,CAChC,MAAM,OAAO,CAAC,CACd,KAAK,SAAS,KAAK,QAAQ,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAC/C,KAAK,OAAO;CAEf,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,sBAAsB,KAAK,MAAM,GAAG,OAAO;CAC/C,IAAI,0BAA0B,KAAK,MAAM,GAAG,OAAO;AAErD"}
@@ -40,8 +40,6 @@ const MAX_SEQUENCE_MESSAGES = 300;
40
40
  */
41
41
  const GAP_LABEL_MARGIN = 1.04;
42
42
  const DIAGRAM_PADDING = 12;
43
- const PARTICIPANT_PAD_X = 14;
44
- const PARTICIPANT_PAD_Y = 8;
45
43
  const PARTICIPANT_MIN_WIDTH = 64;
46
44
  /**
47
45
  * Clear space between two adjacent participant boxes, before any label
@@ -62,14 +60,8 @@ const SELF_LOOP_WIDTH = 32;
62
60
  const SELF_LOOP_LABEL_GAP = 8;
63
61
  const SELF_LOOP_MIN_HEIGHT = 26;
64
62
  const SELF_LOOP_TOP_PAD = 4;
65
- const NOTE_PAD_X = 10;
66
- const NOTE_PAD_Y = 7;
67
63
  const NOTE_ROW_GAP = 14;
68
64
  /**
69
- * How far a `Note over A,B` reaches past the two lifelines it spans.
70
- */
71
- const NOTE_SPAN_OVERHANG = 10;
72
- /**
73
65
  * Clearance between a note box and any lifeline it is not attached to.
74
66
  */
75
67
  const NOTE_CLEARANCE = 10;
@@ -78,8 +70,6 @@ const FRAGMENT_INSET = 9;
78
70
  * How far a depth-0 fragment box reaches past the widest content.
79
71
  */
80
72
  const FRAGMENT_MARGIN = 14;
81
- const FRAGMENT_TAB_PAD_X = 8;
82
- const FRAGMENT_TAB_PAD_Y = 3;
83
73
  const FRAGMENT_TOP_PAD = 8;
84
74
  const FRAGMENT_BOTTOM_PAD = 10;
85
75
  const FRAGMENT_AFTER_GAP = 6;
@@ -129,7 +119,7 @@ const layoutSequence = (model, fontSize = 13) => {
129
119
  const maxX = fragments.length ? content.maxX + FRAGMENT_MARGIN : content.maxX;
130
120
  const dx = DIAGRAM_PADDING - minX;
131
121
  return {
132
- width: maxX - minX + DIAGRAM_PADDING * 2,
122
+ width: maxX - minX + 24,
133
123
  height: rows.bottom + headerHeight + DIAGRAM_PADDING,
134
124
  fontSize,
135
125
  participants: participants.map((participant) => ({
@@ -171,8 +161,8 @@ const measureHead = (lines, actor, fontSize) => {
171
161
  lines: label.lines
172
162
  };
173
163
  return {
174
- width: Math.max(label.width + PARTICIPANT_PAD_X * 2, PARTICIPANT_MIN_WIDTH),
175
- height: label.height + PARTICIPANT_PAD_Y * 2,
164
+ width: Math.max(label.width + 28, PARTICIPANT_MIN_WIDTH),
165
+ height: label.height + 16,
176
166
  lines: label.lines
177
167
  };
178
168
  };
@@ -188,8 +178,8 @@ const measureSteps = (model, fontSize) => {
188
178
  if (step.kind === "note") {
189
179
  const label = measureLabel(step.lines, fontSize);
190
180
  return {
191
- width: label.width + NOTE_PAD_X * 2,
192
- height: label.height + NOTE_PAD_Y * 2,
181
+ width: label.width + 20,
182
+ height: label.height + 14,
193
183
  lines: label.lines
194
184
  };
195
185
  }
@@ -240,13 +230,13 @@ const columnCenters = (model, index, heads, labels) => {
240
230
  widen(from, from + 1, 40 + label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER);
241
231
  continue;
242
232
  }
243
- widen(Math.min(from, to), Math.max(from, to), label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER * 2);
233
+ widen(Math.min(from, to), Math.max(from, to), label.width * GAP_LABEL_MARGIN + 20);
244
234
  continue;
245
235
  }
246
236
  const anchors = step.participants.map((id) => index.get(id)).filter((at) => at !== void 0);
247
237
  if (anchors.length === 0) continue;
248
238
  if (step.placement === "over" && anchors.length > 1) {
249
- widen(Math.min(...anchors), Math.max(...anchors), label.width - NOTE_SPAN_OVERHANG * 2);
239
+ widen(Math.min(...anchors), Math.max(...anchors), label.width - 20);
250
240
  continue;
251
241
  }
252
242
  const anchor = anchors[0];
@@ -255,8 +245,8 @@ const columnCenters = (model, index, heads, labels) => {
255
245
  widen(anchor, anchor + 1, label.width / 2 + NOTE_CLEARANCE);
256
246
  continue;
257
247
  }
258
- if (step.placement === "left") widen(anchor - 1, anchor, label.width + NOTE_CLEARANCE * 2);
259
- else widen(anchor, anchor + 1, label.width + NOTE_CLEARANCE * 2);
248
+ if (step.placement === "left") widen(anchor - 1, anchor, label.width + 20);
249
+ else widen(anchor, anchor + 1, label.width + 20);
260
250
  }
261
251
  const centers = [0];
262
252
  for (const gap of gaps) centers.push(centers[centers.length - 1] + gap);
@@ -273,7 +263,7 @@ const layoutRows = (model, index, centers, labels, context) => {
273
263
  const messages = [];
274
264
  const notes = [];
275
265
  const spans = /* @__PURE__ */ new Map();
276
- const tabHeight = context.fontSize * DIAGRAM_LINE_HEIGHT + FRAGMENT_TAB_PAD_Y * 2;
266
+ const tabHeight = context.fontSize * DIAGRAM_LINE_HEIGHT + 6;
277
267
  const opening = byStep(model, (fragment) => fragment.from, 1);
278
268
  const closing = byStep(model, (fragment) => fragment.to, -1);
279
269
  const dividing = dividersByStep(model);
@@ -409,7 +399,7 @@ const placeNote = (step, label, index, centers, y, out) => {
409
399
  if (anchors.length === 0) return y;
410
400
  const from = Math.min(...anchors);
411
401
  const to = Math.max(...anchors);
412
- const width = step.placement === "over" && to > from ? Math.max(label.width, centers[to] - centers[from] + NOTE_SPAN_OVERHANG * 2) : label.width;
402
+ const width = step.placement === "over" && to > from ? Math.max(label.width, centers[to] - centers[from] + 20) : label.width;
413
403
  const x = step.placement === "left" ? centers[from] - NOTE_CLEARANCE - width : step.placement === "right" ? centers[from] + NOTE_CLEARANCE : (centers[from] + centers[to]) / 2 - width / 2;
414
404
  out.push({
415
405
  placement: step.placement,
@@ -464,8 +454,8 @@ const layoutFragments = (model, rows, content, fontSize) => model.fragments.map(
464
454
  y: span.top,
465
455
  width: Math.max(right - x, FRAGMENT_MIN_WIDTH),
466
456
  height: span.bottom - span.top,
467
- tabWidth: label.width + FRAGMENT_TAB_PAD_X * 2,
468
- tabHeight: label.height + FRAGMENT_TAB_PAD_Y * 2,
457
+ tabWidth: label.width + 16,
458
+ tabHeight: label.height + 6,
469
459
  dividers: fragment.dividers.map((divider, i) => ({
470
460
  y: span.dividers[i] ?? span.top,
471
461
  label: divider.label
@@ -1 +1 @@
1
- {"version":3,"file":"layoutSequence.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/layoutSequence.ts"],"sourcesContent":["import type {\n SequenceArrowHead,\n SequenceFragment,\n SequenceFragmentKind,\n SequenceLineStyle,\n SequenceModel,\n SequenceNote,\n SequenceStep,\n} from \"./sequenceModel.ts\";\nimport {\n DIAGRAM_FONT_SIZE,\n DIAGRAM_LINE_HEIGHT,\n measureLabel,\n} from \"./textMetrics.ts\";\n\n/**\n * The largest diagram that gets laid out. Above either cap the caller falls\n * back to the code block.\n *\n * Unlike the flowchart caps these are NOT about time: layout here is O(n)\n * arithmetic with no ranking to compute, and 300 rows lay out in under a\n * millisecond. They are about legibility and DOM size - 30 lifelines is\n * already far past what anyone can read, and every row is a handful of SVG\n * elements on a page that may carry several diagrams.\n *\n * `MAX_SEQUENCE_MESSAGES` counts ROWS, notes included: a note occupies a\n * row and costs a box, so counting only messages would let a note-heavy\n * diagram past the cap it exists to enforce.\n */\nexport const MAX_SEQUENCE_PARTICIPANTS = 30;\nexport const MAX_SEQUENCE_MESSAGES = 300;\n\n/**\n * The safety margin applied to the width a label needs in the gap between\n * two lifelines. **Gap constraints only** - not participant boxes, which\n * stay tight, and not note boxes, which carry their own padding.\n *\n * ## Why a margin exists here and nowhere else\n *\n * `textMetrics.ts` measures text from a generated per-character width table\n * rather than from the DOM, which is what keeps this a pure function. The\n * table was measured against `canvas.measureText` on the real Inter woff2\n * and agrees **within ~1.3%**, all of it from rounding the ratios to three\n * decimals.\n *\n * The asymmetry is what makes the margin necessary at all. A flowchart\n * label sits INSIDE its box, so a 1.3% underestimate only eats padding. A\n * sequence label sits IN THE GAP between two lifelines, so the same\n * underestimate puts text on top of the neighbouring lifeline. 4% is three\n * times the measured error.\n *\n * Do not \"optimise\" this away as a magic number: it is a measured 1.3% with\n * headroom, and removing it makes long labels collide.\n */\nexport const GAP_LABEL_MARGIN = 1.04;\n\nconst DIAGRAM_PADDING = 12;\nconst PARTICIPANT_PAD_X = 14;\nconst PARTICIPANT_PAD_Y = 8;\nconst PARTICIPANT_MIN_WIDTH = 64;\n/**\n * Clear space between two adjacent participant boxes, before any label\n * widens the gap.\n */\nconst PARTICIPANT_CLEARANCE = 26;\n/**\n * The stick figure an `actor` draws above its name.\n */\nconst ACTOR_FIGURE_HEIGHT = 32;\nconst ACTOR_LABEL_GAP = 4;\nconst ACTOR_MIN_WIDTH = 40;\n\nconst LIFELINE_TOP_GAP = 14;\nconst LIFELINE_BOTTOM_GAP = 14;\n\nconst MESSAGE_LABEL_GAP = 4;\nconst MESSAGE_ROW_GAP = 16;\n/**\n * Clearance between a message label and each lifeline it is centred\n * between.\n */\nconst MESSAGE_LABEL_GUTTER = 10;\n\nconst SELF_LOOP_WIDTH = 32;\nconst SELF_LOOP_LABEL_GAP = 8;\nconst SELF_LOOP_MIN_HEIGHT = 26;\nconst SELF_LOOP_TOP_PAD = 4;\n\nconst NOTE_PAD_X = 10;\nconst NOTE_PAD_Y = 7;\nconst NOTE_ROW_GAP = 14;\n/**\n * How far a `Note over A,B` reaches past the two lifelines it spans.\n */\nconst NOTE_SPAN_OVERHANG = 10;\n/**\n * Clearance between a note box and any lifeline it is not attached to.\n */\nconst NOTE_CLEARANCE = 10;\n\nconst FRAGMENT_INSET = 9;\n/**\n * How far a depth-0 fragment box reaches past the widest content.\n */\nconst FRAGMENT_MARGIN = 14;\nconst FRAGMENT_TAB_PAD_X = 8;\nconst FRAGMENT_TAB_PAD_Y = 3;\nconst FRAGMENT_TOP_PAD = 8;\nconst FRAGMENT_BOTTOM_PAD = 10;\nconst FRAGMENT_AFTER_GAP = 6;\nconst FRAGMENT_MIN_WIDTH = 60;\nconst DIVIDER_GAP = 8;\n\nexport interface PositionedParticipant {\n id: string;\n /**\n * The lines as MEASURED - wrapped and capped. Draw exactly these.\n */\n lines: string[];\n actor: boolean;\n /**\n * TOP-LEFT corner of the header box, the same convention the flowchart\n * layout settled on. An emitter half a box off looks almost right, which\n * is the worst way for this to be wrong.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * Where the lifeline runs. `centerX` is the lifeline's x, and the box is\n * centred on it.\n */\n centerX: number;\n lifelineTop: number;\n lifelineBottom: number;\n /**\n * TOP-LEFT y of the repeated footer box. Its `x`, `width` and `height`\n * are the header's.\n */\n bottomY: number;\n}\n\nexport interface PositionedLabel {\n lines: string[];\n /**\n * TOP-LEFT corner.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PositionedMessage {\n from: string;\n to: string;\n line: SequenceLineStyle;\n head: SequenceArrowHead;\n self: boolean;\n /**\n * Two points for a normal message, four for the loop of a self-message.\n * In from-to order, so the head marker lands on the receiver.\n */\n points: Array<{ x: number; y: number }>;\n /**\n * Already carries the `autonumber` counter when the diagram declared one.\n */\n label: PositionedLabel;\n}\n\nexport interface PositionedNoteBox extends PositionedLabel {\n placement: SequenceNote[\"placement\"];\n}\n\nexport interface PositionedFragment {\n kind: SequenceFragmentKind;\n /**\n * The condition, drawn next to the tab. May be empty.\n */\n label: string;\n depth: number;\n /**\n * TOP-LEFT corner of the box.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * The corner tab carrying the kind (`alt`, `opt`, `loop`).\n */\n tabWidth: number;\n tabHeight: number;\n dividers: Array<{ y: number; label: string }>;\n}\n\n/**\n * A laid-out sequence diagram: data, not markup. No SVG, no React, no DOM.\n */\nexport interface PositionedSequence {\n width: number;\n height: number;\n fontSize: number;\n participants: PositionedParticipant[];\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * Outermost first, so the emitter draws them in order and gets z-order\n * free, the way the flowchart clusters do.\n */\n fragments: PositionedFragment[];\n}\n\n/**\n * Place a `SequenceModel` on a plane.\n *\n * **No layout library is involved, and none is coming back.** `graphre`\n * ranks a node graph; here both axes are already decided by the source -\n * participants left to right in declaration order, rows top to bottom in\n * statement order - so layout is arithmetic. The only genuinely hard part\n * is the column widths, which take two passes (see `columnCenters`).\n *\n * Returns `undefined` (never throws, never a partial diagram) for an empty\n * model or one past the caps. The caller's fallback is the code block.\n */\nexport const layoutSequence = (\n model: SequenceModel,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): PositionedSequence | undefined => {\n if (model.participants.length === 0 || model.steps.length === 0)\n return undefined;\n if (model.participants.length > MAX_SEQUENCE_PARTICIPANTS) return undefined;\n if (model.steps.length > MAX_SEQUENCE_MESSAGES) return undefined;\n\n const index = new Map(model.participants.map((p, i) => [p.id, i]));\n const heads = model.participants.map((participant) =>\n measureHead(participant.lines, participant.actor, fontSize),\n );\n // ⚠️ Numbering happens BEFORE anything is measured. The counter is part of\n // the label, so measuring first and numbering after makes every column\n // too narrow - and it stays invisible until a diagram reaches ten\n // messages and the labels go double-digit.\n const labels = measureSteps(model, fontSize);\n\n const centers = columnCenters(model, index, heads, labels);\n const headerHeight = Math.max(...heads.map((head) => head.height));\n\n const rows = layoutRows(model, index, centers, labels, {\n fontSize,\n top: DIAGRAM_PADDING + headerHeight + LIFELINE_TOP_GAP,\n });\n\n const participants = model.participants.map((participant, i) => ({\n id: participant.id,\n lines: heads[i].lines,\n actor: participant.actor,\n // Header boxes are bottom-aligned so every lifeline starts on the same\n // y, whatever mix of one-line names, wrapped names and actors is on the\n // row.\n x: centers[i] - heads[i].width / 2,\n y: DIAGRAM_PADDING + headerHeight - heads[i].height,\n width: heads[i].width,\n height: heads[i].height,\n centerX: centers[i],\n lifelineTop: DIAGRAM_PADDING + headerHeight,\n lifelineBottom: rows.bottom,\n bottomY: rows.bottom,\n }));\n\n const content = contentBounds(participants, rows);\n const fragments = layoutFragments(model, rows, content, fontSize);\n\n const minX = fragments.length ? content.minX - FRAGMENT_MARGIN : content.minX;\n const maxX = fragments.length ? content.maxX + FRAGMENT_MARGIN : content.maxX;\n const dx = DIAGRAM_PADDING - minX;\n\n return {\n width: maxX - minX + DIAGRAM_PADDING * 2,\n height: rows.bottom + headerHeight + DIAGRAM_PADDING,\n fontSize,\n participants: participants.map((participant) => ({\n ...participant,\n x: participant.x + dx,\n centerX: participant.centerX + dx,\n })),\n messages: rows.messages.map((message) => ({\n ...message,\n points: message.points.map((point) => ({ x: point.x + dx, y: point.y })),\n label: { ...message.label, x: message.label.x + dx },\n })),\n notes: rows.notes.map((note) => ({ ...note, x: note.x + dx })),\n fragments: fragments.map((fragment) => ({\n ...fragment,\n x: fragment.x + dx,\n })),\n };\n};\n\ninterface Measured {\n width: number;\n height: number;\n lines: string[];\n}\n\n/**\n * The header box of one participant. An `actor` is a stick figure with its\n * name underneath rather than a box around it, so it is taller and needs no\n * horizontal padding.\n */\nconst measureHead = (\n lines: string[],\n actor: boolean,\n fontSize: number,\n): Measured => {\n const label = measureLabel(lines, fontSize);\n if (actor)\n return {\n width: Math.max(label.width, ACTOR_MIN_WIDTH),\n height: ACTOR_FIGURE_HEIGHT + ACTOR_LABEL_GAP + label.height,\n lines: label.lines,\n };\n return {\n width: Math.max(label.width + PARTICIPANT_PAD_X * 2, PARTICIPANT_MIN_WIDTH),\n height: label.height + PARTICIPANT_PAD_Y * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Measure every row's label once, applying `autonumber` first.\n *\n * A note's measurement is its BOX (label plus padding); a message's is its\n * bare label, because a message label is drawn straight onto the diagram.\n */\nconst measureSteps = (model: SequenceModel, fontSize: number): Measured[] => {\n let counter = model.autonumber?.start ?? 0;\n return model.steps.map((step) => {\n if (step.kind === \"note\") {\n const label = measureLabel(step.lines, fontSize);\n return {\n width: label.width + NOTE_PAD_X * 2,\n height: label.height + NOTE_PAD_Y * 2,\n lines: label.lines,\n };\n }\n if (!model.autonumber) return measureLabel(step.lines, fontSize);\n\n const number = counter;\n counter += model.autonumber.step;\n const [first, ...rest] = step.lines;\n return measureLabel(\n [first ? `${number}. ${first}` : `${number}`, ...rest],\n fontSize,\n );\n });\n};\n\n/**\n * Where each lifeline sits on the x axis, in two passes.\n *\n * **Pass one** gives every adjacent pair the room its two boxes need side\n * by side.\n *\n * **Pass two** walks every message and note and widens the span it covers\n * until its label fits. A label is centred over its whole span, so a\n * message from participant 1 to participant 5 constrains the sum of four\n * gaps rather than any one of them, and the shortfall is spread evenly\n * across the gaps it crosses. Gaps only ever grow, so one pass over the\n * constraints is enough: widening for a later label can never break an\n * earlier one.\n *\n * The centres come back starting at 0. The caller translates once, at the\n * end, after the true bounding box is known.\n */\nconst columnCenters = (\n model: SequenceModel,\n index: Map<string, number>,\n heads: Measured[],\n labels: Measured[],\n): number[] => {\n const count = model.participants.length;\n const gaps: number[] = [];\n for (let i = 0; i < count - 1; i++)\n gaps.push(\n heads[i].width / 2 + heads[i + 1].width / 2 + PARTICIPANT_CLEARANCE,\n );\n\n const widen = (from: number, to: number, required: number): void => {\n // A constraint can legitimately point off the end of the row: a note to\n // the left of the FIRST lifeline has no gap to widen, and the space it\n // needs falls out of the final bounding box instead. Clamping here\n // rather than at each call site is what keeps those cases from reading\n // `gaps[-1]` and poisoning every later width with a NaN.\n if (to <= from || from < 0 || to > gaps.length) return;\n let current = 0;\n for (let i = from; i < to; i++) current += gaps[i];\n if (current >= required) return;\n const extra = (required - current) / (to - from);\n for (let i = from; i < to; i++) gaps[i] += extra;\n };\n\n for (const [at, step] of model.steps.entries()) {\n const label = labels[at];\n if (step.kind === \"message\") {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) continue;\n\n if (step.self) {\n // The loop hangs to the RIGHT of its lifeline with the label beyond\n // it, so it eats into one gap rather than spanning several. At the\n // last participant there is no gap to eat, and the clearance falls\n // out of the final bounding box instead.\n if (from >= count - 1) continue;\n widen(\n from,\n from + 1,\n SELF_LOOP_WIDTH +\n SELF_LOOP_LABEL_GAP +\n label.width * GAP_LABEL_MARGIN +\n MESSAGE_LABEL_GUTTER,\n );\n continue;\n }\n widen(\n Math.min(from, to),\n Math.max(from, to),\n label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER * 2,\n );\n continue;\n }\n\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) continue;\n\n if (step.placement === \"over\" && anchors.length > 1) {\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n // A note box carries its own padding, so no margin is applied to it -\n // it is not text sitting in a gap.\n widen(from, to, label.width - NOTE_SPAN_OVERHANG * 2);\n continue;\n }\n\n const anchor = anchors[0];\n if (step.placement === \"over\") {\n // Centred on one lifeline, so it eats half its width into each\n // neighbouring gap.\n widen(anchor - 1, anchor, label.width / 2 + NOTE_CLEARANCE);\n widen(anchor, anchor + 1, label.width / 2 + NOTE_CLEARANCE);\n continue;\n }\n if (step.placement === \"left\")\n widen(anchor - 1, anchor, label.width + NOTE_CLEARANCE * 2);\n else widen(anchor, anchor + 1, label.width + NOTE_CLEARANCE * 2);\n }\n\n const centers = [0];\n for (const gap of gaps) centers.push(centers[centers.length - 1] + gap);\n return centers;\n};\n\ninterface RowContext {\n fontSize: number;\n top: number;\n}\n\ninterface Rows {\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * y where every lifeline stops, and the footer boxes start.\n */\n bottom: number;\n /**\n * Per fragment, the box top and bottom and each divider's y, keyed by the\n * fragment's position in `model.fragments`.\n */\n spans: Map<number, { top: number; bottom: number; dividers: number[] }>;\n}\n\n/**\n * One sequential pass down the rows, assigning y.\n *\n * This is the whole reason the model is flat: a nested tree would force\n * this to recurse while threading the cursor through it, and a fragment box\n * would still have to be min/max over the rows it turned out to contain.\n */\nconst layoutRows = (\n model: SequenceModel,\n index: Map<string, number>,\n centers: number[],\n labels: Measured[],\n context: RowContext,\n): Rows => {\n const messages: PositionedMessage[] = [];\n const notes: PositionedNoteBox[] = [];\n const spans = new Map<\n number,\n { top: number; bottom: number; dividers: number[] }\n >();\n const tabHeight =\n context.fontSize * DIAGRAM_LINE_HEIGHT + FRAGMENT_TAB_PAD_Y * 2;\n\n // Outermost first on the way in, innermost first on the way out, so a\n // nested box always sits strictly inside the one that contains it.\n const opening = byStep(model, (fragment) => fragment.from, 1);\n const closing = byStep(model, (fragment) => fragment.to, -1);\n const dividing = dividersByStep(model);\n\n let y = context.top;\n\n for (const [at, step] of model.steps.entries()) {\n for (const owner of opening.get(at) ?? []) {\n spans.set(owner, { top: y, bottom: y, dividers: [] });\n y += tabHeight + FRAGMENT_TOP_PAD;\n }\n for (const owner of dividing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += DIVIDER_GAP;\n span.dividers.push(y);\n // The `else` condition is drawn BELOW its divider, because that is\n // the branch it names, so the room for it goes below too.\n y += context.fontSize * DIAGRAM_LINE_HEIGHT + DIVIDER_GAP;\n }\n\n const label = labels[at];\n y =\n step.kind === \"note\"\n ? placeNote(step, label, index, centers, y, notes)\n : placeMessage(step, label, index, centers, y, messages);\n\n for (const owner of closing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += FRAGMENT_BOTTOM_PAD;\n span.bottom = y;\n y += FRAGMENT_AFTER_GAP;\n }\n }\n\n return { messages, notes, bottom: y + LIFELINE_BOTTOM_GAP, spans };\n};\n\n/**\n * Fragment indices grouped by the step they open or close at, sorted so\n * outer fragments come first on the way in and last on the way out.\n */\nconst byStep = (\n model: SequenceModel,\n pick: (fragment: SequenceFragment) => number,\n order: 1 | -1,\n): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n push(out, pick(fragment), at);\n for (const list of out.values())\n list.sort(\n (a, b) => (model.fragments[a].depth - model.fragments[b].depth) * order,\n );\n return out;\n};\n\n/**\n * Which fragments have an `else` at each step, outermost first: a divider\n * belonging to an outer box has to be drawn above one belonging to a box\n * nested inside it, or the two branches read as swapped.\n */\nconst dividersByStep = (model: SequenceModel): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n for (const divider of fragment.dividers) push(out, divider.at, at);\n for (const list of out.values())\n list.sort((a, b) => model.fragments[a].depth - model.fragments[b].depth);\n return out;\n};\n\nconst push = (map: Map<number, number[]>, key: number, value: number): void => {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n};\n\nconst placeMessage = (\n step: Extract<SequenceStep, { kind: \"message\" }>,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedMessage[],\n): number => {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) return y;\n\n if (step.self) {\n const height = Math.max(SELF_LOOP_MIN_HEIGHT, label.height + 6);\n const top = y + SELF_LOOP_TOP_PAD;\n const bottom = top + height;\n const x = centers[from];\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: true,\n points: [\n { x, y: top },\n { x: x + SELF_LOOP_WIDTH, y: top },\n { x: x + SELF_LOOP_WIDTH, y: bottom },\n { x, y: bottom },\n ],\n label: {\n lines: label.lines,\n x: x + SELF_LOOP_WIDTH + SELF_LOOP_LABEL_GAP,\n y: (top + bottom) / 2 - label.height / 2,\n width: label.width,\n height: label.height,\n },\n });\n return bottom + MESSAGE_ROW_GAP;\n }\n\n const lineY = y + label.height + MESSAGE_LABEL_GAP;\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: false,\n points: [\n { x: centers[from], y: lineY },\n { x: centers[to], y: lineY },\n ],\n label: {\n lines: label.lines,\n x: (centers[from] + centers[to]) / 2 - label.width / 2,\n y,\n width: label.width,\n height: label.height,\n },\n });\n return lineY + MESSAGE_ROW_GAP;\n};\n\nconst placeNote = (\n step: SequenceNote,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedNoteBox[],\n): number => {\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) return y;\n\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n const width =\n step.placement === \"over\" && to > from\n ? Math.max(\n label.width,\n centers[to] - centers[from] + NOTE_SPAN_OVERHANG * 2,\n )\n : label.width;\n\n const x =\n step.placement === \"left\"\n ? centers[from] - NOTE_CLEARANCE - width\n : step.placement === \"right\"\n ? centers[from] + NOTE_CLEARANCE\n : (centers[from] + centers[to]) / 2 - width / 2;\n\n out.push({\n placement: step.placement,\n lines: label.lines,\n x,\n y,\n width,\n height: label.height,\n });\n return y + label.height + NOTE_ROW_GAP;\n};\n\ninterface Bounds {\n minX: number;\n maxX: number;\n}\n\n/**\n * The x extent of everything except the fragment boxes, which are sized\n * FROM it. A note hanging off the first lifeline and a self-message looping\n * off the last one are the two things that reach past the participants.\n */\nconst contentBounds = (\n participants: PositionedParticipant[],\n rows: Rows,\n): Bounds => {\n let minX = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n const cover = (from: number, to: number) => {\n minX = Math.min(minX, from);\n maxX = Math.max(maxX, to);\n };\n\n for (const participant of participants)\n cover(participant.x, participant.x + participant.width);\n for (const note of rows.notes) cover(note.x, note.x + note.width);\n for (const message of rows.messages) {\n for (const point of message.points) cover(point.x, point.x);\n cover(message.label.x, message.label.x + message.label.width);\n }\n return { minX, maxX };\n};\n\n/**\n * Fragment boxes span the whole diagram, inset by depth, exactly as mermaid\n * draws them. Fitting a box to only the participants it happens to mention\n * was considered and dropped: a box that changes width with its contents\n * reads as a shape rather than as a scope.\n */\nconst layoutFragments = (\n model: SequenceModel,\n rows: Rows,\n content: Bounds,\n fontSize: number,\n): PositionedFragment[] =>\n model.fragments\n .map((fragment, at) => {\n const span = rows.spans.get(at);\n if (!span) return undefined;\n const x =\n content.minX - FRAGMENT_MARGIN + fragment.depth * FRAGMENT_INSET;\n const right =\n content.maxX + FRAGMENT_MARGIN - fragment.depth * FRAGMENT_INSET;\n const label = measureLabel([fragment.kind], fontSize);\n return {\n kind: fragment.kind,\n label: fragment.label,\n depth: fragment.depth,\n x,\n y: span.top,\n width: Math.max(right - x, FRAGMENT_MIN_WIDTH),\n height: span.bottom - span.top,\n tabWidth: label.width + FRAGMENT_TAB_PAD_X * 2,\n tabHeight: label.height + FRAGMENT_TAB_PAD_Y * 2,\n dividers: fragment.dividers.map((divider, i) => ({\n y: span.dividers[i] ?? span.top,\n label: divider.label,\n })),\n };\n })\n .filter(\n (fragment): fragment is PositionedFragment => fragment !== undefined,\n )\n // Order IS z-order in SVG, so the outermost box goes down first and a\n // nested one draws on top of it, with no z-index anywhere.\n .sort((a, b) => a.depth - b.depth);\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;;;;;AAK9B,MAAM,wBAAwB;AAM9B,MAAM,kBAAkB;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,QAAQ,GAAG,kBAAkB;EAC7C,QAAQ,KAAK,SAAS,KAAK;EAC3B,UAAU,MAAM,QAAQ,qBAAqB;EAC7C,WAAW,MAAM,SAAS,qBAAqB;EAC/C,UAAU,SAAS,SAAS,KAAK,SAAS,OAAO;GAC/C,GAAG,KAAK,SAAS,MAAM,KAAK;GAC5B,OAAO,QAAQ;EACjB,EAAE;CACJ;AACF,CAAC,CAAC,CACD,QACE,aAA6C,aAAa,KAAA,CAC7D,CAAC,CAGA,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK"}
1
+ {"version":3,"file":"layoutSequence.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/layoutSequence.ts"],"sourcesContent":["import type {\n SequenceArrowHead,\n SequenceFragment,\n SequenceFragmentKind,\n SequenceLineStyle,\n SequenceModel,\n SequenceNote,\n SequenceStep,\n} from \"./sequenceModel.ts\";\nimport {\n DIAGRAM_FONT_SIZE,\n DIAGRAM_LINE_HEIGHT,\n measureLabel,\n} from \"./textMetrics.ts\";\n\n/**\n * The largest diagram that gets laid out. Above either cap the caller falls\n * back to the code block.\n *\n * Unlike the flowchart caps these are NOT about time: layout here is O(n)\n * arithmetic with no ranking to compute, and 300 rows lay out in under a\n * millisecond. They are about legibility and DOM size - 30 lifelines is\n * already far past what anyone can read, and every row is a handful of SVG\n * elements on a page that may carry several diagrams.\n *\n * `MAX_SEQUENCE_MESSAGES` counts ROWS, notes included: a note occupies a\n * row and costs a box, so counting only messages would let a note-heavy\n * diagram past the cap it exists to enforce.\n */\nexport const MAX_SEQUENCE_PARTICIPANTS = 30;\nexport const MAX_SEQUENCE_MESSAGES = 300;\n\n/**\n * The safety margin applied to the width a label needs in the gap between\n * two lifelines. **Gap constraints only** - not participant boxes, which\n * stay tight, and not note boxes, which carry their own padding.\n *\n * ## Why a margin exists here and nowhere else\n *\n * `textMetrics.ts` measures text from a generated per-character width table\n * rather than from the DOM, which is what keeps this a pure function. The\n * table was measured against `canvas.measureText` on the real Inter woff2\n * and agrees **within ~1.3%**, all of it from rounding the ratios to three\n * decimals.\n *\n * The asymmetry is what makes the margin necessary at all. A flowchart\n * label sits INSIDE its box, so a 1.3% underestimate only eats padding. A\n * sequence label sits IN THE GAP between two lifelines, so the same\n * underestimate puts text on top of the neighbouring lifeline. 4% is three\n * times the measured error.\n *\n * Do not \"optimise\" this away as a magic number: it is a measured 1.3% with\n * headroom, and removing it makes long labels collide.\n */\nexport const GAP_LABEL_MARGIN = 1.04;\n\nconst DIAGRAM_PADDING = 12;\nconst PARTICIPANT_PAD_X = 14;\nconst PARTICIPANT_PAD_Y = 8;\nconst PARTICIPANT_MIN_WIDTH = 64;\n/**\n * Clear space between two adjacent participant boxes, before any label\n * widens the gap.\n */\nconst PARTICIPANT_CLEARANCE = 26;\n/**\n * The stick figure an `actor` draws above its name.\n */\nconst ACTOR_FIGURE_HEIGHT = 32;\nconst ACTOR_LABEL_GAP = 4;\nconst ACTOR_MIN_WIDTH = 40;\n\nconst LIFELINE_TOP_GAP = 14;\nconst LIFELINE_BOTTOM_GAP = 14;\n\nconst MESSAGE_LABEL_GAP = 4;\nconst MESSAGE_ROW_GAP = 16;\n/**\n * Clearance between a message label and each lifeline it is centred\n * between.\n */\nconst MESSAGE_LABEL_GUTTER = 10;\n\nconst SELF_LOOP_WIDTH = 32;\nconst SELF_LOOP_LABEL_GAP = 8;\nconst SELF_LOOP_MIN_HEIGHT = 26;\nconst SELF_LOOP_TOP_PAD = 4;\n\nconst NOTE_PAD_X = 10;\nconst NOTE_PAD_Y = 7;\nconst NOTE_ROW_GAP = 14;\n/**\n * How far a `Note over A,B` reaches past the two lifelines it spans.\n */\nconst NOTE_SPAN_OVERHANG = 10;\n/**\n * Clearance between a note box and any lifeline it is not attached to.\n */\nconst NOTE_CLEARANCE = 10;\n\nconst FRAGMENT_INSET = 9;\n/**\n * How far a depth-0 fragment box reaches past the widest content.\n */\nconst FRAGMENT_MARGIN = 14;\nconst FRAGMENT_TAB_PAD_X = 8;\nconst FRAGMENT_TAB_PAD_Y = 3;\nconst FRAGMENT_TOP_PAD = 8;\nconst FRAGMENT_BOTTOM_PAD = 10;\nconst FRAGMENT_AFTER_GAP = 6;\nconst FRAGMENT_MIN_WIDTH = 60;\nconst DIVIDER_GAP = 8;\n\nexport interface PositionedParticipant {\n id: string;\n /**\n * The lines as MEASURED - wrapped and capped. Draw exactly these.\n */\n lines: string[];\n actor: boolean;\n /**\n * TOP-LEFT corner of the header box, the same convention the flowchart\n * layout settled on. An emitter half a box off looks almost right, which\n * is the worst way for this to be wrong.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * Where the lifeline runs. `centerX` is the lifeline's x, and the box is\n * centred on it.\n */\n centerX: number;\n lifelineTop: number;\n lifelineBottom: number;\n /**\n * TOP-LEFT y of the repeated footer box. Its `x`, `width` and `height`\n * are the header's.\n */\n bottomY: number;\n}\n\nexport interface PositionedLabel {\n lines: string[];\n /**\n * TOP-LEFT corner.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PositionedMessage {\n from: string;\n to: string;\n line: SequenceLineStyle;\n head: SequenceArrowHead;\n self: boolean;\n /**\n * Two points for a normal message, four for the loop of a self-message.\n * In from-to order, so the head marker lands on the receiver.\n */\n points: Array<{ x: number; y: number }>;\n /**\n * Already carries the `autonumber` counter when the diagram declared one.\n */\n label: PositionedLabel;\n}\n\nexport interface PositionedNoteBox extends PositionedLabel {\n placement: SequenceNote[\"placement\"];\n}\n\nexport interface PositionedFragment {\n kind: SequenceFragmentKind;\n /**\n * The condition, drawn next to the tab. May be empty.\n */\n label: string;\n depth: number;\n /**\n * TOP-LEFT corner of the box.\n */\n x: number;\n y: number;\n width: number;\n height: number;\n /**\n * The corner tab carrying the kind (`alt`, `opt`, `loop`).\n */\n tabWidth: number;\n tabHeight: number;\n dividers: Array<{ y: number; label: string }>;\n}\n\n/**\n * A laid-out sequence diagram: data, not markup. No SVG, no React, no DOM.\n */\nexport interface PositionedSequence {\n width: number;\n height: number;\n fontSize: number;\n participants: PositionedParticipant[];\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * Outermost first, so the emitter draws them in order and gets z-order\n * free, the way the flowchart clusters do.\n */\n fragments: PositionedFragment[];\n}\n\n/**\n * Place a `SequenceModel` on a plane.\n *\n * **No layout library is involved, and none is coming back.** `graphre`\n * ranks a node graph; here both axes are already decided by the source -\n * participants left to right in declaration order, rows top to bottom in\n * statement order - so layout is arithmetic. The only genuinely hard part\n * is the column widths, which take two passes (see `columnCenters`).\n *\n * Returns `undefined` (never throws, never a partial diagram) for an empty\n * model or one past the caps. The caller's fallback is the code block.\n */\nexport const layoutSequence = (\n model: SequenceModel,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): PositionedSequence | undefined => {\n if (model.participants.length === 0 || model.steps.length === 0)\n return undefined;\n if (model.participants.length > MAX_SEQUENCE_PARTICIPANTS) return undefined;\n if (model.steps.length > MAX_SEQUENCE_MESSAGES) return undefined;\n\n const index = new Map(model.participants.map((p, i) => [p.id, i]));\n const heads = model.participants.map((participant) =>\n measureHead(participant.lines, participant.actor, fontSize),\n );\n // ⚠️ Numbering happens BEFORE anything is measured. The counter is part of\n // the label, so measuring first and numbering after makes every column\n // too narrow - and it stays invisible until a diagram reaches ten\n // messages and the labels go double-digit.\n const labels = measureSteps(model, fontSize);\n\n const centers = columnCenters(model, index, heads, labels);\n const headerHeight = Math.max(...heads.map((head) => head.height));\n\n const rows = layoutRows(model, index, centers, labels, {\n fontSize,\n top: DIAGRAM_PADDING + headerHeight + LIFELINE_TOP_GAP,\n });\n\n const participants = model.participants.map((participant, i) => ({\n id: participant.id,\n lines: heads[i].lines,\n actor: participant.actor,\n // Header boxes are bottom-aligned so every lifeline starts on the same\n // y, whatever mix of one-line names, wrapped names and actors is on the\n // row.\n x: centers[i] - heads[i].width / 2,\n y: DIAGRAM_PADDING + headerHeight - heads[i].height,\n width: heads[i].width,\n height: heads[i].height,\n centerX: centers[i],\n lifelineTop: DIAGRAM_PADDING + headerHeight,\n lifelineBottom: rows.bottom,\n bottomY: rows.bottom,\n }));\n\n const content = contentBounds(participants, rows);\n const fragments = layoutFragments(model, rows, content, fontSize);\n\n const minX = fragments.length ? content.minX - FRAGMENT_MARGIN : content.minX;\n const maxX = fragments.length ? content.maxX + FRAGMENT_MARGIN : content.maxX;\n const dx = DIAGRAM_PADDING - minX;\n\n return {\n width: maxX - minX + DIAGRAM_PADDING * 2,\n height: rows.bottom + headerHeight + DIAGRAM_PADDING,\n fontSize,\n participants: participants.map((participant) => ({\n ...participant,\n x: participant.x + dx,\n centerX: participant.centerX + dx,\n })),\n messages: rows.messages.map((message) => ({\n ...message,\n points: message.points.map((point) => ({ x: point.x + dx, y: point.y })),\n label: { ...message.label, x: message.label.x + dx },\n })),\n notes: rows.notes.map((note) => ({ ...note, x: note.x + dx })),\n fragments: fragments.map((fragment) => ({\n ...fragment,\n x: fragment.x + dx,\n })),\n };\n};\n\ninterface Measured {\n width: number;\n height: number;\n lines: string[];\n}\n\n/**\n * The header box of one participant. An `actor` is a stick figure with its\n * name underneath rather than a box around it, so it is taller and needs no\n * horizontal padding.\n */\nconst measureHead = (\n lines: string[],\n actor: boolean,\n fontSize: number,\n): Measured => {\n const label = measureLabel(lines, fontSize);\n if (actor)\n return {\n width: Math.max(label.width, ACTOR_MIN_WIDTH),\n height: ACTOR_FIGURE_HEIGHT + ACTOR_LABEL_GAP + label.height,\n lines: label.lines,\n };\n return {\n width: Math.max(label.width + PARTICIPANT_PAD_X * 2, PARTICIPANT_MIN_WIDTH),\n height: label.height + PARTICIPANT_PAD_Y * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Measure every row's label once, applying `autonumber` first.\n *\n * A note's measurement is its BOX (label plus padding); a message's is its\n * bare label, because a message label is drawn straight onto the diagram.\n */\nconst measureSteps = (model: SequenceModel, fontSize: number): Measured[] => {\n let counter = model.autonumber?.start ?? 0;\n return model.steps.map((step) => {\n if (step.kind === \"note\") {\n const label = measureLabel(step.lines, fontSize);\n return {\n width: label.width + NOTE_PAD_X * 2,\n height: label.height + NOTE_PAD_Y * 2,\n lines: label.lines,\n };\n }\n if (!model.autonumber) return measureLabel(step.lines, fontSize);\n\n const number = counter;\n counter += model.autonumber.step;\n const [first, ...rest] = step.lines;\n return measureLabel(\n [first ? `${number}. ${first}` : `${number}`, ...rest],\n fontSize,\n );\n });\n};\n\n/**\n * Where each lifeline sits on the x axis, in two passes.\n *\n * **Pass one** gives every adjacent pair the room its two boxes need side\n * by side.\n *\n * **Pass two** walks every message and note and widens the span it covers\n * until its label fits. A label is centred over its whole span, so a\n * message from participant 1 to participant 5 constrains the sum of four\n * gaps rather than any one of them, and the shortfall is spread evenly\n * across the gaps it crosses. Gaps only ever grow, so one pass over the\n * constraints is enough: widening for a later label can never break an\n * earlier one.\n *\n * The centres come back starting at 0. The caller translates once, at the\n * end, after the true bounding box is known.\n */\nconst columnCenters = (\n model: SequenceModel,\n index: Map<string, number>,\n heads: Measured[],\n labels: Measured[],\n): number[] => {\n const count = model.participants.length;\n const gaps: number[] = [];\n for (let i = 0; i < count - 1; i++)\n gaps.push(\n heads[i].width / 2 + heads[i + 1].width / 2 + PARTICIPANT_CLEARANCE,\n );\n\n const widen = (from: number, to: number, required: number): void => {\n // A constraint can legitimately point off the end of the row: a note to\n // the left of the FIRST lifeline has no gap to widen, and the space it\n // needs falls out of the final bounding box instead. Clamping here\n // rather than at each call site is what keeps those cases from reading\n // `gaps[-1]` and poisoning every later width with a NaN.\n if (to <= from || from < 0 || to > gaps.length) return;\n let current = 0;\n for (let i = from; i < to; i++) current += gaps[i];\n if (current >= required) return;\n const extra = (required - current) / (to - from);\n for (let i = from; i < to; i++) gaps[i] += extra;\n };\n\n for (const [at, step] of model.steps.entries()) {\n const label = labels[at];\n if (step.kind === \"message\") {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) continue;\n\n if (step.self) {\n // The loop hangs to the RIGHT of its lifeline with the label beyond\n // it, so it eats into one gap rather than spanning several. At the\n // last participant there is no gap to eat, and the clearance falls\n // out of the final bounding box instead.\n if (from >= count - 1) continue;\n widen(\n from,\n from + 1,\n SELF_LOOP_WIDTH +\n SELF_LOOP_LABEL_GAP +\n label.width * GAP_LABEL_MARGIN +\n MESSAGE_LABEL_GUTTER,\n );\n continue;\n }\n widen(\n Math.min(from, to),\n Math.max(from, to),\n label.width * GAP_LABEL_MARGIN + MESSAGE_LABEL_GUTTER * 2,\n );\n continue;\n }\n\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) continue;\n\n if (step.placement === \"over\" && anchors.length > 1) {\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n // A note box carries its own padding, so no margin is applied to it -\n // it is not text sitting in a gap.\n widen(from, to, label.width - NOTE_SPAN_OVERHANG * 2);\n continue;\n }\n\n const anchor = anchors[0];\n if (step.placement === \"over\") {\n // Centred on one lifeline, so it eats half its width into each\n // neighbouring gap.\n widen(anchor - 1, anchor, label.width / 2 + NOTE_CLEARANCE);\n widen(anchor, anchor + 1, label.width / 2 + NOTE_CLEARANCE);\n continue;\n }\n if (step.placement === \"left\")\n widen(anchor - 1, anchor, label.width + NOTE_CLEARANCE * 2);\n else widen(anchor, anchor + 1, label.width + NOTE_CLEARANCE * 2);\n }\n\n const centers = [0];\n for (const gap of gaps) centers.push(centers[centers.length - 1] + gap);\n return centers;\n};\n\ninterface RowContext {\n fontSize: number;\n top: number;\n}\n\ninterface Rows {\n messages: PositionedMessage[];\n notes: PositionedNoteBox[];\n /**\n * y where every lifeline stops, and the footer boxes start.\n */\n bottom: number;\n /**\n * Per fragment, the box top and bottom and each divider's y, keyed by the\n * fragment's position in `model.fragments`.\n */\n spans: Map<number, { top: number; bottom: number; dividers: number[] }>;\n}\n\n/**\n * One sequential pass down the rows, assigning y.\n *\n * This is the whole reason the model is flat: a nested tree would force\n * this to recurse while threading the cursor through it, and a fragment box\n * would still have to be min/max over the rows it turned out to contain.\n */\nconst layoutRows = (\n model: SequenceModel,\n index: Map<string, number>,\n centers: number[],\n labels: Measured[],\n context: RowContext,\n): Rows => {\n const messages: PositionedMessage[] = [];\n const notes: PositionedNoteBox[] = [];\n const spans = new Map<\n number,\n { top: number; bottom: number; dividers: number[] }\n >();\n const tabHeight =\n context.fontSize * DIAGRAM_LINE_HEIGHT + FRAGMENT_TAB_PAD_Y * 2;\n\n // Outermost first on the way in, innermost first on the way out, so a\n // nested box always sits strictly inside the one that contains it.\n const opening = byStep(model, (fragment) => fragment.from, 1);\n const closing = byStep(model, (fragment) => fragment.to, -1);\n const dividing = dividersByStep(model);\n\n let y = context.top;\n\n for (const [at, step] of model.steps.entries()) {\n for (const owner of opening.get(at) ?? []) {\n spans.set(owner, { top: y, bottom: y, dividers: [] });\n y += tabHeight + FRAGMENT_TOP_PAD;\n }\n for (const owner of dividing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += DIVIDER_GAP;\n span.dividers.push(y);\n // The `else` condition is drawn BELOW its divider, because that is\n // the branch it names, so the room for it goes below too.\n y += context.fontSize * DIAGRAM_LINE_HEIGHT + DIVIDER_GAP;\n }\n\n const label = labels[at];\n y =\n step.kind === \"note\"\n ? placeNote(step, label, index, centers, y, notes)\n : placeMessage(step, label, index, centers, y, messages);\n\n for (const owner of closing.get(at) ?? []) {\n const span = spans.get(owner);\n if (!span) continue;\n y += FRAGMENT_BOTTOM_PAD;\n span.bottom = y;\n y += FRAGMENT_AFTER_GAP;\n }\n }\n\n return { messages, notes, bottom: y + LIFELINE_BOTTOM_GAP, spans };\n};\n\n/**\n * Fragment indices grouped by the step they open or close at, sorted so\n * outer fragments come first on the way in and last on the way out.\n */\nconst byStep = (\n model: SequenceModel,\n pick: (fragment: SequenceFragment) => number,\n order: 1 | -1,\n): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n push(out, pick(fragment), at);\n for (const list of out.values())\n list.sort(\n (a, b) => (model.fragments[a].depth - model.fragments[b].depth) * order,\n );\n return out;\n};\n\n/**\n * Which fragments have an `else` at each step, outermost first: a divider\n * belonging to an outer box has to be drawn above one belonging to a box\n * nested inside it, or the two branches read as swapped.\n */\nconst dividersByStep = (model: SequenceModel): Map<number, number[]> => {\n const out = new Map<number, number[]>();\n for (const [at, fragment] of model.fragments.entries())\n for (const divider of fragment.dividers) push(out, divider.at, at);\n for (const list of out.values())\n list.sort((a, b) => model.fragments[a].depth - model.fragments[b].depth);\n return out;\n};\n\nconst push = (map: Map<number, number[]>, key: number, value: number): void => {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n};\n\nconst placeMessage = (\n step: Extract<SequenceStep, { kind: \"message\" }>,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedMessage[],\n): number => {\n const from = index.get(step.from);\n const to = index.get(step.to);\n if (from === undefined || to === undefined) return y;\n\n if (step.self) {\n const height = Math.max(SELF_LOOP_MIN_HEIGHT, label.height + 6);\n const top = y + SELF_LOOP_TOP_PAD;\n const bottom = top + height;\n const x = centers[from];\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: true,\n points: [\n { x, y: top },\n { x: x + SELF_LOOP_WIDTH, y: top },\n { x: x + SELF_LOOP_WIDTH, y: bottom },\n { x, y: bottom },\n ],\n label: {\n lines: label.lines,\n x: x + SELF_LOOP_WIDTH + SELF_LOOP_LABEL_GAP,\n y: (top + bottom) / 2 - label.height / 2,\n width: label.width,\n height: label.height,\n },\n });\n return bottom + MESSAGE_ROW_GAP;\n }\n\n const lineY = y + label.height + MESSAGE_LABEL_GAP;\n out.push({\n from: step.from,\n to: step.to,\n line: step.line,\n head: step.head,\n self: false,\n points: [\n { x: centers[from], y: lineY },\n { x: centers[to], y: lineY },\n ],\n label: {\n lines: label.lines,\n x: (centers[from] + centers[to]) / 2 - label.width / 2,\n y,\n width: label.width,\n height: label.height,\n },\n });\n return lineY + MESSAGE_ROW_GAP;\n};\n\nconst placeNote = (\n step: SequenceNote,\n label: Measured,\n index: Map<string, number>,\n centers: number[],\n y: number,\n out: PositionedNoteBox[],\n): number => {\n const anchors = step.participants\n .map((id) => index.get(id))\n .filter((at): at is number => at !== undefined);\n if (anchors.length === 0) return y;\n\n const from = Math.min(...anchors);\n const to = Math.max(...anchors);\n const width =\n step.placement === \"over\" && to > from\n ? Math.max(\n label.width,\n centers[to] - centers[from] + NOTE_SPAN_OVERHANG * 2,\n )\n : label.width;\n\n const x =\n step.placement === \"left\"\n ? centers[from] - NOTE_CLEARANCE - width\n : step.placement === \"right\"\n ? centers[from] + NOTE_CLEARANCE\n : (centers[from] + centers[to]) / 2 - width / 2;\n\n out.push({\n placement: step.placement,\n lines: label.lines,\n x,\n y,\n width,\n height: label.height,\n });\n return y + label.height + NOTE_ROW_GAP;\n};\n\ninterface Bounds {\n minX: number;\n maxX: number;\n}\n\n/**\n * The x extent of everything except the fragment boxes, which are sized\n * FROM it. A note hanging off the first lifeline and a self-message looping\n * off the last one are the two things that reach past the participants.\n */\nconst contentBounds = (\n participants: PositionedParticipant[],\n rows: Rows,\n): Bounds => {\n let minX = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n const cover = (from: number, to: number) => {\n minX = Math.min(minX, from);\n maxX = Math.max(maxX, to);\n };\n\n for (const participant of participants)\n cover(participant.x, participant.x + participant.width);\n for (const note of rows.notes) cover(note.x, note.x + note.width);\n for (const message of rows.messages) {\n for (const point of message.points) cover(point.x, point.x);\n cover(message.label.x, message.label.x + message.label.width);\n }\n return { minX, maxX };\n};\n\n/**\n * Fragment boxes span the whole diagram, inset by depth, exactly as mermaid\n * draws them. Fitting a box to only the participants it happens to mention\n * was considered and dropped: a box that changes width with its contents\n * reads as a shape rather than as a scope.\n */\nconst layoutFragments = (\n model: SequenceModel,\n rows: Rows,\n content: Bounds,\n fontSize: number,\n): PositionedFragment[] =>\n model.fragments\n .map((fragment, at) => {\n const span = rows.spans.get(at);\n if (!span) return undefined;\n const x =\n content.minX - FRAGMENT_MARGIN + fragment.depth * FRAGMENT_INSET;\n const right =\n content.maxX + FRAGMENT_MARGIN - fragment.depth * FRAGMENT_INSET;\n const label = measureLabel([fragment.kind], fontSize);\n return {\n kind: fragment.kind,\n label: fragment.label,\n depth: fragment.depth,\n x,\n y: span.top,\n width: Math.max(right - x, FRAGMENT_MIN_WIDTH),\n height: span.bottom - span.top,\n tabWidth: label.width + FRAGMENT_TAB_PAD_X * 2,\n tabHeight: label.height + FRAGMENT_TAB_PAD_Y * 2,\n dividers: fragment.dividers.map((divider, i) => ({\n y: span.dividers[i] ?? span.top,\n label: divider.label,\n })),\n };\n })\n .filter(\n (fragment): fragment is PositionedFragment => fragment !== undefined,\n )\n // Order IS z-order in SVG, so the outermost box goes down first and a\n // nested one draws on top of it, with no z-index anywhere.\n .sort((a, b) => a.depth - b.depth);\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;AAGxB,MAAM,wBAAwB;;;;;AAK9B,MAAM,wBAAwB;AAM9B,MAAM,kBAAkB;AAExB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAE5B,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;;;;;AAKxB,MAAM,uBAAuB;AAE7B,MAAM,kBAAkB;AACxB,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,oBAAoB;AAI1B,MAAM,eAAe;;;;AAQrB,MAAM,iBAAiB;AAEvB,MAAM,iBAAiB;;;;AAIvB,MAAM,kBAAkB;AAGxB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,cAAc;;;;;;;;;;;;;AAmHpB,MAAa,kBACX,OACA,WAAA,OACmC;CACnC,IAAI,MAAM,aAAa,WAAW,KAAK,M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AAM,GAAG,MAAM,CAAC;EAC1D,MAAM,QAAQ,MAAM,GAAG,QAAQ,MAAM,IAAI,QAAQ,MAAM,KAAK;CAC9D;CACA,OAAO;EAAE;EAAM;CAAK;AACtB;;;;;;;AAQA,MAAM,mBACJ,OACA,MACA,SACA,aAEA,MAAM,UACH,KAAK,UAAU,OAAO;CACrB,MAAM,OAAO,KAAK,MAAM,IAAI,EAAE;CAC9B,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,MAAM,IACJ,QAAQ,OAAO,kBAAkB,SAAS,QAAQ;CACpD,MAAM,QACJ,QAAQ,OAAO,kBAAkB,SAAS,QAAQ;CACpD,MAAM,QAAQ,aAAa,CAAC,SAAS,IAAI,GAAG,QAAQ;CACpD,OAAO;EACL,MAAM,SAAS;EACf,OAAO,SAAS;EAChB,OAAO,SAAS;EAChB;EACA,GAAG,KAAK;EACR,OAAO,KAAK,IAAI,QAAQ,GAAG,kBAAkB;EAC7C,QAAQ,KAAK,SAAS,KAAK;EAC3B,UAAU,MAAM,QAAQ;EACxB,WAAW,MAAM,SAAS;EAC1B,UAAU,SAAS,SAAS,KAAK,SAAS,OAAO;GAC/C,GAAG,KAAK,SAAS,MAAM,KAAK;GAC5B,OAAO,QAAQ;EACjB,EAAE;CACJ;AACF,CAAC,CAAC,CACD,QACE,aAA6C,aAAa,KAAA,CAC7D,CAAC,CAGA,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK"}
@@ -37,12 +37,12 @@ const MAX_LABEL_LINES = 8;
37
37
  *
38
38
  * ## How this was produced, and how to reproduce it
39
39
  *
40
- * `scripts/measure-font.mjs` loads the real `@fontsource-variable/inter`
40
+ * `scripts/measure-font.ts` loads the real `@fontsource-variable/inter`
41
41
  * woff2 into Chromium via Playwright, waits for `document.fonts.ready` and
42
42
  * calls `canvas.measureText` on every character below, then buckets them by
43
43
  * rounded ratio. Run it from the repo root and paste the output back here:
44
44
  *
45
- * node packages/@alepha/ui/scripts/measure-font.mjs
45
+ * node packages/@alepha/ui/scripts/measure-font.ts
46
46
  *
47
47
  * The numbers are NOT magic and NOT hand-tuned. If the pinned face or size
48
48
  * ever changes, regenerate rather than nudging a value.
@@ -1 +1 @@
1
- {"version":3,"file":"textMetrics.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/textMetrics.ts"],"sourcesContent":["import type { GraphNode } from \"./graphModel.ts\";\n\n/**\n * The font the diagram pins, and never inherits.\n *\n * Inheriting is the trap: folio view mode and the quest description set\n * prose in Literata at 16.5px and load it lazily after first paint, while\n * every other surface is Inter at `text-sm`. An SVG that inherits would\n * measure against one face and render in another, differently per surface,\n * and shift when the font file lands. So the emitter sets both explicitly\n * and the table below is generated against exactly this face and size.\n *\n * `@alepha/ui` ships Inter through `@fontsource-variable/inter`; the stack\n * degrades to the platform UI sans if it has not loaded.\n */\nexport const DIAGRAM_FONT_FAMILY =\n '\"Inter Variable\", Inter, system-ui, -apple-system, \"Segoe UI\", sans-serif';\n\n/**\n * The one size every diagram label is drawn at.\n */\nexport const DIAGRAM_FONT_SIZE = 13;\n\n/**\n * Baseline-to-baseline distance, as a multiple of the font size.\n */\nexport const DIAGRAM_LINE_HEIGHT = 1.35;\n\n/**\n * The widest a label may measure before it wraps, in pixels at\n * `DIAGRAM_FONT_SIZE`. Without a clamp a 400-character label produces a\n * 4000px box and every other node in the diagram becomes a speck.\n */\nexport const MAX_LABEL_WIDTH = 220;\n\n/**\n * How many lines a label keeps before the rest is cut with an ellipsis.\n */\nexport const MAX_LABEL_LINES = 8;\n\n/**\n * Per-character advance widths for Inter, as a RATIO of the font size, so\n * the table scales to any size.\n *\n * ## How this was produced, and how to reproduce it\n *\n * `scripts/measure-font.mjs` loads the real `@fontsource-variable/inter`\n * woff2 into Chromium via Playwright, waits for `document.fonts.ready` and\n * calls `canvas.measureText` on every character below, then buckets them by\n * rounded ratio. Run it from the repo root and paste the output back here:\n *\n * node packages/@alepha/ui/scripts/measure-font.mjs\n *\n * The numbers are NOT magic and NOT hand-tuned. If the pinned face or size\n * ever changes, regenerate rather than nudging a value.\n *\n * ## Why a table at all\n *\n * Layout needs node sizes before it can place anything, and node width comes\n * from the label. Mermaid gets this by rendering into a hidden DOM node,\n * which is precisely why mermaid cannot run without a browser. Arithmetic\n * keeps the layout core a pure function. It is an approximation: 5% off on a\n * box width is invisible in a boxes-and-arrows diagram, and it is the\n * concrete reason v1 is flowcharts rather than sequence diagrams, whose\n * layout is far more sensitive to text metrics.\n */\nconst WIDTH_BUCKETS: Array<[ratio: number, chars: string]> = [\n [0.242, \"ijl\"],\n [0.261, \"’\"],\n [0.269, \"I\"],\n [0.281, \" \"],\n [0.288, \"!,.:·\"],\n [0.3, \"'\"],\n [0.302, \";\"],\n [0.323, \"`\"],\n [0.327, \"t\"],\n [0.333, \"|\"],\n [0.36, \"/\\\\\"],\n [0.365, \"()[]\"],\n [0.37, \"f\"],\n [0.376, \"r\"],\n [0.407, \"1\"],\n [0.426, \"{}\"],\n [0.44, \"“”\"],\n [0.456, \"_\"],\n [0.46, \"-\"],\n [0.466, '\"'],\n [0.471, \"^\"],\n [0.501, \"*\"],\n [0.511, \"?\"],\n [0.528, \"s\"],\n [0.546, \"x\"],\n [0.549, \"k\"],\n [0.552, \"z\"],\n [0.562, \"avyà\"],\n [0.565, \"L\"],\n [0.566, \"7\"],\n [0.571, \"Jcç\"],\n [0.583, \"eéè\"],\n [0.59, \"F\"],\n [0.591, \"hnuüñ\"],\n [0.593, \"5\"],\n [0.6, \"oö\"],\n [0.601, \"E\"],\n [0.61, \"2\"],\n [0.612, \"bdpq\"],\n [0.613, \"g\"],\n [0.618, \"3\"],\n [0.619, \"8\"],\n [0.62, \"69\"],\n [0.629, \"Z\"],\n [0.631, \"0\"],\n [0.633, \"#\"],\n [0.639, \"P\"],\n [0.642, \"$S\"],\n [0.644, \"&R\"],\n [0.646, \"4T\"],\n [0.654, \"B\"],\n [0.662, \"+<=>~\"],\n [0.672, \"K\"],\n [0.679, \"Y\"],\n [0.682, \"X\"],\n [0.69, \"AV\"],\n [0.722, \"D\"],\n [0.73, \"C\"],\n [0.743, \"H\"],\n [0.744, \"U\"],\n [0.746, \"G\"],\n [0.753, \"N\"],\n [0.765, \"OQ\"],\n [0.818, \"w\"],\n [0.864, \"…\"],\n [0.876, \"m\"],\n [0.903, \"M\"],\n [0.966, \"@\"],\n [0.982, \"%\"],\n [0.985, \"W\"],\n [1, \"→←—\"],\n];\n\n/**\n * Anything unlisted (CJK, emoji, the rest of Unicode) measures at the\n * average of the table. Wrong, but bounded, which is the whole contract.\n */\nconst FALLBACK_RATIO = 0.57;\n\nconst RATIOS: Map<string, number> = new Map(\n WIDTH_BUCKETS.flatMap(([ratio, chars]) =>\n // Width buckets are ASCII characters; there is nothing multi-unit to split.\n // oxlint-disable-next-line typescript/no-misused-spread\n [...chars].map((char) => [char, ratio] as [string, number]),\n ),\n);\n\n/**\n * The rendered width of one line, in pixels, at `fontSize`.\n */\nexport const measureLine = (line: string, fontSize: number): number => {\n let ratio = 0;\n for (const char of line) ratio += RATIOS.get(char) ?? FALLBACK_RATIO;\n return ratio * fontSize;\n};\n\nexport interface LabelMetrics {\n /**\n * The widest line, in pixels.\n */\n width: number;\n /**\n * Total height of the line box stack, in pixels.\n */\n height: number;\n /**\n * The lines as measured - wrapped and capped, so the emitter draws these.\n */\n lines: string[];\n}\n\n/**\n * Measure a node or cluster label, wrapping and clamping it first.\n *\n * Returns the lines it actually measured, not the ones it was given: the\n * emitter must draw exactly what was measured, or text and box disagree.\n */\nexport const measureLabel = (\n lines: string[],\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const wrapped: string[] = [];\n for (const line of lines) {\n for (const piece of wrapLine(line, fontSize)) {\n wrapped.push(piece);\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n\n const cut =\n wrapped.length >= MAX_LABEL_LINES &&\n countWrapped(lines, fontSize) > MAX_LABEL_LINES;\n if (cut)\n wrapped[MAX_LABEL_LINES - 1] = truncate(\n wrapped[MAX_LABEL_LINES - 1],\n fontSize,\n );\n\n const measured = wrapped.length > 0 ? wrapped : [\"\"];\n return {\n width: Math.max(\n ...measured.map((line) => measureLine(line, fontSize)),\n fontSize,\n ),\n height: measured.length * fontSize * DIAGRAM_LINE_HEIGHT,\n lines: measured,\n };\n};\n\n/**\n * The box a node needs: its label plus padding, per shape.\n */\nexport const measureNode = (\n node: Pick<GraphNode, \"lines\" | \"shape\">,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const label = measureLabel(node.lines, fontSize);\n\n if (node.shape === \"circle\") {\n // An axis-aligned w x h box fits an ellipse exactly when\n // (w/2 / rx)^2 + (h/2 / ry)^2 <= 1, and rx = (w/2)·√2, ry = (h/2)·√2 is\n // the solution that touches all four corners. Forcing width === height\n // instead is what turned a two-word label into an enormous disc that\n // made every other node in the diagram a speck.\n const width = label.width * Math.SQRT2 + 12;\n const height = label.height * Math.SQRT2 + 12;\n return {\n // A one-line label is far wider than it is tall, so without a floor\n // the \"circle\" degenerates into a flat sliver.\n width,\n height: Math.max(height, width * 0.55),\n lines: label.lines,\n };\n }\n\n // A diamond has to be wide enough that its slanted sides clear the text.\n const padX = node.shape === \"diamond\" ? 34 : 16;\n const padY = node.shape === \"diamond\" ? 20 : 10;\n return {\n width: label.width + padX * 2,\n height: label.height + padY * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Break one line to fit `MAX_LABEL_WIDTH`, at spaces where there are any.\n */\nconst wrapLine = (line: string, fontSize: number): string[] => {\n if (measureLine(line, fontSize) <= MAX_LABEL_WIDTH) return [line];\n\n const out: string[] = [];\n let current = \"\";\n for (const word of line.split(/\\s+/).filter(Boolean)) {\n const candidate = current ? `${current} ${word}` : word;\n if (current && measureLine(candidate, fontSize) > MAX_LABEL_WIDTH) {\n out.push(current);\n current = word;\n continue;\n }\n current = candidate;\n }\n if (current) out.push(current);\n\n // A single word wider than the cap cannot be wrapped, only cut.\n return out.map((piece) =>\n measureLine(piece, fontSize) > MAX_LABEL_WIDTH\n ? truncate(piece, fontSize)\n : piece,\n );\n};\n\n/**\n * How many lines the label WOULD take unwrapped-capped, so a label that\n * exactly fills the cap is not marked as cut.\n */\nconst countWrapped = (lines: string[], fontSize: number): number =>\n lines.reduce((total, line) => total + wrapLine(line, fontSize).length, 0);\n\nconst truncate = (line: string, fontSize: number): string => {\n const ellipsis = measureLine(\"\\u2026\", fontSize);\n let out = \"\";\n for (const char of line) {\n if (measureLine(out + char, fontSize) + ellipsis > MAX_LABEL_WIDTH) break;\n out += char;\n }\n return `${out}\\u2026`;\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,sBACX;;;;AAKF,MAAa,oBAAoB;;;;AAKjC,MAAa,sBAAsB;;;;;;AAOnC,MAAa,kBAAkB;;;;AAK/B,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,MAAM,gBAAuD;CAC3D,CAAC,MAAO,KAAK;CACb,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,OAAO;CACf,CAAC,IAAK,GAAG;CACT,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,KAAM,KAAK;CACZ,CAAC,MAAO,MAAM;CACd,CAAC,KAAM,GAAG;CACV,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,IAAI;CACZ,CAAC,KAAM,IAAI;CACX,CAAC,MAAO,GAAG;CACX,CAAC,KAAM,GAAG;CACV,CAAC,MAAO,IAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,GAAG;CACX,CAAC,MAAO,MAAM;C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ACvB,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,KAAK,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,GAAG;EACpD,MAAM,YAAY,UAAU,GAAG,QAAQ,GAAG,SAAS;EACnD,IAAI,WAAW,YAAY,WAAW,QAAQ,IAAA,KAAqB;GACjE,IAAI,KAAK,OAAO;GAChB,UAAU;GACV;EACF;EACA,UAAU;CACZ;CACA,IAAI,SAAS,IAAI,KAAK,OAAO;CAG7B,OAAO,IAAI,KAAK,UACd,YAAY,OAAO,QAAQ,IAAA,MACvB,SAAS,OAAO,QAAQ,IACxB,KACN;AACF;;;;;AAMA,MAAM,gBAAgB,OAAiB,aACrC,MAAM,QAAQ,OAAO,SAAS,QAAQ,SAAS,MAAM,QAAQ,CAAC,CAAC,QAAQ,CAAC;AAE1E,MAAM,YAAY,MAAc,aAA6B;CAC3D,MAAM,WAAW,YAAY,KAAU,QAAQ;CAC/C,IAAI,MAAM;CACV,KAAK,MAAM,QAAQ,MAAM;EACvB,IAAI,YAAY,MAAM,MAAM,QAAQ,IAAI,WAAA,KAA4B;EACpE,OAAO;CACT;CACA,OAAO,GAAG,IAAI;AAChB"}
1
+ {"version":3,"file":"textMetrics.js","names":[],"sources":["../../../../src/components/markdown-view/diagram/textMetrics.ts"],"sourcesContent":["import type { GraphNode } from \"./graphModel.ts\";\n\n/**\n * The font the diagram pins, and never inherits.\n *\n * Inheriting is the trap: folio view mode and the quest description set\n * prose in Literata at 16.5px and load it lazily after first paint, while\n * every other surface is Inter at `text-sm`. An SVG that inherits would\n * measure against one face and render in another, differently per surface,\n * and shift when the font file lands. So the emitter sets both explicitly\n * and the table below is generated against exactly this face and size.\n *\n * `@alepha/ui` ships Inter through `@fontsource-variable/inter`; the stack\n * degrades to the platform UI sans if it has not loaded.\n */\nexport const DIAGRAM_FONT_FAMILY =\n '\"Inter Variable\", Inter, system-ui, -apple-system, \"Segoe UI\", sans-serif';\n\n/**\n * The one size every diagram label is drawn at.\n */\nexport const DIAGRAM_FONT_SIZE = 13;\n\n/**\n * Baseline-to-baseline distance, as a multiple of the font size.\n */\nexport const DIAGRAM_LINE_HEIGHT = 1.35;\n\n/**\n * The widest a label may measure before it wraps, in pixels at\n * `DIAGRAM_FONT_SIZE`. Without a clamp a 400-character label produces a\n * 4000px box and every other node in the diagram becomes a speck.\n */\nexport const MAX_LABEL_WIDTH = 220;\n\n/**\n * How many lines a label keeps before the rest is cut with an ellipsis.\n */\nexport const MAX_LABEL_LINES = 8;\n\n/**\n * Per-character advance widths for Inter, as a RATIO of the font size, so\n * the table scales to any size.\n *\n * ## How this was produced, and how to reproduce it\n *\n * `scripts/measure-font.ts` loads the real `@fontsource-variable/inter`\n * woff2 into Chromium via Playwright, waits for `document.fonts.ready` and\n * calls `canvas.measureText` on every character below, then buckets them by\n * rounded ratio. Run it from the repo root and paste the output back here:\n *\n * node packages/@alepha/ui/scripts/measure-font.ts\n *\n * The numbers are NOT magic and NOT hand-tuned. If the pinned face or size\n * ever changes, regenerate rather than nudging a value.\n *\n * ## Why a table at all\n *\n * Layout needs node sizes before it can place anything, and node width comes\n * from the label. Mermaid gets this by rendering into a hidden DOM node,\n * which is precisely why mermaid cannot run without a browser. Arithmetic\n * keeps the layout core a pure function. It is an approximation: 5% off on a\n * box width is invisible in a boxes-and-arrows diagram, and it is the\n * concrete reason v1 is flowcharts rather than sequence diagrams, whose\n * layout is far more sensitive to text metrics.\n */\nconst WIDTH_BUCKETS: Array<[ratio: number, chars: string]> = [\n [0.242, \"ijl\"],\n [0.261, \"’\"],\n [0.269, \"I\"],\n [0.281, \" \"],\n [0.288, \"!,.:·\"],\n [0.3, \"'\"],\n [0.302, \";\"],\n [0.323, \"`\"],\n [0.327, \"t\"],\n [0.333, \"|\"],\n [0.36, \"/\\\\\"],\n [0.365, \"()[]\"],\n [0.37, \"f\"],\n [0.376, \"r\"],\n [0.407, \"1\"],\n [0.426, \"{}\"],\n [0.44, \"“”\"],\n [0.456, \"_\"],\n [0.46, \"-\"],\n [0.466, '\"'],\n [0.471, \"^\"],\n [0.501, \"*\"],\n [0.511, \"?\"],\n [0.528, \"s\"],\n [0.546, \"x\"],\n [0.549, \"k\"],\n [0.552, \"z\"],\n [0.562, \"avyà\"],\n [0.565, \"L\"],\n [0.566, \"7\"],\n [0.571, \"Jcç\"],\n [0.583, \"eéè\"],\n [0.59, \"F\"],\n [0.591, \"hnuüñ\"],\n [0.593, \"5\"],\n [0.6, \"oö\"],\n [0.601, \"E\"],\n [0.61, \"2\"],\n [0.612, \"bdpq\"],\n [0.613, \"g\"],\n [0.618, \"3\"],\n [0.619, \"8\"],\n [0.62, \"69\"],\n [0.629, \"Z\"],\n [0.631, \"0\"],\n [0.633, \"#\"],\n [0.639, \"P\"],\n [0.642, \"$S\"],\n [0.644, \"&R\"],\n [0.646, \"4T\"],\n [0.654, \"B\"],\n [0.662, \"+<=>~\"],\n [0.672, \"K\"],\n [0.679, \"Y\"],\n [0.682, \"X\"],\n [0.69, \"AV\"],\n [0.722, \"D\"],\n [0.73, \"C\"],\n [0.743, \"H\"],\n [0.744, \"U\"],\n [0.746, \"G\"],\n [0.753, \"N\"],\n [0.765, \"OQ\"],\n [0.818, \"w\"],\n [0.864, \"…\"],\n [0.876, \"m\"],\n [0.903, \"M\"],\n [0.966, \"@\"],\n [0.982, \"%\"],\n [0.985, \"W\"],\n [1, \"→←—\"],\n];\n\n/**\n * Anything unlisted (CJK, emoji, the rest of Unicode) measures at the\n * average of the table. Wrong, but bounded, which is the whole contract.\n */\nconst FALLBACK_RATIO = 0.57;\n\nconst RATIOS: Map<string, number> = new Map(\n WIDTH_BUCKETS.flatMap(([ratio, chars]) =>\n // Width buckets are ASCII characters; there is nothing multi-unit to split.\n // oxlint-disable-next-line typescript/no-misused-spread\n [...chars].map((char) => [char, ratio] as [string, number]),\n ),\n);\n\n/**\n * The rendered width of one line, in pixels, at `fontSize`.\n */\nexport const measureLine = (line: string, fontSize: number): number => {\n let ratio = 0;\n for (const char of line) ratio += RATIOS.get(char) ?? FALLBACK_RATIO;\n return ratio * fontSize;\n};\n\nexport interface LabelMetrics {\n /**\n * The widest line, in pixels.\n */\n width: number;\n /**\n * Total height of the line box stack, in pixels.\n */\n height: number;\n /**\n * The lines as measured - wrapped and capped, so the emitter draws these.\n */\n lines: string[];\n}\n\n/**\n * Measure a node or cluster label, wrapping and clamping it first.\n *\n * Returns the lines it actually measured, not the ones it was given: the\n * emitter must draw exactly what was measured, or text and box disagree.\n */\nexport const measureLabel = (\n lines: string[],\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const wrapped: string[] = [];\n for (const line of lines) {\n for (const piece of wrapLine(line, fontSize)) {\n wrapped.push(piece);\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n if (wrapped.length >= MAX_LABEL_LINES) break;\n }\n\n const cut =\n wrapped.length >= MAX_LABEL_LINES &&\n countWrapped(lines, fontSize) > MAX_LABEL_LINES;\n if (cut)\n wrapped[MAX_LABEL_LINES - 1] = truncate(\n wrapped[MAX_LABEL_LINES - 1],\n fontSize,\n );\n\n const measured = wrapped.length > 0 ? wrapped : [\"\"];\n return {\n width: Math.max(\n ...measured.map((line) => measureLine(line, fontSize)),\n fontSize,\n ),\n height: measured.length * fontSize * DIAGRAM_LINE_HEIGHT,\n lines: measured,\n };\n};\n\n/**\n * The box a node needs: its label plus padding, per shape.\n */\nexport const measureNode = (\n node: Pick<GraphNode, \"lines\" | \"shape\">,\n fontSize: number = DIAGRAM_FONT_SIZE,\n): LabelMetrics => {\n const label = measureLabel(node.lines, fontSize);\n\n if (node.shape === \"circle\") {\n // An axis-aligned w x h box fits an ellipse exactly when\n // (w/2 / rx)^2 + (h/2 / ry)^2 <= 1, and rx = (w/2)·√2, ry = (h/2)·√2 is\n // the solution that touches all four corners. Forcing width === height\n // instead is what turned a two-word label into an enormous disc that\n // made every other node in the diagram a speck.\n const width = label.width * Math.SQRT2 + 12;\n const height = label.height * Math.SQRT2 + 12;\n return {\n // A one-line label is far wider than it is tall, so without a floor\n // the \"circle\" degenerates into a flat sliver.\n width,\n height: Math.max(height, width * 0.55),\n lines: label.lines,\n };\n }\n\n // A diamond has to be wide enough that its slanted sides clear the text.\n const padX = node.shape === \"diamond\" ? 34 : 16;\n const padY = node.shape === \"diamond\" ? 20 : 10;\n return {\n width: label.width + padX * 2,\n height: label.height + padY * 2,\n lines: label.lines,\n };\n};\n\n/**\n * Break one line to fit `MAX_LABEL_WIDTH`, at spaces where there are any.\n */\nconst wrapLine = (line: string, fontSize: number): string[] => {\n if (measureLine(line, fontSize) <= MAX_LABEL_WIDTH) return [line];\n\n const out: string[] = [];\n let current = \"\";\n for (const word of line.split(/\\s+/).filter(Boolean)) {\n const candidate = current ? `${current} ${word}` : word;\n if (current && measureLine(candidate, fontSize) > MAX_LABEL_WIDTH) {\n out.push(current);\n current = word;\n continue;\n }\n current = candidate;\n }\n if (current) out.push(current);\n\n // A single word wider than the cap cannot be wrapped, only cut.\n return out.map((piece) =>\n measureLine(piece, fontSize) > MAX_LABEL_WIDTH\n ? truncate(piece, fontSize)\n : piece,\n );\n};\n\n/**\n * How many lines the label WOULD take unwrapped-capped, so a label that\n * exactly fills the cap is not marked as cut.\n */\nconst countWrapped = (lines: string[], fontSize: number): number =>\n lines.reduce((total, line) => total + wrapLine(line, fontSize).length, 0);\n\nconst truncate = (line: string, fontSize: number): string => {\n const ellipsis = measureLine(\"\\u2026\", fontSize);\n let out = \"\";\n for (const char of line) {\n if (measureLine(out + char, fontSize) + ellipsis > MAX_LABEL_WIDTH) break;\n out += char;\n }\n return `${out}\\u2026`;\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,sBACX;;;;AAKF,MAAa,oBAAoB;;;;AAKjC,MAAa,sBAAsB;;;;;;AAOnC,MAAa,kBAAkB;;;;AAK/B,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,MAAM,gBAAuD;CAC3D,CAAC,MAAO,KAAK;CACb,CAAC,MAAO,GAAG;CAC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Y,MAAM,MAAM,QAAQ,IAAI,WAAA,KAA4B;EACpE,OAAO;CACT;CACA,OAAO,GAAG,IAAI;AAChB"}
@@ -177,3 +177,47 @@
177
177
  )
178
178
  right center / 18px 100% no-repeat scroll;
179
179
  }
180
+
181
+ /*
182
+ * Discord-style `||spoilers||`.
183
+ *
184
+ * ⚠️ Not a security feature. The text is in the DOM from the first paint -
185
+ * this covers it, it does not withhold it - and it is in the raw markdown, in
186
+ * an export, over MCP and in any search snippet too. See `SpoilerSpan`.
187
+ *
188
+ * Both states are painted from `--foreground` through `color-mix`, so the
189
+ * dark theme needs no second block: the token already flips, and a hidden
190
+ * spoiler is a strong wash of it while a revealed one is the faint wash every
191
+ * other inline surface here uses.
192
+ *
193
+ * The hidden state sets the text to `transparent` rather than hiding it,
194
+ * which is what keeps the line's metrics: a `display: none` would reflow the
195
+ * paragraph on reveal and move the sentence out from under the reader who
196
+ * just clicked it. `user-select: none` stops a drag-select from lifting the
197
+ * covered text out through the clipboard by accident.
198
+ */
199
+ [data-slot="markdown-view"] [data-spoiler="hidden"] {
200
+ background-color: color-mix(in oklab, var(--foreground) 82%, transparent);
201
+ color: transparent;
202
+ user-select: none;
203
+ transition: background-color 120ms ease;
204
+ }
205
+
206
+ [data-slot="markdown-view"] [data-spoiler="hidden"]:hover {
207
+ background-color: color-mix(in oklab, var(--foreground) 70%, transparent);
208
+ }
209
+
210
+ /*
211
+ * A visible focus ring, because the hidden state has nothing else to show
212
+ * one against: the box IS the content, so the browser's default outline on a
213
+ * `color: transparent` span is the only thing telling a keyboard reader where
214
+ * they are.
215
+ */
216
+ [data-slot="markdown-view"] [data-spoiler="hidden"]:focus-visible {
217
+ outline: 2px solid var(--ring);
218
+ outline-offset: 1px;
219
+ }
220
+
221
+ [data-slot="markdown-view"] [data-spoiler="revealed"] {
222
+ background-color: color-mix(in oklab, var(--foreground) 8%, transparent);
223
+ }