UNPKG

18.7 kBJavaScriptView Raw
1import { v as clear, l as log, c as getConfig } from "./mermaid-a953d906.js";
2import { select } from "d3";
3import "ts-dedent";
4import "dayjs/esm/index.js";
5import "@braintree/sanitize-url";
6import "dompurify";
7import "khroma";
8import "lodash-es/memoize.js";
9import "stylis";
10import "lodash-es/isEmpty.js";
11var 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 = [6, 9, 10];
17 var parser2 = {
18 trace: function trace() {
19 },
20 yy: {},
21 symbols_: { "error": 2, "start": 3, "info": 4, "document": 5, "EOF": 6, "line": 7, "statement": 8, "NL": 9, "showInfo": 10, "$accept": 0, "$end": 1 },
22 terminals_: { 2: "error", 4: "info", 6: "EOF", 9: "NL", 10: "showInfo" },
23 productions_: [0, [3, 3], [5, 0], [5, 2], [7, 1], [7, 1], [8, 1]],
24 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
25 $$.length - 1;
26 switch (yystate) {
27 case 1:
28 return yy;
29 case 4:
30 break;
31 case 6:
32 yy.setInfo(true);
33 break;
34 }
35 },
36 table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: 6, 9: [1, 7], 10: [1, 8] }, { 1: [2, 1] }, o($V0, [2, 3]), o($V0, [2, 4]), o($V0, [2, 5]), o($V0, [2, 6])],
37 defaultActions: { 4: [2, 1] },
38 parseError: function parseError(str, hash) {
39 if (hash.recoverable) {
40 this.trace(str);
41 } else {
42 var error = new Error(str);
43 error.hash = hash;
44 throw error;
45 }
46 },
47 parse: function parse(input) {
48 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
49 var args = lstack.slice.call(arguments, 1);
50 var lexer2 = Object.create(this.lexer);
51 var sharedState = { yy: {} };
52 for (var k in this.yy) {
53 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
54 sharedState.yy[k] = this.yy[k];
55 }
56 }
57 lexer2.setInput(input, sharedState.yy);
58 sharedState.yy.lexer = lexer2;
59 sharedState.yy.parser = this;
60 if (typeof lexer2.yylloc == "undefined") {
61 lexer2.yylloc = {};
62 }
63 var yyloc = lexer2.yylloc;
64 lstack.push(yyloc);
65 var ranges = lexer2.options && lexer2.options.ranges;
66 if (typeof sharedState.yy.parseError === "function") {
67 this.parseError = sharedState.yy.parseError;
68 } else {
69 this.parseError = Object.getPrototypeOf(this).parseError;
70 }
71 function lex() {
72 var token;
73 token = tstack.pop() || lexer2.lex() || EOF;
74 if (typeof token !== "number") {
75 if (token instanceof Array) {
76 tstack = token;
77 token = tstack.pop();
78 }
79 token = self.symbols_[token] || token;
80 }
81 return token;
82 }
83 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
84 while (true) {
85 state = stack[stack.length - 1];
86 if (this.defaultActions[state]) {
87 action = this.defaultActions[state];
88 } else {
89 if (symbol === null || typeof symbol == "undefined") {
90 symbol = lex();
91 }
92 action = table[state] && table[state][symbol];
93 }
94 if (typeof action === "undefined" || !action.length || !action[0]) {
95 var errStr = "";
96 expected = [];
97 for (p in table[state]) {
98 if (this.terminals_[p] && p > TERROR) {
99 expected.push("'" + this.terminals_[p] + "'");
100 }
101 }
102 if (lexer2.showPosition) {
103 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
104 } else {
105 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
106 }
107 this.parseError(errStr, {
108 text: lexer2.match,
109 token: this.terminals_[symbol] || symbol,
110 line: lexer2.yylineno,
111 loc: yyloc,
112 expected
113 });
114 }
115 if (action[0] instanceof Array && action.length > 1) {
116 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
117 }
118 switch (action[0]) {
119 case 1:
120 stack.push(symbol);
121 vstack.push(lexer2.yytext);
122 lstack.push(lexer2.yylloc);
123 stack.push(action[1]);
124 symbol = null;
125 {
126 yyleng = lexer2.yyleng;
127 yytext = lexer2.yytext;
128 yylineno = lexer2.yylineno;
129 yyloc = lexer2.yylloc;
130 }
131 break;
132 case 2:
133 len = this.productions_[action[1]][1];
134 yyval.$ = vstack[vstack.length - len];
135 yyval._$ = {
136 first_line: lstack[lstack.length - (len || 1)].first_line,
137 last_line: lstack[lstack.length - 1].last_line,
138 first_column: lstack[lstack.length - (len || 1)].first_column,
139 last_column: lstack[lstack.length - 1].last_column
140 };
141 if (ranges) {
142 yyval._$.range = [
143 lstack[lstack.length - (len || 1)].range[0],
144 lstack[lstack.length - 1].range[1]
145 ];
146 }
147 r = this.performAction.apply(yyval, [
148 yytext,
149 yyleng,
150 yylineno,
151 sharedState.yy,
152 action[1],
153 vstack,
154 lstack
155 ].concat(args));
156 if (typeof r !== "undefined") {
157 return r;
158 }
159 if (len) {
160 stack = stack.slice(0, -1 * len * 2);
161 vstack = vstack.slice(0, -1 * len);
162 lstack = lstack.slice(0, -1 * len);
163 }
164 stack.push(this.productions_[action[1]][0]);
165 vstack.push(yyval.$);
166 lstack.push(yyval._$);
167 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
168 stack.push(newState);
169 break;
170 case 3:
171 return true;
172 }
173 }
174 return true;
175 }
176 };
177 var lexer = function() {
178 var lexer2 = {
179 EOF: 1,
180 parseError: function parseError(str, hash) {
181 if (this.yy.parser) {
182 this.yy.parser.parseError(str, hash);
183 } else {
184 throw new Error(str);
185 }
186 },
187 // resets the lexer, sets new input
188 setInput: function(input, yy) {
189 this.yy = yy || this.yy || {};
190 this._input = input;
191 this._more = this._backtrack = this.done = false;
192 this.yylineno = this.yyleng = 0;
193 this.yytext = this.matched = this.match = "";
194 this.conditionStack = ["INITIAL"];
195 this.yylloc = {
196 first_line: 1,
197 first_column: 0,
198 last_line: 1,
199 last_column: 0
200 };
201 if (this.options.ranges) {
202 this.yylloc.range = [0, 0];
203 }
204 this.offset = 0;
205 return this;
206 },
207 // consumes and returns one char from the input
208 input: function() {
209 var ch = this._input[0];
210 this.yytext += ch;
211 this.yyleng++;
212 this.offset++;
213 this.match += ch;
214 this.matched += ch;
215 var lines = ch.match(/(?:\r\n?|\n).*/g);
216 if (lines) {
217 this.yylineno++;
218 this.yylloc.last_line++;
219 } else {
220 this.yylloc.last_column++;
221 }
222 if (this.options.ranges) {
223 this.yylloc.range[1]++;
224 }
225 this._input = this._input.slice(1);
226 return ch;
227 },
228 // unshifts one char (or a string) into the input
229 unput: function(ch) {
230 var len = ch.length;
231 var lines = ch.split(/(?:\r\n?|\n)/g);
232 this._input = ch + this._input;
233 this.yytext = this.yytext.substr(0, this.yytext.length - len);
234 this.offset -= len;
235 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
236 this.match = this.match.substr(0, this.match.length - 1);
237 this.matched = this.matched.substr(0, this.matched.length - 1);
238 if (lines.length - 1) {
239 this.yylineno -= lines.length - 1;
240 }
241 var r = this.yylloc.range;
242 this.yylloc = {
243 first_line: this.yylloc.first_line,
244 last_line: this.yylineno + 1,
245 first_column: this.yylloc.first_column,
246 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
247 };
248 if (this.options.ranges) {
249 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
250 }
251 this.yyleng = this.yytext.length;
252 return this;
253 },
254 // When called from action, caches matched text and appends it on next action
255 more: function() {
256 this._more = true;
257 return this;
258 },
259 // 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.
260 reject: function() {
261 if (this.options.backtrack_lexer) {
262 this._backtrack = true;
263 } else {
264 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(), {
265 text: "",
266 token: null,
267 line: this.yylineno
268 });
269 }
270 return this;
271 },
272 // retain first n characters of the match
273 less: function(n) {
274 this.unput(this.match.slice(n));
275 },
276 // displays already matched input, i.e. for error messages
277 pastInput: function() {
278 var past = this.matched.substr(0, this.matched.length - this.match.length);
279 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
280 },
281 // displays upcoming input, i.e. for error messages
282 upcomingInput: function() {
283 var next = this.match;
284 if (next.length < 20) {
285 next += this._input.substr(0, 20 - next.length);
286 }
287 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
288 },
289 // displays the character position where the lexing error occurred, i.e. for error messages
290 showPosition: function() {
291 var pre = this.pastInput();
292 var c = new Array(pre.length + 1).join("-");
293 return pre + this.upcomingInput() + "\n" + c + "^";
294 },
295 // test the lexed token: return FALSE when not a match, otherwise return token
296 test_match: function(match, indexed_rule) {
297 var token, lines, backup;
298 if (this.options.backtrack_lexer) {
299 backup = {
300 yylineno: this.yylineno,
301 yylloc: {
302 first_line: this.yylloc.first_line,
303 last_line: this.last_line,
304 first_column: this.yylloc.first_column,
305 last_column: this.yylloc.last_column
306 },
307 yytext: this.yytext,
308 match: this.match,
309 matches: this.matches,
310 matched: this.matched,
311 yyleng: this.yyleng,
312 offset: this.offset,
313 _more: this._more,
314 _input: this._input,
315 yy: this.yy,
316 conditionStack: this.conditionStack.slice(0),
317 done: this.done
318 };
319 if (this.options.ranges) {
320 backup.yylloc.range = this.yylloc.range.slice(0);
321 }
322 }
323 lines = match[0].match(/(?:\r\n?|\n).*/g);
324 if (lines) {
325 this.yylineno += lines.length;
326 }
327 this.yylloc = {
328 first_line: this.yylloc.last_line,
329 last_line: this.yylineno + 1,
330 first_column: this.yylloc.last_column,
331 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
332 };
333 this.yytext += match[0];
334 this.match += match[0];
335 this.matches = match;
336 this.yyleng = this.yytext.length;
337 if (this.options.ranges) {
338 this.yylloc.range = [this.offset, this.offset += this.yyleng];
339 }
340 this._more = false;
341 this._backtrack = false;
342 this._input = this._input.slice(match[0].length);
343 this.matched += match[0];
344 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
345 if (this.done && this._input) {
346 this.done = false;
347 }
348 if (token) {
349 return token;
350 } else if (this._backtrack) {
351 for (var k in backup) {
352 this[k] = backup[k];
353 }
354 return false;
355 }
356 return false;
357 },
358 // return next match in input
359 next: function() {
360 if (this.done) {
361 return this.EOF;
362 }
363 if (!this._input) {
364 this.done = true;
365 }
366 var token, match, tempMatch, index;
367 if (!this._more) {
368 this.yytext = "";
369 this.match = "";
370 }
371 var rules = this._currentRules();
372 for (var i = 0; i < rules.length; i++) {
373 tempMatch = this._input.match(this.rules[rules[i]]);
374 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
375 match = tempMatch;
376 index = i;
377 if (this.options.backtrack_lexer) {
378 token = this.test_match(tempMatch, rules[i]);
379 if (token !== false) {
380 return token;
381 } else if (this._backtrack) {
382 match = false;
383 continue;
384 } else {
385 return false;
386 }
387 } else if (!this.options.flex) {
388 break;
389 }
390 }
391 }
392 if (match) {
393 token = this.test_match(match, rules[index]);
394 if (token !== false) {
395 return token;
396 }
397 return false;
398 }
399 if (this._input === "") {
400 return this.EOF;
401 } else {
402 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
403 text: "",
404 token: null,
405 line: this.yylineno
406 });
407 }
408 },
409 // return next match that has a token
410 lex: function lex() {
411 var r = this.next();
412 if (r) {
413 return r;
414 } else {
415 return this.lex();
416 }
417 },
418 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
419 begin: function begin(condition) {
420 this.conditionStack.push(condition);
421 },
422 // pop the previously active lexer condition state off the condition stack
423 popState: function popState() {
424 var n = this.conditionStack.length - 1;
425 if (n > 0) {
426 return this.conditionStack.pop();
427 } else {
428 return this.conditionStack[0];
429 }
430 },
431 // produce the lexer rule set which is active for the currently active lexer condition state
432 _currentRules: function _currentRules() {
433 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
434 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
435 } else {
436 return this.conditions["INITIAL"].rules;
437 }
438 },
439 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
440 topState: function topState(n) {
441 n = this.conditionStack.length - 1 - Math.abs(n || 0);
442 if (n >= 0) {
443 return this.conditionStack[n];
444 } else {
445 return "INITIAL";
446 }
447 },
448 // alias for begin(condition)
449 pushState: function pushState(condition) {
450 this.begin(condition);
451 },
452 // return the number of states currently on the stack
453 stateStackSize: function stateStackSize() {
454 return this.conditionStack.length;
455 },
456 options: { "case-insensitive": true },
457 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
458 switch ($avoiding_name_collisions) {
459 case 0:
460 return 4;
461 case 1:
462 return 9;
463 case 2:
464 return "space";
465 case 3:
466 return 10;
467 case 4:
468 return 6;
469 case 5:
470 return "TXT";
471 }
472 },
473 rules: [/^(?:info\b)/i, /^(?:[\s\n\r]+)/i, /^(?:[\s]+)/i, /^(?:showInfo\b)/i, /^(?:$)/i, /^(?:.)/i],
474 conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5], "inclusive": true } }
475 };
476 return lexer2;
477 }();
478 parser2.lexer = lexer;
479 function Parser() {
480 this.yy = {};
481 }
482 Parser.prototype = parser2;
483 parser2.Parser = Parser;
484 return new Parser();
485}();
486parser.parser = parser;
487const parser$1 = parser;
488var message = "";
489var info = false;
490const setMessage = (txt) => {
491 log.debug("Setting message to: " + txt);
492 message = txt;
493};
494const getMessage = () => {
495 return message;
496};
497const setInfo = (inf) => {
498 info = inf;
499};
500const getInfo = () => {
501 return info;
502};
503const db = {
504 setMessage,
505 getMessage,
506 setInfo,
507 getInfo,
508 clear
509 // parseError
510};
511const getStyles = () => ``;
512const styles = getStyles;
513const draw = (text, id, version) => {
514 try {
515 log.debug("Rendering info diagram\n" + text);
516 const securityLevel = getConfig().securityLevel;
517 let sandboxElement;
518 if (securityLevel === "sandbox") {
519 sandboxElement = select("#i" + id);
520 }
521 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
522 const svg = root.select("#" + id);
523 const g = svg.append("g");
524 g.append("text").attr("x", 100).attr("y", 40).attr("class", "version").attr("font-size", "32px").style("text-anchor", "middle").text("v " + version);
525 svg.attr("height", 100);
526 svg.attr("width", 400);
527 } catch (e) {
528 log.error("Error while rendering info diagram");
529 log.error(e.message);
530 }
531};
532const renderer = {
533 draw
534};
535const diagram = {
536 parser: parser$1,
537 db,
538 renderer,
539 styles
540};
541export {
542 diagram
543};