import { insertEdge, insertEdgeLabel, insertMarkers$1, insertNode, positionEdgeLabel, positionNode } from "./chunk-TEMLD6Y2.js"; import "./chunk-2YCCOETS.js"; import { Graph, clone_default } from "./chunk-5METK6HB.js"; import { Tableau10_default, channel_default, clear, common$1, configureSvgSize, getConfig, getConfig$1, getStylesFromArray, log$1, ordinal, require_dist, rgba_default } from "./chunk-3PMDUHG4.js"; import "./chunk-CJRZFFQO.js"; import { select_default } from "./chunk-5KLUPWDV.js"; import "./chunk-HTVXVXIR.js"; import { require_dayjs_min } from "./chunk-V3IZG5IE.js"; import { __toESM } from "./chunk-TNDHKS54.js"; // node_modules/mermaid/dist/blockDiagram-9f4a6865.js var import_dayjs = __toESM(require_dayjs_min(), 1); var import_sanitize_url = __toESM(require_dist(), 1); var _a; var _b; var parser = function() { var o = function(k, v, o2, l) { for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ; return o2; }, $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]; var parser2 = { trace: function trace() { }, yy: {}, 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 }, 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" }, 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]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { var $0 = $$.length - 1; switch (yystate) { case 4: yy.getLogger().debug("Rule: separator (NL) "); break; case 5: yy.getLogger().debug("Rule: separator (Space) "); break; case 6: yy.getLogger().debug("Rule: separator (EOF) "); break; case 7: yy.getLogger().debug("Rule: hierarchy: ", $$[$0 - 1]); yy.setHierarchy($$[$0 - 1]); break; case 8: yy.getLogger().debug("Stop NL "); break; case 9: yy.getLogger().debug("Stop EOF "); break; case 10: yy.getLogger().debug("Stop NL2 "); break; case 11: yy.getLogger().debug("Stop EOF2 "); break; case 12: yy.getLogger().debug("Rule: statement: ", $$[$0]); typeof $$[$0].length === "number" ? this.$ = $$[$0] : this.$ = [$$[$0]]; break; case 13: yy.getLogger().debug("Rule: statement #2: ", $$[$0 - 1]); this.$ = [$$[$0 - 1]].concat($$[$0]); break; case 14: yy.getLogger().debug("Rule: link: ", $$[$0], yytext); this.$ = { edgeTypeStr: $$[$0], label: "" }; break; case 15: yy.getLogger().debug("Rule: LABEL link: ", $$[$0 - 3], $$[$0 - 1], $$[$0]); this.$ = { edgeTypeStr: $$[$0], label: $$[$0 - 1] }; break; case 18: const num = parseInt($$[$0]); const spaceId = yy.generateId(); this.$ = { id: spaceId, type: "space", label: "", width: num, children: [] }; break; case 23: yy.getLogger().debug("Rule: (nodeStatement link node) ", $$[$0 - 2], $$[$0 - 1], $$[$0], " typestr: ", $$[$0 - 1].edgeTypeStr); const edgeData = yy.edgeStrToEdgeData($$[$0 - 1].edgeTypeStr); this.$ = [ { id: $$[$0 - 2].id, label: $$[$0 - 2].label, type: $$[$0 - 2].type, directions: $$[$0 - 2].directions }, { 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" }, { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions } ]; break; case 24: yy.getLogger().debug("Rule: nodeStatement (abc88 node size) ", $$[$0 - 1], $$[$0]); this.$ = { id: $$[$0 - 1].id, label: $$[$0 - 1].label, type: yy.typeStr2Type($$[$0 - 1].typeStr), directions: $$[$0 - 1].directions, widthInColumns: parseInt($$[$0], 10) }; break; case 25: yy.getLogger().debug("Rule: nodeStatement (node) ", $$[$0]); this.$ = { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions, widthInColumns: 1 }; break; case 26: yy.getLogger().debug("APA123", this ? this : "na"); yy.getLogger().debug("COLUMNS: ", $$[$0]); this.$ = { type: "column-setting", columns: $$[$0] === "auto" ? -1 : parseInt($$[$0]) }; break; case 27: yy.getLogger().debug("Rule: id-block statement : ", $$[$0 - 2], $$[$0 - 1]); yy.generateId(); this.$ = { ...$$[$0 - 2], type: "composite", children: $$[$0 - 1] }; break; case 28: yy.getLogger().debug("Rule: blockStatement : ", $$[$0 - 2], $$[$0 - 1], $$[$0]); const id = yy.generateId(); this.$ = { id, type: "composite", label: "", children: $$[$0 - 1] }; break; case 29: yy.getLogger().debug("Rule: node (NODE_ID separator): ", $$[$0]); this.$ = { id: $$[$0] }; break; case 30: yy.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", $$[$0 - 1], $$[$0]); this.$ = { id: $$[$0 - 1], label: $$[$0].label, typeStr: $$[$0].typeStr, directions: $$[$0].directions }; break; case 31: yy.getLogger().debug("Rule: dirList: ", $$[$0]); this.$ = [$$[$0]]; break; case 32: yy.getLogger().debug("Rule: dirList: ", $$[$0 - 1], $$[$0]); this.$ = [$$[$0 - 1]].concat($$[$0]); break; case 33: yy.getLogger().debug("Rule: nodeShapeNLabel: ", $$[$0 - 2], $$[$0 - 1], $$[$0]); this.$ = { typeStr: $$[$0 - 2] + $$[$0], label: $$[$0 - 1] }; break; case 34: yy.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", $$[$0 - 3], $$[$0 - 2], " #3:", $$[$0 - 1], $$[$0]); this.$ = { typeStr: $$[$0 - 3] + $$[$0], label: $$[$0 - 2], directions: $$[$0 - 1] }; break; case 35: case 36: this.$ = { type: "classDef", id: $$[$0 - 1].trim(), css: $$[$0].trim() }; break; case 37: this.$ = { type: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; break; case 38: this.$ = { type: "applyStyles", id: $$[$0 - 1].trim(), stylesStr: $$[$0].trim() }; break; } }, 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] }], defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] }, parseError: function parseError(str, hash) { if (hash.recoverable) { this.trace(str); } else { var error = new Error(str); error.hash = hash; throw error; } }, parse: function parse(input) { var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; var args = lstack.slice.call(arguments, 1); var lexer2 = Object.create(this.lexer); var sharedState = { yy: {} }; for (var k in this.yy) { if (Object.prototype.hasOwnProperty.call(this.yy, k)) { sharedState.yy[k] = this.yy[k]; } } lexer2.setInput(input, sharedState.yy); sharedState.yy.lexer = lexer2; sharedState.yy.parser = this; if (typeof lexer2.yylloc == "undefined") { lexer2.yylloc = {}; } var yyloc = lexer2.yylloc; lstack.push(yyloc); var ranges = lexer2.options && lexer2.options.ranges; if (typeof sharedState.yy.parseError === "function") { this.parseError = sharedState.yy.parseError; } else { this.parseError = Object.getPrototypeOf(this).parseError; } function lex() { var token; token = tstack.pop() || lexer2.lex() || EOF; if (typeof token !== "number") { if (token instanceof Array) { tstack = token; token = tstack.pop(); } token = self.symbols_[token] || token; } return token; } var symbol, state, action, r, yyval = {}, p, len, newState, expected; while (true) { state = stack[stack.length - 1]; if (this.defaultActions[state]) { action = this.defaultActions[state]; } else { if (symbol === null || typeof symbol == "undefined") { symbol = lex(); } action = table[state] && table[state][symbol]; } if (typeof action === "undefined" || !action.length || !action[0]) { var errStr = ""; expected = []; for (p in table[state]) { if (this.terminals_[p] && p > TERROR) { expected.push("'" + this.terminals_[p] + "'"); } } if (lexer2.showPosition) { errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; } else { errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); } this.parseError(errStr, { text: lexer2.match, token: this.terminals_[symbol] || symbol, line: lexer2.yylineno, loc: yyloc, expected }); } if (action[0] instanceof Array && action.length > 1) { throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); } switch (action[0]) { case 1: stack.push(symbol); vstack.push(lexer2.yytext); lstack.push(lexer2.yylloc); stack.push(action[1]); symbol = null; { yyleng = lexer2.yyleng; yytext = lexer2.yytext; yylineno = lexer2.yylineno; yyloc = lexer2.yylloc; } break; case 2: len = this.productions_[action[1]][1]; yyval.$ = vstack[vstack.length - len]; yyval._$ = { first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column }; if (ranges) { yyval._$.range = [ lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1] ]; } r = this.performAction.apply(yyval, [ yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack ].concat(args)); if (typeof r !== "undefined") { return r; } if (len) { stack = stack.slice(0, -1 * len * 2); vstack = vstack.slice(0, -1 * len); lstack = lstack.slice(0, -1 * len); } stack.push(this.productions_[action[1]][0]); vstack.push(yyval.$); lstack.push(yyval._$); newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; stack.push(newState); break; case 3: return true; } } return true; } }; var lexer = /* @__PURE__ */ function() { var lexer2 = { EOF: 1, parseError: function parseError(str, hash) { if (this.yy.parser) { this.yy.parser.parseError(str, hash); } else { throw new Error(str); } }, // resets the lexer, sets new input setInput: function(input, yy) { this.yy = yy || this.yy || {}; this._input = input; this._more = this._backtrack = this.done = false; this.yylineno = this.yyleng = 0; this.yytext = this.matched = this.match = ""; this.conditionStack = ["INITIAL"]; this.yylloc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0 }; if (this.options.ranges) { this.yylloc.range = [0, 0]; } this.offset = 0; return this; }, // consumes and returns one char from the input input: function() { var ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; this.match += ch; this.matched += ch; var lines = ch.match(/(?:\r\n?|\n).*/g); if (lines) { this.yylineno++; this.yylloc.last_line++; } else { this.yylloc.last_column++; } if (this.options.ranges) { this.yylloc.range[1]++; } this._input = this._input.slice(1); return ch; }, // unshifts one char (or a string) into the input unput: function(ch) { var len = ch.length; var lines = ch.split(/(?:\r\n?|\n)/g); this._input = ch + this._input; this.yytext = this.yytext.substr(0, this.yytext.length - len); this.offset -= len; var oldLines = this.match.split(/(?:\r\n?|\n)/g); this.match = this.match.substr(0, this.match.length - 1); this.matched = this.matched.substr(0, this.matched.length - 1); if (lines.length - 1) { this.yylineno -= lines.length - 1; } var r = this.yylloc.range; this.yylloc = { first_line: this.yylloc.first_line, last_line: this.yylineno + 1, first_column: this.yylloc.first_column, 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 }; if (this.options.ranges) { this.yylloc.range = [r[0], r[0] + this.yyleng - len]; } this.yyleng = this.yytext.length; return this; }, // When called from action, caches matched text and appends it on next action more: function() { this._more = true; return this; }, // 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. reject: function() { if (this.options.backtrack_lexer) { this._backtrack = true; } else { 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(), { text: "", token: null, line: this.yylineno }); } return this; }, // retain first n characters of the match less: function(n) { this.unput(this.match.slice(n)); }, // displays already matched input, i.e. for error messages pastInput: function() { var past = this.matched.substr(0, this.matched.length - this.match.length); return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); }, // displays upcoming input, i.e. for error messages upcomingInput: function() { var next = this.match; if (next.length < 20) { next += this._input.substr(0, 20 - next.length); } return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); }, // displays the character position where the lexing error occurred, i.e. for error messages showPosition: function() { var pre = this.pastInput(); var c = new Array(pre.length + 1).join("-"); return pre + this.upcomingInput() + "\n" + c + "^"; }, // test the lexed token: return FALSE when not a match, otherwise return token test_match: function(match, indexed_rule) { var token, lines, backup; if (this.options.backtrack_lexer) { backup = { yylineno: this.yylineno, yylloc: { first_line: this.yylloc.first_line, last_line: this.last_line, first_column: this.yylloc.first_column, last_column: this.yylloc.last_column }, yytext: this.yytext, match: this.match, matches: this.matches, matched: this.matched, yyleng: this.yyleng, offset: this.offset, _more: this._more, _input: this._input, yy: this.yy, conditionStack: this.conditionStack.slice(0), done: this.done }; if (this.options.ranges) { backup.yylloc.range = this.yylloc.range.slice(0); } } lines = match[0].match(/(?:\r\n?|\n).*/g); if (lines) { this.yylineno += lines.length; } this.yylloc = { first_line: this.yylloc.last_line, last_line: this.yylineno + 1, first_column: this.yylloc.last_column, last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length }; this.yytext += match[0]; this.match += match[0]; this.matches = match; this.yyleng = this.yytext.length; if (this.options.ranges) { this.yylloc.range = [this.offset, this.offset += this.yyleng]; } this._more = false; this._backtrack = false; this._input = this._input.slice(match[0].length); this.matched += match[0]; token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); if (this.done && this._input) { this.done = false; } if (token) { return token; } else if (this._backtrack) { for (var k in backup) { this[k] = backup[k]; } return false; } return false; }, // return next match in input next: function() { if (this.done) { return this.EOF; } if (!this._input) { this.done = true; } var token, match, tempMatch, index; if (!this._more) { this.yytext = ""; this.match = ""; } var rules = this._currentRules(); for (var i = 0; i < rules.length; i++) { tempMatch = this._input.match(this.rules[rules[i]]); if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { match = tempMatch; index = i; if (this.options.backtrack_lexer) { token = this.test_match(tempMatch, rules[i]); if (token !== false) { return token; } else if (this._backtrack) { match = false; continue; } else { return false; } } else if (!this.options.flex) { break; } } } if (match) { token = this.test_match(match, rules[index]); if (token !== false) { return token; } return false; } if (this._input === "") { return this.EOF; } else { return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { text: "", token: null, line: this.yylineno }); } }, // return next match that has a token lex: function lex() { var r = this.next(); if (r) { return r; } else { return this.lex(); } }, // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) begin: function begin(condition) { this.conditionStack.push(condition); }, // pop the previously active lexer condition state off the condition stack popState: function popState() { var n = this.conditionStack.length - 1; if (n > 0) { return this.conditionStack.pop(); } else { return this.conditionStack[0]; } }, // produce the lexer rule set which is active for the currently active lexer condition state _currentRules: function _currentRules() { if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; } else { return this.conditions["INITIAL"].rules; } }, // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available topState: function topState(n) { n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; } else { return "INITIAL"; } }, // alias for begin(condition) pushState: function pushState(condition) { this.begin(condition); }, // return the number of states currently on the stack stateStackSize: function stateStackSize() { return this.conditionStack.length; }, options: {}, performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { switch ($avoiding_name_collisions) { case 0: return 10; case 1: yy.getLogger().debug("Found space-block"); return 31; case 2: yy.getLogger().debug("Found nl-block"); return 31; case 3: yy.getLogger().debug("Found space-block"); return 29; case 4: yy.getLogger().debug(".", yy_.yytext); break; case 5: yy.getLogger().debug("_", yy_.yytext); break; case 6: return 5; case 7: yy_.yytext = -1; return 28; case 8: yy_.yytext = yy_.yytext.replace(/columns\s+/, ""); yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); return 28; case 9: this.pushState("md_string"); break; case 10: return "MD_STR"; case 11: this.popState(); break; case 12: this.pushState("string"); break; case 13: yy.getLogger().debug("LEX: POPPING STR:", yy_.yytext); this.popState(); break; case 14: yy.getLogger().debug("LEX: STR end:", yy_.yytext); return "STR"; case 15: yy_.yytext = yy_.yytext.replace(/space\:/, ""); yy.getLogger().debug("SPACE NUM (LEX)", yy_.yytext); return 21; case 16: yy_.yytext = "1"; yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); return 21; case 17: return 43; case 18: return "LINKSTYLE"; case 19: return "INTERPOLATE"; case 20: this.pushState("CLASSDEF"); return 40; case 21: this.popState(); this.pushState("CLASSDEFID"); return "DEFAULT_CLASSDEF_ID"; case 22: this.popState(); this.pushState("CLASSDEFID"); return 41; case 23: this.popState(); return 42; case 24: this.pushState("CLASS"); return 44; case 25: this.popState(); this.pushState("CLASS_STYLE"); return 45; case 26: this.popState(); return 46; case 27: this.pushState("STYLE_STMNT"); return 47; case 28: this.popState(); this.pushState("STYLE_DEFINITION"); return 48; case 29: this.popState(); return 49; case 30: this.pushState("acc_title"); return "acc_title"; case 31: this.popState(); return "acc_title_value"; case 32: this.pushState("acc_descr"); return "acc_descr"; case 33: this.popState(); return "acc_descr_value"; case 34: this.pushState("acc_descr_multiline"); break; case 35: this.popState(); break; case 36: return "acc_descr_multiline_value"; case 37: return 30; case 38: this.popState(); yy.getLogger().debug("Lex: (("); return "NODE_DEND"; case 39: this.popState(); yy.getLogger().debug("Lex: (("); return "NODE_DEND"; case 40: this.popState(); yy.getLogger().debug("Lex: ))"); return "NODE_DEND"; case 41: this.popState(); yy.getLogger().debug("Lex: (("); return "NODE_DEND"; case 42: this.popState(); yy.getLogger().debug("Lex: (("); return "NODE_DEND"; case 43: this.popState(); yy.getLogger().debug("Lex: (-"); return "NODE_DEND"; case 44: this.popState(); yy.getLogger().debug("Lex: -)"); return "NODE_DEND"; case 45: this.popState(); yy.getLogger().debug("Lex: (("); return "NODE_DEND"; case 46: this.popState(); yy.getLogger().debug("Lex: ]]"); return "NODE_DEND"; case 47: this.popState(); yy.getLogger().debug("Lex: ("); return "NODE_DEND"; case 48: this.popState(); yy.getLogger().debug("Lex: ])"); return "NODE_DEND"; case 49: this.popState(); yy.getLogger().debug("Lex: /]"); return "NODE_DEND"; case 50: this.popState(); yy.getLogger().debug("Lex: /]"); return "NODE_DEND"; case 51: this.popState(); yy.getLogger().debug("Lex: )]"); return "NODE_DEND"; case 52: this.popState(); yy.getLogger().debug("Lex: )"); return "NODE_DEND"; case 53: this.popState(); yy.getLogger().debug("Lex: ]>"); return "NODE_DEND"; case 54: this.popState(); yy.getLogger().debug("Lex: ]"); return "NODE_DEND"; case 55: yy.getLogger().debug("Lexa: -)"); this.pushState("NODE"); return 36; case 56: yy.getLogger().debug("Lexa: (-"); this.pushState("NODE"); return 36; case 57: yy.getLogger().debug("Lexa: ))"); this.pushState("NODE"); return 36; case 58: yy.getLogger().debug("Lexa: )"); this.pushState("NODE"); return 36; case 59: yy.getLogger().debug("Lex: ((("); this.pushState("NODE"); return 36; case 60: yy.getLogger().debug("Lexa: )"); this.pushState("NODE"); return 36; case 61: yy.getLogger().debug("Lexa: )"); this.pushState("NODE"); return 36; case 62: yy.getLogger().debug("Lexa: )"); this.pushState("NODE"); return 36; case 63: yy.getLogger().debug("Lexc: >"); this.pushState("NODE"); return 36; case 64: yy.getLogger().debug("Lexa: (["); this.pushState("NODE"); return 36; case 65: yy.getLogger().debug("Lexa: )"); this.pushState("NODE"); return 36; case 66: this.pushState("NODE"); return 36; case 67: this.pushState("NODE"); return 36; case 68: this.pushState("NODE"); return 36; case 69: this.pushState("NODE"); return 36; case 70: this.pushState("NODE"); return 36; case 71: this.pushState("NODE"); return 36; case 72: this.pushState("NODE"); return 36; case 73: yy.getLogger().debug("Lexa: ["); this.pushState("NODE"); return 36; case 74: this.pushState("BLOCK_ARROW"); yy.getLogger().debug("LEX ARR START"); return 38; case 75: yy.getLogger().debug("Lex: NODE_ID", yy_.yytext); return 32; case 76: yy.getLogger().debug("Lex: EOF", yy_.yytext); return 8; case 77: this.pushState("md_string"); break; case 78: this.pushState("md_string"); break; case 79: return "NODE_DESCR"; case 80: this.popState(); break; case 81: yy.getLogger().debug("Lex: Starting string"); this.pushState("string"); break; case 82: yy.getLogger().debug("LEX ARR: Starting string"); this.pushState("string"); break; case 83: yy.getLogger().debug("LEX: NODE_DESCR:", yy_.yytext); return "NODE_DESCR"; case 84: yy.getLogger().debug("LEX POPPING"); this.popState(); break; case 85: yy.getLogger().debug("Lex: =>BAE"); this.pushState("ARROW_DIR"); break; case 86: yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); yy.getLogger().debug("Lex (right): dir:", yy_.yytext); return "DIR"; case 87: yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); yy.getLogger().debug("Lex (left):", yy_.yytext); return "DIR"; case 88: yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); yy.getLogger().debug("Lex (x):", yy_.yytext); return "DIR"; case 89: yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); yy.getLogger().debug("Lex (y):", yy_.yytext); return "DIR"; case 90: yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); yy.getLogger().debug("Lex (up):", yy_.yytext); return "DIR"; case 91: yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); yy.getLogger().debug("Lex (down):", yy_.yytext); return "DIR"; case 92: yy_.yytext = "]>"; yy.getLogger().debug("Lex (ARROW_DIR end):", yy_.yytext); this.popState(); this.popState(); return "BLOCK_ARROW_END"; case 93: yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); return 15; case 94: yy.getLogger().debug("Lex: LINK", yy_.yytext); return 15; case 95: yy.getLogger().debug("Lex: LINK", yy_.yytext); return 15; case 96: yy.getLogger().debug("Lex: LINK", yy_.yytext); return 15; case 97: yy.getLogger().debug("Lex: START_LINK", yy_.yytext); this.pushState("LLABEL"); return 16; case 98: yy.getLogger().debug("Lex: START_LINK", yy_.yytext); this.pushState("LLABEL"); return 16; case 99: yy.getLogger().debug("Lex: START_LINK", yy_.yytext); this.pushState("LLABEL"); return 16; case 100: this.pushState("md_string"); break; case 101: yy.getLogger().debug("Lex: Starting string"); this.pushState("string"); return "LINK_LABEL"; case 102: this.popState(); yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); return 15; case 103: this.popState(); yy.getLogger().debug("Lex: LINK", yy_.yytext); return 15; case 104: this.popState(); yy.getLogger().debug("Lex: LINK", yy_.yytext); return 15; case 105: yy.getLogger().debug("Lex: COLON", yy_.yytext); yy_.yytext = yy_.yytext.slice(1); return 27; } }, 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+)/], 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 } } }; return lexer2; }(); parser2.lexer = lexer; function Parser() { this.yy = {}; } Parser.prototype = parser2; parser2.Parser = Parser; return new Parser(); }(); parser.parser = parser; var parser$1 = parser; var blockDatabase = {}; var edgeList = []; var edgeCount = {}; var COLOR_KEYWORD = "color"; var FILL_KEYWORD = "fill"; var BG_FILL = "bgFill"; var STYLECLASS_SEP = ","; var config = getConfig(); var classes = {}; var sanitizeText = (txt) => common$1.sanitizeText(txt, config); var addStyleClass = function(id, styleAttributes = "") { if (classes[id] === void 0) { classes[id] = { id, styles: [], textStyles: [] }; } const foundClass = classes[id]; if (styleAttributes !== void 0 && styleAttributes !== null) { styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); if (attrib.match(COLOR_KEYWORD)) { const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL); const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD); foundClass.textStyles.push(newStyle2); } foundClass.styles.push(fixedAttrib); }); } }; var addStyle2Node = function(id, styles = "") { const foundBlock = blockDatabase[id]; if (styles !== void 0 && styles !== null) { foundBlock.styles = styles.split(STYLECLASS_SEP); } }; var setCssClass = function(itemIds, cssClassName) { itemIds.split(",").forEach(function(id) { let foundBlock = blockDatabase[id]; if (foundBlock === void 0) { const trimmedId = id.trim(); blockDatabase[trimmedId] = { id: trimmedId, type: "na", children: [] }; foundBlock = blockDatabase[trimmedId]; } if (!foundBlock.classes) { foundBlock.classes = []; } foundBlock.classes.push(cssClassName); }); }; var populateBlockDatabase = (_blockList, parent) => { const blockList = _blockList.flat(); const children = []; for (const block of blockList) { if (block.label) { block.label = sanitizeText(block.label); } if (block.type === "classDef") { addStyleClass(block.id, block.css); continue; } if (block.type === "applyClass") { setCssClass(block.id, (block == null ? void 0 : block.styleClass) || ""); continue; } if (block.type === "applyStyles") { if (block == null ? void 0 : block.stylesStr) { addStyle2Node(block.id, block == null ? void 0 : block.stylesStr); } continue; } if (block.type === "column-setting") { parent.columns = block.columns || -1; } else if (block.type === "edge") { if (edgeCount[block.id]) { edgeCount[block.id]++; } else { edgeCount[block.id] = 1; } block.id = edgeCount[block.id] + "-" + block.id; edgeList.push(block); } else { if (!block.label) { if (block.type === "composite") { block.label = ""; } else { block.label = block.id; } } const newBlock = !blockDatabase[block.id]; if (newBlock) { blockDatabase[block.id] = block; } else { if (block.type !== "na") { blockDatabase[block.id].type = block.type; } if (block.label !== block.id) { blockDatabase[block.id].label = block.label; } } if (block.children) { populateBlockDatabase(block.children, block); } if (block.type === "space") { const w = block.width || 1; for (let j = 0; j < w; j++) { const newBlock2 = clone_default(block); newBlock2.id = newBlock2.id + "-" + j; blockDatabase[newBlock2.id] = newBlock2; children.push(newBlock2); } } else if (newBlock) { children.push(block); } } } parent.children = children; }; var blocks = []; var rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; var clear2 = () => { log$1.debug("Clear called"); clear(); rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; blockDatabase = { root: rootBlock }; blocks = []; classes = {}; edgeList = []; edgeCount = {}; }; function typeStr2Type(typeStr) { log$1.debug("typeStr2Type", typeStr); switch (typeStr) { case "[]": return "square"; case "()": log$1.debug("we have a round"); return "round"; case "(())": return "circle"; case ">]": return "rect_left_inv_arrow"; case "{}": return "diamond"; case "{{}}": return "hexagon"; case "([])": return "stadium"; case "[[]]": return "subroutine"; case "[()]": return "cylinder"; case "((()))": return "doublecircle"; case "[//]": return "lean_right"; case "[\\\\]": return "lean_left"; case "[/\\]": return "trapezoid"; case "[\\/]": return "inv_trapezoid"; case "<[]>": return "block_arrow"; default: return "na"; } } function edgeTypeStr2Type(typeStr) { log$1.debug("typeStr2Type", typeStr); switch (typeStr) { case "==": return "thick"; default: return "normal"; } } function edgeStrToEdgeData(typeStr) { switch (typeStr.trim()) { case "--x": return "arrow_cross"; case "--o": return "arrow_circle"; default: return "arrow_point"; } } var cnt = 0; var generateId = () => { cnt++; return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt; }; var setHierarchy = (block) => { rootBlock.children = block; populateBlockDatabase(block, rootBlock); blocks = rootBlock.children; }; var getColumns = (blockId) => { const block = blockDatabase[blockId]; if (!block) { return -1; } if (block.columns) { return block.columns; } if (!block.children) { return -1; } return block.children.length; }; var getBlocksFlat = () => { return [...Object.values(blockDatabase)]; }; var getBlocks = () => { return blocks || []; }; var getEdges = () => { return edgeList; }; var getBlock = (id) => { return blockDatabase[id]; }; var setBlock = (block) => { blockDatabase[block.id] = block; }; var getLogger = () => console; var getClasses$1 = function() { return classes; }; var db = { getConfig: () => getConfig$1().block, typeStr2Type, edgeTypeStr2Type, edgeStrToEdgeData, getLogger, getBlocksFlat, getBlocks, getEdges, setHierarchy, getBlock, setBlock, getColumns, getClasses: getClasses$1, clear: clear2, generateId }; var db$1 = db; var fade = (color, opacity) => { const channel = channel_default; const r = channel(color, "r"); const g = channel(color, "g"); const b = channel(color, "b"); return rgba_default(r, g, b, opacity); }; var getStyles = (options) => `.label { font-family: ${options.fontFamily}; color: ${options.nodeTextColor || options.textColor}; } .cluster-label text { fill: ${options.titleColor}; } .cluster-label span,p { color: ${options.titleColor}; } .label text,span,p { fill: ${options.nodeTextColor || options.textColor}; color: ${options.nodeTextColor || options.textColor}; } .node rect, .node circle, .node ellipse, .node polygon, .node path { fill: ${options.mainBkg}; stroke: ${options.nodeBorder}; stroke-width: 1px; } .flowchart-label text { text-anchor: middle; } // .flowchart-label .text-outer-tspan { // text-anchor: middle; // } // .flowchart-label .text-inner-tspan { // text-anchor: start; // } .node .label { text-align: center; } .node.clickable { cursor: pointer; } .arrowheadPath { fill: ${options.arrowheadColor}; } .edgePath .path { stroke: ${options.lineColor}; stroke-width: 2.0px; } .flowchart-link { stroke: ${options.lineColor}; fill: none; } .edgeLabel { background-color: ${options.edgeLabelBackground}; rect { opacity: 0.5; background-color: ${options.edgeLabelBackground}; fill: ${options.edgeLabelBackground}; } text-align: center; } /* For html labels only */ .labelBkg { background-color: ${fade(options.edgeLabelBackground, 0.5)}; // background-color: } .node .cluster { // fill: ${fade(options.mainBkg, 0.5)}; fill: ${fade(options.clusterBkg, 0.5)}; stroke: ${fade(options.clusterBorder, 0.2)}; box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px; stroke-width: 1px; } .cluster text { fill: ${options.titleColor}; } .cluster span,p { color: ${options.titleColor}; } /* .cluster div { color: ${options.titleColor}; } */ div.mermaidTooltip { position: absolute; text-align: center; max-width: 200px; padding: 2px; font-family: ${options.fontFamily}; font-size: 12px; background: ${options.tertiaryColor}; border: 1px solid ${options.border2}; border-radius: 2px; pointer-events: none; z-index: 100; } .flowchartTitleText { text-anchor: middle; font-size: 18px; fill: ${options.textColor}; } `; var flowStyles = getStyles; function getNodeFromBlock(block, db2, positioned = false) { var _a2, _b2, _c; const vertex = block; let classStr = "default"; if ((((_a2 = vertex == null ? void 0 : vertex.classes) == null ? void 0 : _a2.length) || 0) > 0) { classStr = ((vertex == null ? void 0 : vertex.classes) || []).join(" "); } classStr = classStr + " flowchart-label"; let radius = 0; let shape = ""; let padding2; switch (vertex.type) { case "round": radius = 5; shape = "rect"; break; case "composite": radius = 0; shape = "composite"; padding2 = 0; break; case "square": shape = "rect"; break; case "diamond": shape = "question"; break; case "hexagon": shape = "hexagon"; break; case "block_arrow": shape = "block_arrow"; break; case "odd": shape = "rect_left_inv_arrow"; break; case "lean_right": shape = "lean_right"; break; case "lean_left": shape = "lean_left"; break; case "trapezoid": shape = "trapezoid"; break; case "inv_trapezoid": shape = "inv_trapezoid"; break; case "rect_left_inv_arrow": shape = "rect_left_inv_arrow"; break; case "circle": shape = "circle"; break; case "ellipse": shape = "ellipse"; break; case "stadium": shape = "stadium"; break; case "subroutine": shape = "subroutine"; break; case "cylinder": shape = "cylinder"; break; case "group": shape = "rect"; break; case "doublecircle": shape = "doublecircle"; break; default: shape = "rect"; } const styles = getStylesFromArray((vertex == null ? void 0 : vertex.styles) || []); const vertexText = vertex.label; const bounds = vertex.size || { width: 0, height: 0, x: 0, y: 0 }; const node = { labelStyle: styles.labelStyle, shape, labelText: vertexText, rx: radius, ry: radius, class: classStr, style: styles.style, id: vertex.id, directions: vertex.directions, width: bounds.width, height: bounds.height, x: bounds.x, y: bounds.y, positioned, intersect: void 0, type: vertex.type, padding: padding2 ?? (((_c = (_b2 = getConfig$1()) == null ? void 0 : _b2.block) == null ? void 0 : _c.padding) || 0) }; return node; } async function calculateBlockSize(elem, block, db2) { const node = getNodeFromBlock(block, db2, false); if (node.type === "group") { return; } const nodeEl = await insertNode(elem, node); const boundingBox = nodeEl.node().getBBox(); const obj = db2.getBlock(node.id); obj.size = { width: boundingBox.width, height: boundingBox.height, x: 0, y: 0, node: nodeEl }; db2.setBlock(obj); nodeEl.remove(); } async function insertBlockPositioned(elem, block, db2) { const node = getNodeFromBlock(block, db2, true); const obj = db2.getBlock(node.id); if (obj.type !== "space") { await insertNode(elem, node); block.intersect = node == null ? void 0 : node.intersect; positionNode(node); } } async function performOperations(elem, blocks2, db2, operation) { for (const block of blocks2) { await operation(elem, block, db2); if (block.children) { await performOperations(elem, block.children, db2, operation); } } } async function calculateBlockSizes(elem, blocks2, db2) { await performOperations(elem, blocks2, db2, calculateBlockSize); } async function insertBlocks(elem, blocks2, db2) { await performOperations(elem, blocks2, db2, insertBlockPositioned); } async function insertEdges(elem, edges, blocks2, db2, id) { const g = new Graph({ multigraph: true, compound: true }); g.setGraph({ rankdir: "TB", nodesep: 10, ranksep: 10, marginx: 8, marginy: 8 }); for (const block of blocks2) { if (block.size) { g.setNode(block.id, { width: block.size.width, height: block.size.height, intersect: block.intersect }); } } for (const edge of edges) { if (edge.start && edge.end) { const startBlock = db2.getBlock(edge.start); const endBlock = db2.getBlock(edge.end); if ((startBlock == null ? void 0 : startBlock.size) && (endBlock == null ? void 0 : endBlock.size)) { const start = startBlock.size; const end = endBlock.size; const points = [ { x: start.x, y: start.y }, { x: start.x + (end.x - start.x) / 2, y: start.y + (end.y - start.y) / 2 }, { x: end.x, y: end.y } ]; await insertEdge( elem, { v: edge.start, w: edge.end, name: edge.id }, { ...edge, arrowTypeEnd: edge.arrowTypeEnd, arrowTypeStart: edge.arrowTypeStart, points, classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" }, void 0, "block", g, id ); if (edge.label) { await insertEdgeLabel(elem, { ...edge, label: edge.label, labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;", arrowTypeEnd: edge.arrowTypeEnd, arrowTypeStart: edge.arrowTypeStart, points, classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" }); await positionEdgeLabel( { ...edge, x: points[1].x, y: points[1].y }, { originalPath: points } ); } } } } } var padding = ((_b = (_a = getConfig()) == null ? void 0 : _a.block) == null ? void 0 : _b.padding) || 8; function calculateBlockPosition(columns, position) { if (columns === 0 || !Number.isInteger(columns)) { throw new Error("Columns must be an integer !== 0."); } if (position < 0 || !Number.isInteger(position)) { throw new Error("Position must be a non-negative integer." + position); } if (columns < 0) { return { px: position, py: 0 }; } if (columns === 1) { return { px: 0, py: position }; } const px = position % columns; const py = Math.floor(position / columns); return { px, py }; } var getMaxChildSize = (block) => { let maxWidth = 0; let maxHeight = 0; for (const child of block.children) { const { width, height, x, y } = child.size || { width: 0, height: 0, x: 0, y: 0 }; log$1.debug( "getMaxChildSize abc95 child:", child.id, "width:", width, "height:", height, "x:", x, "y:", y, child.type ); if (child.type === "space") { continue; } if (width > maxWidth) { maxWidth = width / (block.widthInColumns || 1); } if (height > maxHeight) { maxHeight = height; } } return { width: maxWidth, height: maxHeight }; }; function setBlockSizes(block, db2, siblingWidth = 0, siblingHeight = 0) { var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k; log$1.debug( "setBlockSizes abc95 (start)", block.id, (_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x, "block width =", block == null ? void 0 : block.size, "sieblingWidth", siblingWidth ); if (!((_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.width)) { block.size = { width: siblingWidth, height: siblingHeight, x: 0, y: 0 }; } let maxWidth = 0; let maxHeight = 0; if (((_c = block.children) == null ? void 0 : _c.length) > 0) { for (const child of block.children) { setBlockSizes(child, db2); } const childSize = getMaxChildSize(block); maxWidth = childSize.width; maxHeight = childSize.height; log$1.debug("setBlockSizes abc95 maxWidth of", block.id, ":s children is ", maxWidth, maxHeight); for (const child of block.children) { if (child.size) { log$1.debug( `abc95 Setting size of children of ${block.id} id=${child.id} ${maxWidth} ${maxHeight} ${child.size}` ); child.size.width = maxWidth * (child.widthInColumns || 1) + padding * ((child.widthInColumns || 1) - 1); child.size.height = maxHeight; child.size.x = 0; child.size.y = 0; log$1.debug( `abc95 updating size of ${block.id} children child:${child.id} maxWidth:${maxWidth} maxHeight:${maxHeight}` ); } } for (const child of block.children) { setBlockSizes(child, db2, maxWidth, maxHeight); } const columns = block.columns || -1; let numItems = 0; for (const child of block.children) { numItems += child.widthInColumns || 1; } let xSize = block.children.length; if (columns > 0 && columns < numItems) { xSize = columns; } block.widthInColumns || 1; const ySize = Math.ceil(numItems / xSize); let width = xSize * (maxWidth + padding) + padding; let height = ySize * (maxHeight + padding) + padding; if (width < siblingWidth) { log$1.debug( `Detected to small siebling: abc95 ${block.id} sieblingWidth ${siblingWidth} sieblingHeight ${siblingHeight} width ${width}` ); width = siblingWidth; height = siblingHeight; const childWidth = (siblingWidth - xSize * padding - padding) / xSize; const childHeight = (siblingHeight - ySize * padding - padding) / ySize; log$1.debug("Size indata abc88", block.id, "childWidth", childWidth, "maxWidth", maxWidth); log$1.debug("Size indata abc88", block.id, "childHeight", childHeight, "maxHeight", maxHeight); log$1.debug("Size indata abc88 xSize", xSize, "padding", padding); for (const child of block.children) { if (child.size) { child.size.width = childWidth; child.size.height = childHeight; child.size.x = 0; child.size.y = 0; } } } log$1.debug( `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)}` ); if (width < (((_e = block == null ? void 0 : block.size) == null ? void 0 : _e.width) || 0)) { width = ((_f = block == null ? void 0 : block.size) == null ? void 0 : _f.width) || 0; const num = columns > 0 ? Math.min(block.children.length, columns) : block.children.length; if (num > 0) { const childWidth = (width - num * padding - padding) / num; log$1.debug("abc95 (growing to fit) width", block.id, width, (_g = block.size) == null ? void 0 : _g.width, childWidth); for (const child of block.children) { if (child.size) { child.size.width = childWidth; } } } } block.size = { width, height, x: 0, y: 0 }; } log$1.debug( "setBlockSizes abc94 (done)", block.id, (_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x, (_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width, (_j = block == null ? void 0 : block.size) == null ? void 0 : _j.y, (_k = block == null ? void 0 : block.size) == null ? void 0 : _k.height ); } function layoutBlocks(block, db2) { var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q; log$1.debug( `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}` ); const columns = block.columns || -1; log$1.debug("layoutBlocks columns abc95", block.id, "=>", columns, block); if (block.children && // find max width of children block.children.length > 0) { const width = ((_e = (_d = block == null ? void 0 : block.children[0]) == null ? void 0 : _d.size) == null ? void 0 : _e.width) || 0; const widthOfChildren = block.children.length * width + (block.children.length - 1) * padding; log$1.debug("widthOfChildren 88", widthOfChildren, "posX"); let columnPos = 0; log$1.debug("abc91 block?.size?.x", block.id, (_f = block == null ? void 0 : block.size) == null ? void 0 : _f.x); 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; let rowPos = 0; for (const child of block.children) { const parent = block; if (!child.size) { continue; } const { width: width2, height } = child.size; const { px, py } = calculateBlockPosition(columns, columnPos); if (py != rowPos) { rowPos = py; 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; log$1.debug("New row in layout for block", block.id, " and child ", child.id, rowPos); } log$1.debug( `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}` ); if (parent.size) { const halfWidth = width2 / 2; child.size.x = startingPosX + padding + halfWidth; log$1.debug( `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}` ); startingPosX = child.size.x + halfWidth; child.size.y = parent.size.y - parent.size.height / 2 + py * (height + padding) + height / 2 + padding; log$1.debug( `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}` ); } if (child.children) { layoutBlocks(child); } columnPos += (child == null ? void 0 : child.widthInColumns) || 1; log$1.debug("abc88 columnsPos", child, columnPos); } } log$1.debug( `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}` ); } function findBounds(block, { minX, minY, maxX, maxY } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) { if (block.size && block.id !== "root") { const { x, y, width, height } = block.size; if (x - width / 2 < minX) { minX = x - width / 2; } if (y - height / 2 < minY) { minY = y - height / 2; } if (x + width / 2 > maxX) { maxX = x + width / 2; } if (y + height / 2 > maxY) { maxY = y + height / 2; } } if (block.children) { for (const child of block.children) { ({ minX, minY, maxX, maxY } = findBounds(child, { minX, minY, maxX, maxY })); } } return { minX, minY, maxX, maxY }; } function layout(db2) { const root = db2.getBlock("root"); if (!root) { return; } setBlockSizes(root, db2, 0, 0); layoutBlocks(root); log$1.debug("getBlocks", JSON.stringify(root, null, 2)); const { minX, minY, maxX, maxY } = findBounds(root); const height = maxY - minY; const width = maxX - minX; return { x: minX, y: minY, width, height }; } var getClasses = function(text, diagObj) { return diagObj.db.getClasses(); }; var draw = async function(text, id, _version, diagObj) { const { securityLevel, block: conf } = getConfig$1(); const db2 = diagObj.db; let sandboxElement; if (securityLevel === "sandbox") { sandboxElement = select_default("#i" + id); } const root = securityLevel === "sandbox" ? select_default(sandboxElement.nodes()[0].contentDocument.body) : select_default("body"); const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select_default(`[id="${id}"]`); const markers = ["point", "circle", "cross"]; insertMarkers$1(svg, markers, diagObj.type, id); const bl = db2.getBlocks(); const blArr = db2.getBlocksFlat(); const edges = db2.getEdges(); const nodes = svg.insert("g").attr("class", "block"); await calculateBlockSizes(nodes, bl, db2); const bounds = layout(db2); await insertBlocks(nodes, bl, db2); await insertEdges(nodes, edges, blArr, db2, id); if (bounds) { const bounds2 = bounds; const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height))); const height = bounds2.height + magicFactor + 10; const width = bounds2.width + 10; const { useMaxWidth } = conf; configureSvgSize(svg, height, width, !!useMaxWidth); log$1.debug("Here Bounds", bounds, bounds2); svg.attr( "viewBox", `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}` ); } ordinal(Tableau10_default); }; var renderer = { draw, getClasses }; var diagram = { parser: parser$1, db: db$1, renderer, styles: flowStyles }; export { diagram }; //# sourceMappingURL=blockDiagram-9f4a6865-CRJ63NLF.js.map