UNPKG

33.7 kBJavaScriptView Raw
1import { S as tau, c as getConfig, s as setAccTitle, g as getAccTitle, z as setDiagramTitle, A as getDiagramTitle, a as getAccDescription, b as setAccDescription, m as mermaidAPI, f as common, l as log, B as clear$1, j as select, k as configureSvgSize, T as parseFontSize } from "./mermaid-4b4b971d.js";
2import { i as initRange } from "./init-cc95ec8e.js";
3import { a as array } from "./array-b7dcf730.js";
4import { c as constant } from "./constant-b644328d.js";
5import { d as d3arc } from "./arc-ec6eac64.js";
6class InternMap extends Map {
7 constructor(entries, key = keyof) {
8 super();
9 Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
10 if (entries != null)
11 for (const [key2, value] of entries)
12 this.set(key2, value);
13 }
14 get(key) {
15 return super.get(intern_get(this, key));
16 }
17 has(key) {
18 return super.has(intern_get(this, key));
19 }
20 set(key, value) {
21 return super.set(intern_set(this, key), value);
22 }
23 delete(key) {
24 return super.delete(intern_delete(this, key));
25 }
26}
27function intern_get({ _intern, _key }, value) {
28 const key = _key(value);
29 return _intern.has(key) ? _intern.get(key) : value;
30}
31function intern_set({ _intern, _key }, value) {
32 const key = _key(value);
33 if (_intern.has(key))
34 return _intern.get(key);
35 _intern.set(key, value);
36 return value;
37}
38function intern_delete({ _intern, _key }, value) {
39 const key = _key(value);
40 if (_intern.has(key)) {
41 value = _intern.get(key);
42 _intern.delete(key);
43 }
44 return value;
45}
46function keyof(value) {
47 return value !== null && typeof value === "object" ? value.valueOf() : value;
48}
49const implicit = Symbol("implicit");
50function ordinal() {
51 var index = new InternMap(), domain = [], range = [], unknown = implicit;
52 function scale(d) {
53 let i = index.get(d);
54 if (i === void 0) {
55 if (unknown !== implicit)
56 return unknown;
57 index.set(d, i = domain.push(d) - 1);
58 }
59 return range[i % range.length];
60 }
61 scale.domain = function(_) {
62 if (!arguments.length)
63 return domain.slice();
64 domain = [], index = new InternMap();
65 for (const value of _) {
66 if (index.has(value))
67 continue;
68 index.set(value, domain.push(value) - 1);
69 }
70 return scale;
71 };
72 scale.range = function(_) {
73 return arguments.length ? (range = Array.from(_), scale) : range.slice();
74 };
75 scale.unknown = function(_) {
76 return arguments.length ? (unknown = _, scale) : unknown;
77 };
78 scale.copy = function() {
79 return ordinal(domain, range).unknown(unknown);
80 };
81 initRange.apply(scale, arguments);
82 return scale;
83}
84function descending(a, b) {
85 return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
86}
87function identity(d) {
88 return d;
89}
90function d3pie() {
91 var value = identity, sortValues = descending, sort = null, startAngle = constant(0), endAngle = constant(tau), padAngle = constant(0);
92 function pie(data) {
93 var i, n = (data = array(data)).length, j, k, sum = 0, index = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v;
94 for (i = 0; i < n; ++i) {
95 if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
96 sum += v;
97 }
98 }
99 if (sortValues != null)
100 index.sort(function(i2, j2) {
101 return sortValues(arcs[i2], arcs[j2]);
102 });
103 else if (sort != null)
104 index.sort(function(i2, j2) {
105 return sort(data[i2], data[j2]);
106 });
107 for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
108 j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
109 data: data[j],
110 index: i,
111 value: v,
112 startAngle: a0,
113 endAngle: a1,
114 padAngle: p
115 };
116 }
117 return arcs;
118 }
119 pie.value = function(_) {
120 return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value;
121 };
122 pie.sortValues = function(_) {
123 return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
124 };
125 pie.sort = function(_) {
126 return arguments.length ? (sort = _, sortValues = null, pie) : sort;
127 };
128 pie.startAngle = function(_) {
129 return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle;
130 };
131 pie.endAngle = function(_) {
132 return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle;
133 };
134 pie.padAngle = function(_) {
135 return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle;
136 };
137 return pie;
138}
139var parser = function() {
140 var o = function(k, v, o2, l) {
141 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
142 ;
143 return o2;
144 }, $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];
145 var parser2 = {
146 trace: function trace() {
147 },
148 yy: {},
149 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 },
150 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" },
151 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]],
152 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
153 var $0 = $$.length - 1;
154 switch (yystate) {
155 case 4:
156 yy.setShowData(true);
157 break;
158 case 7:
159 this.$ = $$[$0 - 1];
160 break;
161 case 9:
162 yy.addSection($$[$0 - 1], yy.cleanupValue($$[$0]));
163 break;
164 case 10:
165 this.$ = $$[$0].trim();
166 yy.setDiagramTitle(this.$);
167 break;
168 case 11:
169 this.$ = $$[$0].trim();
170 yy.setAccTitle(this.$);
171 break;
172 case 12:
173 case 13:
174 this.$ = $$[$0].trim();
175 yy.setAccDescription(this.$);
176 break;
177 case 14:
178 yy.addSection($$[$0].substr(8));
179 this.$ = $$[$0].substr(8);
180 break;
181 case 21:
182 yy.parseDirective("%%{", "open_directive");
183 break;
184 case 22:
185 yy.parseDirective($$[$0], "type_directive");
186 break;
187 case 23:
188 $$[$0] = $$[$0].trim().replace(/'/g, '"');
189 yy.parseDirective($$[$0], "arg_directive");
190 break;
191 case 24:
192 yy.parseDirective("}%%", "close_directive", "pie");
193 break;
194 }
195 },
196 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])],
197 defaultActions: { 9: [2, 21], 10: [2, 1], 11: [2, 2], 35: [2, 23] },
198 parseError: function parseError(str, hash) {
199 if (hash.recoverable) {
200 this.trace(str);
201 } else {
202 var error = new Error(str);
203 error.hash = hash;
204 throw error;
205 }
206 },
207 parse: function parse(input) {
208 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
209 var args = lstack.slice.call(arguments, 1);
210 var lexer2 = Object.create(this.lexer);
211 var sharedState = { yy: {} };
212 for (var k in this.yy) {
213 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
214 sharedState.yy[k] = this.yy[k];
215 }
216 }
217 lexer2.setInput(input, sharedState.yy);
218 sharedState.yy.lexer = lexer2;
219 sharedState.yy.parser = this;
220 if (typeof lexer2.yylloc == "undefined") {
221 lexer2.yylloc = {};
222 }
223 var yyloc = lexer2.yylloc;
224 lstack.push(yyloc);
225 var ranges = lexer2.options && lexer2.options.ranges;
226 if (typeof sharedState.yy.parseError === "function") {
227 this.parseError = sharedState.yy.parseError;
228 } else {
229 this.parseError = Object.getPrototypeOf(this).parseError;
230 }
231 function lex() {
232 var token;
233 token = tstack.pop() || lexer2.lex() || EOF;
234 if (typeof token !== "number") {
235 if (token instanceof Array) {
236 tstack = token;
237 token = tstack.pop();
238 }
239 token = self.symbols_[token] || token;
240 }
241 return token;
242 }
243 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
244 while (true) {
245 state = stack[stack.length - 1];
246 if (this.defaultActions[state]) {
247 action = this.defaultActions[state];
248 } else {
249 if (symbol === null || typeof symbol == "undefined") {
250 symbol = lex();
251 }
252 action = table[state] && table[state][symbol];
253 }
254 if (typeof action === "undefined" || !action.length || !action[0]) {
255 var errStr = "";
256 expected = [];
257 for (p in table[state]) {
258 if (this.terminals_[p] && p > TERROR) {
259 expected.push("'" + this.terminals_[p] + "'");
260 }
261 }
262 if (lexer2.showPosition) {
263 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
264 } else {
265 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
266 }
267 this.parseError(errStr, {
268 text: lexer2.match,
269 token: this.terminals_[symbol] || symbol,
270 line: lexer2.yylineno,
271 loc: yyloc,
272 expected
273 });
274 }
275 if (action[0] instanceof Array && action.length > 1) {
276 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
277 }
278 switch (action[0]) {
279 case 1:
280 stack.push(symbol);
281 vstack.push(lexer2.yytext);
282 lstack.push(lexer2.yylloc);
283 stack.push(action[1]);
284 symbol = null;
285 {
286 yyleng = lexer2.yyleng;
287 yytext = lexer2.yytext;
288 yylineno = lexer2.yylineno;
289 yyloc = lexer2.yylloc;
290 }
291 break;
292 case 2:
293 len = this.productions_[action[1]][1];
294 yyval.$ = vstack[vstack.length - len];
295 yyval._$ = {
296 first_line: lstack[lstack.length - (len || 1)].first_line,
297 last_line: lstack[lstack.length - 1].last_line,
298 first_column: lstack[lstack.length - (len || 1)].first_column,
299 last_column: lstack[lstack.length - 1].last_column
300 };
301 if (ranges) {
302 yyval._$.range = [
303 lstack[lstack.length - (len || 1)].range[0],
304 lstack[lstack.length - 1].range[1]
305 ];
306 }
307 r = this.performAction.apply(yyval, [
308 yytext,
309 yyleng,
310 yylineno,
311 sharedState.yy,
312 action[1],
313 vstack,
314 lstack
315 ].concat(args));
316 if (typeof r !== "undefined") {
317 return r;
318 }
319 if (len) {
320 stack = stack.slice(0, -1 * len * 2);
321 vstack = vstack.slice(0, -1 * len);
322 lstack = lstack.slice(0, -1 * len);
323 }
324 stack.push(this.productions_[action[1]][0]);
325 vstack.push(yyval.$);
326 lstack.push(yyval._$);
327 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
328 stack.push(newState);
329 break;
330 case 3:
331 return true;
332 }
333 }
334 return true;
335 }
336 };
337 var lexer = function() {
338 var lexer2 = {
339 EOF: 1,
340 parseError: function parseError(str, hash) {
341 if (this.yy.parser) {
342 this.yy.parser.parseError(str, hash);
343 } else {
344 throw new Error(str);
345 }
346 },
347 // resets the lexer, sets new input
348 setInput: function(input, yy) {
349 this.yy = yy || this.yy || {};
350 this._input = input;
351 this._more = this._backtrack = this.done = false;
352 this.yylineno = this.yyleng = 0;
353 this.yytext = this.matched = this.match = "";
354 this.conditionStack = ["INITIAL"];
355 this.yylloc = {
356 first_line: 1,
357 first_column: 0,
358 last_line: 1,
359 last_column: 0
360 };
361 if (this.options.ranges) {
362 this.yylloc.range = [0, 0];
363 }
364 this.offset = 0;
365 return this;
366 },
367 // consumes and returns one char from the input
368 input: function() {
369 var ch = this._input[0];
370 this.yytext += ch;
371 this.yyleng++;
372 this.offset++;
373 this.match += ch;
374 this.matched += ch;
375 var lines = ch.match(/(?:\r\n?|\n).*/g);
376 if (lines) {
377 this.yylineno++;
378 this.yylloc.last_line++;
379 } else {
380 this.yylloc.last_column++;
381 }
382 if (this.options.ranges) {
383 this.yylloc.range[1]++;
384 }
385 this._input = this._input.slice(1);
386 return ch;
387 },
388 // unshifts one char (or a string) into the input
389 unput: function(ch) {
390 var len = ch.length;
391 var lines = ch.split(/(?:\r\n?|\n)/g);
392 this._input = ch + this._input;
393 this.yytext = this.yytext.substr(0, this.yytext.length - len);
394 this.offset -= len;
395 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
396 this.match = this.match.substr(0, this.match.length - 1);
397 this.matched = this.matched.substr(0, this.matched.length - 1);
398 if (lines.length - 1) {
399 this.yylineno -= lines.length - 1;
400 }
401 var r = this.yylloc.range;
402 this.yylloc = {
403 first_line: this.yylloc.first_line,
404 last_line: this.yylineno + 1,
405 first_column: this.yylloc.first_column,
406 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
407 };
408 if (this.options.ranges) {
409 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
410 }
411 this.yyleng = this.yytext.length;
412 return this;
413 },
414 // When called from action, caches matched text and appends it on next action
415 more: function() {
416 this._more = true;
417 return this;
418 },
419 // 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.
420 reject: function() {
421 if (this.options.backtrack_lexer) {
422 this._backtrack = true;
423 } else {
424 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(), {
425 text: "",
426 token: null,
427 line: this.yylineno
428 });
429 }
430 return this;
431 },
432 // retain first n characters of the match
433 less: function(n) {
434 this.unput(this.match.slice(n));
435 },
436 // displays already matched input, i.e. for error messages
437 pastInput: function() {
438 var past = this.matched.substr(0, this.matched.length - this.match.length);
439 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
440 },
441 // displays upcoming input, i.e. for error messages
442 upcomingInput: function() {
443 var next = this.match;
444 if (next.length < 20) {
445 next += this._input.substr(0, 20 - next.length);
446 }
447 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
448 },
449 // displays the character position where the lexing error occurred, i.e. for error messages
450 showPosition: function() {
451 var pre = this.pastInput();
452 var c = new Array(pre.length + 1).join("-");
453 return pre + this.upcomingInput() + "\n" + c + "^";
454 },
455 // test the lexed token: return FALSE when not a match, otherwise return token
456 test_match: function(match, indexed_rule) {
457 var token, lines, backup;
458 if (this.options.backtrack_lexer) {
459 backup = {
460 yylineno: this.yylineno,
461 yylloc: {
462 first_line: this.yylloc.first_line,
463 last_line: this.last_line,
464 first_column: this.yylloc.first_column,
465 last_column: this.yylloc.last_column
466 },
467 yytext: this.yytext,
468 match: this.match,
469 matches: this.matches,
470 matched: this.matched,
471 yyleng: this.yyleng,
472 offset: this.offset,
473 _more: this._more,
474 _input: this._input,
475 yy: this.yy,
476 conditionStack: this.conditionStack.slice(0),
477 done: this.done
478 };
479 if (this.options.ranges) {
480 backup.yylloc.range = this.yylloc.range.slice(0);
481 }
482 }
483 lines = match[0].match(/(?:\r\n?|\n).*/g);
484 if (lines) {
485 this.yylineno += lines.length;
486 }
487 this.yylloc = {
488 first_line: this.yylloc.last_line,
489 last_line: this.yylineno + 1,
490 first_column: this.yylloc.last_column,
491 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
492 };
493 this.yytext += match[0];
494 this.match += match[0];
495 this.matches = match;
496 this.yyleng = this.yytext.length;
497 if (this.options.ranges) {
498 this.yylloc.range = [this.offset, this.offset += this.yyleng];
499 }
500 this._more = false;
501 this._backtrack = false;
502 this._input = this._input.slice(match[0].length);
503 this.matched += match[0];
504 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
505 if (this.done && this._input) {
506 this.done = false;
507 }
508 if (token) {
509 return token;
510 } else if (this._backtrack) {
511 for (var k in backup) {
512 this[k] = backup[k];
513 }
514 return false;
515 }
516 return false;
517 },
518 // return next match in input
519 next: function() {
520 if (this.done) {
521 return this.EOF;
522 }
523 if (!this._input) {
524 this.done = true;
525 }
526 var token, match, tempMatch, index;
527 if (!this._more) {
528 this.yytext = "";
529 this.match = "";
530 }
531 var rules = this._currentRules();
532 for (var i = 0; i < rules.length; i++) {
533 tempMatch = this._input.match(this.rules[rules[i]]);
534 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
535 match = tempMatch;
536 index = i;
537 if (this.options.backtrack_lexer) {
538 token = this.test_match(tempMatch, rules[i]);
539 if (token !== false) {
540 return token;
541 } else if (this._backtrack) {
542 match = false;
543 continue;
544 } else {
545 return false;
546 }
547 } else if (!this.options.flex) {
548 break;
549 }
550 }
551 }
552 if (match) {
553 token = this.test_match(match, rules[index]);
554 if (token !== false) {
555 return token;
556 }
557 return false;
558 }
559 if (this._input === "") {
560 return this.EOF;
561 } else {
562 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
563 text: "",
564 token: null,
565 line: this.yylineno
566 });
567 }
568 },
569 // return next match that has a token
570 lex: function lex() {
571 var r = this.next();
572 if (r) {
573 return r;
574 } else {
575 return this.lex();
576 }
577 },
578 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
579 begin: function begin(condition) {
580 this.conditionStack.push(condition);
581 },
582 // pop the previously active lexer condition state off the condition stack
583 popState: function popState() {
584 var n = this.conditionStack.length - 1;
585 if (n > 0) {
586 return this.conditionStack.pop();
587 } else {
588 return this.conditionStack[0];
589 }
590 },
591 // produce the lexer rule set which is active for the currently active lexer condition state
592 _currentRules: function _currentRules() {
593 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
594 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
595 } else {
596 return this.conditions["INITIAL"].rules;
597 }
598 },
599 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
600 topState: function topState(n) {
601 n = this.conditionStack.length - 1 - Math.abs(n || 0);
602 if (n >= 0) {
603 return this.conditionStack[n];
604 } else {
605 return "INITIAL";
606 }
607 },
608 // alias for begin(condition)
609 pushState: function pushState(condition) {
610 this.begin(condition);
611 },
612 // return the number of states currently on the stack
613 stateStackSize: function stateStackSize() {
614 return this.conditionStack.length;
615 },
616 options: { "case-insensitive": true },
617 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
618 switch ($avoiding_name_collisions) {
619 case 0:
620 this.begin("open_directive");
621 return 29;
622 case 1:
623 this.begin("type_directive");
624 return 30;
625 case 2:
626 this.popState();
627 this.begin("arg_directive");
628 return 24;
629 case 3:
630 this.popState();
631 this.popState();
632 return 32;
633 case 4:
634 return 31;
635 case 5:
636 break;
637 case 6:
638 break;
639 case 7:
640 return 26;
641 case 8:
642 break;
643 case 9:
644 break;
645 case 10:
646 this.begin("title");
647 return 13;
648 case 11:
649 this.popState();
650 return "title_value";
651 case 12:
652 this.begin("acc_title");
653 return 15;
654 case 13:
655 this.popState();
656 return "acc_title_value";
657 case 14:
658 this.begin("acc_descr");
659 return 17;
660 case 15:
661 this.popState();
662 return "acc_descr_value";
663 case 16:
664 this.begin("acc_descr_multiline");
665 break;
666 case 17:
667 this.popState();
668 break;
669 case 18:
670 return "acc_descr_multiline_value";
671 case 19:
672 this.begin("string");
673 break;
674 case 20:
675 this.popState();
676 break;
677 case 21:
678 return "txt";
679 case 22:
680 return 6;
681 case 23:
682 return 8;
683 case 24:
684 return "value";
685 case 25:
686 return 28;
687 }
688 },
689 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],
690 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 } }
691 };
692 return lexer2;
693 }();
694 parser2.lexer = lexer;
695 function Parser() {
696 this.yy = {};
697 }
698 Parser.prototype = parser2;
699 parser2.Parser = Parser;
700 return new Parser();
701}();
702parser.parser = parser;
703const parser$1 = parser;
704let sections = {};
705let showData = false;
706const parseDirective = function(statement, context, type) {
707 mermaidAPI.parseDirective(this, statement, context, type);
708};
709const addSection = function(id, value) {
710 id = common.sanitizeText(id, getConfig());
711 if (sections[id] === void 0) {
712 sections[id] = value;
713 log.debug("Added new section :", id);
714 }
715};
716const getSections = () => sections;
717const setShowData = function(toggle) {
718 showData = toggle;
719};
720const getShowData = function() {
721 return showData;
722};
723const cleanupValue = function(value) {
724 if (value.substring(0, 1) === ":") {
725 value = value.substring(1).trim();
726 return Number(value.trim());
727 } else {
728 return Number(value.trim());
729 }
730};
731const clear = function() {
732 sections = {};
733 showData = false;
734 clear$1();
735};
736const db = {
737 parseDirective,
738 getConfig: () => getConfig().pie,
739 addSection,
740 getSections,
741 cleanupValue,
742 clear,
743 setAccTitle,
744 getAccTitle,
745 setDiagramTitle,
746 getDiagramTitle,
747 setShowData,
748 getShowData,
749 getAccDescription,
750 setAccDescription
751};
752const getStyles = (options) => `
753 .pieCircle{
754 stroke: ${options.pieStrokeColor};
755 stroke-width : ${options.pieStrokeWidth};
756 opacity : ${options.pieOpacity};
757 }
758 .pieOuterCircle{
759 stroke: ${options.pieOuterStrokeColor};
760 stroke-width: ${options.pieOuterStrokeWidth};
761 fill: none;
762 }
763 .pieTitleText {
764 text-anchor: middle;
765 font-size: ${options.pieTitleTextSize};
766 fill: ${options.pieTitleTextColor};
767 font-family: ${options.fontFamily};
768 }
769 .slice {
770 font-family: ${options.fontFamily};
771 fill: ${options.pieSectionTextColor};
772 font-size:${options.pieSectionTextSize};
773 // fill: white;
774 }
775 .legend text {
776 fill: ${options.pieLegendTextColor};
777 font-family: ${options.fontFamily};
778 font-size: ${options.pieLegendTextSize};
779 }
780`;
781const styles = getStyles;
782let conf = getConfig();
783let width;
784const height = 450;
785const draw = (txt, id, _version, diagObj) => {
786 var _a;
787 try {
788 conf = getConfig();
789 log.debug("Rendering info diagram\n" + txt);
790 const securityLevel = getConfig().securityLevel;
791 let sandboxElement;
792 if (securityLevel === "sandbox") {
793 sandboxElement = select("#i" + id);
794 }
795 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
796 const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
797 diagObj.db.clear();
798 diagObj.parser.parse(txt);
799 log.debug("Parsed info diagram");
800 const elem = doc.getElementById(id);
801 width = elem.parentElement.offsetWidth;
802 if (width === void 0) {
803 width = 1200;
804 }
805 if (conf.useWidth !== void 0) {
806 width = conf.useWidth;
807 }
808 if (conf.pie.useWidth !== void 0) {
809 width = conf.pie.useWidth;
810 }
811 const diagram2 = root.select("#" + id);
812 configureSvgSize(diagram2, height, width, conf.pie.useMaxWidth);
813 elem.setAttribute("viewBox", "0 0 " + width + " " + height);
814 var margin = 40;
815 var legendRectSize = 18;
816 var legendSpacing = 4;
817 var radius = Math.min(width, height) / 2 - margin;
818 var svg = diagram2.append("g").attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
819 var data = diagObj.db.getSections();
820 var sum = 0;
821 Object.keys(data).forEach(function(key) {
822 sum += data[key];
823 });
824 const themeVariables = conf.themeVariables;
825 var myGeneratedColors = [
826 themeVariables.pie1,
827 themeVariables.pie2,
828 themeVariables.pie3,
829 themeVariables.pie4,
830 themeVariables.pie5,
831 themeVariables.pie6,
832 themeVariables.pie7,
833 themeVariables.pie8,
834 themeVariables.pie9,
835 themeVariables.pie10,
836 themeVariables.pie11,
837 themeVariables.pie12
838 ];
839 const textPosition = ((_a = conf.pie) == null ? void 0 : _a.textPosition) ?? 0.75;
840 let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
841 outerStrokeWidth ?? (outerStrokeWidth = 2);
842 var color = ordinal().range(myGeneratedColors);
843 var pieData = Object.entries(data).map(function(el, idx) {
844 return {
845 order: idx,
846 name: el[0],
847 value: el[1]
848 };
849 });
850 var pie = d3pie().value(function(d) {
851 return d.value;
852 }).sort(function(a, b) {
853 return a.order - b.order;
854 });
855 var dataReady = pie(pieData);
856 var arcGenerator = d3arc().innerRadius(0).outerRadius(radius);
857 var labelArcGenerator = d3arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
858 svg.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
859 svg.selectAll("mySlices").data(dataReady).enter().append("path").attr("d", arcGenerator).attr("fill", function(d) {
860 return color(d.data.name);
861 }).attr("class", "pieCircle");
862 svg.selectAll("mySlices").data(dataReady).enter().append("text").text(function(d) {
863 return (d.data.value / sum * 100).toFixed(0) + "%";
864 }).attr("transform", function(d) {
865 return "translate(" + labelArcGenerator.centroid(d) + ")";
866 }).style("text-anchor", "middle").attr("class", "slice");
867 svg.append("text").text(diagObj.db.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText");
868 var legend = svg.selectAll(".legend").data(color.domain()).enter().append("g").attr("class", "legend").attr("transform", function(d, i) {
869 const height2 = legendRectSize + legendSpacing;
870 const offset = height2 * color.domain().length / 2;
871 const horizontal = 12 * legendRectSize;
872 const vertical = i * height2 - offset;
873 return "translate(" + horizontal + "," + vertical + ")";
874 });
875 legend.append("rect").attr("width", legendRectSize).attr("height", legendRectSize).style("fill", color).style("stroke", color);
876 legend.data(dataReady).append("text").attr("x", legendRectSize + legendSpacing).attr("y", legendRectSize - legendSpacing).text(function(d) {
877 if (diagObj.db.getShowData() || conf.showData || conf.pie.showData) {
878 return d.data.name + " [" + d.data.value + "]";
879 } else {
880 return d.data.name;
881 }
882 });
883 } catch (e) {
884 log.error("Error while rendering info diagram");
885 log.error(e);
886 }
887};
888const renderer = {
889 draw
890};
891const diagram = {
892 parser: parser$1,
893 db,
894 renderer,
895 styles
896};
897export {
898 diagram
899};