dominds 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/LICENSE +157 -0
  2. package/README.md +250 -0
  3. package/README.zh.md +161 -0
  4. package/dist/access-control.js +253 -0
  5. package/dist/cli/create.js +263 -0
  6. package/dist/cli/read.js +84 -0
  7. package/dist/cli/tui.js +199 -0
  8. package/dist/cli/webui.js +169 -0
  9. package/dist/cli.js +227 -0
  10. package/dist/dialog-factory.js +53 -0
  11. package/dist/dialog-global-registry.js +68 -0
  12. package/dist/dialog-instance-registry.js +78 -0
  13. package/dist/dialog-run-state.js +198 -0
  14. package/dist/dialog.js +1024 -0
  15. package/dist/evt-registry.js +103 -0
  16. package/dist/index.js +8 -0
  17. package/dist/llm/client.js +69 -0
  18. package/dist/llm/defaults.yaml +386 -0
  19. package/dist/llm/driver.js +3214 -0
  20. package/dist/llm/gen/anthropic.js +611 -0
  21. package/dist/llm/gen/codex.js +375 -0
  22. package/dist/llm/gen/mock.js +326 -0
  23. package/dist/llm/gen/openai.js +470 -0
  24. package/dist/llm/gen/registry.js +26 -0
  25. package/dist/llm/gen.js +2 -0
  26. package/dist/llm/tools-projection.js +37 -0
  27. package/dist/log.js +228 -0
  28. package/dist/mcp/config.js +230 -0
  29. package/dist/mcp/sdk-client.js +129 -0
  30. package/dist/mcp/server-runtime.js +57 -0
  31. package/dist/mcp/stdio-client.js +280 -0
  32. package/dist/mcp/supervisor.js +979 -0
  33. package/dist/mcp/tool-names.js +109 -0
  34. package/dist/minds/builtin/cmdr/persona.md +3 -0
  35. package/dist/minds/builtin/dijiang/knowledge.md +287 -0
  36. package/dist/minds/builtin/dijiang/persona.md +7 -0
  37. package/dist/minds/builtin/fuxi/persona.en.md +59 -0
  38. package/dist/minds/builtin/fuxi/persona.zh.md +49 -0
  39. package/dist/minds/builtin/pangu/persona.en.md +78 -0
  40. package/dist/minds/builtin/pangu/persona.zh.md +71 -0
  41. package/dist/minds/load.js +617 -0
  42. package/dist/minds/minds-i18n.js +131 -0
  43. package/dist/minds/system-prompt.js +281 -0
  44. package/dist/persistence.js +3128 -0
  45. package/dist/problems.js +109 -0
  46. package/dist/server/api-routes.js +1031 -0
  47. package/dist/server/auth.js +180 -0
  48. package/dist/server/mime-types.js +32 -0
  49. package/dist/server/prompts-routes.js +543 -0
  50. package/dist/server/server-core.js +235 -0
  51. package/dist/server/setup-routes.js +697 -0
  52. package/dist/server/static-server.js +132 -0
  53. package/dist/server/websocket-handler.js +1011 -0
  54. package/dist/server.js +164 -0
  55. package/dist/shared/async-fifo-mutex.js +36 -0
  56. package/dist/shared/diligence.js +20 -0
  57. package/dist/shared/dotenv.js +144 -0
  58. package/dist/shared/evt.js +195 -0
  59. package/dist/shared/i18n/driver-messages.js +267 -0
  60. package/dist/shared/i18n/text.js +9 -0
  61. package/dist/shared/i18n/tool-result-messages.js +51 -0
  62. package/dist/shared/rtws-cli.js +73 -0
  63. package/dist/shared/runtime-language.js +47 -0
  64. package/dist/shared/team-mgmt-manual.js +116 -0
  65. package/dist/shared/types/context-health.js +2 -0
  66. package/dist/shared/types/dialog.js +11 -0
  67. package/dist/shared/types/i18n.js +2 -0
  68. package/dist/shared/types/index.js +26 -0
  69. package/dist/shared/types/language.js +40 -0
  70. package/dist/shared/types/problems.js +2 -0
  71. package/dist/shared/types/prompts.js +2 -0
  72. package/dist/shared/types/q4h.js +7 -0
  73. package/dist/shared/types/run-state.js +8 -0
  74. package/dist/shared/types/setup.js +2 -0
  75. package/dist/shared/types/storage.js +10 -0
  76. package/dist/shared/types/tellask.js +8 -0
  77. package/dist/shared/types/tools-registry.js +2 -0
  78. package/dist/shared/types/wire.js +12 -0
  79. package/dist/shared/utils/fmt.js +9 -0
  80. package/dist/shared/utils/html.js +20 -0
  81. package/dist/shared/utils/id.js +18 -0
  82. package/dist/shared/utils/inter-dialog-format.js +101 -0
  83. package/dist/shared/utils/time.js +13 -0
  84. package/dist/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  85. package/dist/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  86. package/dist/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  87. package/dist/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  88. package/dist/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  89. package/dist/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  90. package/dist/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  91. package/dist/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  92. package/dist/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  93. package/dist/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  94. package/dist/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  95. package/dist/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  96. package/dist/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  97. package/dist/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  98. package/dist/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  99. package/dist/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  100. package/dist/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  101. package/dist/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  102. package/dist/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  103. package/dist/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  104. package/dist/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  105. package/dist/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  106. package/dist/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  107. package/dist/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  108. package/dist/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  109. package/dist/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  110. package/dist/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  111. package/dist/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  112. package/dist/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  113. package/dist/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  114. package/dist/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  115. package/dist/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  116. package/dist/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  117. package/dist/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  118. package/dist/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  119. package/dist/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  120. package/dist/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  121. package/dist/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  122. package/dist/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  123. package/dist/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  124. package/dist/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  125. package/dist/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  126. package/dist/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  127. package/dist/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  128. package/dist/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  129. package/dist/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  130. package/dist/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  131. package/dist/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  132. package/dist/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  133. package/dist/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  134. package/dist/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  135. package/dist/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  136. package/dist/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  137. package/dist/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  138. package/dist/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  139. package/dist/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  140. package/dist/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  141. package/dist/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  142. package/dist/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  143. package/dist/static/assets/_baseUniq-Crfl3d5Y.js +661 -0
  144. package/dist/static/assets/_baseUniq-Crfl3d5Y.js.map +1 -0
  145. package/dist/static/assets/arc-CbA_x9GD.js +132 -0
  146. package/dist/static/assets/arc-CbA_x9GD.js.map +1 -0
  147. package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js +8685 -0
  148. package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js.map +1 -0
  149. package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js +3608 -0
  150. package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js.map +1 -0
  151. package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js +2482 -0
  152. package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js.map +1 -0
  153. package/dist/static/assets/channel-BVr1Yke-.js +8 -0
  154. package/dist/static/assets/channel-BVr1Yke-.js.map +1 -0
  155. package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js +17 -0
  156. package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js.map +1 -0
  157. package/dist/static/assets/chunk-55IACEB6-q172NeCV.js +14 -0
  158. package/dist/static/assets/chunk-55IACEB6-q172NeCV.js.map +1 -0
  159. package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js +1827 -0
  160. package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js.map +1 -0
  161. package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js +1916 -0
  162. package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js.map +1 -0
  163. package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js +20 -0
  164. package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js.map +1 -0
  165. package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js +25 -0
  166. package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js.map +1 -0
  167. package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js +18 -0
  168. package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js.map +1 -0
  169. package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js +109 -0
  170. package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js.map +1 -0
  171. package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js +23 -0
  172. package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js.map +1 -0
  173. package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js +23 -0
  174. package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js.map +1 -0
  175. package/dist/static/assets/clone-D2OgLSSn.js +9 -0
  176. package/dist/static/assets/clone-D2OgLSSn.js.map +1 -0
  177. package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js +4943 -0
  178. package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js.map +1 -0
  179. package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js +30240 -0
  180. package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -0
  181. package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js +695 -0
  182. package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js.map +1 -0
  183. package/dist/static/assets/defaultLocale-DVr69WTU.js +207 -0
  184. package/dist/static/assets/defaultLocale-DVr69WTU.js.map +1 -0
  185. package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js +849 -0
  186. package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js.map +1 -0
  187. package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js +303 -0
  188. package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js.map +1 -0
  189. package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js +213 -0
  190. package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js.map +1 -0
  191. package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js +1159 -0
  192. package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js.map +1 -0
  193. package/dist/static/assets/favicon-Cmg5RbCj.svg +8 -0
  194. package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js +2332 -0
  195. package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js.map +1 -0
  196. package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js +3681 -0
  197. package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js.map +1 -0
  198. package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js +1206 -0
  199. package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js.map +1 -0
  200. package/dist/static/assets/graph-CS0Pmm7c.js +597 -0
  201. package/dist/static/assets/graph-CS0Pmm7c.js.map +1 -0
  202. package/dist/static/assets/index-BS6HnGzC.js +112303 -0
  203. package/dist/static/assets/index-BS6HnGzC.js.map +1 -0
  204. package/dist/static/assets/index-DaIsSzC_.css +483 -0
  205. package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js +34 -0
  206. package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js.map +1 -0
  207. package/dist/static/assets/init-ZxktEp_H.js +17 -0
  208. package/dist/static/assets/init-ZxktEp_H.js.map +1 -0
  209. package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js +1255 -0
  210. package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js.map +1 -0
  211. package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js +1048 -0
  212. package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js.map +1 -0
  213. package/dist/static/assets/layout-8TGxpm23.js +2218 -0
  214. package/dist/static/assets/layout-8TGxpm23.js.map +1 -0
  215. package/dist/static/assets/linear-BATBPQQv.js +341 -0
  216. package/dist/static/assets/linear-BATBPQQv.js.map +1 -0
  217. package/dist/static/assets/min-B3oVH3AC.js +42 -0
  218. package/dist/static/assets/min-B3oVH3AC.js.map +1 -0
  219. package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js +1127 -0
  220. package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js.map +1 -0
  221. package/dist/static/assets/ordinal-CxptdPJm.js +77 -0
  222. package/dist/static/assets/ordinal-CxptdPJm.js.map +1 -0
  223. package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js +241 -0
  224. package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js.map +1 -0
  225. package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js +1338 -0
  226. package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js.map +1 -0
  227. package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js +1162 -0
  228. package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js.map +1 -0
  229. package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js +1195 -0
  230. package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js.map +1 -0
  231. package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js +3875 -0
  232. package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js.map +1 -0
  233. package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js +452 -0
  234. package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js.map +1 -0
  235. package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js +22 -0
  236. package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js.map +1 -0
  237. package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js +1223 -0
  238. package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js.map +1 -0
  239. package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js +18753 -0
  240. package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js.map +1 -0
  241. package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js +1888 -0
  242. package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js.map +1 -0
  243. package/dist/static/index.html +71 -0
  244. package/dist/static/testing/dom-observation-utils.js +425 -0
  245. package/dist/static/testing/e2e-test-helper.js +3119 -0
  246. package/dist/team.js +1160 -0
  247. package/dist/tellask.js +431 -0
  248. package/dist/tool.js +150 -0
  249. package/dist/tools/apply-patch.js +542 -0
  250. package/dist/tools/builtins.js +196 -0
  251. package/dist/tools/context-health.js +177 -0
  252. package/dist/tools/ctrl.js +478 -0
  253. package/dist/tools/diag.js +583 -0
  254. package/dist/tools/env.js +184 -0
  255. package/dist/tools/fs.js +818 -0
  256. package/dist/tools/mcp.js +138 -0
  257. package/dist/tools/mem.js +349 -0
  258. package/dist/tools/os.js +751 -0
  259. package/dist/tools/prompts/team_mgmt.en.md +70 -0
  260. package/dist/tools/prompts/team_mgmt.zh.md +70 -0
  261. package/dist/tools/prompts/ws_mod.en.md +86 -0
  262. package/dist/tools/prompts/ws_mod.zh.md +87 -0
  263. package/dist/tools/registry-snapshot.js +31 -0
  264. package/dist/tools/registry.js +121 -0
  265. package/dist/tools/ripgrep.js +678 -0
  266. package/dist/tools/team-mgmt.js +3300 -0
  267. package/dist/tools/txt.js +3178 -0
  268. package/dist/utils/id.js +72 -0
  269. package/dist/utils/task-doc.js +236 -0
  270. package/dist/utils/task-package.js +522 -0
  271. package/dist/utils/taskdoc-search.js +280 -0
  272. package/dist/utils/taskdoc.js +400 -0
  273. package/package.json +69 -0
@@ -0,0 +1,1888 @@
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2
+ import { _ as __name, s as setAccDescription, g as getAccDescription, q as getDiagramTitle, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, l as log, H as selectSvgElement, e as configureSvgSize, y as clear, E as getConfig, D as cleanAndMerge, F as defaultConfig_default, K as getThemeVariables3, i as sanitizeText, aA as computeDimensionOfText, R as line } from "./index-BS6HnGzC.js";
3
+ import { i as initRange } from "./init-ZxktEp_H.js";
4
+ import { o as ordinal } from "./ordinal-CxptdPJm.js";
5
+ import { l as linear } from "./linear-BATBPQQv.js";
6
+ import "./defaultLocale-DVr69WTU.js";
7
+ function range(start, stop, step) {
8
+ start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
9
+ var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range2 = new Array(n);
10
+ while (++i < n) {
11
+ range2[i] = start + i * step;
12
+ }
13
+ return range2;
14
+ }
15
+ function band() {
16
+ var scale = ordinal().unknown(void 0), domain = scale.domain, ordinalRange = scale.range, r0 = 0, r1 = 1, step, bandwidth, round = false, paddingInner = 0, paddingOuter = 0, align = 0.5;
17
+ delete scale.unknown;
18
+ function rescale() {
19
+ var n = domain().length, reverse = r1 < r0, start = reverse ? r1 : r0, stop = reverse ? r0 : r1;
20
+ step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
21
+ if (round) step = Math.floor(step);
22
+ start += (stop - start - step * (n - paddingInner)) * align;
23
+ bandwidth = step * (1 - paddingInner);
24
+ if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
25
+ var values = range(n).map(function(i) {
26
+ return start + step * i;
27
+ });
28
+ return ordinalRange(reverse ? values.reverse() : values);
29
+ }
30
+ scale.domain = function(_) {
31
+ return arguments.length ? (domain(_), rescale()) : domain();
32
+ };
33
+ scale.range = function(_) {
34
+ return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1];
35
+ };
36
+ scale.rangeRound = function(_) {
37
+ return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale();
38
+ };
39
+ scale.bandwidth = function() {
40
+ return bandwidth;
41
+ };
42
+ scale.step = function() {
43
+ return step;
44
+ };
45
+ scale.round = function(_) {
46
+ return arguments.length ? (round = !!_, rescale()) : round;
47
+ };
48
+ scale.padding = function(_) {
49
+ return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
50
+ };
51
+ scale.paddingInner = function(_) {
52
+ return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
53
+ };
54
+ scale.paddingOuter = function(_) {
55
+ return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
56
+ };
57
+ scale.align = function(_) {
58
+ return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
59
+ };
60
+ scale.copy = function() {
61
+ return band(domain(), [r0, r1]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align);
62
+ };
63
+ return initRange.apply(rescale(), arguments);
64
+ }
65
+ var parser = (function() {
66
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
67
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
68
+ return o2;
69
+ }, "o"), $V0 = [1, 10, 12, 14, 16, 18, 19, 21, 23], $V1 = [2, 6], $V2 = [1, 3], $V3 = [1, 5], $V4 = [1, 6], $V5 = [1, 7], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $V7 = [1, 25], $V8 = [1, 26], $V9 = [1, 28], $Va = [1, 29], $Vb = [1, 30], $Vc = [1, 31], $Vd = [1, 32], $Ve = [1, 33], $Vf = [1, 34], $Vg = [1, 35], $Vh = [1, 36], $Vi = [1, 37], $Vj = [1, 43], $Vk = [1, 42], $Vl = [1, 47], $Vm = [1, 50], $Vn = [1, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $Vo = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36], $Vp = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $Vq = [1, 64];
70
+ var parser2 = {
71
+ trace: /* @__PURE__ */ __name(function trace() {
72
+ }, "trace"),
73
+ yy: {},
74
+ symbols_: { "error": 2, "start": 3, "eol": 4, "XYCHART": 5, "chartConfig": 6, "document": 7, "CHART_ORIENTATION": 8, "statement": 9, "title": 10, "text": 11, "X_AXIS": 12, "parseXAxis": 13, "Y_AXIS": 14, "parseYAxis": 15, "LINE": 16, "plotData": 17, "BAR": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "SQUARE_BRACES_START": 24, "commaSeparatedNumbers": 25, "SQUARE_BRACES_END": 26, "NUMBER_WITH_DECIMAL": 27, "COMMA": 28, "xAxisData": 29, "bandData": 30, "ARROW_DELIMITER": 31, "commaSeparatedTexts": 32, "yAxisData": 33, "NEWLINE": 34, "SEMI": 35, "EOF": 36, "alphaNum": 37, "STR": 38, "MD_STR": 39, "alphaNumToken": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "PLUS": 44, "EQUALS": 45, "MULT": 46, "DOT": 47, "BRKT": 48, "MINUS": 49, "UNDERSCORE": 50, "$accept": 0, "$end": 1 },
75
+ terminals_: { 2: "error", 5: "XYCHART", 8: "CHART_ORIENTATION", 10: "title", 12: "X_AXIS", 14: "Y_AXIS", 16: "LINE", 18: "BAR", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "SQUARE_BRACES_START", 26: "SQUARE_BRACES_END", 27: "NUMBER_WITH_DECIMAL", 28: "COMMA", 31: "ARROW_DELIMITER", 34: "NEWLINE", 35: "SEMI", 36: "EOF", 38: "STR", 39: "MD_STR", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "PLUS", 45: "EQUALS", 46: "MULT", 47: "DOT", 48: "BRKT", 49: "MINUS", 50: "UNDERSCORE" },
76
+ productions_: [0, [3, 2], [3, 3], [3, 2], [3, 1], [6, 1], [7, 0], [7, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 3], [9, 2], [9, 3], [9, 2], [9, 2], [9, 1], [17, 3], [25, 3], [25, 1], [13, 1], [13, 2], [13, 1], [29, 1], [29, 3], [30, 3], [32, 3], [32, 1], [15, 1], [15, 2], [15, 1], [33, 3], [4, 1], [4, 1], [4, 1], [11, 1], [11, 1], [11, 1], [37, 1], [37, 2], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1]],
77
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
78
+ var $0 = $$.length - 1;
79
+ switch (yystate) {
80
+ case 5:
81
+ yy.setOrientation($$[$0]);
82
+ break;
83
+ case 9:
84
+ yy.setDiagramTitle($$[$0].text.trim());
85
+ break;
86
+ case 12:
87
+ yy.setLineData({ text: "", type: "text" }, $$[$0]);
88
+ break;
89
+ case 13:
90
+ yy.setLineData($$[$0 - 1], $$[$0]);
91
+ break;
92
+ case 14:
93
+ yy.setBarData({ text: "", type: "text" }, $$[$0]);
94
+ break;
95
+ case 15:
96
+ yy.setBarData($$[$0 - 1], $$[$0]);
97
+ break;
98
+ case 16:
99
+ this.$ = $$[$0].trim();
100
+ yy.setAccTitle(this.$);
101
+ break;
102
+ case 17:
103
+ case 18:
104
+ this.$ = $$[$0].trim();
105
+ yy.setAccDescription(this.$);
106
+ break;
107
+ case 19:
108
+ this.$ = $$[$0 - 1];
109
+ break;
110
+ case 20:
111
+ this.$ = [Number($$[$0 - 2]), ...$$[$0]];
112
+ break;
113
+ case 21:
114
+ this.$ = [Number($$[$0])];
115
+ break;
116
+ case 22:
117
+ yy.setXAxisTitle($$[$0]);
118
+ break;
119
+ case 23:
120
+ yy.setXAxisTitle($$[$0 - 1]);
121
+ break;
122
+ case 24:
123
+ yy.setXAxisTitle({ type: "text", text: "" });
124
+ break;
125
+ case 25:
126
+ yy.setXAxisBand($$[$0]);
127
+ break;
128
+ case 26:
129
+ yy.setXAxisRangeData(Number($$[$0 - 2]), Number($$[$0]));
130
+ break;
131
+ case 27:
132
+ this.$ = $$[$0 - 1];
133
+ break;
134
+ case 28:
135
+ this.$ = [$$[$0 - 2], ...$$[$0]];
136
+ break;
137
+ case 29:
138
+ this.$ = [$$[$0]];
139
+ break;
140
+ case 30:
141
+ yy.setYAxisTitle($$[$0]);
142
+ break;
143
+ case 31:
144
+ yy.setYAxisTitle($$[$0 - 1]);
145
+ break;
146
+ case 32:
147
+ yy.setYAxisTitle({ type: "text", text: "" });
148
+ break;
149
+ case 33:
150
+ yy.setYAxisRangeData(Number($$[$0 - 2]), Number($$[$0]));
151
+ break;
152
+ case 37:
153
+ this.$ = { text: $$[$0], type: "text" };
154
+ break;
155
+ case 38:
156
+ this.$ = { text: $$[$0], type: "text" };
157
+ break;
158
+ case 39:
159
+ this.$ = { text: $$[$0], type: "markdown" };
160
+ break;
161
+ case 40:
162
+ this.$ = $$[$0];
163
+ break;
164
+ case 41:
165
+ this.$ = $$[$0 - 1] + "" + $$[$0];
166
+ break;
167
+ }
168
+ }, "anonymous"),
169
+ table: [o($V0, $V1, { 3: 1, 4: 2, 7: 4, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [3] }, o($V0, $V1, { 4: 2, 7: 4, 3: 8, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), o($V0, $V1, { 4: 2, 7: 4, 6: 9, 3: 10, 5: $V2, 8: [1, 11], 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 4], 9: 12, 10: [1, 13], 12: [1, 14], 14: [1, 15], 16: [1, 16], 18: [1, 17], 19: [1, 18], 21: [1, 19], 23: [1, 20] }, o($V6, [2, 34]), o($V6, [2, 35]), o($V6, [2, 36]), { 1: [2, 1] }, o($V0, $V1, { 4: 2, 7: 4, 3: 21, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 3] }, o($V6, [2, 5]), o($V0, [2, 7], { 4: 22, 34: $V3, 35: $V4, 36: $V5 }), { 11: 23, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 39, 13: 38, 24: $Vj, 27: $Vk, 29: 40, 30: 41, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 45, 15: 44, 27: $Vl, 33: 46, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 49, 17: 48, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 52, 17: 51, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 20: [1, 53] }, { 22: [1, 54] }, o($Vn, [2, 18]), { 1: [2, 2] }, o($Vn, [2, 8]), o($Vn, [2, 9]), o($Vo, [2, 37], { 40: 55, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }), o($Vo, [2, 38]), o($Vo, [2, 39]), o($Vp, [2, 40]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), o($Vp, [2, 47]), o($Vp, [2, 48]), o($Vp, [2, 49]), o($Vp, [2, 50]), o($Vp, [2, 51]), o($Vn, [2, 10]), o($Vn, [2, 22], { 30: 41, 29: 56, 24: $Vj, 27: $Vk }), o($Vn, [2, 24]), o($Vn, [2, 25]), { 31: [1, 57] }, { 11: 59, 32: 58, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 11]), o($Vn, [2, 30], { 33: 60, 27: $Vl }), o($Vn, [2, 32]), { 31: [1, 61] }, o($Vn, [2, 12]), { 17: 62, 24: $Vm }, { 25: 63, 27: $Vq }, o($Vn, [2, 14]), { 17: 65, 24: $Vm }, o($Vn, [2, 16]), o($Vn, [2, 17]), o($Vp, [2, 41]), o($Vn, [2, 23]), { 27: [1, 66] }, { 26: [1, 67] }, { 26: [2, 29], 28: [1, 68] }, o($Vn, [2, 31]), { 27: [1, 69] }, o($Vn, [2, 13]), { 26: [1, 70] }, { 26: [2, 21], 28: [1, 71] }, o($Vn, [2, 15]), o($Vn, [2, 26]), o($Vn, [2, 27]), { 11: 59, 32: 72, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 33]), o($Vn, [2, 19]), { 25: 73, 27: $Vq }, { 26: [2, 28] }, { 26: [2, 20] }],
170
+ defaultActions: { 8: [2, 1], 10: [2, 3], 21: [2, 2], 72: [2, 28], 73: [2, 20] },
171
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
172
+ if (hash.recoverable) {
173
+ this.trace(str);
174
+ } else {
175
+ var error = new Error(str);
176
+ error.hash = hash;
177
+ throw error;
178
+ }
179
+ }, "parseError"),
180
+ parse: /* @__PURE__ */ __name(function parse(input) {
181
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
182
+ var args = lstack.slice.call(arguments, 1);
183
+ var lexer2 = Object.create(this.lexer);
184
+ var sharedState = { yy: {} };
185
+ for (var k in this.yy) {
186
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
187
+ sharedState.yy[k] = this.yy[k];
188
+ }
189
+ }
190
+ lexer2.setInput(input, sharedState.yy);
191
+ sharedState.yy.lexer = lexer2;
192
+ sharedState.yy.parser = this;
193
+ if (typeof lexer2.yylloc == "undefined") {
194
+ lexer2.yylloc = {};
195
+ }
196
+ var yyloc = lexer2.yylloc;
197
+ lstack.push(yyloc);
198
+ var ranges = lexer2.options && lexer2.options.ranges;
199
+ if (typeof sharedState.yy.parseError === "function") {
200
+ this.parseError = sharedState.yy.parseError;
201
+ } else {
202
+ this.parseError = Object.getPrototypeOf(this).parseError;
203
+ }
204
+ function popStack(n) {
205
+ stack.length = stack.length - 2 * n;
206
+ vstack.length = vstack.length - n;
207
+ lstack.length = lstack.length - n;
208
+ }
209
+ __name(popStack, "popStack");
210
+ function lex() {
211
+ var token;
212
+ token = tstack.pop() || lexer2.lex() || EOF;
213
+ if (typeof token !== "number") {
214
+ if (token instanceof Array) {
215
+ tstack = token;
216
+ token = tstack.pop();
217
+ }
218
+ token = self.symbols_[token] || token;
219
+ }
220
+ return token;
221
+ }
222
+ __name(lex, "lex");
223
+ var symbol, state, action, r, yyval = {}, p, len, newState, expected;
224
+ while (true) {
225
+ state = stack[stack.length - 1];
226
+ if (this.defaultActions[state]) {
227
+ action = this.defaultActions[state];
228
+ } else {
229
+ if (symbol === null || typeof symbol == "undefined") {
230
+ symbol = lex();
231
+ }
232
+ action = table[state] && table[state][symbol];
233
+ }
234
+ if (typeof action === "undefined" || !action.length || !action[0]) {
235
+ var errStr = "";
236
+ expected = [];
237
+ for (p in table[state]) {
238
+ if (this.terminals_[p] && p > TERROR) {
239
+ expected.push("'" + this.terminals_[p] + "'");
240
+ }
241
+ }
242
+ if (lexer2.showPosition) {
243
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
244
+ } else {
245
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
246
+ }
247
+ this.parseError(errStr, {
248
+ text: lexer2.match,
249
+ token: this.terminals_[symbol] || symbol,
250
+ line: lexer2.yylineno,
251
+ loc: yyloc,
252
+ expected
253
+ });
254
+ }
255
+ if (action[0] instanceof Array && action.length > 1) {
256
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
257
+ }
258
+ switch (action[0]) {
259
+ case 1:
260
+ stack.push(symbol);
261
+ vstack.push(lexer2.yytext);
262
+ lstack.push(lexer2.yylloc);
263
+ stack.push(action[1]);
264
+ symbol = null;
265
+ {
266
+ yyleng = lexer2.yyleng;
267
+ yytext = lexer2.yytext;
268
+ yylineno = lexer2.yylineno;
269
+ yyloc = lexer2.yylloc;
270
+ }
271
+ break;
272
+ case 2:
273
+ len = this.productions_[action[1]][1];
274
+ yyval.$ = vstack[vstack.length - len];
275
+ yyval._$ = {
276
+ first_line: lstack[lstack.length - (len || 1)].first_line,
277
+ last_line: lstack[lstack.length - 1].last_line,
278
+ first_column: lstack[lstack.length - (len || 1)].first_column,
279
+ last_column: lstack[lstack.length - 1].last_column
280
+ };
281
+ if (ranges) {
282
+ yyval._$.range = [
283
+ lstack[lstack.length - (len || 1)].range[0],
284
+ lstack[lstack.length - 1].range[1]
285
+ ];
286
+ }
287
+ r = this.performAction.apply(yyval, [
288
+ yytext,
289
+ yyleng,
290
+ yylineno,
291
+ sharedState.yy,
292
+ action[1],
293
+ vstack,
294
+ lstack
295
+ ].concat(args));
296
+ if (typeof r !== "undefined") {
297
+ return r;
298
+ }
299
+ if (len) {
300
+ stack = stack.slice(0, -1 * len * 2);
301
+ vstack = vstack.slice(0, -1 * len);
302
+ lstack = lstack.slice(0, -1 * len);
303
+ }
304
+ stack.push(this.productions_[action[1]][0]);
305
+ vstack.push(yyval.$);
306
+ lstack.push(yyval._$);
307
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
308
+ stack.push(newState);
309
+ break;
310
+ case 3:
311
+ return true;
312
+ }
313
+ }
314
+ return true;
315
+ }, "parse")
316
+ };
317
+ var lexer = /* @__PURE__ */ (function() {
318
+ var lexer2 = {
319
+ EOF: 1,
320
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
321
+ if (this.yy.parser) {
322
+ this.yy.parser.parseError(str, hash);
323
+ } else {
324
+ throw new Error(str);
325
+ }
326
+ }, "parseError"),
327
+ // resets the lexer, sets new input
328
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
329
+ this.yy = yy || this.yy || {};
330
+ this._input = input;
331
+ this._more = this._backtrack = this.done = false;
332
+ this.yylineno = this.yyleng = 0;
333
+ this.yytext = this.matched = this.match = "";
334
+ this.conditionStack = ["INITIAL"];
335
+ this.yylloc = {
336
+ first_line: 1,
337
+ first_column: 0,
338
+ last_line: 1,
339
+ last_column: 0
340
+ };
341
+ if (this.options.ranges) {
342
+ this.yylloc.range = [0, 0];
343
+ }
344
+ this.offset = 0;
345
+ return this;
346
+ }, "setInput"),
347
+ // consumes and returns one char from the input
348
+ input: /* @__PURE__ */ __name(function() {
349
+ var ch = this._input[0];
350
+ this.yytext += ch;
351
+ this.yyleng++;
352
+ this.offset++;
353
+ this.match += ch;
354
+ this.matched += ch;
355
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
356
+ if (lines) {
357
+ this.yylineno++;
358
+ this.yylloc.last_line++;
359
+ } else {
360
+ this.yylloc.last_column++;
361
+ }
362
+ if (this.options.ranges) {
363
+ this.yylloc.range[1]++;
364
+ }
365
+ this._input = this._input.slice(1);
366
+ return ch;
367
+ }, "input"),
368
+ // unshifts one char (or a string) into the input
369
+ unput: /* @__PURE__ */ __name(function(ch) {
370
+ var len = ch.length;
371
+ var lines = ch.split(/(?:\r\n?|\n)/g);
372
+ this._input = ch + this._input;
373
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
374
+ this.offset -= len;
375
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
376
+ this.match = this.match.substr(0, this.match.length - 1);
377
+ this.matched = this.matched.substr(0, this.matched.length - 1);
378
+ if (lines.length - 1) {
379
+ this.yylineno -= lines.length - 1;
380
+ }
381
+ var r = this.yylloc.range;
382
+ this.yylloc = {
383
+ first_line: this.yylloc.first_line,
384
+ last_line: this.yylineno + 1,
385
+ first_column: this.yylloc.first_column,
386
+ 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
387
+ };
388
+ if (this.options.ranges) {
389
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
390
+ }
391
+ this.yyleng = this.yytext.length;
392
+ return this;
393
+ }, "unput"),
394
+ // When called from action, caches matched text and appends it on next action
395
+ more: /* @__PURE__ */ __name(function() {
396
+ this._more = true;
397
+ return this;
398
+ }, "more"),
399
+ // 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.
400
+ reject: /* @__PURE__ */ __name(function() {
401
+ if (this.options.backtrack_lexer) {
402
+ this._backtrack = true;
403
+ } else {
404
+ 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(), {
405
+ text: "",
406
+ token: null,
407
+ line: this.yylineno
408
+ });
409
+ }
410
+ return this;
411
+ }, "reject"),
412
+ // retain first n characters of the match
413
+ less: /* @__PURE__ */ __name(function(n) {
414
+ this.unput(this.match.slice(n));
415
+ }, "less"),
416
+ // displays already matched input, i.e. for error messages
417
+ pastInput: /* @__PURE__ */ __name(function() {
418
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
419
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
420
+ }, "pastInput"),
421
+ // displays upcoming input, i.e. for error messages
422
+ upcomingInput: /* @__PURE__ */ __name(function() {
423
+ var next = this.match;
424
+ if (next.length < 20) {
425
+ next += this._input.substr(0, 20 - next.length);
426
+ }
427
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
428
+ }, "upcomingInput"),
429
+ // displays the character position where the lexing error occurred, i.e. for error messages
430
+ showPosition: /* @__PURE__ */ __name(function() {
431
+ var pre = this.pastInput();
432
+ var c = new Array(pre.length + 1).join("-");
433
+ return pre + this.upcomingInput() + "\n" + c + "^";
434
+ }, "showPosition"),
435
+ // test the lexed token: return FALSE when not a match, otherwise return token
436
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
437
+ var token, lines, backup;
438
+ if (this.options.backtrack_lexer) {
439
+ backup = {
440
+ yylineno: this.yylineno,
441
+ yylloc: {
442
+ first_line: this.yylloc.first_line,
443
+ last_line: this.last_line,
444
+ first_column: this.yylloc.first_column,
445
+ last_column: this.yylloc.last_column
446
+ },
447
+ yytext: this.yytext,
448
+ match: this.match,
449
+ matches: this.matches,
450
+ matched: this.matched,
451
+ yyleng: this.yyleng,
452
+ offset: this.offset,
453
+ _more: this._more,
454
+ _input: this._input,
455
+ yy: this.yy,
456
+ conditionStack: this.conditionStack.slice(0),
457
+ done: this.done
458
+ };
459
+ if (this.options.ranges) {
460
+ backup.yylloc.range = this.yylloc.range.slice(0);
461
+ }
462
+ }
463
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
464
+ if (lines) {
465
+ this.yylineno += lines.length;
466
+ }
467
+ this.yylloc = {
468
+ first_line: this.yylloc.last_line,
469
+ last_line: this.yylineno + 1,
470
+ first_column: this.yylloc.last_column,
471
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
472
+ };
473
+ this.yytext += match[0];
474
+ this.match += match[0];
475
+ this.matches = match;
476
+ this.yyleng = this.yytext.length;
477
+ if (this.options.ranges) {
478
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
479
+ }
480
+ this._more = false;
481
+ this._backtrack = false;
482
+ this._input = this._input.slice(match[0].length);
483
+ this.matched += match[0];
484
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
485
+ if (this.done && this._input) {
486
+ this.done = false;
487
+ }
488
+ if (token) {
489
+ return token;
490
+ } else if (this._backtrack) {
491
+ for (var k in backup) {
492
+ this[k] = backup[k];
493
+ }
494
+ return false;
495
+ }
496
+ return false;
497
+ }, "test_match"),
498
+ // return next match in input
499
+ next: /* @__PURE__ */ __name(function() {
500
+ if (this.done) {
501
+ return this.EOF;
502
+ }
503
+ if (!this._input) {
504
+ this.done = true;
505
+ }
506
+ var token, match, tempMatch, index;
507
+ if (!this._more) {
508
+ this.yytext = "";
509
+ this.match = "";
510
+ }
511
+ var rules = this._currentRules();
512
+ for (var i = 0; i < rules.length; i++) {
513
+ tempMatch = this._input.match(this.rules[rules[i]]);
514
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
515
+ match = tempMatch;
516
+ index = i;
517
+ if (this.options.backtrack_lexer) {
518
+ token = this.test_match(tempMatch, rules[i]);
519
+ if (token !== false) {
520
+ return token;
521
+ } else if (this._backtrack) {
522
+ match = false;
523
+ continue;
524
+ } else {
525
+ return false;
526
+ }
527
+ } else if (!this.options.flex) {
528
+ break;
529
+ }
530
+ }
531
+ }
532
+ if (match) {
533
+ token = this.test_match(match, rules[index]);
534
+ if (token !== false) {
535
+ return token;
536
+ }
537
+ return false;
538
+ }
539
+ if (this._input === "") {
540
+ return this.EOF;
541
+ } else {
542
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
543
+ text: "",
544
+ token: null,
545
+ line: this.yylineno
546
+ });
547
+ }
548
+ }, "next"),
549
+ // return next match that has a token
550
+ lex: /* @__PURE__ */ __name(function lex() {
551
+ var r = this.next();
552
+ if (r) {
553
+ return r;
554
+ } else {
555
+ return this.lex();
556
+ }
557
+ }, "lex"),
558
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
559
+ begin: /* @__PURE__ */ __name(function begin(condition) {
560
+ this.conditionStack.push(condition);
561
+ }, "begin"),
562
+ // pop the previously active lexer condition state off the condition stack
563
+ popState: /* @__PURE__ */ __name(function popState() {
564
+ var n = this.conditionStack.length - 1;
565
+ if (n > 0) {
566
+ return this.conditionStack.pop();
567
+ } else {
568
+ return this.conditionStack[0];
569
+ }
570
+ }, "popState"),
571
+ // produce the lexer rule set which is active for the currently active lexer condition state
572
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
573
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
574
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
575
+ } else {
576
+ return this.conditions["INITIAL"].rules;
577
+ }
578
+ }, "_currentRules"),
579
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
580
+ topState: /* @__PURE__ */ __name(function topState(n) {
581
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
582
+ if (n >= 0) {
583
+ return this.conditionStack[n];
584
+ } else {
585
+ return "INITIAL";
586
+ }
587
+ }, "topState"),
588
+ // alias for begin(condition)
589
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
590
+ this.begin(condition);
591
+ }, "pushState"),
592
+ // return the number of states currently on the stack
593
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
594
+ return this.conditionStack.length;
595
+ }, "stateStackSize"),
596
+ options: { "case-insensitive": true },
597
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
598
+ switch ($avoiding_name_collisions) {
599
+ case 0:
600
+ break;
601
+ case 1:
602
+ break;
603
+ case 2:
604
+ this.popState();
605
+ return 34;
606
+ case 3:
607
+ this.popState();
608
+ return 34;
609
+ case 4:
610
+ return 34;
611
+ case 5:
612
+ break;
613
+ case 6:
614
+ return 10;
615
+ case 7:
616
+ this.pushState("acc_title");
617
+ return 19;
618
+ case 8:
619
+ this.popState();
620
+ return "acc_title_value";
621
+ case 9:
622
+ this.pushState("acc_descr");
623
+ return 21;
624
+ case 10:
625
+ this.popState();
626
+ return "acc_descr_value";
627
+ case 11:
628
+ this.pushState("acc_descr_multiline");
629
+ break;
630
+ case 12:
631
+ this.popState();
632
+ break;
633
+ case 13:
634
+ return "acc_descr_multiline_value";
635
+ case 14:
636
+ return 5;
637
+ case 15:
638
+ return 5;
639
+ case 16:
640
+ return 8;
641
+ case 17:
642
+ this.pushState("axis_data");
643
+ return "X_AXIS";
644
+ case 18:
645
+ this.pushState("axis_data");
646
+ return "Y_AXIS";
647
+ case 19:
648
+ this.pushState("axis_band_data");
649
+ return 24;
650
+ case 20:
651
+ return 31;
652
+ case 21:
653
+ this.pushState("data");
654
+ return 16;
655
+ case 22:
656
+ this.pushState("data");
657
+ return 18;
658
+ case 23:
659
+ this.pushState("data_inner");
660
+ return 24;
661
+ case 24:
662
+ return 27;
663
+ case 25:
664
+ this.popState();
665
+ return 26;
666
+ case 26:
667
+ this.popState();
668
+ break;
669
+ case 27:
670
+ this.pushState("string");
671
+ break;
672
+ case 28:
673
+ this.popState();
674
+ break;
675
+ case 29:
676
+ return "STR";
677
+ case 30:
678
+ return 24;
679
+ case 31:
680
+ return 26;
681
+ case 32:
682
+ return 43;
683
+ case 33:
684
+ return "COLON";
685
+ case 34:
686
+ return 44;
687
+ case 35:
688
+ return 28;
689
+ case 36:
690
+ return 45;
691
+ case 37:
692
+ return 46;
693
+ case 38:
694
+ return 48;
695
+ case 39:
696
+ return 50;
697
+ case 40:
698
+ return 47;
699
+ case 41:
700
+ return 41;
701
+ case 42:
702
+ return 49;
703
+ case 43:
704
+ return 42;
705
+ case 44:
706
+ break;
707
+ case 45:
708
+ return 35;
709
+ case 46:
710
+ return 36;
711
+ }
712
+ }, "anonymous"),
713
+ rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:(\r?\n))/i, /^(?:(\r?\n))/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:\{)/i, /^(?:[^\}]*)/i, /^(?:xychart-beta\b)/i, /^(?:xychart\b)/i, /^(?:(?:vertical|horizontal))/i, /^(?:x-axis\b)/i, /^(?:y-axis\b)/i, /^(?:\[)/i, /^(?:-->)/i, /^(?:line\b)/i, /^(?:bar\b)/i, /^(?:\[)/i, /^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i, /^(?:\])/i, /^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s+)/i, /^(?:;)/i, /^(?:$)/i],
714
+ conditions: { "data_inner": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], "inclusive": true }, "data": { "rules": [0, 1, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 23, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], "inclusive": true }, "axis_band_data": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], "inclusive": true }, "axis_data": { "rules": [0, 1, 2, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], "inclusive": true }, "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [], "inclusive": false }, "md_string": { "rules": [], "inclusive": false }, "string": { "rules": [28, 29], "inclusive": false }, "INITIAL": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], "inclusive": true } }
715
+ };
716
+ return lexer2;
717
+ })();
718
+ parser2.lexer = lexer;
719
+ function Parser() {
720
+ this.yy = {};
721
+ }
722
+ __name(Parser, "Parser");
723
+ Parser.prototype = parser2;
724
+ parser2.Parser = Parser;
725
+ return new Parser();
726
+ })();
727
+ parser.parser = parser;
728
+ var xychart_default = parser;
729
+ function isBarPlot(data) {
730
+ return data.type === "bar";
731
+ }
732
+ __name(isBarPlot, "isBarPlot");
733
+ function isBandAxisData(data) {
734
+ return data.type === "band";
735
+ }
736
+ __name(isBandAxisData, "isBandAxisData");
737
+ function isLinearAxisData(data) {
738
+ return data.type === "linear";
739
+ }
740
+ __name(isLinearAxisData, "isLinearAxisData");
741
+ var TextDimensionCalculatorWithFont = (_a = class {
742
+ constructor(parentGroup) {
743
+ this.parentGroup = parentGroup;
744
+ }
745
+ getMaxDimension(texts, fontSize) {
746
+ if (!this.parentGroup) {
747
+ return {
748
+ width: texts.reduce((acc, cur) => Math.max(cur.length, acc), 0) * fontSize,
749
+ height: fontSize
750
+ };
751
+ }
752
+ const dimension = {
753
+ width: 0,
754
+ height: 0
755
+ };
756
+ const elem = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", fontSize);
757
+ for (const t of texts) {
758
+ const bbox = computeDimensionOfText(elem, 1, t);
759
+ const width = bbox ? bbox.width : t.length * fontSize;
760
+ const height = bbox ? bbox.height : fontSize;
761
+ dimension.width = Math.max(dimension.width, width);
762
+ dimension.height = Math.max(dimension.height, height);
763
+ }
764
+ elem.remove();
765
+ return dimension;
766
+ }
767
+ }, __name(_a, "TextDimensionCalculatorWithFont"), _a);
768
+ var BAR_WIDTH_TO_TICK_WIDTH_RATIO = 0.7;
769
+ var MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL = 0.2;
770
+ var BaseAxis = (_b = class {
771
+ constructor(axisConfig, title, textDimensionCalculator, axisThemeConfig) {
772
+ this.axisConfig = axisConfig;
773
+ this.title = title;
774
+ this.textDimensionCalculator = textDimensionCalculator;
775
+ this.axisThemeConfig = axisThemeConfig;
776
+ this.boundingRect = { x: 0, y: 0, width: 0, height: 0 };
777
+ this.axisPosition = "left";
778
+ this.showTitle = false;
779
+ this.showLabel = false;
780
+ this.showTick = false;
781
+ this.showAxisLine = false;
782
+ this.outerPadding = 0;
783
+ this.titleTextHeight = 0;
784
+ this.labelTextHeight = 0;
785
+ this.range = [0, 10];
786
+ this.boundingRect = { x: 0, y: 0, width: 0, height: 0 };
787
+ this.axisPosition = "left";
788
+ }
789
+ setRange(range2) {
790
+ this.range = range2;
791
+ if (this.axisPosition === "left" || this.axisPosition === "right") {
792
+ this.boundingRect.height = range2[1] - range2[0];
793
+ } else {
794
+ this.boundingRect.width = range2[1] - range2[0];
795
+ }
796
+ this.recalculateScale();
797
+ }
798
+ getRange() {
799
+ return [this.range[0] + this.outerPadding, this.range[1] - this.outerPadding];
800
+ }
801
+ setAxisPosition(axisPosition) {
802
+ this.axisPosition = axisPosition;
803
+ this.setRange(this.range);
804
+ }
805
+ getTickDistance() {
806
+ const range2 = this.getRange();
807
+ return Math.abs(range2[0] - range2[1]) / this.getTickValues().length;
808
+ }
809
+ getAxisOuterPadding() {
810
+ return this.outerPadding;
811
+ }
812
+ getLabelDimension() {
813
+ return this.textDimensionCalculator.getMaxDimension(
814
+ this.getTickValues().map((tick) => tick.toString()),
815
+ this.axisConfig.labelFontSize
816
+ );
817
+ }
818
+ recalculateOuterPaddingToDrawBar() {
819
+ if (BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() > this.outerPadding * 2) {
820
+ this.outerPadding = Math.floor(BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() / 2);
821
+ }
822
+ this.recalculateScale();
823
+ }
824
+ calculateSpaceIfDrawnHorizontally(availableSpace) {
825
+ let availableHeight = availableSpace.height;
826
+ if (this.axisConfig.showAxisLine && availableHeight > this.axisConfig.axisLineWidth) {
827
+ availableHeight -= this.axisConfig.axisLineWidth;
828
+ this.showAxisLine = true;
829
+ }
830
+ if (this.axisConfig.showLabel) {
831
+ const spaceRequired = this.getLabelDimension();
832
+ const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.width;
833
+ this.outerPadding = Math.min(spaceRequired.width / 2, maxPadding);
834
+ const heightRequired = spaceRequired.height + this.axisConfig.labelPadding * 2;
835
+ this.labelTextHeight = spaceRequired.height;
836
+ if (heightRequired <= availableHeight) {
837
+ availableHeight -= heightRequired;
838
+ this.showLabel = true;
839
+ }
840
+ }
841
+ if (this.axisConfig.showTick && availableHeight >= this.axisConfig.tickLength) {
842
+ this.showTick = true;
843
+ availableHeight -= this.axisConfig.tickLength;
844
+ }
845
+ if (this.axisConfig.showTitle && this.title) {
846
+ const spaceRequired = this.textDimensionCalculator.getMaxDimension(
847
+ [this.title],
848
+ this.axisConfig.titleFontSize
849
+ );
850
+ const heightRequired = spaceRequired.height + this.axisConfig.titlePadding * 2;
851
+ this.titleTextHeight = spaceRequired.height;
852
+ if (heightRequired <= availableHeight) {
853
+ availableHeight -= heightRequired;
854
+ this.showTitle = true;
855
+ }
856
+ }
857
+ this.boundingRect.width = availableSpace.width;
858
+ this.boundingRect.height = availableSpace.height - availableHeight;
859
+ }
860
+ calculateSpaceIfDrawnVertical(availableSpace) {
861
+ let availableWidth = availableSpace.width;
862
+ if (this.axisConfig.showAxisLine && availableWidth > this.axisConfig.axisLineWidth) {
863
+ availableWidth -= this.axisConfig.axisLineWidth;
864
+ this.showAxisLine = true;
865
+ }
866
+ if (this.axisConfig.showLabel) {
867
+ const spaceRequired = this.getLabelDimension();
868
+ const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.height;
869
+ this.outerPadding = Math.min(spaceRequired.height / 2, maxPadding);
870
+ const widthRequired = spaceRequired.width + this.axisConfig.labelPadding * 2;
871
+ if (widthRequired <= availableWidth) {
872
+ availableWidth -= widthRequired;
873
+ this.showLabel = true;
874
+ }
875
+ }
876
+ if (this.axisConfig.showTick && availableWidth >= this.axisConfig.tickLength) {
877
+ this.showTick = true;
878
+ availableWidth -= this.axisConfig.tickLength;
879
+ }
880
+ if (this.axisConfig.showTitle && this.title) {
881
+ const spaceRequired = this.textDimensionCalculator.getMaxDimension(
882
+ [this.title],
883
+ this.axisConfig.titleFontSize
884
+ );
885
+ const widthRequired = spaceRequired.height + this.axisConfig.titlePadding * 2;
886
+ this.titleTextHeight = spaceRequired.height;
887
+ if (widthRequired <= availableWidth) {
888
+ availableWidth -= widthRequired;
889
+ this.showTitle = true;
890
+ }
891
+ }
892
+ this.boundingRect.width = availableSpace.width - availableWidth;
893
+ this.boundingRect.height = availableSpace.height;
894
+ }
895
+ calculateSpace(availableSpace) {
896
+ if (this.axisPosition === "left" || this.axisPosition === "right") {
897
+ this.calculateSpaceIfDrawnVertical(availableSpace);
898
+ } else {
899
+ this.calculateSpaceIfDrawnHorizontally(availableSpace);
900
+ }
901
+ this.recalculateScale();
902
+ return {
903
+ width: this.boundingRect.width,
904
+ height: this.boundingRect.height
905
+ };
906
+ }
907
+ setBoundingBoxXY(point) {
908
+ this.boundingRect.x = point.x;
909
+ this.boundingRect.y = point.y;
910
+ }
911
+ getDrawableElementsForLeftAxis() {
912
+ const drawableElement = [];
913
+ if (this.showAxisLine) {
914
+ const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2;
915
+ drawableElement.push({
916
+ type: "path",
917
+ groupTexts: ["left-axis", "axisl-line"],
918
+ data: [
919
+ {
920
+ path: `M ${x},${this.boundingRect.y} L ${x},${this.boundingRect.y + this.boundingRect.height} `,
921
+ strokeFill: this.axisThemeConfig.axisLineColor,
922
+ strokeWidth: this.axisConfig.axisLineWidth
923
+ }
924
+ ]
925
+ });
926
+ }
927
+ if (this.showLabel) {
928
+ drawableElement.push({
929
+ type: "text",
930
+ groupTexts: ["left-axis", "label"],
931
+ data: this.getTickValues().map((tick) => ({
932
+ text: tick.toString(),
933
+ x: this.boundingRect.x + this.boundingRect.width - (this.showLabel ? this.axisConfig.labelPadding : 0) - (this.showTick ? this.axisConfig.tickLength : 0) - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0),
934
+ y: this.getScaleValue(tick),
935
+ fill: this.axisThemeConfig.labelColor,
936
+ fontSize: this.axisConfig.labelFontSize,
937
+ rotation: 0,
938
+ verticalPos: "middle",
939
+ horizontalPos: "right"
940
+ }))
941
+ });
942
+ }
943
+ if (this.showTick) {
944
+ const x = this.boundingRect.x + this.boundingRect.width - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
945
+ drawableElement.push({
946
+ type: "path",
947
+ groupTexts: ["left-axis", "ticks"],
948
+ data: this.getTickValues().map((tick) => ({
949
+ path: `M ${x},${this.getScaleValue(tick)} L ${x - this.axisConfig.tickLength},${this.getScaleValue(tick)}`,
950
+ strokeFill: this.axisThemeConfig.tickColor,
951
+ strokeWidth: this.axisConfig.tickWidth
952
+ }))
953
+ });
954
+ }
955
+ if (this.showTitle) {
956
+ drawableElement.push({
957
+ type: "text",
958
+ groupTexts: ["left-axis", "title"],
959
+ data: [
960
+ {
961
+ text: this.title,
962
+ x: this.boundingRect.x + this.axisConfig.titlePadding,
963
+ y: this.boundingRect.y + this.boundingRect.height / 2,
964
+ fill: this.axisThemeConfig.titleColor,
965
+ fontSize: this.axisConfig.titleFontSize,
966
+ rotation: 270,
967
+ verticalPos: "top",
968
+ horizontalPos: "center"
969
+ }
970
+ ]
971
+ });
972
+ }
973
+ return drawableElement;
974
+ }
975
+ getDrawableElementsForBottomAxis() {
976
+ const drawableElement = [];
977
+ if (this.showAxisLine) {
978
+ const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2;
979
+ drawableElement.push({
980
+ type: "path",
981
+ groupTexts: ["bottom-axis", "axis-line"],
982
+ data: [
983
+ {
984
+ path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`,
985
+ strokeFill: this.axisThemeConfig.axisLineColor,
986
+ strokeWidth: this.axisConfig.axisLineWidth
987
+ }
988
+ ]
989
+ });
990
+ }
991
+ if (this.showLabel) {
992
+ drawableElement.push({
993
+ type: "text",
994
+ groupTexts: ["bottom-axis", "label"],
995
+ data: this.getTickValues().map((tick) => ({
996
+ text: tick.toString(),
997
+ x: this.getScaleValue(tick),
998
+ y: this.boundingRect.y + this.axisConfig.labelPadding + (this.showTick ? this.axisConfig.tickLength : 0) + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0),
999
+ fill: this.axisThemeConfig.labelColor,
1000
+ fontSize: this.axisConfig.labelFontSize,
1001
+ rotation: 0,
1002
+ verticalPos: "top",
1003
+ horizontalPos: "center"
1004
+ }))
1005
+ });
1006
+ }
1007
+ if (this.showTick) {
1008
+ const y = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
1009
+ drawableElement.push({
1010
+ type: "path",
1011
+ groupTexts: ["bottom-axis", "ticks"],
1012
+ data: this.getTickValues().map((tick) => ({
1013
+ path: `M ${this.getScaleValue(tick)},${y} L ${this.getScaleValue(tick)},${y + this.axisConfig.tickLength}`,
1014
+ strokeFill: this.axisThemeConfig.tickColor,
1015
+ strokeWidth: this.axisConfig.tickWidth
1016
+ }))
1017
+ });
1018
+ }
1019
+ if (this.showTitle) {
1020
+ drawableElement.push({
1021
+ type: "text",
1022
+ groupTexts: ["bottom-axis", "title"],
1023
+ data: [
1024
+ {
1025
+ text: this.title,
1026
+ x: this.range[0] + (this.range[1] - this.range[0]) / 2,
1027
+ y: this.boundingRect.y + this.boundingRect.height - this.axisConfig.titlePadding - this.titleTextHeight,
1028
+ fill: this.axisThemeConfig.titleColor,
1029
+ fontSize: this.axisConfig.titleFontSize,
1030
+ rotation: 0,
1031
+ verticalPos: "top",
1032
+ horizontalPos: "center"
1033
+ }
1034
+ ]
1035
+ });
1036
+ }
1037
+ return drawableElement;
1038
+ }
1039
+ getDrawableElementsForTopAxis() {
1040
+ const drawableElement = [];
1041
+ if (this.showAxisLine) {
1042
+ const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2;
1043
+ drawableElement.push({
1044
+ type: "path",
1045
+ groupTexts: ["top-axis", "axis-line"],
1046
+ data: [
1047
+ {
1048
+ path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`,
1049
+ strokeFill: this.axisThemeConfig.axisLineColor,
1050
+ strokeWidth: this.axisConfig.axisLineWidth
1051
+ }
1052
+ ]
1053
+ });
1054
+ }
1055
+ if (this.showLabel) {
1056
+ drawableElement.push({
1057
+ type: "text",
1058
+ groupTexts: ["top-axis", "label"],
1059
+ data: this.getTickValues().map((tick) => ({
1060
+ text: tick.toString(),
1061
+ x: this.getScaleValue(tick),
1062
+ y: this.boundingRect.y + (this.showTitle ? this.titleTextHeight + this.axisConfig.titlePadding * 2 : 0) + this.axisConfig.labelPadding,
1063
+ fill: this.axisThemeConfig.labelColor,
1064
+ fontSize: this.axisConfig.labelFontSize,
1065
+ rotation: 0,
1066
+ verticalPos: "top",
1067
+ horizontalPos: "center"
1068
+ }))
1069
+ });
1070
+ }
1071
+ if (this.showTick) {
1072
+ const y = this.boundingRect.y;
1073
+ drawableElement.push({
1074
+ type: "path",
1075
+ groupTexts: ["top-axis", "ticks"],
1076
+ data: this.getTickValues().map((tick) => ({
1077
+ path: `M ${this.getScaleValue(tick)},${y + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(tick)},${y + this.boundingRect.height - this.axisConfig.tickLength - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)}`,
1078
+ strokeFill: this.axisThemeConfig.tickColor,
1079
+ strokeWidth: this.axisConfig.tickWidth
1080
+ }))
1081
+ });
1082
+ }
1083
+ if (this.showTitle) {
1084
+ drawableElement.push({
1085
+ type: "text",
1086
+ groupTexts: ["top-axis", "title"],
1087
+ data: [
1088
+ {
1089
+ text: this.title,
1090
+ x: this.boundingRect.x + this.boundingRect.width / 2,
1091
+ y: this.boundingRect.y + this.axisConfig.titlePadding,
1092
+ fill: this.axisThemeConfig.titleColor,
1093
+ fontSize: this.axisConfig.titleFontSize,
1094
+ rotation: 0,
1095
+ verticalPos: "top",
1096
+ horizontalPos: "center"
1097
+ }
1098
+ ]
1099
+ });
1100
+ }
1101
+ return drawableElement;
1102
+ }
1103
+ getDrawableElements() {
1104
+ if (this.axisPosition === "left") {
1105
+ return this.getDrawableElementsForLeftAxis();
1106
+ }
1107
+ if (this.axisPosition === "right") {
1108
+ throw Error("Drawing of right axis is not implemented");
1109
+ }
1110
+ if (this.axisPosition === "bottom") {
1111
+ return this.getDrawableElementsForBottomAxis();
1112
+ }
1113
+ if (this.axisPosition === "top") {
1114
+ return this.getDrawableElementsForTopAxis();
1115
+ }
1116
+ return [];
1117
+ }
1118
+ }, __name(_b, "BaseAxis"), _b);
1119
+ var BandAxis = (_c = class extends BaseAxis {
1120
+ constructor(axisConfig, axisThemeConfig, categories, title, textDimensionCalculator) {
1121
+ super(axisConfig, title, textDimensionCalculator, axisThemeConfig);
1122
+ this.categories = categories;
1123
+ this.scale = band().domain(this.categories).range(this.getRange());
1124
+ }
1125
+ setRange(range2) {
1126
+ super.setRange(range2);
1127
+ }
1128
+ recalculateScale() {
1129
+ this.scale = band().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5);
1130
+ log.trace("BandAxis axis final categories, range: ", this.categories, this.getRange());
1131
+ }
1132
+ getTickValues() {
1133
+ return this.categories;
1134
+ }
1135
+ getScaleValue(value) {
1136
+ return this.scale(value) ?? this.getRange()[0];
1137
+ }
1138
+ }, __name(_c, "BandAxis"), _c);
1139
+ var LinearAxis = (_d = class extends BaseAxis {
1140
+ constructor(axisConfig, axisThemeConfig, domain, title, textDimensionCalculator) {
1141
+ super(axisConfig, title, textDimensionCalculator, axisThemeConfig);
1142
+ this.domain = domain;
1143
+ this.scale = linear().domain(this.domain).range(this.getRange());
1144
+ }
1145
+ getTickValues() {
1146
+ return this.scale.ticks();
1147
+ }
1148
+ recalculateScale() {
1149
+ const domain = [...this.domain];
1150
+ if (this.axisPosition === "left") {
1151
+ domain.reverse();
1152
+ }
1153
+ this.scale = linear().domain(domain).range(this.getRange());
1154
+ }
1155
+ getScaleValue(value) {
1156
+ return this.scale(value);
1157
+ }
1158
+ }, __name(_d, "LinearAxis"), _d);
1159
+ function getAxis(data, axisConfig, axisThemeConfig, tmpSVGGroup2) {
1160
+ const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2);
1161
+ if (isBandAxisData(data)) {
1162
+ return new BandAxis(
1163
+ axisConfig,
1164
+ axisThemeConfig,
1165
+ data.categories,
1166
+ data.title,
1167
+ textDimensionCalculator
1168
+ );
1169
+ }
1170
+ return new LinearAxis(
1171
+ axisConfig,
1172
+ axisThemeConfig,
1173
+ [data.min, data.max],
1174
+ data.title,
1175
+ textDimensionCalculator
1176
+ );
1177
+ }
1178
+ __name(getAxis, "getAxis");
1179
+ var ChartTitle = (_e = class {
1180
+ constructor(textDimensionCalculator, chartConfig, chartData, chartThemeConfig) {
1181
+ this.textDimensionCalculator = textDimensionCalculator;
1182
+ this.chartConfig = chartConfig;
1183
+ this.chartData = chartData;
1184
+ this.chartThemeConfig = chartThemeConfig;
1185
+ this.boundingRect = {
1186
+ x: 0,
1187
+ y: 0,
1188
+ width: 0,
1189
+ height: 0
1190
+ };
1191
+ this.showChartTitle = false;
1192
+ }
1193
+ setBoundingBoxXY(point) {
1194
+ this.boundingRect.x = point.x;
1195
+ this.boundingRect.y = point.y;
1196
+ }
1197
+ calculateSpace(availableSpace) {
1198
+ const titleDimension = this.textDimensionCalculator.getMaxDimension(
1199
+ [this.chartData.title],
1200
+ this.chartConfig.titleFontSize
1201
+ );
1202
+ const widthRequired = Math.max(titleDimension.width, availableSpace.width);
1203
+ const heightRequired = titleDimension.height + 2 * this.chartConfig.titlePadding;
1204
+ if (titleDimension.width <= widthRequired && titleDimension.height <= heightRequired && this.chartConfig.showTitle && this.chartData.title) {
1205
+ this.boundingRect.width = widthRequired;
1206
+ this.boundingRect.height = heightRequired;
1207
+ this.showChartTitle = true;
1208
+ }
1209
+ return {
1210
+ width: this.boundingRect.width,
1211
+ height: this.boundingRect.height
1212
+ };
1213
+ }
1214
+ getDrawableElements() {
1215
+ const drawableElem = [];
1216
+ if (this.showChartTitle) {
1217
+ drawableElem.push({
1218
+ groupTexts: ["chart-title"],
1219
+ type: "text",
1220
+ data: [
1221
+ {
1222
+ fontSize: this.chartConfig.titleFontSize,
1223
+ text: this.chartData.title,
1224
+ verticalPos: "middle",
1225
+ horizontalPos: "center",
1226
+ x: this.boundingRect.x + this.boundingRect.width / 2,
1227
+ y: this.boundingRect.y + this.boundingRect.height / 2,
1228
+ fill: this.chartThemeConfig.titleColor,
1229
+ rotation: 0
1230
+ }
1231
+ ]
1232
+ });
1233
+ }
1234
+ return drawableElem;
1235
+ }
1236
+ }, __name(_e, "ChartTitle"), _e);
1237
+ function getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) {
1238
+ const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2);
1239
+ return new ChartTitle(textDimensionCalculator, chartConfig, chartData, chartThemeConfig);
1240
+ }
1241
+ __name(getChartTitleComponent, "getChartTitleComponent");
1242
+ var LinePlot = (_f = class {
1243
+ constructor(plotData, xAxis, yAxis, orientation, plotIndex2) {
1244
+ this.plotData = plotData;
1245
+ this.xAxis = xAxis;
1246
+ this.yAxis = yAxis;
1247
+ this.orientation = orientation;
1248
+ this.plotIndex = plotIndex2;
1249
+ }
1250
+ getDrawableElement() {
1251
+ const finalData = this.plotData.data.map((d) => [
1252
+ this.xAxis.getScaleValue(d[0]),
1253
+ this.yAxis.getScaleValue(d[1])
1254
+ ]);
1255
+ let path;
1256
+ if (this.orientation === "horizontal") {
1257
+ path = line().y((d) => d[0]).x((d) => d[1])(finalData);
1258
+ } else {
1259
+ path = line().x((d) => d[0]).y((d) => d[1])(finalData);
1260
+ }
1261
+ if (!path) {
1262
+ return [];
1263
+ }
1264
+ return [
1265
+ {
1266
+ groupTexts: ["plot", `line-plot-${this.plotIndex}`],
1267
+ type: "path",
1268
+ data: [
1269
+ {
1270
+ path,
1271
+ strokeFill: this.plotData.strokeFill,
1272
+ strokeWidth: this.plotData.strokeWidth
1273
+ }
1274
+ ]
1275
+ }
1276
+ ];
1277
+ }
1278
+ }, __name(_f, "LinePlot"), _f);
1279
+ var BarPlot = (_g = class {
1280
+ constructor(barData, boundingRect, xAxis, yAxis, orientation, plotIndex2) {
1281
+ this.barData = barData;
1282
+ this.boundingRect = boundingRect;
1283
+ this.xAxis = xAxis;
1284
+ this.yAxis = yAxis;
1285
+ this.orientation = orientation;
1286
+ this.plotIndex = plotIndex2;
1287
+ }
1288
+ getDrawableElement() {
1289
+ const finalData = this.barData.data.map((d) => [
1290
+ this.xAxis.getScaleValue(d[0]),
1291
+ this.yAxis.getScaleValue(d[1])
1292
+ ]);
1293
+ const barPaddingPercent = 0.05;
1294
+ const barWidth = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * (1 - barPaddingPercent);
1295
+ const barWidthHalf = barWidth / 2;
1296
+ if (this.orientation === "horizontal") {
1297
+ return [
1298
+ {
1299
+ groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
1300
+ type: "rect",
1301
+ data: finalData.map((data) => ({
1302
+ x: this.boundingRect.x,
1303
+ y: data[0] - barWidthHalf,
1304
+ height: barWidth,
1305
+ width: data[1] - this.boundingRect.x,
1306
+ fill: this.barData.fill,
1307
+ strokeWidth: 0,
1308
+ strokeFill: this.barData.fill
1309
+ }))
1310
+ }
1311
+ ];
1312
+ }
1313
+ return [
1314
+ {
1315
+ groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
1316
+ type: "rect",
1317
+ data: finalData.map((data) => ({
1318
+ x: data[0] - barWidthHalf,
1319
+ y: data[1],
1320
+ width: barWidth,
1321
+ height: this.boundingRect.y + this.boundingRect.height - data[1],
1322
+ fill: this.barData.fill,
1323
+ strokeWidth: 0,
1324
+ strokeFill: this.barData.fill
1325
+ }))
1326
+ }
1327
+ ];
1328
+ }
1329
+ }, __name(_g, "BarPlot"), _g);
1330
+ var BasePlot = (_h = class {
1331
+ constructor(chartConfig, chartData, chartThemeConfig) {
1332
+ this.chartConfig = chartConfig;
1333
+ this.chartData = chartData;
1334
+ this.chartThemeConfig = chartThemeConfig;
1335
+ this.boundingRect = {
1336
+ x: 0,
1337
+ y: 0,
1338
+ width: 0,
1339
+ height: 0
1340
+ };
1341
+ }
1342
+ setAxes(xAxis, yAxis) {
1343
+ this.xAxis = xAxis;
1344
+ this.yAxis = yAxis;
1345
+ }
1346
+ setBoundingBoxXY(point) {
1347
+ this.boundingRect.x = point.x;
1348
+ this.boundingRect.y = point.y;
1349
+ }
1350
+ calculateSpace(availableSpace) {
1351
+ this.boundingRect.width = availableSpace.width;
1352
+ this.boundingRect.height = availableSpace.height;
1353
+ return {
1354
+ width: this.boundingRect.width,
1355
+ height: this.boundingRect.height
1356
+ };
1357
+ }
1358
+ getDrawableElements() {
1359
+ if (!(this.xAxis && this.yAxis)) {
1360
+ throw Error("Axes must be passed to render Plots");
1361
+ }
1362
+ const drawableElem = [];
1363
+ for (const [i, plot] of this.chartData.plots.entries()) {
1364
+ switch (plot.type) {
1365
+ case "line":
1366
+ {
1367
+ const linePlot = new LinePlot(
1368
+ plot,
1369
+ this.xAxis,
1370
+ this.yAxis,
1371
+ this.chartConfig.chartOrientation,
1372
+ i
1373
+ );
1374
+ drawableElem.push(...linePlot.getDrawableElement());
1375
+ }
1376
+ break;
1377
+ case "bar":
1378
+ {
1379
+ const barPlot = new BarPlot(
1380
+ plot,
1381
+ this.boundingRect,
1382
+ this.xAxis,
1383
+ this.yAxis,
1384
+ this.chartConfig.chartOrientation,
1385
+ i
1386
+ );
1387
+ drawableElem.push(...barPlot.getDrawableElement());
1388
+ }
1389
+ break;
1390
+ }
1391
+ }
1392
+ return drawableElem;
1393
+ }
1394
+ }, __name(_h, "BasePlot"), _h);
1395
+ function getPlotComponent(chartConfig, chartData, chartThemeConfig) {
1396
+ return new BasePlot(chartConfig, chartData, chartThemeConfig);
1397
+ }
1398
+ __name(getPlotComponent, "getPlotComponent");
1399
+ var Orchestrator = (_i = class {
1400
+ constructor(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) {
1401
+ this.chartConfig = chartConfig;
1402
+ this.chartData = chartData;
1403
+ this.componentStore = {
1404
+ title: getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2),
1405
+ plot: getPlotComponent(chartConfig, chartData, chartThemeConfig),
1406
+ xAxis: getAxis(
1407
+ chartData.xAxis,
1408
+ chartConfig.xAxis,
1409
+ {
1410
+ titleColor: chartThemeConfig.xAxisTitleColor,
1411
+ labelColor: chartThemeConfig.xAxisLabelColor,
1412
+ tickColor: chartThemeConfig.xAxisTickColor,
1413
+ axisLineColor: chartThemeConfig.xAxisLineColor
1414
+ },
1415
+ tmpSVGGroup2
1416
+ ),
1417
+ yAxis: getAxis(
1418
+ chartData.yAxis,
1419
+ chartConfig.yAxis,
1420
+ {
1421
+ titleColor: chartThemeConfig.yAxisTitleColor,
1422
+ labelColor: chartThemeConfig.yAxisLabelColor,
1423
+ tickColor: chartThemeConfig.yAxisTickColor,
1424
+ axisLineColor: chartThemeConfig.yAxisLineColor
1425
+ },
1426
+ tmpSVGGroup2
1427
+ )
1428
+ };
1429
+ }
1430
+ calculateVerticalSpace() {
1431
+ let availableWidth = this.chartConfig.width;
1432
+ let availableHeight = this.chartConfig.height;
1433
+ let plotX = 0;
1434
+ let plotY = 0;
1435
+ let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100);
1436
+ let chartHeight = Math.floor(
1437
+ availableHeight * this.chartConfig.plotReservedSpacePercent / 100
1438
+ );
1439
+ let spaceUsed = this.componentStore.plot.calculateSpace({
1440
+ width: chartWidth,
1441
+ height: chartHeight
1442
+ });
1443
+ availableWidth -= spaceUsed.width;
1444
+ availableHeight -= spaceUsed.height;
1445
+ spaceUsed = this.componentStore.title.calculateSpace({
1446
+ width: this.chartConfig.width,
1447
+ height: availableHeight
1448
+ });
1449
+ plotY = spaceUsed.height;
1450
+ availableHeight -= spaceUsed.height;
1451
+ this.componentStore.xAxis.setAxisPosition("bottom");
1452
+ spaceUsed = this.componentStore.xAxis.calculateSpace({
1453
+ width: availableWidth,
1454
+ height: availableHeight
1455
+ });
1456
+ availableHeight -= spaceUsed.height;
1457
+ this.componentStore.yAxis.setAxisPosition("left");
1458
+ spaceUsed = this.componentStore.yAxis.calculateSpace({
1459
+ width: availableWidth,
1460
+ height: availableHeight
1461
+ });
1462
+ plotX = spaceUsed.width;
1463
+ availableWidth -= spaceUsed.width;
1464
+ if (availableWidth > 0) {
1465
+ chartWidth += availableWidth;
1466
+ availableWidth = 0;
1467
+ }
1468
+ if (availableHeight > 0) {
1469
+ chartHeight += availableHeight;
1470
+ availableHeight = 0;
1471
+ }
1472
+ this.componentStore.plot.calculateSpace({
1473
+ width: chartWidth,
1474
+ height: chartHeight
1475
+ });
1476
+ this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY });
1477
+ this.componentStore.xAxis.setRange([plotX, plotX + chartWidth]);
1478
+ this.componentStore.xAxis.setBoundingBoxXY({ x: plotX, y: plotY + chartHeight });
1479
+ this.componentStore.yAxis.setRange([plotY, plotY + chartHeight]);
1480
+ this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: plotY });
1481
+ if (this.chartData.plots.some((p) => isBarPlot(p))) {
1482
+ this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
1483
+ }
1484
+ }
1485
+ calculateHorizontalSpace() {
1486
+ let availableWidth = this.chartConfig.width;
1487
+ let availableHeight = this.chartConfig.height;
1488
+ let titleYEnd = 0;
1489
+ let plotX = 0;
1490
+ let plotY = 0;
1491
+ let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100);
1492
+ let chartHeight = Math.floor(
1493
+ availableHeight * this.chartConfig.plotReservedSpacePercent / 100
1494
+ );
1495
+ let spaceUsed = this.componentStore.plot.calculateSpace({
1496
+ width: chartWidth,
1497
+ height: chartHeight
1498
+ });
1499
+ availableWidth -= spaceUsed.width;
1500
+ availableHeight -= spaceUsed.height;
1501
+ spaceUsed = this.componentStore.title.calculateSpace({
1502
+ width: this.chartConfig.width,
1503
+ height: availableHeight
1504
+ });
1505
+ titleYEnd = spaceUsed.height;
1506
+ availableHeight -= spaceUsed.height;
1507
+ this.componentStore.xAxis.setAxisPosition("left");
1508
+ spaceUsed = this.componentStore.xAxis.calculateSpace({
1509
+ width: availableWidth,
1510
+ height: availableHeight
1511
+ });
1512
+ availableWidth -= spaceUsed.width;
1513
+ plotX = spaceUsed.width;
1514
+ this.componentStore.yAxis.setAxisPosition("top");
1515
+ spaceUsed = this.componentStore.yAxis.calculateSpace({
1516
+ width: availableWidth,
1517
+ height: availableHeight
1518
+ });
1519
+ availableHeight -= spaceUsed.height;
1520
+ plotY = titleYEnd + spaceUsed.height;
1521
+ if (availableWidth > 0) {
1522
+ chartWidth += availableWidth;
1523
+ availableWidth = 0;
1524
+ }
1525
+ if (availableHeight > 0) {
1526
+ chartHeight += availableHeight;
1527
+ availableHeight = 0;
1528
+ }
1529
+ this.componentStore.plot.calculateSpace({
1530
+ width: chartWidth,
1531
+ height: chartHeight
1532
+ });
1533
+ this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY });
1534
+ this.componentStore.yAxis.setRange([plotX, plotX + chartWidth]);
1535
+ this.componentStore.yAxis.setBoundingBoxXY({ x: plotX, y: titleYEnd });
1536
+ this.componentStore.xAxis.setRange([plotY, plotY + chartHeight]);
1537
+ this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: plotY });
1538
+ if (this.chartData.plots.some((p) => isBarPlot(p))) {
1539
+ this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
1540
+ }
1541
+ }
1542
+ calculateSpace() {
1543
+ if (this.chartConfig.chartOrientation === "horizontal") {
1544
+ this.calculateHorizontalSpace();
1545
+ } else {
1546
+ this.calculateVerticalSpace();
1547
+ }
1548
+ }
1549
+ getDrawableElement() {
1550
+ this.calculateSpace();
1551
+ const drawableElem = [];
1552
+ this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis);
1553
+ for (const component of Object.values(this.componentStore)) {
1554
+ drawableElem.push(...component.getDrawableElements());
1555
+ }
1556
+ return drawableElem;
1557
+ }
1558
+ }, __name(_i, "Orchestrator"), _i);
1559
+ var XYChartBuilder = (_j = class {
1560
+ static build(config, chartData, chartThemeConfig, tmpSVGGroup2) {
1561
+ const orchestrator = new Orchestrator(config, chartData, chartThemeConfig, tmpSVGGroup2);
1562
+ return orchestrator.getDrawableElement();
1563
+ }
1564
+ }, __name(_j, "XYChartBuilder"), _j);
1565
+ var plotIndex = 0;
1566
+ var tmpSVGGroup;
1567
+ var xyChartConfig = getChartDefaultConfig();
1568
+ var xyChartThemeConfig = getChartDefaultThemeConfig();
1569
+ var xyChartData = getChartDefaultData();
1570
+ var plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim());
1571
+ var hasSetXAxis = false;
1572
+ var hasSetYAxis = false;
1573
+ function getChartDefaultThemeConfig() {
1574
+ const defaultThemeVariables = getThemeVariables3();
1575
+ const config = getConfig();
1576
+ return cleanAndMerge(defaultThemeVariables.xyChart, config.themeVariables.xyChart);
1577
+ }
1578
+ __name(getChartDefaultThemeConfig, "getChartDefaultThemeConfig");
1579
+ function getChartDefaultConfig() {
1580
+ const config = getConfig();
1581
+ return cleanAndMerge(
1582
+ defaultConfig_default.xyChart,
1583
+ config.xyChart
1584
+ );
1585
+ }
1586
+ __name(getChartDefaultConfig, "getChartDefaultConfig");
1587
+ function getChartDefaultData() {
1588
+ return {
1589
+ yAxis: {
1590
+ type: "linear",
1591
+ title: "",
1592
+ min: Infinity,
1593
+ max: -Infinity
1594
+ },
1595
+ xAxis: {
1596
+ type: "band",
1597
+ title: "",
1598
+ categories: []
1599
+ },
1600
+ title: "",
1601
+ plots: []
1602
+ };
1603
+ }
1604
+ __name(getChartDefaultData, "getChartDefaultData");
1605
+ function textSanitizer(text) {
1606
+ const config = getConfig();
1607
+ return sanitizeText(text.trim(), config);
1608
+ }
1609
+ __name(textSanitizer, "textSanitizer");
1610
+ function setTmpSVGG(SVGG) {
1611
+ tmpSVGGroup = SVGG;
1612
+ }
1613
+ __name(setTmpSVGG, "setTmpSVGG");
1614
+ function setOrientation(orientation) {
1615
+ if (orientation === "horizontal") {
1616
+ xyChartConfig.chartOrientation = "horizontal";
1617
+ } else {
1618
+ xyChartConfig.chartOrientation = "vertical";
1619
+ }
1620
+ }
1621
+ __name(setOrientation, "setOrientation");
1622
+ function setXAxisTitle(title) {
1623
+ xyChartData.xAxis.title = textSanitizer(title.text);
1624
+ }
1625
+ __name(setXAxisTitle, "setXAxisTitle");
1626
+ function setXAxisRangeData(min, max) {
1627
+ xyChartData.xAxis = { type: "linear", title: xyChartData.xAxis.title, min, max };
1628
+ hasSetXAxis = true;
1629
+ }
1630
+ __name(setXAxisRangeData, "setXAxisRangeData");
1631
+ function setXAxisBand(categories) {
1632
+ xyChartData.xAxis = {
1633
+ type: "band",
1634
+ title: xyChartData.xAxis.title,
1635
+ categories: categories.map((c) => textSanitizer(c.text))
1636
+ };
1637
+ hasSetXAxis = true;
1638
+ }
1639
+ __name(setXAxisBand, "setXAxisBand");
1640
+ function setYAxisTitle(title) {
1641
+ xyChartData.yAxis.title = textSanitizer(title.text);
1642
+ }
1643
+ __name(setYAxisTitle, "setYAxisTitle");
1644
+ function setYAxisRangeData(min, max) {
1645
+ xyChartData.yAxis = { type: "linear", title: xyChartData.yAxis.title, min, max };
1646
+ hasSetYAxis = true;
1647
+ }
1648
+ __name(setYAxisRangeData, "setYAxisRangeData");
1649
+ function setYAxisRangeFromPlotData(data) {
1650
+ const minValue = Math.min(...data);
1651
+ const maxValue = Math.max(...data);
1652
+ const prevMinValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Infinity;
1653
+ const prevMaxValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.max : -Infinity;
1654
+ xyChartData.yAxis = {
1655
+ type: "linear",
1656
+ title: xyChartData.yAxis.title,
1657
+ min: Math.min(prevMinValue, minValue),
1658
+ max: Math.max(prevMaxValue, maxValue)
1659
+ };
1660
+ }
1661
+ __name(setYAxisRangeFromPlotData, "setYAxisRangeFromPlotData");
1662
+ function transformDataWithoutCategory(data) {
1663
+ let retData = [];
1664
+ if (data.length === 0) {
1665
+ return retData;
1666
+ }
1667
+ if (!hasSetXAxis) {
1668
+ const prevMinValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.min : Infinity;
1669
+ const prevMaxValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.max : -Infinity;
1670
+ setXAxisRangeData(Math.min(prevMinValue, 1), Math.max(prevMaxValue, data.length));
1671
+ }
1672
+ if (!hasSetYAxis) {
1673
+ setYAxisRangeFromPlotData(data);
1674
+ }
1675
+ if (isBandAxisData(xyChartData.xAxis)) {
1676
+ retData = xyChartData.xAxis.categories.map((c, i) => [c, data[i]]);
1677
+ }
1678
+ if (isLinearAxisData(xyChartData.xAxis)) {
1679
+ const min = xyChartData.xAxis.min;
1680
+ const max = xyChartData.xAxis.max;
1681
+ const step = (max - min) / (data.length - 1);
1682
+ const categories = [];
1683
+ for (let i = min; i <= max; i += step) {
1684
+ categories.push(`${i}`);
1685
+ }
1686
+ retData = categories.map((c, i) => [c, data[i]]);
1687
+ }
1688
+ return retData;
1689
+ }
1690
+ __name(transformDataWithoutCategory, "transformDataWithoutCategory");
1691
+ function getPlotColorFromPalette(plotIndex2) {
1692
+ return plotColorPalette[plotIndex2 === 0 ? 0 : plotIndex2 % plotColorPalette.length];
1693
+ }
1694
+ __name(getPlotColorFromPalette, "getPlotColorFromPalette");
1695
+ function setLineData(title, data) {
1696
+ const plotData = transformDataWithoutCategory(data);
1697
+ xyChartData.plots.push({
1698
+ type: "line",
1699
+ strokeFill: getPlotColorFromPalette(plotIndex),
1700
+ strokeWidth: 2,
1701
+ data: plotData
1702
+ });
1703
+ plotIndex++;
1704
+ }
1705
+ __name(setLineData, "setLineData");
1706
+ function setBarData(title, data) {
1707
+ const plotData = transformDataWithoutCategory(data);
1708
+ xyChartData.plots.push({
1709
+ type: "bar",
1710
+ fill: getPlotColorFromPalette(plotIndex),
1711
+ data: plotData
1712
+ });
1713
+ plotIndex++;
1714
+ }
1715
+ __name(setBarData, "setBarData");
1716
+ function getDrawableElem() {
1717
+ if (xyChartData.plots.length === 0) {
1718
+ throw Error("No Plot to render, please provide a plot with some data");
1719
+ }
1720
+ xyChartData.title = getDiagramTitle();
1721
+ return XYChartBuilder.build(xyChartConfig, xyChartData, xyChartThemeConfig, tmpSVGGroup);
1722
+ }
1723
+ __name(getDrawableElem, "getDrawableElem");
1724
+ function getChartThemeConfig() {
1725
+ return xyChartThemeConfig;
1726
+ }
1727
+ __name(getChartThemeConfig, "getChartThemeConfig");
1728
+ function getChartConfig() {
1729
+ return xyChartConfig;
1730
+ }
1731
+ __name(getChartConfig, "getChartConfig");
1732
+ function getXYChartData() {
1733
+ return xyChartData;
1734
+ }
1735
+ __name(getXYChartData, "getXYChartData");
1736
+ var clear2 = /* @__PURE__ */ __name(function() {
1737
+ clear();
1738
+ plotIndex = 0;
1739
+ xyChartConfig = getChartDefaultConfig();
1740
+ xyChartData = getChartDefaultData();
1741
+ xyChartThemeConfig = getChartDefaultThemeConfig();
1742
+ plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim());
1743
+ hasSetXAxis = false;
1744
+ hasSetYAxis = false;
1745
+ }, "clear");
1746
+ var xychartDb_default = {
1747
+ getDrawableElem,
1748
+ clear: clear2,
1749
+ setAccTitle,
1750
+ getAccTitle,
1751
+ setDiagramTitle,
1752
+ getDiagramTitle,
1753
+ getAccDescription,
1754
+ setAccDescription,
1755
+ setOrientation,
1756
+ setXAxisTitle,
1757
+ setXAxisRangeData,
1758
+ setXAxisBand,
1759
+ setYAxisTitle,
1760
+ setYAxisRangeData,
1761
+ setLineData,
1762
+ setBarData,
1763
+ setTmpSVGG,
1764
+ getChartThemeConfig,
1765
+ getChartConfig,
1766
+ getXYChartData
1767
+ };
1768
+ var draw = /* @__PURE__ */ __name((txt, id, _version, diagObj) => {
1769
+ const db = diagObj.db;
1770
+ const themeConfig = db.getChartThemeConfig();
1771
+ const chartConfig = db.getChartConfig();
1772
+ const labelData = db.getXYChartData().plots[0].data.map((data) => data[1]);
1773
+ function getDominantBaseLine(horizontalPos) {
1774
+ return horizontalPos === "top" ? "text-before-edge" : "middle";
1775
+ }
1776
+ __name(getDominantBaseLine, "getDominantBaseLine");
1777
+ function getTextAnchor(verticalPos) {
1778
+ return verticalPos === "left" ? "start" : verticalPos === "right" ? "end" : "middle";
1779
+ }
1780
+ __name(getTextAnchor, "getTextAnchor");
1781
+ function getTextTransformation(data) {
1782
+ return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`;
1783
+ }
1784
+ __name(getTextTransformation, "getTextTransformation");
1785
+ log.debug("Rendering xychart chart\n" + txt);
1786
+ const svg = selectSvgElement(id);
1787
+ const group = svg.append("g").attr("class", "main");
1788
+ const background = group.append("rect").attr("width", chartConfig.width).attr("height", chartConfig.height).attr("class", "background");
1789
+ configureSvgSize(svg, chartConfig.height, chartConfig.width, true);
1790
+ svg.attr("viewBox", `0 0 ${chartConfig.width} ${chartConfig.height}`);
1791
+ background.attr("fill", themeConfig.backgroundColor);
1792
+ db.setTmpSVGG(svg.append("g").attr("class", "mermaid-tmp-group"));
1793
+ const shapes = db.getDrawableElem();
1794
+ const groups = {};
1795
+ function getGroup(gList) {
1796
+ let elem = group;
1797
+ let prefix = "";
1798
+ for (const [i] of gList.entries()) {
1799
+ let parent = group;
1800
+ if (i > 0 && groups[prefix]) {
1801
+ parent = groups[prefix];
1802
+ }
1803
+ prefix += gList[i];
1804
+ elem = groups[prefix];
1805
+ if (!elem) {
1806
+ elem = groups[prefix] = parent.append("g").attr("class", gList[i]);
1807
+ }
1808
+ }
1809
+ return elem;
1810
+ }
1811
+ __name(getGroup, "getGroup");
1812
+ for (const shape of shapes) {
1813
+ if (shape.data.length === 0) {
1814
+ continue;
1815
+ }
1816
+ const shapeGroup = getGroup(shape.groupTexts);
1817
+ switch (shape.type) {
1818
+ case "rect":
1819
+ shapeGroup.selectAll("rect").data(shape.data).enter().append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill).attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth);
1820
+ if (chartConfig.showDataLabel) {
1821
+ if (chartConfig.chartOrientation === "horizontal") {
1822
+ let fitsHorizontally2 = function(item, fontSize) {
1823
+ const { data, label } = item;
1824
+ const textWidth = fontSize * label.length * charWidthFactor;
1825
+ return textWidth <= data.width - 10;
1826
+ };
1827
+ __name(fitsHorizontally2, "fitsHorizontally");
1828
+ const charWidthFactor = 0.7;
1829
+ const validItems = shape.data.map((d, i) => ({ data: d, label: labelData[i].toString() })).filter((item) => item.data.width > 0 && item.data.height > 0);
1830
+ const candidateFontSizes = validItems.map((item) => {
1831
+ const { data } = item;
1832
+ let fontSize = data.height * 0.7;
1833
+ while (!fitsHorizontally2(item, fontSize) && fontSize > 0) {
1834
+ fontSize -= 1;
1835
+ }
1836
+ return fontSize;
1837
+ });
1838
+ const uniformFontSize = Math.floor(Math.min(...candidateFontSizes));
1839
+ shapeGroup.selectAll("text").data(validItems).enter().append("text").attr("x", (item) => item.data.x + item.data.width - 10).attr("y", (item) => item.data.y + item.data.height / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").attr("fill", "black").attr("font-size", `${uniformFontSize}px`).text((item) => item.label);
1840
+ } else {
1841
+ let fitsInBar2 = function(item, fontSize, yOffset2) {
1842
+ const { data, label } = item;
1843
+ const charWidthFactor = 0.7;
1844
+ const textWidth = fontSize * label.length * charWidthFactor;
1845
+ const centerX = data.x + data.width / 2;
1846
+ const leftEdge = centerX - textWidth / 2;
1847
+ const rightEdge = centerX + textWidth / 2;
1848
+ const horizontalFits = leftEdge >= data.x && rightEdge <= data.x + data.width;
1849
+ const verticalFits = data.y + yOffset2 + fontSize <= data.y + data.height;
1850
+ return horizontalFits && verticalFits;
1851
+ };
1852
+ __name(fitsInBar2, "fitsInBar");
1853
+ const yOffset = 10;
1854
+ const validItems = shape.data.map((d, i) => ({ data: d, label: labelData[i].toString() })).filter((item) => item.data.width > 0 && item.data.height > 0);
1855
+ const candidateFontSizes = validItems.map((item) => {
1856
+ const { data, label } = item;
1857
+ let fontSize = data.width / (label.length * 0.7);
1858
+ while (!fitsInBar2(item, fontSize, yOffset) && fontSize > 0) {
1859
+ fontSize -= 1;
1860
+ }
1861
+ return fontSize;
1862
+ });
1863
+ const uniformFontSize = Math.floor(Math.min(...candidateFontSizes));
1864
+ shapeGroup.selectAll("text").data(validItems).enter().append("text").attr("x", (item) => item.data.x + item.data.width / 2).attr("y", (item) => item.data.y + yOffset).attr("text-anchor", "middle").attr("dominant-baseline", "hanging").attr("fill", "black").attr("font-size", `${uniformFontSize}px`).text((item) => item.label);
1865
+ }
1866
+ }
1867
+ break;
1868
+ case "text":
1869
+ shapeGroup.selectAll("text").data(shape.data).enter().append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.verticalPos)).attr("text-anchor", (data) => getTextAnchor(data.horizontalPos)).attr("transform", (data) => getTextTransformation(data)).text((data) => data.text);
1870
+ break;
1871
+ case "path":
1872
+ shapeGroup.selectAll("path").data(shape.data).enter().append("path").attr("d", (data) => data.path).attr("fill", (data) => data.fill ? data.fill : "none").attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth);
1873
+ break;
1874
+ }
1875
+ }
1876
+ }, "draw");
1877
+ var xychartRenderer_default = {
1878
+ draw
1879
+ };
1880
+ var diagram = {
1881
+ parser: xychart_default,
1882
+ db: xychartDb_default,
1883
+ renderer: xychartRenderer_default
1884
+ };
1885
+ export {
1886
+ diagram
1887
+ };
1888
+ //# sourceMappingURL=xychartDiagram-PRI3JC2R-C0J9iwTO.js.map