UNPKG

134 kBJavaScriptView Raw
1import { g as getAccTitle, t as getDiagramTitle, r as setDiagramTitle, c as getConfig, s as setAccTitle, b as setAccDescription, a as getAccDescription, m as mermaidAPI, v as clear$1, l as log, d as sanitizeText, e as common, B as parseFontSize, E as addFunction, f as assignWithDepth, i as configureSvgSize, u as utils } from "./mermaid-a953d906.js";
2import { select, selectAll } from "d3";
3import { d as drawRect$1, a as drawBackgroundRect$1, b as drawEmbeddedImage, c as drawImage, e as getTextObj$1, g as getNoteRect$1 } from "./svgDrawCommon-f26cad39.js";
4import { sanitizeUrl } from "@braintree/sanitize-url";
5import "ts-dedent";
6import "dayjs/esm/index.js";
7import "dompurify";
8import "khroma";
9import "lodash-es/memoize.js";
10import "stylis";
11import "lodash-es/isEmpty.js";
12var parser = function() {
13 var o = function(k, v, o2, l) {
14 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
15 ;
16 return o2;
17 }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 7], $V4 = [2, 5], $V5 = [1, 15], $V6 = [1, 17], $V7 = [1, 19], $V8 = [1, 21], $V9 = [1, 22], $Va = [1, 23], $Vb = [1, 29], $Vc = [1, 30], $Vd = [1, 31], $Ve = [1, 32], $Vf = [1, 33], $Vg = [1, 34], $Vh = [1, 35], $Vi = [1, 36], $Vj = [1, 37], $Vk = [1, 38], $Vl = [1, 39], $Vm = [1, 40], $Vn = [1, 41], $Vo = [1, 43], $Vp = [1, 44], $Vq = [1, 46], $Vr = [1, 47], $Vs = [1, 48], $Vt = [1, 49], $Vu = [1, 50], $Vv = [1, 51], $Vw = [1, 54], $Vx = [1, 4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 52, 53, 54, 55, 57, 58, 63, 64, 65, 66, 74, 84], $Vy = [4, 5, 21, 55, 57], $Vz = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VA = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 54, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VB = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 53, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VC = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 52, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VD = [72, 73, 74], $VE = [1, 128], $VF = [1, 4, 5, 7, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 52, 53, 54, 55, 57, 58, 63, 64, 65, 66, 74, 84];
18 var parser2 = {
19 trace: function trace() {
20 },
21 yy: {},
22 symbols_: { "error": 2, "start": 3, "SPACE": 4, "NEWLINE": 5, "directive": 6, "SD": 7, "document": 8, "line": 9, "statement": 10, "box_section": 11, "box_line": 12, "participant_statement": 13, "openDirective": 14, "typeDirective": 15, "closeDirective": 16, ":": 17, "argDirective": 18, "box": 19, "restOfLine": 20, "end": 21, "signal": 22, "autonumber": 23, "NUM": 24, "off": 25, "activate": 26, "actor": 27, "deactivate": 28, "note_statement": 29, "links_statement": 30, "link_statement": 31, "properties_statement": 32, "details_statement": 33, "title": 34, "legacy_title": 35, "acc_title": 36, "acc_title_value": 37, "acc_descr": 38, "acc_descr_value": 39, "acc_descr_multiline_value": 40, "loop": 41, "rect": 42, "opt": 43, "alt": 44, "else_sections": 45, "par": 46, "par_sections": 47, "par_over": 48, "critical": 49, "option_sections": 50, "break": 51, "option": 52, "and": 53, "else": 54, "participant": 55, "AS": 56, "participant_actor": 57, "note": 58, "placement": 59, "text2": 60, "over": 61, "actor_pair": 62, "links": 63, "link": 64, "properties": 65, "details": 66, "spaceList": 67, ",": 68, "left_of": 69, "right_of": 70, "signaltype": 71, "+": 72, "-": 73, "ACTOR": 74, "SOLID_OPEN_ARROW": 75, "DOTTED_OPEN_ARROW": 76, "SOLID_ARROW": 77, "DOTTED_ARROW": 78, "SOLID_CROSS": 79, "DOTTED_CROSS": 80, "SOLID_POINT": 81, "DOTTED_POINT": 82, "TXT": 83, "open_directive": 84, "type_directive": 85, "arg_directive": 86, "close_directive": 87, "$accept": 0, "$end": 1 },
23 terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 7: "SD", 17: ":", 19: "box", 20: "restOfLine", 21: "end", 23: "autonumber", 24: "NUM", 25: "off", 26: "activate", 28: "deactivate", 34: "title", 35: "legacy_title", 36: "acc_title", 37: "acc_title_value", 38: "acc_descr", 39: "acc_descr_value", 40: "acc_descr_multiline_value", 41: "loop", 42: "rect", 43: "opt", 44: "alt", 46: "par", 48: "par_over", 49: "critical", 51: "break", 52: "option", 53: "and", 54: "else", 55: "participant", 56: "AS", 57: "participant_actor", 58: "note", 61: "over", 63: "links", 64: "link", 65: "properties", 66: "details", 68: ",", 69: "left_of", 70: "right_of", 72: "+", 73: "-", 74: "ACTOR", 75: "SOLID_OPEN_ARROW", 76: "DOTTED_OPEN_ARROW", 77: "SOLID_ARROW", 78: "DOTTED_ARROW", 79: "SOLID_CROSS", 80: "DOTTED_CROSS", 81: "SOLID_POINT", 82: "DOTTED_POINT", 83: "TXT", 84: "open_directive", 85: "type_directive", 86: "arg_directive", 87: "close_directive" },
24 productions_: [0, [3, 2], [3, 2], [3, 2], [3, 2], [8, 0], [8, 2], [9, 2], [9, 1], [9, 1], [11, 0], [11, 2], [12, 2], [12, 1], [12, 1], [6, 4], [6, 6], [10, 1], [10, 4], [10, 2], [10, 4], [10, 3], [10, 3], [10, 2], [10, 3], [10, 3], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 1], [50, 1], [50, 4], [47, 1], [47, 4], [45, 1], [45, 4], [13, 5], [13, 3], [13, 5], [13, 3], [29, 4], [29, 4], [30, 3], [31, 3], [32, 3], [33, 3], [67, 2], [67, 1], [62, 3], [62, 1], [59, 1], [59, 1], [22, 5], [22, 5], [22, 4], [27, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [60, 1], [14, 1], [15, 1], [18, 1], [16, 1]],
25 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
26 var $0 = $$.length - 1;
27 switch (yystate) {
28 case 4:
29 yy.apply($$[$0]);
30 return $$[$0];
31 case 5:
32 case 10:
33 this.$ = [];
34 break;
35 case 6:
36 case 11:
37 $$[$0 - 1].push($$[$0]);
38 this.$ = $$[$0 - 1];
39 break;
40 case 7:
41 case 8:
42 case 12:
43 case 13:
44 this.$ = $$[$0];
45 break;
46 case 9:
47 case 14:
48 this.$ = [];
49 break;
50 case 18:
51 $$[$0 - 1].unshift({ type: "boxStart", boxData: yy.parseBoxData($$[$0 - 2]) });
52 $$[$0 - 1].push({ type: "boxEnd", boxText: $$[$0 - 2] });
53 this.$ = $$[$0 - 1];
54 break;
55 case 20:
56 this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 2]), sequenceIndexStep: Number($$[$0 - 1]), sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
57 break;
58 case 21:
59 this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 1]), sequenceIndexStep: 1, sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
60 break;
61 case 22:
62 this.$ = { type: "sequenceIndex", sequenceVisible: false, signalType: yy.LINETYPE.AUTONUMBER };
63 break;
64 case 23:
65 this.$ = { type: "sequenceIndex", sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
66 break;
67 case 24:
68 this.$ = { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] };
69 break;
70 case 25:
71 this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1] };
72 break;
73 case 31:
74 yy.setDiagramTitle($$[$0].substring(6));
75 this.$ = $$[$0].substring(6);
76 break;
77 case 32:
78 yy.setDiagramTitle($$[$0].substring(7));
79 this.$ = $$[$0].substring(7);
80 break;
81 case 33:
82 this.$ = $$[$0].trim();
83 yy.setAccTitle(this.$);
84 break;
85 case 34:
86 case 35:
87 this.$ = $$[$0].trim();
88 yy.setAccDescription(this.$);
89 break;
90 case 36:
91 $$[$0 - 1].unshift({ type: "loopStart", loopText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.LOOP_START });
92 $$[$0 - 1].push({ type: "loopEnd", loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END });
93 this.$ = $$[$0 - 1];
94 break;
95 case 37:
96 $$[$0 - 1].unshift({ type: "rectStart", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_START });
97 $$[$0 - 1].push({ type: "rectEnd", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_END });
98 this.$ = $$[$0 - 1];
99 break;
100 case 38:
101 $$[$0 - 1].unshift({ type: "optStart", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_START });
102 $$[$0 - 1].push({ type: "optEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_END });
103 this.$ = $$[$0 - 1];
104 break;
105 case 39:
106 $$[$0 - 1].unshift({ type: "altStart", altText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.ALT_START });
107 $$[$0 - 1].push({ type: "altEnd", signalType: yy.LINETYPE.ALT_END });
108 this.$ = $$[$0 - 1];
109 break;
110 case 40:
111 $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_START });
112 $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END });
113 this.$ = $$[$0 - 1];
114 break;
115 case 41:
116 $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_OVER_START });
117 $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END });
118 this.$ = $$[$0 - 1];
119 break;
120 case 42:
121 $$[$0 - 1].unshift({ type: "criticalStart", criticalText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.CRITICAL_START });
122 $$[$0 - 1].push({ type: "criticalEnd", signalType: yy.LINETYPE.CRITICAL_END });
123 this.$ = $$[$0 - 1];
124 break;
125 case 43:
126 $$[$0 - 1].unshift({ type: "breakStart", breakText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_START });
127 $$[$0 - 1].push({ type: "breakEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_END });
128 this.$ = $$[$0 - 1];
129 break;
130 case 46:
131 this.$ = $$[$0 - 3].concat([{ type: "option", optionText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.CRITICAL_OPTION }, $$[$0]]);
132 break;
133 case 48:
134 this.$ = $$[$0 - 3].concat([{ type: "and", parText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.PAR_AND }, $$[$0]]);
135 break;
136 case 50:
137 this.$ = $$[$0 - 3].concat([{ type: "else", altText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.ALT_ELSE }, $$[$0]]);
138 break;
139 case 51:
140 $$[$0 - 3].type = "addParticipant";
141 $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]);
142 this.$ = $$[$0 - 3];
143 break;
144 case 52:
145 $$[$0 - 1].type = "addParticipant";
146 this.$ = $$[$0 - 1];
147 break;
148 case 53:
149 $$[$0 - 3].type = "addActor";
150 $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]);
151 this.$ = $$[$0 - 3];
152 break;
153 case 54:
154 $$[$0 - 1].type = "addActor";
155 this.$ = $$[$0 - 1];
156 break;
157 case 55:
158 this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }];
159 break;
160 case 56:
161 $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2);
162 $$[$0 - 2][0] = $$[$0 - 2][0].actor;
163 $$[$0 - 2][1] = $$[$0 - 2][1].actor;
164 this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }];
165 break;
166 case 57:
167 this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }];
168 break;
169 case 58:
170 this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }];
171 break;
172 case 59:
173 this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }];
174 break;
175 case 60:
176 this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }];
177 break;
178 case 63:
179 this.$ = [$$[$0 - 2], $$[$0]];
180 break;
181 case 64:
182 this.$ = $$[$0];
183 break;
184 case 65:
185 this.$ = yy.PLACEMENT.LEFTOF;
186 break;
187 case 66:
188 this.$ = yy.PLACEMENT.RIGHTOF;
189 break;
190 case 67:
191 this.$ = [
192 $$[$0 - 4],
193 $$[$0 - 1],
194 { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] },
195 { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] }
196 ];
197 break;
198 case 68:
199 this.$ = [
200 $$[$0 - 4],
201 $$[$0 - 1],
202 { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] },
203 { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4] }
204 ];
205 break;
206 case 69:
207 this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }];
208 break;
209 case 70:
210 this.$ = { type: "addParticipant", actor: $$[$0] };
211 break;
212 case 71:
213 this.$ = yy.LINETYPE.SOLID_OPEN;
214 break;
215 case 72:
216 this.$ = yy.LINETYPE.DOTTED_OPEN;
217 break;
218 case 73:
219 this.$ = yy.LINETYPE.SOLID;
220 break;
221 case 74:
222 this.$ = yy.LINETYPE.DOTTED;
223 break;
224 case 75:
225 this.$ = yy.LINETYPE.SOLID_CROSS;
226 break;
227 case 76:
228 this.$ = yy.LINETYPE.DOTTED_CROSS;
229 break;
230 case 77:
231 this.$ = yy.LINETYPE.SOLID_POINT;
232 break;
233 case 78:
234 this.$ = yy.LINETYPE.DOTTED_POINT;
235 break;
236 case 79:
237 this.$ = yy.parseMessage($$[$0].trim().substring(1));
238 break;
239 case 80:
240 yy.parseDirective("%%{", "open_directive");
241 break;
242 case 81:
243 yy.parseDirective($$[$0], "type_directive");
244 break;
245 case 82:
246 $$[$0] = $$[$0].trim().replace(/'/g, '"');
247 yy.parseDirective($$[$0], "arg_directive");
248 break;
249 case 83:
250 yy.parseDirective("}%%", "close_directive", "sequence");
251 break;
252 }
253 },
254 table: [{ 3: 1, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, { 1: [3] }, { 3: 8, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, { 3: 9, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, { 3: 10, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, o([1, 4, 5, 19, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 55, 57, 58, 63, 64, 65, 66, 74, 84], $V4, { 8: 11 }), { 15: 12, 85: [1, 13] }, { 85: [2, 80] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3] }, { 1: [2, 4], 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 16: 52, 17: [1, 53], 87: $Vw }, o([17, 87], [2, 81]), o($Vx, [2, 6]), { 6: 42, 10: 55, 13: 18, 14: 6, 19: $V7, 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, o($Vx, [2, 8]), o($Vx, [2, 9]), o($Vx, [2, 17]), { 20: [1, 56] }, { 5: [1, 57] }, { 5: [1, 60], 24: [1, 58], 25: [1, 59] }, { 27: 61, 74: $Vv }, { 27: 62, 74: $Vv }, { 5: [1, 63] }, { 5: [1, 64] }, { 5: [1, 65] }, { 5: [1, 66] }, { 5: [1, 67] }, o($Vx, [2, 31]), o($Vx, [2, 32]), { 37: [1, 68] }, { 39: [1, 69] }, o($Vx, [2, 35]), { 20: [1, 70] }, { 20: [1, 71] }, { 20: [1, 72] }, { 20: [1, 73] }, { 20: [1, 74] }, { 20: [1, 75] }, { 20: [1, 76] }, { 20: [1, 77] }, o($Vx, [2, 44]), { 27: 78, 74: $Vv }, { 27: 79, 74: $Vv }, { 71: 80, 75: [1, 81], 76: [1, 82], 77: [1, 83], 78: [1, 84], 79: [1, 85], 80: [1, 86], 81: [1, 87], 82: [1, 88] }, { 59: 89, 61: [1, 90], 69: [1, 91], 70: [1, 92] }, { 27: 93, 74: $Vv }, { 27: 94, 74: $Vv }, { 27: 95, 74: $Vv }, { 27: 96, 74: $Vv }, o([5, 56, 68, 75, 76, 77, 78, 79, 80, 81, 82, 83], [2, 70]), { 5: [1, 97] }, { 18: 98, 86: [1, 99] }, { 5: [2, 83] }, o($Vx, [2, 7]), o($Vy, [2, 10], { 11: 100 }), o($Vx, [2, 19]), { 5: [1, 102], 24: [1, 101] }, { 5: [1, 103] }, o($Vx, [2, 23]), { 5: [1, 104] }, { 5: [1, 105] }, o($Vx, [2, 26]), o($Vx, [2, 27]), o($Vx, [2, 28]), o($Vx, [2, 29]), o($Vx, [2, 30]), o($Vx, [2, 33]), o($Vx, [2, 34]), o($Vz, $V4, { 8: 106 }), o($Vz, $V4, { 8: 107 }), o($Vz, $V4, { 8: 108 }), o($VA, $V4, { 45: 109, 8: 110 }), o($VB, $V4, { 47: 111, 8: 112 }), o($VB, $V4, { 8: 112, 47: 113 }), o($VC, $V4, { 50: 114, 8: 115 }), o($Vz, $V4, { 8: 116 }), { 5: [1, 118], 56: [1, 117] }, { 5: [1, 120], 56: [1, 119] }, { 27: 123, 72: [1, 121], 73: [1, 122], 74: $Vv }, o($VD, [2, 71]), o($VD, [2, 72]), o($VD, [2, 73]), o($VD, [2, 74]), o($VD, [2, 75]), o($VD, [2, 76]), o($VD, [2, 77]), o($VD, [2, 78]), { 27: 124, 74: $Vv }, { 27: 126, 62: 125, 74: $Vv }, { 74: [2, 65] }, { 74: [2, 66] }, { 60: 127, 83: $VE }, { 60: 129, 83: $VE }, { 60: 130, 83: $VE }, { 60: 131, 83: $VE }, o($VF, [2, 15]), { 16: 132, 87: $Vw }, { 87: [2, 82] }, { 4: [1, 135], 5: [1, 137], 12: 134, 13: 136, 21: [1, 133], 55: $Vo, 57: $Vp }, { 5: [1, 138] }, o($Vx, [2, 21]), o($Vx, [2, 22]), o($Vx, [2, 24]), o($Vx, [2, 25]), { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 139], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 140], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 141], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 21: [1, 142] }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [2, 49], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 54: [1, 143], 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 21: [1, 144] }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [2, 47], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 53: [1, 145], 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 21: [1, 146] }, { 21: [1, 147] }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [2, 45], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 52: [1, 148], 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 149], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 20: [1, 150] }, o($Vx, [2, 52]), { 20: [1, 151] }, o($Vx, [2, 54]), { 27: 152, 74: $Vv }, { 27: 153, 74: $Vv }, { 60: 154, 83: $VE }, { 60: 155, 83: $VE }, { 60: 156, 83: $VE }, { 68: [1, 157], 83: [2, 64] }, { 5: [2, 57] }, { 5: [2, 79] }, { 5: [2, 58] }, { 5: [2, 59] }, { 5: [2, 60] }, { 5: [1, 158] }, o($Vx, [2, 18]), o($Vy, [2, 11]), { 13: 159, 55: $Vo, 57: $Vp }, o($Vy, [2, 13]), o($Vy, [2, 14]), o($Vx, [2, 20]), o($Vx, [2, 36]), o($Vx, [2, 37]), o($Vx, [2, 38]), o($Vx, [2, 39]), { 20: [1, 160] }, o($Vx, [2, 40]), { 20: [1, 161] }, o($Vx, [2, 41]), o($Vx, [2, 42]), { 20: [1, 162] }, o($Vx, [2, 43]), { 5: [1, 163] }, { 5: [1, 164] }, { 60: 165, 83: $VE }, { 60: 166, 83: $VE }, { 5: [2, 69] }, { 5: [2, 55] }, { 5: [2, 56] }, { 27: 167, 74: $Vv }, o($VF, [2, 16]), o($Vy, [2, 12]), o($VA, $V4, { 8: 110, 45: 168 }), o($VB, $V4, { 8: 112, 47: 169 }), o($VC, $V4, { 8: 115, 50: 170 }), o($Vx, [2, 51]), o($Vx, [2, 53]), { 5: [2, 67] }, { 5: [2, 68] }, { 83: [2, 63] }, { 21: [2, 50] }, { 21: [2, 48] }, { 21: [2, 46] }],
255 defaultActions: { 7: [2, 80], 8: [2, 1], 9: [2, 2], 10: [2, 3], 54: [2, 83], 91: [2, 65], 92: [2, 66], 99: [2, 82], 127: [2, 57], 128: [2, 79], 129: [2, 58], 130: [2, 59], 131: [2, 60], 154: [2, 69], 155: [2, 55], 156: [2, 56], 165: [2, 67], 166: [2, 68], 167: [2, 63], 168: [2, 50], 169: [2, 48], 170: [2, 46] },
256 parseError: function parseError(str, hash) {
257 if (hash.recoverable) {
258 this.trace(str);
259 } else {
260 var error = new Error(str);
261 error.hash = hash;
262 throw error;
263 }
264 },
265 parse: function parse(input) {
266 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
267 var args = lstack.slice.call(arguments, 1);
268 var lexer2 = Object.create(this.lexer);
269 var sharedState = { yy: {} };
270 for (var k in this.yy) {
271 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
272 sharedState.yy[k] = this.yy[k];
273 }
274 }
275 lexer2.setInput(input, sharedState.yy);
276 sharedState.yy.lexer = lexer2;
277 sharedState.yy.parser = this;
278 if (typeof lexer2.yylloc == "undefined") {
279 lexer2.yylloc = {};
280 }
281 var yyloc = lexer2.yylloc;
282 lstack.push(yyloc);
283 var ranges = lexer2.options && lexer2.options.ranges;
284 if (typeof sharedState.yy.parseError === "function") {
285 this.parseError = sharedState.yy.parseError;
286 } else {
287 this.parseError = Object.getPrototypeOf(this).parseError;
288 }
289 function lex() {
290 var token;
291 token = tstack.pop() || lexer2.lex() || EOF;
292 if (typeof token !== "number") {
293 if (token instanceof Array) {
294 tstack = token;
295 token = tstack.pop();
296 }
297 token = self.symbols_[token] || token;
298 }
299 return token;
300 }
301 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
302 while (true) {
303 state = stack[stack.length - 1];
304 if (this.defaultActions[state]) {
305 action = this.defaultActions[state];
306 } else {
307 if (symbol === null || typeof symbol == "undefined") {
308 symbol = lex();
309 }
310 action = table[state] && table[state][symbol];
311 }
312 if (typeof action === "undefined" || !action.length || !action[0]) {
313 var errStr = "";
314 expected = [];
315 for (p in table[state]) {
316 if (this.terminals_[p] && p > TERROR) {
317 expected.push("'" + this.terminals_[p] + "'");
318 }
319 }
320 if (lexer2.showPosition) {
321 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
322 } else {
323 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
324 }
325 this.parseError(errStr, {
326 text: lexer2.match,
327 token: this.terminals_[symbol] || symbol,
328 line: lexer2.yylineno,
329 loc: yyloc,
330 expected
331 });
332 }
333 if (action[0] instanceof Array && action.length > 1) {
334 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
335 }
336 switch (action[0]) {
337 case 1:
338 stack.push(symbol);
339 vstack.push(lexer2.yytext);
340 lstack.push(lexer2.yylloc);
341 stack.push(action[1]);
342 symbol = null;
343 {
344 yyleng = lexer2.yyleng;
345 yytext = lexer2.yytext;
346 yylineno = lexer2.yylineno;
347 yyloc = lexer2.yylloc;
348 }
349 break;
350 case 2:
351 len = this.productions_[action[1]][1];
352 yyval.$ = vstack[vstack.length - len];
353 yyval._$ = {
354 first_line: lstack[lstack.length - (len || 1)].first_line,
355 last_line: lstack[lstack.length - 1].last_line,
356 first_column: lstack[lstack.length - (len || 1)].first_column,
357 last_column: lstack[lstack.length - 1].last_column
358 };
359 if (ranges) {
360 yyval._$.range = [
361 lstack[lstack.length - (len || 1)].range[0],
362 lstack[lstack.length - 1].range[1]
363 ];
364 }
365 r = this.performAction.apply(yyval, [
366 yytext,
367 yyleng,
368 yylineno,
369 sharedState.yy,
370 action[1],
371 vstack,
372 lstack
373 ].concat(args));
374 if (typeof r !== "undefined") {
375 return r;
376 }
377 if (len) {
378 stack = stack.slice(0, -1 * len * 2);
379 vstack = vstack.slice(0, -1 * len);
380 lstack = lstack.slice(0, -1 * len);
381 }
382 stack.push(this.productions_[action[1]][0]);
383 vstack.push(yyval.$);
384 lstack.push(yyval._$);
385 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
386 stack.push(newState);
387 break;
388 case 3:
389 return true;
390 }
391 }
392 return true;
393 }
394 };
395 var lexer = function() {
396 var lexer2 = {
397 EOF: 1,
398 parseError: function parseError(str, hash) {
399 if (this.yy.parser) {
400 this.yy.parser.parseError(str, hash);
401 } else {
402 throw new Error(str);
403 }
404 },
405 // resets the lexer, sets new input
406 setInput: function(input, yy) {
407 this.yy = yy || this.yy || {};
408 this._input = input;
409 this._more = this._backtrack = this.done = false;
410 this.yylineno = this.yyleng = 0;
411 this.yytext = this.matched = this.match = "";
412 this.conditionStack = ["INITIAL"];
413 this.yylloc = {
414 first_line: 1,
415 first_column: 0,
416 last_line: 1,
417 last_column: 0
418 };
419 if (this.options.ranges) {
420 this.yylloc.range = [0, 0];
421 }
422 this.offset = 0;
423 return this;
424 },
425 // consumes and returns one char from the input
426 input: function() {
427 var ch = this._input[0];
428 this.yytext += ch;
429 this.yyleng++;
430 this.offset++;
431 this.match += ch;
432 this.matched += ch;
433 var lines = ch.match(/(?:\r\n?|\n).*/g);
434 if (lines) {
435 this.yylineno++;
436 this.yylloc.last_line++;
437 } else {
438 this.yylloc.last_column++;
439 }
440 if (this.options.ranges) {
441 this.yylloc.range[1]++;
442 }
443 this._input = this._input.slice(1);
444 return ch;
445 },
446 // unshifts one char (or a string) into the input
447 unput: function(ch) {
448 var len = ch.length;
449 var lines = ch.split(/(?:\r\n?|\n)/g);
450 this._input = ch + this._input;
451 this.yytext = this.yytext.substr(0, this.yytext.length - len);
452 this.offset -= len;
453 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
454 this.match = this.match.substr(0, this.match.length - 1);
455 this.matched = this.matched.substr(0, this.matched.length - 1);
456 if (lines.length - 1) {
457 this.yylineno -= lines.length - 1;
458 }
459 var r = this.yylloc.range;
460 this.yylloc = {
461 first_line: this.yylloc.first_line,
462 last_line: this.yylineno + 1,
463 first_column: this.yylloc.first_column,
464 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
465 };
466 if (this.options.ranges) {
467 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
468 }
469 this.yyleng = this.yytext.length;
470 return this;
471 },
472 // When called from action, caches matched text and appends it on next action
473 more: function() {
474 this._more = true;
475 return this;
476 },
477 // 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.
478 reject: function() {
479 if (this.options.backtrack_lexer) {
480 this._backtrack = true;
481 } else {
482 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(), {
483 text: "",
484 token: null,
485 line: this.yylineno
486 });
487 }
488 return this;
489 },
490 // retain first n characters of the match
491 less: function(n) {
492 this.unput(this.match.slice(n));
493 },
494 // displays already matched input, i.e. for error messages
495 pastInput: function() {
496 var past = this.matched.substr(0, this.matched.length - this.match.length);
497 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
498 },
499 // displays upcoming input, i.e. for error messages
500 upcomingInput: function() {
501 var next = this.match;
502 if (next.length < 20) {
503 next += this._input.substr(0, 20 - next.length);
504 }
505 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
506 },
507 // displays the character position where the lexing error occurred, i.e. for error messages
508 showPosition: function() {
509 var pre = this.pastInput();
510 var c = new Array(pre.length + 1).join("-");
511 return pre + this.upcomingInput() + "\n" + c + "^";
512 },
513 // test the lexed token: return FALSE when not a match, otherwise return token
514 test_match: function(match, indexed_rule) {
515 var token, lines, backup;
516 if (this.options.backtrack_lexer) {
517 backup = {
518 yylineno: this.yylineno,
519 yylloc: {
520 first_line: this.yylloc.first_line,
521 last_line: this.last_line,
522 first_column: this.yylloc.first_column,
523 last_column: this.yylloc.last_column
524 },
525 yytext: this.yytext,
526 match: this.match,
527 matches: this.matches,
528 matched: this.matched,
529 yyleng: this.yyleng,
530 offset: this.offset,
531 _more: this._more,
532 _input: this._input,
533 yy: this.yy,
534 conditionStack: this.conditionStack.slice(0),
535 done: this.done
536 };
537 if (this.options.ranges) {
538 backup.yylloc.range = this.yylloc.range.slice(0);
539 }
540 }
541 lines = match[0].match(/(?:\r\n?|\n).*/g);
542 if (lines) {
543 this.yylineno += lines.length;
544 }
545 this.yylloc = {
546 first_line: this.yylloc.last_line,
547 last_line: this.yylineno + 1,
548 first_column: this.yylloc.last_column,
549 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
550 };
551 this.yytext += match[0];
552 this.match += match[0];
553 this.matches = match;
554 this.yyleng = this.yytext.length;
555 if (this.options.ranges) {
556 this.yylloc.range = [this.offset, this.offset += this.yyleng];
557 }
558 this._more = false;
559 this._backtrack = false;
560 this._input = this._input.slice(match[0].length);
561 this.matched += match[0];
562 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
563 if (this.done && this._input) {
564 this.done = false;
565 }
566 if (token) {
567 return token;
568 } else if (this._backtrack) {
569 for (var k in backup) {
570 this[k] = backup[k];
571 }
572 return false;
573 }
574 return false;
575 },
576 // return next match in input
577 next: function() {
578 if (this.done) {
579 return this.EOF;
580 }
581 if (!this._input) {
582 this.done = true;
583 }
584 var token, match, tempMatch, index;
585 if (!this._more) {
586 this.yytext = "";
587 this.match = "";
588 }
589 var rules = this._currentRules();
590 for (var i = 0; i < rules.length; i++) {
591 tempMatch = this._input.match(this.rules[rules[i]]);
592 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
593 match = tempMatch;
594 index = i;
595 if (this.options.backtrack_lexer) {
596 token = this.test_match(tempMatch, rules[i]);
597 if (token !== false) {
598 return token;
599 } else if (this._backtrack) {
600 match = false;
601 continue;
602 } else {
603 return false;
604 }
605 } else if (!this.options.flex) {
606 break;
607 }
608 }
609 }
610 if (match) {
611 token = this.test_match(match, rules[index]);
612 if (token !== false) {
613 return token;
614 }
615 return false;
616 }
617 if (this._input === "") {
618 return this.EOF;
619 } else {
620 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
621 text: "",
622 token: null,
623 line: this.yylineno
624 });
625 }
626 },
627 // return next match that has a token
628 lex: function lex() {
629 var r = this.next();
630 if (r) {
631 return r;
632 } else {
633 return this.lex();
634 }
635 },
636 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
637 begin: function begin(condition) {
638 this.conditionStack.push(condition);
639 },
640 // pop the previously active lexer condition state off the condition stack
641 popState: function popState() {
642 var n = this.conditionStack.length - 1;
643 if (n > 0) {
644 return this.conditionStack.pop();
645 } else {
646 return this.conditionStack[0];
647 }
648 },
649 // produce the lexer rule set which is active for the currently active lexer condition state
650 _currentRules: function _currentRules() {
651 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
652 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
653 } else {
654 return this.conditions["INITIAL"].rules;
655 }
656 },
657 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
658 topState: function topState(n) {
659 n = this.conditionStack.length - 1 - Math.abs(n || 0);
660 if (n >= 0) {
661 return this.conditionStack[n];
662 } else {
663 return "INITIAL";
664 }
665 },
666 // alias for begin(condition)
667 pushState: function pushState(condition) {
668 this.begin(condition);
669 },
670 // return the number of states currently on the stack
671 stateStackSize: function stateStackSize() {
672 return this.conditionStack.length;
673 },
674 options: { "case-insensitive": true },
675 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
676 switch ($avoiding_name_collisions) {
677 case 0:
678 this.begin("open_directive");
679 return 84;
680 case 1:
681 this.begin("type_directive");
682 return 85;
683 case 2:
684 this.popState();
685 this.begin("arg_directive");
686 return 17;
687 case 3:
688 this.popState();
689 this.popState();
690 return 87;
691 case 4:
692 return 86;
693 case 5:
694 return 5;
695 case 6:
696 break;
697 case 7:
698 break;
699 case 8:
700 break;
701 case 9:
702 break;
703 case 10:
704 break;
705 case 11:
706 return 24;
707 case 12:
708 this.begin("LINE");
709 return 19;
710 case 13:
711 this.begin("ID");
712 return 55;
713 case 14:
714 this.begin("ID");
715 return 57;
716 case 15:
717 yy_.yytext = yy_.yytext.trim();
718 this.begin("ALIAS");
719 return 74;
720 case 16:
721 this.popState();
722 this.popState();
723 this.begin("LINE");
724 return 56;
725 case 17:
726 this.popState();
727 this.popState();
728 return 5;
729 case 18:
730 this.begin("LINE");
731 return 41;
732 case 19:
733 this.begin("LINE");
734 return 42;
735 case 20:
736 this.begin("LINE");
737 return 43;
738 case 21:
739 this.begin("LINE");
740 return 44;
741 case 22:
742 this.begin("LINE");
743 return 54;
744 case 23:
745 this.begin("LINE");
746 return 46;
747 case 24:
748 this.begin("LINE");
749 return 48;
750 case 25:
751 this.begin("LINE");
752 return 53;
753 case 26:
754 this.begin("LINE");
755 return 49;
756 case 27:
757 this.begin("LINE");
758 return 52;
759 case 28:
760 this.begin("LINE");
761 return 51;
762 case 29:
763 this.popState();
764 return 20;
765 case 30:
766 return 21;
767 case 31:
768 return 69;
769 case 32:
770 return 70;
771 case 33:
772 return 63;
773 case 34:
774 return 64;
775 case 35:
776 return 65;
777 case 36:
778 return 66;
779 case 37:
780 return 61;
781 case 38:
782 return 58;
783 case 39:
784 this.begin("ID");
785 return 26;
786 case 40:
787 this.begin("ID");
788 return 28;
789 case 41:
790 return 34;
791 case 42:
792 return 35;
793 case 43:
794 this.begin("acc_title");
795 return 36;
796 case 44:
797 this.popState();
798 return "acc_title_value";
799 case 45:
800 this.begin("acc_descr");
801 return 38;
802 case 46:
803 this.popState();
804 return "acc_descr_value";
805 case 47:
806 this.begin("acc_descr_multiline");
807 break;
808 case 48:
809 this.popState();
810 break;
811 case 49:
812 return "acc_descr_multiline_value";
813 case 50:
814 return 7;
815 case 51:
816 return 23;
817 case 52:
818 return 25;
819 case 53:
820 return 68;
821 case 54:
822 return 5;
823 case 55:
824 yy_.yytext = yy_.yytext.trim();
825 return 74;
826 case 56:
827 return 77;
828 case 57:
829 return 78;
830 case 58:
831 return 75;
832 case 59:
833 return 76;
834 case 60:
835 return 79;
836 case 61:
837 return 80;
838 case 62:
839 return 81;
840 case 63:
841 return 82;
842 case 64:
843 return 83;
844 case 65:
845 return 72;
846 case 66:
847 return 73;
848 case 67:
849 return 5;
850 case 68:
851 return "INVALID";
852 }
853 },
854 rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \n]+))/i, /^(?:box\b)/i, /^(?:participant\b)/i, /^(?:actor\b)/i, /^(?:[^\->:\n,;]+?([\-]*[^\->:\n,;]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:rect\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:par_over\b)/i, /^(?:and\b)/i, /^(?:critical\b)/i, /^(?:option\b)/i, /^(?:break\b)/i, /^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:links\b)/i, /^(?:link\b)/i, /^(?:properties\b)/i, /^(?:details\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\s[^#\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, /^(?:sequenceDiagram\b)/i, /^(?:autonumber\b)/i, /^(?:off\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^\+\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+\->:\n,;]+)*)/i, /^(?:->>)/i, /^(?:-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i],
855 conditions: { "acc_descr_multiline": { "rules": [48, 49], "inclusive": false }, "acc_descr": { "rules": [46], "inclusive": false }, "acc_title": { "rules": [44], "inclusive": false }, "open_directive": { "rules": [1, 8], "inclusive": false }, "type_directive": { "rules": [2, 3, 8], "inclusive": false }, "arg_directive": { "rules": [3, 4, 8], "inclusive": false }, "ID": { "rules": [7, 8, 15], "inclusive": false }, "ALIAS": { "rules": [7, 8, 16, 17], "inclusive": false }, "LINE": { "rules": [7, 8, 29], "inclusive": false }, "INITIAL": { "rules": [0, 5, 6, 8, 9, 10, 11, 12, 13, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68], "inclusive": true } }
856 };
857 return lexer2;
858 }();
859 parser2.lexer = lexer;
860 function Parser() {
861 this.yy = {};
862 }
863 Parser.prototype = parser2;
864 parser2.Parser = Parser;
865 return new Parser();
866}();
867parser.parser = parser;
868const parser$1 = parser;
869let prevActor = void 0;
870let actors = {};
871let boxes = [];
872let messages = [];
873let sequenceNumbersEnabled = false;
874let wrapEnabled;
875let currentBox = void 0;
876const parseDirective = function(statement, context, type) {
877 mermaidAPI.parseDirective(this, statement, context, type);
878};
879const addBox = function(data) {
880 boxes.push({
881 name: data.text,
882 wrap: data.wrap === void 0 && autoWrap() || !!data.wrap,
883 fill: data.color,
884 actorKeys: []
885 });
886 currentBox = boxes.slice(-1)[0];
887};
888const addActor = function(id, name, description, type) {
889 let assignedBox = currentBox;
890 const old = actors[id];
891 if (old) {
892 if (currentBox && old.box && currentBox !== old.box) {
893 throw new Error(
894 "A same participant should only be defined in one Box: " + old.name + " can't be in '" + old.box.name + "' and in '" + currentBox.name + "' at the same time."
895 );
896 }
897 assignedBox = old.box ? old.box : currentBox;
898 old.box = assignedBox;
899 if (old && name === old.name && description == null) {
900 return;
901 }
902 }
903 if (description == null || description.text == null) {
904 description = { text: name, wrap: null, type };
905 }
906 if (type == null || description.text == null) {
907 description = { text: name, wrap: null, type };
908 }
909 actors[id] = {
910 box: assignedBox,
911 name,
912 description: description.text,
913 wrap: description.wrap === void 0 && autoWrap() || !!description.wrap,
914 prevActor,
915 links: {},
916 properties: {},
917 actorCnt: null,
918 rectData: null,
919 type: type || "participant"
920 };
921 if (prevActor && actors[prevActor]) {
922 actors[prevActor].nextActor = id;
923 }
924 if (currentBox) {
925 currentBox.actorKeys.push(id);
926 }
927 prevActor = id;
928};
929const activationCount = (part) => {
930 let i;
931 let count = 0;
932 for (i = 0; i < messages.length; i++) {
933 if (messages[i].type === LINETYPE.ACTIVE_START && messages[i].from.actor === part) {
934 count++;
935 }
936 if (messages[i].type === LINETYPE.ACTIVE_END && messages[i].from.actor === part) {
937 count--;
938 }
939 }
940 return count;
941};
942const addMessage = function(idFrom, idTo, message, answer) {
943 messages.push({
944 from: idFrom,
945 to: idTo,
946 message: message.text,
947 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
948 answer
949 });
950};
951const addSignal = function(idFrom, idTo, message = { text: void 0, wrap: void 0 }, messageType) {
952 if (messageType === LINETYPE.ACTIVE_END) {
953 const cnt = activationCount(idFrom.actor);
954 if (cnt < 1) {
955 let error = new Error("Trying to inactivate an inactive participant (" + idFrom.actor + ")");
956 error.hash = {
957 text: "->>-",
958 token: "->>-",
959 line: "1",
960 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
961 expected: ["'ACTIVE_PARTICIPANT'"]
962 };
963 throw error;
964 }
965 }
966 messages.push({
967 from: idFrom,
968 to: idTo,
969 message: message.text,
970 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
971 type: messageType
972 });
973 return true;
974};
975const hasAtLeastOneBox = function() {
976 return boxes.length > 0;
977};
978const hasAtLeastOneBoxWithTitle = function() {
979 return boxes.some((b) => b.name);
980};
981const getMessages = function() {
982 return messages;
983};
984const getBoxes = function() {
985 return boxes;
986};
987const getActors = function() {
988 return actors;
989};
990const getActor = function(id) {
991 return actors[id];
992};
993const getActorKeys = function() {
994 return Object.keys(actors);
995};
996const enableSequenceNumbers = function() {
997 sequenceNumbersEnabled = true;
998};
999const disableSequenceNumbers = function() {
1000 sequenceNumbersEnabled = false;
1001};
1002const showSequenceNumbers = () => sequenceNumbersEnabled;
1003const setWrap = function(wrapSetting) {
1004 wrapEnabled = wrapSetting;
1005};
1006const autoWrap = () => {
1007 if (wrapEnabled !== void 0) {
1008 return wrapEnabled;
1009 }
1010 return getConfig().sequence.wrap;
1011};
1012const clear = function() {
1013 actors = {};
1014 boxes = [];
1015 messages = [];
1016 sequenceNumbersEnabled = false;
1017 clear$1();
1018};
1019const parseMessage = function(str) {
1020 const _str = str.trim();
1021 const message = {
1022 text: _str.replace(/^:?(?:no)?wrap:/, "").trim(),
1023 wrap: _str.match(/^:?wrap:/) !== null ? true : _str.match(/^:?nowrap:/) !== null ? false : void 0
1024 };
1025 log.debug("parseMessage:", message);
1026 return message;
1027};
1028const parseBoxData = function(str) {
1029 const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/);
1030 let color = match != null && match[1] ? match[1].trim() : "transparent";
1031 let title = match != null && match[2] ? match[2].trim() : void 0;
1032 if (window && window.CSS) {
1033 if (!window.CSS.supports("color", color)) {
1034 color = "transparent";
1035 title = str.trim();
1036 }
1037 } else {
1038 const style = new Option().style;
1039 style.color = color;
1040 if (style.color !== color) {
1041 color = "transparent";
1042 title = str.trim();
1043 }
1044 }
1045 const boxData = {
1046 color,
1047 text: title !== void 0 ? sanitizeText(title.replace(/^:?(?:no)?wrap:/, ""), getConfig()) : void 0,
1048 wrap: title !== void 0 ? title.match(/^:?wrap:/) !== null ? true : title.match(/^:?nowrap:/) !== null ? false : void 0 : void 0
1049 };
1050 return boxData;
1051};
1052const LINETYPE = {
1053 SOLID: 0,
1054 DOTTED: 1,
1055 NOTE: 2,
1056 SOLID_CROSS: 3,
1057 DOTTED_CROSS: 4,
1058 SOLID_OPEN: 5,
1059 DOTTED_OPEN: 6,
1060 LOOP_START: 10,
1061 LOOP_END: 11,
1062 ALT_START: 12,
1063 ALT_ELSE: 13,
1064 ALT_END: 14,
1065 OPT_START: 15,
1066 OPT_END: 16,
1067 ACTIVE_START: 17,
1068 ACTIVE_END: 18,
1069 PAR_START: 19,
1070 PAR_AND: 20,
1071 PAR_END: 21,
1072 RECT_START: 22,
1073 RECT_END: 23,
1074 SOLID_POINT: 24,
1075 DOTTED_POINT: 25,
1076 AUTONUMBER: 26,
1077 CRITICAL_START: 27,
1078 CRITICAL_OPTION: 28,
1079 CRITICAL_END: 29,
1080 BREAK_START: 30,
1081 BREAK_END: 31,
1082 PAR_OVER_START: 32
1083};
1084const ARROWTYPE = {
1085 FILLED: 0,
1086 OPEN: 1
1087};
1088const PLACEMENT = {
1089 LEFTOF: 0,
1090 RIGHTOF: 1,
1091 OVER: 2
1092};
1093const addNote = function(actor, placement, message) {
1094 ({
1095 actor,
1096 placement,
1097 message: message.text,
1098 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap
1099 });
1100 const actors2 = [].concat(actor, actor);
1101 messages.push({
1102 from: actors2[0],
1103 to: actors2[1],
1104 message: message.text,
1105 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
1106 type: LINETYPE.NOTE,
1107 placement
1108 });
1109};
1110const addLinks = function(actorId, text) {
1111 const actor = getActor(actorId);
1112 try {
1113 let sanitizedText = sanitizeText(text.text, getConfig());
1114 sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1115 sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1116 const links = JSON.parse(sanitizedText);
1117 insertLinks(actor, links);
1118 } catch (e) {
1119 log.error("error while parsing actor link text", e);
1120 }
1121};
1122const addALink = function(actorId, text) {
1123 const actor = getActor(actorId);
1124 try {
1125 const links = {};
1126 let sanitizedText = sanitizeText(text.text, getConfig());
1127 var sep = sanitizedText.indexOf("@");
1128 sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1129 sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1130 var label = sanitizedText.slice(0, sep - 1).trim();
1131 var link = sanitizedText.slice(sep + 1).trim();
1132 links[label] = link;
1133 insertLinks(actor, links);
1134 } catch (e) {
1135 log.error("error while parsing actor link text", e);
1136 }
1137};
1138function insertLinks(actor, links) {
1139 if (actor.links == null) {
1140 actor.links = links;
1141 } else {
1142 for (let key in links) {
1143 actor.links[key] = links[key];
1144 }
1145 }
1146}
1147const addProperties = function(actorId, text) {
1148 const actor = getActor(actorId);
1149 try {
1150 let sanitizedText = sanitizeText(text.text, getConfig());
1151 const properties = JSON.parse(sanitizedText);
1152 insertProperties(actor, properties);
1153 } catch (e) {
1154 log.error("error while parsing actor properties text", e);
1155 }
1156};
1157function insertProperties(actor, properties) {
1158 if (actor.properties == null) {
1159 actor.properties = properties;
1160 } else {
1161 for (let key in properties) {
1162 actor.properties[key] = properties[key];
1163 }
1164 }
1165}
1166function boxEnd() {
1167 currentBox = void 0;
1168}
1169const addDetails = function(actorId, text) {
1170 const actor = getActor(actorId);
1171 const elem = document.getElementById(text.text);
1172 try {
1173 const text2 = elem.innerHTML;
1174 const details = JSON.parse(text2);
1175 if (details["properties"]) {
1176 insertProperties(actor, details["properties"]);
1177 }
1178 if (details["links"]) {
1179 insertLinks(actor, details["links"]);
1180 }
1181 } catch (e) {
1182 log.error("error while parsing actor details text", e);
1183 }
1184};
1185const getActorProperty = function(actor, key) {
1186 if (actor !== void 0 && actor.properties !== void 0) {
1187 return actor.properties[key];
1188 }
1189 return void 0;
1190};
1191const apply = function(param) {
1192 if (Array.isArray(param)) {
1193 param.forEach(function(item) {
1194 apply(item);
1195 });
1196 } else {
1197 switch (param.type) {
1198 case "sequenceIndex":
1199 messages.push({
1200 from: void 0,
1201 to: void 0,
1202 message: {
1203 start: param.sequenceIndex,
1204 step: param.sequenceIndexStep,
1205 visible: param.sequenceVisible
1206 },
1207 wrap: false,
1208 type: param.signalType
1209 });
1210 break;
1211 case "addParticipant":
1212 addActor(param.actor, param.actor, param.description, "participant");
1213 break;
1214 case "addActor":
1215 addActor(param.actor, param.actor, param.description, "actor");
1216 break;
1217 case "activeStart":
1218 addSignal(param.actor, void 0, void 0, param.signalType);
1219 break;
1220 case "activeEnd":
1221 addSignal(param.actor, void 0, void 0, param.signalType);
1222 break;
1223 case "addNote":
1224 addNote(param.actor, param.placement, param.text);
1225 break;
1226 case "addLinks":
1227 addLinks(param.actor, param.text);
1228 break;
1229 case "addALink":
1230 addALink(param.actor, param.text);
1231 break;
1232 case "addProperties":
1233 addProperties(param.actor, param.text);
1234 break;
1235 case "addDetails":
1236 addDetails(param.actor, param.text);
1237 break;
1238 case "addMessage":
1239 addSignal(param.from, param.to, param.msg, param.signalType);
1240 break;
1241 case "boxStart":
1242 addBox(param.boxData);
1243 break;
1244 case "boxEnd":
1245 boxEnd();
1246 break;
1247 case "loopStart":
1248 addSignal(void 0, void 0, param.loopText, param.signalType);
1249 break;
1250 case "loopEnd":
1251 addSignal(void 0, void 0, void 0, param.signalType);
1252 break;
1253 case "rectStart":
1254 addSignal(void 0, void 0, param.color, param.signalType);
1255 break;
1256 case "rectEnd":
1257 addSignal(void 0, void 0, void 0, param.signalType);
1258 break;
1259 case "optStart":
1260 addSignal(void 0, void 0, param.optText, param.signalType);
1261 break;
1262 case "optEnd":
1263 addSignal(void 0, void 0, void 0, param.signalType);
1264 break;
1265 case "altStart":
1266 addSignal(void 0, void 0, param.altText, param.signalType);
1267 break;
1268 case "else":
1269 addSignal(void 0, void 0, param.altText, param.signalType);
1270 break;
1271 case "altEnd":
1272 addSignal(void 0, void 0, void 0, param.signalType);
1273 break;
1274 case "setAccTitle":
1275 setAccTitle(param.text);
1276 break;
1277 case "parStart":
1278 addSignal(void 0, void 0, param.parText, param.signalType);
1279 break;
1280 case "and":
1281 addSignal(void 0, void 0, param.parText, param.signalType);
1282 break;
1283 case "parEnd":
1284 addSignal(void 0, void 0, void 0, param.signalType);
1285 break;
1286 case "criticalStart":
1287 addSignal(void 0, void 0, param.criticalText, param.signalType);
1288 break;
1289 case "option":
1290 addSignal(void 0, void 0, param.optionText, param.signalType);
1291 break;
1292 case "criticalEnd":
1293 addSignal(void 0, void 0, void 0, param.signalType);
1294 break;
1295 case "breakStart":
1296 addSignal(void 0, void 0, param.breakText, param.signalType);
1297 break;
1298 case "breakEnd":
1299 addSignal(void 0, void 0, void 0, param.signalType);
1300 break;
1301 }
1302 }
1303};
1304const db = {
1305 addActor,
1306 addMessage,
1307 addSignal,
1308 addLinks,
1309 addDetails,
1310 addProperties,
1311 autoWrap,
1312 setWrap,
1313 enableSequenceNumbers,
1314 disableSequenceNumbers,
1315 showSequenceNumbers,
1316 getMessages,
1317 getActors,
1318 getActor,
1319 getActorKeys,
1320 getActorProperty,
1321 getAccTitle,
1322 getBoxes,
1323 getDiagramTitle,
1324 setDiagramTitle,
1325 parseDirective,
1326 getConfig: () => getConfig().sequence,
1327 clear,
1328 parseMessage,
1329 parseBoxData,
1330 LINETYPE,
1331 ARROWTYPE,
1332 PLACEMENT,
1333 addNote,
1334 setAccTitle,
1335 apply,
1336 setAccDescription,
1337 getAccDescription,
1338 hasAtLeastOneBox,
1339 hasAtLeastOneBoxWithTitle
1340};
1341const getStyles = (options) => `.actor {
1342 stroke: ${options.actorBorder};
1343 fill: ${options.actorBkg};
1344 }
1345
1346 text.actor > tspan {
1347 fill: ${options.actorTextColor};
1348 stroke: none;
1349 }
1350
1351 .actor-line {
1352 stroke: ${options.actorLineColor};
1353 }
1354
1355 .messageLine0 {
1356 stroke-width: 1.5;
1357 stroke-dasharray: none;
1358 stroke: ${options.signalColor};
1359 }
1360
1361 .messageLine1 {
1362 stroke-width: 1.5;
1363 stroke-dasharray: 2, 2;
1364 stroke: ${options.signalColor};
1365 }
1366
1367 #arrowhead path {
1368 fill: ${options.signalColor};
1369 stroke: ${options.signalColor};
1370 }
1371
1372 .sequenceNumber {
1373 fill: ${options.sequenceNumberColor};
1374 }
1375
1376 #sequencenumber {
1377 fill: ${options.signalColor};
1378 }
1379
1380 #crosshead path {
1381 fill: ${options.signalColor};
1382 stroke: ${options.signalColor};
1383 }
1384
1385 .messageText {
1386 fill: ${options.signalTextColor};
1387 stroke: none;
1388 }
1389
1390 .labelBox {
1391 stroke: ${options.labelBoxBorderColor};
1392 fill: ${options.labelBoxBkgColor};
1393 }
1394
1395 .labelText, .labelText > tspan {
1396 fill: ${options.labelTextColor};
1397 stroke: none;
1398 }
1399
1400 .loopText, .loopText > tspan {
1401 fill: ${options.loopTextColor};
1402 stroke: none;
1403 }
1404
1405 .loopLine {
1406 stroke-width: 2px;
1407 stroke-dasharray: 2, 2;
1408 stroke: ${options.labelBoxBorderColor};
1409 fill: ${options.labelBoxBorderColor};
1410 }
1411
1412 .note {
1413 //stroke: #decc93;
1414 stroke: ${options.noteBorderColor};
1415 fill: ${options.noteBkgColor};
1416 }
1417
1418 .noteText, .noteText > tspan {
1419 fill: ${options.noteTextColor};
1420 stroke: none;
1421 }
1422
1423 .activation0 {
1424 fill: ${options.activationBkgColor};
1425 stroke: ${options.activationBorderColor};
1426 }
1427
1428 .activation1 {
1429 fill: ${options.activationBkgColor};
1430 stroke: ${options.activationBorderColor};
1431 }
1432
1433 .activation2 {
1434 fill: ${options.activationBkgColor};
1435 stroke: ${options.activationBorderColor};
1436 }
1437
1438 .actorPopupMenu {
1439 position: absolute;
1440 }
1441
1442 .actorPopupMenuPanel {
1443 position: absolute;
1444 fill: ${options.actorBkg};
1445 box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
1446 filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));
1447}
1448 .actor-man line {
1449 stroke: ${options.actorBorder};
1450 fill: ${options.actorBkg};
1451 }
1452 .actor-man circle, line {
1453 stroke: ${options.actorBorder};
1454 fill: ${options.actorBkg};
1455 stroke-width: 2px;
1456 }
1457`;
1458const styles = getStyles;
1459const drawRect = function(elem, rectData) {
1460 return drawRect$1(elem, rectData);
1461};
1462const addPopupInteraction = (id, actorCnt2) => {
1463 addFunction(() => {
1464 const arr = document.querySelectorAll(id);
1465 if (arr.length === 0) {
1466 return;
1467 }
1468 arr[0].addEventListener("mouseover", function() {
1469 popupMenuUpFunc("actor" + actorCnt2 + "_popup");
1470 });
1471 arr[0].addEventListener("mouseout", function() {
1472 popupMenuDownFunc("actor" + actorCnt2 + "_popup");
1473 });
1474 });
1475};
1476const drawPopup = function(elem, actor, minMenuWidth, textAttrs, forceMenus) {
1477 if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) {
1478 return { height: 0, width: 0 };
1479 }
1480 const links = actor.links;
1481 const actorCnt2 = actor.actorCnt;
1482 const rectData = actor.rectData;
1483 var displayValue = "none";
1484 if (forceMenus) {
1485 displayValue = "block !important";
1486 }
1487 const g = elem.append("g");
1488 g.attr("id", "actor" + actorCnt2 + "_popup");
1489 g.attr("class", "actorPopupMenu");
1490 g.attr("display", displayValue);
1491 addPopupInteraction("#actor" + actorCnt2 + "_popup", actorCnt2);
1492 var actorClass = "";
1493 if (rectData.class !== void 0) {
1494 actorClass = " " + rectData.class;
1495 }
1496 let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth;
1497 const rectElem = g.append("rect");
1498 rectElem.attr("class", "actorPopupMenuPanel" + actorClass);
1499 rectElem.attr("x", rectData.x);
1500 rectElem.attr("y", rectData.height);
1501 rectElem.attr("fill", rectData.fill);
1502 rectElem.attr("stroke", rectData.stroke);
1503 rectElem.attr("width", menuWidth);
1504 rectElem.attr("height", rectData.height);
1505 rectElem.attr("rx", rectData.rx);
1506 rectElem.attr("ry", rectData.ry);
1507 if (links != null) {
1508 var linkY = 20;
1509 for (let key in links) {
1510 var linkElem = g.append("a");
1511 var sanitizedLink = sanitizeUrl(links[key]);
1512 linkElem.attr("xlink:href", sanitizedLink);
1513 linkElem.attr("target", "_blank");
1514 _drawMenuItemTextCandidateFunc(textAttrs)(
1515 key,
1516 linkElem,
1517 rectData.x + 10,
1518 rectData.height + linkY,
1519 menuWidth,
1520 20,
1521 { class: "actor" },
1522 textAttrs
1523 );
1524 linkY += 30;
1525 }
1526 }
1527 rectElem.attr("height", linkY);
1528 return { height: rectData.height + linkY, width: menuWidth };
1529};
1530const popupMenu = function(popid) {
1531 return "var pu = document.getElementById('" + popid + "'); if (pu != null) { pu.style.display = 'block'; }";
1532};
1533const popdownMenu = function(popid) {
1534 return "var pu = document.getElementById('" + popid + "'); if (pu != null) { pu.style.display = 'none'; }";
1535};
1536const popupMenuUpFunc = function(popupId) {
1537 var pu = document.getElementById(popupId);
1538 if (pu != null) {
1539 pu.style.display = "block";
1540 }
1541};
1542const popupMenuDownFunc = function(popupId) {
1543 var pu = document.getElementById(popupId);
1544 if (pu != null) {
1545 pu.style.display = "none";
1546 }
1547};
1548const drawText = function(elem, textData) {
1549 let prevTextHeight = 0;
1550 let textHeight = 0;
1551 const lines = textData.text.split(common.lineBreakRegex);
1552 const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize);
1553 let textElems = [];
1554 let dy = 0;
1555 let yfunc = () => textData.y;
1556 if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1557 switch (textData.valign) {
1558 case "top":
1559 case "start":
1560 yfunc = () => Math.round(textData.y + textData.textMargin);
1561 break;
1562 case "middle":
1563 case "center":
1564 yfunc = () => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2);
1565 break;
1566 case "bottom":
1567 case "end":
1568 yfunc = () => Math.round(
1569 textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin
1570 );
1571 break;
1572 }
1573 }
1574 if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) {
1575 switch (textData.anchor) {
1576 case "left":
1577 case "start":
1578 textData.x = Math.round(textData.x + textData.textMargin);
1579 textData.anchor = "start";
1580 textData.dominantBaseline = "middle";
1581 textData.alignmentBaseline = "middle";
1582 break;
1583 case "middle":
1584 case "center":
1585 textData.x = Math.round(textData.x + textData.width / 2);
1586 textData.anchor = "middle";
1587 textData.dominantBaseline = "middle";
1588 textData.alignmentBaseline = "middle";
1589 break;
1590 case "right":
1591 case "end":
1592 textData.x = Math.round(textData.x + textData.width - textData.textMargin);
1593 textData.anchor = "end";
1594 textData.dominantBaseline = "middle";
1595 textData.alignmentBaseline = "middle";
1596 break;
1597 }
1598 }
1599 for (let [i, line] of lines.entries()) {
1600 if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) {
1601 dy = i * _textFontSize;
1602 }
1603 const textElem = elem.append("text");
1604 textElem.attr("x", textData.x);
1605 textElem.attr("y", yfunc());
1606 if (textData.anchor !== void 0) {
1607 textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline);
1608 }
1609 if (textData.fontFamily !== void 0) {
1610 textElem.style("font-family", textData.fontFamily);
1611 }
1612 if (_textFontSizePx !== void 0) {
1613 textElem.style("font-size", _textFontSizePx);
1614 }
1615 if (textData.fontWeight !== void 0) {
1616 textElem.style("font-weight", textData.fontWeight);
1617 }
1618 if (textData.fill !== void 0) {
1619 textElem.attr("fill", textData.fill);
1620 }
1621 if (textData.class !== void 0) {
1622 textElem.attr("class", textData.class);
1623 }
1624 if (textData.dy !== void 0) {
1625 textElem.attr("dy", textData.dy);
1626 } else if (dy !== 0) {
1627 textElem.attr("dy", dy);
1628 }
1629 if (textData.tspan) {
1630 const span = textElem.append("tspan");
1631 span.attr("x", textData.x);
1632 if (textData.fill !== void 0) {
1633 span.attr("fill", textData.fill);
1634 }
1635 span.text(line);
1636 } else {
1637 textElem.text(line);
1638 }
1639 if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1640 textHeight += (textElem._groups || textElem)[0][0].getBBox().height;
1641 prevTextHeight = textHeight;
1642 }
1643 textElems.push(textElem);
1644 }
1645 return textElems;
1646};
1647const drawLabel = function(elem, txtObject) {
1648 function genPoints(x, y, width, height, cut) {
1649 return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
1650 }
1651 const polygon = elem.append("polygon");
1652 polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7));
1653 polygon.attr("class", "labelBox");
1654 txtObject.y = txtObject.y + txtObject.height / 2;
1655 drawText(elem, txtObject);
1656 return polygon;
1657};
1658let actorCnt = -1;
1659const fixLifeLineHeights = (diagram2, bounds2) => {
1660 if (!diagram2.selectAll) {
1661 return;
1662 }
1663 diagram2.selectAll(".actor-line").attr("class", "200").attr("y2", bounds2 - 55);
1664};
1665const drawActorTypeParticipant = function(elem, actor, conf2, isFooter) {
1666 const center = actor.x + actor.width / 2;
1667 const centerY = actor.y + 5;
1668 const boxpluslineGroup = elem.append("g");
1669 var g = boxpluslineGroup;
1670 if (!isFooter) {
1671 actorCnt++;
1672 g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("stroke-width", "0.5px").attr("stroke", "#999");
1673 g = boxpluslineGroup.append("g");
1674 actor.actorCnt = actorCnt;
1675 if (actor.links != null) {
1676 g.attr("id", "root-" + actorCnt);
1677 addPopupInteraction("#root-" + actorCnt, actorCnt);
1678 }
1679 }
1680 const rect = getNoteRect$1();
1681 var cssclass = "actor";
1682 if (actor.properties != null && actor.properties["class"]) {
1683 cssclass = actor.properties["class"];
1684 } else {
1685 rect.fill = "#eaeaea";
1686 }
1687 rect.x = actor.x;
1688 rect.y = actor.y;
1689 rect.width = actor.width;
1690 rect.height = actor.height;
1691 rect.class = cssclass;
1692 rect.rx = 3;
1693 rect.ry = 3;
1694 const rectElem = drawRect(g, rect);
1695 actor.rectData = rect;
1696 if (actor.properties != null && actor.properties["icon"]) {
1697 const iconSrc = actor.properties["icon"].trim();
1698 if (iconSrc.charAt(0) === "@") {
1699 drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1));
1700 } else {
1701 drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc);
1702 }
1703 }
1704 _drawTextCandidateFunc(conf2)(
1705 actor.description,
1706 g,
1707 rect.x,
1708 rect.y,
1709 rect.width,
1710 rect.height,
1711 { class: "actor" },
1712 conf2
1713 );
1714 let height = actor.height;
1715 if (rectElem.node) {
1716 const bounds2 = rectElem.node().getBBox();
1717 actor.height = bounds2.height;
1718 height = bounds2.height;
1719 }
1720 return height;
1721};
1722const drawActorTypeActor = function(elem, actor, conf2, isFooter) {
1723 const center = actor.x + actor.width / 2;
1724 const centerY = actor.y + 80;
1725 if (!isFooter) {
1726 actorCnt++;
1727 elem.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("stroke-width", "0.5px").attr("stroke", "#999");
1728 }
1729 const actElem = elem.append("g");
1730 actElem.attr("class", "actor-man");
1731 const rect = getNoteRect$1();
1732 rect.x = actor.x;
1733 rect.y = actor.y;
1734 rect.fill = "#eaeaea";
1735 rect.width = actor.width;
1736 rect.height = actor.height;
1737 rect.class = "actor";
1738 rect.rx = 3;
1739 rect.ry = 3;
1740 actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actor.y + 25).attr("x2", center).attr("y2", actor.y + 45);
1741 actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", center - 18).attr("y1", actor.y + 33).attr("x2", center + 18).attr("y2", actor.y + 33);
1742 actElem.append("line").attr("x1", center - 18).attr("y1", actor.y + 60).attr("x2", center).attr("y2", actor.y + 45);
1743 actElem.append("line").attr("x1", center).attr("y1", actor.y + 45).attr("x2", center + 16).attr("y2", actor.y + 60);
1744 const circle = actElem.append("circle");
1745 circle.attr("cx", actor.x + actor.width / 2);
1746 circle.attr("cy", actor.y + 10);
1747 circle.attr("r", 15);
1748 circle.attr("width", actor.width);
1749 circle.attr("height", actor.height);
1750 const bounds2 = actElem.node().getBBox();
1751 actor.height = bounds2.height;
1752 _drawTextCandidateFunc(conf2)(
1753 actor.description,
1754 actElem,
1755 rect.x,
1756 rect.y + 35,
1757 rect.width,
1758 rect.height,
1759 { class: "actor" },
1760 conf2
1761 );
1762 return actor.height;
1763};
1764const drawActor = function(elem, actor, conf2, isFooter) {
1765 switch (actor.type) {
1766 case "actor":
1767 return drawActorTypeActor(elem, actor, conf2, isFooter);
1768 case "participant":
1769 return drawActorTypeParticipant(elem, actor, conf2, isFooter);
1770 }
1771};
1772const drawBox = function(elem, box, conf2) {
1773 const boxplustextGroup = elem.append("g");
1774 const g = boxplustextGroup;
1775 drawBackgroundRect(g, box);
1776 if (box.name) {
1777 _drawTextCandidateFunc(conf2)(
1778 box.name,
1779 g,
1780 box.x,
1781 box.y + (box.textMaxHeight || 0) / 2,
1782 box.width,
1783 0,
1784 { class: "text" },
1785 conf2
1786 );
1787 }
1788 g.lower();
1789};
1790const anchorElement = function(elem) {
1791 return elem.append("g");
1792};
1793const drawActivation = function(elem, bounds2, verticalPos, conf2, actorActivations2) {
1794 const rect = getNoteRect$1();
1795 const g = bounds2.anchored;
1796 rect.x = bounds2.startx;
1797 rect.y = bounds2.starty;
1798 rect.class = "activation" + actorActivations2 % 3;
1799 rect.width = bounds2.stopx - bounds2.startx;
1800 rect.height = verticalPos - bounds2.starty;
1801 drawRect(g, rect);
1802};
1803const drawLoop = function(elem, loopModel, labelText, conf2) {
1804 const {
1805 boxMargin,
1806 boxTextMargin,
1807 labelBoxHeight,
1808 labelBoxWidth,
1809 messageFontFamily: fontFamily,
1810 messageFontSize: fontSize,
1811 messageFontWeight: fontWeight
1812 } = conf2;
1813 const g = elem.append("g");
1814 const drawLoopLine = function(startx, starty, stopx, stopy) {
1815 return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine");
1816 };
1817 drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty);
1818 drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy);
1819 drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy);
1820 drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy);
1821 if (loopModel.sections !== void 0) {
1822 loopModel.sections.forEach(function(item) {
1823 drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style(
1824 "stroke-dasharray",
1825 "3, 3"
1826 );
1827 });
1828 }
1829 let txt = getTextObj$1();
1830 txt.text = labelText;
1831 txt.x = loopModel.startx;
1832 txt.y = loopModel.starty;
1833 txt.fontFamily = fontFamily;
1834 txt.fontSize = fontSize;
1835 txt.fontWeight = fontWeight;
1836 txt.anchor = "middle";
1837 txt.valign = "middle";
1838 txt.tspan = false;
1839 txt.width = labelBoxWidth || 50;
1840 txt.height = labelBoxHeight || 20;
1841 txt.textMargin = boxTextMargin;
1842 txt.class = "labelText";
1843 drawLabel(g, txt);
1844 txt = getTextObj();
1845 txt.text = loopModel.title;
1846 txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2;
1847 txt.y = loopModel.starty + boxMargin + boxTextMargin;
1848 txt.anchor = "middle";
1849 txt.valign = "middle";
1850 txt.textMargin = boxTextMargin;
1851 txt.class = "loopText";
1852 txt.fontFamily = fontFamily;
1853 txt.fontSize = fontSize;
1854 txt.fontWeight = fontWeight;
1855 txt.wrap = true;
1856 let textElem = drawText(g, txt);
1857 if (loopModel.sectionTitles !== void 0) {
1858 loopModel.sectionTitles.forEach(function(item, idx) {
1859 if (item.message) {
1860 txt.text = item.message;
1861 txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2;
1862 txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin;
1863 txt.class = "loopText";
1864 txt.anchor = "middle";
1865 txt.valign = "middle";
1866 txt.tspan = false;
1867 txt.fontFamily = fontFamily;
1868 txt.fontSize = fontSize;
1869 txt.fontWeight = fontWeight;
1870 txt.wrap = loopModel.wrap;
1871 textElem = drawText(g, txt);
1872 let sectionHeight = Math.round(
1873 textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
1874 );
1875 loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin);
1876 }
1877 });
1878 }
1879 loopModel.height = Math.round(loopModel.stopy - loopModel.starty);
1880 return g;
1881};
1882const drawBackgroundRect = function(elem, bounds2) {
1883 drawBackgroundRect$1(elem, bounds2);
1884};
1885const insertDatabaseIcon = function(elem) {
1886 elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr(
1887 "d",
1888 "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z"
1889 );
1890};
1891const insertComputerIcon = function(elem) {
1892 elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
1893 "d",
1894 "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z"
1895 );
1896};
1897const insertClockIcon = function(elem) {
1898 elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
1899 "d",
1900 "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z"
1901 );
1902};
1903const insertArrowHead = function(elem) {
1904 elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z");
1905};
1906const insertArrowFilledHead = function(elem) {
1907 elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 18).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z");
1908};
1909const insertSequenceNumber = function(elem) {
1910 elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6);
1911};
1912const insertArrowCrossHead = function(elem) {
1913 const defs = elem.append("defs");
1914 const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 5);
1915 marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1pt").attr("d", "M 1,2 L 6,7 M 6,2 L 1,7");
1916};
1917const getTextObj = function() {
1918 return {
1919 x: 0,
1920 y: 0,
1921 fill: void 0,
1922 anchor: void 0,
1923 style: "#666",
1924 width: void 0,
1925 height: void 0,
1926 textMargin: 0,
1927 rx: 0,
1928 ry: 0,
1929 tspan: true,
1930 valign: void 0
1931 };
1932};
1933const getNoteRect = function() {
1934 return {
1935 x: 0,
1936 y: 0,
1937 fill: "#EDF2AE",
1938 stroke: "#666",
1939 width: 100,
1940 anchor: "start",
1941 height: 100,
1942 rx: 0,
1943 ry: 0
1944 };
1945};
1946const _drawTextCandidateFunc = function() {
1947 function byText(content, g, x, y, width, height, textAttrs) {
1948 const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content);
1949 _setTextAttrs(text, textAttrs);
1950 }
1951 function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
1952 const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
1953 const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize);
1954 const lines = content.split(common.lineBreakRegex);
1955 for (let i = 0; i < lines.length; i++) {
1956 const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2;
1957 const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").style("font-size", _actorFontSizePx).style("font-weight", actorFontWeight).style("font-family", actorFontFamily);
1958 text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
1959 text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
1960 _setTextAttrs(text, textAttrs);
1961 }
1962 }
1963 function byFo(content, g, x, y, width, height, textAttrs, conf2) {
1964 const s = g.append("switch");
1965 const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
1966 const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
1967 text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
1968 byTspan(content, s, x, y, width, height, textAttrs, conf2);
1969 _setTextAttrs(text, textAttrs);
1970 }
1971 function _setTextAttrs(toText, fromTextAttrsDict) {
1972 for (const key in fromTextAttrsDict) {
1973 if (fromTextAttrsDict.hasOwnProperty(key)) {
1974 toText.attr(key, fromTextAttrsDict[key]);
1975 }
1976 }
1977 }
1978 return function(conf2) {
1979 return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
1980 };
1981}();
1982const _drawMenuItemTextCandidateFunc = function() {
1983 function byText(content, g, x, y, width, height, textAttrs) {
1984 const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content);
1985 _setTextAttrs(text, textAttrs);
1986 }
1987 function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
1988 const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
1989 const lines = content.split(common.lineBreakRegex);
1990 for (let i = 0; i < lines.length; i++) {
1991 const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2;
1992 const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").style("font-size", actorFontSize).style("font-weight", actorFontWeight).style("font-family", actorFontFamily);
1993 text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]);
1994 text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
1995 _setTextAttrs(text, textAttrs);
1996 }
1997 }
1998 function byFo(content, g, x, y, width, height, textAttrs, conf2) {
1999 const s = g.append("switch");
2000 const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
2001 const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
2002 text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
2003 byTspan(content, s, x, y, width, height, textAttrs, conf2);
2004 _setTextAttrs(text, textAttrs);
2005 }
2006 function _setTextAttrs(toText, fromTextAttrsDict) {
2007 for (const key in fromTextAttrsDict) {
2008 if (fromTextAttrsDict.hasOwnProperty(key)) {
2009 toText.attr(key, fromTextAttrsDict[key]);
2010 }
2011 }
2012 }
2013 return function(conf2) {
2014 return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
2015 };
2016}();
2017const svgDraw = {
2018 drawRect,
2019 drawText,
2020 drawLabel,
2021 drawActor,
2022 drawBox,
2023 drawPopup,
2024 anchorElement,
2025 drawActivation,
2026 drawLoop,
2027 drawBackgroundRect,
2028 insertArrowHead,
2029 insertArrowFilledHead,
2030 insertSequenceNumber,
2031 insertArrowCrossHead,
2032 insertDatabaseIcon,
2033 insertComputerIcon,
2034 insertClockIcon,
2035 getTextObj,
2036 getNoteRect,
2037 popupMenu,
2038 popdownMenu,
2039 fixLifeLineHeights,
2040 sanitizeUrl
2041};
2042let conf = {};
2043const bounds = {
2044 data: {
2045 startx: void 0,
2046 stopx: void 0,
2047 starty: void 0,
2048 stopy: void 0
2049 },
2050 verticalPos: 0,
2051 sequenceItems: [],
2052 activations: [],
2053 models: {
2054 getHeight: function() {
2055 return Math.max.apply(
2056 null,
2057 this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0)
2058 ) + (this.loops.length === 0 ? 0 : this.loops.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.messages.length === 0 ? 0 : this.messages.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.notes.length === 0 ? 0 : this.notes.map((it) => it.height || 0).reduce((acc, h) => acc + h));
2059 },
2060 clear: function() {
2061 this.actors = [];
2062 this.boxes = [];
2063 this.loops = [];
2064 this.messages = [];
2065 this.notes = [];
2066 },
2067 addBox: function(boxModel) {
2068 this.boxes.push(boxModel);
2069 },
2070 addActor: function(actorModel) {
2071 this.actors.push(actorModel);
2072 },
2073 addLoop: function(loopModel) {
2074 this.loops.push(loopModel);
2075 },
2076 addMessage: function(msgModel) {
2077 this.messages.push(msgModel);
2078 },
2079 addNote: function(noteModel) {
2080 this.notes.push(noteModel);
2081 },
2082 lastActor: function() {
2083 return this.actors[this.actors.length - 1];
2084 },
2085 lastLoop: function() {
2086 return this.loops[this.loops.length - 1];
2087 },
2088 lastMessage: function() {
2089 return this.messages[this.messages.length - 1];
2090 },
2091 lastNote: function() {
2092 return this.notes[this.notes.length - 1];
2093 },
2094 actors: [],
2095 boxes: [],
2096 loops: [],
2097 messages: [],
2098 notes: []
2099 },
2100 init: function() {
2101 this.sequenceItems = [];
2102 this.activations = [];
2103 this.models.clear();
2104 this.data = {
2105 startx: void 0,
2106 stopx: void 0,
2107 starty: void 0,
2108 stopy: void 0
2109 };
2110 this.verticalPos = 0;
2111 setConf(getConfig());
2112 },
2113 updateVal: function(obj, key, val, fun) {
2114 if (obj[key] === void 0) {
2115 obj[key] = val;
2116 } else {
2117 obj[key] = fun(val, obj[key]);
2118 }
2119 },
2120 updateBounds: function(startx, starty, stopx, stopy) {
2121 const _self = this;
2122 let cnt = 0;
2123 function updateFn(type) {
2124 return function updateItemBounds(item) {
2125 cnt++;
2126 const n = _self.sequenceItems.length - cnt + 1;
2127 _self.updateVal(item, "starty", starty - n * conf.boxMargin, Math.min);
2128 _self.updateVal(item, "stopy", stopy + n * conf.boxMargin, Math.max);
2129 _self.updateVal(bounds.data, "startx", startx - n * conf.boxMargin, Math.min);
2130 _self.updateVal(bounds.data, "stopx", stopx + n * conf.boxMargin, Math.max);
2131 if (!(type === "activation")) {
2132 _self.updateVal(item, "startx", startx - n * conf.boxMargin, Math.min);
2133 _self.updateVal(item, "stopx", stopx + n * conf.boxMargin, Math.max);
2134 _self.updateVal(bounds.data, "starty", starty - n * conf.boxMargin, Math.min);
2135 _self.updateVal(bounds.data, "stopy", stopy + n * conf.boxMargin, Math.max);
2136 }
2137 };
2138 }
2139 this.sequenceItems.forEach(updateFn());
2140 this.activations.forEach(updateFn("activation"));
2141 },
2142 insert: function(startx, starty, stopx, stopy) {
2143 const _startx = common.getMin(startx, stopx);
2144 const _stopx = common.getMax(startx, stopx);
2145 const _starty = common.getMin(starty, stopy);
2146 const _stopy = common.getMax(starty, stopy);
2147 this.updateVal(bounds.data, "startx", _startx, Math.min);
2148 this.updateVal(bounds.data, "starty", _starty, Math.min);
2149 this.updateVal(bounds.data, "stopx", _stopx, Math.max);
2150 this.updateVal(bounds.data, "stopy", _stopy, Math.max);
2151 this.updateBounds(_startx, _starty, _stopx, _stopy);
2152 },
2153 newActivation: function(message, diagram2, actors2) {
2154 const actorRect = actors2[message.from.actor];
2155 const stackedSize = actorActivations(message.from.actor).length || 0;
2156 const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
2157 this.activations.push({
2158 startx: x,
2159 starty: this.verticalPos + 2,
2160 stopx: x + conf.activationWidth,
2161 stopy: void 0,
2162 actor: message.from.actor,
2163 anchored: svgDraw.anchorElement(diagram2)
2164 });
2165 },
2166 endActivation: function(message) {
2167 const lastActorActivationIdx = this.activations.map(function(activation) {
2168 return activation.actor;
2169 }).lastIndexOf(message.from.actor);
2170 return this.activations.splice(lastActorActivationIdx, 1)[0];
2171 },
2172 createLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2173 return {
2174 startx: void 0,
2175 starty: this.verticalPos,
2176 stopx: void 0,
2177 stopy: void 0,
2178 title: title.message,
2179 wrap: title.wrap,
2180 width: title.width,
2181 height: 0,
2182 fill
2183 };
2184 },
2185 newLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2186 this.sequenceItems.push(this.createLoop(title, fill));
2187 },
2188 endLoop: function() {
2189 return this.sequenceItems.pop();
2190 },
2191 isLoopOverlap: function() {
2192 return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false;
2193 },
2194 addSectionToLoop: function(message) {
2195 const loop = this.sequenceItems.pop();
2196 loop.sections = loop.sections || [];
2197 loop.sectionTitles = loop.sectionTitles || [];
2198 loop.sections.push({ y: bounds.getVerticalPos(), height: 0 });
2199 loop.sectionTitles.push(message);
2200 this.sequenceItems.push(loop);
2201 },
2202 saveVerticalPos: function() {
2203 if (this.isLoopOverlap()) {
2204 this.savedVerticalPos = this.verticalPos;
2205 }
2206 },
2207 resetVerticalPos: function() {
2208 if (this.isLoopOverlap()) {
2209 this.verticalPos = this.savedVerticalPos;
2210 }
2211 },
2212 bumpVerticalPos: function(bump) {
2213 this.verticalPos = this.verticalPos + bump;
2214 this.data.stopy = common.getMax(this.data.stopy, this.verticalPos);
2215 },
2216 getVerticalPos: function() {
2217 return this.verticalPos;
2218 },
2219 getBounds: function() {
2220 return { bounds: this.data, models: this.models };
2221 }
2222};
2223const drawNote = function(elem, noteModel) {
2224 bounds.bumpVerticalPos(conf.boxMargin);
2225 noteModel.height = conf.boxMargin;
2226 noteModel.starty = bounds.getVerticalPos();
2227 const rect = getNoteRect$1();
2228 rect.x = noteModel.startx;
2229 rect.y = noteModel.starty;
2230 rect.width = noteModel.width || conf.width;
2231 rect.class = "note";
2232 const g = elem.append("g");
2233 const rectElem = svgDraw.drawRect(g, rect);
2234 const textObj = getTextObj$1();
2235 textObj.x = noteModel.startx;
2236 textObj.y = noteModel.starty;
2237 textObj.width = rect.width;
2238 textObj.dy = "1em";
2239 textObj.text = noteModel.message;
2240 textObj.class = "noteText";
2241 textObj.fontFamily = conf.noteFontFamily;
2242 textObj.fontSize = conf.noteFontSize;
2243 textObj.fontWeight = conf.noteFontWeight;
2244 textObj.anchor = conf.noteAlign;
2245 textObj.textMargin = conf.noteMargin;
2246 textObj.valign = "center";
2247 const textElem = drawText(g, textObj);
2248 const textHeight = Math.round(
2249 textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
2250 );
2251 rectElem.attr("height", textHeight + 2 * conf.noteMargin);
2252 noteModel.height += textHeight + 2 * conf.noteMargin;
2253 bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin);
2254 noteModel.stopy = noteModel.starty + textHeight + 2 * conf.noteMargin;
2255 noteModel.stopx = noteModel.startx + rect.width;
2256 bounds.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy);
2257 bounds.models.addNote(noteModel);
2258};
2259const messageFont = (cnf) => {
2260 return {
2261 fontFamily: cnf.messageFontFamily,
2262 fontSize: cnf.messageFontSize,
2263 fontWeight: cnf.messageFontWeight
2264 };
2265};
2266const noteFont = (cnf) => {
2267 return {
2268 fontFamily: cnf.noteFontFamily,
2269 fontSize: cnf.noteFontSize,
2270 fontWeight: cnf.noteFontWeight
2271 };
2272};
2273const actorFont = (cnf) => {
2274 return {
2275 fontFamily: cnf.actorFontFamily,
2276 fontSize: cnf.actorFontSize,
2277 fontWeight: cnf.actorFontWeight
2278 };
2279};
2280function boundMessage(_diagram, msgModel) {
2281 bounds.bumpVerticalPos(10);
2282 const { startx, stopx, message } = msgModel;
2283 const lines = common.splitBreaks(message).length;
2284 const textDims = utils.calculateTextDimensions(message, messageFont(conf));
2285 const lineHeight = textDims.height / lines;
2286 msgModel.height += lineHeight;
2287 bounds.bumpVerticalPos(lineHeight);
2288 let lineStartY;
2289 let totalOffset = textDims.height - 10;
2290 const textWidth = textDims.width;
2291 if (startx === stopx) {
2292 lineStartY = bounds.getVerticalPos() + totalOffset;
2293 if (!conf.rightAngles) {
2294 totalOffset += conf.boxMargin;
2295 lineStartY = bounds.getVerticalPos() + totalOffset;
2296 }
2297 totalOffset += 30;
2298 const dx = common.getMax(textWidth / 2, conf.width / 2);
2299 bounds.insert(
2300 startx - dx,
2301 bounds.getVerticalPos() - 10 + totalOffset,
2302 stopx + dx,
2303 bounds.getVerticalPos() + 30 + totalOffset
2304 );
2305 } else {
2306 totalOffset += conf.boxMargin;
2307 lineStartY = bounds.getVerticalPos() + totalOffset;
2308 bounds.insert(startx, lineStartY - 10, stopx, lineStartY);
2309 }
2310 bounds.bumpVerticalPos(totalOffset);
2311 msgModel.height += totalOffset;
2312 msgModel.stopy = msgModel.starty + msgModel.height;
2313 bounds.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy);
2314 return lineStartY;
2315}
2316const drawMessage = function(diagram2, msgModel, lineStartY, diagObj) {
2317 const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel;
2318 const textDims = utils.calculateTextDimensions(message, messageFont(conf));
2319 const textObj = getTextObj$1();
2320 textObj.x = startx;
2321 textObj.y = starty + 10;
2322 textObj.width = stopx - startx;
2323 textObj.class = "messageText";
2324 textObj.dy = "1em";
2325 textObj.text = message;
2326 textObj.fontFamily = conf.messageFontFamily;
2327 textObj.fontSize = conf.messageFontSize;
2328 textObj.fontWeight = conf.messageFontWeight;
2329 textObj.anchor = conf.messageAlign;
2330 textObj.valign = "center";
2331 textObj.textMargin = conf.wrapPadding;
2332 textObj.tspan = false;
2333 drawText(diagram2, textObj);
2334 const textWidth = textDims.width;
2335 let line;
2336 if (startx === stopx) {
2337 if (conf.rightAngles) {
2338 line = diagram2.append("path").attr(
2339 "d",
2340 `M ${startx},${lineStartY} H ${startx + common.getMax(conf.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}`
2341 );
2342 } else {
2343 line = diagram2.append("path").attr(
2344 "d",
2345 "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20)
2346 );
2347 }
2348 } else {
2349 line = diagram2.append("line");
2350 line.attr("x1", startx);
2351 line.attr("y1", lineStartY);
2352 line.attr("x2", stopx);
2353 line.attr("y2", lineStartY);
2354 }
2355 if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN) {
2356 line.style("stroke-dasharray", "3, 3");
2357 line.attr("class", "messageLine1");
2358 } else {
2359 line.attr("class", "messageLine0");
2360 }
2361 let url = "";
2362 if (conf.arrowMarkerAbsolute) {
2363 url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
2364 url = url.replace(/\(/g, "\\(");
2365 url = url.replace(/\)/g, "\\)");
2366 }
2367 line.attr("stroke-width", 2);
2368 line.attr("stroke", "none");
2369 line.style("fill", "none");
2370 if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) {
2371 line.attr("marker-end", "url(" + url + "#arrowhead)");
2372 }
2373 if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) {
2374 line.attr("marker-end", "url(" + url + "#filled-head)");
2375 }
2376 if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) {
2377 line.attr("marker-end", "url(" + url + "#crosshead)");
2378 }
2379 if (sequenceVisible || conf.showSequenceNumbers) {
2380 line.attr("marker-start", "url(" + url + "#sequencenumber)");
2381 diagram2.append("text").attr("x", startx).attr("y", lineStartY + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(sequenceIndex);
2382 }
2383};
2384const drawActors = function(diagram2, actors2, actorKeys, verticalPos, configuration, messages2, isFooter) {
2385 if (configuration.hideUnusedParticipants === true) {
2386 const newActors = /* @__PURE__ */ new Set();
2387 messages2.forEach((message) => {
2388 newActors.add(message.from);
2389 newActors.add(message.to);
2390 });
2391 actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey));
2392 }
2393 let prevWidth = 0;
2394 let prevMargin = 0;
2395 let maxHeight = 0;
2396 let prevBox = void 0;
2397 for (const actorKey of actorKeys) {
2398 const actor = actors2[actorKey];
2399 const box = actor.box;
2400 if (prevBox && prevBox != box) {
2401 if (!isFooter) {
2402 bounds.models.addBox(prevBox);
2403 }
2404 prevMargin += conf.boxMargin + prevBox.margin;
2405 }
2406 if (box && box != prevBox) {
2407 if (!isFooter) {
2408 box.x = prevWidth + prevMargin;
2409 box.y = verticalPos;
2410 }
2411 prevMargin += box.margin;
2412 }
2413 actor.width = actor.width || conf.width;
2414 actor.height = common.getMax(actor.height || conf.height, conf.height);
2415 actor.margin = actor.margin || conf.actorMargin;
2416 actor.x = prevWidth + prevMargin;
2417 actor.y = bounds.getVerticalPos();
2418 const height = svgDraw.drawActor(diagram2, actor, conf, isFooter);
2419 maxHeight = common.getMax(maxHeight, height);
2420 bounds.insert(actor.x, verticalPos, actor.x + actor.width, actor.height);
2421 prevWidth += actor.width + prevMargin;
2422 if (actor.box) {
2423 actor.box.width = prevWidth + box.margin - actor.box.x;
2424 }
2425 prevMargin = actor.margin;
2426 prevBox = actor.box;
2427 bounds.models.addActor(actor);
2428 }
2429 if (prevBox && !isFooter) {
2430 bounds.models.addBox(prevBox);
2431 }
2432 bounds.bumpVerticalPos(maxHeight);
2433};
2434const drawActorsPopup = function(diagram2, actors2, actorKeys, doc) {
2435 let maxHeight = 0;
2436 let maxWidth = 0;
2437 for (const actorKey of actorKeys) {
2438 const actor = actors2[actorKey];
2439 const minMenuWidth = getRequiredPopupWidth(actor);
2440 const menuDimensions = svgDraw.drawPopup(
2441 diagram2,
2442 actor,
2443 minMenuWidth,
2444 conf,
2445 conf.forceMenus,
2446 doc
2447 );
2448 if (menuDimensions.height > maxHeight) {
2449 maxHeight = menuDimensions.height;
2450 }
2451 if (menuDimensions.width + actor.x > maxWidth) {
2452 maxWidth = menuDimensions.width + actor.x;
2453 }
2454 }
2455 return { maxHeight, maxWidth };
2456};
2457const setConf = function(cnf) {
2458 assignWithDepth(conf, cnf);
2459 if (cnf.fontFamily) {
2460 conf.actorFontFamily = conf.noteFontFamily = conf.messageFontFamily = cnf.fontFamily;
2461 }
2462 if (cnf.fontSize) {
2463 conf.actorFontSize = conf.noteFontSize = conf.messageFontSize = cnf.fontSize;
2464 }
2465 if (cnf.fontWeight) {
2466 conf.actorFontWeight = conf.noteFontWeight = conf.messageFontWeight = cnf.fontWeight;
2467 }
2468};
2469const actorActivations = function(actor) {
2470 return bounds.activations.filter(function(activation) {
2471 return activation.actor === actor;
2472 });
2473};
2474const activationBounds = function(actor, actors2) {
2475 const actorObj = actors2[actor];
2476 const activations = actorActivations(actor);
2477 const left = activations.reduce(function(acc, activation) {
2478 return common.getMin(acc, activation.startx);
2479 }, actorObj.x + actorObj.width / 2);
2480 const right = activations.reduce(function(acc, activation) {
2481 return common.getMax(acc, activation.stopx);
2482 }, actorObj.x + actorObj.width / 2);
2483 return [left, right];
2484};
2485function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) {
2486 bounds.bumpVerticalPos(preMargin);
2487 let heightAdjust = postMargin;
2488 if (msg.id && msg.message && loopWidths[msg.id]) {
2489 const loopWidth = loopWidths[msg.id].width;
2490 const textConf = messageFont(conf);
2491 msg.message = utils.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf.wrapPadding, textConf);
2492 msg.width = loopWidth;
2493 msg.wrap = true;
2494 const textDims = utils.calculateTextDimensions(msg.message, textConf);
2495 const totalOffset = common.getMax(textDims.height, conf.labelBoxHeight);
2496 heightAdjust = postMargin + totalOffset;
2497 log.debug(`${totalOffset} - ${msg.message}`);
2498 }
2499 addLoopFn(msg);
2500 bounds.bumpVerticalPos(heightAdjust);
2501}
2502const draw = function(_text, id, _version, diagObj) {
2503 const { securityLevel, sequence } = getConfig();
2504 conf = sequence;
2505 diagObj.db.clear();
2506 diagObj.parser.parse(_text);
2507 let sandboxElement;
2508 if (securityLevel === "sandbox") {
2509 sandboxElement = select("#i" + id);
2510 }
2511 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
2512 const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
2513 bounds.init();
2514 log.debug(diagObj.db);
2515 const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`);
2516 const actors2 = diagObj.db.getActors();
2517 const boxes2 = diagObj.db.getBoxes();
2518 const actorKeys = diagObj.db.getActorKeys();
2519 const messages2 = diagObj.db.getMessages();
2520 const title = diagObj.db.getDiagramTitle();
2521 const hasBoxes = diagObj.db.hasAtLeastOneBox();
2522 const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle();
2523 const maxMessageWidthPerActor = getMaxMessageWidthPerActor(actors2, messages2, diagObj);
2524 conf.height = calculateActorMargins(actors2, maxMessageWidthPerActor, boxes2);
2525 svgDraw.insertComputerIcon(diagram2);
2526 svgDraw.insertDatabaseIcon(diagram2);
2527 svgDraw.insertClockIcon(diagram2);
2528 if (hasBoxes) {
2529 bounds.bumpVerticalPos(conf.boxMargin);
2530 if (hasBoxTitles) {
2531 bounds.bumpVerticalPos(boxes2[0].textMaxHeight);
2532 }
2533 }
2534 drawActors(diagram2, actors2, actorKeys, 0, conf, messages2, false);
2535 const loopWidths = calculateLoopBounds(messages2, actors2, maxMessageWidthPerActor, diagObj);
2536 svgDraw.insertArrowHead(diagram2);
2537 svgDraw.insertArrowCrossHead(diagram2);
2538 svgDraw.insertArrowFilledHead(diagram2);
2539 svgDraw.insertSequenceNumber(diagram2);
2540 function activeEnd(msg, verticalPos) {
2541 const activationData = bounds.endActivation(msg);
2542 if (activationData.starty + 18 > verticalPos) {
2543 activationData.starty = verticalPos - 6;
2544 verticalPos += 12;
2545 }
2546 svgDraw.drawActivation(
2547 diagram2,
2548 activationData,
2549 verticalPos,
2550 conf,
2551 actorActivations(msg.from.actor).length
2552 );
2553 bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos);
2554 }
2555 let sequenceIndex = 1;
2556 let sequenceIndexStep = 1;
2557 const messagesToDraw = [];
2558 messages2.forEach(function(msg) {
2559 let loopModel, noteModel, msgModel;
2560 switch (msg.type) {
2561 case diagObj.db.LINETYPE.NOTE:
2562 bounds.resetVerticalPos();
2563 noteModel = msg.noteModel;
2564 drawNote(diagram2, noteModel);
2565 break;
2566 case diagObj.db.LINETYPE.ACTIVE_START:
2567 bounds.newActivation(msg, diagram2, actors2);
2568 break;
2569 case diagObj.db.LINETYPE.ACTIVE_END:
2570 activeEnd(msg, bounds.getVerticalPos());
2571 break;
2572 case diagObj.db.LINETYPE.LOOP_START:
2573 adjustLoopHeightForWrap(
2574 loopWidths,
2575 msg,
2576 conf.boxMargin,
2577 conf.boxMargin + conf.boxTextMargin,
2578 (message) => bounds.newLoop(message)
2579 );
2580 break;
2581 case diagObj.db.LINETYPE.LOOP_END:
2582 loopModel = bounds.endLoop();
2583 svgDraw.drawLoop(diagram2, loopModel, "loop", conf);
2584 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2585 bounds.models.addLoop(loopModel);
2586 break;
2587 case diagObj.db.LINETYPE.RECT_START:
2588 adjustLoopHeightForWrap(
2589 loopWidths,
2590 msg,
2591 conf.boxMargin,
2592 conf.boxMargin,
2593 (message) => bounds.newLoop(void 0, message.message)
2594 );
2595 break;
2596 case diagObj.db.LINETYPE.RECT_END:
2597 loopModel = bounds.endLoop();
2598 svgDraw.drawBackgroundRect(diagram2, loopModel);
2599 bounds.models.addLoop(loopModel);
2600 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2601 break;
2602 case diagObj.db.LINETYPE.OPT_START:
2603 adjustLoopHeightForWrap(
2604 loopWidths,
2605 msg,
2606 conf.boxMargin,
2607 conf.boxMargin + conf.boxTextMargin,
2608 (message) => bounds.newLoop(message)
2609 );
2610 break;
2611 case diagObj.db.LINETYPE.OPT_END:
2612 loopModel = bounds.endLoop();
2613 svgDraw.drawLoop(diagram2, loopModel, "opt", conf);
2614 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2615 bounds.models.addLoop(loopModel);
2616 break;
2617 case diagObj.db.LINETYPE.ALT_START:
2618 adjustLoopHeightForWrap(
2619 loopWidths,
2620 msg,
2621 conf.boxMargin,
2622 conf.boxMargin + conf.boxTextMargin,
2623 (message) => bounds.newLoop(message)
2624 );
2625 break;
2626 case diagObj.db.LINETYPE.ALT_ELSE:
2627 adjustLoopHeightForWrap(
2628 loopWidths,
2629 msg,
2630 conf.boxMargin + conf.boxTextMargin,
2631 conf.boxMargin,
2632 (message) => bounds.addSectionToLoop(message)
2633 );
2634 break;
2635 case diagObj.db.LINETYPE.ALT_END:
2636 loopModel = bounds.endLoop();
2637 svgDraw.drawLoop(diagram2, loopModel, "alt", conf);
2638 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2639 bounds.models.addLoop(loopModel);
2640 break;
2641 case diagObj.db.LINETYPE.PAR_START:
2642 case diagObj.db.LINETYPE.PAR_OVER_START:
2643 adjustLoopHeightForWrap(
2644 loopWidths,
2645 msg,
2646 conf.boxMargin,
2647 conf.boxMargin + conf.boxTextMargin,
2648 (message) => bounds.newLoop(message)
2649 );
2650 bounds.saveVerticalPos();
2651 break;
2652 case diagObj.db.LINETYPE.PAR_AND:
2653 adjustLoopHeightForWrap(
2654 loopWidths,
2655 msg,
2656 conf.boxMargin + conf.boxTextMargin,
2657 conf.boxMargin,
2658 (message) => bounds.addSectionToLoop(message)
2659 );
2660 break;
2661 case diagObj.db.LINETYPE.PAR_END:
2662 loopModel = bounds.endLoop();
2663 svgDraw.drawLoop(diagram2, loopModel, "par", conf);
2664 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2665 bounds.models.addLoop(loopModel);
2666 break;
2667 case diagObj.db.LINETYPE.AUTONUMBER:
2668 sequenceIndex = msg.message.start || sequenceIndex;
2669 sequenceIndexStep = msg.message.step || sequenceIndexStep;
2670 if (msg.message.visible) {
2671 diagObj.db.enableSequenceNumbers();
2672 } else {
2673 diagObj.db.disableSequenceNumbers();
2674 }
2675 break;
2676 case diagObj.db.LINETYPE.CRITICAL_START:
2677 adjustLoopHeightForWrap(
2678 loopWidths,
2679 msg,
2680 conf.boxMargin,
2681 conf.boxMargin + conf.boxTextMargin,
2682 (message) => bounds.newLoop(message)
2683 );
2684 break;
2685 case diagObj.db.LINETYPE.CRITICAL_OPTION:
2686 adjustLoopHeightForWrap(
2687 loopWidths,
2688 msg,
2689 conf.boxMargin + conf.boxTextMargin,
2690 conf.boxMargin,
2691 (message) => bounds.addSectionToLoop(message)
2692 );
2693 break;
2694 case diagObj.db.LINETYPE.CRITICAL_END:
2695 loopModel = bounds.endLoop();
2696 svgDraw.drawLoop(diagram2, loopModel, "critical", conf);
2697 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2698 bounds.models.addLoop(loopModel);
2699 break;
2700 case diagObj.db.LINETYPE.BREAK_START:
2701 adjustLoopHeightForWrap(
2702 loopWidths,
2703 msg,
2704 conf.boxMargin,
2705 conf.boxMargin + conf.boxTextMargin,
2706 (message) => bounds.newLoop(message)
2707 );
2708 break;
2709 case diagObj.db.LINETYPE.BREAK_END:
2710 loopModel = bounds.endLoop();
2711 svgDraw.drawLoop(diagram2, loopModel, "break", conf);
2712 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2713 bounds.models.addLoop(loopModel);
2714 break;
2715 default:
2716 try {
2717 bounds.resetVerticalPos();
2718 msgModel = msg.msgModel;
2719 msgModel.starty = bounds.getVerticalPos();
2720 msgModel.sequenceIndex = sequenceIndex;
2721 msgModel.sequenceVisible = diagObj.db.showSequenceNumbers();
2722 const lineStartY = boundMessage(diagram2, msgModel);
2723 messagesToDraw.push({ messageModel: msgModel, lineStartY });
2724 bounds.models.addMessage(msgModel);
2725 } catch (e) {
2726 log.error("error while drawing message", e);
2727 }
2728 }
2729 if ([
2730 diagObj.db.LINETYPE.SOLID_OPEN,
2731 diagObj.db.LINETYPE.DOTTED_OPEN,
2732 diagObj.db.LINETYPE.SOLID,
2733 diagObj.db.LINETYPE.DOTTED,
2734 diagObj.db.LINETYPE.SOLID_CROSS,
2735 diagObj.db.LINETYPE.DOTTED_CROSS,
2736 diagObj.db.LINETYPE.SOLID_POINT,
2737 diagObj.db.LINETYPE.DOTTED_POINT
2738 ].includes(msg.type)) {
2739 sequenceIndex = sequenceIndex + sequenceIndexStep;
2740 }
2741 });
2742 messagesToDraw.forEach((e) => drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj));
2743 if (conf.mirrorActors) {
2744 bounds.bumpVerticalPos(conf.boxMargin * 2);
2745 drawActors(diagram2, actors2, actorKeys, bounds.getVerticalPos(), conf, messages2, true);
2746 bounds.bumpVerticalPos(conf.boxMargin);
2747 fixLifeLineHeights(diagram2, bounds.getVerticalPos());
2748 }
2749 bounds.models.boxes.forEach(function(box2) {
2750 box2.height = bounds.getVerticalPos() - box2.y;
2751 bounds.insert(box2.x, box2.y, box2.x + box2.width, box2.height);
2752 box2.startx = box2.x;
2753 box2.starty = box2.y;
2754 box2.stopx = box2.startx + box2.width;
2755 box2.stopy = box2.starty + box2.height;
2756 box2.stroke = "rgb(0,0,0, 0.5)";
2757 svgDraw.drawBox(diagram2, box2, conf);
2758 });
2759 if (hasBoxes) {
2760 bounds.bumpVerticalPos(conf.boxMargin);
2761 }
2762 const requiredBoxSize = drawActorsPopup(diagram2, actors2, actorKeys, doc);
2763 const { bounds: box } = bounds.getBounds();
2764 log.debug("For line height fix Querying: #" + id + " .actor-line");
2765 const actorLines = selectAll("#" + id + " .actor-line");
2766 actorLines.attr("y2", box.stopy);
2767 let boxHeight = box.stopy - box.starty;
2768 if (boxHeight < requiredBoxSize.maxHeight) {
2769 boxHeight = requiredBoxSize.maxHeight;
2770 }
2771 let height = boxHeight + 2 * conf.diagramMarginY;
2772 if (conf.mirrorActors) {
2773 height = height - conf.boxMargin + conf.bottomMarginAdj;
2774 }
2775 let boxWidth = box.stopx - box.startx;
2776 if (boxWidth < requiredBoxSize.maxWidth) {
2777 boxWidth = requiredBoxSize.maxWidth;
2778 }
2779 const width = boxWidth + 2 * conf.diagramMarginX;
2780 if (title) {
2781 diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf.diagramMarginX).attr("y", -25);
2782 }
2783 configureSvgSize(diagram2, height, width, conf.useMaxWidth);
2784 const extraVertForTitle = title ? 40 : 0;
2785 diagram2.attr(
2786 "viewBox",
2787 box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle)
2788 );
2789 log.debug(`models:`, bounds.models);
2790};
2791function getMaxMessageWidthPerActor(actors2, messages2, diagObj) {
2792 const maxMessageWidthPerActor = {};
2793 messages2.forEach(function(msg) {
2794 if (actors2[msg.to] && actors2[msg.from]) {
2795 const actor = actors2[msg.to];
2796 if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) {
2797 return;
2798 }
2799 if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) {
2800 return;
2801 }
2802 const isNote = msg.placement !== void 0;
2803 const isMessage = !isNote;
2804 const textFont = isNote ? noteFont(conf) : messageFont(conf);
2805 const wrappedMessage = msg.wrap ? utils.wrapLabel(msg.message, conf.width - 2 * conf.wrapPadding, textFont) : msg.message;
2806 const messageDimensions = utils.calculateTextDimensions(wrappedMessage, textFont);
2807 const messageWidth = messageDimensions.width + 2 * conf.wrapPadding;
2808 if (isMessage && msg.from === actor.nextActor) {
2809 maxMessageWidthPerActor[msg.to] = common.getMax(
2810 maxMessageWidthPerActor[msg.to] || 0,
2811 messageWidth
2812 );
2813 } else if (isMessage && msg.from === actor.prevActor) {
2814 maxMessageWidthPerActor[msg.from] = common.getMax(
2815 maxMessageWidthPerActor[msg.from] || 0,
2816 messageWidth
2817 );
2818 } else if (isMessage && msg.from === msg.to) {
2819 maxMessageWidthPerActor[msg.from] = common.getMax(
2820 maxMessageWidthPerActor[msg.from] || 0,
2821 messageWidth / 2
2822 );
2823 maxMessageWidthPerActor[msg.to] = common.getMax(
2824 maxMessageWidthPerActor[msg.to] || 0,
2825 messageWidth / 2
2826 );
2827 } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
2828 maxMessageWidthPerActor[msg.from] = common.getMax(
2829 maxMessageWidthPerActor[msg.from] || 0,
2830 messageWidth
2831 );
2832 } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
2833 maxMessageWidthPerActor[actor.prevActor] = common.getMax(
2834 maxMessageWidthPerActor[actor.prevActor] || 0,
2835 messageWidth
2836 );
2837 } else if (msg.placement === diagObj.db.PLACEMENT.OVER) {
2838 if (actor.prevActor) {
2839 maxMessageWidthPerActor[actor.prevActor] = common.getMax(
2840 maxMessageWidthPerActor[actor.prevActor] || 0,
2841 messageWidth / 2
2842 );
2843 }
2844 if (actor.nextActor) {
2845 maxMessageWidthPerActor[msg.from] = common.getMax(
2846 maxMessageWidthPerActor[msg.from] || 0,
2847 messageWidth / 2
2848 );
2849 }
2850 }
2851 }
2852 });
2853 log.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor);
2854 return maxMessageWidthPerActor;
2855}
2856const getRequiredPopupWidth = function(actor) {
2857 let requiredPopupWidth = 0;
2858 const textFont = actorFont(conf);
2859 for (const key in actor.links) {
2860 const labelDimensions = utils.calculateTextDimensions(key, textFont);
2861 const labelWidth = labelDimensions.width + 2 * conf.wrapPadding + 2 * conf.boxMargin;
2862 if (requiredPopupWidth < labelWidth) {
2863 requiredPopupWidth = labelWidth;
2864 }
2865 }
2866 return requiredPopupWidth;
2867};
2868function calculateActorMargins(actors2, actorToMessageWidth, boxes2) {
2869 let maxHeight = 0;
2870 Object.keys(actors2).forEach((prop) => {
2871 const actor = actors2[prop];
2872 if (actor.wrap) {
2873 actor.description = utils.wrapLabel(
2874 actor.description,
2875 conf.width - 2 * conf.wrapPadding,
2876 actorFont(conf)
2877 );
2878 }
2879 const actDims = utils.calculateTextDimensions(actor.description, actorFont(conf));
2880 actor.width = actor.wrap ? conf.width : common.getMax(conf.width, actDims.width + 2 * conf.wrapPadding);
2881 actor.height = actor.wrap ? common.getMax(actDims.height, conf.height) : conf.height;
2882 maxHeight = common.getMax(maxHeight, actor.height);
2883 });
2884 for (const actorKey in actorToMessageWidth) {
2885 const actor = actors2[actorKey];
2886 if (!actor) {
2887 continue;
2888 }
2889 const nextActor = actors2[actor.nextActor];
2890 if (!nextActor) {
2891 const messageWidth2 = actorToMessageWidth[actorKey];
2892 const actorWidth2 = messageWidth2 + conf.actorMargin - actor.width / 2;
2893 actor.margin = common.getMax(actorWidth2, conf.actorMargin);
2894 continue;
2895 }
2896 const messageWidth = actorToMessageWidth[actorKey];
2897 const actorWidth = messageWidth + conf.actorMargin - actor.width / 2 - nextActor.width / 2;
2898 actor.margin = common.getMax(actorWidth, conf.actorMargin);
2899 }
2900 let maxBoxHeight = 0;
2901 boxes2.forEach((box) => {
2902 const textFont = messageFont(conf);
2903 let totalWidth = box.actorKeys.reduce((total, aKey) => {
2904 return total += actors2[aKey].width + (actors2[aKey].margin || 0);
2905 }, 0);
2906 totalWidth -= 2 * conf.boxTextMargin;
2907 if (box.wrap) {
2908 box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont);
2909 }
2910 const boxMsgDimensions = utils.calculateTextDimensions(box.name, textFont);
2911 maxBoxHeight = common.getMax(boxMsgDimensions.height, maxBoxHeight);
2912 const minWidth = common.getMax(totalWidth, boxMsgDimensions.width + 2 * conf.wrapPadding);
2913 box.margin = conf.boxTextMargin;
2914 if (totalWidth < minWidth) {
2915 const missing = (minWidth - totalWidth) / 2;
2916 box.margin += missing;
2917 }
2918 });
2919 boxes2.forEach((box) => box.textMaxHeight = maxBoxHeight);
2920 return common.getMax(maxHeight, conf.height);
2921}
2922const buildNoteModel = function(msg, actors2, diagObj) {
2923 const startx = actors2[msg.from].x;
2924 const stopx = actors2[msg.to].x;
2925 const shouldWrap = msg.wrap && msg.message;
2926 let textDimensions = utils.calculateTextDimensions(
2927 shouldWrap ? utils.wrapLabel(msg.message, conf.width, noteFont(conf)) : msg.message,
2928 noteFont(conf)
2929 );
2930 const noteModel = {
2931 width: shouldWrap ? conf.width : common.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin),
2932 height: 0,
2933 startx: actors2[msg.from].x,
2934 stopx: 0,
2935 starty: 0,
2936 stopy: 0,
2937 message: msg.message
2938 };
2939 if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
2940 noteModel.width = shouldWrap ? common.getMax(conf.width, textDimensions.width) : common.getMax(
2941 actors2[msg.from].width / 2 + actors2[msg.to].width / 2,
2942 textDimensions.width + 2 * conf.noteMargin
2943 );
2944 noteModel.startx = startx + (actors2[msg.from].width + conf.actorMargin) / 2;
2945 } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
2946 noteModel.width = shouldWrap ? common.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common.getMax(
2947 actors2[msg.from].width / 2 + actors2[msg.to].width / 2,
2948 textDimensions.width + 2 * conf.noteMargin
2949 );
2950 noteModel.startx = startx - noteModel.width + (actors2[msg.from].width - conf.actorMargin) / 2;
2951 } else if (msg.to === msg.from) {
2952 textDimensions = utils.calculateTextDimensions(
2953 shouldWrap ? utils.wrapLabel(
2954 msg.message,
2955 common.getMax(conf.width, actors2[msg.from].width),
2956 noteFont(conf)
2957 ) : msg.message,
2958 noteFont(conf)
2959 );
2960 noteModel.width = shouldWrap ? common.getMax(conf.width, actors2[msg.from].width) : common.getMax(
2961 actors2[msg.from].width,
2962 conf.width,
2963 textDimensions.width + 2 * conf.noteMargin
2964 );
2965 noteModel.startx = startx + (actors2[msg.from].width - noteModel.width) / 2;
2966 } else {
2967 noteModel.width = Math.abs(startx + actors2[msg.from].width / 2 - (stopx + actors2[msg.to].width / 2)) + conf.actorMargin;
2968 noteModel.startx = startx < stopx ? startx + actors2[msg.from].width / 2 - conf.actorMargin / 2 : stopx + actors2[msg.to].width / 2 - conf.actorMargin / 2;
2969 }
2970 if (shouldWrap) {
2971 noteModel.message = utils.wrapLabel(
2972 msg.message,
2973 noteModel.width - 2 * conf.wrapPadding,
2974 noteFont(conf)
2975 );
2976 }
2977 log.debug(
2978 `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]`
2979 );
2980 return noteModel;
2981};
2982const buildMessageModel = function(msg, actors2, diagObj) {
2983 let process = false;
2984 if ([
2985 diagObj.db.LINETYPE.SOLID_OPEN,
2986 diagObj.db.LINETYPE.DOTTED_OPEN,
2987 diagObj.db.LINETYPE.SOLID,
2988 diagObj.db.LINETYPE.DOTTED,
2989 diagObj.db.LINETYPE.SOLID_CROSS,
2990 diagObj.db.LINETYPE.DOTTED_CROSS,
2991 diagObj.db.LINETYPE.SOLID_POINT,
2992 diagObj.db.LINETYPE.DOTTED_POINT
2993 ].includes(msg.type)) {
2994 process = true;
2995 }
2996 if (!process) {
2997 return {};
2998 }
2999 const fromBounds = activationBounds(msg.from, actors2);
3000 const toBounds = activationBounds(msg.to, actors2);
3001 const fromIdx = fromBounds[0] <= toBounds[0] ? 1 : 0;
3002 const toIdx = fromBounds[0] < toBounds[0] ? 0 : 1;
3003 const allBounds = [...fromBounds, ...toBounds];
3004 const boundedWidth = Math.abs(toBounds[toIdx] - fromBounds[fromIdx]);
3005 if (msg.wrap && msg.message) {
3006 msg.message = utils.wrapLabel(
3007 msg.message,
3008 common.getMax(boundedWidth + 2 * conf.wrapPadding, conf.width),
3009 messageFont(conf)
3010 );
3011 }
3012 const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf));
3013 return {
3014 width: common.getMax(
3015 msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding,
3016 boundedWidth + 2 * conf.wrapPadding,
3017 conf.width
3018 ),
3019 height: 0,
3020 startx: fromBounds[fromIdx],
3021 stopx: toBounds[toIdx],
3022 starty: 0,
3023 stopy: 0,
3024 message: msg.message,
3025 type: msg.type,
3026 wrap: msg.wrap,
3027 fromBounds: Math.min.apply(null, allBounds),
3028 toBounds: Math.max.apply(null, allBounds)
3029 };
3030};
3031const calculateLoopBounds = function(messages2, actors2, _maxWidthPerActor, diagObj) {
3032 const loops = {};
3033 const stack = [];
3034 let current, noteModel, msgModel;
3035 messages2.forEach(function(msg) {
3036 msg.id = utils.random({ length: 10 });
3037 switch (msg.type) {
3038 case diagObj.db.LINETYPE.LOOP_START:
3039 case diagObj.db.LINETYPE.ALT_START:
3040 case diagObj.db.LINETYPE.OPT_START:
3041 case diagObj.db.LINETYPE.PAR_START:
3042 case diagObj.db.LINETYPE.PAR_OVER_START:
3043 case diagObj.db.LINETYPE.CRITICAL_START:
3044 case diagObj.db.LINETYPE.BREAK_START:
3045 stack.push({
3046 id: msg.id,
3047 msg: msg.message,
3048 from: Number.MAX_SAFE_INTEGER,
3049 to: Number.MIN_SAFE_INTEGER,
3050 width: 0
3051 });
3052 break;
3053 case diagObj.db.LINETYPE.ALT_ELSE:
3054 case diagObj.db.LINETYPE.PAR_AND:
3055 case diagObj.db.LINETYPE.CRITICAL_OPTION:
3056 if (msg.message) {
3057 current = stack.pop();
3058 loops[current.id] = current;
3059 loops[msg.id] = current;
3060 stack.push(current);
3061 }
3062 break;
3063 case diagObj.db.LINETYPE.LOOP_END:
3064 case diagObj.db.LINETYPE.ALT_END:
3065 case diagObj.db.LINETYPE.OPT_END:
3066 case diagObj.db.LINETYPE.PAR_END:
3067 case diagObj.db.LINETYPE.CRITICAL_END:
3068 case diagObj.db.LINETYPE.BREAK_END:
3069 current = stack.pop();
3070 loops[current.id] = current;
3071 break;
3072 case diagObj.db.LINETYPE.ACTIVE_START:
3073 {
3074 const actorRect = actors2[msg.from ? msg.from.actor : msg.to.actor];
3075 const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length;
3076 const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
3077 const toAdd = {
3078 startx: x,
3079 stopx: x + conf.activationWidth,
3080 actor: msg.from.actor,
3081 enabled: true
3082 };
3083 bounds.activations.push(toAdd);
3084 }
3085 break;
3086 case diagObj.db.LINETYPE.ACTIVE_END:
3087 {
3088 const lastActorActivationIdx = bounds.activations.map((a) => a.actor).lastIndexOf(msg.from.actor);
3089 delete bounds.activations.splice(lastActorActivationIdx, 1)[0];
3090 }
3091 break;
3092 }
3093 const isNote = msg.placement !== void 0;
3094 if (isNote) {
3095 noteModel = buildNoteModel(msg, actors2, diagObj);
3096 msg.noteModel = noteModel;
3097 stack.forEach((stk) => {
3098 current = stk;
3099 current.from = common.getMin(current.from, noteModel.startx);
3100 current.to = common.getMax(current.to, noteModel.startx + noteModel.width);
3101 current.width = common.getMax(current.width, Math.abs(current.from - current.to)) - conf.labelBoxWidth;
3102 });
3103 } else {
3104 msgModel = buildMessageModel(msg, actors2, diagObj);
3105 msg.msgModel = msgModel;
3106 if (msgModel.startx && msgModel.stopx && stack.length > 0) {
3107 stack.forEach((stk) => {
3108 current = stk;
3109 if (msgModel.startx === msgModel.stopx) {
3110 const from = actors2[msg.from];
3111 const to = actors2[msg.to];
3112 current.from = common.getMin(
3113 from.x - msgModel.width / 2,
3114 from.x - from.width / 2,
3115 current.from
3116 );
3117 current.to = common.getMax(
3118 to.x + msgModel.width / 2,
3119 to.x + from.width / 2,
3120 current.to
3121 );
3122 current.width = common.getMax(current.width, Math.abs(current.to - current.from)) - conf.labelBoxWidth;
3123 } else {
3124 current.from = common.getMin(msgModel.startx, current.from);
3125 current.to = common.getMax(msgModel.stopx, current.to);
3126 current.width = common.getMax(current.width, msgModel.width) - conf.labelBoxWidth;
3127 }
3128 });
3129 }
3130 }
3131 });
3132 bounds.activations = [];
3133 log.debug("Loop type widths:", loops);
3134 return loops;
3135};
3136const renderer = {
3137 bounds,
3138 drawActors,
3139 drawActorsPopup,
3140 setConf,
3141 draw
3142};
3143const diagram = {
3144 parser: parser$1,
3145 db,
3146 renderer,
3147 styles
3148};
3149export {
3150 diagram
3151};