UNPKG

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