UNPKG

49.8 kBJavaScriptView Raw
1import { c as getConfig, g as getAccTitle, s as setAccTitle, a as getAccDescription, b as setAccDescription, r as setDiagramTitle, t as getDiagramTitle, m as mermaidAPI, l as log, e as common, v as clear$1, F as generateId } from "./mermaid-a953d906.js";
2var parser = function() {
3 var o = function(k, v, o2, l) {
4 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
5 ;
6 return o2;
7 }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 7], $V4 = [2, 5], $V5 = [1, 15], $V6 = [1, 17], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 37], $Vc = [1, 25], $Vd = [1, 26], $Ve = [1, 27], $Vf = [1, 28], $Vg = [1, 29], $Vh = [1, 32], $Vi = [1, 33], $Vj = [1, 34], $Vk = [1, 35], $Vl = [1, 36], $Vm = [1, 39], $Vn = [1, 40], $Vo = [1, 41], $Vp = [1, 42], $Vq = [1, 38], $Vr = [1, 45], $Vs = [1, 4, 5, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 42, 50, 51, 52, 53, 56, 60], $Vt = [1, 4, 5, 14, 15, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 42, 50, 51, 52, 53, 56, 60], $Vu = [1, 4, 5, 7, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 42, 50, 51, 52, 53, 56, 60], $Vv = [4, 5, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 42, 50, 51, 52, 53, 56, 60];
8 var parser2 = {
9 trace: function trace() {
10 },
11 yy: {},
12 symbols_: { "error": 2, "start": 3, "SPACE": 4, "NL": 5, "directive": 6, "SD": 7, "document": 8, "line": 9, "statement": 10, "classDefStatement": 11, "cssClassStatement": 12, "idStatement": 13, "DESCR": 14, "-->": 15, "HIDE_EMPTY": 16, "scale": 17, "WIDTH": 18, "COMPOSIT_STATE": 19, "STRUCT_START": 20, "STRUCT_STOP": 21, "STATE_DESCR": 22, "AS": 23, "ID": 24, "FORK": 25, "JOIN": 26, "CHOICE": 27, "CONCURRENT": 28, "note": 29, "notePosition": 30, "NOTE_TEXT": 31, "direction": 32, "acc_title": 33, "acc_title_value": 34, "acc_descr": 35, "acc_descr_value": 36, "acc_descr_multiline_value": 37, "classDef": 38, "CLASSDEF_ID": 39, "CLASSDEF_STYLEOPTS": 40, "DEFAULT": 41, "class": 42, "CLASSENTITY_IDS": 43, "STYLECLASS": 44, "openDirective": 45, "typeDirective": 46, "closeDirective": 47, ":": 48, "argDirective": 49, "direction_tb": 50, "direction_bt": 51, "direction_rl": 52, "direction_lr": 53, "eol": 54, ";": 55, "EDGE_STATE": 56, "STYLE_SEPARATOR": 57, "left_of": 58, "right_of": 59, "open_directive": 60, "type_directive": 61, "arg_directive": 62, "close_directive": 63, "$accept": 0, "$end": 1 },
13 terminals_: { 2: "error", 4: "SPACE", 5: "NL", 7: "SD", 14: "DESCR", 15: "-->", 16: "HIDE_EMPTY", 17: "scale", 18: "WIDTH", 19: "COMPOSIT_STATE", 20: "STRUCT_START", 21: "STRUCT_STOP", 22: "STATE_DESCR", 23: "AS", 24: "ID", 25: "FORK", 26: "JOIN", 27: "CHOICE", 28: "CONCURRENT", 29: "note", 31: "NOTE_TEXT", 33: "acc_title", 34: "acc_title_value", 35: "acc_descr", 36: "acc_descr_value", 37: "acc_descr_multiline_value", 38: "classDef", 39: "CLASSDEF_ID", 40: "CLASSDEF_STYLEOPTS", 41: "DEFAULT", 42: "class", 43: "CLASSENTITY_IDS", 44: "STYLECLASS", 48: ":", 50: "direction_tb", 51: "direction_bt", 52: "direction_rl", 53: "direction_lr", 55: ";", 56: "EDGE_STATE", 57: "STYLE_SEPARATOR", 58: "left_of", 59: "right_of", 60: "open_directive", 61: "type_directive", 62: "arg_directive", 63: "close_directive" },
14 productions_: [0, [3, 2], [3, 2], [3, 2], [3, 2], [8, 0], [8, 2], [9, 2], [9, 1], [9, 1], [10, 1], [10, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 1], [10, 2], [10, 1], [10, 4], [10, 3], [10, 6], [10, 1], [10, 1], [10, 1], [10, 1], [10, 4], [10, 4], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [11, 3], [11, 3], [12, 3], [6, 3], [6, 5], [32, 1], [32, 1], [32, 1], [32, 1], [54, 1], [54, 1], [13, 1], [13, 1], [13, 3], [13, 3], [30, 1], [30, 1], [45, 1], [46, 1], [49, 1], [47, 1]],
15 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
16 var $0 = $$.length - 1;
17 switch (yystate) {
18 case 4:
19 yy.setRootDoc($$[$0]);
20 return $$[$0];
21 case 5:
22 this.$ = [];
23 break;
24 case 6:
25 if ($$[$0] != "nl") {
26 $$[$0 - 1].push($$[$0]);
27 this.$ = $$[$0 - 1];
28 }
29 break;
30 case 7:
31 case 8:
32 this.$ = $$[$0];
33 break;
34 case 9:
35 this.$ = "nl";
36 break;
37 case 12:
38 this.$ = $$[$0];
39 break;
40 case 13:
41 const stateStmt = $$[$0 - 1];
42 stateStmt.description = yy.trimColon($$[$0]);
43 this.$ = stateStmt;
44 break;
45 case 14:
46 this.$ = { stmt: "relation", state1: $$[$0 - 2], state2: $$[$0] };
47 break;
48 case 15:
49 const relDescription = yy.trimColon($$[$0]);
50 this.$ = { stmt: "relation", state1: $$[$0 - 3], state2: $$[$0 - 1], description: relDescription };
51 break;
52 case 19:
53 this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: "", doc: $$[$0 - 1] };
54 break;
55 case 20:
56 var id = $$[$0];
57 var description = $$[$0 - 2].trim();
58 if ($$[$0].match(":")) {
59 var parts = $$[$0].split(":");
60 id = parts[0];
61 description = [description, parts[1]];
62 }
63 this.$ = { stmt: "state", id, type: "default", description };
64 break;
65 case 21:
66 this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: $$[$0 - 5], doc: $$[$0 - 1] };
67 break;
68 case 22:
69 this.$ = { stmt: "state", id: $$[$0], type: "fork" };
70 break;
71 case 23:
72 this.$ = { stmt: "state", id: $$[$0], type: "join" };
73 break;
74 case 24:
75 this.$ = { stmt: "state", id: $$[$0], type: "choice" };
76 break;
77 case 25:
78 this.$ = { stmt: "state", id: yy.getDividerId(), type: "divider" };
79 break;
80 case 26:
81 this.$ = { stmt: "state", id: $$[$0 - 1].trim(), note: { position: $$[$0 - 2].trim(), text: $$[$0].trim() } };
82 break;
83 case 30:
84 this.$ = $$[$0].trim();
85 yy.setAccTitle(this.$);
86 break;
87 case 31:
88 case 32:
89 this.$ = $$[$0].trim();
90 yy.setAccDescription(this.$);
91 break;
92 case 33:
93 case 34:
94 this.$ = { stmt: "classDef", id: $$[$0 - 1].trim(), classes: $$[$0].trim() };
95 break;
96 case 35:
97 this.$ = { stmt: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() };
98 break;
99 case 38:
100 yy.setDirection("TB");
101 this.$ = { stmt: "dir", value: "TB" };
102 break;
103 case 39:
104 yy.setDirection("BT");
105 this.$ = { stmt: "dir", value: "BT" };
106 break;
107 case 40:
108 yy.setDirection("RL");
109 this.$ = { stmt: "dir", value: "RL" };
110 break;
111 case 41:
112 yy.setDirection("LR");
113 this.$ = { stmt: "dir", value: "LR" };
114 break;
115 case 44:
116 case 45:
117 this.$ = { stmt: "state", id: $$[$0].trim(), type: "default", description: "" };
118 break;
119 case 46:
120 this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" };
121 break;
122 case 47:
123 this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" };
124 break;
125 case 50:
126 yy.parseDirective("%%{", "open_directive");
127 break;
128 case 51:
129 yy.parseDirective($$[$0], "type_directive");
130 break;
131 case 52:
132 $$[$0] = $$[$0].trim().replace(/'/g, '"');
133 yy.parseDirective($$[$0], "arg_directive");
134 break;
135 case 53:
136 yy.parseDirective("}%%", "close_directive", "state");
137 break;
138 }
139 },
140 table: [{ 3: 1, 4: $V0, 5: $V1, 6: 4, 7: $V2, 45: 6, 60: $V3 }, { 1: [3] }, { 3: 8, 4: $V0, 5: $V1, 6: 4, 7: $V2, 45: 6, 60: $V3 }, { 3: 9, 4: $V0, 5: $V1, 6: 4, 7: $V2, 45: 6, 60: $V3 }, { 3: 10, 4: $V0, 5: $V1, 6: 4, 7: $V2, 45: 6, 60: $V3 }, o([1, 4, 5, 16, 17, 19, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 42, 50, 51, 52, 53, 56, 60], $V4, { 8: 11 }), { 46: 12, 61: [1, 13] }, { 61: [2, 50] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3] }, { 1: [2, 4], 4: $V5, 5: $V6, 6: 30, 9: 14, 10: 16, 11: 18, 12: 19, 13: 20, 16: $V7, 17: $V8, 19: $V9, 22: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 29: $Vg, 32: 31, 33: $Vh, 35: $Vi, 37: $Vj, 38: $Vk, 42: $Vl, 45: 6, 50: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 56: $Vq, 60: $V3 }, { 47: 43, 48: [1, 44], 63: $Vr }, o([48, 63], [2, 51]), o($Vs, [2, 6]), { 6: 30, 10: 46, 11: 18, 12: 19, 13: 20, 16: $V7, 17: $V8, 19: $V9, 22: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 29: $Vg, 32: 31, 33: $Vh, 35: $Vi, 37: $Vj, 38: $Vk, 42: $Vl, 45: 6, 50: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 56: $Vq, 60: $V3 }, o($Vs, [2, 8]), o($Vs, [2, 9]), o($Vs, [2, 10]), o($Vs, [2, 11]), o($Vs, [2, 12], { 14: [1, 47], 15: [1, 48] }), o($Vs, [2, 16]), { 18: [1, 49] }, o($Vs, [2, 18], { 20: [1, 50] }), { 23: [1, 51] }, o($Vs, [2, 22]), o($Vs, [2, 23]), o($Vs, [2, 24]), o($Vs, [2, 25]), { 30: 52, 31: [1, 53], 58: [1, 54], 59: [1, 55] }, o($Vs, [2, 28]), o($Vs, [2, 29]), { 34: [1, 56] }, { 36: [1, 57] }, o($Vs, [2, 32]), { 39: [1, 58], 41: [1, 59] }, { 43: [1, 60] }, o($Vt, [2, 44], { 57: [1, 61] }), o($Vt, [2, 45], { 57: [1, 62] }), o($Vs, [2, 38]), o($Vs, [2, 39]), o($Vs, [2, 40]), o($Vs, [2, 41]), o($Vu, [2, 36]), { 49: 63, 62: [1, 64] }, o($Vu, [2, 53]), o($Vs, [2, 7]), o($Vs, [2, 13]), { 13: 65, 24: $Vb, 56: $Vq }, o($Vs, [2, 17]), o($Vv, $V4, { 8: 66 }), { 24: [1, 67] }, { 24: [1, 68] }, { 23: [1, 69] }, { 24: [2, 48] }, { 24: [2, 49] }, o($Vs, [2, 30]), o($Vs, [2, 31]), { 40: [1, 70] }, { 40: [1, 71] }, { 44: [1, 72] }, { 24: [1, 73] }, { 24: [1, 74] }, { 47: 75, 63: $Vr }, { 63: [2, 52] }, o($Vs, [2, 14], { 14: [1, 76] }), { 4: $V5, 5: $V6, 6: 30, 9: 14, 10: 16, 11: 18, 12: 19, 13: 20, 16: $V7, 17: $V8, 19: $V9, 21: [1, 77], 22: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 29: $Vg, 32: 31, 33: $Vh, 35: $Vi, 37: $Vj, 38: $Vk, 42: $Vl, 45: 6, 50: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 56: $Vq, 60: $V3 }, o($Vs, [2, 20], { 20: [1, 78] }), { 31: [1, 79] }, { 24: [1, 80] }, o($Vs, [2, 33]), o($Vs, [2, 34]), o($Vs, [2, 35]), o($Vt, [2, 46]), o($Vt, [2, 47]), o($Vu, [2, 37]), o($Vs, [2, 15]), o($Vs, [2, 19]), o($Vv, $V4, { 8: 81 }), o($Vs, [2, 26]), o($Vs, [2, 27]), { 4: $V5, 5: $V6, 6: 30, 9: 14, 10: 16, 11: 18, 12: 19, 13: 20, 16: $V7, 17: $V8, 19: $V9, 21: [1, 82], 22: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 29: $Vg, 32: 31, 33: $Vh, 35: $Vi, 37: $Vj, 38: $Vk, 42: $Vl, 45: 6, 50: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 56: $Vq, 60: $V3 }, o($Vs, [2, 21])],
141 defaultActions: { 7: [2, 50], 8: [2, 1], 9: [2, 2], 10: [2, 3], 54: [2, 48], 55: [2, 49], 64: [2, 52] },
142 parseError: function parseError(str, hash) {
143 if (hash.recoverable) {
144 this.trace(str);
145 } else {
146 var error = new Error(str);
147 error.hash = hash;
148 throw error;
149 }
150 },
151 parse: function parse(input) {
152 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
153 var args = lstack.slice.call(arguments, 1);
154 var lexer2 = Object.create(this.lexer);
155 var sharedState = { yy: {} };
156 for (var k in this.yy) {
157 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
158 sharedState.yy[k] = this.yy[k];
159 }
160 }
161 lexer2.setInput(input, sharedState.yy);
162 sharedState.yy.lexer = lexer2;
163 sharedState.yy.parser = this;
164 if (typeof lexer2.yylloc == "undefined") {
165 lexer2.yylloc = {};
166 }
167 var yyloc = lexer2.yylloc;
168 lstack.push(yyloc);
169 var ranges = lexer2.options && lexer2.options.ranges;
170 if (typeof sharedState.yy.parseError === "function") {
171 this.parseError = sharedState.yy.parseError;
172 } else {
173 this.parseError = Object.getPrototypeOf(this).parseError;
174 }
175 function lex() {
176 var token;
177 token = tstack.pop() || lexer2.lex() || EOF;
178 if (typeof token !== "number") {
179 if (token instanceof Array) {
180 tstack = token;
181 token = tstack.pop();
182 }
183 token = self.symbols_[token] || token;
184 }
185 return token;
186 }
187 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
188 while (true) {
189 state = stack[stack.length - 1];
190 if (this.defaultActions[state]) {
191 action = this.defaultActions[state];
192 } else {
193 if (symbol === null || typeof symbol == "undefined") {
194 symbol = lex();
195 }
196 action = table[state] && table[state][symbol];
197 }
198 if (typeof action === "undefined" || !action.length || !action[0]) {
199 var errStr = "";
200 expected = [];
201 for (p in table[state]) {
202 if (this.terminals_[p] && p > TERROR) {
203 expected.push("'" + this.terminals_[p] + "'");
204 }
205 }
206 if (lexer2.showPosition) {
207 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
208 } else {
209 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
210 }
211 this.parseError(errStr, {
212 text: lexer2.match,
213 token: this.terminals_[symbol] || symbol,
214 line: lexer2.yylineno,
215 loc: yyloc,
216 expected
217 });
218 }
219 if (action[0] instanceof Array && action.length > 1) {
220 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
221 }
222 switch (action[0]) {
223 case 1:
224 stack.push(symbol);
225 vstack.push(lexer2.yytext);
226 lstack.push(lexer2.yylloc);
227 stack.push(action[1]);
228 symbol = null;
229 {
230 yyleng = lexer2.yyleng;
231 yytext = lexer2.yytext;
232 yylineno = lexer2.yylineno;
233 yyloc = lexer2.yylloc;
234 }
235 break;
236 case 2:
237 len = this.productions_[action[1]][1];
238 yyval.$ = vstack[vstack.length - len];
239 yyval._$ = {
240 first_line: lstack[lstack.length - (len || 1)].first_line,
241 last_line: lstack[lstack.length - 1].last_line,
242 first_column: lstack[lstack.length - (len || 1)].first_column,
243 last_column: lstack[lstack.length - 1].last_column
244 };
245 if (ranges) {
246 yyval._$.range = [
247 lstack[lstack.length - (len || 1)].range[0],
248 lstack[lstack.length - 1].range[1]
249 ];
250 }
251 r = this.performAction.apply(yyval, [
252 yytext,
253 yyleng,
254 yylineno,
255 sharedState.yy,
256 action[1],
257 vstack,
258 lstack
259 ].concat(args));
260 if (typeof r !== "undefined") {
261 return r;
262 }
263 if (len) {
264 stack = stack.slice(0, -1 * len * 2);
265 vstack = vstack.slice(0, -1 * len);
266 lstack = lstack.slice(0, -1 * len);
267 }
268 stack.push(this.productions_[action[1]][0]);
269 vstack.push(yyval.$);
270 lstack.push(yyval._$);
271 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
272 stack.push(newState);
273 break;
274 case 3:
275 return true;
276 }
277 }
278 return true;
279 }
280 };
281 var lexer = function() {
282 var lexer2 = {
283 EOF: 1,
284 parseError: function parseError(str, hash) {
285 if (this.yy.parser) {
286 this.yy.parser.parseError(str, hash);
287 } else {
288 throw new Error(str);
289 }
290 },
291 // resets the lexer, sets new input
292 setInput: function(input, yy) {
293 this.yy = yy || this.yy || {};
294 this._input = input;
295 this._more = this._backtrack = this.done = false;
296 this.yylineno = this.yyleng = 0;
297 this.yytext = this.matched = this.match = "";
298 this.conditionStack = ["INITIAL"];
299 this.yylloc = {
300 first_line: 1,
301 first_column: 0,
302 last_line: 1,
303 last_column: 0
304 };
305 if (this.options.ranges) {
306 this.yylloc.range = [0, 0];
307 }
308 this.offset = 0;
309 return this;
310 },
311 // consumes and returns one char from the input
312 input: function() {
313 var ch = this._input[0];
314 this.yytext += ch;
315 this.yyleng++;
316 this.offset++;
317 this.match += ch;
318 this.matched += ch;
319 var lines = ch.match(/(?:\r\n?|\n).*/g);
320 if (lines) {
321 this.yylineno++;
322 this.yylloc.last_line++;
323 } else {
324 this.yylloc.last_column++;
325 }
326 if (this.options.ranges) {
327 this.yylloc.range[1]++;
328 }
329 this._input = this._input.slice(1);
330 return ch;
331 },
332 // unshifts one char (or a string) into the input
333 unput: function(ch) {
334 var len = ch.length;
335 var lines = ch.split(/(?:\r\n?|\n)/g);
336 this._input = ch + this._input;
337 this.yytext = this.yytext.substr(0, this.yytext.length - len);
338 this.offset -= len;
339 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
340 this.match = this.match.substr(0, this.match.length - 1);
341 this.matched = this.matched.substr(0, this.matched.length - 1);
342 if (lines.length - 1) {
343 this.yylineno -= lines.length - 1;
344 }
345 var r = this.yylloc.range;
346 this.yylloc = {
347 first_line: this.yylloc.first_line,
348 last_line: this.yylineno + 1,
349 first_column: this.yylloc.first_column,
350 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
351 };
352 if (this.options.ranges) {
353 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
354 }
355 this.yyleng = this.yytext.length;
356 return this;
357 },
358 // When called from action, caches matched text and appends it on next action
359 more: function() {
360 this._more = true;
361 return this;
362 },
363 // 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.
364 reject: function() {
365 if (this.options.backtrack_lexer) {
366 this._backtrack = true;
367 } else {
368 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(), {
369 text: "",
370 token: null,
371 line: this.yylineno
372 });
373 }
374 return this;
375 },
376 // retain first n characters of the match
377 less: function(n) {
378 this.unput(this.match.slice(n));
379 },
380 // displays already matched input, i.e. for error messages
381 pastInput: function() {
382 var past = this.matched.substr(0, this.matched.length - this.match.length);
383 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
384 },
385 // displays upcoming input, i.e. for error messages
386 upcomingInput: function() {
387 var next = this.match;
388 if (next.length < 20) {
389 next += this._input.substr(0, 20 - next.length);
390 }
391 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
392 },
393 // displays the character position where the lexing error occurred, i.e. for error messages
394 showPosition: function() {
395 var pre = this.pastInput();
396 var c = new Array(pre.length + 1).join("-");
397 return pre + this.upcomingInput() + "\n" + c + "^";
398 },
399 // test the lexed token: return FALSE when not a match, otherwise return token
400 test_match: function(match, indexed_rule) {
401 var token, lines, backup;
402 if (this.options.backtrack_lexer) {
403 backup = {
404 yylineno: this.yylineno,
405 yylloc: {
406 first_line: this.yylloc.first_line,
407 last_line: this.last_line,
408 first_column: this.yylloc.first_column,
409 last_column: this.yylloc.last_column
410 },
411 yytext: this.yytext,
412 match: this.match,
413 matches: this.matches,
414 matched: this.matched,
415 yyleng: this.yyleng,
416 offset: this.offset,
417 _more: this._more,
418 _input: this._input,
419 yy: this.yy,
420 conditionStack: this.conditionStack.slice(0),
421 done: this.done
422 };
423 if (this.options.ranges) {
424 backup.yylloc.range = this.yylloc.range.slice(0);
425 }
426 }
427 lines = match[0].match(/(?:\r\n?|\n).*/g);
428 if (lines) {
429 this.yylineno += lines.length;
430 }
431 this.yylloc = {
432 first_line: this.yylloc.last_line,
433 last_line: this.yylineno + 1,
434 first_column: this.yylloc.last_column,
435 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
436 };
437 this.yytext += match[0];
438 this.match += match[0];
439 this.matches = match;
440 this.yyleng = this.yytext.length;
441 if (this.options.ranges) {
442 this.yylloc.range = [this.offset, this.offset += this.yyleng];
443 }
444 this._more = false;
445 this._backtrack = false;
446 this._input = this._input.slice(match[0].length);
447 this.matched += match[0];
448 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
449 if (this.done && this._input) {
450 this.done = false;
451 }
452 if (token) {
453 return token;
454 } else if (this._backtrack) {
455 for (var k in backup) {
456 this[k] = backup[k];
457 }
458 return false;
459 }
460 return false;
461 },
462 // return next match in input
463 next: function() {
464 if (this.done) {
465 return this.EOF;
466 }
467 if (!this._input) {
468 this.done = true;
469 }
470 var token, match, tempMatch, index;
471 if (!this._more) {
472 this.yytext = "";
473 this.match = "";
474 }
475 var rules = this._currentRules();
476 for (var i = 0; i < rules.length; i++) {
477 tempMatch = this._input.match(this.rules[rules[i]]);
478 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
479 match = tempMatch;
480 index = i;
481 if (this.options.backtrack_lexer) {
482 token = this.test_match(tempMatch, rules[i]);
483 if (token !== false) {
484 return token;
485 } else if (this._backtrack) {
486 match = false;
487 continue;
488 } else {
489 return false;
490 }
491 } else if (!this.options.flex) {
492 break;
493 }
494 }
495 }
496 if (match) {
497 token = this.test_match(match, rules[index]);
498 if (token !== false) {
499 return token;
500 }
501 return false;
502 }
503 if (this._input === "") {
504 return this.EOF;
505 } else {
506 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
507 text: "",
508 token: null,
509 line: this.yylineno
510 });
511 }
512 },
513 // return next match that has a token
514 lex: function lex() {
515 var r = this.next();
516 if (r) {
517 return r;
518 } else {
519 return this.lex();
520 }
521 },
522 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
523 begin: function begin(condition) {
524 this.conditionStack.push(condition);
525 },
526 // pop the previously active lexer condition state off the condition stack
527 popState: function popState() {
528 var n = this.conditionStack.length - 1;
529 if (n > 0) {
530 return this.conditionStack.pop();
531 } else {
532 return this.conditionStack[0];
533 }
534 },
535 // produce the lexer rule set which is active for the currently active lexer condition state
536 _currentRules: function _currentRules() {
537 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
538 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
539 } else {
540 return this.conditions["INITIAL"].rules;
541 }
542 },
543 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
544 topState: function topState(n) {
545 n = this.conditionStack.length - 1 - Math.abs(n || 0);
546 if (n >= 0) {
547 return this.conditionStack[n];
548 } else {
549 return "INITIAL";
550 }
551 },
552 // alias for begin(condition)
553 pushState: function pushState(condition) {
554 this.begin(condition);
555 },
556 // return the number of states currently on the stack
557 stateStackSize: function stateStackSize() {
558 return this.conditionStack.length;
559 },
560 options: { "case-insensitive": true },
561 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
562 switch ($avoiding_name_collisions) {
563 case 0:
564 return 41;
565 case 1:
566 return 50;
567 case 2:
568 return 51;
569 case 3:
570 return 52;
571 case 4:
572 return 53;
573 case 5:
574 this.begin("open_directive");
575 return 60;
576 case 6:
577 this.begin("type_directive");
578 return 61;
579 case 7:
580 this.popState();
581 this.begin("arg_directive");
582 return 48;
583 case 8:
584 this.popState();
585 this.popState();
586 return 63;
587 case 9:
588 return 62;
589 case 10:
590 break;
591 case 11:
592 break;
593 case 12:
594 return 5;
595 case 13:
596 break;
597 case 14:
598 break;
599 case 15:
600 break;
601 case 16:
602 break;
603 case 17:
604 this.pushState("SCALE");
605 return 17;
606 case 18:
607 return 18;
608 case 19:
609 this.popState();
610 break;
611 case 20:
612 this.begin("acc_title");
613 return 33;
614 case 21:
615 this.popState();
616 return "acc_title_value";
617 case 22:
618 this.begin("acc_descr");
619 return 35;
620 case 23:
621 this.popState();
622 return "acc_descr_value";
623 case 24:
624 this.begin("acc_descr_multiline");
625 break;
626 case 25:
627 this.popState();
628 break;
629 case 26:
630 return "acc_descr_multiline_value";
631 case 27:
632 this.pushState("CLASSDEF");
633 return 38;
634 case 28:
635 this.popState();
636 this.pushState("CLASSDEFID");
637 return "DEFAULT_CLASSDEF_ID";
638 case 29:
639 this.popState();
640 this.pushState("CLASSDEFID");
641 return 39;
642 case 30:
643 this.popState();
644 return 40;
645 case 31:
646 this.pushState("CLASS");
647 return 42;
648 case 32:
649 this.popState();
650 this.pushState("CLASS_STYLE");
651 return 43;
652 case 33:
653 this.popState();
654 return 44;
655 case 34:
656 this.pushState("SCALE");
657 return 17;
658 case 35:
659 return 18;
660 case 36:
661 this.popState();
662 break;
663 case 37:
664 this.pushState("STATE");
665 break;
666 case 38:
667 this.popState();
668 yy_.yytext = yy_.yytext.slice(0, -8).trim();
669 return 25;
670 case 39:
671 this.popState();
672 yy_.yytext = yy_.yytext.slice(0, -8).trim();
673 return 26;
674 case 40:
675 this.popState();
676 yy_.yytext = yy_.yytext.slice(0, -10).trim();
677 return 27;
678 case 41:
679 this.popState();
680 yy_.yytext = yy_.yytext.slice(0, -8).trim();
681 return 25;
682 case 42:
683 this.popState();
684 yy_.yytext = yy_.yytext.slice(0, -8).trim();
685 return 26;
686 case 43:
687 this.popState();
688 yy_.yytext = yy_.yytext.slice(0, -10).trim();
689 return 27;
690 case 44:
691 return 50;
692 case 45:
693 return 51;
694 case 46:
695 return 52;
696 case 47:
697 return 53;
698 case 48:
699 this.pushState("STATE_STRING");
700 break;
701 case 49:
702 this.pushState("STATE_ID");
703 return "AS";
704 case 50:
705 this.popState();
706 return "ID";
707 case 51:
708 this.popState();
709 break;
710 case 52:
711 return "STATE_DESCR";
712 case 53:
713 return 19;
714 case 54:
715 this.popState();
716 break;
717 case 55:
718 this.popState();
719 this.pushState("struct");
720 return 20;
721 case 56:
722 break;
723 case 57:
724 this.popState();
725 return 21;
726 case 58:
727 break;
728 case 59:
729 this.begin("NOTE");
730 return 29;
731 case 60:
732 this.popState();
733 this.pushState("NOTE_ID");
734 return 58;
735 case 61:
736 this.popState();
737 this.pushState("NOTE_ID");
738 return 59;
739 case 62:
740 this.popState();
741 this.pushState("FLOATING_NOTE");
742 break;
743 case 63:
744 this.popState();
745 this.pushState("FLOATING_NOTE_ID");
746 return "AS";
747 case 64:
748 break;
749 case 65:
750 return "NOTE_TEXT";
751 case 66:
752 this.popState();
753 return "ID";
754 case 67:
755 this.popState();
756 this.pushState("NOTE_TEXT");
757 return 24;
758 case 68:
759 this.popState();
760 yy_.yytext = yy_.yytext.substr(2).trim();
761 return 31;
762 case 69:
763 this.popState();
764 yy_.yytext = yy_.yytext.slice(0, -8).trim();
765 return 31;
766 case 70:
767 return 7;
768 case 71:
769 return 7;
770 case 72:
771 return 16;
772 case 73:
773 return 56;
774 case 74:
775 return 24;
776 case 75:
777 yy_.yytext = yy_.yytext.trim();
778 return 14;
779 case 76:
780 return 15;
781 case 77:
782 return 28;
783 case 78:
784 return 57;
785 case 79:
786 return 5;
787 case 80:
788 return "INVALID";
789 }
790 },
791 rules: [/^(?:default\b)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:classDef\s+)/i, /^(?:DEFAULT\s+)/i, /^(?:\w+\s+)/i, /^(?:[^\n]*)/i, /^(?:class\s+)/i, /^(?:(\w+)+((,\s*\w+)*))/i, /^(?:[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:state\s+)/i, /^(?:.*<<fork>>)/i, /^(?:.*<<join>>)/i, /^(?:.*<<choice>>)/i, /^(?:.*\[\[fork\]\])/i, /^(?:.*\[\[join\]\])/i, /^(?:.*\[\[choice\]\])/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:["])/i, /^(?:\s*as\s+)/i, /^(?:[^\n\{]*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n\s\{]+)/i, /^(?:\n)/i, /^(?:\{)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:\})/i, /^(?:[\n])/i, /^(?:note\s+)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:")/i, /^(?:\s*as\s*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n]*)/i, /^(?:\s*[^:\n\s\-]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:[\s\S]*?end note\b)/i, /^(?:stateDiagram\s+)/i, /^(?:stateDiagram-v2\s+)/i, /^(?:hide empty description\b)/i, /^(?:\[\*\])/i, /^(?:[^:\n\s\-\{]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:-->)/i, /^(?:--)/i, /^(?::::)/i, /^(?:$)/i, /^(?:.)/i],
792 conditions: { "LINE": { "rules": [14, 15], "inclusive": false }, "close_directive": { "rules": [14, 15], "inclusive": false }, "arg_directive": { "rules": [8, 9, 14, 15], "inclusive": false }, "type_directive": { "rules": [7, 8, 14, 15], "inclusive": false }, "open_directive": { "rules": [6, 14, 15], "inclusive": false }, "struct": { "rules": [14, 15, 27, 31, 37, 44, 45, 46, 47, 56, 57, 58, 59, 73, 74, 75, 76, 77], "inclusive": false }, "FLOATING_NOTE_ID": { "rules": [66], "inclusive": false }, "FLOATING_NOTE": { "rules": [63, 64, 65], "inclusive": false }, "NOTE_TEXT": { "rules": [68, 69], "inclusive": false }, "NOTE_ID": { "rules": [67], "inclusive": false }, "NOTE": { "rules": [60, 61, 62], "inclusive": false }, "CLASS_STYLE": { "rules": [33], "inclusive": false }, "CLASS": { "rules": [32], "inclusive": false }, "CLASSDEFID": { "rules": [30], "inclusive": false }, "CLASSDEF": { "rules": [28, 29], "inclusive": false }, "acc_descr_multiline": { "rules": [25, 26], "inclusive": false }, "acc_descr": { "rules": [23], "inclusive": false }, "acc_title": { "rules": [21], "inclusive": false }, "SCALE": { "rules": [18, 19, 35, 36], "inclusive": false }, "ALIAS": { "rules": [], "inclusive": false }, "STATE_ID": { "rules": [50], "inclusive": false }, "STATE_STRING": { "rules": [51, 52], "inclusive": false }, "FORK_STATE": { "rules": [], "inclusive": false }, "STATE": { "rules": [14, 15, 38, 39, 40, 41, 42, 43, 48, 49, 53, 54, 55], "inclusive": false }, "ID": { "rules": [14, 15], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 15, 16, 17, 20, 22, 24, 27, 31, 34, 37, 55, 59, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80], "inclusive": true } }
793 };
794 return lexer2;
795 }();
796 parser2.lexer = lexer;
797 function Parser() {
798 this.yy = {};
799 }
800 Parser.prototype = parser2;
801 parser2.Parser = Parser;
802 return new Parser();
803}();
804parser.parser = parser;
805const parser$1 = parser;
806const DEFAULT_DIAGRAM_DIRECTION = "LR";
807const DEFAULT_NESTED_DOC_DIR = "TB";
808const STMT_STATE = "state";
809const STMT_RELATION = "relation";
810const STMT_CLASSDEF = "classDef";
811const STMT_APPLYCLASS = "applyClass";
812const DEFAULT_STATE_TYPE = "default";
813const DIVIDER_TYPE = "divider";
814const START_NODE = "[*]";
815const START_TYPE = "start";
816const END_NODE = START_NODE;
817const END_TYPE = "end";
818const COLOR_KEYWORD = "color";
819const FILL_KEYWORD = "fill";
820const BG_FILL = "bgFill";
821const STYLECLASS_SEP = ",";
822function newClassesList() {
823 return {};
824}
825let direction = DEFAULT_DIAGRAM_DIRECTION;
826let rootDoc = [];
827let classes = newClassesList();
828const newDoc = () => {
829 return {
830 relations: [],
831 states: {},
832 documents: {}
833 };
834};
835let documents = {
836 root: newDoc()
837};
838let currentDocument = documents.root;
839let startEndCount = 0;
840let dividerCnt = 0;
841const lineType = {
842 LINE: 0,
843 DOTTED_LINE: 1
844};
845const relationType = {
846 AGGREGATION: 0,
847 EXTENSION: 1,
848 COMPOSITION: 2,
849 DEPENDENCY: 3
850};
851const clone = (o) => JSON.parse(JSON.stringify(o));
852const parseDirective = function(statement, context, type) {
853 mermaidAPI.parseDirective(this, statement, context, type);
854};
855const setRootDoc = (o) => {
856 log.info("Setting root doc", o);
857 rootDoc = o;
858};
859const getRootDoc = () => rootDoc;
860const docTranslator = (parent, node, first) => {
861 if (node.stmt === STMT_RELATION) {
862 docTranslator(parent, node.state1, true);
863 docTranslator(parent, node.state2, false);
864 } else {
865 if (node.stmt === STMT_STATE) {
866 if (node.id === "[*]") {
867 node.id = first ? parent.id + "_start" : parent.id + "_end";
868 node.start = first;
869 } else {
870 node.id = node.id.trim();
871 }
872 }
873 if (node.doc) {
874 const doc = [];
875 let currentDoc = [];
876 let i;
877 for (i = 0; i < node.doc.length; i++) {
878 if (node.doc[i].type === DIVIDER_TYPE) {
879 const newNode = clone(node.doc[i]);
880 newNode.doc = clone(currentDoc);
881 doc.push(newNode);
882 currentDoc = [];
883 } else {
884 currentDoc.push(node.doc[i]);
885 }
886 }
887 if (doc.length > 0 && currentDoc.length > 0) {
888 const newNode = {
889 stmt: STMT_STATE,
890 id: generateId(),
891 type: "divider",
892 doc: clone(currentDoc)
893 };
894 doc.push(clone(newNode));
895 node.doc = doc;
896 }
897 node.doc.forEach((docNode) => docTranslator(node, docNode, true));
898 }
899 }
900};
901const getRootDocV2 = () => {
902 docTranslator({ id: "root" }, { id: "root", doc: rootDoc }, true);
903 return { id: "root", doc: rootDoc };
904};
905const extract = (_doc) => {
906 let doc;
907 if (_doc.doc) {
908 doc = _doc.doc;
909 } else {
910 doc = _doc;
911 }
912 log.info(doc);
913 clear(true);
914 log.info("Extract", doc);
915 doc.forEach((item) => {
916 switch (item.stmt) {
917 case STMT_STATE:
918 addState(
919 item.id.trim(),
920 item.type,
921 item.doc,
922 item.description,
923 item.note,
924 item.classes,
925 item.styles,
926 item.textStyles
927 );
928 break;
929 case STMT_RELATION:
930 addRelation(item.state1, item.state2, item.description);
931 break;
932 case STMT_CLASSDEF:
933 addStyleClass(item.id.trim(), item.classes);
934 break;
935 case STMT_APPLYCLASS:
936 setCssClass(item.id.trim(), item.styleClass);
937 break;
938 }
939 });
940};
941const addState = function(id, type = DEFAULT_STATE_TYPE, doc = null, descr = null, note = null, classes2 = null, styles2 = null, textStyles = null) {
942 const trimmedId = id == null ? void 0 : id.trim();
943 if (currentDocument.states[trimmedId] === void 0) {
944 log.info("Adding state ", trimmedId, descr);
945 currentDocument.states[trimmedId] = {
946 id: trimmedId,
947 descriptions: [],
948 type,
949 doc,
950 note,
951 classes: [],
952 styles: [],
953 textStyles: []
954 };
955 } else {
956 if (!currentDocument.states[trimmedId].doc) {
957 currentDocument.states[trimmedId].doc = doc;
958 }
959 if (!currentDocument.states[trimmedId].type) {
960 currentDocument.states[trimmedId].type = type;
961 }
962 }
963 if (descr) {
964 log.info("Setting state description", trimmedId, descr);
965 if (typeof descr === "string") {
966 addDescription(trimmedId, descr.trim());
967 }
968 if (typeof descr === "object") {
969 descr.forEach((des) => addDescription(trimmedId, des.trim()));
970 }
971 }
972 if (note) {
973 currentDocument.states[trimmedId].note = note;
974 currentDocument.states[trimmedId].note.text = common.sanitizeText(
975 currentDocument.states[trimmedId].note.text,
976 getConfig()
977 );
978 }
979 if (classes2) {
980 log.info("Setting state classes", trimmedId, classes2);
981 const classesList = typeof classes2 === "string" ? [classes2] : classes2;
982 classesList.forEach((klass) => setCssClass(trimmedId, klass.trim()));
983 }
984 if (styles2) {
985 log.info("Setting state styles", trimmedId, styles2);
986 const stylesList = typeof styles2 === "string" ? [styles2] : styles2;
987 stylesList.forEach((style) => setStyle(trimmedId, style.trim()));
988 }
989 if (textStyles) {
990 log.info("Setting state styles", trimmedId, styles2);
991 const textStylesList = typeof textStyles === "string" ? [textStyles] : textStyles;
992 textStylesList.forEach((textStyle) => setTextStyle(trimmedId, textStyle.trim()));
993 }
994};
995const clear = function(saveCommon) {
996 documents = {
997 root: newDoc()
998 };
999 currentDocument = documents.root;
1000 startEndCount = 0;
1001 classes = newClassesList();
1002 if (!saveCommon) {
1003 clear$1();
1004 }
1005};
1006const getState = function(id) {
1007 return currentDocument.states[id];
1008};
1009const getStates = function() {
1010 return currentDocument.states;
1011};
1012const logDocuments = function() {
1013 log.info("Documents = ", documents);
1014};
1015const getRelations = function() {
1016 return currentDocument.relations;
1017};
1018function startIdIfNeeded(id = "") {
1019 let fixedId = id;
1020 if (id === START_NODE) {
1021 startEndCount++;
1022 fixedId = `${START_TYPE}${startEndCount}`;
1023 }
1024 return fixedId;
1025}
1026function startTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) {
1027 return id === START_NODE ? START_TYPE : type;
1028}
1029function endIdIfNeeded(id = "") {
1030 let fixedId = id;
1031 if (id === END_NODE) {
1032 startEndCount++;
1033 fixedId = `${END_TYPE}${startEndCount}`;
1034 }
1035 return fixedId;
1036}
1037function endTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) {
1038 return id === END_NODE ? END_TYPE : type;
1039}
1040function addRelationObjs(item1, item2, relationTitle) {
1041 let id1 = startIdIfNeeded(item1.id.trim());
1042 let type1 = startTypeIfNeeded(item1.id.trim(), item1.type);
1043 let id2 = startIdIfNeeded(item2.id.trim());
1044 let type2 = startTypeIfNeeded(item2.id.trim(), item2.type);
1045 addState(
1046 id1,
1047 type1,
1048 item1.doc,
1049 item1.description,
1050 item1.note,
1051 item1.classes,
1052 item1.styles,
1053 item1.textStyles
1054 );
1055 addState(
1056 id2,
1057 type2,
1058 item2.doc,
1059 item2.description,
1060 item2.note,
1061 item2.classes,
1062 item2.styles,
1063 item2.textStyles
1064 );
1065 currentDocument.relations.push({
1066 id1,
1067 id2,
1068 relationTitle: common.sanitizeText(relationTitle, getConfig())
1069 });
1070}
1071const addRelation = function(item1, item2, title) {
1072 if (typeof item1 === "object") {
1073 addRelationObjs(item1, item2, title);
1074 } else {
1075 const id1 = startIdIfNeeded(item1.trim());
1076 const type1 = startTypeIfNeeded(item1);
1077 const id2 = endIdIfNeeded(item2.trim());
1078 const type2 = endTypeIfNeeded(item2);
1079 addState(id1, type1);
1080 addState(id2, type2);
1081 currentDocument.relations.push({
1082 id1,
1083 id2,
1084 title: common.sanitizeText(title, getConfig())
1085 });
1086 }
1087};
1088const addDescription = function(id, descr) {
1089 const theState = currentDocument.states[id];
1090 const _descr = descr.startsWith(":") ? descr.replace(":", "").trim() : descr;
1091 theState.descriptions.push(common.sanitizeText(_descr, getConfig()));
1092};
1093const cleanupLabel = function(label) {
1094 if (label.substring(0, 1) === ":") {
1095 return label.substr(2).trim();
1096 } else {
1097 return label.trim();
1098 }
1099};
1100const getDividerId = () => {
1101 dividerCnt++;
1102 return "divider-id-" + dividerCnt;
1103};
1104const addStyleClass = function(id, styleAttributes = "") {
1105 if (classes[id] === void 0) {
1106 classes[id] = { id, styles: [], textStyles: [] };
1107 }
1108 const foundClass = classes[id];
1109 if (styleAttributes !== void 0 && styleAttributes !== null) {
1110 styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => {
1111 const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim();
1112 if (attrib.match(COLOR_KEYWORD)) {
1113 const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL);
1114 const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD);
1115 foundClass.textStyles.push(newStyle2);
1116 }
1117 foundClass.styles.push(fixedAttrib);
1118 });
1119 }
1120};
1121const getClasses = function() {
1122 return classes;
1123};
1124const setCssClass = function(itemIds, cssClassName) {
1125 itemIds.split(",").forEach(function(id) {
1126 let foundState = getState(id);
1127 if (foundState === void 0) {
1128 const trimmedId = id.trim();
1129 addState(trimmedId);
1130 foundState = getState(trimmedId);
1131 }
1132 foundState.classes.push(cssClassName);
1133 });
1134};
1135const setStyle = function(itemId, styleText) {
1136 const item = getState(itemId);
1137 if (item !== void 0) {
1138 item.textStyles.push(styleText);
1139 }
1140};
1141const setTextStyle = function(itemId, cssClassName) {
1142 const item = getState(itemId);
1143 if (item !== void 0) {
1144 item.textStyles.push(cssClassName);
1145 }
1146};
1147const getDirection = () => direction;
1148const setDirection = (dir) => {
1149 direction = dir;
1150};
1151const trimColon = (str) => str && str[0] === ":" ? str.substr(1).trim() : str.trim();
1152const db = {
1153 parseDirective,
1154 getConfig: () => getConfig().state,
1155 addState,
1156 clear,
1157 getState,
1158 getStates,
1159 getRelations,
1160 getClasses,
1161 getDirection,
1162 addRelation,
1163 getDividerId,
1164 setDirection,
1165 cleanupLabel,
1166 lineType,
1167 relationType,
1168 logDocuments,
1169 getRootDoc,
1170 setRootDoc,
1171 getRootDocV2,
1172 extract,
1173 trimColon,
1174 getAccTitle,
1175 setAccTitle,
1176 getAccDescription,
1177 setAccDescription,
1178 addStyleClass,
1179 setCssClass,
1180 addDescription,
1181 setDiagramTitle,
1182 getDiagramTitle
1183};
1184const getStyles = (options) => `
1185defs #statediagram-barbEnd {
1186 fill: ${options.transitionColor};
1187 stroke: ${options.transitionColor};
1188 }
1189g.stateGroup text {
1190 fill: ${options.nodeBorder};
1191 stroke: none;
1192 font-size: 10px;
1193}
1194g.stateGroup text {
1195 fill: ${options.textColor};
1196 stroke: none;
1197 font-size: 10px;
1198
1199}
1200g.stateGroup .state-title {
1201 font-weight: bolder;
1202 fill: ${options.stateLabelColor};
1203}
1204
1205g.stateGroup rect {
1206 fill: ${options.mainBkg};
1207 stroke: ${options.nodeBorder};
1208}
1209
1210g.stateGroup line {
1211 stroke: ${options.lineColor};
1212 stroke-width: 1;
1213}
1214
1215.transition {
1216 stroke: ${options.transitionColor};
1217 stroke-width: 1;
1218 fill: none;
1219}
1220
1221.stateGroup .composit {
1222 fill: ${options.background};
1223 border-bottom: 1px
1224}
1225
1226.stateGroup .alt-composit {
1227 fill: #e0e0e0;
1228 border-bottom: 1px
1229}
1230
1231.state-note {
1232 stroke: ${options.noteBorderColor};
1233 fill: ${options.noteBkgColor};
1234
1235 text {
1236 fill: ${options.noteTextColor};
1237 stroke: none;
1238 font-size: 10px;
1239 }
1240}
1241
1242.stateLabel .box {
1243 stroke: none;
1244 stroke-width: 0;
1245 fill: ${options.mainBkg};
1246 opacity: 0.5;
1247}
1248
1249.edgeLabel .label rect {
1250 fill: ${options.labelBackgroundColor};
1251 opacity: 0.5;
1252}
1253.edgeLabel .label text {
1254 fill: ${options.transitionLabelColor || options.tertiaryTextColor};
1255}
1256.label div .edgeLabel {
1257 color: ${options.transitionLabelColor || options.tertiaryTextColor};
1258}
1259
1260.stateLabel text {
1261 fill: ${options.stateLabelColor};
1262 font-size: 10px;
1263 font-weight: bold;
1264}
1265
1266.node circle.state-start {
1267 fill: ${options.specialStateColor};
1268 stroke: ${options.specialStateColor};
1269}
1270
1271.node .fork-join {
1272 fill: ${options.specialStateColor};
1273 stroke: ${options.specialStateColor};
1274}
1275
1276.node circle.state-end {
1277 fill: ${options.innerEndBackground};
1278 stroke: ${options.background};
1279 stroke-width: 1.5
1280}
1281.end-state-inner {
1282 fill: ${options.compositeBackground || options.background};
1283 // stroke: ${options.background};
1284 stroke-width: 1.5
1285}
1286
1287.node rect {
1288 fill: ${options.stateBkg || options.mainBkg};
1289 stroke: ${options.stateBorder || options.nodeBorder};
1290 stroke-width: 1px;
1291}
1292.node polygon {
1293 fill: ${options.mainBkg};
1294 stroke: ${options.stateBorder || options.nodeBorder};;
1295 stroke-width: 1px;
1296}
1297#statediagram-barbEnd {
1298 fill: ${options.lineColor};
1299}
1300
1301.statediagram-cluster rect {
1302 fill: ${options.compositeTitleBackground};
1303 stroke: ${options.stateBorder || options.nodeBorder};
1304 stroke-width: 1px;
1305}
1306
1307.cluster-label, .nodeLabel {
1308 color: ${options.stateLabelColor};
1309}
1310
1311.statediagram-cluster rect.outer {
1312 rx: 5px;
1313 ry: 5px;
1314}
1315.statediagram-state .divider {
1316 stroke: ${options.stateBorder || options.nodeBorder};
1317}
1318
1319.statediagram-state .title-state {
1320 rx: 5px;
1321 ry: 5px;
1322}
1323.statediagram-cluster.statediagram-cluster .inner {
1324 fill: ${options.compositeBackground || options.background};
1325}
1326.statediagram-cluster.statediagram-cluster-alt .inner {
1327 fill: ${options.altBackground ? options.altBackground : "#efefef"};
1328}
1329
1330.statediagram-cluster .inner {
1331 rx:0;
1332 ry:0;
1333}
1334
1335.statediagram-state rect.basic {
1336 rx: 5px;
1337 ry: 5px;
1338}
1339.statediagram-state rect.divider {
1340 stroke-dasharray: 10,10;
1341 fill: ${options.altBackground ? options.altBackground : "#efefef"};
1342}
1343
1344.note-edge {
1345 stroke-dasharray: 5;
1346}
1347
1348.statediagram-note rect {
1349 fill: ${options.noteBkgColor};
1350 stroke: ${options.noteBorderColor};
1351 stroke-width: 1px;
1352 rx: 0;
1353 ry: 0;
1354}
1355.statediagram-note rect {
1356 fill: ${options.noteBkgColor};
1357 stroke: ${options.noteBorderColor};
1358 stroke-width: 1px;
1359 rx: 0;
1360 ry: 0;
1361}
1362
1363.statediagram-note text {
1364 fill: ${options.noteTextColor};
1365}
1366
1367.statediagram-note .nodeLabel {
1368 color: ${options.noteTextColor};
1369}
1370.statediagram .edgeLabel {
1371 color: red; // ${options.noteTextColor};
1372}
1373
1374#dependencyStart, #dependencyEnd {
1375 fill: ${options.lineColor};
1376 stroke: ${options.lineColor};
1377 stroke-width: 1;
1378}
1379
1380.statediagramTitleText {
1381 text-anchor: middle;
1382 font-size: 18px;
1383 fill: ${options.textColor};
1384}
1385`;
1386const styles = getStyles;
1387export {
1388 DEFAULT_STATE_TYPE as D,
1389 STMT_RELATION as S,
1390 DIVIDER_TYPE as a,
1391 STMT_STATE as b,
1392 DEFAULT_NESTED_DOC_DIR as c,
1393 db as d,
1394 parser$1 as p,
1395 styles as s
1396};