UNPKG

66.9 kBJavaScriptView Raw
1var _a, _b;
2import { c as getConfig, _ as getConfig$1, l as log, E as clear$1, f as common, B as rgba, o as getStylesFromArray, j as d3select, k as configureSvgSize } from "./mermaid-dcacb631.js";
3import { c as clone } from "./clone-9ea6bfeb.js";
4import { c as channel } from "./channel-f9001828.js";
5import { h as insertEdge, f as insertEdgeLabel, j as positionEdgeLabel, e as insertNode, p as positionNode, a as insertMarkers } from "./edges-ce5cfb7c.js";
6import { G as Graph } from "./graph-fe24fab6.js";
7import { o as ordinal } from "./ordinal-475e0c0c.js";
8import { d as d3schemeTableau10 } from "./Tableau10-31042135.js";
9import "./createText-b70fe78a.js";
10import "./line-87f517ef.js";
11import "./array-b7dcf730.js";
12import "./path-39bad7e2.js";
13import "./init-cc95ec8e.js";
14var parser = function() {
15 var o = function(k, v, o2, l) {
16 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
17 ;
18 return o2;
19 }, $V0 = [1, 7], $V1 = [1, 13], $V2 = [1, 14], $V3 = [1, 15], $V4 = [1, 19], $V5 = [1, 16], $V6 = [1, 17], $V7 = [1, 18], $V8 = [8, 30], $V9 = [8, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Va = [1, 23], $Vb = [1, 24], $Vc = [8, 15, 16, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Vd = [8, 15, 16, 21, 27, 28, 29, 30, 31, 32, 40, 44, 47], $Ve = [1, 49];
20 var parser2 = {
21 trace: function trace() {
22 },
23 yy: {},
24 symbols_: { "error": 2, "spaceLines": 3, "SPACELINE": 4, "NL": 5, "separator": 6, "SPACE": 7, "EOF": 8, "start": 9, "BLOCK_DIAGRAM_KEY": 10, "document": 11, "stop": 12, "statement": 13, "link": 14, "LINK": 15, "START_LINK": 16, "LINK_LABEL": 17, "STR": 18, "nodeStatement": 19, "columnsStatement": 20, "SPACE_BLOCK": 21, "blockStatement": 22, "classDefStatement": 23, "cssClassStatement": 24, "styleStatement": 25, "node": 26, "SIZE": 27, "COLUMNS": 28, "id-block": 29, "end": 30, "block": 31, "NODE_ID": 32, "nodeShapeNLabel": 33, "dirList": 34, "DIR": 35, "NODE_DSTART": 36, "NODE_DEND": 37, "BLOCK_ARROW_START": 38, "BLOCK_ARROW_END": 39, "classDef": 40, "CLASSDEF_ID": 41, "CLASSDEF_STYLEOPTS": 42, "DEFAULT": 43, "class": 44, "CLASSENTITY_IDS": 45, "STYLECLASS": 46, "style": 47, "STYLE_ENTITY_IDS": 48, "STYLE_DEFINITION_DATA": 49, "$accept": 0, "$end": 1 },
25 terminals_: { 2: "error", 4: "SPACELINE", 5: "NL", 7: "SPACE", 8: "EOF", 10: "BLOCK_DIAGRAM_KEY", 15: "LINK", 16: "START_LINK", 17: "LINK_LABEL", 18: "STR", 21: "SPACE_BLOCK", 27: "SIZE", 28: "COLUMNS", 29: "id-block", 30: "end", 31: "block", 32: "NODE_ID", 35: "DIR", 36: "NODE_DSTART", 37: "NODE_DEND", 38: "BLOCK_ARROW_START", 39: "BLOCK_ARROW_END", 40: "classDef", 41: "CLASSDEF_ID", 42: "CLASSDEF_STYLEOPTS", 43: "DEFAULT", 44: "class", 45: "CLASSENTITY_IDS", 46: "STYLECLASS", 47: "style", 48: "STYLE_ENTITY_IDS", 49: "STYLE_DEFINITION_DATA" },
26 productions_: [0, [3, 1], [3, 2], [3, 2], [6, 1], [6, 1], [6, 1], [9, 3], [12, 1], [12, 1], [12, 2], [12, 2], [11, 1], [11, 2], [14, 1], [14, 4], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [19, 3], [19, 2], [19, 1], [20, 1], [22, 4], [22, 3], [26, 1], [26, 2], [34, 1], [34, 2], [33, 3], [33, 4], [23, 3], [23, 3], [24, 3], [25, 3]],
27 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
28 var $0 = $$.length - 1;
29 switch (yystate) {
30 case 4:
31 yy.getLogger().debug("Rule: separator (NL) ");
32 break;
33 case 5:
34 yy.getLogger().debug("Rule: separator (Space) ");
35 break;
36 case 6:
37 yy.getLogger().debug("Rule: separator (EOF) ");
38 break;
39 case 7:
40 yy.getLogger().debug("Rule: hierarchy: ", $$[$0 - 1]);
41 yy.setHierarchy($$[$0 - 1]);
42 break;
43 case 8:
44 yy.getLogger().debug("Stop NL ");
45 break;
46 case 9:
47 yy.getLogger().debug("Stop EOF ");
48 break;
49 case 10:
50 yy.getLogger().debug("Stop NL2 ");
51 break;
52 case 11:
53 yy.getLogger().debug("Stop EOF2 ");
54 break;
55 case 12:
56 yy.getLogger().debug("Rule: statement: ", $$[$0]);
57 typeof $$[$0].length === "number" ? this.$ = $$[$0] : this.$ = [$$[$0]];
58 break;
59 case 13:
60 yy.getLogger().debug("Rule: statement #2: ", $$[$0 - 1]);
61 this.$ = [$$[$0 - 1]].concat($$[$0]);
62 break;
63 case 14:
64 yy.getLogger().debug("Rule: link: ", $$[$0], yytext);
65 this.$ = { edgeTypeStr: $$[$0], label: "" };
66 break;
67 case 15:
68 yy.getLogger().debug("Rule: LABEL link: ", $$[$0 - 3], $$[$0 - 1], $$[$0]);
69 this.$ = { edgeTypeStr: $$[$0], label: $$[$0 - 1] };
70 break;
71 case 18:
72 const num = parseInt($$[$0]);
73 const spaceId = yy.generateId();
74 this.$ = { id: spaceId, type: "space", label: "", width: num, children: [] };
75 break;
76 case 23:
77 yy.getLogger().debug("Rule: (nodeStatement link node) ", $$[$0 - 2], $$[$0 - 1], $$[$0], " typestr: ", $$[$0 - 1].edgeTypeStr);
78 const edgeData = yy.edgeStrToEdgeData($$[$0 - 1].edgeTypeStr);
79 this.$ = [
80 { id: $$[$0 - 2].id, label: $$[$0 - 2].label, type: $$[$0 - 2].type, directions: $$[$0 - 2].directions },
81 { id: $$[$0 - 2].id + "-" + $$[$0].id, start: $$[$0 - 2].id, end: $$[$0].id, label: $$[$0 - 1].label, type: "edge", directions: $$[$0].directions, arrowTypeEnd: edgeData, arrowTypeStart: "arrow_open" },
82 { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions }
83 ];
84 break;
85 case 24:
86 yy.getLogger().debug("Rule: nodeStatement (abc88 node size) ", $$[$0 - 1], $$[$0]);
87 this.$ = { id: $$[$0 - 1].id, label: $$[$0 - 1].label, type: yy.typeStr2Type($$[$0 - 1].typeStr), directions: $$[$0 - 1].directions, widthInColumns: parseInt($$[$0], 10) };
88 break;
89 case 25:
90 yy.getLogger().debug("Rule: nodeStatement (node) ", $$[$0]);
91 this.$ = { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions, widthInColumns: 1 };
92 break;
93 case 26:
94 yy.getLogger().debug("APA123", this ? this : "na");
95 yy.getLogger().debug("COLUMNS: ", $$[$0]);
96 this.$ = { type: "column-setting", columns: $$[$0] === "auto" ? -1 : parseInt($$[$0]) };
97 break;
98 case 27:
99 yy.getLogger().debug("Rule: id-block statement : ", $$[$0 - 2], $$[$0 - 1]);
100 yy.generateId();
101 this.$ = { ...$$[$0 - 2], type: "composite", children: $$[$0 - 1] };
102 break;
103 case 28:
104 yy.getLogger().debug("Rule: blockStatement : ", $$[$0 - 2], $$[$0 - 1], $$[$0]);
105 const id = yy.generateId();
106 this.$ = { id, type: "composite", label: "", children: $$[$0 - 1] };
107 break;
108 case 29:
109 yy.getLogger().debug("Rule: node (NODE_ID separator): ", $$[$0]);
110 this.$ = { id: $$[$0] };
111 break;
112 case 30:
113 yy.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", $$[$0 - 1], $$[$0]);
114 this.$ = { id: $$[$0 - 1], label: $$[$0].label, typeStr: $$[$0].typeStr, directions: $$[$0].directions };
115 break;
116 case 31:
117 yy.getLogger().debug("Rule: dirList: ", $$[$0]);
118 this.$ = [$$[$0]];
119 break;
120 case 32:
121 yy.getLogger().debug("Rule: dirList: ", $$[$0 - 1], $$[$0]);
122 this.$ = [$$[$0 - 1]].concat($$[$0]);
123 break;
124 case 33:
125 yy.getLogger().debug("Rule: nodeShapeNLabel: ", $$[$0 - 2], $$[$0 - 1], $$[$0]);
126 this.$ = { typeStr: $$[$0 - 2] + $$[$0], label: $$[$0 - 1] };
127 break;
128 case 34:
129 yy.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", $$[$0 - 3], $$[$0 - 2], " #3:", $$[$0 - 1], $$[$0]);
130 this.$ = { typeStr: $$[$0 - 3] + $$[$0], label: $$[$0 - 2], directions: $$[$0 - 1] };
131 break;
132 case 35:
133 case 36:
134 this.$ = { type: "classDef", id: $$[$0 - 1].trim(), css: $$[$0].trim() };
135 break;
136 case 37:
137 this.$ = { type: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() };
138 break;
139 case 38:
140 this.$ = { type: "applyStyles", id: $$[$0 - 1].trim(), stylesStr: $$[$0].trim() };
141 break;
142 }
143 },
144 table: [{ 9: 1, 10: [1, 2] }, { 1: [3] }, { 11: 3, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 8: [1, 20] }, o($V8, [2, 12], { 13: 4, 19: 5, 20: 6, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 11: 21, 21: $V0, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }), o($V9, [2, 16], { 14: 22, 15: $Va, 16: $Vb }), o($V9, [2, 17]), o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), o($V9, [2, 21]), o($V9, [2, 22]), o($Vc, [2, 25], { 27: [1, 25] }), o($V9, [2, 26]), { 19: 26, 26: 12, 32: $V4 }, { 11: 27, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 41: [1, 28], 43: [1, 29] }, { 45: [1, 30] }, { 48: [1, 31] }, o($Vd, [2, 29], { 33: 32, 36: [1, 33], 38: [1, 34] }), { 1: [2, 7] }, o($V8, [2, 13]), { 26: 35, 32: $V4 }, { 32: [2, 14] }, { 17: [1, 36] }, o($Vc, [2, 24]), { 11: 37, 13: 4, 14: 22, 15: $Va, 16: $Vb, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 30: [1, 38] }, { 42: [1, 39] }, { 42: [1, 40] }, { 46: [1, 41] }, { 49: [1, 42] }, o($Vd, [2, 30]), { 18: [1, 43] }, { 18: [1, 44] }, o($Vc, [2, 23]), { 18: [1, 45] }, { 30: [1, 46] }, o($V9, [2, 28]), o($V9, [2, 35]), o($V9, [2, 36]), o($V9, [2, 37]), o($V9, [2, 38]), { 37: [1, 47] }, { 34: 48, 35: $Ve }, { 15: [1, 50] }, o($V9, [2, 27]), o($Vd, [2, 33]), { 39: [1, 51] }, { 34: 52, 35: $Ve, 39: [2, 31] }, { 32: [2, 15] }, o($Vd, [2, 34]), { 39: [2, 32] }],
145 defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] },
146 parseError: function parseError(str, hash) {
147 if (hash.recoverable) {
148 this.trace(str);
149 } else {
150 var error = new Error(str);
151 error.hash = hash;
152 throw error;
153 }
154 },
155 parse: function parse(input) {
156 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
157 var args = lstack.slice.call(arguments, 1);
158 var lexer2 = Object.create(this.lexer);
159 var sharedState = { yy: {} };
160 for (var k in this.yy) {
161 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
162 sharedState.yy[k] = this.yy[k];
163 }
164 }
165 lexer2.setInput(input, sharedState.yy);
166 sharedState.yy.lexer = lexer2;
167 sharedState.yy.parser = this;
168 if (typeof lexer2.yylloc == "undefined") {
169 lexer2.yylloc = {};
170 }
171 var yyloc = lexer2.yylloc;
172 lstack.push(yyloc);
173 var ranges = lexer2.options && lexer2.options.ranges;
174 if (typeof sharedState.yy.parseError === "function") {
175 this.parseError = sharedState.yy.parseError;
176 } else {
177 this.parseError = Object.getPrototypeOf(this).parseError;
178 }
179 function lex() {
180 var token;
181 token = tstack.pop() || lexer2.lex() || EOF;
182 if (typeof token !== "number") {
183 if (token instanceof Array) {
184 tstack = token;
185 token = tstack.pop();
186 }
187 token = self.symbols_[token] || token;
188 }
189 return token;
190 }
191 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
192 while (true) {
193 state = stack[stack.length - 1];
194 if (this.defaultActions[state]) {
195 action = this.defaultActions[state];
196 } else {
197 if (symbol === null || typeof symbol == "undefined") {
198 symbol = lex();
199 }
200 action = table[state] && table[state][symbol];
201 }
202 if (typeof action === "undefined" || !action.length || !action[0]) {
203 var errStr = "";
204 expected = [];
205 for (p in table[state]) {
206 if (this.terminals_[p] && p > TERROR) {
207 expected.push("'" + this.terminals_[p] + "'");
208 }
209 }
210 if (lexer2.showPosition) {
211 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
212 } else {
213 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
214 }
215 this.parseError(errStr, {
216 text: lexer2.match,
217 token: this.terminals_[symbol] || symbol,
218 line: lexer2.yylineno,
219 loc: yyloc,
220 expected
221 });
222 }
223 if (action[0] instanceof Array && action.length > 1) {
224 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
225 }
226 switch (action[0]) {
227 case 1:
228 stack.push(symbol);
229 vstack.push(lexer2.yytext);
230 lstack.push(lexer2.yylloc);
231 stack.push(action[1]);
232 symbol = null;
233 {
234 yyleng = lexer2.yyleng;
235 yytext = lexer2.yytext;
236 yylineno = lexer2.yylineno;
237 yyloc = lexer2.yylloc;
238 }
239 break;
240 case 2:
241 len = this.productions_[action[1]][1];
242 yyval.$ = vstack[vstack.length - len];
243 yyval._$ = {
244 first_line: lstack[lstack.length - (len || 1)].first_line,
245 last_line: lstack[lstack.length - 1].last_line,
246 first_column: lstack[lstack.length - (len || 1)].first_column,
247 last_column: lstack[lstack.length - 1].last_column
248 };
249 if (ranges) {
250 yyval._$.range = [
251 lstack[lstack.length - (len || 1)].range[0],
252 lstack[lstack.length - 1].range[1]
253 ];
254 }
255 r = this.performAction.apply(yyval, [
256 yytext,
257 yyleng,
258 yylineno,
259 sharedState.yy,
260 action[1],
261 vstack,
262 lstack
263 ].concat(args));
264 if (typeof r !== "undefined") {
265 return r;
266 }
267 if (len) {
268 stack = stack.slice(0, -1 * len * 2);
269 vstack = vstack.slice(0, -1 * len);
270 lstack = lstack.slice(0, -1 * len);
271 }
272 stack.push(this.productions_[action[1]][0]);
273 vstack.push(yyval.$);
274 lstack.push(yyval._$);
275 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
276 stack.push(newState);
277 break;
278 case 3:
279 return true;
280 }
281 }
282 return true;
283 }
284 };
285 var lexer = function() {
286 var lexer2 = {
287 EOF: 1,
288 parseError: function parseError(str, hash) {
289 if (this.yy.parser) {
290 this.yy.parser.parseError(str, hash);
291 } else {
292 throw new Error(str);
293 }
294 },
295 // resets the lexer, sets new input
296 setInput: function(input, yy) {
297 this.yy = yy || this.yy || {};
298 this._input = input;
299 this._more = this._backtrack = this.done = false;
300 this.yylineno = this.yyleng = 0;
301 this.yytext = this.matched = this.match = "";
302 this.conditionStack = ["INITIAL"];
303 this.yylloc = {
304 first_line: 1,
305 first_column: 0,
306 last_line: 1,
307 last_column: 0
308 };
309 if (this.options.ranges) {
310 this.yylloc.range = [0, 0];
311 }
312 this.offset = 0;
313 return this;
314 },
315 // consumes and returns one char from the input
316 input: function() {
317 var ch = this._input[0];
318 this.yytext += ch;
319 this.yyleng++;
320 this.offset++;
321 this.match += ch;
322 this.matched += ch;
323 var lines = ch.match(/(?:\r\n?|\n).*/g);
324 if (lines) {
325 this.yylineno++;
326 this.yylloc.last_line++;
327 } else {
328 this.yylloc.last_column++;
329 }
330 if (this.options.ranges) {
331 this.yylloc.range[1]++;
332 }
333 this._input = this._input.slice(1);
334 return ch;
335 },
336 // unshifts one char (or a string) into the input
337 unput: function(ch) {
338 var len = ch.length;
339 var lines = ch.split(/(?:\r\n?|\n)/g);
340 this._input = ch + this._input;
341 this.yytext = this.yytext.substr(0, this.yytext.length - len);
342 this.offset -= len;
343 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
344 this.match = this.match.substr(0, this.match.length - 1);
345 this.matched = this.matched.substr(0, this.matched.length - 1);
346 if (lines.length - 1) {
347 this.yylineno -= lines.length - 1;
348 }
349 var r = this.yylloc.range;
350 this.yylloc = {
351 first_line: this.yylloc.first_line,
352 last_line: this.yylineno + 1,
353 first_column: this.yylloc.first_column,
354 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
355 };
356 if (this.options.ranges) {
357 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
358 }
359 this.yyleng = this.yytext.length;
360 return this;
361 },
362 // When called from action, caches matched text and appends it on next action
363 more: function() {
364 this._more = true;
365 return this;
366 },
367 // 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.
368 reject: function() {
369 if (this.options.backtrack_lexer) {
370 this._backtrack = true;
371 } else {
372 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(), {
373 text: "",
374 token: null,
375 line: this.yylineno
376 });
377 }
378 return this;
379 },
380 // retain first n characters of the match
381 less: function(n) {
382 this.unput(this.match.slice(n));
383 },
384 // displays already matched input, i.e. for error messages
385 pastInput: function() {
386 var past = this.matched.substr(0, this.matched.length - this.match.length);
387 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
388 },
389 // displays upcoming input, i.e. for error messages
390 upcomingInput: function() {
391 var next = this.match;
392 if (next.length < 20) {
393 next += this._input.substr(0, 20 - next.length);
394 }
395 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
396 },
397 // displays the character position where the lexing error occurred, i.e. for error messages
398 showPosition: function() {
399 var pre = this.pastInput();
400 var c = new Array(pre.length + 1).join("-");
401 return pre + this.upcomingInput() + "\n" + c + "^";
402 },
403 // test the lexed token: return FALSE when not a match, otherwise return token
404 test_match: function(match, indexed_rule) {
405 var token, lines, backup;
406 if (this.options.backtrack_lexer) {
407 backup = {
408 yylineno: this.yylineno,
409 yylloc: {
410 first_line: this.yylloc.first_line,
411 last_line: this.last_line,
412 first_column: this.yylloc.first_column,
413 last_column: this.yylloc.last_column
414 },
415 yytext: this.yytext,
416 match: this.match,
417 matches: this.matches,
418 matched: this.matched,
419 yyleng: this.yyleng,
420 offset: this.offset,
421 _more: this._more,
422 _input: this._input,
423 yy: this.yy,
424 conditionStack: this.conditionStack.slice(0),
425 done: this.done
426 };
427 if (this.options.ranges) {
428 backup.yylloc.range = this.yylloc.range.slice(0);
429 }
430 }
431 lines = match[0].match(/(?:\r\n?|\n).*/g);
432 if (lines) {
433 this.yylineno += lines.length;
434 }
435 this.yylloc = {
436 first_line: this.yylloc.last_line,
437 last_line: this.yylineno + 1,
438 first_column: this.yylloc.last_column,
439 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
440 };
441 this.yytext += match[0];
442 this.match += match[0];
443 this.matches = match;
444 this.yyleng = this.yytext.length;
445 if (this.options.ranges) {
446 this.yylloc.range = [this.offset, this.offset += this.yyleng];
447 }
448 this._more = false;
449 this._backtrack = false;
450 this._input = this._input.slice(match[0].length);
451 this.matched += match[0];
452 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
453 if (this.done && this._input) {
454 this.done = false;
455 }
456 if (token) {
457 return token;
458 } else if (this._backtrack) {
459 for (var k in backup) {
460 this[k] = backup[k];
461 }
462 return false;
463 }
464 return false;
465 },
466 // return next match in input
467 next: function() {
468 if (this.done) {
469 return this.EOF;
470 }
471 if (!this._input) {
472 this.done = true;
473 }
474 var token, match, tempMatch, index;
475 if (!this._more) {
476 this.yytext = "";
477 this.match = "";
478 }
479 var rules = this._currentRules();
480 for (var i = 0; i < rules.length; i++) {
481 tempMatch = this._input.match(this.rules[rules[i]]);
482 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
483 match = tempMatch;
484 index = i;
485 if (this.options.backtrack_lexer) {
486 token = this.test_match(tempMatch, rules[i]);
487 if (token !== false) {
488 return token;
489 } else if (this._backtrack) {
490 match = false;
491 continue;
492 } else {
493 return false;
494 }
495 } else if (!this.options.flex) {
496 break;
497 }
498 }
499 }
500 if (match) {
501 token = this.test_match(match, rules[index]);
502 if (token !== false) {
503 return token;
504 }
505 return false;
506 }
507 if (this._input === "") {
508 return this.EOF;
509 } else {
510 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
511 text: "",
512 token: null,
513 line: this.yylineno
514 });
515 }
516 },
517 // return next match that has a token
518 lex: function lex() {
519 var r = this.next();
520 if (r) {
521 return r;
522 } else {
523 return this.lex();
524 }
525 },
526 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
527 begin: function begin(condition) {
528 this.conditionStack.push(condition);
529 },
530 // pop the previously active lexer condition state off the condition stack
531 popState: function popState() {
532 var n = this.conditionStack.length - 1;
533 if (n > 0) {
534 return this.conditionStack.pop();
535 } else {
536 return this.conditionStack[0];
537 }
538 },
539 // produce the lexer rule set which is active for the currently active lexer condition state
540 _currentRules: function _currentRules() {
541 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
542 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
543 } else {
544 return this.conditions["INITIAL"].rules;
545 }
546 },
547 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
548 topState: function topState(n) {
549 n = this.conditionStack.length - 1 - Math.abs(n || 0);
550 if (n >= 0) {
551 return this.conditionStack[n];
552 } else {
553 return "INITIAL";
554 }
555 },
556 // alias for begin(condition)
557 pushState: function pushState(condition) {
558 this.begin(condition);
559 },
560 // return the number of states currently on the stack
561 stateStackSize: function stateStackSize() {
562 return this.conditionStack.length;
563 },
564 options: {},
565 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
566 switch ($avoiding_name_collisions) {
567 case 0:
568 return 10;
569 case 1:
570 yy.getLogger().debug("Found space-block");
571 return 31;
572 case 2:
573 yy.getLogger().debug("Found nl-block");
574 return 31;
575 case 3:
576 yy.getLogger().debug("Found space-block");
577 return 29;
578 case 4:
579 yy.getLogger().debug(".", yy_.yytext);
580 break;
581 case 5:
582 yy.getLogger().debug("_", yy_.yytext);
583 break;
584 case 6:
585 return 5;
586 case 7:
587 yy_.yytext = -1;
588 return 28;
589 case 8:
590 yy_.yytext = yy_.yytext.replace(/columns\s+/, "");
591 yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext);
592 return 28;
593 case 9:
594 this.pushState("md_string");
595 break;
596 case 10:
597 return "MD_STR";
598 case 11:
599 this.popState();
600 break;
601 case 12:
602 this.pushState("string");
603 break;
604 case 13:
605 yy.getLogger().debug("LEX: POPPING STR:", yy_.yytext);
606 this.popState();
607 break;
608 case 14:
609 yy.getLogger().debug("LEX: STR end:", yy_.yytext);
610 return "STR";
611 case 15:
612 yy_.yytext = yy_.yytext.replace(/space\:/, "");
613 yy.getLogger().debug("SPACE NUM (LEX)", yy_.yytext);
614 return 21;
615 case 16:
616 yy_.yytext = "1";
617 yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext);
618 return 21;
619 case 17:
620 return 43;
621 case 18:
622 return "LINKSTYLE";
623 case 19:
624 return "INTERPOLATE";
625 case 20:
626 this.pushState("CLASSDEF");
627 return 40;
628 case 21:
629 this.popState();
630 this.pushState("CLASSDEFID");
631 return "DEFAULT_CLASSDEF_ID";
632 case 22:
633 this.popState();
634 this.pushState("CLASSDEFID");
635 return 41;
636 case 23:
637 this.popState();
638 return 42;
639 case 24:
640 this.pushState("CLASS");
641 return 44;
642 case 25:
643 this.popState();
644 this.pushState("CLASS_STYLE");
645 return 45;
646 case 26:
647 this.popState();
648 return 46;
649 case 27:
650 this.pushState("STYLE_STMNT");
651 return 47;
652 case 28:
653 this.popState();
654 this.pushState("STYLE_DEFINITION");
655 return 48;
656 case 29:
657 this.popState();
658 return 49;
659 case 30:
660 this.pushState("acc_title");
661 return "acc_title";
662 case 31:
663 this.popState();
664 return "acc_title_value";
665 case 32:
666 this.pushState("acc_descr");
667 return "acc_descr";
668 case 33:
669 this.popState();
670 return "acc_descr_value";
671 case 34:
672 this.pushState("acc_descr_multiline");
673 break;
674 case 35:
675 this.popState();
676 break;
677 case 36:
678 return "acc_descr_multiline_value";
679 case 37:
680 return 30;
681 case 38:
682 this.popState();
683 yy.getLogger().debug("Lex: ((");
684 return "NODE_DEND";
685 case 39:
686 this.popState();
687 yy.getLogger().debug("Lex: ((");
688 return "NODE_DEND";
689 case 40:
690 this.popState();
691 yy.getLogger().debug("Lex: ))");
692 return "NODE_DEND";
693 case 41:
694 this.popState();
695 yy.getLogger().debug("Lex: ((");
696 return "NODE_DEND";
697 case 42:
698 this.popState();
699 yy.getLogger().debug("Lex: ((");
700 return "NODE_DEND";
701 case 43:
702 this.popState();
703 yy.getLogger().debug("Lex: (-");
704 return "NODE_DEND";
705 case 44:
706 this.popState();
707 yy.getLogger().debug("Lex: -)");
708 return "NODE_DEND";
709 case 45:
710 this.popState();
711 yy.getLogger().debug("Lex: ((");
712 return "NODE_DEND";
713 case 46:
714 this.popState();
715 yy.getLogger().debug("Lex: ]]");
716 return "NODE_DEND";
717 case 47:
718 this.popState();
719 yy.getLogger().debug("Lex: (");
720 return "NODE_DEND";
721 case 48:
722 this.popState();
723 yy.getLogger().debug("Lex: ])");
724 return "NODE_DEND";
725 case 49:
726 this.popState();
727 yy.getLogger().debug("Lex: /]");
728 return "NODE_DEND";
729 case 50:
730 this.popState();
731 yy.getLogger().debug("Lex: /]");
732 return "NODE_DEND";
733 case 51:
734 this.popState();
735 yy.getLogger().debug("Lex: )]");
736 return "NODE_DEND";
737 case 52:
738 this.popState();
739 yy.getLogger().debug("Lex: )");
740 return "NODE_DEND";
741 case 53:
742 this.popState();
743 yy.getLogger().debug("Lex: ]>");
744 return "NODE_DEND";
745 case 54:
746 this.popState();
747 yy.getLogger().debug("Lex: ]");
748 return "NODE_DEND";
749 case 55:
750 yy.getLogger().debug("Lexa: -)");
751 this.pushState("NODE");
752 return 36;
753 case 56:
754 yy.getLogger().debug("Lexa: (-");
755 this.pushState("NODE");
756 return 36;
757 case 57:
758 yy.getLogger().debug("Lexa: ))");
759 this.pushState("NODE");
760 return 36;
761 case 58:
762 yy.getLogger().debug("Lexa: )");
763 this.pushState("NODE");
764 return 36;
765 case 59:
766 yy.getLogger().debug("Lex: (((");
767 this.pushState("NODE");
768 return 36;
769 case 60:
770 yy.getLogger().debug("Lexa: )");
771 this.pushState("NODE");
772 return 36;
773 case 61:
774 yy.getLogger().debug("Lexa: )");
775 this.pushState("NODE");
776 return 36;
777 case 62:
778 yy.getLogger().debug("Lexa: )");
779 this.pushState("NODE");
780 return 36;
781 case 63:
782 yy.getLogger().debug("Lexc: >");
783 this.pushState("NODE");
784 return 36;
785 case 64:
786 yy.getLogger().debug("Lexa: ([");
787 this.pushState("NODE");
788 return 36;
789 case 65:
790 yy.getLogger().debug("Lexa: )");
791 this.pushState("NODE");
792 return 36;
793 case 66:
794 this.pushState("NODE");
795 return 36;
796 case 67:
797 this.pushState("NODE");
798 return 36;
799 case 68:
800 this.pushState("NODE");
801 return 36;
802 case 69:
803 this.pushState("NODE");
804 return 36;
805 case 70:
806 this.pushState("NODE");
807 return 36;
808 case 71:
809 this.pushState("NODE");
810 return 36;
811 case 72:
812 this.pushState("NODE");
813 return 36;
814 case 73:
815 yy.getLogger().debug("Lexa: [");
816 this.pushState("NODE");
817 return 36;
818 case 74:
819 this.pushState("BLOCK_ARROW");
820 yy.getLogger().debug("LEX ARR START");
821 return 38;
822 case 75:
823 yy.getLogger().debug("Lex: NODE_ID", yy_.yytext);
824 return 32;
825 case 76:
826 yy.getLogger().debug("Lex: EOF", yy_.yytext);
827 return 8;
828 case 77:
829 this.pushState("md_string");
830 break;
831 case 78:
832 this.pushState("md_string");
833 break;
834 case 79:
835 return "NODE_DESCR";
836 case 80:
837 this.popState();
838 break;
839 case 81:
840 yy.getLogger().debug("Lex: Starting string");
841 this.pushState("string");
842 break;
843 case 82:
844 yy.getLogger().debug("LEX ARR: Starting string");
845 this.pushState("string");
846 break;
847 case 83:
848 yy.getLogger().debug("LEX: NODE_DESCR:", yy_.yytext);
849 return "NODE_DESCR";
850 case 84:
851 yy.getLogger().debug("LEX POPPING");
852 this.popState();
853 break;
854 case 85:
855 yy.getLogger().debug("Lex: =>BAE");
856 this.pushState("ARROW_DIR");
857 break;
858 case 86:
859 yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
860 yy.getLogger().debug("Lex (right): dir:", yy_.yytext);
861 return "DIR";
862 case 87:
863 yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
864 yy.getLogger().debug("Lex (left):", yy_.yytext);
865 return "DIR";
866 case 88:
867 yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
868 yy.getLogger().debug("Lex (x):", yy_.yytext);
869 return "DIR";
870 case 89:
871 yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
872 yy.getLogger().debug("Lex (y):", yy_.yytext);
873 return "DIR";
874 case 90:
875 yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
876 yy.getLogger().debug("Lex (up):", yy_.yytext);
877 return "DIR";
878 case 91:
879 yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
880 yy.getLogger().debug("Lex (down):", yy_.yytext);
881 return "DIR";
882 case 92:
883 yy_.yytext = "]>";
884 yy.getLogger().debug("Lex (ARROW_DIR end):", yy_.yytext);
885 this.popState();
886 this.popState();
887 return "BLOCK_ARROW_END";
888 case 93:
889 yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#");
890 return 15;
891 case 94:
892 yy.getLogger().debug("Lex: LINK", yy_.yytext);
893 return 15;
894 case 95:
895 yy.getLogger().debug("Lex: LINK", yy_.yytext);
896 return 15;
897 case 96:
898 yy.getLogger().debug("Lex: LINK", yy_.yytext);
899 return 15;
900 case 97:
901 yy.getLogger().debug("Lex: START_LINK", yy_.yytext);
902 this.pushState("LLABEL");
903 return 16;
904 case 98:
905 yy.getLogger().debug("Lex: START_LINK", yy_.yytext);
906 this.pushState("LLABEL");
907 return 16;
908 case 99:
909 yy.getLogger().debug("Lex: START_LINK", yy_.yytext);
910 this.pushState("LLABEL");
911 return 16;
912 case 100:
913 this.pushState("md_string");
914 break;
915 case 101:
916 yy.getLogger().debug("Lex: Starting string");
917 this.pushState("string");
918 return "LINK_LABEL";
919 case 102:
920 this.popState();
921 yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#");
922 return 15;
923 case 103:
924 this.popState();
925 yy.getLogger().debug("Lex: LINK", yy_.yytext);
926 return 15;
927 case 104:
928 this.popState();
929 yy.getLogger().debug("Lex: LINK", yy_.yytext);
930 return 15;
931 case 105:
932 yy.getLogger().debug("Lex: COLON", yy_.yytext);
933 yy_.yytext = yy_.yytext.slice(1);
934 return 27;
935 }
936 },
937 rules: [/^(?:block-beta\b)/, /^(?:block\s+)/, /^(?:block\n+)/, /^(?:block:)/, /^(?:[\s]+)/, /^(?:[\n]+)/, /^(?:((\u000D\u000A)|(\u000A)))/, /^(?:columns\s+auto\b)/, /^(?:columns\s+[\d]+)/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:space[:]\d+)/, /^(?:space\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\s+)/, /^(?:DEFAULT\s+)/, /^(?:\w+\s+)/, /^(?:[^\n]*)/, /^(?:class\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:style\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:end\b\s*)/, /^(?:\(\(\()/, /^(?:\)\)\))/, /^(?:[\)]\))/, /^(?:\}\})/, /^(?:\})/, /^(?:\(-)/, /^(?:-\))/, /^(?:\(\()/, /^(?:\]\])/, /^(?:\()/, /^(?:\]\))/, /^(?:\\\])/, /^(?:\/\])/, /^(?:\)\])/, /^(?:[\)])/, /^(?:\]>)/, /^(?:[\]])/, /^(?:-\))/, /^(?:\(-)/, /^(?:\)\))/, /^(?:\))/, /^(?:\(\(\()/, /^(?:\(\()/, /^(?:\{\{)/, /^(?:\{)/, /^(?:>)/, /^(?:\(\[)/, /^(?:\()/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\[\\)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:\[)/, /^(?:<\[)/, /^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/, /^(?:$)/, /^(?:["][`])/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:\]>\s*\()/, /^(?:,?\s*right\s*)/, /^(?:,?\s*left\s*)/, /^(?:,?\s*x\s*)/, /^(?:,?\s*y\s*)/, /^(?:,?\s*up\s*)/, /^(?:,?\s*down\s*)/, /^(?:\)\s*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*~~[\~]+\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:["][`])/, /^(?:["])/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?::\d+)/],
938 conditions: { "STYLE_DEFINITION": { "rules": [29], "inclusive": false }, "STYLE_STMNT": { "rules": [28], "inclusive": false }, "CLASSDEFID": { "rules": [23], "inclusive": false }, "CLASSDEF": { "rules": [21, 22], "inclusive": false }, "CLASS_STYLE": { "rules": [26], "inclusive": false }, "CLASS": { "rules": [25], "inclusive": false }, "LLABEL": { "rules": [100, 101, 102, 103, 104], "inclusive": false }, "ARROW_DIR": { "rules": [86, 87, 88, 89, 90, 91, 92], "inclusive": false }, "BLOCK_ARROW": { "rules": [77, 82, 85], "inclusive": false }, "NODE": { "rules": [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 78, 81], "inclusive": false }, "md_string": { "rules": [10, 11, 79, 80], "inclusive": false }, "space": { "rules": [], "inclusive": false }, "string": { "rules": [13, 14, 83, 84], "inclusive": false }, "acc_descr_multiline": { "rules": [35, 36], "inclusive": false }, "acc_descr": { "rules": [33], "inclusive": false }, "acc_title": { "rules": [31], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 24, 27, 30, 32, 34, 37, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 93, 94, 95, 96, 97, 98, 99, 105], "inclusive": true } }
939 };
940 return lexer2;
941 }();
942 parser2.lexer = lexer;
943 function Parser() {
944 this.yy = {};
945 }
946 Parser.prototype = parser2;
947 parser2.Parser = Parser;
948 return new Parser();
949}();
950parser.parser = parser;
951const parser$1 = parser;
952let blockDatabase = {};
953let edgeList = [];
954let edgeCount = {};
955const COLOR_KEYWORD = "color";
956const FILL_KEYWORD = "fill";
957const BG_FILL = "bgFill";
958const STYLECLASS_SEP = ",";
959const config = getConfig();
960let classes = {};
961const sanitizeText = (txt) => common.sanitizeText(txt, config);
962const addStyleClass = function(id, styleAttributes = "") {
963 if (classes[id] === void 0) {
964 classes[id] = { id, styles: [], textStyles: [] };
965 }
966 const foundClass = classes[id];
967 if (styleAttributes !== void 0 && styleAttributes !== null) {
968 styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => {
969 const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim();
970 if (attrib.match(COLOR_KEYWORD)) {
971 const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL);
972 const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD);
973 foundClass.textStyles.push(newStyle2);
974 }
975 foundClass.styles.push(fixedAttrib);
976 });
977 }
978};
979const addStyle2Node = function(id, styles = "") {
980 const foundBlock = blockDatabase[id];
981 if (styles !== void 0 && styles !== null) {
982 foundBlock.styles = styles.split(STYLECLASS_SEP);
983 }
984};
985const setCssClass = function(itemIds, cssClassName) {
986 itemIds.split(",").forEach(function(id) {
987 let foundBlock = blockDatabase[id];
988 if (foundBlock === void 0) {
989 const trimmedId = id.trim();
990 blockDatabase[trimmedId] = { id: trimmedId, type: "na", children: [] };
991 foundBlock = blockDatabase[trimmedId];
992 }
993 if (!foundBlock.classes) {
994 foundBlock.classes = [];
995 }
996 foundBlock.classes.push(cssClassName);
997 });
998};
999const populateBlockDatabase = (_blockList, parent) => {
1000 const blockList = _blockList.flat();
1001 const children = [];
1002 for (const block of blockList) {
1003 if (block.label) {
1004 block.label = sanitizeText(block.label);
1005 }
1006 if (block.type === "classDef") {
1007 addStyleClass(block.id, block.css);
1008 continue;
1009 }
1010 if (block.type === "applyClass") {
1011 setCssClass(block.id, (block == null ? void 0 : block.styleClass) || "");
1012 continue;
1013 }
1014 if (block.type === "applyStyles") {
1015 if (block == null ? void 0 : block.stylesStr) {
1016 addStyle2Node(block.id, block == null ? void 0 : block.stylesStr);
1017 }
1018 continue;
1019 }
1020 if (block.type === "column-setting") {
1021 parent.columns = block.columns || -1;
1022 } else if (block.type === "edge") {
1023 if (edgeCount[block.id]) {
1024 edgeCount[block.id]++;
1025 } else {
1026 edgeCount[block.id] = 1;
1027 }
1028 block.id = edgeCount[block.id] + "-" + block.id;
1029 edgeList.push(block);
1030 } else {
1031 if (!block.label) {
1032 if (block.type === "composite") {
1033 block.label = "";
1034 } else {
1035 block.label = block.id;
1036 }
1037 }
1038 const newBlock = !blockDatabase[block.id];
1039 if (newBlock) {
1040 blockDatabase[block.id] = block;
1041 } else {
1042 if (block.type !== "na") {
1043 blockDatabase[block.id].type = block.type;
1044 }
1045 if (block.label !== block.id) {
1046 blockDatabase[block.id].label = block.label;
1047 }
1048 }
1049 if (block.children) {
1050 populateBlockDatabase(block.children, block);
1051 }
1052 if (block.type === "space") {
1053 const w = block.width || 1;
1054 for (let j = 0; j < w; j++) {
1055 const newBlock2 = clone(block);
1056 newBlock2.id = newBlock2.id + "-" + j;
1057 blockDatabase[newBlock2.id] = newBlock2;
1058 children.push(newBlock2);
1059 }
1060 } else if (newBlock) {
1061 children.push(block);
1062 }
1063 }
1064 }
1065 parent.children = children;
1066};
1067let blocks = [];
1068let rootBlock = { id: "root", type: "composite", children: [], columns: -1 };
1069const clear = () => {
1070 log.debug("Clear called");
1071 clear$1();
1072 rootBlock = { id: "root", type: "composite", children: [], columns: -1 };
1073 blockDatabase = { root: rootBlock };
1074 blocks = [];
1075 classes = {};
1076 edgeList = [];
1077 edgeCount = {};
1078};
1079function typeStr2Type(typeStr) {
1080 log.debug("typeStr2Type", typeStr);
1081 switch (typeStr) {
1082 case "[]":
1083 return "square";
1084 case "()":
1085 log.debug("we have a round");
1086 return "round";
1087 case "(())":
1088 return "circle";
1089 case ">]":
1090 return "rect_left_inv_arrow";
1091 case "{}":
1092 return "diamond";
1093 case "{{}}":
1094 return "hexagon";
1095 case "([])":
1096 return "stadium";
1097 case "[[]]":
1098 return "subroutine";
1099 case "[()]":
1100 return "cylinder";
1101 case "((()))":
1102 return "doublecircle";
1103 case "[//]":
1104 return "lean_right";
1105 case "[\\\\]":
1106 return "lean_left";
1107 case "[/\\]":
1108 return "trapezoid";
1109 case "[\\/]":
1110 return "inv_trapezoid";
1111 case "<[]>":
1112 return "block_arrow";
1113 default:
1114 return "na";
1115 }
1116}
1117function edgeTypeStr2Type(typeStr) {
1118 log.debug("typeStr2Type", typeStr);
1119 switch (typeStr) {
1120 case "==":
1121 return "thick";
1122 default:
1123 return "normal";
1124 }
1125}
1126function edgeStrToEdgeData(typeStr) {
1127 switch (typeStr.trim()) {
1128 case "--x":
1129 return "arrow_cross";
1130 case "--o":
1131 return "arrow_circle";
1132 default:
1133 return "arrow_point";
1134 }
1135}
1136let cnt = 0;
1137const generateId = () => {
1138 cnt++;
1139 return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt;
1140};
1141const setHierarchy = (block) => {
1142 rootBlock.children = block;
1143 populateBlockDatabase(block, rootBlock);
1144 blocks = rootBlock.children;
1145};
1146const getColumns = (blockId) => {
1147 const block = blockDatabase[blockId];
1148 if (!block) {
1149 return -1;
1150 }
1151 if (block.columns) {
1152 return block.columns;
1153 }
1154 if (!block.children) {
1155 return -1;
1156 }
1157 return block.children.length;
1158};
1159const getBlocksFlat = () => {
1160 return [...Object.values(blockDatabase)];
1161};
1162const getBlocks = () => {
1163 return blocks || [];
1164};
1165const getEdges = () => {
1166 return edgeList;
1167};
1168const getBlock = (id) => {
1169 return blockDatabase[id];
1170};
1171const setBlock = (block) => {
1172 blockDatabase[block.id] = block;
1173};
1174const getLogger = () => console;
1175const getClasses$1 = function() {
1176 return classes;
1177};
1178const db = {
1179 getConfig: () => getConfig$1().block,
1180 typeStr2Type,
1181 edgeTypeStr2Type,
1182 edgeStrToEdgeData,
1183 getLogger,
1184 getBlocksFlat,
1185 getBlocks,
1186 getEdges,
1187 setHierarchy,
1188 getBlock,
1189 setBlock,
1190 getColumns,
1191 getClasses: getClasses$1,
1192 clear,
1193 generateId
1194};
1195const db$1 = db;
1196const fade = (color, opacity) => {
1197 const channel$1 = channel;
1198 const r = channel$1(color, "r");
1199 const g = channel$1(color, "g");
1200 const b = channel$1(color, "b");
1201 return rgba(r, g, b, opacity);
1202};
1203const getStyles = (options) => `.label {
1204 font-family: ${options.fontFamily};
1205 color: ${options.nodeTextColor || options.textColor};
1206 }
1207 .cluster-label text {
1208 fill: ${options.titleColor};
1209 }
1210 .cluster-label span,p {
1211 color: ${options.titleColor};
1212 }
1213
1214
1215
1216 .label text,span,p {
1217 fill: ${options.nodeTextColor || options.textColor};
1218 color: ${options.nodeTextColor || options.textColor};
1219 }
1220
1221 .node rect,
1222 .node circle,
1223 .node ellipse,
1224 .node polygon,
1225 .node path {
1226 fill: ${options.mainBkg};
1227 stroke: ${options.nodeBorder};
1228 stroke-width: 1px;
1229 }
1230 .flowchart-label text {
1231 text-anchor: middle;
1232 }
1233 // .flowchart-label .text-outer-tspan {
1234 // text-anchor: middle;
1235 // }
1236 // .flowchart-label .text-inner-tspan {
1237 // text-anchor: start;
1238 // }
1239
1240 .node .label {
1241 text-align: center;
1242 }
1243 .node.clickable {
1244 cursor: pointer;
1245 }
1246
1247 .arrowheadPath {
1248 fill: ${options.arrowheadColor};
1249 }
1250
1251 .edgePath .path {
1252 stroke: ${options.lineColor};
1253 stroke-width: 2.0px;
1254 }
1255
1256 .flowchart-link {
1257 stroke: ${options.lineColor};
1258 fill: none;
1259 }
1260
1261 .edgeLabel {
1262 background-color: ${options.edgeLabelBackground};
1263 rect {
1264 opacity: 0.5;
1265 background-color: ${options.edgeLabelBackground};
1266 fill: ${options.edgeLabelBackground};
1267 }
1268 text-align: center;
1269 }
1270
1271 /* For html labels only */
1272 .labelBkg {
1273 background-color: ${fade(options.edgeLabelBackground, 0.5)};
1274 // background-color:
1275 }
1276
1277 .node .cluster {
1278 // fill: ${fade(options.mainBkg, 0.5)};
1279 fill: ${fade(options.clusterBkg, 0.5)};
1280 stroke: ${fade(options.clusterBorder, 0.2)};
1281 box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
1282 stroke-width: 1px;
1283 }
1284
1285 .cluster text {
1286 fill: ${options.titleColor};
1287 }
1288
1289 .cluster span,p {
1290 color: ${options.titleColor};
1291 }
1292 /* .cluster div {
1293 color: ${options.titleColor};
1294 } */
1295
1296 div.mermaidTooltip {
1297 position: absolute;
1298 text-align: center;
1299 max-width: 200px;
1300 padding: 2px;
1301 font-family: ${options.fontFamily};
1302 font-size: 12px;
1303 background: ${options.tertiaryColor};
1304 border: 1px solid ${options.border2};
1305 border-radius: 2px;
1306 pointer-events: none;
1307 z-index: 100;
1308 }
1309
1310 .flowchartTitleText {
1311 text-anchor: middle;
1312 font-size: 18px;
1313 fill: ${options.textColor};
1314 }
1315`;
1316const flowStyles = getStyles;
1317function getNodeFromBlock(block, db2, positioned = false) {
1318 var _a2, _b2, _c;
1319 const vertex = block;
1320 let classStr = "default";
1321 if ((((_a2 = vertex == null ? void 0 : vertex.classes) == null ? void 0 : _a2.length) || 0) > 0) {
1322 classStr = ((vertex == null ? void 0 : vertex.classes) || []).join(" ");
1323 }
1324 classStr = classStr + " flowchart-label";
1325 let radius = 0;
1326 let shape = "";
1327 let padding2;
1328 switch (vertex.type) {
1329 case "round":
1330 radius = 5;
1331 shape = "rect";
1332 break;
1333 case "composite":
1334 radius = 0;
1335 shape = "composite";
1336 padding2 = 0;
1337 break;
1338 case "square":
1339 shape = "rect";
1340 break;
1341 case "diamond":
1342 shape = "question";
1343 break;
1344 case "hexagon":
1345 shape = "hexagon";
1346 break;
1347 case "block_arrow":
1348 shape = "block_arrow";
1349 break;
1350 case "odd":
1351 shape = "rect_left_inv_arrow";
1352 break;
1353 case "lean_right":
1354 shape = "lean_right";
1355 break;
1356 case "lean_left":
1357 shape = "lean_left";
1358 break;
1359 case "trapezoid":
1360 shape = "trapezoid";
1361 break;
1362 case "inv_trapezoid":
1363 shape = "inv_trapezoid";
1364 break;
1365 case "rect_left_inv_arrow":
1366 shape = "rect_left_inv_arrow";
1367 break;
1368 case "circle":
1369 shape = "circle";
1370 break;
1371 case "ellipse":
1372 shape = "ellipse";
1373 break;
1374 case "stadium":
1375 shape = "stadium";
1376 break;
1377 case "subroutine":
1378 shape = "subroutine";
1379 break;
1380 case "cylinder":
1381 shape = "cylinder";
1382 break;
1383 case "group":
1384 shape = "rect";
1385 break;
1386 case "doublecircle":
1387 shape = "doublecircle";
1388 break;
1389 default:
1390 shape = "rect";
1391 }
1392 const styles = getStylesFromArray((vertex == null ? void 0 : vertex.styles) || []);
1393 const vertexText = vertex.label;
1394 const bounds = vertex.size || { width: 0, height: 0, x: 0, y: 0 };
1395 const node = {
1396 labelStyle: styles.labelStyle,
1397 shape,
1398 labelText: vertexText,
1399 rx: radius,
1400 ry: radius,
1401 class: classStr,
1402 style: styles.style,
1403 id: vertex.id,
1404 directions: vertex.directions,
1405 width: bounds.width,
1406 height: bounds.height,
1407 x: bounds.x,
1408 y: bounds.y,
1409 positioned,
1410 intersect: void 0,
1411 type: vertex.type,
1412 padding: padding2 ?? (((_c = (_b2 = getConfig$1()) == null ? void 0 : _b2.block) == null ? void 0 : _c.padding) || 0)
1413 };
1414 return node;
1415}
1416async function calculateBlockSize(elem, block, db2) {
1417 const node = getNodeFromBlock(block, db2, false);
1418 if (node.type === "group") {
1419 return;
1420 }
1421 const nodeEl = await insertNode(elem, node);
1422 const boundingBox = nodeEl.node().getBBox();
1423 const obj = db2.getBlock(node.id);
1424 obj.size = { width: boundingBox.width, height: boundingBox.height, x: 0, y: 0, node: nodeEl };
1425 db2.setBlock(obj);
1426 nodeEl.remove();
1427}
1428async function insertBlockPositioned(elem, block, db2) {
1429 const node = getNodeFromBlock(block, db2, true);
1430 const obj = db2.getBlock(node.id);
1431 if (obj.type !== "space") {
1432 await insertNode(elem, node);
1433 block.intersect = node == null ? void 0 : node.intersect;
1434 positionNode(node);
1435 }
1436}
1437async function performOperations(elem, blocks2, db2, operation) {
1438 for (const block of blocks2) {
1439 await operation(elem, block, db2);
1440 if (block.children) {
1441 await performOperations(elem, block.children, db2, operation);
1442 }
1443 }
1444}
1445async function calculateBlockSizes(elem, blocks2, db2) {
1446 await performOperations(elem, blocks2, db2, calculateBlockSize);
1447}
1448async function insertBlocks(elem, blocks2, db2) {
1449 await performOperations(elem, blocks2, db2, insertBlockPositioned);
1450}
1451async function insertEdges(elem, edges, blocks2, db2, id) {
1452 const g = new Graph({
1453 multigraph: true,
1454 compound: true
1455 });
1456 g.setGraph({
1457 rankdir: "TB",
1458 nodesep: 10,
1459 ranksep: 10,
1460 marginx: 8,
1461 marginy: 8
1462 });
1463 for (const block of blocks2) {
1464 if (block.size) {
1465 g.setNode(block.id, {
1466 width: block.size.width,
1467 height: block.size.height,
1468 intersect: block.intersect
1469 });
1470 }
1471 }
1472 for (const edge of edges) {
1473 if (edge.start && edge.end) {
1474 const startBlock = db2.getBlock(edge.start);
1475 const endBlock = db2.getBlock(edge.end);
1476 if ((startBlock == null ? void 0 : startBlock.size) && (endBlock == null ? void 0 : endBlock.size)) {
1477 const start = startBlock.size;
1478 const end = endBlock.size;
1479 const points = [
1480 { x: start.x, y: start.y },
1481 { x: start.x + (end.x - start.x) / 2, y: start.y + (end.y - start.y) / 2 },
1482 { x: end.x, y: end.y }
1483 ];
1484 await insertEdge(
1485 elem,
1486 { v: edge.start, w: edge.end, name: edge.id },
1487 {
1488 ...edge,
1489 arrowTypeEnd: edge.arrowTypeEnd,
1490 arrowTypeStart: edge.arrowTypeStart,
1491 points,
1492 classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"
1493 },
1494 void 0,
1495 "block",
1496 g,
1497 id
1498 );
1499 if (edge.label) {
1500 await insertEdgeLabel(elem, {
1501 ...edge,
1502 label: edge.label,
1503 labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;",
1504 arrowTypeEnd: edge.arrowTypeEnd,
1505 arrowTypeStart: edge.arrowTypeStart,
1506 points,
1507 classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"
1508 });
1509 await positionEdgeLabel(
1510 { ...edge, x: points[1].x, y: points[1].y },
1511 {
1512 originalPath: points
1513 }
1514 );
1515 }
1516 }
1517 }
1518 }
1519}
1520const padding = ((_b = (_a = getConfig()) == null ? void 0 : _a.block) == null ? void 0 : _b.padding) || 8;
1521function calculateBlockPosition(columns, position) {
1522 if (columns === 0 || !Number.isInteger(columns)) {
1523 throw new Error("Columns must be an integer !== 0.");
1524 }
1525 if (position < 0 || !Number.isInteger(position)) {
1526 throw new Error("Position must be a non-negative integer." + position);
1527 }
1528 if (columns < 0) {
1529 return { px: position, py: 0 };
1530 }
1531 if (columns === 1) {
1532 return { px: 0, py: position };
1533 }
1534 const px = position % columns;
1535 const py = Math.floor(position / columns);
1536 return { px, py };
1537}
1538const getMaxChildSize = (block) => {
1539 let maxWidth = 0;
1540 let maxHeight = 0;
1541 for (const child of block.children) {
1542 const { width, height, x, y } = child.size || { width: 0, height: 0, x: 0, y: 0 };
1543 log.debug(
1544 "getMaxChildSize abc95 child:",
1545 child.id,
1546 "width:",
1547 width,
1548 "height:",
1549 height,
1550 "x:",
1551 x,
1552 "y:",
1553 y,
1554 child.type
1555 );
1556 if (child.type === "space") {
1557 continue;
1558 }
1559 if (width > maxWidth) {
1560 maxWidth = width / (block.widthInColumns || 1);
1561 }
1562 if (height > maxHeight) {
1563 maxHeight = height;
1564 }
1565 }
1566 return { width: maxWidth, height: maxHeight };
1567};
1568function setBlockSizes(block, db2, siblingWidth = 0, siblingHeight = 0) {
1569 var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1570 log.debug(
1571 "setBlockSizes abc95 (start)",
1572 block.id,
1573 (_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x,
1574 "block width =",
1575 block == null ? void 0 : block.size,
1576 "sieblingWidth",
1577 siblingWidth
1578 );
1579 if (!((_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.width)) {
1580 block.size = {
1581 width: siblingWidth,
1582 height: siblingHeight,
1583 x: 0,
1584 y: 0
1585 };
1586 }
1587 let maxWidth = 0;
1588 let maxHeight = 0;
1589 if (((_c = block.children) == null ? void 0 : _c.length) > 0) {
1590 for (const child of block.children) {
1591 setBlockSizes(child, db2);
1592 }
1593 const childSize = getMaxChildSize(block);
1594 maxWidth = childSize.width;
1595 maxHeight = childSize.height;
1596 log.debug("setBlockSizes abc95 maxWidth of", block.id, ":s children is ", maxWidth, maxHeight);
1597 for (const child of block.children) {
1598 if (child.size) {
1599 log.debug(
1600 `abc95 Setting size of children of ${block.id} id=${child.id} ${maxWidth} ${maxHeight} ${child.size}`
1601 );
1602 child.size.width = maxWidth * (child.widthInColumns || 1) + padding * ((child.widthInColumns || 1) - 1);
1603 child.size.height = maxHeight;
1604 child.size.x = 0;
1605 child.size.y = 0;
1606 log.debug(
1607 `abc95 updating size of ${block.id} children child:${child.id} maxWidth:${maxWidth} maxHeight:${maxHeight}`
1608 );
1609 }
1610 }
1611 for (const child of block.children) {
1612 setBlockSizes(child, db2, maxWidth, maxHeight);
1613 }
1614 const columns = block.columns || -1;
1615 let numItems = 0;
1616 for (const child of block.children) {
1617 numItems += child.widthInColumns || 1;
1618 }
1619 let xSize = block.children.length;
1620 if (columns > 0 && columns < numItems) {
1621 xSize = columns;
1622 }
1623 block.widthInColumns || 1;
1624 const ySize = Math.ceil(numItems / xSize);
1625 let width = xSize * (maxWidth + padding) + padding;
1626 let height = ySize * (maxHeight + padding) + padding;
1627 if (width < siblingWidth) {
1628 log.debug(
1629 `Detected to small siebling: abc95 ${block.id} sieblingWidth ${siblingWidth} sieblingHeight ${siblingHeight} width ${width}`
1630 );
1631 width = siblingWidth;
1632 height = siblingHeight;
1633 const childWidth = (siblingWidth - xSize * padding - padding) / xSize;
1634 const childHeight = (siblingHeight - ySize * padding - padding) / ySize;
1635 log.debug("Size indata abc88", block.id, "childWidth", childWidth, "maxWidth", maxWidth);
1636 log.debug("Size indata abc88", block.id, "childHeight", childHeight, "maxHeight", maxHeight);
1637 log.debug("Size indata abc88 xSize", xSize, "padding", padding);
1638 for (const child of block.children) {
1639 if (child.size) {
1640 child.size.width = childWidth;
1641 child.size.height = childHeight;
1642 child.size.x = 0;
1643 child.size.y = 0;
1644 }
1645 }
1646 }
1647 log.debug(
1648 `abc95 (finale calc) ${block.id} xSize ${xSize} ySize ${ySize} columns ${columns}${block.children.length} width=${Math.max(width, ((_d = block.size) == null ? void 0 : _d.width) || 0)}`
1649 );
1650 if (width < (((_e = block == null ? void 0 : block.size) == null ? void 0 : _e.width) || 0)) {
1651 width = ((_f = block == null ? void 0 : block.size) == null ? void 0 : _f.width) || 0;
1652 const num = columns > 0 ? Math.min(block.children.length, columns) : block.children.length;
1653 if (num > 0) {
1654 const childWidth = (width - num * padding - padding) / num;
1655 log.debug("abc95 (growing to fit) width", block.id, width, (_g = block.size) == null ? void 0 : _g.width, childWidth);
1656 for (const child of block.children) {
1657 if (child.size) {
1658 child.size.width = childWidth;
1659 }
1660 }
1661 }
1662 }
1663 block.size = {
1664 width,
1665 height,
1666 x: 0,
1667 y: 0
1668 };
1669 }
1670 log.debug(
1671 "setBlockSizes abc94 (done)",
1672 block.id,
1673 (_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x,
1674 (_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width,
1675 (_j = block == null ? void 0 : block.size) == null ? void 0 : _j.y,
1676 (_k = block == null ? void 0 : block.size) == null ? void 0 : _k.height
1677 );
1678}
1679function layoutBlocks(block, db2) {
1680 var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1681 log.debug(
1682 `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${(_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x} y: ${(_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.y} width: ${(_c = block == null ? void 0 : block.size) == null ? void 0 : _c.width}`
1683 );
1684 const columns = block.columns || -1;
1685 log.debug("layoutBlocks columns abc95", block.id, "=>", columns, block);
1686 if (block.children && // find max width of children
1687 block.children.length > 0) {
1688 const width = ((_e = (_d = block == null ? void 0 : block.children[0]) == null ? void 0 : _d.size) == null ? void 0 : _e.width) || 0;
1689 const widthOfChildren = block.children.length * width + (block.children.length - 1) * padding;
1690 log.debug("widthOfChildren 88", widthOfChildren, "posX");
1691 let columnPos = 0;
1692 log.debug("abc91 block?.size?.x", block.id, (_f = block == null ? void 0 : block.size) == null ? void 0 : _f.x);
1693 let startingPosX = ((_g = block == null ? void 0 : block.size) == null ? void 0 : _g.x) ? ((_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x) + (-((_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width) / 2 || 0) : -padding;
1694 let rowPos = 0;
1695 for (const child of block.children) {
1696 const parent = block;
1697 if (!child.size) {
1698 continue;
1699 }
1700 const { width: width2, height } = child.size;
1701 const { px, py } = calculateBlockPosition(columns, columnPos);
1702 if (py != rowPos) {
1703 rowPos = py;
1704 startingPosX = ((_j = block == null ? void 0 : block.size) == null ? void 0 : _j.x) ? ((_k = block == null ? void 0 : block.size) == null ? void 0 : _k.x) + (-((_l = block == null ? void 0 : block.size) == null ? void 0 : _l.width) / 2 || 0) : -padding;
1705 log.debug("New row in layout for block", block.id, " and child ", child.id, rowPos);
1706 }
1707 log.debug(
1708 `abc89 layout blocks (child) id: ${child.id} Pos: ${columnPos} (px, py) ${px},${py} (${(_m = parent == null ? void 0 : parent.size) == null ? void 0 : _m.x},${(_n = parent == null ? void 0 : parent.size) == null ? void 0 : _n.y}) parent: ${parent.id} width: ${width2}${padding}`
1709 );
1710 if (parent.size) {
1711 const halfWidth = width2 / 2;
1712 child.size.x = startingPosX + padding + halfWidth;
1713 log.debug(
1714 `abc91 layout blocks (calc) px, pyid:${child.id} startingPos=X${startingPosX} new startingPosX${child.size.x} ${halfWidth} padding=${padding} width=${width2} halfWidth=${halfWidth} => x:${child.size.x} y:${child.size.y} ${child.widthInColumns} (width * (child?.w || 1)) / 2 ${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}`
1715 );
1716 startingPosX = child.size.x + halfWidth;
1717 child.size.y = parent.size.y - parent.size.height / 2 + py * (height + padding) + height / 2 + padding;
1718 log.debug(
1719 `abc88 layout blocks (calc) px, pyid:${child.id}startingPosX${startingPosX}${padding}${halfWidth}=>x:${child.size.x}y:${child.size.y}${child.widthInColumns}(width * (child?.w || 1)) / 2${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}`
1720 );
1721 }
1722 if (child.children) {
1723 layoutBlocks(child);
1724 }
1725 columnPos += (child == null ? void 0 : child.widthInColumns) || 1;
1726 log.debug("abc88 columnsPos", child, columnPos);
1727 }
1728 }
1729 log.debug(
1730 `layout blocks (<==layoutBlocks) ${block.id} x: ${(_o = block == null ? void 0 : block.size) == null ? void 0 : _o.x} y: ${(_p = block == null ? void 0 : block.size) == null ? void 0 : _p.y} width: ${(_q = block == null ? void 0 : block.size) == null ? void 0 : _q.width}`
1731 );
1732}
1733function findBounds(block, { minX, minY, maxX, maxY } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) {
1734 if (block.size && block.id !== "root") {
1735 const { x, y, width, height } = block.size;
1736 if (x - width / 2 < minX) {
1737 minX = x - width / 2;
1738 }
1739 if (y - height / 2 < minY) {
1740 minY = y - height / 2;
1741 }
1742 if (x + width / 2 > maxX) {
1743 maxX = x + width / 2;
1744 }
1745 if (y + height / 2 > maxY) {
1746 maxY = y + height / 2;
1747 }
1748 }
1749 if (block.children) {
1750 for (const child of block.children) {
1751 ({ minX, minY, maxX, maxY } = findBounds(child, { minX, minY, maxX, maxY }));
1752 }
1753 }
1754 return { minX, minY, maxX, maxY };
1755}
1756function layout(db2) {
1757 const root = db2.getBlock("root");
1758 if (!root) {
1759 return;
1760 }
1761 setBlockSizes(root, db2, 0, 0);
1762 layoutBlocks(root);
1763 log.debug("getBlocks", JSON.stringify(root, null, 2));
1764 const { minX, minY, maxX, maxY } = findBounds(root);
1765 const height = maxY - minY;
1766 const width = maxX - minX;
1767 return { x: minX, y: minY, width, height };
1768}
1769const getClasses = function(text, diagObj) {
1770 return diagObj.db.getClasses();
1771};
1772const draw = async function(text, id, _version, diagObj) {
1773 const { securityLevel, block: conf } = getConfig$1();
1774 const db2 = diagObj.db;
1775 let sandboxElement;
1776 if (securityLevel === "sandbox") {
1777 sandboxElement = d3select("#i" + id);
1778 }
1779 const root = securityLevel === "sandbox" ? d3select(sandboxElement.nodes()[0].contentDocument.body) : d3select("body");
1780 const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : d3select(`[id="${id}"]`);
1781 const markers = ["point", "circle", "cross"];
1782 insertMarkers(svg, markers, diagObj.type, id);
1783 const bl = db2.getBlocks();
1784 const blArr = db2.getBlocksFlat();
1785 const edges = db2.getEdges();
1786 const nodes = svg.insert("g").attr("class", "block");
1787 await calculateBlockSizes(nodes, bl, db2);
1788 const bounds = layout(db2);
1789 await insertBlocks(nodes, bl, db2);
1790 await insertEdges(nodes, edges, blArr, db2, id);
1791 if (bounds) {
1792 const bounds2 = bounds;
1793 const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height)));
1794 const height = bounds2.height + magicFactor + 10;
1795 const width = bounds2.width + 10;
1796 const { useMaxWidth } = conf;
1797 configureSvgSize(svg, height, width, !!useMaxWidth);
1798 log.debug("Here Bounds", bounds, bounds2);
1799 svg.attr(
1800 "viewBox",
1801 `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}`
1802 );
1803 }
1804 ordinal(d3schemeTableau10);
1805};
1806const renderer = {
1807 draw,
1808 getClasses
1809};
1810const diagram = {
1811 parser: parser$1,
1812 db: db$1,
1813 renderer,
1814 styles: flowStyles
1815};
1816export {
1817 diagram
1818};