research-copilot 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 (395) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/app/build/icon.icns +0 -0
  4. package/app/build/icon.ico +0 -0
  5. package/app/build/icon.png +0 -0
  6. package/app/out/main/index.mjs +6719 -0
  7. package/app/out/preload/index.js +141 -0
  8. package/app/out/renderer/assets/Inter-Variable-Latin-8kRkwJBP.woff2 +0 -0
  9. package/app/out/renderer/assets/Inter-Variable-LatinExt-B_-bZUTo.woff2 +0 -0
  10. package/app/out/renderer/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  11. package/app/out/renderer/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  12. package/app/out/renderer/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  13. package/app/out/renderer/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  14. package/app/out/renderer/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  15. package/app/out/renderer/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  16. package/app/out/renderer/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  17. package/app/out/renderer/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  18. package/app/out/renderer/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  19. package/app/out/renderer/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  20. package/app/out/renderer/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  21. package/app/out/renderer/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  22. package/app/out/renderer/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  23. package/app/out/renderer/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  24. package/app/out/renderer/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  25. package/app/out/renderer/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  26. package/app/out/renderer/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  27. package/app/out/renderer/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  28. package/app/out/renderer/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  29. package/app/out/renderer/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  30. package/app/out/renderer/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  31. package/app/out/renderer/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  32. package/app/out/renderer/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  33. package/app/out/renderer/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  34. package/app/out/renderer/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  35. package/app/out/renderer/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  36. package/app/out/renderer/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  37. package/app/out/renderer/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  38. package/app/out/renderer/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  39. package/app/out/renderer/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  40. package/app/out/renderer/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  41. package/app/out/renderer/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  42. package/app/out/renderer/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  43. package/app/out/renderer/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  44. package/app/out/renderer/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  45. package/app/out/renderer/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  46. package/app/out/renderer/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  47. package/app/out/renderer/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  48. package/app/out/renderer/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  49. package/app/out/renderer/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  50. package/app/out/renderer/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  51. package/app/out/renderer/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  52. package/app/out/renderer/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  53. package/app/out/renderer/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  54. package/app/out/renderer/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  55. package/app/out/renderer/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  56. package/app/out/renderer/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  57. package/app/out/renderer/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  58. package/app/out/renderer/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  59. package/app/out/renderer/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  60. package/app/out/renderer/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  61. package/app/out/renderer/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  62. package/app/out/renderer/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  63. package/app/out/renderer/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  64. package/app/out/renderer/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  65. package/app/out/renderer/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  66. package/app/out/renderer/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  67. package/app/out/renderer/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  68. package/app/out/renderer/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  69. package/app/out/renderer/assets/MilkdownMarkdownEditor-bLPxrCVb.js +89821 -0
  70. package/app/out/renderer/assets/MilkdownMarkdownEditor-tTNRIB2K.css +2555 -0
  71. package/app/out/renderer/assets/Tableau10-BqnYsPR6.js +9 -0
  72. package/app/out/renderer/assets/apl-fqmucPXA.js +140 -0
  73. package/app/out/renderer/assets/arc-J47ePHZ2.js +132 -0
  74. package/app/out/renderer/assets/array-DgktLKBx.js +6 -0
  75. package/app/out/renderer/assets/asciiarmor-DucZyvP0.js +56 -0
  76. package/app/out/renderer/assets/asn1-BnOEsgAm.js +144 -0
  77. package/app/out/renderer/assets/asterisk-QAlztEwS.js +345 -0
  78. package/app/out/renderer/assets/blockDiagram-c4efeb88-5uRQXgQJ.js +1817 -0
  79. package/app/out/renderer/assets/brainfuck-DZVCuF_t.js +53 -0
  80. package/app/out/renderer/assets/c4Diagram-c83219d4-C4iCTPEL.js +2464 -0
  81. package/app/out/renderer/assets/channel-ZAmhHE3g.js +7 -0
  82. package/app/out/renderer/assets/classDiagram-beda092f-7NOZxq_W.js +357 -0
  83. package/app/out/renderer/assets/classDiagram-v2-2358418a-5fPT-cUH.js +291 -0
  84. package/app/out/renderer/assets/clike-xqXYL6ge.js +805 -0
  85. package/app/out/renderer/assets/clojure-BhXMqnxz.js +849 -0
  86. package/app/out/renderer/assets/clone-CsnzsYXQ.js +8 -0
  87. package/app/out/renderer/assets/cmake-BGaNd9E7.js +71 -0
  88. package/app/out/renderer/assets/cobol-4yqQntpt.js +120 -0
  89. package/app/out/renderer/assets/coffeescript-D2dXvhEc.js +308 -0
  90. package/app/out/renderer/assets/commonlisp-CF_VNHQR.js +130 -0
  91. package/app/out/renderer/assets/createText-1719965b-Cji7KN4K.js +4904 -0
  92. package/app/out/renderer/assets/crystal-DyuLTqLs.js +398 -0
  93. package/app/out/renderer/assets/css-c-jst79C.js +1783 -0
  94. package/app/out/renderer/assets/cypher-Dlu_3r4V.js +121 -0
  95. package/app/out/renderer/assets/d-UURgV0Ux.js +179 -0
  96. package/app/out/renderer/assets/diff-B_Bi2Crb.js +25 -0
  97. package/app/out/renderer/assets/dockerfile-Bvk733Ga.js +201 -0
  98. package/app/out/renderer/assets/dtd-Dy74G54E.js +114 -0
  99. package/app/out/renderer/assets/dylan-TSb-Nfix.js +314 -0
  100. package/app/out/renderer/assets/ebnf-DAomQUbD.js +139 -0
  101. package/app/out/renderer/assets/ecl-B59qGGVg.js +178 -0
  102. package/app/out/renderer/assets/edges-96097737-CD0EvAZQ.js +1844 -0
  103. package/app/out/renderer/assets/eiffel-Dze7nlu3.js +134 -0
  104. package/app/out/renderer/assets/elm-DG7jkhNZ.js +176 -0
  105. package/app/out/renderer/assets/erDiagram-0228fc6a-DRYXBpi7.js +1321 -0
  106. package/app/out/renderer/assets/erlang-BO6gOnGA.js +674 -0
  107. package/app/out/renderer/assets/factor-CMxFHDqz.js +65 -0
  108. package/app/out/renderer/assets/fcl-CDDUNjTj.js +141 -0
  109. package/app/out/renderer/assets/flowDb-c6c81e3f-CuoIN-Cy.js +1713 -0
  110. package/app/out/renderer/assets/flowDiagram-50d868cf-CPWPLOml.js +1272 -0
  111. package/app/out/renderer/assets/flowDiagram-v2-4f6560a1-C_R12s4S.js +33 -0
  112. package/app/out/renderer/assets/flowchart-elk-definition-6af322e1-BdKUSFpi.js +92921 -0
  113. package/app/out/renderer/assets/forth-B9D2JCeE.js +116 -0
  114. package/app/out/renderer/assets/fortran-CAG2BFbe.js +467 -0
  115. package/app/out/renderer/assets/ganttDiagram-a2739b55-ygqT5HlG.js +3399 -0
  116. package/app/out/renderer/assets/gas-d3KEcW3x.js +294 -0
  117. package/app/out/renderer/assets/gherkin-DhZlEZiy.js +115 -0
  118. package/app/out/renderer/assets/gitGraphDiagram-82fe8481-D97GT4iA.js +1791 -0
  119. package/app/out/renderer/assets/graph-DpC13d95.js +1237 -0
  120. package/app/out/renderer/assets/groovy-CpwJiBl7.js +223 -0
  121. package/app/out/renderer/assets/haskell-BlGBCCe3.js +459 -0
  122. package/app/out/renderer/assets/haxe-7MlzfeYV.js +514 -0
  123. package/app/out/renderer/assets/http-BqypyemW.js +79 -0
  124. package/app/out/renderer/assets/idl-4HIGJlDI.js +985 -0
  125. package/app/out/renderer/assets/index-4-ziknCv.js +292 -0
  126. package/app/out/renderer/assets/index-5325376f-Bbs7Fbqr.js +663 -0
  127. package/app/out/renderer/assets/index-B2jip-rk.js +2489 -0
  128. package/app/out/renderer/assets/index-BKTVfokE.js +312 -0
  129. package/app/out/renderer/assets/index-BiJbFgVG.js +118 -0
  130. package/app/out/renderer/assets/index-Bn433Fat.js +83 -0
  131. package/app/out/renderer/assets/index-BqDyyRCx.js +39679 -0
  132. package/app/out/renderer/assets/index-BzFMeMPn.js +158 -0
  133. package/app/out/renderer/assets/index-C-_uCjZJ.css +2701 -0
  134. package/app/out/renderer/assets/index-C1ithNW1.js +1765 -0
  135. package/app/out/renderer/assets/index-CAJkRYkO.js +407 -0
  136. package/app/out/renderer/assets/index-CleO0-yj.js +690 -0
  137. package/app/out/renderer/assets/index-Cq4MH3sY.js +1020 -0
  138. package/app/out/renderer/assets/index-CtA0Xj22.js +705 -0
  139. package/app/out/renderer/assets/index-CvAZkqBZ.js +83 -0
  140. package/app/out/renderer/assets/index-D3UDN-5c.js +152 -0
  141. package/app/out/renderer/assets/index-D4F9R5ao.js +179 -0
  142. package/app/out/renderer/assets/index-D6RguhZ5.js +328 -0
  143. package/app/out/renderer/assets/index-DnEowqXv.js +386 -0
  144. package/app/out/renderer/assets/index-K8c8Mqdy.js +98 -0
  145. package/app/out/renderer/assets/index-Kh14gO6K.js +62 -0
  146. package/app/out/renderer/assets/index-WFd2jRnA.js +333 -0
  147. package/app/out/renderer/assets/index-WgMfkRFp.js +313 -0
  148. package/app/out/renderer/assets/index-Y4lKyF6t.js +1042 -0
  149. package/app/out/renderer/assets/index-fx307_f1.js +643 -0
  150. package/app/out/renderer/assets/infoDiagram-8eee0895-ptaVSwzq.js +511 -0
  151. package/app/out/renderer/assets/init-ZxktEp_H.js +16 -0
  152. package/app/out/renderer/assets/javascript-C3MnDRiU.js +994 -0
  153. package/app/out/renderer/assets/journeyDiagram-c64418c1-aloEGOQp.js +1184 -0
  154. package/app/out/renderer/assets/julia-Bs6JJhYG.js +407 -0
  155. package/app/out/renderer/assets/layout-ZeuHE_aY.js +2217 -0
  156. package/app/out/renderer/assets/line-CAgaGl-S.js +45 -0
  157. package/app/out/renderer/assets/linear-DIg7lTe1.js +539 -0
  158. package/app/out/renderer/assets/livescript-DmzgM3Yt.js +296 -0
  159. package/app/out/renderer/assets/lua-8cJgIlqe.js +256 -0
  160. package/app/out/renderer/assets/mathematica-DNLOL9PQ.js +110 -0
  161. package/app/out/renderer/assets/mbox-Ga7d4MMN.js +117 -0
  162. package/app/out/renderer/assets/mindmap-definition-8da855dc-B8XVoUxz.js +36054 -0
  163. package/app/out/renderer/assets/mirc-Dma3B8rS.js +107 -0
  164. package/app/out/renderer/assets/mllike-DHn7xckP.js +334 -0
  165. package/app/out/renderer/assets/modelica-0d55jYY0.js +147 -0
  166. package/app/out/renderer/assets/mscgen-DdqZYINH.js +135 -0
  167. package/app/out/renderer/assets/mumps-Btr8VblO.js +93 -0
  168. package/app/out/renderer/assets/nginx-DTDtBDVN.js +141 -0
  169. package/app/out/renderer/assets/nsis-3zG7tgur.js +62 -0
  170. package/app/out/renderer/assets/ntriples-CvgOYMpL.js +153 -0
  171. package/app/out/renderer/assets/octave-DYBj3-tl.js +200 -0
  172. package/app/out/renderer/assets/ordinal-DSZU4PqD.js +76 -0
  173. package/app/out/renderer/assets/oz-R_e8WMIi.js +231 -0
  174. package/app/out/renderer/assets/pascal-GD8iposT.js +105 -0
  175. package/app/out/renderer/assets/path-Cp2qmpkd.js +109 -0
  176. package/app/out/renderer/assets/perl-DL9mHpoi.js +1105 -0
  177. package/app/out/renderer/assets/pieDiagram-a8764435-DlwoeBU2.js +770 -0
  178. package/app/out/renderer/assets/pig-C_4T4YIV.js +101 -0
  179. package/app/out/renderer/assets/powershell-B0suO7Vd.js +328 -0
  180. package/app/out/renderer/assets/properties-BR-vP1aU.js +58 -0
  181. package/app/out/renderer/assets/protobuf-BxgpyhoW.js +77 -0
  182. package/app/out/renderer/assets/pug-By0kVCfm.js +405 -0
  183. package/app/out/renderer/assets/puppet-Bdao66PW.js +137 -0
  184. package/app/out/renderer/assets/python-CvWbmiX4.js +427 -0
  185. package/app/out/renderer/assets/q-CrbCVq4a.js +131 -0
  186. package/app/out/renderer/assets/quadrantDiagram-1e28029f-BaSi1XB4.js +1200 -0
  187. package/app/out/renderer/assets/r-V7nswm59.js +170 -0
  188. package/app/out/renderer/assets/requirementDiagram-08caed73-D3EFyegZ.js +1092 -0
  189. package/app/out/renderer/assets/rpm-C-DLY-If.js +109 -0
  190. package/app/out/renderer/assets/ruby-JDKLJNK0.js +330 -0
  191. package/app/out/renderer/assets/sankeyDiagram-a04cb91d-Cv44AsnM.js +1174 -0
  192. package/app/out/renderer/assets/sas-D2UG-yhZ.js +207 -0
  193. package/app/out/renderer/assets/scheme-BKzrkGJD.js +222 -0
  194. package/app/out/renderer/assets/sequenceDiagram-c5b8d532-CuUBu-x4.js +3337 -0
  195. package/app/out/renderer/assets/shell-BlsXDxCn.js +222 -0
  196. package/app/out/renderer/assets/sieve-CjwBwOY5.js +135 -0
  197. package/app/out/renderer/assets/simple-mode-DMneyfDu.js +130 -0
  198. package/app/out/renderer/assets/smalltalk-BOIGQuhN.js +121 -0
  199. package/app/out/renderer/assets/solr-CwD7U71z.js +69 -0
  200. package/app/out/renderer/assets/sparql-DYskk2vE.js +249 -0
  201. package/app/out/renderer/assets/spreadsheet-Bgtt3oLP.js +87 -0
  202. package/app/out/renderer/assets/sql-BSrOzCRI.js +354 -0
  203. package/app/out/renderer/assets/stateDiagram-1ecb1508-BOU34Zp4.js +454 -0
  204. package/app/out/renderer/assets/stateDiagram-v2-c2b004d7-BgRoffou.js +326 -0
  205. package/app/out/renderer/assets/stex-B6LNC55o.js +231 -0
  206. package/app/out/renderer/assets/styles-b4e223ce-BMr9TPuj.js +1483 -0
  207. package/app/out/renderer/assets/styles-ca3715f6-DgbNw99p.js +1363 -0
  208. package/app/out/renderer/assets/styles-d45a18b0-DtRYKYKf.js +574 -0
  209. package/app/out/renderer/assets/stylus-BkS-boTH.js +565 -0
  210. package/app/out/renderer/assets/svgDrawCommon-b86b1483-Bein03PD.js +100 -0
  211. package/app/out/renderer/assets/swift-FRZi1uvB.js +291 -0
  212. package/app/out/renderer/assets/tcl-CUcaCdmq.js +114 -0
  213. package/app/out/renderer/assets/textile-BnFpjsrl.js +414 -0
  214. package/app/out/renderer/assets/tiddlywiki-CjprD-Qp.js +218 -0
  215. package/app/out/renderer/assets/tiki-B4EPSQ1G.js +265 -0
  216. package/app/out/renderer/assets/timeline-definition-faaaa080-BlWpLE_4.js +1212 -0
  217. package/app/out/renderer/assets/toml-BOuWGMcf.js +76 -0
  218. package/app/out/renderer/assets/troff-E1bJ0PPL.js +61 -0
  219. package/app/out/renderer/assets/ttcn-cfg-Dc39-fIP.js +133 -0
  220. package/app/out/renderer/assets/ttcn-tKd4HLu4.js +192 -0
  221. package/app/out/renderer/assets/turtle-Dq7-1WAf.js +124 -0
  222. package/app/out/renderer/assets/vb-Dp90gtsv.js +196 -0
  223. package/app/out/renderer/assets/vbscript-CI6_mxxU.js +479 -0
  224. package/app/out/renderer/assets/velocity-BwIZK1TH.js +149 -0
  225. package/app/out/renderer/assets/verilog-DDCYnHN8.js +430 -0
  226. package/app/out/renderer/assets/vhdl-DCkMIyT9.js +158 -0
  227. package/app/out/renderer/assets/webidl-BTLTThCm.js +204 -0
  228. package/app/out/renderer/assets/xquery-BgiOC5Ce.js +525 -0
  229. package/app/out/renderer/assets/xychartDiagram-f5964ef8-Bhga-YXm.js +1799 -0
  230. package/app/out/renderer/assets/yacas-b5lAVEIl.js +130 -0
  231. package/app/out/renderer/assets/z80-BZV19vqv.js +93 -0
  232. package/app/out/renderer/index.html +13 -0
  233. package/app/out/skills/community-builtin/README.md +29 -0
  234. package/app/out/skills/community-builtin/document-docx/SKILL.md +44 -0
  235. package/app/out/skills/community-builtin/document-docx/scripts/docx-to-markdown.sh +20 -0
  236. package/app/out/skills/community-builtin/document-docx/scripts/extract-docx-text.sh +28 -0
  237. package/app/out/skills/community-builtin/document-docx/scripts/init-docx-template.sh +32 -0
  238. package/app/out/skills/community-builtin/document-docx/scripts/setup-docx-tools.sh +10 -0
  239. package/app/out/skills/community-builtin/markitdown/SKILL.md +105 -0
  240. package/app/out/skills/community-builtin/markitdown/scripts/batch-convert.sh +40 -0
  241. package/app/out/skills/community-builtin/markitdown/scripts/convert-file.sh +24 -0
  242. package/app/out/skills/community-builtin/markitdown/scripts/setup-markitdown.sh +10 -0
  243. package/app/out/skills/community-builtin/repo-quick-audit/SKILL.md +27 -0
  244. package/app/out/skills/community-builtin/repo-quick-audit/scripts/audit-basics.sh +19 -0
  245. package/app/out/skills/research-pilot-default-project-skills/README.md +23 -0
  246. package/app/out/skills/research-pilot-default-project-skills/citation-management/SKILL.md +39 -0
  247. package/app/out/skills/research-pilot-default-project-skills/citation-management/scripts/doi-to-bibtex.sh +25 -0
  248. package/app/out/skills/research-pilot-default-project-skills/citation-management/scripts/normalize-bibtex-keys.sh +51 -0
  249. package/app/out/skills/research-pilot-default-project-skills/citation-management/scripts/setup-citation-tools.sh +10 -0
  250. package/app/out/skills/research-pilot-default-project-skills/citation-management/scripts/validate-bib.sh +31 -0
  251. package/app/out/skills/research-pilot-default-project-skills/matplotlib/SKILL.md +34 -0
  252. package/app/out/skills/research-pilot-default-project-skills/matplotlib/references/api_reference.md +412 -0
  253. package/app/out/skills/research-pilot-default-project-skills/matplotlib/references/common_issues.md +563 -0
  254. package/app/out/skills/research-pilot-default-project-skills/matplotlib/references/plot_types.md +476 -0
  255. package/app/out/skills/research-pilot-default-project-skills/matplotlib/references/styling_guide.md +589 -0
  256. package/app/out/skills/research-pilot-default-project-skills/matplotlib/references/subagent_quickstart.md +30 -0
  257. package/app/out/skills/research-pilot-default-project-skills/matplotlib/scripts/plot_template.py +401 -0
  258. package/app/out/skills/research-pilot-default-project-skills/matplotlib/scripts/style_configurator.py +409 -0
  259. package/app/out/skills/research-pilot-default-project-skills/research-grants/SKILL.md +38 -0
  260. package/app/out/skills/research-pilot-default-project-skills/research-grants/scripts/check-grant-compliance.sh +40 -0
  261. package/app/out/skills/research-pilot-default-project-skills/research-grants/scripts/grant-summary-card.sh +32 -0
  262. package/app/out/skills/research-pilot-default-project-skills/research-grants/scripts/init-grant-structure.sh +70 -0
  263. package/app/package.json +77 -0
  264. package/bin/cli.mjs +56 -0
  265. package/lib/README.md +145 -0
  266. package/lib/skills/_generated.ts +13 -0
  267. package/lib/skills/builtin/brainstorming-research-ideas/SKILL.md +280 -0
  268. package/lib/skills/builtin/coding/SKILL.md +114 -0
  269. package/lib/skills/builtin/creative-thinking-for-research/SKILL.md +273 -0
  270. package/lib/skills/builtin/matplotlib/SKILL.md +361 -0
  271. package/lib/skills/builtin/matplotlib/references/api_reference.md +412 -0
  272. package/lib/skills/builtin/matplotlib/references/common_issues.md +563 -0
  273. package/lib/skills/builtin/matplotlib/references/plot_types.md +476 -0
  274. package/lib/skills/builtin/matplotlib/references/styling_guide.md +589 -0
  275. package/lib/skills/builtin/matplotlib/scripts/plot_template.py +401 -0
  276. package/lib/skills/builtin/matplotlib/scripts/style_configurator.py +409 -0
  277. package/lib/skills/builtin/paper-writing/SKILL.md +554 -0
  278. package/lib/skills/builtin/paper-writing/references/checklists.md +524 -0
  279. package/lib/skills/builtin/paper-writing/references/citation-workflow.md +562 -0
  280. package/lib/skills/builtin/paper-writing/references/reviewer-guidelines.md +462 -0
  281. package/lib/skills/builtin/paper-writing/references/sources.md +189 -0
  282. package/lib/skills/builtin/paper-writing/references/systems-conferences.md +260 -0
  283. package/lib/skills/builtin/paper-writing/references/writing-guide.md +476 -0
  284. package/lib/skills/builtin/paper-writing/templates/README.md +408 -0
  285. package/lib/skills/builtin/paper-writing/templates/aaai2026/README.md +534 -0
  286. package/lib/skills/builtin/paper-writing/templates/aaai2026/aaai2026-unified-supp.tex +144 -0
  287. package/lib/skills/builtin/paper-writing/templates/aaai2026/aaai2026-unified-template.tex +952 -0
  288. package/lib/skills/builtin/paper-writing/templates/aaai2026/aaai2026.bib +111 -0
  289. package/lib/skills/builtin/paper-writing/templates/aaai2026/aaai2026.bst +1493 -0
  290. package/lib/skills/builtin/paper-writing/templates/aaai2026/aaai2026.sty +315 -0
  291. package/lib/skills/builtin/paper-writing/templates/acl/README.md +50 -0
  292. package/lib/skills/builtin/paper-writing/templates/acl/acl.sty +312 -0
  293. package/lib/skills/builtin/paper-writing/templates/acl/acl_latex.tex +377 -0
  294. package/lib/skills/builtin/paper-writing/templates/acl/acl_lualatex.tex +101 -0
  295. package/lib/skills/builtin/paper-writing/templates/acl/acl_natbib.bst +1940 -0
  296. package/lib/skills/builtin/paper-writing/templates/acl/anthology.bib.txt +26 -0
  297. package/lib/skills/builtin/paper-writing/templates/acl/custom.bib +70 -0
  298. package/lib/skills/builtin/paper-writing/templates/acl/formatting.md +326 -0
  299. package/lib/skills/builtin/paper-writing/templates/asplos2027/main.tex +459 -0
  300. package/lib/skills/builtin/paper-writing/templates/asplos2027/references.bib +135 -0
  301. package/lib/skills/builtin/paper-writing/templates/colm2025/README.md +3 -0
  302. package/lib/skills/builtin/paper-writing/templates/colm2025/colm2025_conference.bib +11 -0
  303. package/lib/skills/builtin/paper-writing/templates/colm2025/colm2025_conference.bst +1440 -0
  304. package/lib/skills/builtin/paper-writing/templates/colm2025/colm2025_conference.pdf +0 -0
  305. package/lib/skills/builtin/paper-writing/templates/colm2025/colm2025_conference.sty +218 -0
  306. package/lib/skills/builtin/paper-writing/templates/colm2025/colm2025_conference.tex +305 -0
  307. package/lib/skills/builtin/paper-writing/templates/colm2025/fancyhdr.sty +485 -0
  308. package/lib/skills/builtin/paper-writing/templates/colm2025/math_commands.tex +508 -0
  309. package/lib/skills/builtin/paper-writing/templates/colm2025/natbib.sty +1246 -0
  310. package/lib/skills/builtin/paper-writing/templates/iclr2026/fancyhdr.sty +485 -0
  311. package/lib/skills/builtin/paper-writing/templates/iclr2026/iclr2026_conference.bib +24 -0
  312. package/lib/skills/builtin/paper-writing/templates/iclr2026/iclr2026_conference.bst +1440 -0
  313. package/lib/skills/builtin/paper-writing/templates/iclr2026/iclr2026_conference.pdf +0 -0
  314. package/lib/skills/builtin/paper-writing/templates/iclr2026/iclr2026_conference.sty +246 -0
  315. package/lib/skills/builtin/paper-writing/templates/iclr2026/iclr2026_conference.tex +414 -0
  316. package/lib/skills/builtin/paper-writing/templates/iclr2026/math_commands.tex +508 -0
  317. package/lib/skills/builtin/paper-writing/templates/iclr2026/natbib.sty +1246 -0
  318. package/lib/skills/builtin/paper-writing/templates/icml2026/algorithm.sty +79 -0
  319. package/lib/skills/builtin/paper-writing/templates/icml2026/algorithmic.sty +201 -0
  320. package/lib/skills/builtin/paper-writing/templates/icml2026/example_paper.bib +75 -0
  321. package/lib/skills/builtin/paper-writing/templates/icml2026/example_paper.pdf +0 -0
  322. package/lib/skills/builtin/paper-writing/templates/icml2026/example_paper.tex +662 -0
  323. package/lib/skills/builtin/paper-writing/templates/icml2026/fancyhdr.sty +864 -0
  324. package/lib/skills/builtin/paper-writing/templates/icml2026/icml2026.bst +1443 -0
  325. package/lib/skills/builtin/paper-writing/templates/icml2026/icml2026.sty +767 -0
  326. package/lib/skills/builtin/paper-writing/templates/icml2026/icml_numpapers.pdf +0 -0
  327. package/lib/skills/builtin/paper-writing/templates/neurips2025/Makefile +36 -0
  328. package/lib/skills/builtin/paper-writing/templates/neurips2025/extra_pkgs.tex +53 -0
  329. package/lib/skills/builtin/paper-writing/templates/neurips2025/main.tex +38 -0
  330. package/lib/skills/builtin/paper-writing/templates/neurips2025/neurips.sty +382 -0
  331. package/lib/skills/builtin/paper-writing/templates/nsdi2027/main.tex +426 -0
  332. package/lib/skills/builtin/paper-writing/templates/nsdi2027/references.bib +151 -0
  333. package/lib/skills/builtin/paper-writing/templates/nsdi2027/usenix-2020-09.sty +83 -0
  334. package/lib/skills/builtin/paper-writing/templates/osdi2026/main.tex +429 -0
  335. package/lib/skills/builtin/paper-writing/templates/osdi2026/references.bib +150 -0
  336. package/lib/skills/builtin/paper-writing/templates/osdi2026/usenix-2020-09.sty +83 -0
  337. package/lib/skills/builtin/paper-writing/templates/sosp2026/main.tex +532 -0
  338. package/lib/skills/builtin/paper-writing/templates/sosp2026/references.bib +148 -0
  339. package/lib/skills/builtin/research-grants/SKILL.md +958 -0
  340. package/lib/skills/builtin/research-grants/assets/budget_justification_template.md +453 -0
  341. package/lib/skills/builtin/research-grants/assets/nih_specific_aims_template.md +166 -0
  342. package/lib/skills/builtin/research-grants/assets/nsf_project_summary_template.md +92 -0
  343. package/lib/skills/builtin/research-grants/references/README.md +285 -0
  344. package/lib/skills/builtin/research-grants/references/broader_impacts.md +392 -0
  345. package/lib/skills/builtin/research-grants/references/darpa_guidelines.md +636 -0
  346. package/lib/skills/builtin/research-grants/references/doe_guidelines.md +586 -0
  347. package/lib/skills/builtin/research-grants/references/nih_guidelines.md +851 -0
  348. package/lib/skills/builtin/research-grants/references/nsf_guidelines.md +570 -0
  349. package/lib/skills/builtin/research-grants/references/nstc_guidelines.md +733 -0
  350. package/lib/skills/builtin/research-grants/references/specific_aims_guide.md +458 -0
  351. package/lib/skills/builtin/rewrite-humanize/SKILL.md +116 -0
  352. package/lib/skills/builtin/rewrite-humanize/references/cs-venue-tone.md +57 -0
  353. package/lib/skills/builtin/rewrite-humanize/references/lexicon.md +50 -0
  354. package/lib/skills/builtin/scholar-evaluation/SKILL.md +300 -0
  355. package/lib/skills/builtin/scholar-evaluation/references/evaluation_framework.md +663 -0
  356. package/lib/skills/builtin/scholar-evaluation/scripts/calculate_scores.py +379 -0
  357. package/lib/skills/builtin/scientific-schematics/SKILL.md +603 -0
  358. package/lib/skills/builtin/scientific-schematics/references/QUICK_REFERENCE.md +182 -0
  359. package/lib/skills/builtin/scientific-schematics/references/README.md +292 -0
  360. package/lib/skills/builtin/scientific-schematics/references/best_practices.md +560 -0
  361. package/lib/skills/builtin/scientific-schematics/scripts/__pycache__/generate_schematic.cpython-312.pyc +0 -0
  362. package/lib/skills/builtin/scientific-schematics/scripts/__pycache__/generate_schematic_ai.cpython-312.pyc +0 -0
  363. package/lib/skills/builtin/scientific-schematics/scripts/example_usage.sh +85 -0
  364. package/lib/skills/builtin/scientific-schematics/scripts/generate_schematic.py +141 -0
  365. package/lib/skills/builtin/scientific-schematics/scripts/generate_schematic_ai.py +910 -0
  366. package/lib/skills/builtin/scientific-visualization/SKILL.md +749 -0
  367. package/lib/skills/builtin/scientific-visualization/assets/color_palettes.py +197 -0
  368. package/lib/skills/builtin/scientific-visualization/assets/nature.mplstyle +63 -0
  369. package/lib/skills/builtin/scientific-visualization/assets/presentation.mplstyle +61 -0
  370. package/lib/skills/builtin/scientific-visualization/assets/publication.mplstyle +68 -0
  371. package/lib/skills/builtin/scientific-visualization/references/color_palettes.md +348 -0
  372. package/lib/skills/builtin/scientific-visualization/references/journal_requirements.md +320 -0
  373. package/lib/skills/builtin/scientific-visualization/references/matplotlib_examples.md +620 -0
  374. package/lib/skills/builtin/scientific-visualization/references/publication_guidelines.md +205 -0
  375. package/lib/skills/builtin/scientific-visualization/scripts/figure_export.py +343 -0
  376. package/lib/skills/builtin/scientific-visualization/scripts/style_presets.py +416 -0
  377. package/lib/skills/builtin/scientific-writing/SKILL.md +745 -0
  378. package/lib/skills/builtin/scientific-writing/assets/REPORT_FORMATTING_GUIDE.md +574 -0
  379. package/lib/skills/builtin/scientific-writing/assets/scientific_report.sty +606 -0
  380. package/lib/skills/builtin/scientific-writing/assets/scientific_report_template.tex +449 -0
  381. package/lib/skills/builtin/scientific-writing/references/citation_styles.md +720 -0
  382. package/lib/skills/builtin/scientific-writing/references/figures_tables.md +806 -0
  383. package/lib/skills/builtin/scientific-writing/references/imrad_structure.md +686 -0
  384. package/lib/skills/builtin/scientific-writing/references/professional_report_formatting.md +664 -0
  385. package/lib/skills/builtin/scientific-writing/references/reporting_guidelines.md +748 -0
  386. package/lib/skills/builtin/scientific-writing/references/writing_principles.md +824 -0
  387. package/lib/skills/builtin/seaborn/SKILL.md +674 -0
  388. package/lib/skills/builtin/seaborn/references/examples.md +822 -0
  389. package/lib/skills/builtin/seaborn/references/function_reference.md +770 -0
  390. package/lib/skills/builtin/seaborn/references/objects_interface.md +964 -0
  391. package/lib/skills/data-analysis/SKILL.md +285 -0
  392. package/lib/skills/generate-skill-content.mjs +58 -0
  393. package/lib/skills/index.ts +34 -0
  394. package/lib/skills/loader.ts +452 -0
  395. package/package.json +62 -0
@@ -0,0 +1,3337 @@
1
+ import { n as getAccDescription, m as setAccDescription, q as setAccTitle, J as setDiagramTitle, H as getDiagramTitle, o as getAccTitle, r as getConfig, u as select, v as log$1, A as dist, w as configureSvgSize, x as assignWithDepth$1, C as common$1, z as sanitizeText$2, M as clear$1, O as utils, ad as hasKatex, ae as calculateMathMLDimensions, af as parseFontSize, ag as ZERO_WIDTH_SPACE, ah as renderKatexSanitized, ai as getConfig$1 } from "./MilkdownMarkdownEditor-bLPxrCVb.js";
2
+ import { a as drawBackgroundRect$1, d as drawRect$1, b as getTextObj$1, c as drawEmbeddedImage, e as drawImage, g as getNoteRect$1 } from "./svgDrawCommon-b86b1483-Bein03PD.js";
3
+ import "./index-BqDyyRCx.js";
4
+ var parser = function() {
5
+ var o = function(k, v, o2, l) {
6
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
7
+ ;
8
+ return o2;
9
+ }, $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, 54, 59, 60, 61, 62, 70], $Vy = [4, 5, 16, 50, 52, 53], $Vz = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VA = [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, 54, 59, 60, 61, 62, 70], $VB = [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, 54, 59, 60, 61, 62, 70], $VC = [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, 54, 59, 60, 61, 62, 70], $VD = [68, 69, 70], $VE = [1, 120];
10
+ var parser2 = {
11
+ trace: function trace() {
12
+ },
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, "note": 54, "placement": 55, "text2": 56, "over": 57, "actor_pair": 58, "links": 59, "link": 60, "properties": 61, "details": 62, "spaceList": 63, ",": 64, "left_of": 65, "right_of": 66, "signaltype": 67, "+": 68, "-": 69, "ACTOR": 70, "SOLID_OPEN_ARROW": 71, "DOTTED_OPEN_ARROW": 72, "SOLID_ARROW": 73, "DOTTED_ARROW": 74, "SOLID_CROSS": 75, "DOTTED_CROSS": 76, "SOLID_POINT": 77, "DOTTED_POINT": 78, "TXT": 79, "$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", 54: "note", 57: "over", 59: "links", 60: "link", 61: "properties", 62: "details", 64: ",", 65: "left_of", 66: "right_of", 68: "+", 69: "-", 70: "ACTOR", 71: "SOLID_OPEN_ARROW", 72: "DOTTED_OPEN_ARROW", 73: "SOLID_ARROW", 74: "DOTTED_ARROW", 75: "SOLID_CROSS", 76: "DOTTED_CROSS", 77: "SOLID_POINT", 78: "DOTTED_POINT", 79: "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], [24, 4], [24, 4], [25, 3], [26, 3], [27, 3], [28, 3], [63, 2], [63, 1], [58, 3], [58, 1], [55, 1], [55, 1], [17, 5], [17, 5], [17, 4], [22, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [56, 1]],
17
+ performAction: 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] };
65
+ break;
66
+ case 23:
67
+ this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1] };
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
+ this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }];
163
+ break;
164
+ case 54:
165
+ $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2);
166
+ $$[$0 - 2][0] = $$[$0 - 2][0].actor;
167
+ $$[$0 - 2][1] = $$[$0 - 2][1].actor;
168
+ this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }];
169
+ break;
170
+ case 55:
171
+ this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }];
172
+ break;
173
+ case 56:
174
+ this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }];
175
+ break;
176
+ case 57:
177
+ this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }];
178
+ break;
179
+ case 58:
180
+ this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }];
181
+ break;
182
+ case 61:
183
+ this.$ = [$$[$0 - 2], $$[$0]];
184
+ break;
185
+ case 62:
186
+ this.$ = $$[$0];
187
+ break;
188
+ case 63:
189
+ this.$ = yy.PLACEMENT.LEFTOF;
190
+ break;
191
+ case 64:
192
+ this.$ = yy.PLACEMENT.RIGHTOF;
193
+ break;
194
+ case 65:
195
+ this.$ = [
196
+ $$[$0 - 4],
197
+ $$[$0 - 1],
198
+ { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0], activate: true },
199
+ { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] }
200
+ ];
201
+ break;
202
+ case 66:
203
+ this.$ = [
204
+ $$[$0 - 4],
205
+ $$[$0 - 1],
206
+ { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] },
207
+ { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4] }
208
+ ];
209
+ break;
210
+ case 67:
211
+ this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }];
212
+ break;
213
+ case 68:
214
+ this.$ = { type: "addParticipant", actor: $$[$0] };
215
+ break;
216
+ case 69:
217
+ this.$ = yy.LINETYPE.SOLID_OPEN;
218
+ break;
219
+ case 70:
220
+ this.$ = yy.LINETYPE.DOTTED_OPEN;
221
+ break;
222
+ case 71:
223
+ this.$ = yy.LINETYPE.SOLID;
224
+ break;
225
+ case 72:
226
+ this.$ = yy.LINETYPE.DOTTED;
227
+ break;
228
+ case 73:
229
+ this.$ = yy.LINETYPE.SOLID_CROSS;
230
+ break;
231
+ case 74:
232
+ this.$ = yy.LINETYPE.DOTTED_CROSS;
233
+ break;
234
+ case 75:
235
+ this.$ = yy.LINETYPE.SOLID_POINT;
236
+ break;
237
+ case 76:
238
+ this.$ = yy.LINETYPE.DOTTED_POINT;
239
+ break;
240
+ case 77:
241
+ this.$ = yy.parseMessage($$[$0].trim().substring(1));
242
+ break;
243
+ }
244
+ },
245
+ 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, 54, 59, 60, 61, 62, 70], $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, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $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, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $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, 70: $Vw }, { 22: 55, 70: $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, 70: $Vw }, { 22: 72, 70: $Vw }, { 22: 73, 70: $Vw }, { 67: 74, 71: [1, 75], 72: [1, 76], 73: [1, 77], 74: [1, 78], 75: [1, 79], 76: [1, 80], 77: [1, 81], 78: [1, 82] }, { 55: 83, 57: [1, 84], 65: [1, 85], 66: [1, 86] }, { 22: 87, 70: $Vw }, { 22: 88, 70: $Vw }, { 22: 89, 70: $Vw }, { 22: 90, 70: $Vw }, o([5, 51, 64, 71, 72, 73, 74, 75, 76, 77, 78, 79], [2, 68]), o($Vx, [2, 6]), o($Vx, [2, 15]), o($Vy, [2, 9], { 10: 91 }), o($Vx, [2, 17]), { 5: [1, 93], 19: [1, 92] }, { 5: [1, 94] }, o($Vx, [2, 21]), { 5: [1, 95] }, { 5: [1, 96] }, 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($Vz, $V3, { 7: 97 }), o($Vz, $V3, { 7: 98 }), o($Vz, $V3, { 7: 99 }), o($VA, $V3, { 40: 100, 7: 101 }), o($VB, $V3, { 42: 102, 7: 103 }), o($VB, $V3, { 7: 103, 42: 104 }), o($VC, $V3, { 45: 105, 7: 106 }), o($Vz, $V3, { 7: 107 }), { 5: [1, 109], 51: [1, 108] }, { 5: [1, 111], 51: [1, 110] }, { 5: [1, 112] }, { 22: 115, 68: [1, 113], 69: [1, 114], 70: $Vw }, o($VD, [2, 69]), o($VD, [2, 70]), o($VD, [2, 71]), o($VD, [2, 72]), o($VD, [2, 73]), o($VD, [2, 74]), o($VD, [2, 75]), o($VD, [2, 76]), { 22: 116, 70: $Vw }, { 22: 118, 58: 117, 70: $Vw }, { 70: [2, 63] }, { 70: [2, 64] }, { 56: 119, 79: $VE }, { 56: 121, 79: $VE }, { 56: 122, 79: $VE }, { 56: 123, 79: $VE }, { 4: [1, 126], 5: [1, 128], 11: 125, 12: 127, 16: [1, 124], 50: $Vo, 52: $Vp, 53: $Vq }, { 5: [1, 129] }, 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, 130], 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, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 131], 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, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 132], 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, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 133] }, { 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, 134], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 135] }, { 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, 136], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 137] }, { 16: [1, 138] }, { 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, 139], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 140], 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, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 15: [1, 141] }, o($Vx, [2, 49]), { 15: [1, 142] }, o($Vx, [2, 51]), o($Vx, [2, 52]), { 22: 143, 70: $Vw }, { 22: 144, 70: $Vw }, { 56: 145, 79: $VE }, { 56: 146, 79: $VE }, { 56: 147, 79: $VE }, { 64: [1, 148], 79: [2, 62] }, { 5: [2, 55] }, { 5: [2, 77] }, { 5: [2, 56] }, { 5: [2, 57] }, { 5: [2, 58] }, o($Vx, [2, 16]), o($Vy, [2, 10]), { 12: 149, 50: $Vo, 52: $Vp, 53: $Vq }, o($Vy, [2, 12]), o($Vy, [2, 13]), o($Vx, [2, 18]), o($Vx, [2, 34]), o($Vx, [2, 35]), o($Vx, [2, 36]), o($Vx, [2, 37]), { 15: [1, 150] }, o($Vx, [2, 38]), { 15: [1, 151] }, o($Vx, [2, 39]), o($Vx, [2, 40]), { 15: [1, 152] }, o($Vx, [2, 41]), { 5: [1, 153] }, { 5: [1, 154] }, { 56: 155, 79: $VE }, { 56: 156, 79: $VE }, { 5: [2, 67] }, { 5: [2, 53] }, { 5: [2, 54] }, { 22: 157, 70: $Vw }, o($Vy, [2, 11]), o($VA, $V3, { 7: 101, 40: 158 }), o($VB, $V3, { 7: 103, 42: 159 }), o($VC, $V3, { 7: 106, 45: 160 }), o($Vx, [2, 48]), o($Vx, [2, 50]), { 5: [2, 65] }, { 5: [2, 66] }, { 79: [2, 61] }, { 16: [2, 47] }, { 16: [2, 45] }, { 16: [2, 43] }],
246
+ defaultActions: { 5: [2, 1], 6: [2, 2], 85: [2, 63], 86: [2, 64], 119: [2, 55], 120: [2, 77], 121: [2, 56], 122: [2, 57], 123: [2, 58], 145: [2, 67], 146: [2, 53], 147: [2, 54], 155: [2, 65], 156: [2, 66], 157: [2, 61], 158: [2, 47], 159: [2, 45], 160: [2, 43] },
247
+ parseError: function parseError(str, hash) {
248
+ if (hash.recoverable) {
249
+ this.trace(str);
250
+ } else {
251
+ var error = new Error(str);
252
+ error.hash = hash;
253
+ throw error;
254
+ }
255
+ },
256
+ parse: function parse(input) {
257
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
258
+ var args = lstack.slice.call(arguments, 1);
259
+ var lexer2 = Object.create(this.lexer);
260
+ var sharedState = { yy: {} };
261
+ for (var k in this.yy) {
262
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
263
+ sharedState.yy[k] = this.yy[k];
264
+ }
265
+ }
266
+ lexer2.setInput(input, sharedState.yy);
267
+ sharedState.yy.lexer = lexer2;
268
+ sharedState.yy.parser = this;
269
+ if (typeof lexer2.yylloc == "undefined") {
270
+ lexer2.yylloc = {};
271
+ }
272
+ var yyloc = lexer2.yylloc;
273
+ lstack.push(yyloc);
274
+ var ranges = lexer2.options && lexer2.options.ranges;
275
+ if (typeof sharedState.yy.parseError === "function") {
276
+ this.parseError = sharedState.yy.parseError;
277
+ } else {
278
+ this.parseError = Object.getPrototypeOf(this).parseError;
279
+ }
280
+ function lex() {
281
+ var token;
282
+ token = tstack.pop() || lexer2.lex() || EOF;
283
+ if (typeof token !== "number") {
284
+ if (token instanceof Array) {
285
+ tstack = token;
286
+ token = tstack.pop();
287
+ }
288
+ token = self.symbols_[token] || token;
289
+ }
290
+ return token;
291
+ }
292
+ var symbol, state2, action, r, yyval = {}, p, len, newState, expected;
293
+ while (true) {
294
+ state2 = stack[stack.length - 1];
295
+ if (this.defaultActions[state2]) {
296
+ action = this.defaultActions[state2];
297
+ } else {
298
+ if (symbol === null || typeof symbol == "undefined") {
299
+ symbol = lex();
300
+ }
301
+ action = table[state2] && table[state2][symbol];
302
+ }
303
+ if (typeof action === "undefined" || !action.length || !action[0]) {
304
+ var errStr = "";
305
+ expected = [];
306
+ for (p in table[state2]) {
307
+ if (this.terminals_[p] && p > TERROR) {
308
+ expected.push("'" + this.terminals_[p] + "'");
309
+ }
310
+ }
311
+ if (lexer2.showPosition) {
312
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
313
+ } else {
314
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
315
+ }
316
+ this.parseError(errStr, {
317
+ text: lexer2.match,
318
+ token: this.terminals_[symbol] || symbol,
319
+ line: lexer2.yylineno,
320
+ loc: yyloc,
321
+ expected
322
+ });
323
+ }
324
+ if (action[0] instanceof Array && action.length > 1) {
325
+ throw new Error("Parse Error: multiple actions possible at state: " + state2 + ", token: " + symbol);
326
+ }
327
+ switch (action[0]) {
328
+ case 1:
329
+ stack.push(symbol);
330
+ vstack.push(lexer2.yytext);
331
+ lstack.push(lexer2.yylloc);
332
+ stack.push(action[1]);
333
+ symbol = null;
334
+ {
335
+ yyleng = lexer2.yyleng;
336
+ yytext = lexer2.yytext;
337
+ yylineno = lexer2.yylineno;
338
+ yyloc = lexer2.yylloc;
339
+ }
340
+ break;
341
+ case 2:
342
+ len = this.productions_[action[1]][1];
343
+ yyval.$ = vstack[vstack.length - len];
344
+ yyval._$ = {
345
+ first_line: lstack[lstack.length - (len || 1)].first_line,
346
+ last_line: lstack[lstack.length - 1].last_line,
347
+ first_column: lstack[lstack.length - (len || 1)].first_column,
348
+ last_column: lstack[lstack.length - 1].last_column
349
+ };
350
+ if (ranges) {
351
+ yyval._$.range = [
352
+ lstack[lstack.length - (len || 1)].range[0],
353
+ lstack[lstack.length - 1].range[1]
354
+ ];
355
+ }
356
+ r = this.performAction.apply(yyval, [
357
+ yytext,
358
+ yyleng,
359
+ yylineno,
360
+ sharedState.yy,
361
+ action[1],
362
+ vstack,
363
+ lstack
364
+ ].concat(args));
365
+ if (typeof r !== "undefined") {
366
+ return r;
367
+ }
368
+ if (len) {
369
+ stack = stack.slice(0, -1 * len * 2);
370
+ vstack = vstack.slice(0, -1 * len);
371
+ lstack = lstack.slice(0, -1 * len);
372
+ }
373
+ stack.push(this.productions_[action[1]][0]);
374
+ vstack.push(yyval.$);
375
+ lstack.push(yyval._$);
376
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
377
+ stack.push(newState);
378
+ break;
379
+ case 3:
380
+ return true;
381
+ }
382
+ }
383
+ return true;
384
+ }
385
+ };
386
+ var lexer = /* @__PURE__ */ function() {
387
+ var lexer2 = {
388
+ EOF: 1,
389
+ parseError: function parseError(str, hash) {
390
+ if (this.yy.parser) {
391
+ this.yy.parser.parseError(str, hash);
392
+ } else {
393
+ throw new Error(str);
394
+ }
395
+ },
396
+ // resets the lexer, sets new input
397
+ setInput: function(input, yy) {
398
+ this.yy = yy || this.yy || {};
399
+ this._input = input;
400
+ this._more = this._backtrack = this.done = false;
401
+ this.yylineno = this.yyleng = 0;
402
+ this.yytext = this.matched = this.match = "";
403
+ this.conditionStack = ["INITIAL"];
404
+ this.yylloc = {
405
+ first_line: 1,
406
+ first_column: 0,
407
+ last_line: 1,
408
+ last_column: 0
409
+ };
410
+ if (this.options.ranges) {
411
+ this.yylloc.range = [0, 0];
412
+ }
413
+ this.offset = 0;
414
+ return this;
415
+ },
416
+ // consumes and returns one char from the input
417
+ input: function() {
418
+ var ch = this._input[0];
419
+ this.yytext += ch;
420
+ this.yyleng++;
421
+ this.offset++;
422
+ this.match += ch;
423
+ this.matched += ch;
424
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
425
+ if (lines) {
426
+ this.yylineno++;
427
+ this.yylloc.last_line++;
428
+ } else {
429
+ this.yylloc.last_column++;
430
+ }
431
+ if (this.options.ranges) {
432
+ this.yylloc.range[1]++;
433
+ }
434
+ this._input = this._input.slice(1);
435
+ return ch;
436
+ },
437
+ // unshifts one char (or a string) into the input
438
+ unput: function(ch) {
439
+ var len = ch.length;
440
+ var lines = ch.split(/(?:\r\n?|\n)/g);
441
+ this._input = ch + this._input;
442
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
443
+ this.offset -= len;
444
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
445
+ this.match = this.match.substr(0, this.match.length - 1);
446
+ this.matched = this.matched.substr(0, this.matched.length - 1);
447
+ if (lines.length - 1) {
448
+ this.yylineno -= lines.length - 1;
449
+ }
450
+ var r = this.yylloc.range;
451
+ this.yylloc = {
452
+ first_line: this.yylloc.first_line,
453
+ last_line: this.yylineno + 1,
454
+ first_column: this.yylloc.first_column,
455
+ 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
456
+ };
457
+ if (this.options.ranges) {
458
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
459
+ }
460
+ this.yyleng = this.yytext.length;
461
+ return this;
462
+ },
463
+ // When called from action, caches matched text and appends it on next action
464
+ more: function() {
465
+ this._more = true;
466
+ return this;
467
+ },
468
+ // 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.
469
+ reject: function() {
470
+ if (this.options.backtrack_lexer) {
471
+ this._backtrack = true;
472
+ } else {
473
+ 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(), {
474
+ text: "",
475
+ token: null,
476
+ line: this.yylineno
477
+ });
478
+ }
479
+ return this;
480
+ },
481
+ // retain first n characters of the match
482
+ less: function(n) {
483
+ this.unput(this.match.slice(n));
484
+ },
485
+ // displays already matched input, i.e. for error messages
486
+ pastInput: function() {
487
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
488
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
489
+ },
490
+ // displays upcoming input, i.e. for error messages
491
+ upcomingInput: function() {
492
+ var next = this.match;
493
+ if (next.length < 20) {
494
+ next += this._input.substr(0, 20 - next.length);
495
+ }
496
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
497
+ },
498
+ // displays the character position where the lexing error occurred, i.e. for error messages
499
+ showPosition: function() {
500
+ var pre = this.pastInput();
501
+ var c = new Array(pre.length + 1).join("-");
502
+ return pre + this.upcomingInput() + "\n" + c + "^";
503
+ },
504
+ // test the lexed token: return FALSE when not a match, otherwise return token
505
+ test_match: function(match, indexed_rule) {
506
+ var token, lines, backup;
507
+ if (this.options.backtrack_lexer) {
508
+ backup = {
509
+ yylineno: this.yylineno,
510
+ yylloc: {
511
+ first_line: this.yylloc.first_line,
512
+ last_line: this.last_line,
513
+ first_column: this.yylloc.first_column,
514
+ last_column: this.yylloc.last_column
515
+ },
516
+ yytext: this.yytext,
517
+ match: this.match,
518
+ matches: this.matches,
519
+ matched: this.matched,
520
+ yyleng: this.yyleng,
521
+ offset: this.offset,
522
+ _more: this._more,
523
+ _input: this._input,
524
+ yy: this.yy,
525
+ conditionStack: this.conditionStack.slice(0),
526
+ done: this.done
527
+ };
528
+ if (this.options.ranges) {
529
+ backup.yylloc.range = this.yylloc.range.slice(0);
530
+ }
531
+ }
532
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
533
+ if (lines) {
534
+ this.yylineno += lines.length;
535
+ }
536
+ this.yylloc = {
537
+ first_line: this.yylloc.last_line,
538
+ last_line: this.yylineno + 1,
539
+ first_column: this.yylloc.last_column,
540
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
541
+ };
542
+ this.yytext += match[0];
543
+ this.match += match[0];
544
+ this.matches = match;
545
+ this.yyleng = this.yytext.length;
546
+ if (this.options.ranges) {
547
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
548
+ }
549
+ this._more = false;
550
+ this._backtrack = false;
551
+ this._input = this._input.slice(match[0].length);
552
+ this.matched += match[0];
553
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
554
+ if (this.done && this._input) {
555
+ this.done = false;
556
+ }
557
+ if (token) {
558
+ return token;
559
+ } else if (this._backtrack) {
560
+ for (var k in backup) {
561
+ this[k] = backup[k];
562
+ }
563
+ return false;
564
+ }
565
+ return false;
566
+ },
567
+ // return next match in input
568
+ next: function() {
569
+ if (this.done) {
570
+ return this.EOF;
571
+ }
572
+ if (!this._input) {
573
+ this.done = true;
574
+ }
575
+ var token, match, tempMatch, index;
576
+ if (!this._more) {
577
+ this.yytext = "";
578
+ this.match = "";
579
+ }
580
+ var rules = this._currentRules();
581
+ for (var i = 0; i < rules.length; i++) {
582
+ tempMatch = this._input.match(this.rules[rules[i]]);
583
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
584
+ match = tempMatch;
585
+ index = i;
586
+ if (this.options.backtrack_lexer) {
587
+ token = this.test_match(tempMatch, rules[i]);
588
+ if (token !== false) {
589
+ return token;
590
+ } else if (this._backtrack) {
591
+ match = false;
592
+ continue;
593
+ } else {
594
+ return false;
595
+ }
596
+ } else if (!this.options.flex) {
597
+ break;
598
+ }
599
+ }
600
+ }
601
+ if (match) {
602
+ token = this.test_match(match, rules[index]);
603
+ if (token !== false) {
604
+ return token;
605
+ }
606
+ return false;
607
+ }
608
+ if (this._input === "") {
609
+ return this.EOF;
610
+ } else {
611
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
612
+ text: "",
613
+ token: null,
614
+ line: this.yylineno
615
+ });
616
+ }
617
+ },
618
+ // return next match that has a token
619
+ lex: function lex() {
620
+ var r = this.next();
621
+ if (r) {
622
+ return r;
623
+ } else {
624
+ return this.lex();
625
+ }
626
+ },
627
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
628
+ begin: function begin(condition) {
629
+ this.conditionStack.push(condition);
630
+ },
631
+ // pop the previously active lexer condition state off the condition stack
632
+ popState: function popState() {
633
+ var n = this.conditionStack.length - 1;
634
+ if (n > 0) {
635
+ return this.conditionStack.pop();
636
+ } else {
637
+ return this.conditionStack[0];
638
+ }
639
+ },
640
+ // produce the lexer rule set which is active for the currently active lexer condition state
641
+ _currentRules: function _currentRules() {
642
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
643
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
644
+ } else {
645
+ return this.conditions["INITIAL"].rules;
646
+ }
647
+ },
648
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
649
+ topState: function topState(n) {
650
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
651
+ if (n >= 0) {
652
+ return this.conditionStack[n];
653
+ } else {
654
+ return "INITIAL";
655
+ }
656
+ },
657
+ // alias for begin(condition)
658
+ pushState: function pushState(condition) {
659
+ this.begin(condition);
660
+ },
661
+ // return the number of states currently on the stack
662
+ stateStackSize: function stateStackSize() {
663
+ return this.conditionStack.length;
664
+ },
665
+ options: { "case-insensitive": true },
666
+ performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
667
+ switch ($avoiding_name_collisions) {
668
+ case 0:
669
+ return 5;
670
+ case 1:
671
+ break;
672
+ case 2:
673
+ break;
674
+ case 3:
675
+ break;
676
+ case 4:
677
+ break;
678
+ case 5:
679
+ break;
680
+ case 6:
681
+ return 19;
682
+ case 7:
683
+ this.begin("LINE");
684
+ return 14;
685
+ case 8:
686
+ this.begin("ID");
687
+ return 50;
688
+ case 9:
689
+ this.begin("ID");
690
+ return 52;
691
+ case 10:
692
+ return 13;
693
+ case 11:
694
+ this.begin("ID");
695
+ return 53;
696
+ case 12:
697
+ yy_.yytext = yy_.yytext.trim();
698
+ this.begin("ALIAS");
699
+ return 70;
700
+ case 13:
701
+ this.popState();
702
+ this.popState();
703
+ this.begin("LINE");
704
+ return 51;
705
+ case 14:
706
+ this.popState();
707
+ this.popState();
708
+ return 5;
709
+ case 15:
710
+ this.begin("LINE");
711
+ return 36;
712
+ case 16:
713
+ this.begin("LINE");
714
+ return 37;
715
+ case 17:
716
+ this.begin("LINE");
717
+ return 38;
718
+ case 18:
719
+ this.begin("LINE");
720
+ return 39;
721
+ case 19:
722
+ this.begin("LINE");
723
+ return 49;
724
+ case 20:
725
+ this.begin("LINE");
726
+ return 41;
727
+ case 21:
728
+ this.begin("LINE");
729
+ return 43;
730
+ case 22:
731
+ this.begin("LINE");
732
+ return 48;
733
+ case 23:
734
+ this.begin("LINE");
735
+ return 44;
736
+ case 24:
737
+ this.begin("LINE");
738
+ return 47;
739
+ case 25:
740
+ this.begin("LINE");
741
+ return 46;
742
+ case 26:
743
+ this.popState();
744
+ return 15;
745
+ case 27:
746
+ return 16;
747
+ case 28:
748
+ return 65;
749
+ case 29:
750
+ return 66;
751
+ case 30:
752
+ return 59;
753
+ case 31:
754
+ return 60;
755
+ case 32:
756
+ return 61;
757
+ case 33:
758
+ return 62;
759
+ case 34:
760
+ return 57;
761
+ case 35:
762
+ return 54;
763
+ case 36:
764
+ this.begin("ID");
765
+ return 21;
766
+ case 37:
767
+ this.begin("ID");
768
+ return 23;
769
+ case 38:
770
+ return 29;
771
+ case 39:
772
+ return 30;
773
+ case 40:
774
+ this.begin("acc_title");
775
+ return 31;
776
+ case 41:
777
+ this.popState();
778
+ return "acc_title_value";
779
+ case 42:
780
+ this.begin("acc_descr");
781
+ return 33;
782
+ case 43:
783
+ this.popState();
784
+ return "acc_descr_value";
785
+ case 44:
786
+ this.begin("acc_descr_multiline");
787
+ break;
788
+ case 45:
789
+ this.popState();
790
+ break;
791
+ case 46:
792
+ return "acc_descr_multiline_value";
793
+ case 47:
794
+ return 6;
795
+ case 48:
796
+ return 18;
797
+ case 49:
798
+ return 20;
799
+ case 50:
800
+ return 64;
801
+ case 51:
802
+ return 5;
803
+ case 52:
804
+ yy_.yytext = yy_.yytext.trim();
805
+ return 70;
806
+ case 53:
807
+ return 73;
808
+ case 54:
809
+ return 74;
810
+ case 55:
811
+ return 71;
812
+ case 56:
813
+ return 72;
814
+ case 57:
815
+ return 75;
816
+ case 58:
817
+ return 76;
818
+ case 59:
819
+ return 77;
820
+ case 60:
821
+ return 78;
822
+ case 61:
823
+ return 79;
824
+ case 62:
825
+ return 68;
826
+ case 63:
827
+ return 69;
828
+ case 64:
829
+ return 5;
830
+ case 65:
831
+ return "INVALID";
832
+ }
833
+ },
834
+ rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \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, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i],
835
+ conditions: { "acc_descr_multiline": { "rules": [45, 46], "inclusive": false }, "acc_descr": { "rules": [43], "inclusive": false }, "acc_title": { "rules": [41], "inclusive": false }, "ID": { "rules": [2, 3, 12], "inclusive": false }, "ALIAS": { "rules": [2, 3, 13, 14], "inclusive": false }, "LINE": { "rules": [2, 3, 26], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], "inclusive": true } }
836
+ };
837
+ return lexer2;
838
+ }();
839
+ parser2.lexer = lexer;
840
+ function Parser() {
841
+ this.yy = {};
842
+ }
843
+ Parser.prototype = parser2;
844
+ parser2.Parser = Parser;
845
+ return new Parser();
846
+ }();
847
+ parser.parser = parser;
848
+ const parser$1 = parser;
849
+ class ImperativeState {
850
+ /**
851
+ * @param init - Function that creates the default state.
852
+ */
853
+ constructor(init) {
854
+ this.init = init;
855
+ this.records = this.init();
856
+ }
857
+ reset() {
858
+ this.records = this.init();
859
+ }
860
+ }
861
+ const state = new ImperativeState(() => ({
862
+ prevActor: void 0,
863
+ actors: {},
864
+ createdActors: {},
865
+ destroyedActors: {},
866
+ boxes: [],
867
+ messages: [],
868
+ notes: [],
869
+ sequenceNumbersEnabled: false,
870
+ wrapEnabled: void 0,
871
+ currentBox: void 0,
872
+ lastCreated: void 0,
873
+ lastDestroyed: void 0
874
+ }));
875
+ const addBox = function(data) {
876
+ state.records.boxes.push({
877
+ name: data.text,
878
+ wrap: data.wrap === void 0 && autoWrap() || !!data.wrap,
879
+ fill: data.color,
880
+ actorKeys: []
881
+ });
882
+ state.records.currentBox = state.records.boxes.slice(-1)[0];
883
+ };
884
+ const addActor = function(id, name, description, type) {
885
+ let assignedBox = state.records.currentBox;
886
+ const old = state.records.actors[id];
887
+ if (old) {
888
+ if (state.records.currentBox && old.box && state.records.currentBox !== old.box) {
889
+ throw new Error(
890
+ "A same participant should only be defined in one Box: " + old.name + " can't be in '" + old.box.name + "' and in '" + state.records.currentBox.name + "' at the same time."
891
+ );
892
+ }
893
+ assignedBox = old.box ? old.box : state.records.currentBox;
894
+ old.box = assignedBox;
895
+ if (old && name === old.name && description == null) {
896
+ return;
897
+ }
898
+ }
899
+ if (description == null || description.text == null) {
900
+ description = { text: name, wrap: null, type };
901
+ }
902
+ if (type == null || description.text == null) {
903
+ description = { text: name, wrap: null, type };
904
+ }
905
+ state.records.actors[id] = {
906
+ box: assignedBox,
907
+ name,
908
+ description: description.text,
909
+ wrap: description.wrap === void 0 && autoWrap() || !!description.wrap,
910
+ prevActor: state.records.prevActor,
911
+ links: {},
912
+ properties: {},
913
+ actorCnt: null,
914
+ rectData: null,
915
+ type: type || "participant"
916
+ };
917
+ if (state.records.prevActor && state.records.actors[state.records.prevActor]) {
918
+ state.records.actors[state.records.prevActor].nextActor = id;
919
+ }
920
+ if (state.records.currentBox) {
921
+ state.records.currentBox.actorKeys.push(id);
922
+ }
923
+ state.records.prevActor = id;
924
+ };
925
+ const activationCount = (part) => {
926
+ let i;
927
+ let count = 0;
928
+ for (i = 0; i < state.records.messages.length; i++) {
929
+ if (state.records.messages[i].type === LINETYPE.ACTIVE_START && state.records.messages[i].from.actor === part) {
930
+ count++;
931
+ }
932
+ if (state.records.messages[i].type === LINETYPE.ACTIVE_END && state.records.messages[i].from.actor === part) {
933
+ count--;
934
+ }
935
+ }
936
+ return count;
937
+ };
938
+ const addMessage = function(idFrom, idTo, message, answer) {
939
+ state.records.messages.push({
940
+ from: idFrom,
941
+ to: idTo,
942
+ message: message.text,
943
+ wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
944
+ answer
945
+ });
946
+ };
947
+ const addSignal = function(idFrom, idTo, message = { text: void 0, wrap: void 0 }, messageType, activate = false) {
948
+ if (messageType === LINETYPE.ACTIVE_END) {
949
+ const cnt = activationCount(idFrom.actor);
950
+ if (cnt < 1) {
951
+ let error = new Error("Trying to inactivate an inactive participant (" + idFrom.actor + ")");
952
+ error.hash = {
953
+ text: "->>-",
954
+ token: "->>-",
955
+ line: "1",
956
+ loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
957
+ expected: ["'ACTIVE_PARTICIPANT'"]
958
+ };
959
+ throw error;
960
+ }
961
+ }
962
+ state.records.messages.push({
963
+ from: idFrom,
964
+ to: idTo,
965
+ message: message.text,
966
+ wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
967
+ type: messageType,
968
+ activate
969
+ });
970
+ return true;
971
+ };
972
+ const hasAtLeastOneBox = function() {
973
+ return state.records.boxes.length > 0;
974
+ };
975
+ const hasAtLeastOneBoxWithTitle = function() {
976
+ return state.records.boxes.some((b) => b.name);
977
+ };
978
+ const getMessages = function() {
979
+ return state.records.messages;
980
+ };
981
+ const getBoxes = function() {
982
+ return state.records.boxes;
983
+ };
984
+ const getActors = function() {
985
+ return state.records.actors;
986
+ };
987
+ const getCreatedActors = function() {
988
+ return state.records.createdActors;
989
+ };
990
+ const getDestroyedActors = function() {
991
+ return state.records.destroyedActors;
992
+ };
993
+ const getActor = function(id) {
994
+ return state.records.actors[id];
995
+ };
996
+ const getActorKeys = function() {
997
+ return Object.keys(state.records.actors);
998
+ };
999
+ const enableSequenceNumbers = function() {
1000
+ state.records.sequenceNumbersEnabled = true;
1001
+ };
1002
+ const disableSequenceNumbers = function() {
1003
+ state.records.sequenceNumbersEnabled = false;
1004
+ };
1005
+ const showSequenceNumbers = () => state.records.sequenceNumbersEnabled;
1006
+ const setWrap = function(wrapSetting) {
1007
+ state.records.wrapEnabled = wrapSetting;
1008
+ };
1009
+ const autoWrap = () => {
1010
+ if (state.records.wrapEnabled !== void 0) {
1011
+ return state.records.wrapEnabled;
1012
+ }
1013
+ return getConfig().sequence.wrap;
1014
+ };
1015
+ const clear = function() {
1016
+ state.reset();
1017
+ clear$1();
1018
+ };
1019
+ const parseMessage = function(str) {
1020
+ const _str = str.trim();
1021
+ const message = {
1022
+ text: _str.replace(/^:?(?:no)?wrap:/, "").trim(),
1023
+ wrap: _str.match(/^:?wrap:/) !== null ? true : _str.match(/^:?nowrap:/) !== null ? false : void 0
1024
+ };
1025
+ log$1.debug("parseMessage:", message);
1026
+ return message;
1027
+ };
1028
+ const parseBoxData = function(str) {
1029
+ const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/);
1030
+ let color = match != null && match[1] ? match[1].trim() : "transparent";
1031
+ let title = match != null && match[2] ? match[2].trim() : void 0;
1032
+ if (window && window.CSS) {
1033
+ if (!window.CSS.supports("color", color)) {
1034
+ color = "transparent";
1035
+ title = str.trim();
1036
+ }
1037
+ } else {
1038
+ const style = new Option().style;
1039
+ style.color = color;
1040
+ if (style.color !== color) {
1041
+ color = "transparent";
1042
+ title = str.trim();
1043
+ }
1044
+ }
1045
+ return {
1046
+ color,
1047
+ text: title !== void 0 ? sanitizeText$2(title.replace(/^:?(?:no)?wrap:/, ""), getConfig()) : void 0,
1048
+ wrap: title !== void 0 ? title.match(/^:?wrap:/) !== null ? true : title.match(/^:?nowrap:/) !== null ? false : void 0 : void 0
1049
+ };
1050
+ };
1051
+ const LINETYPE = {
1052
+ SOLID: 0,
1053
+ DOTTED: 1,
1054
+ NOTE: 2,
1055
+ SOLID_CROSS: 3,
1056
+ DOTTED_CROSS: 4,
1057
+ SOLID_OPEN: 5,
1058
+ DOTTED_OPEN: 6,
1059
+ LOOP_START: 10,
1060
+ LOOP_END: 11,
1061
+ ALT_START: 12,
1062
+ ALT_ELSE: 13,
1063
+ ALT_END: 14,
1064
+ OPT_START: 15,
1065
+ OPT_END: 16,
1066
+ ACTIVE_START: 17,
1067
+ ACTIVE_END: 18,
1068
+ PAR_START: 19,
1069
+ PAR_AND: 20,
1070
+ PAR_END: 21,
1071
+ RECT_START: 22,
1072
+ RECT_END: 23,
1073
+ SOLID_POINT: 24,
1074
+ DOTTED_POINT: 25,
1075
+ AUTONUMBER: 26,
1076
+ CRITICAL_START: 27,
1077
+ CRITICAL_OPTION: 28,
1078
+ CRITICAL_END: 29,
1079
+ BREAK_START: 30,
1080
+ BREAK_END: 31,
1081
+ PAR_OVER_START: 32
1082
+ };
1083
+ const ARROWTYPE = {
1084
+ FILLED: 0,
1085
+ OPEN: 1
1086
+ };
1087
+ const PLACEMENT = {
1088
+ LEFTOF: 0,
1089
+ RIGHTOF: 1,
1090
+ OVER: 2
1091
+ };
1092
+ const addNote = function(actor, placement, message) {
1093
+ const note = {
1094
+ actor,
1095
+ placement,
1096
+ message: message.text,
1097
+ wrap: message.wrap === void 0 && autoWrap() || !!message.wrap
1098
+ };
1099
+ const actors = [].concat(actor, actor);
1100
+ state.records.notes.push(note);
1101
+ state.records.messages.push({
1102
+ from: actors[0],
1103
+ to: actors[1],
1104
+ message: message.text,
1105
+ wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
1106
+ type: LINETYPE.NOTE,
1107
+ placement
1108
+ });
1109
+ };
1110
+ const addLinks = function(actorId, text) {
1111
+ const actor = getActor(actorId);
1112
+ try {
1113
+ let sanitizedText = sanitizeText$2(text.text, getConfig());
1114
+ sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1115
+ sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1116
+ const links = JSON.parse(sanitizedText);
1117
+ insertLinks(actor, links);
1118
+ } catch (e) {
1119
+ log$1.error("error while parsing actor link text", e);
1120
+ }
1121
+ };
1122
+ const addALink = function(actorId, text) {
1123
+ const actor = getActor(actorId);
1124
+ try {
1125
+ const links = {};
1126
+ let sanitizedText = sanitizeText$2(text.text, getConfig());
1127
+ var sep = sanitizedText.indexOf("@");
1128
+ sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1129
+ sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1130
+ var label = sanitizedText.slice(0, sep - 1).trim();
1131
+ var link = sanitizedText.slice(sep + 1).trim();
1132
+ links[label] = link;
1133
+ insertLinks(actor, links);
1134
+ } catch (e) {
1135
+ log$1.error("error while parsing actor link text", e);
1136
+ }
1137
+ };
1138
+ function insertLinks(actor, links) {
1139
+ if (actor.links == null) {
1140
+ actor.links = links;
1141
+ } else {
1142
+ for (let key in links) {
1143
+ actor.links[key] = links[key];
1144
+ }
1145
+ }
1146
+ }
1147
+ const addProperties = function(actorId, text) {
1148
+ const actor = getActor(actorId);
1149
+ try {
1150
+ let sanitizedText = sanitizeText$2(text.text, getConfig());
1151
+ const properties = JSON.parse(sanitizedText);
1152
+ insertProperties(actor, properties);
1153
+ } catch (e) {
1154
+ log$1.error("error while parsing actor properties text", e);
1155
+ }
1156
+ };
1157
+ function insertProperties(actor, properties) {
1158
+ if (actor.properties == null) {
1159
+ actor.properties = properties;
1160
+ } else {
1161
+ for (let key in properties) {
1162
+ actor.properties[key] = properties[key];
1163
+ }
1164
+ }
1165
+ }
1166
+ function boxEnd() {
1167
+ state.records.currentBox = void 0;
1168
+ }
1169
+ const addDetails = function(actorId, text) {
1170
+ const actor = getActor(actorId);
1171
+ const elem = document.getElementById(text.text);
1172
+ try {
1173
+ const text2 = elem.innerHTML;
1174
+ const details = JSON.parse(text2);
1175
+ if (details["properties"]) {
1176
+ insertProperties(actor, details["properties"]);
1177
+ }
1178
+ if (details["links"]) {
1179
+ insertLinks(actor, details["links"]);
1180
+ }
1181
+ } catch (e) {
1182
+ log$1.error("error while parsing actor details text", e);
1183
+ }
1184
+ };
1185
+ const getActorProperty = function(actor, key) {
1186
+ if (actor !== void 0 && actor.properties !== void 0) {
1187
+ return actor.properties[key];
1188
+ }
1189
+ return void 0;
1190
+ };
1191
+ const apply = function(param) {
1192
+ if (Array.isArray(param)) {
1193
+ param.forEach(function(item) {
1194
+ apply(item);
1195
+ });
1196
+ } else {
1197
+ switch (param.type) {
1198
+ case "sequenceIndex":
1199
+ state.records.messages.push({
1200
+ from: void 0,
1201
+ to: void 0,
1202
+ message: {
1203
+ start: param.sequenceIndex,
1204
+ step: param.sequenceIndexStep,
1205
+ visible: param.sequenceVisible
1206
+ },
1207
+ wrap: false,
1208
+ type: param.signalType
1209
+ });
1210
+ break;
1211
+ case "addParticipant":
1212
+ addActor(param.actor, param.actor, param.description, param.draw);
1213
+ break;
1214
+ case "createParticipant":
1215
+ if (state.records.actors[param.actor]) {
1216
+ throw new Error(
1217
+ "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"
1218
+ );
1219
+ }
1220
+ state.records.lastCreated = param.actor;
1221
+ addActor(param.actor, param.actor, param.description, param.draw);
1222
+ state.records.createdActors[param.actor] = state.records.messages.length;
1223
+ break;
1224
+ case "destroyParticipant":
1225
+ state.records.lastDestroyed = param.actor;
1226
+ state.records.destroyedActors[param.actor] = state.records.messages.length;
1227
+ break;
1228
+ case "activeStart":
1229
+ addSignal(param.actor, void 0, void 0, param.signalType);
1230
+ break;
1231
+ case "activeEnd":
1232
+ addSignal(param.actor, void 0, void 0, param.signalType);
1233
+ break;
1234
+ case "addNote":
1235
+ addNote(param.actor, param.placement, param.text);
1236
+ break;
1237
+ case "addLinks":
1238
+ addLinks(param.actor, param.text);
1239
+ break;
1240
+ case "addALink":
1241
+ addALink(param.actor, param.text);
1242
+ break;
1243
+ case "addProperties":
1244
+ addProperties(param.actor, param.text);
1245
+ break;
1246
+ case "addDetails":
1247
+ addDetails(param.actor, param.text);
1248
+ break;
1249
+ case "addMessage":
1250
+ if (state.records.lastCreated) {
1251
+ if (param.to !== state.records.lastCreated) {
1252
+ throw new Error(
1253
+ "The created participant " + state.records.lastCreated + " does not have an associated creating message after its declaration. Please check the sequence diagram."
1254
+ );
1255
+ } else {
1256
+ state.records.lastCreated = void 0;
1257
+ }
1258
+ } else if (state.records.lastDestroyed) {
1259
+ if (param.to !== state.records.lastDestroyed && param.from !== state.records.lastDestroyed) {
1260
+ throw new Error(
1261
+ "The destroyed participant " + state.records.lastDestroyed + " does not have an associated destroying message after its declaration. Please check the sequence diagram."
1262
+ );
1263
+ } else {
1264
+ state.records.lastDestroyed = void 0;
1265
+ }
1266
+ }
1267
+ addSignal(param.from, param.to, param.msg, param.signalType, param.activate);
1268
+ break;
1269
+ case "boxStart":
1270
+ addBox(param.boxData);
1271
+ break;
1272
+ case "boxEnd":
1273
+ boxEnd();
1274
+ break;
1275
+ case "loopStart":
1276
+ addSignal(void 0, void 0, param.loopText, param.signalType);
1277
+ break;
1278
+ case "loopEnd":
1279
+ addSignal(void 0, void 0, void 0, param.signalType);
1280
+ break;
1281
+ case "rectStart":
1282
+ addSignal(void 0, void 0, param.color, param.signalType);
1283
+ break;
1284
+ case "rectEnd":
1285
+ addSignal(void 0, void 0, void 0, param.signalType);
1286
+ break;
1287
+ case "optStart":
1288
+ addSignal(void 0, void 0, param.optText, param.signalType);
1289
+ break;
1290
+ case "optEnd":
1291
+ addSignal(void 0, void 0, void 0, param.signalType);
1292
+ break;
1293
+ case "altStart":
1294
+ addSignal(void 0, void 0, param.altText, param.signalType);
1295
+ break;
1296
+ case "else":
1297
+ addSignal(void 0, void 0, param.altText, param.signalType);
1298
+ break;
1299
+ case "altEnd":
1300
+ addSignal(void 0, void 0, void 0, param.signalType);
1301
+ break;
1302
+ case "setAccTitle":
1303
+ setAccTitle(param.text);
1304
+ break;
1305
+ case "parStart":
1306
+ addSignal(void 0, void 0, param.parText, param.signalType);
1307
+ break;
1308
+ case "and":
1309
+ addSignal(void 0, void 0, param.parText, param.signalType);
1310
+ break;
1311
+ case "parEnd":
1312
+ addSignal(void 0, void 0, void 0, param.signalType);
1313
+ break;
1314
+ case "criticalStart":
1315
+ addSignal(void 0, void 0, param.criticalText, param.signalType);
1316
+ break;
1317
+ case "option":
1318
+ addSignal(void 0, void 0, param.optionText, param.signalType);
1319
+ break;
1320
+ case "criticalEnd":
1321
+ addSignal(void 0, void 0, void 0, param.signalType);
1322
+ break;
1323
+ case "breakStart":
1324
+ addSignal(void 0, void 0, param.breakText, param.signalType);
1325
+ break;
1326
+ case "breakEnd":
1327
+ addSignal(void 0, void 0, void 0, param.signalType);
1328
+ break;
1329
+ }
1330
+ }
1331
+ };
1332
+ const db = {
1333
+ addActor,
1334
+ addMessage,
1335
+ addSignal,
1336
+ addLinks,
1337
+ addDetails,
1338
+ addProperties,
1339
+ autoWrap,
1340
+ setWrap,
1341
+ enableSequenceNumbers,
1342
+ disableSequenceNumbers,
1343
+ showSequenceNumbers,
1344
+ getMessages,
1345
+ getActors,
1346
+ getCreatedActors,
1347
+ getDestroyedActors,
1348
+ getActor,
1349
+ getActorKeys,
1350
+ getActorProperty,
1351
+ getAccTitle,
1352
+ getBoxes,
1353
+ getDiagramTitle,
1354
+ setDiagramTitle,
1355
+ getConfig: () => getConfig().sequence,
1356
+ clear,
1357
+ parseMessage,
1358
+ parseBoxData,
1359
+ LINETYPE,
1360
+ ARROWTYPE,
1361
+ PLACEMENT,
1362
+ addNote,
1363
+ setAccTitle,
1364
+ apply,
1365
+ setAccDescription,
1366
+ getAccDescription,
1367
+ hasAtLeastOneBox,
1368
+ hasAtLeastOneBoxWithTitle
1369
+ };
1370
+ const getStyles = (options) => `.actor {
1371
+ stroke: ${options.actorBorder};
1372
+ fill: ${options.actorBkg};
1373
+ }
1374
+
1375
+ text.actor > tspan {
1376
+ fill: ${options.actorTextColor};
1377
+ stroke: none;
1378
+ }
1379
+
1380
+ .actor-line {
1381
+ stroke: ${options.actorLineColor};
1382
+ }
1383
+
1384
+ .messageLine0 {
1385
+ stroke-width: 1.5;
1386
+ stroke-dasharray: none;
1387
+ stroke: ${options.signalColor};
1388
+ }
1389
+
1390
+ .messageLine1 {
1391
+ stroke-width: 1.5;
1392
+ stroke-dasharray: 2, 2;
1393
+ stroke: ${options.signalColor};
1394
+ }
1395
+
1396
+ #arrowhead path {
1397
+ fill: ${options.signalColor};
1398
+ stroke: ${options.signalColor};
1399
+ }
1400
+
1401
+ .sequenceNumber {
1402
+ fill: ${options.sequenceNumberColor};
1403
+ }
1404
+
1405
+ #sequencenumber {
1406
+ fill: ${options.signalColor};
1407
+ }
1408
+
1409
+ #crosshead path {
1410
+ fill: ${options.signalColor};
1411
+ stroke: ${options.signalColor};
1412
+ }
1413
+
1414
+ .messageText {
1415
+ fill: ${options.signalTextColor};
1416
+ stroke: none;
1417
+ }
1418
+
1419
+ .labelBox {
1420
+ stroke: ${options.labelBoxBorderColor};
1421
+ fill: ${options.labelBoxBkgColor};
1422
+ }
1423
+
1424
+ .labelText, .labelText > tspan {
1425
+ fill: ${options.labelTextColor};
1426
+ stroke: none;
1427
+ }
1428
+
1429
+ .loopText, .loopText > tspan {
1430
+ fill: ${options.loopTextColor};
1431
+ stroke: none;
1432
+ }
1433
+
1434
+ .loopLine {
1435
+ stroke-width: 2px;
1436
+ stroke-dasharray: 2, 2;
1437
+ stroke: ${options.labelBoxBorderColor};
1438
+ fill: ${options.labelBoxBorderColor};
1439
+ }
1440
+
1441
+ .note {
1442
+ //stroke: #decc93;
1443
+ stroke: ${options.noteBorderColor};
1444
+ fill: ${options.noteBkgColor};
1445
+ }
1446
+
1447
+ .noteText, .noteText > tspan {
1448
+ fill: ${options.noteTextColor};
1449
+ stroke: none;
1450
+ }
1451
+
1452
+ .activation0 {
1453
+ fill: ${options.activationBkgColor};
1454
+ stroke: ${options.activationBorderColor};
1455
+ }
1456
+
1457
+ .activation1 {
1458
+ fill: ${options.activationBkgColor};
1459
+ stroke: ${options.activationBorderColor};
1460
+ }
1461
+
1462
+ .activation2 {
1463
+ fill: ${options.activationBkgColor};
1464
+ stroke: ${options.activationBorderColor};
1465
+ }
1466
+
1467
+ .actorPopupMenu {
1468
+ position: absolute;
1469
+ }
1470
+
1471
+ .actorPopupMenuPanel {
1472
+ position: absolute;
1473
+ fill: ${options.actorBkg};
1474
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
1475
+ filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));
1476
+ }
1477
+ .actor-man line {
1478
+ stroke: ${options.actorBorder};
1479
+ fill: ${options.actorBkg};
1480
+ }
1481
+ .actor-man circle, line {
1482
+ stroke: ${options.actorBorder};
1483
+ fill: ${options.actorBkg};
1484
+ stroke-width: 2px;
1485
+ }
1486
+ `;
1487
+ const styles = getStyles;
1488
+ const ACTOR_TYPE_WIDTH = 18 * 2;
1489
+ const TOP_ACTOR_CLASS = "actor-top";
1490
+ const BOTTOM_ACTOR_CLASS = "actor-bottom";
1491
+ const drawRect = function(elem, rectData) {
1492
+ return drawRect$1(elem, rectData);
1493
+ };
1494
+ const drawPopup = function(elem, actor, minMenuWidth, textAttrs, forceMenus) {
1495
+ if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) {
1496
+ return { height: 0, width: 0 };
1497
+ }
1498
+ const links = actor.links;
1499
+ const actorCnt2 = actor.actorCnt;
1500
+ const rectData = actor.rectData;
1501
+ var displayValue = "none";
1502
+ if (forceMenus) {
1503
+ displayValue = "block !important";
1504
+ }
1505
+ const g = elem.append("g");
1506
+ g.attr("id", "actor" + actorCnt2 + "_popup");
1507
+ g.attr("class", "actorPopupMenu");
1508
+ g.attr("display", displayValue);
1509
+ var actorClass = "";
1510
+ if (rectData.class !== void 0) {
1511
+ actorClass = " " + rectData.class;
1512
+ }
1513
+ let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth;
1514
+ const rectElem = g.append("rect");
1515
+ rectElem.attr("class", "actorPopupMenuPanel" + actorClass);
1516
+ rectElem.attr("x", rectData.x);
1517
+ rectElem.attr("y", rectData.height);
1518
+ rectElem.attr("fill", rectData.fill);
1519
+ rectElem.attr("stroke", rectData.stroke);
1520
+ rectElem.attr("width", menuWidth);
1521
+ rectElem.attr("height", rectData.height);
1522
+ rectElem.attr("rx", rectData.rx);
1523
+ rectElem.attr("ry", rectData.ry);
1524
+ if (links != null) {
1525
+ var linkY = 20;
1526
+ for (let key in links) {
1527
+ var linkElem = g.append("a");
1528
+ var sanitizedLink = dist.sanitizeUrl(links[key]);
1529
+ linkElem.attr("xlink:href", sanitizedLink);
1530
+ linkElem.attr("target", "_blank");
1531
+ _drawMenuItemTextCandidateFunc(textAttrs)(
1532
+ key,
1533
+ linkElem,
1534
+ rectData.x + 10,
1535
+ rectData.height + linkY,
1536
+ menuWidth,
1537
+ 20,
1538
+ { class: "actor" },
1539
+ textAttrs
1540
+ );
1541
+ linkY += 30;
1542
+ }
1543
+ }
1544
+ rectElem.attr("height", linkY);
1545
+ return { height: rectData.height + linkY, width: menuWidth };
1546
+ };
1547
+ const popupMenuToggle = function(popId) {
1548
+ return "var pu = document.getElementById('" + popId + "'); if (pu != null) { pu.style.display = pu.style.display == 'block' ? 'none' : 'block'; }";
1549
+ };
1550
+ const drawKatex = async function(elem, textData, msgModel = null) {
1551
+ let textElem = elem.append("foreignObject");
1552
+ const linesSanitized = await renderKatexSanitized(textData.text, getConfig$1());
1553
+ const divElem = textElem.append("xhtml:div").attr("style", "width: fit-content;").attr("xmlns", "http://www.w3.org/1999/xhtml").html(linesSanitized);
1554
+ const dim = divElem.node().getBoundingClientRect();
1555
+ textElem.attr("height", Math.round(dim.height)).attr("width", Math.round(dim.width));
1556
+ if (textData.class === "noteText") {
1557
+ const rectElem = elem.node().firstChild;
1558
+ rectElem.setAttribute("height", dim.height + 2 * textData.textMargin);
1559
+ const rectDim = rectElem.getBBox();
1560
+ 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));
1561
+ } else if (msgModel) {
1562
+ let { startx, stopx, starty } = msgModel;
1563
+ if (startx > stopx) {
1564
+ const temp = startx;
1565
+ startx = stopx;
1566
+ stopx = temp;
1567
+ }
1568
+ textElem.attr("x", Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2));
1569
+ if (textData.class === "loopText") {
1570
+ textElem.attr("y", Math.round(starty));
1571
+ } else {
1572
+ textElem.attr("y", Math.round(starty - dim.height));
1573
+ }
1574
+ }
1575
+ return [textElem];
1576
+ };
1577
+ const drawText = function(elem, textData) {
1578
+ let prevTextHeight = 0;
1579
+ let textHeight = 0;
1580
+ const lines = textData.text.split(common$1.lineBreakRegex);
1581
+ const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize);
1582
+ let textElems = [];
1583
+ let dy = 0;
1584
+ let yfunc = () => textData.y;
1585
+ if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1586
+ switch (textData.valign) {
1587
+ case "top":
1588
+ case "start":
1589
+ yfunc = () => Math.round(textData.y + textData.textMargin);
1590
+ break;
1591
+ case "middle":
1592
+ case "center":
1593
+ yfunc = () => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2);
1594
+ break;
1595
+ case "bottom":
1596
+ case "end":
1597
+ yfunc = () => Math.round(
1598
+ textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin
1599
+ );
1600
+ break;
1601
+ }
1602
+ }
1603
+ if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) {
1604
+ switch (textData.anchor) {
1605
+ case "left":
1606
+ case "start":
1607
+ textData.x = Math.round(textData.x + textData.textMargin);
1608
+ textData.anchor = "start";
1609
+ textData.dominantBaseline = "middle";
1610
+ textData.alignmentBaseline = "middle";
1611
+ break;
1612
+ case "middle":
1613
+ case "center":
1614
+ textData.x = Math.round(textData.x + textData.width / 2);
1615
+ textData.anchor = "middle";
1616
+ textData.dominantBaseline = "middle";
1617
+ textData.alignmentBaseline = "middle";
1618
+ break;
1619
+ case "right":
1620
+ case "end":
1621
+ textData.x = Math.round(textData.x + textData.width - textData.textMargin);
1622
+ textData.anchor = "end";
1623
+ textData.dominantBaseline = "middle";
1624
+ textData.alignmentBaseline = "middle";
1625
+ break;
1626
+ }
1627
+ }
1628
+ for (let [i, line] of lines.entries()) {
1629
+ if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) {
1630
+ dy = i * _textFontSize;
1631
+ }
1632
+ const textElem = elem.append("text");
1633
+ textElem.attr("x", textData.x);
1634
+ textElem.attr("y", yfunc());
1635
+ if (textData.anchor !== void 0) {
1636
+ textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline);
1637
+ }
1638
+ if (textData.fontFamily !== void 0) {
1639
+ textElem.style("font-family", textData.fontFamily);
1640
+ }
1641
+ if (_textFontSizePx !== void 0) {
1642
+ textElem.style("font-size", _textFontSizePx);
1643
+ }
1644
+ if (textData.fontWeight !== void 0) {
1645
+ textElem.style("font-weight", textData.fontWeight);
1646
+ }
1647
+ if (textData.fill !== void 0) {
1648
+ textElem.attr("fill", textData.fill);
1649
+ }
1650
+ if (textData.class !== void 0) {
1651
+ textElem.attr("class", textData.class);
1652
+ }
1653
+ if (textData.dy !== void 0) {
1654
+ textElem.attr("dy", textData.dy);
1655
+ } else if (dy !== 0) {
1656
+ textElem.attr("dy", dy);
1657
+ }
1658
+ const text = line || ZERO_WIDTH_SPACE;
1659
+ if (textData.tspan) {
1660
+ const span = textElem.append("tspan");
1661
+ span.attr("x", textData.x);
1662
+ if (textData.fill !== void 0) {
1663
+ span.attr("fill", textData.fill);
1664
+ }
1665
+ span.text(text);
1666
+ } else {
1667
+ textElem.text(text);
1668
+ }
1669
+ if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1670
+ textHeight += (textElem._groups || textElem)[0][0].getBBox().height;
1671
+ prevTextHeight = textHeight;
1672
+ }
1673
+ textElems.push(textElem);
1674
+ }
1675
+ return textElems;
1676
+ };
1677
+ const drawLabel = function(elem, txtObject) {
1678
+ function genPoints(x, y, width, height, cut) {
1679
+ return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
1680
+ }
1681
+ const polygon = elem.append("polygon");
1682
+ polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7));
1683
+ polygon.attr("class", "labelBox");
1684
+ txtObject.y = txtObject.y + txtObject.height / 2;
1685
+ drawText(elem, txtObject);
1686
+ return polygon;
1687
+ };
1688
+ let actorCnt = -1;
1689
+ const fixLifeLineHeights = (diagram2, actors, actorKeys, conf2) => {
1690
+ if (!diagram2.select) {
1691
+ return;
1692
+ }
1693
+ actorKeys.forEach((actorKey) => {
1694
+ const actor = actors[actorKey];
1695
+ const actorDOM = diagram2.select("#actor" + actor.actorCnt);
1696
+ if (!conf2.mirrorActors && actor.stopy) {
1697
+ actorDOM.attr("y2", actor.stopy + actor.height / 2);
1698
+ } else if (conf2.mirrorActors) {
1699
+ actorDOM.attr("y2", actor.stopy);
1700
+ }
1701
+ });
1702
+ };
1703
+ const drawActorTypeParticipant = async function(elem, actor, conf2, isFooter) {
1704
+ const actorY = isFooter ? actor.stopy : actor.starty;
1705
+ const center = actor.x + actor.width / 2;
1706
+ const centerY = actorY + 5;
1707
+ const boxplusLineGroup = elem.append("g").lower();
1708
+ var g = boxplusLineGroup;
1709
+ if (!isFooter) {
1710
+ actorCnt++;
1711
+ if (Object.keys(actor.links || {}).length && !conf2.forceMenus) {
1712
+ g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer");
1713
+ }
1714
+ g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999");
1715
+ g = boxplusLineGroup.append("g");
1716
+ actor.actorCnt = actorCnt;
1717
+ if (actor.links != null) {
1718
+ g.attr("id", "root-" + actorCnt);
1719
+ }
1720
+ }
1721
+ const rect = getNoteRect$1();
1722
+ var cssclass = "actor";
1723
+ if (actor.properties != null && actor.properties["class"]) {
1724
+ cssclass = actor.properties["class"];
1725
+ } else {
1726
+ rect.fill = "#eaeaea";
1727
+ }
1728
+ if (isFooter) {
1729
+ cssclass += ` ${BOTTOM_ACTOR_CLASS}`;
1730
+ } else {
1731
+ cssclass += ` ${TOP_ACTOR_CLASS}`;
1732
+ }
1733
+ rect.x = actor.x;
1734
+ rect.y = actorY;
1735
+ rect.width = actor.width;
1736
+ rect.height = actor.height;
1737
+ rect.class = cssclass;
1738
+ rect.rx = 3;
1739
+ rect.ry = 3;
1740
+ rect.name = actor.name;
1741
+ const rectElem = drawRect(g, rect);
1742
+ actor.rectData = rect;
1743
+ if (actor.properties != null && actor.properties["icon"]) {
1744
+ const iconSrc = actor.properties["icon"].trim();
1745
+ if (iconSrc.charAt(0) === "@") {
1746
+ drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1));
1747
+ } else {
1748
+ drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc);
1749
+ }
1750
+ }
1751
+ await _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
1752
+ actor.description,
1753
+ g,
1754
+ rect.x,
1755
+ rect.y,
1756
+ rect.width,
1757
+ rect.height,
1758
+ { class: "actor" },
1759
+ conf2
1760
+ );
1761
+ let height = actor.height;
1762
+ if (rectElem.node) {
1763
+ const bounds2 = rectElem.node().getBBox();
1764
+ actor.height = bounds2.height;
1765
+ height = bounds2.height;
1766
+ }
1767
+ return height;
1768
+ };
1769
+ const drawActorTypeActor = async function(elem, actor, conf2, isFooter) {
1770
+ const actorY = isFooter ? actor.stopy : actor.starty;
1771
+ const center = actor.x + actor.width / 2;
1772
+ const centerY = actorY + 80;
1773
+ elem.lower();
1774
+ if (!isFooter) {
1775
+ actorCnt++;
1776
+ elem.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999");
1777
+ actor.actorCnt = actorCnt;
1778
+ }
1779
+ const actElem = elem.append("g");
1780
+ let cssClass = "actor-man";
1781
+ if (isFooter) {
1782
+ cssClass += ` ${BOTTOM_ACTOR_CLASS}`;
1783
+ } else {
1784
+ cssClass += ` ${TOP_ACTOR_CLASS}`;
1785
+ }
1786
+ actElem.attr("class", cssClass);
1787
+ actElem.attr("name", actor.name);
1788
+ const rect = getNoteRect$1();
1789
+ rect.x = actor.x;
1790
+ rect.y = actorY;
1791
+ rect.fill = "#eaeaea";
1792
+ rect.width = actor.width;
1793
+ rect.height = actor.height;
1794
+ rect.class = "actor";
1795
+ rect.rx = 3;
1796
+ rect.ry = 3;
1797
+ actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actorY + 25).attr("x2", center).attr("y2", actorY + 45);
1798
+ 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);
1799
+ actElem.append("line").attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 60).attr("x2", center).attr("y2", actorY + 45);
1800
+ actElem.append("line").attr("x1", center).attr("y1", actorY + 45).attr("x2", center + ACTOR_TYPE_WIDTH / 2 - 2).attr("y2", actorY + 60);
1801
+ const circle = actElem.append("circle");
1802
+ circle.attr("cx", actor.x + actor.width / 2);
1803
+ circle.attr("cy", actorY + 10);
1804
+ circle.attr("r", 15);
1805
+ circle.attr("width", actor.width);
1806
+ circle.attr("height", actor.height);
1807
+ const bounds2 = actElem.node().getBBox();
1808
+ actor.height = bounds2.height;
1809
+ await _drawTextCandidateFunc(conf2, hasKatex(actor.description))(
1810
+ actor.description,
1811
+ actElem,
1812
+ rect.x,
1813
+ rect.y + 35,
1814
+ rect.width,
1815
+ rect.height,
1816
+ { class: "actor" },
1817
+ conf2
1818
+ );
1819
+ return actor.height;
1820
+ };
1821
+ const drawActor = async function(elem, actor, conf2, isFooter) {
1822
+ switch (actor.type) {
1823
+ case "actor":
1824
+ return await drawActorTypeActor(elem, actor, conf2, isFooter);
1825
+ case "participant":
1826
+ return await drawActorTypeParticipant(elem, actor, conf2, isFooter);
1827
+ }
1828
+ };
1829
+ const drawBox = async function(elem, box, conf2) {
1830
+ const boxplusTextGroup = elem.append("g");
1831
+ const g = boxplusTextGroup;
1832
+ drawBackgroundRect(g, box);
1833
+ if (box.name) {
1834
+ await _drawTextCandidateFunc(conf2)(
1835
+ box.name,
1836
+ g,
1837
+ box.x,
1838
+ box.y + (box.textMaxHeight || 0) / 2,
1839
+ box.width,
1840
+ 0,
1841
+ { class: "text" },
1842
+ conf2
1843
+ );
1844
+ }
1845
+ g.lower();
1846
+ };
1847
+ const anchorElement = function(elem) {
1848
+ return elem.append("g");
1849
+ };
1850
+ const drawActivation = function(elem, bounds2, verticalPos, conf2, actorActivations2) {
1851
+ const rect = getNoteRect$1();
1852
+ const g = bounds2.anchored;
1853
+ rect.x = bounds2.startx;
1854
+ rect.y = bounds2.starty;
1855
+ rect.class = "activation" + actorActivations2 % 3;
1856
+ rect.width = bounds2.stopx - bounds2.startx;
1857
+ rect.height = verticalPos - bounds2.starty;
1858
+ drawRect(g, rect);
1859
+ };
1860
+ const drawLoop = async function(elem, loopModel, labelText, conf2) {
1861
+ const {
1862
+ boxMargin,
1863
+ boxTextMargin,
1864
+ labelBoxHeight,
1865
+ labelBoxWidth,
1866
+ messageFontFamily: fontFamily,
1867
+ messageFontSize: fontSize,
1868
+ messageFontWeight: fontWeight
1869
+ } = conf2;
1870
+ const g = elem.append("g");
1871
+ const drawLoopLine = function(startx, starty, stopx, stopy) {
1872
+ return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine");
1873
+ };
1874
+ drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty);
1875
+ drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy);
1876
+ drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy);
1877
+ drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy);
1878
+ if (loopModel.sections !== void 0) {
1879
+ loopModel.sections.forEach(function(item) {
1880
+ drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style(
1881
+ "stroke-dasharray",
1882
+ "3, 3"
1883
+ );
1884
+ });
1885
+ }
1886
+ let txt = getTextObj$1();
1887
+ txt.text = labelText;
1888
+ txt.x = loopModel.startx;
1889
+ txt.y = loopModel.starty;
1890
+ txt.fontFamily = fontFamily;
1891
+ txt.fontSize = fontSize;
1892
+ txt.fontWeight = fontWeight;
1893
+ txt.anchor = "middle";
1894
+ txt.valign = "middle";
1895
+ txt.tspan = false;
1896
+ txt.width = labelBoxWidth || 50;
1897
+ txt.height = labelBoxHeight || 20;
1898
+ txt.textMargin = boxTextMargin;
1899
+ txt.class = "labelText";
1900
+ drawLabel(g, txt);
1901
+ txt = getTextObj();
1902
+ txt.text = loopModel.title;
1903
+ txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2;
1904
+ txt.y = loopModel.starty + boxMargin + boxTextMargin;
1905
+ txt.anchor = "middle";
1906
+ txt.valign = "middle";
1907
+ txt.textMargin = boxTextMargin;
1908
+ txt.class = "loopText";
1909
+ txt.fontFamily = fontFamily;
1910
+ txt.fontSize = fontSize;
1911
+ txt.fontWeight = fontWeight;
1912
+ txt.wrap = true;
1913
+ let textElem = hasKatex(txt.text) ? await drawKatex(g, txt, loopModel) : drawText(g, txt);
1914
+ if (loopModel.sectionTitles !== void 0) {
1915
+ for (const [idx, item] of Object.entries(loopModel.sectionTitles)) {
1916
+ if (item.message) {
1917
+ txt.text = item.message;
1918
+ txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2;
1919
+ txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin;
1920
+ txt.class = "loopText";
1921
+ txt.anchor = "middle";
1922
+ txt.valign = "middle";
1923
+ txt.tspan = false;
1924
+ txt.fontFamily = fontFamily;
1925
+ txt.fontSize = fontSize;
1926
+ txt.fontWeight = fontWeight;
1927
+ txt.wrap = loopModel.wrap;
1928
+ if (hasKatex(txt.text)) {
1929
+ loopModel.starty = loopModel.sections[idx].y;
1930
+ await drawKatex(g, txt, loopModel);
1931
+ } else {
1932
+ drawText(g, txt);
1933
+ }
1934
+ let sectionHeight = Math.round(
1935
+ textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
1936
+ );
1937
+ loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin);
1938
+ }
1939
+ }
1940
+ }
1941
+ loopModel.height = Math.round(loopModel.stopy - loopModel.starty);
1942
+ return g;
1943
+ };
1944
+ const drawBackgroundRect = function(elem, bounds2) {
1945
+ drawBackgroundRect$1(elem, bounds2);
1946
+ };
1947
+ const insertDatabaseIcon = function(elem) {
1948
+ elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr(
1949
+ "d",
1950
+ "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"
1951
+ );
1952
+ };
1953
+ const insertComputerIcon = function(elem) {
1954
+ elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
1955
+ "d",
1956
+ "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"
1957
+ );
1958
+ };
1959
+ const insertClockIcon = function(elem) {
1960
+ elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
1961
+ "d",
1962
+ "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"
1963
+ );
1964
+ };
1965
+ const insertArrowHead = function(elem) {
1966
+ 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").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z");
1967
+ };
1968
+ const insertArrowFilledHead = function(elem) {
1969
+ 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");
1970
+ };
1971
+ const insertSequenceNumber = function(elem) {
1972
+ 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);
1973
+ };
1974
+ const insertArrowCrossHead = function(elem) {
1975
+ const defs = elem.append("defs");
1976
+ const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 4.5);
1977
+ 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");
1978
+ };
1979
+ const getTextObj = function() {
1980
+ return {
1981
+ x: 0,
1982
+ y: 0,
1983
+ fill: void 0,
1984
+ anchor: void 0,
1985
+ style: "#666",
1986
+ width: void 0,
1987
+ height: void 0,
1988
+ textMargin: 0,
1989
+ rx: 0,
1990
+ ry: 0,
1991
+ tspan: true,
1992
+ valign: void 0
1993
+ };
1994
+ };
1995
+ const getNoteRect = function() {
1996
+ return {
1997
+ x: 0,
1998
+ y: 0,
1999
+ fill: "#EDF2AE",
2000
+ stroke: "#666",
2001
+ width: 100,
2002
+ anchor: "start",
2003
+ height: 100,
2004
+ rx: 0,
2005
+ ry: 0
2006
+ };
2007
+ };
2008
+ const _drawTextCandidateFunc = /* @__PURE__ */ function() {
2009
+ function byText(content, g, x, y, width, height, textAttrs) {
2010
+ const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content);
2011
+ _setTextAttrs(text, textAttrs);
2012
+ }
2013
+ function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
2014
+ const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
2015
+ const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize);
2016
+ const lines = content.split(common$1.lineBreakRegex);
2017
+ for (let i = 0; i < lines.length; i++) {
2018
+ const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2;
2019
+ 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);
2020
+ text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
2021
+ text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
2022
+ _setTextAttrs(text, textAttrs);
2023
+ }
2024
+ }
2025
+ function byFo(content, g, x, y, width, height, textAttrs, conf2) {
2026
+ const s = g.append("switch");
2027
+ const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
2028
+ const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
2029
+ text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
2030
+ byTspan(content, s, x, y, width, height, textAttrs, conf2);
2031
+ _setTextAttrs(text, textAttrs);
2032
+ }
2033
+ async function byKatex(content, g, x, y, width, height, textAttrs, conf2) {
2034
+ const dim = await calculateMathMLDimensions(content, getConfig$1());
2035
+ const s = g.append("switch");
2036
+ 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);
2037
+ const text = f.append("xhtml:div").style("height", "100%").style("width", "100%");
2038
+ text.append("div").style("text-align", "center").style("vertical-align", "middle").html(await renderKatexSanitized(content, getConfig$1()));
2039
+ byTspan(content, s, x, y, width, height, textAttrs, conf2);
2040
+ _setTextAttrs(text, textAttrs);
2041
+ }
2042
+ function _setTextAttrs(toText, fromTextAttrsDict) {
2043
+ for (const key in fromTextAttrsDict) {
2044
+ if (fromTextAttrsDict.hasOwnProperty(key)) {
2045
+ toText.attr(key, fromTextAttrsDict[key]);
2046
+ }
2047
+ }
2048
+ }
2049
+ return function(conf2, hasKatex2 = false) {
2050
+ if (hasKatex2) {
2051
+ return byKatex;
2052
+ }
2053
+ return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
2054
+ };
2055
+ }();
2056
+ const _drawMenuItemTextCandidateFunc = /* @__PURE__ */ function() {
2057
+ function byText(content, g, x, y, width, height, textAttrs) {
2058
+ const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content);
2059
+ _setTextAttrs(text, textAttrs);
2060
+ }
2061
+ function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
2062
+ const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
2063
+ const lines = content.split(common$1.lineBreakRegex);
2064
+ for (let i = 0; i < lines.length; i++) {
2065
+ const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2;
2066
+ 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);
2067
+ text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]);
2068
+ text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
2069
+ _setTextAttrs(text, textAttrs);
2070
+ }
2071
+ }
2072
+ function byFo(content, g, x, y, width, height, textAttrs, conf2) {
2073
+ const s = g.append("switch");
2074
+ const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
2075
+ const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
2076
+ text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
2077
+ byTspan(content, s, x, y, width, height, textAttrs, conf2);
2078
+ _setTextAttrs(text, textAttrs);
2079
+ }
2080
+ function _setTextAttrs(toText, fromTextAttrsDict) {
2081
+ for (const key in fromTextAttrsDict) {
2082
+ if (fromTextAttrsDict.hasOwnProperty(key)) {
2083
+ toText.attr(key, fromTextAttrsDict[key]);
2084
+ }
2085
+ }
2086
+ }
2087
+ return function(conf2) {
2088
+ return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
2089
+ };
2090
+ }();
2091
+ const svgDraw = {
2092
+ drawRect,
2093
+ drawText,
2094
+ drawLabel,
2095
+ drawActor,
2096
+ drawBox,
2097
+ drawPopup,
2098
+ anchorElement,
2099
+ drawActivation,
2100
+ drawLoop,
2101
+ drawBackgroundRect,
2102
+ insertArrowHead,
2103
+ insertArrowFilledHead,
2104
+ insertSequenceNumber,
2105
+ insertArrowCrossHead,
2106
+ insertDatabaseIcon,
2107
+ insertComputerIcon,
2108
+ insertClockIcon,
2109
+ getTextObj,
2110
+ getNoteRect,
2111
+ fixLifeLineHeights,
2112
+ sanitizeUrl: dist.sanitizeUrl
2113
+ };
2114
+ let conf = {};
2115
+ const bounds = {
2116
+ data: {
2117
+ startx: void 0,
2118
+ stopx: void 0,
2119
+ starty: void 0,
2120
+ stopy: void 0
2121
+ },
2122
+ verticalPos: 0,
2123
+ sequenceItems: [],
2124
+ activations: [],
2125
+ models: {
2126
+ getHeight: function() {
2127
+ return Math.max.apply(
2128
+ null,
2129
+ this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0)
2130
+ ) + (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));
2131
+ },
2132
+ clear: function() {
2133
+ this.actors = [];
2134
+ this.boxes = [];
2135
+ this.loops = [];
2136
+ this.messages = [];
2137
+ this.notes = [];
2138
+ },
2139
+ addBox: function(boxModel) {
2140
+ this.boxes.push(boxModel);
2141
+ },
2142
+ addActor: function(actorModel) {
2143
+ this.actors.push(actorModel);
2144
+ },
2145
+ addLoop: function(loopModel) {
2146
+ this.loops.push(loopModel);
2147
+ },
2148
+ addMessage: function(msgModel) {
2149
+ this.messages.push(msgModel);
2150
+ },
2151
+ addNote: function(noteModel) {
2152
+ this.notes.push(noteModel);
2153
+ },
2154
+ lastActor: function() {
2155
+ return this.actors[this.actors.length - 1];
2156
+ },
2157
+ lastLoop: function() {
2158
+ return this.loops[this.loops.length - 1];
2159
+ },
2160
+ lastMessage: function() {
2161
+ return this.messages[this.messages.length - 1];
2162
+ },
2163
+ lastNote: function() {
2164
+ return this.notes[this.notes.length - 1];
2165
+ },
2166
+ actors: [],
2167
+ boxes: [],
2168
+ loops: [],
2169
+ messages: [],
2170
+ notes: []
2171
+ },
2172
+ init: function() {
2173
+ this.sequenceItems = [];
2174
+ this.activations = [];
2175
+ this.models.clear();
2176
+ this.data = {
2177
+ startx: void 0,
2178
+ stopx: void 0,
2179
+ starty: void 0,
2180
+ stopy: void 0
2181
+ };
2182
+ this.verticalPos = 0;
2183
+ setConf(getConfig());
2184
+ },
2185
+ updateVal: function(obj, key, val, fun) {
2186
+ if (obj[key] === void 0) {
2187
+ obj[key] = val;
2188
+ } else {
2189
+ obj[key] = fun(val, obj[key]);
2190
+ }
2191
+ },
2192
+ updateBounds: function(startx, starty, stopx, stopy) {
2193
+ const _self = this;
2194
+ let cnt = 0;
2195
+ function updateFn(type) {
2196
+ return function updateItemBounds(item) {
2197
+ cnt++;
2198
+ const n = _self.sequenceItems.length - cnt + 1;
2199
+ _self.updateVal(item, "starty", starty - n * conf.boxMargin, Math.min);
2200
+ _self.updateVal(item, "stopy", stopy + n * conf.boxMargin, Math.max);
2201
+ _self.updateVal(bounds.data, "startx", startx - n * conf.boxMargin, Math.min);
2202
+ _self.updateVal(bounds.data, "stopx", stopx + n * conf.boxMargin, Math.max);
2203
+ if (!(type === "activation")) {
2204
+ _self.updateVal(item, "startx", startx - n * conf.boxMargin, Math.min);
2205
+ _self.updateVal(item, "stopx", stopx + n * conf.boxMargin, Math.max);
2206
+ _self.updateVal(bounds.data, "starty", starty - n * conf.boxMargin, Math.min);
2207
+ _self.updateVal(bounds.data, "stopy", stopy + n * conf.boxMargin, Math.max);
2208
+ }
2209
+ };
2210
+ }
2211
+ this.sequenceItems.forEach(updateFn());
2212
+ this.activations.forEach(updateFn("activation"));
2213
+ },
2214
+ insert: function(startx, starty, stopx, stopy) {
2215
+ const _startx = common$1.getMin(startx, stopx);
2216
+ const _stopx = common$1.getMax(startx, stopx);
2217
+ const _starty = common$1.getMin(starty, stopy);
2218
+ const _stopy = common$1.getMax(starty, stopy);
2219
+ this.updateVal(bounds.data, "startx", _startx, Math.min);
2220
+ this.updateVal(bounds.data, "starty", _starty, Math.min);
2221
+ this.updateVal(bounds.data, "stopx", _stopx, Math.max);
2222
+ this.updateVal(bounds.data, "stopy", _stopy, Math.max);
2223
+ this.updateBounds(_startx, _starty, _stopx, _stopy);
2224
+ },
2225
+ newActivation: function(message, diagram2, actors) {
2226
+ const actorRect = actors[message.from.actor];
2227
+ const stackedSize = actorActivations(message.from.actor).length || 0;
2228
+ const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
2229
+ this.activations.push({
2230
+ startx: x,
2231
+ starty: this.verticalPos + 2,
2232
+ stopx: x + conf.activationWidth,
2233
+ stopy: void 0,
2234
+ actor: message.from.actor,
2235
+ anchored: svgDraw.anchorElement(diagram2)
2236
+ });
2237
+ },
2238
+ endActivation: function(message) {
2239
+ const lastActorActivationIdx = this.activations.map(function(activation) {
2240
+ return activation.actor;
2241
+ }).lastIndexOf(message.from.actor);
2242
+ return this.activations.splice(lastActorActivationIdx, 1)[0];
2243
+ },
2244
+ createLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2245
+ return {
2246
+ startx: void 0,
2247
+ starty: this.verticalPos,
2248
+ stopx: void 0,
2249
+ stopy: void 0,
2250
+ title: title.message,
2251
+ wrap: title.wrap,
2252
+ width: title.width,
2253
+ height: 0,
2254
+ fill
2255
+ };
2256
+ },
2257
+ newLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2258
+ this.sequenceItems.push(this.createLoop(title, fill));
2259
+ },
2260
+ endLoop: function() {
2261
+ return this.sequenceItems.pop();
2262
+ },
2263
+ isLoopOverlap: function() {
2264
+ return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false;
2265
+ },
2266
+ addSectionToLoop: function(message) {
2267
+ const loop = this.sequenceItems.pop();
2268
+ loop.sections = loop.sections || [];
2269
+ loop.sectionTitles = loop.sectionTitles || [];
2270
+ loop.sections.push({ y: bounds.getVerticalPos(), height: 0 });
2271
+ loop.sectionTitles.push(message);
2272
+ this.sequenceItems.push(loop);
2273
+ },
2274
+ saveVerticalPos: function() {
2275
+ if (this.isLoopOverlap()) {
2276
+ this.savedVerticalPos = this.verticalPos;
2277
+ }
2278
+ },
2279
+ resetVerticalPos: function() {
2280
+ if (this.isLoopOverlap()) {
2281
+ this.verticalPos = this.savedVerticalPos;
2282
+ }
2283
+ },
2284
+ bumpVerticalPos: function(bump) {
2285
+ this.verticalPos = this.verticalPos + bump;
2286
+ this.data.stopy = common$1.getMax(this.data.stopy, this.verticalPos);
2287
+ },
2288
+ getVerticalPos: function() {
2289
+ return this.verticalPos;
2290
+ },
2291
+ getBounds: function() {
2292
+ return { bounds: this.data, models: this.models };
2293
+ }
2294
+ };
2295
+ const drawNote = async function(elem, noteModel) {
2296
+ bounds.bumpVerticalPos(conf.boxMargin);
2297
+ noteModel.height = conf.boxMargin;
2298
+ noteModel.starty = bounds.getVerticalPos();
2299
+ const rect = getNoteRect$1();
2300
+ rect.x = noteModel.startx;
2301
+ rect.y = noteModel.starty;
2302
+ rect.width = noteModel.width || conf.width;
2303
+ rect.class = "note";
2304
+ const g = elem.append("g");
2305
+ const rectElem = svgDraw.drawRect(g, rect);
2306
+ const textObj = getTextObj$1();
2307
+ textObj.x = noteModel.startx;
2308
+ textObj.y = noteModel.starty;
2309
+ textObj.width = rect.width;
2310
+ textObj.dy = "1em";
2311
+ textObj.text = noteModel.message;
2312
+ textObj.class = "noteText";
2313
+ textObj.fontFamily = conf.noteFontFamily;
2314
+ textObj.fontSize = conf.noteFontSize;
2315
+ textObj.fontWeight = conf.noteFontWeight;
2316
+ textObj.anchor = conf.noteAlign;
2317
+ textObj.textMargin = conf.noteMargin;
2318
+ textObj.valign = "center";
2319
+ const textElem = hasKatex(textObj.text) ? await drawKatex(g, textObj) : drawText(g, textObj);
2320
+ const textHeight = Math.round(
2321
+ textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
2322
+ );
2323
+ rectElem.attr("height", textHeight + 2 * conf.noteMargin);
2324
+ noteModel.height += textHeight + 2 * conf.noteMargin;
2325
+ bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin);
2326
+ noteModel.stopy = noteModel.starty + textHeight + 2 * conf.noteMargin;
2327
+ noteModel.stopx = noteModel.startx + rect.width;
2328
+ bounds.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy);
2329
+ bounds.models.addNote(noteModel);
2330
+ };
2331
+ const messageFont = (cnf) => {
2332
+ return {
2333
+ fontFamily: cnf.messageFontFamily,
2334
+ fontSize: cnf.messageFontSize,
2335
+ fontWeight: cnf.messageFontWeight
2336
+ };
2337
+ };
2338
+ const noteFont = (cnf) => {
2339
+ return {
2340
+ fontFamily: cnf.noteFontFamily,
2341
+ fontSize: cnf.noteFontSize,
2342
+ fontWeight: cnf.noteFontWeight
2343
+ };
2344
+ };
2345
+ const actorFont = (cnf) => {
2346
+ return {
2347
+ fontFamily: cnf.actorFontFamily,
2348
+ fontSize: cnf.actorFontSize,
2349
+ fontWeight: cnf.actorFontWeight
2350
+ };
2351
+ };
2352
+ async function boundMessage(_diagram, msgModel) {
2353
+ bounds.bumpVerticalPos(10);
2354
+ const { startx, stopx, message } = msgModel;
2355
+ const lines = common$1.splitBreaks(message).length;
2356
+ const isKatexMsg = hasKatex(message);
2357
+ const textDims = isKatexMsg ? await calculateMathMLDimensions(message, getConfig()) : utils.calculateTextDimensions(message, messageFont(conf));
2358
+ if (!isKatexMsg) {
2359
+ const lineHeight = textDims.height / lines;
2360
+ msgModel.height += lineHeight;
2361
+ bounds.bumpVerticalPos(lineHeight);
2362
+ }
2363
+ let lineStartY;
2364
+ let totalOffset = textDims.height - 10;
2365
+ const textWidth = textDims.width;
2366
+ if (startx === stopx) {
2367
+ lineStartY = bounds.getVerticalPos() + totalOffset;
2368
+ if (!conf.rightAngles) {
2369
+ totalOffset += conf.boxMargin;
2370
+ lineStartY = bounds.getVerticalPos() + totalOffset;
2371
+ }
2372
+ totalOffset += 30;
2373
+ const dx = common$1.getMax(textWidth / 2, conf.width / 2);
2374
+ bounds.insert(
2375
+ startx - dx,
2376
+ bounds.getVerticalPos() - 10 + totalOffset,
2377
+ stopx + dx,
2378
+ bounds.getVerticalPos() + 30 + totalOffset
2379
+ );
2380
+ } else {
2381
+ totalOffset += conf.boxMargin;
2382
+ lineStartY = bounds.getVerticalPos() + totalOffset;
2383
+ bounds.insert(startx, lineStartY - 10, stopx, lineStartY);
2384
+ }
2385
+ bounds.bumpVerticalPos(totalOffset);
2386
+ msgModel.height += totalOffset;
2387
+ msgModel.stopy = msgModel.starty + msgModel.height;
2388
+ bounds.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy);
2389
+ return lineStartY;
2390
+ }
2391
+ const drawMessage = async function(diagram2, msgModel, lineStartY, diagObj) {
2392
+ const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel;
2393
+ const textDims = utils.calculateTextDimensions(message, messageFont(conf));
2394
+ const textObj = getTextObj$1();
2395
+ textObj.x = startx;
2396
+ textObj.y = starty + 10;
2397
+ textObj.width = stopx - startx;
2398
+ textObj.class = "messageText";
2399
+ textObj.dy = "1em";
2400
+ textObj.text = message;
2401
+ textObj.fontFamily = conf.messageFontFamily;
2402
+ textObj.fontSize = conf.messageFontSize;
2403
+ textObj.fontWeight = conf.messageFontWeight;
2404
+ textObj.anchor = conf.messageAlign;
2405
+ textObj.valign = "center";
2406
+ textObj.textMargin = conf.wrapPadding;
2407
+ textObj.tspan = false;
2408
+ hasKatex(textObj.text) ? await drawKatex(diagram2, textObj, { startx, stopx, starty: lineStartY }) : drawText(diagram2, textObj);
2409
+ const textWidth = textDims.width;
2410
+ let line;
2411
+ if (startx === stopx) {
2412
+ if (conf.rightAngles) {
2413
+ line = diagram2.append("path").attr(
2414
+ "d",
2415
+ `M ${startx},${lineStartY} H ${startx + common$1.getMax(conf.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}`
2416
+ );
2417
+ } else {
2418
+ line = diagram2.append("path").attr(
2419
+ "d",
2420
+ "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20)
2421
+ );
2422
+ }
2423
+ } else {
2424
+ line = diagram2.append("line");
2425
+ line.attr("x1", startx);
2426
+ line.attr("y1", lineStartY);
2427
+ line.attr("x2", stopx);
2428
+ line.attr("y2", lineStartY);
2429
+ }
2430
+ if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN) {
2431
+ line.style("stroke-dasharray", "3, 3");
2432
+ line.attr("class", "messageLine1");
2433
+ } else {
2434
+ line.attr("class", "messageLine0");
2435
+ }
2436
+ let url = "";
2437
+ if (conf.arrowMarkerAbsolute) {
2438
+ url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
2439
+ url = url.replace(/\(/g, "\\(");
2440
+ url = url.replace(/\)/g, "\\)");
2441
+ }
2442
+ line.attr("stroke-width", 2);
2443
+ line.attr("stroke", "none");
2444
+ line.style("fill", "none");
2445
+ if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) {
2446
+ line.attr("marker-end", "url(" + url + "#arrowhead)");
2447
+ }
2448
+ if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) {
2449
+ line.attr("marker-end", "url(" + url + "#filled-head)");
2450
+ }
2451
+ if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) {
2452
+ line.attr("marker-end", "url(" + url + "#crosshead)");
2453
+ }
2454
+ if (sequenceVisible || conf.showSequenceNumbers) {
2455
+ line.attr("marker-start", "url(" + url + "#sequencenumber)");
2456
+ 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);
2457
+ }
2458
+ };
2459
+ const addActorRenderingData = async function(diagram2, actors, createdActors, actorKeys, verticalPos, messages, isFooter) {
2460
+ let prevWidth = 0;
2461
+ let prevMargin = 0;
2462
+ let prevBox = void 0;
2463
+ let maxHeight = 0;
2464
+ for (const actorKey of actorKeys) {
2465
+ const actor = actors[actorKey];
2466
+ const box = actor.box;
2467
+ if (prevBox && prevBox != box) {
2468
+ {
2469
+ bounds.models.addBox(prevBox);
2470
+ }
2471
+ prevMargin += conf.boxMargin + prevBox.margin;
2472
+ }
2473
+ if (box && box != prevBox) {
2474
+ {
2475
+ box.x = prevWidth + prevMargin;
2476
+ box.y = verticalPos;
2477
+ }
2478
+ prevMargin += box.margin;
2479
+ }
2480
+ actor.width = actor.width || conf.width;
2481
+ actor.height = common$1.getMax(actor.height || conf.height, conf.height);
2482
+ actor.margin = actor.margin || conf.actorMargin;
2483
+ maxHeight = common$1.getMax(maxHeight, actor.height);
2484
+ if (createdActors[actor.name]) {
2485
+ prevMargin += actor.width / 2;
2486
+ }
2487
+ actor.x = prevWidth + prevMargin;
2488
+ actor.starty = bounds.getVerticalPos();
2489
+ bounds.insert(actor.x, verticalPos, actor.x + actor.width, actor.height);
2490
+ prevWidth += actor.width + prevMargin;
2491
+ if (actor.box) {
2492
+ actor.box.width = prevWidth + box.margin - actor.box.x;
2493
+ }
2494
+ prevMargin = actor.margin;
2495
+ prevBox = actor.box;
2496
+ bounds.models.addActor(actor);
2497
+ }
2498
+ if (prevBox && true) {
2499
+ bounds.models.addBox(prevBox);
2500
+ }
2501
+ bounds.bumpVerticalPos(maxHeight);
2502
+ };
2503
+ const drawActors = async function(diagram2, actors, actorKeys, isFooter) {
2504
+ if (!isFooter) {
2505
+ for (const actorKey of actorKeys) {
2506
+ const actor = actors[actorKey];
2507
+ await svgDraw.drawActor(diagram2, actor, conf, false);
2508
+ }
2509
+ } else {
2510
+ let maxHeight = 0;
2511
+ bounds.bumpVerticalPos(conf.boxMargin * 2);
2512
+ for (const actorKey of actorKeys) {
2513
+ const actor = actors[actorKey];
2514
+ if (!actor.stopy) {
2515
+ actor.stopy = bounds.getVerticalPos();
2516
+ }
2517
+ const height = await svgDraw.drawActor(diagram2, actor, conf, true);
2518
+ maxHeight = common$1.getMax(maxHeight, height);
2519
+ }
2520
+ bounds.bumpVerticalPos(maxHeight + conf.boxMargin);
2521
+ }
2522
+ };
2523
+ const drawActorsPopup = function(diagram2, actors, actorKeys, doc) {
2524
+ let maxHeight = 0;
2525
+ let maxWidth = 0;
2526
+ for (const actorKey of actorKeys) {
2527
+ const actor = actors[actorKey];
2528
+ const minMenuWidth = getRequiredPopupWidth(actor);
2529
+ const menuDimensions = svgDraw.drawPopup(
2530
+ diagram2,
2531
+ actor,
2532
+ minMenuWidth,
2533
+ conf,
2534
+ conf.forceMenus,
2535
+ doc
2536
+ );
2537
+ if (menuDimensions.height > maxHeight) {
2538
+ maxHeight = menuDimensions.height;
2539
+ }
2540
+ if (menuDimensions.width + actor.x > maxWidth) {
2541
+ maxWidth = menuDimensions.width + actor.x;
2542
+ }
2543
+ }
2544
+ return { maxHeight, maxWidth };
2545
+ };
2546
+ const setConf = function(cnf) {
2547
+ assignWithDepth$1(conf, cnf);
2548
+ if (cnf.fontFamily) {
2549
+ conf.actorFontFamily = conf.noteFontFamily = conf.messageFontFamily = cnf.fontFamily;
2550
+ }
2551
+ if (cnf.fontSize) {
2552
+ conf.actorFontSize = conf.noteFontSize = conf.messageFontSize = cnf.fontSize;
2553
+ }
2554
+ if (cnf.fontWeight) {
2555
+ conf.actorFontWeight = conf.noteFontWeight = conf.messageFontWeight = cnf.fontWeight;
2556
+ }
2557
+ };
2558
+ const actorActivations = function(actor) {
2559
+ return bounds.activations.filter(function(activation) {
2560
+ return activation.actor === actor;
2561
+ });
2562
+ };
2563
+ const activationBounds = function(actor, actors) {
2564
+ const actorObj = actors[actor];
2565
+ const activations = actorActivations(actor);
2566
+ const left = activations.reduce(function(acc, activation) {
2567
+ return common$1.getMin(acc, activation.startx);
2568
+ }, actorObj.x + actorObj.width / 2 - 1);
2569
+ const right = activations.reduce(function(acc, activation) {
2570
+ return common$1.getMax(acc, activation.stopx);
2571
+ }, actorObj.x + actorObj.width / 2 + 1);
2572
+ return [left, right];
2573
+ };
2574
+ function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) {
2575
+ bounds.bumpVerticalPos(preMargin);
2576
+ let heightAdjust = postMargin;
2577
+ if (msg.id && msg.message && loopWidths[msg.id]) {
2578
+ const loopWidth = loopWidths[msg.id].width;
2579
+ const textConf = messageFont(conf);
2580
+ msg.message = utils.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf.wrapPadding, textConf);
2581
+ msg.width = loopWidth;
2582
+ msg.wrap = true;
2583
+ const textDims = utils.calculateTextDimensions(msg.message, textConf);
2584
+ const totalOffset = common$1.getMax(textDims.height, conf.labelBoxHeight);
2585
+ heightAdjust = postMargin + totalOffset;
2586
+ log$1.debug(`${totalOffset} - ${msg.message}`);
2587
+ }
2588
+ addLoopFn(msg);
2589
+ bounds.bumpVerticalPos(heightAdjust);
2590
+ }
2591
+ function adjustCreatedDestroyedData(msg, msgModel, lineStartY, index, actors, createdActors, destroyedActors) {
2592
+ function receiverAdjustment(actor, adjustment) {
2593
+ if (actor.x < actors[msg.from].x) {
2594
+ bounds.insert(
2595
+ msgModel.stopx - adjustment,
2596
+ msgModel.starty,
2597
+ msgModel.startx,
2598
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
2599
+ );
2600
+ msgModel.stopx = msgModel.stopx + adjustment;
2601
+ } else {
2602
+ bounds.insert(
2603
+ msgModel.startx,
2604
+ msgModel.starty,
2605
+ msgModel.stopx + adjustment,
2606
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
2607
+ );
2608
+ msgModel.stopx = msgModel.stopx - adjustment;
2609
+ }
2610
+ }
2611
+ function senderAdjustment(actor, adjustment) {
2612
+ if (actor.x < actors[msg.to].x) {
2613
+ bounds.insert(
2614
+ msgModel.startx - adjustment,
2615
+ msgModel.starty,
2616
+ msgModel.stopx,
2617
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
2618
+ );
2619
+ msgModel.startx = msgModel.startx + adjustment;
2620
+ } else {
2621
+ bounds.insert(
2622
+ msgModel.stopx,
2623
+ msgModel.starty,
2624
+ msgModel.startx + adjustment,
2625
+ msgModel.stopy + actor.height / 2 + conf.noteMargin
2626
+ );
2627
+ msgModel.startx = msgModel.startx - adjustment;
2628
+ }
2629
+ }
2630
+ if (createdActors[msg.to] == index) {
2631
+ const actor = actors[msg.to];
2632
+ const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3;
2633
+ receiverAdjustment(actor, adjustment);
2634
+ actor.starty = lineStartY - actor.height / 2;
2635
+ bounds.bumpVerticalPos(actor.height / 2);
2636
+ } else if (destroyedActors[msg.from] == index) {
2637
+ const actor = actors[msg.from];
2638
+ if (conf.mirrorActors) {
2639
+ const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 : actor.width / 2;
2640
+ senderAdjustment(actor, adjustment);
2641
+ }
2642
+ actor.stopy = lineStartY - actor.height / 2;
2643
+ bounds.bumpVerticalPos(actor.height / 2);
2644
+ } else if (destroyedActors[msg.to] == index) {
2645
+ const actor = actors[msg.to];
2646
+ if (conf.mirrorActors) {
2647
+ const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3;
2648
+ receiverAdjustment(actor, adjustment);
2649
+ }
2650
+ actor.stopy = lineStartY - actor.height / 2;
2651
+ bounds.bumpVerticalPos(actor.height / 2);
2652
+ }
2653
+ }
2654
+ const draw = async function(_text, id, _version, diagObj) {
2655
+ const { securityLevel, sequence } = getConfig();
2656
+ conf = sequence;
2657
+ let sandboxElement;
2658
+ if (securityLevel === "sandbox") {
2659
+ sandboxElement = select("#i" + id);
2660
+ }
2661
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
2662
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
2663
+ bounds.init();
2664
+ log$1.debug(diagObj.db);
2665
+ const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`);
2666
+ const actors = diagObj.db.getActors();
2667
+ const createdActors = diagObj.db.getCreatedActors();
2668
+ const destroyedActors = diagObj.db.getDestroyedActors();
2669
+ const boxes = diagObj.db.getBoxes();
2670
+ let actorKeys = diagObj.db.getActorKeys();
2671
+ const messages = diagObj.db.getMessages();
2672
+ const title = diagObj.db.getDiagramTitle();
2673
+ const hasBoxes = diagObj.db.hasAtLeastOneBox();
2674
+ const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle();
2675
+ const maxMessageWidthPerActor = await getMaxMessageWidthPerActor(actors, messages, diagObj);
2676
+ conf.height = await calculateActorMargins(actors, maxMessageWidthPerActor, boxes);
2677
+ svgDraw.insertComputerIcon(diagram2);
2678
+ svgDraw.insertDatabaseIcon(diagram2);
2679
+ svgDraw.insertClockIcon(diagram2);
2680
+ if (hasBoxes) {
2681
+ bounds.bumpVerticalPos(conf.boxMargin);
2682
+ if (hasBoxTitles) {
2683
+ bounds.bumpVerticalPos(boxes[0].textMaxHeight);
2684
+ }
2685
+ }
2686
+ if (conf.hideUnusedParticipants === true) {
2687
+ const newActors = /* @__PURE__ */ new Set();
2688
+ messages.forEach((message) => {
2689
+ newActors.add(message.from);
2690
+ newActors.add(message.to);
2691
+ });
2692
+ actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey));
2693
+ }
2694
+ await addActorRenderingData(diagram2, actors, createdActors, actorKeys, 0);
2695
+ const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj);
2696
+ svgDraw.insertArrowHead(diagram2);
2697
+ svgDraw.insertArrowCrossHead(diagram2);
2698
+ svgDraw.insertArrowFilledHead(diagram2);
2699
+ svgDraw.insertSequenceNumber(diagram2);
2700
+ function activeEnd(msg, verticalPos) {
2701
+ const activationData = bounds.endActivation(msg);
2702
+ if (activationData.starty + 18 > verticalPos) {
2703
+ activationData.starty = verticalPos - 6;
2704
+ verticalPos += 12;
2705
+ }
2706
+ svgDraw.drawActivation(
2707
+ diagram2,
2708
+ activationData,
2709
+ verticalPos,
2710
+ conf,
2711
+ actorActivations(msg.from.actor).length
2712
+ );
2713
+ bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos);
2714
+ }
2715
+ let sequenceIndex = 1;
2716
+ let sequenceIndexStep = 1;
2717
+ const messagesToDraw = [];
2718
+ const backgrounds = [];
2719
+ let index = 0;
2720
+ for (const msg of messages) {
2721
+ let loopModel, noteModel, msgModel;
2722
+ switch (msg.type) {
2723
+ case diagObj.db.LINETYPE.NOTE:
2724
+ bounds.resetVerticalPos();
2725
+ noteModel = msg.noteModel;
2726
+ await drawNote(diagram2, noteModel);
2727
+ break;
2728
+ case diagObj.db.LINETYPE.ACTIVE_START:
2729
+ bounds.newActivation(msg, diagram2, actors);
2730
+ break;
2731
+ case diagObj.db.LINETYPE.ACTIVE_END:
2732
+ activeEnd(msg, bounds.getVerticalPos());
2733
+ break;
2734
+ case diagObj.db.LINETYPE.LOOP_START:
2735
+ adjustLoopHeightForWrap(
2736
+ loopWidths,
2737
+ msg,
2738
+ conf.boxMargin,
2739
+ conf.boxMargin + conf.boxTextMargin,
2740
+ (message) => bounds.newLoop(message)
2741
+ );
2742
+ break;
2743
+ case diagObj.db.LINETYPE.LOOP_END:
2744
+ loopModel = bounds.endLoop();
2745
+ await svgDraw.drawLoop(diagram2, loopModel, "loop", conf);
2746
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2747
+ bounds.models.addLoop(loopModel);
2748
+ break;
2749
+ case diagObj.db.LINETYPE.RECT_START:
2750
+ adjustLoopHeightForWrap(
2751
+ loopWidths,
2752
+ msg,
2753
+ conf.boxMargin,
2754
+ conf.boxMargin,
2755
+ (message) => bounds.newLoop(void 0, message.message)
2756
+ );
2757
+ break;
2758
+ case diagObj.db.LINETYPE.RECT_END:
2759
+ loopModel = bounds.endLoop();
2760
+ backgrounds.push(loopModel);
2761
+ bounds.models.addLoop(loopModel);
2762
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2763
+ break;
2764
+ case diagObj.db.LINETYPE.OPT_START:
2765
+ adjustLoopHeightForWrap(
2766
+ loopWidths,
2767
+ msg,
2768
+ conf.boxMargin,
2769
+ conf.boxMargin + conf.boxTextMargin,
2770
+ (message) => bounds.newLoop(message)
2771
+ );
2772
+ break;
2773
+ case diagObj.db.LINETYPE.OPT_END:
2774
+ loopModel = bounds.endLoop();
2775
+ await svgDraw.drawLoop(diagram2, loopModel, "opt", conf);
2776
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2777
+ bounds.models.addLoop(loopModel);
2778
+ break;
2779
+ case diagObj.db.LINETYPE.ALT_START:
2780
+ adjustLoopHeightForWrap(
2781
+ loopWidths,
2782
+ msg,
2783
+ conf.boxMargin,
2784
+ conf.boxMargin + conf.boxTextMargin,
2785
+ (message) => bounds.newLoop(message)
2786
+ );
2787
+ break;
2788
+ case diagObj.db.LINETYPE.ALT_ELSE:
2789
+ adjustLoopHeightForWrap(
2790
+ loopWidths,
2791
+ msg,
2792
+ conf.boxMargin + conf.boxTextMargin,
2793
+ conf.boxMargin,
2794
+ (message) => bounds.addSectionToLoop(message)
2795
+ );
2796
+ break;
2797
+ case diagObj.db.LINETYPE.ALT_END:
2798
+ loopModel = bounds.endLoop();
2799
+ await svgDraw.drawLoop(diagram2, loopModel, "alt", conf);
2800
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2801
+ bounds.models.addLoop(loopModel);
2802
+ break;
2803
+ case diagObj.db.LINETYPE.PAR_START:
2804
+ case diagObj.db.LINETYPE.PAR_OVER_START:
2805
+ adjustLoopHeightForWrap(
2806
+ loopWidths,
2807
+ msg,
2808
+ conf.boxMargin,
2809
+ conf.boxMargin + conf.boxTextMargin,
2810
+ (message) => bounds.newLoop(message)
2811
+ );
2812
+ bounds.saveVerticalPos();
2813
+ break;
2814
+ case diagObj.db.LINETYPE.PAR_AND:
2815
+ adjustLoopHeightForWrap(
2816
+ loopWidths,
2817
+ msg,
2818
+ conf.boxMargin + conf.boxTextMargin,
2819
+ conf.boxMargin,
2820
+ (message) => bounds.addSectionToLoop(message)
2821
+ );
2822
+ break;
2823
+ case diagObj.db.LINETYPE.PAR_END:
2824
+ loopModel = bounds.endLoop();
2825
+ await svgDraw.drawLoop(diagram2, loopModel, "par", conf);
2826
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2827
+ bounds.models.addLoop(loopModel);
2828
+ break;
2829
+ case diagObj.db.LINETYPE.AUTONUMBER:
2830
+ sequenceIndex = msg.message.start || sequenceIndex;
2831
+ sequenceIndexStep = msg.message.step || sequenceIndexStep;
2832
+ if (msg.message.visible) {
2833
+ diagObj.db.enableSequenceNumbers();
2834
+ } else {
2835
+ diagObj.db.disableSequenceNumbers();
2836
+ }
2837
+ break;
2838
+ case diagObj.db.LINETYPE.CRITICAL_START:
2839
+ adjustLoopHeightForWrap(
2840
+ loopWidths,
2841
+ msg,
2842
+ conf.boxMargin,
2843
+ conf.boxMargin + conf.boxTextMargin,
2844
+ (message) => bounds.newLoop(message)
2845
+ );
2846
+ break;
2847
+ case diagObj.db.LINETYPE.CRITICAL_OPTION:
2848
+ adjustLoopHeightForWrap(
2849
+ loopWidths,
2850
+ msg,
2851
+ conf.boxMargin + conf.boxTextMargin,
2852
+ conf.boxMargin,
2853
+ (message) => bounds.addSectionToLoop(message)
2854
+ );
2855
+ break;
2856
+ case diagObj.db.LINETYPE.CRITICAL_END:
2857
+ loopModel = bounds.endLoop();
2858
+ await svgDraw.drawLoop(diagram2, loopModel, "critical", conf);
2859
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2860
+ bounds.models.addLoop(loopModel);
2861
+ break;
2862
+ case diagObj.db.LINETYPE.BREAK_START:
2863
+ adjustLoopHeightForWrap(
2864
+ loopWidths,
2865
+ msg,
2866
+ conf.boxMargin,
2867
+ conf.boxMargin + conf.boxTextMargin,
2868
+ (message) => bounds.newLoop(message)
2869
+ );
2870
+ break;
2871
+ case diagObj.db.LINETYPE.BREAK_END:
2872
+ loopModel = bounds.endLoop();
2873
+ await svgDraw.drawLoop(diagram2, loopModel, "break", conf);
2874
+ bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2875
+ bounds.models.addLoop(loopModel);
2876
+ break;
2877
+ default:
2878
+ try {
2879
+ msgModel = msg.msgModel;
2880
+ msgModel.starty = bounds.getVerticalPos();
2881
+ msgModel.sequenceIndex = sequenceIndex;
2882
+ msgModel.sequenceVisible = diagObj.db.showSequenceNumbers();
2883
+ const lineStartY = await boundMessage(diagram2, msgModel);
2884
+ adjustCreatedDestroyedData(
2885
+ msg,
2886
+ msgModel,
2887
+ lineStartY,
2888
+ index,
2889
+ actors,
2890
+ createdActors,
2891
+ destroyedActors
2892
+ );
2893
+ messagesToDraw.push({ messageModel: msgModel, lineStartY });
2894
+ bounds.models.addMessage(msgModel);
2895
+ } catch (e) {
2896
+ log$1.error("error while drawing message", e);
2897
+ }
2898
+ }
2899
+ if ([
2900
+ diagObj.db.LINETYPE.SOLID_OPEN,
2901
+ diagObj.db.LINETYPE.DOTTED_OPEN,
2902
+ diagObj.db.LINETYPE.SOLID,
2903
+ diagObj.db.LINETYPE.DOTTED,
2904
+ diagObj.db.LINETYPE.SOLID_CROSS,
2905
+ diagObj.db.LINETYPE.DOTTED_CROSS,
2906
+ diagObj.db.LINETYPE.SOLID_POINT,
2907
+ diagObj.db.LINETYPE.DOTTED_POINT
2908
+ ].includes(msg.type)) {
2909
+ sequenceIndex = sequenceIndex + sequenceIndexStep;
2910
+ }
2911
+ index++;
2912
+ }
2913
+ log$1.debug("createdActors", createdActors);
2914
+ log$1.debug("destroyedActors", destroyedActors);
2915
+ await drawActors(diagram2, actors, actorKeys, false);
2916
+ for (const e of messagesToDraw) {
2917
+ await drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj);
2918
+ }
2919
+ if (conf.mirrorActors) {
2920
+ await drawActors(diagram2, actors, actorKeys, true);
2921
+ }
2922
+ backgrounds.forEach((e) => svgDraw.drawBackgroundRect(diagram2, e));
2923
+ fixLifeLineHeights(diagram2, actors, actorKeys, conf);
2924
+ for (const box2 of bounds.models.boxes) {
2925
+ box2.height = bounds.getVerticalPos() - box2.y;
2926
+ bounds.insert(box2.x, box2.y, box2.x + box2.width, box2.height);
2927
+ box2.startx = box2.x;
2928
+ box2.starty = box2.y;
2929
+ box2.stopx = box2.startx + box2.width;
2930
+ box2.stopy = box2.starty + box2.height;
2931
+ box2.stroke = "rgb(0,0,0, 0.5)";
2932
+ await svgDraw.drawBox(diagram2, box2, conf);
2933
+ }
2934
+ if (hasBoxes) {
2935
+ bounds.bumpVerticalPos(conf.boxMargin);
2936
+ }
2937
+ const requiredBoxSize = drawActorsPopup(diagram2, actors, actorKeys, doc);
2938
+ const { bounds: box } = bounds.getBounds();
2939
+ let boxHeight = box.stopy - box.starty;
2940
+ if (boxHeight < requiredBoxSize.maxHeight) {
2941
+ boxHeight = requiredBoxSize.maxHeight;
2942
+ }
2943
+ let height = boxHeight + 2 * conf.diagramMarginY;
2944
+ if (conf.mirrorActors) {
2945
+ height = height - conf.boxMargin + conf.bottomMarginAdj;
2946
+ }
2947
+ let boxWidth = box.stopx - box.startx;
2948
+ if (boxWidth < requiredBoxSize.maxWidth) {
2949
+ boxWidth = requiredBoxSize.maxWidth;
2950
+ }
2951
+ const width = boxWidth + 2 * conf.diagramMarginX;
2952
+ if (title) {
2953
+ diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf.diagramMarginX).attr("y", -25);
2954
+ }
2955
+ configureSvgSize(diagram2, height, width, conf.useMaxWidth);
2956
+ const extraVertForTitle = title ? 40 : 0;
2957
+ diagram2.attr(
2958
+ "viewBox",
2959
+ box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle)
2960
+ );
2961
+ log$1.debug(`models:`, bounds.models);
2962
+ };
2963
+ async function getMaxMessageWidthPerActor(actors, messages, diagObj) {
2964
+ const maxMessageWidthPerActor = {};
2965
+ for (const msg of messages) {
2966
+ if (actors[msg.to] && actors[msg.from]) {
2967
+ const actor = actors[msg.to];
2968
+ if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) {
2969
+ continue;
2970
+ }
2971
+ if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) {
2972
+ continue;
2973
+ }
2974
+ const isNote = msg.placement !== void 0;
2975
+ const isMessage = !isNote;
2976
+ const textFont = isNote ? noteFont(conf) : messageFont(conf);
2977
+ const wrappedMessage = msg.wrap ? utils.wrapLabel(msg.message, conf.width - 2 * conf.wrapPadding, textFont) : msg.message;
2978
+ const messageDimensions = hasKatex(wrappedMessage) ? await calculateMathMLDimensions(msg.message, getConfig()) : utils.calculateTextDimensions(wrappedMessage, textFont);
2979
+ const messageWidth = messageDimensions.width + 2 * conf.wrapPadding;
2980
+ if (isMessage && msg.from === actor.nextActor) {
2981
+ maxMessageWidthPerActor[msg.to] = common$1.getMax(
2982
+ maxMessageWidthPerActor[msg.to] || 0,
2983
+ messageWidth
2984
+ );
2985
+ } else if (isMessage && msg.from === actor.prevActor) {
2986
+ maxMessageWidthPerActor[msg.from] = common$1.getMax(
2987
+ maxMessageWidthPerActor[msg.from] || 0,
2988
+ messageWidth
2989
+ );
2990
+ } else if (isMessage && msg.from === msg.to) {
2991
+ maxMessageWidthPerActor[msg.from] = common$1.getMax(
2992
+ maxMessageWidthPerActor[msg.from] || 0,
2993
+ messageWidth / 2
2994
+ );
2995
+ maxMessageWidthPerActor[msg.to] = common$1.getMax(
2996
+ maxMessageWidthPerActor[msg.to] || 0,
2997
+ messageWidth / 2
2998
+ );
2999
+ } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
3000
+ maxMessageWidthPerActor[msg.from] = common$1.getMax(
3001
+ maxMessageWidthPerActor[msg.from] || 0,
3002
+ messageWidth
3003
+ );
3004
+ } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
3005
+ maxMessageWidthPerActor[actor.prevActor] = common$1.getMax(
3006
+ maxMessageWidthPerActor[actor.prevActor] || 0,
3007
+ messageWidth
3008
+ );
3009
+ } else if (msg.placement === diagObj.db.PLACEMENT.OVER) {
3010
+ if (actor.prevActor) {
3011
+ maxMessageWidthPerActor[actor.prevActor] = common$1.getMax(
3012
+ maxMessageWidthPerActor[actor.prevActor] || 0,
3013
+ messageWidth / 2
3014
+ );
3015
+ }
3016
+ if (actor.nextActor) {
3017
+ maxMessageWidthPerActor[msg.from] = common$1.getMax(
3018
+ maxMessageWidthPerActor[msg.from] || 0,
3019
+ messageWidth / 2
3020
+ );
3021
+ }
3022
+ }
3023
+ }
3024
+ }
3025
+ log$1.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor);
3026
+ return maxMessageWidthPerActor;
3027
+ }
3028
+ const getRequiredPopupWidth = function(actor) {
3029
+ let requiredPopupWidth = 0;
3030
+ const textFont = actorFont(conf);
3031
+ for (const key in actor.links) {
3032
+ const labelDimensions = utils.calculateTextDimensions(key, textFont);
3033
+ const labelWidth = labelDimensions.width + 2 * conf.wrapPadding + 2 * conf.boxMargin;
3034
+ if (requiredPopupWidth < labelWidth) {
3035
+ requiredPopupWidth = labelWidth;
3036
+ }
3037
+ }
3038
+ return requiredPopupWidth;
3039
+ };
3040
+ async function calculateActorMargins(actors, actorToMessageWidth, boxes) {
3041
+ let maxHeight = 0;
3042
+ for (const prop of Object.keys(actors)) {
3043
+ const actor = actors[prop];
3044
+ if (actor.wrap) {
3045
+ actor.description = utils.wrapLabel(
3046
+ actor.description,
3047
+ conf.width - 2 * conf.wrapPadding,
3048
+ actorFont(conf)
3049
+ );
3050
+ }
3051
+ const actDims = hasKatex(actor.description) ? await calculateMathMLDimensions(actor.description, getConfig()) : utils.calculateTextDimensions(actor.description, actorFont(conf));
3052
+ actor.width = actor.wrap ? conf.width : common$1.getMax(conf.width, actDims.width + 2 * conf.wrapPadding);
3053
+ actor.height = actor.wrap ? common$1.getMax(actDims.height, conf.height) : conf.height;
3054
+ maxHeight = common$1.getMax(maxHeight, actor.height);
3055
+ }
3056
+ for (const actorKey in actorToMessageWidth) {
3057
+ const actor = actors[actorKey];
3058
+ if (!actor) {
3059
+ continue;
3060
+ }
3061
+ const nextActor = actors[actor.nextActor];
3062
+ if (!nextActor) {
3063
+ const messageWidth2 = actorToMessageWidth[actorKey];
3064
+ const actorWidth2 = messageWidth2 + conf.actorMargin - actor.width / 2;
3065
+ actor.margin = common$1.getMax(actorWidth2, conf.actorMargin);
3066
+ continue;
3067
+ }
3068
+ const messageWidth = actorToMessageWidth[actorKey];
3069
+ const actorWidth = messageWidth + conf.actorMargin - actor.width / 2 - nextActor.width / 2;
3070
+ actor.margin = common$1.getMax(actorWidth, conf.actorMargin);
3071
+ }
3072
+ let maxBoxHeight = 0;
3073
+ boxes.forEach((box) => {
3074
+ const textFont = messageFont(conf);
3075
+ let totalWidth = box.actorKeys.reduce((total, aKey) => {
3076
+ return total += actors[aKey].width + (actors[aKey].margin || 0);
3077
+ }, 0);
3078
+ totalWidth -= 2 * conf.boxTextMargin;
3079
+ if (box.wrap) {
3080
+ box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont);
3081
+ }
3082
+ const boxMsgDimensions = utils.calculateTextDimensions(box.name, textFont);
3083
+ maxBoxHeight = common$1.getMax(boxMsgDimensions.height, maxBoxHeight);
3084
+ const minWidth = common$1.getMax(totalWidth, boxMsgDimensions.width + 2 * conf.wrapPadding);
3085
+ box.margin = conf.boxTextMargin;
3086
+ if (totalWidth < minWidth) {
3087
+ const missing = (minWidth - totalWidth) / 2;
3088
+ box.margin += missing;
3089
+ }
3090
+ });
3091
+ boxes.forEach((box) => box.textMaxHeight = maxBoxHeight);
3092
+ return common$1.getMax(maxHeight, conf.height);
3093
+ }
3094
+ const buildNoteModel = async function(msg, actors, diagObj) {
3095
+ const startx = actors[msg.from].x;
3096
+ const stopx = actors[msg.to].x;
3097
+ const shouldWrap = msg.wrap && msg.message;
3098
+ let textDimensions = hasKatex(msg.message) ? await calculateMathMLDimensions(msg.message, getConfig()) : utils.calculateTextDimensions(
3099
+ shouldWrap ? utils.wrapLabel(msg.message, conf.width, noteFont(conf)) : msg.message,
3100
+ noteFont(conf)
3101
+ );
3102
+ const noteModel = {
3103
+ width: shouldWrap ? conf.width : common$1.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin),
3104
+ height: 0,
3105
+ startx: actors[msg.from].x,
3106
+ stopx: 0,
3107
+ starty: 0,
3108
+ stopy: 0,
3109
+ message: msg.message
3110
+ };
3111
+ if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
3112
+ noteModel.width = shouldWrap ? common$1.getMax(conf.width, textDimensions.width) : common$1.getMax(
3113
+ actors[msg.from].width / 2 + actors[msg.to].width / 2,
3114
+ textDimensions.width + 2 * conf.noteMargin
3115
+ );
3116
+ noteModel.startx = startx + (actors[msg.from].width + conf.actorMargin) / 2;
3117
+ } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
3118
+ noteModel.width = shouldWrap ? common$1.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common$1.getMax(
3119
+ actors[msg.from].width / 2 + actors[msg.to].width / 2,
3120
+ textDimensions.width + 2 * conf.noteMargin
3121
+ );
3122
+ noteModel.startx = startx - noteModel.width + (actors[msg.from].width - conf.actorMargin) / 2;
3123
+ } else if (msg.to === msg.from) {
3124
+ textDimensions = utils.calculateTextDimensions(
3125
+ shouldWrap ? utils.wrapLabel(
3126
+ msg.message,
3127
+ common$1.getMax(conf.width, actors[msg.from].width),
3128
+ noteFont(conf)
3129
+ ) : msg.message,
3130
+ noteFont(conf)
3131
+ );
3132
+ noteModel.width = shouldWrap ? common$1.getMax(conf.width, actors[msg.from].width) : common$1.getMax(
3133
+ actors[msg.from].width,
3134
+ conf.width,
3135
+ textDimensions.width + 2 * conf.noteMargin
3136
+ );
3137
+ noteModel.startx = startx + (actors[msg.from].width - noteModel.width) / 2;
3138
+ } else {
3139
+ noteModel.width = Math.abs(startx + actors[msg.from].width / 2 - (stopx + actors[msg.to].width / 2)) + conf.actorMargin;
3140
+ noteModel.startx = startx < stopx ? startx + actors[msg.from].width / 2 - conf.actorMargin / 2 : stopx + actors[msg.to].width / 2 - conf.actorMargin / 2;
3141
+ }
3142
+ if (shouldWrap) {
3143
+ noteModel.message = utils.wrapLabel(
3144
+ msg.message,
3145
+ noteModel.width - 2 * conf.wrapPadding,
3146
+ noteFont(conf)
3147
+ );
3148
+ }
3149
+ log$1.debug(
3150
+ `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]`
3151
+ );
3152
+ return noteModel;
3153
+ };
3154
+ const buildMessageModel = function(msg, actors, diagObj) {
3155
+ if (![
3156
+ diagObj.db.LINETYPE.SOLID_OPEN,
3157
+ diagObj.db.LINETYPE.DOTTED_OPEN,
3158
+ diagObj.db.LINETYPE.SOLID,
3159
+ diagObj.db.LINETYPE.DOTTED,
3160
+ diagObj.db.LINETYPE.SOLID_CROSS,
3161
+ diagObj.db.LINETYPE.DOTTED_CROSS,
3162
+ diagObj.db.LINETYPE.SOLID_POINT,
3163
+ diagObj.db.LINETYPE.DOTTED_POINT
3164
+ ].includes(msg.type)) {
3165
+ return {};
3166
+ }
3167
+ const [fromLeft, fromRight] = activationBounds(msg.from, actors);
3168
+ const [toLeft, toRight] = activationBounds(msg.to, actors);
3169
+ const isArrowToRight = fromLeft <= toLeft;
3170
+ const startx = isArrowToRight ? fromRight : fromLeft;
3171
+ let stopx = isArrowToRight ? toLeft : toRight;
3172
+ const isArrowToActivation = Math.abs(toLeft - toRight) > 2;
3173
+ const adjustValue = (value) => {
3174
+ return isArrowToRight ? -value : value;
3175
+ };
3176
+ if (msg.from === msg.to) {
3177
+ stopx = startx;
3178
+ } else {
3179
+ if (msg.activate && !isArrowToActivation) {
3180
+ stopx += adjustValue(conf.activationWidth / 2 - 1);
3181
+ }
3182
+ if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) {
3183
+ stopx += adjustValue(3);
3184
+ }
3185
+ }
3186
+ const allBounds = [fromLeft, fromRight, toLeft, toRight];
3187
+ const boundedWidth = Math.abs(startx - stopx);
3188
+ if (msg.wrap && msg.message) {
3189
+ msg.message = utils.wrapLabel(
3190
+ msg.message,
3191
+ common$1.getMax(boundedWidth + 2 * conf.wrapPadding, conf.width),
3192
+ messageFont(conf)
3193
+ );
3194
+ }
3195
+ const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf));
3196
+ return {
3197
+ width: common$1.getMax(
3198
+ msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding,
3199
+ boundedWidth + 2 * conf.wrapPadding,
3200
+ conf.width
3201
+ ),
3202
+ height: 0,
3203
+ startx,
3204
+ stopx,
3205
+ starty: 0,
3206
+ stopy: 0,
3207
+ message: msg.message,
3208
+ type: msg.type,
3209
+ wrap: msg.wrap,
3210
+ fromBounds: Math.min.apply(null, allBounds),
3211
+ toBounds: Math.max.apply(null, allBounds)
3212
+ };
3213
+ };
3214
+ const calculateLoopBounds = async function(messages, actors, _maxWidthPerActor, diagObj) {
3215
+ const loops = {};
3216
+ const stack = [];
3217
+ let current, noteModel, msgModel;
3218
+ for (const msg of messages) {
3219
+ msg.id = utils.random({ length: 10 });
3220
+ switch (msg.type) {
3221
+ case diagObj.db.LINETYPE.LOOP_START:
3222
+ case diagObj.db.LINETYPE.ALT_START:
3223
+ case diagObj.db.LINETYPE.OPT_START:
3224
+ case diagObj.db.LINETYPE.PAR_START:
3225
+ case diagObj.db.LINETYPE.PAR_OVER_START:
3226
+ case diagObj.db.LINETYPE.CRITICAL_START:
3227
+ case diagObj.db.LINETYPE.BREAK_START:
3228
+ stack.push({
3229
+ id: msg.id,
3230
+ msg: msg.message,
3231
+ from: Number.MAX_SAFE_INTEGER,
3232
+ to: Number.MIN_SAFE_INTEGER,
3233
+ width: 0
3234
+ });
3235
+ break;
3236
+ case diagObj.db.LINETYPE.ALT_ELSE:
3237
+ case diagObj.db.LINETYPE.PAR_AND:
3238
+ case diagObj.db.LINETYPE.CRITICAL_OPTION:
3239
+ if (msg.message) {
3240
+ current = stack.pop();
3241
+ loops[current.id] = current;
3242
+ loops[msg.id] = current;
3243
+ stack.push(current);
3244
+ }
3245
+ break;
3246
+ case diagObj.db.LINETYPE.LOOP_END:
3247
+ case diagObj.db.LINETYPE.ALT_END:
3248
+ case diagObj.db.LINETYPE.OPT_END:
3249
+ case diagObj.db.LINETYPE.PAR_END:
3250
+ case diagObj.db.LINETYPE.CRITICAL_END:
3251
+ case diagObj.db.LINETYPE.BREAK_END:
3252
+ current = stack.pop();
3253
+ loops[current.id] = current;
3254
+ break;
3255
+ case diagObj.db.LINETYPE.ACTIVE_START:
3256
+ {
3257
+ const actorRect = actors[msg.from ? msg.from.actor : msg.to.actor];
3258
+ const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length;
3259
+ const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
3260
+ const toAdd = {
3261
+ startx: x,
3262
+ stopx: x + conf.activationWidth,
3263
+ actor: msg.from.actor,
3264
+ enabled: true
3265
+ };
3266
+ bounds.activations.push(toAdd);
3267
+ }
3268
+ break;
3269
+ case diagObj.db.LINETYPE.ACTIVE_END:
3270
+ {
3271
+ const lastActorActivationIdx = bounds.activations.map((a) => a.actor).lastIndexOf(msg.from.actor);
3272
+ delete bounds.activations.splice(lastActorActivationIdx, 1)[0];
3273
+ }
3274
+ break;
3275
+ }
3276
+ const isNote = msg.placement !== void 0;
3277
+ if (isNote) {
3278
+ noteModel = await buildNoteModel(msg, actors, diagObj);
3279
+ msg.noteModel = noteModel;
3280
+ stack.forEach((stk) => {
3281
+ current = stk;
3282
+ current.from = common$1.getMin(current.from, noteModel.startx);
3283
+ current.to = common$1.getMax(current.to, noteModel.startx + noteModel.width);
3284
+ current.width = common$1.getMax(current.width, Math.abs(current.from - current.to)) - conf.labelBoxWidth;
3285
+ });
3286
+ } else {
3287
+ msgModel = buildMessageModel(msg, actors, diagObj);
3288
+ msg.msgModel = msgModel;
3289
+ if (msgModel.startx && msgModel.stopx && stack.length > 0) {
3290
+ stack.forEach((stk) => {
3291
+ current = stk;
3292
+ if (msgModel.startx === msgModel.stopx) {
3293
+ const from = actors[msg.from];
3294
+ const to = actors[msg.to];
3295
+ current.from = common$1.getMin(
3296
+ from.x - msgModel.width / 2,
3297
+ from.x - from.width / 2,
3298
+ current.from
3299
+ );
3300
+ current.to = common$1.getMax(
3301
+ to.x + msgModel.width / 2,
3302
+ to.x + from.width / 2,
3303
+ current.to
3304
+ );
3305
+ current.width = common$1.getMax(current.width, Math.abs(current.to - current.from)) - conf.labelBoxWidth;
3306
+ } else {
3307
+ current.from = common$1.getMin(msgModel.startx, current.from);
3308
+ current.to = common$1.getMax(msgModel.stopx, current.to);
3309
+ current.width = common$1.getMax(current.width, msgModel.width) - conf.labelBoxWidth;
3310
+ }
3311
+ });
3312
+ }
3313
+ }
3314
+ }
3315
+ bounds.activations = [];
3316
+ log$1.debug("Loop type widths:", loops);
3317
+ return loops;
3318
+ };
3319
+ const renderer = {
3320
+ bounds,
3321
+ drawActors,
3322
+ drawActorsPopup,
3323
+ setConf,
3324
+ draw
3325
+ };
3326
+ const diagram = {
3327
+ parser: parser$1,
3328
+ db,
3329
+ renderer,
3330
+ styles,
3331
+ init: ({ wrap }) => {
3332
+ db.setWrap(wrap);
3333
+ }
3334
+ };
3335
+ export {
3336
+ diagram
3337
+ };