UNPKG

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