UNPKG

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