UNPKG

43.7 kBJavaScriptView Raw
1import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, l as log, E as clear$1, j as d3select, k as configureSvgSize, f as common } from "./mermaid-dcacb631.js";
2import { G as Graph } from "./graph-fe24fab6.js";
3import { l as layout } from "./layout-163b9689.js";
4import { l as line } from "./line-87f517ef.js";
5import "./array-b7dcf730.js";
6import "./path-39bad7e2.js";
7var 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 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [5, 6, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63], $V5 = [1, 18], $V6 = [2, 7], $V7 = [1, 22], $V8 = [1, 23], $V9 = [1, 24], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 20], $Ve = [1, 28], $Vf = [1, 29], $Vg = [62, 63], $Vh = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 51, 53, 62, 63], $Vi = [1, 47], $Vj = [1, 48], $Vk = [1, 49], $Vl = [1, 50], $Vm = [1, 51], $Vn = [1, 52], $Vo = [1, 53], $Vp = [53, 54], $Vq = [1, 64], $Vr = [1, 60], $Vs = [1, 61], $Vt = [1, 62], $Vu = [1, 63], $Vv = [1, 65], $Vw = [1, 69], $Vx = [1, 70], $Vy = [1, 67], $Vz = [1, 68], $VA = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63];
13 var parser2 = {
14 trace: function trace() {
15 },
16 yy: {},
17 symbols_: { "error": 2, "start": 3, "directive": 4, "NEWLINE": 5, "RD": 6, "diagram": 7, "EOF": 8, "acc_title": 9, "acc_title_value": 10, "acc_descr": 11, "acc_descr_value": 12, "acc_descr_multiline_value": 13, "requirementDef": 14, "elementDef": 15, "relationshipDef": 16, "requirementType": 17, "requirementName": 18, "STRUCT_START": 19, "requirementBody": 20, "ID": 21, "COLONSEP": 22, "id": 23, "TEXT": 24, "text": 25, "RISK": 26, "riskLevel": 27, "VERIFYMTHD": 28, "verifyType": 29, "STRUCT_STOP": 30, "REQUIREMENT": 31, "FUNCTIONAL_REQUIREMENT": 32, "INTERFACE_REQUIREMENT": 33, "PERFORMANCE_REQUIREMENT": 34, "PHYSICAL_REQUIREMENT": 35, "DESIGN_CONSTRAINT": 36, "LOW_RISK": 37, "MED_RISK": 38, "HIGH_RISK": 39, "VERIFY_ANALYSIS": 40, "VERIFY_DEMONSTRATION": 41, "VERIFY_INSPECTION": 42, "VERIFY_TEST": 43, "ELEMENT": 44, "elementName": 45, "elementBody": 46, "TYPE": 47, "type": 48, "DOCREF": 49, "ref": 50, "END_ARROW_L": 51, "relationship": 52, "LINE": 53, "END_ARROW_R": 54, "CONTAINS": 55, "COPIES": 56, "DERIVES": 57, "SATISFIES": 58, "VERIFIES": 59, "REFINES": 60, "TRACES": 61, "unqString": 62, "qString": 63, "$accept": 0, "$end": 1 },
18 terminals_: { 2: "error", 5: "NEWLINE", 6: "RD", 8: "EOF", 9: "acc_title", 10: "acc_title_value", 11: "acc_descr", 12: "acc_descr_value", 13: "acc_descr_multiline_value", 19: "STRUCT_START", 21: "ID", 22: "COLONSEP", 24: "TEXT", 26: "RISK", 28: "VERIFYMTHD", 30: "STRUCT_STOP", 31: "REQUIREMENT", 32: "FUNCTIONAL_REQUIREMENT", 33: "INTERFACE_REQUIREMENT", 34: "PERFORMANCE_REQUIREMENT", 35: "PHYSICAL_REQUIREMENT", 36: "DESIGN_CONSTRAINT", 37: "LOW_RISK", 38: "MED_RISK", 39: "HIGH_RISK", 40: "VERIFY_ANALYSIS", 41: "VERIFY_DEMONSTRATION", 42: "VERIFY_INSPECTION", 43: "VERIFY_TEST", 44: "ELEMENT", 47: "TYPE", 49: "DOCREF", 51: "END_ARROW_L", 53: "LINE", 54: "END_ARROW_R", 55: "CONTAINS", 56: "COPIES", 57: "DERIVES", 58: "SATISFIES", 59: "VERIFIES", 60: "REFINES", 61: "TRACES", 62: "unqString", 63: "qString" },
19 productions_: [0, [3, 3], [3, 2], [3, 4], [4, 2], [4, 2], [4, 1], [7, 0], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [14, 5], [20, 5], [20, 5], [20, 5], [20, 5], [20, 2], [20, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [27, 1], [27, 1], [27, 1], [29, 1], [29, 1], [29, 1], [29, 1], [15, 5], [46, 5], [46, 5], [46, 2], [46, 1], [16, 5], [16, 5], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [18, 1], [18, 1], [23, 1], [23, 1], [25, 1], [25, 1], [45, 1], [45, 1], [48, 1], [48, 1], [50, 1], [50, 1]],
20 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
21 var $0 = $$.length - 1;
22 switch (yystate) {
23 case 4:
24 this.$ = $$[$0].trim();
25 yy.setAccTitle(this.$);
26 break;
27 case 5:
28 case 6:
29 this.$ = $$[$0].trim();
30 yy.setAccDescription(this.$);
31 break;
32 case 7:
33 this.$ = [];
34 break;
35 case 13:
36 yy.addRequirement($$[$0 - 3], $$[$0 - 4]);
37 break;
38 case 14:
39 yy.setNewReqId($$[$0 - 2]);
40 break;
41 case 15:
42 yy.setNewReqText($$[$0 - 2]);
43 break;
44 case 16:
45 yy.setNewReqRisk($$[$0 - 2]);
46 break;
47 case 17:
48 yy.setNewReqVerifyMethod($$[$0 - 2]);
49 break;
50 case 20:
51 this.$ = yy.RequirementType.REQUIREMENT;
52 break;
53 case 21:
54 this.$ = yy.RequirementType.FUNCTIONAL_REQUIREMENT;
55 break;
56 case 22:
57 this.$ = yy.RequirementType.INTERFACE_REQUIREMENT;
58 break;
59 case 23:
60 this.$ = yy.RequirementType.PERFORMANCE_REQUIREMENT;
61 break;
62 case 24:
63 this.$ = yy.RequirementType.PHYSICAL_REQUIREMENT;
64 break;
65 case 25:
66 this.$ = yy.RequirementType.DESIGN_CONSTRAINT;
67 break;
68 case 26:
69 this.$ = yy.RiskLevel.LOW_RISK;
70 break;
71 case 27:
72 this.$ = yy.RiskLevel.MED_RISK;
73 break;
74 case 28:
75 this.$ = yy.RiskLevel.HIGH_RISK;
76 break;
77 case 29:
78 this.$ = yy.VerifyType.VERIFY_ANALYSIS;
79 break;
80 case 30:
81 this.$ = yy.VerifyType.VERIFY_DEMONSTRATION;
82 break;
83 case 31:
84 this.$ = yy.VerifyType.VERIFY_INSPECTION;
85 break;
86 case 32:
87 this.$ = yy.VerifyType.VERIFY_TEST;
88 break;
89 case 33:
90 yy.addElement($$[$0 - 3]);
91 break;
92 case 34:
93 yy.setNewElementType($$[$0 - 2]);
94 break;
95 case 35:
96 yy.setNewElementDocRef($$[$0 - 2]);
97 break;
98 case 38:
99 yy.addRelationship($$[$0 - 2], $$[$0], $$[$0 - 4]);
100 break;
101 case 39:
102 yy.addRelationship($$[$0 - 2], $$[$0 - 4], $$[$0]);
103 break;
104 case 40:
105 this.$ = yy.Relationships.CONTAINS;
106 break;
107 case 41:
108 this.$ = yy.Relationships.COPIES;
109 break;
110 case 42:
111 this.$ = yy.Relationships.DERIVES;
112 break;
113 case 43:
114 this.$ = yy.Relationships.SATISFIES;
115 break;
116 case 44:
117 this.$ = yy.Relationships.VERIFIES;
118 break;
119 case 45:
120 this.$ = yy.Relationships.REFINES;
121 break;
122 case 46:
123 this.$ = yy.Relationships.TRACES;
124 break;
125 }
126 },
127 table: [{ 3: 1, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [3] }, { 3: 8, 4: 2, 5: [1, 7], 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 5: [1, 9] }, { 10: [1, 10] }, { 12: [1, 11] }, o($V4, [2, 6]), { 3: 12, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [2, 2] }, { 4: 17, 5: $V5, 7: 13, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 1] }, { 8: [1, 30] }, { 4: 17, 5: $V5, 7: 31, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 32, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 33, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 34, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 35, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 18: 36, 62: [1, 37], 63: [1, 38] }, { 45: 39, 62: [1, 40], 63: [1, 41] }, { 51: [1, 42], 53: [1, 43] }, o($Vg, [2, 20]), o($Vg, [2, 21]), o($Vg, [2, 22]), o($Vg, [2, 23]), o($Vg, [2, 24]), o($Vg, [2, 25]), o($Vh, [2, 49]), o($Vh, [2, 50]), { 1: [2, 3] }, { 8: [2, 8] }, { 8: [2, 9] }, { 8: [2, 10] }, { 8: [2, 11] }, { 8: [2, 12] }, { 19: [1, 44] }, { 19: [2, 47] }, { 19: [2, 48] }, { 19: [1, 45] }, { 19: [2, 53] }, { 19: [2, 54] }, { 52: 46, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 52: 54, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 5: [1, 55] }, { 5: [1, 56] }, { 53: [1, 57] }, o($Vp, [2, 40]), o($Vp, [2, 41]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), { 54: [1, 58] }, { 5: $Vq, 20: 59, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 66, 47: $Vy, 49: $Vz }, { 23: 71, 62: $Ve, 63: $Vf }, { 23: 72, 62: $Ve, 63: $Vf }, o($VA, [2, 13]), { 22: [1, 73] }, { 22: [1, 74] }, { 22: [1, 75] }, { 22: [1, 76] }, { 5: $Vq, 20: 77, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, o($VA, [2, 19]), o($VA, [2, 33]), { 22: [1, 78] }, { 22: [1, 79] }, { 5: $Vw, 30: $Vx, 46: 80, 47: $Vy, 49: $Vz }, o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), { 23: 81, 62: $Ve, 63: $Vf }, { 25: 82, 62: [1, 83], 63: [1, 84] }, { 27: 85, 37: [1, 86], 38: [1, 87], 39: [1, 88] }, { 29: 89, 40: [1, 90], 41: [1, 91], 42: [1, 92], 43: [1, 93] }, o($VA, [2, 18]), { 48: 94, 62: [1, 95], 63: [1, 96] }, { 50: 97, 62: [1, 98], 63: [1, 99] }, o($VA, [2, 36]), { 5: [1, 100] }, { 5: [1, 101] }, { 5: [2, 51] }, { 5: [2, 52] }, { 5: [1, 102] }, { 5: [2, 26] }, { 5: [2, 27] }, { 5: [2, 28] }, { 5: [1, 103] }, { 5: [2, 29] }, { 5: [2, 30] }, { 5: [2, 31] }, { 5: [2, 32] }, { 5: [1, 104] }, { 5: [2, 55] }, { 5: [2, 56] }, { 5: [1, 105] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: $Vq, 20: 106, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 107, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 108, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 109, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 110, 47: $Vy, 49: $Vz }, { 5: $Vw, 30: $Vx, 46: 111, 47: $Vy, 49: $Vz }, o($VA, [2, 14]), o($VA, [2, 15]), o($VA, [2, 16]), o($VA, [2, 17]), o($VA, [2, 34]), o($VA, [2, 35])],
128 defaultActions: { 8: [2, 2], 12: [2, 1], 30: [2, 3], 31: [2, 8], 32: [2, 9], 33: [2, 10], 34: [2, 11], 35: [2, 12], 37: [2, 47], 38: [2, 48], 40: [2, 53], 41: [2, 54], 83: [2, 51], 84: [2, 52], 86: [2, 26], 87: [2, 27], 88: [2, 28], 90: [2, 29], 91: [2, 30], 92: [2, 31], 93: [2, 32], 95: [2, 55], 96: [2, 56], 98: [2, 57], 99: [2, 58] },
129 parseError: function parseError(str, hash) {
130 if (hash.recoverable) {
131 this.trace(str);
132 } else {
133 var error = new Error(str);
134 error.hash = hash;
135 throw error;
136 }
137 },
138 parse: function parse(input) {
139 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
140 var args = lstack.slice.call(arguments, 1);
141 var lexer2 = Object.create(this.lexer);
142 var sharedState = { yy: {} };
143 for (var k in this.yy) {
144 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
145 sharedState.yy[k] = this.yy[k];
146 }
147 }
148 lexer2.setInput(input, sharedState.yy);
149 sharedState.yy.lexer = lexer2;
150 sharedState.yy.parser = this;
151 if (typeof lexer2.yylloc == "undefined") {
152 lexer2.yylloc = {};
153 }
154 var yyloc = lexer2.yylloc;
155 lstack.push(yyloc);
156 var ranges = lexer2.options && lexer2.options.ranges;
157 if (typeof sharedState.yy.parseError === "function") {
158 this.parseError = sharedState.yy.parseError;
159 } else {
160 this.parseError = Object.getPrototypeOf(this).parseError;
161 }
162 function lex() {
163 var token;
164 token = tstack.pop() || lexer2.lex() || EOF;
165 if (typeof token !== "number") {
166 if (token instanceof Array) {
167 tstack = token;
168 token = tstack.pop();
169 }
170 token = self.symbols_[token] || token;
171 }
172 return token;
173 }
174 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
175 while (true) {
176 state = stack[stack.length - 1];
177 if (this.defaultActions[state]) {
178 action = this.defaultActions[state];
179 } else {
180 if (symbol === null || typeof symbol == "undefined") {
181 symbol = lex();
182 }
183 action = table[state] && table[state][symbol];
184 }
185 if (typeof action === "undefined" || !action.length || !action[0]) {
186 var errStr = "";
187 expected = [];
188 for (p in table[state]) {
189 if (this.terminals_[p] && p > TERROR) {
190 expected.push("'" + this.terminals_[p] + "'");
191 }
192 }
193 if (lexer2.showPosition) {
194 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
195 } else {
196 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
197 }
198 this.parseError(errStr, {
199 text: lexer2.match,
200 token: this.terminals_[symbol] || symbol,
201 line: lexer2.yylineno,
202 loc: yyloc,
203 expected
204 });
205 }
206 if (action[0] instanceof Array && action.length > 1) {
207 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
208 }
209 switch (action[0]) {
210 case 1:
211 stack.push(symbol);
212 vstack.push(lexer2.yytext);
213 lstack.push(lexer2.yylloc);
214 stack.push(action[1]);
215 symbol = null;
216 {
217 yyleng = lexer2.yyleng;
218 yytext = lexer2.yytext;
219 yylineno = lexer2.yylineno;
220 yyloc = lexer2.yylloc;
221 }
222 break;
223 case 2:
224 len = this.productions_[action[1]][1];
225 yyval.$ = vstack[vstack.length - len];
226 yyval._$ = {
227 first_line: lstack[lstack.length - (len || 1)].first_line,
228 last_line: lstack[lstack.length - 1].last_line,
229 first_column: lstack[lstack.length - (len || 1)].first_column,
230 last_column: lstack[lstack.length - 1].last_column
231 };
232 if (ranges) {
233 yyval._$.range = [
234 lstack[lstack.length - (len || 1)].range[0],
235 lstack[lstack.length - 1].range[1]
236 ];
237 }
238 r = this.performAction.apply(yyval, [
239 yytext,
240 yyleng,
241 yylineno,
242 sharedState.yy,
243 action[1],
244 vstack,
245 lstack
246 ].concat(args));
247 if (typeof r !== "undefined") {
248 return r;
249 }
250 if (len) {
251 stack = stack.slice(0, -1 * len * 2);
252 vstack = vstack.slice(0, -1 * len);
253 lstack = lstack.slice(0, -1 * len);
254 }
255 stack.push(this.productions_[action[1]][0]);
256 vstack.push(yyval.$);
257 lstack.push(yyval._$);
258 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
259 stack.push(newState);
260 break;
261 case 3:
262 return true;
263 }
264 }
265 return true;
266 }
267 };
268 var lexer = function() {
269 var lexer2 = {
270 EOF: 1,
271 parseError: function parseError(str, hash) {
272 if (this.yy.parser) {
273 this.yy.parser.parseError(str, hash);
274 } else {
275 throw new Error(str);
276 }
277 },
278 // resets the lexer, sets new input
279 setInput: function(input, yy) {
280 this.yy = yy || this.yy || {};
281 this._input = input;
282 this._more = this._backtrack = this.done = false;
283 this.yylineno = this.yyleng = 0;
284 this.yytext = this.matched = this.match = "";
285 this.conditionStack = ["INITIAL"];
286 this.yylloc = {
287 first_line: 1,
288 first_column: 0,
289 last_line: 1,
290 last_column: 0
291 };
292 if (this.options.ranges) {
293 this.yylloc.range = [0, 0];
294 }
295 this.offset = 0;
296 return this;
297 },
298 // consumes and returns one char from the input
299 input: function() {
300 var ch = this._input[0];
301 this.yytext += ch;
302 this.yyleng++;
303 this.offset++;
304 this.match += ch;
305 this.matched += ch;
306 var lines = ch.match(/(?:\r\n?|\n).*/g);
307 if (lines) {
308 this.yylineno++;
309 this.yylloc.last_line++;
310 } else {
311 this.yylloc.last_column++;
312 }
313 if (this.options.ranges) {
314 this.yylloc.range[1]++;
315 }
316 this._input = this._input.slice(1);
317 return ch;
318 },
319 // unshifts one char (or a string) into the input
320 unput: function(ch) {
321 var len = ch.length;
322 var lines = ch.split(/(?:\r\n?|\n)/g);
323 this._input = ch + this._input;
324 this.yytext = this.yytext.substr(0, this.yytext.length - len);
325 this.offset -= len;
326 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
327 this.match = this.match.substr(0, this.match.length - 1);
328 this.matched = this.matched.substr(0, this.matched.length - 1);
329 if (lines.length - 1) {
330 this.yylineno -= lines.length - 1;
331 }
332 var r = this.yylloc.range;
333 this.yylloc = {
334 first_line: this.yylloc.first_line,
335 last_line: this.yylineno + 1,
336 first_column: this.yylloc.first_column,
337 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
338 };
339 if (this.options.ranges) {
340 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
341 }
342 this.yyleng = this.yytext.length;
343 return this;
344 },
345 // When called from action, caches matched text and appends it on next action
346 more: function() {
347 this._more = true;
348 return this;
349 },
350 // 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.
351 reject: function() {
352 if (this.options.backtrack_lexer) {
353 this._backtrack = true;
354 } else {
355 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(), {
356 text: "",
357 token: null,
358 line: this.yylineno
359 });
360 }
361 return this;
362 },
363 // retain first n characters of the match
364 less: function(n) {
365 this.unput(this.match.slice(n));
366 },
367 // displays already matched input, i.e. for error messages
368 pastInput: function() {
369 var past = this.matched.substr(0, this.matched.length - this.match.length);
370 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
371 },
372 // displays upcoming input, i.e. for error messages
373 upcomingInput: function() {
374 var next = this.match;
375 if (next.length < 20) {
376 next += this._input.substr(0, 20 - next.length);
377 }
378 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
379 },
380 // displays the character position where the lexing error occurred, i.e. for error messages
381 showPosition: function() {
382 var pre = this.pastInput();
383 var c = new Array(pre.length + 1).join("-");
384 return pre + this.upcomingInput() + "\n" + c + "^";
385 },
386 // test the lexed token: return FALSE when not a match, otherwise return token
387 test_match: function(match, indexed_rule) {
388 var token, lines, backup;
389 if (this.options.backtrack_lexer) {
390 backup = {
391 yylineno: this.yylineno,
392 yylloc: {
393 first_line: this.yylloc.first_line,
394 last_line: this.last_line,
395 first_column: this.yylloc.first_column,
396 last_column: this.yylloc.last_column
397 },
398 yytext: this.yytext,
399 match: this.match,
400 matches: this.matches,
401 matched: this.matched,
402 yyleng: this.yyleng,
403 offset: this.offset,
404 _more: this._more,
405 _input: this._input,
406 yy: this.yy,
407 conditionStack: this.conditionStack.slice(0),
408 done: this.done
409 };
410 if (this.options.ranges) {
411 backup.yylloc.range = this.yylloc.range.slice(0);
412 }
413 }
414 lines = match[0].match(/(?:\r\n?|\n).*/g);
415 if (lines) {
416 this.yylineno += lines.length;
417 }
418 this.yylloc = {
419 first_line: this.yylloc.last_line,
420 last_line: this.yylineno + 1,
421 first_column: this.yylloc.last_column,
422 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
423 };
424 this.yytext += match[0];
425 this.match += match[0];
426 this.matches = match;
427 this.yyleng = this.yytext.length;
428 if (this.options.ranges) {
429 this.yylloc.range = [this.offset, this.offset += this.yyleng];
430 }
431 this._more = false;
432 this._backtrack = false;
433 this._input = this._input.slice(match[0].length);
434 this.matched += match[0];
435 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
436 if (this.done && this._input) {
437 this.done = false;
438 }
439 if (token) {
440 return token;
441 } else if (this._backtrack) {
442 for (var k in backup) {
443 this[k] = backup[k];
444 }
445 return false;
446 }
447 return false;
448 },
449 // return next match in input
450 next: function() {
451 if (this.done) {
452 return this.EOF;
453 }
454 if (!this._input) {
455 this.done = true;
456 }
457 var token, match, tempMatch, index;
458 if (!this._more) {
459 this.yytext = "";
460 this.match = "";
461 }
462 var rules = this._currentRules();
463 for (var i = 0; i < rules.length; i++) {
464 tempMatch = this._input.match(this.rules[rules[i]]);
465 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
466 match = tempMatch;
467 index = i;
468 if (this.options.backtrack_lexer) {
469 token = this.test_match(tempMatch, rules[i]);
470 if (token !== false) {
471 return token;
472 } else if (this._backtrack) {
473 match = false;
474 continue;
475 } else {
476 return false;
477 }
478 } else if (!this.options.flex) {
479 break;
480 }
481 }
482 }
483 if (match) {
484 token = this.test_match(match, rules[index]);
485 if (token !== false) {
486 return token;
487 }
488 return false;
489 }
490 if (this._input === "") {
491 return this.EOF;
492 } else {
493 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
494 text: "",
495 token: null,
496 line: this.yylineno
497 });
498 }
499 },
500 // return next match that has a token
501 lex: function lex() {
502 var r = this.next();
503 if (r) {
504 return r;
505 } else {
506 return this.lex();
507 }
508 },
509 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
510 begin: function begin(condition) {
511 this.conditionStack.push(condition);
512 },
513 // pop the previously active lexer condition state off the condition stack
514 popState: function popState() {
515 var n = this.conditionStack.length - 1;
516 if (n > 0) {
517 return this.conditionStack.pop();
518 } else {
519 return this.conditionStack[0];
520 }
521 },
522 // produce the lexer rule set which is active for the currently active lexer condition state
523 _currentRules: function _currentRules() {
524 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
525 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
526 } else {
527 return this.conditions["INITIAL"].rules;
528 }
529 },
530 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
531 topState: function topState(n) {
532 n = this.conditionStack.length - 1 - Math.abs(n || 0);
533 if (n >= 0) {
534 return this.conditionStack[n];
535 } else {
536 return "INITIAL";
537 }
538 },
539 // alias for begin(condition)
540 pushState: function pushState(condition) {
541 this.begin(condition);
542 },
543 // return the number of states currently on the stack
544 stateStackSize: function stateStackSize() {
545 return this.conditionStack.length;
546 },
547 options: { "case-insensitive": true },
548 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
549 switch ($avoiding_name_collisions) {
550 case 0:
551 return "title";
552 case 1:
553 this.begin("acc_title");
554 return 9;
555 case 2:
556 this.popState();
557 return "acc_title_value";
558 case 3:
559 this.begin("acc_descr");
560 return 11;
561 case 4:
562 this.popState();
563 return "acc_descr_value";
564 case 5:
565 this.begin("acc_descr_multiline");
566 break;
567 case 6:
568 this.popState();
569 break;
570 case 7:
571 return "acc_descr_multiline_value";
572 case 8:
573 return 5;
574 case 9:
575 break;
576 case 10:
577 break;
578 case 11:
579 break;
580 case 12:
581 return 8;
582 case 13:
583 return 6;
584 case 14:
585 return 19;
586 case 15:
587 return 30;
588 case 16:
589 return 22;
590 case 17:
591 return 21;
592 case 18:
593 return 24;
594 case 19:
595 return 26;
596 case 20:
597 return 28;
598 case 21:
599 return 31;
600 case 22:
601 return 32;
602 case 23:
603 return 33;
604 case 24:
605 return 34;
606 case 25:
607 return 35;
608 case 26:
609 return 36;
610 case 27:
611 return 37;
612 case 28:
613 return 38;
614 case 29:
615 return 39;
616 case 30:
617 return 40;
618 case 31:
619 return 41;
620 case 32:
621 return 42;
622 case 33:
623 return 43;
624 case 34:
625 return 44;
626 case 35:
627 return 55;
628 case 36:
629 return 56;
630 case 37:
631 return 57;
632 case 38:
633 return 58;
634 case 39:
635 return 59;
636 case 40:
637 return 60;
638 case 41:
639 return 61;
640 case 42:
641 return 47;
642 case 43:
643 return 49;
644 case 44:
645 return 51;
646 case 45:
647 return 54;
648 case 46:
649 return 53;
650 case 47:
651 this.begin("string");
652 break;
653 case 48:
654 this.popState();
655 break;
656 case 49:
657 return "qString";
658 case 50:
659 yy_.yytext = yy_.yytext.trim();
660 return 62;
661 }
662 },
663 rules: [/^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:$)/i, /^(?:requirementDiagram\b)/i, /^(?:\{)/i, /^(?:\})/i, /^(?::)/i, /^(?:id\b)/i, /^(?:text\b)/i, /^(?:risk\b)/i, /^(?:verifyMethod\b)/i, /^(?:requirement\b)/i, /^(?:functionalRequirement\b)/i, /^(?:interfaceRequirement\b)/i, /^(?:performanceRequirement\b)/i, /^(?:physicalRequirement\b)/i, /^(?:designConstraint\b)/i, /^(?:low\b)/i, /^(?:medium\b)/i, /^(?:high\b)/i, /^(?:analysis\b)/i, /^(?:demonstration\b)/i, /^(?:inspection\b)/i, /^(?:test\b)/i, /^(?:element\b)/i, /^(?:contains\b)/i, /^(?:copies\b)/i, /^(?:derives\b)/i, /^(?:satisfies\b)/i, /^(?:verifies\b)/i, /^(?:refines\b)/i, /^(?:traces\b)/i, /^(?:type\b)/i, /^(?:docref\b)/i, /^(?:<-)/i, /^(?:->)/i, /^(?:-)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[\w][^\r\n\{\<\>\-\=]*)/i],
664 conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "unqString": { "rules": [], "inclusive": false }, "token": { "rules": [], "inclusive": false }, "string": { "rules": [48, 49], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 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, 50], "inclusive": true } }
665 };
666 return lexer2;
667 }();
668 parser2.lexer = lexer;
669 function Parser() {
670 this.yy = {};
671 }
672 Parser.prototype = parser2;
673 parser2.Parser = Parser;
674 return new Parser();
675}();
676parser.parser = parser;
677const parser$1 = parser;
678let relations = [];
679let latestRequirement = {};
680let requirements = {};
681let latestElement = {};
682let elements = {};
683const RequirementType = {
684 REQUIREMENT: "Requirement",
685 FUNCTIONAL_REQUIREMENT: "Functional Requirement",
686 INTERFACE_REQUIREMENT: "Interface Requirement",
687 PERFORMANCE_REQUIREMENT: "Performance Requirement",
688 PHYSICAL_REQUIREMENT: "Physical Requirement",
689 DESIGN_CONSTRAINT: "Design Constraint"
690};
691const RiskLevel = {
692 LOW_RISK: "Low",
693 MED_RISK: "Medium",
694 HIGH_RISK: "High"
695};
696const VerifyType = {
697 VERIFY_ANALYSIS: "Analysis",
698 VERIFY_DEMONSTRATION: "Demonstration",
699 VERIFY_INSPECTION: "Inspection",
700 VERIFY_TEST: "Test"
701};
702const Relationships = {
703 CONTAINS: "contains",
704 COPIES: "copies",
705 DERIVES: "derives",
706 SATISFIES: "satisfies",
707 VERIFIES: "verifies",
708 REFINES: "refines",
709 TRACES: "traces"
710};
711const addRequirement = (name, type) => {
712 if (requirements[name] === void 0) {
713 requirements[name] = {
714 name,
715 type,
716 id: latestRequirement.id,
717 text: latestRequirement.text,
718 risk: latestRequirement.risk,
719 verifyMethod: latestRequirement.verifyMethod
720 };
721 }
722 latestRequirement = {};
723 return requirements[name];
724};
725const getRequirements = () => requirements;
726const setNewReqId = (id) => {
727 if (latestRequirement !== void 0) {
728 latestRequirement.id = id;
729 }
730};
731const setNewReqText = (text) => {
732 if (latestRequirement !== void 0) {
733 latestRequirement.text = text;
734 }
735};
736const setNewReqRisk = (risk) => {
737 if (latestRequirement !== void 0) {
738 latestRequirement.risk = risk;
739 }
740};
741const setNewReqVerifyMethod = (verifyMethod) => {
742 if (latestRequirement !== void 0) {
743 latestRequirement.verifyMethod = verifyMethod;
744 }
745};
746const addElement = (name) => {
747 if (elements[name] === void 0) {
748 elements[name] = {
749 name,
750 type: latestElement.type,
751 docRef: latestElement.docRef
752 };
753 log.info("Added new requirement: ", name);
754 }
755 latestElement = {};
756 return elements[name];
757};
758const getElements = () => elements;
759const setNewElementType = (type) => {
760 if (latestElement !== void 0) {
761 latestElement.type = type;
762 }
763};
764const setNewElementDocRef = (docRef) => {
765 if (latestElement !== void 0) {
766 latestElement.docRef = docRef;
767 }
768};
769const addRelationship = (type, src, dst) => {
770 relations.push({
771 type,
772 src,
773 dst
774 });
775};
776const getRelationships = () => relations;
777const clear = () => {
778 relations = [];
779 latestRequirement = {};
780 requirements = {};
781 latestElement = {};
782 elements = {};
783 clear$1();
784};
785const db = {
786 RequirementType,
787 RiskLevel,
788 VerifyType,
789 Relationships,
790 getConfig: () => getConfig().req,
791 addRequirement,
792 getRequirements,
793 setNewReqId,
794 setNewReqText,
795 setNewReqRisk,
796 setNewReqVerifyMethod,
797 setAccTitle,
798 getAccTitle,
799 setAccDescription,
800 getAccDescription,
801 addElement,
802 getElements,
803 setNewElementType,
804 setNewElementDocRef,
805 addRelationship,
806 getRelationships,
807 clear
808};
809const getStyles = (options) => `
810
811 marker {
812 fill: ${options.relationColor};
813 stroke: ${options.relationColor};
814 }
815
816 marker.cross {
817 stroke: ${options.lineColor};
818 }
819
820 svg {
821 font-family: ${options.fontFamily};
822 font-size: ${options.fontSize};
823 }
824
825 .reqBox {
826 fill: ${options.requirementBackground};
827 fill-opacity: 1.0;
828 stroke: ${options.requirementBorderColor};
829 stroke-width: ${options.requirementBorderSize};
830 }
831
832 .reqTitle, .reqLabel{
833 fill: ${options.requirementTextColor};
834 }
835 .reqLabelBox {
836 fill: ${options.relationLabelBackground};
837 fill-opacity: 1.0;
838 }
839
840 .req-title-line {
841 stroke: ${options.requirementBorderColor};
842 stroke-width: ${options.requirementBorderSize};
843 }
844 .relationshipLine {
845 stroke: ${options.relationColor};
846 stroke-width: 1;
847 }
848 .relationshipLabel {
849 fill: ${options.relationLabelColor};
850 }
851
852`;
853const styles = getStyles;
854const ReqMarkers = {
855 CONTAINS: "contains",
856 ARROW: "arrow"
857};
858const insertLineEndings = (parentNode, conf2) => {
859 let containsNode = parentNode.append("defs").append("marker").attr("id", ReqMarkers.CONTAINS + "_line_ending").attr("refX", 0).attr("refY", conf2.line_height / 2).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("g");
860 containsNode.append("circle").attr("cx", conf2.line_height / 2).attr("cy", conf2.line_height / 2).attr("r", conf2.line_height / 2).attr("fill", "none");
861 containsNode.append("line").attr("x1", 0).attr("x2", conf2.line_height).attr("y1", conf2.line_height / 2).attr("y2", conf2.line_height / 2).attr("stroke-width", 1);
862 containsNode.append("line").attr("y1", 0).attr("y2", conf2.line_height).attr("x1", conf2.line_height / 2).attr("x2", conf2.line_height / 2).attr("stroke-width", 1);
863 parentNode.append("defs").append("marker").attr("id", ReqMarkers.ARROW + "_line_ending").attr("refX", conf2.line_height).attr("refY", 0.5 * conf2.line_height).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("path").attr(
864 "d",
865 `M0,0
866 L${conf2.line_height},${conf2.line_height / 2}
867 M${conf2.line_height},${conf2.line_height / 2}
868 L0,${conf2.line_height}`
869 ).attr("stroke-width", 1);
870};
871const markers = {
872 ReqMarkers,
873 insertLineEndings
874};
875let conf = {};
876let relCnt = 0;
877const newRectNode = (parentNode, id) => {
878 return parentNode.insert("rect", "#" + id).attr("class", "req reqBox").attr("x", 0).attr("y", 0).attr("width", conf.rect_min_width + "px").attr("height", conf.rect_min_height + "px");
879};
880const newTitleNode = (parentNode, id, txts) => {
881 let x = conf.rect_min_width / 2;
882 let title = parentNode.append("text").attr("class", "req reqLabel reqTitle").attr("id", id).attr("x", x).attr("y", conf.rect_padding).attr("dominant-baseline", "hanging");
883 let i = 0;
884 txts.forEach((textStr) => {
885 if (i == 0) {
886 title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", 0).text(textStr);
887 } else {
888 title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", conf.line_height * 0.75).text(textStr);
889 }
890 i++;
891 });
892 let yPadding = 1.5 * conf.rect_padding;
893 let linePadding = i * conf.line_height * 0.75;
894 let totalY = yPadding + linePadding;
895 parentNode.append("line").attr("class", "req-title-line").attr("x1", "0").attr("x2", conf.rect_min_width).attr("y1", totalY).attr("y2", totalY);
896 return {
897 titleNode: title,
898 y: totalY
899 };
900};
901const newBodyNode = (parentNode, id, txts, yStart) => {
902 let body = parentNode.append("text").attr("class", "req reqLabel").attr("id", id).attr("x", conf.rect_padding).attr("y", yStart).attr("dominant-baseline", "hanging");
903 let currentRow = 0;
904 const charLimit = 30;
905 let wrappedTxts = [];
906 txts.forEach((textStr) => {
907 let currentTextLen = textStr.length;
908 while (currentTextLen > charLimit && currentRow < 3) {
909 let firstPart = textStr.substring(0, charLimit);
910 textStr = textStr.substring(charLimit, textStr.length);
911 currentTextLen = textStr.length;
912 wrappedTxts[wrappedTxts.length] = firstPart;
913 currentRow++;
914 }
915 if (currentRow == 3) {
916 let lastStr = wrappedTxts[wrappedTxts.length - 1];
917 wrappedTxts[wrappedTxts.length - 1] = lastStr.substring(0, lastStr.length - 4) + "...";
918 } else {
919 wrappedTxts[wrappedTxts.length] = textStr;
920 }
921 currentRow = 0;
922 });
923 wrappedTxts.forEach((textStr) => {
924 body.append("tspan").attr("x", conf.rect_padding).attr("dy", conf.line_height).text(textStr);
925 });
926 return body;
927};
928const addEdgeLabel = (parentNode, svgPath, conf2, txt) => {
929 const len = svgPath.node().getTotalLength();
930 const labelPoint = svgPath.node().getPointAtLength(len * 0.5);
931 const labelId = "rel" + relCnt;
932 relCnt++;
933 const labelNode = parentNode.append("text").attr("class", "req relationshipLabel").attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(txt);
934 const labelBBox = labelNode.node().getBBox();
935 parentNode.insert("rect", "#" + labelId).attr("class", "req reqLabelBox").attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height).attr("fill", "white").attr("fill-opacity", "85%");
936};
937const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) {
938 const edge = g.edge(elementString(rel.src), elementString(rel.dst));
939 const lineFunction = line().x(function(d) {
940 return d.x;
941 }).y(function(d) {
942 return d.y;
943 });
944 const svgPath = svg.insert("path", "#" + insert).attr("class", "er relationshipLine").attr("d", lineFunction(edge.points)).attr("fill", "none");
945 if (rel.type == diagObj.db.Relationships.CONTAINS) {
946 svgPath.attr(
947 "marker-start",
948 "url(" + common.getUrl(conf.arrowMarkerAbsolute) + "#" + rel.type + "_line_ending)"
949 );
950 } else {
951 svgPath.attr("stroke-dasharray", "10,7");
952 svgPath.attr(
953 "marker-end",
954 "url(" + common.getUrl(conf.arrowMarkerAbsolute) + "#" + markers.ReqMarkers.ARROW + "_line_ending)"
955 );
956 }
957 addEdgeLabel(svg, svgPath, conf, `<<${rel.type}>>`);
958 return;
959};
960const drawReqs = (reqs, graph, svgNode) => {
961 Object.keys(reqs).forEach((reqName) => {
962 let req = reqs[reqName];
963 reqName = elementString(reqName);
964 log.info("Added new requirement: ", reqName);
965 const groupNode = svgNode.append("g").attr("id", reqName);
966 const textId = "req-" + reqName;
967 const rectNode = newRectNode(groupNode, textId);
968 let titleNodeInfo = newTitleNode(groupNode, reqName + "_title", [
969 `<<${req.type}>>`,
970 `${req.name}`
971 ]);
972 newBodyNode(
973 groupNode,
974 reqName + "_body",
975 [
976 `Id: ${req.id}`,
977 `Text: ${req.text}`,
978 `Risk: ${req.risk}`,
979 `Verification: ${req.verifyMethod}`
980 ],
981 titleNodeInfo.y
982 );
983 const rectBBox = rectNode.node().getBBox();
984 graph.setNode(reqName, {
985 width: rectBBox.width,
986 height: rectBBox.height,
987 shape: "rect",
988 id: reqName
989 });
990 });
991};
992const drawElements = (els, graph, svgNode) => {
993 Object.keys(els).forEach((elName) => {
994 let el = els[elName];
995 const id = elementString(elName);
996 const groupNode = svgNode.append("g").attr("id", id);
997 const textId = "element-" + id;
998 const rectNode = newRectNode(groupNode, textId);
999 let titleNodeInfo = newTitleNode(groupNode, textId + "_title", [`<<Element>>`, `${elName}`]);
1000 newBodyNode(
1001 groupNode,
1002 textId + "_body",
1003 [`Type: ${el.type || "Not Specified"}`, `Doc Ref: ${el.docRef || "None"}`],
1004 titleNodeInfo.y
1005 );
1006 const rectBBox = rectNode.node().getBBox();
1007 graph.setNode(id, {
1008 width: rectBBox.width,
1009 height: rectBBox.height,
1010 shape: "rect",
1011 id
1012 });
1013 });
1014};
1015const addRelationships = (relationships, g) => {
1016 relationships.forEach(function(r) {
1017 let src = elementString(r.src);
1018 let dst = elementString(r.dst);
1019 g.setEdge(src, dst, { relationship: r });
1020 });
1021 return relationships;
1022};
1023const adjustEntities = function(svgNode, graph) {
1024 graph.nodes().forEach(function(v) {
1025 if (v !== void 0 && graph.node(v) !== void 0) {
1026 svgNode.select("#" + v);
1027 svgNode.select("#" + v).attr(
1028 "transform",
1029 "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )"
1030 );
1031 }
1032 });
1033 return;
1034};
1035const elementString = (str) => {
1036 return str.replace(/\s/g, "").replace(/\./g, "_");
1037};
1038const draw = (text, id, _version, diagObj) => {
1039 conf = getConfig().requirement;
1040 const securityLevel = conf.securityLevel;
1041 let sandboxElement;
1042 if (securityLevel === "sandbox") {
1043 sandboxElement = d3select("#i" + id);
1044 }
1045 const root = securityLevel === "sandbox" ? d3select(sandboxElement.nodes()[0].contentDocument.body) : d3select("body");
1046 const svg = root.select(`[id='${id}']`);
1047 markers.insertLineEndings(svg, conf);
1048 const g = new Graph({
1049 multigraph: false,
1050 compound: false,
1051 directed: true
1052 }).setGraph({
1053 rankdir: conf.layoutDirection,
1054 marginx: 20,
1055 marginy: 20,
1056 nodesep: 100,
1057 edgesep: 100,
1058 ranksep: 100
1059 }).setDefaultEdgeLabel(function() {
1060 return {};
1061 });
1062 let requirements2 = diagObj.db.getRequirements();
1063 let elements2 = diagObj.db.getElements();
1064 let relationships = diagObj.db.getRelationships();
1065 drawReqs(requirements2, g, svg);
1066 drawElements(elements2, g, svg);
1067 addRelationships(relationships, g);
1068 layout(g);
1069 adjustEntities(svg, g);
1070 relationships.forEach(function(rel) {
1071 drawRelationshipFromLayout(svg, rel, g, id, diagObj);
1072 });
1073 const padding = conf.rect_padding;
1074 const svgBounds = svg.node().getBBox();
1075 const width = svgBounds.width + padding * 2;
1076 const height = svgBounds.height + padding * 2;
1077 configureSvgSize(svg, height, width, conf.useMaxWidth);
1078 svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
1079};
1080const renderer = {
1081 draw
1082};
1083const diagram = {
1084 parser: parser$1,
1085 db,
1086 renderer,
1087 styles
1088};
1089export {
1090 diagram
1091};
1092
\No newline at end of file