UNPKG

71.5 kBJavaScriptView Raw
1import { c as getConfig, s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log, f as common, E as clear$2, H as random, j as d3select, A as utils, I as setupGraphViewbox } from "./mermaid-dcacb631.js";
2var parser = function() {
3 var o = function(k, v, o2, l) {
4 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
5 ;
6 return o2;
7 }, $V0 = [1, 3], $V1 = [1, 6], $V2 = [1, 4], $V3 = [1, 5], $V4 = [2, 5], $V5 = [1, 12], $V6 = [5, 7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40, 47], $V7 = [7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V8 = [7, 12, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V9 = [7, 13, 47], $Va = [1, 42], $Vb = [1, 41], $Vc = [7, 13, 29, 32, 35, 38, 47], $Vd = [1, 55], $Ve = [1, 56], $Vf = [1, 57], $Vg = [7, 13, 32, 35, 42, 47];
8 var parser2 = {
9 trace: function trace() {
10 },
11 yy: {},
12 symbols_: { "error": 2, "start": 3, "eol": 4, "GG": 5, "document": 6, "EOF": 7, ":": 8, "DIR": 9, "options": 10, "body": 11, "OPT": 12, "NL": 13, "line": 14, "statement": 15, "commitStatement": 16, "mergeStatement": 17, "cherryPickStatement": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "section": 24, "branchStatement": 25, "CHECKOUT": 26, "ref": 27, "BRANCH": 28, "ORDER": 29, "NUM": 30, "CHERRY_PICK": 31, "COMMIT_ID": 32, "STR": 33, "PARENT_COMMIT": 34, "COMMIT_TAG": 35, "EMPTYSTR": 36, "MERGE": 37, "COMMIT_TYPE": 38, "commitType": 39, "COMMIT": 40, "commit_arg": 41, "COMMIT_MSG": 42, "NORMAL": 43, "REVERSE": 44, "HIGHLIGHT": 45, "ID": 46, ";": 47, "$accept": 0, "$end": 1 },
13 terminals_: { 2: "error", 5: "GG", 7: "EOF", 8: ":", 9: "DIR", 12: "OPT", 13: "NL", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "section", 26: "CHECKOUT", 28: "BRANCH", 29: "ORDER", 30: "NUM", 31: "CHERRY_PICK", 32: "COMMIT_ID", 33: "STR", 34: "PARENT_COMMIT", 35: "COMMIT_TAG", 36: "EMPTYSTR", 37: "MERGE", 38: "COMMIT_TYPE", 40: "COMMIT", 42: "COMMIT_MSG", 43: "NORMAL", 44: "REVERSE", 45: "HIGHLIGHT", 46: "ID", 47: ";" },
14 productions_: [0, [3, 2], [3, 3], [3, 4], [3, 5], [6, 0], [6, 2], [10, 2], [10, 1], [11, 0], [11, 2], [14, 2], [14, 1], [15, 1], [15, 1], [15, 1], [15, 2], [15, 2], [15, 1], [15, 1], [15, 1], [15, 2], [25, 2], [25, 4], [18, 3], [18, 5], [18, 5], [18, 7], [18, 7], [18, 5], [18, 5], [18, 5], [18, 7], [18, 7], [18, 7], [18, 7], [17, 2], [17, 4], [17, 4], [17, 4], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [16, 2], [16, 3], [16, 3], [16, 5], [16, 5], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [41, 0], [41, 1], [39, 1], [39, 1], [39, 1], [27, 1], [27, 1], [4, 1], [4, 1], [4, 1]],
15 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
16 var $0 = $$.length - 1;
17 switch (yystate) {
18 case 2:
19 return $$[$0];
20 case 3:
21 return $$[$0 - 1];
22 case 4:
23 yy.setDirection($$[$0 - 3]);
24 return $$[$0 - 1];
25 case 6:
26 yy.setOptions($$[$0 - 1]);
27 this.$ = $$[$0];
28 break;
29 case 7:
30 $$[$0 - 1] += $$[$0];
31 this.$ = $$[$0 - 1];
32 break;
33 case 9:
34 this.$ = [];
35 break;
36 case 10:
37 $$[$0 - 1].push($$[$0]);
38 this.$ = $$[$0 - 1];
39 break;
40 case 11:
41 this.$ = $$[$0 - 1];
42 break;
43 case 16:
44 this.$ = $$[$0].trim();
45 yy.setAccTitle(this.$);
46 break;
47 case 17:
48 case 18:
49 this.$ = $$[$0].trim();
50 yy.setAccDescription(this.$);
51 break;
52 case 19:
53 yy.addSection($$[$0].substr(8));
54 this.$ = $$[$0].substr(8);
55 break;
56 case 21:
57 yy.checkout($$[$0]);
58 break;
59 case 22:
60 yy.branch($$[$0]);
61 break;
62 case 23:
63 yy.branch($$[$0 - 2], $$[$0]);
64 break;
65 case 24:
66 yy.cherryPick($$[$0], "", void 0);
67 break;
68 case 25:
69 yy.cherryPick($$[$0 - 2], "", void 0, $$[$0]);
70 break;
71 case 26:
72 yy.cherryPick($$[$0 - 2], "", $$[$0]);
73 break;
74 case 27:
75 yy.cherryPick($$[$0 - 4], "", $$[$0], $$[$0 - 2]);
76 break;
77 case 28:
78 yy.cherryPick($$[$0 - 4], "", $$[$0 - 2], $$[$0]);
79 break;
80 case 29:
81 yy.cherryPick($$[$0], "", $$[$0 - 2]);
82 break;
83 case 30:
84 yy.cherryPick($$[$0], "", "");
85 break;
86 case 31:
87 yy.cherryPick($$[$0 - 2], "", "");
88 break;
89 case 32:
90 yy.cherryPick($$[$0 - 4], "", "", $$[$0 - 2]);
91 break;
92 case 33:
93 yy.cherryPick($$[$0 - 4], "", "", $$[$0]);
94 break;
95 case 34:
96 yy.cherryPick($$[$0 - 2], "", $$[$0 - 4], $$[$0]);
97 break;
98 case 35:
99 yy.cherryPick($$[$0 - 2], "", "", $$[$0]);
100 break;
101 case 36:
102 yy.merge($$[$0], "", "", "");
103 break;
104 case 37:
105 yy.merge($$[$0 - 2], $$[$0], "", "");
106 break;
107 case 38:
108 yy.merge($$[$0 - 2], "", $$[$0], "");
109 break;
110 case 39:
111 yy.merge($$[$0 - 2], "", "", $$[$0]);
112 break;
113 case 40:
114 yy.merge($$[$0 - 4], $$[$0], "", $$[$0 - 2]);
115 break;
116 case 41:
117 yy.merge($$[$0 - 4], "", $$[$0], $$[$0 - 2]);
118 break;
119 case 42:
120 yy.merge($$[$0 - 4], "", $$[$0 - 2], $$[$0]);
121 break;
122 case 43:
123 yy.merge($$[$0 - 4], $$[$0 - 2], $$[$0], "");
124 break;
125 case 44:
126 yy.merge($$[$0 - 4], $$[$0 - 2], "", $$[$0]);
127 break;
128 case 45:
129 yy.merge($$[$0 - 4], $$[$0], $$[$0 - 2], "");
130 break;
131 case 46:
132 yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]);
133 break;
134 case 47:
135 yy.merge($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]);
136 break;
137 case 48:
138 yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]);
139 break;
140 case 49:
141 yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]);
142 break;
143 case 50:
144 yy.merge($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]);
145 break;
146 case 51:
147 yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]);
148 break;
149 case 52:
150 yy.commit($$[$0]);
151 break;
152 case 53:
153 yy.commit("", "", yy.commitType.NORMAL, $$[$0]);
154 break;
155 case 54:
156 yy.commit("", "", $$[$0], "");
157 break;
158 case 55:
159 yy.commit("", "", $$[$0], $$[$0 - 2]);
160 break;
161 case 56:
162 yy.commit("", "", $$[$0 - 2], $$[$0]);
163 break;
164 case 57:
165 yy.commit("", $$[$0], yy.commitType.NORMAL, "");
166 break;
167 case 58:
168 yy.commit("", $$[$0 - 2], yy.commitType.NORMAL, $$[$0]);
169 break;
170 case 59:
171 yy.commit("", $$[$0], yy.commitType.NORMAL, $$[$0 - 2]);
172 break;
173 case 60:
174 yy.commit("", $$[$0 - 2], $$[$0], "");
175 break;
176 case 61:
177 yy.commit("", $$[$0], $$[$0 - 2], "");
178 break;
179 case 62:
180 yy.commit("", $$[$0 - 4], $$[$0 - 2], $$[$0]);
181 break;
182 case 63:
183 yy.commit("", $$[$0 - 4], $$[$0], $$[$0 - 2]);
184 break;
185 case 64:
186 yy.commit("", $$[$0 - 2], $$[$0 - 4], $$[$0]);
187 break;
188 case 65:
189 yy.commit("", $$[$0], $$[$0 - 4], $$[$0 - 2]);
190 break;
191 case 66:
192 yy.commit("", $$[$0], $$[$0 - 2], $$[$0 - 4]);
193 break;
194 case 67:
195 yy.commit("", $$[$0 - 2], $$[$0], $$[$0 - 4]);
196 break;
197 case 68:
198 yy.commit($$[$0], "", yy.commitType.NORMAL, "");
199 break;
200 case 69:
201 yy.commit($$[$0], "", yy.commitType.NORMAL, $$[$0 - 2]);
202 break;
203 case 70:
204 yy.commit($$[$0 - 2], "", yy.commitType.NORMAL, $$[$0]);
205 break;
206 case 71:
207 yy.commit($$[$0 - 2], "", $$[$0], "");
208 break;
209 case 72:
210 yy.commit($$[$0], "", $$[$0 - 2], "");
211 break;
212 case 73:
213 yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, "");
214 break;
215 case 74:
216 yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, "");
217 break;
218 case 75:
219 yy.commit($$[$0 - 4], "", $$[$0 - 2], $$[$0]);
220 break;
221 case 76:
222 yy.commit($$[$0 - 4], "", $$[$0], $$[$0 - 2]);
223 break;
224 case 77:
225 yy.commit($$[$0 - 2], "", $$[$0 - 4], $$[$0]);
226 break;
227 case 78:
228 yy.commit($$[$0], "", $$[$0 - 4], $$[$0 - 2]);
229 break;
230 case 79:
231 yy.commit($$[$0], "", $$[$0 - 2], $$[$0 - 4]);
232 break;
233 case 80:
234 yy.commit($$[$0 - 2], "", $$[$0], $$[$0 - 4]);
235 break;
236 case 81:
237 yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], "");
238 break;
239 case 82:
240 yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], "");
241 break;
242 case 83:
243 yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], "");
244 break;
245 case 84:
246 yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], "");
247 break;
248 case 85:
249 yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], "");
250 break;
251 case 86:
252 yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], "");
253 break;
254 case 87:
255 yy.commit($$[$0 - 4], $$[$0], yy.commitType.NORMAL, $$[$0 - 2]);
256 break;
257 case 88:
258 yy.commit($$[$0 - 4], $$[$0 - 2], yy.commitType.NORMAL, $$[$0]);
259 break;
260 case 89:
261 yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, $$[$0 - 4]);
262 break;
263 case 90:
264 yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, $$[$0 - 4]);
265 break;
266 case 91:
267 yy.commit($$[$0], $$[$0 - 4], yy.commitType.NORMAL, $$[$0 - 2]);
268 break;
269 case 92:
270 yy.commit($$[$0 - 2], $$[$0 - 4], yy.commitType.NORMAL, $$[$0]);
271 break;
272 case 93:
273 yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]);
274 break;
275 case 94:
276 yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]);
277 break;
278 case 95:
279 yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]);
280 break;
281 case 96:
282 yy.commit($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]);
283 break;
284 case 97:
285 yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]);
286 break;
287 case 98:
288 yy.commit($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]);
289 break;
290 case 99:
291 yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0 - 2], $$[$0]);
292 break;
293 case 100:
294 yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0], $$[$0 - 2]);
295 break;
296 case 101:
297 yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0 - 4], $$[$0]);
298 break;
299 case 102:
300 yy.commit($$[$0], $$[$0 - 6], $$[$0 - 4], $$[$0 - 2]);
301 break;
302 case 103:
303 yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0], $$[$0 - 4]);
304 break;
305 case 104:
306 yy.commit($$[$0], $$[$0 - 6], $$[$0 - 2], $$[$0 - 4]);
307 break;
308 case 105:
309 yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], $$[$0 - 6]);
310 break;
311 case 106:
312 yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], $$[$0 - 6]);
313 break;
314 case 107:
315 yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], $$[$0 - 6]);
316 break;
317 case 108:
318 yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], $$[$0 - 6]);
319 break;
320 case 109:
321 yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], $$[$0 - 6]);
322 break;
323 case 110:
324 yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 6]);
325 break;
326 case 111:
327 yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0 - 6], $$[$0]);
328 break;
329 case 112:
330 yy.commit($$[$0], $$[$0 - 4], $$[$0 - 6], $$[$0 - 2]);
331 break;
332 case 113:
333 yy.commit($$[$0 - 2], $$[$0], $$[$0 - 6], $$[$0 - 4]);
334 break;
335 case 114:
336 yy.commit($$[$0], $$[$0 - 2], $$[$0 - 6], $$[$0 - 4]);
337 break;
338 case 115:
339 yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0 - 6], $$[$0]);
340 break;
341 case 116:
342 yy.commit($$[$0 - 4], $$[$0], $$[$0 - 6], $$[$0 - 2]);
343 break;
344 case 117:
345 this.$ = "";
346 break;
347 case 118:
348 this.$ = $$[$0];
349 break;
350 case 119:
351 this.$ = yy.commitType.NORMAL;
352 break;
353 case 120:
354 this.$ = yy.commitType.REVERSE;
355 break;
356 case 121:
357 this.$ = yy.commitType.HIGHLIGHT;
358 break;
359 }
360 },
361 table: [{ 3: 1, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 6: 8, 7: $V4, 8: [1, 9], 9: [1, 10], 10: 11, 13: $V5 }, o($V6, [2, 124]), o($V6, [2, 125]), o($V6, [2, 126]), { 1: [2, 1] }, { 7: [1, 13] }, { 6: 14, 7: $V4, 10: 11, 13: $V5 }, { 8: [1, 15] }, o($V7, [2, 9], { 11: 16, 12: [1, 17] }), o($V8, [2, 8]), { 1: [2, 2] }, { 7: [1, 18] }, { 6: 19, 7: $V4, 10: 11, 13: $V5 }, { 7: [2, 6], 13: [1, 22], 14: 20, 15: 21, 16: 23, 17: 24, 18: 25, 19: [1, 26], 21: [1, 27], 23: [1, 28], 24: [1, 29], 25: 30, 26: [1, 31], 28: [1, 35], 31: [1, 34], 37: [1, 33], 40: [1, 32] }, o($V8, [2, 7]), { 1: [2, 3] }, { 7: [1, 36] }, o($V7, [2, 10]), { 4: 37, 7: $V1, 13: $V2, 47: $V3 }, o($V7, [2, 12]), o($V9, [2, 13]), o($V9, [2, 14]), o($V9, [2, 15]), { 20: [1, 38] }, { 22: [1, 39] }, o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), { 27: 40, 33: $Va, 46: $Vb }, o($V9, [2, 117], { 41: 43, 32: [1, 46], 33: [1, 48], 35: [1, 44], 38: [1, 45], 42: [1, 47] }), { 27: 49, 33: $Va, 46: $Vb }, { 32: [1, 50], 35: [1, 51] }, { 27: 52, 33: $Va, 46: $Vb }, { 1: [2, 4] }, o($V7, [2, 11]), o($V9, [2, 16]), o($V9, [2, 17]), o($V9, [2, 21]), o($Vc, [2, 122]), o($Vc, [2, 123]), o($V9, [2, 52]), { 33: [1, 53] }, { 39: 54, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 58] }, { 33: [1, 59] }, o($V9, [2, 118]), o($V9, [2, 36], { 32: [1, 60], 35: [1, 62], 38: [1, 61] }), { 33: [1, 63] }, { 33: [1, 64], 36: [1, 65] }, o($V9, [2, 22], { 29: [1, 66] }), o($V9, [2, 53], { 32: [1, 68], 38: [1, 67], 42: [1, 69] }), o($V9, [2, 54], { 32: [1, 71], 35: [1, 70], 42: [1, 72] }), o($Vg, [2, 119]), o($Vg, [2, 120]), o($Vg, [2, 121]), o($V9, [2, 57], { 35: [1, 73], 38: [1, 74], 42: [1, 75] }), o($V9, [2, 68], { 32: [1, 78], 35: [1, 76], 38: [1, 77] }), { 33: [1, 79] }, { 39: 80, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 81] }, o($V9, [2, 24], { 34: [1, 82], 35: [1, 83] }), { 32: [1, 84] }, { 32: [1, 85] }, { 30: [1, 86] }, { 39: 87, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 88] }, { 33: [1, 89] }, { 33: [1, 90] }, { 33: [1, 91] }, { 33: [1, 92] }, { 33: [1, 93] }, { 39: 94, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 95] }, { 33: [1, 96] }, { 39: 97, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 98] }, o($V9, [2, 37], { 35: [1, 100], 38: [1, 99] }), o($V9, [2, 38], { 32: [1, 102], 35: [1, 101] }), o($V9, [2, 39], { 32: [1, 103], 38: [1, 104] }), { 33: [1, 105] }, { 33: [1, 106], 36: [1, 107] }, { 33: [1, 108] }, { 33: [1, 109] }, o($V9, [2, 23]), o($V9, [2, 55], { 32: [1, 110], 42: [1, 111] }), o($V9, [2, 59], { 38: [1, 112], 42: [1, 113] }), o($V9, [2, 69], { 32: [1, 115], 38: [1, 114] }), o($V9, [2, 56], { 32: [1, 116], 42: [1, 117] }), o($V9, [2, 61], { 35: [1, 118], 42: [1, 119] }), o($V9, [2, 72], { 32: [1, 121], 35: [1, 120] }), o($V9, [2, 58], { 38: [1, 122], 42: [1, 123] }), o($V9, [2, 60], { 35: [1, 124], 42: [1, 125] }), o($V9, [2, 73], { 35: [1, 127], 38: [1, 126] }), o($V9, [2, 70], { 32: [1, 129], 38: [1, 128] }), o($V9, [2, 71], { 32: [1, 131], 35: [1, 130] }), o($V9, [2, 74], { 35: [1, 133], 38: [1, 132] }), { 39: 134, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 135] }, { 33: [1, 136] }, { 33: [1, 137] }, { 33: [1, 138] }, { 39: 139, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 25], { 35: [1, 140] }), o($V9, [2, 26], { 34: [1, 141] }), o($V9, [2, 31], { 34: [1, 142] }), o($V9, [2, 29], { 34: [1, 143] }), o($V9, [2, 30], { 34: [1, 144] }), { 33: [1, 145] }, { 33: [1, 146] }, { 39: 147, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 148] }, { 39: 149, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 150] }, { 33: [1, 151] }, { 33: [1, 152] }, { 33: [1, 153] }, { 33: [1, 154] }, { 33: [1, 155] }, { 33: [1, 156] }, { 39: 157, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 158] }, { 33: [1, 159] }, { 33: [1, 160] }, { 39: 161, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 162] }, { 39: 163, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 164] }, { 33: [1, 165] }, { 33: [1, 166] }, { 39: 167, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 168] }, o($V9, [2, 43], { 35: [1, 169] }), o($V9, [2, 44], { 38: [1, 170] }), o($V9, [2, 42], { 32: [1, 171] }), o($V9, [2, 45], { 35: [1, 172] }), o($V9, [2, 40], { 38: [1, 173] }), o($V9, [2, 41], { 32: [1, 174] }), { 33: [1, 175], 36: [1, 176] }, { 33: [1, 177] }, { 33: [1, 178] }, { 33: [1, 179] }, { 33: [1, 180] }, o($V9, [2, 66], { 42: [1, 181] }), o($V9, [2, 79], { 32: [1, 182] }), o($V9, [2, 67], { 42: [1, 183] }), o($V9, [2, 90], { 38: [1, 184] }), o($V9, [2, 80], { 32: [1, 185] }), o($V9, [2, 89], { 38: [1, 186] }), o($V9, [2, 65], { 42: [1, 187] }), o($V9, [2, 78], { 32: [1, 188] }), o($V9, [2, 64], { 42: [1, 189] }), o($V9, [2, 84], { 35: [1, 190] }), o($V9, [2, 77], { 32: [1, 191] }), o($V9, [2, 83], { 35: [1, 192] }), o($V9, [2, 63], { 42: [1, 193] }), o($V9, [2, 91], { 38: [1, 194] }), o($V9, [2, 62], { 42: [1, 195] }), o($V9, [2, 85], { 35: [1, 196] }), o($V9, [2, 86], { 35: [1, 197] }), o($V9, [2, 92], { 38: [1, 198] }), o($V9, [2, 76], { 32: [1, 199] }), o($V9, [2, 87], { 38: [1, 200] }), o($V9, [2, 75], { 32: [1, 201] }), o($V9, [2, 81], { 35: [1, 202] }), o($V9, [2, 82], { 35: [1, 203] }), o($V9, [2, 88], { 38: [1, 204] }), { 33: [1, 205] }, { 39: 206, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 207] }, { 33: [1, 208] }, { 39: 209, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 210] }, o($V9, [2, 27]), o($V9, [2, 32]), o($V9, [2, 28]), o($V9, [2, 33]), o($V9, [2, 34]), o($V9, [2, 35]), { 33: [1, 211] }, { 33: [1, 212] }, { 33: [1, 213] }, { 39: 214, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 215] }, { 39: 216, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 217] }, { 33: [1, 218] }, { 33: [1, 219] }, { 33: [1, 220] }, { 33: [1, 221] }, { 33: [1, 222] }, { 33: [1, 223] }, { 39: 224, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 225] }, { 33: [1, 226] }, { 33: [1, 227] }, { 39: 228, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 229] }, { 39: 230, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 231] }, { 33: [1, 232] }, { 33: [1, 233] }, { 39: 234, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 46]), o($V9, [2, 48]), o($V9, [2, 47]), o($V9, [2, 49]), o($V9, [2, 51]), o($V9, [2, 50]), o($V9, [2, 107]), o($V9, [2, 108]), o($V9, [2, 105]), o($V9, [2, 106]), o($V9, [2, 110]), o($V9, [2, 109]), o($V9, [2, 114]), o($V9, [2, 113]), o($V9, [2, 112]), o($V9, [2, 111]), o($V9, [2, 116]), o($V9, [2, 115]), o($V9, [2, 104]), o($V9, [2, 103]), o($V9, [2, 102]), o($V9, [2, 101]), o($V9, [2, 99]), o($V9, [2, 100]), o($V9, [2, 98]), o($V9, [2, 97]), o($V9, [2, 96]), o($V9, [2, 95]), o($V9, [2, 93]), o($V9, [2, 94])],
362 defaultActions: { 7: [2, 1], 13: [2, 2], 18: [2, 3], 36: [2, 4] },
363 parseError: function parseError(str, hash) {
364 if (hash.recoverable) {
365 this.trace(str);
366 } else {
367 var error = new Error(str);
368 error.hash = hash;
369 throw error;
370 }
371 },
372 parse: function parse(input) {
373 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
374 var args = lstack.slice.call(arguments, 1);
375 var lexer2 = Object.create(this.lexer);
376 var sharedState = { yy: {} };
377 for (var k in this.yy) {
378 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
379 sharedState.yy[k] = this.yy[k];
380 }
381 }
382 lexer2.setInput(input, sharedState.yy);
383 sharedState.yy.lexer = lexer2;
384 sharedState.yy.parser = this;
385 if (typeof lexer2.yylloc == "undefined") {
386 lexer2.yylloc = {};
387 }
388 var yyloc = lexer2.yylloc;
389 lstack.push(yyloc);
390 var ranges = lexer2.options && lexer2.options.ranges;
391 if (typeof sharedState.yy.parseError === "function") {
392 this.parseError = sharedState.yy.parseError;
393 } else {
394 this.parseError = Object.getPrototypeOf(this).parseError;
395 }
396 function lex() {
397 var token;
398 token = tstack.pop() || lexer2.lex() || EOF;
399 if (typeof token !== "number") {
400 if (token instanceof Array) {
401 tstack = token;
402 token = tstack.pop();
403 }
404 token = self.symbols_[token] || token;
405 }
406 return token;
407 }
408 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
409 while (true) {
410 state = stack[stack.length - 1];
411 if (this.defaultActions[state]) {
412 action = this.defaultActions[state];
413 } else {
414 if (symbol === null || typeof symbol == "undefined") {
415 symbol = lex();
416 }
417 action = table[state] && table[state][symbol];
418 }
419 if (typeof action === "undefined" || !action.length || !action[0]) {
420 var errStr = "";
421 expected = [];
422 for (p in table[state]) {
423 if (this.terminals_[p] && p > TERROR) {
424 expected.push("'" + this.terminals_[p] + "'");
425 }
426 }
427 if (lexer2.showPosition) {
428 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
429 } else {
430 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
431 }
432 this.parseError(errStr, {
433 text: lexer2.match,
434 token: this.terminals_[symbol] || symbol,
435 line: lexer2.yylineno,
436 loc: yyloc,
437 expected
438 });
439 }
440 if (action[0] instanceof Array && action.length > 1) {
441 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
442 }
443 switch (action[0]) {
444 case 1:
445 stack.push(symbol);
446 vstack.push(lexer2.yytext);
447 lstack.push(lexer2.yylloc);
448 stack.push(action[1]);
449 symbol = null;
450 {
451 yyleng = lexer2.yyleng;
452 yytext = lexer2.yytext;
453 yylineno = lexer2.yylineno;
454 yyloc = lexer2.yylloc;
455 }
456 break;
457 case 2:
458 len = this.productions_[action[1]][1];
459 yyval.$ = vstack[vstack.length - len];
460 yyval._$ = {
461 first_line: lstack[lstack.length - (len || 1)].first_line,
462 last_line: lstack[lstack.length - 1].last_line,
463 first_column: lstack[lstack.length - (len || 1)].first_column,
464 last_column: lstack[lstack.length - 1].last_column
465 };
466 if (ranges) {
467 yyval._$.range = [
468 lstack[lstack.length - (len || 1)].range[0],
469 lstack[lstack.length - 1].range[1]
470 ];
471 }
472 r = this.performAction.apply(yyval, [
473 yytext,
474 yyleng,
475 yylineno,
476 sharedState.yy,
477 action[1],
478 vstack,
479 lstack
480 ].concat(args));
481 if (typeof r !== "undefined") {
482 return r;
483 }
484 if (len) {
485 stack = stack.slice(0, -1 * len * 2);
486 vstack = vstack.slice(0, -1 * len);
487 lstack = lstack.slice(0, -1 * len);
488 }
489 stack.push(this.productions_[action[1]][0]);
490 vstack.push(yyval.$);
491 lstack.push(yyval._$);
492 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
493 stack.push(newState);
494 break;
495 case 3:
496 return true;
497 }
498 }
499 return true;
500 }
501 };
502 var lexer = function() {
503 var lexer2 = {
504 EOF: 1,
505 parseError: function parseError(str, hash) {
506 if (this.yy.parser) {
507 this.yy.parser.parseError(str, hash);
508 } else {
509 throw new Error(str);
510 }
511 },
512 // resets the lexer, sets new input
513 setInput: function(input, yy) {
514 this.yy = yy || this.yy || {};
515 this._input = input;
516 this._more = this._backtrack = this.done = false;
517 this.yylineno = this.yyleng = 0;
518 this.yytext = this.matched = this.match = "";
519 this.conditionStack = ["INITIAL"];
520 this.yylloc = {
521 first_line: 1,
522 first_column: 0,
523 last_line: 1,
524 last_column: 0
525 };
526 if (this.options.ranges) {
527 this.yylloc.range = [0, 0];
528 }
529 this.offset = 0;
530 return this;
531 },
532 // consumes and returns one char from the input
533 input: function() {
534 var ch = this._input[0];
535 this.yytext += ch;
536 this.yyleng++;
537 this.offset++;
538 this.match += ch;
539 this.matched += ch;
540 var lines = ch.match(/(?:\r\n?|\n).*/g);
541 if (lines) {
542 this.yylineno++;
543 this.yylloc.last_line++;
544 } else {
545 this.yylloc.last_column++;
546 }
547 if (this.options.ranges) {
548 this.yylloc.range[1]++;
549 }
550 this._input = this._input.slice(1);
551 return ch;
552 },
553 // unshifts one char (or a string) into the input
554 unput: function(ch) {
555 var len = ch.length;
556 var lines = ch.split(/(?:\r\n?|\n)/g);
557 this._input = ch + this._input;
558 this.yytext = this.yytext.substr(0, this.yytext.length - len);
559 this.offset -= len;
560 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
561 this.match = this.match.substr(0, this.match.length - 1);
562 this.matched = this.matched.substr(0, this.matched.length - 1);
563 if (lines.length - 1) {
564 this.yylineno -= lines.length - 1;
565 }
566 var r = this.yylloc.range;
567 this.yylloc = {
568 first_line: this.yylloc.first_line,
569 last_line: this.yylineno + 1,
570 first_column: this.yylloc.first_column,
571 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
572 };
573 if (this.options.ranges) {
574 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
575 }
576 this.yyleng = this.yytext.length;
577 return this;
578 },
579 // When called from action, caches matched text and appends it on next action
580 more: function() {
581 this._more = true;
582 return this;
583 },
584 // 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.
585 reject: function() {
586 if (this.options.backtrack_lexer) {
587 this._backtrack = true;
588 } else {
589 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(), {
590 text: "",
591 token: null,
592 line: this.yylineno
593 });
594 }
595 return this;
596 },
597 // retain first n characters of the match
598 less: function(n) {
599 this.unput(this.match.slice(n));
600 },
601 // displays already matched input, i.e. for error messages
602 pastInput: function() {
603 var past = this.matched.substr(0, this.matched.length - this.match.length);
604 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
605 },
606 // displays upcoming input, i.e. for error messages
607 upcomingInput: function() {
608 var next = this.match;
609 if (next.length < 20) {
610 next += this._input.substr(0, 20 - next.length);
611 }
612 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
613 },
614 // displays the character position where the lexing error occurred, i.e. for error messages
615 showPosition: function() {
616 var pre = this.pastInput();
617 var c = new Array(pre.length + 1).join("-");
618 return pre + this.upcomingInput() + "\n" + c + "^";
619 },
620 // test the lexed token: return FALSE when not a match, otherwise return token
621 test_match: function(match, indexed_rule) {
622 var token, lines, backup;
623 if (this.options.backtrack_lexer) {
624 backup = {
625 yylineno: this.yylineno,
626 yylloc: {
627 first_line: this.yylloc.first_line,
628 last_line: this.last_line,
629 first_column: this.yylloc.first_column,
630 last_column: this.yylloc.last_column
631 },
632 yytext: this.yytext,
633 match: this.match,
634 matches: this.matches,
635 matched: this.matched,
636 yyleng: this.yyleng,
637 offset: this.offset,
638 _more: this._more,
639 _input: this._input,
640 yy: this.yy,
641 conditionStack: this.conditionStack.slice(0),
642 done: this.done
643 };
644 if (this.options.ranges) {
645 backup.yylloc.range = this.yylloc.range.slice(0);
646 }
647 }
648 lines = match[0].match(/(?:\r\n?|\n).*/g);
649 if (lines) {
650 this.yylineno += lines.length;
651 }
652 this.yylloc = {
653 first_line: this.yylloc.last_line,
654 last_line: this.yylineno + 1,
655 first_column: this.yylloc.last_column,
656 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
657 };
658 this.yytext += match[0];
659 this.match += match[0];
660 this.matches = match;
661 this.yyleng = this.yytext.length;
662 if (this.options.ranges) {
663 this.yylloc.range = [this.offset, this.offset += this.yyleng];
664 }
665 this._more = false;
666 this._backtrack = false;
667 this._input = this._input.slice(match[0].length);
668 this.matched += match[0];
669 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
670 if (this.done && this._input) {
671 this.done = false;
672 }
673 if (token) {
674 return token;
675 } else if (this._backtrack) {
676 for (var k in backup) {
677 this[k] = backup[k];
678 }
679 return false;
680 }
681 return false;
682 },
683 // return next match in input
684 next: function() {
685 if (this.done) {
686 return this.EOF;
687 }
688 if (!this._input) {
689 this.done = true;
690 }
691 var token, match, tempMatch, index;
692 if (!this._more) {
693 this.yytext = "";
694 this.match = "";
695 }
696 var rules = this._currentRules();
697 for (var i = 0; i < rules.length; i++) {
698 tempMatch = this._input.match(this.rules[rules[i]]);
699 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
700 match = tempMatch;
701 index = i;
702 if (this.options.backtrack_lexer) {
703 token = this.test_match(tempMatch, rules[i]);
704 if (token !== false) {
705 return token;
706 } else if (this._backtrack) {
707 match = false;
708 continue;
709 } else {
710 return false;
711 }
712 } else if (!this.options.flex) {
713 break;
714 }
715 }
716 }
717 if (match) {
718 token = this.test_match(match, rules[index]);
719 if (token !== false) {
720 return token;
721 }
722 return false;
723 }
724 if (this._input === "") {
725 return this.EOF;
726 } else {
727 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
728 text: "",
729 token: null,
730 line: this.yylineno
731 });
732 }
733 },
734 // return next match that has a token
735 lex: function lex() {
736 var r = this.next();
737 if (r) {
738 return r;
739 } else {
740 return this.lex();
741 }
742 },
743 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
744 begin: function begin(condition) {
745 this.conditionStack.push(condition);
746 },
747 // pop the previously active lexer condition state off the condition stack
748 popState: function popState() {
749 var n = this.conditionStack.length - 1;
750 if (n > 0) {
751 return this.conditionStack.pop();
752 } else {
753 return this.conditionStack[0];
754 }
755 },
756 // produce the lexer rule set which is active for the currently active lexer condition state
757 _currentRules: function _currentRules() {
758 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
759 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
760 } else {
761 return this.conditions["INITIAL"].rules;
762 }
763 },
764 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
765 topState: function topState(n) {
766 n = this.conditionStack.length - 1 - Math.abs(n || 0);
767 if (n >= 0) {
768 return this.conditionStack[n];
769 } else {
770 return "INITIAL";
771 }
772 },
773 // alias for begin(condition)
774 pushState: function pushState(condition) {
775 this.begin(condition);
776 },
777 // return the number of states currently on the stack
778 stateStackSize: function stateStackSize() {
779 return this.conditionStack.length;
780 },
781 options: { "case-insensitive": true },
782 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
783 switch ($avoiding_name_collisions) {
784 case 0:
785 this.begin("acc_title");
786 return 19;
787 case 1:
788 this.popState();
789 return "acc_title_value";
790 case 2:
791 this.begin("acc_descr");
792 return 21;
793 case 3:
794 this.popState();
795 return "acc_descr_value";
796 case 4:
797 this.begin("acc_descr_multiline");
798 break;
799 case 5:
800 this.popState();
801 break;
802 case 6:
803 return "acc_descr_multiline_value";
804 case 7:
805 return 13;
806 case 8:
807 break;
808 case 9:
809 break;
810 case 10:
811 return 5;
812 case 11:
813 return 40;
814 case 12:
815 return 32;
816 case 13:
817 return 38;
818 case 14:
819 return 42;
820 case 15:
821 return 43;
822 case 16:
823 return 44;
824 case 17:
825 return 45;
826 case 18:
827 return 35;
828 case 19:
829 return 28;
830 case 20:
831 return 29;
832 case 21:
833 return 37;
834 case 22:
835 return 31;
836 case 23:
837 return 34;
838 case 24:
839 return 26;
840 case 25:
841 return 9;
842 case 26:
843 return 9;
844 case 27:
845 return 8;
846 case 28:
847 return "CARET";
848 case 29:
849 this.begin("options");
850 break;
851 case 30:
852 this.popState();
853 break;
854 case 31:
855 return 12;
856 case 32:
857 return 36;
858 case 33:
859 this.begin("string");
860 break;
861 case 34:
862 this.popState();
863 break;
864 case 35:
865 return 33;
866 case 36:
867 return 30;
868 case 37:
869 return 46;
870 case 38:
871 return 7;
872 }
873 },
874 rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gitGraph\b)/i, /^(?:commit(?=\s|$))/i, /^(?:id:)/i, /^(?:type:)/i, /^(?:msg:)/i, /^(?:NORMAL\b)/i, /^(?:REVERSE\b)/i, /^(?:HIGHLIGHT\b)/i, /^(?:tag:)/i, /^(?:branch(?=\s|$))/i, /^(?:order:)/i, /^(?:merge(?=\s|$))/i, /^(?:cherry-pick(?=\s|$))/i, /^(?:parent:)/i, /^(?:checkout(?=\s|$))/i, /^(?:LR\b)/i, /^(?:TB\b)/i, /^(?::)/i, /^(?:\^)/i, /^(?:options\r?\n)/i, /^(?:[ \r\n\t]+end\b)/i, /^(?:[\s\S]+(?=[ \r\n\t]+end))/i, /^(?:["]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[0-9]+(?=\s|$))/i, /^(?:\w([-\./\w]*[-\w])?)/i, /^(?:$)/i, /^(?:\s+)/i],
875 conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "options": { "rules": [30, 31], "inclusive": false }, "string": { "rules": [34, 35], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 36, 37, 38, 39], "inclusive": true } }
876 };
877 return lexer2;
878 }();
879 parser2.lexer = lexer;
880 function Parser() {
881 this.yy = {};
882 }
883 Parser.prototype = parser2;
884 parser2.Parser = Parser;
885 return new Parser();
886}();
887parser.parser = parser;
888const gitGraphParser = parser;
889let mainBranchName = getConfig().gitGraph.mainBranchName;
890let mainBranchOrder = getConfig().gitGraph.mainBranchOrder;
891let commits = {};
892let head = null;
893let branchesConfig = {};
894branchesConfig[mainBranchName] = { name: mainBranchName, order: mainBranchOrder };
895let branches = {};
896branches[mainBranchName] = head;
897let curBranch = mainBranchName;
898let direction = "LR";
899let seq = 0;
900function getId() {
901 return random({ length: 7 });
902}
903function uniqBy(list, fn) {
904 const recordMap = /* @__PURE__ */ Object.create(null);
905 return list.reduce((out, item) => {
906 const key = fn(item);
907 if (!recordMap[key]) {
908 recordMap[key] = true;
909 out.push(item);
910 }
911 return out;
912 }, []);
913}
914const setDirection = function(dir2) {
915 direction = dir2;
916};
917let options = {};
918const setOptions = function(rawOptString) {
919 log.debug("options str", rawOptString);
920 rawOptString = rawOptString && rawOptString.trim();
921 rawOptString = rawOptString || "{}";
922 try {
923 options = JSON.parse(rawOptString);
924 } catch (e) {
925 log.error("error while parsing gitGraph options", e.message);
926 }
927};
928const getOptions = function() {
929 return options;
930};
931const commit = function(msg, id, type, tag) {
932 log.debug("Entering commit:", msg, id, type, tag);
933 id = common.sanitizeText(id, getConfig());
934 msg = common.sanitizeText(msg, getConfig());
935 tag = common.sanitizeText(tag, getConfig());
936 const commit2 = {
937 id: id ? id : seq + "-" + getId(),
938 message: msg,
939 seq: seq++,
940 type: type ? type : commitType$1.NORMAL,
941 tag: tag ? tag : "",
942 parents: head == null ? [] : [head.id],
943 branch: curBranch
944 };
945 head = commit2;
946 commits[commit2.id] = commit2;
947 branches[curBranch] = commit2.id;
948 log.debug("in pushCommit " + commit2.id);
949};
950const branch = function(name, order) {
951 name = common.sanitizeText(name, getConfig());
952 if (branches[name] === void 0) {
953 branches[name] = head != null ? head.id : null;
954 branchesConfig[name] = { name, order: order ? parseInt(order, 10) : null };
955 checkout(name);
956 log.debug("in createBranch");
957 } else {
958 let error = new Error(
959 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ' + name + '")'
960 );
961 error.hash = {
962 text: "branch " + name,
963 token: "branch " + name,
964 line: "1",
965 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
966 expected: ['"checkout ' + name + '"']
967 };
968 throw error;
969 }
970};
971const merge = function(otherBranch, custom_id, override_type, custom_tag) {
972 otherBranch = common.sanitizeText(otherBranch, getConfig());
973 custom_id = common.sanitizeText(custom_id, getConfig());
974 const currentCommit = commits[branches[curBranch]];
975 const otherCommit = commits[branches[otherBranch]];
976 if (curBranch === otherBranch) {
977 let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
978 error.hash = {
979 text: "merge " + otherBranch,
980 token: "merge " + otherBranch,
981 line: "1",
982 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
983 expected: ["branch abc"]
984 };
985 throw error;
986 } else if (currentCommit === void 0 || !currentCommit) {
987 let error = new Error(
988 'Incorrect usage of "merge". Current branch (' + curBranch + ")has no commits"
989 );
990 error.hash = {
991 text: "merge " + otherBranch,
992 token: "merge " + otherBranch,
993 line: "1",
994 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
995 expected: ["commit"]
996 };
997 throw error;
998 } else if (branches[otherBranch] === void 0) {
999 let error = new Error(
1000 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") does not exist"
1001 );
1002 error.hash = {
1003 text: "merge " + otherBranch,
1004 token: "merge " + otherBranch,
1005 line: "1",
1006 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1007 expected: ["branch " + otherBranch]
1008 };
1009 throw error;
1010 } else if (otherCommit === void 0 || !otherCommit) {
1011 let error = new Error(
1012 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") has no commits"
1013 );
1014 error.hash = {
1015 text: "merge " + otherBranch,
1016 token: "merge " + otherBranch,
1017 line: "1",
1018 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1019 expected: ['"commit"']
1020 };
1021 throw error;
1022 } else if (currentCommit === otherCommit) {
1023 let error = new Error('Incorrect usage of "merge". Both branches have same head');
1024 error.hash = {
1025 text: "merge " + otherBranch,
1026 token: "merge " + otherBranch,
1027 line: "1",
1028 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1029 expected: ["branch abc"]
1030 };
1031 throw error;
1032 } else if (custom_id && commits[custom_id] !== void 0) {
1033 let error = new Error(
1034 'Incorrect usage of "merge". Commit with id:' + custom_id + " already exists, use different custom Id"
1035 );
1036 error.hash = {
1037 text: "merge " + otherBranch + custom_id + override_type + custom_tag,
1038 token: "merge " + otherBranch + custom_id + override_type + custom_tag,
1039 line: "1",
1040 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1041 expected: [
1042 "merge " + otherBranch + " " + custom_id + "_UNIQUE " + override_type + " " + custom_tag
1043 ]
1044 };
1045 throw error;
1046 }
1047 const commit2 = {
1048 id: custom_id ? custom_id : seq + "-" + getId(),
1049 message: "merged branch " + otherBranch + " into " + curBranch,
1050 seq: seq++,
1051 parents: [head == null ? null : head.id, branches[otherBranch]],
1052 branch: curBranch,
1053 type: commitType$1.MERGE,
1054 customType: override_type,
1055 customId: custom_id ? true : false,
1056 tag: custom_tag ? custom_tag : ""
1057 };
1058 head = commit2;
1059 commits[commit2.id] = commit2;
1060 branches[curBranch] = commit2.id;
1061 log.debug(branches);
1062 log.debug("in mergeBranch");
1063};
1064const cherryPick = function(sourceId, targetId, tag, parentCommitId) {
1065 log.debug("Entering cherryPick:", sourceId, targetId, tag);
1066 sourceId = common.sanitizeText(sourceId, getConfig());
1067 targetId = common.sanitizeText(targetId, getConfig());
1068 tag = common.sanitizeText(tag, getConfig());
1069 parentCommitId = common.sanitizeText(parentCommitId, getConfig());
1070 if (!sourceId || commits[sourceId] === void 0) {
1071 let error = new Error(
1072 'Incorrect usage of "cherryPick". Source commit id should exist and provided'
1073 );
1074 error.hash = {
1075 text: "cherryPick " + sourceId + " " + targetId,
1076 token: "cherryPick " + sourceId + " " + targetId,
1077 line: "1",
1078 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1079 expected: ["cherry-pick abc"]
1080 };
1081 throw error;
1082 }
1083 let sourceCommit = commits[sourceId];
1084 let sourceCommitBranch = sourceCommit.branch;
1085 if (parentCommitId && !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) {
1086 let error = new Error(
1087 "Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."
1088 );
1089 throw error;
1090 }
1091 if (sourceCommit.type === commitType$1.MERGE && !parentCommitId) {
1092 let error = new Error(
1093 "Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."
1094 );
1095 throw error;
1096 }
1097 if (!targetId || commits[targetId] === void 0) {
1098 if (sourceCommitBranch === curBranch) {
1099 let error = new Error(
1100 'Incorrect usage of "cherryPick". Source commit is already on current branch'
1101 );
1102 error.hash = {
1103 text: "cherryPick " + sourceId + " " + targetId,
1104 token: "cherryPick " + sourceId + " " + targetId,
1105 line: "1",
1106 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1107 expected: ["cherry-pick abc"]
1108 };
1109 throw error;
1110 }
1111 const currentCommit = commits[branches[curBranch]];
1112 if (currentCommit === void 0 || !currentCommit) {
1113 let error = new Error(
1114 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ")has no commits"
1115 );
1116 error.hash = {
1117 text: "cherryPick " + sourceId + " " + targetId,
1118 token: "cherryPick " + sourceId + " " + targetId,
1119 line: "1",
1120 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1121 expected: ["cherry-pick abc"]
1122 };
1123 throw error;
1124 }
1125 const commit2 = {
1126 id: seq + "-" + getId(),
1127 message: "cherry-picked " + sourceCommit + " into " + curBranch,
1128 seq: seq++,
1129 parents: [head == null ? null : head.id, sourceCommit.id],
1130 branch: curBranch,
1131 type: commitType$1.CHERRY_PICK,
1132 tag: tag ?? `cherry-pick:${sourceCommit.id}${sourceCommit.type === commitType$1.MERGE ? `|parent:${parentCommitId}` : ""}`
1133 };
1134 head = commit2;
1135 commits[commit2.id] = commit2;
1136 branches[curBranch] = commit2.id;
1137 log.debug(branches);
1138 log.debug("in cherryPick");
1139 }
1140};
1141const checkout = function(branch2) {
1142 branch2 = common.sanitizeText(branch2, getConfig());
1143 if (branches[branch2] === void 0) {
1144 let error = new Error(
1145 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch2 + '")'
1146 );
1147 error.hash = {
1148 text: "checkout " + branch2,
1149 token: "checkout " + branch2,
1150 line: "1",
1151 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
1152 expected: ['"branch ' + branch2 + '"']
1153 };
1154 throw error;
1155 } else {
1156 curBranch = branch2;
1157 const id = branches[curBranch];
1158 head = commits[id];
1159 }
1160};
1161function upsert(arr, key, newVal) {
1162 const index = arr.indexOf(key);
1163 if (index === -1) {
1164 arr.push(newVal);
1165 } else {
1166 arr.splice(index, 1, newVal);
1167 }
1168}
1169function prettyPrintCommitHistory(commitArr) {
1170 const commit2 = commitArr.reduce((out, commit3) => {
1171 if (out.seq > commit3.seq) {
1172 return out;
1173 }
1174 return commit3;
1175 }, commitArr[0]);
1176 let line = "";
1177 commitArr.forEach(function(c) {
1178 if (c === commit2) {
1179 line += " *";
1180 } else {
1181 line += " |";
1182 }
1183 });
1184 const label = [line, commit2.id, commit2.seq];
1185 for (let branch2 in branches) {
1186 if (branches[branch2] === commit2.id) {
1187 label.push(branch2);
1188 }
1189 }
1190 log.debug(label.join(" "));
1191 if (commit2.parents && commit2.parents.length == 2) {
1192 const newCommit = commits[commit2.parents[0]];
1193 upsert(commitArr, commit2, newCommit);
1194 commitArr.push(commits[commit2.parents[1]]);
1195 } else if (commit2.parents.length == 0) {
1196 return;
1197 } else {
1198 const nextCommit = commits[commit2.parents];
1199 upsert(commitArr, commit2, nextCommit);
1200 }
1201 commitArr = uniqBy(commitArr, (c) => c.id);
1202 prettyPrintCommitHistory(commitArr);
1203}
1204const prettyPrint = function() {
1205 log.debug(commits);
1206 const node = getCommitsArray()[0];
1207 prettyPrintCommitHistory([node]);
1208};
1209const clear$1 = function() {
1210 commits = {};
1211 head = null;
1212 let mainBranch = getConfig().gitGraph.mainBranchName;
1213 let mainBranchOrder2 = getConfig().gitGraph.mainBranchOrder;
1214 branches = {};
1215 branches[mainBranch] = null;
1216 branchesConfig = {};
1217 branchesConfig[mainBranch] = { name: mainBranch, order: mainBranchOrder2 };
1218 curBranch = mainBranch;
1219 seq = 0;
1220 clear$2();
1221};
1222const getBranchesAsObjArray = function() {
1223 const branchesArray = Object.values(branchesConfig).map((branchConfig, i) => {
1224 if (branchConfig.order !== null) {
1225 return branchConfig;
1226 }
1227 return {
1228 ...branchConfig,
1229 order: parseFloat(`0.${i}`, 10)
1230 };
1231 }).sort((a, b) => a.order - b.order).map(({ name }) => ({ name }));
1232 return branchesArray;
1233};
1234const getBranches = function() {
1235 return branches;
1236};
1237const getCommits = function() {
1238 return commits;
1239};
1240const getCommitsArray = function() {
1241 const commitArr = Object.keys(commits).map(function(key) {
1242 return commits[key];
1243 });
1244 commitArr.forEach(function(o) {
1245 log.debug(o.id);
1246 });
1247 commitArr.sort((a, b) => a.seq - b.seq);
1248 return commitArr;
1249};
1250const getCurrentBranch = function() {
1251 return curBranch;
1252};
1253const getDirection = function() {
1254 return direction;
1255};
1256const getHead = function() {
1257 return head;
1258};
1259const commitType$1 = {
1260 NORMAL: 0,
1261 REVERSE: 1,
1262 HIGHLIGHT: 2,
1263 MERGE: 3,
1264 CHERRY_PICK: 4
1265};
1266const gitGraphDb = {
1267 getConfig: () => getConfig().gitGraph,
1268 setDirection,
1269 setOptions,
1270 getOptions,
1271 commit,
1272 branch,
1273 merge,
1274 cherryPick,
1275 checkout,
1276 //reset,
1277 prettyPrint,
1278 clear: clear$1,
1279 getBranchesAsObjArray,
1280 getBranches,
1281 getCommits,
1282 getCommitsArray,
1283 getCurrentBranch,
1284 getDirection,
1285 getHead,
1286 setAccTitle,
1287 getAccTitle,
1288 getAccDescription,
1289 setAccDescription,
1290 setDiagramTitle,
1291 getDiagramTitle,
1292 commitType: commitType$1
1293};
1294let allCommitsDict = {};
1295const commitType = {
1296 NORMAL: 0,
1297 REVERSE: 1,
1298 HIGHLIGHT: 2,
1299 MERGE: 3,
1300 CHERRY_PICK: 4
1301};
1302const THEME_COLOR_LIMIT = 8;
1303let branchPos = {};
1304let commitPos = {};
1305let lanes = [];
1306let maxPos = 0;
1307let dir = "LR";
1308const clear = () => {
1309 branchPos = {};
1310 commitPos = {};
1311 allCommitsDict = {};
1312 maxPos = 0;
1313 lanes = [];
1314 dir = "LR";
1315};
1316const drawText = (txt) => {
1317 const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text");
1318 let rows = [];
1319 if (typeof txt === "string") {
1320 rows = txt.split(/\\n|\n|<br\s*\/?>/gi);
1321 } else if (Array.isArray(txt)) {
1322 rows = txt;
1323 } else {
1324 rows = [];
1325 }
1326 for (const row of rows) {
1327 const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
1328 tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
1329 tspan.setAttribute("dy", "1em");
1330 tspan.setAttribute("x", "0");
1331 tspan.setAttribute("class", "row");
1332 tspan.textContent = row.trim();
1333 svgLabel.appendChild(tspan);
1334 }
1335 return svgLabel;
1336};
1337const findClosestParent = (parents) => {
1338 let closestParent = "";
1339 let maxPosition = 0;
1340 parents.forEach((parent) => {
1341 const parentPosition = dir === "TB" ? commitPos[parent].y : commitPos[parent].x;
1342 if (parentPosition >= maxPosition) {
1343 closestParent = parent;
1344 maxPosition = parentPosition;
1345 }
1346 });
1347 return closestParent || void 0;
1348};
1349const drawCommits = (svg, commits2, modifyGraph) => {
1350 const gitGraphConfig = getConfig().gitGraph;
1351 const gBullets = svg.append("g").attr("class", "commit-bullets");
1352 const gLabels = svg.append("g").attr("class", "commit-labels");
1353 let pos = 0;
1354 if (dir === "TB") {
1355 pos = 30;
1356 }
1357 const keys = Object.keys(commits2);
1358 const sortedKeys = keys.sort((a, b) => {
1359 return commits2[a].seq - commits2[b].seq;
1360 });
1361 const isParallelCommits = gitGraphConfig.parallelCommits;
1362 const layoutOffset = 10;
1363 const commitStep = 40;
1364 sortedKeys.forEach((key) => {
1365 const commit2 = commits2[key];
1366 if (isParallelCommits) {
1367 if (commit2.parents.length) {
1368 const closestParent = findClosestParent(commit2.parents);
1369 pos = dir === "TB" ? commitPos[closestParent].y + commitStep : commitPos[closestParent].x + commitStep;
1370 } else {
1371 pos = 0;
1372 if (dir === "TB") {
1373 pos = 30;
1374 }
1375 }
1376 }
1377 const posWithOffset = pos + layoutOffset;
1378 const y = dir === "TB" ? posWithOffset : branchPos[commit2.branch].pos;
1379 const x = dir === "TB" ? branchPos[commit2.branch].pos : posWithOffset;
1380 if (modifyGraph) {
1381 let typeClass;
1382 let commitSymbolType = commit2.customType !== void 0 && commit2.customType !== "" ? commit2.customType : commit2.type;
1383 switch (commitSymbolType) {
1384 case commitType.NORMAL:
1385 typeClass = "commit-normal";
1386 break;
1387 case commitType.REVERSE:
1388 typeClass = "commit-reverse";
1389 break;
1390 case commitType.HIGHLIGHT:
1391 typeClass = "commit-highlight";
1392 break;
1393 case commitType.MERGE:
1394 typeClass = "commit-merge";
1395 break;
1396 case commitType.CHERRY_PICK:
1397 typeClass = "commit-cherry-pick";
1398 break;
1399 default:
1400 typeClass = "commit-normal";
1401 }
1402 if (commitSymbolType === commitType.HIGHLIGHT) {
1403 const circle = gBullets.append("rect");
1404 circle.attr("x", x - 10);
1405 circle.attr("y", y - 10);
1406 circle.attr("height", 20);
1407 circle.attr("width", 20);
1408 circle.attr(
1409 "class",
1410 `commit ${commit2.id} commit-highlight${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-outer`
1411 );
1412 gBullets.append("rect").attr("x", x - 6).attr("y", y - 6).attr("height", 12).attr("width", 12).attr(
1413 "class",
1414 `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-inner`
1415 );
1416 } else if (commitSymbolType === commitType.CHERRY_PICK) {
1417 gBullets.append("circle").attr("cx", x).attr("cy", y).attr("r", 10).attr("class", `commit ${commit2.id} ${typeClass}`);
1418 gBullets.append("circle").attr("cx", x - 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
1419 gBullets.append("circle").attr("cx", x + 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
1420 gBullets.append("line").attr("x1", x + 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
1421 gBullets.append("line").attr("x1", x - 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
1422 } else {
1423 const circle = gBullets.append("circle");
1424 circle.attr("cx", x);
1425 circle.attr("cy", y);
1426 circle.attr("r", commit2.type === commitType.MERGE ? 9 : 10);
1427 circle.attr(
1428 "class",
1429 `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}`
1430 );
1431 if (commitSymbolType === commitType.MERGE) {
1432 const circle2 = gBullets.append("circle");
1433 circle2.attr("cx", x);
1434 circle2.attr("cy", y);
1435 circle2.attr("r", 6);
1436 circle2.attr(
1437 "class",
1438 `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}`
1439 );
1440 }
1441 if (commitSymbolType === commitType.REVERSE) {
1442 const cross = gBullets.append("path");
1443 cross.attr("d", `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`).attr(
1444 "class",
1445 `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}`
1446 );
1447 }
1448 }
1449 }
1450 if (dir === "TB") {
1451 commitPos[commit2.id] = { x, y: posWithOffset };
1452 } else {
1453 commitPos[commit2.id] = { x: posWithOffset, y };
1454 }
1455 if (modifyGraph) {
1456 const px = 4;
1457 const py = 2;
1458 if (commit2.type !== commitType.CHERRY_PICK && (commit2.customId && commit2.type === commitType.MERGE || commit2.type !== commitType.MERGE) && gitGraphConfig.showCommitLabel) {
1459 const wrapper = gLabels.append("g");
1460 const labelBkg = wrapper.insert("rect").attr("class", "commit-label-bkg");
1461 const text = wrapper.append("text").attr("x", pos).attr("y", y + 25).attr("class", "commit-label").text(commit2.id);
1462 let bbox = text.node().getBBox();
1463 labelBkg.attr("x", posWithOffset - bbox.width / 2 - py).attr("y", y + 13.5).attr("width", bbox.width + 2 * py).attr("height", bbox.height + 2 * py);
1464 if (dir === "TB") {
1465 labelBkg.attr("x", x - (bbox.width + 4 * px + 5)).attr("y", y - 12);
1466 text.attr("x", x - (bbox.width + 4 * px)).attr("y", y + bbox.height - 12);
1467 }
1468 if (dir !== "TB") {
1469 text.attr("x", posWithOffset - bbox.width / 2);
1470 }
1471 if (gitGraphConfig.rotateCommitLabel) {
1472 if (dir === "TB") {
1473 text.attr("transform", "rotate(-45, " + x + ", " + y + ")");
1474 labelBkg.attr("transform", "rotate(-45, " + x + ", " + y + ")");
1475 } else {
1476 let r_x = -7.5 - (bbox.width + 10) / 25 * 9.5;
1477 let r_y = 10 + bbox.width / 25 * 8.5;
1478 wrapper.attr(
1479 "transform",
1480 "translate(" + r_x + ", " + r_y + ") rotate(-45, " + pos + ", " + y + ")"
1481 );
1482 }
1483 }
1484 }
1485 if (commit2.tag) {
1486 const rect = gLabels.insert("polygon");
1487 const hole = gLabels.append("circle");
1488 const tag = gLabels.append("text").attr("y", y - 16).attr("class", "tag-label").text(commit2.tag);
1489 let tagBbox = tag.node().getBBox();
1490 tag.attr("x", posWithOffset - tagBbox.width / 2);
1491 const h2 = tagBbox.height / 2;
1492 const ly = y - 19.2;
1493 rect.attr("class", "tag-label-bkg").attr(
1494 "points",
1495 `
1496 ${pos - tagBbox.width / 2 - px / 2},${ly + py}
1497 ${pos - tagBbox.width / 2 - px / 2},${ly - py}
1498 ${posWithOffset - tagBbox.width / 2 - px},${ly - h2 - py}
1499 ${posWithOffset + tagBbox.width / 2 + px},${ly - h2 - py}
1500 ${posWithOffset + tagBbox.width / 2 + px},${ly + h2 + py}
1501 ${posWithOffset - tagBbox.width / 2 - px},${ly + h2 + py}`
1502 );
1503 hole.attr("cx", pos - tagBbox.width / 2 + px / 2).attr("cy", ly).attr("r", 1.5).attr("class", "tag-hole");
1504 if (dir === "TB") {
1505 rect.attr("class", "tag-label-bkg").attr(
1506 "points",
1507 `
1508 ${x},${pos + py}
1509 ${x},${pos - py}
1510 ${x + layoutOffset},${pos - h2 - py}
1511 ${x + layoutOffset + tagBbox.width + px},${pos - h2 - py}
1512 ${x + layoutOffset + tagBbox.width + px},${pos + h2 + py}
1513 ${x + layoutOffset},${pos + h2 + py}`
1514 ).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")");
1515 hole.attr("cx", x + px / 2).attr("cy", pos).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")");
1516 tag.attr("x", x + 5).attr("y", pos + 3).attr("transform", "translate(14,14) rotate(45, " + x + "," + pos + ")");
1517 }
1518 }
1519 }
1520 pos += commitStep + layoutOffset;
1521 if (pos > maxPos) {
1522 maxPos = pos;
1523 }
1524 });
1525};
1526const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => {
1527 const commitBIsFurthest = dir === "TB" ? p1.x < p2.x : p1.y < p2.y;
1528 const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch;
1529 const isOnBranchToGetCurve = (x) => x.branch === branchToGetCurve;
1530 const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
1531 return Object.values(allCommits).some((commitX) => {
1532 return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX);
1533 });
1534};
1535const findLane = (y1, y2, depth = 0) => {
1536 const candidate = y1 + Math.abs(y1 - y2) / 2;
1537 if (depth > 5) {
1538 return candidate;
1539 }
1540 let ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10);
1541 if (ok) {
1542 lanes.push(candidate);
1543 return candidate;
1544 }
1545 const diff = Math.abs(y1 - y2);
1546 return findLane(y1, y2 - diff / 5, depth + 1);
1547};
1548const drawArrow = (svg, commitA, commitB, allCommits) => {
1549 const p1 = commitPos[commitA.id];
1550 const p2 = commitPos[commitB.id];
1551 const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits);
1552 let arc = "";
1553 let arc2 = "";
1554 let radius = 0;
1555 let offset = 0;
1556 let colorClassNum = branchPos[commitB.branch].index;
1557 if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1558 colorClassNum = branchPos[commitA.branch].index;
1559 }
1560 let lineDef;
1561 if (arrowNeedsRerouting) {
1562 arc = "A 10 10, 0, 0, 0,";
1563 arc2 = "A 10 10, 0, 0, 1,";
1564 radius = 10;
1565 offset = 10;
1566 const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y);
1567 const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x);
1568 if (dir === "TB") {
1569 if (p1.x < p2.x) {
1570 lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1571 } else {
1572 colorClassNum = branchPos[commitA.branch].index;
1573 lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
1574 }
1575 } else {
1576 if (p1.y < p2.y) {
1577 lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`;
1578 } else {
1579 colorClassNum = branchPos[commitA.branch].index;
1580 lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`;
1581 }
1582 }
1583 } else {
1584 arc = "A 20 20, 0, 0, 0,";
1585 arc2 = "A 20 20, 0, 0, 1,";
1586 radius = 20;
1587 offset = 20;
1588 if (dir === "TB") {
1589 if (p1.x < p2.x) {
1590 if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1591 lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1592 } else {
1593 lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
1594 }
1595 }
1596 if (p1.x > p2.x) {
1597 arc = "A 20 20, 0, 0, 0,";
1598 arc2 = "A 20 20, 0, 0, 1,";
1599 radius = 20;
1600 offset = 20;
1601 if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1602 lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`;
1603 } else {
1604 lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
1605 }
1606 }
1607 if (p1.x === p2.x) {
1608 lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
1609 }
1610 } else {
1611 if (p1.y < p2.y) {
1612 if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1613 lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
1614 } else {
1615 lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1616 }
1617 }
1618 if (p1.y > p2.y) {
1619 if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
1620 lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
1621 } else {
1622 lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
1623 }
1624 }
1625 if (p1.y === p2.y) {
1626 lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
1627 }
1628 }
1629 }
1630 svg.append("path").attr("d", lineDef).attr("class", "arrow arrow" + colorClassNum % THEME_COLOR_LIMIT);
1631};
1632const drawArrows = (svg, commits2) => {
1633 const gArrows = svg.append("g").attr("class", "commit-arrows");
1634 Object.keys(commits2).forEach((key) => {
1635 const commit2 = commits2[key];
1636 if (commit2.parents && commit2.parents.length > 0) {
1637 commit2.parents.forEach((parent) => {
1638 drawArrow(gArrows, commits2[parent], commit2, commits2);
1639 });
1640 }
1641 });
1642};
1643const drawBranches = (svg, branches2) => {
1644 const gitGraphConfig = getConfig().gitGraph;
1645 const g = svg.append("g");
1646 branches2.forEach((branch2, index) => {
1647 const adjustIndexForTheme = index % THEME_COLOR_LIMIT;
1648 const pos = branchPos[branch2.name].pos;
1649 const line = g.append("line");
1650 line.attr("x1", 0);
1651 line.attr("y1", pos);
1652 line.attr("x2", maxPos);
1653 line.attr("y2", pos);
1654 line.attr("class", "branch branch" + adjustIndexForTheme);
1655 if (dir === "TB") {
1656 line.attr("y1", 30);
1657 line.attr("x1", pos);
1658 line.attr("y2", maxPos);
1659 line.attr("x2", pos);
1660 }
1661 lanes.push(pos);
1662 let name = branch2.name;
1663 const labelElement = drawText(name);
1664 const bkg = g.insert("rect");
1665 const branchLabel = g.insert("g").attr("class", "branchLabel");
1666 const label = branchLabel.insert("g").attr("class", "label branch-label" + adjustIndexForTheme);
1667 label.node().appendChild(labelElement);
1668 let bbox = labelElement.getBBox();
1669 bkg.attr("class", "branchLabelBkg label" + adjustIndexForTheme).attr("rx", 4).attr("ry", 4).attr("x", -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)).attr("y", -bbox.height / 2 + 8).attr("width", bbox.width + 18).attr("height", bbox.height + 4);
1670 label.attr(
1671 "transform",
1672 "translate(" + (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + ", " + (pos - bbox.height / 2 - 1) + ")"
1673 );
1674 if (dir === "TB") {
1675 bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", 0);
1676 label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", 0)");
1677 }
1678 if (dir !== "TB") {
1679 bkg.attr("transform", "translate(-19, " + (pos - bbox.height / 2) + ")");
1680 }
1681 });
1682};
1683const draw = function(txt, id, ver, diagObj) {
1684 clear();
1685 const conf = getConfig();
1686 const gitGraphConfig = conf.gitGraph;
1687 log.debug("in gitgraph renderer", txt + "\n", "id:", id, ver);
1688 allCommitsDict = diagObj.db.getCommits();
1689 const branches2 = diagObj.db.getBranchesAsObjArray();
1690 dir = diagObj.db.getDirection();
1691 const diagram2 = d3select(`[id="${id}"]`);
1692 let pos = 0;
1693 branches2.forEach((branch2, index) => {
1694 const labelElement = drawText(branch2.name);
1695 const g = diagram2.append("g");
1696 const branchLabel = g.insert("g").attr("class", "branchLabel");
1697 const label = branchLabel.insert("g").attr("class", "label branch-label");
1698 label.node().appendChild(labelElement);
1699 let bbox = labelElement.getBBox();
1700 branchPos[branch2.name] = { pos, index };
1701 pos += 50 + (gitGraphConfig.rotateCommitLabel ? 40 : 0) + (dir === "TB" ? bbox.width / 2 : 0);
1702 label.remove();
1703 branchLabel.remove();
1704 g.remove();
1705 });
1706 drawCommits(diagram2, allCommitsDict, false);
1707 if (gitGraphConfig.showBranches) {
1708 drawBranches(diagram2, branches2);
1709 }
1710 drawArrows(diagram2, allCommitsDict);
1711 drawCommits(diagram2, allCommitsDict, true);
1712 utils.insertTitle(
1713 diagram2,
1714 "gitTitleText",
1715 gitGraphConfig.titleTopMargin,
1716 diagObj.db.getDiagramTitle()
1717 );
1718 setupGraphViewbox(
1719 void 0,
1720 diagram2,
1721 gitGraphConfig.diagramPadding,
1722 gitGraphConfig.useMaxWidth ?? conf.useMaxWidth
1723 );
1724};
1725const gitGraphRenderer = {
1726 draw
1727};
1728const getStyles = (options2) => `
1729 .commit-id,
1730 .commit-msg,
1731 .branch-label {
1732 fill: lightgrey;
1733 color: lightgrey;
1734 font-family: 'trebuchet ms', verdana, arial, sans-serif;
1735 font-family: var(--mermaid-font-family);
1736 }
1737 ${[0, 1, 2, 3, 4, 5, 6, 7].map(
1738 (i) => `
1739 .branch-label${i} { fill: ${options2["gitBranchLabel" + i]}; }
1740 .commit${i} { stroke: ${options2["git" + i]}; fill: ${options2["git" + i]}; }
1741 .commit-highlight${i} { stroke: ${options2["gitInv" + i]}; fill: ${options2["gitInv" + i]}; }
1742 .label${i} { fill: ${options2["git" + i]}; }
1743 .arrow${i} { stroke: ${options2["git" + i]}; }
1744 `
1745).join("\n")}
1746
1747 .branch {
1748 stroke-width: 1;
1749 stroke: ${options2.lineColor};
1750 stroke-dasharray: 2;
1751 }
1752 .commit-label { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelColor};}
1753 .commit-label-bkg { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelBackground}; opacity: 0.5; }
1754 .tag-label { font-size: ${options2.tagLabelFontSize}; fill: ${options2.tagLabelColor};}
1755 .tag-label-bkg { fill: ${options2.tagLabelBackground}; stroke: ${options2.tagLabelBorder}; }
1756 .tag-hole { fill: ${options2.textColor}; }
1757
1758 .commit-merge {
1759 stroke: ${options2.primaryColor};
1760 fill: ${options2.primaryColor};
1761 }
1762 .commit-reverse {
1763 stroke: ${options2.primaryColor};
1764 fill: ${options2.primaryColor};
1765 stroke-width: 3;
1766 }
1767 .commit-highlight-outer {
1768 }
1769 .commit-highlight-inner {
1770 stroke: ${options2.primaryColor};
1771 fill: ${options2.primaryColor};
1772 }
1773
1774 .arrow { stroke-width: 8; stroke-linecap: round; fill: none}
1775 .gitTitleText {
1776 text-anchor: middle;
1777 font-size: 18px;
1778 fill: ${options2.textColor};
1779 }
1780`;
1781const gitGraphStyles = getStyles;
1782const diagram = {
1783 parser: gitGraphParser,
1784 db: gitGraphDb,
1785 renderer: gitGraphRenderer,
1786 styles: gitGraphStyles
1787};
1788export {
1789 diagram
1790};
1791
\No newline at end of file