UNPKG

42.5 kBJavaScriptView Raw
1import { c as getConfig, r as setDiagramTitle, t as getDiagramTitle, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, m as mermaidAPI, v as clear$1, i as configureSvgSize } from "./mermaid-a953d906.js";
2import { arc, select } from "d3";
3import { d as drawRect$1, f as drawText$1, a as drawBackgroundRect$1, g as getNoteRect } from "./svgDrawCommon-f26cad39.js";
4import "ts-dedent";
5import "dayjs/esm/index.js";
6import "@braintree/sanitize-url";
7import "dompurify";
8import "khroma";
9import "lodash-es/memoize.js";
10import "stylis";
11import "lodash-es/isEmpty.js";
12var parser = function() {
13 var o = function(k, v, o2, l) {
14 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
15 ;
16 return o2;
17 }, $V0 = [1, 2], $V1 = [1, 5], $V2 = [6, 9, 11, 17, 18, 20, 22, 23, 24, 26], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 17], $V6 = [1, 18], $V7 = [1, 19], $V8 = [1, 20], $V9 = [1, 24], $Va = [4, 6, 9, 11, 17, 18, 20, 22, 23, 24, 26];
18 var parser2 = {
19 trace: function trace() {
20 },
21 yy: {},
22 symbols_: { "error": 2, "start": 3, "journey": 4, "document": 5, "EOF": 6, "directive": 7, "line": 8, "SPACE": 9, "statement": 10, "NEWLINE": 11, "openDirective": 12, "typeDirective": 13, "closeDirective": 14, ":": 15, "argDirective": 16, "title": 17, "acc_title": 18, "acc_title_value": 19, "acc_descr": 20, "acc_descr_value": 21, "acc_descr_multiline_value": 22, "section": 23, "taskName": 24, "taskData": 25, "open_directive": 26, "type_directive": 27, "arg_directive": 28, "close_directive": 29, "$accept": 0, "$end": 1 },
23 terminals_: { 2: "error", 4: "journey", 6: "EOF", 9: "SPACE", 11: "NEWLINE", 15: ":", 17: "title", 18: "acc_title", 19: "acc_title_value", 20: "acc_descr", 21: "acc_descr_value", 22: "acc_descr_multiline_value", 23: "section", 24: "taskName", 25: "taskData", 26: "open_directive", 27: "type_directive", 28: "arg_directive", 29: "close_directive" },
24 productions_: [0, [3, 3], [3, 2], [5, 0], [5, 2], [8, 2], [8, 1], [8, 1], [8, 1], [7, 4], [7, 6], [10, 1], [10, 2], [10, 2], [10, 1], [10, 1], [10, 2], [10, 1], [12, 1], [13, 1], [16, 1], [14, 1]],
25 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
26 var $0 = $$.length - 1;
27 switch (yystate) {
28 case 1:
29 return $$[$0 - 1];
30 case 3:
31 this.$ = [];
32 break;
33 case 4:
34 $$[$0 - 1].push($$[$0]);
35 this.$ = $$[$0 - 1];
36 break;
37 case 5:
38 case 6:
39 this.$ = $$[$0];
40 break;
41 case 7:
42 case 8:
43 this.$ = [];
44 break;
45 case 11:
46 yy.setDiagramTitle($$[$0].substr(6));
47 this.$ = $$[$0].substr(6);
48 break;
49 case 12:
50 this.$ = $$[$0].trim();
51 yy.setAccTitle(this.$);
52 break;
53 case 13:
54 case 14:
55 this.$ = $$[$0].trim();
56 yy.setAccDescription(this.$);
57 break;
58 case 15:
59 yy.addSection($$[$0].substr(8));
60 this.$ = $$[$0].substr(8);
61 break;
62 case 16:
63 yy.addTask($$[$0 - 1], $$[$0]);
64 this.$ = "task";
65 break;
66 case 18:
67 yy.parseDirective("%%{", "open_directive");
68 break;
69 case 19:
70 yy.parseDirective($$[$0], "type_directive");
71 break;
72 case 20:
73 $$[$0] = $$[$0].trim().replace(/'/g, '"');
74 yy.parseDirective($$[$0], "arg_directive");
75 break;
76 case 21:
77 yy.parseDirective("}%%", "close_directive", "journey");
78 break;
79 }
80 },
81 table: [{ 3: 1, 4: $V0, 7: 3, 12: 4, 26: $V1 }, { 1: [3] }, o($V2, [2, 3], { 5: 6 }), { 3: 7, 4: $V0, 7: 3, 12: 4, 26: $V1 }, { 13: 8, 27: [1, 9] }, { 27: [2, 18] }, { 6: [1, 10], 7: 21, 8: 11, 9: [1, 12], 10: 13, 11: [1, 14], 12: 4, 17: $V3, 18: $V4, 20: $V5, 22: $V6, 23: $V7, 24: $V8, 26: $V1 }, { 1: [2, 2] }, { 14: 22, 15: [1, 23], 29: $V9 }, o([15, 29], [2, 19]), o($V2, [2, 8], { 1: [2, 1] }), o($V2, [2, 4]), { 7: 21, 10: 25, 12: 4, 17: $V3, 18: $V4, 20: $V5, 22: $V6, 23: $V7, 24: $V8, 26: $V1 }, o($V2, [2, 6]), o($V2, [2, 7]), o($V2, [2, 11]), { 19: [1, 26] }, { 21: [1, 27] }, o($V2, [2, 14]), o($V2, [2, 15]), { 25: [1, 28] }, o($V2, [2, 17]), { 11: [1, 29] }, { 16: 30, 28: [1, 31] }, { 11: [2, 21] }, o($V2, [2, 5]), o($V2, [2, 12]), o($V2, [2, 13]), o($V2, [2, 16]), o($Va, [2, 9]), { 14: 32, 29: $V9 }, { 29: [2, 20] }, { 11: [1, 33] }, o($Va, [2, 10])],
82 defaultActions: { 5: [2, 18], 7: [2, 2], 24: [2, 21], 31: [2, 20] },
83 parseError: function parseError(str, hash) {
84 if (hash.recoverable) {
85 this.trace(str);
86 } else {
87 var error = new Error(str);
88 error.hash = hash;
89 throw error;
90 }
91 },
92 parse: function parse(input) {
93 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
94 var args = lstack.slice.call(arguments, 1);
95 var lexer2 = Object.create(this.lexer);
96 var sharedState = { yy: {} };
97 for (var k in this.yy) {
98 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
99 sharedState.yy[k] = this.yy[k];
100 }
101 }
102 lexer2.setInput(input, sharedState.yy);
103 sharedState.yy.lexer = lexer2;
104 sharedState.yy.parser = this;
105 if (typeof lexer2.yylloc == "undefined") {
106 lexer2.yylloc = {};
107 }
108 var yyloc = lexer2.yylloc;
109 lstack.push(yyloc);
110 var ranges = lexer2.options && lexer2.options.ranges;
111 if (typeof sharedState.yy.parseError === "function") {
112 this.parseError = sharedState.yy.parseError;
113 } else {
114 this.parseError = Object.getPrototypeOf(this).parseError;
115 }
116 function lex() {
117 var token;
118 token = tstack.pop() || lexer2.lex() || EOF;
119 if (typeof token !== "number") {
120 if (token instanceof Array) {
121 tstack = token;
122 token = tstack.pop();
123 }
124 token = self.symbols_[token] || token;
125 }
126 return token;
127 }
128 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
129 while (true) {
130 state = stack[stack.length - 1];
131 if (this.defaultActions[state]) {
132 action = this.defaultActions[state];
133 } else {
134 if (symbol === null || typeof symbol == "undefined") {
135 symbol = lex();
136 }
137 action = table[state] && table[state][symbol];
138 }
139 if (typeof action === "undefined" || !action.length || !action[0]) {
140 var errStr = "";
141 expected = [];
142 for (p in table[state]) {
143 if (this.terminals_[p] && p > TERROR) {
144 expected.push("'" + this.terminals_[p] + "'");
145 }
146 }
147 if (lexer2.showPosition) {
148 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
149 } else {
150 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
151 }
152 this.parseError(errStr, {
153 text: lexer2.match,
154 token: this.terminals_[symbol] || symbol,
155 line: lexer2.yylineno,
156 loc: yyloc,
157 expected
158 });
159 }
160 if (action[0] instanceof Array && action.length > 1) {
161 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
162 }
163 switch (action[0]) {
164 case 1:
165 stack.push(symbol);
166 vstack.push(lexer2.yytext);
167 lstack.push(lexer2.yylloc);
168 stack.push(action[1]);
169 symbol = null;
170 {
171 yyleng = lexer2.yyleng;
172 yytext = lexer2.yytext;
173 yylineno = lexer2.yylineno;
174 yyloc = lexer2.yylloc;
175 }
176 break;
177 case 2:
178 len = this.productions_[action[1]][1];
179 yyval.$ = vstack[vstack.length - len];
180 yyval._$ = {
181 first_line: lstack[lstack.length - (len || 1)].first_line,
182 last_line: lstack[lstack.length - 1].last_line,
183 first_column: lstack[lstack.length - (len || 1)].first_column,
184 last_column: lstack[lstack.length - 1].last_column
185 };
186 if (ranges) {
187 yyval._$.range = [
188 lstack[lstack.length - (len || 1)].range[0],
189 lstack[lstack.length - 1].range[1]
190 ];
191 }
192 r = this.performAction.apply(yyval, [
193 yytext,
194 yyleng,
195 yylineno,
196 sharedState.yy,
197 action[1],
198 vstack,
199 lstack
200 ].concat(args));
201 if (typeof r !== "undefined") {
202 return r;
203 }
204 if (len) {
205 stack = stack.slice(0, -1 * len * 2);
206 vstack = vstack.slice(0, -1 * len);
207 lstack = lstack.slice(0, -1 * len);
208 }
209 stack.push(this.productions_[action[1]][0]);
210 vstack.push(yyval.$);
211 lstack.push(yyval._$);
212 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
213 stack.push(newState);
214 break;
215 case 3:
216 return true;
217 }
218 }
219 return true;
220 }
221 };
222 var lexer = function() {
223 var lexer2 = {
224 EOF: 1,
225 parseError: function parseError(str, hash) {
226 if (this.yy.parser) {
227 this.yy.parser.parseError(str, hash);
228 } else {
229 throw new Error(str);
230 }
231 },
232 // resets the lexer, sets new input
233 setInput: function(input, yy) {
234 this.yy = yy || this.yy || {};
235 this._input = input;
236 this._more = this._backtrack = this.done = false;
237 this.yylineno = this.yyleng = 0;
238 this.yytext = this.matched = this.match = "";
239 this.conditionStack = ["INITIAL"];
240 this.yylloc = {
241 first_line: 1,
242 first_column: 0,
243 last_line: 1,
244 last_column: 0
245 };
246 if (this.options.ranges) {
247 this.yylloc.range = [0, 0];
248 }
249 this.offset = 0;
250 return this;
251 },
252 // consumes and returns one char from the input
253 input: function() {
254 var ch = this._input[0];
255 this.yytext += ch;
256 this.yyleng++;
257 this.offset++;
258 this.match += ch;
259 this.matched += ch;
260 var lines = ch.match(/(?:\r\n?|\n).*/g);
261 if (lines) {
262 this.yylineno++;
263 this.yylloc.last_line++;
264 } else {
265 this.yylloc.last_column++;
266 }
267 if (this.options.ranges) {
268 this.yylloc.range[1]++;
269 }
270 this._input = this._input.slice(1);
271 return ch;
272 },
273 // unshifts one char (or a string) into the input
274 unput: function(ch) {
275 var len = ch.length;
276 var lines = ch.split(/(?:\r\n?|\n)/g);
277 this._input = ch + this._input;
278 this.yytext = this.yytext.substr(0, this.yytext.length - len);
279 this.offset -= len;
280 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
281 this.match = this.match.substr(0, this.match.length - 1);
282 this.matched = this.matched.substr(0, this.matched.length - 1);
283 if (lines.length - 1) {
284 this.yylineno -= lines.length - 1;
285 }
286 var r = this.yylloc.range;
287 this.yylloc = {
288 first_line: this.yylloc.first_line,
289 last_line: this.yylineno + 1,
290 first_column: this.yylloc.first_column,
291 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
292 };
293 if (this.options.ranges) {
294 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
295 }
296 this.yyleng = this.yytext.length;
297 return this;
298 },
299 // When called from action, caches matched text and appends it on next action
300 more: function() {
301 this._more = true;
302 return this;
303 },
304 // 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.
305 reject: function() {
306 if (this.options.backtrack_lexer) {
307 this._backtrack = true;
308 } else {
309 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(), {
310 text: "",
311 token: null,
312 line: this.yylineno
313 });
314 }
315 return this;
316 },
317 // retain first n characters of the match
318 less: function(n) {
319 this.unput(this.match.slice(n));
320 },
321 // displays already matched input, i.e. for error messages
322 pastInput: function() {
323 var past = this.matched.substr(0, this.matched.length - this.match.length);
324 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
325 },
326 // displays upcoming input, i.e. for error messages
327 upcomingInput: function() {
328 var next = this.match;
329 if (next.length < 20) {
330 next += this._input.substr(0, 20 - next.length);
331 }
332 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
333 },
334 // displays the character position where the lexing error occurred, i.e. for error messages
335 showPosition: function() {
336 var pre = this.pastInput();
337 var c = new Array(pre.length + 1).join("-");
338 return pre + this.upcomingInput() + "\n" + c + "^";
339 },
340 // test the lexed token: return FALSE when not a match, otherwise return token
341 test_match: function(match, indexed_rule) {
342 var token, lines, backup;
343 if (this.options.backtrack_lexer) {
344 backup = {
345 yylineno: this.yylineno,
346 yylloc: {
347 first_line: this.yylloc.first_line,
348 last_line: this.last_line,
349 first_column: this.yylloc.first_column,
350 last_column: this.yylloc.last_column
351 },
352 yytext: this.yytext,
353 match: this.match,
354 matches: this.matches,
355 matched: this.matched,
356 yyleng: this.yyleng,
357 offset: this.offset,
358 _more: this._more,
359 _input: this._input,
360 yy: this.yy,
361 conditionStack: this.conditionStack.slice(0),
362 done: this.done
363 };
364 if (this.options.ranges) {
365 backup.yylloc.range = this.yylloc.range.slice(0);
366 }
367 }
368 lines = match[0].match(/(?:\r\n?|\n).*/g);
369 if (lines) {
370 this.yylineno += lines.length;
371 }
372 this.yylloc = {
373 first_line: this.yylloc.last_line,
374 last_line: this.yylineno + 1,
375 first_column: this.yylloc.last_column,
376 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
377 };
378 this.yytext += match[0];
379 this.match += match[0];
380 this.matches = match;
381 this.yyleng = this.yytext.length;
382 if (this.options.ranges) {
383 this.yylloc.range = [this.offset, this.offset += this.yyleng];
384 }
385 this._more = false;
386 this._backtrack = false;
387 this._input = this._input.slice(match[0].length);
388 this.matched += match[0];
389 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
390 if (this.done && this._input) {
391 this.done = false;
392 }
393 if (token) {
394 return token;
395 } else if (this._backtrack) {
396 for (var k in backup) {
397 this[k] = backup[k];
398 }
399 return false;
400 }
401 return false;
402 },
403 // return next match in input
404 next: function() {
405 if (this.done) {
406 return this.EOF;
407 }
408 if (!this._input) {
409 this.done = true;
410 }
411 var token, match, tempMatch, index;
412 if (!this._more) {
413 this.yytext = "";
414 this.match = "";
415 }
416 var rules = this._currentRules();
417 for (var i = 0; i < rules.length; i++) {
418 tempMatch = this._input.match(this.rules[rules[i]]);
419 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
420 match = tempMatch;
421 index = i;
422 if (this.options.backtrack_lexer) {
423 token = this.test_match(tempMatch, rules[i]);
424 if (token !== false) {
425 return token;
426 } else if (this._backtrack) {
427 match = false;
428 continue;
429 } else {
430 return false;
431 }
432 } else if (!this.options.flex) {
433 break;
434 }
435 }
436 }
437 if (match) {
438 token = this.test_match(match, rules[index]);
439 if (token !== false) {
440 return token;
441 }
442 return false;
443 }
444 if (this._input === "") {
445 return this.EOF;
446 } else {
447 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
448 text: "",
449 token: null,
450 line: this.yylineno
451 });
452 }
453 },
454 // return next match that has a token
455 lex: function lex() {
456 var r = this.next();
457 if (r) {
458 return r;
459 } else {
460 return this.lex();
461 }
462 },
463 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
464 begin: function begin(condition) {
465 this.conditionStack.push(condition);
466 },
467 // pop the previously active lexer condition state off the condition stack
468 popState: function popState() {
469 var n = this.conditionStack.length - 1;
470 if (n > 0) {
471 return this.conditionStack.pop();
472 } else {
473 return this.conditionStack[0];
474 }
475 },
476 // produce the lexer rule set which is active for the currently active lexer condition state
477 _currentRules: function _currentRules() {
478 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
479 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
480 } else {
481 return this.conditions["INITIAL"].rules;
482 }
483 },
484 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
485 topState: function topState(n) {
486 n = this.conditionStack.length - 1 - Math.abs(n || 0);
487 if (n >= 0) {
488 return this.conditionStack[n];
489 } else {
490 return "INITIAL";
491 }
492 },
493 // alias for begin(condition)
494 pushState: function pushState(condition) {
495 this.begin(condition);
496 },
497 // return the number of states currently on the stack
498 stateStackSize: function stateStackSize() {
499 return this.conditionStack.length;
500 },
501 options: { "case-insensitive": true },
502 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
503 switch ($avoiding_name_collisions) {
504 case 0:
505 this.begin("open_directive");
506 return 26;
507 case 1:
508 this.begin("type_directive");
509 return 27;
510 case 2:
511 this.popState();
512 this.begin("arg_directive");
513 return 15;
514 case 3:
515 this.popState();
516 this.popState();
517 return 29;
518 case 4:
519 return 28;
520 case 5:
521 break;
522 case 6:
523 break;
524 case 7:
525 return 11;
526 case 8:
527 break;
528 case 9:
529 break;
530 case 10:
531 return 4;
532 case 11:
533 return 17;
534 case 12:
535 this.begin("acc_title");
536 return 18;
537 case 13:
538 this.popState();
539 return "acc_title_value";
540 case 14:
541 this.begin("acc_descr");
542 return 20;
543 case 15:
544 this.popState();
545 return "acc_descr_value";
546 case 16:
547 this.begin("acc_descr_multiline");
548 break;
549 case 17:
550 this.popState();
551 break;
552 case 18:
553 return "acc_descr_multiline_value";
554 case 19:
555 return 23;
556 case 20:
557 return 24;
558 case 21:
559 return 25;
560 case 22:
561 return 15;
562 case 23:
563 return 6;
564 case 24:
565 return "INVALID";
566 }
567 },
568 rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:journey\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i],
569 conditions: { "open_directive": { "rules": [1], "inclusive": false }, "type_directive": { "rules": [2, 3], "inclusive": false }, "arg_directive": { "rules": [3, 4], "inclusive": false }, "acc_descr_multiline": { "rules": [17, 18], "inclusive": false }, "acc_descr": { "rules": [15], "inclusive": false }, "acc_title": { "rules": [13], "inclusive": false }, "INITIAL": { "rules": [0, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 19, 20, 21, 22, 23, 24], "inclusive": true } }
570 };
571 return lexer2;
572 }();
573 parser2.lexer = lexer;
574 function Parser() {
575 this.yy = {};
576 }
577 Parser.prototype = parser2;
578 parser2.Parser = Parser;
579 return new Parser();
580}();
581parser.parser = parser;
582const parser$1 = parser;
583let currentSection = "";
584const sections = [];
585const tasks = [];
586const rawTasks = [];
587const parseDirective = function(statement, context, type) {
588 mermaidAPI.parseDirective(this, statement, context, type);
589};
590const clear = function() {
591 sections.length = 0;
592 tasks.length = 0;
593 currentSection = "";
594 rawTasks.length = 0;
595 clear$1();
596};
597const addSection = function(txt) {
598 currentSection = txt;
599 sections.push(txt);
600};
601const getSections = function() {
602 return sections;
603};
604const getTasks = function() {
605 let allItemsProcessed = compileTasks();
606 const maxDepth = 100;
607 let iterationCount = 0;
608 while (!allItemsProcessed && iterationCount < maxDepth) {
609 allItemsProcessed = compileTasks();
610 iterationCount++;
611 }
612 tasks.push(...rawTasks);
613 return tasks;
614};
615const updateActors = function() {
616 const tempActors = [];
617 tasks.forEach((task) => {
618 if (task.people) {
619 tempActors.push(...task.people);
620 }
621 });
622 const unique = new Set(tempActors);
623 return [...unique].sort();
624};
625const addTask = function(descr, taskData) {
626 const pieces = taskData.substr(1).split(":");
627 let score = 0;
628 let peeps = [];
629 if (pieces.length === 1) {
630 score = Number(pieces[0]);
631 peeps = [];
632 } else {
633 score = Number(pieces[0]);
634 peeps = pieces[1].split(",");
635 }
636 const peopleList = peeps.map((s) => s.trim());
637 const rawTask = {
638 section: currentSection,
639 type: currentSection,
640 people: peopleList,
641 task: descr,
642 score
643 };
644 rawTasks.push(rawTask);
645};
646const addTaskOrg = function(descr) {
647 const newTask = {
648 section: currentSection,
649 type: currentSection,
650 description: descr,
651 task: descr,
652 classes: []
653 };
654 tasks.push(newTask);
655};
656const compileTasks = function() {
657 const compileTask = function(pos) {
658 return rawTasks[pos].processed;
659 };
660 let allProcessed = true;
661 for (const [i, rawTask] of rawTasks.entries()) {
662 compileTask(i);
663 allProcessed = allProcessed && rawTask.processed;
664 }
665 return allProcessed;
666};
667const getActors = function() {
668 return updateActors();
669};
670const db = {
671 parseDirective,
672 getConfig: () => getConfig().journey,
673 clear,
674 setDiagramTitle,
675 getDiagramTitle,
676 setAccTitle,
677 getAccTitle,
678 setAccDescription,
679 getAccDescription,
680 addSection,
681 getSections,
682 getTasks,
683 addTask,
684 addTaskOrg,
685 getActors
686};
687const getStyles = (options) => `.label {
688 font-family: 'trebuchet ms', verdana, arial, sans-serif;
689 font-family: var(--mermaid-font-family);
690 color: ${options.textColor};
691 }
692 .mouth {
693 stroke: #666;
694 }
695
696 line {
697 stroke: ${options.textColor}
698 }
699
700 .legend {
701 fill: ${options.textColor};
702 }
703
704 .label text {
705 fill: #333;
706 }
707 .label {
708 color: ${options.textColor}
709 }
710
711 .face {
712 ${options.faceColor ? `fill: ${options.faceColor}` : "fill: #FFF8DC"};
713 stroke: #999;
714 }
715
716 .node rect,
717 .node circle,
718 .node ellipse,
719 .node polygon,
720 .node path {
721 fill: ${options.mainBkg};
722 stroke: ${options.nodeBorder};
723 stroke-width: 1px;
724 }
725
726 .node .label {
727 text-align: center;
728 }
729 .node.clickable {
730 cursor: pointer;
731 }
732
733 .arrowheadPath {
734 fill: ${options.arrowheadColor};
735 }
736
737 .edgePath .path {
738 stroke: ${options.lineColor};
739 stroke-width: 1.5px;
740 }
741
742 .flowchart-link {
743 stroke: ${options.lineColor};
744 fill: none;
745 }
746
747 .edgeLabel {
748 background-color: ${options.edgeLabelBackground};
749 rect {
750 opacity: 0.5;
751 }
752 text-align: center;
753 }
754
755 .cluster rect {
756 }
757
758 .cluster text {
759 fill: ${options.titleColor};
760 }
761
762 div.mermaidTooltip {
763 position: absolute;
764 text-align: center;
765 max-width: 200px;
766 padding: 2px;
767 font-family: 'trebuchet ms', verdana, arial, sans-serif;
768 font-family: var(--mermaid-font-family);
769 font-size: 12px;
770 background: ${options.tertiaryColor};
771 border: 1px solid ${options.border2};
772 border-radius: 2px;
773 pointer-events: none;
774 z-index: 100;
775 }
776
777 .task-type-0, .section-type-0 {
778 ${options.fillType0 ? `fill: ${options.fillType0}` : ""};
779 }
780 .task-type-1, .section-type-1 {
781 ${options.fillType0 ? `fill: ${options.fillType1}` : ""};
782 }
783 .task-type-2, .section-type-2 {
784 ${options.fillType0 ? `fill: ${options.fillType2}` : ""};
785 }
786 .task-type-3, .section-type-3 {
787 ${options.fillType0 ? `fill: ${options.fillType3}` : ""};
788 }
789 .task-type-4, .section-type-4 {
790 ${options.fillType0 ? `fill: ${options.fillType4}` : ""};
791 }
792 .task-type-5, .section-type-5 {
793 ${options.fillType0 ? `fill: ${options.fillType5}` : ""};
794 }
795 .task-type-6, .section-type-6 {
796 ${options.fillType0 ? `fill: ${options.fillType6}` : ""};
797 }
798 .task-type-7, .section-type-7 {
799 ${options.fillType0 ? `fill: ${options.fillType7}` : ""};
800 }
801
802 .actor-0 {
803 ${options.actor0 ? `fill: ${options.actor0}` : ""};
804 }
805 .actor-1 {
806 ${options.actor1 ? `fill: ${options.actor1}` : ""};
807 }
808 .actor-2 {
809 ${options.actor2 ? `fill: ${options.actor2}` : ""};
810 }
811 .actor-3 {
812 ${options.actor3 ? `fill: ${options.actor3}` : ""};
813 }
814 .actor-4 {
815 ${options.actor4 ? `fill: ${options.actor4}` : ""};
816 }
817 .actor-5 {
818 ${options.actor5 ? `fill: ${options.actor5}` : ""};
819 }
820`;
821const styles = getStyles;
822const drawRect = function(elem, rectData) {
823 return drawRect$1(elem, rectData);
824};
825const drawFace = function(element, faceData) {
826 const radius = 15;
827 const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible");
828 const face = element.append("g");
829 face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666");
830 face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666");
831 function smile(face2) {
832 const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2);
833 face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")");
834 }
835 function sad(face2) {
836 const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2);
837 face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")");
838 }
839 function ambivalent(face2) {
840 face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666");
841 }
842 if (faceData.score > 3) {
843 smile(face);
844 } else if (faceData.score < 3) {
845 sad(face);
846 } else {
847 ambivalent(face);
848 }
849 return circleElement;
850};
851const drawCircle = function(element, circleData) {
852 const circleElement = element.append("circle");
853 circleElement.attr("cx", circleData.cx);
854 circleElement.attr("cy", circleData.cy);
855 circleElement.attr("class", "actor-" + circleData.pos);
856 circleElement.attr("fill", circleData.fill);
857 circleElement.attr("stroke", circleData.stroke);
858 circleElement.attr("r", circleData.r);
859 if (circleElement.class !== void 0) {
860 circleElement.attr("class", circleElement.class);
861 }
862 if (circleData.title !== void 0) {
863 circleElement.append("title").text(circleData.title);
864 }
865 return circleElement;
866};
867const drawText = function(elem, textData) {
868 return drawText$1(elem, textData);
869};
870const drawLabel = function(elem, txtObject) {
871 function genPoints(x, y, width, height, cut) {
872 return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
873 }
874 const polygon = elem.append("polygon");
875 polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7));
876 polygon.attr("class", "labelBox");
877 txtObject.y = txtObject.y + txtObject.labelMargin;
878 txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin;
879 drawText(elem, txtObject);
880};
881const drawSection = function(elem, section, conf2) {
882 const g = elem.append("g");
883 const rect = getNoteRect();
884 rect.x = section.x;
885 rect.y = section.y;
886 rect.fill = section.fill;
887 rect.width = conf2.width * section.taskCount + // width of the tasks
888 conf2.diagramMarginX * (section.taskCount - 1);
889 rect.height = conf2.height;
890 rect.class = "journey-section section-type-" + section.num;
891 rect.rx = 3;
892 rect.ry = 3;
893 drawRect(g, rect);
894 _drawTextCandidateFunc(conf2)(
895 section.text,
896 g,
897 rect.x,
898 rect.y,
899 rect.width,
900 rect.height,
901 { class: "journey-section section-type-" + section.num },
902 conf2,
903 section.colour
904 );
905};
906let taskCount = -1;
907const drawTask = function(elem, task, conf2) {
908 const center = task.x + conf2.width / 2;
909 const g = elem.append("g");
910 taskCount++;
911 const maxHeight = 300 + 5 * 30;
912 g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666");
913 drawFace(g, {
914 cx: center,
915 cy: 300 + (5 - task.score) * 30,
916 score: task.score
917 });
918 const rect = getNoteRect();
919 rect.x = task.x;
920 rect.y = task.y;
921 rect.fill = task.fill;
922 rect.width = conf2.width;
923 rect.height = conf2.height;
924 rect.class = "task task-type-" + task.num;
925 rect.rx = 3;
926 rect.ry = 3;
927 drawRect(g, rect);
928 let xPos = task.x + 14;
929 task.people.forEach((person) => {
930 const colour = task.actors[person].color;
931 const circle = {
932 cx: xPos,
933 cy: task.y,
934 r: 7,
935 fill: colour,
936 stroke: "#000",
937 title: person,
938 pos: task.actors[person].position
939 };
940 drawCircle(g, circle);
941 xPos += 10;
942 });
943 _drawTextCandidateFunc(conf2)(
944 task.task,
945 g,
946 rect.x,
947 rect.y,
948 rect.width,
949 rect.height,
950 { class: "task" },
951 conf2,
952 task.colour
953 );
954};
955const drawBackgroundRect = function(elem, bounds2) {
956 drawBackgroundRect$1(elem, bounds2);
957};
958const _drawTextCandidateFunc = function() {
959 function byText(content, g, x, y, width, height, textAttrs, colour) {
960 const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content);
961 _setTextAttrs(text, textAttrs);
962 }
963 function byTspan(content, g, x, y, width, height, textAttrs, conf2, colour) {
964 const { taskFontSize, taskFontFamily } = conf2;
965 const lines = content.split(/<br\s*\/?>/gi);
966 for (let i = 0; i < lines.length; i++) {
967 const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2;
968 const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily);
969 text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
970 text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
971 _setTextAttrs(text, textAttrs);
972 }
973 }
974 function byFo(content, g, x, y, width, height, textAttrs, conf2) {
975 const body = g.append("switch");
976 const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed");
977 const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
978 text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
979 byTspan(content, body, x, y, width, height, textAttrs, conf2);
980 _setTextAttrs(text, textAttrs);
981 }
982 function _setTextAttrs(toText, fromTextAttrsDict) {
983 for (const key in fromTextAttrsDict) {
984 if (key in fromTextAttrsDict) {
985 toText.attr(key, fromTextAttrsDict[key]);
986 }
987 }
988 }
989 return function(conf2) {
990 return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
991 };
992}();
993const initGraphics = function(graphics) {
994 graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z");
995};
996const svgDraw = {
997 drawRect,
998 drawCircle,
999 drawSection,
1000 drawText,
1001 drawLabel,
1002 drawTask,
1003 drawBackgroundRect,
1004 initGraphics
1005};
1006const setConf = function(cnf) {
1007 const keys = Object.keys(cnf);
1008 keys.forEach(function(key) {
1009 conf[key] = cnf[key];
1010 });
1011};
1012const actors = {};
1013function drawActorLegend(diagram2) {
1014 const conf2 = getConfig().journey;
1015 let yPos = 60;
1016 Object.keys(actors).forEach((person) => {
1017 const colour = actors[person].color;
1018 const circleData = {
1019 cx: 20,
1020 cy: yPos,
1021 r: 7,
1022 fill: colour,
1023 stroke: "#000",
1024 pos: actors[person].position
1025 };
1026 svgDraw.drawCircle(diagram2, circleData);
1027 const labelData = {
1028 x: 40,
1029 y: yPos + 7,
1030 fill: "#666",
1031 text: person,
1032 textMargin: conf2.boxTextMargin | 5
1033 };
1034 svgDraw.drawText(diagram2, labelData);
1035 yPos += 20;
1036 });
1037}
1038const conf = getConfig().journey;
1039const LEFT_MARGIN = conf.leftMargin;
1040const draw = function(text, id, version, diagObj) {
1041 const conf2 = getConfig().journey;
1042 diagObj.db.clear();
1043 diagObj.parser.parse(text + "\n");
1044 const securityLevel = getConfig().securityLevel;
1045 let sandboxElement;
1046 if (securityLevel === "sandbox") {
1047 sandboxElement = select("#i" + id);
1048 }
1049 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
1050 bounds.init();
1051 const diagram2 = root.select("#" + id);
1052 svgDraw.initGraphics(diagram2);
1053 const tasks2 = diagObj.db.getTasks();
1054 const title = diagObj.db.getDiagramTitle();
1055 const actorNames = diagObj.db.getActors();
1056 for (const member in actors) {
1057 delete actors[member];
1058 }
1059 let actorPos = 0;
1060 actorNames.forEach((actorName) => {
1061 actors[actorName] = {
1062 color: conf2.actorColours[actorPos % conf2.actorColours.length],
1063 position: actorPos
1064 };
1065 actorPos++;
1066 });
1067 drawActorLegend(diagram2);
1068 bounds.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50);
1069 drawTasks(diagram2, tasks2, 0);
1070 const box = bounds.getBounds();
1071 if (title) {
1072 diagram2.append("text").text(title).attr("x", LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 25);
1073 }
1074 const height = box.stopy - box.starty + 2 * conf2.diagramMarginY;
1075 const width = LEFT_MARGIN + box.stopx + 2 * conf2.diagramMarginX;
1076 configureSvgSize(diagram2, height, width, conf2.useMaxWidth);
1077 diagram2.append("line").attr("x1", LEFT_MARGIN).attr("y1", conf2.height * 4).attr("x2", width - LEFT_MARGIN - 4).attr("y2", conf2.height * 4).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)");
1078 const extraVertForTitle = title ? 70 : 0;
1079 diagram2.attr("viewBox", `${box.startx} -25 ${width} ${height + extraVertForTitle}`);
1080 diagram2.attr("preserveAspectRatio", "xMinYMin meet");
1081 diagram2.attr("height", height + extraVertForTitle + 25);
1082};
1083const bounds = {
1084 data: {
1085 startx: void 0,
1086 stopx: void 0,
1087 starty: void 0,
1088 stopy: void 0
1089 },
1090 verticalPos: 0,
1091 sequenceItems: [],
1092 init: function() {
1093 this.sequenceItems = [];
1094 this.data = {
1095 startx: void 0,
1096 stopx: void 0,
1097 starty: void 0,
1098 stopy: void 0
1099 };
1100 this.verticalPos = 0;
1101 },
1102 updateVal: function(obj, key, val, fun) {
1103 if (obj[key] === void 0) {
1104 obj[key] = val;
1105 } else {
1106 obj[key] = fun(val, obj[key]);
1107 }
1108 },
1109 updateBounds: function(startx, starty, stopx, stopy) {
1110 const conf2 = getConfig().journey;
1111 const _self = this;
1112 let cnt = 0;
1113 function updateFn(type) {
1114 return function updateItemBounds(item) {
1115 cnt++;
1116 const n = _self.sequenceItems.length - cnt + 1;
1117 _self.updateVal(item, "starty", starty - n * conf2.boxMargin, Math.min);
1118 _self.updateVal(item, "stopy", stopy + n * conf2.boxMargin, Math.max);
1119 _self.updateVal(bounds.data, "startx", startx - n * conf2.boxMargin, Math.min);
1120 _self.updateVal(bounds.data, "stopx", stopx + n * conf2.boxMargin, Math.max);
1121 if (!(type === "activation")) {
1122 _self.updateVal(item, "startx", startx - n * conf2.boxMargin, Math.min);
1123 _self.updateVal(item, "stopx", stopx + n * conf2.boxMargin, Math.max);
1124 _self.updateVal(bounds.data, "starty", starty - n * conf2.boxMargin, Math.min);
1125 _self.updateVal(bounds.data, "stopy", stopy + n * conf2.boxMargin, Math.max);
1126 }
1127 };
1128 }
1129 this.sequenceItems.forEach(updateFn());
1130 },
1131 insert: function(startx, starty, stopx, stopy) {
1132 const _startx = Math.min(startx, stopx);
1133 const _stopx = Math.max(startx, stopx);
1134 const _starty = Math.min(starty, stopy);
1135 const _stopy = Math.max(starty, stopy);
1136 this.updateVal(bounds.data, "startx", _startx, Math.min);
1137 this.updateVal(bounds.data, "starty", _starty, Math.min);
1138 this.updateVal(bounds.data, "stopx", _stopx, Math.max);
1139 this.updateVal(bounds.data, "stopy", _stopy, Math.max);
1140 this.updateBounds(_startx, _starty, _stopx, _stopy);
1141 },
1142 bumpVerticalPos: function(bump) {
1143 this.verticalPos = this.verticalPos + bump;
1144 this.data.stopy = this.verticalPos;
1145 },
1146 getVerticalPos: function() {
1147 return this.verticalPos;
1148 },
1149 getBounds: function() {
1150 return this.data;
1151 }
1152};
1153const fills = conf.sectionFills;
1154const textColours = conf.sectionColours;
1155const drawTasks = function(diagram2, tasks2, verticalPos) {
1156 const conf2 = getConfig().journey;
1157 let lastSection = "";
1158 const sectionVHeight = conf2.height * 2 + conf2.diagramMarginY;
1159 const taskPos = verticalPos + sectionVHeight;
1160 let sectionNumber = 0;
1161 let fill = "#CCC";
1162 let colour = "black";
1163 let num = 0;
1164 for (const [i, task] of tasks2.entries()) {
1165 if (lastSection !== task.section) {
1166 fill = fills[sectionNumber % fills.length];
1167 num = sectionNumber % fills.length;
1168 colour = textColours[sectionNumber % textColours.length];
1169 let taskInSectionCount = 0;
1170 const currentSection2 = task.section;
1171 for (let taskIndex = i; taskIndex < tasks2.length; taskIndex++) {
1172 if (tasks2[taskIndex].section == currentSection2) {
1173 taskInSectionCount = taskInSectionCount + 1;
1174 } else {
1175 break;
1176 }
1177 }
1178 const section = {
1179 x: i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN,
1180 y: 50,
1181 text: task.section,
1182 fill,
1183 num,
1184 colour,
1185 taskCount: taskInSectionCount
1186 };
1187 svgDraw.drawSection(diagram2, section, conf2);
1188 lastSection = task.section;
1189 sectionNumber++;
1190 }
1191 const taskActors = task.people.reduce((acc, actorName) => {
1192 if (actors[actorName]) {
1193 acc[actorName] = actors[actorName];
1194 }
1195 return acc;
1196 }, {});
1197 task.x = i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN;
1198 task.y = taskPos;
1199 task.width = conf2.diagramMarginX;
1200 task.height = conf2.diagramMarginY;
1201 task.colour = colour;
1202 task.fill = fill;
1203 task.num = num;
1204 task.actors = taskActors;
1205 svgDraw.drawTask(diagram2, task, conf2);
1206 bounds.insert(task.x, task.y, task.x + task.width + conf2.taskMargin, 300 + 5 * 30);
1207 }
1208};
1209const renderer = {
1210 setConf,
1211 draw
1212};
1213const diagram = {
1214 parser: parser$1,
1215 db,
1216 renderer,
1217 styles,
1218 init: (cnf) => {
1219 renderer.setConf(cnf.journey);
1220 db.clear();
1221 }
1222};
1223export {
1224 diagram
1225};