1 | import { l as log, c as getConfig, B as defaultConfig, d as sanitizeText, D as parseFontSize, A as selectSvgElement, o as setupGraphViewbox } from "./mermaid-6dc72991.js";
|
2 | import cytoscape from "cytoscape";
|
3 | import coseBilkent from "cytoscape-cose-bilkent";
|
4 | import { select } from "d3";
|
5 | import { a as createText } from "./createText-ca0c5216.js";
|
6 | import { isDark, lighten, darken } from "khroma";
|
7 | import "ts-dedent";
|
8 | import "dayjs";
|
9 | import "@braintree/sanitize-url";
|
10 | import "dompurify";
|
11 | import "lodash-es/memoize.js";
|
12 | import "lodash-es/merge.js";
|
13 | import "stylis";
|
14 | import "lodash-es/isEmpty.js";
|
15 | import "mdast-util-from-markdown";
|
16 | var parser = function() {
|
17 | var o = function(k, v, o2, l) {
|
18 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
19 | ;
|
20 | return o2;
|
21 | }, $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];
|
22 | var parser2 = {
|
23 | trace: function trace() {
|
24 | },
|
25 | yy: {},
|
26 | 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 },
|
27 | 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" },
|
28 | 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]],
|
29 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
30 | var $0 = $$.length - 1;
|
31 | switch (yystate) {
|
32 | case 6:
|
33 | case 7:
|
34 | return yy;
|
35 | case 8:
|
36 | yy.getLogger().trace("Stop NL ");
|
37 | break;
|
38 | case 9:
|
39 | yy.getLogger().trace("Stop EOF ");
|
40 | break;
|
41 | case 11:
|
42 | yy.getLogger().trace("Stop NL2 ");
|
43 | break;
|
44 | case 12:
|
45 | yy.getLogger().trace("Stop EOF2 ");
|
46 | break;
|
47 | case 15:
|
48 | yy.getLogger().info("Node: ", $$[$0].id);
|
49 | yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type);
|
50 | break;
|
51 | case 16:
|
52 | yy.getLogger().trace("Icon: ", $$[$0]);
|
53 | yy.decorateNode({ icon: $$[$0] });
|
54 | break;
|
55 | case 17:
|
56 | case 21:
|
57 | yy.decorateNode({ class: $$[$0] });
|
58 | break;
|
59 | case 18:
|
60 | yy.getLogger().trace("SPACELIST");
|
61 | break;
|
62 | case 19:
|
63 | yy.getLogger().trace("Node: ", $$[$0].id);
|
64 | yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type);
|
65 | break;
|
66 | case 20:
|
67 | yy.decorateNode({ icon: $$[$0] });
|
68 | break;
|
69 | case 25:
|
70 | yy.getLogger().trace("node found ..", $$[$0 - 2]);
|
71 | this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) };
|
72 | break;
|
73 | case 26:
|
74 | this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT };
|
75 | break;
|
76 | case 27:
|
77 | yy.getLogger().trace("node found ..", $$[$0 - 3]);
|
78 | this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) };
|
79 | break;
|
80 | }
|
81 | },
|
82 | 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])],
|
83 | defaultActions: { 2: [2, 1], 6: [2, 2] },
|
84 | parseError: function parseError(str, hash) {
|
85 | if (hash.recoverable) {
|
86 | this.trace(str);
|
87 | } else {
|
88 | var error = new Error(str);
|
89 | error.hash = hash;
|
90 | throw error;
|
91 | }
|
92 | },
|
93 | parse: function parse(input) {
|
94 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
95 | var args = lstack.slice.call(arguments, 1);
|
96 | var lexer2 = Object.create(this.lexer);
|
97 | var sharedState = { yy: {} };
|
98 | for (var k in this.yy) {
|
99 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
100 | sharedState.yy[k] = this.yy[k];
|
101 | }
|
102 | }
|
103 | lexer2.setInput(input, sharedState.yy);
|
104 | sharedState.yy.lexer = lexer2;
|
105 | sharedState.yy.parser = this;
|
106 | if (typeof lexer2.yylloc == "undefined") {
|
107 | lexer2.yylloc = {};
|
108 | }
|
109 | var yyloc = lexer2.yylloc;
|
110 | lstack.push(yyloc);
|
111 | var ranges = lexer2.options && lexer2.options.ranges;
|
112 | if (typeof sharedState.yy.parseError === "function") {
|
113 | this.parseError = sharedState.yy.parseError;
|
114 | } else {
|
115 | this.parseError = Object.getPrototypeOf(this).parseError;
|
116 | }
|
117 | function lex() {
|
118 | var token;
|
119 | token = tstack.pop() || lexer2.lex() || EOF;
|
120 | if (typeof token !== "number") {
|
121 | if (token instanceof Array) {
|
122 | tstack = token;
|
123 | token = tstack.pop();
|
124 | }
|
125 | token = self.symbols_[token] || token;
|
126 | }
|
127 | return token;
|
128 | }
|
129 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
130 | while (true) {
|
131 | state = stack[stack.length - 1];
|
132 | if (this.defaultActions[state]) {
|
133 | action = this.defaultActions[state];
|
134 | } else {
|
135 | if (symbol === null || typeof symbol == "undefined") {
|
136 | symbol = lex();
|
137 | }
|
138 | action = table[state] && table[state][symbol];
|
139 | }
|
140 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
141 | var errStr = "";
|
142 | expected = [];
|
143 | for (p in table[state]) {
|
144 | if (this.terminals_[p] && p > TERROR) {
|
145 | expected.push("'" + this.terminals_[p] + "'");
|
146 | }
|
147 | }
|
148 | if (lexer2.showPosition) {
|
149 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
150 | } else {
|
151 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
152 | }
|
153 | this.parseError(errStr, {
|
154 | text: lexer2.match,
|
155 | token: this.terminals_[symbol] || symbol,
|
156 | line: lexer2.yylineno,
|
157 | loc: yyloc,
|
158 | expected
|
159 | });
|
160 | }
|
161 | if (action[0] instanceof Array && action.length > 1) {
|
162 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
163 | }
|
164 | switch (action[0]) {
|
165 | case 1:
|
166 | stack.push(symbol);
|
167 | vstack.push(lexer2.yytext);
|
168 | lstack.push(lexer2.yylloc);
|
169 | stack.push(action[1]);
|
170 | symbol = null;
|
171 | {
|
172 | yyleng = lexer2.yyleng;
|
173 | yytext = lexer2.yytext;
|
174 | yylineno = lexer2.yylineno;
|
175 | yyloc = lexer2.yylloc;
|
176 | }
|
177 | break;
|
178 | case 2:
|
179 | len = this.productions_[action[1]][1];
|
180 | yyval.$ = vstack[vstack.length - len];
|
181 | yyval._$ = {
|
182 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
183 | last_line: lstack[lstack.length - 1].last_line,
|
184 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
185 | last_column: lstack[lstack.length - 1].last_column
|
186 | };
|
187 | if (ranges) {
|
188 | yyval._$.range = [
|
189 | lstack[lstack.length - (len || 1)].range[0],
|
190 | lstack[lstack.length - 1].range[1]
|
191 | ];
|
192 | }
|
193 | r = this.performAction.apply(yyval, [
|
194 | yytext,
|
195 | yyleng,
|
196 | yylineno,
|
197 | sharedState.yy,
|
198 | action[1],
|
199 | vstack,
|
200 | lstack
|
201 | ].concat(args));
|
202 | if (typeof r !== "undefined") {
|
203 | return r;
|
204 | }
|
205 | if (len) {
|
206 | stack = stack.slice(0, -1 * len * 2);
|
207 | vstack = vstack.slice(0, -1 * len);
|
208 | lstack = lstack.slice(0, -1 * len);
|
209 | }
|
210 | stack.push(this.productions_[action[1]][0]);
|
211 | vstack.push(yyval.$);
|
212 | lstack.push(yyval._$);
|
213 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
214 | stack.push(newState);
|
215 | break;
|
216 | case 3:
|
217 | return true;
|
218 | }
|
219 | }
|
220 | return true;
|
221 | }
|
222 | };
|
223 | var lexer = function() {
|
224 | var lexer2 = {
|
225 | EOF: 1,
|
226 | parseError: function parseError(str, hash) {
|
227 | if (this.yy.parser) {
|
228 | this.yy.parser.parseError(str, hash);
|
229 | } else {
|
230 | throw new Error(str);
|
231 | }
|
232 | },
|
233 |
|
234 | setInput: function(input, yy) {
|
235 | this.yy = yy || this.yy || {};
|
236 | this._input = input;
|
237 | this._more = this._backtrack = this.done = false;
|
238 | this.yylineno = this.yyleng = 0;
|
239 | this.yytext = this.matched = this.match = "";
|
240 | this.conditionStack = ["INITIAL"];
|
241 | this.yylloc = {
|
242 | first_line: 1,
|
243 | first_column: 0,
|
244 | last_line: 1,
|
245 | last_column: 0
|
246 | };
|
247 | if (this.options.ranges) {
|
248 | this.yylloc.range = [0, 0];
|
249 | }
|
250 | this.offset = 0;
|
251 | return this;
|
252 | },
|
253 |
|
254 | input: function() {
|
255 | var ch = this._input[0];
|
256 | this.yytext += ch;
|
257 | this.yyleng++;
|
258 | this.offset++;
|
259 | this.match += ch;
|
260 | this.matched += ch;
|
261 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
262 | if (lines) {
|
263 | this.yylineno++;
|
264 | this.yylloc.last_line++;
|
265 | } else {
|
266 | this.yylloc.last_column++;
|
267 | }
|
268 | if (this.options.ranges) {
|
269 | this.yylloc.range[1]++;
|
270 | }
|
271 | this._input = this._input.slice(1);
|
272 | return ch;
|
273 | },
|
274 |
|
275 | unput: function(ch) {
|
276 | var len = ch.length;
|
277 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
278 | this._input = ch + this._input;
|
279 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
280 | this.offset -= len;
|
281 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
282 | this.match = this.match.substr(0, this.match.length - 1);
|
283 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
284 | if (lines.length - 1) {
|
285 | this.yylineno -= lines.length - 1;
|
286 | }
|
287 | var r = this.yylloc.range;
|
288 | this.yylloc = {
|
289 | first_line: this.yylloc.first_line,
|
290 | last_line: this.yylineno + 1,
|
291 | first_column: this.yylloc.first_column,
|
292 | 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
|
293 | };
|
294 | if (this.options.ranges) {
|
295 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
296 | }
|
297 | this.yyleng = this.yytext.length;
|
298 | return this;
|
299 | },
|
300 |
|
301 | more: function() {
|
302 | this._more = true;
|
303 | return this;
|
304 | },
|
305 |
|
306 | reject: function() {
|
307 | if (this.options.backtrack_lexer) {
|
308 | this._backtrack = true;
|
309 | } else {
|
310 | 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(), {
|
311 | text: "",
|
312 | token: null,
|
313 | line: this.yylineno
|
314 | });
|
315 | }
|
316 | return this;
|
317 | },
|
318 |
|
319 | less: function(n) {
|
320 | this.unput(this.match.slice(n));
|
321 | },
|
322 |
|
323 | pastInput: function() {
|
324 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
325 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
326 | },
|
327 |
|
328 | upcomingInput: function() {
|
329 | var next = this.match;
|
330 | if (next.length < 20) {
|
331 | next += this._input.substr(0, 20 - next.length);
|
332 | }
|
333 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
334 | },
|
335 |
|
336 | showPosition: function() {
|
337 | var pre = this.pastInput();
|
338 | var c = new Array(pre.length + 1).join("-");
|
339 | return pre + this.upcomingInput() + "\n" + c + "^";
|
340 | },
|
341 |
|
342 | test_match: function(match, indexed_rule) {
|
343 | var token, lines, backup;
|
344 | if (this.options.backtrack_lexer) {
|
345 | backup = {
|
346 | yylineno: this.yylineno,
|
347 | yylloc: {
|
348 | first_line: this.yylloc.first_line,
|
349 | last_line: this.last_line,
|
350 | first_column: this.yylloc.first_column,
|
351 | last_column: this.yylloc.last_column
|
352 | },
|
353 | yytext: this.yytext,
|
354 | match: this.match,
|
355 | matches: this.matches,
|
356 | matched: this.matched,
|
357 | yyleng: this.yyleng,
|
358 | offset: this.offset,
|
359 | _more: this._more,
|
360 | _input: this._input,
|
361 | yy: this.yy,
|
362 | conditionStack: this.conditionStack.slice(0),
|
363 | done: this.done
|
364 | };
|
365 | if (this.options.ranges) {
|
366 | backup.yylloc.range = this.yylloc.range.slice(0);
|
367 | }
|
368 | }
|
369 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
370 | if (lines) {
|
371 | this.yylineno += lines.length;
|
372 | }
|
373 | this.yylloc = {
|
374 | first_line: this.yylloc.last_line,
|
375 | last_line: this.yylineno + 1,
|
376 | first_column: this.yylloc.last_column,
|
377 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
378 | };
|
379 | this.yytext += match[0];
|
380 | this.match += match[0];
|
381 | this.matches = match;
|
382 | this.yyleng = this.yytext.length;
|
383 | if (this.options.ranges) {
|
384 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
385 | }
|
386 | this._more = false;
|
387 | this._backtrack = false;
|
388 | this._input = this._input.slice(match[0].length);
|
389 | this.matched += match[0];
|
390 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
391 | if (this.done && this._input) {
|
392 | this.done = false;
|
393 | }
|
394 | if (token) {
|
395 | return token;
|
396 | } else if (this._backtrack) {
|
397 | for (var k in backup) {
|
398 | this[k] = backup[k];
|
399 | }
|
400 | return false;
|
401 | }
|
402 | return false;
|
403 | },
|
404 |
|
405 | next: function() {
|
406 | if (this.done) {
|
407 | return this.EOF;
|
408 | }
|
409 | if (!this._input) {
|
410 | this.done = true;
|
411 | }
|
412 | var token, match, tempMatch, index;
|
413 | if (!this._more) {
|
414 | this.yytext = "";
|
415 | this.match = "";
|
416 | }
|
417 | var rules = this._currentRules();
|
418 | for (var i = 0; i < rules.length; i++) {
|
419 | tempMatch = this._input.match(this.rules[rules[i]]);
|
420 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
421 | match = tempMatch;
|
422 | index = i;
|
423 | if (this.options.backtrack_lexer) {
|
424 | token = this.test_match(tempMatch, rules[i]);
|
425 | if (token !== false) {
|
426 | return token;
|
427 | } else if (this._backtrack) {
|
428 | match = false;
|
429 | continue;
|
430 | } else {
|
431 | return false;
|
432 | }
|
433 | } else if (!this.options.flex) {
|
434 | break;
|
435 | }
|
436 | }
|
437 | }
|
438 | if (match) {
|
439 | token = this.test_match(match, rules[index]);
|
440 | if (token !== false) {
|
441 | return token;
|
442 | }
|
443 | return false;
|
444 | }
|
445 | if (this._input === "") {
|
446 | return this.EOF;
|
447 | } else {
|
448 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
449 | text: "",
|
450 | token: null,
|
451 | line: this.yylineno
|
452 | });
|
453 | }
|
454 | },
|
455 |
|
456 | lex: function lex() {
|
457 | var r = this.next();
|
458 | if (r) {
|
459 | return r;
|
460 | } else {
|
461 | return this.lex();
|
462 | }
|
463 | },
|
464 |
|
465 | begin: function begin(condition) {
|
466 | this.conditionStack.push(condition);
|
467 | },
|
468 |
|
469 | popState: function popState() {
|
470 | var n = this.conditionStack.length - 1;
|
471 | if (n > 0) {
|
472 | return this.conditionStack.pop();
|
473 | } else {
|
474 | return this.conditionStack[0];
|
475 | }
|
476 | },
|
477 |
|
478 | _currentRules: function _currentRules() {
|
479 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
480 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
481 | } else {
|
482 | return this.conditions["INITIAL"].rules;
|
483 | }
|
484 | },
|
485 |
|
486 | topState: function topState(n) {
|
487 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
488 | if (n >= 0) {
|
489 | return this.conditionStack[n];
|
490 | } else {
|
491 | return "INITIAL";
|
492 | }
|
493 | },
|
494 |
|
495 | pushState: function pushState(condition) {
|
496 | this.begin(condition);
|
497 | },
|
498 |
|
499 | stateStackSize: function stateStackSize() {
|
500 | return this.conditionStack.length;
|
501 | },
|
502 | options: { "case-insensitive": true },
|
503 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
504 | switch ($avoiding_name_collisions) {
|
505 | case 0:
|
506 | yy.getLogger().trace("Found comment", yy_.yytext);
|
507 | return 6;
|
508 | case 1:
|
509 | return 8;
|
510 | case 2:
|
511 | this.begin("CLASS");
|
512 | break;
|
513 | case 3:
|
514 | this.popState();
|
515 | return 16;
|
516 | case 4:
|
517 | this.popState();
|
518 | break;
|
519 | case 5:
|
520 | yy.getLogger().trace("Begin icon");
|
521 | this.begin("ICON");
|
522 | break;
|
523 | case 6:
|
524 | yy.getLogger().trace("SPACELINE");
|
525 | return 6;
|
526 | case 7:
|
527 | return 7;
|
528 | case 8:
|
529 | return 15;
|
530 | case 9:
|
531 | yy.getLogger().trace("end icon");
|
532 | this.popState();
|
533 | break;
|
534 | case 10:
|
535 | yy.getLogger().trace("Exploding node");
|
536 | this.begin("NODE");
|
537 | return 19;
|
538 | case 11:
|
539 | yy.getLogger().trace("Cloud");
|
540 | this.begin("NODE");
|
541 | return 19;
|
542 | case 12:
|
543 | yy.getLogger().trace("Explosion Bang");
|
544 | this.begin("NODE");
|
545 | return 19;
|
546 | case 13:
|
547 | yy.getLogger().trace("Cloud Bang");
|
548 | this.begin("NODE");
|
549 | return 19;
|
550 | case 14:
|
551 | this.begin("NODE");
|
552 | return 19;
|
553 | case 15:
|
554 | this.begin("NODE");
|
555 | return 19;
|
556 | case 16:
|
557 | this.begin("NODE");
|
558 | return 19;
|
559 | case 17:
|
560 | this.begin("NODE");
|
561 | return 19;
|
562 | case 18:
|
563 | return 13;
|
564 | case 19:
|
565 | return 22;
|
566 | case 20:
|
567 | return 11;
|
568 | case 21:
|
569 | this.begin("NSTR2");
|
570 | break;
|
571 | case 22:
|
572 | return "NODE_DESCR";
|
573 | case 23:
|
574 | this.popState();
|
575 | break;
|
576 | case 24:
|
577 | yy.getLogger().trace("Starting NSTR");
|
578 | this.begin("NSTR");
|
579 | break;
|
580 | case 25:
|
581 | yy.getLogger().trace("description:", yy_.yytext);
|
582 | return "NODE_DESCR";
|
583 | case 26:
|
584 | this.popState();
|
585 | break;
|
586 | case 27:
|
587 | this.popState();
|
588 | yy.getLogger().trace("node end ))");
|
589 | return "NODE_DEND";
|
590 | case 28:
|
591 | this.popState();
|
592 | yy.getLogger().trace("node end )");
|
593 | return "NODE_DEND";
|
594 | case 29:
|
595 | this.popState();
|
596 | yy.getLogger().trace("node end ...", yy_.yytext);
|
597 | return "NODE_DEND";
|
598 | case 30:
|
599 | this.popState();
|
600 | yy.getLogger().trace("node end ((");
|
601 | return "NODE_DEND";
|
602 | case 31:
|
603 | this.popState();
|
604 | yy.getLogger().trace("node end (-");
|
605 | return "NODE_DEND";
|
606 | case 32:
|
607 | this.popState();
|
608 | yy.getLogger().trace("node end (-");
|
609 | return "NODE_DEND";
|
610 | case 33:
|
611 | this.popState();
|
612 | yy.getLogger().trace("node end ((");
|
613 | return "NODE_DEND";
|
614 | case 34:
|
615 | this.popState();
|
616 | yy.getLogger().trace("node end ((");
|
617 | return "NODE_DEND";
|
618 | case 35:
|
619 | yy.getLogger().trace("Long description:", yy_.yytext);
|
620 | return 20;
|
621 | case 36:
|
622 | yy.getLogger().trace("Long description:", yy_.yytext);
|
623 | return 20;
|
624 | }
|
625 | },
|
626 | 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],
|
627 | 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 } }
|
628 | };
|
629 | return lexer2;
|
630 | }();
|
631 | parser2.lexer = lexer;
|
632 | function Parser() {
|
633 | this.yy = {};
|
634 | }
|
635 | Parser.prototype = parser2;
|
636 | parser2.Parser = Parser;
|
637 | return new Parser();
|
638 | }();
|
639 | parser.parser = parser;
|
640 | const parser$1 = parser;
|
641 | let nodes = [];
|
642 | let cnt = 0;
|
643 | let elements = {};
|
644 | const clear = () => {
|
645 | nodes = [];
|
646 | cnt = 0;
|
647 | elements = {};
|
648 | };
|
649 | const getParent = function(level) {
|
650 | for (let i = nodes.length - 1; i >= 0; i--) {
|
651 | if (nodes[i].level < level) {
|
652 | return nodes[i];
|
653 | }
|
654 | }
|
655 | return null;
|
656 | };
|
657 | const getMindmap = () => {
|
658 | return nodes.length > 0 ? nodes[0] : null;
|
659 | };
|
660 | const addNode = (level, id, descr, type) => {
|
661 | var _a, _b;
|
662 | log.info("addNode", level, id, descr, type);
|
663 | const conf = getConfig();
|
664 | let padding = ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig.mindmap.padding;
|
665 | switch (type) {
|
666 | case nodeType.ROUNDED_RECT:
|
667 | case nodeType.RECT:
|
668 | case nodeType.HEXAGON:
|
669 | padding *= 2;
|
670 | }
|
671 | const node = {
|
672 | id: cnt++,
|
673 | nodeId: sanitizeText(id, conf),
|
674 | level,
|
675 | descr: sanitizeText(descr, conf),
|
676 | type,
|
677 | children: [],
|
678 | width: ((_b = conf.mindmap) == null ? void 0 : _b.maxNodeWidth) ?? defaultConfig.mindmap.maxNodeWidth,
|
679 | padding
|
680 | };
|
681 | const parent = getParent(level);
|
682 | if (parent) {
|
683 | parent.children.push(node);
|
684 | nodes.push(node);
|
685 | } else {
|
686 | if (nodes.length === 0) {
|
687 | nodes.push(node);
|
688 | } else {
|
689 | throw new Error(
|
690 | 'There can be only one root. No parent could be found for ("' + node.descr + '")'
|
691 | );
|
692 | }
|
693 | }
|
694 | };
|
695 | const nodeType = {
|
696 | DEFAULT: 0,
|
697 | NO_BORDER: 0,
|
698 | ROUNDED_RECT: 1,
|
699 | RECT: 2,
|
700 | CIRCLE: 3,
|
701 | CLOUD: 4,
|
702 | BANG: 5,
|
703 | HEXAGON: 6
|
704 | };
|
705 | const getType = (startStr, endStr) => {
|
706 | log.debug("In get type", startStr, endStr);
|
707 | switch (startStr) {
|
708 | case "[":
|
709 | return nodeType.RECT;
|
710 | case "(":
|
711 | return endStr === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD;
|
712 | case "((":
|
713 | return nodeType.CIRCLE;
|
714 | case ")":
|
715 | return nodeType.CLOUD;
|
716 | case "))":
|
717 | return nodeType.BANG;
|
718 | case "{{":
|
719 | return nodeType.HEXAGON;
|
720 | default:
|
721 | return nodeType.DEFAULT;
|
722 | }
|
723 | };
|
724 | const setElementForId = (id, element) => {
|
725 | elements[id] = element;
|
726 | };
|
727 | const decorateNode = (decoration) => {
|
728 | if (!decoration) {
|
729 | return;
|
730 | }
|
731 | const config = getConfig();
|
732 | const node = nodes[nodes.length - 1];
|
733 | if (decoration.icon) {
|
734 | node.icon = sanitizeText(decoration.icon, config);
|
735 | }
|
736 | if (decoration.class) {
|
737 | node.class = sanitizeText(decoration.class, config);
|
738 | }
|
739 | };
|
740 | const type2Str = (type) => {
|
741 | switch (type) {
|
742 | case nodeType.DEFAULT:
|
743 | return "no-border";
|
744 | case nodeType.RECT:
|
745 | return "rect";
|
746 | case nodeType.ROUNDED_RECT:
|
747 | return "rounded-rect";
|
748 | case nodeType.CIRCLE:
|
749 | return "circle";
|
750 | case nodeType.CLOUD:
|
751 | return "cloud";
|
752 | case nodeType.BANG:
|
753 | return "bang";
|
754 | case nodeType.HEXAGON:
|
755 | return "hexgon";
|
756 | default:
|
757 | return "no-border";
|
758 | }
|
759 | };
|
760 | const getLogger = () => log;
|
761 | const getElementById = (id) => elements[id];
|
762 | const db = {
|
763 | clear,
|
764 | addNode,
|
765 | getMindmap,
|
766 | nodeType,
|
767 | getType,
|
768 | setElementForId,
|
769 | decorateNode,
|
770 | type2Str,
|
771 | getLogger,
|
772 | getElementById
|
773 | };
|
774 | const db$1 = db;
|
775 | const MAX_SECTIONS = 12;
|
776 | const defaultBkg = function(db2, elem, node, section) {
|
777 | const rd = 5;
|
778 | elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr(
|
779 | "d",
|
780 | `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z`
|
781 | );
|
782 | elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height);
|
783 | };
|
784 | const rectBkg = function(db2, elem, node) {
|
785 | elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("width", node.width);
|
786 | };
|
787 | const cloudBkg = function(db2, elem, node) {
|
788 | const w = node.width;
|
789 | const h = node.height;
|
790 | const r1 = 0.15 * w;
|
791 | const r2 = 0.25 * w;
|
792 | const r3 = 0.35 * w;
|
793 | const r4 = 0.2 * w;
|
794 | elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr(
|
795 | "d",
|
796 | `M0 0 a${r1},${r1} 0 0,1 ${w * 0.25},${-1 * w * 0.1}
|
797 | a${r3},${r3} 1 0,1 ${w * 0.4},${-1 * w * 0.1}
|
798 | a${r2},${r2} 1 0,1 ${w * 0.35},${1 * w * 0.2}
|
799 |
|
800 | a${r1},${r1} 1 0,1 ${w * 0.15},${1 * h * 0.35}
|
801 | a${r4},${r4} 1 0,1 ${-1 * w * 0.15},${1 * h * 0.65}
|
802 |
|
803 | a${r2},${r1} 1 0,1 ${-1 * w * 0.25},${w * 0.15}
|
804 | a${r3},${r3} 1 0,1 ${-1 * w * 0.5},${0}
|
805 | a${r1},${r1} 1 0,1 ${-1 * w * 0.25},${-1 * w * 0.15}
|
806 |
|
807 | a${r1},${r1} 1 0,1 ${-1 * w * 0.1},${-1 * h * 0.35}
|
808 | a${r4},${r4} 1 0,1 ${w * 0.1},${-1 * h * 0.65}
|
809 |
|
810 | H0 V0 Z`
|
811 | );
|
812 | };
|
813 | const bangBkg = function(db2, elem, node) {
|
814 | const w = node.width;
|
815 | const h = node.height;
|
816 | const r = 0.15 * w;
|
817 | elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr(
|
818 | "d",
|
819 | `M0 0 a${r},${r} 1 0,0 ${w * 0.25},${-1 * h * 0.1}
|
820 | a${r},${r} 1 0,0 ${w * 0.25},${0}
|
821 | a${r},${r} 1 0,0 ${w * 0.25},${0}
|
822 | a${r},${r} 1 0,0 ${w * 0.25},${1 * h * 0.1}
|
823 |
|
824 | a${r},${r} 1 0,0 ${w * 0.15},${1 * h * 0.33}
|
825 | a${r * 0.8},${r * 0.8} 1 0,0 ${0},${1 * h * 0.34}
|
826 | a${r},${r} 1 0,0 ${-1 * w * 0.15},${1 * h * 0.33}
|
827 |
|
828 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${h * 0.15}
|
829 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${0}
|
830 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${0}
|
831 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${-1 * h * 0.15}
|
832 |
|
833 | a${r},${r} 1 0,0 ${-1 * w * 0.1},${-1 * h * 0.33}
|
834 | a${r * 0.8},${r * 0.8} 1 0,0 ${0},${-1 * h * 0.34}
|
835 | a${r},${r} 1 0,0 ${w * 0.1},${-1 * h * 0.33}
|
836 |
|
837 | H0 V0 Z`
|
838 | );
|
839 | };
|
840 | const circleBkg = function(db2, elem, node) {
|
841 | elem.append("circle").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("r", node.width / 2);
|
842 | };
|
843 | function insertPolygonShape(parent, w, h, points, node) {
|
844 | return parent.insert("polygon", ":first-child").attr(
|
845 | "points",
|
846 | points.map(function(d) {
|
847 | return d.x + "," + d.y;
|
848 | }).join(" ")
|
849 | ).attr("transform", "translate(" + (node.width - w) / 2 + ", " + h + ")");
|
850 | }
|
851 | const hexagonBkg = function(_db, elem, node) {
|
852 | const h = node.height;
|
853 | const f = 4;
|
854 | const m = h / f;
|
855 | const w = node.width - node.padding + 2 * m;
|
856 | const points = [
|
857 | { x: m, y: 0 },
|
858 | { x: w - m, y: 0 },
|
859 | { x: w, y: -h / 2 },
|
860 | { x: w - m, y: -h },
|
861 | { x: m, y: -h },
|
862 | { x: 0, y: -h / 2 }
|
863 | ];
|
864 | insertPolygonShape(elem, w, h, points, node);
|
865 | };
|
866 | const roundedRectBkg = function(db2, elem, node) {
|
867 | elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("rx", node.padding).attr("ry", node.padding).attr("width", node.width);
|
868 | };
|
869 | const drawNode = function(db2, elem, node, fullSection, conf) {
|
870 | const htmlLabels = conf.htmlLabels;
|
871 | const section = fullSection % (MAX_SECTIONS - 1);
|
872 | const nodeElem = elem.append("g");
|
873 | node.section = section;
|
874 | let sectionClass = "section-" + section;
|
875 | if (section < 0) {
|
876 | sectionClass += " section-root";
|
877 | }
|
878 | nodeElem.attr("class", (node.class ? node.class + " " : "") + "mindmap-node " + sectionClass);
|
879 | const bkgElem = nodeElem.append("g");
|
880 | const textElem = nodeElem.append("g");
|
881 | const description = node.descr.replace(/(<br\/*>)/g, "\n");
|
882 | createText(textElem, description, {
|
883 | useHtmlLabels: htmlLabels,
|
884 | width: node.width,
|
885 | classes: "mindmap-node-label"
|
886 | });
|
887 | if (!htmlLabels) {
|
888 | textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle");
|
889 | }
|
890 | const bbox = textElem.node().getBBox();
|
891 | const [fontSize] = parseFontSize(conf.fontSize);
|
892 | node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding;
|
893 | node.width = bbox.width + 2 * node.padding;
|
894 | if (node.icon) {
|
895 | if (node.type === db2.nodeType.CIRCLE) {
|
896 | node.height += 50;
|
897 | node.width += 50;
|
898 | const icon = nodeElem.append("foreignObject").attr("height", "50px").attr("width", node.width).attr("style", "text-align: center;");
|
899 | icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon);
|
900 | textElem.attr(
|
901 | "transform",
|
902 | "translate(" + node.width / 2 + ", " + (node.height / 2 - 1.5 * node.padding) + ")"
|
903 | );
|
904 | } else {
|
905 | node.width += 50;
|
906 | const orgHeight = node.height;
|
907 | node.height = Math.max(orgHeight, 60);
|
908 | const heightDiff = Math.abs(node.height - orgHeight);
|
909 | const icon = nodeElem.append("foreignObject").attr("width", "60px").attr("height", node.height).attr("style", "text-align: center;margin-top:" + heightDiff / 2 + "px;");
|
910 | icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon);
|
911 | textElem.attr(
|
912 | "transform",
|
913 | "translate(" + (25 + node.width / 2) + ", " + (heightDiff / 2 + node.padding / 2) + ")"
|
914 | );
|
915 | }
|
916 | } else {
|
917 | if (!htmlLabels) {
|
918 | const dx = node.width / 2;
|
919 | const dy = node.padding / 2;
|
920 | textElem.attr("transform", "translate(" + dx + ", " + dy + ")");
|
921 | } else {
|
922 | const dx = (node.width - bbox.width) / 2;
|
923 | const dy = (node.height - bbox.height) / 2;
|
924 | textElem.attr("transform", "translate(" + dx + ", " + dy + ")");
|
925 | }
|
926 | }
|
927 | switch (node.type) {
|
928 | case db2.nodeType.DEFAULT:
|
929 | defaultBkg(db2, bkgElem, node, section);
|
930 | break;
|
931 | case db2.nodeType.ROUNDED_RECT:
|
932 | roundedRectBkg(db2, bkgElem, node);
|
933 | break;
|
934 | case db2.nodeType.RECT:
|
935 | rectBkg(db2, bkgElem, node);
|
936 | break;
|
937 | case db2.nodeType.CIRCLE:
|
938 | bkgElem.attr("transform", "translate(" + node.width / 2 + ", " + +node.height / 2 + ")");
|
939 | circleBkg(db2, bkgElem, node);
|
940 | break;
|
941 | case db2.nodeType.CLOUD:
|
942 | cloudBkg(db2, bkgElem, node);
|
943 | break;
|
944 | case db2.nodeType.BANG:
|
945 | bangBkg(db2, bkgElem, node);
|
946 | break;
|
947 | case db2.nodeType.HEXAGON:
|
948 | hexagonBkg(db2, bkgElem, node);
|
949 | break;
|
950 | }
|
951 | db2.setElementForId(node.id, nodeElem);
|
952 | return node.height;
|
953 | };
|
954 | const positionNode = function(db2, node) {
|
955 | const nodeElem = db2.getElementById(node.id);
|
956 | const x = node.x || 0;
|
957 | const y = node.y || 0;
|
958 | nodeElem.attr("transform", "translate(" + x + "," + y + ")");
|
959 | };
|
960 | cytoscape.use(coseBilkent);
|
961 | function drawNodes(db2, svg, mindmap, section, conf) {
|
962 | drawNode(db2, svg, mindmap, section, conf);
|
963 | if (mindmap.children) {
|
964 | mindmap.children.forEach((child, index) => {
|
965 | drawNodes(db2, svg, child, section < 0 ? index : section, conf);
|
966 | });
|
967 | }
|
968 | }
|
969 | function drawEdges(edgesEl, cy) {
|
970 | cy.edges().map((edge, id) => {
|
971 | const data = edge.data();
|
972 | if (edge[0]._private.bodyBounds) {
|
973 | const bounds = edge[0]._private.rscratch;
|
974 | log.trace("Edge: ", id, data);
|
975 | edgesEl.insert("path").attr(
|
976 | "d",
|
977 | `M ${bounds.startX},${bounds.startY} L ${bounds.midX},${bounds.midY} L${bounds.endX},${bounds.endY} `
|
978 | ).attr("class", "edge section-edge-" + data.section + " edge-depth-" + data.depth);
|
979 | }
|
980 | });
|
981 | }
|
982 | function addNodes(mindmap, cy, conf, level) {
|
983 | cy.add({
|
984 | group: "nodes",
|
985 | data: {
|
986 | id: mindmap.id.toString(),
|
987 | labelText: mindmap.descr,
|
988 | height: mindmap.height,
|
989 | width: mindmap.width,
|
990 | level,
|
991 | nodeId: mindmap.id,
|
992 | padding: mindmap.padding,
|
993 | type: mindmap.type
|
994 | },
|
995 | position: {
|
996 | x: mindmap.x,
|
997 | y: mindmap.y
|
998 | }
|
999 | });
|
1000 | if (mindmap.children) {
|
1001 | mindmap.children.forEach((child) => {
|
1002 | addNodes(child, cy, conf, level + 1);
|
1003 | cy.add({
|
1004 | group: "edges",
|
1005 | data: {
|
1006 | id: `${mindmap.id}_${child.id}`,
|
1007 | source: mindmap.id,
|
1008 | target: child.id,
|
1009 | depth: level,
|
1010 | section: child.section
|
1011 | }
|
1012 | });
|
1013 | });
|
1014 | }
|
1015 | }
|
1016 | function layoutMindmap(node, conf) {
|
1017 | return new Promise((resolve) => {
|
1018 | const renderEl = select("body").append("div").attr("id", "cy").attr("style", "display:none");
|
1019 | const cy = cytoscape({
|
1020 | container: document.getElementById("cy"),
|
1021 | // container to render in
|
1022 | style: [
|
1023 | {
|
1024 | selector: "edge",
|
1025 | style: {
|
1026 | "curve-style": "bezier"
|
1027 | }
|
1028 | }
|
1029 | ]
|
1030 | });
|
1031 | renderEl.remove();
|
1032 | addNodes(node, cy, conf, 0);
|
1033 | cy.nodes().forEach(function(n) {
|
1034 | n.layoutDimensions = () => {
|
1035 | const data = n.data();
|
1036 | return { w: data.width, h: data.height };
|
1037 | };
|
1038 | });
|
1039 | cy.layout({
|
1040 | name: "cose-bilkent",
|
1041 | // @ts-ignore Types for cose-bilkent are not correct?
|
1042 | quality: "proof",
|
1043 | styleEnabled: false,
|
1044 | animate: false
|
1045 | }).run();
|
1046 | cy.ready((e) => {
|
1047 | log.info("Ready", e);
|
1048 | resolve(cy);
|
1049 | });
|
1050 | });
|
1051 | }
|
1052 | function positionNodes(db2, cy) {
|
1053 | cy.nodes().map((node, id) => {
|
1054 | const data = node.data();
|
1055 | data.x = node.position().x;
|
1056 | data.y = node.position().y;
|
1057 | positionNode(db2, data);
|
1058 | const el = db2.getElementById(data.nodeId);
|
1059 | log.info("Id:", id, "Position: (", node.position().x, ", ", node.position().y, ")", data);
|
1060 | el.attr(
|
1061 | "transform",
|
1062 | `translate(${node.position().x - data.width / 2}, ${node.position().y - data.height / 2})`
|
1063 | );
|
1064 | el.attr("attr", `apa-${id})`);
|
1065 | });
|
1066 | }
|
1067 | const draw = async (text, id, _version, diagObj) => {
|
1068 | var _a, _b;
|
1069 | log.debug("Rendering mindmap diagram\n" + text);
|
1070 | const db2 = diagObj.db;
|
1071 | const mm = db2.getMindmap();
|
1072 | if (!mm) {
|
1073 | return;
|
1074 | }
|
1075 | const conf = getConfig();
|
1076 | conf.htmlLabels = false;
|
1077 | const svg = selectSvgElement(id);
|
1078 | const edgesElem = svg.append("g");
|
1079 | edgesElem.attr("class", "mindmap-edges");
|
1080 | const nodesElem = svg.append("g");
|
1081 | nodesElem.attr("class", "mindmap-nodes");
|
1082 | drawNodes(db2, nodesElem, mm, -1, conf);
|
1083 | const cy = await layoutMindmap(mm, conf);
|
1084 | drawEdges(edgesElem, cy);
|
1085 | positionNodes(db2, cy);
|
1086 | setupGraphViewbox(
|
1087 | void 0,
|
1088 | svg,
|
1089 | ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig.mindmap.padding,
|
1090 | ((_b = conf.mindmap) == null ? void 0 : _b.useMaxWidth) ?? defaultConfig.mindmap.useMaxWidth
|
1091 | );
|
1092 | };
|
1093 | const renderer = {
|
1094 | draw
|
1095 | };
|
1096 | const genSections = (options) => {
|
1097 | let sections = "";
|
1098 | for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
|
1099 | options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i];
|
1100 | if (isDark(options["lineColor" + i])) {
|
1101 | options["lineColor" + i] = lighten(options["lineColor" + i], 20);
|
1102 | } else {
|
1103 | options["lineColor" + i] = darken(options["lineColor" + i], 20);
|
1104 | }
|
1105 | }
|
1106 | for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
|
1107 | const sw = "" + (17 - 3 * i);
|
1108 | sections += `
|
1109 | .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path {
|
1110 | fill: ${options["cScale" + i]};
|
1111 | }
|
1112 | .section-${i - 1} text {
|
1113 | fill: ${options["cScaleLabel" + i]};
|
1114 | }
|
1115 | .node-icon-${i - 1} {
|
1116 | font-size: 40px;
|
1117 | color: ${options["cScaleLabel" + i]};
|
1118 | }
|
1119 | .section-edge-${i - 1}{
|
1120 | stroke: ${options["cScale" + i]};
|
1121 | }
|
1122 | .edge-depth-${i - 1}{
|
1123 | stroke-width: ${sw};
|
1124 | }
|
1125 | .section-${i - 1} line {
|
1126 | stroke: ${options["cScaleInv" + i]} ;
|
1127 | stroke-width: 3;
|
1128 | }
|
1129 |
|
1130 | .disabled, .disabled circle, .disabled text {
|
1131 | fill: lightgray;
|
1132 | }
|
1133 | .disabled text {
|
1134 | fill: #efefef;
|
1135 | }
|
1136 | `;
|
1137 | }
|
1138 | return sections;
|
1139 | };
|
1140 | const getStyles = (options) => `
|
1141 | .edge {
|
1142 | stroke-width: 3;
|
1143 | }
|
1144 | ${genSections(options)}
|
1145 | .section-root rect, .section-root path, .section-root circle, .section-root polygon {
|
1146 | fill: ${options.git0};
|
1147 | }
|
1148 | .section-root text {
|
1149 | fill: ${options.gitBranchLabel0};
|
1150 | }
|
1151 | .icon-container {
|
1152 | height:100%;
|
1153 | display: flex;
|
1154 | justify-content: center;
|
1155 | align-items: center;
|
1156 | }
|
1157 | .edge {
|
1158 | fill: none;
|
1159 | }
|
1160 | .mindmap-node-label {
|
1161 | dy: 1em;
|
1162 | alignment-baseline: middle;
|
1163 | text-anchor: middle;
|
1164 | dominant-baseline: middle;
|
1165 | text-align: center;
|
1166 | }
|
1167 | `;
|
1168 | const styles = getStyles;
|
1169 | const diagram = {
|
1170 | db: db$1,
|
1171 | renderer,
|
1172 | parser: parser$1,
|
1173 | styles
|
1174 | };
|
1175 | export {
|
1176 | diagram
|
1177 | };
|
1178 |
|
\ | No newline at end of file |