1 | import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log, E as clear$1, j as d3select, A as utils, k as configureSvgSize, F as curveBasis, G as parseGenericTypes } from "./mermaid-dcacb631.js";
|
2 | import { G as Graph } from "./graph-fe24fab6.js";
|
3 | import { l as layout } from "./layout-163b9689.js";
|
4 | import { l as line } from "./line-87f517ef.js";
|
5 | import "./array-b7dcf730.js";
|
6 | import "./path-39bad7e2.js";
|
7 | var parser = function() {
|
8 | var o = function(k, v, o2, l) {
|
9 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
10 | ;
|
11 | return o2;
|
12 | }, $V0 = [6, 8, 10, 20, 22, 24, 26, 27, 28], $V1 = [1, 10], $V2 = [1, 11], $V3 = [1, 12], $V4 = [1, 13], $V5 = [1, 14], $V6 = [1, 15], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 25], $Vc = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], $Vd = [1, 34], $Ve = [27, 28, 46, 47], $Vf = [41, 42, 43, 44, 45], $Vg = [17, 34], $Vh = [1, 54], $Vi = [1, 53], $Vj = [17, 34, 36, 38];
|
13 | var parser2 = {
|
14 | trace: function trace() {
|
15 | },
|
16 | yy: {},
|
17 | symbols_: { "error": 2, "start": 3, "ER_DIAGRAM": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "entityName": 11, "relSpec": 12, ":": 13, "role": 14, "BLOCK_START": 15, "attributes": 16, "BLOCK_STOP": 17, "SQS": 18, "SQE": 19, "title": 20, "title_value": 21, "acc_title": 22, "acc_title_value": 23, "acc_descr": 24, "acc_descr_value": 25, "acc_descr_multiline_value": 26, "ALPHANUM": 27, "ENTITY_NAME": 28, "attribute": 29, "attributeType": 30, "attributeName": 31, "attributeKeyTypeList": 32, "attributeComment": 33, "ATTRIBUTE_WORD": 34, "attributeKeyType": 35, "COMMA": 36, "ATTRIBUTE_KEY": 37, "COMMENT": 38, "cardinality": 39, "relType": 40, "ZERO_OR_ONE": 41, "ZERO_OR_MORE": 42, "ONE_OR_MORE": 43, "ONLY_ONE": 44, "MD_PARENT": 45, "NON_IDENTIFYING": 46, "IDENTIFYING": 47, "WORD": 48, "$accept": 0, "$end": 1 },
|
18 | terminals_: { 2: "error", 4: "ER_DIAGRAM", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 13: ":", 15: "BLOCK_START", 17: "BLOCK_STOP", 18: "SQS", 19: "SQE", 20: "title", 21: "title_value", 22: "acc_title", 23: "acc_title_value", 24: "acc_descr", 25: "acc_descr_value", 26: "acc_descr_multiline_value", 27: "ALPHANUM", 28: "ENTITY_NAME", 34: "ATTRIBUTE_WORD", 36: "COMMA", 37: "ATTRIBUTE_KEY", 38: "COMMENT", 41: "ZERO_OR_ONE", 42: "ZERO_OR_MORE", 43: "ONE_OR_MORE", 44: "ONLY_ONE", 45: "MD_PARENT", 46: "NON_IDENTIFYING", 47: "IDENTIFYING", 48: "WORD" },
|
19 | productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]],
|
20 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
21 | var $0 = $$.length - 1;
|
22 | switch (yystate) {
|
23 | case 1:
|
24 | break;
|
25 | case 2:
|
26 | this.$ = [];
|
27 | break;
|
28 | case 3:
|
29 | $$[$0 - 1].push($$[$0]);
|
30 | this.$ = $$[$0 - 1];
|
31 | break;
|
32 | case 4:
|
33 | case 5:
|
34 | this.$ = $$[$0];
|
35 | break;
|
36 | case 6:
|
37 | case 7:
|
38 | this.$ = [];
|
39 | break;
|
40 | case 8:
|
41 | yy.addEntity($$[$0 - 4]);
|
42 | yy.addEntity($$[$0 - 2]);
|
43 | yy.addRelationship($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 3]);
|
44 | break;
|
45 | case 9:
|
46 | yy.addEntity($$[$0 - 3]);
|
47 | yy.addAttributes($$[$0 - 3], $$[$0 - 1]);
|
48 | break;
|
49 | case 10:
|
50 | yy.addEntity($$[$0 - 2]);
|
51 | break;
|
52 | case 11:
|
53 | yy.addEntity($$[$0]);
|
54 | break;
|
55 | case 12:
|
56 | yy.addEntity($$[$0 - 6], $$[$0 - 4]);
|
57 | yy.addAttributes($$[$0 - 6], $$[$0 - 1]);
|
58 | break;
|
59 | case 13:
|
60 | yy.addEntity($$[$0 - 5], $$[$0 - 3]);
|
61 | break;
|
62 | case 14:
|
63 | yy.addEntity($$[$0 - 3], $$[$0 - 1]);
|
64 | break;
|
65 | case 15:
|
66 | case 16:
|
67 | this.$ = $$[$0].trim();
|
68 | yy.setAccTitle(this.$);
|
69 | break;
|
70 | case 17:
|
71 | case 18:
|
72 | this.$ = $$[$0].trim();
|
73 | yy.setAccDescription(this.$);
|
74 | break;
|
75 | case 19:
|
76 | case 43:
|
77 | this.$ = $$[$0];
|
78 | break;
|
79 | case 20:
|
80 | case 41:
|
81 | case 42:
|
82 | this.$ = $$[$0].replace(/"/g, "");
|
83 | break;
|
84 | case 21:
|
85 | case 29:
|
86 | this.$ = [$$[$0]];
|
87 | break;
|
88 | case 22:
|
89 | $$[$0].push($$[$0 - 1]);
|
90 | this.$ = $$[$0];
|
91 | break;
|
92 | case 23:
|
93 | this.$ = { attributeType: $$[$0 - 1], attributeName: $$[$0] };
|
94 | break;
|
95 | case 24:
|
96 | this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeKeyTypeList: $$[$0] };
|
97 | break;
|
98 | case 25:
|
99 | this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeComment: $$[$0] };
|
100 | break;
|
101 | case 26:
|
102 | this.$ = { attributeType: $$[$0 - 3], attributeName: $$[$0 - 2], attributeKeyTypeList: $$[$0 - 1], attributeComment: $$[$0] };
|
103 | break;
|
104 | case 27:
|
105 | case 28:
|
106 | case 31:
|
107 | this.$ = $$[$0];
|
108 | break;
|
109 | case 30:
|
110 | $$[$0 - 2].push($$[$0]);
|
111 | this.$ = $$[$0 - 2];
|
112 | break;
|
113 | case 32:
|
114 | this.$ = $$[$0].replace(/"/g, "");
|
115 | break;
|
116 | case 33:
|
117 | this.$ = { cardA: $$[$0], relType: $$[$0 - 1], cardB: $$[$0 - 2] };
|
118 | break;
|
119 | case 34:
|
120 | this.$ = yy.Cardinality.ZERO_OR_ONE;
|
121 | break;
|
122 | case 35:
|
123 | this.$ = yy.Cardinality.ZERO_OR_MORE;
|
124 | break;
|
125 | case 36:
|
126 | this.$ = yy.Cardinality.ONE_OR_MORE;
|
127 | break;
|
128 | case 37:
|
129 | this.$ = yy.Cardinality.ONLY_ONE;
|
130 | break;
|
131 | case 38:
|
132 | this.$ = yy.Cardinality.MD_PARENT;
|
133 | break;
|
134 | case 39:
|
135 | this.$ = yy.Identification.NON_IDENTIFYING;
|
136 | break;
|
137 | case 40:
|
138 | this.$ = yy.Identification.IDENTIFYING;
|
139 | break;
|
140 | }
|
141 | },
|
142 | table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 16, 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, o($V0, [2, 18]), o($Vc, [2, 19]), o($Vc, [2, 20]), o($V0, [2, 4]), { 11: 29, 27: $V5, 28: $V6 }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: $Vd }, { 11: 35, 27: $V5, 28: $V6 }, { 40: 36, 46: [1, 37], 47: [1, 38] }, o($Ve, [2, 34]), o($Ve, [2, 35]), o($Ve, [2, 36]), o($Ve, [2, 37]), o($Ve, [2, 38]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, o($V0, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: $Vd }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }, o($Vf, [2, 39]), o($Vf, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, o($V0, [2, 9]), { 17: [2, 22] }, o($Vg, [2, 23], { 32: 50, 33: 51, 35: 52, 37: $Vh, 38: $Vi }), o([17, 34, 37, 38], [2, 28]), o($V0, [2, 14], { 15: [1, 55] }), o([27, 28], [2, 33]), o($V0, [2, 8]), o($V0, [2, 41]), o($V0, [2, 42]), o($V0, [2, 43]), o($Vg, [2, 24], { 33: 56, 36: [1, 57], 38: $Vi }), o($Vg, [2, 25]), o($Vj, [2, 29]), o($Vg, [2, 32]), o($Vj, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: $Vd }, o($Vg, [2, 26]), { 35: 60, 37: $Vh }, { 17: [1, 61] }, o($V0, [2, 13]), o($Vj, [2, 30]), o($V0, [2, 12])],
|
143 | defaultActions: { 34: [2, 27], 41: [2, 22] },
|
144 | parseError: function parseError(str, hash) {
|
145 | if (hash.recoverable) {
|
146 | this.trace(str);
|
147 | } else {
|
148 | var error = new Error(str);
|
149 | error.hash = hash;
|
150 | throw error;
|
151 | }
|
152 | },
|
153 | parse: function parse2(input) {
|
154 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
155 | var args = lstack.slice.call(arguments, 1);
|
156 | var lexer2 = Object.create(this.lexer);
|
157 | var sharedState = { yy: {} };
|
158 | for (var k in this.yy) {
|
159 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
160 | sharedState.yy[k] = this.yy[k];
|
161 | }
|
162 | }
|
163 | lexer2.setInput(input, sharedState.yy);
|
164 | sharedState.yy.lexer = lexer2;
|
165 | sharedState.yy.parser = this;
|
166 | if (typeof lexer2.yylloc == "undefined") {
|
167 | lexer2.yylloc = {};
|
168 | }
|
169 | var yyloc = lexer2.yylloc;
|
170 | lstack.push(yyloc);
|
171 | var ranges = lexer2.options && lexer2.options.ranges;
|
172 | if (typeof sharedState.yy.parseError === "function") {
|
173 | this.parseError = sharedState.yy.parseError;
|
174 | } else {
|
175 | this.parseError = Object.getPrototypeOf(this).parseError;
|
176 | }
|
177 | function lex() {
|
178 | var token;
|
179 | token = tstack.pop() || lexer2.lex() || EOF;
|
180 | if (typeof token !== "number") {
|
181 | if (token instanceof Array) {
|
182 | tstack = token;
|
183 | token = tstack.pop();
|
184 | }
|
185 | token = self.symbols_[token] || token;
|
186 | }
|
187 | return token;
|
188 | }
|
189 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
190 | while (true) {
|
191 | state = stack[stack.length - 1];
|
192 | if (this.defaultActions[state]) {
|
193 | action = this.defaultActions[state];
|
194 | } else {
|
195 | if (symbol === null || typeof symbol == "undefined") {
|
196 | symbol = lex();
|
197 | }
|
198 | action = table[state] && table[state][symbol];
|
199 | }
|
200 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
201 | var errStr = "";
|
202 | expected = [];
|
203 | for (p in table[state]) {
|
204 | if (this.terminals_[p] && p > TERROR) {
|
205 | expected.push("'" + this.terminals_[p] + "'");
|
206 | }
|
207 | }
|
208 | if (lexer2.showPosition) {
|
209 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
210 | } else {
|
211 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
212 | }
|
213 | this.parseError(errStr, {
|
214 | text: lexer2.match,
|
215 | token: this.terminals_[symbol] || symbol,
|
216 | line: lexer2.yylineno,
|
217 | loc: yyloc,
|
218 | expected
|
219 | });
|
220 | }
|
221 | if (action[0] instanceof Array && action.length > 1) {
|
222 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
223 | }
|
224 | switch (action[0]) {
|
225 | case 1:
|
226 | stack.push(symbol);
|
227 | vstack.push(lexer2.yytext);
|
228 | lstack.push(lexer2.yylloc);
|
229 | stack.push(action[1]);
|
230 | symbol = null;
|
231 | {
|
232 | yyleng = lexer2.yyleng;
|
233 | yytext = lexer2.yytext;
|
234 | yylineno = lexer2.yylineno;
|
235 | yyloc = lexer2.yylloc;
|
236 | }
|
237 | break;
|
238 | case 2:
|
239 | len = this.productions_[action[1]][1];
|
240 | yyval.$ = vstack[vstack.length - len];
|
241 | yyval._$ = {
|
242 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
243 | last_line: lstack[lstack.length - 1].last_line,
|
244 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
245 | last_column: lstack[lstack.length - 1].last_column
|
246 | };
|
247 | if (ranges) {
|
248 | yyval._$.range = [
|
249 | lstack[lstack.length - (len || 1)].range[0],
|
250 | lstack[lstack.length - 1].range[1]
|
251 | ];
|
252 | }
|
253 | r = this.performAction.apply(yyval, [
|
254 | yytext,
|
255 | yyleng,
|
256 | yylineno,
|
257 | sharedState.yy,
|
258 | action[1],
|
259 | vstack,
|
260 | lstack
|
261 | ].concat(args));
|
262 | if (typeof r !== "undefined") {
|
263 | return r;
|
264 | }
|
265 | if (len) {
|
266 | stack = stack.slice(0, -1 * len * 2);
|
267 | vstack = vstack.slice(0, -1 * len);
|
268 | lstack = lstack.slice(0, -1 * len);
|
269 | }
|
270 | stack.push(this.productions_[action[1]][0]);
|
271 | vstack.push(yyval.$);
|
272 | lstack.push(yyval._$);
|
273 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
274 | stack.push(newState);
|
275 | break;
|
276 | case 3:
|
277 | return true;
|
278 | }
|
279 | }
|
280 | return true;
|
281 | }
|
282 | };
|
283 | var lexer = function() {
|
284 | var lexer2 = {
|
285 | EOF: 1,
|
286 | parseError: function parseError(str, hash) {
|
287 | if (this.yy.parser) {
|
288 | this.yy.parser.parseError(str, hash);
|
289 | } else {
|
290 | throw new Error(str);
|
291 | }
|
292 | },
|
293 |
|
294 | setInput: function(input, yy) {
|
295 | this.yy = yy || this.yy || {};
|
296 | this._input = input;
|
297 | this._more = this._backtrack = this.done = false;
|
298 | this.yylineno = this.yyleng = 0;
|
299 | this.yytext = this.matched = this.match = "";
|
300 | this.conditionStack = ["INITIAL"];
|
301 | this.yylloc = {
|
302 | first_line: 1,
|
303 | first_column: 0,
|
304 | last_line: 1,
|
305 | last_column: 0
|
306 | };
|
307 | if (this.options.ranges) {
|
308 | this.yylloc.range = [0, 0];
|
309 | }
|
310 | this.offset = 0;
|
311 | return this;
|
312 | },
|
313 |
|
314 | input: function() {
|
315 | var ch = this._input[0];
|
316 | this.yytext += ch;
|
317 | this.yyleng++;
|
318 | this.offset++;
|
319 | this.match += ch;
|
320 | this.matched += ch;
|
321 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
322 | if (lines) {
|
323 | this.yylineno++;
|
324 | this.yylloc.last_line++;
|
325 | } else {
|
326 | this.yylloc.last_column++;
|
327 | }
|
328 | if (this.options.ranges) {
|
329 | this.yylloc.range[1]++;
|
330 | }
|
331 | this._input = this._input.slice(1);
|
332 | return ch;
|
333 | },
|
334 |
|
335 | unput: function(ch) {
|
336 | var len = ch.length;
|
337 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
338 | this._input = ch + this._input;
|
339 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
340 | this.offset -= len;
|
341 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
342 | this.match = this.match.substr(0, this.match.length - 1);
|
343 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
344 | if (lines.length - 1) {
|
345 | this.yylineno -= lines.length - 1;
|
346 | }
|
347 | var r = this.yylloc.range;
|
348 | this.yylloc = {
|
349 | first_line: this.yylloc.first_line,
|
350 | last_line: this.yylineno + 1,
|
351 | first_column: this.yylloc.first_column,
|
352 | 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
|
353 | };
|
354 | if (this.options.ranges) {
|
355 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
356 | }
|
357 | this.yyleng = this.yytext.length;
|
358 | return this;
|
359 | },
|
360 |
|
361 | more: function() {
|
362 | this._more = true;
|
363 | return this;
|
364 | },
|
365 |
|
366 | reject: function() {
|
367 | if (this.options.backtrack_lexer) {
|
368 | this._backtrack = true;
|
369 | } else {
|
370 | 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(), {
|
371 | text: "",
|
372 | token: null,
|
373 | line: this.yylineno
|
374 | });
|
375 | }
|
376 | return this;
|
377 | },
|
378 |
|
379 | less: function(n) {
|
380 | this.unput(this.match.slice(n));
|
381 | },
|
382 |
|
383 | pastInput: function() {
|
384 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
385 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
386 | },
|
387 |
|
388 | upcomingInput: function() {
|
389 | var next = this.match;
|
390 | if (next.length < 20) {
|
391 | next += this._input.substr(0, 20 - next.length);
|
392 | }
|
393 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
394 | },
|
395 |
|
396 | showPosition: function() {
|
397 | var pre = this.pastInput();
|
398 | var c = new Array(pre.length + 1).join("-");
|
399 | return pre + this.upcomingInput() + "\n" + c + "^";
|
400 | },
|
401 |
|
402 | test_match: function(match, indexed_rule) {
|
403 | var token, lines, backup;
|
404 | if (this.options.backtrack_lexer) {
|
405 | backup = {
|
406 | yylineno: this.yylineno,
|
407 | yylloc: {
|
408 | first_line: this.yylloc.first_line,
|
409 | last_line: this.last_line,
|
410 | first_column: this.yylloc.first_column,
|
411 | last_column: this.yylloc.last_column
|
412 | },
|
413 | yytext: this.yytext,
|
414 | match: this.match,
|
415 | matches: this.matches,
|
416 | matched: this.matched,
|
417 | yyleng: this.yyleng,
|
418 | offset: this.offset,
|
419 | _more: this._more,
|
420 | _input: this._input,
|
421 | yy: this.yy,
|
422 | conditionStack: this.conditionStack.slice(0),
|
423 | done: this.done
|
424 | };
|
425 | if (this.options.ranges) {
|
426 | backup.yylloc.range = this.yylloc.range.slice(0);
|
427 | }
|
428 | }
|
429 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
430 | if (lines) {
|
431 | this.yylineno += lines.length;
|
432 | }
|
433 | this.yylloc = {
|
434 | first_line: this.yylloc.last_line,
|
435 | last_line: this.yylineno + 1,
|
436 | first_column: this.yylloc.last_column,
|
437 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
438 | };
|
439 | this.yytext += match[0];
|
440 | this.match += match[0];
|
441 | this.matches = match;
|
442 | this.yyleng = this.yytext.length;
|
443 | if (this.options.ranges) {
|
444 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
445 | }
|
446 | this._more = false;
|
447 | this._backtrack = false;
|
448 | this._input = this._input.slice(match[0].length);
|
449 | this.matched += match[0];
|
450 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
451 | if (this.done && this._input) {
|
452 | this.done = false;
|
453 | }
|
454 | if (token) {
|
455 | return token;
|
456 | } else if (this._backtrack) {
|
457 | for (var k in backup) {
|
458 | this[k] = backup[k];
|
459 | }
|
460 | return false;
|
461 | }
|
462 | return false;
|
463 | },
|
464 |
|
465 | next: function() {
|
466 | if (this.done) {
|
467 | return this.EOF;
|
468 | }
|
469 | if (!this._input) {
|
470 | this.done = true;
|
471 | }
|
472 | var token, match, tempMatch, index;
|
473 | if (!this._more) {
|
474 | this.yytext = "";
|
475 | this.match = "";
|
476 | }
|
477 | var rules = this._currentRules();
|
478 | for (var i = 0; i < rules.length; i++) {
|
479 | tempMatch = this._input.match(this.rules[rules[i]]);
|
480 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
481 | match = tempMatch;
|
482 | index = i;
|
483 | if (this.options.backtrack_lexer) {
|
484 | token = this.test_match(tempMatch, rules[i]);
|
485 | if (token !== false) {
|
486 | return token;
|
487 | } else if (this._backtrack) {
|
488 | match = false;
|
489 | continue;
|
490 | } else {
|
491 | return false;
|
492 | }
|
493 | } else if (!this.options.flex) {
|
494 | break;
|
495 | }
|
496 | }
|
497 | }
|
498 | if (match) {
|
499 | token = this.test_match(match, rules[index]);
|
500 | if (token !== false) {
|
501 | return token;
|
502 | }
|
503 | return false;
|
504 | }
|
505 | if (this._input === "") {
|
506 | return this.EOF;
|
507 | } else {
|
508 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
509 | text: "",
|
510 | token: null,
|
511 | line: this.yylineno
|
512 | });
|
513 | }
|
514 | },
|
515 |
|
516 | lex: function lex() {
|
517 | var r = this.next();
|
518 | if (r) {
|
519 | return r;
|
520 | } else {
|
521 | return this.lex();
|
522 | }
|
523 | },
|
524 |
|
525 | begin: function begin(condition) {
|
526 | this.conditionStack.push(condition);
|
527 | },
|
528 |
|
529 | popState: function popState() {
|
530 | var n = this.conditionStack.length - 1;
|
531 | if (n > 0) {
|
532 | return this.conditionStack.pop();
|
533 | } else {
|
534 | return this.conditionStack[0];
|
535 | }
|
536 | },
|
537 |
|
538 | _currentRules: function _currentRules() {
|
539 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
540 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
541 | } else {
|
542 | return this.conditions["INITIAL"].rules;
|
543 | }
|
544 | },
|
545 |
|
546 | topState: function topState(n) {
|
547 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
548 | if (n >= 0) {
|
549 | return this.conditionStack[n];
|
550 | } else {
|
551 | return "INITIAL";
|
552 | }
|
553 | },
|
554 |
|
555 | pushState: function pushState(condition) {
|
556 | this.begin(condition);
|
557 | },
|
558 |
|
559 | stateStackSize: function stateStackSize() {
|
560 | return this.conditionStack.length;
|
561 | },
|
562 | options: { "case-insensitive": true },
|
563 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
564 | switch ($avoiding_name_collisions) {
|
565 | case 0:
|
566 | this.begin("acc_title");
|
567 | return 22;
|
568 | case 1:
|
569 | this.popState();
|
570 | return "acc_title_value";
|
571 | case 2:
|
572 | this.begin("acc_descr");
|
573 | return 24;
|
574 | case 3:
|
575 | this.popState();
|
576 | return "acc_descr_value";
|
577 | case 4:
|
578 | this.begin("acc_descr_multiline");
|
579 | break;
|
580 | case 5:
|
581 | this.popState();
|
582 | break;
|
583 | case 6:
|
584 | return "acc_descr_multiline_value";
|
585 | case 7:
|
586 | return 10;
|
587 | case 8:
|
588 | break;
|
589 | case 9:
|
590 | return 8;
|
591 | case 10:
|
592 | return 28;
|
593 | case 11:
|
594 | return 48;
|
595 | case 12:
|
596 | return 4;
|
597 | case 13:
|
598 | this.begin("block");
|
599 | return 15;
|
600 | case 14:
|
601 | return 36;
|
602 | case 15:
|
603 | break;
|
604 | case 16:
|
605 | return 37;
|
606 | case 17:
|
607 | return 34;
|
608 | case 18:
|
609 | return 34;
|
610 | case 19:
|
611 | return 38;
|
612 | case 20:
|
613 | break;
|
614 | case 21:
|
615 | this.popState();
|
616 | return 17;
|
617 | case 22:
|
618 | return yy_.yytext[0];
|
619 | case 23:
|
620 | return 18;
|
621 | case 24:
|
622 | return 19;
|
623 | case 25:
|
624 | return 41;
|
625 | case 26:
|
626 | return 43;
|
627 | case 27:
|
628 | return 43;
|
629 | case 28:
|
630 | return 43;
|
631 | case 29:
|
632 | return 41;
|
633 | case 30:
|
634 | return 41;
|
635 | case 31:
|
636 | return 42;
|
637 | case 32:
|
638 | return 42;
|
639 | case 33:
|
640 | return 42;
|
641 | case 34:
|
642 | return 42;
|
643 | case 35:
|
644 | return 42;
|
645 | case 36:
|
646 | return 43;
|
647 | case 37:
|
648 | return 42;
|
649 | case 38:
|
650 | return 43;
|
651 | case 39:
|
652 | return 44;
|
653 | case 40:
|
654 | return 44;
|
655 | case 41:
|
656 | return 44;
|
657 | case 42:
|
658 | return 44;
|
659 | case 43:
|
660 | return 41;
|
661 | case 44:
|
662 | return 42;
|
663 | case 45:
|
664 | return 43;
|
665 | case 46:
|
666 | return 45;
|
667 | case 47:
|
668 | return 46;
|
669 | case 48:
|
670 | return 47;
|
671 | case 49:
|
672 | return 47;
|
673 | case 50:
|
674 | return 46;
|
675 | case 51:
|
676 | return 46;
|
677 | case 52:
|
678 | return 46;
|
679 | case 53:
|
680 | return 27;
|
681 | case 54:
|
682 | return yy_.yytext[0];
|
683 | case 55:
|
684 | return 6;
|
685 | }
|
686 | },
|
687 | rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:[\s]+)/i, /^(?:"[^"%\r\n\v\b\\]+")/i, /^(?:"[^"]*")/i, /^(?:erDiagram\b)/i, /^(?:\{)/i, /^(?:,)/i, /^(?:\s+)/i, /^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]*)/i, /^(?:"[^"]*")/i, /^(?:[\n]+)/i, /^(?:\})/i, /^(?:.)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:one or zero\b)/i, /^(?:one or more\b)/i, /^(?:one or many\b)/i, /^(?:1\+)/i, /^(?:\|o\b)/i, /^(?:zero or one\b)/i, /^(?:zero or more\b)/i, /^(?:zero or many\b)/i, /^(?:0\+)/i, /^(?:\}o\b)/i, /^(?:many\(0\))/i, /^(?:many\(1\))/i, /^(?:many\b)/i, /^(?:\}\|)/i, /^(?:one\b)/i, /^(?:only one\b)/i, /^(?:1\b)/i, /^(?:\|\|)/i, /^(?:o\|)/i, /^(?:o\{)/i, /^(?:\|\{)/i, /^(?:\s*u\b)/i, /^(?:\.\.)/i, /^(?:--)/i, /^(?:to\b)/i, /^(?:optionally to\b)/i, /^(?:\.-)/i, /^(?:-\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i, /^(?:.)/i, /^(?:$)/i],
|
688 | conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "block": { "rules": [14, 15, 16, 17, 18, 19, 20, 21, 22], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], "inclusive": true } }
|
689 | };
|
690 | return lexer2;
|
691 | }();
|
692 | parser2.lexer = lexer;
|
693 | function Parser() {
|
694 | this.yy = {};
|
695 | }
|
696 | Parser.prototype = parser2;
|
697 | parser2.Parser = Parser;
|
698 | return new Parser();
|
699 | }();
|
700 | parser.parser = parser;
|
701 | const erParser = parser;
|
702 | let entities = {};
|
703 | let relationships = [];
|
704 | const Cardinality = {
|
705 | ZERO_OR_ONE: "ZERO_OR_ONE",
|
706 | ZERO_OR_MORE: "ZERO_OR_MORE",
|
707 | ONE_OR_MORE: "ONE_OR_MORE",
|
708 | ONLY_ONE: "ONLY_ONE",
|
709 | MD_PARENT: "MD_PARENT"
|
710 | };
|
711 | const Identification = {
|
712 | NON_IDENTIFYING: "NON_IDENTIFYING",
|
713 | IDENTIFYING: "IDENTIFYING"
|
714 | };
|
715 | const addEntity = function(name, alias = void 0) {
|
716 | if (entities[name] === void 0) {
|
717 | entities[name] = { attributes: [], alias };
|
718 | log.info("Added new entity :", name);
|
719 | } else if (entities[name] && !entities[name].alias && alias) {
|
720 | entities[name].alias = alias;
|
721 | log.info(`Add alias '${alias}' to entity '${name}'`);
|
722 | }
|
723 | return entities[name];
|
724 | };
|
725 | const getEntities = () => entities;
|
726 | const addAttributes = function(entityName, attribs) {
|
727 | let entity = addEntity(entityName);
|
728 | let i;
|
729 | for (i = attribs.length - 1; i >= 0; i--) {
|
730 | entity.attributes.push(attribs[i]);
|
731 | log.debug("Added attribute ", attribs[i].attributeName);
|
732 | }
|
733 | };
|
734 | const addRelationship = function(entA, rolA, entB, rSpec) {
|
735 | let rel = {
|
736 | entityA: entA,
|
737 | roleA: rolA,
|
738 | entityB: entB,
|
739 | relSpec: rSpec
|
740 | };
|
741 | relationships.push(rel);
|
742 | log.debug("Added new relationship :", rel);
|
743 | };
|
744 | const getRelationships = () => relationships;
|
745 | const clear = function() {
|
746 | entities = {};
|
747 | relationships = [];
|
748 | clear$1();
|
749 | };
|
750 | const erDb = {
|
751 | Cardinality,
|
752 | Identification,
|
753 | getConfig: () => getConfig().er,
|
754 | addEntity,
|
755 | addAttributes,
|
756 | getEntities,
|
757 | addRelationship,
|
758 | getRelationships,
|
759 | clear,
|
760 | setAccTitle,
|
761 | getAccTitle,
|
762 | setAccDescription,
|
763 | getAccDescription,
|
764 | setDiagramTitle,
|
765 | getDiagramTitle
|
766 | };
|
767 | const ERMarkers = {
|
768 | ONLY_ONE_START: "ONLY_ONE_START",
|
769 | ONLY_ONE_END: "ONLY_ONE_END",
|
770 | ZERO_OR_ONE_START: "ZERO_OR_ONE_START",
|
771 | ZERO_OR_ONE_END: "ZERO_OR_ONE_END",
|
772 | ONE_OR_MORE_START: "ONE_OR_MORE_START",
|
773 | ONE_OR_MORE_END: "ONE_OR_MORE_END",
|
774 | ZERO_OR_MORE_START: "ZERO_OR_MORE_START",
|
775 | ZERO_OR_MORE_END: "ZERO_OR_MORE_END",
|
776 | MD_PARENT_END: "MD_PARENT_END",
|
777 | MD_PARENT_START: "MD_PARENT_START"
|
778 | };
|
779 | const insertMarkers = function(elem, conf2) {
|
780 | let marker;
|
781 | elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_START).attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z");
|
782 | elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_END).attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z");
|
783 | elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18 M15,0 L15,18");
|
784 | elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_END).attr("refX", 18).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,0 L3,18 M9,0 L9,18");
|
785 | marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto");
|
786 | marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 21).attr("cy", 9).attr("r", 6);
|
787 | marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18");
|
788 | marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_END).attr("refX", 30).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto");
|
789 | marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 9).attr("r", 6);
|
790 | marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,0 L21,18");
|
791 | elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27");
|
792 | elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_END).attr("refX", 27).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18");
|
793 | marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto");
|
794 | marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 48).attr("cy", 18).attr("r", 6);
|
795 | marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q18,0 36,18 Q18,36 0,18");
|
796 | marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_END).attr("refX", 39).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto");
|
797 | marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 18).attr("r", 6);
|
798 | marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,18 Q39,0 57,18 Q39,36 21,18");
|
799 | return;
|
800 | };
|
801 | const erMarkers = {
|
802 | ERMarkers,
|
803 | insertMarkers
|
804 | };
|
805 | const REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
806 | function validate(uuid) {
|
807 | return typeof uuid === "string" && REGEX.test(uuid);
|
808 | }
|
809 | const byteToHex = [];
|
810 | for (let i = 0; i < 256; ++i) {
|
811 | byteToHex.push((i + 256).toString(16).slice(1));
|
812 | }
|
813 | function unsafeStringify(arr, offset = 0) {
|
814 | return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
815 | }
|
816 | function parse(uuid) {
|
817 | if (!validate(uuid)) {
|
818 | throw TypeError("Invalid UUID");
|
819 | }
|
820 | let v;
|
821 | const arr = new Uint8Array(16);
|
822 | arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
823 | arr[1] = v >>> 16 & 255;
|
824 | arr[2] = v >>> 8 & 255;
|
825 | arr[3] = v & 255;
|
826 | arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
827 | arr[5] = v & 255;
|
828 | arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
829 | arr[7] = v & 255;
|
830 | arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
831 | arr[9] = v & 255;
|
832 | arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255;
|
833 | arr[11] = v / 4294967296 & 255;
|
834 | arr[12] = v >>> 24 & 255;
|
835 | arr[13] = v >>> 16 & 255;
|
836 | arr[14] = v >>> 8 & 255;
|
837 | arr[15] = v & 255;
|
838 | return arr;
|
839 | }
|
840 | function stringToBytes(str) {
|
841 | str = unescape(encodeURIComponent(str));
|
842 | const bytes = [];
|
843 | for (let i = 0; i < str.length; ++i) {
|
844 | bytes.push(str.charCodeAt(i));
|
845 | }
|
846 | return bytes;
|
847 | }
|
848 | const DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
849 | const URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
850 | function v35(name, version, hashfunc) {
|
851 | function generateUUID(value, namespace, buf, offset) {
|
852 | var _namespace;
|
853 | if (typeof value === "string") {
|
854 | value = stringToBytes(value);
|
855 | }
|
856 | if (typeof namespace === "string") {
|
857 | namespace = parse(namespace);
|
858 | }
|
859 | if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
860 | throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
861 | }
|
862 | let bytes = new Uint8Array(16 + value.length);
|
863 | bytes.set(namespace);
|
864 | bytes.set(value, namespace.length);
|
865 | bytes = hashfunc(bytes);
|
866 | bytes[6] = bytes[6] & 15 | version;
|
867 | bytes[8] = bytes[8] & 63 | 128;
|
868 | if (buf) {
|
869 | offset = offset || 0;
|
870 | for (let i = 0; i < 16; ++i) {
|
871 | buf[offset + i] = bytes[i];
|
872 | }
|
873 | return buf;
|
874 | }
|
875 | return unsafeStringify(bytes);
|
876 | }
|
877 | try {
|
878 | generateUUID.name = name;
|
879 | } catch (err) {
|
880 | }
|
881 | generateUUID.DNS = DNS;
|
882 | generateUUID.URL = URL;
|
883 | return generateUUID;
|
884 | }
|
885 | function f(s, x, y, z) {
|
886 | switch (s) {
|
887 | case 0:
|
888 | return x & y ^ ~x & z;
|
889 | case 1:
|
890 | return x ^ y ^ z;
|
891 | case 2:
|
892 | return x & y ^ x & z ^ y & z;
|
893 | case 3:
|
894 | return x ^ y ^ z;
|
895 | }
|
896 | }
|
897 | function ROTL(x, n) {
|
898 | return x << n | x >>> 32 - n;
|
899 | }
|
900 | function sha1(bytes) {
|
901 | const K = [1518500249, 1859775393, 2400959708, 3395469782];
|
902 | const H = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
903 | if (typeof bytes === "string") {
|
904 | const msg = unescape(encodeURIComponent(bytes));
|
905 | bytes = [];
|
906 | for (let i = 0; i < msg.length; ++i) {
|
907 | bytes.push(msg.charCodeAt(i));
|
908 | }
|
909 | } else if (!Array.isArray(bytes)) {
|
910 | bytes = Array.prototype.slice.call(bytes);
|
911 | }
|
912 | bytes.push(128);
|
913 | const l = bytes.length / 4 + 2;
|
914 | const N = Math.ceil(l / 16);
|
915 | const M = new Array(N);
|
916 | for (let i = 0; i < N; ++i) {
|
917 | const arr = new Uint32Array(16);
|
918 | for (let j = 0; j < 16; ++j) {
|
919 | arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
|
920 | }
|
921 | M[i] = arr;
|
922 | }
|
923 | M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
924 | M[N - 1][14] = Math.floor(M[N - 1][14]);
|
925 | M[N - 1][15] = (bytes.length - 1) * 8 & 4294967295;
|
926 | for (let i = 0; i < N; ++i) {
|
927 | const W = new Uint32Array(80);
|
928 | for (let t = 0; t < 16; ++t) {
|
929 | W[t] = M[i][t];
|
930 | }
|
931 | for (let t = 16; t < 80; ++t) {
|
932 | W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
933 | }
|
934 | let a = H[0];
|
935 | let b = H[1];
|
936 | let c = H[2];
|
937 | let d = H[3];
|
938 | let e = H[4];
|
939 | for (let t = 0; t < 80; ++t) {
|
940 | const s = Math.floor(t / 20);
|
941 | const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
942 | e = d;
|
943 | d = c;
|
944 | c = ROTL(b, 30) >>> 0;
|
945 | b = a;
|
946 | a = T;
|
947 | }
|
948 | H[0] = H[0] + a >>> 0;
|
949 | H[1] = H[1] + b >>> 0;
|
950 | H[2] = H[2] + c >>> 0;
|
951 | H[3] = H[3] + d >>> 0;
|
952 | H[4] = H[4] + e >>> 0;
|
953 | }
|
954 | return [H[0] >> 24 & 255, H[0] >> 16 & 255, H[0] >> 8 & 255, H[0] & 255, H[1] >> 24 & 255, H[1] >> 16 & 255, H[1] >> 8 & 255, H[1] & 255, H[2] >> 24 & 255, H[2] >> 16 & 255, H[2] >> 8 & 255, H[2] & 255, H[3] >> 24 & 255, H[3] >> 16 & 255, H[3] >> 8 & 255, H[3] & 255, H[4] >> 24 & 255, H[4] >> 16 & 255, H[4] >> 8 & 255, H[4] & 255];
|
955 | }
|
956 | const v5 = v35("v5", 80, sha1);
|
957 | const uuid5 = v5;
|
958 | const BAD_ID_CHARS_REGEXP = /[^\dA-Za-z](\W)*/g;
|
959 | let conf = {};
|
960 | let entityNameIds = new Map();
|
961 | const setConf = function(cnf) {
|
962 | const keys = Object.keys(cnf);
|
963 | for (const key of keys) {
|
964 | conf[key] = cnf[key];
|
965 | }
|
966 | };
|
967 | const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
968 | const heightPadding = conf.entityPadding / 3;
|
969 | const widthPadding = conf.entityPadding / 3;
|
970 | const attrFontSize = conf.fontSize * 0.85;
|
971 | const labelBBox = entityTextNode.node().getBBox();
|
972 | const attributeNodes = [];
|
973 | let hasKeyType = false;
|
974 | let hasComment = false;
|
975 | let maxTypeWidth = 0;
|
976 | let maxNameWidth = 0;
|
977 | let maxKeyWidth = 0;
|
978 | let maxCommentWidth = 0;
|
979 | let cumulativeHeight = labelBBox.height + heightPadding * 2;
|
980 | let attrNum = 1;
|
981 | attributes.forEach((item) => {
|
982 | if (item.attributeKeyTypeList !== void 0 && item.attributeKeyTypeList.length > 0) {
|
983 | hasKeyType = true;
|
984 | }
|
985 | if (item.attributeComment !== void 0) {
|
986 | hasComment = true;
|
987 | }
|
988 | });
|
989 | attributes.forEach((item) => {
|
990 | const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`;
|
991 | let nodeHeight = 0;
|
992 | const attributeType = parseGenericTypes(item.attributeType);
|
993 | const typeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-type`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(attributeType);
|
994 | const nameNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-name`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeName);
|
995 | const attributeNode = {};
|
996 | attributeNode.tn = typeNode;
|
997 | attributeNode.nn = nameNode;
|
998 | const typeBBox = typeNode.node().getBBox();
|
999 | const nameBBox = nameNode.node().getBBox();
|
1000 | maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width);
|
1001 | maxNameWidth = Math.max(maxNameWidth, nameBBox.width);
|
1002 | nodeHeight = Math.max(typeBBox.height, nameBBox.height);
|
1003 | if (hasKeyType) {
|
1004 | const keyTypeNodeText = item.attributeKeyTypeList !== void 0 ? item.attributeKeyTypeList.join(",") : "";
|
1005 | const keyTypeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-key`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(keyTypeNodeText);
|
1006 | attributeNode.kn = keyTypeNode;
|
1007 | const keyTypeBBox = keyTypeNode.node().getBBox();
|
1008 | maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width);
|
1009 | nodeHeight = Math.max(nodeHeight, keyTypeBBox.height);
|
1010 | }
|
1011 | if (hasComment) {
|
1012 | const commentNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-comment`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeComment || "");
|
1013 | attributeNode.cn = commentNode;
|
1014 | const commentNodeBBox = commentNode.node().getBBox();
|
1015 | maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width);
|
1016 | nodeHeight = Math.max(nodeHeight, commentNodeBBox.height);
|
1017 | }
|
1018 | attributeNode.height = nodeHeight;
|
1019 | attributeNodes.push(attributeNode);
|
1020 | cumulativeHeight += nodeHeight + heightPadding * 2;
|
1021 | attrNum += 1;
|
1022 | });
|
1023 | let widthPaddingFactor = 4;
|
1024 | if (hasKeyType) {
|
1025 | widthPaddingFactor += 2;
|
1026 | }
|
1027 | if (hasComment) {
|
1028 | widthPaddingFactor += 2;
|
1029 | }
|
1030 | const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth;
|
1031 | const bBox = {
|
1032 | width: Math.max(
|
1033 | conf.minEntityWidth,
|
1034 | Math.max(
|
1035 | labelBBox.width + conf.entityPadding * 2,
|
1036 | maxWidth + widthPadding * widthPaddingFactor
|
1037 | )
|
1038 | ),
|
1039 | height: attributes.length > 0 ? cumulativeHeight : Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2)
|
1040 | };
|
1041 | if (attributes.length > 0) {
|
1042 | const spareColumnWidth = Math.max(
|
1043 | 0,
|
1044 | (bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2)
|
1045 | );
|
1046 | entityTextNode.attr(
|
1047 | "transform",
|
1048 | "translate(" + bBox.width / 2 + "," + (heightPadding + labelBBox.height / 2) + ")"
|
1049 | );
|
1050 | let heightOffset = labelBBox.height + heightPadding * 2;
|
1051 | let attribStyle = "attributeBoxOdd";
|
1052 | attributeNodes.forEach((attributeNode) => {
|
1053 | const alignY = heightOffset + heightPadding + attributeNode.height / 2;
|
1054 | attributeNode.tn.attr("transform", "translate(" + widthPadding + "," + alignY + ")");
|
1055 | const typeRect = groupNode.insert("rect", "#" + attributeNode.tn.node().id).classed(`er ${attribStyle}`, true).attr("x", 0).attr("y", heightOffset).attr("width", maxTypeWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2);
|
1056 | const nameXOffset = parseFloat(typeRect.attr("x")) + parseFloat(typeRect.attr("width"));
|
1057 | attributeNode.nn.attr(
|
1058 | "transform",
|
1059 | "translate(" + (nameXOffset + widthPadding) + "," + alignY + ")"
|
1060 | );
|
1061 | const nameRect = groupNode.insert("rect", "#" + attributeNode.nn.node().id).classed(`er ${attribStyle}`, true).attr("x", nameXOffset).attr("y", heightOffset).attr("width", maxNameWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2);
|
1062 | let keyTypeAndCommentXOffset = parseFloat(nameRect.attr("x")) + parseFloat(nameRect.attr("width"));
|
1063 | if (hasKeyType) {
|
1064 | attributeNode.kn.attr(
|
1065 | "transform",
|
1066 | "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")"
|
1067 | );
|
1068 | const keyTypeRect = groupNode.insert("rect", "#" + attributeNode.kn.node().id).classed(`er ${attribStyle}`, true).attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxKeyWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2);
|
1069 | keyTypeAndCommentXOffset = parseFloat(keyTypeRect.attr("x")) + parseFloat(keyTypeRect.attr("width"));
|
1070 | }
|
1071 | if (hasComment) {
|
1072 | attributeNode.cn.attr(
|
1073 | "transform",
|
1074 | "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")"
|
1075 | );
|
1076 | groupNode.insert("rect", "#" + attributeNode.cn.node().id).classed(`er ${attribStyle}`, "true").attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxCommentWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2);
|
1077 | }
|
1078 | heightOffset += attributeNode.height + heightPadding * 2;
|
1079 | attribStyle = attribStyle === "attributeBoxOdd" ? "attributeBoxEven" : "attributeBoxOdd";
|
1080 | });
|
1081 | } else {
|
1082 | bBox.height = Math.max(conf.minEntityHeight, cumulativeHeight);
|
1083 | entityTextNode.attr("transform", "translate(" + bBox.width / 2 + "," + bBox.height / 2 + ")");
|
1084 | }
|
1085 | return bBox;
|
1086 | };
|
1087 | const drawEntities = function(svgNode, entities2, graph) {
|
1088 | const keys = Object.keys(entities2);
|
1089 | let firstOne;
|
1090 | keys.forEach(function(entityName) {
|
1091 | const entityId = generateId(entityName, "entity");
|
1092 | entityNameIds.set(entityName, entityId);
|
1093 | const groupNode = svgNode.append("g").attr("id", entityId);
|
1094 | firstOne = firstOne === void 0 ? entityId : firstOne;
|
1095 | const textId = "text-" + entityId;
|
1096 | const textNode = groupNode.append("text").classed("er entityLabel", true).attr("id", textId).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "middle").style("font-family", getConfig().fontFamily).style("font-size", conf.fontSize + "px").text(entities2[entityName].alias ?? entityName);
|
1097 | const { width: entityWidth, height: entityHeight } = drawAttributes(
|
1098 | groupNode,
|
1099 | textNode,
|
1100 | entities2[entityName].attributes
|
1101 | );
|
1102 | const rectNode = groupNode.insert("rect", "#" + textId).classed("er entityBox", true).attr("x", 0).attr("y", 0).attr("width", entityWidth).attr("height", entityHeight);
|
1103 | const rectBBox = rectNode.node().getBBox();
|
1104 | graph.setNode(entityId, {
|
1105 | width: rectBBox.width,
|
1106 | height: rectBBox.height,
|
1107 | shape: "rect",
|
1108 | id: entityId
|
1109 | });
|
1110 | });
|
1111 | return firstOne;
|
1112 | };
|
1113 | const adjustEntities = function(svgNode, graph) {
|
1114 | graph.nodes().forEach(function(v) {
|
1115 | if (v !== void 0 && graph.node(v) !== void 0) {
|
1116 | svgNode.select("#" + v).attr(
|
1117 | "transform",
|
1118 | "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )"
|
1119 | );
|
1120 | }
|
1121 | });
|
1122 | };
|
1123 | const getEdgeName = function(rel) {
|
1124 | return (rel.entityA + rel.roleA + rel.entityB).replace(/\s/g, "");
|
1125 | };
|
1126 | const addRelationships = function(relationships2, g) {
|
1127 | relationships2.forEach(function(r) {
|
1128 | g.setEdge(
|
1129 | entityNameIds.get(r.entityA),
|
1130 | entityNameIds.get(r.entityB),
|
1131 | { relationship: r },
|
1132 | getEdgeName(r)
|
1133 | );
|
1134 | });
|
1135 | return relationships2;
|
1136 | };
|
1137 | let relCnt = 0;
|
1138 | const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) {
|
1139 | relCnt++;
|
1140 | const edge = g.edge(
|
1141 | entityNameIds.get(rel.entityA),
|
1142 | entityNameIds.get(rel.entityB),
|
1143 | getEdgeName(rel)
|
1144 | );
|
1145 | const lineFunction = line().x(function(d) {
|
1146 | return d.x;
|
1147 | }).y(function(d) {
|
1148 | return d.y;
|
1149 | }).curve(curveBasis);
|
1150 | const svgPath = svg.insert("path", "#" + insert).classed("er relationshipLine", true).attr("d", lineFunction(edge.points)).style("stroke", conf.stroke).style("fill", "none");
|
1151 | if (rel.relSpec.relType === diagObj.db.Identification.NON_IDENTIFYING) {
|
1152 | svgPath.attr("stroke-dasharray", "8,8");
|
1153 | }
|
1154 | let url = "";
|
1155 | if (conf.arrowMarkerAbsolute) {
|
1156 | url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
|
1157 | url = url.replace(/\(/g, "\\(");
|
1158 | url = url.replace(/\)/g, "\\)");
|
1159 | }
|
1160 | switch (rel.relSpec.cardA) {
|
1161 | case diagObj.db.Cardinality.ZERO_OR_ONE:
|
1162 | svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_END + ")");
|
1163 | break;
|
1164 | case diagObj.db.Cardinality.ZERO_OR_MORE:
|
1165 | svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_END + ")");
|
1166 | break;
|
1167 | case diagObj.db.Cardinality.ONE_OR_MORE:
|
1168 | svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_END + ")");
|
1169 | break;
|
1170 | case diagObj.db.Cardinality.ONLY_ONE:
|
1171 | svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_END + ")");
|
1172 | break;
|
1173 | case diagObj.db.Cardinality.MD_PARENT:
|
1174 | svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_END + ")");
|
1175 | break;
|
1176 | }
|
1177 | switch (rel.relSpec.cardB) {
|
1178 | case diagObj.db.Cardinality.ZERO_OR_ONE:
|
1179 | svgPath.attr(
|
1180 | "marker-start",
|
1181 | "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_START + ")"
|
1182 | );
|
1183 | break;
|
1184 | case diagObj.db.Cardinality.ZERO_OR_MORE:
|
1185 | svgPath.attr(
|
1186 | "marker-start",
|
1187 | "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_START + ")"
|
1188 | );
|
1189 | break;
|
1190 | case diagObj.db.Cardinality.ONE_OR_MORE:
|
1191 | svgPath.attr(
|
1192 | "marker-start",
|
1193 | "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_START + ")"
|
1194 | );
|
1195 | break;
|
1196 | case diagObj.db.Cardinality.ONLY_ONE:
|
1197 | svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_START + ")");
|
1198 | break;
|
1199 | case diagObj.db.Cardinality.MD_PARENT:
|
1200 | svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_START + ")");
|
1201 | break;
|
1202 | }
|
1203 | const len = svgPath.node().getTotalLength();
|
1204 | const labelPoint = svgPath.node().getPointAtLength(len * 0.5);
|
1205 | const labelId = "rel" + relCnt;
|
1206 | const labelNode = svg.append("text").classed("er relationshipLabel", true).attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).style("text-anchor", "middle").style("dominant-baseline", "middle").style("font-family", getConfig().fontFamily).style("font-size", conf.fontSize + "px").text(rel.roleA);
|
1207 | const labelBBox = labelNode.node().getBBox();
|
1208 | svg.insert("rect", "#" + labelId).classed("er relationshipLabelBox", true).attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height);
|
1209 | };
|
1210 | const draw = function(text, id, _version, diagObj) {
|
1211 | conf = getConfig().er;
|
1212 | log.info("Drawing ER diagram");
|
1213 | const securityLevel = getConfig().securityLevel;
|
1214 | let sandboxElement;
|
1215 | if (securityLevel === "sandbox") {
|
1216 | sandboxElement = d3select("#i" + id);
|
1217 | }
|
1218 | const root = securityLevel === "sandbox" ? d3select(sandboxElement.nodes()[0].contentDocument.body) : d3select("body");
|
1219 | const svg = root.select(`[id='${id}']`);
|
1220 | erMarkers.insertMarkers(svg, conf);
|
1221 | let g;
|
1222 | g = new Graph({
|
1223 | multigraph: true,
|
1224 | directed: true,
|
1225 | compound: false
|
1226 | }).setGraph({
|
1227 | rankdir: conf.layoutDirection,
|
1228 | marginx: 20,
|
1229 | marginy: 20,
|
1230 | nodesep: 100,
|
1231 | edgesep: 100,
|
1232 | ranksep: 100
|
1233 | }).setDefaultEdgeLabel(function() {
|
1234 | return {};
|
1235 | });
|
1236 | const firstEntity = drawEntities(svg, diagObj.db.getEntities(), g);
|
1237 | const relationships2 = addRelationships(diagObj.db.getRelationships(), g);
|
1238 | layout(g);
|
1239 | adjustEntities(svg, g);
|
1240 | relationships2.forEach(function(rel) {
|
1241 | drawRelationshipFromLayout(svg, rel, g, firstEntity, diagObj);
|
1242 | });
|
1243 | const padding = conf.diagramPadding;
|
1244 | utils.insertTitle(svg, "entityTitleText", conf.titleTopMargin, diagObj.db.getDiagramTitle());
|
1245 | const svgBounds = svg.node().getBBox();
|
1246 | const width = svgBounds.width + padding * 2;
|
1247 | const height = svgBounds.height + padding * 2;
|
1248 | configureSvgSize(svg, height, width, conf.useMaxWidth);
|
1249 | svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
|
1250 | };
|
1251 | const MERMAID_ERDIAGRAM_UUID = "28e9f9db-3c8d-5aa5-9faf-44286ae5937c";
|
1252 | function generateId(str = "", prefix = "") {
|
1253 | const simplifiedStr = str.replace(BAD_ID_CHARS_REGEXP, "");
|
1254 | return `${strWithHyphen(prefix)}${strWithHyphen(simplifiedStr)}${uuid5(
|
1255 | str,
|
1256 | MERMAID_ERDIAGRAM_UUID
|
1257 | )}`;
|
1258 | }
|
1259 | function strWithHyphen(str = "") {
|
1260 | return str.length > 0 ? `${str}-` : "";
|
1261 | }
|
1262 | const erRenderer = {
|
1263 | setConf,
|
1264 | draw
|
1265 | };
|
1266 | const getStyles = (options) => `
|
1267 | .entityBox {
|
1268 | fill: ${options.mainBkg};
|
1269 | stroke: ${options.nodeBorder};
|
1270 | }
|
1271 |
|
1272 | .attributeBoxOdd {
|
1273 | fill: ${options.attributeBackgroundColorOdd};
|
1274 | stroke: ${options.nodeBorder};
|
1275 | }
|
1276 |
|
1277 | .attributeBoxEven {
|
1278 | fill: ${options.attributeBackgroundColorEven};
|
1279 | stroke: ${options.nodeBorder};
|
1280 | }
|
1281 |
|
1282 | .relationshipLabelBox {
|
1283 | fill: ${options.tertiaryColor};
|
1284 | opacity: 0.7;
|
1285 | background-color: ${options.tertiaryColor};
|
1286 | rect {
|
1287 | opacity: 0.5;
|
1288 | }
|
1289 | }
|
1290 |
|
1291 | .relationshipLine {
|
1292 | stroke: ${options.lineColor};
|
1293 | }
|
1294 |
|
1295 | .entityTitleText {
|
1296 | text-anchor: middle;
|
1297 | font-size: 18px;
|
1298 | fill: ${options.textColor};
|
1299 | }
|
1300 | #MD_PARENT_START {
|
1301 | fill: #f5f5f5 !important;
|
1302 | stroke: ${options.lineColor} !important;
|
1303 | stroke-width: 1;
|
1304 | }
|
1305 | #MD_PARENT_END {
|
1306 | fill: #f5f5f5 !important;
|
1307 | stroke: ${options.lineColor} !important;
|
1308 | stroke-width: 1;
|
1309 | }
|
1310 |
|
1311 | `;
|
1312 | const erStyles = getStyles;
|
1313 | const diagram = {
|
1314 | parser: erParser,
|
1315 | db: erDb,
|
1316 | renderer: erRenderer,
|
1317 | styles: erStyles
|
1318 | };
|
1319 | export {
|
1320 | diagram
|
1321 | };
|