@copilotkitnext/react 0.0.22-alpha.7 → 0.0.22-alpha.8

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 (236) hide show
  1. package/package.json +4 -4
  2. package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
  3. package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
  4. package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
  5. package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
  6. package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
  7. package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
  8. package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
  9. package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
  10. package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
  11. package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
  12. package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
  13. package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
  14. package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
  15. package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
  16. package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
  17. package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
  18. package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
  19. package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
  20. package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
  21. package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
  22. package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
  23. package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
  24. package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
  25. package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
  26. package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
  27. package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
  28. package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
  29. package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
  30. package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
  31. package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
  32. package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
  33. package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
  34. package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
  35. package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
  36. package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
  37. package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
  38. package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
  39. package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
  40. package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
  41. package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
  42. package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
  43. package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
  44. package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
  45. package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
  46. package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
  47. package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
  48. package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
  49. package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
  50. package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
  51. package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
  52. package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
  53. package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
  54. package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
  55. package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
  56. package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
  57. package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
  58. package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
  59. package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
  60. package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
  61. package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
  62. package/dist/angular-html-LD6QEAZE.mjs +0 -7
  63. package/dist/angular-html-LD6QEAZE.mjs.map +0 -1
  64. package/dist/angular-ts-FGK7I2F5.mjs +0 -37
  65. package/dist/angular-ts-FGK7I2F5.mjs.map +0 -1
  66. package/dist/angular-ts-XZTE5LQS.mjs +0 -37
  67. package/dist/angular-ts-XZTE5LQS.mjs.map +0 -1
  68. package/dist/apl-VB2EG5RZ.mjs +0 -22
  69. package/dist/apl-VB2EG5RZ.mjs.map +0 -1
  70. package/dist/architectureDiagram-VXUJARFQ-PPLKSFYC.mjs +0 -8712
  71. package/dist/architectureDiagram-VXUJARFQ-PPLKSFYC.mjs.map +0 -1
  72. package/dist/blade-EZDWULER.mjs +0 -26
  73. package/dist/blade-EZDWULER.mjs.map +0 -1
  74. package/dist/blade-HS4Z7O3Y.mjs +0 -26
  75. package/dist/blade-HS4Z7O3Y.mjs.map +0 -1
  76. package/dist/blockDiagram-VD42YOAC-7SIEWHYD.mjs +0 -3618
  77. package/dist/blockDiagram-VD42YOAC-7SIEWHYD.mjs.map +0 -1
  78. package/dist/c4Diagram-YG6GDRKO-G2UUBRHQ.mjs +0 -2495
  79. package/dist/c4Diagram-YG6GDRKO-G2UUBRHQ.mjs.map +0 -1
  80. package/dist/chunk-2BAFECUC.mjs +0 -28
  81. package/dist/chunk-2BAFECUC.mjs.map +0 -1
  82. package/dist/chunk-BF5LDW2L.mjs +0 -65
  83. package/dist/chunk-BF5LDW2L.mjs.map +0 -1
  84. package/dist/chunk-BUEC2HNL.mjs +0 -762
  85. package/dist/chunk-BUEC2HNL.mjs.map +0 -1
  86. package/dist/chunk-CRGJ2YCV.mjs +0 -109
  87. package/dist/chunk-CRGJ2YCV.mjs.map +0 -1
  88. package/dist/chunk-DKZXT4VQ.mjs +0 -19
  89. package/dist/chunk-DKZXT4VQ.mjs.map +0 -1
  90. package/dist/chunk-DYQXFOGA.mjs +0 -34
  91. package/dist/chunk-DYQXFOGA.mjs.map +0 -1
  92. package/dist/chunk-ENI667QL.mjs +0 -806
  93. package/dist/chunk-ENI667QL.mjs.map +0 -1
  94. package/dist/chunk-GEUZOPED.mjs +0 -1834
  95. package/dist/chunk-GEUZOPED.mjs.map +0 -1
  96. package/dist/chunk-GU7334FJ.mjs +0 -538
  97. package/dist/chunk-GU7334FJ.mjs.map +0 -1
  98. package/dist/chunk-HNKEYT4A.mjs +0 -4693
  99. package/dist/chunk-HNKEYT4A.mjs.map +0 -1
  100. package/dist/chunk-HTMHAYGC.mjs +0 -14
  101. package/dist/chunk-HTMHAYGC.mjs.map +0 -1
  102. package/dist/chunk-JRLFMJ6U.mjs +0 -1923
  103. package/dist/chunk-JRLFMJ6U.mjs.map +0 -1
  104. package/dist/chunk-JYRND4DC.mjs +0 -22
  105. package/dist/chunk-JYRND4DC.mjs.map +0 -1
  106. package/dist/chunk-KFEPUFID.mjs +0 -52
  107. package/dist/chunk-KFEPUFID.mjs.map +0 -1
  108. package/dist/chunk-M3UH7XZX.mjs +0 -6222
  109. package/dist/chunk-M3UH7XZX.mjs.map +0 -1
  110. package/dist/chunk-ND4RYWG7.mjs +0 -12
  111. package/dist/chunk-ND4RYWG7.mjs.map +0 -1
  112. package/dist/chunk-VLSLBZME.mjs +0 -51
  113. package/dist/chunk-VLSLBZME.mjs.map +0 -1
  114. package/dist/chunk-WJBV3P3K.mjs +0 -55
  115. package/dist/chunk-WJBV3P3K.mjs.map +0 -1
  116. package/dist/chunk-X2TQ2HDS.mjs +0 -44
  117. package/dist/chunk-X2TQ2HDS.mjs.map +0 -1
  118. package/dist/chunk-YIDZOZG3.mjs +0 -103
  119. package/dist/chunk-YIDZOZG3.mjs.map +0 -1
  120. package/dist/chunk-YLW7IP7V.mjs +0 -14525
  121. package/dist/chunk-YLW7IP7V.mjs.map +0 -1
  122. package/dist/classDiagram-2ON5EDUG-WUV4PTK5.mjs +0 -38
  123. package/dist/classDiagram-2ON5EDUG-WUV4PTK5.mjs.map +0 -1
  124. package/dist/classDiagram-v2-WZHVMYZB-J4QNVYPE.mjs +0 -38
  125. package/dist/classDiagram-v2-WZHVMYZB-J4QNVYPE.mjs.map +0 -1
  126. package/dist/cobol-PNTKRG5I.mjs +0 -17
  127. package/dist/cobol-PNTKRG5I.mjs.map +0 -1
  128. package/dist/crystal-BSMHK65A.mjs +0 -23
  129. package/dist/crystal-BSMHK65A.mjs.map +0 -1
  130. package/dist/dagre-6UL2VRFP-XN667C7N.mjs +0 -710
  131. package/dist/dagre-6UL2VRFP-XN667C7N.mjs.map +0 -1
  132. package/dist/diagram-PSM6KHXK-VA2CF5LZ.mjs +0 -538
  133. package/dist/diagram-PSM6KHXK-VA2CF5LZ.mjs.map +0 -1
  134. package/dist/diagram-QEK2KX5R-H3EHES33.mjs +0 -319
  135. package/dist/diagram-QEK2KX5R-H3EHES33.mjs.map +0 -1
  136. package/dist/diagram-S2PKOQOG-FOQYPB22.mjs +0 -231
  137. package/dist/diagram-S2PKOQOG-FOQYPB22.mjs.map +0 -1
  138. package/dist/edge-JOI74UJM.mjs +0 -19
  139. package/dist/edge-JOI74UJM.mjs.map +0 -1
  140. package/dist/elixir-FEL6DDPJ.mjs +0 -15
  141. package/dist/elixir-FEL6DDPJ.mjs.map +0 -1
  142. package/dist/erDiagram-Q2GNP2WA-IXNJSD2A.mjs +0 -1175
  143. package/dist/erDiagram-Q2GNP2WA-IXNJSD2A.mjs.map +0 -1
  144. package/dist/erb-Q2D6FWX3.mjs +0 -32
  145. package/dist/erb-Q2D6FWX3.mjs.map +0 -1
  146. package/dist/flowDiagram-NV44I4VS-ISKGEBMD.mjs +0 -2349
  147. package/dist/flowDiagram-NV44I4VS-ISKGEBMD.mjs.map +0 -1
  148. package/dist/ganttDiagram-LVOFAZNH-OAL7V7IR.mjs +0 -2344
  149. package/dist/ganttDiagram-LVOFAZNH-OAL7V7IR.mjs.map +0 -1
  150. package/dist/gitGraphDiagram-NY62KEGX-RKN2CCAZ.mjs +0 -1221
  151. package/dist/gitGraphDiagram-NY62KEGX-RKN2CCAZ.mjs.map +0 -1
  152. package/dist/glimmer-js-B32LCGFA.mjs +0 -19
  153. package/dist/glimmer-js-B32LCGFA.mjs.map +0 -1
  154. package/dist/glimmer-ts-4PHFAQCG.mjs +0 -19
  155. package/dist/glimmer-ts-4PHFAQCG.mjs.map +0 -1
  156. package/dist/hack-3ZNSL4KD.mjs +0 -17
  157. package/dist/hack-3ZNSL4KD.mjs.map +0 -1
  158. package/dist/handlebars-ICBC3AZK.mjs +0 -19
  159. package/dist/handlebars-ICBC3AZK.mjs.map +0 -1
  160. package/dist/html-BGY5P773.mjs +0 -6
  161. package/dist/html-BGY5P773.mjs.map +0 -1
  162. package/dist/html-derivative-3HGXHHFE.mjs +0 -7
  163. package/dist/html-derivative-3HGXHHFE.mjs.map +0 -1
  164. package/dist/index.css +0 -2385
  165. package/dist/index.css.map +0 -1
  166. package/dist/infoDiagram-F6ZHWCRC-Z7KMJJ45.mjs +0 -49
  167. package/dist/infoDiagram-F6ZHWCRC-Z7KMJJ45.mjs.map +0 -1
  168. package/dist/jinja-WL6HNMB5.mjs +0 -22
  169. package/dist/jinja-WL6HNMB5.mjs.map +0 -1
  170. package/dist/journeyDiagram-XKPGCS4Q-BMTOBHZ4.mjs +0 -1259
  171. package/dist/journeyDiagram-XKPGCS4Q-BMTOBHZ4.mjs.map +0 -1
  172. package/dist/kanban-definition-3W4ZIXB7-MVFRARF4.mjs +0 -1062
  173. package/dist/kanban-definition-3W4ZIXB7-MVFRARF4.mjs.map +0 -1
  174. package/dist/katex-4R42CMCB.mjs +0 -4
  175. package/dist/katex-4R42CMCB.mjs.map +0 -1
  176. package/dist/liquid-YS3YPW54.mjs +0 -19
  177. package/dist/liquid-YS3YPW54.mjs.map +0 -1
  178. package/dist/logo-mark-OHF64HAY.svg +0 -8
  179. package/dist/mdc-A66KLOT4.mjs +0 -20
  180. package/dist/mdc-A66KLOT4.mjs.map +0 -1
  181. package/dist/mermaid.core-4OWTNZSL.mjs +0 -1587
  182. package/dist/mermaid.core-4OWTNZSL.mjs.map +0 -1
  183. package/dist/mermaid.core-7AUE4M6E.mjs +0 -1587
  184. package/dist/mermaid.core-7AUE4M6E.mjs.map +0 -1
  185. package/dist/mindmap-definition-VGOIOE7T-7FMA2CPY.mjs +0 -1112
  186. package/dist/mindmap-definition-VGOIOE7T-7FMA2CPY.mjs.map +0 -1
  187. package/dist/mindmap-definition-VGOIOE7T-VNF7JZOY.mjs +0 -1112
  188. package/dist/mindmap-definition-VGOIOE7T-VNF7JZOY.mjs.map +0 -1
  189. package/dist/nim-HUBKBJHZ.mjs +0 -26
  190. package/dist/nim-HUBKBJHZ.mjs.map +0 -1
  191. package/dist/perl-QHAMWWQ5.mjs +0 -22
  192. package/dist/perl-QHAMWWQ5.mjs.map +0 -1
  193. package/dist/php-FS5GKSPN.mjs +0 -11
  194. package/dist/php-FS5GKSPN.mjs.map +0 -1
  195. package/dist/pieDiagram-ADFJNKIX-EER3WTCU.mjs +0 -200
  196. package/dist/pieDiagram-ADFJNKIX-EER3WTCU.mjs.map +0 -1
  197. package/dist/pug-WTY5FMEA.mjs +0 -17
  198. package/dist/pug-WTY5FMEA.mjs.map +0 -1
  199. package/dist/quadrantDiagram-AYHSOK5B-WQCIRJOK.mjs +0 -1344
  200. package/dist/quadrantDiagram-AYHSOK5B-WQCIRJOK.mjs.map +0 -1
  201. package/dist/razor-BAB7LFWZ.mjs +0 -17
  202. package/dist/razor-BAB7LFWZ.mjs.map +0 -1
  203. package/dist/requirementDiagram-UZGBJVZJ-RVM6Q2TT.mjs +0 -1179
  204. package/dist/requirementDiagram-UZGBJVZJ-RVM6Q2TT.mjs.map +0 -1
  205. package/dist/rst-AY7U27YM.mjs +0 -41
  206. package/dist/rst-AY7U27YM.mjs.map +0 -1
  207. package/dist/rst-Y2VLYMJI.mjs +0 -41
  208. package/dist/rst-Y2VLYMJI.mjs.map +0 -1
  209. package/dist/ruby-K4BNEYWG.mjs +0 -22
  210. package/dist/ruby-K4BNEYWG.mjs.map +0 -1
  211. package/dist/sankeyDiagram-TZEHDZUN-H7BVEXGO.mjs +0 -1230
  212. package/dist/sankeyDiagram-TZEHDZUN-H7BVEXGO.mjs.map +0 -1
  213. package/dist/sequenceDiagram-WL72ISMW-XBGZSOYI.mjs +0 -3885
  214. package/dist/sequenceDiagram-WL72ISMW-XBGZSOYI.mjs.map +0 -1
  215. package/dist/soy-5QMQV2KL.mjs +0 -15
  216. package/dist/soy-5QMQV2KL.mjs.map +0 -1
  217. package/dist/stateDiagram-FKZM4ZOC-WRIBVFSJ.mjs +0 -467
  218. package/dist/stateDiagram-FKZM4ZOC-WRIBVFSJ.mjs.map +0 -1
  219. package/dist/stateDiagram-v2-4FDKWEC3-SPDO7R6D.mjs +0 -37
  220. package/dist/stateDiagram-v2-4FDKWEC3-SPDO7R6D.mjs.map +0 -1
  221. package/dist/templ-VSARRSO2.mjs +0 -17
  222. package/dist/templ-VSARRSO2.mjs.map +0 -1
  223. package/dist/timeline-definition-IT6M3QCI-PX4A2RIH.mjs +0 -1226
  224. package/dist/timeline-definition-IT6M3QCI-PX4A2RIH.mjs.map +0 -1
  225. package/dist/ts-tags-YK3Q2LIW.mjs +0 -68
  226. package/dist/ts-tags-YK3Q2LIW.mjs.map +0 -1
  227. package/dist/twig-HNMWLN6H.mjs +0 -40
  228. package/dist/twig-HNMWLN6H.mjs.map +0 -1
  229. package/dist/vue-7OSX6ZY5.mjs +0 -10
  230. package/dist/vue-7OSX6ZY5.mjs.map +0 -1
  231. package/dist/vue-html-AQH2V2EU.mjs +0 -20
  232. package/dist/vue-html-AQH2V2EU.mjs.map +0 -1
  233. package/dist/vue-vine-GCYT2IGV.mjs +0 -29
  234. package/dist/vue-vine-GCYT2IGV.mjs.map +0 -1
  235. package/dist/xychartDiagram-PRI3JC2R-65KZQZDU.mjs +0 -1865
  236. package/dist/xychartDiagram-PRI3JC2R-65KZQZDU.mjs.map +0 -1
@@ -1,1221 +0,0 @@
1
- import { populateCommonDb } from './chunk-TTWRCDIC.mjs';
2
- import { parse } from './chunk-S7QNUGK2.mjs';
3
- import { ImperativeState } from './chunk-6HFDM2CT.mjs';
4
- import './chunk-WJTQD7PW.mjs';
5
- import './chunk-TO2PW746.mjs';
6
- import './chunk-4ZPM5JLE.mjs';
7
- import './chunk-UDJFODZR.mjs';
8
- import './chunk-TKSZKNX6.mjs';
9
- import './chunk-FBSCEMOY.mjs';
10
- import './chunk-LAALMHUD.mjs';
11
- import './chunk-6BGV5W65.mjs';
12
- import './chunk-GKV77NWJ.mjs';
13
- import './chunk-JIP2SELZ.mjs';
14
- import { cleanAndMerge, random, utils_default } from './chunk-GU7334FJ.mjs';
15
- import './chunk-ZGPFSRJJ.mjs';
16
- import { defaultConfig_default, getConfig2, getConfig, getDiagramTitle, setDiagramTitle, setAccDescription, getAccDescription, getAccTitle, setAccTitle, common_default, clear, setupGraphViewbox2 } from './chunk-HNKEYT4A.mjs';
17
- import './chunk-7O6EKIFY.mjs';
18
- import { __name, log, select_default } from './chunk-WHXHCOFP.mjs';
19
- import './chunk-SH6YXSHR.mjs';
20
-
21
- // ../../node_modules/.pnpm/mermaid@11.12.0/node_modules/mermaid/dist/chunks/mermaid.core/gitGraphDiagram-NY62KEGX.mjs
22
- var commitType = {
23
- NORMAL: 0,
24
- REVERSE: 1,
25
- HIGHLIGHT: 2,
26
- MERGE: 3,
27
- CHERRY_PICK: 4
28
- };
29
- var DEFAULT_GITGRAPH_CONFIG = defaultConfig_default.gitGraph;
30
- var getConfig3 = /* @__PURE__ */ __name(() => {
31
- const config = cleanAndMerge({
32
- ...DEFAULT_GITGRAPH_CONFIG,
33
- ...getConfig().gitGraph
34
- });
35
- return config;
36
- }, "getConfig");
37
- var state = new ImperativeState(() => {
38
- const config = getConfig3();
39
- const mainBranchName = config.mainBranchName;
40
- const mainBranchOrder = config.mainBranchOrder;
41
- return {
42
- mainBranchName,
43
- commits: /* @__PURE__ */ new Map(),
44
- head: null,
45
- branchConfig: /* @__PURE__ */ new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]),
46
- branches: /* @__PURE__ */ new Map([[mainBranchName, null]]),
47
- currBranch: mainBranchName,
48
- direction: "LR",
49
- seq: 0,
50
- options: {}
51
- };
52
- });
53
- function getID() {
54
- return random({ length: 7 });
55
- }
56
- __name(getID, "getID");
57
- function uniqBy(list, fn) {
58
- const recordMap = /* @__PURE__ */ Object.create(null);
59
- return list.reduce((out, item) => {
60
- const key = fn(item);
61
- if (!recordMap[key]) {
62
- recordMap[key] = true;
63
- out.push(item);
64
- }
65
- return out;
66
- }, []);
67
- }
68
- __name(uniqBy, "uniqBy");
69
- var setDirection = /* @__PURE__ */ __name(function(dir2) {
70
- state.records.direction = dir2;
71
- }, "setDirection");
72
- var setOptions = /* @__PURE__ */ __name(function(rawOptString) {
73
- log.debug("options str", rawOptString);
74
- rawOptString = rawOptString?.trim();
75
- rawOptString = rawOptString || "{}";
76
- try {
77
- state.records.options = JSON.parse(rawOptString);
78
- } catch (e) {
79
- log.error("error while parsing gitGraph options", e.message);
80
- }
81
- }, "setOptions");
82
- var getOptions = /* @__PURE__ */ __name(function() {
83
- return state.records.options;
84
- }, "getOptions");
85
- var commit = /* @__PURE__ */ __name(function(commitDB) {
86
- let msg = commitDB.msg;
87
- let id = commitDB.id;
88
- const type = commitDB.type;
89
- let tags = commitDB.tags;
90
- log.info("commit", msg, id, type, tags);
91
- log.debug("Entering commit:", msg, id, type, tags);
92
- const config = getConfig3();
93
- id = common_default.sanitizeText(id, config);
94
- msg = common_default.sanitizeText(msg, config);
95
- tags = tags?.map((tag) => common_default.sanitizeText(tag, config));
96
- const newCommit = {
97
- id: id ? id : state.records.seq + "-" + getID(),
98
- message: msg,
99
- seq: state.records.seq++,
100
- type: type ?? commitType.NORMAL,
101
- tags: tags ?? [],
102
- parents: state.records.head == null ? [] : [state.records.head.id],
103
- branch: state.records.currBranch
104
- };
105
- state.records.head = newCommit;
106
- log.info("main branch", config.mainBranchName);
107
- if (state.records.commits.has(newCommit.id)) {
108
- log.warn(`Commit ID ${newCommit.id} already exists`);
109
- }
110
- state.records.commits.set(newCommit.id, newCommit);
111
- state.records.branches.set(state.records.currBranch, newCommit.id);
112
- log.debug("in pushCommit " + newCommit.id);
113
- }, "commit");
114
- var branch = /* @__PURE__ */ __name(function(branchDB) {
115
- let name = branchDB.name;
116
- const order = branchDB.order;
117
- name = common_default.sanitizeText(name, getConfig3());
118
- if (state.records.branches.has(name)) {
119
- throw new Error(
120
- `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")`
121
- );
122
- }
123
- state.records.branches.set(name, state.records.head != null ? state.records.head.id : null);
124
- state.records.branchConfig.set(name, { name, order });
125
- checkout(name);
126
- log.debug("in createBranch");
127
- }, "branch");
128
- var merge = /* @__PURE__ */ __name((mergeDB) => {
129
- let otherBranch = mergeDB.branch;
130
- let customId = mergeDB.id;
131
- const overrideType = mergeDB.type;
132
- const customTags = mergeDB.tags;
133
- const config = getConfig3();
134
- otherBranch = common_default.sanitizeText(otherBranch, config);
135
- if (customId) {
136
- customId = common_default.sanitizeText(customId, config);
137
- }
138
- const currentBranchCheck = state.records.branches.get(state.records.currBranch);
139
- const otherBranchCheck = state.records.branches.get(otherBranch);
140
- const currentCommit = currentBranchCheck ? state.records.commits.get(currentBranchCheck) : void 0;
141
- const otherCommit = otherBranchCheck ? state.records.commits.get(otherBranchCheck) : void 0;
142
- if (currentCommit && otherCommit && currentCommit.branch === otherBranch) {
143
- throw new Error(`Cannot merge branch '${otherBranch}' into itself.`);
144
- }
145
- if (state.records.currBranch === otherBranch) {
146
- const error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
147
- error.hash = {
148
- text: `merge ${otherBranch}`,
149
- token: `merge ${otherBranch}`,
150
- expected: ["branch abc"]
151
- };
152
- throw error;
153
- }
154
- if (currentCommit === void 0 || !currentCommit) {
155
- const error = new Error(
156
- `Incorrect usage of "merge". Current branch (${state.records.currBranch})has no commits`
157
- );
158
- error.hash = {
159
- text: `merge ${otherBranch}`,
160
- token: `merge ${otherBranch}`,
161
- expected: ["commit"]
162
- };
163
- throw error;
164
- }
165
- if (!state.records.branches.has(otherBranch)) {
166
- const error = new Error(
167
- 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") does not exist"
168
- );
169
- error.hash = {
170
- text: `merge ${otherBranch}`,
171
- token: `merge ${otherBranch}`,
172
- expected: [`branch ${otherBranch}`]
173
- };
174
- throw error;
175
- }
176
- if (otherCommit === void 0 || !otherCommit) {
177
- const error = new Error(
178
- 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") has no commits"
179
- );
180
- error.hash = {
181
- text: `merge ${otherBranch}`,
182
- token: `merge ${otherBranch}`,
183
- expected: ['"commit"']
184
- };
185
- throw error;
186
- }
187
- if (currentCommit === otherCommit) {
188
- const error = new Error('Incorrect usage of "merge". Both branches have same head');
189
- error.hash = {
190
- text: `merge ${otherBranch}`,
191
- token: `merge ${otherBranch}`,
192
- expected: ["branch abc"]
193
- };
194
- throw error;
195
- }
196
- if (customId && state.records.commits.has(customId)) {
197
- const error = new Error(
198
- 'Incorrect usage of "merge". Commit with id:' + customId + " already exists, use different custom id"
199
- );
200
- error.hash = {
201
- text: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(" ")}`,
202
- token: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(" ")}`,
203
- expected: [
204
- `merge ${otherBranch} ${customId}_UNIQUE ${overrideType} ${customTags?.join(" ")}`
205
- ]
206
- };
207
- throw error;
208
- }
209
- const verifiedBranch = otherBranchCheck ? otherBranchCheck : "";
210
- const commit2 = {
211
- id: customId || `${state.records.seq}-${getID()}`,
212
- message: `merged branch ${otherBranch} into ${state.records.currBranch}`,
213
- seq: state.records.seq++,
214
- parents: state.records.head == null ? [] : [state.records.head.id, verifiedBranch],
215
- branch: state.records.currBranch,
216
- type: commitType.MERGE,
217
- customType: overrideType,
218
- customId: customId ? true : false,
219
- tags: customTags ?? []
220
- };
221
- state.records.head = commit2;
222
- state.records.commits.set(commit2.id, commit2);
223
- state.records.branches.set(state.records.currBranch, commit2.id);
224
- log.debug(state.records.branches);
225
- log.debug("in mergeBranch");
226
- }, "merge");
227
- var cherryPick = /* @__PURE__ */ __name(function(cherryPickDB) {
228
- let sourceId = cherryPickDB.id;
229
- let targetId = cherryPickDB.targetId;
230
- let tags = cherryPickDB.tags;
231
- let parentCommitId = cherryPickDB.parent;
232
- log.debug("Entering cherryPick:", sourceId, targetId, tags);
233
- const config = getConfig3();
234
- sourceId = common_default.sanitizeText(sourceId, config);
235
- targetId = common_default.sanitizeText(targetId, config);
236
- tags = tags?.map((tag) => common_default.sanitizeText(tag, config));
237
- parentCommitId = common_default.sanitizeText(parentCommitId, config);
238
- if (!sourceId || !state.records.commits.has(sourceId)) {
239
- const error = new Error(
240
- 'Incorrect usage of "cherryPick". Source commit id should exist and provided'
241
- );
242
- error.hash = {
243
- text: `cherryPick ${sourceId} ${targetId}`,
244
- token: `cherryPick ${sourceId} ${targetId}`,
245
- expected: ["cherry-pick abc"]
246
- };
247
- throw error;
248
- }
249
- const sourceCommit = state.records.commits.get(sourceId);
250
- if (sourceCommit === void 0 || !sourceCommit) {
251
- throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');
252
- }
253
- if (parentCommitId && !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) {
254
- const error = new Error(
255
- "Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."
256
- );
257
- throw error;
258
- }
259
- const sourceCommitBranch = sourceCommit.branch;
260
- if (sourceCommit.type === commitType.MERGE && !parentCommitId) {
261
- const error = new Error(
262
- "Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."
263
- );
264
- throw error;
265
- }
266
- if (!targetId || !state.records.commits.has(targetId)) {
267
- if (sourceCommitBranch === state.records.currBranch) {
268
- const error = new Error(
269
- 'Incorrect usage of "cherryPick". Source commit is already on current branch'
270
- );
271
- error.hash = {
272
- text: `cherryPick ${sourceId} ${targetId}`,
273
- token: `cherryPick ${sourceId} ${targetId}`,
274
- expected: ["cherry-pick abc"]
275
- };
276
- throw error;
277
- }
278
- const currentCommitId = state.records.branches.get(state.records.currBranch);
279
- if (currentCommitId === void 0 || !currentCommitId) {
280
- const error = new Error(
281
- `Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits`
282
- );
283
- error.hash = {
284
- text: `cherryPick ${sourceId} ${targetId}`,
285
- token: `cherryPick ${sourceId} ${targetId}`,
286
- expected: ["cherry-pick abc"]
287
- };
288
- throw error;
289
- }
290
- const currentCommit = state.records.commits.get(currentCommitId);
291
- if (currentCommit === void 0 || !currentCommit) {
292
- const error = new Error(
293
- `Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits`
294
- );
295
- error.hash = {
296
- text: `cherryPick ${sourceId} ${targetId}`,
297
- token: `cherryPick ${sourceId} ${targetId}`,
298
- expected: ["cherry-pick abc"]
299
- };
300
- throw error;
301
- }
302
- const commit2 = {
303
- id: state.records.seq + "-" + getID(),
304
- message: `cherry-picked ${sourceCommit?.message} into ${state.records.currBranch}`,
305
- seq: state.records.seq++,
306
- parents: state.records.head == null ? [] : [state.records.head.id, sourceCommit.id],
307
- branch: state.records.currBranch,
308
- type: commitType.CHERRY_PICK,
309
- tags: tags ? tags.filter(Boolean) : [
310
- `cherry-pick:${sourceCommit.id}${sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : ""}`
311
- ]
312
- };
313
- state.records.head = commit2;
314
- state.records.commits.set(commit2.id, commit2);
315
- state.records.branches.set(state.records.currBranch, commit2.id);
316
- log.debug(state.records.branches);
317
- log.debug("in cherryPick");
318
- }
319
- }, "cherryPick");
320
- var checkout = /* @__PURE__ */ __name(function(branch2) {
321
- branch2 = common_default.sanitizeText(branch2, getConfig3());
322
- if (!state.records.branches.has(branch2)) {
323
- const error = new Error(
324
- `Trying to checkout branch which is not yet created. (Help try using "branch ${branch2}")`
325
- );
326
- error.hash = {
327
- text: `checkout ${branch2}`,
328
- token: `checkout ${branch2}`,
329
- expected: [`branch ${branch2}`]
330
- };
331
- throw error;
332
- } else {
333
- state.records.currBranch = branch2;
334
- const id = state.records.branches.get(state.records.currBranch);
335
- if (id === void 0 || !id) {
336
- state.records.head = null;
337
- } else {
338
- state.records.head = state.records.commits.get(id) ?? null;
339
- }
340
- }
341
- }, "checkout");
342
- function upsert(arr, key, newVal) {
343
- const index = arr.indexOf(key);
344
- if (index === -1) {
345
- arr.push(newVal);
346
- } else {
347
- arr.splice(index, 1, newVal);
348
- }
349
- }
350
- __name(upsert, "upsert");
351
- function prettyPrintCommitHistory(commitArr) {
352
- const commit2 = commitArr.reduce((out, commit3) => {
353
- if (out.seq > commit3.seq) {
354
- return out;
355
- }
356
- return commit3;
357
- }, commitArr[0]);
358
- let line = "";
359
- commitArr.forEach(function(c) {
360
- if (c === commit2) {
361
- line += " *";
362
- } else {
363
- line += " |";
364
- }
365
- });
366
- const label = [line, commit2.id, commit2.seq];
367
- for (const branch2 in state.records.branches) {
368
- if (state.records.branches.get(branch2) === commit2.id) {
369
- label.push(branch2);
370
- }
371
- }
372
- log.debug(label.join(" "));
373
- if (commit2.parents && commit2.parents.length == 2 && commit2.parents[0] && commit2.parents[1]) {
374
- const newCommit = state.records.commits.get(commit2.parents[0]);
375
- upsert(commitArr, commit2, newCommit);
376
- if (commit2.parents[1]) {
377
- commitArr.push(state.records.commits.get(commit2.parents[1]));
378
- }
379
- } else if (commit2.parents.length == 0) {
380
- return;
381
- } else {
382
- if (commit2.parents[0]) {
383
- const newCommit = state.records.commits.get(commit2.parents[0]);
384
- upsert(commitArr, commit2, newCommit);
385
- }
386
- }
387
- commitArr = uniqBy(commitArr, (c) => c.id);
388
- prettyPrintCommitHistory(commitArr);
389
- }
390
- __name(prettyPrintCommitHistory, "prettyPrintCommitHistory");
391
- var prettyPrint = /* @__PURE__ */ __name(function() {
392
- log.debug(state.records.commits);
393
- const node = getCommitsArray()[0];
394
- prettyPrintCommitHistory([node]);
395
- }, "prettyPrint");
396
- var clear2 = /* @__PURE__ */ __name(function() {
397
- state.reset();
398
- clear();
399
- }, "clear");
400
- var getBranchesAsObjArray = /* @__PURE__ */ __name(function() {
401
- const branchesArray = [...state.records.branchConfig.values()].map((branchConfig, i) => {
402
- if (branchConfig.order !== null && branchConfig.order !== void 0) {
403
- return branchConfig;
404
- }
405
- return {
406
- ...branchConfig,
407
- order: parseFloat(`0.${i}`)
408
- };
409
- }).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)).map(({ name }) => ({ name }));
410
- return branchesArray;
411
- }, "getBranchesAsObjArray");
412
- var getBranches = /* @__PURE__ */ __name(function() {
413
- return state.records.branches;
414
- }, "getBranches");
415
- var getCommits = /* @__PURE__ */ __name(function() {
416
- return state.records.commits;
417
- }, "getCommits");
418
- var getCommitsArray = /* @__PURE__ */ __name(function() {
419
- const commitArr = [...state.records.commits.values()];
420
- commitArr.forEach(function(o) {
421
- log.debug(o.id);
422
- });
423
- commitArr.sort((a, b) => a.seq - b.seq);
424
- return commitArr;
425
- }, "getCommitsArray");
426
- var getCurrentBranch = /* @__PURE__ */ __name(function() {
427
- return state.records.currBranch;
428
- }, "getCurrentBranch");
429
- var getDirection = /* @__PURE__ */ __name(function() {
430
- return state.records.direction;
431
- }, "getDirection");
432
- var getHead = /* @__PURE__ */ __name(function() {
433
- return state.records.head;
434
- }, "getHead");
435
- var db = {
436
- commitType,
437
- getConfig: getConfig3,
438
- setDirection,
439
- setOptions,
440
- getOptions,
441
- commit,
442
- branch,
443
- merge,
444
- cherryPick,
445
- checkout,
446
- //reset,
447
- prettyPrint,
448
- clear: clear2,
449
- getBranchesAsObjArray,
450
- getBranches,
451
- getCommits,
452
- getCommitsArray,
453
- getCurrentBranch,
454
- getDirection,
455
- getHead,
456
- setAccTitle,
457
- getAccTitle,
458
- getAccDescription,
459
- setAccDescription,
460
- setDiagramTitle,
461
- getDiagramTitle
462
- };
463
- var populate = /* @__PURE__ */ __name((ast, db2) => {
464
- populateCommonDb(ast, db2);
465
- if (ast.dir) {
466
- db2.setDirection(ast.dir);
467
- }
468
- for (const statement of ast.statements) {
469
- parseStatement(statement, db2);
470
- }
471
- }, "populate");
472
- var parseStatement = /* @__PURE__ */ __name((statement, db2) => {
473
- const parsers = {
474
- Commit: /* @__PURE__ */ __name((stmt) => db2.commit(parseCommit(stmt)), "Commit"),
475
- Branch: /* @__PURE__ */ __name((stmt) => db2.branch(parseBranch(stmt)), "Branch"),
476
- Merge: /* @__PURE__ */ __name((stmt) => db2.merge(parseMerge(stmt)), "Merge"),
477
- Checkout: /* @__PURE__ */ __name((stmt) => db2.checkout(parseCheckout(stmt)), "Checkout"),
478
- CherryPicking: /* @__PURE__ */ __name((stmt) => db2.cherryPick(parseCherryPicking(stmt)), "CherryPicking")
479
- };
480
- const parser2 = parsers[statement.$type];
481
- if (parser2) {
482
- parser2(statement);
483
- } else {
484
- log.error(`Unknown statement type: ${statement.$type}`);
485
- }
486
- }, "parseStatement");
487
- var parseCommit = /* @__PURE__ */ __name((commit2) => {
488
- const commitDB = {
489
- id: commit2.id,
490
- msg: commit2.message ?? "",
491
- type: commit2.type !== void 0 ? commitType[commit2.type] : commitType.NORMAL,
492
- tags: commit2.tags ?? void 0
493
- };
494
- return commitDB;
495
- }, "parseCommit");
496
- var parseBranch = /* @__PURE__ */ __name((branch2) => {
497
- const branchDB = {
498
- name: branch2.name,
499
- order: branch2.order ?? 0
500
- };
501
- return branchDB;
502
- }, "parseBranch");
503
- var parseMerge = /* @__PURE__ */ __name((merge2) => {
504
- const mergeDB = {
505
- branch: merge2.branch,
506
- id: merge2.id ?? "",
507
- type: merge2.type !== void 0 ? commitType[merge2.type] : void 0,
508
- tags: merge2.tags ?? void 0
509
- };
510
- return mergeDB;
511
- }, "parseMerge");
512
- var parseCheckout = /* @__PURE__ */ __name((checkout2) => {
513
- const branch2 = checkout2.branch;
514
- return branch2;
515
- }, "parseCheckout");
516
- var parseCherryPicking = /* @__PURE__ */ __name((cherryPicking) => {
517
- const cherryPickDB = {
518
- id: cherryPicking.id,
519
- targetId: "",
520
- tags: cherryPicking.tags?.length === 0 ? void 0 : cherryPicking.tags,
521
- parent: cherryPicking.parent
522
- };
523
- return cherryPickDB;
524
- }, "parseCherryPicking");
525
- var parser = {
526
- parse: /* @__PURE__ */ __name(async (input) => {
527
- const ast = await parse("gitGraph", input);
528
- log.debug(ast);
529
- populate(ast, db);
530
- }, "parse")
531
- };
532
- var DEFAULT_CONFIG = getConfig2();
533
- var DEFAULT_GITGRAPH_CONFIG2 = DEFAULT_CONFIG?.gitGraph;
534
- var LAYOUT_OFFSET = 10;
535
- var COMMIT_STEP = 40;
536
- var PX = 4;
537
- var PY = 2;
538
- var THEME_COLOR_LIMIT = 8;
539
- var branchPos = /* @__PURE__ */ new Map();
540
- var commitPos = /* @__PURE__ */ new Map();
541
- var defaultPos = 30;
542
- var allCommitsDict = /* @__PURE__ */ new Map();
543
- var lanes = [];
544
- var maxPos = 0;
545
- var dir = "LR";
546
- var clear3 = /* @__PURE__ */ __name(() => {
547
- branchPos.clear();
548
- commitPos.clear();
549
- allCommitsDict.clear();
550
- maxPos = 0;
551
- lanes = [];
552
- dir = "LR";
553
- }, "clear");
554
- var drawText = /* @__PURE__ */ __name((txt) => {
555
- const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text");
556
- const rows = typeof txt === "string" ? txt.split(/\\n|\n|<br\s*\/?>/gi) : txt;
557
- rows.forEach((row) => {
558
- const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
559
- tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
560
- tspan.setAttribute("dy", "1em");
561
- tspan.setAttribute("x", "0");
562
- tspan.setAttribute("class", "row");
563
- tspan.textContent = row.trim();
564
- svgLabel.appendChild(tspan);
565
- });
566
- return svgLabel;
567
- }, "drawText");
568
- var findClosestParent = /* @__PURE__ */ __name((parents) => {
569
- let closestParent;
570
- let comparisonFunc;
571
- let targetPosition;
572
- if (dir === "BT") {
573
- comparisonFunc = /* @__PURE__ */ __name((a, b) => a <= b, "comparisonFunc");
574
- targetPosition = Infinity;
575
- } else {
576
- comparisonFunc = /* @__PURE__ */ __name((a, b) => a >= b, "comparisonFunc");
577
- targetPosition = 0;
578
- }
579
- parents.forEach((parent) => {
580
- const parentPosition = dir === "TB" || dir == "BT" ? commitPos.get(parent)?.y : commitPos.get(parent)?.x;
581
- if (parentPosition !== void 0 && comparisonFunc(parentPosition, targetPosition)) {
582
- closestParent = parent;
583
- targetPosition = parentPosition;
584
- }
585
- });
586
- return closestParent;
587
- }, "findClosestParent");
588
- var findClosestParentBT = /* @__PURE__ */ __name((parents) => {
589
- let closestParent = "";
590
- let maxPosition = Infinity;
591
- parents.forEach((parent) => {
592
- const parentPosition = commitPos.get(parent).y;
593
- if (parentPosition <= maxPosition) {
594
- closestParent = parent;
595
- maxPosition = parentPosition;
596
- }
597
- });
598
- return closestParent || void 0;
599
- }, "findClosestParentBT");
600
- var setParallelBTPos = /* @__PURE__ */ __name((sortedKeys, commits, defaultPos2) => {
601
- let curPos = defaultPos2;
602
- let maxPosition = defaultPos2;
603
- const roots = [];
604
- sortedKeys.forEach((key) => {
605
- const commit2 = commits.get(key);
606
- if (!commit2) {
607
- throw new Error(`Commit not found for key ${key}`);
608
- }
609
- if (commit2.parents.length) {
610
- curPos = calculateCommitPosition(commit2);
611
- maxPosition = Math.max(curPos, maxPosition);
612
- } else {
613
- roots.push(commit2);
614
- }
615
- setCommitPosition(commit2, curPos);
616
- });
617
- curPos = maxPosition;
618
- roots.forEach((commit2) => {
619
- setRootPosition(commit2, curPos, defaultPos2);
620
- });
621
- sortedKeys.forEach((key) => {
622
- const commit2 = commits.get(key);
623
- if (commit2?.parents.length) {
624
- const closestParent = findClosestParentBT(commit2.parents);
625
- curPos = commitPos.get(closestParent).y - COMMIT_STEP;
626
- if (curPos <= maxPosition) {
627
- maxPosition = curPos;
628
- }
629
- const x = branchPos.get(commit2.branch).pos;
630
- const y = curPos - LAYOUT_OFFSET;
631
- commitPos.set(commit2.id, { x, y });
632
- }
633
- });
634
- }, "setParallelBTPos");
635
- var findClosestParentPos = /* @__PURE__ */ __name((commit2) => {
636
- const closestParent = findClosestParent(commit2.parents.filter((p) => p !== null));
637
- if (!closestParent) {
638
- throw new Error(`Closest parent not found for commit ${commit2.id}`);
639
- }
640
- const closestParentPos = commitPos.get(closestParent)?.y;
641
- if (closestParentPos === void 0) {
642
- throw new Error(`Closest parent position not found for commit ${commit2.id}`);
643
- }
644
- return closestParentPos;
645
- }, "findClosestParentPos");
646
- var calculateCommitPosition = /* @__PURE__ */ __name((commit2) => {
647
- const closestParentPos = findClosestParentPos(commit2);
648
- return closestParentPos + COMMIT_STEP;
649
- }, "calculateCommitPosition");
650
- var setCommitPosition = /* @__PURE__ */ __name((commit2, curPos) => {
651
- const branch2 = branchPos.get(commit2.branch);
652
- if (!branch2) {
653
- throw new Error(`Branch not found for commit ${commit2.id}`);
654
- }
655
- const x = branch2.pos;
656
- const y = curPos + LAYOUT_OFFSET;
657
- commitPos.set(commit2.id, { x, y });
658
- return { x, y };
659
- }, "setCommitPosition");
660
- var setRootPosition = /* @__PURE__ */ __name((commit2, curPos, defaultPos2) => {
661
- const branch2 = branchPos.get(commit2.branch);
662
- if (!branch2) {
663
- throw new Error(`Branch not found for commit ${commit2.id}`);
664
- }
665
- const y = curPos + defaultPos2;
666
- const x = branch2.pos;
667
- commitPos.set(commit2.id, { x, y });
668
- }, "setRootPosition");
669
- var drawCommitBullet = /* @__PURE__ */ __name((gBullets, commit2, commitPosition, typeClass, branchIndex, commitSymbolType) => {
670
- if (commitSymbolType === commitType.HIGHLIGHT) {
671
- gBullets.append("rect").attr("x", commitPosition.x - 10).attr("y", commitPosition.y - 10).attr("width", 20).attr("height", 20).attr(
672
- "class",
673
- `commit ${commit2.id} commit-highlight${branchIndex % THEME_COLOR_LIMIT} ${typeClass}-outer`
674
- );
675
- gBullets.append("rect").attr("x", commitPosition.x - 6).attr("y", commitPosition.y - 6).attr("width", 12).attr("height", 12).attr(
676
- "class",
677
- `commit ${commit2.id} commit${branchIndex % THEME_COLOR_LIMIT} ${typeClass}-inner`
678
- );
679
- } else if (commitSymbolType === commitType.CHERRY_PICK) {
680
- gBullets.append("circle").attr("cx", commitPosition.x).attr("cy", commitPosition.y).attr("r", 10).attr("class", `commit ${commit2.id} ${typeClass}`);
681
- gBullets.append("circle").attr("cx", commitPosition.x - 3).attr("cy", commitPosition.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
682
- gBullets.append("circle").attr("cx", commitPosition.x + 3).attr("cy", commitPosition.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
683
- gBullets.append("line").attr("x1", commitPosition.x + 3).attr("y1", commitPosition.y + 1).attr("x2", commitPosition.x).attr("y2", commitPosition.y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
684
- gBullets.append("line").attr("x1", commitPosition.x - 3).attr("y1", commitPosition.y + 1).attr("x2", commitPosition.x).attr("y2", commitPosition.y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
685
- } else {
686
- const circle = gBullets.append("circle");
687
- circle.attr("cx", commitPosition.x);
688
- circle.attr("cy", commitPosition.y);
689
- circle.attr("r", commit2.type === commitType.MERGE ? 9 : 10);
690
- circle.attr("class", `commit ${commit2.id} commit${branchIndex % THEME_COLOR_LIMIT}`);
691
- if (commitSymbolType === commitType.MERGE) {
692
- const circle2 = gBullets.append("circle");
693
- circle2.attr("cx", commitPosition.x);
694
- circle2.attr("cy", commitPosition.y);
695
- circle2.attr("r", 6);
696
- circle2.attr(
697
- "class",
698
- `commit ${typeClass} ${commit2.id} commit${branchIndex % THEME_COLOR_LIMIT}`
699
- );
700
- }
701
- if (commitSymbolType === commitType.REVERSE) {
702
- const cross = gBullets.append("path");
703
- cross.attr(
704
- "d",
705
- `M ${commitPosition.x - 5},${commitPosition.y - 5}L${commitPosition.x + 5},${commitPosition.y + 5}M${commitPosition.x - 5},${commitPosition.y + 5}L${commitPosition.x + 5},${commitPosition.y - 5}`
706
- ).attr("class", `commit ${typeClass} ${commit2.id} commit${branchIndex % THEME_COLOR_LIMIT}`);
707
- }
708
- }
709
- }, "drawCommitBullet");
710
- var drawCommitLabel = /* @__PURE__ */ __name((gLabels, commit2, commitPosition, pos) => {
711
- if (commit2.type !== commitType.CHERRY_PICK && (commit2.customId && commit2.type === commitType.MERGE || commit2.type !== commitType.MERGE) && DEFAULT_GITGRAPH_CONFIG2?.showCommitLabel) {
712
- const wrapper = gLabels.append("g");
713
- const labelBkg = wrapper.insert("rect").attr("class", "commit-label-bkg");
714
- const text = wrapper.append("text").attr("x", pos).attr("y", commitPosition.y + 25).attr("class", "commit-label").text(commit2.id);
715
- const bbox = text.node()?.getBBox();
716
- if (bbox) {
717
- labelBkg.attr("x", commitPosition.posWithOffset - bbox.width / 2 - PY).attr("y", commitPosition.y + 13.5).attr("width", bbox.width + 2 * PY).attr("height", bbox.height + 2 * PY);
718
- if (dir === "TB" || dir === "BT") {
719
- labelBkg.attr("x", commitPosition.x - (bbox.width + 4 * PX + 5)).attr("y", commitPosition.y - 12);
720
- text.attr("x", commitPosition.x - (bbox.width + 4 * PX)).attr("y", commitPosition.y + bbox.height - 12);
721
- } else {
722
- text.attr("x", commitPosition.posWithOffset - bbox.width / 2);
723
- }
724
- if (DEFAULT_GITGRAPH_CONFIG2.rotateCommitLabel) {
725
- if (dir === "TB" || dir === "BT") {
726
- text.attr(
727
- "transform",
728
- "rotate(-45, " + commitPosition.x + ", " + commitPosition.y + ")"
729
- );
730
- labelBkg.attr(
731
- "transform",
732
- "rotate(-45, " + commitPosition.x + ", " + commitPosition.y + ")"
733
- );
734
- } else {
735
- const r_x = -7.5 - (bbox.width + 10) / 25 * 9.5;
736
- const r_y = 10 + bbox.width / 25 * 8.5;
737
- wrapper.attr(
738
- "transform",
739
- "translate(" + r_x + ", " + r_y + ") rotate(-45, " + pos + ", " + commitPosition.y + ")"
740
- );
741
- }
742
- }
743
- }
744
- }
745
- }, "drawCommitLabel");
746
- var drawCommitTags = /* @__PURE__ */ __name((gLabels, commit2, commitPosition, pos) => {
747
- if (commit2.tags.length > 0) {
748
- let yOffset = 0;
749
- let maxTagBboxWidth = 0;
750
- let maxTagBboxHeight = 0;
751
- const tagElements = [];
752
- for (const tagValue of commit2.tags.reverse()) {
753
- const rect = gLabels.insert("polygon");
754
- const hole = gLabels.append("circle");
755
- const tag = gLabels.append("text").attr("y", commitPosition.y - 16 - yOffset).attr("class", "tag-label").text(tagValue);
756
- const tagBbox = tag.node()?.getBBox();
757
- if (!tagBbox) {
758
- throw new Error("Tag bbox not found");
759
- }
760
- maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width);
761
- maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height);
762
- tag.attr("x", commitPosition.posWithOffset - tagBbox.width / 2);
763
- tagElements.push({
764
- tag,
765
- hole,
766
- rect,
767
- yOffset
768
- });
769
- yOffset += 20;
770
- }
771
- for (const { tag, hole, rect, yOffset: yOffset2 } of tagElements) {
772
- const h2 = maxTagBboxHeight / 2;
773
- const ly = commitPosition.y - 19.2 - yOffset2;
774
- rect.attr("class", "tag-label-bkg").attr(
775
- "points",
776
- `
777
- ${pos - maxTagBboxWidth / 2 - PX / 2},${ly + PY}
778
- ${pos - maxTagBboxWidth / 2 - PX / 2},${ly - PY}
779
- ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - PX},${ly - h2 - PY}
780
- ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + PX},${ly - h2 - PY}
781
- ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + PX},${ly + h2 + PY}
782
- ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - PX},${ly + h2 + PY}`
783
- );
784
- hole.attr("cy", ly).attr("cx", pos - maxTagBboxWidth / 2 + PX / 2).attr("r", 1.5).attr("class", "tag-hole");
785
- if (dir === "TB" || dir === "BT") {
786
- const yOrigin = pos + yOffset2;
787
- rect.attr("class", "tag-label-bkg").attr(
788
- "points",
789
- `
790
- ${commitPosition.x},${yOrigin + 2}
791
- ${commitPosition.x},${yOrigin - 2}
792
- ${commitPosition.x + LAYOUT_OFFSET},${yOrigin - h2 - 2}
793
- ${commitPosition.x + LAYOUT_OFFSET + maxTagBboxWidth + 4},${yOrigin - h2 - 2}
794
- ${commitPosition.x + LAYOUT_OFFSET + maxTagBboxWidth + 4},${yOrigin + h2 + 2}
795
- ${commitPosition.x + LAYOUT_OFFSET},${yOrigin + h2 + 2}`
796
- ).attr("transform", "translate(12,12) rotate(45, " + commitPosition.x + "," + pos + ")");
797
- hole.attr("cx", commitPosition.x + PX / 2).attr("cy", yOrigin).attr("transform", "translate(12,12) rotate(45, " + commitPosition.x + "," + pos + ")");
798
- tag.attr("x", commitPosition.x + 5).attr("y", yOrigin + 3).attr("transform", "translate(14,14) rotate(45, " + commitPosition.x + "," + pos + ")");
799
- }
800
- }
801
- }
802
- }, "drawCommitTags");
803
- var getCommitClassType = /* @__PURE__ */ __name((commit2) => {
804
- const commitSymbolType = commit2.customType ?? commit2.type;
805
- switch (commitSymbolType) {
806
- case commitType.NORMAL:
807
- return "commit-normal";
808
- case commitType.REVERSE:
809
- return "commit-reverse";
810
- case commitType.HIGHLIGHT:
811
- return "commit-highlight";
812
- case commitType.MERGE:
813
- return "commit-merge";
814
- case commitType.CHERRY_PICK:
815
- return "commit-cherry-pick";
816
- default:
817
- return "commit-normal";
818
- }
819
- }, "getCommitClassType");
820
- var calculatePosition = /* @__PURE__ */ __name((commit2, dir2, pos, commitPos2) => {
821
- const defaultCommitPosition = { x: 0, y: 0 };
822
- if (commit2.parents.length > 0) {
823
- const closestParent = findClosestParent(commit2.parents);
824
- if (closestParent) {
825
- const parentPosition = commitPos2.get(closestParent) ?? defaultCommitPosition;
826
- if (dir2 === "TB") {
827
- return parentPosition.y + COMMIT_STEP;
828
- } else if (dir2 === "BT") {
829
- const currentPosition = commitPos2.get(commit2.id) ?? defaultCommitPosition;
830
- return currentPosition.y - COMMIT_STEP;
831
- } else {
832
- return parentPosition.x + COMMIT_STEP;
833
- }
834
- }
835
- } else {
836
- if (dir2 === "TB") {
837
- return defaultPos;
838
- } else if (dir2 === "BT") {
839
- const currentPosition = commitPos2.get(commit2.id) ?? defaultCommitPosition;
840
- return currentPosition.y - COMMIT_STEP;
841
- } else {
842
- return 0;
843
- }
844
- }
845
- return 0;
846
- }, "calculatePosition");
847
- var getCommitPosition = /* @__PURE__ */ __name((commit2, pos, isParallelCommits) => {
848
- const posWithOffset = dir === "BT" && isParallelCommits ? pos : pos + LAYOUT_OFFSET;
849
- const y = dir === "TB" || dir === "BT" ? posWithOffset : branchPos.get(commit2.branch)?.pos;
850
- const x = dir === "TB" || dir === "BT" ? branchPos.get(commit2.branch)?.pos : posWithOffset;
851
- if (x === void 0 || y === void 0) {
852
- throw new Error(`Position were undefined for commit ${commit2.id}`);
853
- }
854
- return { x, y, posWithOffset };
855
- }, "getCommitPosition");
856
- var drawCommits = /* @__PURE__ */ __name((svg, commits, modifyGraph) => {
857
- if (!DEFAULT_GITGRAPH_CONFIG2) {
858
- throw new Error("GitGraph config not found");
859
- }
860
- const gBullets = svg.append("g").attr("class", "commit-bullets");
861
- const gLabels = svg.append("g").attr("class", "commit-labels");
862
- let pos = dir === "TB" || dir === "BT" ? defaultPos : 0;
863
- const keys = [...commits.keys()];
864
- const isParallelCommits = DEFAULT_GITGRAPH_CONFIG2?.parallelCommits ?? false;
865
- const sortKeys = /* @__PURE__ */ __name((a, b) => {
866
- const seqA = commits.get(a)?.seq;
867
- const seqB = commits.get(b)?.seq;
868
- return seqA !== void 0 && seqB !== void 0 ? seqA - seqB : 0;
869
- }, "sortKeys");
870
- let sortedKeys = keys.sort(sortKeys);
871
- if (dir === "BT") {
872
- if (isParallelCommits) {
873
- setParallelBTPos(sortedKeys, commits, pos);
874
- }
875
- sortedKeys = sortedKeys.reverse();
876
- }
877
- sortedKeys.forEach((key) => {
878
- const commit2 = commits.get(key);
879
- if (!commit2) {
880
- throw new Error(`Commit not found for key ${key}`);
881
- }
882
- if (isParallelCommits) {
883
- pos = calculatePosition(commit2, dir, pos, commitPos);
884
- }
885
- const commitPosition = getCommitPosition(commit2, pos, isParallelCommits);
886
- if (modifyGraph) {
887
- const typeClass = getCommitClassType(commit2);
888
- const commitSymbolType = commit2.customType ?? commit2.type;
889
- const branchIndex = branchPos.get(commit2.branch)?.index ?? 0;
890
- drawCommitBullet(gBullets, commit2, commitPosition, typeClass, branchIndex, commitSymbolType);
891
- drawCommitLabel(gLabels, commit2, commitPosition, pos);
892
- drawCommitTags(gLabels, commit2, commitPosition, pos);
893
- }
894
- if (dir === "TB" || dir === "BT") {
895
- commitPos.set(commit2.id, { x: commitPosition.x, y: commitPosition.posWithOffset });
896
- } else {
897
- commitPos.set(commit2.id, { x: commitPosition.posWithOffset, y: commitPosition.y });
898
- }
899
- pos = dir === "BT" && isParallelCommits ? pos + COMMIT_STEP : pos + COMMIT_STEP + LAYOUT_OFFSET;
900
- if (pos > maxPos) {
901
- maxPos = pos;
902
- }
903
- });
904
- }, "drawCommits");
905
- var shouldRerouteArrow = /* @__PURE__ */ __name((commitA, commitB, p1, p2, allCommits) => {
906
- const commitBIsFurthest = dir === "TB" || dir === "BT" ? p1.x < p2.x : p1.y < p2.y;
907
- const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch;
908
- const isOnBranchToGetCurve = /* @__PURE__ */ __name((x) => x.branch === branchToGetCurve, "isOnBranchToGetCurve");
909
- const isBetweenCommits = /* @__PURE__ */ __name((x) => x.seq > commitA.seq && x.seq < commitB.seq, "isBetweenCommits");
910
- return [...allCommits.values()].some((commitX) => {
911
- return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX);
912
- });
913
- }, "shouldRerouteArrow");
914
- var findLane = /* @__PURE__ */ __name((y1, y2, depth = 0) => {
915
- const candidate = y1 + Math.abs(y1 - y2) / 2;
916
- if (depth > 5) {
917
- return candidate;
918
- }
919
- const ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10);
920
- if (ok) {
921
- lanes.push(candidate);
922
- return candidate;
923
- }
924
- const diff = Math.abs(y1 - y2);
925
- return findLane(y1, y2 - diff / 5, depth + 1);
926
- }, "findLane");
927
- var drawArrow = /* @__PURE__ */ __name((svg, commitA, commitB, allCommits) => {
928
- const p1 = commitPos.get(commitA.id);
929
- const p2 = commitPos.get(commitB.id);
930
- if (p1 === void 0 || p2 === void 0) {
931
- throw new Error(`Commit positions not found for commits ${commitA.id} and ${commitB.id}`);
932
- }
933
- const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits);
934
- let arc = "";
935
- let arc2 = "";
936
- let radius = 0;
937
- let offset = 0;
938
- let colorClassNum = branchPos.get(commitB.branch)?.index;
939
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
940
- colorClassNum = branchPos.get(commitA.branch)?.index;
941
- }
942
- let lineDef;
943
- if (arrowNeedsRerouting) {
944
- arc = "A 10 10, 0, 0, 0,";
945
- arc2 = "A 10 10, 0, 0, 1,";
946
- radius = 10;
947
- offset = 10;
948
- const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y);
949
- const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x);
950
- if (dir === "TB") {
951
- if (p1.x < p2.x) {
952
- lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
953
- } else {
954
- colorClassNum = branchPos.get(commitA.branch)?.index;
955
- lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
956
- }
957
- } else if (dir === "BT") {
958
- if (p1.x < p2.x) {
959
- lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc2} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
960
- } else {
961
- colorClassNum = branchPos.get(commitA.branch)?.index;
962
- lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc2} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
963
- }
964
- } else {
965
- if (p1.y < p2.y) {
966
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`;
967
- } else {
968
- colorClassNum = branchPos.get(commitA.branch)?.index;
969
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`;
970
- }
971
- }
972
- } else {
973
- arc = "A 20 20, 0, 0, 0,";
974
- arc2 = "A 20 20, 0, 0, 1,";
975
- radius = 20;
976
- offset = 20;
977
- if (dir === "TB") {
978
- if (p1.x < p2.x) {
979
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
980
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
981
- } else {
982
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
983
- }
984
- }
985
- if (p1.x > p2.x) {
986
- arc = "A 20 20, 0, 0, 0,";
987
- arc2 = "A 20 20, 0, 0, 1,";
988
- radius = 20;
989
- offset = 20;
990
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
991
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`;
992
- } else {
993
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
994
- }
995
- }
996
- if (p1.x === p2.x) {
997
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
998
- }
999
- } else if (dir === "BT") {
1000
- if (p1.x < p2.x) {
1001
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1002
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1003
- } else {
1004
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
1005
- }
1006
- }
1007
- if (p1.x > p2.x) {
1008
- arc = "A 20 20, 0, 0, 0,";
1009
- arc2 = "A 20 20, 0, 0, 1,";
1010
- radius = 20;
1011
- offset = 20;
1012
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1013
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`;
1014
- } else {
1015
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
1016
- }
1017
- }
1018
- if (p1.x === p2.x) {
1019
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
1020
- }
1021
- } else {
1022
- if (p1.y < p2.y) {
1023
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1024
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
1025
- } else {
1026
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1027
- }
1028
- }
1029
- if (p1.y > p2.y) {
1030
- if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1031
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
1032
- } else {
1033
- lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1034
- }
1035
- }
1036
- if (p1.y === p2.y) {
1037
- lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
1038
- }
1039
- }
1040
- }
1041
- if (lineDef === void 0) {
1042
- throw new Error("Line definition not found");
1043
- }
1044
- svg.append("path").attr("d", lineDef).attr("class", "arrow arrow" + colorClassNum % THEME_COLOR_LIMIT);
1045
- }, "drawArrow");
1046
- var drawArrows = /* @__PURE__ */ __name((svg, commits) => {
1047
- const gArrows = svg.append("g").attr("class", "commit-arrows");
1048
- [...commits.keys()].forEach((key) => {
1049
- const commit2 = commits.get(key);
1050
- if (commit2.parents && commit2.parents.length > 0) {
1051
- commit2.parents.forEach((parent) => {
1052
- drawArrow(gArrows, commits.get(parent), commit2, commits);
1053
- });
1054
- }
1055
- });
1056
- }, "drawArrows");
1057
- var drawBranches = /* @__PURE__ */ __name((svg, branches) => {
1058
- const g = svg.append("g");
1059
- branches.forEach((branch2, index) => {
1060
- const adjustIndexForTheme = index % THEME_COLOR_LIMIT;
1061
- const pos = branchPos.get(branch2.name)?.pos;
1062
- if (pos === void 0) {
1063
- throw new Error(`Position not found for branch ${branch2.name}`);
1064
- }
1065
- const line = g.append("line");
1066
- line.attr("x1", 0);
1067
- line.attr("y1", pos);
1068
- line.attr("x2", maxPos);
1069
- line.attr("y2", pos);
1070
- line.attr("class", "branch branch" + adjustIndexForTheme);
1071
- if (dir === "TB") {
1072
- line.attr("y1", defaultPos);
1073
- line.attr("x1", pos);
1074
- line.attr("y2", maxPos);
1075
- line.attr("x2", pos);
1076
- } else if (dir === "BT") {
1077
- line.attr("y1", maxPos);
1078
- line.attr("x1", pos);
1079
- line.attr("y2", defaultPos);
1080
- line.attr("x2", pos);
1081
- }
1082
- lanes.push(pos);
1083
- const name = branch2.name;
1084
- const labelElement = drawText(name);
1085
- const bkg = g.insert("rect");
1086
- const branchLabel = g.insert("g").attr("class", "branchLabel");
1087
- const label = branchLabel.insert("g").attr("class", "label branch-label" + adjustIndexForTheme);
1088
- label.node().appendChild(labelElement);
1089
- const bbox = labelElement.getBBox();
1090
- bkg.attr("class", "branchLabelBkg label" + adjustIndexForTheme).attr("rx", 4).attr("ry", 4).attr("x", -bbox.width - 4 - (DEFAULT_GITGRAPH_CONFIG2?.rotateCommitLabel === true ? 30 : 0)).attr("y", -bbox.height / 2 + 8).attr("width", bbox.width + 18).attr("height", bbox.height + 4);
1091
- label.attr(
1092
- "transform",
1093
- "translate(" + (-bbox.width - 14 - (DEFAULT_GITGRAPH_CONFIG2?.rotateCommitLabel === true ? 30 : 0)) + ", " + (pos - bbox.height / 2 - 1) + ")"
1094
- );
1095
- if (dir === "TB") {
1096
- bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", 0);
1097
- label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", 0)");
1098
- } else if (dir === "BT") {
1099
- bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", maxPos);
1100
- label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", " + maxPos + ")");
1101
- } else {
1102
- bkg.attr("transform", "translate(-19, " + (pos - bbox.height / 2) + ")");
1103
- }
1104
- });
1105
- }, "drawBranches");
1106
- var setBranchPosition = /* @__PURE__ */ __name(function(name, pos, index, bbox, rotateCommitLabel) {
1107
- branchPos.set(name, { pos, index });
1108
- pos += 50 + (rotateCommitLabel ? 40 : 0) + (dir === "TB" || dir === "BT" ? bbox.width / 2 : 0);
1109
- return pos;
1110
- }, "setBranchPosition");
1111
- var draw = /* @__PURE__ */ __name(function(txt, id, ver, diagObj) {
1112
- clear3();
1113
- log.debug("in gitgraph renderer", txt + "\n", "id:", id, ver);
1114
- if (!DEFAULT_GITGRAPH_CONFIG2) {
1115
- throw new Error("GitGraph config not found");
1116
- }
1117
- const rotateCommitLabel = DEFAULT_GITGRAPH_CONFIG2.rotateCommitLabel ?? false;
1118
- const db2 = diagObj.db;
1119
- allCommitsDict = db2.getCommits();
1120
- const branches = db2.getBranchesAsObjArray();
1121
- dir = db2.getDirection();
1122
- const diagram2 = select_default(`[id="${id}"]`);
1123
- let pos = 0;
1124
- branches.forEach((branch2, index) => {
1125
- const labelElement = drawText(branch2.name);
1126
- const g = diagram2.append("g");
1127
- const branchLabel = g.insert("g").attr("class", "branchLabel");
1128
- const label = branchLabel.insert("g").attr("class", "label branch-label");
1129
- label.node()?.appendChild(labelElement);
1130
- const bbox = labelElement.getBBox();
1131
- pos = setBranchPosition(branch2.name, pos, index, bbox, rotateCommitLabel);
1132
- label.remove();
1133
- branchLabel.remove();
1134
- g.remove();
1135
- });
1136
- drawCommits(diagram2, allCommitsDict, false);
1137
- if (DEFAULT_GITGRAPH_CONFIG2.showBranches) {
1138
- drawBranches(diagram2, branches);
1139
- }
1140
- drawArrows(diagram2, allCommitsDict);
1141
- drawCommits(diagram2, allCommitsDict, true);
1142
- utils_default.insertTitle(
1143
- diagram2,
1144
- "gitTitleText",
1145
- DEFAULT_GITGRAPH_CONFIG2.titleTopMargin ?? 0,
1146
- db2.getDiagramTitle()
1147
- );
1148
- setupGraphViewbox2(
1149
- void 0,
1150
- diagram2,
1151
- DEFAULT_GITGRAPH_CONFIG2.diagramPadding,
1152
- DEFAULT_GITGRAPH_CONFIG2.useMaxWidth
1153
- );
1154
- }, "draw");
1155
- var gitGraphRenderer_default = {
1156
- draw
1157
- };
1158
- var getStyles = /* @__PURE__ */ __name((options) => `
1159
- .commit-id,
1160
- .commit-msg,
1161
- .branch-label {
1162
- fill: lightgrey;
1163
- color: lightgrey;
1164
- font-family: 'trebuchet ms', verdana, arial, sans-serif;
1165
- font-family: var(--mermaid-font-family);
1166
- }
1167
- ${[0, 1, 2, 3, 4, 5, 6, 7].map(
1168
- (i) => `
1169
- .branch-label${i} { fill: ${options["gitBranchLabel" + i]}; }
1170
- .commit${i} { stroke: ${options["git" + i]}; fill: ${options["git" + i]}; }
1171
- .commit-highlight${i} { stroke: ${options["gitInv" + i]}; fill: ${options["gitInv" + i]}; }
1172
- .label${i} { fill: ${options["git" + i]}; }
1173
- .arrow${i} { stroke: ${options["git" + i]}; }
1174
- `
1175
- ).join("\n")}
1176
-
1177
- .branch {
1178
- stroke-width: 1;
1179
- stroke: ${options.lineColor};
1180
- stroke-dasharray: 2;
1181
- }
1182
- .commit-label { font-size: ${options.commitLabelFontSize}; fill: ${options.commitLabelColor};}
1183
- .commit-label-bkg { font-size: ${options.commitLabelFontSize}; fill: ${options.commitLabelBackground}; opacity: 0.5; }
1184
- .tag-label { font-size: ${options.tagLabelFontSize}; fill: ${options.tagLabelColor};}
1185
- .tag-label-bkg { fill: ${options.tagLabelBackground}; stroke: ${options.tagLabelBorder}; }
1186
- .tag-hole { fill: ${options.textColor}; }
1187
-
1188
- .commit-merge {
1189
- stroke: ${options.primaryColor};
1190
- fill: ${options.primaryColor};
1191
- }
1192
- .commit-reverse {
1193
- stroke: ${options.primaryColor};
1194
- fill: ${options.primaryColor};
1195
- stroke-width: 3;
1196
- }
1197
- .commit-highlight-outer {
1198
- }
1199
- .commit-highlight-inner {
1200
- stroke: ${options.primaryColor};
1201
- fill: ${options.primaryColor};
1202
- }
1203
-
1204
- .arrow { stroke-width: 8; stroke-linecap: round; fill: none}
1205
- .gitTitleText {
1206
- text-anchor: middle;
1207
- font-size: 18px;
1208
- fill: ${options.textColor};
1209
- }
1210
- `, "getStyles");
1211
- var styles_default = getStyles;
1212
- var diagram = {
1213
- parser,
1214
- db,
1215
- renderer: gitGraphRenderer_default,
1216
- styles: styles_default
1217
- };
1218
-
1219
- export { diagram };
1220
- //# sourceMappingURL=gitGraphDiagram-NY62KEGX-RKN2CCAZ.mjs.map
1221
- //# sourceMappingURL=gitGraphDiagram-NY62KEGX-RKN2CCAZ.mjs.map