1 | import { c as getConfig, s as setAccTitle, g as getAccTitle, r as setDiagramTitle, t as getDiagramTitle, a as getAccDescription, b as setAccDescription, m as mermaidAPI, e as common, l as log, v as clear$1, i as configureSvgSize, B as parseFontSize } from "./mermaid-a953d906.js";
|
2 | import { select, scaleOrdinal, pie, arc } from "d3";
|
3 | import "ts-dedent";
|
4 | import "dayjs/esm/index.js";
|
5 | import "@braintree/sanitize-url";
|
6 | import "dompurify";
|
7 | import "khroma";
|
8 | import "lodash-es/memoize.js";
|
9 | import "stylis";
|
10 | import "lodash-es/isEmpty.js";
|
11 | var parser = function() {
|
12 | var o = function(k, v, o2, l) {
|
13 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
14 | ;
|
15 | return o2;
|
16 | }, $V0 = [1, 4], $V1 = [1, 5], $V2 = [1, 6], $V3 = [1, 7], $V4 = [1, 9], $V5 = [1, 11, 13, 15, 17, 19, 20, 26, 27, 28, 29], $V6 = [2, 5], $V7 = [1, 6, 11, 13, 15, 17, 19, 20, 26, 27, 28, 29], $V8 = [26, 27, 28], $V9 = [2, 8], $Va = [1, 18], $Vb = [1, 19], $Vc = [1, 20], $Vd = [1, 21], $Ve = [1, 22], $Vf = [1, 23], $Vg = [1, 28], $Vh = [6, 26, 27, 28, 29];
|
17 | var parser2 = {
|
18 | trace: function trace() {
|
19 | },
|
20 | yy: {},
|
21 | symbols_: { "error": 2, "start": 3, "eol": 4, "directive": 5, "PIE": 6, "document": 7, "showData": 8, "line": 9, "statement": 10, "txt": 11, "value": 12, "title": 13, "title_value": 14, "acc_title": 15, "acc_title_value": 16, "acc_descr": 17, "acc_descr_value": 18, "acc_descr_multiline_value": 19, "section": 20, "openDirective": 21, "typeDirective": 22, "closeDirective": 23, ":": 24, "argDirective": 25, "NEWLINE": 26, ";": 27, "EOF": 28, "open_directive": 29, "type_directive": 30, "arg_directive": 31, "close_directive": 32, "$accept": 0, "$end": 1 },
|
22 | terminals_: { 2: "error", 6: "PIE", 8: "showData", 11: "txt", 12: "value", 13: "title", 14: "title_value", 15: "acc_title", 16: "acc_title_value", 17: "acc_descr", 18: "acc_descr_value", 19: "acc_descr_multiline_value", 20: "section", 24: ":", 26: "NEWLINE", 27: ";", 28: "EOF", 29: "open_directive", 30: "type_directive", 31: "arg_directive", 32: "close_directive" },
|
23 | productions_: [0, [3, 2], [3, 2], [3, 2], [3, 3], [7, 0], [7, 2], [9, 2], [10, 0], [10, 2], [10, 2], [10, 2], [10, 2], [10, 1], [10, 1], [10, 1], [5, 3], [5, 5], [4, 1], [4, 1], [4, 1], [21, 1], [22, 1], [25, 1], [23, 1]],
|
24 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
25 | var $0 = $$.length - 1;
|
26 | switch (yystate) {
|
27 | case 4:
|
28 | yy.setShowData(true);
|
29 | break;
|
30 | case 7:
|
31 | this.$ = $$[$0 - 1];
|
32 | break;
|
33 | case 9:
|
34 | yy.addSection($$[$0 - 1], yy.cleanupValue($$[$0]));
|
35 | break;
|
36 | case 10:
|
37 | this.$ = $$[$0].trim();
|
38 | yy.setDiagramTitle(this.$);
|
39 | break;
|
40 | case 11:
|
41 | this.$ = $$[$0].trim();
|
42 | yy.setAccTitle(this.$);
|
43 | break;
|
44 | case 12:
|
45 | case 13:
|
46 | this.$ = $$[$0].trim();
|
47 | yy.setAccDescription(this.$);
|
48 | break;
|
49 | case 14:
|
50 | yy.addSection($$[$0].substr(8));
|
51 | this.$ = $$[$0].substr(8);
|
52 | break;
|
53 | case 21:
|
54 | yy.parseDirective("%%{", "open_directive");
|
55 | break;
|
56 | case 22:
|
57 | yy.parseDirective($$[$0], "type_directive");
|
58 | break;
|
59 | case 23:
|
60 | $$[$0] = $$[$0].trim().replace(/'/g, '"');
|
61 | yy.parseDirective($$[$0], "arg_directive");
|
62 | break;
|
63 | case 24:
|
64 | yy.parseDirective("}%%", "close_directive", "pie");
|
65 | break;
|
66 | }
|
67 | },
|
68 | table: [{ 3: 1, 4: 2, 5: 3, 6: $V0, 21: 8, 26: $V1, 27: $V2, 28: $V3, 29: $V4 }, { 1: [3] }, { 3: 10, 4: 2, 5: 3, 6: $V0, 21: 8, 26: $V1, 27: $V2, 28: $V3, 29: $V4 }, { 3: 11, 4: 2, 5: 3, 6: $V0, 21: 8, 26: $V1, 27: $V2, 28: $V3, 29: $V4 }, o($V5, $V6, { 7: 12, 8: [1, 13] }), o($V7, [2, 18]), o($V7, [2, 19]), o($V7, [2, 20]), { 22: 14, 30: [1, 15] }, { 30: [2, 21] }, { 1: [2, 1] }, { 1: [2, 2] }, o($V8, $V9, { 21: 8, 9: 16, 10: 17, 5: 24, 1: [2, 3], 11: $Va, 13: $Vb, 15: $Vc, 17: $Vd, 19: $Ve, 20: $Vf, 29: $V4 }), o($V5, $V6, { 7: 25 }), { 23: 26, 24: [1, 27], 32: $Vg }, o([24, 32], [2, 22]), o($V5, [2, 6]), { 4: 29, 26: $V1, 27: $V2, 28: $V3 }, { 12: [1, 30] }, { 14: [1, 31] }, { 16: [1, 32] }, { 18: [1, 33] }, o($V8, [2, 13]), o($V8, [2, 14]), o($V8, [2, 15]), o($V8, $V9, { 21: 8, 9: 16, 10: 17, 5: 24, 1: [2, 4], 11: $Va, 13: $Vb, 15: $Vc, 17: $Vd, 19: $Ve, 20: $Vf, 29: $V4 }), o($Vh, [2, 16]), { 25: 34, 31: [1, 35] }, o($Vh, [2, 24]), o($V5, [2, 7]), o($V8, [2, 9]), o($V8, [2, 10]), o($V8, [2, 11]), o($V8, [2, 12]), { 23: 36, 32: $Vg }, { 32: [2, 23] }, o($Vh, [2, 17])],
|
69 | defaultActions: { 9: [2, 21], 10: [2, 1], 11: [2, 2], 35: [2, 23] },
|
70 | parseError: function parseError(str, hash) {
|
71 | if (hash.recoverable) {
|
72 | this.trace(str);
|
73 | } else {
|
74 | var error = new Error(str);
|
75 | error.hash = hash;
|
76 | throw error;
|
77 | }
|
78 | },
|
79 | parse: function parse(input) {
|
80 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
81 | var args = lstack.slice.call(arguments, 1);
|
82 | var lexer2 = Object.create(this.lexer);
|
83 | var sharedState = { yy: {} };
|
84 | for (var k in this.yy) {
|
85 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
86 | sharedState.yy[k] = this.yy[k];
|
87 | }
|
88 | }
|
89 | lexer2.setInput(input, sharedState.yy);
|
90 | sharedState.yy.lexer = lexer2;
|
91 | sharedState.yy.parser = this;
|
92 | if (typeof lexer2.yylloc == "undefined") {
|
93 | lexer2.yylloc = {};
|
94 | }
|
95 | var yyloc = lexer2.yylloc;
|
96 | lstack.push(yyloc);
|
97 | var ranges = lexer2.options && lexer2.options.ranges;
|
98 | if (typeof sharedState.yy.parseError === "function") {
|
99 | this.parseError = sharedState.yy.parseError;
|
100 | } else {
|
101 | this.parseError = Object.getPrototypeOf(this).parseError;
|
102 | }
|
103 | function lex() {
|
104 | var token;
|
105 | token = tstack.pop() || lexer2.lex() || EOF;
|
106 | if (typeof token !== "number") {
|
107 | if (token instanceof Array) {
|
108 | tstack = token;
|
109 | token = tstack.pop();
|
110 | }
|
111 | token = self.symbols_[token] || token;
|
112 | }
|
113 | return token;
|
114 | }
|
115 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
116 | while (true) {
|
117 | state = stack[stack.length - 1];
|
118 | if (this.defaultActions[state]) {
|
119 | action = this.defaultActions[state];
|
120 | } else {
|
121 | if (symbol === null || typeof symbol == "undefined") {
|
122 | symbol = lex();
|
123 | }
|
124 | action = table[state] && table[state][symbol];
|
125 | }
|
126 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
127 | var errStr = "";
|
128 | expected = [];
|
129 | for (p in table[state]) {
|
130 | if (this.terminals_[p] && p > TERROR) {
|
131 | expected.push("'" + this.terminals_[p] + "'");
|
132 | }
|
133 | }
|
134 | if (lexer2.showPosition) {
|
135 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
136 | } else {
|
137 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
138 | }
|
139 | this.parseError(errStr, {
|
140 | text: lexer2.match,
|
141 | token: this.terminals_[symbol] || symbol,
|
142 | line: lexer2.yylineno,
|
143 | loc: yyloc,
|
144 | expected
|
145 | });
|
146 | }
|
147 | if (action[0] instanceof Array && action.length > 1) {
|
148 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
149 | }
|
150 | switch (action[0]) {
|
151 | case 1:
|
152 | stack.push(symbol);
|
153 | vstack.push(lexer2.yytext);
|
154 | lstack.push(lexer2.yylloc);
|
155 | stack.push(action[1]);
|
156 | symbol = null;
|
157 | {
|
158 | yyleng = lexer2.yyleng;
|
159 | yytext = lexer2.yytext;
|
160 | yylineno = lexer2.yylineno;
|
161 | yyloc = lexer2.yylloc;
|
162 | }
|
163 | break;
|
164 | case 2:
|
165 | len = this.productions_[action[1]][1];
|
166 | yyval.$ = vstack[vstack.length - len];
|
167 | yyval._$ = {
|
168 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
169 | last_line: lstack[lstack.length - 1].last_line,
|
170 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
171 | last_column: lstack[lstack.length - 1].last_column
|
172 | };
|
173 | if (ranges) {
|
174 | yyval._$.range = [
|
175 | lstack[lstack.length - (len || 1)].range[0],
|
176 | lstack[lstack.length - 1].range[1]
|
177 | ];
|
178 | }
|
179 | r = this.performAction.apply(yyval, [
|
180 | yytext,
|
181 | yyleng,
|
182 | yylineno,
|
183 | sharedState.yy,
|
184 | action[1],
|
185 | vstack,
|
186 | lstack
|
187 | ].concat(args));
|
188 | if (typeof r !== "undefined") {
|
189 | return r;
|
190 | }
|
191 | if (len) {
|
192 | stack = stack.slice(0, -1 * len * 2);
|
193 | vstack = vstack.slice(0, -1 * len);
|
194 | lstack = lstack.slice(0, -1 * len);
|
195 | }
|
196 | stack.push(this.productions_[action[1]][0]);
|
197 | vstack.push(yyval.$);
|
198 | lstack.push(yyval._$);
|
199 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
200 | stack.push(newState);
|
201 | break;
|
202 | case 3:
|
203 | return true;
|
204 | }
|
205 | }
|
206 | return true;
|
207 | }
|
208 | };
|
209 | var lexer = function() {
|
210 | var lexer2 = {
|
211 | EOF: 1,
|
212 | parseError: function parseError(str, hash) {
|
213 | if (this.yy.parser) {
|
214 | this.yy.parser.parseError(str, hash);
|
215 | } else {
|
216 | throw new Error(str);
|
217 | }
|
218 | },
|
219 |
|
220 | setInput: function(input, yy) {
|
221 | this.yy = yy || this.yy || {};
|
222 | this._input = input;
|
223 | this._more = this._backtrack = this.done = false;
|
224 | this.yylineno = this.yyleng = 0;
|
225 | this.yytext = this.matched = this.match = "";
|
226 | this.conditionStack = ["INITIAL"];
|
227 | this.yylloc = {
|
228 | first_line: 1,
|
229 | first_column: 0,
|
230 | last_line: 1,
|
231 | last_column: 0
|
232 | };
|
233 | if (this.options.ranges) {
|
234 | this.yylloc.range = [0, 0];
|
235 | }
|
236 | this.offset = 0;
|
237 | return this;
|
238 | },
|
239 |
|
240 | input: function() {
|
241 | var ch = this._input[0];
|
242 | this.yytext += ch;
|
243 | this.yyleng++;
|
244 | this.offset++;
|
245 | this.match += ch;
|
246 | this.matched += ch;
|
247 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
248 | if (lines) {
|
249 | this.yylineno++;
|
250 | this.yylloc.last_line++;
|
251 | } else {
|
252 | this.yylloc.last_column++;
|
253 | }
|
254 | if (this.options.ranges) {
|
255 | this.yylloc.range[1]++;
|
256 | }
|
257 | this._input = this._input.slice(1);
|
258 | return ch;
|
259 | },
|
260 |
|
261 | unput: function(ch) {
|
262 | var len = ch.length;
|
263 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
264 | this._input = ch + this._input;
|
265 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
266 | this.offset -= len;
|
267 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
268 | this.match = this.match.substr(0, this.match.length - 1);
|
269 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
270 | if (lines.length - 1) {
|
271 | this.yylineno -= lines.length - 1;
|
272 | }
|
273 | var r = this.yylloc.range;
|
274 | this.yylloc = {
|
275 | first_line: this.yylloc.first_line,
|
276 | last_line: this.yylineno + 1,
|
277 | first_column: this.yylloc.first_column,
|
278 | 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
|
279 | };
|
280 | if (this.options.ranges) {
|
281 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
282 | }
|
283 | this.yyleng = this.yytext.length;
|
284 | return this;
|
285 | },
|
286 |
|
287 | more: function() {
|
288 | this._more = true;
|
289 | return this;
|
290 | },
|
291 |
|
292 | reject: function() {
|
293 | if (this.options.backtrack_lexer) {
|
294 | this._backtrack = true;
|
295 | } else {
|
296 | 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(), {
|
297 | text: "",
|
298 | token: null,
|
299 | line: this.yylineno
|
300 | });
|
301 | }
|
302 | return this;
|
303 | },
|
304 |
|
305 | less: function(n) {
|
306 | this.unput(this.match.slice(n));
|
307 | },
|
308 |
|
309 | pastInput: function() {
|
310 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
311 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
312 | },
|
313 |
|
314 | upcomingInput: function() {
|
315 | var next = this.match;
|
316 | if (next.length < 20) {
|
317 | next += this._input.substr(0, 20 - next.length);
|
318 | }
|
319 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
320 | },
|
321 |
|
322 | showPosition: function() {
|
323 | var pre = this.pastInput();
|
324 | var c = new Array(pre.length + 1).join("-");
|
325 | return pre + this.upcomingInput() + "\n" + c + "^";
|
326 | },
|
327 |
|
328 | test_match: function(match, indexed_rule) {
|
329 | var token, lines, backup;
|
330 | if (this.options.backtrack_lexer) {
|
331 | backup = {
|
332 | yylineno: this.yylineno,
|
333 | yylloc: {
|
334 | first_line: this.yylloc.first_line,
|
335 | last_line: this.last_line,
|
336 | first_column: this.yylloc.first_column,
|
337 | last_column: this.yylloc.last_column
|
338 | },
|
339 | yytext: this.yytext,
|
340 | match: this.match,
|
341 | matches: this.matches,
|
342 | matched: this.matched,
|
343 | yyleng: this.yyleng,
|
344 | offset: this.offset,
|
345 | _more: this._more,
|
346 | _input: this._input,
|
347 | yy: this.yy,
|
348 | conditionStack: this.conditionStack.slice(0),
|
349 | done: this.done
|
350 | };
|
351 | if (this.options.ranges) {
|
352 | backup.yylloc.range = this.yylloc.range.slice(0);
|
353 | }
|
354 | }
|
355 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
356 | if (lines) {
|
357 | this.yylineno += lines.length;
|
358 | }
|
359 | this.yylloc = {
|
360 | first_line: this.yylloc.last_line,
|
361 | last_line: this.yylineno + 1,
|
362 | first_column: this.yylloc.last_column,
|
363 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
364 | };
|
365 | this.yytext += match[0];
|
366 | this.match += match[0];
|
367 | this.matches = match;
|
368 | this.yyleng = this.yytext.length;
|
369 | if (this.options.ranges) {
|
370 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
371 | }
|
372 | this._more = false;
|
373 | this._backtrack = false;
|
374 | this._input = this._input.slice(match[0].length);
|
375 | this.matched += match[0];
|
376 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
377 | if (this.done && this._input) {
|
378 | this.done = false;
|
379 | }
|
380 | if (token) {
|
381 | return token;
|
382 | } else if (this._backtrack) {
|
383 | for (var k in backup) {
|
384 | this[k] = backup[k];
|
385 | }
|
386 | return false;
|
387 | }
|
388 | return false;
|
389 | },
|
390 |
|
391 | next: function() {
|
392 | if (this.done) {
|
393 | return this.EOF;
|
394 | }
|
395 | if (!this._input) {
|
396 | this.done = true;
|
397 | }
|
398 | var token, match, tempMatch, index;
|
399 | if (!this._more) {
|
400 | this.yytext = "";
|
401 | this.match = "";
|
402 | }
|
403 | var rules = this._currentRules();
|
404 | for (var i = 0; i < rules.length; i++) {
|
405 | tempMatch = this._input.match(this.rules[rules[i]]);
|
406 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
407 | match = tempMatch;
|
408 | index = i;
|
409 | if (this.options.backtrack_lexer) {
|
410 | token = this.test_match(tempMatch, rules[i]);
|
411 | if (token !== false) {
|
412 | return token;
|
413 | } else if (this._backtrack) {
|
414 | match = false;
|
415 | continue;
|
416 | } else {
|
417 | return false;
|
418 | }
|
419 | } else if (!this.options.flex) {
|
420 | break;
|
421 | }
|
422 | }
|
423 | }
|
424 | if (match) {
|
425 | token = this.test_match(match, rules[index]);
|
426 | if (token !== false) {
|
427 | return token;
|
428 | }
|
429 | return false;
|
430 | }
|
431 | if (this._input === "") {
|
432 | return this.EOF;
|
433 | } else {
|
434 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
435 | text: "",
|
436 | token: null,
|
437 | line: this.yylineno
|
438 | });
|
439 | }
|
440 | },
|
441 |
|
442 | lex: function lex() {
|
443 | var r = this.next();
|
444 | if (r) {
|
445 | return r;
|
446 | } else {
|
447 | return this.lex();
|
448 | }
|
449 | },
|
450 |
|
451 | begin: function begin(condition) {
|
452 | this.conditionStack.push(condition);
|
453 | },
|
454 |
|
455 | popState: function popState() {
|
456 | var n = this.conditionStack.length - 1;
|
457 | if (n > 0) {
|
458 | return this.conditionStack.pop();
|
459 | } else {
|
460 | return this.conditionStack[0];
|
461 | }
|
462 | },
|
463 |
|
464 | _currentRules: function _currentRules() {
|
465 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
466 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
467 | } else {
|
468 | return this.conditions["INITIAL"].rules;
|
469 | }
|
470 | },
|
471 |
|
472 | topState: function topState(n) {
|
473 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
474 | if (n >= 0) {
|
475 | return this.conditionStack[n];
|
476 | } else {
|
477 | return "INITIAL";
|
478 | }
|
479 | },
|
480 |
|
481 | pushState: function pushState(condition) {
|
482 | this.begin(condition);
|
483 | },
|
484 |
|
485 | stateStackSize: function stateStackSize() {
|
486 | return this.conditionStack.length;
|
487 | },
|
488 | options: { "case-insensitive": true },
|
489 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
490 | switch ($avoiding_name_collisions) {
|
491 | case 0:
|
492 | this.begin("open_directive");
|
493 | return 29;
|
494 | case 1:
|
495 | this.begin("type_directive");
|
496 | return 30;
|
497 | case 2:
|
498 | this.popState();
|
499 | this.begin("arg_directive");
|
500 | return 24;
|
501 | case 3:
|
502 | this.popState();
|
503 | this.popState();
|
504 | return 32;
|
505 | case 4:
|
506 | return 31;
|
507 | case 5:
|
508 | break;
|
509 | case 6:
|
510 | break;
|
511 | case 7:
|
512 | return 26;
|
513 | case 8:
|
514 | break;
|
515 | case 9:
|
516 | break;
|
517 | case 10:
|
518 | this.begin("title");
|
519 | return 13;
|
520 | case 11:
|
521 | this.popState();
|
522 | return "title_value";
|
523 | case 12:
|
524 | this.begin("acc_title");
|
525 | return 15;
|
526 | case 13:
|
527 | this.popState();
|
528 | return "acc_title_value";
|
529 | case 14:
|
530 | this.begin("acc_descr");
|
531 | return 17;
|
532 | case 15:
|
533 | this.popState();
|
534 | return "acc_descr_value";
|
535 | case 16:
|
536 | this.begin("acc_descr_multiline");
|
537 | break;
|
538 | case 17:
|
539 | this.popState();
|
540 | break;
|
541 | case 18:
|
542 | return "acc_descr_multiline_value";
|
543 | case 19:
|
544 | this.begin("string");
|
545 | break;
|
546 | case 20:
|
547 | this.popState();
|
548 | break;
|
549 | case 21:
|
550 | return "txt";
|
551 | case 22:
|
552 | return 6;
|
553 | case 23:
|
554 | return 8;
|
555 | case 24:
|
556 | return "value";
|
557 | case 25:
|
558 | return 28;
|
559 | }
|
560 | },
|
561 | rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:[\s]+)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:pie\b)/i, /^(?:showData\b)/i, /^(?::[\s]*[\d]+(?:\.[\d]+)?)/i, /^(?:$)/i],
|
562 | conditions: { "acc_descr_multiline": { "rules": [17, 18], "inclusive": false }, "acc_descr": { "rules": [15], "inclusive": false }, "acc_title": { "rules": [13], "inclusive": false }, "close_directive": { "rules": [], "inclusive": false }, "arg_directive": { "rules": [3, 4], "inclusive": false }, "type_directive": { "rules": [2, 3], "inclusive": false }, "open_directive": { "rules": [1], "inclusive": false }, "title": { "rules": [11], "inclusive": false }, "string": { "rules": [20, 21], "inclusive": false }, "INITIAL": { "rules": [0, 5, 6, 7, 8, 9, 10, 12, 14, 16, 19, 22, 23, 24, 25], "inclusive": true } }
|
563 | };
|
564 | return lexer2;
|
565 | }();
|
566 | parser2.lexer = lexer;
|
567 | function Parser() {
|
568 | this.yy = {};
|
569 | }
|
570 | Parser.prototype = parser2;
|
571 | parser2.Parser = Parser;
|
572 | return new Parser();
|
573 | }();
|
574 | parser.parser = parser;
|
575 | const parser$1 = parser;
|
576 | let sections = {};
|
577 | let showData = false;
|
578 | const parseDirective = function(statement, context, type) {
|
579 | mermaidAPI.parseDirective(this, statement, context, type);
|
580 | };
|
581 | const addSection = function(id, value) {
|
582 | id = common.sanitizeText(id, getConfig());
|
583 | if (sections[id] === void 0) {
|
584 | sections[id] = value;
|
585 | log.debug("Added new section :", id);
|
586 | }
|
587 | };
|
588 | const getSections = () => sections;
|
589 | const setShowData = function(toggle) {
|
590 | showData = toggle;
|
591 | };
|
592 | const getShowData = function() {
|
593 | return showData;
|
594 | };
|
595 | const cleanupValue = function(value) {
|
596 | if (value.substring(0, 1) === ":") {
|
597 | value = value.substring(1).trim();
|
598 | return Number(value.trim());
|
599 | } else {
|
600 | return Number(value.trim());
|
601 | }
|
602 | };
|
603 | const clear = function() {
|
604 | sections = {};
|
605 | showData = false;
|
606 | clear$1();
|
607 | };
|
608 | const db = {
|
609 | parseDirective,
|
610 | getConfig: () => getConfig().pie,
|
611 | addSection,
|
612 | getSections,
|
613 | cleanupValue,
|
614 | clear,
|
615 | setAccTitle,
|
616 | getAccTitle,
|
617 | setDiagramTitle,
|
618 | getDiagramTitle,
|
619 | setShowData,
|
620 | getShowData,
|
621 | getAccDescription,
|
622 | setAccDescription
|
623 | };
|
624 | const getStyles = (options) => `
|
625 | .pieCircle{
|
626 | stroke: ${options.pieStrokeColor};
|
627 | stroke-width : ${options.pieStrokeWidth};
|
628 | opacity : ${options.pieOpacity};
|
629 | }
|
630 | .pieOuterCircle{
|
631 | stroke: ${options.pieOuterStrokeColor};
|
632 | stroke-width: ${options.pieOuterStrokeWidth};
|
633 | fill: none;
|
634 | }
|
635 | .pieTitleText {
|
636 | text-anchor: middle;
|
637 | font-size: ${options.pieTitleTextSize};
|
638 | fill: ${options.pieTitleTextColor};
|
639 | font-family: ${options.fontFamily};
|
640 | }
|
641 | .slice {
|
642 | font-family: ${options.fontFamily};
|
643 | fill: ${options.pieSectionTextColor};
|
644 | font-size:${options.pieSectionTextSize};
|
645 | // fill: white;
|
646 | }
|
647 | .legend text {
|
648 | fill: ${options.pieLegendTextColor};
|
649 | font-family: ${options.fontFamily};
|
650 | font-size: ${options.pieLegendTextSize};
|
651 | }
|
652 | `;
|
653 | const styles = getStyles;
|
654 | let conf = getConfig();
|
655 | let width;
|
656 | const height = 450;
|
657 | const draw = (txt, id, _version, diagObj) => {
|
658 | var _a;
|
659 | try {
|
660 | conf = getConfig();
|
661 | log.debug("Rendering info diagram\n" + txt);
|
662 | const securityLevel = getConfig().securityLevel;
|
663 | let sandboxElement;
|
664 | if (securityLevel === "sandbox") {
|
665 | sandboxElement = select("#i" + id);
|
666 | }
|
667 | const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
668 | const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
|
669 | diagObj.db.clear();
|
670 | diagObj.parser.parse(txt);
|
671 | log.debug("Parsed info diagram");
|
672 | const elem = doc.getElementById(id);
|
673 | width = elem.parentElement.offsetWidth;
|
674 | if (width === void 0) {
|
675 | width = 1200;
|
676 | }
|
677 | if (conf.useWidth !== void 0) {
|
678 | width = conf.useWidth;
|
679 | }
|
680 | if (conf.pie.useWidth !== void 0) {
|
681 | width = conf.pie.useWidth;
|
682 | }
|
683 | const diagram2 = root.select("#" + id);
|
684 | configureSvgSize(diagram2, height, width, conf.pie.useMaxWidth);
|
685 | elem.setAttribute("viewBox", "0 0 " + width + " " + height);
|
686 | var margin = 40;
|
687 | var legendRectSize = 18;
|
688 | var legendSpacing = 4;
|
689 | var radius = Math.min(width, height) / 2 - margin;
|
690 | var svg = diagram2.append("g").attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
|
691 | var data = diagObj.db.getSections();
|
692 | var sum = 0;
|
693 | Object.keys(data).forEach(function(key) {
|
694 | sum += data[key];
|
695 | });
|
696 | const themeVariables = conf.themeVariables;
|
697 | var myGeneratedColors = [
|
698 | themeVariables.pie1,
|
699 | themeVariables.pie2,
|
700 | themeVariables.pie3,
|
701 | themeVariables.pie4,
|
702 | themeVariables.pie5,
|
703 | themeVariables.pie6,
|
704 | themeVariables.pie7,
|
705 | themeVariables.pie8,
|
706 | themeVariables.pie9,
|
707 | themeVariables.pie10,
|
708 | themeVariables.pie11,
|
709 | themeVariables.pie12
|
710 | ];
|
711 | const textPosition = ((_a = conf.pie) == null ? void 0 : _a.textPosition) ?? 0.75;
|
712 | let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
|
713 | outerStrokeWidth ?? (outerStrokeWidth = 2);
|
714 | var color = scaleOrdinal().range(myGeneratedColors);
|
715 | var pieData = Object.entries(data).map(function(el, idx) {
|
716 | return {
|
717 | order: idx,
|
718 | name: el[0],
|
719 | value: el[1]
|
720 | };
|
721 | });
|
722 | var pie$1 = pie().value(function(d) {
|
723 | return d.value;
|
724 | }).sort(function(a, b) {
|
725 | return a.order - b.order;
|
726 | });
|
727 | var dataReady = pie$1(pieData);
|
728 | var arcGenerator = arc().innerRadius(0).outerRadius(radius);
|
729 | var labelArcGenerator = arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
|
730 | svg.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
|
731 | svg.selectAll("mySlices").data(dataReady).enter().append("path").attr("d", arcGenerator).attr("fill", function(d) {
|
732 | return color(d.data.name);
|
733 | }).attr("class", "pieCircle");
|
734 | svg.selectAll("mySlices").data(dataReady).enter().append("text").text(function(d) {
|
735 | return (d.data.value / sum * 100).toFixed(0) + "%";
|
736 | }).attr("transform", function(d) {
|
737 | return "translate(" + labelArcGenerator.centroid(d) + ")";
|
738 | }).style("text-anchor", "middle").attr("class", "slice");
|
739 | svg.append("text").text(diagObj.db.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText");
|
740 | var legend = svg.selectAll(".legend").data(color.domain()).enter().append("g").attr("class", "legend").attr("transform", function(d, i) {
|
741 | const height2 = legendRectSize + legendSpacing;
|
742 | const offset = height2 * color.domain().length / 2;
|
743 | const horizontal = 12 * legendRectSize;
|
744 | const vertical = i * height2 - offset;
|
745 | return "translate(" + horizontal + "," + vertical + ")";
|
746 | });
|
747 | legend.append("rect").attr("width", legendRectSize).attr("height", legendRectSize).style("fill", color).style("stroke", color);
|
748 | legend.data(dataReady).append("text").attr("x", legendRectSize + legendSpacing).attr("y", legendRectSize - legendSpacing).text(function(d) {
|
749 | if (diagObj.db.getShowData() || conf.showData || conf.pie.showData) {
|
750 | return d.data.name + " [" + d.data.value + "]";
|
751 | } else {
|
752 | return d.data.name;
|
753 | }
|
754 | });
|
755 | } catch (e) {
|
756 | log.error("Error while rendering info diagram");
|
757 | log.error(e);
|
758 | }
|
759 | };
|
760 | const renderer = {
|
761 | draw
|
762 | };
|
763 | const diagram = {
|
764 | parser: parser$1,
|
765 | db,
|
766 | renderer,
|
767 | styles
|
768 | };
|
769 | export {
|
770 | diagram
|
771 | };
|