@infinilabs/ai-chat 0.0.0 → 0.0.2

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 (119) hide show
  1. package/README.md +310 -56
  2. package/dist/_baseUniq-BFn6cCm9.js +152 -0
  3. package/dist/_baseUniq-nfJyj2zU.cjs +151 -0
  4. package/dist/arc-BWSMkwk2.cjs +130 -0
  5. package/dist/arc-DODeX7B9.js +131 -0
  6. package/dist/architecture-U656AL7Q-B4C0nw6C.js +5 -0
  7. package/dist/architecture-U656AL7Q-CVURQXwt.cjs +5 -0
  8. package/dist/architectureDiagram-VXUJARFQ-2UbdzpNz.cjs +8681 -0
  9. package/dist/architectureDiagram-VXUJARFQ-NCVmzKuE.js +8681 -0
  10. package/dist/blockDiagram-VD42YOAC-B3yCPK1N.cjs +3606 -0
  11. package/dist/blockDiagram-VD42YOAC-C4FsmQfk.js +3606 -0
  12. package/dist/c4Diagram-YG6GDRKO-ATyoKzFV.js +2481 -0
  13. package/dist/c4Diagram-YG6GDRKO-COwVcHWj.cjs +2481 -0
  14. package/dist/channel-2Y73gsu9.cjs +6 -0
  15. package/dist/channel-oB8MffQV.js +7 -0
  16. package/dist/chunk-4BX2VUAB-C3diNHZw.cjs +15 -0
  17. package/dist/chunk-4BX2VUAB-sd2zFBFz.js +16 -0
  18. package/dist/chunk-55IACEB6-6ohTnYE3.js +13 -0
  19. package/dist/chunk-55IACEB6-T-CzlJke.cjs +12 -0
  20. package/dist/chunk-B4BG7PRW-B1zqG62l.cjs +1825 -0
  21. package/dist/chunk-B4BG7PRW-E1dti26Y.js +1826 -0
  22. package/dist/chunk-DI55MBZ5-Dk0kfYBV.cjs +1914 -0
  23. package/dist/chunk-DI55MBZ5-DpHw-vMw.js +1915 -0
  24. package/dist/chunk-FMBD7UC4-B1vXpasq.js +19 -0
  25. package/dist/chunk-FMBD7UC4-CShN9-qf.cjs +18 -0
  26. package/dist/chunk-QN33PNHL-Cw7FG91D.js +24 -0
  27. package/dist/chunk-QN33PNHL-DJi1fhak.cjs +23 -0
  28. package/dist/chunk-QZHKN3VN-BweiBR9P.js +17 -0
  29. package/dist/chunk-QZHKN3VN-DfUW_gDw.cjs +16 -0
  30. package/dist/chunk-TZMSLE5B-DY2Kbag4.cjs +107 -0
  31. package/dist/chunk-TZMSLE5B-ZQ2Esoix.js +108 -0
  32. package/dist/classDiagram-2ON5EDUG-D2tIbkjc.js +19 -0
  33. package/dist/classDiagram-2ON5EDUG-DRhRmkUb.cjs +19 -0
  34. package/dist/classDiagram-v2-WZHVMYZB-D2tIbkjc.js +19 -0
  35. package/dist/classDiagram-v2-WZHVMYZB-DRhRmkUb.cjs +19 -0
  36. package/dist/clone-BMkj3yun.cjs +7 -0
  37. package/dist/clone-ChHXIoR6.js +8 -0
  38. package/dist/cose-bilkent-S5V4N54A-BXnWH5Od.cjs +4942 -0
  39. package/dist/cose-bilkent-S5V4N54A-D15BmpCb.js +4942 -0
  40. package/dist/cytoscape.esm-BfvZ3QT_.js +30239 -0
  41. package/dist/cytoscape.esm-D8IBYQeQ.cjs +30238 -0
  42. package/dist/dagre-6UL2VRFP-DGQ6TW_g.cjs +693 -0
  43. package/dist/dagre-6UL2VRFP-WmhUYWg8.js +693 -0
  44. package/dist/defaultLocale-DVr69WTU.js +206 -0
  45. package/dist/defaultLocale-DwYGIg9G.cjs +203 -0
  46. package/dist/diagram-PSM6KHXK-DSfHBoUT.js +845 -0
  47. package/dist/diagram-PSM6KHXK-J4qyGeN7.cjs +845 -0
  48. package/dist/diagram-QEK2KX5R-D96wT5cH.cjs +300 -0
  49. package/dist/diagram-QEK2KX5R-I_nyexpY.js +300 -0
  50. package/dist/diagram-S2PKOQOG-BC_WyKEe.cjs +210 -0
  51. package/dist/diagram-S2PKOQOG-aooXSMNo.js +210 -0
  52. package/dist/erDiagram-Q2GNP2WA-DQ8Lquay.cjs +1158 -0
  53. package/dist/erDiagram-Q2GNP2WA-DWF8e6EL.js +1158 -0
  54. package/dist/flowDiagram-NV44I4VS-CM9c4F1o.js +2331 -0
  55. package/dist/flowDiagram-NV44I4VS-DpYNkyM2.cjs +2331 -0
  56. package/dist/ganttDiagram-JELNMOA3-CAsoD6rZ.js +3679 -0
  57. package/dist/ganttDiagram-JELNMOA3-DfKahpj4.cjs +3679 -0
  58. package/dist/gitGraph-F6HP7TQM-BX2fz4_i.js +5 -0
  59. package/dist/gitGraph-F6HP7TQM-DRkGg4T1.cjs +5 -0
  60. package/dist/gitGraphDiagram-NY62KEGX-PXpI94u6.js +1203 -0
  61. package/dist/gitGraphDiagram-NY62KEGX-YhnKpooH.cjs +1203 -0
  62. package/dist/graph-BvxpI7Xc.js +596 -0
  63. package/dist/graph-CI_TWBSn.cjs +595 -0
  64. package/dist/index-BctLGjTK.cjs +120500 -0
  65. package/dist/index-CjSgoo1P.js +120485 -0
  66. package/dist/index.cjs +19 -0
  67. package/dist/index.js +12 -19961
  68. package/dist/info-NVLQJR56-BGbTE7dw.cjs +5 -0
  69. package/dist/info-NVLQJR56-DRxIh-N8.js +5 -0
  70. package/dist/infoDiagram-WHAUD3N6-BB2Bnbnh.cjs +31 -0
  71. package/dist/infoDiagram-WHAUD3N6-D_RrgwxS.js +31 -0
  72. package/dist/init-DevvdK2U.cjs +15 -0
  73. package/dist/init-ZxktEp_H.js +16 -0
  74. package/dist/journeyDiagram-XKPGCS4Q-BJjXlMIj.js +1254 -0
  75. package/dist/journeyDiagram-XKPGCS4Q-BcBLsfI9.cjs +1254 -0
  76. package/dist/kanban-definition-3W4ZIXB7-0wwNBZ93.js +1047 -0
  77. package/dist/kanban-definition-3W4ZIXB7-CaY0q4j9.cjs +1047 -0
  78. package/dist/katex-BhpYeT3b.cjs +14523 -0
  79. package/dist/katex-ei8sH3Uy.js +14524 -0
  80. package/dist/layout-CcghncRv.js +2183 -0
  81. package/dist/layout-CvwzED_C.cjs +2182 -0
  82. package/dist/linear-CYow-mAK.cjs +339 -0
  83. package/dist/linear-D_gKQzVp.js +340 -0
  84. package/dist/mermaid-parser.core-CzmkR-3i.cjs +18703 -0
  85. package/dist/mermaid-parser.core-DCMDT-Cp.js +18704 -0
  86. package/dist/min-BBp7Smma.js +41 -0
  87. package/dist/min-Gu1I_bJ9.cjs +40 -0
  88. package/dist/mindmap-definition-VGOIOE7T-D16Pp1u5.cjs +1126 -0
  89. package/dist/mindmap-definition-VGOIOE7T-PjSLRtz4.js +1126 -0
  90. package/dist/ordinal-CxptdPJm.js +76 -0
  91. package/dist/ordinal-D7sQNqXZ.cjs +75 -0
  92. package/dist/packet-BFZMPI3H-BvdogPiS.js +5 -0
  93. package/dist/packet-BFZMPI3H-C7pOHUWY.cjs +5 -0
  94. package/dist/pie-7BOR55EZ-D-DxSHbP.cjs +5 -0
  95. package/dist/pie-7BOR55EZ-DEWJe4Xn.js +5 -0
  96. package/dist/pieDiagram-ADFJNKIX-CoDddKZl.js +237 -0
  97. package/dist/pieDiagram-ADFJNKIX-DjN4DU9l.cjs +237 -0
  98. package/dist/quadrantDiagram-AYHSOK5B-BZOg0JMm.js +1335 -0
  99. package/dist/quadrantDiagram-AYHSOK5B-DXjTSOL4.cjs +1335 -0
  100. package/dist/radar-NHE76QYJ-BrnDXy9q.cjs +5 -0
  101. package/dist/radar-NHE76QYJ-C2WmPmJ4.js +5 -0
  102. package/dist/requirementDiagram-UZGBJVZJ-CCW1O1xH.js +1161 -0
  103. package/dist/requirementDiagram-UZGBJVZJ-e5F3-dDI.cjs +1161 -0
  104. package/dist/sankeyDiagram-TZEHDZUN-BaGzCxTp.js +1193 -0
  105. package/dist/sankeyDiagram-TZEHDZUN-DtIvOvVI.cjs +1193 -0
  106. package/dist/sequenceDiagram-WL72ISMW-0vFhYnxn.cjs +3874 -0
  107. package/dist/sequenceDiagram-WL72ISMW-DL3B7U56.js +3874 -0
  108. package/dist/stateDiagram-FKZM4ZOC-CXW608BR.cjs +447 -0
  109. package/dist/stateDiagram-FKZM4ZOC-Ddw6HxPD.js +447 -0
  110. package/dist/stateDiagram-v2-4FDKWEC3-DZCkQKmp.js +19 -0
  111. package/dist/stateDiagram-v2-4FDKWEC3-DefWUbvq.cjs +19 -0
  112. package/dist/timeline-definition-IT6M3QCI-C3TfA9lE.cjs +1222 -0
  113. package/dist/timeline-definition-IT6M3QCI-DiS88lUo.js +1222 -0
  114. package/dist/treemap-KMMF4GRG-Bl-H6j2c.cjs +5 -0
  115. package/dist/treemap-KMMF4GRG-DGGr_R9A.js +5 -0
  116. package/dist/xychartDiagram-PRI3JC2R-BrOwRjfF.js +1886 -0
  117. package/dist/xychartDiagram-PRI3JC2R-CM06DttH.cjs +1886 -0
  118. package/package.json +22 -11
  119. package/dist/index.css +0 -1582
@@ -0,0 +1,1126 @@
1
+ var _a;
2
+ import { g as getDiagramElement } from "./chunk-55IACEB6-6ohTnYE3.js";
3
+ import { s as setupViewPortForSVG } from "./chunk-QN33PNHL-Cw7FG91D.js";
4
+ import { _ as __name, l as log, o as getRegisteredLayoutAlgorithm, r as render, F as defaultConfig_default, c as getConfig2, i as sanitizeText, aC as getUserDefinedConfig, W as isDark, X as lighten, Y as darken } from "./index-CjSgoo1P.js";
5
+ const byteToHex = [];
6
+ for (let i = 0; i < 256; ++i) {
7
+ byteToHex.push((i + 256).toString(16).slice(1));
8
+ }
9
+ function unsafeStringify(arr, offset = 0) {
10
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
11
+ }
12
+ let getRandomValues;
13
+ const rnds8 = new Uint8Array(16);
14
+ function rng() {
15
+ if (!getRandomValues) {
16
+ if (typeof crypto === "undefined" || !crypto.getRandomValues) {
17
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
18
+ }
19
+ getRandomValues = crypto.getRandomValues.bind(crypto);
20
+ }
21
+ return getRandomValues(rnds8);
22
+ }
23
+ const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
24
+ const native = { randomUUID };
25
+ function v4(options, buf, offset) {
26
+ if (native.randomUUID && true && !options) {
27
+ return native.randomUUID();
28
+ }
29
+ options = options || {};
30
+ const rnds = options.random ?? options.rng?.() ?? rng();
31
+ if (rnds.length < 16) {
32
+ throw new Error("Random bytes length must be >= 16");
33
+ }
34
+ rnds[6] = rnds[6] & 15 | 64;
35
+ rnds[8] = rnds[8] & 63 | 128;
36
+ return unsafeStringify(rnds);
37
+ }
38
+ var parser = (function() {
39
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
40
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
41
+ return o2;
42
+ }, "o"), $V0 = [1, 4], $V1 = [1, 13], $V2 = [1, 12], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 20], $V6 = [1, 19], $V7 = [6, 7, 8], $V8 = [1, 26], $V9 = [1, 24], $Va = [1, 25], $Vb = [6, 7, 11], $Vc = [1, 6, 13, 15, 16, 19, 22], $Vd = [1, 33], $Ve = [1, 34], $Vf = [1, 6, 7, 11, 13, 15, 16, 19, 22];
43
+ var parser2 = {
44
+ trace: /* @__PURE__ */ __name(function trace() {
45
+ }, "trace"),
46
+ yy: {},
47
+ symbols_: { "error": 2, "start": 3, "mindMap": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "MINDMAP": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "node": 14, "ICON": 15, "CLASS": 16, "nodeWithId": 17, "nodeWithoutId": 18, "NODE_DSTART": 19, "NODE_DESCR": 20, "NODE_DEND": 21, "NODE_ID": 22, "$accept": 0, "$end": 1 },
48
+ terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" },
49
+ productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]],
50
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
51
+ var $0 = $$.length - 1;
52
+ switch (yystate) {
53
+ case 6:
54
+ case 7:
55
+ return yy;
56
+ case 8:
57
+ yy.getLogger().trace("Stop NL ");
58
+ break;
59
+ case 9:
60
+ yy.getLogger().trace("Stop EOF ");
61
+ break;
62
+ case 11:
63
+ yy.getLogger().trace("Stop NL2 ");
64
+ break;
65
+ case 12:
66
+ yy.getLogger().trace("Stop EOF2 ");
67
+ break;
68
+ case 15:
69
+ yy.getLogger().info("Node: ", $$[$0].id);
70
+ yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type);
71
+ break;
72
+ case 16:
73
+ yy.getLogger().trace("Icon: ", $$[$0]);
74
+ yy.decorateNode({ icon: $$[$0] });
75
+ break;
76
+ case 17:
77
+ case 21:
78
+ yy.decorateNode({ class: $$[$0] });
79
+ break;
80
+ case 18:
81
+ yy.getLogger().trace("SPACELIST");
82
+ break;
83
+ case 19:
84
+ yy.getLogger().trace("Node: ", $$[$0].id);
85
+ yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type);
86
+ break;
87
+ case 20:
88
+ yy.decorateNode({ icon: $$[$0] });
89
+ break;
90
+ case 25:
91
+ yy.getLogger().trace("node found ..", $$[$0 - 2]);
92
+ this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) };
93
+ break;
94
+ case 26:
95
+ this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT };
96
+ break;
97
+ case 27:
98
+ yy.getLogger().trace("node found ..", $$[$0 - 3]);
99
+ this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) };
100
+ break;
101
+ }
102
+ }, "anonymous"),
103
+ table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($V7, [2, 3]), { 1: [2, 2] }, o($V7, [2, 4]), o($V7, [2, 5]), { 1: [2, 6], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V1, 9: 22, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V8, 7: $V9, 10: 23, 11: $Va }, o($Vb, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: $V5, 22: $V6 }), o($Vb, [2, 18]), o($Vb, [2, 19]), o($Vb, [2, 20]), o($Vb, [2, 21]), o($Vb, [2, 23]), o($Vb, [2, 24]), o($Vb, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: $V8, 7: $V9, 10: 32, 11: $Va }, { 1: [2, 7], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($Vc, [2, 14], { 7: $Vd, 11: $Ve }), o($Vf, [2, 8]), o($Vf, [2, 9]), o($Vf, [2, 10]), o($Vb, [2, 15]), o($Vb, [2, 16]), o($Vb, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, o($Vc, [2, 13], { 7: $Vd, 11: $Ve }), o($Vf, [2, 11]), o($Vf, [2, 12]), { 21: [1, 37] }, o($Vb, [2, 25]), o($Vb, [2, 27])],
104
+ defaultActions: { 2: [2, 1], 6: [2, 2] },
105
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
106
+ if (hash.recoverable) {
107
+ this.trace(str);
108
+ } else {
109
+ var error = new Error(str);
110
+ error.hash = hash;
111
+ throw error;
112
+ }
113
+ }, "parseError"),
114
+ parse: /* @__PURE__ */ __name(function parse(input) {
115
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
116
+ var args = lstack.slice.call(arguments, 1);
117
+ var lexer2 = Object.create(this.lexer);
118
+ var sharedState = { yy: {} };
119
+ for (var k in this.yy) {
120
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
121
+ sharedState.yy[k] = this.yy[k];
122
+ }
123
+ }
124
+ lexer2.setInput(input, sharedState.yy);
125
+ sharedState.yy.lexer = lexer2;
126
+ sharedState.yy.parser = this;
127
+ if (typeof lexer2.yylloc == "undefined") {
128
+ lexer2.yylloc = {};
129
+ }
130
+ var yyloc = lexer2.yylloc;
131
+ lstack.push(yyloc);
132
+ var ranges = lexer2.options && lexer2.options.ranges;
133
+ if (typeof sharedState.yy.parseError === "function") {
134
+ this.parseError = sharedState.yy.parseError;
135
+ } else {
136
+ this.parseError = Object.getPrototypeOf(this).parseError;
137
+ }
138
+ function popStack(n) {
139
+ stack.length = stack.length - 2 * n;
140
+ vstack.length = vstack.length - n;
141
+ lstack.length = lstack.length - n;
142
+ }
143
+ __name(popStack, "popStack");
144
+ function lex() {
145
+ var token;
146
+ token = tstack.pop() || lexer2.lex() || EOF;
147
+ if (typeof token !== "number") {
148
+ if (token instanceof Array) {
149
+ tstack = token;
150
+ token = tstack.pop();
151
+ }
152
+ token = self.symbols_[token] || token;
153
+ }
154
+ return token;
155
+ }
156
+ __name(lex, "lex");
157
+ var symbol, state, action, r, yyval = {}, p, len, newState, expected;
158
+ while (true) {
159
+ state = stack[stack.length - 1];
160
+ if (this.defaultActions[state]) {
161
+ action = this.defaultActions[state];
162
+ } else {
163
+ if (symbol === null || typeof symbol == "undefined") {
164
+ symbol = lex();
165
+ }
166
+ action = table[state] && table[state][symbol];
167
+ }
168
+ if (typeof action === "undefined" || !action.length || !action[0]) {
169
+ var errStr = "";
170
+ expected = [];
171
+ for (p in table[state]) {
172
+ if (this.terminals_[p] && p > TERROR) {
173
+ expected.push("'" + this.terminals_[p] + "'");
174
+ }
175
+ }
176
+ if (lexer2.showPosition) {
177
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
178
+ } else {
179
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
180
+ }
181
+ this.parseError(errStr, {
182
+ text: lexer2.match,
183
+ token: this.terminals_[symbol] || symbol,
184
+ line: lexer2.yylineno,
185
+ loc: yyloc,
186
+ expected
187
+ });
188
+ }
189
+ if (action[0] instanceof Array && action.length > 1) {
190
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
191
+ }
192
+ switch (action[0]) {
193
+ case 1:
194
+ stack.push(symbol);
195
+ vstack.push(lexer2.yytext);
196
+ lstack.push(lexer2.yylloc);
197
+ stack.push(action[1]);
198
+ symbol = null;
199
+ {
200
+ yyleng = lexer2.yyleng;
201
+ yytext = lexer2.yytext;
202
+ yylineno = lexer2.yylineno;
203
+ yyloc = lexer2.yylloc;
204
+ }
205
+ break;
206
+ case 2:
207
+ len = this.productions_[action[1]][1];
208
+ yyval.$ = vstack[vstack.length - len];
209
+ yyval._$ = {
210
+ first_line: lstack[lstack.length - (len || 1)].first_line,
211
+ last_line: lstack[lstack.length - 1].last_line,
212
+ first_column: lstack[lstack.length - (len || 1)].first_column,
213
+ last_column: lstack[lstack.length - 1].last_column
214
+ };
215
+ if (ranges) {
216
+ yyval._$.range = [
217
+ lstack[lstack.length - (len || 1)].range[0],
218
+ lstack[lstack.length - 1].range[1]
219
+ ];
220
+ }
221
+ r = this.performAction.apply(yyval, [
222
+ yytext,
223
+ yyleng,
224
+ yylineno,
225
+ sharedState.yy,
226
+ action[1],
227
+ vstack,
228
+ lstack
229
+ ].concat(args));
230
+ if (typeof r !== "undefined") {
231
+ return r;
232
+ }
233
+ if (len) {
234
+ stack = stack.slice(0, -1 * len * 2);
235
+ vstack = vstack.slice(0, -1 * len);
236
+ lstack = lstack.slice(0, -1 * len);
237
+ }
238
+ stack.push(this.productions_[action[1]][0]);
239
+ vstack.push(yyval.$);
240
+ lstack.push(yyval._$);
241
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
242
+ stack.push(newState);
243
+ break;
244
+ case 3:
245
+ return true;
246
+ }
247
+ }
248
+ return true;
249
+ }, "parse")
250
+ };
251
+ var lexer = /* @__PURE__ */ (function() {
252
+ var lexer2 = {
253
+ EOF: 1,
254
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
255
+ if (this.yy.parser) {
256
+ this.yy.parser.parseError(str, hash);
257
+ } else {
258
+ throw new Error(str);
259
+ }
260
+ }, "parseError"),
261
+ // resets the lexer, sets new input
262
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
263
+ this.yy = yy || this.yy || {};
264
+ this._input = input;
265
+ this._more = this._backtrack = this.done = false;
266
+ this.yylineno = this.yyleng = 0;
267
+ this.yytext = this.matched = this.match = "";
268
+ this.conditionStack = ["INITIAL"];
269
+ this.yylloc = {
270
+ first_line: 1,
271
+ first_column: 0,
272
+ last_line: 1,
273
+ last_column: 0
274
+ };
275
+ if (this.options.ranges) {
276
+ this.yylloc.range = [0, 0];
277
+ }
278
+ this.offset = 0;
279
+ return this;
280
+ }, "setInput"),
281
+ // consumes and returns one char from the input
282
+ input: /* @__PURE__ */ __name(function() {
283
+ var ch = this._input[0];
284
+ this.yytext += ch;
285
+ this.yyleng++;
286
+ this.offset++;
287
+ this.match += ch;
288
+ this.matched += ch;
289
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
290
+ if (lines) {
291
+ this.yylineno++;
292
+ this.yylloc.last_line++;
293
+ } else {
294
+ this.yylloc.last_column++;
295
+ }
296
+ if (this.options.ranges) {
297
+ this.yylloc.range[1]++;
298
+ }
299
+ this._input = this._input.slice(1);
300
+ return ch;
301
+ }, "input"),
302
+ // unshifts one char (or a string) into the input
303
+ unput: /* @__PURE__ */ __name(function(ch) {
304
+ var len = ch.length;
305
+ var lines = ch.split(/(?:\r\n?|\n)/g);
306
+ this._input = ch + this._input;
307
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
308
+ this.offset -= len;
309
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
310
+ this.match = this.match.substr(0, this.match.length - 1);
311
+ this.matched = this.matched.substr(0, this.matched.length - 1);
312
+ if (lines.length - 1) {
313
+ this.yylineno -= lines.length - 1;
314
+ }
315
+ var r = this.yylloc.range;
316
+ this.yylloc = {
317
+ first_line: this.yylloc.first_line,
318
+ last_line: this.yylineno + 1,
319
+ first_column: this.yylloc.first_column,
320
+ 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
321
+ };
322
+ if (this.options.ranges) {
323
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
324
+ }
325
+ this.yyleng = this.yytext.length;
326
+ return this;
327
+ }, "unput"),
328
+ // When called from action, caches matched text and appends it on next action
329
+ more: /* @__PURE__ */ __name(function() {
330
+ this._more = true;
331
+ return this;
332
+ }, "more"),
333
+ // 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.
334
+ reject: /* @__PURE__ */ __name(function() {
335
+ if (this.options.backtrack_lexer) {
336
+ this._backtrack = true;
337
+ } else {
338
+ 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(), {
339
+ text: "",
340
+ token: null,
341
+ line: this.yylineno
342
+ });
343
+ }
344
+ return this;
345
+ }, "reject"),
346
+ // retain first n characters of the match
347
+ less: /* @__PURE__ */ __name(function(n) {
348
+ this.unput(this.match.slice(n));
349
+ }, "less"),
350
+ // displays already matched input, i.e. for error messages
351
+ pastInput: /* @__PURE__ */ __name(function() {
352
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
353
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
354
+ }, "pastInput"),
355
+ // displays upcoming input, i.e. for error messages
356
+ upcomingInput: /* @__PURE__ */ __name(function() {
357
+ var next = this.match;
358
+ if (next.length < 20) {
359
+ next += this._input.substr(0, 20 - next.length);
360
+ }
361
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
362
+ }, "upcomingInput"),
363
+ // displays the character position where the lexing error occurred, i.e. for error messages
364
+ showPosition: /* @__PURE__ */ __name(function() {
365
+ var pre = this.pastInput();
366
+ var c = new Array(pre.length + 1).join("-");
367
+ return pre + this.upcomingInput() + "\n" + c + "^";
368
+ }, "showPosition"),
369
+ // test the lexed token: return FALSE when not a match, otherwise return token
370
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
371
+ var token, lines, backup;
372
+ if (this.options.backtrack_lexer) {
373
+ backup = {
374
+ yylineno: this.yylineno,
375
+ yylloc: {
376
+ first_line: this.yylloc.first_line,
377
+ last_line: this.last_line,
378
+ first_column: this.yylloc.first_column,
379
+ last_column: this.yylloc.last_column
380
+ },
381
+ yytext: this.yytext,
382
+ match: this.match,
383
+ matches: this.matches,
384
+ matched: this.matched,
385
+ yyleng: this.yyleng,
386
+ offset: this.offset,
387
+ _more: this._more,
388
+ _input: this._input,
389
+ yy: this.yy,
390
+ conditionStack: this.conditionStack.slice(0),
391
+ done: this.done
392
+ };
393
+ if (this.options.ranges) {
394
+ backup.yylloc.range = this.yylloc.range.slice(0);
395
+ }
396
+ }
397
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
398
+ if (lines) {
399
+ this.yylineno += lines.length;
400
+ }
401
+ this.yylloc = {
402
+ first_line: this.yylloc.last_line,
403
+ last_line: this.yylineno + 1,
404
+ first_column: this.yylloc.last_column,
405
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
406
+ };
407
+ this.yytext += match[0];
408
+ this.match += match[0];
409
+ this.matches = match;
410
+ this.yyleng = this.yytext.length;
411
+ if (this.options.ranges) {
412
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
413
+ }
414
+ this._more = false;
415
+ this._backtrack = false;
416
+ this._input = this._input.slice(match[0].length);
417
+ this.matched += match[0];
418
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
419
+ if (this.done && this._input) {
420
+ this.done = false;
421
+ }
422
+ if (token) {
423
+ return token;
424
+ } else if (this._backtrack) {
425
+ for (var k in backup) {
426
+ this[k] = backup[k];
427
+ }
428
+ return false;
429
+ }
430
+ return false;
431
+ }, "test_match"),
432
+ // return next match in input
433
+ next: /* @__PURE__ */ __name(function() {
434
+ if (this.done) {
435
+ return this.EOF;
436
+ }
437
+ if (!this._input) {
438
+ this.done = true;
439
+ }
440
+ var token, match, tempMatch, index;
441
+ if (!this._more) {
442
+ this.yytext = "";
443
+ this.match = "";
444
+ }
445
+ var rules = this._currentRules();
446
+ for (var i = 0; i < rules.length; i++) {
447
+ tempMatch = this._input.match(this.rules[rules[i]]);
448
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
449
+ match = tempMatch;
450
+ index = i;
451
+ if (this.options.backtrack_lexer) {
452
+ token = this.test_match(tempMatch, rules[i]);
453
+ if (token !== false) {
454
+ return token;
455
+ } else if (this._backtrack) {
456
+ match = false;
457
+ continue;
458
+ } else {
459
+ return false;
460
+ }
461
+ } else if (!this.options.flex) {
462
+ break;
463
+ }
464
+ }
465
+ }
466
+ if (match) {
467
+ token = this.test_match(match, rules[index]);
468
+ if (token !== false) {
469
+ return token;
470
+ }
471
+ return false;
472
+ }
473
+ if (this._input === "") {
474
+ return this.EOF;
475
+ } else {
476
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
477
+ text: "",
478
+ token: null,
479
+ line: this.yylineno
480
+ });
481
+ }
482
+ }, "next"),
483
+ // return next match that has a token
484
+ lex: /* @__PURE__ */ __name(function lex() {
485
+ var r = this.next();
486
+ if (r) {
487
+ return r;
488
+ } else {
489
+ return this.lex();
490
+ }
491
+ }, "lex"),
492
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
493
+ begin: /* @__PURE__ */ __name(function begin(condition) {
494
+ this.conditionStack.push(condition);
495
+ }, "begin"),
496
+ // pop the previously active lexer condition state off the condition stack
497
+ popState: /* @__PURE__ */ __name(function popState() {
498
+ var n = this.conditionStack.length - 1;
499
+ if (n > 0) {
500
+ return this.conditionStack.pop();
501
+ } else {
502
+ return this.conditionStack[0];
503
+ }
504
+ }, "popState"),
505
+ // produce the lexer rule set which is active for the currently active lexer condition state
506
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
507
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
508
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
509
+ } else {
510
+ return this.conditions["INITIAL"].rules;
511
+ }
512
+ }, "_currentRules"),
513
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
514
+ topState: /* @__PURE__ */ __name(function topState(n) {
515
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
516
+ if (n >= 0) {
517
+ return this.conditionStack[n];
518
+ } else {
519
+ return "INITIAL";
520
+ }
521
+ }, "topState"),
522
+ // alias for begin(condition)
523
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
524
+ this.begin(condition);
525
+ }, "pushState"),
526
+ // return the number of states currently on the stack
527
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
528
+ return this.conditionStack.length;
529
+ }, "stateStackSize"),
530
+ options: { "case-insensitive": true },
531
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
532
+ switch ($avoiding_name_collisions) {
533
+ case 0:
534
+ yy.getLogger().trace("Found comment", yy_.yytext);
535
+ return 6;
536
+ case 1:
537
+ return 8;
538
+ case 2:
539
+ this.begin("CLASS");
540
+ break;
541
+ case 3:
542
+ this.popState();
543
+ return 16;
544
+ case 4:
545
+ this.popState();
546
+ break;
547
+ case 5:
548
+ yy.getLogger().trace("Begin icon");
549
+ this.begin("ICON");
550
+ break;
551
+ case 6:
552
+ yy.getLogger().trace("SPACELINE");
553
+ return 6;
554
+ case 7:
555
+ return 7;
556
+ case 8:
557
+ return 15;
558
+ case 9:
559
+ yy.getLogger().trace("end icon");
560
+ this.popState();
561
+ break;
562
+ case 10:
563
+ yy.getLogger().trace("Exploding node");
564
+ this.begin("NODE");
565
+ return 19;
566
+ case 11:
567
+ yy.getLogger().trace("Cloud");
568
+ this.begin("NODE");
569
+ return 19;
570
+ case 12:
571
+ yy.getLogger().trace("Explosion Bang");
572
+ this.begin("NODE");
573
+ return 19;
574
+ case 13:
575
+ yy.getLogger().trace("Cloud Bang");
576
+ this.begin("NODE");
577
+ return 19;
578
+ case 14:
579
+ this.begin("NODE");
580
+ return 19;
581
+ case 15:
582
+ this.begin("NODE");
583
+ return 19;
584
+ case 16:
585
+ this.begin("NODE");
586
+ return 19;
587
+ case 17:
588
+ this.begin("NODE");
589
+ return 19;
590
+ case 18:
591
+ return 13;
592
+ case 19:
593
+ return 22;
594
+ case 20:
595
+ return 11;
596
+ case 21:
597
+ this.begin("NSTR2");
598
+ break;
599
+ case 22:
600
+ return "NODE_DESCR";
601
+ case 23:
602
+ this.popState();
603
+ break;
604
+ case 24:
605
+ yy.getLogger().trace("Starting NSTR");
606
+ this.begin("NSTR");
607
+ break;
608
+ case 25:
609
+ yy.getLogger().trace("description:", yy_.yytext);
610
+ return "NODE_DESCR";
611
+ case 26:
612
+ this.popState();
613
+ break;
614
+ case 27:
615
+ this.popState();
616
+ yy.getLogger().trace("node end ))");
617
+ return "NODE_DEND";
618
+ case 28:
619
+ this.popState();
620
+ yy.getLogger().trace("node end )");
621
+ return "NODE_DEND";
622
+ case 29:
623
+ this.popState();
624
+ yy.getLogger().trace("node end ...", yy_.yytext);
625
+ return "NODE_DEND";
626
+ case 30:
627
+ this.popState();
628
+ yy.getLogger().trace("node end ((");
629
+ return "NODE_DEND";
630
+ case 31:
631
+ this.popState();
632
+ yy.getLogger().trace("node end (-");
633
+ return "NODE_DEND";
634
+ case 32:
635
+ this.popState();
636
+ yy.getLogger().trace("node end (-");
637
+ return "NODE_DEND";
638
+ case 33:
639
+ this.popState();
640
+ yy.getLogger().trace("node end ((");
641
+ return "NODE_DEND";
642
+ case 34:
643
+ this.popState();
644
+ yy.getLogger().trace("node end ((");
645
+ return "NODE_DEND";
646
+ case 35:
647
+ yy.getLogger().trace("Long description:", yy_.yytext);
648
+ return 20;
649
+ case 36:
650
+ yy.getLogger().trace("Long description:", yy_.yytext);
651
+ return 20;
652
+ }
653
+ }, "anonymous"),
654
+ rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i],
655
+ conditions: { "CLASS": { "rules": [3, 4], "inclusive": false }, "ICON": { "rules": [8, 9], "inclusive": false }, "NSTR2": { "rules": [22, 23], "inclusive": false }, "NSTR": { "rules": [25, 26], "inclusive": false }, "NODE": { "rules": [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "inclusive": true } }
656
+ };
657
+ return lexer2;
658
+ })();
659
+ parser2.lexer = lexer;
660
+ function Parser() {
661
+ this.yy = {};
662
+ }
663
+ __name(Parser, "Parser");
664
+ Parser.prototype = parser2;
665
+ parser2.Parser = Parser;
666
+ return new Parser();
667
+ })();
668
+ parser.parser = parser;
669
+ var mindmap_default = parser;
670
+ var nodeType = {
671
+ DEFAULT: 0,
672
+ NO_BORDER: 0,
673
+ ROUNDED_RECT: 1,
674
+ RECT: 2,
675
+ CIRCLE: 3,
676
+ CLOUD: 4,
677
+ BANG: 5,
678
+ HEXAGON: 6
679
+ };
680
+ var MindmapDB = (_a = class {
681
+ constructor() {
682
+ this.nodes = [];
683
+ this.count = 0;
684
+ this.elements = {};
685
+ this.getLogger = this.getLogger.bind(this);
686
+ this.nodeType = nodeType;
687
+ this.clear();
688
+ this.getType = this.getType.bind(this);
689
+ this.getElementById = this.getElementById.bind(this);
690
+ this.getParent = this.getParent.bind(this);
691
+ this.getMindmap = this.getMindmap.bind(this);
692
+ this.addNode = this.addNode.bind(this);
693
+ this.decorateNode = this.decorateNode.bind(this);
694
+ }
695
+ clear() {
696
+ this.nodes = [];
697
+ this.count = 0;
698
+ this.elements = {};
699
+ this.baseLevel = void 0;
700
+ }
701
+ getParent(level) {
702
+ for (let i = this.nodes.length - 1; i >= 0; i--) {
703
+ if (this.nodes[i].level < level) {
704
+ return this.nodes[i];
705
+ }
706
+ }
707
+ return null;
708
+ }
709
+ getMindmap() {
710
+ return this.nodes.length > 0 ? this.nodes[0] : null;
711
+ }
712
+ addNode(level, id, descr, type) {
713
+ log.info("addNode", level, id, descr, type);
714
+ let isRoot = false;
715
+ if (this.nodes.length === 0) {
716
+ this.baseLevel = level;
717
+ level = 0;
718
+ isRoot = true;
719
+ } else if (this.baseLevel !== void 0) {
720
+ level = level - this.baseLevel;
721
+ isRoot = false;
722
+ }
723
+ const conf = getConfig2();
724
+ let padding = conf.mindmap?.padding ?? defaultConfig_default.mindmap.padding;
725
+ switch (type) {
726
+ case this.nodeType.ROUNDED_RECT:
727
+ case this.nodeType.RECT:
728
+ case this.nodeType.HEXAGON:
729
+ padding *= 2;
730
+ break;
731
+ }
732
+ const node = {
733
+ id: this.count++,
734
+ nodeId: sanitizeText(id, conf),
735
+ level,
736
+ descr: sanitizeText(descr, conf),
737
+ type,
738
+ children: [],
739
+ width: conf.mindmap?.maxNodeWidth ?? defaultConfig_default.mindmap.maxNodeWidth,
740
+ padding,
741
+ isRoot
742
+ };
743
+ const parent = this.getParent(level);
744
+ if (parent) {
745
+ parent.children.push(node);
746
+ this.nodes.push(node);
747
+ } else {
748
+ if (isRoot) {
749
+ this.nodes.push(node);
750
+ } else {
751
+ throw new Error(
752
+ `There can be only one root. No parent could be found for ("${node.descr}")`
753
+ );
754
+ }
755
+ }
756
+ }
757
+ getType(startStr, endStr) {
758
+ log.debug("In get type", startStr, endStr);
759
+ switch (startStr) {
760
+ case "[":
761
+ return this.nodeType.RECT;
762
+ case "(":
763
+ return endStr === ")" ? this.nodeType.ROUNDED_RECT : this.nodeType.CLOUD;
764
+ case "((":
765
+ return this.nodeType.CIRCLE;
766
+ case ")":
767
+ return this.nodeType.CLOUD;
768
+ case "))":
769
+ return this.nodeType.BANG;
770
+ case "{{":
771
+ return this.nodeType.HEXAGON;
772
+ default:
773
+ return this.nodeType.DEFAULT;
774
+ }
775
+ }
776
+ setElementForId(id, element) {
777
+ this.elements[id] = element;
778
+ }
779
+ getElementById(id) {
780
+ return this.elements[id];
781
+ }
782
+ decorateNode(decoration) {
783
+ if (!decoration) {
784
+ return;
785
+ }
786
+ const config = getConfig2();
787
+ const node = this.nodes[this.nodes.length - 1];
788
+ if (decoration.icon) {
789
+ node.icon = sanitizeText(decoration.icon, config);
790
+ }
791
+ if (decoration.class) {
792
+ node.class = sanitizeText(decoration.class, config);
793
+ }
794
+ }
795
+ type2Str(type) {
796
+ switch (type) {
797
+ case this.nodeType.DEFAULT:
798
+ return "no-border";
799
+ case this.nodeType.RECT:
800
+ return "rect";
801
+ case this.nodeType.ROUNDED_RECT:
802
+ return "rounded-rect";
803
+ case this.nodeType.CIRCLE:
804
+ return "circle";
805
+ case this.nodeType.CLOUD:
806
+ return "cloud";
807
+ case this.nodeType.BANG:
808
+ return "bang";
809
+ case this.nodeType.HEXAGON:
810
+ return "hexgon";
811
+ // cspell: disable-line
812
+ default:
813
+ return "no-border";
814
+ }
815
+ }
816
+ /**
817
+ * Assign section numbers to nodes based on their position relative to root
818
+ * @param node - The mindmap node to process
819
+ * @param sectionNumber - The section number to assign (undefined for root)
820
+ */
821
+ assignSections(node, sectionNumber) {
822
+ if (node.level === 0) {
823
+ node.section = void 0;
824
+ } else {
825
+ node.section = sectionNumber;
826
+ }
827
+ if (node.children) {
828
+ for (const [index, child] of node.children.entries()) {
829
+ const childSectionNumber = node.level === 0 ? index : sectionNumber;
830
+ this.assignSections(child, childSectionNumber);
831
+ }
832
+ }
833
+ }
834
+ /**
835
+ * Convert mindmap tree structure to flat array of nodes
836
+ * @param node - The mindmap node to process
837
+ * @param processedNodes - Array to collect processed nodes
838
+ */
839
+ flattenNodes(node, processedNodes) {
840
+ const cssClasses = ["mindmap-node"];
841
+ if (node.isRoot === true) {
842
+ cssClasses.push("section-root", "section--1");
843
+ } else if (node.section !== void 0) {
844
+ cssClasses.push(`section-${node.section}`);
845
+ }
846
+ if (node.class) {
847
+ cssClasses.push(node.class);
848
+ }
849
+ const classes = cssClasses.join(" ");
850
+ const getShapeFromType = /* @__PURE__ */ __name((type) => {
851
+ switch (type) {
852
+ case nodeType.CIRCLE:
853
+ return "mindmapCircle";
854
+ case nodeType.RECT:
855
+ return "rect";
856
+ case nodeType.ROUNDED_RECT:
857
+ return "rounded";
858
+ case nodeType.CLOUD:
859
+ return "cloud";
860
+ case nodeType.BANG:
861
+ return "bang";
862
+ case nodeType.HEXAGON:
863
+ return "hexagon";
864
+ case nodeType.DEFAULT:
865
+ return "defaultMindmapNode";
866
+ case nodeType.NO_BORDER:
867
+ default:
868
+ return "rect";
869
+ }
870
+ }, "getShapeFromType");
871
+ const processedNode = {
872
+ id: node.id.toString(),
873
+ domId: "node_" + node.id.toString(),
874
+ label: node.descr,
875
+ isGroup: false,
876
+ shape: getShapeFromType(node.type),
877
+ width: node.width,
878
+ height: node.height ?? 0,
879
+ padding: node.padding,
880
+ cssClasses: classes,
881
+ cssStyles: [],
882
+ look: "default",
883
+ icon: node.icon,
884
+ x: node.x,
885
+ y: node.y,
886
+ // Mindmap-specific properties
887
+ level: node.level,
888
+ nodeId: node.nodeId,
889
+ type: node.type,
890
+ section: node.section
891
+ };
892
+ processedNodes.push(processedNode);
893
+ if (node.children) {
894
+ for (const child of node.children) {
895
+ this.flattenNodes(child, processedNodes);
896
+ }
897
+ }
898
+ }
899
+ /**
900
+ * Generate edges from parent-child relationships in mindmap tree
901
+ * @param node - The mindmap node to process
902
+ * @param edges - Array to collect edges
903
+ */
904
+ generateEdges(node, edges) {
905
+ if (!node.children) {
906
+ return;
907
+ }
908
+ for (const child of node.children) {
909
+ let edgeClasses = "edge";
910
+ if (child.section !== void 0) {
911
+ edgeClasses += ` section-edge-${child.section}`;
912
+ }
913
+ const edgeDepth = node.level + 1;
914
+ edgeClasses += ` edge-depth-${edgeDepth}`;
915
+ const edge = {
916
+ id: `edge_${node.id}_${child.id}`,
917
+ start: node.id.toString(),
918
+ end: child.id.toString(),
919
+ type: "normal",
920
+ curve: "basis",
921
+ thickness: "normal",
922
+ look: "default",
923
+ classes: edgeClasses,
924
+ // Store mindmap-specific data
925
+ depth: node.level,
926
+ section: child.section
927
+ };
928
+ edges.push(edge);
929
+ this.generateEdges(child, edges);
930
+ }
931
+ }
932
+ /**
933
+ * Get structured data for layout algorithms
934
+ * Following the pattern established by ER diagrams
935
+ * @returns Structured data containing nodes, edges, and config
936
+ */
937
+ getData() {
938
+ const mindmapRoot = this.getMindmap();
939
+ const config = getConfig2();
940
+ const userDefinedConfig = getUserDefinedConfig();
941
+ const hasUserDefinedLayout = userDefinedConfig.layout !== void 0;
942
+ const finalConfig = config;
943
+ if (!hasUserDefinedLayout) {
944
+ finalConfig.layout = "cose-bilkent";
945
+ }
946
+ if (!mindmapRoot) {
947
+ return {
948
+ nodes: [],
949
+ edges: [],
950
+ config: finalConfig
951
+ };
952
+ }
953
+ log.debug("getData: mindmapRoot", mindmapRoot, config);
954
+ this.assignSections(mindmapRoot);
955
+ const processedNodes = [];
956
+ const processedEdges = [];
957
+ this.flattenNodes(mindmapRoot, processedNodes);
958
+ this.generateEdges(mindmapRoot, processedEdges);
959
+ log.debug(
960
+ `getData: processed ${processedNodes.length} nodes and ${processedEdges.length} edges`
961
+ );
962
+ const shapes = /* @__PURE__ */ new Map();
963
+ for (const node of processedNodes) {
964
+ shapes.set(node.id, {
965
+ shape: node.shape,
966
+ width: node.width,
967
+ height: node.height,
968
+ padding: node.padding
969
+ });
970
+ }
971
+ return {
972
+ nodes: processedNodes,
973
+ edges: processedEdges,
974
+ config: finalConfig,
975
+ // Store the root node for mindmap-specific layout algorithms
976
+ rootNode: mindmapRoot,
977
+ // Properties required by dagre layout algorithm
978
+ markers: ["point"],
979
+ // Mindmaps don't use markers
980
+ direction: "TB",
981
+ // Top-to-bottom direction for mindmaps
982
+ nodeSpacing: 50,
983
+ // Default spacing between nodes
984
+ rankSpacing: 50,
985
+ // Default spacing between ranks
986
+ // Add shapes for ELK compatibility
987
+ shapes: Object.fromEntries(shapes),
988
+ // Additional properties that layout algorithms might expect
989
+ type: "mindmap",
990
+ diagramId: "mindmap-" + v4()
991
+ };
992
+ }
993
+ // Expose logger to grammar
994
+ getLogger() {
995
+ return log;
996
+ }
997
+ }, __name(_a, "MindmapDB"), _a);
998
+ var draw = /* @__PURE__ */ __name(async (text, id, _version, diagObj) => {
999
+ log.debug("Rendering mindmap diagram\n" + text);
1000
+ const db = diagObj.db;
1001
+ const data4Layout = db.getData();
1002
+ const svg = getDiagramElement(id, data4Layout.config.securityLevel);
1003
+ data4Layout.type = diagObj.type;
1004
+ data4Layout.layoutAlgorithm = getRegisteredLayoutAlgorithm(data4Layout.config.layout, {
1005
+ fallback: "cose-bilkent"
1006
+ });
1007
+ data4Layout.diagramId = id;
1008
+ const mm = db.getMindmap();
1009
+ if (!mm) {
1010
+ return;
1011
+ }
1012
+ data4Layout.nodes.forEach((node) => {
1013
+ if (node.shape === "rounded") {
1014
+ node.radius = 15;
1015
+ node.taper = 15;
1016
+ node.stroke = "none";
1017
+ node.width = 0;
1018
+ node.padding = 15;
1019
+ } else if (node.shape === "circle") {
1020
+ node.padding = 10;
1021
+ } else if (node.shape === "rect") {
1022
+ node.width = 0;
1023
+ node.padding = 10;
1024
+ }
1025
+ });
1026
+ await render(data4Layout, svg);
1027
+ setupViewPortForSVG(
1028
+ svg,
1029
+ data4Layout.config.mindmap?.padding ?? defaultConfig_default.mindmap.padding,
1030
+ "mindmapDiagram",
1031
+ data4Layout.config.mindmap?.useMaxWidth ?? defaultConfig_default.mindmap.useMaxWidth
1032
+ );
1033
+ }, "draw");
1034
+ var mindmapRenderer_default = {
1035
+ draw
1036
+ };
1037
+ var genSections = /* @__PURE__ */ __name((options) => {
1038
+ let sections = "";
1039
+ for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
1040
+ options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i];
1041
+ if (isDark(options["lineColor" + i])) {
1042
+ options["lineColor" + i] = lighten(options["lineColor" + i], 20);
1043
+ } else {
1044
+ options["lineColor" + i] = darken(options["lineColor" + i], 20);
1045
+ }
1046
+ }
1047
+ for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
1048
+ const sw = "" + (17 - 3 * i);
1049
+ sections += `
1050
+ .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path {
1051
+ fill: ${options["cScale" + i]};
1052
+ }
1053
+ .section-${i - 1} text {
1054
+ fill: ${options["cScaleLabel" + i]};
1055
+ }
1056
+ .node-icon-${i - 1} {
1057
+ font-size: 40px;
1058
+ color: ${options["cScaleLabel" + i]};
1059
+ }
1060
+ .section-edge-${i - 1}{
1061
+ stroke: ${options["cScale" + i]};
1062
+ }
1063
+ .edge-depth-${i - 1}{
1064
+ stroke-width: ${sw};
1065
+ }
1066
+ .section-${i - 1} line {
1067
+ stroke: ${options["cScaleInv" + i]} ;
1068
+ stroke-width: 3;
1069
+ }
1070
+
1071
+ .disabled, .disabled circle, .disabled text {
1072
+ fill: lightgray;
1073
+ }
1074
+ .disabled text {
1075
+ fill: #efefef;
1076
+ }
1077
+ `;
1078
+ }
1079
+ return sections;
1080
+ }, "genSections");
1081
+ var getStyles = /* @__PURE__ */ __name((options) => `
1082
+ .edge {
1083
+ stroke-width: 3;
1084
+ }
1085
+ ${genSections(options)}
1086
+ .section-root rect, .section-root path, .section-root circle, .section-root polygon {
1087
+ fill: ${options.git0};
1088
+ }
1089
+ .section-root text {
1090
+ fill: ${options.gitBranchLabel0};
1091
+ }
1092
+ .section-root span {
1093
+ color: ${options.gitBranchLabel0};
1094
+ }
1095
+ .section-2 span {
1096
+ color: ${options.gitBranchLabel0};
1097
+ }
1098
+ .icon-container {
1099
+ height:100%;
1100
+ display: flex;
1101
+ justify-content: center;
1102
+ align-items: center;
1103
+ }
1104
+ .edge {
1105
+ fill: none;
1106
+ }
1107
+ .mindmap-node-label {
1108
+ dy: 1em;
1109
+ alignment-baseline: middle;
1110
+ text-anchor: middle;
1111
+ dominant-baseline: middle;
1112
+ text-align: center;
1113
+ }
1114
+ `, "getStyles");
1115
+ var styles_default = getStyles;
1116
+ var diagram = {
1117
+ get db() {
1118
+ return new MindmapDB();
1119
+ },
1120
+ renderer: mindmapRenderer_default,
1121
+ parser: mindmap_default,
1122
+ styles: styles_default
1123
+ };
1124
+ export {
1125
+ diagram
1126
+ };