UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.

1,395 lines (1,386 loc) 1.15 MB
import { d as sanitizeText$1, c as getConfig, l as log, T as commonjsGlobal, U as getDefaultExportFromCjs, j as d3select, t as setupGraphViewbox, aV as isDark, aW as lighten, aX as darken } from "./mermaid-f185fde2.js"; import { c as createText } from "./createText-6836bc4a.js"; 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, 4], $V1 = [1, 13], $V2 = [1, 12], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 20], $V6 = [1, 19], $V7 = [6, 7, 8], $V8 = [1, 26], $V9 = [1, 24], $Va = [1, 25], $Vb = [6, 7, 11], $Vc = [1, 6, 13, 15, 16, 19, 22], $Vd = [1, 33], $Ve = [1, 34], $Vf = [1, 6, 7, 11, 13, 15, 16, 19, 22]; var parser2 = { trace: function trace() { }, yy: {}, symbols_: { "error": 2, "start": 3, "mindMap": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "MINDMAP": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "node": 14, "ICON": 15, "CLASS": 16, "nodeWithId": 17, "nodeWithoutId": 18, "NODE_DSTART": 19, "NODE_DESCR": 20, "NODE_DEND": 21, "NODE_ID": 22, "$accept": 0, "$end": 1 }, terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" }, productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { var $0 = $$.length - 1; switch (yystate) { case 6: case 7: return yy; case 8: yy.getLogger().trace("Stop NL "); break; case 9: yy.getLogger().trace("Stop EOF "); break; case 11: yy.getLogger().trace("Stop NL2 "); break; case 12: yy.getLogger().trace("Stop EOF2 "); break; case 15: yy.getLogger().info("Node: ", $$[$0].id); yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type); break; case 16: yy.getLogger().trace("Icon: ", $$[$0]); yy.decorateNode({ icon: $$[$0] }); break; case 17: case 21: yy.decorateNode({ class: $$[$0] }); break; case 18: yy.getLogger().trace("SPACELIST"); break; case 19: yy.getLogger().trace("Node: ", $$[$0].id); yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type); break; case 20: yy.decorateNode({ icon: $$[$0] }); break; case 25: yy.getLogger().trace("node found ..", $$[$0 - 2]); this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; break; case 26: this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT }; break; case 27: yy.getLogger().trace("node found ..", $$[$0 - 3]); this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; break; } }, table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($V7, [2, 3]), { 1: [2, 2] }, o($V7, [2, 4]), o($V7, [2, 5]), { 1: [2, 6], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V1, 9: 22, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V8, 7: $V9, 10: 23, 11: $Va }, o($Vb, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: $V5, 22: $V6 }), o($Vb, [2, 18]), o($Vb, [2, 19]), o($Vb, [2, 20]), o($Vb, [2, 21]), o($Vb, [2, 23]), o($Vb, [2, 24]), o($Vb, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: $V8, 7: $V9, 10: 32, 11: $Va }, { 1: [2, 7], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($Vc, [2, 14], { 7: $Vd, 11: $Ve }), o($Vf, [2, 8]), o($Vf, [2, 9]), o($Vf, [2, 10]), o($Vb, [2, 15]), o($Vb, [2, 16]), o($Vb, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, o($Vc, [2, 13], { 7: $Vd, 11: $Ve }), o($Vf, [2, 11]), o($Vf, [2, 12]), { 21: [1, 37] }, o($Vb, [2, 25]), o($Vb, [2, 27])], defaultActions: { 2: [2, 1], 6: [2, 2] }, parseError: function parseError2(str, hash) { if (hash.recoverable) { this.trace(str); } else { var error = new Error(str); error.hash = hash; throw error; } }, parse: function parse(input) { var self2 = 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 = self2.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 = function() { var lexer2 = { EOF: 1, parseError: function parseError2(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 next2 = this.match; if (next2.length < 20) { next2 += this._input.substr(0, 20 - next2.length); } return (next2.substr(0, 20) + (next2.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: { "case-insensitive": true }, performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { switch ($avoiding_name_collisions) { case 0: yy.getLogger().trace("Found comment", yy_.yytext); return 6; case 1: return 8; case 2: this.begin("CLASS"); break; case 3: this.popState(); return 16; case 4: this.popState(); break; case 5: yy.getLogger().trace("Begin icon"); this.begin("ICON"); break; case 6: yy.getLogger().trace("SPACELINE"); return 6; case 7: return 7; case 8: return 15; case 9: yy.getLogger().trace("end icon"); this.popState(); break; case 10: yy.getLogger().trace("Exploding node"); this.begin("NODE"); return 19; case 11: yy.getLogger().trace("Cloud"); this.begin("NODE"); return 19; case 12: yy.getLogger().trace("Explosion Bang"); this.begin("NODE"); return 19; case 13: yy.getLogger().trace("Cloud Bang"); this.begin("NODE"); return 19; case 14: this.begin("NODE"); return 19; case 15: this.begin("NODE"); return 19; case 16: this.begin("NODE"); return 19; case 17: this.begin("NODE"); return 19; case 18: return 13; case 19: return 22; case 20: return 11; case 21: this.begin("NSTR2"); break; case 22: return "NODE_DESCR"; case 23: this.popState(); break; case 24: yy.getLogger().trace("Starting NSTR"); this.begin("NSTR"); break; case 25: yy.getLogger().trace("description:", yy_.yytext); return "NODE_DESCR"; case 26: this.popState(); break; case 27: this.popState(); yy.getLogger().trace("node end ))"); return "NODE_DEND"; case 28: this.popState(); yy.getLogger().trace("node end )"); return "NODE_DEND"; case 29: this.popState(); yy.getLogger().trace("node end ...", yy_.yytext); return "NODE_DEND"; case 30: this.popState(); yy.getLogger().trace("node end (("); return "NODE_DEND"; case 31: this.popState(); yy.getLogger().trace("node end (-"); return "NODE_DEND"; case 32: this.popState(); yy.getLogger().trace("node end (-"); return "NODE_DEND"; case 33: this.popState(); yy.getLogger().trace("node end (("); return "NODE_DEND"; case 34: this.popState(); yy.getLogger().trace("node end (("); return "NODE_DEND"; case 35: yy.getLogger().trace("Long description:", yy_.yytext); return 20; case 36: yy.getLogger().trace("Long description:", yy_.yytext); return 20; } }, rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i], conditions: { "CLASS": { "rules": [3, 4], "inclusive": false }, "ICON": { "rules": [8, 9], "inclusive": false }, "NSTR2": { "rules": [22, 23], "inclusive": false }, "NSTR": { "rules": [25, 26], "inclusive": false }, "NODE": { "rules": [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "inclusive": true } } }; return lexer2; }(); parser2.lexer = lexer; function Parser() { this.yy = {}; } Parser.prototype = parser2; parser2.Parser = Parser; return new Parser(); }(); parser.parser = parser; const mindmapParser = parser; const sanitizeText = (text) => sanitizeText$1(text, getConfig()); let nodes = []; let cnt = 0; let elements = {}; const clear = () => { nodes = []; cnt = 0; elements = {}; }; const getParent = function(level) { for (let i = nodes.length - 1; i >= 0; i--) { if (nodes[i].level < level) { return nodes[i]; } } return null; }; const getMindmap = () => { return nodes.length > 0 ? nodes[0] : null; }; const addNode = (level, id, descr, type) => { log.info("addNode", level, id, descr, type); const conf = getConfig(); const node = { id: cnt++, nodeId: sanitizeText(id), level, descr: sanitizeText(descr), type, children: [], width: getConfig().mindmap.maxNodeWidth }; switch (node.type) { case nodeType.ROUNDED_RECT: node.padding = 2 * conf.mindmap.padding; break; case nodeType.RECT: node.padding = 2 * conf.mindmap.padding; break; case nodeType.HEXAGON: node.padding = 2 * conf.mindmap.padding; break; default: node.padding = conf.mindmap.padding; } const parent = getParent(level); if (parent) { parent.children.push(node); nodes.push(node); } else { if (nodes.length === 0) { nodes.push(node); } else { let error = new Error( 'There can be only one root. No parent could be found for ("' + node.descr + '")' ); error.hash = { text: "branch " + name, token: "branch " + name, line: "1", loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['"checkout ' + name + '"'] }; throw error; } } }; const nodeType = { DEFAULT: 0, NO_BORDER: 0, ROUNDED_RECT: 1, RECT: 2, CIRCLE: 3, CLOUD: 4, BANG: 5, HEXAGON: 6 }; const getType = (startStr, endStr) => { log.debug("In get type", startStr, endStr); switch (startStr) { case "[": return nodeType.RECT; case "(": return endStr === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD; case "((": return nodeType.CIRCLE; case ")": return nodeType.CLOUD; case "))": return nodeType.BANG; case "{{": return nodeType.HEXAGON; default: return nodeType.DEFAULT; } }; const setElementForId = (id, element) => { elements[id] = element; }; const decorateNode = (decoration) => { const node = nodes[nodes.length - 1]; if (decoration && decoration.icon) { node.icon = sanitizeText(decoration.icon); } if (decoration && decoration.class) { node.class = sanitizeText(decoration.class); } }; const type2Str = (type) => { switch (type) { case nodeType.DEFAULT: return "no-border"; case nodeType.RECT: return "rect"; case nodeType.ROUNDED_RECT: return "rounded-rect"; case nodeType.CIRCLE: return "circle"; case nodeType.CLOUD: return "cloud"; case nodeType.BANG: return "bang"; case nodeType.HEXAGON: return "hexgon"; default: return "no-border"; } }; let parseError; const setErrorHandler = (handler) => { parseError = handler; }; const getLogger = () => log; const getNodeById = (id) => nodes[id]; const getElementById = (id) => elements[id]; const mindmapDb = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, addNode, clear, decorateNode, getElementById, getLogger, getMindmap, getNodeById, getType, nodeType, get parseError() { return parseError; }, sanitizeText, setElementForId, setErrorHandler, type2Str }, Symbol.toStringTag, { value: "Module" })); const MAX_SECTIONS = 12; const defaultBkg = function(elem, node, section) { const rd = 5; elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr( "d", `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` ); elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); }; const rectBkg = function(elem, node) { elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr("height", node.height).attr("width", node.width); }; const cloudBkg = function(elem, node) { const w = node.width; const h = node.height; const r1 = 0.15 * w; const r2 = 0.25 * w; const r3 = 0.35 * w; const r4 = 0.2 * w; elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr( "d", `M0 0 a${r1},${r1} 0 0,1 ${w * 0.25},${-1 * w * 0.1} a${r3},${r3} 1 0,1 ${w * 0.4},${-1 * w * 0.1} a${r2},${r2} 1 0,1 ${w * 0.35},${1 * w * 0.2} a${r1},${r1} 1 0,1 ${w * 0.15},${1 * h * 0.35} a${r4},${r4} 1 0,1 ${-1 * w * 0.15},${1 * h * 0.65} a${r2},${r1} 1 0,1 ${-1 * w * 0.25},${w * 0.15} a${r3},${r3} 1 0,1 ${-1 * w * 0.5},${0} a${r1},${r1} 1 0,1 ${-1 * w * 0.25},${-1 * w * 0.15} a${r1},${r1} 1 0,1 ${-1 * w * 0.1},${-1 * h * 0.35} a${r4},${r4} 1 0,1 ${w * 0.1},${-1 * h * 0.65} H0 V0 Z` ); }; const bangBkg = function(elem, node) { const w = node.width; const h = node.height; const r = 0.15 * w; elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr( "d", `M0 0 a${r},${r} 1 0,0 ${w * 0.25},${-1 * h * 0.1} a${r},${r} 1 0,0 ${w * 0.25},${0} a${r},${r} 1 0,0 ${w * 0.25},${0} a${r},${r} 1 0,0 ${w * 0.25},${1 * h * 0.1} a${r},${r} 1 0,0 ${w * 0.15},${1 * h * 0.33} a${r * 0.8},${r * 0.8} 1 0,0 ${0},${1 * h * 0.34} a${r},${r} 1 0,0 ${-1 * w * 0.15},${1 * h * 0.33} a${r},${r} 1 0,0 ${-1 * w * 0.25},${h * 0.15} a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} a${r},${r} 1 0,0 ${-1 * w * 0.25},${-1 * h * 0.15} a${r},${r} 1 0,0 ${-1 * w * 0.1},${-1 * h * 0.33} a${r * 0.8},${r * 0.8} 1 0,0 ${0},${-1 * h * 0.34} a${r},${r} 1 0,0 ${w * 0.1},${-1 * h * 0.33} H0 V0 Z` ); }; const circleBkg = function(elem, node) { elem.append("circle").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr("r", node.width / 2); }; function insertPolygonShape(parent, w, h, points, node) { return parent.insert("polygon", ":first-child").attr( "points", points.map(function(d) { return d.x + "," + d.y; }).join(" ") ).attr("transform", "translate(" + (node.width - w) / 2 + ", " + h + ")"); } const hexagonBkg = function(elem, node) { const h = node.height; const f = 4; const m = h / f; const w = node.width - node.padding + 2 * m; const points = [ { x: m, y: 0 }, { x: w - m, y: 0 }, { x: w, y: -h / 2 }, { x: w - m, y: -h }, { x: m, y: -h }, { x: 0, y: -h / 2 } ]; insertPolygonShape(elem, w, h, points, node); }; const roundedRectBkg = function(elem, node) { elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr("height", node.height).attr("rx", node.padding).attr("ry", node.padding).attr("width", node.width); }; const drawNode = function(elem, node, fullSection, conf) { const htmlLabels = conf.htmlLabels; const section = fullSection % (MAX_SECTIONS - 1); const nodeElem = elem.append("g"); node.section = section; let sectionClass = "section-" + section; if (section < 0) { sectionClass += " section-root"; } nodeElem.attr("class", (node.class ? node.class + " " : "") + "mindmap-node " + sectionClass); const bkgElem = nodeElem.append("g"); const textElem = nodeElem.append("g"); const description = node.descr.replace(/(<br\/*>)/g, "\n"); createText(textElem, description, { useHtmlLabels: htmlLabels, width: node.width, classes: "mindmap-node-label" }); if (!htmlLabels) { textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle"); } const bbox = textElem.node().getBBox(); const fontSize = conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; node.width = bbox.width + 2 * node.padding; if (node.icon) { if (node.type === nodeType.CIRCLE) { node.height += 50; node.width += 50; const icon = nodeElem.append("foreignObject").attr("height", "50px").attr("width", node.width).attr("style", "text-align: center;"); icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); textElem.attr( "transform", "translate(" + node.width / 2 + ", " + (node.height / 2 - 1.5 * node.padding) + ")" ); } else { node.width += 50; const orgHeight = node.height; node.height = Math.max(orgHeight, 60); const heightDiff = Math.abs(node.height - orgHeight); const icon = nodeElem.append("foreignObject").attr("width", "60px").attr("height", node.height).attr("style", "text-align: center;margin-top:" + heightDiff / 2 + "px;"); icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); textElem.attr( "transform", "translate(" + (25 + node.width / 2) + ", " + (heightDiff / 2 + node.padding / 2) + ")" ); } } else { if (!htmlLabels) { const dx = node.width / 2; const dy = node.padding / 2; textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); } else { const dx = (node.width - bbox.width) / 2; const dy = (node.height - bbox.height) / 2; textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); } } switch (node.type) { case nodeType.DEFAULT: defaultBkg(bkgElem, node, section); break; case nodeType.ROUNDED_RECT: roundedRectBkg(bkgElem, node); break; case nodeType.RECT: rectBkg(bkgElem, node); break; case nodeType.CIRCLE: bkgElem.attr("transform", "translate(" + node.width / 2 + ", " + +node.height / 2 + ")"); circleBkg(bkgElem, node); break; case nodeType.CLOUD: cloudBkg(bkgElem, node); break; case nodeType.BANG: bangBkg(bkgElem, node); break; case nodeType.HEXAGON: hexagonBkg(bkgElem, node); break; } setElementForId(node.id, nodeElem); return node.height; }; const drawEdge = function drawEdge2(edgesElem, mindmap, parent, depth, fullSection) { const section = fullSection % (MAX_SECTIONS - 1); const sx = parent.x + parent.width / 2; const sy = parent.y + parent.height / 2; const ex = mindmap.x + mindmap.width / 2; const ey = mindmap.y + mindmap.height / 2; const mx = ex > sx ? sx + Math.abs(sx - ex) / 2 : sx - Math.abs(sx - ex) / 2; const my = ey > sy ? sy + Math.abs(sy - ey) / 2 : sy - Math.abs(sy - ey) / 2; const qx = ex > sx ? Math.abs(sx - mx) / 2 + sx : -Math.abs(sx - mx) / 2 + sx; const qy = ey > sy ? Math.abs(sy - my) / 2 + sy : -Math.abs(sy - my) / 2 + sy; edgesElem.append("path").attr( "d", parent.direction === "TB" || parent.direction === "BT" ? `M${sx},${sy} Q${sx},${qy} ${mx},${my} T${ex},${ey}` : `M${sx},${sy} Q${qx},${sy} ${mx},${my} T${ex},${ey}` ).attr("class", "edge section-edge-" + section + " edge-depth-" + depth); }; const positionNode = function(node) { const nodeElem = getElementById(node.id); const x = node.x || 0; const y = node.y || 0; nodeElem.attr("transform", "translate(" + x + "," + y + ")"); }; const svgDraw = { drawNode, positionNode, drawEdge }; var cytoscape_umd = { exports: {} }; (function(module, exports) { (function(global, factory) { module.exports = factory(); })(commonjsGlobal, function() { function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) { return typeof obj2; } : function(obj2) { return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; }, _typeof(obj); } function _classCallCheck(instance2, Constructor) { if (!(instance2 instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i2 = 0; i2 < props.length; i2++) { var descriptor = props[i2]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _slicedToArray(arr, i2) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i2) || _unsupportedIterableToArray(arr, i2) || _nonIterableRest(); } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArrayLimit(arr, i2) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i2 && _arr.length === i2) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) arr2[i2] = arr[i2]; return arr2; } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var window$1 = typeof window === "undefined" ? null : window; var navigator = window$1 ? window$1.navigator : null; window$1 ? window$1.document : null; var typeofstr = _typeof(""); var typeofobj = _typeof({}); var typeoffn = _typeof(function() { }); var typeofhtmlele = typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement); var instanceStr = function instanceStr2(obj) { return obj && obj.instanceString && fn$6(obj.instanceString) ? obj.instanceString() : null; }; var string = function string2(obj) { return obj != null && _typeof(obj) == typeofstr; }; var fn$6 = function fn2(obj) { return obj != null && _typeof(obj) === typeoffn; }; var array = function array2(obj) { return !elementOrCollection(obj) && (Array.isArray ? Array.isArray(obj) : obj != null && obj instanceof Array); }; var plainObject = function plainObject2(obj) { return obj != null && _typeof(obj) === typeofobj && !array(obj) && obj.constructor === Object; }; var object = function object2(obj) { return obj != null && _typeof(obj) === typeofobj; }; var number$1 = function number2(obj) { return obj != null && _typeof(obj) === _typeof(1) && !isNaN(obj); }; var integer = function integer2(obj) { return number$1(obj) && Math.floor(obj) === obj; }; var htmlElement = function htmlElement2(obj) { if ("undefined" === typeofhtmlele) { return void 0; } else { return null != obj && obj instanceof HTMLElement; } }; var elementOrCollection = function elementOrCollection2(obj) { return element(obj) || collection(obj); }; var element = function element2(obj) { return instanceStr(obj) === "collection" && obj._private.single; }; var collection = function collection2(obj) { return instanceStr(obj) === "collection" && !obj._private.single; }; var core = function core2(obj) { return instanceStr(obj) === "core"; }; var stylesheet = function stylesheet2(obj) { return instanceStr(obj) === "stylesheet"; }; var event = function event2(obj) { return instanceStr(obj) === "event"; }; var emptyString = function emptyString2(obj) { if (obj === void 0 || obj === null) { return true; } else if (obj === "" || obj.match(/^\s+$/)) { return true; } return false; }; var domElement = function domElement2(obj) { if (typeof HTMLElement === "undefined") { return false; } else { return obj instanceof HTMLElement; } }; var boundingBox = function boundingBox2(obj) { return plainObject(obj) && number$1(obj.x1) && number$1(obj.x2) && number$1(obj.y1) && number$1(obj.y2); }; var promise = function promise2(obj) { return object(obj) && fn$6(obj.then); }; var ms = function ms2() { return navigator && navigator.userAgent.match(/msie|trident|edge/i); }; var memoize$1 = function memoize2(fn2, keyFn) { if (!keyFn) { keyFn = function keyFn2() { if (arguments.length === 1) { return arguments[0]; } else if (arguments.length === 0) { return "undefined"; } var args = []; for (var i2 = 0; i2 < arguments.length; i2++) { args.push(arguments[i2]); } return args.join("$"); }; } var memoizedFn = function memoizedFn2() { var self2 = this; var args = arguments; var ret; var k = keyFn.apply(self2, args); var cache2 = memoizedFn2.cache; if (!(ret = cache2[k])) { ret = cache2[k] = fn2.apply(self2, args); } return ret; }; memoizedFn.cache = {}; return memoizedFn; }; var camel2dash = memoize$1(function(str) { return str.replace(/([A-Z])/g, function(v) { return "-" + v.toLowerCase(); }); }); var dash2camel = memoize$1(function(str) { return str.replace(/(-\w)/g, function(v) { return v[1].toUpperCase(); }); }); var prependCamel = memoize$1(function(prefix, str) { return prefix + str[0].toUpperCase() + str.substring(1); }, function(prefix, str) { return prefix + "$" + str; }); var capitalize = function capitalize2(str) { if (emptyString(str)) { return str; } return str.charAt(0).toUpperCase() + str.substring(1); }; var number = "(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))"; var rgba = "rgb[a]?\\((" + number + "[%]?)\\s*,\\s*(" + number + "[%]?)\\s*,\\s*(" + number + "[%]?)(?:\\s*,\\s*(" + number + "))?\\)"; var rgbaNoBackRefs = "rgb[a]?\\((?:" + number + "[%]?)\\s*,\\s*(?:" + number + "[%]?)\\s*,\\s*(?:" + number + "[%]?)(?:\\s*,\\s*(?:" + number + "))?\\)"; var hsla = "hsl[a]?\\((" + number + ")\\s*,\\s*(" + number + "[%])\\s*,\\s*(" + number + "[%])(?:\\s*,\\s*(" + number + "))?\\)"; var hslaNoBackRefs = "hsl[a]?\\((?:" + number + ")\\s*,\\s*(?:" + number + "[%])\\s*,\\s*(?:" + number + "[%])(?:\\s*,\\s*(?:" + number + "))?\\)"; var hex3 = "\\#[0-9a-fA-F]{3}"; var hex6 = "\\#[0-9a-fA-F]{6}"; var ascending = function ascending2(a, b) { if (a < b) { return -1; } else if (a > b) { return 1; } else { return 0; } }; var descending = function descending2(a, b) { return -1 * ascending(a, b); }; var extend = Object.assign != null ? Object.assign.bind(Object) : function(tgt) { var args = arguments; for (var i2 = 1; i2 < args.length; i2++) { var obj = args[i2]; if (obj == null) { continue; } var keys = Object.keys(obj); for (var j = 0; j < keys.length; j++) { var k = keys[j]; tgt[k] = obj[k]; } } return tgt; }; var hex2tuple = function hex2tuple2(hex) { if (!(hex.length === 4 || hex.length === 7) || hex[0] !== "#") { return; } var shortHex = hex.length === 4; var r, g, b; var base = 16; if (shortHex) { r = parseInt(hex[1] + hex[1], base); g = parseInt(hex[2] + hex[2], base); b = parseInt(hex[3] + hex[3], base); } else { r = parseInt(hex[1] + hex[2], base); g = parseInt(hex[3] + hex[4], base); b = parseInt(hex[5] + hex[6], base); } return [r, g, b]; }; var hsl2tuple = function hsl2tuple2(hsl) { var ret; var h, s, l, a, r, g, b; function hue2rgb(p3, q2, t) { if (t < 0) t += 1; if (t > 1) t -= 1; if (t < 1 / 6) return p3 + (q2 - p3) * 6 * t; if (t < 1 / 2) return q2; if (t < 2 / 3) return p3 + (q2 - p3) * (2 / 3 - t) * 6; return p3; } var m = new RegExp("^" + hsla + "$").exec(hsl); if (m) { h = parseInt(m[1]); if (h < 0) { h = (360 - -1 * h % 360) % 360; } else if (h > 360) { h = h % 360; } h /= 360; s = parseFloat(m[2]); if (s < 0 || s > 100) { return; } s = s / 100; l = parseFloat(m[3]); if (l < 0 || l > 100) { return; } l = l / 100; a = m[4]; if (a !== void 0) { a = parseFloat(a); if (a < 0 || a > 1) { return; } } if (s === 0) { r = g = b = Math.round(l * 255); } else { var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p2 = 2 * l - q; r = Math.round(255 * hue2rgb(p2, q, h + 1 / 3)); g = Math.round(255 * hue2rgb(p2, q, h)); b = Math.round(255 * hue2rgb(p2, q, h - 1 / 3)); } ret = [r, g, b, a]; } return ret; }; var rgb2tuple = function rgb2tuple2(rgb) { var ret; var m = new RegExp("^" + rgba + "$").exec(rgb); if (m) { ret = []; var isPct = []; for (var i2 = 1; i2 <= 3; i2++) { var channel = m[i2]; if (channel[channel.length - 1] === "%") { isPct[i2] = true; } channel = parseFloat(channel); if (isPct[i2]) { channel = channel / 100 * 255; } if (channel < 0 || channel > 255) { return; } ret.push(Math.floor(channel)); } var atLeastOneIsPct = isPct[1] || isPct[2] || isPct[3]; var allArePct = isPct[1] && isPct[2] && isPct[3]; if (atLeastOneIsPct && !allArePct) { return; } var alpha = m[4]; if (alpha !== void 0) { alpha = parseFloat(alpha); if (alpha < 0 || alpha > 1) { return; } ret.push(alpha); } } return ret; }; var colorname2tuple = function colorname2tuple2(color) { return colors[color.toLowerCase()]; }; var color2tuple = function color2tuple2(color) { return (array(color) ? color : null) || colorname2tuple(color) || hex2tuple(color) || rgb2tuple(color) || hsl2tuple(color); }; var colors = { // special colour names transparent: [0, 0, 0, 0], // NB alpha === 0 // regular colours aliceblue: [240, 248, 255], antiquewhite: [250, 235, 215], aqua: [0, 255, 255], aquamarine: [127, 255, 212], azure: [240, 255, 255], beige: [245, 245, 220], bisque: [255, 228, 196], black: [0, 0, 0], blanchedalmond: [255, 235, 205], blue: [0, 0, 255], blueviolet: [138, 43, 226], brown: [165, 42, 42], burlywood: [222, 184, 135], cadetblue: [95, 158, 160], chartreuse: [127, 255, 0], chocolate: [210, 105, 30], coral: [255, 127, 80], cornflowerblue: [100, 149, 237],