dominds 0.1.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 (273) hide show
  1. package/LICENSE +157 -0
  2. package/README.md +250 -0
  3. package/README.zh.md +161 -0
  4. package/dist/access-control.js +253 -0
  5. package/dist/cli/create.js +263 -0
  6. package/dist/cli/read.js +84 -0
  7. package/dist/cli/tui.js +199 -0
  8. package/dist/cli/webui.js +169 -0
  9. package/dist/cli.js +227 -0
  10. package/dist/dialog-factory.js +53 -0
  11. package/dist/dialog-global-registry.js +68 -0
  12. package/dist/dialog-instance-registry.js +78 -0
  13. package/dist/dialog-run-state.js +198 -0
  14. package/dist/dialog.js +1024 -0
  15. package/dist/evt-registry.js +103 -0
  16. package/dist/index.js +8 -0
  17. package/dist/llm/client.js +69 -0
  18. package/dist/llm/defaults.yaml +386 -0
  19. package/dist/llm/driver.js +3214 -0
  20. package/dist/llm/gen/anthropic.js +611 -0
  21. package/dist/llm/gen/codex.js +375 -0
  22. package/dist/llm/gen/mock.js +326 -0
  23. package/dist/llm/gen/openai.js +470 -0
  24. package/dist/llm/gen/registry.js +26 -0
  25. package/dist/llm/gen.js +2 -0
  26. package/dist/llm/tools-projection.js +37 -0
  27. package/dist/log.js +228 -0
  28. package/dist/mcp/config.js +230 -0
  29. package/dist/mcp/sdk-client.js +129 -0
  30. package/dist/mcp/server-runtime.js +57 -0
  31. package/dist/mcp/stdio-client.js +280 -0
  32. package/dist/mcp/supervisor.js +979 -0
  33. package/dist/mcp/tool-names.js +109 -0
  34. package/dist/minds/builtin/cmdr/persona.md +3 -0
  35. package/dist/minds/builtin/dijiang/knowledge.md +287 -0
  36. package/dist/minds/builtin/dijiang/persona.md +7 -0
  37. package/dist/minds/builtin/fuxi/persona.en.md +59 -0
  38. package/dist/minds/builtin/fuxi/persona.zh.md +49 -0
  39. package/dist/minds/builtin/pangu/persona.en.md +78 -0
  40. package/dist/minds/builtin/pangu/persona.zh.md +71 -0
  41. package/dist/minds/load.js +617 -0
  42. package/dist/minds/minds-i18n.js +131 -0
  43. package/dist/minds/system-prompt.js +281 -0
  44. package/dist/persistence.js +3128 -0
  45. package/dist/problems.js +109 -0
  46. package/dist/server/api-routes.js +1031 -0
  47. package/dist/server/auth.js +180 -0
  48. package/dist/server/mime-types.js +32 -0
  49. package/dist/server/prompts-routes.js +543 -0
  50. package/dist/server/server-core.js +235 -0
  51. package/dist/server/setup-routes.js +697 -0
  52. package/dist/server/static-server.js +132 -0
  53. package/dist/server/websocket-handler.js +1011 -0
  54. package/dist/server.js +164 -0
  55. package/dist/shared/async-fifo-mutex.js +36 -0
  56. package/dist/shared/diligence.js +20 -0
  57. package/dist/shared/dotenv.js +144 -0
  58. package/dist/shared/evt.js +195 -0
  59. package/dist/shared/i18n/driver-messages.js +267 -0
  60. package/dist/shared/i18n/text.js +9 -0
  61. package/dist/shared/i18n/tool-result-messages.js +51 -0
  62. package/dist/shared/rtws-cli.js +73 -0
  63. package/dist/shared/runtime-language.js +47 -0
  64. package/dist/shared/team-mgmt-manual.js +116 -0
  65. package/dist/shared/types/context-health.js +2 -0
  66. package/dist/shared/types/dialog.js +11 -0
  67. package/dist/shared/types/i18n.js +2 -0
  68. package/dist/shared/types/index.js +26 -0
  69. package/dist/shared/types/language.js +40 -0
  70. package/dist/shared/types/problems.js +2 -0
  71. package/dist/shared/types/prompts.js +2 -0
  72. package/dist/shared/types/q4h.js +7 -0
  73. package/dist/shared/types/run-state.js +8 -0
  74. package/dist/shared/types/setup.js +2 -0
  75. package/dist/shared/types/storage.js +10 -0
  76. package/dist/shared/types/tellask.js +8 -0
  77. package/dist/shared/types/tools-registry.js +2 -0
  78. package/dist/shared/types/wire.js +12 -0
  79. package/dist/shared/utils/fmt.js +9 -0
  80. package/dist/shared/utils/html.js +20 -0
  81. package/dist/shared/utils/id.js +18 -0
  82. package/dist/shared/utils/inter-dialog-format.js +101 -0
  83. package/dist/shared/utils/time.js +13 -0
  84. package/dist/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  85. package/dist/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  86. package/dist/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  87. package/dist/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  88. package/dist/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  89. package/dist/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  90. package/dist/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  91. package/dist/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  92. package/dist/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  93. package/dist/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  94. package/dist/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  95. package/dist/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  96. package/dist/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  97. package/dist/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  98. package/dist/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  99. package/dist/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  100. package/dist/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  101. package/dist/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  102. package/dist/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  103. package/dist/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  104. package/dist/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  105. package/dist/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  106. package/dist/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  107. package/dist/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  108. package/dist/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  109. package/dist/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  110. package/dist/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  111. package/dist/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  112. package/dist/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  113. package/dist/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  114. package/dist/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  115. package/dist/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  116. package/dist/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  117. package/dist/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  118. package/dist/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  119. package/dist/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  120. package/dist/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  121. package/dist/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  122. package/dist/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  123. package/dist/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  124. package/dist/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  125. package/dist/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  126. package/dist/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  127. package/dist/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  128. package/dist/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  129. package/dist/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  130. package/dist/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  131. package/dist/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  132. package/dist/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  133. package/dist/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  134. package/dist/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  135. package/dist/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  136. package/dist/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  137. package/dist/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  138. package/dist/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  139. package/dist/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  140. package/dist/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  141. package/dist/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  142. package/dist/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  143. package/dist/static/assets/_baseUniq-Crfl3d5Y.js +661 -0
  144. package/dist/static/assets/_baseUniq-Crfl3d5Y.js.map +1 -0
  145. package/dist/static/assets/arc-CbA_x9GD.js +132 -0
  146. package/dist/static/assets/arc-CbA_x9GD.js.map +1 -0
  147. package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js +8685 -0
  148. package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js.map +1 -0
  149. package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js +3608 -0
  150. package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js.map +1 -0
  151. package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js +2482 -0
  152. package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js.map +1 -0
  153. package/dist/static/assets/channel-BVr1Yke-.js +8 -0
  154. package/dist/static/assets/channel-BVr1Yke-.js.map +1 -0
  155. package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js +17 -0
  156. package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js.map +1 -0
  157. package/dist/static/assets/chunk-55IACEB6-q172NeCV.js +14 -0
  158. package/dist/static/assets/chunk-55IACEB6-q172NeCV.js.map +1 -0
  159. package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js +1827 -0
  160. package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js.map +1 -0
  161. package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js +1916 -0
  162. package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js.map +1 -0
  163. package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js +20 -0
  164. package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js.map +1 -0
  165. package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js +25 -0
  166. package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js.map +1 -0
  167. package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js +18 -0
  168. package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js.map +1 -0
  169. package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js +109 -0
  170. package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js.map +1 -0
  171. package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js +23 -0
  172. package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js.map +1 -0
  173. package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js +23 -0
  174. package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js.map +1 -0
  175. package/dist/static/assets/clone-D2OgLSSn.js +9 -0
  176. package/dist/static/assets/clone-D2OgLSSn.js.map +1 -0
  177. package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js +4943 -0
  178. package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js.map +1 -0
  179. package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js +30240 -0
  180. package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -0
  181. package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js +695 -0
  182. package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js.map +1 -0
  183. package/dist/static/assets/defaultLocale-DVr69WTU.js +207 -0
  184. package/dist/static/assets/defaultLocale-DVr69WTU.js.map +1 -0
  185. package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js +849 -0
  186. package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js.map +1 -0
  187. package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js +303 -0
  188. package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js.map +1 -0
  189. package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js +213 -0
  190. package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js.map +1 -0
  191. package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js +1159 -0
  192. package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js.map +1 -0
  193. package/dist/static/assets/favicon-Cmg5RbCj.svg +8 -0
  194. package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js +2332 -0
  195. package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js.map +1 -0
  196. package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js +3681 -0
  197. package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js.map +1 -0
  198. package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js +1206 -0
  199. package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js.map +1 -0
  200. package/dist/static/assets/graph-CS0Pmm7c.js +597 -0
  201. package/dist/static/assets/graph-CS0Pmm7c.js.map +1 -0
  202. package/dist/static/assets/index-BS6HnGzC.js +112303 -0
  203. package/dist/static/assets/index-BS6HnGzC.js.map +1 -0
  204. package/dist/static/assets/index-DaIsSzC_.css +483 -0
  205. package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js +34 -0
  206. package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js.map +1 -0
  207. package/dist/static/assets/init-ZxktEp_H.js +17 -0
  208. package/dist/static/assets/init-ZxktEp_H.js.map +1 -0
  209. package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js +1255 -0
  210. package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js.map +1 -0
  211. package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js +1048 -0
  212. package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js.map +1 -0
  213. package/dist/static/assets/layout-8TGxpm23.js +2218 -0
  214. package/dist/static/assets/layout-8TGxpm23.js.map +1 -0
  215. package/dist/static/assets/linear-BATBPQQv.js +341 -0
  216. package/dist/static/assets/linear-BATBPQQv.js.map +1 -0
  217. package/dist/static/assets/min-B3oVH3AC.js +42 -0
  218. package/dist/static/assets/min-B3oVH3AC.js.map +1 -0
  219. package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js +1127 -0
  220. package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js.map +1 -0
  221. package/dist/static/assets/ordinal-CxptdPJm.js +77 -0
  222. package/dist/static/assets/ordinal-CxptdPJm.js.map +1 -0
  223. package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js +241 -0
  224. package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js.map +1 -0
  225. package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js +1338 -0
  226. package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js.map +1 -0
  227. package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js +1162 -0
  228. package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js.map +1 -0
  229. package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js +1195 -0
  230. package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js.map +1 -0
  231. package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js +3875 -0
  232. package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js.map +1 -0
  233. package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js +452 -0
  234. package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js.map +1 -0
  235. package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js +22 -0
  236. package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js.map +1 -0
  237. package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js +1223 -0
  238. package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js.map +1 -0
  239. package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js +18753 -0
  240. package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js.map +1 -0
  241. package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js +1888 -0
  242. package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js.map +1 -0
  243. package/dist/static/index.html +71 -0
  244. package/dist/static/testing/dom-observation-utils.js +425 -0
  245. package/dist/static/testing/e2e-test-helper.js +3119 -0
  246. package/dist/team.js +1160 -0
  247. package/dist/tellask.js +431 -0
  248. package/dist/tool.js +150 -0
  249. package/dist/tools/apply-patch.js +542 -0
  250. package/dist/tools/builtins.js +196 -0
  251. package/dist/tools/context-health.js +177 -0
  252. package/dist/tools/ctrl.js +478 -0
  253. package/dist/tools/diag.js +583 -0
  254. package/dist/tools/env.js +184 -0
  255. package/dist/tools/fs.js +818 -0
  256. package/dist/tools/mcp.js +138 -0
  257. package/dist/tools/mem.js +349 -0
  258. package/dist/tools/os.js +751 -0
  259. package/dist/tools/prompts/team_mgmt.en.md +70 -0
  260. package/dist/tools/prompts/team_mgmt.zh.md +70 -0
  261. package/dist/tools/prompts/ws_mod.en.md +86 -0
  262. package/dist/tools/prompts/ws_mod.zh.md +87 -0
  263. package/dist/tools/registry-snapshot.js +31 -0
  264. package/dist/tools/registry.js +121 -0
  265. package/dist/tools/ripgrep.js +678 -0
  266. package/dist/tools/team-mgmt.js +3300 -0
  267. package/dist/tools/txt.js +3178 -0
  268. package/dist/utils/id.js +72 -0
  269. package/dist/utils/task-doc.js +236 -0
  270. package/dist/utils/task-package.js +522 -0
  271. package/dist/utils/taskdoc-search.js +280 -0
  272. package/dist/utils/taskdoc.js +400 -0
  273. package/package.json +69 -0
@@ -0,0 +1,3875 @@
1
+ var _a;
2
+ import { a as drawBackgroundRect, b as getTextObj, g as getNoteRect, d as drawRect, c as drawEmbeddedImage, e as drawImage } from "./chunk-TZMSLE5B-BxtzW6--.js";
3
+ import { _ as __name, n as setConfig2, c as getConfig2, d as select, l as log, j as distExports, e as configureSvgSize, f as assignWithDepth_default, k as common_default, b as setAccTitle, s as setAccDescription, p as setDiagramTitle, a as getAccTitle, g as getAccDescription, q as getDiagramTitle, t as load, J as JSON_SCHEMA, y as clear, i as sanitizeText, u as utils_default, L as hasKatex, M as calculateMathMLDimensions, N as parseFontSize, Z as ZERO_WIDTH_SPACE, O as getUrl, P as renderKatexSanitized, E as getConfig } from "./index-BS6HnGzC.js";
4
+ import { I as ImperativeState } from "./chunk-QZHKN3VN-CNgjMR-e.js";
5
+ var parser = (function() {
6
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
7
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
8
+ return o2;
9
+ }, "o"), $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 13], $V7 = [1, 14], $V8 = [1, 16], $V9 = [1, 17], $Va = [1, 18], $Vb = [1, 24], $Vc = [1, 25], $Vd = [1, 26], $Ve = [1, 27], $Vf = [1, 28], $Vg = [1, 29], $Vh = [1, 30], $Vi = [1, 31], $Vj = [1, 32], $Vk = [1, 33], $Vl = [1, 34], $Vm = [1, 35], $Vn = [1, 36], $Vo = [1, 37], $Vp = [1, 38], $Vq = [1, 39], $Vr = [1, 41], $Vs = [1, 42], $Vt = [1, 43], $Vu = [1, 44], $Vv = [1, 45], $Vw = [1, 46], $Vx = [1, 4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 48, 49, 50, 52, 53, 55, 60, 61, 62, 63, 71], $Vy = [2, 71], $Vz = [4, 5, 16, 50, 52, 53], $VA = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 55, 60, 61, 62, 63, 71], $VB = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 49, 50, 52, 53, 55, 60, 61, 62, 63, 71], $VC = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 48, 50, 52, 53, 55, 60, 61, 62, 63, 71], $VD = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 50, 52, 53, 55, 60, 61, 62, 63, 71], $VE = [69, 70, 71], $VF = [1, 127];
10
+ var parser2 = {
11
+ trace: /* @__PURE__ */ __name(function trace() {
12
+ }, "trace"),
13
+ yy: {},
14
+ symbols_: { "error": 2, "start": 3, "SPACE": 4, "NEWLINE": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "box_section": 10, "box_line": 11, "participant_statement": 12, "create": 13, "box": 14, "restOfLine": 15, "end": 16, "signal": 17, "autonumber": 18, "NUM": 19, "off": 20, "activate": 21, "actor": 22, "deactivate": 23, "note_statement": 24, "links_statement": 25, "link_statement": 26, "properties_statement": 27, "details_statement": 28, "title": 29, "legacy_title": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "loop": 36, "rect": 37, "opt": 38, "alt": 39, "else_sections": 40, "par": 41, "par_sections": 42, "par_over": 43, "critical": 44, "option_sections": 45, "break": 46, "option": 47, "and": 48, "else": 49, "participant": 50, "AS": 51, "participant_actor": 52, "destroy": 53, "actor_with_config": 54, "note": 55, "placement": 56, "text2": 57, "over": 58, "actor_pair": 59, "links": 60, "link": 61, "properties": 62, "details": 63, "spaceList": 64, ",": 65, "left_of": 66, "right_of": 67, "signaltype": 68, "+": 69, "-": 70, "ACTOR": 71, "config_object": 72, "CONFIG_START": 73, "CONFIG_CONTENT": 74, "CONFIG_END": 75, "SOLID_OPEN_ARROW": 76, "DOTTED_OPEN_ARROW": 77, "SOLID_ARROW": 78, "BIDIRECTIONAL_SOLID_ARROW": 79, "DOTTED_ARROW": 80, "BIDIRECTIONAL_DOTTED_ARROW": 81, "SOLID_CROSS": 82, "DOTTED_CROSS": 83, "SOLID_POINT": 84, "DOTTED_POINT": 85, "TXT": 86, "$accept": 0, "$end": 1 },
15
+ terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 6: "SD", 13: "create", 14: "box", 15: "restOfLine", 16: "end", 18: "autonumber", 19: "NUM", 20: "off", 21: "activate", 23: "deactivate", 29: "title", 30: "legacy_title", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 36: "loop", 37: "rect", 38: "opt", 39: "alt", 41: "par", 43: "par_over", 44: "critical", 46: "break", 47: "option", 48: "and", 49: "else", 50: "participant", 51: "AS", 52: "participant_actor", 53: "destroy", 55: "note", 58: "over", 60: "links", 61: "link", 62: "properties", 63: "details", 65: ",", 66: "left_of", 67: "right_of", 69: "+", 70: "-", 71: "ACTOR", 73: "CONFIG_START", 74: "CONFIG_CONTENT", 75: "CONFIG_END", 76: "SOLID_OPEN_ARROW", 77: "DOTTED_OPEN_ARROW", 78: "SOLID_ARROW", 79: "BIDIRECTIONAL_SOLID_ARROW", 80: "DOTTED_ARROW", 81: "BIDIRECTIONAL_DOTTED_ARROW", 82: "SOLID_CROSS", 83: "DOTTED_CROSS", 84: "SOLID_POINT", 85: "DOTTED_POINT", 86: "TXT" },
16
+ productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [10, 0], [10, 2], [11, 2], [11, 1], [11, 1], [9, 1], [9, 2], [9, 4], [9, 2], [9, 4], [9, 3], [9, 3], [9, 2], [9, 3], [9, 3], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [45, 1], [45, 4], [42, 1], [42, 4], [40, 1], [40, 4], [12, 5], [12, 3], [12, 5], [12, 3], [12, 3], [12, 3], [24, 4], [24, 4], [25, 3], [26, 3], [27, 3], [28, 3], [64, 2], [64, 1], [59, 3], [59, 1], [56, 1], [56, 1], [17, 5], [17, 5], [17, 4], [54, 2], [72, 3], [22, 1], [68, 1], [68, 1], [68, 1], [68, 1], [68, 1], [68, 1], [68, 1], [68, 1], [68, 1], [68, 1], [57, 1]],
17
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
18
+ var $0 = $$.length - 1;
19
+ switch (yystate) {
20
+ case 3:
21
+ yy.apply($$[$0]);
22
+ return $$[$0];
23
+ case 4:
24
+ case 9:
25
+ this.$ = [];
26
+ break;
27
+ case 5:
28
+ case 10:
29
+ $$[$0 - 1].push($$[$0]);
30
+ this.$ = $$[$0 - 1];
31
+ break;
32
+ case 6:
33
+ case 7:
34
+ case 11:
35
+ case 12:
36
+ this.$ = $$[$0];
37
+ break;
38
+ case 8:
39
+ case 13:
40
+ this.$ = [];
41
+ break;
42
+ case 15:
43
+ $$[$0].type = "createParticipant";
44
+ this.$ = $$[$0];
45
+ break;
46
+ case 16:
47
+ $$[$0 - 1].unshift({ type: "boxStart", boxData: yy.parseBoxData($$[$0 - 2]) });
48
+ $$[$0 - 1].push({ type: "boxEnd", boxText: $$[$0 - 2] });
49
+ this.$ = $$[$0 - 1];
50
+ break;
51
+ case 18:
52
+ this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 2]), sequenceIndexStep: Number($$[$0 - 1]), sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
53
+ break;
54
+ case 19:
55
+ this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 1]), sequenceIndexStep: 1, sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
56
+ break;
57
+ case 20:
58
+ this.$ = { type: "sequenceIndex", sequenceVisible: false, signalType: yy.LINETYPE.AUTONUMBER };
59
+ break;
60
+ case 21:
61
+ this.$ = { type: "sequenceIndex", sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
62
+ break;
63
+ case 22:
64
+ this.$ = { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1].actor };
65
+ break;
66
+ case 23:
67
+ this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1].actor };
68
+ break;
69
+ case 29:
70
+ yy.setDiagramTitle($$[$0].substring(6));
71
+ this.$ = $$[$0].substring(6);
72
+ break;
73
+ case 30:
74
+ yy.setDiagramTitle($$[$0].substring(7));
75
+ this.$ = $$[$0].substring(7);
76
+ break;
77
+ case 31:
78
+ this.$ = $$[$0].trim();
79
+ yy.setAccTitle(this.$);
80
+ break;
81
+ case 32:
82
+ case 33:
83
+ this.$ = $$[$0].trim();
84
+ yy.setAccDescription(this.$);
85
+ break;
86
+ case 34:
87
+ $$[$0 - 1].unshift({ type: "loopStart", loopText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.LOOP_START });
88
+ $$[$0 - 1].push({ type: "loopEnd", loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END });
89
+ this.$ = $$[$0 - 1];
90
+ break;
91
+ case 35:
92
+ $$[$0 - 1].unshift({ type: "rectStart", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_START });
93
+ $$[$0 - 1].push({ type: "rectEnd", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_END });
94
+ this.$ = $$[$0 - 1];
95
+ break;
96
+ case 36:
97
+ $$[$0 - 1].unshift({ type: "optStart", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_START });
98
+ $$[$0 - 1].push({ type: "optEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_END });
99
+ this.$ = $$[$0 - 1];
100
+ break;
101
+ case 37:
102
+ $$[$0 - 1].unshift({ type: "altStart", altText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.ALT_START });
103
+ $$[$0 - 1].push({ type: "altEnd", signalType: yy.LINETYPE.ALT_END });
104
+ this.$ = $$[$0 - 1];
105
+ break;
106
+ case 38:
107
+ $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_START });
108
+ $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END });
109
+ this.$ = $$[$0 - 1];
110
+ break;
111
+ case 39:
112
+ $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_OVER_START });
113
+ $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END });
114
+ this.$ = $$[$0 - 1];
115
+ break;
116
+ case 40:
117
+ $$[$0 - 1].unshift({ type: "criticalStart", criticalText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.CRITICAL_START });
118
+ $$[$0 - 1].push({ type: "criticalEnd", signalType: yy.LINETYPE.CRITICAL_END });
119
+ this.$ = $$[$0 - 1];
120
+ break;
121
+ case 41:
122
+ $$[$0 - 1].unshift({ type: "breakStart", breakText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_START });
123
+ $$[$0 - 1].push({ type: "breakEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_END });
124
+ this.$ = $$[$0 - 1];
125
+ break;
126
+ case 43:
127
+ this.$ = $$[$0 - 3].concat([{ type: "option", optionText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.CRITICAL_OPTION }, $$[$0]]);
128
+ break;
129
+ case 45:
130
+ this.$ = $$[$0 - 3].concat([{ type: "and", parText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.PAR_AND }, $$[$0]]);
131
+ break;
132
+ case 47:
133
+ this.$ = $$[$0 - 3].concat([{ type: "else", altText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.ALT_ELSE }, $$[$0]]);
134
+ break;
135
+ case 48:
136
+ $$[$0 - 3].draw = "participant";
137
+ $$[$0 - 3].type = "addParticipant";
138
+ $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]);
139
+ this.$ = $$[$0 - 3];
140
+ break;
141
+ case 49:
142
+ $$[$0 - 1].draw = "participant";
143
+ $$[$0 - 1].type = "addParticipant";
144
+ this.$ = $$[$0 - 1];
145
+ break;
146
+ case 50:
147
+ $$[$0 - 3].draw = "actor";
148
+ $$[$0 - 3].type = "addParticipant";
149
+ $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]);
150
+ this.$ = $$[$0 - 3];
151
+ break;
152
+ case 51:
153
+ $$[$0 - 1].draw = "actor";
154
+ $$[$0 - 1].type = "addParticipant";
155
+ this.$ = $$[$0 - 1];
156
+ break;
157
+ case 52:
158
+ $$[$0 - 1].type = "destroyParticipant";
159
+ this.$ = $$[$0 - 1];
160
+ break;
161
+ case 53:
162
+ $$[$0 - 1].draw = "participant";
163
+ $$[$0 - 1].type = "addParticipant";
164
+ this.$ = $$[$0 - 1];
165
+ break;
166
+ case 54:
167
+ this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }];
168
+ break;
169
+ case 55:
170
+ $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2);
171
+ $$[$0 - 2][0] = $$[$0 - 2][0].actor;
172
+ $$[$0 - 2][1] = $$[$0 - 2][1].actor;
173
+ this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }];
174
+ break;
175
+ case 56:
176
+ this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }];
177
+ break;
178
+ case 57:
179
+ this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }];
180
+ break;
181
+ case 58:
182
+ this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }];
183
+ break;
184
+ case 59:
185
+ this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }];
186
+ break;
187
+ case 62:
188
+ this.$ = [$$[$0 - 2], $$[$0]];
189
+ break;
190
+ case 63:
191
+ this.$ = $$[$0];
192
+ break;
193
+ case 64:
194
+ this.$ = yy.PLACEMENT.LEFTOF;
195
+ break;
196
+ case 65:
197
+ this.$ = yy.PLACEMENT.RIGHTOF;
198
+ break;
199
+ case 66:
200
+ this.$ = [
201
+ $$[$0 - 4],
202
+ $$[$0 - 1],
203
+ { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0], activate: true },
204
+ { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1].actor }
205
+ ];
206
+ break;
207
+ case 67:
208
+ this.$ = [
209
+ $$[$0 - 4],
210
+ $$[$0 - 1],
211
+ { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] },
212
+ { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4].actor }
213
+ ];
214
+ break;
215
+ case 68:
216
+ this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }];
217
+ break;
218
+ case 69:
219
+ this.$ = {
220
+ type: "addParticipant",
221
+ actor: $$[$0 - 1],
222
+ config: $$[$0]
223
+ };
224
+ break;
225
+ case 70:
226
+ this.$ = $$[$0 - 1].trim();
227
+ break;
228
+ case 71:
229
+ this.$ = { type: "addParticipant", actor: $$[$0] };
230
+ break;
231
+ case 72:
232
+ this.$ = yy.LINETYPE.SOLID_OPEN;
233
+ break;
234
+ case 73:
235
+ this.$ = yy.LINETYPE.DOTTED_OPEN;
236
+ break;
237
+ case 74:
238
+ this.$ = yy.LINETYPE.SOLID;
239
+ break;
240
+ case 75:
241
+ this.$ = yy.LINETYPE.BIDIRECTIONAL_SOLID;
242
+ break;
243
+ case 76:
244
+ this.$ = yy.LINETYPE.DOTTED;
245
+ break;
246
+ case 77:
247
+ this.$ = yy.LINETYPE.BIDIRECTIONAL_DOTTED;
248
+ break;
249
+ case 78:
250
+ this.$ = yy.LINETYPE.SOLID_CROSS;
251
+ break;
252
+ case 79:
253
+ this.$ = yy.LINETYPE.DOTTED_CROSS;
254
+ break;
255
+ case 80:
256
+ this.$ = yy.LINETYPE.SOLID_POINT;
257
+ break;
258
+ case 81:
259
+ this.$ = yy.LINETYPE.DOTTED_POINT;
260
+ break;
261
+ case 82:
262
+ this.$ = yy.parseMessage($$[$0].trim().substring(1));
263
+ break;
264
+ }
265
+ }, "anonymous"),
266
+ table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 13, 14, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 55, 60, 61, 62, 63, 71], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, o($Vx, [2, 5]), { 9: 47, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, o($Vx, [2, 7]), o($Vx, [2, 8]), o($Vx, [2, 14]), { 12: 48, 50: $Vo, 52: $Vp, 53: $Vq }, { 15: [1, 49] }, { 5: [1, 50] }, { 5: [1, 53], 19: [1, 51], 20: [1, 52] }, { 22: 54, 71: $Vw }, { 22: 55, 71: $Vw }, { 5: [1, 56] }, { 5: [1, 57] }, { 5: [1, 58] }, { 5: [1, 59] }, { 5: [1, 60] }, o($Vx, [2, 29]), o($Vx, [2, 30]), { 32: [1, 61] }, { 34: [1, 62] }, o($Vx, [2, 33]), { 15: [1, 63] }, { 15: [1, 64] }, { 15: [1, 65] }, { 15: [1, 66] }, { 15: [1, 67] }, { 15: [1, 68] }, { 15: [1, 69] }, { 15: [1, 70] }, { 22: 71, 54: 72, 71: [1, 73] }, { 22: 74, 71: $Vw }, { 22: 75, 71: $Vw }, { 68: 76, 76: [1, 77], 77: [1, 78], 78: [1, 79], 79: [1, 80], 80: [1, 81], 81: [1, 82], 82: [1, 83], 83: [1, 84], 84: [1, 85], 85: [1, 86] }, { 56: 87, 58: [1, 88], 66: [1, 89], 67: [1, 90] }, { 22: 91, 71: $Vw }, { 22: 92, 71: $Vw }, { 22: 93, 71: $Vw }, { 22: 94, 71: $Vw }, o([5, 51, 65, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86], $Vy), o($Vx, [2, 6]), o($Vx, [2, 15]), o($Vz, [2, 9], { 10: 95 }), o($Vx, [2, 17]), { 5: [1, 97], 19: [1, 96] }, { 5: [1, 98] }, o($Vx, [2, 21]), { 5: [1, 99] }, { 5: [1, 100] }, o($Vx, [2, 24]), o($Vx, [2, 25]), o($Vx, [2, 26]), o($Vx, [2, 27]), o($Vx, [2, 28]), o($Vx, [2, 31]), o($Vx, [2, 32]), o($VA, $V3, { 7: 101 }), o($VA, $V3, { 7: 102 }), o($VA, $V3, { 7: 103 }), o($VB, $V3, { 40: 104, 7: 105 }), o($VC, $V3, { 42: 106, 7: 107 }), o($VC, $V3, { 7: 107, 42: 108 }), o($VD, $V3, { 45: 109, 7: 110 }), o($VA, $V3, { 7: 111 }), { 5: [1, 113], 51: [1, 112] }, { 5: [1, 114] }, o([5, 51], $Vy, { 72: 115, 73: [1, 116] }), { 5: [1, 118], 51: [1, 117] }, { 5: [1, 119] }, { 22: 122, 69: [1, 120], 70: [1, 121], 71: $Vw }, o($VE, [2, 72]), o($VE, [2, 73]), o($VE, [2, 74]), o($VE, [2, 75]), o($VE, [2, 76]), o($VE, [2, 77]), o($VE, [2, 78]), o($VE, [2, 79]), o($VE, [2, 80]), o($VE, [2, 81]), { 22: 123, 71: $Vw }, { 22: 125, 59: 124, 71: $Vw }, { 71: [2, 64] }, { 71: [2, 65] }, { 57: 126, 86: $VF }, { 57: 128, 86: $VF }, { 57: 129, 86: $VF }, { 57: 130, 86: $VF }, { 4: [1, 133], 5: [1, 135], 11: 132, 12: 134, 16: [1, 131], 50: $Vo, 52: $Vp, 53: $Vq }, { 5: [1, 136] }, o($Vx, [2, 19]), o($Vx, [2, 20]), o($Vx, [2, 22]), o($Vx, [2, 23]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 137], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 138], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 139], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 16: [1, 140] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 46], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 49: [1, 141], 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 16: [1, 142] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 44], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 48: [1, 143], 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 16: [1, 144] }, { 16: [1, 145] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 42], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 47: [1, 146], 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 147], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 55: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 71: $Vw }, { 15: [1, 148] }, o($Vx, [2, 49]), o($Vx, [2, 53]), { 5: [2, 69] }, { 74: [1, 149] }, { 15: [1, 150] }, o($Vx, [2, 51]), o($Vx, [2, 52]), { 22: 151, 71: $Vw }, { 22: 152, 71: $Vw }, { 57: 153, 86: $VF }, { 57: 154, 86: $VF }, { 57: 155, 86: $VF }, { 65: [1, 156], 86: [2, 63] }, { 5: [2, 56] }, { 5: [2, 82] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: [2, 59] }, o($Vx, [2, 16]), o($Vz, [2, 10]), { 12: 157, 50: $Vo, 52: $Vp, 53: $Vq }, o($Vz, [2, 12]), o($Vz, [2, 13]), o($Vx, [2, 18]), o($Vx, [2, 34]), o($Vx, [2, 35]), o($Vx, [2, 36]), o($Vx, [2, 37]), { 15: [1, 158] }, o($Vx, [2, 38]), { 15: [1, 159] }, o($Vx, [2, 39]), o($Vx, [2, 40]), { 15: [1, 160] }, o($Vx, [2, 41]), { 5: [1, 161] }, { 75: [1, 162] }, { 5: [1, 163] }, { 57: 164, 86: $VF }, { 57: 165, 86: $VF }, { 5: [2, 68] }, { 5: [2, 54] }, { 5: [2, 55] }, { 22: 166, 71: $Vw }, o($Vz, [2, 11]), o($VB, $V3, { 7: 105, 40: 167 }), o($VC, $V3, { 7: 107, 42: 168 }), o($VD, $V3, { 7: 110, 45: 169 }), o($Vx, [2, 48]), { 5: [2, 70] }, o($Vx, [2, 50]), { 5: [2, 66] }, { 5: [2, 67] }, { 86: [2, 62] }, { 16: [2, 47] }, { 16: [2, 45] }, { 16: [2, 43] }],
267
+ defaultActions: { 5: [2, 1], 6: [2, 2], 89: [2, 64], 90: [2, 65], 115: [2, 69], 126: [2, 56], 127: [2, 82], 128: [2, 57], 129: [2, 58], 130: [2, 59], 153: [2, 68], 154: [2, 54], 155: [2, 55], 162: [2, 70], 164: [2, 66], 165: [2, 67], 166: [2, 62], 167: [2, 47], 168: [2, 45], 169: [2, 43] },
268
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
269
+ if (hash.recoverable) {
270
+ this.trace(str);
271
+ } else {
272
+ var error = new Error(str);
273
+ error.hash = hash;
274
+ throw error;
275
+ }
276
+ }, "parseError"),
277
+ parse: /* @__PURE__ */ __name(function parse(input) {
278
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
279
+ var args = lstack.slice.call(arguments, 1);
280
+ var lexer2 = Object.create(this.lexer);
281
+ var sharedState = { yy: {} };
282
+ for (var k in this.yy) {
283
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
284
+ sharedState.yy[k] = this.yy[k];
285
+ }
286
+ }
287
+ lexer2.setInput(input, sharedState.yy);
288
+ sharedState.yy.lexer = lexer2;
289
+ sharedState.yy.parser = this;
290
+ if (typeof lexer2.yylloc == "undefined") {
291
+ lexer2.yylloc = {};
292
+ }
293
+ var yyloc = lexer2.yylloc;
294
+ lstack.push(yyloc);
295
+ var ranges = lexer2.options && lexer2.options.ranges;
296
+ if (typeof sharedState.yy.parseError === "function") {
297
+ this.parseError = sharedState.yy.parseError;
298
+ } else {
299
+ this.parseError = Object.getPrototypeOf(this).parseError;
300
+ }
301
+ function popStack(n) {
302
+ stack.length = stack.length - 2 * n;
303
+ vstack.length = vstack.length - n;
304
+ lstack.length = lstack.length - n;
305
+ }
306
+ __name(popStack, "popStack");
307
+ function lex() {
308
+ var token;
309
+ token = tstack.pop() || lexer2.lex() || EOF;
310
+ if (typeof token !== "number") {
311
+ if (token instanceof Array) {
312
+ tstack = token;
313
+ token = tstack.pop();
314
+ }
315
+ token = self.symbols_[token] || token;
316
+ }
317
+ return token;
318
+ }
319
+ __name(lex, "lex");
320
+ var symbol, state, action, r, yyval = {}, p, len, newState, expected;
321
+ while (true) {
322
+ state = stack[stack.length - 1];
323
+ if (this.defaultActions[state]) {
324
+ action = this.defaultActions[state];
325
+ } else {
326
+ if (symbol === null || typeof symbol == "undefined") {
327
+ symbol = lex();
328
+ }
329
+ action = table[state] && table[state][symbol];
330
+ }
331
+ if (typeof action === "undefined" || !action.length || !action[0]) {
332
+ var errStr = "";
333
+ expected = [];
334
+ for (p in table[state]) {
335
+ if (this.terminals_[p] && p > TERROR) {
336
+ expected.push("'" + this.terminals_[p] + "'");
337
+ }
338
+ }
339
+ if (lexer2.showPosition) {
340
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
341
+ } else {
342
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
343
+ }
344
+ this.parseError(errStr, {
345
+ text: lexer2.match,
346
+ token: this.terminals_[symbol] || symbol,
347
+ line: lexer2.yylineno,
348
+ loc: yyloc,
349
+ expected
350
+ });
351
+ }
352
+ if (action[0] instanceof Array && action.length > 1) {
353
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
354
+ }
355
+ switch (action[0]) {
356
+ case 1:
357
+ stack.push(symbol);
358
+ vstack.push(lexer2.yytext);
359
+ lstack.push(lexer2.yylloc);
360
+ stack.push(action[1]);
361
+ symbol = null;
362
+ {
363
+ yyleng = lexer2.yyleng;
364
+ yytext = lexer2.yytext;
365
+ yylineno = lexer2.yylineno;
366
+ yyloc = lexer2.yylloc;
367
+ }
368
+ break;
369
+ case 2:
370
+ len = this.productions_[action[1]][1];
371
+ yyval.$ = vstack[vstack.length - len];
372
+ yyval._$ = {
373
+ first_line: lstack[lstack.length - (len || 1)].first_line,
374
+ last_line: lstack[lstack.length - 1].last_line,
375
+ first_column: lstack[lstack.length - (len || 1)].first_column,
376
+ last_column: lstack[lstack.length - 1].last_column
377
+ };
378
+ if (ranges) {
379
+ yyval._$.range = [
380
+ lstack[lstack.length - (len || 1)].range[0],
381
+ lstack[lstack.length - 1].range[1]
382
+ ];
383
+ }
384
+ r = this.performAction.apply(yyval, [
385
+ yytext,
386
+ yyleng,
387
+ yylineno,
388
+ sharedState.yy,
389
+ action[1],
390
+ vstack,
391
+ lstack
392
+ ].concat(args));
393
+ if (typeof r !== "undefined") {
394
+ return r;
395
+ }
396
+ if (len) {
397
+ stack = stack.slice(0, -1 * len * 2);
398
+ vstack = vstack.slice(0, -1 * len);
399
+ lstack = lstack.slice(0, -1 * len);
400
+ }
401
+ stack.push(this.productions_[action[1]][0]);
402
+ vstack.push(yyval.$);
403
+ lstack.push(yyval._$);
404
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
405
+ stack.push(newState);
406
+ break;
407
+ case 3:
408
+ return true;
409
+ }
410
+ }
411
+ return true;
412
+ }, "parse")
413
+ };
414
+ var lexer = /* @__PURE__ */ (function() {
415
+ var lexer2 = {
416
+ EOF: 1,
417
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
418
+ if (this.yy.parser) {
419
+ this.yy.parser.parseError(str, hash);
420
+ } else {
421
+ throw new Error(str);
422
+ }
423
+ }, "parseError"),
424
+ // resets the lexer, sets new input
425
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
426
+ this.yy = yy || this.yy || {};
427
+ this._input = input;
428
+ this._more = this._backtrack = this.done = false;
429
+ this.yylineno = this.yyleng = 0;
430
+ this.yytext = this.matched = this.match = "";
431
+ this.conditionStack = ["INITIAL"];
432
+ this.yylloc = {
433
+ first_line: 1,
434
+ first_column: 0,
435
+ last_line: 1,
436
+ last_column: 0
437
+ };
438
+ if (this.options.ranges) {
439
+ this.yylloc.range = [0, 0];
440
+ }
441
+ this.offset = 0;
442
+ return this;
443
+ }, "setInput"),
444
+ // consumes and returns one char from the input
445
+ input: /* @__PURE__ */ __name(function() {
446
+ var ch = this._input[0];
447
+ this.yytext += ch;
448
+ this.yyleng++;
449
+ this.offset++;
450
+ this.match += ch;
451
+ this.matched += ch;
452
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
453
+ if (lines) {
454
+ this.yylineno++;
455
+ this.yylloc.last_line++;
456
+ } else {
457
+ this.yylloc.last_column++;
458
+ }
459
+ if (this.options.ranges) {
460
+ this.yylloc.range[1]++;
461
+ }
462
+ this._input = this._input.slice(1);
463
+ return ch;
464
+ }, "input"),
465
+ // unshifts one char (or a string) into the input
466
+ unput: /* @__PURE__ */ __name(function(ch) {
467
+ var len = ch.length;
468
+ var lines = ch.split(/(?:\r\n?|\n)/g);
469
+ this._input = ch + this._input;
470
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
471
+ this.offset -= len;
472
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
473
+ this.match = this.match.substr(0, this.match.length - 1);
474
+ this.matched = this.matched.substr(0, this.matched.length - 1);
475
+ if (lines.length - 1) {
476
+ this.yylineno -= lines.length - 1;
477
+ }
478
+ var r = this.yylloc.range;
479
+ this.yylloc = {
480
+ first_line: this.yylloc.first_line,
481
+ last_line: this.yylineno + 1,
482
+ first_column: this.yylloc.first_column,
483
+ last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
484
+ };
485
+ if (this.options.ranges) {
486
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
487
+ }
488
+ this.yyleng = this.yytext.length;
489
+ return this;
490
+ }, "unput"),
491
+ // When called from action, caches matched text and appends it on next action
492
+ more: /* @__PURE__ */ __name(function() {
493
+ this._more = true;
494
+ return this;
495
+ }, "more"),
496
+ // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
497
+ reject: /* @__PURE__ */ __name(function() {
498
+ if (this.options.backtrack_lexer) {
499
+ this._backtrack = true;
500
+ } else {
501
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
502
+ text: "",
503
+ token: null,
504
+ line: this.yylineno
505
+ });
506
+ }
507
+ return this;
508
+ }, "reject"),
509
+ // retain first n characters of the match
510
+ less: /* @__PURE__ */ __name(function(n) {
511
+ this.unput(this.match.slice(n));
512
+ }, "less"),
513
+ // displays already matched input, i.e. for error messages
514
+ pastInput: /* @__PURE__ */ __name(function() {
515
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
516
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
517
+ }, "pastInput"),
518
+ // displays upcoming input, i.e. for error messages
519
+ upcomingInput: /* @__PURE__ */ __name(function() {
520
+ var next = this.match;
521
+ if (next.length < 20) {
522
+ next += this._input.substr(0, 20 - next.length);
523
+ }
524
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
525
+ }, "upcomingInput"),
526
+ // displays the character position where the lexing error occurred, i.e. for error messages
527
+ showPosition: /* @__PURE__ */ __name(function() {
528
+ var pre = this.pastInput();
529
+ var c = new Array(pre.length + 1).join("-");
530
+ return pre + this.upcomingInput() + "\n" + c + "^";
531
+ }, "showPosition"),
532
+ // test the lexed token: return FALSE when not a match, otherwise return token
533
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
534
+ var token, lines, backup;
535
+ if (this.options.backtrack_lexer) {
536
+ backup = {
537
+ yylineno: this.yylineno,
538
+ yylloc: {
539
+ first_line: this.yylloc.first_line,
540
+ last_line: this.last_line,
541
+ first_column: this.yylloc.first_column,
542
+ last_column: this.yylloc.last_column
543
+ },
544
+ yytext: this.yytext,
545
+ match: this.match,
546
+ matches: this.matches,
547
+ matched: this.matched,
548
+ yyleng: this.yyleng,
549
+ offset: this.offset,
550
+ _more: this._more,
551
+ _input: this._input,
552
+ yy: this.yy,
553
+ conditionStack: this.conditionStack.slice(0),
554
+ done: this.done
555
+ };
556
+ if (this.options.ranges) {
557
+ backup.yylloc.range = this.yylloc.range.slice(0);
558
+ }
559
+ }
560
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
561
+ if (lines) {
562
+ this.yylineno += lines.length;
563
+ }
564
+ this.yylloc = {
565
+ first_line: this.yylloc.last_line,
566
+ last_line: this.yylineno + 1,
567
+ first_column: this.yylloc.last_column,
568
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
569
+ };
570
+ this.yytext += match[0];
571
+ this.match += match[0];
572
+ this.matches = match;
573
+ this.yyleng = this.yytext.length;
574
+ if (this.options.ranges) {
575
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
576
+ }
577
+ this._more = false;
578
+ this._backtrack = false;
579
+ this._input = this._input.slice(match[0].length);
580
+ this.matched += match[0];
581
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
582
+ if (this.done && this._input) {
583
+ this.done = false;
584
+ }
585
+ if (token) {
586
+ return token;
587
+ } else if (this._backtrack) {
588
+ for (var k in backup) {
589
+ this[k] = backup[k];
590
+ }
591
+ return false;
592
+ }
593
+ return false;
594
+ }, "test_match"),
595
+ // return next match in input
596
+ next: /* @__PURE__ */ __name(function() {
597
+ if (this.done) {
598
+ return this.EOF;
599
+ }
600
+ if (!this._input) {
601
+ this.done = true;
602
+ }
603
+ var token, match, tempMatch, index;
604
+ if (!this._more) {
605
+ this.yytext = "";
606
+ this.match = "";
607
+ }
608
+ var rules = this._currentRules();
609
+ for (var i = 0; i < rules.length; i++) {
610
+ tempMatch = this._input.match(this.rules[rules[i]]);
611
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
612
+ match = tempMatch;
613
+ index = i;
614
+ if (this.options.backtrack_lexer) {
615
+ token = this.test_match(tempMatch, rules[i]);
616
+ if (token !== false) {
617
+ return token;
618
+ } else if (this._backtrack) {
619
+ match = false;
620
+ continue;
621
+ } else {
622
+ return false;
623
+ }
624
+ } else if (!this.options.flex) {
625
+ break;
626
+ }
627
+ }
628
+ }
629
+ if (match) {
630
+ token = this.test_match(match, rules[index]);
631
+ if (token !== false) {
632
+ return token;
633
+ }
634
+ return false;
635
+ }
636
+ if (this._input === "") {
637
+ return this.EOF;
638
+ } else {
639
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
640
+ text: "",
641
+ token: null,
642
+ line: this.yylineno
643
+ });
644
+ }
645
+ }, "next"),
646
+ // return next match that has a token
647
+ lex: /* @__PURE__ */ __name(function lex() {
648
+ var r = this.next();
649
+ if (r) {
650
+ return r;
651
+ } else {
652
+ return this.lex();
653
+ }
654
+ }, "lex"),
655
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
656
+ begin: /* @__PURE__ */ __name(function begin(condition) {
657
+ this.conditionStack.push(condition);
658
+ }, "begin"),
659
+ // pop the previously active lexer condition state off the condition stack
660
+ popState: /* @__PURE__ */ __name(function popState() {
661
+ var n = this.conditionStack.length - 1;
662
+ if (n > 0) {
663
+ return this.conditionStack.pop();
664
+ } else {
665
+ return this.conditionStack[0];
666
+ }
667
+ }, "popState"),
668
+ // produce the lexer rule set which is active for the currently active lexer condition state
669
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
670
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
671
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
672
+ } else {
673
+ return this.conditions["INITIAL"].rules;
674
+ }
675
+ }, "_currentRules"),
676
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
677
+ topState: /* @__PURE__ */ __name(function topState(n) {
678
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
679
+ if (n >= 0) {
680
+ return this.conditionStack[n];
681
+ } else {
682
+ return "INITIAL";
683
+ }
684
+ }, "topState"),
685
+ // alias for begin(condition)
686
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
687
+ this.begin(condition);
688
+ }, "pushState"),
689
+ // return the number of states currently on the stack
690
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
691
+ return this.conditionStack.length;
692
+ }, "stateStackSize"),
693
+ options: { "case-insensitive": true },
694
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
695
+ switch ($avoiding_name_collisions) {
696
+ case 0:
697
+ return 5;
698
+ case 1:
699
+ break;
700
+ case 2:
701
+ break;
702
+ case 3:
703
+ break;
704
+ case 4:
705
+ break;
706
+ case 5:
707
+ break;
708
+ case 6:
709
+ return 19;
710
+ case 7:
711
+ this.begin("CONFIG");
712
+ return 73;
713
+ case 8:
714
+ return 74;
715
+ case 9:
716
+ this.popState();
717
+ this.popState();
718
+ return 75;
719
+ case 10:
720
+ yy_.yytext = yy_.yytext.trim();
721
+ return 71;
722
+ case 11:
723
+ yy_.yytext = yy_.yytext.trim();
724
+ this.begin("ALIAS");
725
+ return 71;
726
+ case 12:
727
+ this.begin("LINE");
728
+ return 14;
729
+ case 13:
730
+ this.begin("ID");
731
+ return 50;
732
+ case 14:
733
+ this.begin("ID");
734
+ return 52;
735
+ case 15:
736
+ return 13;
737
+ case 16:
738
+ this.begin("ID");
739
+ return 53;
740
+ case 17:
741
+ yy_.yytext = yy_.yytext.trim();
742
+ this.begin("ALIAS");
743
+ return 71;
744
+ case 18:
745
+ this.popState();
746
+ this.popState();
747
+ this.begin("LINE");
748
+ return 51;
749
+ case 19:
750
+ this.popState();
751
+ this.popState();
752
+ return 5;
753
+ case 20:
754
+ this.begin("LINE");
755
+ return 36;
756
+ case 21:
757
+ this.begin("LINE");
758
+ return 37;
759
+ case 22:
760
+ this.begin("LINE");
761
+ return 38;
762
+ case 23:
763
+ this.begin("LINE");
764
+ return 39;
765
+ case 24:
766
+ this.begin("LINE");
767
+ return 49;
768
+ case 25:
769
+ this.begin("LINE");
770
+ return 41;
771
+ case 26:
772
+ this.begin("LINE");
773
+ return 43;
774
+ case 27:
775
+ this.begin("LINE");
776
+ return 48;
777
+ case 28:
778
+ this.begin("LINE");
779
+ return 44;
780
+ case 29:
781
+ this.begin("LINE");
782
+ return 47;
783
+ case 30:
784
+ this.begin("LINE");
785
+ return 46;
786
+ case 31:
787
+ this.popState();
788
+ return 15;
789
+ case 32:
790
+ return 16;
791
+ case 33:
792
+ return 66;
793
+ case 34:
794
+ return 67;
795
+ case 35:
796
+ return 60;
797
+ case 36:
798
+ return 61;
799
+ case 37:
800
+ return 62;
801
+ case 38:
802
+ return 63;
803
+ case 39:
804
+ return 58;
805
+ case 40:
806
+ return 55;
807
+ case 41:
808
+ this.begin("ID");
809
+ return 21;
810
+ case 42:
811
+ this.begin("ID");
812
+ return 23;
813
+ case 43:
814
+ return 29;
815
+ case 44:
816
+ return 30;
817
+ case 45:
818
+ this.begin("acc_title");
819
+ return 31;
820
+ case 46:
821
+ this.popState();
822
+ return "acc_title_value";
823
+ case 47:
824
+ this.begin("acc_descr");
825
+ return 33;
826
+ case 48:
827
+ this.popState();
828
+ return "acc_descr_value";
829
+ case 49:
830
+ this.begin("acc_descr_multiline");
831
+ break;
832
+ case 50:
833
+ this.popState();
834
+ break;
835
+ case 51:
836
+ return "acc_descr_multiline_value";
837
+ case 52:
838
+ return 6;
839
+ case 53:
840
+ return 18;
841
+ case 54:
842
+ return 20;
843
+ case 55:
844
+ return 65;
845
+ case 56:
846
+ return 5;
847
+ case 57:
848
+ yy_.yytext = yy_.yytext.trim();
849
+ return 71;
850
+ case 58:
851
+ return 78;
852
+ case 59:
853
+ return 79;
854
+ case 60:
855
+ return 80;
856
+ case 61:
857
+ return 81;
858
+ case 62:
859
+ return 76;
860
+ case 63:
861
+ return 77;
862
+ case 64:
863
+ return 82;
864
+ case 65:
865
+ return 83;
866
+ case 66:
867
+ return 84;
868
+ case 67:
869
+ return 85;
870
+ case 68:
871
+ return 86;
872
+ case 69:
873
+ return 86;
874
+ case 70:
875
+ return 69;
876
+ case 71:
877
+ return 70;
878
+ case 72:
879
+ return 5;
880
+ case 73:
881
+ return "INVALID";
882
+ }
883
+ }, "anonymous"),
884
+ rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \n]+))/i, /^(?:@\{)/i, /^(?:[^\}]+)/i, /^(?:\})/i, /^(?:[^\<->\->:\n,;@\s]+(?=@\{))/i, /^(?:[^\<->\->:\n,;@]+?([\-]*[^\<->\->:\n,;@]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:box\b)/i, /^(?:participant\b)/i, /^(?:actor\b)/i, /^(?:create\b)/i, /^(?:destroy\b)/i, /^(?:[^<\->\->:\n,;]+?([\-]*[^<\->\->:\n,;]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:rect\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:par_over\b)/i, /^(?:and\b)/i, /^(?:critical\b)/i, /^(?:option\b)/i, /^(?:break\b)/i, /^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:links\b)/i, /^(?:link\b)/i, /^(?:properties\b)/i, /^(?:details\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:title:\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:sequenceDiagram\b)/i, /^(?:autonumber\b)/i, /^(?:off\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^+<\->\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+<\->\->:\n,;]+)*)/i, /^(?:->>)/i, /^(?:<<->>)/i, /^(?:-->>)/i, /^(?:<<-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]*)/i, /^(?::)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i],
885
+ conditions: { "acc_descr_multiline": { "rules": [50, 51], "inclusive": false }, "acc_descr": { "rules": [48], "inclusive": false }, "acc_title": { "rules": [46], "inclusive": false }, "ID": { "rules": [2, 3, 7, 10, 11, 17], "inclusive": false }, "ALIAS": { "rules": [2, 3, 18, 19], "inclusive": false }, "LINE": { "rules": [2, 3, 31], "inclusive": false }, "CONFIG": { "rules": [8, 9], "inclusive": false }, "CONFIG_DATA": { "rules": [], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 4, 5, 6, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 49, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73], "inclusive": true } }
886
+ };
887
+ return lexer2;
888
+ })();
889
+ parser2.lexer = lexer;
890
+ function Parser() {
891
+ this.yy = {};
892
+ }
893
+ __name(Parser, "Parser");
894
+ Parser.prototype = parser2;
895
+ parser2.Parser = Parser;
896
+ return new Parser();
897
+ })();
898
+ parser.parser = parser;
899
+ var sequenceDiagram_default = parser;
900
+ var LINETYPE = {
901
+ SOLID: 0,
902
+ DOTTED: 1,
903
+ NOTE: 2,
904
+ SOLID_CROSS: 3,
905
+ DOTTED_CROSS: 4,
906
+ SOLID_OPEN: 5,
907
+ DOTTED_OPEN: 6,
908
+ LOOP_START: 10,
909
+ LOOP_END: 11,
910
+ ALT_START: 12,
911
+ ALT_ELSE: 13,
912
+ ALT_END: 14,
913
+ OPT_START: 15,
914
+ OPT_END: 16,
915
+ ACTIVE_START: 17,
916
+ ACTIVE_END: 18,
917
+ PAR_START: 19,
918
+ PAR_AND: 20,
919
+ PAR_END: 21,
920
+ RECT_START: 22,
921
+ RECT_END: 23,
922
+ SOLID_POINT: 24,
923
+ DOTTED_POINT: 25,
924
+ AUTONUMBER: 26,
925
+ CRITICAL_START: 27,
926
+ CRITICAL_OPTION: 28,
927
+ CRITICAL_END: 29,
928
+ BREAK_START: 30,
929
+ BREAK_END: 31,
930
+ PAR_OVER_START: 32,
931
+ BIDIRECTIONAL_SOLID: 33,
932
+ BIDIRECTIONAL_DOTTED: 34
933
+ };
934
+ var ARROWTYPE = {
935
+ FILLED: 0,
936
+ OPEN: 1
937
+ };
938
+ var PLACEMENT = {
939
+ LEFTOF: 0,
940
+ RIGHTOF: 1,
941
+ OVER: 2
942
+ };
943
+ var PARTICIPANT_TYPE = {
944
+ ACTOR: "actor",
945
+ CONTROL: "control",
946
+ DATABASE: "database",
947
+ ENTITY: "entity"
948
+ };
949
+ var SequenceDB = (_a = class {
950
+ constructor() {
951
+ this.state = new ImperativeState(() => ({
952
+ prevActor: void 0,
953
+ actors: /* @__PURE__ */ new Map(),
954
+ createdActors: /* @__PURE__ */ new Map(),
955
+ destroyedActors: /* @__PURE__ */ new Map(),
956
+ boxes: [],
957
+ messages: [],
958
+ notes: [],
959
+ sequenceNumbersEnabled: false,
960
+ wrapEnabled: void 0,
961
+ currentBox: void 0,
962
+ lastCreated: void 0,
963
+ lastDestroyed: void 0
964
+ }));
965
+ this.setAccTitle = setAccTitle;
966
+ this.setAccDescription = setAccDescription;
967
+ this.setDiagramTitle = setDiagramTitle;
968
+ this.getAccTitle = getAccTitle;
969
+ this.getAccDescription = getAccDescription;
970
+ this.getDiagramTitle = getDiagramTitle;
971
+ this.apply = this.apply.bind(this);
972
+ this.parseBoxData = this.parseBoxData.bind(this);
973
+ this.parseMessage = this.parseMessage.bind(this);
974
+ this.clear();
975
+ this.setWrap(getConfig2().wrap);
976
+ this.LINETYPE = LINETYPE;
977
+ this.ARROWTYPE = ARROWTYPE;
978
+ this.PLACEMENT = PLACEMENT;
979
+ }
980
+ addBox(data) {
981
+ this.state.records.boxes.push({
982
+ name: data.text,
983
+ wrap: data.wrap ?? this.autoWrap(),
984
+ fill: data.color,
985
+ actorKeys: []
986
+ });
987
+ this.state.records.currentBox = this.state.records.boxes.slice(-1)[0];
988
+ }
989
+ addActor(id, name, description, type, metadata) {
990
+ let assignedBox = this.state.records.currentBox;
991
+ let doc;
992
+ if (metadata !== void 0) {
993
+ let yamlData;
994
+ if (!metadata.includes("\n")) {
995
+ yamlData = "{\n" + metadata + "\n}";
996
+ } else {
997
+ yamlData = metadata + "\n";
998
+ }
999
+ doc = load(yamlData, { schema: JSON_SCHEMA });
1000
+ }
1001
+ type = doc?.type ?? type;
1002
+ const old = this.state.records.actors.get(id);
1003
+ if (old) {
1004
+ if (this.state.records.currentBox && old.box && this.state.records.currentBox !== old.box) {
1005
+ throw new Error(
1006
+ `A same participant should only be defined in one Box: ${old.name} can't be in '${old.box.name}' and in '${this.state.records.currentBox.name}' at the same time.`
1007
+ );
1008
+ }
1009
+ assignedBox = old.box ? old.box : this.state.records.currentBox;
1010
+ old.box = assignedBox;
1011
+ if (old && name === old.name && description == null) {
1012
+ return;
1013
+ }
1014
+ }
1015
+ if (description?.text == null) {
1016
+ description = { text: name, type };
1017
+ }
1018
+ if (type == null || description.text == null) {
1019
+ description = { text: name, type };
1020
+ }
1021
+ this.state.records.actors.set(id, {
1022
+ box: assignedBox,
1023
+ name,
1024
+ description: description.text,
1025
+ wrap: description.wrap ?? this.autoWrap(),
1026
+ prevActor: this.state.records.prevActor,
1027
+ links: {},
1028
+ properties: {},
1029
+ actorCnt: null,
1030
+ rectData: null,
1031
+ type: type ?? "participant"
1032
+ });
1033
+ if (this.state.records.prevActor) {
1034
+ const prevActorInRecords = this.state.records.actors.get(this.state.records.prevActor);
1035
+ if (prevActorInRecords) {
1036
+ prevActorInRecords.nextActor = id;
1037
+ }
1038
+ }
1039
+ if (this.state.records.currentBox) {
1040
+ this.state.records.currentBox.actorKeys.push(id);
1041
+ }
1042
+ this.state.records.prevActor = id;
1043
+ }
1044
+ activationCount(part) {
1045
+ let i;
1046
+ let count = 0;
1047
+ if (!part) {
1048
+ return 0;
1049
+ }
1050
+ for (i = 0; i < this.state.records.messages.length; i++) {
1051
+ if (this.state.records.messages[i].type === this.LINETYPE.ACTIVE_START && this.state.records.messages[i].from === part) {
1052
+ count++;
1053
+ }
1054
+ if (this.state.records.messages[i].type === this.LINETYPE.ACTIVE_END && this.state.records.messages[i].from === part) {
1055
+ count--;
1056
+ }
1057
+ }
1058
+ return count;
1059
+ }
1060
+ addMessage(idFrom, idTo, message, answer) {
1061
+ this.state.records.messages.push({
1062
+ id: this.state.records.messages.length.toString(),
1063
+ from: idFrom,
1064
+ to: idTo,
1065
+ message: message.text,
1066
+ wrap: message.wrap ?? this.autoWrap(),
1067
+ answer
1068
+ });
1069
+ }
1070
+ addSignal(idFrom, idTo, message, messageType, activate = false) {
1071
+ if (messageType === this.LINETYPE.ACTIVE_END) {
1072
+ const cnt = this.activationCount(idFrom ?? "");
1073
+ if (cnt < 1) {
1074
+ const error = new Error("Trying to inactivate an inactive participant (" + idFrom + ")");
1075
+ error.hash = {
1076
+ text: "->>-",
1077
+ token: "->>-",
1078
+ line: "1",
1079
+ loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1080
+ expected: ["'ACTIVE_PARTICIPANT'"]
1081
+ };
1082
+ throw error;
1083
+ }
1084
+ }
1085
+ this.state.records.messages.push({
1086
+ id: this.state.records.messages.length.toString(),
1087
+ from: idFrom,
1088
+ to: idTo,
1089
+ message: message?.text ?? "",
1090
+ wrap: message?.wrap ?? this.autoWrap(),
1091
+ type: messageType,
1092
+ activate
1093
+ });
1094
+ return true;
1095
+ }
1096
+ hasAtLeastOneBox() {
1097
+ return this.state.records.boxes.length > 0;
1098
+ }
1099
+ hasAtLeastOneBoxWithTitle() {
1100
+ return this.state.records.boxes.some((b) => b.name);
1101
+ }
1102
+ getMessages() {
1103
+ return this.state.records.messages;
1104
+ }
1105
+ getBoxes() {
1106
+ return this.state.records.boxes;
1107
+ }
1108
+ getActors() {
1109
+ return this.state.records.actors;
1110
+ }
1111
+ getCreatedActors() {
1112
+ return this.state.records.createdActors;
1113
+ }
1114
+ getDestroyedActors() {
1115
+ return this.state.records.destroyedActors;
1116
+ }
1117
+ getActor(id) {
1118
+ return this.state.records.actors.get(id);
1119
+ }
1120
+ getActorKeys() {
1121
+ return [...this.state.records.actors.keys()];
1122
+ }
1123
+ enableSequenceNumbers() {
1124
+ this.state.records.sequenceNumbersEnabled = true;
1125
+ }
1126
+ disableSequenceNumbers() {
1127
+ this.state.records.sequenceNumbersEnabled = false;
1128
+ }
1129
+ showSequenceNumbers() {
1130
+ return this.state.records.sequenceNumbersEnabled;
1131
+ }
1132
+ setWrap(wrapSetting) {
1133
+ this.state.records.wrapEnabled = wrapSetting;
1134
+ }
1135
+ extractWrap(text) {
1136
+ if (text === void 0) {
1137
+ return {};
1138
+ }
1139
+ text = text.trim();
1140
+ const wrap = /^:?wrap:/.exec(text) !== null ? true : /^:?nowrap:/.exec(text) !== null ? false : void 0;
1141
+ const cleanedText = (wrap === void 0 ? text : text.replace(/^:?(?:no)?wrap:/, "")).trim();
1142
+ return { cleanedText, wrap };
1143
+ }
1144
+ autoWrap() {
1145
+ if (this.state.records.wrapEnabled !== void 0) {
1146
+ return this.state.records.wrapEnabled;
1147
+ }
1148
+ return getConfig2().sequence?.wrap ?? false;
1149
+ }
1150
+ clear() {
1151
+ this.state.reset();
1152
+ clear();
1153
+ }
1154
+ parseMessage(str) {
1155
+ const trimmedStr = str.trim();
1156
+ const { wrap, cleanedText } = this.extractWrap(trimmedStr);
1157
+ const message = {
1158
+ text: cleanedText,
1159
+ wrap
1160
+ };
1161
+ log.debug(`parseMessage: ${JSON.stringify(message)}`);
1162
+ return message;
1163
+ }
1164
+ // We expect the box statement to be color first then description
1165
+ // The color can be rgb,rgba,hsl,hsla, or css code names #hex codes are not supported for now because of the way the char # is handled
1166
+ // We extract first segment as color, the rest of the line is considered as text
1167
+ parseBoxData(str) {
1168
+ const match = /^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/.exec(str);
1169
+ let color = match?.[1] ? match[1].trim() : "transparent";
1170
+ let title = match?.[2] ? match[2].trim() : void 0;
1171
+ if (window?.CSS) {
1172
+ if (!window.CSS.supports("color", color)) {
1173
+ color = "transparent";
1174
+ title = str.trim();
1175
+ }
1176
+ } else {
1177
+ const style = new Option().style;
1178
+ style.color = color;
1179
+ if (style.color !== color) {
1180
+ color = "transparent";
1181
+ title = str.trim();
1182
+ }
1183
+ }
1184
+ const { wrap, cleanedText } = this.extractWrap(title);
1185
+ return {
1186
+ text: cleanedText ? sanitizeText(cleanedText, getConfig2()) : void 0,
1187
+ color,
1188
+ wrap
1189
+ };
1190
+ }
1191
+ addNote(actor, placement, message) {
1192
+ const note = {
1193
+ actor,
1194
+ placement,
1195
+ message: message.text,
1196
+ wrap: message.wrap ?? this.autoWrap()
1197
+ };
1198
+ const actors = [].concat(actor, actor);
1199
+ this.state.records.notes.push(note);
1200
+ this.state.records.messages.push({
1201
+ id: this.state.records.messages.length.toString(),
1202
+ from: actors[0],
1203
+ to: actors[1],
1204
+ message: message.text,
1205
+ wrap: message.wrap ?? this.autoWrap(),
1206
+ type: this.LINETYPE.NOTE,
1207
+ placement
1208
+ });
1209
+ }
1210
+ addLinks(actorId, text) {
1211
+ const actor = this.getActor(actorId);
1212
+ try {
1213
+ let sanitizedText = sanitizeText(text.text, getConfig2());
1214
+ sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1215
+ sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1216
+ const links = JSON.parse(sanitizedText);
1217
+ this.insertLinks(actor, links);
1218
+ } catch (e) {
1219
+ log.error("error while parsing actor link text", e);
1220
+ }
1221
+ }
1222
+ addALink(actorId, text) {
1223
+ const actor = this.getActor(actorId);
1224
+ try {
1225
+ const links = {};
1226
+ let sanitizedText = sanitizeText(text.text, getConfig2());
1227
+ const sep = sanitizedText.indexOf("@");
1228
+ sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1229
+ sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1230
+ const label = sanitizedText.slice(0, sep - 1).trim();
1231
+ const link = sanitizedText.slice(sep + 1).trim();
1232
+ links[label] = link;
1233
+ this.insertLinks(actor, links);
1234
+ } catch (e) {
1235
+ log.error("error while parsing actor link text", e);
1236
+ }
1237
+ }
1238
+ insertLinks(actor, links) {
1239
+ if (actor.links == null) {
1240
+ actor.links = links;
1241
+ } else {
1242
+ for (const key in links) {
1243
+ actor.links[key] = links[key];
1244
+ }
1245
+ }
1246
+ }
1247
+ addProperties(actorId, text) {
1248
+ const actor = this.getActor(actorId);
1249
+ try {
1250
+ const sanitizedText = sanitizeText(text.text, getConfig2());
1251
+ const properties = JSON.parse(sanitizedText);
1252
+ this.insertProperties(actor, properties);
1253
+ } catch (e) {
1254
+ log.error("error while parsing actor properties text", e);
1255
+ }
1256
+ }
1257
+ insertProperties(actor, properties) {
1258
+ if (actor.properties == null) {
1259
+ actor.properties = properties;
1260
+ } else {
1261
+ for (const key in properties) {
1262
+ actor.properties[key] = properties[key];
1263
+ }
1264
+ }
1265
+ }
1266
+ boxEnd() {
1267
+ this.state.records.currentBox = void 0;
1268
+ }
1269
+ addDetails(actorId, text) {
1270
+ const actor = this.getActor(actorId);
1271
+ const elem = document.getElementById(text.text);
1272
+ try {
1273
+ const text2 = elem.innerHTML;
1274
+ const details = JSON.parse(text2);
1275
+ if (details.properties) {
1276
+ this.insertProperties(actor, details.properties);
1277
+ }
1278
+ if (details.links) {
1279
+ this.insertLinks(actor, details.links);
1280
+ }
1281
+ } catch (e) {
1282
+ log.error("error while parsing actor details text", e);
1283
+ }
1284
+ }
1285
+ getActorProperty(actor, key) {
1286
+ if (actor?.properties !== void 0) {
1287
+ return actor.properties[key];
1288
+ }
1289
+ return void 0;
1290
+ }
1291
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents
1292
+ apply(param) {
1293
+ if (Array.isArray(param)) {
1294
+ param.forEach((item) => {
1295
+ this.apply(item);
1296
+ });
1297
+ } else {
1298
+ switch (param.type) {
1299
+ case "sequenceIndex":
1300
+ this.state.records.messages.push({
1301
+ id: this.state.records.messages.length.toString(),
1302
+ from: void 0,
1303
+ to: void 0,
1304
+ message: {
1305
+ start: param.sequenceIndex,
1306
+ step: param.sequenceIndexStep,
1307
+ visible: param.sequenceVisible
1308
+ },
1309
+ wrap: false,
1310
+ type: param.signalType
1311
+ });
1312
+ break;
1313
+ case "addParticipant":
1314
+ this.addActor(param.actor, param.actor, param.description, param.draw, param.config);
1315
+ break;
1316
+ case "createParticipant":
1317
+ if (this.state.records.actors.has(param.actor)) {
1318
+ throw new Error(
1319
+ "It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior"
1320
+ );
1321
+ }
1322
+ this.state.records.lastCreated = param.actor;
1323
+ this.addActor(param.actor, param.actor, param.description, param.draw, param.config);
1324
+ this.state.records.createdActors.set(param.actor, this.state.records.messages.length);
1325
+ break;
1326
+ case "destroyParticipant":
1327
+ this.state.records.lastDestroyed = param.actor;
1328
+ this.state.records.destroyedActors.set(param.actor, this.state.records.messages.length);
1329
+ break;
1330
+ case "activeStart":
1331
+ this.addSignal(param.actor, void 0, void 0, param.signalType);
1332
+ break;
1333
+ case "activeEnd":
1334
+ this.addSignal(param.actor, void 0, void 0, param.signalType);
1335
+ break;
1336
+ case "addNote":
1337
+ this.addNote(param.actor, param.placement, param.text);
1338
+ break;
1339
+ case "addLinks":
1340
+ this.addLinks(param.actor, param.text);
1341
+ break;
1342
+ case "addALink":
1343
+ this.addALink(param.actor, param.text);
1344
+ break;
1345
+ case "addProperties":
1346
+ this.addProperties(param.actor, param.text);
1347
+ break;
1348
+ case "addDetails":
1349
+ this.addDetails(param.actor, param.text);
1350
+ break;
1351
+ case "addMessage":
1352
+ if (this.state.records.lastCreated) {
1353
+ if (param.to !== this.state.records.lastCreated) {
1354
+ throw new Error(
1355
+ "The created participant " + this.state.records.lastCreated.name + " does not have an associated creating message after its declaration. Please check the sequence diagram."
1356
+ );
1357
+ } else {
1358
+ this.state.records.lastCreated = void 0;
1359
+ }
1360
+ } else if (this.state.records.lastDestroyed) {
1361
+ if (param.to !== this.state.records.lastDestroyed && param.from !== this.state.records.lastDestroyed) {
1362
+ throw new Error(
1363
+ "The destroyed participant " + this.state.records.lastDestroyed.name + " does not have an associated destroying message after its declaration. Please check the sequence diagram."
1364
+ );
1365
+ } else {
1366
+ this.state.records.lastDestroyed = void 0;
1367
+ }
1368
+ }
1369
+ this.addSignal(param.from, param.to, param.msg, param.signalType, param.activate);
1370
+ break;
1371
+ case "boxStart":
1372
+ this.addBox(param.boxData);
1373
+ break;
1374
+ case "boxEnd":
1375
+ this.boxEnd();
1376
+ break;
1377
+ case "loopStart":
1378
+ this.addSignal(void 0, void 0, param.loopText, param.signalType);
1379
+ break;
1380
+ case "loopEnd":
1381
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1382
+ break;
1383
+ case "rectStart":
1384
+ this.addSignal(void 0, void 0, param.color, param.signalType);
1385
+ break;
1386
+ case "rectEnd":
1387
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1388
+ break;
1389
+ case "optStart":
1390
+ this.addSignal(void 0, void 0, param.optText, param.signalType);
1391
+ break;
1392
+ case "optEnd":
1393
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1394
+ break;
1395
+ case "altStart":
1396
+ this.addSignal(void 0, void 0, param.altText, param.signalType);
1397
+ break;
1398
+ case "else":
1399
+ this.addSignal(void 0, void 0, param.altText, param.signalType);
1400
+ break;
1401
+ case "altEnd":
1402
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1403
+ break;
1404
+ case "setAccTitle":
1405
+ setAccTitle(param.text);
1406
+ break;
1407
+ case "parStart":
1408
+ this.addSignal(void 0, void 0, param.parText, param.signalType);
1409
+ break;
1410
+ case "and":
1411
+ this.addSignal(void 0, void 0, param.parText, param.signalType);
1412
+ break;
1413
+ case "parEnd":
1414
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1415
+ break;
1416
+ case "criticalStart":
1417
+ this.addSignal(void 0, void 0, param.criticalText, param.signalType);
1418
+ break;
1419
+ case "option":
1420
+ this.addSignal(void 0, void 0, param.optionText, param.signalType);
1421
+ break;
1422
+ case "criticalEnd":
1423
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1424
+ break;
1425
+ case "breakStart":
1426
+ this.addSignal(void 0, void 0, param.breakText, param.signalType);
1427
+ break;
1428
+ case "breakEnd":
1429
+ this.addSignal(void 0, void 0, void 0, param.signalType);
1430
+ break;
1431
+ }
1432
+ }
1433
+ }
1434
+ getConfig() {
1435
+ return getConfig2().sequence;
1436
+ }
1437
+ }, __name(_a, "SequenceDB"), _a);
1438
+ var getStyles = /* @__PURE__ */ __name((options) => `.actor {
1439
+ stroke: ${options.actorBorder};
1440
+ fill: ${options.actorBkg};
1441
+ }
1442
+
1443
+ text.actor > tspan {
1444
+ fill: ${options.actorTextColor};
1445
+ stroke: none;
1446
+ }
1447
+
1448
+ .actor-line {
1449
+ stroke: ${options.actorLineColor};
1450
+ }
1451
+
1452
+ .innerArc {
1453
+ stroke-width: 1.5;
1454
+ stroke-dasharray: none;
1455
+ }
1456
+
1457
+ .messageLine0 {
1458
+ stroke-width: 1.5;
1459
+ stroke-dasharray: none;
1460
+ stroke: ${options.signalColor};
1461
+ }
1462
+
1463
+ .messageLine1 {
1464
+ stroke-width: 1.5;
1465
+ stroke-dasharray: 2, 2;
1466
+ stroke: ${options.signalColor};
1467
+ }
1468
+
1469
+ #arrowhead path {
1470
+ fill: ${options.signalColor};
1471
+ stroke: ${options.signalColor};
1472
+ }
1473
+
1474
+ .sequenceNumber {
1475
+ fill: ${options.sequenceNumberColor};
1476
+ }
1477
+
1478
+ #sequencenumber {
1479
+ fill: ${options.signalColor};
1480
+ }
1481
+
1482
+ #crosshead path {
1483
+ fill: ${options.signalColor};
1484
+ stroke: ${options.signalColor};
1485
+ }
1486
+
1487
+ .messageText {
1488
+ fill: ${options.signalTextColor};
1489
+ stroke: none;
1490
+ }
1491
+
1492
+ .labelBox {
1493
+ stroke: ${options.labelBoxBorderColor};
1494
+ fill: ${options.labelBoxBkgColor};
1495
+ }
1496
+
1497
+ .labelText, .labelText > tspan {
1498
+ fill: ${options.labelTextColor};
1499
+ stroke: none;
1500
+ }
1501
+
1502
+ .loopText, .loopText > tspan {
1503
+ fill: ${options.loopTextColor};
1504
+ stroke: none;
1505
+ }
1506
+
1507
+ .loopLine {
1508
+ stroke-width: 2px;
1509
+ stroke-dasharray: 2, 2;
1510
+ stroke: ${options.labelBoxBorderColor};
1511
+ fill: ${options.labelBoxBorderColor};
1512
+ }
1513
+
1514
+ .note {
1515
+ //stroke: #decc93;
1516
+ stroke: ${options.noteBorderColor};
1517
+ fill: ${options.noteBkgColor};
1518
+ }
1519
+
1520
+ .noteText, .noteText > tspan {
1521
+ fill: ${options.noteTextColor};
1522
+ stroke: none;
1523
+ }
1524
+
1525
+ .activation0 {
1526
+ fill: ${options.activationBkgColor};
1527
+ stroke: ${options.activationBorderColor};
1528
+ }
1529
+
1530
+ .activation1 {
1531
+ fill: ${options.activationBkgColor};
1532
+ stroke: ${options.activationBorderColor};
1533
+ }
1534
+
1535
+ .activation2 {
1536
+ fill: ${options.activationBkgColor};
1537
+ stroke: ${options.activationBorderColor};
1538
+ }
1539
+
1540
+ .actorPopupMenu {
1541
+ position: absolute;
1542
+ }
1543
+
1544
+ .actorPopupMenuPanel {
1545
+ position: absolute;
1546
+ fill: ${options.actorBkg};
1547
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
1548
+ filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));
1549
+ }
1550
+ .actor-man line {
1551
+ stroke: ${options.actorBorder};
1552
+ fill: ${options.actorBkg};
1553
+ }
1554
+ .actor-man circle, line {
1555
+ stroke: ${options.actorBorder};
1556
+ fill: ${options.actorBkg};
1557
+ stroke-width: 2px;
1558
+ }
1559
+
1560
+ `, "getStyles");
1561
+ var styles_default = getStyles;
1562
+ var ACTOR_TYPE_WIDTH = 18 * 2;
1563
+ var TOP_ACTOR_CLASS = "actor-top";
1564
+ var BOTTOM_ACTOR_CLASS = "actor-bottom";
1565
+ var ACTOR_BOX_CLASS = "actor-box";
1566
+ var ACTOR_MAN_FIGURE_CLASS = "actor-man";
1567
+ var drawRect2 = /* @__PURE__ */ __name(function(elem, rectData) {
1568
+ return drawRect(elem, rectData);
1569
+ }, "drawRect");
1570
+ var drawPopup = /* @__PURE__ */ __name(function(elem, actor, minMenuWidth, textAttrs, forceMenus) {
1571
+ if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) {
1572
+ return { height: 0, width: 0 };
1573
+ }
1574
+ const links = actor.links;
1575
+ const actorCnt2 = actor.actorCnt;
1576
+ const rectData = actor.rectData;
1577
+ var displayValue = "none";
1578
+ if (forceMenus) {
1579
+ displayValue = "block !important";
1580
+ }
1581
+ const g = elem.append("g");
1582
+ g.attr("id", "actor" + actorCnt2 + "_popup");
1583
+ g.attr("class", "actorPopupMenu");
1584
+ g.attr("display", displayValue);
1585
+ var actorClass = "";
1586
+ if (rectData.class !== void 0) {
1587
+ actorClass = " " + rectData.class;
1588
+ }
1589
+ let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth;
1590
+ const rectElem = g.append("rect");
1591
+ rectElem.attr("class", "actorPopupMenuPanel" + actorClass);
1592
+ rectElem.attr("x", rectData.x);
1593
+ rectElem.attr("y", rectData.height);
1594
+ rectElem.attr("fill", rectData.fill);
1595
+ rectElem.attr("stroke", rectData.stroke);
1596
+ rectElem.attr("width", menuWidth);
1597
+ rectElem.attr("height", rectData.height);
1598
+ rectElem.attr("rx", rectData.rx);
1599
+ rectElem.attr("ry", rectData.ry);
1600
+ if (links != null) {
1601
+ var linkY = 20;
1602
+ for (let key in links) {
1603
+ var linkElem = g.append("a");
1604
+ var sanitizedLink = distExports.sanitizeUrl(links[key]);
1605
+ linkElem.attr("xlink:href", sanitizedLink);
1606
+ linkElem.attr("target", "_blank");
1607
+ _drawMenuItemTextCandidateFunc(textAttrs)(
1608
+ key,
1609
+ linkElem,
1610
+ rectData.x + 10,
1611
+ rectData.height + linkY,
1612
+ menuWidth,
1613
+ 20,
1614
+ { class: "actor" },
1615
+ textAttrs
1616
+ );
1617
+ linkY += 30;
1618
+ }
1619
+ }
1620
+ rectElem.attr("height", linkY);
1621
+ return { height: rectData.height + linkY, width: menuWidth };
1622
+ }, "drawPopup");
1623
+ var popupMenuToggle = /* @__PURE__ */ __name(function(popId) {
1624
+ return "var pu = document.getElementById('" + popId + "'); if (pu != null) { pu.style.display = pu.style.display == 'block' ? 'none' : 'block'; }";
1625
+ }, "popupMenuToggle");
1626
+ var drawKatex = /* @__PURE__ */ __name(async function(elem, textData, msgModel = null) {
1627
+ let textElem = elem.append("foreignObject");
1628
+ const linesSanitized = await renderKatexSanitized(textData.text, getConfig());
1629
+ const divElem = textElem.append("xhtml:div").attr("style", "width: fit-content;").attr("xmlns", "http://www.w3.org/1999/xhtml").html(linesSanitized);
1630
+ const dim = divElem.node().getBoundingClientRect();
1631
+ textElem.attr("height", Math.round(dim.height)).attr("width", Math.round(dim.width));
1632
+ if (textData.class === "noteText") {
1633
+ const rectElem = elem.node().firstChild;
1634
+ rectElem.setAttribute("height", dim.height + 2 * textData.textMargin);
1635
+ const rectDim = rectElem.getBBox();
1636
+ textElem.attr("x", Math.round(rectDim.x + rectDim.width / 2 - dim.width / 2)).attr("y", Math.round(rectDim.y + rectDim.height / 2 - dim.height / 2));
1637
+ } else if (msgModel) {
1638
+ let { startx, stopx, starty } = msgModel;
1639
+ if (startx > stopx) {
1640
+ const temp = startx;
1641
+ startx = stopx;
1642
+ stopx = temp;
1643
+ }
1644
+ textElem.attr("x", Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2));
1645
+ if (textData.class === "loopText") {
1646
+ textElem.attr("y", Math.round(starty));
1647
+ } else {
1648
+ textElem.attr("y", Math.round(starty - dim.height));
1649
+ }
1650
+ }
1651
+ return [textElem];
1652
+ }, "drawKatex");
1653
+ var drawText = /* @__PURE__ */ __name(function(elem, textData) {
1654
+ let prevTextHeight = 0;
1655
+ let textHeight = 0;
1656
+ const lines = textData.text.split(common_default.lineBreakRegex);
1657
+ const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize);
1658
+ let textElems = [];
1659
+ let dy = 0;
1660
+ let yfunc = /* @__PURE__ */ __name(() => textData.y, "yfunc");
1661
+ if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1662
+ switch (textData.valign) {
1663
+ case "top":
1664
+ case "start":
1665
+ yfunc = /* @__PURE__ */ __name(() => Math.round(textData.y + textData.textMargin), "yfunc");
1666
+ break;
1667
+ case "middle":
1668
+ case "center":
1669
+ yfunc = /* @__PURE__ */ __name(() => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2), "yfunc");
1670
+ break;
1671
+ case "bottom":
1672
+ case "end":
1673
+ yfunc = /* @__PURE__ */ __name(() => Math.round(
1674
+ textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin
1675
+ ), "yfunc");
1676
+ break;
1677
+ }
1678
+ }
1679
+ if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) {
1680
+ switch (textData.anchor) {
1681
+ case "left":
1682
+ case "start":
1683
+ textData.x = Math.round(textData.x + textData.textMargin);
1684
+ textData.anchor = "start";
1685
+ textData.dominantBaseline = "middle";
1686
+ textData.alignmentBaseline = "middle";
1687
+ break;
1688
+ case "middle":
1689
+ case "center":
1690
+ textData.x = Math.round(textData.x + textData.width / 2);
1691
+ textData.anchor = "middle";
1692
+ textData.dominantBaseline = "middle";
1693
+ textData.alignmentBaseline = "middle";
1694
+ break;
1695
+ case "right":
1696
+ case "end":
1697
+ textData.x = Math.round(textData.x + textData.width - textData.textMargin);
1698
+ textData.anchor = "end";
1699
+ textData.dominantBaseline = "middle";
1700
+ textData.alignmentBaseline = "middle";
1701
+ break;
1702
+ }
1703
+ }
1704
+ for (let [i, line] of lines.entries()) {
1705
+ if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) {
1706
+ dy = i * _textFontSize;
1707
+ }
1708
+ const textElem = elem.append("text");
1709
+ textElem.attr("x", textData.x);
1710
+ textElem.attr("y", yfunc());
1711
+ if (textData.anchor !== void 0) {
1712
+ textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline);
1713
+ }
1714
+ if (textData.fontFamily !== void 0) {
1715
+ textElem.style("font-family", textData.fontFamily);
1716
+ }
1717
+ if (_textFontSizePx !== void 0) {
1718
+ textElem.style("font-size", _textFontSizePx);
1719
+ }
1720
+ if (textData.fontWeight !== void 0) {
1721
+ textElem.style("font-weight", textData.fontWeight);
1722
+ }
1723
+ if (textData.fill !== void 0) {
1724
+ textElem.attr("fill", textData.fill);
1725
+ }
1726
+ if (textData.class !== void 0) {
1727
+ textElem.attr("class", textData.class);
1728
+ }
1729
+ if (textData.dy !== void 0) {
1730
+ textElem.attr("dy", textData.dy);
1731
+ } else if (dy !== 0) {
1732
+ textElem.attr("dy", dy);
1733
+ }
1734
+ const text = line || ZERO_WIDTH_SPACE;
1735
+ if (textData.tspan) {
1736
+ const span = textElem.append("tspan");
1737
+ span.attr("x", textData.x);
1738
+ if (textData.fill !== void 0) {
1739
+ span.attr("fill", textData.fill);
1740
+ }
1741
+ span.text(text);
1742
+ } else {
1743
+ textElem.text(text);
1744
+ }
1745
+ if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1746
+ textHeight += (textElem._groups || textElem)[0][0].getBBox().height;
1747
+ prevTextHeight = textHeight;
1748
+ }
1749
+ textElems.push(textElem);
1750
+ }
1751
+ return textElems;
1752
+ }, "drawText");
1753
+ var drawLabel = /* @__PURE__ */ __name(function(elem, txtObject) {
1754
+ function genPoints(x, y, width, height, cut) {
1755
+ return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
1756
+ }
1757
+ __name(genPoints, "genPoints");
1758
+ const polygon = elem.append("polygon");
1759
+ polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7));
1760
+ polygon.attr("class", "labelBox");
1761
+ txtObject.y = txtObject.y + txtObject.height / 2;
1762
+ drawText(elem, txtObject);
1763
+ return polygon;
1764
+ }, "drawLabel");
1765
+ var actorCnt = -1;
1766
+ var fixLifeLineHeights = /* @__PURE__ */ __name((diagram2, actors, actorKeys, conf2) => {
1767
+ if (!diagram2.select) {
1768
+ return;
1769
+ }
1770
+ actorKeys.forEach((actorKey) => {
1771
+ const actor = actors.get(actorKey);
1772
+ const actorDOM = diagram2.select("#actor" + actor.actorCnt);
1773
+ if (!conf2.mirrorActors && actor.stopy) {
1774
+ actorDOM.attr("y2", actor.stopy + actor.height / 2);
1775
+ } else if (conf2.mirrorActors) {
1776
+ actorDOM.attr("y2", actor.stopy);
1777
+ }
1778
+ });
1779
+ }, "fixLifeLineHeights");
1780
+ var drawActorTypeParticipant = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
1781
+ const actorY = isFooter ? actor.stopy : actor.starty;
1782
+ const center = actor.x + actor.width / 2;
1783
+ const centerY = actorY + actor.height;
1784
+ const boxplusLineGroup = elem.append("g").lower();
1785
+ var g = boxplusLineGroup;
1786
+ if (!isFooter) {
1787
+ actorCnt++;
1788
+ if (Object.keys(actor.links || {}).length && !conf2.forceMenus) {
1789
+ g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer");
1790
+ }
1791
+ g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
1792
+ g = boxplusLineGroup.append("g");
1793
+ actor.actorCnt = actorCnt;
1794
+ if (actor.links != null) {
1795
+ g.attr("id", "root-" + actorCnt);
1796
+ }
1797
+ }
1798
+ const rect = getNoteRect();
1799
+ var cssclass = "actor";
1800
+ if (actor.properties?.class) {
1801
+ cssclass = actor.properties.class;
1802
+ } else {
1803
+ rect.fill = "#eaeaea";
1804
+ }
1805
+ if (isFooter) {
1806
+ cssclass += ` ${BOTTOM_ACTOR_CLASS}`;
1807
+ } else {
1808
+ cssclass += ` ${TOP_ACTOR_CLASS}`;
1809
+ }
1810
+ rect.x = actor.x;
1811
+ rect.y = actorY;
1812
+ rect.width = actor.width;
1813
+ rect.height = actor.height;
1814
+ rect.class = cssclass;
1815
+ rect.rx = 3;
1816
+ rect.ry = 3;
1817
+ rect.name = actor.name;
1818
+ const rectElem = drawRect2(g, rect);
1819
+ actor.rectData = rect;
1820
+ if (actor.properties?.icon) {
1821
+ const iconSrc = actor.properties.icon.trim();
1822
+ if (iconSrc.charAt(0) === "@") {
1823
+ drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1));
1824
+ } else {
1825
+ drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc);
1826
+ }
1827
+ }
1828
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
1829
+ actor.description,
1830
+ g,
1831
+ rect.x,
1832
+ rect.y,
1833
+ rect.width,
1834
+ rect.height,
1835
+ { class: `actor ${ACTOR_BOX_CLASS}` },
1836
+ conf2
1837
+ );
1838
+ let height = actor.height;
1839
+ if (rectElem.node) {
1840
+ const bounds2 = rectElem.node().getBBox();
1841
+ actor.height = bounds2.height;
1842
+ height = bounds2.height;
1843
+ }
1844
+ return height;
1845
+ }, "drawActorTypeParticipant");
1846
+ var drawActorTypeCollections = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
1847
+ const actorY = isFooter ? actor.stopy : actor.starty;
1848
+ const center = actor.x + actor.width / 2;
1849
+ const centerY = actorY + actor.height;
1850
+ const boxplusLineGroup = elem.append("g").lower();
1851
+ var g = boxplusLineGroup;
1852
+ if (!isFooter) {
1853
+ actorCnt++;
1854
+ if (Object.keys(actor.links || {}).length && !conf2.forceMenus) {
1855
+ g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer");
1856
+ }
1857
+ g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
1858
+ g = boxplusLineGroup.append("g");
1859
+ actor.actorCnt = actorCnt;
1860
+ if (actor.links != null) {
1861
+ g.attr("id", "root-" + actorCnt);
1862
+ }
1863
+ }
1864
+ const rect = getNoteRect();
1865
+ var cssclass = "actor";
1866
+ if (actor.properties?.class) {
1867
+ cssclass = actor.properties.class;
1868
+ } else {
1869
+ rect.fill = "#eaeaea";
1870
+ }
1871
+ if (isFooter) {
1872
+ cssclass += ` ${BOTTOM_ACTOR_CLASS}`;
1873
+ } else {
1874
+ cssclass += ` ${TOP_ACTOR_CLASS}`;
1875
+ }
1876
+ rect.x = actor.x;
1877
+ rect.y = actorY;
1878
+ rect.width = actor.width;
1879
+ rect.height = actor.height;
1880
+ rect.class = cssclass;
1881
+ rect.name = actor.name;
1882
+ const offset = 6;
1883
+ const shadowRect = {
1884
+ ...rect,
1885
+ x: rect.x + (isFooter ? -offset : -offset),
1886
+ y: rect.y + (isFooter ? +offset : +offset),
1887
+ class: "actor"
1888
+ };
1889
+ const rectElem = drawRect2(g, rect);
1890
+ drawRect2(g, shadowRect);
1891
+ actor.rectData = rect;
1892
+ if (actor.properties?.icon) {
1893
+ const iconSrc = actor.properties.icon.trim();
1894
+ if (iconSrc.charAt(0) === "@") {
1895
+ drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1));
1896
+ } else {
1897
+ drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc);
1898
+ }
1899
+ }
1900
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
1901
+ actor.description,
1902
+ g,
1903
+ rect.x - offset,
1904
+ rect.y + offset,
1905
+ rect.width,
1906
+ rect.height,
1907
+ { class: `actor ${ACTOR_BOX_CLASS}` },
1908
+ conf2
1909
+ );
1910
+ let height = actor.height;
1911
+ if (rectElem.node) {
1912
+ const bounds2 = rectElem.node().getBBox();
1913
+ actor.height = bounds2.height;
1914
+ height = bounds2.height;
1915
+ }
1916
+ return height;
1917
+ }, "drawActorTypeCollections");
1918
+ var drawActorTypeQueue = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
1919
+ const actorY = isFooter ? actor.stopy : actor.starty;
1920
+ const center = actor.x + actor.width / 2;
1921
+ const centerY = actorY + actor.height;
1922
+ const boxplusLineGroup = elem.append("g").lower();
1923
+ let g = boxplusLineGroup;
1924
+ if (!isFooter) {
1925
+ actorCnt++;
1926
+ if (Object.keys(actor.links || {}).length && !conf2.forceMenus) {
1927
+ g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer");
1928
+ }
1929
+ g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
1930
+ g = boxplusLineGroup.append("g");
1931
+ actor.actorCnt = actorCnt;
1932
+ if (actor.links != null) {
1933
+ g.attr("id", "root-" + actorCnt);
1934
+ }
1935
+ }
1936
+ const rect = getNoteRect();
1937
+ let cssclass = "actor";
1938
+ if (actor.properties?.class) {
1939
+ cssclass = actor.properties.class;
1940
+ } else {
1941
+ rect.fill = "#eaeaea";
1942
+ }
1943
+ if (isFooter) {
1944
+ cssclass += ` ${BOTTOM_ACTOR_CLASS}`;
1945
+ } else {
1946
+ cssclass += ` ${TOP_ACTOR_CLASS}`;
1947
+ }
1948
+ rect.x = actor.x;
1949
+ rect.y = actorY;
1950
+ rect.width = actor.width;
1951
+ rect.height = actor.height;
1952
+ rect.class = cssclass;
1953
+ rect.name = actor.name;
1954
+ const ry = rect.height / 2;
1955
+ const rx = ry / (2.5 + rect.height / 50);
1956
+ const cylinderGroup = g.append("g");
1957
+ const cylinderArc = g.append("g");
1958
+ cylinderGroup.append("path").attr(
1959
+ "d",
1960
+ `M ${rect.x},${rect.y + ry}
1961
+ a ${rx},${ry} 0 0 0 0,${rect.height}
1962
+ h ${rect.width - 2 * rx}
1963
+ a ${rx},${ry} 0 0 0 0,-${rect.height}
1964
+ Z
1965
+ `
1966
+ ).attr("class", cssclass);
1967
+ cylinderArc.append("path").attr(
1968
+ "d",
1969
+ `M ${rect.x},${rect.y + ry}
1970
+ a ${rx},${ry} 0 0 0 0,${rect.height}`
1971
+ ).attr("stroke", "#666").attr("stroke-width", "1px").attr("class", cssclass);
1972
+ cylinderGroup.attr("transform", `translate(${rx}, ${-(rect.height / 2)})`);
1973
+ cylinderArc.attr("transform", `translate(${rect.width - rx}, ${-rect.height / 2})`);
1974
+ actor.rectData = rect;
1975
+ if (actor.properties?.icon) {
1976
+ const iconSrc = actor.properties.icon.trim();
1977
+ const iconX = rect.x + rect.width - 20;
1978
+ const iconY = rect.y + 10;
1979
+ if (iconSrc.charAt(0) === "@") {
1980
+ drawEmbeddedImage(g, iconX, iconY, iconSrc.substr(1));
1981
+ } else {
1982
+ drawImage(g, iconX, iconY, iconSrc);
1983
+ }
1984
+ }
1985
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
1986
+ actor.description,
1987
+ g,
1988
+ rect.x,
1989
+ rect.y,
1990
+ rect.width,
1991
+ rect.height,
1992
+ { class: `actor ${ACTOR_BOX_CLASS}` },
1993
+ conf2
1994
+ );
1995
+ let height = actor.height;
1996
+ const lastPath = cylinderGroup.select("path:last-child");
1997
+ if (lastPath.node()) {
1998
+ const bounds2 = lastPath.node().getBBox();
1999
+ actor.height = bounds2.height;
2000
+ height = bounds2.height;
2001
+ }
2002
+ return height;
2003
+ }, "drawActorTypeQueue");
2004
+ var drawActorTypeControl = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
2005
+ const actorY = isFooter ? actor.stopy : actor.starty;
2006
+ const center = actor.x + actor.width / 2;
2007
+ const centerY = actorY + 75;
2008
+ const line = elem.append("g").lower();
2009
+ if (!isFooter) {
2010
+ actorCnt++;
2011
+ line.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
2012
+ actor.actorCnt = actorCnt;
2013
+ }
2014
+ const actElem = elem.append("g");
2015
+ let cssClass = ACTOR_MAN_FIGURE_CLASS;
2016
+ if (isFooter) {
2017
+ cssClass += ` ${BOTTOM_ACTOR_CLASS}`;
2018
+ } else {
2019
+ cssClass += ` ${TOP_ACTOR_CLASS}`;
2020
+ }
2021
+ actElem.attr("class", cssClass);
2022
+ actElem.attr("name", actor.name);
2023
+ const rect = getNoteRect();
2024
+ rect.x = actor.x;
2025
+ rect.y = actorY;
2026
+ rect.fill = "#eaeaea";
2027
+ rect.width = actor.width;
2028
+ rect.height = actor.height;
2029
+ rect.class = "actor";
2030
+ const cx = actor.x + actor.width / 2;
2031
+ const cy = actorY + 30;
2032
+ const r = 18;
2033
+ actElem.append("defs").append("marker").attr("id", "filled-head-control").attr("refX", 11).attr("refY", 5.8).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "172.5").append("path").attr("d", "M 14.4 5.6 L 7.2 10.4 L 8.8 5.6 L 7.2 0.8 Z");
2034
+ actElem.append("circle").attr("cx", cx).attr("cy", cy).attr("r", r).attr("fill", "#eaeaf7").attr("stroke", "#666").attr("stroke-width", 1.2);
2035
+ actElem.append("line").attr("marker-end", "url(#filled-head-control)").attr("transform", `translate(${cx}, ${cy - r})`);
2036
+ const bounds2 = actElem.node().getBBox();
2037
+ actor.height = bounds2.height + 2 * (conf2?.sequence?.labelBoxHeight ?? 0);
2038
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
2039
+ actor.description,
2040
+ actElem,
2041
+ rect.x,
2042
+ rect.y + r + (isFooter ? 5 : 10),
2043
+ rect.width,
2044
+ rect.height,
2045
+ { class: `actor ${ACTOR_MAN_FIGURE_CLASS}` },
2046
+ conf2
2047
+ );
2048
+ return actor.height;
2049
+ }, "drawActorTypeControl");
2050
+ var drawActorTypeEntity = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
2051
+ const actorY = isFooter ? actor.stopy : actor.starty;
2052
+ const center = actor.x + actor.width / 2;
2053
+ const centerY = actorY + 75;
2054
+ const line = elem.append("g").lower();
2055
+ const actElem = elem.append("g");
2056
+ let cssClass = ACTOR_MAN_FIGURE_CLASS;
2057
+ if (isFooter) {
2058
+ cssClass += ` ${BOTTOM_ACTOR_CLASS}`;
2059
+ } else {
2060
+ cssClass += ` ${TOP_ACTOR_CLASS}`;
2061
+ }
2062
+ actElem.attr("class", cssClass);
2063
+ actElem.attr("name", actor.name);
2064
+ const rect = getNoteRect();
2065
+ rect.x = actor.x;
2066
+ rect.y = actorY;
2067
+ rect.fill = "#eaeaea";
2068
+ rect.width = actor.width;
2069
+ rect.height = actor.height;
2070
+ rect.class = "actor";
2071
+ const cx = actor.x + actor.width / 2;
2072
+ const cy = actorY + (!isFooter ? 25 : 10);
2073
+ const r = 18;
2074
+ actElem.append("circle").attr("cx", cx).attr("cy", cy).attr("r", r).attr("width", actor.width).attr("height", actor.height);
2075
+ actElem.append("line").attr("x1", cx - r).attr("x2", cx + r).attr("y1", cy + r).attr("y2", cy + r).attr("stroke", "#333").attr("stroke-width", 2);
2076
+ const bounds2 = actElem.node().getBBox();
2077
+ actor.height = bounds2.height + (conf2?.sequence?.labelBoxHeight ?? 0);
2078
+ if (!isFooter) {
2079
+ actorCnt++;
2080
+ line.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
2081
+ actor.actorCnt = actorCnt;
2082
+ }
2083
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
2084
+ actor.description,
2085
+ actElem,
2086
+ rect.x,
2087
+ rect.y + (!isFooter ? (cy + r - actorY) / 2 : (cy - actorY + r - 5) / 2),
2088
+ rect.width,
2089
+ rect.height,
2090
+ { class: `actor ${ACTOR_MAN_FIGURE_CLASS}` },
2091
+ conf2
2092
+ );
2093
+ if (!isFooter) {
2094
+ actElem.attr("transform", `translate(${0}, ${r / 2})`);
2095
+ } else {
2096
+ actElem.attr("transform", `translate(${0}, ${r / 2})`);
2097
+ }
2098
+ return actor.height;
2099
+ }, "drawActorTypeEntity");
2100
+ var drawActorTypeDatabase = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
2101
+ const actorY = isFooter ? actor.stopy : actor.starty;
2102
+ const center = actor.x + actor.width / 2;
2103
+ const centerY = actorY + actor.height + 2 * conf2.boxTextMargin;
2104
+ const boxplusLineGroup = elem.append("g").lower();
2105
+ let g = boxplusLineGroup;
2106
+ if (!isFooter) {
2107
+ actorCnt++;
2108
+ if (Object.keys(actor.links || {}).length && !conf2.forceMenus) {
2109
+ g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer");
2110
+ }
2111
+ g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
2112
+ g = boxplusLineGroup.append("g");
2113
+ actor.actorCnt = actorCnt;
2114
+ if (actor.links != null) {
2115
+ g.attr("id", "root-" + actorCnt);
2116
+ }
2117
+ }
2118
+ const rect = getNoteRect();
2119
+ let cssclass = "actor";
2120
+ if (actor.properties?.class) {
2121
+ cssclass = actor.properties.class;
2122
+ } else {
2123
+ rect.fill = "#eaeaea";
2124
+ }
2125
+ if (isFooter) {
2126
+ cssclass += ` ${BOTTOM_ACTOR_CLASS}`;
2127
+ } else {
2128
+ cssclass += ` ${TOP_ACTOR_CLASS}`;
2129
+ }
2130
+ rect.x = actor.x;
2131
+ rect.y = actorY;
2132
+ rect.width = actor.width;
2133
+ rect.height = actor.height;
2134
+ rect.class = cssclass;
2135
+ rect.name = actor.name;
2136
+ rect.x = actor.x;
2137
+ rect.y = actorY;
2138
+ const w = rect.width / 4;
2139
+ const h = rect.width / 4;
2140
+ const rx = w / 2;
2141
+ const ry = rx / (2.5 + w / 50);
2142
+ const cylinderGroup = g.append("g");
2143
+ const d = `
2144
+ M ${rect.x},${rect.y + ry}
2145
+ a ${rx},${ry} 0 0 0 ${w},0
2146
+ a ${rx},${ry} 0 0 0 -${w},0
2147
+ l 0,${h - 2 * ry}
2148
+ a ${rx},${ry} 0 0 0 ${w},0
2149
+ l 0,-${h - 2 * ry}
2150
+ `;
2151
+ cylinderGroup.append("path").attr("d", d).attr("fill", "#eaeaea").attr("stroke", "#000").attr("stroke-width", 1).attr("class", cssclass);
2152
+ if (!isFooter) {
2153
+ cylinderGroup.attr("transform", `translate(${w * 1.5}, ${(rect.height + ry) / 4})`);
2154
+ } else {
2155
+ cylinderGroup.attr("transform", `translate(${w * 1.5}, ${rect.height / 4 - 2 * ry})`);
2156
+ }
2157
+ actor.rectData = rect;
2158
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
2159
+ actor.description,
2160
+ g,
2161
+ rect.x,
2162
+ rect.y + (!isFooter ? (rect.height + ry) / 2 : (rect.height + h) / 4),
2163
+ rect.width,
2164
+ rect.height,
2165
+ { class: `actor ${ACTOR_BOX_CLASS}` },
2166
+ conf2
2167
+ );
2168
+ const lastPath = cylinderGroup.select("path:last-child");
2169
+ if (lastPath.node()) {
2170
+ const bounds2 = lastPath.node().getBBox();
2171
+ actor.height = bounds2.height + (conf2.sequence.labelBoxHeight ?? 0);
2172
+ }
2173
+ return actor.height;
2174
+ }, "drawActorTypeDatabase");
2175
+ var drawActorTypeBoundary = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
2176
+ const actorY = isFooter ? actor.stopy : actor.starty;
2177
+ const center = actor.x + actor.width / 2;
2178
+ const centerY = actorY + 80;
2179
+ const radius = 30;
2180
+ const line = elem.append("g").lower();
2181
+ if (!isFooter) {
2182
+ actorCnt++;
2183
+ line.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
2184
+ actor.actorCnt = actorCnt;
2185
+ }
2186
+ const actElem = elem.append("g");
2187
+ let cssClass = ACTOR_MAN_FIGURE_CLASS;
2188
+ if (isFooter) {
2189
+ cssClass += ` ${BOTTOM_ACTOR_CLASS}`;
2190
+ } else {
2191
+ cssClass += ` ${TOP_ACTOR_CLASS}`;
2192
+ }
2193
+ actElem.attr("class", cssClass);
2194
+ actElem.attr("name", actor.name);
2195
+ const rect = getNoteRect();
2196
+ rect.x = actor.x;
2197
+ rect.y = actorY;
2198
+ rect.fill = "#eaeaea";
2199
+ rect.width = actor.width;
2200
+ rect.height = actor.height;
2201
+ rect.class = "actor";
2202
+ actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", actor.x + actor.width / 2 - radius * 2.5).attr("y1", actorY + 10).attr("x2", actor.x + actor.width / 2 - 15).attr("y2", actorY + 10);
2203
+ actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", actor.x + actor.width / 2 - radius * 2.5).attr("y1", actorY + 0).attr("x2", actor.x + actor.width / 2 - radius * 2.5).attr("y2", actorY + 20);
2204
+ actElem.append("circle").attr("cx", actor.x + actor.width / 2).attr("cy", actorY + 10).attr("r", radius);
2205
+ const bounds2 = actElem.node().getBBox();
2206
+ actor.height = bounds2.height + (conf2.sequence.labelBoxHeight ?? 0);
2207
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
2208
+ actor.description,
2209
+ actElem,
2210
+ rect.x,
2211
+ rect.y + (!isFooter ? radius / 2 + 3 : radius / 2 - 4),
2212
+ rect.width,
2213
+ rect.height,
2214
+ { class: `actor ${ACTOR_MAN_FIGURE_CLASS}` },
2215
+ conf2
2216
+ );
2217
+ if (!isFooter) {
2218
+ actElem.attr("transform", `translate(0,${radius / 2 + 7})`);
2219
+ } else {
2220
+ actElem.attr("transform", `translate(0,${radius / 2 + 7})`);
2221
+ }
2222
+ return actor.height;
2223
+ }, "drawActorTypeBoundary");
2224
+ var drawActorTypeActor = /* @__PURE__ */ __name(function(elem, actor, conf2, isFooter) {
2225
+ const actorY = isFooter ? actor.stopy : actor.starty;
2226
+ const center = actor.x + actor.width / 2;
2227
+ const centerY = actorY + 80;
2228
+ const line = elem.append("g").lower();
2229
+ if (!isFooter) {
2230
+ actorCnt++;
2231
+ line.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line 200").attr("stroke-width", "0.5px").attr("stroke", "#999").attr("name", actor.name);
2232
+ actor.actorCnt = actorCnt;
2233
+ }
2234
+ const actElem = elem.append("g");
2235
+ let cssClass = ACTOR_MAN_FIGURE_CLASS;
2236
+ if (isFooter) {
2237
+ cssClass += ` ${BOTTOM_ACTOR_CLASS}`;
2238
+ } else {
2239
+ cssClass += ` ${TOP_ACTOR_CLASS}`;
2240
+ }
2241
+ actElem.attr("class", cssClass);
2242
+ actElem.attr("name", actor.name);
2243
+ const rect = getNoteRect();
2244
+ rect.x = actor.x;
2245
+ rect.y = actorY;
2246
+ rect.fill = "#eaeaea";
2247
+ rect.width = actor.width;
2248
+ rect.height = actor.height;
2249
+ rect.class = "actor";
2250
+ rect.rx = 3;
2251
+ rect.ry = 3;
2252
+ actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actorY + 25).attr("x2", center).attr("y2", actorY + 45);
2253
+ actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 33).attr("x2", center + ACTOR_TYPE_WIDTH / 2).attr("y2", actorY + 33);
2254
+ actElem.append("line").attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 60).attr("x2", center).attr("y2", actorY + 45);
2255
+ actElem.append("line").attr("x1", center).attr("y1", actorY + 45).attr("x2", center + ACTOR_TYPE_WIDTH / 2 - 2).attr("y2", actorY + 60);
2256
+ const circle = actElem.append("circle");
2257
+ circle.attr("cx", actor.x + actor.width / 2);
2258
+ circle.attr("cy", actorY + 10);
2259
+ circle.attr("r", 15);
2260
+ circle.attr("width", actor.width);
2261
+ circle.attr("height", actor.height);
2262
+ const bounds2 = actElem.node().getBBox();
2263
+ actor.height = bounds2.height;
2264
+ _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
2265
+ actor.description,
2266
+ actElem,
2267
+ rect.x,
2268
+ rect.y + 35,
2269
+ rect.width,
2270
+ rect.height,
2271
+ { class: `actor ${ACTOR_MAN_FIGURE_CLASS}` },
2272
+ conf2
2273
+ );
2274
+ return actor.height;
2275
+ }, "drawActorTypeActor");
2276
+ var drawActor = /* @__PURE__ */ __name(async function(elem, actor, conf2, isFooter) {
2277
+ switch (actor.type) {
2278
+ case "actor":
2279
+ return await drawActorTypeActor(elem, actor, conf2, isFooter);
2280
+ case "participant":
2281
+ return await drawActorTypeParticipant(elem, actor, conf2, isFooter);
2282
+ case "boundary":
2283
+ return await drawActorTypeBoundary(elem, actor, conf2, isFooter);
2284
+ case "control":
2285
+ return await drawActorTypeControl(elem, actor, conf2, isFooter);
2286
+ case "entity":
2287
+ return await drawActorTypeEntity(elem, actor, conf2, isFooter);
2288
+ case "database":
2289
+ return await drawActorTypeDatabase(elem, actor, conf2, isFooter);
2290
+ case "collections":
2291
+ return await drawActorTypeCollections(elem, actor, conf2, isFooter);
2292
+ case "queue":
2293
+ return await drawActorTypeQueue(elem, actor, conf2, isFooter);
2294
+ }
2295
+ }, "drawActor");
2296
+ var drawBox = /* @__PURE__ */ __name(function(elem, box, conf2) {
2297
+ const boxplusTextGroup = elem.append("g");
2298
+ const g = boxplusTextGroup;
2299
+ drawBackgroundRect2(g, box);
2300
+ if (box.name) {
2301
+ _drawTextCandidateFunc(conf2)(
2302
+ box.name,
2303
+ g,
2304
+ box.x,
2305
+ box.y + conf2.boxTextMargin + (box.textMaxHeight || 0) / 2,
2306
+ box.width,
2307
+ 0,
2308
+ { class: "text" },
2309
+ conf2
2310
+ );
2311
+ }
2312
+ g.lower();
2313
+ }, "drawBox");
2314
+ var anchorElement = /* @__PURE__ */ __name(function(elem) {
2315
+ return elem.append("g");
2316
+ }, "anchorElement");
2317
+ var drawActivation = /* @__PURE__ */ __name(function(elem, bounds2, verticalPos, conf2, actorActivations2) {
2318
+ const rect = getNoteRect();
2319
+ const g = bounds2.anchored;
2320
+ rect.x = bounds2.startx;
2321
+ rect.y = bounds2.starty;
2322
+ rect.class = "activation" + actorActivations2 % 3;
2323
+ rect.width = bounds2.stopx - bounds2.startx;
2324
+ rect.height = verticalPos - bounds2.starty;
2325
+ drawRect2(g, rect);
2326
+ }, "drawActivation");
2327
+ var drawLoop = /* @__PURE__ */ __name(async function(elem, loopModel, labelText, conf2) {
2328
+ const {
2329
+ boxMargin,
2330
+ boxTextMargin,
2331
+ labelBoxHeight,
2332
+ labelBoxWidth,
2333
+ messageFontFamily: fontFamily,
2334
+ messageFontSize: fontSize,
2335
+ messageFontWeight: fontWeight
2336
+ } = conf2;
2337
+ const g = elem.append("g");
2338
+ const drawLoopLine = /* @__PURE__ */ __name(function(startx, starty, stopx, stopy) {
2339
+ return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine");
2340
+ }, "drawLoopLine");
2341
+ drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty);
2342
+ drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy);
2343
+ drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy);
2344
+ drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy);
2345
+ if (loopModel.sections !== void 0) {
2346
+ loopModel.sections.forEach(function(item) {
2347
+ drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style(
2348
+ "stroke-dasharray",
2349
+ "3, 3"
2350
+ );
2351
+ });
2352
+ }
2353
+ let txt = getTextObj();
2354
+ txt.text = labelText;
2355
+ txt.x = loopModel.startx;
2356
+ txt.y = loopModel.starty;
2357
+ txt.fontFamily = fontFamily;
2358
+ txt.fontSize = fontSize;
2359
+ txt.fontWeight = fontWeight;
2360
+ txt.anchor = "middle";
2361
+ txt.valign = "middle";
2362
+ txt.tspan = false;
2363
+ txt.width = labelBoxWidth || 50;
2364
+ txt.height = labelBoxHeight || 20;
2365
+ txt.textMargin = boxTextMargin;
2366
+ txt.class = "labelText";
2367
+ drawLabel(g, txt);
2368
+ txt = getTextObj2();
2369
+ txt.text = loopModel.title;
2370
+ txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2;
2371
+ txt.y = loopModel.starty + boxMargin + boxTextMargin;
2372
+ txt.anchor = "middle";
2373
+ txt.valign = "middle";
2374
+ txt.textMargin = boxTextMargin;
2375
+ txt.class = "loopText";
2376
+ txt.fontFamily = fontFamily;
2377
+ txt.fontSize = fontSize;
2378
+ txt.fontWeight = fontWeight;
2379
+ txt.wrap = true;
2380
+ let textElem = hasKatex(txt.text) ? await drawKatex(g, txt, loopModel) : drawText(g, txt);
2381
+ if (loopModel.sectionTitles !== void 0) {
2382
+ for (const [idx, item] of Object.entries(loopModel.sectionTitles)) {
2383
+ if (item.message) {
2384
+ txt.text = item.message;
2385
+ txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2;
2386
+ txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin;
2387
+ txt.class = "loopText";
2388
+ txt.anchor = "middle";
2389
+ txt.valign = "middle";
2390
+ txt.tspan = false;
2391
+ txt.fontFamily = fontFamily;
2392
+ txt.fontSize = fontSize;
2393
+ txt.fontWeight = fontWeight;
2394
+ txt.wrap = loopModel.wrap;
2395
+ if (hasKatex(txt.text)) {
2396
+ loopModel.starty = loopModel.sections[idx].y;
2397
+ await drawKatex(g, txt, loopModel);
2398
+ } else {
2399
+ drawText(g, txt);
2400
+ }
2401
+ let sectionHeight = Math.round(
2402
+ textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
2403
+ );
2404
+ loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin);
2405
+ }
2406
+ }
2407
+ }
2408
+ loopModel.height = Math.round(loopModel.stopy - loopModel.starty);
2409
+ return g;
2410
+ }, "drawLoop");
2411
+ var drawBackgroundRect2 = /* @__PURE__ */ __name(function(elem, bounds2) {
2412
+ drawBackgroundRect(elem, bounds2);
2413
+ }, "drawBackgroundRect");
2414
+ var insertDatabaseIcon = /* @__PURE__ */ __name(function(elem) {
2415
+ elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr(
2416
+ "d",
2417
+ "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z"
2418
+ );
2419
+ }, "insertDatabaseIcon");
2420
+ var insertComputerIcon = /* @__PURE__ */ __name(function(elem) {
2421
+ elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
2422
+ "d",
2423
+ "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z"
2424
+ );
2425
+ }, "insertComputerIcon");
2426
+ var insertClockIcon = /* @__PURE__ */ __name(function(elem) {
2427
+ elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
2428
+ "d",
2429
+ "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z"
2430
+ );
2431
+ }, "insertClockIcon");
2432
+ var insertArrowHead = /* @__PURE__ */ __name(function(elem) {
2433
+ elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 7.9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto-start-reverse").append("path").attr("d", "M -1 0 L 10 5 L 0 10 z");
2434
+ }, "insertArrowHead");
2435
+ var insertArrowFilledHead = /* @__PURE__ */ __name(function(elem) {
2436
+ elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 15.5).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z");
2437
+ }, "insertArrowFilledHead");
2438
+ var insertSequenceNumber = /* @__PURE__ */ __name(function(elem) {
2439
+ elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6);
2440
+ }, "insertSequenceNumber");
2441
+ var insertArrowCrossHead = /* @__PURE__ */ __name(function(elem) {
2442
+ const defs = elem.append("defs");
2443
+ const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 4.5);
2444
+ marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1pt").attr("d", "M 1,2 L 6,7 M 6,2 L 1,7");
2445
+ }, "insertArrowCrossHead");
2446
+ var getTextObj2 = /* @__PURE__ */ __name(function() {
2447
+ return {
2448
+ x: 0,
2449
+ y: 0,
2450
+ fill: void 0,
2451
+ anchor: void 0,
2452
+ style: "#666",
2453
+ width: void 0,
2454
+ height: void 0,
2455
+ textMargin: 0,
2456
+ rx: 0,
2457
+ ry: 0,
2458
+ tspan: true,
2459
+ valign: void 0
2460
+ };
2461
+ }, "getTextObj");
2462
+ var getNoteRect2 = /* @__PURE__ */ __name(function() {
2463
+ return {
2464
+ x: 0,
2465
+ y: 0,
2466
+ fill: "#EDF2AE",
2467
+ stroke: "#666",
2468
+ width: 100,
2469
+ anchor: "start",
2470
+ height: 100,
2471
+ rx: 0,
2472
+ ry: 0
2473
+ };
2474
+ }, "getNoteRect");
2475
+ var _drawTextCandidateFunc = /* @__PURE__ */ (function() {
2476
+ function byText(content, g, x, y, width, height, textAttrs) {
2477
+ const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content);
2478
+ _setTextAttrs(text, textAttrs);
2479
+ }
2480
+ __name(byText, "byText");
2481
+ function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
2482
+ const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
2483
+ const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize);
2484
+ const lines = content.split(common_default.lineBreakRegex);
2485
+ for (let i = 0; i < lines.length; i++) {
2486
+ const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2;
2487
+ const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").style("font-size", _actorFontSizePx).style("font-weight", actorFontWeight).style("font-family", actorFontFamily);
2488
+ text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
2489
+ text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
2490
+ _setTextAttrs(text, textAttrs);
2491
+ }
2492
+ }
2493
+ __name(byTspan, "byTspan");
2494
+ function byFo(content, g, x, y, width, height, textAttrs, conf2) {
2495
+ const s = g.append("switch");
2496
+ const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
2497
+ const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
2498
+ text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
2499
+ byTspan(content, s, x, y, width, height, textAttrs, conf2);
2500
+ _setTextAttrs(text, textAttrs);
2501
+ }
2502
+ __name(byFo, "byFo");
2503
+ async function byKatex(content, g, x, y, width, height, textAttrs, conf2) {
2504
+ const dim = await calculateMathMLDimensions(content, getConfig());
2505
+ const s = g.append("switch");
2506
+ const f = s.append("foreignObject").attr("x", x + width / 2 - dim.width / 2).attr("y", y + height / 2 - dim.height / 2).attr("width", dim.width).attr("height", dim.height);
2507
+ const text = f.append("xhtml:div").style("height", "100%").style("width", "100%");
2508
+ text.append("div").style("text-align", "center").style("vertical-align", "middle").html(await renderKatexSanitized(content, getConfig()));
2509
+ byTspan(content, s, x, y, width, height, textAttrs, conf2);
2510
+ _setTextAttrs(text, textAttrs);
2511
+ }
2512
+ __name(byKatex, "byKatex");
2513
+ function _setTextAttrs(toText, fromTextAttrsDict) {
2514
+ for (const key in fromTextAttrsDict) {
2515
+ if (fromTextAttrsDict.hasOwnProperty(key)) {
2516
+ toText.attr(key, fromTextAttrsDict[key]);
2517
+ }
2518
+ }
2519
+ }
2520
+ __name(_setTextAttrs, "_setTextAttrs");
2521
+ return function(conf2, hasKatex2 = false) {
2522
+ if (hasKatex2) {
2523
+ return byKatex;
2524
+ }
2525
+ return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
2526
+ };
2527
+ })();
2528
+ var _drawMenuItemTextCandidateFunc = /* @__PURE__ */ (function() {
2529
+ function byText(content, g, x, y, width, height, textAttrs) {
2530
+ const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content);
2531
+ _setTextAttrs(text, textAttrs);
2532
+ }
2533
+ __name(byText, "byText");
2534
+ function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
2535
+ const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
2536
+ const lines = content.split(common_default.lineBreakRegex);
2537
+ for (let i = 0; i < lines.length; i++) {
2538
+ const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2;
2539
+ const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").style("font-size", actorFontSize).style("font-weight", actorFontWeight).style("font-family", actorFontFamily);
2540
+ text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]);
2541
+ text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
2542
+ _setTextAttrs(text, textAttrs);
2543
+ }
2544
+ }
2545
+ __name(byTspan, "byTspan");
2546
+ function byFo(content, g, x, y, width, height, textAttrs, conf2) {
2547
+ const s = g.append("switch");
2548
+ const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
2549
+ const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
2550
+ text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
2551
+ byTspan(content, s, x, y, width, height, textAttrs, conf2);
2552
+ _setTextAttrs(text, textAttrs);
2553
+ }
2554
+ __name(byFo, "byFo");
2555
+ function _setTextAttrs(toText, fromTextAttrsDict) {
2556
+ for (const key in fromTextAttrsDict) {
2557
+ if (fromTextAttrsDict.hasOwnProperty(key)) {
2558
+ toText.attr(key, fromTextAttrsDict[key]);
2559
+ }
2560
+ }
2561
+ }
2562
+ __name(_setTextAttrs, "_setTextAttrs");
2563
+ return function(conf2) {
2564
+ return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
2565
+ };
2566
+ })();
2567
+ var svgDraw_default = {
2568
+ drawRect: drawRect2,
2569
+ drawText,
2570
+ drawLabel,
2571
+ drawActor,
2572
+ drawBox,
2573
+ drawPopup,
2574
+ anchorElement,
2575
+ drawActivation,
2576
+ drawLoop,
2577
+ drawBackgroundRect: drawBackgroundRect2,
2578
+ insertArrowHead,
2579
+ insertArrowFilledHead,
2580
+ insertSequenceNumber,
2581
+ insertArrowCrossHead,
2582
+ insertDatabaseIcon,
2583
+ insertComputerIcon,
2584
+ insertClockIcon,
2585
+ getTextObj: getTextObj2,
2586
+ getNoteRect: getNoteRect2,
2587
+ fixLifeLineHeights,
2588
+ sanitizeUrl: distExports.sanitizeUrl
2589
+ };
2590
+ var conf = {};
2591
+ var bounds = {
2592
+ data: {
2593
+ startx: void 0,
2594
+ stopx: void 0,
2595
+ starty: void 0,
2596
+ stopy: void 0
2597
+ },
2598
+ verticalPos: 0,
2599
+ sequenceItems: [],
2600
+ activations: [],
2601
+ models: {
2602
+ getHeight: /* @__PURE__ */ __name(function() {
2603
+ return Math.max.apply(
2604
+ null,
2605
+ this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0)
2606
+ ) + (this.loops.length === 0 ? 0 : this.loops.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.messages.length === 0 ? 0 : this.messages.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.notes.length === 0 ? 0 : this.notes.map((it) => it.height || 0).reduce((acc, h) => acc + h));
2607
+ }, "getHeight"),
2608
+ clear: /* @__PURE__ */ __name(function() {
2609
+ this.actors = [];
2610
+ this.boxes = [];
2611
+ this.loops = [];
2612
+ this.messages = [];
2613
+ this.notes = [];
2614
+ }, "clear"),
2615
+ addBox: /* @__PURE__ */ __name(function(boxModel) {
2616
+ this.boxes.push(boxModel);
2617
+ }, "addBox"),
2618
+ addActor: /* @__PURE__ */ __name(function(actorModel) {
2619
+ this.actors.push(actorModel);
2620
+ }, "addActor"),
2621
+ addLoop: /* @__PURE__ */ __name(function(loopModel) {
2622
+ this.loops.push(loopModel);
2623
+ }, "addLoop"),
2624
+ addMessage: /* @__PURE__ */ __name(function(msgModel) {
2625
+ this.messages.push(msgModel);
2626
+ }, "addMessage"),
2627
+ addNote: /* @__PURE__ */ __name(function(noteModel) {
2628
+ this.notes.push(noteModel);
2629
+ }, "addNote"),
2630
+ lastActor: /* @__PURE__ */ __name(function() {
2631
+ return this.actors[this.actors.length - 1];
2632
+ }, "lastActor"),
2633
+ lastLoop: /* @__PURE__ */ __name(function() {
2634
+ return this.loops[this.loops.length - 1];
2635
+ }, "lastLoop"),
2636
+ lastMessage: /* @__PURE__ */ __name(function() {
2637
+ return this.messages[this.messages.length - 1];
2638
+ }, "lastMessage"),
2639
+ lastNote: /* @__PURE__ */ __name(function() {
2640
+ return this.notes[this.notes.length - 1];
2641
+ }, "lastNote"),
2642
+ actors: [],
2643
+ boxes: [],
2644
+ loops: [],
2645
+ messages: [],
2646
+ notes: []
2647
+ },
2648
+ init: /* @__PURE__ */ __name(function() {
2649
+ this.sequenceItems = [];
2650
+ this.activations = [];
2651
+ this.models.clear();
2652
+ this.data = {
2653
+ startx: void 0,
2654
+ stopx: void 0,
2655
+ starty: void 0,
2656
+ stopy: void 0
2657
+ };
2658
+ this.verticalPos = 0;
2659
+ setConf(getConfig2());
2660
+ }, "init"),
2661
+ updateVal: /* @__PURE__ */ __name(function(obj, key, val, fun) {
2662
+ if (obj[key] === void 0) {
2663
+ obj[key] = val;
2664
+ } else {
2665
+ obj[key] = fun(val, obj[key]);
2666
+ }
2667
+ }, "updateVal"),
2668
+ updateBounds: /* @__PURE__ */ __name(function(startx, starty, stopx, stopy) {
2669
+ const _self = this;
2670
+ let cnt = 0;
2671
+ function updateFn(type) {
2672
+ return /* @__PURE__ */ __name(function updateItemBounds(item) {
2673
+ cnt++;
2674
+ const n = _self.sequenceItems.length - cnt + 1;
2675
+ _self.updateVal(item, "starty", starty - n * conf.boxMargin, Math.min);
2676
+ _self.updateVal(item, "stopy", stopy + n * conf.boxMargin, Math.max);
2677
+ _self.updateVal(bounds.data, "startx", startx - n * conf.boxMargin, Math.min);
2678
+ _self.updateVal(bounds.data, "stopx", stopx + n * conf.boxMargin, Math.max);
2679
+ if (!(type === "activation")) {
2680
+ _self.updateVal(item, "startx", startx - n * conf.boxMargin, Math.min);
2681
+ _self.updateVal(item, "stopx", stopx + n * conf.boxMargin, Math.max);
2682
+ _self.updateVal(bounds.data, "starty", starty - n * conf.boxMargin, Math.min);
2683
+ _self.updateVal(bounds.data, "stopy", stopy + n * conf.boxMargin, Math.max);
2684
+ }
2685
+ }, "updateItemBounds");
2686
+ }
2687
+ __name(updateFn, "updateFn");
2688
+ this.sequenceItems.forEach(updateFn());
2689
+ this.activations.forEach(updateFn("activation"));
2690
+ }, "updateBounds"),
2691
+ insert: /* @__PURE__ */ __name(function(startx, starty, stopx, stopy) {
2692
+ const _startx = common_default.getMin(startx, stopx);
2693
+ const _stopx = common_default.getMax(startx, stopx);
2694
+ const _starty = common_default.getMin(starty, stopy);
2695
+ const _stopy = common_default.getMax(starty, stopy);
2696
+ this.updateVal(bounds.data, "startx", _startx, Math.min);
2697
+ this.updateVal(bounds.data, "starty", _starty, Math.min);
2698
+ this.updateVal(bounds.data, "stopx", _stopx, Math.max);
2699
+ this.updateVal(bounds.data, "stopy", _stopy, Math.max);
2700
+ this.updateBounds(_startx, _starty, _stopx, _stopy);
2701
+ }, "insert"),
2702
+ newActivation: /* @__PURE__ */ __name(function(message, diagram2, actors) {
2703
+ const actorRect = actors.get(message.from);
2704
+ const stackedSize = actorActivations(message.from).length || 0;
2705
+ const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
2706
+ this.activations.push({
2707
+ startx: x,
2708
+ starty: this.verticalPos + 2,
2709
+ stopx: x + conf.activationWidth,
2710
+ stopy: void 0,
2711
+ actor: message.from,
2712
+ anchored: svgDraw_default.anchorElement(diagram2)
2713
+ });
2714
+ }, "newActivation"),
2715
+ endActivation: /* @__PURE__ */ __name(function(message) {
2716
+ const lastActorActivationIdx = this.activations.map(function(activation) {
2717
+ return activation.actor;
2718
+ }).lastIndexOf(message.from);
2719
+ return this.activations.splice(lastActorActivationIdx, 1)[0];
2720
+ }, "endActivation"),
2721
+ createLoop: /* @__PURE__ */ __name(function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2722
+ return {
2723
+ startx: void 0,
2724
+ starty: this.verticalPos,
2725
+ stopx: void 0,
2726
+ stopy: void 0,
2727
+ title: title.message,
2728
+ wrap: title.wrap,
2729
+ width: title.width,
2730
+ height: 0,
2731
+ fill
2732
+ };
2733
+ }, "createLoop"),
2734
+ newLoop: /* @__PURE__ */ __name(function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2735
+ this.sequenceItems.push(this.createLoop(title, fill));
2736
+ }, "newLoop"),
2737
+ endLoop: /* @__PURE__ */ __name(function() {
2738
+ return this.sequenceItems.pop();
2739
+ }, "endLoop"),
2740
+ isLoopOverlap: /* @__PURE__ */ __name(function() {
2741
+ return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false;
2742
+ }, "isLoopOverlap"),
2743
+ addSectionToLoop: /* @__PURE__ */ __name(function(message) {
2744
+ const loop = this.sequenceItems.pop();
2745
+ loop.sections = loop.sections || [];
2746
+ loop.sectionTitles = loop.sectionTitles || [];
2747
+ loop.sections.push({ y: bounds.getVerticalPos(), height: 0 });
2748
+ loop.sectionTitles.push(message);
2749
+ this.sequenceItems.push(loop);
2750
+ }, "addSectionToLoop"),
2751
+ saveVerticalPos: /* @__PURE__ */ __name(function() {
2752
+ if (this.isLoopOverlap()) {
2753
+ this.savedVerticalPos = this.verticalPos;
2754
+ }
2755
+ }, "saveVerticalPos"),
2756
+ resetVerticalPos: /* @__PURE__ */ __name(function() {
2757
+ if (this.isLoopOverlap()) {
2758
+ this.verticalPos = this.savedVerticalPos;
2759
+ }
2760
+ }, "resetVerticalPos"),
2761
+ bumpVerticalPos: /* @__PURE__ */ __name(function(bump) {
2762
+ this.verticalPos = this.verticalPos + bump;
2763
+ this.data.stopy = common_default.getMax(this.data.stopy, this.verticalPos);
2764
+ }, "bumpVerticalPos"),
2765
+ getVerticalPos: /* @__PURE__ */ __name(function() {
2766
+ return this.verticalPos;
2767
+ }, "getVerticalPos"),
2768
+ getBounds: /* @__PURE__ */ __name(function() {
2769
+ return { bounds: this.data, models: this.models };
2770
+ }, "getBounds")
2771
+ };
2772
+ var drawNote = /* @__PURE__ */ __name(async function(elem, noteModel) {
2773
+ bounds.bumpVerticalPos(conf.boxMargin);
2774
+ noteModel.height = conf.boxMargin;
2775
+ noteModel.starty = bounds.getVerticalPos();
2776
+ const rect = getNoteRect();
2777
+ rect.x = noteModel.startx;
2778
+ rect.y = noteModel.starty;
2779
+ rect.width = noteModel.width || conf.width;
2780
+ rect.class = "note";
2781
+ const g = elem.append("g");
2782
+ const rectElem = svgDraw_default.drawRect(g, rect);
2783
+ const textObj = getTextObj();
2784
+ textObj.x = noteModel.startx;
2785
+ textObj.y = noteModel.starty;
2786
+ textObj.width = rect.width;
2787
+ textObj.dy = "1em";
2788
+ textObj.text = noteModel.message;
2789
+ textObj.class = "noteText";
2790
+ textObj.fontFamily = conf.noteFontFamily;
2791
+ textObj.fontSize = conf.noteFontSize;
2792
+ textObj.fontWeight = conf.noteFontWeight;
2793
+ textObj.anchor = conf.noteAlign;
2794
+ textObj.textMargin = conf.noteMargin;
2795
+ textObj.valign = "center";
2796
+ const textElem = hasKatex(textObj.text) ? await drawKatex(g, textObj) : drawText(g, textObj);
2797
+ const textHeight = Math.round(
2798
+ textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
2799
+ );
2800
+ rectElem.attr("height", textHeight + 2 * conf.noteMargin);
2801
+ noteModel.height += textHeight + 2 * conf.noteMargin;
2802
+ bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin);
2803
+ noteModel.stopy = noteModel.starty + textHeight + 2 * conf.noteMargin;
2804
+ noteModel.stopx = noteModel.startx + rect.width;
2805
+ bounds.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy);
2806
+ bounds.models.addNote(noteModel);
2807
+ }, "drawNote");
2808
+ var messageFont = /* @__PURE__ */ __name((cnf) => {
2809
+ return {
2810
+ fontFamily: cnf.messageFontFamily,
2811
+ fontSize: cnf.messageFontSize,
2812
+ fontWeight: cnf.messageFontWeight
2813
+ };
2814
+ }, "messageFont");
2815
+ var noteFont = /* @__PURE__ */ __name((cnf) => {
2816
+ return {
2817
+ fontFamily: cnf.noteFontFamily,
2818
+ fontSize: cnf.noteFontSize,
2819
+ fontWeight: cnf.noteFontWeight
2820
+ };
2821
+ }, "noteFont");
2822
+ var actorFont = /* @__PURE__ */ __name((cnf) => {
2823
+ return {
2824
+ fontFamily: cnf.actorFontFamily,
2825
+ fontSize: cnf.actorFontSize,
2826
+ fontWeight: cnf.actorFontWeight
2827
+ };
2828
+ }, "actorFont");
2829
+ async function boundMessage(_diagram, msgModel) {
2830
+ bounds.bumpVerticalPos(10);
2831
+ const { startx, stopx, message } = msgModel;
2832
+ const lines = common_default.splitBreaks(message).length;
2833
+ const isKatexMsg = hasKatex(message);
2834
+ const textDims = isKatexMsg ? await calculateMathMLDimensions(message, getConfig2()) : utils_default.calculateTextDimensions(message, messageFont(conf));
2835
+ if (!isKatexMsg) {
2836
+ const lineHeight = textDims.height / lines;
2837
+ msgModel.height += lineHeight;
2838
+ bounds.bumpVerticalPos(lineHeight);
2839
+ }
2840
+ let lineStartY;
2841
+ let totalOffset = textDims.height - 10;
2842
+ const textWidth = textDims.width;
2843
+ if (startx === stopx) {
2844
+ lineStartY = bounds.getVerticalPos() + totalOffset;
2845
+ if (!conf.rightAngles) {
2846
+ totalOffset += conf.boxMargin;
2847
+ lineStartY = bounds.getVerticalPos() + totalOffset;
2848
+ }
2849
+ totalOffset += 30;
2850
+ const dx = common_default.getMax(textWidth / 2, conf.width / 2);
2851
+ bounds.insert(
2852
+ startx - dx,
2853
+ bounds.getVerticalPos() - 10 + totalOffset,
2854
+ stopx + dx,
2855
+ bounds.getVerticalPos() + 30 + totalOffset
2856
+ );
2857
+ } else {
2858
+ totalOffset += conf.boxMargin;
2859
+ lineStartY = bounds.getVerticalPos() + totalOffset;
2860
+ bounds.insert(startx, lineStartY - 10, stopx, lineStartY);
2861
+ }
2862
+ bounds.bumpVerticalPos(totalOffset);
2863
+ msgModel.height += totalOffset;
2864
+ msgModel.stopy = msgModel.starty + msgModel.height;
2865
+ bounds.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy);
2866
+ return lineStartY;
2867
+ }
2868
+ __name(boundMessage, "boundMessage");
2869
+ var drawMessage = /* @__PURE__ */ __name(async function(diagram2, msgModel, lineStartY, diagObj) {
2870
+ const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel;
2871
+ const textDims = utils_default.calculateTextDimensions(message, messageFont(conf));
2872
+ const textObj = getTextObj();
2873
+ textObj.x = startx;
2874
+ textObj.y = starty + 10;
2875
+ textObj.width = stopx - startx;
2876
+ textObj.class = "messageText";
2877
+ textObj.dy = "1em";
2878
+ textObj.text = message;
2879
+ textObj.fontFamily = conf.messageFontFamily;
2880
+ textObj.fontSize = conf.messageFontSize;
2881
+ textObj.fontWeight = conf.messageFontWeight;
2882
+ textObj.anchor = conf.messageAlign;
2883
+ textObj.valign = "center";
2884
+ textObj.textMargin = conf.wrapPadding;
2885
+ textObj.tspan = false;
2886
+ if (hasKatex(textObj.text)) {
2887
+ await drawKatex(diagram2, textObj, { startx, stopx, starty: lineStartY });
2888
+ } else {
2889
+ drawText(diagram2, textObj);
2890
+ }
2891
+ const textWidth = textDims.width;
2892
+ let line;
2893
+ if (startx === stopx) {
2894
+ if (conf.rightAngles) {
2895
+ line = diagram2.append("path").attr(
2896
+ "d",
2897
+ `M ${startx},${lineStartY} H ${startx + common_default.getMax(conf.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}`
2898
+ );
2899
+ } else {
2900
+ line = diagram2.append("path").attr(
2901
+ "d",
2902
+ "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20)
2903
+ );
2904
+ }
2905
+ } else {
2906
+ line = diagram2.append("line");
2907
+ line.attr("x1", startx);
2908
+ line.attr("y1", lineStartY);
2909
+ line.attr("x2", stopx);
2910
+ line.attr("y2", lineStartY);
2911
+ }
2912
+ if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN || type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED) {
2913
+ line.style("stroke-dasharray", "3, 3");
2914
+ line.attr("class", "messageLine1");
2915
+ } else {
2916
+ line.attr("class", "messageLine0");
2917
+ }
2918
+ let url = "";
2919
+ if (conf.arrowMarkerAbsolute) {
2920
+ url = getUrl(true);
2921
+ }
2922
+ line.attr("stroke-width", 2);
2923
+ line.attr("stroke", "none");
2924
+ line.style("fill", "none");
2925
+ if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) {
2926
+ line.attr("marker-end", "url(" + url + "#arrowhead)");
2927
+ }
2928
+ if (type === diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID || type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED) {
2929
+ line.attr("marker-start", "url(" + url + "#arrowhead)");
2930
+ line.attr("marker-end", "url(" + url + "#arrowhead)");
2931
+ }
2932
+ if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) {
2933
+ line.attr("marker-end", "url(" + url + "#filled-head)");
2934
+ }
2935
+ if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) {
2936
+ line.attr("marker-end", "url(" + url + "#crosshead)");
2937
+ }
2938
+ if (sequenceVisible || conf.showSequenceNumbers) {
2939
+ const isBidirectional = type === diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID || type === diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED;
2940
+ if (isBidirectional) {
2941
+ const SEQUENCE_NUMBER_RADIUS = 6;
2942
+ if (startx < stopx) {
2943
+ line.attr("x1", startx + 2 * SEQUENCE_NUMBER_RADIUS);
2944
+ } else {
2945
+ line.attr("x1", startx + SEQUENCE_NUMBER_RADIUS);
2946
+ }
2947
+ }
2948
+ diagram2.append("line").attr("x1", startx).attr("y1", lineStartY).attr("x2", startx).attr("y2", lineStartY).attr("stroke-width", 0).attr("marker-start", "url(" + url + "#sequencenumber)");
2949
+ diagram2.append("text").attr("x", startx).attr("y", lineStartY + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(sequenceIndex);
2950
+ }
2951
+ }, "drawMessage");
2952
+ var addActorRenderingData = /* @__PURE__ */ __name(function(diagram2, actors, createdActors, actorKeys, verticalPos, messages, isFooter) {
2953
+ let prevWidth = 0;
2954
+ let prevMargin = 0;
2955
+ let prevBox = void 0;
2956
+ let maxHeight = 0;
2957
+ for (const actorKey of actorKeys) {
2958
+ const actor = actors.get(actorKey);
2959
+ const box = actor.box;
2960
+ if (prevBox && prevBox != box) {
2961
+ if (!isFooter) {
2962
+ bounds.models.addBox(prevBox);
2963
+ }
2964
+ prevMargin += conf.boxMargin + prevBox.margin;
2965
+ }
2966
+ if (box && box != prevBox) {
2967
+ if (!isFooter) {
2968
+ box.x = prevWidth + prevMargin;
2969
+ box.y = verticalPos;
2970
+ }
2971
+ prevMargin += box.margin;
2972
+ }
2973
+ actor.width = actor.width || conf.width;
2974
+ actor.height = common_default.getMax(actor.height || conf.height, conf.height);
2975
+ actor.margin = actor.margin || conf.actorMargin;
2976
+ maxHeight = common_default.getMax(maxHeight, actor.height);
2977
+ if (createdActors.get(actor.name)) {
2978
+ prevMargin += actor.width / 2;
2979
+ }
2980
+ actor.x = prevWidth + prevMargin;
2981
+ actor.starty = bounds.getVerticalPos();
2982
+ bounds.insert(actor.x, verticalPos, actor.x + actor.width, actor.height);
2983
+ prevWidth += actor.width + prevMargin;
2984
+ if (actor.box) {
2985
+ actor.box.width = prevWidth + box.margin - actor.box.x;
2986
+ }
2987
+ prevMargin = actor.margin;
2988
+ prevBox = actor.box;
2989
+ bounds.models.addActor(actor);
2990
+ }
2991
+ if (prevBox && !isFooter) {
2992
+ bounds.models.addBox(prevBox);
2993
+ }
2994
+ bounds.bumpVerticalPos(maxHeight);
2995
+ }, "addActorRenderingData");
2996
+ var drawActors = /* @__PURE__ */ __name(async function(diagram2, actors, actorKeys, isFooter) {
2997
+ if (!isFooter) {
2998
+ for (const actorKey of actorKeys) {
2999
+ const actor = actors.get(actorKey);
3000
+ await svgDraw_default.drawActor(diagram2, actor, conf, false);
3001
+ }
3002
+ } else {
3003
+ let maxHeight = 0;
3004
+ bounds.bumpVerticalPos(conf.boxMargin * 2);
3005
+ for (const actorKey of actorKeys) {
3006
+ const actor = actors.get(actorKey);
3007
+ if (!actor.stopy) {
3008
+ actor.stopy = bounds.getVerticalPos();
3009
+ }
3010
+ const height = await svgDraw_default.drawActor(diagram2, actor, conf, true);
3011
+ maxHeight = common_default.getMax(maxHeight, height);
3012
+ }
3013
+ bounds.bumpVerticalPos(maxHeight + conf.boxMargin);
3014
+ }
3015
+ }, "drawActors");
3016
+ var drawActorsPopup = /* @__PURE__ */ __name(function(diagram2, actors, actorKeys, doc) {
3017
+ let maxHeight = 0;
3018
+ let maxWidth = 0;
3019
+ for (const actorKey of actorKeys) {
3020
+ const actor = actors.get(actorKey);
3021
+ const minMenuWidth = getRequiredPopupWidth(actor);
3022
+ const menuDimensions = svgDraw_default.drawPopup(
3023
+ diagram2,
3024
+ actor,
3025
+ minMenuWidth,
3026
+ conf,
3027
+ conf.forceMenus,
3028
+ doc
3029
+ );
3030
+ if (menuDimensions.height > maxHeight) {
3031
+ maxHeight = menuDimensions.height;
3032
+ }
3033
+ if (menuDimensions.width + actor.x > maxWidth) {
3034
+ maxWidth = menuDimensions.width + actor.x;
3035
+ }
3036
+ }
3037
+ return { maxHeight, maxWidth };
3038
+ }, "drawActorsPopup");
3039
+ var setConf = /* @__PURE__ */ __name(function(cnf) {
3040
+ assignWithDepth_default(conf, cnf);
3041
+ if (cnf.fontFamily) {
3042
+ conf.actorFontFamily = conf.noteFontFamily = conf.messageFontFamily = cnf.fontFamily;
3043
+ }
3044
+ if (cnf.fontSize) {
3045
+ conf.actorFontSize = conf.noteFontSize = conf.messageFontSize = cnf.fontSize;
3046
+ }
3047
+ if (cnf.fontWeight) {
3048
+ conf.actorFontWeight = conf.noteFontWeight = conf.messageFontWeight = cnf.fontWeight;
3049
+ }
3050
+ }, "setConf");
3051
+ var actorActivations = /* @__PURE__ */ __name(function(actor) {
3052
+ return bounds.activations.filter(function(activation) {
3053
+ return activation.actor === actor;
3054
+ });
3055
+ }, "actorActivations");
3056
+ var activationBounds = /* @__PURE__ */ __name(function(actor, actors) {
3057
+ const actorObj = actors.get(actor);
3058
+ const activations = actorActivations(actor);
3059
+ const left = activations.reduce(
3060
+ function(acc, activation) {
3061
+ return common_default.getMin(acc, activation.startx);
3062
+ },
3063
+ actorObj.x + actorObj.width / 2 - 1
3064
+ );
3065
+ const right = activations.reduce(
3066
+ function(acc, activation) {
3067
+ return common_default.getMax(acc, activation.stopx);
3068
+ },
3069
+ actorObj.x + actorObj.width / 2 + 1
3070
+ );
3071
+ return [left, right];
3072
+ }, "activationBounds");
3073
+ function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) {
3074
+ bounds.bumpVerticalPos(preMargin);
3075
+ let heightAdjust = postMargin;
3076
+ if (msg.id && msg.message && loopWidths[msg.id]) {
3077
+ const loopWidth = loopWidths[msg.id].width;
3078
+ const textConf = messageFont(conf);
3079
+ msg.message = utils_default.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf.wrapPadding, textConf);
3080
+ msg.width = loopWidth;
3081
+ msg.wrap = true;
3082
+ const textDims = utils_default.calculateTextDimensions(msg.message, textConf);
3083
+ const totalOffset = common_default.getMax(textDims.height, conf.labelBoxHeight);
3084
+ heightAdjust = postMargin + totalOffset;
3085
+ log.debug(`${totalOffset} - ${msg.message}`);
3086
+ }
3087
+ addLoopFn(msg);
3088
+ bounds.bumpVerticalPos(heightAdjust);
3089
+ }
3090
+ __name(adjustLoopHeightForWrap, "adjustLoopHeightForWrap");
3091
+ function adjustCreatedDestroyedData(msg, msgModel, lineStartY, index, actors, createdActors, destroyedActors) {
3092
+ function receiverAdjustment(actor, adjustment) {
3093
+ if (actor.x < actors.get(msg.from).x) {
3094
+ bounds.insert(
3095
+ msgModel.stopx - adjustment,
3096
+ msgModel.starty,
3097
+ msgModel.startx,
3098
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
3099
+ );
3100
+ msgModel.stopx = msgModel.stopx + adjustment;
3101
+ } else {
3102
+ bounds.insert(
3103
+ msgModel.startx,
3104
+ msgModel.starty,
3105
+ msgModel.stopx + adjustment,
3106
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
3107
+ );
3108
+ msgModel.stopx = msgModel.stopx - adjustment;
3109
+ }
3110
+ }
3111
+ __name(receiverAdjustment, "receiverAdjustment");
3112
+ function senderAdjustment(actor, adjustment) {
3113
+ if (actor.x < actors.get(msg.to).x) {
3114
+ bounds.insert(
3115
+ msgModel.startx - adjustment,
3116
+ msgModel.starty,
3117
+ msgModel.stopx,
3118
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
3119
+ );
3120
+ msgModel.startx = msgModel.startx + adjustment;
3121
+ } else {
3122
+ bounds.insert(
3123
+ msgModel.stopx,
3124
+ msgModel.starty,
3125
+ msgModel.startx + adjustment,
3126
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
3127
+ );
3128
+ msgModel.startx = msgModel.startx - adjustment;
3129
+ }
3130
+ }
3131
+ __name(senderAdjustment, "senderAdjustment");
3132
+ const actorArray = [
3133
+ PARTICIPANT_TYPE.ACTOR,
3134
+ PARTICIPANT_TYPE.CONTROL,
3135
+ PARTICIPANT_TYPE.ENTITY,
3136
+ PARTICIPANT_TYPE.DATABASE
3137
+ ];
3138
+ if (createdActors.get(msg.to) == index) {
3139
+ const actor = actors.get(msg.to);
3140
+ const adjustment = actorArray.includes(actor.type) ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3;
3141
+ receiverAdjustment(actor, adjustment);
3142
+ actor.starty = lineStartY - actor.height / 2;
3143
+ bounds.bumpVerticalPos(actor.height / 2);
3144
+ } else if (destroyedActors.get(msg.from) == index) {
3145
+ const actor = actors.get(msg.from);
3146
+ if (conf.mirrorActors) {
3147
+ const adjustment = actorArray.includes(actor.type) ? ACTOR_TYPE_WIDTH / 2 : actor.width / 2;
3148
+ senderAdjustment(actor, adjustment);
3149
+ }
3150
+ actor.stopy = lineStartY - actor.height / 2;
3151
+ bounds.bumpVerticalPos(actor.height / 2);
3152
+ } else if (destroyedActors.get(msg.to) == index) {
3153
+ const actor = actors.get(msg.to);
3154
+ if (conf.mirrorActors) {
3155
+ const adjustment = actorArray.includes(actor.type) ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3;
3156
+ receiverAdjustment(actor, adjustment);
3157
+ }
3158
+ actor.stopy = lineStartY - actor.height / 2;
3159
+ bounds.bumpVerticalPos(actor.height / 2);
3160
+ }
3161
+ }
3162
+ __name(adjustCreatedDestroyedData, "adjustCreatedDestroyedData");
3163
+ var draw = /* @__PURE__ */ __name(async function(_text, id, _version, diagObj) {
3164
+ const { securityLevel, sequence } = getConfig2();
3165
+ conf = sequence;
3166
+ let sandboxElement;
3167
+ if (securityLevel === "sandbox") {
3168
+ sandboxElement = select("#i" + id);
3169
+ }
3170
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
3171
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
3172
+ bounds.init();
3173
+ log.debug(diagObj.db);
3174
+ const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`);
3175
+ const actors = diagObj.db.getActors();
3176
+ const createdActors = diagObj.db.getCreatedActors();
3177
+ const destroyedActors = diagObj.db.getDestroyedActors();
3178
+ const boxes = diagObj.db.getBoxes();
3179
+ let actorKeys = diagObj.db.getActorKeys();
3180
+ const messages = diagObj.db.getMessages();
3181
+ const title = diagObj.db.getDiagramTitle();
3182
+ const hasBoxes = diagObj.db.hasAtLeastOneBox();
3183
+ const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle();
3184
+ const maxMessageWidthPerActor = await getMaxMessageWidthPerActor(actors, messages, diagObj);
3185
+ conf.height = await calculateActorMargins(actors, maxMessageWidthPerActor, boxes);
3186
+ svgDraw_default.insertComputerIcon(diagram2);
3187
+ svgDraw_default.insertDatabaseIcon(diagram2);
3188
+ svgDraw_default.insertClockIcon(diagram2);
3189
+ if (hasBoxes) {
3190
+ bounds.bumpVerticalPos(conf.boxMargin);
3191
+ if (hasBoxTitles) {
3192
+ bounds.bumpVerticalPos(boxes[0].textMaxHeight);
3193
+ }
3194
+ }
3195
+ if (conf.hideUnusedParticipants === true) {
3196
+ const newActors = /* @__PURE__ */ new Set();
3197
+ messages.forEach((message) => {
3198
+ newActors.add(message.from);
3199
+ newActors.add(message.to);
3200
+ });
3201
+ actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey));
3202
+ }
3203
+ addActorRenderingData(diagram2, actors, createdActors, actorKeys, 0, messages, false);
3204
+ const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj);
3205
+ svgDraw_default.insertArrowHead(diagram2);
3206
+ svgDraw_default.insertArrowCrossHead(diagram2);
3207
+ svgDraw_default.insertArrowFilledHead(diagram2);
3208
+ svgDraw_default.insertSequenceNumber(diagram2);
3209
+ function activeEnd(msg, verticalPos) {
3210
+ const activationData = bounds.endActivation(msg);
3211
+ if (activationData.starty + 18 > verticalPos) {
3212
+ activationData.starty = verticalPos - 6;
3213
+ verticalPos += 12;
3214
+ }
3215
+ svgDraw_default.drawActivation(
3216
+ diagram2,
3217
+ activationData,
3218
+ verticalPos,
3219
+ conf,
3220
+ actorActivations(msg.from).length
3221
+ );
3222
+ bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos);
3223
+ }
3224
+ __name(activeEnd, "activeEnd");
3225
+ let sequenceIndex = 1;
3226
+ let sequenceIndexStep = 1;
3227
+ const messagesToDraw = [];
3228
+ const backgrounds = [];
3229
+ let index = 0;
3230
+ for (const msg of messages) {
3231
+ let loopModel, noteModel, msgModel;
3232
+ switch (msg.type) {
3233
+ case diagObj.db.LINETYPE.NOTE:
3234
+ bounds.resetVerticalPos();
3235
+ noteModel = msg.noteModel;
3236
+ await drawNote(diagram2, noteModel);
3237
+ break;
3238
+ case diagObj.db.LINETYPE.ACTIVE_START:
3239
+ bounds.newActivation(msg, diagram2, actors);
3240
+ break;
3241
+ case diagObj.db.LINETYPE.ACTIVE_END:
3242
+ activeEnd(msg, bounds.getVerticalPos());
3243
+ break;
3244
+ case diagObj.db.LINETYPE.LOOP_START:
3245
+ adjustLoopHeightForWrap(
3246
+ loopWidths,
3247
+ msg,
3248
+ conf.boxMargin,
3249
+ conf.boxMargin + conf.boxTextMargin,
3250
+ (message) => bounds.newLoop(message)
3251
+ );
3252
+ break;
3253
+ case diagObj.db.LINETYPE.LOOP_END:
3254
+ loopModel = bounds.endLoop();
3255
+ await svgDraw_default.drawLoop(diagram2, loopModel, "loop", conf);
3256
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3257
+ bounds.models.addLoop(loopModel);
3258
+ break;
3259
+ case diagObj.db.LINETYPE.RECT_START:
3260
+ adjustLoopHeightForWrap(
3261
+ loopWidths,
3262
+ msg,
3263
+ conf.boxMargin,
3264
+ conf.boxMargin,
3265
+ (message) => bounds.newLoop(void 0, message.message)
3266
+ );
3267
+ break;
3268
+ case diagObj.db.LINETYPE.RECT_END:
3269
+ loopModel = bounds.endLoop();
3270
+ backgrounds.push(loopModel);
3271
+ bounds.models.addLoop(loopModel);
3272
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3273
+ break;
3274
+ case diagObj.db.LINETYPE.OPT_START:
3275
+ adjustLoopHeightForWrap(
3276
+ loopWidths,
3277
+ msg,
3278
+ conf.boxMargin,
3279
+ conf.boxMargin + conf.boxTextMargin,
3280
+ (message) => bounds.newLoop(message)
3281
+ );
3282
+ break;
3283
+ case diagObj.db.LINETYPE.OPT_END:
3284
+ loopModel = bounds.endLoop();
3285
+ await svgDraw_default.drawLoop(diagram2, loopModel, "opt", conf);
3286
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3287
+ bounds.models.addLoop(loopModel);
3288
+ break;
3289
+ case diagObj.db.LINETYPE.ALT_START:
3290
+ adjustLoopHeightForWrap(
3291
+ loopWidths,
3292
+ msg,
3293
+ conf.boxMargin,
3294
+ conf.boxMargin + conf.boxTextMargin,
3295
+ (message) => bounds.newLoop(message)
3296
+ );
3297
+ break;
3298
+ case diagObj.db.LINETYPE.ALT_ELSE:
3299
+ adjustLoopHeightForWrap(
3300
+ loopWidths,
3301
+ msg,
3302
+ conf.boxMargin + conf.boxTextMargin,
3303
+ conf.boxMargin,
3304
+ (message) => bounds.addSectionToLoop(message)
3305
+ );
3306
+ break;
3307
+ case diagObj.db.LINETYPE.ALT_END:
3308
+ loopModel = bounds.endLoop();
3309
+ await svgDraw_default.drawLoop(diagram2, loopModel, "alt", conf);
3310
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3311
+ bounds.models.addLoop(loopModel);
3312
+ break;
3313
+ case diagObj.db.LINETYPE.PAR_START:
3314
+ case diagObj.db.LINETYPE.PAR_OVER_START:
3315
+ adjustLoopHeightForWrap(
3316
+ loopWidths,
3317
+ msg,
3318
+ conf.boxMargin,
3319
+ conf.boxMargin + conf.boxTextMargin,
3320
+ (message) => bounds.newLoop(message)
3321
+ );
3322
+ bounds.saveVerticalPos();
3323
+ break;
3324
+ case diagObj.db.LINETYPE.PAR_AND:
3325
+ adjustLoopHeightForWrap(
3326
+ loopWidths,
3327
+ msg,
3328
+ conf.boxMargin + conf.boxTextMargin,
3329
+ conf.boxMargin,
3330
+ (message) => bounds.addSectionToLoop(message)
3331
+ );
3332
+ break;
3333
+ case diagObj.db.LINETYPE.PAR_END:
3334
+ loopModel = bounds.endLoop();
3335
+ await svgDraw_default.drawLoop(diagram2, loopModel, "par", conf);
3336
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3337
+ bounds.models.addLoop(loopModel);
3338
+ break;
3339
+ case diagObj.db.LINETYPE.AUTONUMBER:
3340
+ sequenceIndex = msg.message.start || sequenceIndex;
3341
+ sequenceIndexStep = msg.message.step || sequenceIndexStep;
3342
+ if (msg.message.visible) {
3343
+ diagObj.db.enableSequenceNumbers();
3344
+ } else {
3345
+ diagObj.db.disableSequenceNumbers();
3346
+ }
3347
+ break;
3348
+ case diagObj.db.LINETYPE.CRITICAL_START:
3349
+ adjustLoopHeightForWrap(
3350
+ loopWidths,
3351
+ msg,
3352
+ conf.boxMargin,
3353
+ conf.boxMargin + conf.boxTextMargin,
3354
+ (message) => bounds.newLoop(message)
3355
+ );
3356
+ break;
3357
+ case diagObj.db.LINETYPE.CRITICAL_OPTION:
3358
+ adjustLoopHeightForWrap(
3359
+ loopWidths,
3360
+ msg,
3361
+ conf.boxMargin + conf.boxTextMargin,
3362
+ conf.boxMargin,
3363
+ (message) => bounds.addSectionToLoop(message)
3364
+ );
3365
+ break;
3366
+ case diagObj.db.LINETYPE.CRITICAL_END:
3367
+ loopModel = bounds.endLoop();
3368
+ await svgDraw_default.drawLoop(diagram2, loopModel, "critical", conf);
3369
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3370
+ bounds.models.addLoop(loopModel);
3371
+ break;
3372
+ case diagObj.db.LINETYPE.BREAK_START:
3373
+ adjustLoopHeightForWrap(
3374
+ loopWidths,
3375
+ msg,
3376
+ conf.boxMargin,
3377
+ conf.boxMargin + conf.boxTextMargin,
3378
+ (message) => bounds.newLoop(message)
3379
+ );
3380
+ break;
3381
+ case diagObj.db.LINETYPE.BREAK_END:
3382
+ loopModel = bounds.endLoop();
3383
+ await svgDraw_default.drawLoop(diagram2, loopModel, "break", conf);
3384
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
3385
+ bounds.models.addLoop(loopModel);
3386
+ break;
3387
+ default:
3388
+ try {
3389
+ msgModel = msg.msgModel;
3390
+ msgModel.starty = bounds.getVerticalPos();
3391
+ msgModel.sequenceIndex = sequenceIndex;
3392
+ msgModel.sequenceVisible = diagObj.db.showSequenceNumbers();
3393
+ const lineStartY = await boundMessage(diagram2, msgModel);
3394
+ adjustCreatedDestroyedData(
3395
+ msg,
3396
+ msgModel,
3397
+ lineStartY,
3398
+ index,
3399
+ actors,
3400
+ createdActors,
3401
+ destroyedActors
3402
+ );
3403
+ messagesToDraw.push({ messageModel: msgModel, lineStartY });
3404
+ bounds.models.addMessage(msgModel);
3405
+ } catch (e) {
3406
+ log.error("error while drawing message", e);
3407
+ }
3408
+ }
3409
+ if ([
3410
+ diagObj.db.LINETYPE.SOLID_OPEN,
3411
+ diagObj.db.LINETYPE.DOTTED_OPEN,
3412
+ diagObj.db.LINETYPE.SOLID,
3413
+ diagObj.db.LINETYPE.DOTTED,
3414
+ diagObj.db.LINETYPE.SOLID_CROSS,
3415
+ diagObj.db.LINETYPE.DOTTED_CROSS,
3416
+ diagObj.db.LINETYPE.SOLID_POINT,
3417
+ diagObj.db.LINETYPE.DOTTED_POINT,
3418
+ diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID,
3419
+ diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED
3420
+ ].includes(msg.type)) {
3421
+ sequenceIndex = sequenceIndex + sequenceIndexStep;
3422
+ }
3423
+ index++;
3424
+ }
3425
+ log.debug("createdActors", createdActors);
3426
+ log.debug("destroyedActors", destroyedActors);
3427
+ await drawActors(diagram2, actors, actorKeys, false);
3428
+ for (const e of messagesToDraw) {
3429
+ await drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj);
3430
+ }
3431
+ if (conf.mirrorActors) {
3432
+ await drawActors(diagram2, actors, actorKeys, true);
3433
+ }
3434
+ backgrounds.forEach((e) => svgDraw_default.drawBackgroundRect(diagram2, e));
3435
+ fixLifeLineHeights(diagram2, actors, actorKeys, conf);
3436
+ for (const box2 of bounds.models.boxes) {
3437
+ box2.height = bounds.getVerticalPos() - box2.y;
3438
+ bounds.insert(box2.x, box2.y, box2.x + box2.width, box2.height);
3439
+ const boxPadding = conf.boxMargin * 2;
3440
+ box2.startx = box2.x - boxPadding;
3441
+ box2.starty = box2.y - boxPadding * 0.25;
3442
+ box2.stopx = box2.startx + box2.width + 2 * boxPadding;
3443
+ box2.stopy = box2.starty + box2.height + boxPadding * 0.75;
3444
+ box2.stroke = "rgb(0,0,0, 0.5)";
3445
+ svgDraw_default.drawBox(diagram2, box2, conf);
3446
+ }
3447
+ if (hasBoxes) {
3448
+ bounds.bumpVerticalPos(conf.boxMargin);
3449
+ }
3450
+ const requiredBoxSize = drawActorsPopup(diagram2, actors, actorKeys, doc);
3451
+ const { bounds: box } = bounds.getBounds();
3452
+ if (box.startx === void 0) {
3453
+ box.startx = 0;
3454
+ }
3455
+ if (box.starty === void 0) {
3456
+ box.starty = 0;
3457
+ }
3458
+ if (box.stopx === void 0) {
3459
+ box.stopx = 0;
3460
+ }
3461
+ if (box.stopy === void 0) {
3462
+ box.stopy = 0;
3463
+ }
3464
+ let boxHeight = box.stopy - box.starty;
3465
+ if (boxHeight < requiredBoxSize.maxHeight) {
3466
+ boxHeight = requiredBoxSize.maxHeight;
3467
+ }
3468
+ let height = boxHeight + 2 * conf.diagramMarginY;
3469
+ if (conf.mirrorActors) {
3470
+ height = height - conf.boxMargin + conf.bottomMarginAdj;
3471
+ }
3472
+ let boxWidth = box.stopx - box.startx;
3473
+ if (boxWidth < requiredBoxSize.maxWidth) {
3474
+ boxWidth = requiredBoxSize.maxWidth;
3475
+ }
3476
+ const width = boxWidth + 2 * conf.diagramMarginX;
3477
+ if (title) {
3478
+ diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf.diagramMarginX).attr("y", -25);
3479
+ }
3480
+ configureSvgSize(diagram2, height, width, conf.useMaxWidth);
3481
+ const extraVertForTitle = title ? 40 : 0;
3482
+ diagram2.attr(
3483
+ "viewBox",
3484
+ box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle)
3485
+ );
3486
+ log.debug(`models:`, bounds.models);
3487
+ }, "draw");
3488
+ async function getMaxMessageWidthPerActor(actors, messages, diagObj) {
3489
+ const maxMessageWidthPerActor = {};
3490
+ for (const msg of messages) {
3491
+ if (actors.get(msg.to) && actors.get(msg.from)) {
3492
+ const actor = actors.get(msg.to);
3493
+ if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) {
3494
+ continue;
3495
+ }
3496
+ if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) {
3497
+ continue;
3498
+ }
3499
+ const isNote = msg.placement !== void 0;
3500
+ const isMessage = !isNote;
3501
+ const textFont = isNote ? noteFont(conf) : messageFont(conf);
3502
+ const wrappedMessage = msg.wrap ? utils_default.wrapLabel(msg.message, conf.width - 2 * conf.wrapPadding, textFont) : msg.message;
3503
+ const messageDimensions = hasKatex(wrappedMessage) ? await calculateMathMLDimensions(msg.message, getConfig2()) : utils_default.calculateTextDimensions(wrappedMessage, textFont);
3504
+ const messageWidth = messageDimensions.width + 2 * conf.wrapPadding;
3505
+ if (isMessage && msg.from === actor.nextActor) {
3506
+ maxMessageWidthPerActor[msg.to] = common_default.getMax(
3507
+ maxMessageWidthPerActor[msg.to] || 0,
3508
+ messageWidth
3509
+ );
3510
+ } else if (isMessage && msg.from === actor.prevActor) {
3511
+ maxMessageWidthPerActor[msg.from] = common_default.getMax(
3512
+ maxMessageWidthPerActor[msg.from] || 0,
3513
+ messageWidth
3514
+ );
3515
+ } else if (isMessage && msg.from === msg.to) {
3516
+ maxMessageWidthPerActor[msg.from] = common_default.getMax(
3517
+ maxMessageWidthPerActor[msg.from] || 0,
3518
+ messageWidth / 2
3519
+ );
3520
+ maxMessageWidthPerActor[msg.to] = common_default.getMax(
3521
+ maxMessageWidthPerActor[msg.to] || 0,
3522
+ messageWidth / 2
3523
+ );
3524
+ } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
3525
+ maxMessageWidthPerActor[msg.from] = common_default.getMax(
3526
+ maxMessageWidthPerActor[msg.from] || 0,
3527
+ messageWidth
3528
+ );
3529
+ } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
3530
+ maxMessageWidthPerActor[actor.prevActor] = common_default.getMax(
3531
+ maxMessageWidthPerActor[actor.prevActor] || 0,
3532
+ messageWidth
3533
+ );
3534
+ } else if (msg.placement === diagObj.db.PLACEMENT.OVER) {
3535
+ if (actor.prevActor) {
3536
+ maxMessageWidthPerActor[actor.prevActor] = common_default.getMax(
3537
+ maxMessageWidthPerActor[actor.prevActor] || 0,
3538
+ messageWidth / 2
3539
+ );
3540
+ }
3541
+ if (actor.nextActor) {
3542
+ maxMessageWidthPerActor[msg.from] = common_default.getMax(
3543
+ maxMessageWidthPerActor[msg.from] || 0,
3544
+ messageWidth / 2
3545
+ );
3546
+ }
3547
+ }
3548
+ }
3549
+ }
3550
+ log.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor);
3551
+ return maxMessageWidthPerActor;
3552
+ }
3553
+ __name(getMaxMessageWidthPerActor, "getMaxMessageWidthPerActor");
3554
+ var getRequiredPopupWidth = /* @__PURE__ */ __name(function(actor) {
3555
+ let requiredPopupWidth = 0;
3556
+ const textFont = actorFont(conf);
3557
+ for (const key in actor.links) {
3558
+ const labelDimensions = utils_default.calculateTextDimensions(key, textFont);
3559
+ const labelWidth = labelDimensions.width + 2 * conf.wrapPadding + 2 * conf.boxMargin;
3560
+ if (requiredPopupWidth < labelWidth) {
3561
+ requiredPopupWidth = labelWidth;
3562
+ }
3563
+ }
3564
+ return requiredPopupWidth;
3565
+ }, "getRequiredPopupWidth");
3566
+ async function calculateActorMargins(actors, actorToMessageWidth, boxes) {
3567
+ let maxHeight = 0;
3568
+ for (const prop of actors.keys()) {
3569
+ const actor = actors.get(prop);
3570
+ if (actor.wrap) {
3571
+ actor.description = utils_default.wrapLabel(
3572
+ actor.description,
3573
+ conf.width - 2 * conf.wrapPadding,
3574
+ actorFont(conf)
3575
+ );
3576
+ }
3577
+ const actDims = hasKatex(actor.description) ? await calculateMathMLDimensions(actor.description, getConfig2()) : utils_default.calculateTextDimensions(actor.description, actorFont(conf));
3578
+ actor.width = actor.wrap ? conf.width : common_default.getMax(conf.width, actDims.width + 2 * conf.wrapPadding);
3579
+ actor.height = actor.wrap ? common_default.getMax(actDims.height, conf.height) : conf.height;
3580
+ maxHeight = common_default.getMax(maxHeight, actor.height);
3581
+ }
3582
+ for (const actorKey in actorToMessageWidth) {
3583
+ const actor = actors.get(actorKey);
3584
+ if (!actor) {
3585
+ continue;
3586
+ }
3587
+ const nextActor = actors.get(actor.nextActor);
3588
+ if (!nextActor) {
3589
+ const messageWidth2 = actorToMessageWidth[actorKey];
3590
+ const actorWidth2 = messageWidth2 + conf.actorMargin - actor.width / 2;
3591
+ actor.margin = common_default.getMax(actorWidth2, conf.actorMargin);
3592
+ continue;
3593
+ }
3594
+ const messageWidth = actorToMessageWidth[actorKey];
3595
+ const actorWidth = messageWidth + conf.actorMargin - actor.width / 2 - nextActor.width / 2;
3596
+ actor.margin = common_default.getMax(actorWidth, conf.actorMargin);
3597
+ }
3598
+ let maxBoxHeight = 0;
3599
+ boxes.forEach((box) => {
3600
+ const textFont = messageFont(conf);
3601
+ let totalWidth = box.actorKeys.reduce((total, aKey) => {
3602
+ return total += actors.get(aKey).width + (actors.get(aKey).margin || 0);
3603
+ }, 0);
3604
+ const standardBoxPadding = conf.boxMargin * 8;
3605
+ totalWidth += standardBoxPadding;
3606
+ totalWidth -= 2 * conf.boxTextMargin;
3607
+ if (box.wrap) {
3608
+ box.name = utils_default.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont);
3609
+ }
3610
+ const boxMsgDimensions = utils_default.calculateTextDimensions(box.name, textFont);
3611
+ maxBoxHeight = common_default.getMax(boxMsgDimensions.height, maxBoxHeight);
3612
+ const minWidth = common_default.getMax(totalWidth, boxMsgDimensions.width + 2 * conf.wrapPadding);
3613
+ box.margin = conf.boxTextMargin;
3614
+ if (totalWidth < minWidth) {
3615
+ const missing = (minWidth - totalWidth) / 2;
3616
+ box.margin += missing;
3617
+ }
3618
+ });
3619
+ boxes.forEach((box) => box.textMaxHeight = maxBoxHeight);
3620
+ return common_default.getMax(maxHeight, conf.height);
3621
+ }
3622
+ __name(calculateActorMargins, "calculateActorMargins");
3623
+ var buildNoteModel = /* @__PURE__ */ __name(async function(msg, actors, diagObj) {
3624
+ const fromActor = actors.get(msg.from);
3625
+ const toActor = actors.get(msg.to);
3626
+ const startx = fromActor.x;
3627
+ const stopx = toActor.x;
3628
+ const shouldWrap = msg.wrap && msg.message;
3629
+ let textDimensions = hasKatex(msg.message) ? await calculateMathMLDimensions(msg.message, getConfig2()) : utils_default.calculateTextDimensions(
3630
+ shouldWrap ? utils_default.wrapLabel(msg.message, conf.width, noteFont(conf)) : msg.message,
3631
+ noteFont(conf)
3632
+ );
3633
+ const noteModel = {
3634
+ width: shouldWrap ? conf.width : common_default.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin),
3635
+ height: 0,
3636
+ startx: fromActor.x,
3637
+ stopx: 0,
3638
+ starty: 0,
3639
+ stopy: 0,
3640
+ message: msg.message
3641
+ };
3642
+ if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
3643
+ noteModel.width = shouldWrap ? common_default.getMax(conf.width, textDimensions.width) : common_default.getMax(
3644
+ fromActor.width / 2 + toActor.width / 2,
3645
+ textDimensions.width + 2 * conf.noteMargin
3646
+ );
3647
+ noteModel.startx = startx + (fromActor.width + conf.actorMargin) / 2;
3648
+ } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
3649
+ noteModel.width = shouldWrap ? common_default.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common_default.getMax(
3650
+ fromActor.width / 2 + toActor.width / 2,
3651
+ textDimensions.width + 2 * conf.noteMargin
3652
+ );
3653
+ noteModel.startx = startx - noteModel.width + (fromActor.width - conf.actorMargin) / 2;
3654
+ } else if (msg.to === msg.from) {
3655
+ textDimensions = utils_default.calculateTextDimensions(
3656
+ shouldWrap ? utils_default.wrapLabel(msg.message, common_default.getMax(conf.width, fromActor.width), noteFont(conf)) : msg.message,
3657
+ noteFont(conf)
3658
+ );
3659
+ noteModel.width = shouldWrap ? common_default.getMax(conf.width, fromActor.width) : common_default.getMax(fromActor.width, conf.width, textDimensions.width + 2 * conf.noteMargin);
3660
+ noteModel.startx = startx + (fromActor.width - noteModel.width) / 2;
3661
+ } else {
3662
+ noteModel.width = Math.abs(startx + fromActor.width / 2 - (stopx + toActor.width / 2)) + conf.actorMargin;
3663
+ noteModel.startx = startx < stopx ? startx + fromActor.width / 2 - conf.actorMargin / 2 : stopx + toActor.width / 2 - conf.actorMargin / 2;
3664
+ }
3665
+ if (shouldWrap) {
3666
+ noteModel.message = utils_default.wrapLabel(
3667
+ msg.message,
3668
+ noteModel.width - 2 * conf.wrapPadding,
3669
+ noteFont(conf)
3670
+ );
3671
+ }
3672
+ log.debug(
3673
+ `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]`
3674
+ );
3675
+ return noteModel;
3676
+ }, "buildNoteModel");
3677
+ var buildMessageModel = /* @__PURE__ */ __name(function(msg, actors, diagObj) {
3678
+ if (![
3679
+ diagObj.db.LINETYPE.SOLID_OPEN,
3680
+ diagObj.db.LINETYPE.DOTTED_OPEN,
3681
+ diagObj.db.LINETYPE.SOLID,
3682
+ diagObj.db.LINETYPE.DOTTED,
3683
+ diagObj.db.LINETYPE.SOLID_CROSS,
3684
+ diagObj.db.LINETYPE.DOTTED_CROSS,
3685
+ diagObj.db.LINETYPE.SOLID_POINT,
3686
+ diagObj.db.LINETYPE.DOTTED_POINT,
3687
+ diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID,
3688
+ diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED
3689
+ ].includes(msg.type)) {
3690
+ return {};
3691
+ }
3692
+ const [fromLeft, fromRight] = activationBounds(msg.from, actors);
3693
+ const [toLeft, toRight] = activationBounds(msg.to, actors);
3694
+ const isArrowToRight = fromLeft <= toLeft;
3695
+ let startx = isArrowToRight ? fromRight : fromLeft;
3696
+ let stopx = isArrowToRight ? toLeft : toRight;
3697
+ const isArrowToActivation = Math.abs(toLeft - toRight) > 2;
3698
+ const adjustValue = /* @__PURE__ */ __name((value) => {
3699
+ return isArrowToRight ? -value : value;
3700
+ }, "adjustValue");
3701
+ if (msg.from === msg.to) {
3702
+ stopx = startx;
3703
+ } else {
3704
+ if (msg.activate && !isArrowToActivation) {
3705
+ stopx += adjustValue(conf.activationWidth / 2 - 1);
3706
+ }
3707
+ if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) {
3708
+ stopx += adjustValue(3);
3709
+ }
3710
+ if ([diagObj.db.LINETYPE.BIDIRECTIONAL_SOLID, diagObj.db.LINETYPE.BIDIRECTIONAL_DOTTED].includes(
3711
+ msg.type
3712
+ )) {
3713
+ startx -= adjustValue(3);
3714
+ }
3715
+ }
3716
+ const allBounds = [fromLeft, fromRight, toLeft, toRight];
3717
+ const boundedWidth = Math.abs(startx - stopx);
3718
+ if (msg.wrap && msg.message) {
3719
+ msg.message = utils_default.wrapLabel(
3720
+ msg.message,
3721
+ common_default.getMax(boundedWidth + 2 * conf.wrapPadding, conf.width),
3722
+ messageFont(conf)
3723
+ );
3724
+ }
3725
+ const msgDims = utils_default.calculateTextDimensions(msg.message, messageFont(conf));
3726
+ return {
3727
+ width: common_default.getMax(
3728
+ msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding,
3729
+ boundedWidth + 2 * conf.wrapPadding,
3730
+ conf.width
3731
+ ),
3732
+ height: 0,
3733
+ startx,
3734
+ stopx,
3735
+ starty: 0,
3736
+ stopy: 0,
3737
+ message: msg.message,
3738
+ type: msg.type,
3739
+ wrap: msg.wrap,
3740
+ fromBounds: Math.min.apply(null, allBounds),
3741
+ toBounds: Math.max.apply(null, allBounds)
3742
+ };
3743
+ }, "buildMessageModel");
3744
+ var calculateLoopBounds = /* @__PURE__ */ __name(async function(messages, actors, _maxWidthPerActor, diagObj) {
3745
+ const loops = {};
3746
+ const stack = [];
3747
+ let current, noteModel, msgModel;
3748
+ for (const msg of messages) {
3749
+ switch (msg.type) {
3750
+ case diagObj.db.LINETYPE.LOOP_START:
3751
+ case diagObj.db.LINETYPE.ALT_START:
3752
+ case diagObj.db.LINETYPE.OPT_START:
3753
+ case diagObj.db.LINETYPE.PAR_START:
3754
+ case diagObj.db.LINETYPE.PAR_OVER_START:
3755
+ case diagObj.db.LINETYPE.CRITICAL_START:
3756
+ case diagObj.db.LINETYPE.BREAK_START:
3757
+ stack.push({
3758
+ id: msg.id,
3759
+ msg: msg.message,
3760
+ from: Number.MAX_SAFE_INTEGER,
3761
+ to: Number.MIN_SAFE_INTEGER,
3762
+ width: 0
3763
+ });
3764
+ break;
3765
+ case diagObj.db.LINETYPE.ALT_ELSE:
3766
+ case diagObj.db.LINETYPE.PAR_AND:
3767
+ case diagObj.db.LINETYPE.CRITICAL_OPTION:
3768
+ if (msg.message) {
3769
+ current = stack.pop();
3770
+ loops[current.id] = current;
3771
+ loops[msg.id] = current;
3772
+ stack.push(current);
3773
+ }
3774
+ break;
3775
+ case diagObj.db.LINETYPE.LOOP_END:
3776
+ case diagObj.db.LINETYPE.ALT_END:
3777
+ case diagObj.db.LINETYPE.OPT_END:
3778
+ case diagObj.db.LINETYPE.PAR_END:
3779
+ case diagObj.db.LINETYPE.CRITICAL_END:
3780
+ case diagObj.db.LINETYPE.BREAK_END:
3781
+ current = stack.pop();
3782
+ loops[current.id] = current;
3783
+ break;
3784
+ case diagObj.db.LINETYPE.ACTIVE_START:
3785
+ {
3786
+ const actorRect = actors.get(msg.from ? msg.from : msg.to.actor);
3787
+ const stackedSize = actorActivations(msg.from ? msg.from : msg.to.actor).length;
3788
+ const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
3789
+ const toAdd = {
3790
+ startx: x,
3791
+ stopx: x + conf.activationWidth,
3792
+ actor: msg.from,
3793
+ enabled: true
3794
+ };
3795
+ bounds.activations.push(toAdd);
3796
+ }
3797
+ break;
3798
+ case diagObj.db.LINETYPE.ACTIVE_END:
3799
+ {
3800
+ const lastActorActivationIdx = bounds.activations.map((a) => a.actor).lastIndexOf(msg.from);
3801
+ bounds.activations.splice(lastActorActivationIdx, 1).splice(0, 1);
3802
+ }
3803
+ break;
3804
+ }
3805
+ const isNote = msg.placement !== void 0;
3806
+ if (isNote) {
3807
+ noteModel = await buildNoteModel(msg, actors, diagObj);
3808
+ msg.noteModel = noteModel;
3809
+ stack.forEach((stk) => {
3810
+ current = stk;
3811
+ current.from = common_default.getMin(current.from, noteModel.startx);
3812
+ current.to = common_default.getMax(current.to, noteModel.startx + noteModel.width);
3813
+ current.width = common_default.getMax(current.width, Math.abs(current.from - current.to)) - conf.labelBoxWidth;
3814
+ });
3815
+ } else {
3816
+ msgModel = buildMessageModel(msg, actors, diagObj);
3817
+ msg.msgModel = msgModel;
3818
+ if (msgModel.startx && msgModel.stopx && stack.length > 0) {
3819
+ stack.forEach((stk) => {
3820
+ current = stk;
3821
+ if (msgModel.startx === msgModel.stopx) {
3822
+ const from = actors.get(msg.from);
3823
+ const to = actors.get(msg.to);
3824
+ current.from = common_default.getMin(
3825
+ from.x - msgModel.width / 2,
3826
+ from.x - from.width / 2,
3827
+ current.from
3828
+ );
3829
+ current.to = common_default.getMax(
3830
+ to.x + msgModel.width / 2,
3831
+ to.x + from.width / 2,
3832
+ current.to
3833
+ );
3834
+ current.width = common_default.getMax(current.width, Math.abs(current.to - current.from)) - conf.labelBoxWidth;
3835
+ } else {
3836
+ current.from = common_default.getMin(msgModel.startx, current.from);
3837
+ current.to = common_default.getMax(msgModel.stopx, current.to);
3838
+ current.width = common_default.getMax(current.width, msgModel.width) - conf.labelBoxWidth;
3839
+ }
3840
+ });
3841
+ }
3842
+ }
3843
+ }
3844
+ bounds.activations = [];
3845
+ log.debug("Loop type widths:", loops);
3846
+ return loops;
3847
+ }, "calculateLoopBounds");
3848
+ var sequenceRenderer_default = {
3849
+ bounds,
3850
+ drawActors,
3851
+ drawActorsPopup,
3852
+ setConf,
3853
+ draw
3854
+ };
3855
+ var diagram = {
3856
+ parser: sequenceDiagram_default,
3857
+ get db() {
3858
+ return new SequenceDB();
3859
+ },
3860
+ renderer: sequenceRenderer_default,
3861
+ styles: styles_default,
3862
+ init: /* @__PURE__ */ __name((cnf) => {
3863
+ if (!cnf.sequence) {
3864
+ cnf.sequence = {};
3865
+ }
3866
+ if (cnf.wrap) {
3867
+ cnf.sequence.wrap = cnf.wrap;
3868
+ setConfig2({ sequence: { wrap: cnf.wrap } });
3869
+ }
3870
+ }, "init")
3871
+ };
3872
+ export {
3873
+ diagram
3874
+ };
3875
+ //# sourceMappingURL=sequenceDiagram-WL72ISMW-oXU2lRh_.js.map