@cardenelabs/dragon 0.37.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +38 -1
  2. package/dist/cli.cjs +2403 -550
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +2408 -555
  5. package/dist/cli.js.map +1 -1
  6. package/dist/export.cjs +2252 -537
  7. package/dist/export.cjs.map +1 -1
  8. package/dist/export.d.cts +3 -1
  9. package/dist/export.d.ts +3 -1
  10. package/dist/export.js +2257 -542
  11. package/dist/export.js.map +1 -1
  12. package/dist/index.cjs +2387 -495
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +11 -154
  15. package/dist/index.d.ts +11 -154
  16. package/dist/index.js +2387 -496
  17. package/dist/index.js.map +1 -1
  18. package/dist/ink-B_7OXxtb.d.cts +360 -0
  19. package/dist/ink-B_7OXxtb.d.ts +360 -0
  20. package/dist/player.global.js +2 -2
  21. package/package.json +1 -1
  22. package/src/cli.ts +9 -0
  23. package/src/export/index.ts +4 -1
  24. package/src/field-messages.ts +8 -0
  25. package/src/figure-text.ts +28 -0
  26. package/src/index.ts +3 -0
  27. package/src/layout/architecture.ts +123 -44
  28. package/src/layout/git.ts +728 -0
  29. package/src/layout/measure.ts +10 -0
  30. package/src/layout/scene.ts +300 -19
  31. package/src/layout/sequence.ts +29 -11
  32. package/src/layout/state.ts +82 -62
  33. package/src/look/values.ts +57 -4
  34. package/src/messages.ts +47 -4
  35. package/src/parser.ts +142 -7
  36. package/src/player.ts +44 -0
  37. package/src/printer.ts +16 -4
  38. package/src/render/git.ts +161 -0
  39. package/src/render/ink.ts +104 -0
  40. package/src/render/parts.ts +103 -36
  41. package/src/render/svg.ts +63 -15
  42. package/src/schema.ts +47 -13
  43. package/src/schemas/diagram.schema.json +75 -8
  44. package/src/schemas/validate-diagram.js +1 -1
  45. package/src/timeline.ts +18 -3
  46. package/src/words.ts +19 -3
  47. package/dist/schema-B2MTRv66.d.cts +0 -133
  48. package/dist/schema-B2MTRv66.d.ts +0 -133
package/dist/cli.cjs CHANGED
@@ -270,7 +270,11 @@ var TYPE = {
270
270
  stepTitle: text(15, 700),
271
271
  stepBody: text(13.5, 500),
272
272
  stepNo: text(13, 700, "mono"),
273
- button: text(14, 700)
273
+ button: text(14, 700),
274
+ /** 枝分かれの図 (#3164) の、丸の中の commit の名札と、丸の外に添える hash と一言 */
275
+ gitId: text(11, 700),
276
+ gitHash: text(10.5, 600, "mono"),
277
+ gitNote: text(10.5, 650)
274
278
  };
275
279
  var LOOK = {
276
280
  /** 部品どうしの最小の隙間 */
@@ -280,7 +284,11 @@ var LOOK = {
280
284
  box: { h: 72, minW: 92, padX: 12, radius: 12, icon: 24, iconRadius: 7, iconY: -16, iconScale: 0.74, nameY: 12, subY: 27 },
281
285
  region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
282
286
  architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
283
- sequence: { columnGap: 40, labelRoom: 16, firstRow: 22, rowGap: 14, stepGap: 8, minPitch: 40, tail: 18, selfW: 34, selfH: 18 },
287
+ /**
288
+ * 時系列図。線の名前の札は、構成図と状態遷移図より線に寄せる (`labelOffset` は線から札の真ん中まで)。
289
+ * 札と線の離れが図の他の空きと同じ 6 になり、行を詰めても札がどの線の名前かが分かる (#3177)。
290
+ */
291
+ sequence: { columnGap: 40, labelRoom: 16, labelOffset: 16, firstRow: 10, rowGap: 6, stepGap: 6, minPitch: 32, tail: 10, selfW: 34, selfH: 18 },
284
292
  /**
285
293
  * 状態遷移図 (#3163)。状態は `columns` つずつ並べて次の段へ折り返し、段の間 (`rowGap`) の真ん中を、段をまたぐ線が通る。
286
294
  * `start` と `end` は始まりと終わりの印の半径と、印の中の丸の半径。`drop` は最初の状態の上端から始まりの印の中心まで、
@@ -310,17 +318,60 @@ var LOOK = {
310
318
  done: { r: 6.5, inset: 13 },
311
319
  pastLabel: 0.85
312
320
  },
321
+ /**
322
+ * 枝分かれの図 (#3164)。見本帳の試作 (`scenes/git.js`) の寸法を写す。
323
+ * commit は列ごとに `pitch` ずつ右へ並べ、一番上でない帯の commit は列の半分だけ右へずらす。`x0` は最初の列の真ん中の x の下限、
324
+ * `textGap` は隣の列の hash と一言の間に空ける最小の隙間。`r` は丸の半径、`orphan` はどの札からも辿れなくなった commit の点線の丸の半径。
325
+ * `topLine` と `line` は帯の上端から丸を並べる線まで (一番上の帯と、それより下の帯)、`topBelow` と `below` は線から帯の下端まで。
326
+ * `bare` は線の名前を下に置かない帯の、線から帯の下端まで。
327
+ * hash と一言は一番上の帯では丸の上に、ほかの帯では丸の下に置き、`above` と `under` は丸の真ん中から丸に近い行の基準線まで、`lineStep` は行の間。
328
+ * 札は丸の上に段を重ねて置き、`tagTop` と `tag` は丸の真ん中から 1 段目の札の真ん中まで (一番上の帯と、ほかの帯)、`row` は札の段の間。
329
+ * 札の段が 2 段より多い commit がある帯は、多い段の分だけ線を下げる。
330
+ * `turn` は枝へ分かれる線と枝から入る線が曲がり終えて横へ進むまでの長さ、`samples` は曲がりを区切る点の数、`boxGap` は commit の並びと箱の間。
331
+ * `labelUnder` はほかの帯で、丸の真ん中から線の名前の札の上端まで。`colors` は帯の色を上から配る順
332
+ */
333
+ git: {
334
+ x0: 120,
335
+ pitch: 90,
336
+ textGap: 12,
337
+ r: 12,
338
+ orphan: 13.5,
339
+ topLine: 120,
340
+ line: 90,
341
+ topBelow: 30,
342
+ below: 82,
343
+ bare: 62,
344
+ above: 18,
345
+ under: 27,
346
+ lineStep: 13,
347
+ tagTop: 58,
348
+ tag: 30,
349
+ row: 22,
350
+ turn: 60,
351
+ samples: 12,
352
+ boxGap: 24,
353
+ labelUnder: 50,
354
+ colors: ["blue", "violet", "green", "amber", "rose"]
355
+ },
313
356
  /** `bend` は線の曲がりを丸める半径 (#3171) */
314
357
  edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
315
- label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6 },
358
+ /** `touch` は線の名前と、同じ時刻に見えている段の番号の丸の間に空ける最小の隙間 (#3175) */
359
+ label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6, touch: 2 },
316
360
  action: { h: 22, padX: 10, radius: 11 },
317
361
  badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
318
362
  carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
363
+ /**
364
+ * 運ぶ物の置き場 (#3176)。運ぶ物を出し入れする箱は、絵柄の右に点線の枠を持ち、運ぶ物は着いた後と走り出す前にそこで待つ。
365
+ * `gap` は絵柄と枠の間、`pad` は枠と運ぶ物の間、`spread` は枠の中に横に並べた運ぶ物の間、`h` と `radius` は枠の高さと角の丸み。
366
+ * `clear` は状態遷移図の右上の済んだ印と枠の間に空ける最小の隙間。`lifeline` は時系列図で生存線と運ぶ物の間、
367
+ * `mark` は状態遷移図の始まりの印と、その左で走り出しを待つ運ぶ物の間
368
+ */
369
+ slot: { gap: 6, pad: 3, spread: 4, h: 24, radius: 7, clear: 2, lifeline: 5, mark: 4 },
319
370
  /**
320
371
  * `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
321
372
  */
322
373
  strip: { h: 72, line: 44, pad: 12, icon: 24, titleX: 44, fieldGap: 22, sepInset: 14, tagGap: 6, tagH: 15, tagPadX: 7, nameY: 22, valueY: 43, trail: { r: 5.4, step: 16 }, now: { r: 3, gap: 7 } },
323
- stroke: { hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
374
+ stroke: { git: 2.25, gitOrphan: 1.5, slot: 1.2, hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
324
375
  shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
325
376
  mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
326
377
  /**
@@ -334,7 +385,7 @@ var LOOK = {
334
385
  */
335
386
  follow: { aspect: 0.75, minH: 320, fitMinH: 160, ease: 0.6, narrow: 440, badgeRoom: 8, headRoom: 10, head: { pad: 8, h: 40, nameY: 17, subY: 31 } },
336
387
  /** 色を混ぜる割合 (%) */
337
- mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
388
+ mix: { slot: 45, icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
338
389
  /** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
339
390
  baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8, mark: 4 },
340
391
  /** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
@@ -382,6 +433,8 @@ var EASE = {
382
433
  };
383
434
 
384
435
  // src/figure-text.ts
436
+ var spaced = (word) => /[0-9A-Za-z]$/u.test(word) ? `${word} ` : word;
437
+ var capital = (text2) => text2.charAt(0).toUpperCase() + text2.slice(1);
385
438
  var FIGURE_TEXT = {
386
439
  ja: {
387
440
  cannotDraw: (detail2) => `\u56F3\u3092\u63CF\u3051\u306A\u3044: ${detail2}`,
@@ -396,7 +449,14 @@ var FIGURE_TEXT = {
396
449
  sideFrom: (count) => `${count} \u3064\u306E\u72B6\u614B\u304B\u3089\u5165\u308C\u308B`,
397
450
  trail: "\u901A\u3063\u305F\u72B6\u614B",
398
451
  start: "\u59CB\u307E\u308A",
399
- end: "\u7D42\u308F\u308A"
452
+ end: "\u7D42\u308F\u308A",
453
+ badgeName: (no) => `\u6BB5\u306E\u756A\u53F7 ${no}`,
454
+ quoted: (text2) => `\u300C${text2}\u300D`,
455
+ iconOf: (box) => `\u300C${box} \u306E\u7D75\u67C4\u300D`,
456
+ coin: "\u300C\u786C\u8CA8\u300D",
457
+ envelope: "\u300C\u5C01\u7B52\u300D",
458
+ textsOverlap: (a, b) => `${spaced(a)}\u3068${spaced(b)}\u304C\u91CD\u306A\u308B`,
459
+ lineCrosses: (from, to, text2) => `\u7DDA ${from} \u2192 ${to} \u304C${spaced(text2)}\u3092\u6A2A\u5207\u308B`
400
460
  },
401
461
  en: {
402
462
  cannotDraw: (detail2) => `Cannot draw the diagram: ${detail2}`,
@@ -411,7 +471,14 @@ var FIGURE_TEXT = {
411
471
  sideFrom: (count) => `Enterable from ${count} ${count === 1 ? "state" : "states"}`,
412
472
  trail: "States passed",
413
473
  start: "Start",
414
- end: "End"
474
+ end: "End",
475
+ badgeName: (no) => `step number ${no}`,
476
+ quoted: (text2) => `"${text2}"`,
477
+ iconOf: (box) => `the icon of "${box}"`,
478
+ coin: "the coin",
479
+ envelope: "the envelope",
480
+ textsOverlap: (a, b) => capital(`${a} and ${b} overlap`),
481
+ lineCrosses: (from, to, text2) => `The line ${from} \u2192 ${to} crosses ${text2}`
415
482
  }
416
483
  };
417
484
 
@@ -426,6 +493,10 @@ function textWidth(text2, style) {
426
493
  for (const ch of text2) sum += advance(ch, family);
427
494
  return sum * style.size / EM;
428
495
  }
496
+ function textBox(text2, x, y, style, anchor = "start") {
497
+ const w = textWidth(text2, style);
498
+ return { x: anchor === "middle" ? x - w / 2 : x, y: y - style.size * 0.8, w, h: style.size };
499
+ }
429
500
 
430
501
  // src/layout/scene.ts
431
502
  function edgesOf(diagram) {
@@ -460,11 +531,93 @@ function boxWidth(diagram, id, withActions) {
460
531
  }
461
532
  return Math.max(LOOK.box.minW, Math.max(...lines) + LOOK.box.padX * 2);
462
533
  }
534
+ function carrierHalf(carry) {
535
+ const C = LOOK.carrier;
536
+ if (carry.kind === "tag") return [(textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2, C.tagH / 2];
537
+ if (carry.kind === "coin") return [C.coinR, C.coinR];
538
+ return [C.envW / 2, C.envH / 2];
539
+ }
540
+ var roomWidth = (room) => room.main + room.coin + (room.main > 0 && room.coin > 0 ? LOOK.slot.spread : 0);
541
+ function slotRooms(diagram) {
542
+ const rooms = /* @__PURE__ */ new Map();
543
+ const ids = new Set(diagram.boxes.map((b) => b.id));
544
+ for (const step of diagram.steps) {
545
+ for (const event of step.events) {
546
+ if (event.type !== "edge" || event.carry.kind === "none") continue;
547
+ const who = event.carry.kind === "coin" ? "coin" : "main";
548
+ const w = carrierHalf(event.carry)[0] * 2;
549
+ for (const id of [event.from, event.to]) {
550
+ if (!ids.has(id)) continue;
551
+ const room = rooms.get(id) ?? { main: 0, coin: 0 };
552
+ room[who] = Math.max(room[who], w);
553
+ rooms.set(id, room);
554
+ }
555
+ }
556
+ }
557
+ return rooms;
558
+ }
559
+ function slotBoxWidth(room, icon, right) {
560
+ if (!room) return 0;
561
+ return (icon ? LOOK.box.icon + LOOK.slot.gap : 0) + roomWidth(room) + LOOK.slot.pad * 2 + LOOK.box.padX + right;
562
+ }
563
+ function placeSlot(box, room, right = LOOK.box.padX) {
564
+ if (!room) return;
565
+ const B = LOOK.box;
566
+ const S2 = LOOK.slot;
567
+ const w = roomWidth(room) + S2.pad * 2;
568
+ const lead = box.icon ? B.icon + S2.gap : 0;
569
+ const left = Math.max(box.x + B.padX, Math.min(box.cx - (lead + w) / 2, box.x + box.w - right - (lead + w)));
570
+ if (box.icon) box.iconX = left + B.icon / 2;
571
+ box.slot = { x: left + lead, y: box.cy + B.iconY - S2.h / 2, w, h: S2.h };
572
+ }
573
+ function seatCarriers(edges, boxes, rooms) {
574
+ const S2 = LOOK.slot;
575
+ const seat = (id, carry) => {
576
+ const box = boxes.get(id);
577
+ const room = rooms.get(id);
578
+ if (!box?.slot || !room) return void 0;
579
+ const inner = box.slot.x + S2.pad;
580
+ const y = box.slot.y + box.slot.h / 2;
581
+ if (room.main > 0 && room.coin > 0) return carry.kind === "coin" ? [inner + room.main + S2.spread + room.coin / 2, y] : [inner + room.main / 2, y];
582
+ return [box.slot.x + box.slot.w / 2, y];
583
+ };
584
+ for (const edge2 of edges) {
585
+ if (edge2.carry.kind === "none") continue;
586
+ const settle = seat(edge2.to, edge2.carry);
587
+ const wait = seat(edge2.from, edge2.carry);
588
+ if (settle) edge2.settle = settle;
589
+ if (wait) edge2.wait = wait;
590
+ }
591
+ }
463
592
  function gapBetween(a, b) {
464
593
  const dx = Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w));
465
594
  const dy = Math.max(b.y - (a.y + a.h), a.y - (b.y + b.h));
466
595
  return Math.max(dx, dy);
467
596
  }
597
+ function crossesRect(points, rect, inset = 0) {
598
+ const x0 = rect.x + inset;
599
+ const y0 = rect.y + inset;
600
+ const x1 = rect.x + rect.w - inset;
601
+ const y1 = rect.y + rect.h - inset;
602
+ if (x1 <= x0 || y1 <= y0) return false;
603
+ for (let i = 1; i < points.length; i++) {
604
+ const [ax, ay] = points[i - 1];
605
+ const [bx, by] = points[i];
606
+ const dx = bx - ax;
607
+ const dy = by - ay;
608
+ let lo = 0;
609
+ let hi = 1;
610
+ const cut = (p, q) => {
611
+ if (p === 0) return q > 0;
612
+ const r = q / p;
613
+ if (p < 0) lo = Math.max(lo, r);
614
+ else hi = Math.min(hi, r);
615
+ return lo < hi;
616
+ };
617
+ if (cut(-dx, ax - x0) && cut(dx, x1 - ax) && cut(-dy, ay - y0) && cut(dy, y1 - ay)) return true;
618
+ }
619
+ return false;
620
+ }
468
621
  function longest(points) {
469
622
  let best = { a: points[0], b: points[1] ?? points[0], length: -1 };
470
623
  for (let i = 1; i < points.length; i++) {
@@ -495,34 +648,122 @@ function pathLength(points) {
495
648
  }
496
649
  return sum;
497
650
  }
498
- function badgeOnPath(points) {
651
+ function loopUnder(box) {
652
+ const { w, h, samples } = LOOK.state.loop;
653
+ const bottom = box.y + box.h;
654
+ const p0 = [box.cx + w / 2, bottom];
655
+ const c1 = [box.cx + w * 3 / 4, bottom + h * 4 / 3];
656
+ const c2 = [box.cx - w * 3 / 4, bottom + h * 4 / 3];
657
+ const p3 = [box.cx - w / 2, bottom + LOOK.edge.inset];
658
+ return Array.from({ length: samples + 1 }, (_, k) => {
659
+ const t = k / samples;
660
+ const u = 1 - t;
661
+ const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
662
+ return [at2(0), at2(1)];
663
+ });
664
+ }
665
+ function loopBadge(points) {
666
+ const right = Math.max(...points.map(([px]) => px));
667
+ const top = points[0][1];
668
+ const deep = Math.max(...points.map(([, py]) => py));
669
+ return [right + LOOK.badge.r + LOOK.badge.inset, top + (deep - top) * LOOK.state.loop.badgeAt];
670
+ }
671
+ function loopLabelBase(points, w) {
672
+ return { x: (points[0]?.[0] ?? 0) - LOOK.state.loop.w / 2 - w / 2, y: Math.max(...points.map(([, y]) => y)) + LOOK.label.soft };
673
+ }
674
+ var LOOP_ROOM = LOOK.state.loop.h + LOOK.label.soft * 2 + LOOK.label.h;
675
+ function badgeOnPath(points, taken = [], lines = []) {
676
+ const length = pathLength(points);
677
+ const first = length < LOOK.badge.short ? Math.min(LOOK.badge.r + 1, length / 2) : LOOK.badge.along;
678
+ const apart = LOOK.badge.r * 2 + LOOK.badge.inset;
679
+ for (let d = first; d <= length; d += 1) {
680
+ const p = along(points, d);
681
+ if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart)) return p;
682
+ }
683
+ return besideLine(points, first, taken, lines) ?? along(points, first);
684
+ }
685
+ function besideLine(points, at2, taken, lines) {
499
686
  const length = pathLength(points);
500
- return along(points, length < LOOK.badge.short ? length / 2 : LOOK.badge.along);
687
+ const [px, py] = along(points, at2);
688
+ const [ax, ay] = along(points, Math.max(0, at2 - 1));
689
+ const [bx, by] = along(points, Math.min(length, at2 + 1));
690
+ const n = Math.hypot(bx - ax, by - ay);
691
+ if (n === 0) return void 0;
692
+ const [nx, ny] = [-(by - ay) / n, (bx - ax) / n];
693
+ const size = LOOK.badge.r * 2;
694
+ for (const margin of [LOOK.edge.arrowHalf, 0]) {
695
+ for (let s = 1; s <= size + LOOK.badge.inset; s++) {
696
+ for (const sign of [1, -1]) {
697
+ const c = [px + nx * s * sign, py + ny * s * sign];
698
+ const free = taken.every(([x, y]) => Math.max(Math.abs(c[0] - x), Math.abs(c[1] - y)) >= size + 1);
699
+ if (free && lines.every((line) => !crossesRect(line, badgeRect(c), -margin))) return c;
700
+ }
701
+ }
702
+ }
703
+ return void 0;
704
+ }
705
+ var lineKey = (edge2) => edge2.points.map(([x, y]) => `${Math.round(x * 10)},${Math.round(y * 10)}`).join(" ");
706
+ function lineBadges(edges, steps, at2 = (edge2, taken, lines) => badgeOnPath(edge2.points, taken, lines)) {
707
+ const out = /* @__PURE__ */ new Map();
708
+ const taken = [];
709
+ const placed = /* @__PURE__ */ new Map();
710
+ for (let s = 0; s < steps; s++) {
711
+ const edge2 = edges.find((e) => e.step === s && e.points.length > 0);
712
+ if (!edge2) continue;
713
+ const key = lineKey(edge2);
714
+ const before = placed.get(key);
715
+ if (before) {
716
+ out.set(s, { point: before, edge: edge2 });
717
+ continue;
718
+ }
719
+ const lines = edges.filter((e) => e.points.length > 1 && lineKey(e) !== key).map((e) => e.points);
720
+ const point = at2(edge2, taken, lines);
721
+ taken.push(point);
722
+ placed.set(key, point);
723
+ out.set(s, { point, edge: edge2 });
724
+ }
725
+ return out;
501
726
  }
727
+ function replaceSameSpot(badges2) {
728
+ const same2 = (a, b) => Math.hypot(a.x - b.x, a.y - b.y) <= 0.5;
729
+ return badges2.map((badge2) => {
730
+ const next = badges2.filter((other) => other.step > badge2.step && same2(other, badge2)).sort((a, b) => a.step - b.step)[0];
731
+ return next ? { ...badge2, until: next.step } : badge2;
732
+ });
733
+ }
734
+ var badgeRect = ([x, y]) => ({ x: x - LOOK.badge.r, y: y - LOOK.badge.r, w: LOOK.badge.r * 2, h: LOOK.badge.r * 2 });
735
+ var markText = (e) => [e.x + LOOK.state.text, e.y + LOOK.baseline.mark];
502
736
  var labelStyle = (text2) => hasWide(text2) ? TYPE.labelJa : TYPE.label;
737
+ var OPPOSITE = { above: "below", below: "above", left: "right", right: "left" };
503
738
  function placeLabel(request, obstacles) {
504
739
  const w = textWidth(request.text, labelStyle(request.text)) + LOOK.label.padX * 2;
505
740
  const h = LOOK.label.h;
506
741
  const segment = longest(request.points);
507
742
  const mx = (segment.a[0] + segment.b[0]) / 2;
508
743
  const my = (segment.a[1] + segment.b[1]) / 2;
509
- const side2 = request.side ?? (segment.vertical ? "right" : "above");
510
- const { offset, side: sideGap } = LOOK.label;
511
- const base = side2 === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side2 === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side2 === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
512
- const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
513
- const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
514
- const slideMax = side2 === "above" || side2 === "below" ? w : h * 4;
515
- const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft);
744
+ const preferred = request.side ?? (segment.vertical ? "right" : "above");
745
+ const { side: sideGap } = LOOK.label;
746
+ const offset = request.offset ?? LOOK.label.offset;
747
+ const baseOf = (side2) => side2 === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side2 === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side2 === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
748
+ const first = request.base ? { ...request.base, w, h } : baseOf(preferred);
749
+ const sides = request.flip ? [preferred, OPPOSITE[preferred]] : [preferred];
750
+ const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft) && (obstacles.touch ?? []).every((mark) => gapBetween(rect, mark) >= LOOK.label.touch) && (obstacles.lines ?? []).every((line) => !crossesRect(line, rect, -2));
516
751
  const { search, searchMax } = LOOK.label;
517
752
  for (let d = 0; d <= searchMax; d += search) {
518
- for (let s = 0; s <= slideMax; s += search) {
519
- for (const sign of s === 0 ? [1] : [1, -1]) {
520
- const rect = { x: base.x + away[0] * d + slideAxis[0] * s * sign, y: base.y + away[1] * d + slideAxis[1] * s * sign, w, h };
521
- if (clear(rect)) return { ...rect, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
753
+ for (const side2 of sides) {
754
+ const base = side2 === preferred ? first : baseOf(side2);
755
+ const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
756
+ const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
757
+ const slideMax = request.slide ?? (side2 === "above" || side2 === "below" ? w : h * 4);
758
+ for (let s = 0; s <= slideMax; s += search) {
759
+ for (const sign of s === 0 ? [1] : [1, -1]) {
760
+ const rect = { x: base.x + away[0] * d + slideAxis[0] * s * sign, y: base.y + away[1] * d + slideAxis[1] * s * sign, w, h };
761
+ if (clear(rect)) return { ...rect, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
762
+ }
522
763
  }
523
764
  }
524
765
  }
525
- return { ...base, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
766
+ return { ...first, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
526
767
  }
527
768
  function fieldWidth(diagram, name) {
528
769
  let value = 0;
@@ -577,6 +818,8 @@ function shiftContent(layout, dx, dy) {
577
818
  move(box);
578
819
  box.cx += dx;
579
820
  box.cy += dy;
821
+ if (box.slot) move(box.slot);
822
+ if (box.iconX !== void 0) box.iconX += dx;
580
823
  }
581
824
  for (const region of layout.regions) {
582
825
  region.y += dy;
@@ -590,6 +833,7 @@ function shiftContent(layout, dx, dy) {
590
833
  for (const edge2 of layout.edges) {
591
834
  edge2.points = edge2.points.map(([px, py]) => [px + dx, py + dy]);
592
835
  if (edge2.settle) edge2.settle = [edge2.settle[0] + dx, edge2.settle[1] + dy];
836
+ if (edge2.wait) edge2.wait = [edge2.wait[0] + dx, edge2.wait[1] + dy];
593
837
  }
594
838
  for (const label2 of layout.labels) move(label2);
595
839
  for (const path2 of layout.paths) {
@@ -623,11 +867,11 @@ function cornerBadge(events, step, layout) {
623
867
  for (const event of events) {
624
868
  const id = event.type === "swap" || event.type === "action" ? event.box : void 0;
625
869
  const box2 = layout.boxes.find((b) => b.id === id);
626
- if (box2) return { step, x: box2.x + inset, y: box2.y + inset, color: box2.color };
870
+ if (box2) return { step, x: box2.x, y: box2.y, color: box2.color };
627
871
  }
628
872
  if (layout.strip && events.some((event) => event.type === "strip")) return { step, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" };
629
873
  const box = layout.boxes[0];
630
- return { step, x: box.x + inset, y: box.y + inset, color: box.color };
874
+ return { step, x: box.x, y: box.y, color: box.color };
631
875
  }
632
876
 
633
877
  // src/layout/architecture.ts
@@ -726,7 +970,8 @@ function arrange(diagram, groups, slots, rooms) {
726
970
  const regionColor = regionColors(diagram);
727
971
  const edges = edgesOf(diagram);
728
972
  const columnCount = Math.max(1, ...[...slots.values()].map((s) => s.col + 1));
729
- const widths = new Map(diagram.boxes.map((b) => [b.id, boxWidth(diagram, b.id, true)]));
973
+ const carriedIn = slotRooms(diagram);
974
+ const widths = new Map(diagram.boxes.map((b) => [b.id, Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== void 0, B.padX))]));
730
975
  const colW = Array.from({ length: columnCount }, (_, c) => Math.max(B.minW, ...[...slots].filter(([, s]) => s.col === c).map(([id]) => widths.get(id) ?? B.minW)));
731
976
  const between = Array.from({ length: Math.max(0, columnCount - 1) }, () => A.columnGap);
732
977
  for (const { edge: edge2 } of edges) {
@@ -741,7 +986,13 @@ function arrange(diagram, groups, slots, rooms) {
741
986
  const headerW = Math.max(0, ...headers.map((h) => h ? h.w + R.inset * 2 : 0));
742
987
  const colLeft = [];
743
988
  for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin + (headerW > 0 ? headerW : R.pad) : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
744
- const center = (c) => colLeft[c] + colW[c] / 2;
989
+ const center2 = (c) => colLeft[c] + colW[c] / 2;
990
+ const looped = new Set(edges.filter(({ edge: edge2 }) => edge2.from === edge2.to).map(({ edge: edge2 }) => edge2.from));
991
+ const loopRows = new Set([...looped].flatMap((id) => {
992
+ const slot = slots.get(id);
993
+ return slot ? [`${slot.group}:${slot.row}`] : [];
994
+ }));
995
+ const loopRoom = (g, row) => loopRows.has(`${g}:${row}`) ? LOOP_ROOM : 0;
745
996
  const boxes = [];
746
997
  const bands = [];
747
998
  let cursor = margin;
@@ -749,12 +1000,14 @@ function arrange(diagram, groups, slots, rooms) {
749
1000
  const rows = Math.max(1, ...group.members.map((id) => (slots.get(id)?.row ?? 0) + 1));
750
1001
  const room = rooms[g];
751
1002
  const top = cursor + R.pad + room.top;
1003
+ const rowTop = [0];
1004
+ for (let r = 1; r < rows; r++) rowTop.push(rowTop[r - 1] + B.h + A.rowGap + loopRoom(g, r - 1));
752
1005
  for (const id of group.members) {
753
1006
  const slot = slots.get(id);
754
1007
  const source = diagram.boxes.find((b) => b.id === id);
755
1008
  const w = widths.get(id) ?? B.minW;
756
- const cx = center(slot.col);
757
- const y = top + slot.row * (B.h + A.rowGap);
1009
+ const cx = center2(slot.col);
1010
+ const y = top + rowTop[slot.row];
758
1011
  boxes.push({
759
1012
  id,
760
1013
  name: source?.name ?? id,
@@ -769,29 +1022,36 @@ function arrange(diagram, groups, slots, rooms) {
769
1022
  cy: y + B.h / 2
770
1023
  });
771
1024
  }
772
- const contentBottom = top + rows * B.h + (rows - 1) * A.rowGap;
1025
+ const contentBottom2 = top + rowTop[rows - 1] + B.h + loopRoom(g, rows - 1);
773
1026
  const header = headers[g];
774
- const h = Math.max(contentBottom + R.pad + room.bottom - cursor, header ? header.h + R.inset * 2 : 0, group.region ? R.minH : 0);
1027
+ const h = Math.max(contentBottom2 + R.pad + room.bottom - cursor, header ? header.h + R.inset * 2 : 0, group.region ? R.minH : 0);
775
1028
  bands.push({ group: g, y: cursor, h, rows });
776
1029
  cursor += h + R.gap;
777
1030
  });
778
1031
  const bandsBottom = cursor - R.gap;
1032
+ for (const box of boxes) placeSlot(box, carriedIn.get(box.id));
779
1033
  const byId = new Map(boxes.map((b) => [b.id, b]));
780
1034
  const bandOf = (id) => bands[slots.get(id)?.group ?? 0];
781
- const blocked = (points, a, b) => boxes.some((box) => {
782
- if (box.id === a || box.id === b) return false;
783
- const pad2 = LOOK.label.search;
1035
+ const crosses = (points, rect, pad2) => {
784
1036
  for (let i = 1; i < points.length; i++) {
785
1037
  const [x1, y1] = points[i - 1];
786
1038
  const [x2, y2] = points[i];
787
- if (Math.min(x1, x2) <= box.x + box.w + pad2 && Math.max(x1, x2) >= box.x - pad2 && Math.min(y1, y2) <= box.y + box.h + pad2 && Math.max(y1, y2) >= box.y - pad2) return true;
1039
+ if (Math.min(x1, x2) <= rect.x + rect.w + pad2 && Math.max(x1, x2) >= rect.x - pad2 && Math.min(y1, y2) <= rect.y + rect.h + pad2 && Math.max(y1, y2) >= rect.y - pad2) return true;
788
1040
  }
789
1041
  return false;
1042
+ };
1043
+ const loopZones = [...looped].flatMap((id) => {
1044
+ const box = byId.get(id);
1045
+ return box ? [{ x: box.x, y: box.y + box.h, w: box.w, h: LOOP_ROOM }] : [];
790
1046
  });
1047
+ const onLoop = (points) => loopZones.some((zone) => crosses(points, zone, 0));
1048
+ const blocked = (points, a, b) => boxes.some((box) => box.id !== a && box.id !== b && crosses(points, box, LOOK.label.search)) || onLoop(points);
791
1049
  const laneBelow = (id) => {
792
1050
  const box = byId.get(id);
793
1051
  const band2 = bandOf(id);
794
- return (slots.get(id)?.row ?? 0) < band2.rows - 1 ? box.y + box.h + A.rowGap / 2 : Math.min(box.y + box.h + R.pad / 2, band2.y + band2.h - LOOK.edge.inset);
1052
+ const slot = slots.get(id);
1053
+ const under = box.y + box.h + (slot ? loopRoom(slot.group, slot.row) : 0);
1054
+ return (slot?.row ?? 0) < band2.rows - 1 ? under + A.rowGap / 2 : Math.min(under + R.pad / 2, band2.y + band2.h - LOOK.edge.inset);
795
1055
  };
796
1056
  const laneAbove = (id) => {
797
1057
  const box = byId.get(id);
@@ -799,9 +1059,11 @@ function arrange(diagram, groups, slots, rooms) {
799
1059
  return (slots.get(id)?.row ?? 0) > 0 ? box.y - A.rowGap / 2 : Math.max(box.y - R.pad / 2, band2.y + LOOK.edge.inset);
800
1060
  };
801
1061
  const inset = LOOK.edge.inset;
1062
+ const gapX = (col, toRight) => toRight ? colLeft[col] + colW[col] + (between[col] ?? A.columnGap) / 2 : colLeft[col] - (between[col - 1] ?? A.columnGap) / 2;
802
1063
  const route = (from, to) => {
803
1064
  const a = byId.get(from);
804
1065
  const b = byId.get(to);
1066
+ if (from === to) return loopUnder(a);
805
1067
  const sa = slots.get(from);
806
1068
  const sb = slots.get(to);
807
1069
  if (sa.group === sb.group && sa.row === sb.row) {
@@ -811,13 +1073,22 @@ function arrange(diagram, groups, slots, rooms) {
811
1073
  [right2 ? b.x - inset : b.x + b.w + inset, b.cy]
812
1074
  ];
813
1075
  if (!blocked(straight, from, to)) return straight;
814
- const lane2 = laneBelow(from);
815
- return [
1076
+ const below = laneBelow(from);
1077
+ const under = [
816
1078
  [a.cx, a.y + a.h],
817
- [a.cx, lane2],
818
- [b.cx, lane2],
1079
+ [a.cx, below],
1080
+ [b.cx, below],
819
1081
  [b.cx, b.y + b.h + inset]
820
1082
  ];
1083
+ if (!onLoop(under)) return under;
1084
+ const above = laneAbove(from);
1085
+ const over = [
1086
+ [a.cx, a.y],
1087
+ [a.cx, above],
1088
+ [b.cx, above],
1089
+ [b.cx, b.y - inset]
1090
+ ];
1091
+ return onLoop(over) ? under : over;
821
1092
  }
822
1093
  const down = b.cy > a.cy;
823
1094
  const leave = [a.cx, down ? a.y + a.h : a.y];
@@ -825,7 +1096,7 @@ function arrange(diagram, groups, slots, rooms) {
825
1096
  if (sa.col === sb.col) {
826
1097
  const straight = [leave, enter];
827
1098
  if (!blocked(straight, from, to)) return straight;
828
- const x = a.x + a.w + (between[sa.col] ?? A.columnGap) / 2;
1099
+ const x = gapX(sa.col, true);
829
1100
  return [
830
1101
  [a.x + a.w, a.cy],
831
1102
  [x, a.cy],
@@ -840,21 +1111,34 @@ function arrange(diagram, groups, slots, rooms) {
840
1111
  [[right ? a.x + a.w : a.x, a.cy], [b.cx, a.cy], enter],
841
1112
  [leave, [a.cx, lane], [b.cx, lane], enter]
842
1113
  ];
1114
+ if (looped.has(from) || looped.has(to)) {
1115
+ const ax = gapX(sa.col, right);
1116
+ const bx = gapX(sb.col, !right);
1117
+ const out = [
1118
+ [right ? a.x + a.w : a.x, a.cy],
1119
+ [ax, a.cy]
1120
+ ];
1121
+ const side2 = [right ? b.x - inset : b.x + b.w + inset, b.cy];
1122
+ candidates.push(
1123
+ [...out, [ax, b.cy], side2],
1124
+ [...out, [ax, lane], [b.cx, lane], enter],
1125
+ [leave, [a.cx, lane], [bx, lane], [bx, b.cy], side2],
1126
+ [...out, [ax, lane], [bx, lane], [bx, b.cy], side2]
1127
+ );
1128
+ }
843
1129
  return candidates.find((points) => !blocked(points, from, to)) ?? candidates[2];
844
1130
  };
845
- const sceneEdges = edges.map(({ step, event, edge: edge2 }) => {
846
- const target = byId.get(edge2.to);
847
- return {
848
- step,
849
- event,
850
- from: edge2.from,
851
- to: edge2.to,
852
- points: route(edge2.from, edge2.to),
853
- color: edgeColor(edge2, colors),
854
- carry: edge2.carry,
855
- settle: [target.cx, target.cy + B.iconY]
856
- };
857
- });
1131
+ const sceneEdges = edges.map(({ step, event, edge: edge2 }) => ({
1132
+ step,
1133
+ event,
1134
+ from: edge2.from,
1135
+ to: edge2.to,
1136
+ points: route(edge2.from, edge2.to),
1137
+ color: edgeColor(edge2, colors),
1138
+ carry: edge2.carry
1139
+ }));
1140
+ seatCarriers(sceneEdges, byId, carriedIn);
1141
+ const outward = /* @__PURE__ */ new Map();
858
1142
  for (const edge2 of sceneEdges) {
859
1143
  if (edge2.points.length !== 2) continue;
860
1144
  const back = sceneEdges.some((other) => other.from === edge2.to && other.to === edge2.from && other.points.length === 2);
@@ -863,6 +1147,7 @@ function arrange(diagram, groups, slots, rooms) {
863
1147
  const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
864
1148
  const d = (edge2.from < edge2.to ? 1 : -1) * LOOK.edge.parallel;
865
1149
  edge2.points = edge2.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
1150
+ outward.set(edge2, flat ? d > 0 ? "below" : "above" : d > 0 ? "right" : "left");
866
1151
  }
867
1152
  const regions = [];
868
1153
  groups.forEach((group, g) => {
@@ -882,15 +1167,20 @@ function arrange(diagram, groups, slots, rooms) {
882
1167
  header: { x: margin + R.inset, y: band2.y + R.inset, w: header.w, h: header.h }
883
1168
  });
884
1169
  });
1170
+ const badgeAt = (edge2, taken, lines2) => edge2.from === edge2.to ? loopBadge(edge2.points) : badgeOnPath(edge2.points, taken, lines2);
1171
+ const early = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
885
1172
  const labels = [];
886
1173
  for (const edge2 of sceneEdges) {
887
1174
  const source = diagram.steps[edge2.step]?.events[edge2.event];
888
1175
  if (source?.type !== "edge" || source.label === void 0) continue;
1176
+ const seen = [...early].filter(([s]) => s <= edge2.step).map(([, b]) => badgeRect(b.point));
889
1177
  const soft = [...regions.map((r) => r.header), ...labels.filter((l) => l.step === edge2.step)];
1178
+ const side2 = source.labelSide ?? outward.get(edge2);
1179
+ const below = edge2.from === edge2.to ? { side: "below", base: loopLabelBase(edge2.points, textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2) } : void 0;
890
1180
  labels.push(
891
1181
  placeLabel(
892
- { step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...source.labelSide ? { side: source.labelSide } : {} },
893
- { hard: boxes, soft }
1182
+ { step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...below ?? (side2 ? { side: side2 } : { flip: true }) },
1183
+ { hard: boxes, soft, touch: seen }
894
1184
  )
895
1185
  );
896
1186
  }
@@ -900,16 +1190,19 @@ function arrange(diagram, groups, slots, rooms) {
900
1190
  const contentRight = Math.max(...boxes.map((b) => b.x + b.w + R.pad), ...labels.map((l) => l.x + l.w + LOOK.label.soft), ...sceneEdges.flatMap((e) => e.points.map((p) => p[0] + R.pad)));
901
1191
  const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
902
1192
  for (const region of regions) region.w = width - margin * 2;
903
- const strip2 = layoutStrip(diagram, margin, bandsBottom + gap, width - margin * 2);
1193
+ const contentBottom = Math.max(bandsBottom, ...labels.map((l) => l.y + l.h));
1194
+ const strip2 = layoutStrip(diagram, margin, contentBottom + gap, width - margin * 2);
904
1195
  layout.width = width;
905
- layout.height = (strip2 ? strip2.y + strip2.h : bandsBottom) + margin;
1196
+ layout.height = (strip2 ? strip2.y + strip2.h : contentBottom) + margin;
906
1197
  if (strip2) layout.strip = strip2;
907
- layout.badges = diagram.steps.map((step, s) => {
908
- const edge2 = sceneEdges.find((e) => e.step === s);
909
- if (!edge2) return cornerBadge(step.events, s, layout);
910
- const [x, y] = badgeOnPath(edge2.points);
911
- return { step: s, x, y, color: edge2.color };
912
- });
1198
+ const lines = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
1199
+ layout.badges = replaceSameSpot(
1200
+ diagram.steps.map((step, s) => {
1201
+ const line = lines.get(s);
1202
+ if (!line) return cornerBadge(step.events, s, layout);
1203
+ return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
1204
+ })
1205
+ );
913
1206
  return layout;
914
1207
  }
915
1208
  function grow(layout, groups, slots, rooms) {
@@ -937,6 +1230,524 @@ function grow(layout, groups, slots, rooms) {
937
1230
  return grown;
938
1231
  }
939
1232
 
1233
+ // src/words.ts
1234
+ var keys = (table) => Object.keys(table);
1235
+ var KINDS = keys({ sequence: true, architecture: true, state: true, git: true });
1236
+ var STATE_ENDS = ["start", "finish"];
1237
+ var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set", "branch", "commit"];
1238
+ var AS = "as";
1239
+ var ON = "on";
1240
+ var COPY = "copy";
1241
+ var MERGE = "merge";
1242
+ var FROM = "from";
1243
+ var HEAD = "HEAD";
1244
+ var ATTRS = {
1245
+ diagram: ["view"],
1246
+ group: ["note", "color", "icon"],
1247
+ box: ["note", "color", "icon"],
1248
+ edge: ["carry", "tag", "side"],
1249
+ set: ["tag"],
1250
+ branch: ["note"],
1251
+ commit: ["hash", "note"]
1252
+ };
1253
+ var CARRIES = keys({ coin: true, none: true });
1254
+ var VIEWS = keys({ fixed: true, follow: true });
1255
+ var SIDES = keys({ above: true, below: true, left: true, right: true });
1256
+ var OLD_HEADS = {
1257
+ \u6642\u7CFB\u5217\u56F3: "sequence",
1258
+ \u69CB\u6210\u56F3: "architecture",
1259
+ \u533A\u753B: "group",
1260
+ \u898B\u305B\u65B9: "view",
1261
+ region: "group",
1262
+ view: "view"
1263
+ };
1264
+
1265
+ // src/layout/git.ts
1266
+ var isGitLayout = (layout) => layout.kind === "git";
1267
+ function walk(diagram) {
1268
+ const branches = (diagram.git?.branches ?? []).map((b) => b.id);
1269
+ const lane = (id) => {
1270
+ if (!branches.includes(id)) branches.push(id);
1271
+ };
1272
+ for (const step of diagram.steps) for (const e of step.events) if (e.type === "commit" || e.type === "branch") lane(e.branch);
1273
+ const tips = new Map(branches.map((b) => [b, null]));
1274
+ let headAt = null;
1275
+ let attached = null;
1276
+ const made = [];
1277
+ const byId = /* @__PURE__ */ new Map();
1278
+ const links = [];
1279
+ const moves = [];
1280
+ const tags = [];
1281
+ const rows = /* @__PURE__ */ new Map();
1282
+ const most = /* @__PURE__ */ new Map();
1283
+ const shown = /* @__PURE__ */ new Map();
1284
+ const names = [...branches, HEAD];
1285
+ const at2 = new Map(names.map((n) => [n, []]));
1286
+ const heads = [];
1287
+ const visible2 = (ref) => ref === HEAD ? attached === null ? headAt : null : tips.get(ref) ?? null;
1288
+ const freeRow = (commit2) => {
1289
+ const list2 = rows.get(commit2) ?? [];
1290
+ const free = list2.indexOf(null);
1291
+ return free < 0 ? list2.length : free;
1292
+ };
1293
+ const settle = (step, event, change, lineFor) => {
1294
+ const before = new Map(names.map((n) => [n, visible2(n)]));
1295
+ const headBefore = headAt;
1296
+ change();
1297
+ const changed = names.filter((n) => before.get(n) !== visible2(n));
1298
+ const leaving = changed.map((ref) => {
1299
+ const slot = shown.get(ref);
1300
+ if (slot) {
1301
+ rows.get(slot.commit)[slot.row] = null;
1302
+ shown.delete(ref);
1303
+ }
1304
+ return { ref, slot };
1305
+ });
1306
+ for (const { ref, slot } of leaving) {
1307
+ const from = slot ?? (ref === HEAD && headBefore !== null ? { commit: headBefore, row: freeRow(headBefore) } : void 0);
1308
+ const target = visible2(ref);
1309
+ let to;
1310
+ if (target !== null) {
1311
+ to = { commit: target, row: freeRow(target) };
1312
+ const list2 = rows.get(target) ?? [];
1313
+ list2[to.row] = ref;
1314
+ rows.set(target, list2);
1315
+ most.set(target, Math.max(most.get(target) ?? 0, list2.filter((r) => r !== null).length));
1316
+ shown.set(ref, to);
1317
+ }
1318
+ moves.push({ ref, step, event, ...from ? { from } : {}, ...to ? { to } : {}, line: ref === lineFor });
1319
+ }
1320
+ };
1321
+ const prune = (step, event) => {
1322
+ const reach = /* @__PURE__ */ new Set();
1323
+ const stack = [...tips.values(), headAt].filter((c) => c !== null);
1324
+ while (stack.length > 0) {
1325
+ const id = stack.pop();
1326
+ if (reach.has(id)) continue;
1327
+ reach.add(id);
1328
+ stack.push(...byId.get(id)?.parents ?? []);
1329
+ }
1330
+ for (const c of made) if (!reach.has(c.id) && c.orphan === void 0) c.orphan = { step, event };
1331
+ };
1332
+ diagram.steps.forEach((step, s) => {
1333
+ step.events.forEach((e, k) => {
1334
+ if (e.type === "commit") commit(e, s, k);
1335
+ else if (e.type === "branch") {
1336
+ if (!byId.has(e.from)) return;
1337
+ if (laneOf(e.from) !== e.branch) links.push({ kind: "branch", from: e.from, to: e.branch, step: s, event: k });
1338
+ settle(s, k, () => {
1339
+ tips.set(e.branch, e.from);
1340
+ attached = e.branch;
1341
+ headAt = e.from;
1342
+ });
1343
+ } else if (e.type === "edge") {
1344
+ const ref = e.from;
1345
+ if (ref !== HEAD && !tips.has(ref) || !byId.has(e.to)) return;
1346
+ settle(
1347
+ s,
1348
+ k,
1349
+ () => {
1350
+ if (ref === HEAD) {
1351
+ attached = null;
1352
+ headAt = e.to;
1353
+ return;
1354
+ }
1355
+ tips.set(ref, e.to);
1356
+ if (attached === ref) headAt = e.to;
1357
+ else if (attached === null && headAt === e.to) attached = ref;
1358
+ },
1359
+ ref
1360
+ );
1361
+ } else return;
1362
+ prune(s, k);
1363
+ });
1364
+ for (const n of names) at2.get(n)?.push(n === HEAD ? headAt : tips.get(n) ?? null);
1365
+ heads.push(attached);
1366
+ for (const n of names) {
1367
+ const slot = shown.get(n);
1368
+ if (slot) tags.push({ ref: n, step: s, slot });
1369
+ }
1370
+ });
1371
+ function laneOf(id) {
1372
+ return byId.get(id)?.branch;
1373
+ }
1374
+ function commit(e, s, k) {
1375
+ if (byId.has(e.id)) return;
1376
+ const copy = e.copy !== void 0 && byId.has(e.copy) ? e.copy : void 0;
1377
+ const base = copy !== void 0 && attached === null && headAt !== null ? headAt : tips.get(e.branch) ?? null;
1378
+ const joined = e.merge !== void 0 && e.merge !== e.branch ? tips.get(e.merge) ?? void 0 : void 0;
1379
+ const parents = [...new Set([base, joined].filter((c2) => c2 !== null && c2 !== void 0))];
1380
+ const c = {
1381
+ id: e.id,
1382
+ branch: e.branch,
1383
+ parents,
1384
+ ...joined !== void 0 && joined !== base ? { joined } : {},
1385
+ ...copy !== void 0 ? { copy } : {},
1386
+ ...e.hash !== void 0 ? { hash: e.hash } : {},
1387
+ ...e.note !== void 0 ? { note: e.note } : {},
1388
+ step: s,
1389
+ event: k
1390
+ };
1391
+ made.push(c);
1392
+ byId.set(c.id, c);
1393
+ for (const p of parents) links.push({ kind: "parent", from: p, to: c.id, step: s, event: k });
1394
+ if (copy !== void 0) links.push({ kind: "copy", from: copy, to: c.id, step: s, event: k });
1395
+ const first = attached === null && headAt === null;
1396
+ settle(s, k, () => {
1397
+ if (copy === void 0) {
1398
+ tips.set(e.branch, c.id);
1399
+ if (attached === e.branch) headAt = c.id;
1400
+ } else if (attached === null) headAt = c.id;
1401
+ if (first) {
1402
+ attached = e.branch;
1403
+ headAt = c.id;
1404
+ }
1405
+ });
1406
+ }
1407
+ const refs = names.map((name) => ({ name, at: at2.get(name) ?? [], ...name === HEAD ? { attached: heads } : {} }));
1408
+ return { branches, made, links, moves, refs, tags, rows: most };
1409
+ }
1410
+ function cubic(p0, c1, c2, p3) {
1411
+ const n = LOOK.git.samples;
1412
+ return Array.from({ length: n }, (_, k) => {
1413
+ const t = (k + 1) / n;
1414
+ const u = 1 - t;
1415
+ const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
1416
+ return [at2(0), at2(1)];
1417
+ });
1418
+ }
1419
+ function elbow(from, to) {
1420
+ if (Math.abs(from[1] - to[1]) < 0.5) return [from, to];
1421
+ return from[1] > to[1] ? [from, [from[0], to[1]], to] : [from, [to[0], from[1]], to];
1422
+ }
1423
+ function fork(p, tx, ty) {
1424
+ const sign = ty > p.cy ? 1 : -1;
1425
+ const p0 = [p.cx, p.cy + sign * p.r];
1426
+ const turn = Math.max(0, Math.min(LOOK.git.turn, tx - p.cx));
1427
+ const p3 = [p.cx + turn, ty];
1428
+ const curve = cubic(p0, [p0[0], p0[1] + (ty - p0[1]) * 0.7], [p.cx + turn * 0.2, ty], p3);
1429
+ return [p0, ...curve, ...tx > p3[0] ? [[tx, ty]] : []];
1430
+ }
1431
+ function join(p, c) {
1432
+ const sign = c.cy < p.cy ? 1 : -1;
1433
+ const p0 = [p.cx + p.r, p.cy];
1434
+ const p3 = [c.cx, c.cy + sign * c.r];
1435
+ const turn = Math.max(0, Math.min(LOOK.git.turn, c.cx - p0[0]));
1436
+ const h = [c.cx - turn, p.cy];
1437
+ const curve = cubic(h, [c.cx - turn * 0.2, p.cy], [c.cx, p3[1] + (p.cy - p3[1]) * 0.7], p3);
1438
+ return [p0, ...h[0] > p0[0] ? [h] : [], ...curve];
1439
+ }
1440
+ function copyLine(p, c) {
1441
+ if (Math.abs(p.cy - c.cy) < 0.5) {
1442
+ const top = p.cy - p.r;
1443
+ const lift = LOOK.git.turn * 0.7;
1444
+ return [[p.cx, top], ...cubic([p.cx, top], [p.cx, top - lift], [c.cx, top - lift], [c.cx, top])];
1445
+ }
1446
+ const sign = c.cy < p.cy ? -1 : 1;
1447
+ const p0 = [p.cx, p.cy + sign * p.r];
1448
+ const p3 = [c.cx, c.cy - sign * c.r];
1449
+ const mid = (p3[1] - p0[1]) * 0.5;
1450
+ return [p0, ...cubic(p0, [p0[0], p0[1] + mid], [p3[0], p3[1] - mid], p3)];
1451
+ }
1452
+ function layoutGit(diagram) {
1453
+ const { margin, gap, box: B, region: R, git: G, carrier: C } = LOOK;
1454
+ const walked = walk(diagram);
1455
+ const notes = new Map((diagram.git?.branches ?? []).map((b) => [b.id, b.note]));
1456
+ const laneIndex = new Map(walked.branches.map((id, i) => [id, i]));
1457
+ const colorOf2 = (branch) => G.colors[(laneIndex.get(branch) ?? 0) % G.colors.length];
1458
+ const col = /* @__PURE__ */ new Map();
1459
+ const laneLast = /* @__PURE__ */ new Map();
1460
+ for (const c of walked.made) {
1461
+ const k = Math.max(0, ...c.parents.map((p) => (col.get(p) ?? -1) + 1), (laneLast.get(c.branch) ?? -1) + 1);
1462
+ col.set(c.id, k);
1463
+ laneLast.set(c.branch, k);
1464
+ }
1465
+ const linesOf = (c) => [
1466
+ ...c.hash !== void 0 ? [{ text: c.hash, style: TYPE.gitHash }] : [],
1467
+ ...c.note !== void 0 ? [{ text: c.note, style: TYPE.gitNote }] : []
1468
+ ];
1469
+ const textW = (c) => Math.max(0, ...linesOf(c).map((line) => textWidth(line.text, line.style)));
1470
+ const tagW = (ref) => textWidth(ref, hasWide(ref) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
1471
+ const refWidth = Math.max(0, ...walked.refs.map((r) => tagW(r.name)));
1472
+ const pitch = Math.max(G.pitch, ...walked.made.map((c) => textW(c) + G.textGap), refWidth + G.textGap);
1473
+ const headers = walked.branches.map((id) => ({ w: Math.max(R.icon, textWidth(id, TYPE.regionName), textWidth(notes.get(id) ?? "", TYPE.regionNote)) }));
1474
+ const headerRight = margin + R.inset + Math.max(0, ...headers.map((h) => h.w));
1475
+ const firstHalf = Math.max(G.r, ...walked.made.filter((c) => col.get(c.id) === 0 && laneIndex.get(c.branch) === 0).map((c) => textW(c) / 2), refWidth / 2);
1476
+ const x0 = Math.max(G.x0, headerRight + gap + firstHalf);
1477
+ const named = new Set(
1478
+ walked.moves.flatMap((mv) => {
1479
+ const source = diagram.steps[mv.step]?.events[mv.event];
1480
+ return mv.line && mv.to && source?.type === "edge" && source.label !== void 0 ? [walked.made.find((c) => c.id === mv.to?.commit)?.branch ?? ""] : [];
1481
+ })
1482
+ );
1483
+ const extraRows = (branch) => Math.max(0, ...walked.made.filter((c) => c.branch === branch).map((c) => (walked.rows.get(c.id) ?? 0) - 2)) * G.row;
1484
+ const topText = walked.made.some((c) => laneIndex.get(c.branch) === 0 && linesOf(c).length > 0);
1485
+ const lanes = [];
1486
+ let y = margin;
1487
+ walked.branches.forEach((id, i) => {
1488
+ const top = i === 0;
1489
+ const tagBase = top && topText ? G.tagTop : G.tag;
1490
+ const line = y + (top ? G.topLine - (G.tagTop - tagBase) : G.line) + extraRows(id);
1491
+ const h = line - y + (top ? G.topBelow : named.has(id) ? G.below : G.bare);
1492
+ lanes.push({ id, x: margin, y, w: 0, h, line, color: colorOf2(id), tagBase });
1493
+ y += h + R.gap;
1494
+ });
1495
+ const lanesBottom = y - R.gap;
1496
+ const laneOf = new Map(lanes.map((l) => [l.id, l]));
1497
+ const commits = walked.made.map((c) => {
1498
+ const lane = laneOf.get(c.branch);
1499
+ const isTop = laneIndex.get(c.branch) === 0;
1500
+ const cx = x0 + pitch * (col.get(c.id) ?? 0) + (isTop ? 0 : pitch / 2);
1501
+ const cy = lane.line;
1502
+ const lines = linesOf(c);
1503
+ const baselines = lines.map((_, k) => isTop ? cy - G.above - (lines.length - 1 - k) * G.lineStep : cy + G.under + k * G.lineStep);
1504
+ const boxes2 = lines.map((line, k) => textBox(line.text, cx, baselines[k], line.style, "middle"));
1505
+ const text2 = boxes2.length === 0 ? void 0 : { ...union(boxes2), lines: lines.map((line) => line.text), baselines };
1506
+ const color = c.copy !== void 0 ? colorOf2(walked.made.find((m) => m.id === c.copy)?.branch ?? c.branch) : colorOf2(c.branch);
1507
+ return {
1508
+ id: c.id,
1509
+ branch: c.branch,
1510
+ color,
1511
+ cx,
1512
+ cy,
1513
+ r: G.r,
1514
+ step: c.step,
1515
+ event: c.event,
1516
+ parents: c.parents,
1517
+ ...c.copy !== void 0 ? { copy: c.copy } : {},
1518
+ ...c.hash !== void 0 ? { hash: c.hash } : {},
1519
+ ...c.note !== void 0 ? { note: c.note } : {},
1520
+ ...text2 ? { text: text2 } : {},
1521
+ ...c.orphan ? { orphan: c.orphan.step, orphanEvent: c.orphan.event } : {}
1522
+ };
1523
+ });
1524
+ const placed = new Map(commits.map((c) => [c.id, c]));
1525
+ const links = walked.links.flatMap((l) => {
1526
+ const from = placed.get(l.from);
1527
+ if (!from) return [];
1528
+ if (l.kind === "branch") {
1529
+ if (!walked.made.some((c) => c.branch === l.to)) return [];
1530
+ const lane = laneOf.get(l.to);
1531
+ return [{ ...l, points: fork(from, from.cx + G.turn, lane.line), color: colorOf2(l.to) }];
1532
+ }
1533
+ const to = placed.get(l.to);
1534
+ const made = walked.made.find((m) => m.id === l.to);
1535
+ let points;
1536
+ if (l.kind === "copy") points = copyLine(from, to);
1537
+ else if (Math.abs(from.cy - to.cy) < 0.5) points = [[from.cx + from.r, from.cy], [to.cx - to.r, to.cy]];
1538
+ else if (made?.joined === l.from) points = join(from, to);
1539
+ else points = fork(from, to.cx - to.r, to.cy);
1540
+ return [{ ...l, points, color: to.color }];
1541
+ });
1542
+ const tagRect = (ref, slot) => {
1543
+ const c = placed.get(slot.commit);
1544
+ const base = laneOf.get(c.branch)?.tagBase ?? G.tag;
1545
+ const w = tagW(ref);
1546
+ return { x: c.cx - w / 2, y: c.cy - base - slot.row * G.row - C.tagH / 2, w, h: C.tagH };
1547
+ };
1548
+ const center2 = (r) => [r.x + r.w / 2, r.y + r.h / 2];
1549
+ const moves = walked.moves.map((m) => {
1550
+ const from = m.from ? tagRect(m.ref, m.from) : void 0;
1551
+ const to = m.to ? tagRect(m.ref, m.to) : void 0;
1552
+ const source = diagram.steps[m.step]?.events[m.event];
1553
+ const carried = m.line && source?.type === "edge" && source.carry.kind !== "none" && !(source.carry.kind === "tag" && source.carry.text === source.from);
1554
+ return {
1555
+ ref: m.ref,
1556
+ step: m.step,
1557
+ event: m.event,
1558
+ ...from ? { from } : {},
1559
+ ...to ? { to } : {},
1560
+ ...m.to ? { target: m.to.commit } : {},
1561
+ ...carried ? { carried: true } : {},
1562
+ ...m.line && from && to ? { line: elbow(center2(from), center2(to)) } : {},
1563
+ color: "slate"
1564
+ };
1565
+ });
1566
+ const tags = walked.tags.map((t) => ({ ...tagRect(t.ref, t.slot), ref: t.ref, step: t.step }));
1567
+ const colors = boxColors(diagram);
1568
+ const right = Math.max(
1569
+ x0,
1570
+ ...commits.flatMap((c) => [c.cx + c.r, ...c.text ? [c.text.x + c.text.w] : []]),
1571
+ ...tags.map((t) => t.x + t.w),
1572
+ ...moves.flatMap((m) => [m.from, m.to].flatMap((r) => r ? [r.x + r.w] : []))
1573
+ );
1574
+ const boxX = right + G.boxGap;
1575
+ const firstCy = (lanes[1] ?? lanes[0])?.line ?? margin + B.h / 2;
1576
+ const boxes = diagram.boxes.map((b, i) => {
1577
+ const w = boxWidth(diagram, b.id, true);
1578
+ const cy = firstCy + i * (B.h + gap);
1579
+ return {
1580
+ id: b.id,
1581
+ name: b.name,
1582
+ ...b.sub !== void 0 ? { sub: b.sub } : {},
1583
+ ...b.icon !== void 0 ? { icon: b.icon } : {},
1584
+ color: colors.get(b.id) ?? "slate",
1585
+ x: boxX,
1586
+ y: cy - B.h / 2,
1587
+ w,
1588
+ h: B.h,
1589
+ cx: boxX + w / 2,
1590
+ cy
1591
+ };
1592
+ });
1593
+ const regions = lanes.map((lane, i) => {
1594
+ const note = notes.get(lane.id);
1595
+ return {
1596
+ id: lane.id,
1597
+ lines: [lane.id],
1598
+ ...note !== void 0 ? { note } : {},
1599
+ icon: "branch",
1600
+ color: lane.color,
1601
+ x: lane.x,
1602
+ y: lane.y,
1603
+ w: 0,
1604
+ h: lane.h,
1605
+ header: { x: lane.x + R.inset, y: lane.y + R.inset, w: headers[i]?.w ?? 0, h: R.nameY - R.inset + (note !== void 0 ? R.line : 0) + gap / 2 }
1606
+ };
1607
+ });
1608
+ const layout = {
1609
+ kind: "git",
1610
+ width: 0,
1611
+ height: 0,
1612
+ regions,
1613
+ boxes,
1614
+ lifelines: [],
1615
+ edges: [],
1616
+ labels: [],
1617
+ actions: [],
1618
+ badges: [],
1619
+ paths: [],
1620
+ ends: [],
1621
+ lanes,
1622
+ commits,
1623
+ links,
1624
+ tags,
1625
+ refs: walked.refs,
1626
+ moves
1627
+ };
1628
+ layout.badges = badgesOf(diagram, layout);
1629
+ layout.labels = labelsOf(diagram, layout);
1630
+ const contentRight = Math.max(right, ...boxes.map((b) => b.x + b.w), ...layout.labels.map((l) => l.x + l.w)) + R.pad;
1631
+ const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
1632
+ for (const region of regions) region.w = width - margin * 2;
1633
+ for (const lane of lanes) lane.w = width - margin * 2;
1634
+ const bottom = Math.max(lanesBottom, ...boxes.map((b) => b.y + b.h), ...layout.labels.map((l) => l.y + l.h));
1635
+ const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2);
1636
+ layout.width = width;
1637
+ layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
1638
+ if (strip2) layout.strip = strip2;
1639
+ layout.badges = badgesOf(diagram, layout);
1640
+ return layout;
1641
+ }
1642
+ function union(rects) {
1643
+ const x = Math.min(...rects.map((r) => r.x));
1644
+ const y = Math.min(...rects.map((r) => r.y));
1645
+ return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
1646
+ }
1647
+ function firstMark(layout, step) {
1648
+ const marks = [
1649
+ ...layout.links.filter((l) => l.step === step && l.kind !== "copy").map((l) => ({ event: l.event, points: l.points, color: l.color })),
1650
+ ...layout.moves.flatMap((m) => {
1651
+ const target = layout.commits.find((c) => c.id === m.target);
1652
+ return m.step === step && m.line && target ? [{ event: m.event, target, color: target.color }] : [];
1653
+ })
1654
+ ].sort((a, b) => a.event - b.event);
1655
+ return marks[0];
1656
+ }
1657
+ function besideCommit(c, taken, avoid) {
1658
+ const { r, inset } = LOOK.badge;
1659
+ const d = c.r + inset + r;
1660
+ const apart = r * 2 + inset;
1661
+ const spots = [
1662
+ [c.cx + d, c.cy],
1663
+ [c.cx, c.cy + d],
1664
+ [c.cx - d, c.cy],
1665
+ [c.cx, c.cy - d]
1666
+ ];
1667
+ return spots.find((p) => taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(badgeRect(p), a) >= LOOK.label.touch));
1668
+ }
1669
+ function clearOnPath(points, taken, avoid) {
1670
+ const { r, inset, along: start, short } = LOOK.badge;
1671
+ const length = pathLength(points);
1672
+ const first = length < short ? Math.min(r + 1, length / 2) : start;
1673
+ const apart = r * 2 + inset;
1674
+ for (let d = first; d <= length; d += 1) {
1675
+ const p = along(points, d);
1676
+ const rect = badgeRect(p);
1677
+ if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(rect, a) >= LOOK.label.touch)) return p;
1678
+ }
1679
+ return void 0;
1680
+ }
1681
+ function badgesOf(diagram, layout) {
1682
+ const { inset } = LOOK.badge;
1683
+ const taken = [];
1684
+ const all = [...layout.links.map((l) => l.points), ...layout.moves.flatMap((m) => m.line ? [m.line] : [])];
1685
+ const out = [];
1686
+ const avoid = [
1687
+ ...layout.tags,
1688
+ ...layout.commits.flatMap((c) => [{ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }, ...c.text ? [c.text] : []])
1689
+ ];
1690
+ diagram.steps.forEach((step, s) => {
1691
+ const mark = firstMark(layout, s);
1692
+ const near = mark?.target ? besideCommit(mark.target, taken, avoid) : void 0;
1693
+ if (mark && (mark.points || near)) {
1694
+ const points = mark.points;
1695
+ const point = near ?? (points ? clearOnPath(points, taken, avoid) ?? badgeOnPath(points, taken, all.filter((p) => p !== points)) : [0, 0]);
1696
+ taken.push(point);
1697
+ out.push({ step: s, x: point[0], y: point[1], color: mark.color });
1698
+ return;
1699
+ }
1700
+ const box = step.events.flatMap((e) => e.type === "swap" || e.type === "action" ? [e.box] : []).map((id) => layout.boxes.find((b) => b.id === id))[0];
1701
+ if (box) {
1702
+ out.push({ step: s, x: box.x, y: box.y, color: box.color });
1703
+ return;
1704
+ }
1705
+ if (layout.strip && step.events.some((e) => e.type === "strip")) {
1706
+ out.push({ step: s, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" });
1707
+ return;
1708
+ }
1709
+ const tip = layout.commits.find((c) => c.id === layout.refs[0]?.at[s]);
1710
+ const spot = tip ? besideCommit(tip, taken, avoid) : void 0;
1711
+ if (tip && spot) {
1712
+ taken.push(spot);
1713
+ out.push({ step: s, x: spot[0], y: spot[1], color: tip.color });
1714
+ return;
1715
+ }
1716
+ const before = out[out.length - 1];
1717
+ const lane = layout.lanes[0];
1718
+ out.push(before ? { ...before, step: s } : { step: s, x: (lane?.x ?? 0) + (lane?.w ?? 0) - inset - LOOK.badge.r, y: (lane?.y ?? 0) + inset + LOOK.badge.r, color: lane?.color ?? "slate" });
1719
+ });
1720
+ return replaceSameSpot(out);
1721
+ }
1722
+ function labelsOf(diagram, layout) {
1723
+ const G = LOOK.git;
1724
+ const labels = [];
1725
+ const circles = layout.commits.map((c) => ({ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }));
1726
+ const texts = layout.commits.flatMap((c) => c.text ? [c.text] : []);
1727
+ const headers = layout.regions.map((r) => r.header);
1728
+ for (const move of layout.moves) {
1729
+ const source = diagram.steps[move.step]?.events[move.event];
1730
+ if (source?.type !== "edge" || source.label === void 0 || !move.line) continue;
1731
+ const target = layout.commits.find((c) => c.id === source.to);
1732
+ if (!target) continue;
1733
+ const top = layout.lanes[0]?.id === target.branch;
1734
+ const w = textWidth(source.label, hasWide(source.label) ? TYPE.labelJa : TYPE.label) + LOOK.label.padX * 2;
1735
+ const [mx] = move.line.reduce((sum, p) => [sum[0] + p[0] / move.line.length, 0], [0, 0]);
1736
+ const rows = Math.max(0, ...layout.tags.filter((t) => t.step === move.step && Math.abs(t.x + t.w / 2 - target.cx) < 0.5).map((t) => target.cy - t.y));
1737
+ const side2 = source.labelSide ?? (top ? "above" : "below");
1738
+ const base = source.labelSide !== void 0 ? void 0 : top ? { x: mx - w / 2, y: target.cy - Math.max(rows, (layout.lanes[0]?.tagBase ?? G.tag) + LOOK.carrier.tagH / 2) - LOOK.label.soft - LOOK.label.h } : { x: mx - w / 2, y: target.cy + G.labelUnder };
1739
+ const seen = layout.badges.filter((b) => b.step <= move.step).map((b) => badgeRect([b.x, b.y]));
1740
+ const tags = layout.tags.filter((t) => t.step === move.step);
1741
+ labels.push(
1742
+ placeLabel(
1743
+ { step: move.step, event: move.event, text: source.label, points: move.line, color: move.color, side: side2, ...base ? { base } : {} },
1744
+ { hard: [...circles, ...layout.boxes], soft: [...texts, ...tags, ...headers, ...labels.filter((l) => l.step === move.step)], touch: seen }
1745
+ )
1746
+ );
1747
+ }
1748
+ return labels;
1749
+ }
1750
+
940
1751
  // src/layout/sequence.ts
941
1752
  function layoutSequence(diagram) {
942
1753
  const { box: B, sequence: Q, label: L, margin, gap } = LOOK;
@@ -1004,8 +1815,8 @@ function layoutSequence(diagram) {
1004
1815
  const side2 = event.labelSide ?? "above";
1005
1816
  const self = event.from === event.to;
1006
1817
  const named = event.label !== void 0;
1007
- above = named && side2 === "above" ? L.offset + L.h / 2 : gap;
1008
- under = self ? Q.selfH + gap : named && side2 === "below" ? L.offset + L.h / 2 : gap;
1818
+ above = named && side2 === "above" ? Q.labelOffset + L.h / 2 : gap;
1819
+ under = self ? Q.selfH + gap : named && side2 === "below" ? Q.labelOffset + L.h / 2 : gap;
1009
1820
  } else {
1010
1821
  above = LOOK.action.h / 2;
1011
1822
  under = LOOK.action.h / 2;
@@ -1027,7 +1838,17 @@ function layoutSequence(diagram) {
1027
1838
  [xt - dir * LOOK.edge.inset, y]
1028
1839
  ];
1029
1840
  const color = edgeColor(event, colors);
1030
- edges.push({ step: s, event: e, from: event.from, to: event.to, points, color, carry: event.carry });
1841
+ const seats = {};
1842
+ if (event.carry.kind !== "none") {
1843
+ const reach = LOOK.slot.lifeline + carrierHalf(event.carry)[0];
1844
+ const [p0, p1] = points;
1845
+ const [q0, q1] = points.slice(-2);
1846
+ const out = Math.sign(p1[0] - p0[0]) || 1;
1847
+ const into = Math.sign(q1[0] - q0[0]) || -1;
1848
+ seats.wait = [xf - out * reach, p0[1]];
1849
+ seats.settle = [xt + into * reach, q1[1]];
1850
+ }
1851
+ edges.push({ step: s, event: e, from: event.from, to: event.to, points, color, carry: event.carry, ...seats });
1031
1852
  if (event.label !== void 0) {
1032
1853
  requests.push({
1033
1854
  step: s,
@@ -1035,7 +1856,8 @@ function layoutSequence(diagram) {
1035
1856
  text: event.label,
1036
1857
  points,
1037
1858
  color,
1038
- ...event.labelSide ? { side: event.labelSide } : xf === xt ? { side: "right" } : {}
1859
+ ...event.labelSide ? { side: event.labelSide } : xf === xt ? { side: "right" } : {},
1860
+ offset: Q.labelOffset
1039
1861
  });
1040
1862
  }
1041
1863
  } else {
@@ -1047,10 +1869,12 @@ function layoutSequence(diagram) {
1047
1869
  });
1048
1870
  const bottom = (first ? headBottom : y + below) + Q.tail;
1049
1871
  const lifelines = order.map((id, i) => ({ id, x: xs[i], y1: headBottom, y2: bottom }));
1872
+ const early = lineBadges(edges, diagram.steps.length);
1050
1873
  const labels = [];
1051
1874
  for (const request of requests) {
1875
+ const seen = [...early].filter(([s]) => s <= request.step).map(([, b]) => badgeRect(b.point));
1052
1876
  const soft = [...labels.filter((l) => l.step === request.step), ...actions];
1053
- labels.push(placeLabel(request, { hard: boxes, soft }));
1877
+ labels.push(placeLabel(request, { hard: boxes, soft, touch: seen }));
1054
1878
  }
1055
1879
  const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [], paths: [], ends: [] };
1056
1880
  const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...actions.map((a) => a.x)];
@@ -1066,44 +1890,18 @@ function layoutSequence(diagram) {
1066
1890
  return layout;
1067
1891
  }
1068
1892
  function badges(diagram, layout) {
1069
- return diagram.steps.map((step, s) => {
1070
- const edge2 = layout.edges.find((e) => e.step === s);
1071
- if (edge2) {
1072
- const [x, y] = badgeOnPath(edge2.points);
1073
- return { step: s, x, y, color: edge2.color };
1074
- }
1893
+ const lines = lineBadges(layout.edges, diagram.steps.length);
1894
+ const placed = diagram.steps.map((step, s) => {
1895
+ const line = lines.get(s);
1896
+ if (line) return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
1075
1897
  const action2 = layout.actions.find((a) => a.step === s);
1076
1898
  const lifeline2 = action2 && layout.lifelines.find((l) => l.id === action2.box);
1077
1899
  if (action2 && lifeline2) return { step: s, x: lifeline2.x, y: action2.y + action2.h / 2, color: action2.color };
1078
1900
  return cornerBadge(step.events, s, layout);
1079
1901
  });
1902
+ return replaceSameSpot(placed);
1080
1903
  }
1081
1904
 
1082
- // src/words.ts
1083
- var keys = (table) => Object.keys(table);
1084
- var KINDS = keys({ sequence: true, architecture: true, state: true });
1085
- var STATE_ENDS = ["start", "finish"];
1086
- var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
1087
- var AS = "as";
1088
- var ATTRS = {
1089
- diagram: ["view"],
1090
- group: ["note", "color", "icon"],
1091
- box: ["note", "color", "icon"],
1092
- edge: ["carry", "tag", "side"],
1093
- set: ["tag"]
1094
- };
1095
- var CARRIES = keys({ coin: true, none: true });
1096
- var VIEWS = keys({ fixed: true, follow: true });
1097
- var SIDES = keys({ above: true, below: true, left: true, right: true });
1098
- var OLD_HEADS = {
1099
- \u6642\u7CFB\u5217\u56F3: "sequence",
1100
- \u69CB\u6210\u56F3: "architecture",
1101
- \u533A\u753B: "group",
1102
- \u898B\u305B\u65B9: "view",
1103
- region: "group",
1104
- view: "view"
1105
- };
1106
-
1107
1905
  // src/layout/state.ts
1108
1906
  var isEnd = (id) => STATE_ENDS.includes(id);
1109
1907
  function visitOrder(diagram) {
@@ -1117,12 +1915,6 @@ function visitOrder(diagram) {
1117
1915
  }
1118
1916
  return order;
1119
1917
  }
1120
- function carrierHalf(carry) {
1121
- const C = LOOK.carrier;
1122
- if (carry.kind === "tag") return (textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2;
1123
- if (carry.kind === "coin") return C.coinR;
1124
- return C.envW / 2;
1125
- }
1126
1918
  var same = (a, b) => a.from === b.from && a.to === b.to;
1127
1919
  function layoutState(diagram, lang) {
1128
1920
  const { box: B, state: T, margin, gap } = LOOK;
@@ -1139,7 +1931,11 @@ function layoutState(diagram, lang) {
1139
1931
  const source = diagram.boxes.find((b) => b.id === id);
1140
1932
  return G.pad * 2 + B.icon + G.gap + Math.max(textWidth(source?.name ?? id, TYPE.boxName), textWidth(source?.sub ?? "", TYPE.boxSub));
1141
1933
  };
1142
- const widths = new Map(diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : boxWidth(diagram, b.id, true)]));
1934
+ const carriedIn = slotRooms(diagram);
1935
+ const doneSide = Math.max(B.padX, T.done.inset + T.done.r + LOOK.slot.clear);
1936
+ const widths = new Map(
1937
+ diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== void 0, doneSide))])
1938
+ );
1143
1939
  const columnCount = Math.max(1, Math.min(T.columns, walked.length));
1144
1940
  const rowCount = Math.max(1, Math.ceil(walked.length / T.columns));
1145
1941
  const slot = new Map(
@@ -1160,7 +1956,7 @@ function layoutState(diagram, lang) {
1160
1956
  }
1161
1957
  const colLeft = [];
1162
1958
  for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
1163
- const center = (c) => colLeft[c] + colW[c] / 2;
1959
+ const center2 = (c) => colLeft[c] + colW[c] / 2;
1164
1960
  const isGhost = (id) => ghosts.includes(id);
1165
1961
  const enteringFrom = new Set(notTaken.filter((p) => isGhost(p.to) && !isGhost(p.from) && !isEnd(p.from)).map((p) => p.from));
1166
1962
  const notes = [words.sideNote, ...enteringFrom.size > 0 ? [words.sideFrom(enteringFrom.size)] : []];
@@ -1190,8 +1986,9 @@ function layoutState(diagram, lang) {
1190
1986
  };
1191
1987
  const boxes = walked.map((id) => {
1192
1988
  const s = slot.get(id);
1193
- return boxOf(id, center(s.col), rowY(s.row), false);
1989
+ return boxOf(id, center2(s.col), rowY(s.row), false);
1194
1990
  });
1991
+ for (const box of boxes) placeSlot(box, carriedIn.get(box.id), doneSide);
1195
1992
  const byId = new Map(boxes.map((b) => [b.id, b]));
1196
1993
  const below = (box) => boxes.some((other) => other !== box && Math.abs(other.cx - box.cx) < 0.5 && other.y > box.y);
1197
1994
  const ends = [];
@@ -1262,20 +2059,6 @@ function layoutState(diagram, lang) {
1262
2059
  };
1263
2060
  const exitX = (box) => starts && box === first ? box.cx + T.side.entry : box.cx;
1264
2061
  const finishOf = (id) => ends.find((e) => e.kind === "finish" && e.box === id);
1265
- const loopOf = (box) => {
1266
- const { w, h, samples } = T.loop;
1267
- const bottom2 = box.y + box.h;
1268
- const p0 = [box.cx + w / 2, bottom2];
1269
- const c1 = [box.cx + w * 3 / 4, bottom2 + h * 4 / 3];
1270
- const c2 = [box.cx - w * 3 / 4, bottom2 + h * 4 / 3];
1271
- const p3 = [box.cx - w / 2, bottom2 + inset];
1272
- return Array.from({ length: samples + 1 }, (_, k) => {
1273
- const t = k / samples;
1274
- const u = 1 - t;
1275
- const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
1276
- return [at2(0), at2(1)];
1277
- });
1278
- };
1279
2062
  const route = (from, to) => {
1280
2063
  if (from === "start") {
1281
2064
  const start = ends.find((e) => e.kind === "start");
@@ -1292,7 +2075,7 @@ function layoutState(diagram, lang) {
1292
2075
  }
1293
2076
  const b = byId.get(to);
1294
2077
  if (!b) return [];
1295
- if (from === to) return loopOf(a);
2078
+ if (from === to) return loopUnder(a);
1296
2079
  if (b.ghost && !a.ghost) {
1297
2080
  const sx = exitX(a);
1298
2081
  const ex = entryOf(from, b);
@@ -1303,15 +2086,18 @@ function layoutState(diagram, lang) {
1303
2086
  return between2(a, b);
1304
2087
  };
1305
2088
  const settleOf = (edge2) => {
1306
- const target = byId.get(edge2.to);
1307
- if (target) return [target.cx, target.cy + B.iconY];
1308
2089
  const end = edge2.to === "finish" ? finishOf(edge2.from) : void 0;
1309
2090
  if (!end) return void 0;
1310
2091
  const from = byId.get(edge2.from);
1311
- return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry), end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
2092
+ return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry)[0], end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
2093
+ };
2094
+ const waitOf = (edge2) => {
2095
+ const start = edge2.from === "start" ? ends.find((e) => e.kind === "start") : void 0;
2096
+ return start ? [start.x - start.r - LOOK.slot.mark - carrierHalf(edge2.carry)[0], start.y] : void 0;
1312
2097
  };
1313
2098
  const sceneEdges = steps.map(({ step, event, edge: edge2 }) => {
1314
2099
  const settle = settleOf(edge2);
2100
+ const wait = edge2.carry.kind === "none" ? void 0 : waitOf(edge2);
1315
2101
  return {
1316
2102
  step,
1317
2103
  event,
@@ -1320,49 +2106,67 @@ function layoutState(diagram, lang) {
1320
2106
  points: route(edge2.from, edge2.to),
1321
2107
  color: colorOf(edge2, colors),
1322
2108
  carry: edge2.carry,
1323
- ...settle ? { settle } : {}
2109
+ ...settle ? { settle } : {},
2110
+ ...wait ? { wait } : {}
1324
2111
  };
1325
2112
  });
2113
+ seatCarriers(sceneEdges, byId, carriedIn);
2114
+ const outward = /* @__PURE__ */ new Map();
1326
2115
  for (const e of sceneEdges) {
1327
2116
  if (e.points.length !== 2 || !sceneEdges.some((o) => o.from === e.to && o.to === e.from && o.points.length === 2)) continue;
1328
2117
  const [p, q] = e.points;
1329
2118
  const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
1330
2119
  const d = (e.from < e.to ? 1 : -1) * LOOK.edge.parallel;
1331
2120
  e.points = e.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
2121
+ outward.set(e, flat ? d > 0 ? "below" : "above" : d > 0 ? "right" : "left");
1332
2122
  }
1333
2123
  const paths = notTaken.map((p) => ({ from: p.from, to: p.to, points: route(p.from, p.to) }));
2124
+ const badgeAt = (edge2, taken, lines2) => edge2.from === edge2.to ? loopBadge(edge2.points) : badgeOnPath(edge2.points, taken, lines2);
1334
2125
  const labels = [];
1335
- const soft = side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [];
2126
+ const marks = ends.flatMap((e) => e.text === "" ? [] : [textBox(e.text, ...markText(e), TYPE.regionNote)]);
2127
+ const badgeRects = [...lineBadges(sceneEdges, diagram.steps.length, badgeAt).values()].map((b) => badgeRect(b.point));
2128
+ const soft = [...side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [], ...marks];
2129
+ const others = (own) => [...sceneEdges.map((o) => o.points), ...paths.map((o) => o.points)].filter((line) => line !== own);
1336
2130
  for (const e of sceneEdges) {
1337
2131
  const source = diagram.steps[e.step]?.events[e.event];
1338
2132
  if (source?.type !== "edge" || source.label === void 0) continue;
1339
- const style = labelStyle(source.label);
1340
- if (e.from === e.to) {
1341
- const w = textWidth(source.label, style) + LOOK.label.padX * 2;
1342
- const bottom2 = Math.max(...e.points.map(([, y]) => y));
1343
- labels.push({ step: e.step, event: e.event, text: source.label, family: style.family, color: e.color, x: (e.points[0]?.[0] ?? 0) - T.loop.w / 2 - w / 2, y: bottom2 + LOOK.label.soft, w, h: LOOK.label.h });
2133
+ const loop = e.from === e.to;
2134
+ const key = lineKey(e);
2135
+ const named = labels.filter((l) => l.text === source.label && sceneEdges.some((o) => o.step === l.step && o.event === l.event && lineKey(o) === key));
2136
+ const same2 = named[named.length - 1];
2137
+ if (same2) {
2138
+ same2.until = e.step;
2139
+ labels.push({ x: same2.x, y: same2.y, w: same2.w, h: same2.h, step: e.step, event: e.event, text: same2.text, family: same2.family, color: e.color });
1344
2140
  continue;
1345
2141
  }
1346
- const side22 = source.labelSide ?? (e.to === "finish" ? "left" : void 0);
2142
+ const w = textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2;
2143
+ const below2 = loop ? { side: "below", base: loopLabelBase(e.points, w) } : {};
2144
+ const side22 = source.labelSide ?? (e.to === "finish" ? "left" : outward.get(e));
1347
2145
  labels.push(
1348
2146
  placeLabel(
1349
- { step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : {} },
1350
- { hard: boxes, soft: [...soft, ...labels.filter((l) => l.step === e.step)] }
2147
+ { step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : loop ? {} : { flip: true }, ...below2 },
2148
+ { hard: boxes, soft: [...soft, ...labels], touch: badgeRects, lines: others(e.points) }
1351
2149
  )
1352
2150
  );
1353
2151
  }
2152
+ const placed = [];
1354
2153
  notTaken.forEach((p, i) => {
1355
2154
  const path2 = paths[i];
1356
2155
  if (p.label === void 0 || path2.points.length === 0) return;
1357
2156
  const style = labelStyle(p.label);
1358
2157
  const into = byId.get(p.to)?.ghost === true && byId.get(p.from)?.ghost !== true;
1359
- const rect = into ? { x: path2.points[0][0] + LOOK.label.soft, y: lane + LOOK.label.soft, w: textWidth(p.label, style) + LOOK.label.padX * 2, h: LOOK.label.h } : placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate" }, { hard: boxes, soft });
2158
+ const x0 = path2.points[0][0];
2159
+ const lead = into ? { side: "below", base: { x: x0 + LOOK.label.soft, y: lane + LOOK.label.soft }, slide: Math.max(...path2.points.map(([x]) => Math.abs(x - x0))) } : {};
2160
+ const rect = placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate", ...lead }, { hard: boxes, soft: [...soft, ...labels, ...placed], touch: badgeRects, lines: others(path2.points) });
2161
+ placed.push(rect);
1360
2162
  path2.label = { x: rect.x, y: rect.y, w: rect.w, h: rect.h, text: p.label, family: style.family };
1361
2163
  });
1362
2164
  const layout = { kind: "state", width: 0, height: 0, regions: [], boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths, ends, ...side2 ? { side: side2 } : {} };
1363
2165
  const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...paths.flatMap((p) => p.label ? [p.label.x] : [])];
2166
+ const tops = [...labels.map((l) => l.y), ...paths.flatMap((p) => p.label ? [p.label.y] : [])];
1364
2167
  const shift = Math.max(0, margin - Math.min(...lefts));
1365
- if (shift > 0) shiftContent(layout, shift, 0);
2168
+ const drop = tops.length > 0 ? Math.max(0, margin - Math.min(...tops)) : 0;
2169
+ if (shift > 0 || drop > 0) shiftContent(layout, shift, drop);
1366
2170
  const endRight = (e) => e.x + (e.text === "" ? e.r : T.text + textWidth(e.text, TYPE.regionNote));
1367
2171
  const rights = [
1368
2172
  ...boxes.map((b) => b.x + b.w),
@@ -1380,18 +2184,14 @@ function layoutState(diagram, lang) {
1380
2184
  layout.width = width;
1381
2185
  layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
1382
2186
  if (strip2) layout.strip = strip2;
1383
- layout.badges = diagram.steps.map((step, s) => {
1384
- const edge2 = sceneEdges.find((e) => e.step === s && e.points.length > 0);
1385
- if (!edge2) return cornerBadge(step.events, s, layout);
1386
- if (edge2.from === edge2.to) {
1387
- const right = Math.max(...edge2.points.map(([px]) => px));
1388
- const top = edge2.points[0][1];
1389
- const deep = Math.max(...edge2.points.map(([, py]) => py));
1390
- return { step: s, x: right + LOOK.badge.r + LOOK.badge.inset, y: top + (deep - top) * T.loop.badgeAt, color: edge2.color };
1391
- }
1392
- const [x, y] = badgeOnPath(edge2.points);
1393
- return { step: s, x, y, color: edge2.color };
1394
- });
2187
+ const placedBadges = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
2188
+ layout.badges = replaceSameSpot(
2189
+ diagram.steps.map((step, s) => {
2190
+ const line = placedBadges.get(s);
2191
+ if (!line) return cornerBadge(step.events, s, layout);
2192
+ return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
2193
+ })
2194
+ );
1395
2195
  return layout;
1396
2196
  }
1397
2197
  function colorOf(edge2, colors) {
@@ -1431,6 +2231,8 @@ var ja = {
1431
2231
  const: (value) => `${value} \u306B\u3059\u308B`,
1432
2232
  not: (allowed) => allowed ? `${allowed.field} \u306E\u6B04\u306F kind \u304C ${allowed.kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B` : "\u3053\u306E\u6B04\u306E\u7D44\u307F\u5408\u308F\u305B\u306F\u66F8\u3051\u306A\u3044",
1433
2233
  reserved: (names) => `${names.join(" \u3068 ")} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
2234
+ kindOnly: (types, kind) => `${types.join(" \u3068 ")} \u306E\u51FA\u6765\u4E8B\u306F kind \u304C ${kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B`,
2235
+ hex: (min, max) => `0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 ${min} \u304B\u3089 ${max} \u5B57\u306B\u3059\u308B`,
1434
2236
  anyOf: (fields) => fields.length > 0 ? `${fields.join(" \u304B ")} \u306E${fields.length === 2 ? "\u3069\u3061\u3089\u304B" : "\u3069\u308C\u304B"}\u306E\u6B04\u304C\u8981\u308B` : "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u306B\u3082\u5408\u308F\u306A\u3044",
1435
2237
  oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
1436
2238
  discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
@@ -1448,6 +2250,8 @@ var en = {
1448
2250
  const: (value) => `Use ${value}`,
1449
2251
  not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
1450
2252
  reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
2253
+ kindOnly: (types, kind) => `${types.join(" and ")} events are allowed only when kind is ${kind}`,
2254
+ hex: (min, max) => `Use ${min} to ${max} characters of 0-9 and a-f`,
1451
2255
  anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
1452
2256
  oneOf: "Match exactly one of the allowed shapes",
1453
2257
  discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
@@ -1462,10 +2266,10 @@ function ucs2length(str) {
1462
2266
  return length;
1463
2267
  }
1464
2268
  var validate_diagram_default = validate10;
1465
- var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" }, "state": { "$ref": "#/definitions/state" } }};
2269
+ var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state", "git"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" }, "state": { "$ref": "#/definitions/state" }, "git": { "$ref": "#/definitions/git" } }};
1466
2270
  var func2 = Object.prototype.hasOwnProperty;
1467
2271
  var func3 = ucs2length;
1468
- var schema17 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
2272
+ var schema28 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
1469
2273
  var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
1470
2274
  function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
1471
2275
  let vErrors = null;
@@ -1569,7 +2373,7 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
1569
2373
  if (data.color !== void 0) {
1570
2374
  let data3 = data.color;
1571
2375
  if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
1572
- const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema17.enum }, message: "must be equal to one of the allowed values" };
2376
+ const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema28.enum }, message: "must be equal to one of the allowed values" };
1573
2377
  if (vErrors === null) {
1574
2378
  vErrors = [err9];
1575
2379
  } else {
@@ -1714,7 +2518,7 @@ function validate13(data, { instancePath = "", parentData, parentDataProperty, r
1714
2518
  if (data.color !== void 0) {
1715
2519
  let data3 = data.color;
1716
2520
  if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
1717
- const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema17.enum }, message: "must be equal to one of the allowed values" };
2521
+ const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema28.enum }, message: "must be equal to one of the allowed values" };
1718
2522
  if (vErrors === null) {
1719
2523
  vErrors = [err9];
1720
2524
  } else {
@@ -1891,8 +2695,9 @@ function validate15(data, { instancePath = "", parentData, parentDataProperty, r
1891
2695
  validate15.errors = vErrors;
1892
2696
  return errors === 0;
1893
2697
  }
1894
- var schema33 = { "oneOf": [{ "description": "\u7DDA\u3002\u904B\u3076\u7269\u3092\u8F09\u305B\u3066\u9001\u308B\u5074\u304B\u3089\u53D7\u3051\u308B\u5074\u3078\u8D70\u308B", "type": "object", "additionalProperties": false, "required": ["type", "from", "to", "carry"], "properties": { "type": { "const": "edge" }, "from": { "$ref": "#/definitions/id" }, "to": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" }, "carry": { "$ref": "#/definitions/carry" }, "labelSide": { "description": "\u7DDA\u306E\u540D\u524D\u3092\u7F6E\u304F\u5074 (\u5BC4\u305B\u306E\u6307\u793A)", "enum": ["above", "below", "left", "right"] } } }, { "description": "\u7BB1\u306E\u4E2D\u306E\u51E6\u7406", "type": "object", "additionalProperties": false, "required": ["type", "box", "label"], "properties": { "type": { "const": "action" }, "box": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" } } }, { "description": "\u7BB1\u306E\u4E0B\u306E\u5C0F\u3055\u306A\u5B57\u306E\u66F8\u304D\u63DB\u3048", "type": "object", "additionalProperties": false, "required": ["type", "box", "text"], "properties": { "type": { "const": "swap" }, "box": { "$ref": "#/definitions/id" }, "text": { "$ref": "#/definitions/text" } } }, { "description": "\u4E2D\u8EAB\u306E\u5E2F\u306E\u6B04\u306E\u5024\u3068\u672D", "type": "object", "additionalProperties": false, "required": ["type", "field"], "anyOf": [{ "required": ["value"] }, { "required": ["tag"] }], "properties": { "type": { "const": "strip" }, "field": { "$ref": "#/definitions/text" }, "value": { "$ref": "#/definitions/text" }, "tag": { "$ref": "#/definitions/text" } } }] };
1895
- var schema37 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
2698
+ var schema44 = { "oneOf": [{ "description": "\u7DDA\u3002\u904B\u3076\u7269\u3092\u8F09\u305B\u3066\u9001\u308B\u5074\u304B\u3089\u53D7\u3051\u308B\u5074\u3078\u8D70\u308B", "type": "object", "additionalProperties": false, "required": ["type", "from", "to", "carry"], "properties": { "type": { "const": "edge" }, "from": { "$ref": "#/definitions/id" }, "to": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" }, "carry": { "$ref": "#/definitions/carry" }, "labelSide": { "description": "\u7DDA\u306E\u540D\u524D\u3092\u7F6E\u304F\u5074 (\u5BC4\u305B\u306E\u6307\u793A)", "enum": ["above", "below", "left", "right"] } } }, { "description": "\u7BB1\u306E\u4E2D\u306E\u51E6\u7406", "type": "object", "additionalProperties": false, "required": ["type", "box", "label"], "properties": { "type": { "const": "action" }, "box": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" } } }, { "description": "\u7BB1\u306E\u4E0B\u306E\u5C0F\u3055\u306A\u5B57\u306E\u66F8\u304D\u63DB\u3048", "type": "object", "additionalProperties": false, "required": ["type", "box", "text"], "properties": { "type": { "const": "swap" }, "box": { "$ref": "#/definitions/id" }, "text": { "$ref": "#/definitions/text" } } }, { "description": "commit \u3092\u7A4D\u3080\u3002\u679D\u5206\u304B\u308C\u306E\u56F3\u3060\u3051\u304C\u66F8\u3051\u308B\u3002\u7A4D\u3093\u3060\u679D\u306E\u672D\u3068\u3001\u305D\u306E\u679D\u3092\u6307\u3059 HEAD \u304C\u9032\u3080\u3002\u5F53\u3066\u76F4\u3057 (copy) \u306F\u679D\u306E\u672D\u3092\u52D5\u304B\u3055\u305A\u3001merge commit (merge) \u306F\u53D6\u308A\u8FBC\u3080\u679D\u306E\u5148\u7AEF\u3082\u89AA\u306B\u6301\u3064", "type": "object", "additionalProperties": false, "required": ["type", "id", "branch"], "properties": { "type": { "const": "commit" }, "id": { "$ref": "#/definitions/id" }, "branch": { "$ref": "#/definitions/id" }, "copy": { "$ref": "#/definitions/id" }, "merge": { "$ref": "#/definitions/id" }, "hash": { "$ref": "#/definitions/hash" }, "note": { "$ref": "#/definitions/text" } } }, { "description": "\u679D\u3092\u5207\u308B\u3002\u679D\u5206\u304B\u308C\u306E\u56F3\u3060\u3051\u304C\u66F8\u3051\u308B\u3002\u679D\u306E\u672D\u3092 from \u306E commit \u3078\u7F6E\u304D\u3001HEAD \u3092\u305D\u306E\u679D\u3078\u79FB\u3059", "type": "object", "additionalProperties": false, "required": ["type", "branch", "from"], "properties": { "type": { "const": "branch" }, "branch": { "$ref": "#/definitions/id" }, "from": { "$ref": "#/definitions/id" } } }, { "description": "\u4E2D\u8EAB\u306E\u5E2F\u306E\u6B04\u306E\u5024\u3068\u672D", "type": "object", "additionalProperties": false, "required": ["type", "field"], "anyOf": [{ "required": ["value"] }, { "required": ["tag"] }], "properties": { "type": { "const": "strip" }, "field": { "$ref": "#/definitions/text" }, "value": { "$ref": "#/definitions/text" }, "tag": { "$ref": "#/definitions/text" } } }] };
2699
+ var pattern11 = new RegExp("^[0-9a-f]{4,40}$", "u");
2700
+ var schema48 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
1896
2701
  function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
1897
2702
  let vErrors = null;
1898
2703
  let errors = 0;
@@ -2019,7 +2824,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
2019
2824
  if (data.kind !== void 0) {
2020
2825
  let data1 = data.kind;
2021
2826
  if (!(data1 === "envelope" || data1 === "tag" || data1 === "coin" || data1 === "none")) {
2022
- const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema37.properties.kind.enum }, message: "must be equal to one of the allowed values" };
2827
+ const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema48.properties.kind.enum }, message: "must be equal to one of the allowed values" };
2023
2828
  if (vErrors === null) {
2024
2829
  vErrors = [err8];
2025
2830
  } else {
@@ -2212,7 +3017,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2212
3017
  if (data.labelSide !== void 0) {
2213
3018
  let data5 = data.labelSide;
2214
3019
  if (!(data5 === "above" || data5 === "below" || data5 === "left" || data5 === "right")) {
2215
- const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues: schema33.oneOf[0].properties.labelSide.enum }, message: "must be equal to one of the allowed values" };
3020
+ const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues: schema44.oneOf[0].properties.labelSide.enum }, message: "must be equal to one of the allowed values" };
2216
3021
  if (vErrors === null) {
2217
3022
  vErrors = [err13];
2218
3023
  } else {
@@ -2438,13 +3243,10 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2438
3243
  }
2439
3244
  errors++;
2440
3245
  }
2441
- } else if (tag0 === "strip") {
2442
- const _errs39 = errors;
2443
- let valid15 = false;
2444
- const _errs40 = errors;
3246
+ } else if (tag0 === "commit") {
2445
3247
  if (data && typeof data == "object" && !Array.isArray(data)) {
2446
- if (data.value === void 0) {
2447
- const err35 = { instancePath, schemaPath: "#/oneOf/3/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
3248
+ if (data.type === void 0) {
3249
+ const err35 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
2448
3250
  if (vErrors === null) {
2449
3251
  vErrors = [err35];
2450
3252
  } else {
@@ -2452,120 +3254,104 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2452
3254
  }
2453
3255
  errors++;
2454
3256
  }
2455
- }
2456
- var _valid0 = _errs40 === errors;
2457
- valid15 = valid15 || _valid0;
2458
- if (!valid15) {
2459
- const _errs41 = errors;
2460
- if (data && typeof data == "object" && !Array.isArray(data)) {
2461
- if (data.tag === void 0) {
2462
- const err36 = { instancePath, schemaPath: "#/oneOf/3/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
2463
- if (vErrors === null) {
2464
- vErrors = [err36];
2465
- } else {
2466
- vErrors.push(err36);
2467
- }
2468
- errors++;
2469
- }
2470
- }
2471
- var _valid0 = _errs41 === errors;
2472
- valid15 = valid15 || _valid0;
2473
- }
2474
- if (!valid15) {
2475
- const err37 = { instancePath, schemaPath: "#/oneOf/3/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
2476
- if (vErrors === null) {
2477
- vErrors = [err37];
2478
- } else {
2479
- vErrors.push(err37);
2480
- }
2481
- errors++;
2482
- } else {
2483
- errors = _errs39;
2484
- if (vErrors !== null) {
2485
- if (_errs39) {
2486
- vErrors.length = _errs39;
2487
- } else {
2488
- vErrors = null;
2489
- }
2490
- }
2491
- }
2492
- if (data && typeof data == "object" && !Array.isArray(data)) {
2493
- if (data.type === void 0) {
2494
- const err38 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
3257
+ if (data.id === void 0) {
3258
+ const err36 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
2495
3259
  if (vErrors === null) {
2496
- vErrors = [err38];
3260
+ vErrors = [err36];
2497
3261
  } else {
2498
- vErrors.push(err38);
3262
+ vErrors.push(err36);
2499
3263
  }
2500
3264
  errors++;
2501
3265
  }
2502
- if (data.field === void 0) {
2503
- const err39 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
3266
+ if (data.branch === void 0) {
3267
+ const err37 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
2504
3268
  if (vErrors === null) {
2505
- vErrors = [err39];
3269
+ vErrors = [err37];
2506
3270
  } else {
2507
- vErrors.push(err39);
3271
+ vErrors.push(err37);
2508
3272
  }
2509
3273
  errors++;
2510
3274
  }
2511
3275
  for (const key3 in data) {
2512
- if (!(key3 === "type" || key3 === "field" || key3 === "value" || key3 === "tag")) {
2513
- const err40 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
3276
+ if (!(key3 === "type" || key3 === "id" || key3 === "branch" || key3 === "copy" || key3 === "merge" || key3 === "hash" || key3 === "note")) {
3277
+ const err38 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
2514
3278
  if (vErrors === null) {
2515
- vErrors = [err40];
3279
+ vErrors = [err38];
2516
3280
  } else {
2517
- vErrors.push(err40);
3281
+ vErrors.push(err38);
2518
3282
  }
2519
3283
  errors++;
2520
3284
  }
2521
3285
  }
2522
3286
  if (data.type !== void 0) {
2523
- if ("strip" !== data.type) {
2524
- const err41 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
3287
+ if ("commit" !== data.type) {
3288
+ const err39 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "commit" }, message: "must be equal to constant" };
2525
3289
  if (vErrors === null) {
2526
- vErrors = [err41];
3290
+ vErrors = [err39];
2527
3291
  } else {
2528
- vErrors.push(err41);
3292
+ vErrors.push(err39);
2529
3293
  }
2530
3294
  errors++;
2531
3295
  }
2532
3296
  }
2533
- if (data.field !== void 0) {
2534
- let data13 = data.field;
3297
+ if (data.id !== void 0) {
3298
+ let data13 = data.id;
2535
3299
  if (typeof data13 === "string") {
2536
- if (func3(data13) < 1) {
2537
- const err42 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3300
+ if (!pattern0.test(data13)) {
3301
+ const err40 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2538
3302
  if (vErrors === null) {
2539
- vErrors = [err42];
3303
+ vErrors = [err40];
2540
3304
  } else {
2541
- vErrors.push(err42);
3305
+ vErrors.push(err40);
2542
3306
  }
2543
3307
  errors++;
2544
3308
  }
2545
3309
  } else {
2546
- const err43 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3310
+ const err41 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2547
3311
  if (vErrors === null) {
2548
- vErrors = [err43];
3312
+ vErrors = [err41];
2549
3313
  } else {
2550
- vErrors.push(err43);
3314
+ vErrors.push(err41);
2551
3315
  }
2552
3316
  errors++;
2553
3317
  }
2554
3318
  }
2555
- if (data.value !== void 0) {
2556
- let data14 = data.value;
3319
+ if (data.branch !== void 0) {
3320
+ let data14 = data.branch;
2557
3321
  if (typeof data14 === "string") {
2558
- if (func3(data14) < 1) {
2559
- const err44 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3322
+ if (!pattern0.test(data14)) {
3323
+ const err42 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2560
3324
  if (vErrors === null) {
2561
- vErrors = [err44];
3325
+ vErrors = [err42];
2562
3326
  } else {
2563
- vErrors.push(err44);
3327
+ vErrors.push(err42);
2564
3328
  }
2565
3329
  errors++;
2566
3330
  }
2567
3331
  } else {
2568
- const err45 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3332
+ const err43 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3333
+ if (vErrors === null) {
3334
+ vErrors = [err43];
3335
+ } else {
3336
+ vErrors.push(err43);
3337
+ }
3338
+ errors++;
3339
+ }
3340
+ }
3341
+ if (data.copy !== void 0) {
3342
+ let data15 = data.copy;
3343
+ if (typeof data15 === "string") {
3344
+ if (!pattern0.test(data15)) {
3345
+ const err44 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
3346
+ if (vErrors === null) {
3347
+ vErrors = [err44];
3348
+ } else {
3349
+ vErrors.push(err44);
3350
+ }
3351
+ errors++;
3352
+ }
3353
+ } else {
3354
+ const err45 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2569
3355
  if (vErrors === null) {
2570
3356
  vErrors = [err45];
2571
3357
  } else {
@@ -2574,11 +3360,11 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2574
3360
  errors++;
2575
3361
  }
2576
3362
  }
2577
- if (data.tag !== void 0) {
2578
- let data15 = data.tag;
2579
- if (typeof data15 === "string") {
2580
- if (func3(data15) < 1) {
2581
- const err46 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3363
+ if (data.merge !== void 0) {
3364
+ let data16 = data.merge;
3365
+ if (typeof data16 === "string") {
3366
+ if (!pattern0.test(data16)) {
3367
+ const err46 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2582
3368
  if (vErrors === null) {
2583
3369
  vErrors = [err46];
2584
3370
  } else {
@@ -2587,7 +3373,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2587
3373
  errors++;
2588
3374
  }
2589
3375
  } else {
2590
- const err47 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3376
+ const err47 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2591
3377
  if (vErrors === null) {
2592
3378
  vErrors = [err47];
2593
3379
  } else {
@@ -2596,39 +3382,354 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2596
3382
  errors++;
2597
3383
  }
2598
3384
  }
3385
+ if (data.hash !== void 0) {
3386
+ let data17 = data.hash;
3387
+ if (typeof data17 === "string") {
3388
+ if (!pattern11.test(data17)) {
3389
+ const err48 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/pattern", keyword: "pattern", params: { pattern: "^[0-9a-f]{4,40}$" }, message: 'must match pattern "^[0-9a-f]{4,40}$"' };
3390
+ if (vErrors === null) {
3391
+ vErrors = [err48];
3392
+ } else {
3393
+ vErrors.push(err48);
3394
+ }
3395
+ errors++;
3396
+ }
3397
+ } else {
3398
+ const err49 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3399
+ if (vErrors === null) {
3400
+ vErrors = [err49];
3401
+ } else {
3402
+ vErrors.push(err49);
3403
+ }
3404
+ errors++;
3405
+ }
3406
+ }
3407
+ if (data.note !== void 0) {
3408
+ let data18 = data.note;
3409
+ if (typeof data18 === "string") {
3410
+ if (func3(data18) < 1) {
3411
+ const err50 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3412
+ if (vErrors === null) {
3413
+ vErrors = [err50];
3414
+ } else {
3415
+ vErrors.push(err50);
3416
+ }
3417
+ errors++;
3418
+ }
3419
+ } else {
3420
+ const err51 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3421
+ if (vErrors === null) {
3422
+ vErrors = [err51];
3423
+ } else {
3424
+ vErrors.push(err51);
3425
+ }
3426
+ errors++;
3427
+ }
3428
+ }
3429
+ } else {
3430
+ const err52 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3431
+ if (vErrors === null) {
3432
+ vErrors = [err52];
3433
+ } else {
3434
+ vErrors.push(err52);
3435
+ }
3436
+ errors++;
3437
+ }
3438
+ } else if (tag0 === "branch") {
3439
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3440
+ if (data.type === void 0) {
3441
+ const err53 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
3442
+ if (vErrors === null) {
3443
+ vErrors = [err53];
3444
+ } else {
3445
+ vErrors.push(err53);
3446
+ }
3447
+ errors++;
3448
+ }
3449
+ if (data.branch === void 0) {
3450
+ const err54 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
3451
+ if (vErrors === null) {
3452
+ vErrors = [err54];
3453
+ } else {
3454
+ vErrors.push(err54);
3455
+ }
3456
+ errors++;
3457
+ }
3458
+ if (data.from === void 0) {
3459
+ const err55 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
3460
+ if (vErrors === null) {
3461
+ vErrors = [err55];
3462
+ } else {
3463
+ vErrors.push(err55);
3464
+ }
3465
+ errors++;
3466
+ }
3467
+ for (const key4 in data) {
3468
+ if (!(key4 === "type" || key4 === "branch" || key4 === "from")) {
3469
+ const err56 = { instancePath, schemaPath: "#/oneOf/4/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key4 }, message: "must NOT have additional properties" };
3470
+ if (vErrors === null) {
3471
+ vErrors = [err56];
3472
+ } else {
3473
+ vErrors.push(err56);
3474
+ }
3475
+ errors++;
3476
+ }
3477
+ }
3478
+ if (data.type !== void 0) {
3479
+ if ("branch" !== data.type) {
3480
+ const err57 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/4/properties/type/const", keyword: "const", params: { allowedValue: "branch" }, message: "must be equal to constant" };
3481
+ if (vErrors === null) {
3482
+ vErrors = [err57];
3483
+ } else {
3484
+ vErrors.push(err57);
3485
+ }
3486
+ errors++;
3487
+ }
3488
+ }
3489
+ if (data.branch !== void 0) {
3490
+ let data20 = data.branch;
3491
+ if (typeof data20 === "string") {
3492
+ if (!pattern0.test(data20)) {
3493
+ const err58 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
3494
+ if (vErrors === null) {
3495
+ vErrors = [err58];
3496
+ } else {
3497
+ vErrors.push(err58);
3498
+ }
3499
+ errors++;
3500
+ }
3501
+ } else {
3502
+ const err59 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3503
+ if (vErrors === null) {
3504
+ vErrors = [err59];
3505
+ } else {
3506
+ vErrors.push(err59);
3507
+ }
3508
+ errors++;
3509
+ }
3510
+ }
3511
+ if (data.from !== void 0) {
3512
+ let data21 = data.from;
3513
+ if (typeof data21 === "string") {
3514
+ if (!pattern0.test(data21)) {
3515
+ const err60 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
3516
+ if (vErrors === null) {
3517
+ vErrors = [err60];
3518
+ } else {
3519
+ vErrors.push(err60);
3520
+ }
3521
+ errors++;
3522
+ }
3523
+ } else {
3524
+ const err61 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3525
+ if (vErrors === null) {
3526
+ vErrors = [err61];
3527
+ } else {
3528
+ vErrors.push(err61);
3529
+ }
3530
+ errors++;
3531
+ }
3532
+ }
3533
+ } else {
3534
+ const err62 = { instancePath, schemaPath: "#/oneOf/4/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3535
+ if (vErrors === null) {
3536
+ vErrors = [err62];
3537
+ } else {
3538
+ vErrors.push(err62);
3539
+ }
3540
+ errors++;
3541
+ }
3542
+ } else if (tag0 === "strip") {
3543
+ const _errs71 = errors;
3544
+ let valid27 = false;
3545
+ const _errs72 = errors;
3546
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3547
+ if (data.value === void 0) {
3548
+ const err63 = { instancePath, schemaPath: "#/oneOf/5/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
3549
+ if (vErrors === null) {
3550
+ vErrors = [err63];
3551
+ } else {
3552
+ vErrors.push(err63);
3553
+ }
3554
+ errors++;
3555
+ }
3556
+ }
3557
+ var _valid0 = _errs72 === errors;
3558
+ valid27 = valid27 || _valid0;
3559
+ if (!valid27) {
3560
+ const _errs73 = errors;
3561
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3562
+ if (data.tag === void 0) {
3563
+ const err64 = { instancePath, schemaPath: "#/oneOf/5/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
3564
+ if (vErrors === null) {
3565
+ vErrors = [err64];
3566
+ } else {
3567
+ vErrors.push(err64);
3568
+ }
3569
+ errors++;
3570
+ }
3571
+ }
3572
+ var _valid0 = _errs73 === errors;
3573
+ valid27 = valid27 || _valid0;
3574
+ }
3575
+ if (!valid27) {
3576
+ const err65 = { instancePath, schemaPath: "#/oneOf/5/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
3577
+ if (vErrors === null) {
3578
+ vErrors = [err65];
3579
+ } else {
3580
+ vErrors.push(err65);
3581
+ }
3582
+ errors++;
3583
+ } else {
3584
+ errors = _errs71;
3585
+ if (vErrors !== null) {
3586
+ if (_errs71) {
3587
+ vErrors.length = _errs71;
3588
+ } else {
3589
+ vErrors = null;
3590
+ }
3591
+ }
3592
+ }
3593
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3594
+ if (data.type === void 0) {
3595
+ const err66 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
3596
+ if (vErrors === null) {
3597
+ vErrors = [err66];
3598
+ } else {
3599
+ vErrors.push(err66);
3600
+ }
3601
+ errors++;
3602
+ }
3603
+ if (data.field === void 0) {
3604
+ const err67 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
3605
+ if (vErrors === null) {
3606
+ vErrors = [err67];
3607
+ } else {
3608
+ vErrors.push(err67);
3609
+ }
3610
+ errors++;
3611
+ }
3612
+ for (const key5 in data) {
3613
+ if (!(key5 === "type" || key5 === "field" || key5 === "value" || key5 === "tag")) {
3614
+ const err68 = { instancePath, schemaPath: "#/oneOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
3615
+ if (vErrors === null) {
3616
+ vErrors = [err68];
3617
+ } else {
3618
+ vErrors.push(err68);
3619
+ }
3620
+ errors++;
3621
+ }
3622
+ }
3623
+ if (data.type !== void 0) {
3624
+ if ("strip" !== data.type) {
3625
+ const err69 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/5/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
3626
+ if (vErrors === null) {
3627
+ vErrors = [err69];
3628
+ } else {
3629
+ vErrors.push(err69);
3630
+ }
3631
+ errors++;
3632
+ }
3633
+ }
3634
+ if (data.field !== void 0) {
3635
+ let data23 = data.field;
3636
+ if (typeof data23 === "string") {
3637
+ if (func3(data23) < 1) {
3638
+ const err70 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3639
+ if (vErrors === null) {
3640
+ vErrors = [err70];
3641
+ } else {
3642
+ vErrors.push(err70);
3643
+ }
3644
+ errors++;
3645
+ }
3646
+ } else {
3647
+ const err71 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3648
+ if (vErrors === null) {
3649
+ vErrors = [err71];
3650
+ } else {
3651
+ vErrors.push(err71);
3652
+ }
3653
+ errors++;
3654
+ }
3655
+ }
3656
+ if (data.value !== void 0) {
3657
+ let data24 = data.value;
3658
+ if (typeof data24 === "string") {
3659
+ if (func3(data24) < 1) {
3660
+ const err72 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3661
+ if (vErrors === null) {
3662
+ vErrors = [err72];
3663
+ } else {
3664
+ vErrors.push(err72);
3665
+ }
3666
+ errors++;
3667
+ }
3668
+ } else {
3669
+ const err73 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3670
+ if (vErrors === null) {
3671
+ vErrors = [err73];
3672
+ } else {
3673
+ vErrors.push(err73);
3674
+ }
3675
+ errors++;
3676
+ }
3677
+ }
3678
+ if (data.tag !== void 0) {
3679
+ let data25 = data.tag;
3680
+ if (typeof data25 === "string") {
3681
+ if (func3(data25) < 1) {
3682
+ const err74 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3683
+ if (vErrors === null) {
3684
+ vErrors = [err74];
3685
+ } else {
3686
+ vErrors.push(err74);
3687
+ }
3688
+ errors++;
3689
+ }
3690
+ } else {
3691
+ const err75 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3692
+ if (vErrors === null) {
3693
+ vErrors = [err75];
3694
+ } else {
3695
+ vErrors.push(err75);
3696
+ }
3697
+ errors++;
3698
+ }
3699
+ }
2599
3700
  } else {
2600
- const err48 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3701
+ const err76 = { instancePath, schemaPath: "#/oneOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2601
3702
  if (vErrors === null) {
2602
- vErrors = [err48];
3703
+ vErrors = [err76];
2603
3704
  } else {
2604
- vErrors.push(err48);
3705
+ vErrors.push(err76);
2605
3706
  }
2606
3707
  errors++;
2607
3708
  }
2608
3709
  } else {
2609
- const err49 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
3710
+ const err77 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
2610
3711
  if (vErrors === null) {
2611
- vErrors = [err49];
3712
+ vErrors = [err77];
2612
3713
  } else {
2613
- vErrors.push(err49);
3714
+ vErrors.push(err77);
2614
3715
  }
2615
3716
  errors++;
2616
3717
  }
2617
3718
  } else {
2618
- const err50 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
3719
+ const err78 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
2619
3720
  if (vErrors === null) {
2620
- vErrors = [err50];
3721
+ vErrors = [err78];
2621
3722
  } else {
2622
- vErrors.push(err50);
3723
+ vErrors.push(err78);
2623
3724
  }
2624
3725
  errors++;
2625
3726
  }
2626
3727
  } else {
2627
- const err51 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3728
+ const err79 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2628
3729
  if (vErrors === null) {
2629
- vErrors = [err51];
3730
+ vErrors = [err79];
2630
3731
  } else {
2631
- vErrors.push(err51);
3732
+ vErrors.push(err79);
2632
3733
  }
2633
3734
  errors++;
2634
3735
  }
@@ -2950,29 +4051,174 @@ function validate26(data, { instancePath = "", parentData, parentDataProperty, r
2950
4051
  if (vErrors === null) {
2951
4052
  vErrors = [err8];
2952
4053
  } else {
2953
- vErrors.push(err8);
4054
+ vErrors.push(err8);
4055
+ }
4056
+ errors++;
4057
+ }
4058
+ }
4059
+ } else {
4060
+ const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4061
+ if (vErrors === null) {
4062
+ vErrors = [err9];
4063
+ } else {
4064
+ vErrors.push(err9);
4065
+ }
4066
+ errors++;
4067
+ }
4068
+ validate26.errors = vErrors;
4069
+ return errors === 0;
4070
+ }
4071
+ function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4072
+ let vErrors = null;
4073
+ let errors = 0;
4074
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4075
+ if (data.paths === void 0) {
4076
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "paths" }, message: "must have required property 'paths'" };
4077
+ if (vErrors === null) {
4078
+ vErrors = [err0];
4079
+ } else {
4080
+ vErrors.push(err0);
4081
+ }
4082
+ errors++;
4083
+ }
4084
+ for (const key0 in data) {
4085
+ if (!(key0 === "paths")) {
4086
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
4087
+ if (vErrors === null) {
4088
+ vErrors = [err1];
4089
+ } else {
4090
+ vErrors.push(err1);
4091
+ }
4092
+ errors++;
4093
+ }
4094
+ }
4095
+ if (data.paths !== void 0) {
4096
+ let data0 = data.paths;
4097
+ if (Array.isArray(data0)) {
4098
+ if (data0.length < 1) {
4099
+ const err2 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4100
+ if (vErrors === null) {
4101
+ vErrors = [err2];
4102
+ } else {
4103
+ vErrors.push(err2);
4104
+ }
4105
+ errors++;
4106
+ }
4107
+ const len0 = data0.length;
4108
+ for (let i0 = 0; i0 < len0; i0++) {
4109
+ if (!validate26(data0[i0], { instancePath: instancePath + "/paths/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
4110
+ vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
4111
+ errors = vErrors.length;
4112
+ }
4113
+ }
4114
+ } else {
4115
+ const err3 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4116
+ if (vErrors === null) {
4117
+ vErrors = [err3];
4118
+ } else {
4119
+ vErrors.push(err3);
4120
+ }
4121
+ errors++;
4122
+ }
4123
+ }
4124
+ } else {
4125
+ const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4126
+ if (vErrors === null) {
4127
+ vErrors = [err4];
4128
+ } else {
4129
+ vErrors.push(err4);
4130
+ }
4131
+ errors++;
4132
+ }
4133
+ validate25.errors = vErrors;
4134
+ return errors === 0;
4135
+ }
4136
+ function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4137
+ let vErrors = null;
4138
+ let errors = 0;
4139
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4140
+ if (data.id === void 0) {
4141
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
4142
+ if (vErrors === null) {
4143
+ vErrors = [err0];
4144
+ } else {
4145
+ vErrors.push(err0);
4146
+ }
4147
+ errors++;
4148
+ }
4149
+ for (const key0 in data) {
4150
+ if (!(key0 === "id" || key0 === "note")) {
4151
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
4152
+ if (vErrors === null) {
4153
+ vErrors = [err1];
4154
+ } else {
4155
+ vErrors.push(err1);
4156
+ }
4157
+ errors++;
4158
+ }
4159
+ }
4160
+ if (data.id !== void 0) {
4161
+ let data0 = data.id;
4162
+ if (typeof data0 === "string") {
4163
+ if (!pattern0.test(data0)) {
4164
+ const err2 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
4165
+ if (vErrors === null) {
4166
+ vErrors = [err2];
4167
+ } else {
4168
+ vErrors.push(err2);
4169
+ }
4170
+ errors++;
4171
+ }
4172
+ } else {
4173
+ const err3 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4174
+ if (vErrors === null) {
4175
+ vErrors = [err3];
4176
+ } else {
4177
+ vErrors.push(err3);
4178
+ }
4179
+ errors++;
4180
+ }
4181
+ }
4182
+ if (data.note !== void 0) {
4183
+ let data1 = data.note;
4184
+ if (typeof data1 === "string") {
4185
+ if (func3(data1) < 1) {
4186
+ const err4 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
4187
+ if (vErrors === null) {
4188
+ vErrors = [err4];
4189
+ } else {
4190
+ vErrors.push(err4);
4191
+ }
4192
+ errors++;
4193
+ }
4194
+ } else {
4195
+ const err5 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4196
+ if (vErrors === null) {
4197
+ vErrors = [err5];
4198
+ } else {
4199
+ vErrors.push(err5);
2954
4200
  }
2955
4201
  errors++;
2956
4202
  }
2957
4203
  }
2958
4204
  } else {
2959
- const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4205
+ const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2960
4206
  if (vErrors === null) {
2961
- vErrors = [err9];
4207
+ vErrors = [err6];
2962
4208
  } else {
2963
- vErrors.push(err9);
4209
+ vErrors.push(err6);
2964
4210
  }
2965
4211
  errors++;
2966
4212
  }
2967
- validate26.errors = vErrors;
4213
+ validate30.errors = vErrors;
2968
4214
  return errors === 0;
2969
4215
  }
2970
- function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4216
+ function validate29(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
2971
4217
  let vErrors = null;
2972
4218
  let errors = 0;
2973
4219
  if (data && typeof data == "object" && !Array.isArray(data)) {
2974
- if (data.paths === void 0) {
2975
- const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "paths" }, message: "must have required property 'paths'" };
4220
+ if (data.branches === void 0) {
4221
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "branches" }, message: "must have required property 'branches'" };
2976
4222
  if (vErrors === null) {
2977
4223
  vErrors = [err0];
2978
4224
  } else {
@@ -2981,7 +4227,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
2981
4227
  errors++;
2982
4228
  }
2983
4229
  for (const key0 in data) {
2984
- if (!(key0 === "paths")) {
4230
+ if (!(key0 === "branches")) {
2985
4231
  const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
2986
4232
  if (vErrors === null) {
2987
4233
  vErrors = [err1];
@@ -2991,11 +4237,11 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
2991
4237
  errors++;
2992
4238
  }
2993
4239
  }
2994
- if (data.paths !== void 0) {
2995
- let data0 = data.paths;
4240
+ if (data.branches !== void 0) {
4241
+ let data0 = data.branches;
2996
4242
  if (Array.isArray(data0)) {
2997
4243
  if (data0.length < 1) {
2998
- const err2 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4244
+ const err2 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2999
4245
  if (vErrors === null) {
3000
4246
  vErrors = [err2];
3001
4247
  } else {
@@ -3005,13 +4251,13 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
3005
4251
  }
3006
4252
  const len0 = data0.length;
3007
4253
  for (let i0 = 0; i0 < len0; i0++) {
3008
- if (!validate26(data0[i0], { instancePath: instancePath + "/paths/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
3009
- vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
4254
+ if (!validate30(data0[i0], { instancePath: instancePath + "/branches/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
4255
+ vErrors = vErrors === null ? validate30.errors : vErrors.concat(validate30.errors);
3010
4256
  errors = vErrors.length;
3011
4257
  }
3012
4258
  }
3013
4259
  } else {
3014
- const err3 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4260
+ const err3 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3015
4261
  if (vErrors === null) {
3016
4262
  vErrors = [err3];
3017
4263
  } else {
@@ -3029,7 +4275,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
3029
4275
  }
3030
4276
  errors++;
3031
4277
  }
3032
- validate25.errors = vErrors;
4278
+ validate29.errors = vErrors;
3033
4279
  return errors === 0;
3034
4280
  }
3035
4281
  function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
@@ -3073,11 +4319,9 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3073
4319
  let ifClause0;
3074
4320
  if (_valid0) {
3075
4321
  const _errs4 = errors;
3076
- const _errs5 = errors;
3077
- const _errs6 = errors;
3078
4322
  if (data && typeof data == "object" && !Array.isArray(data)) {
3079
- if (data.state === void 0 && ("state")) {
3080
- const err2 = {};
4323
+ if (data.sequence === void 0) {
4324
+ const err2 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
3081
4325
  if (vErrors === null) {
3082
4326
  vErrors = [err2];
3083
4327
  } else {
@@ -3085,147 +4329,181 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3085
4329
  }
3086
4330
  errors++;
3087
4331
  }
3088
- }
3089
- var valid2 = _errs6 === errors;
3090
- if (valid2) {
3091
- const err3 = { instancePath, schemaPath: "#/then/not", keyword: "not", params: {}, message: "must NOT be valid" };
3092
- if (vErrors === null) {
3093
- vErrors = [err3];
3094
- } else {
3095
- vErrors.push(err3);
4332
+ if (data.boxes !== void 0) {
4333
+ let data1 = data.boxes;
4334
+ if (Array.isArray(data1)) {
4335
+ if (data1.length < 1) {
4336
+ const err3 = { instancePath: instancePath + "/boxes", schemaPath: "#/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4337
+ if (vErrors === null) {
4338
+ vErrors = [err3];
4339
+ } else {
4340
+ vErrors.push(err3);
4341
+ }
4342
+ errors++;
4343
+ }
4344
+ }
3096
4345
  }
3097
- errors++;
3098
- } else {
3099
- errors = _errs5;
3100
- if (vErrors !== null) {
3101
- if (_errs5) {
3102
- vErrors.length = _errs5;
3103
- } else {
3104
- vErrors = null;
4346
+ if (data.steps !== void 0) {
4347
+ let data2 = data.steps;
4348
+ if (Array.isArray(data2)) {
4349
+ const len0 = data2.length;
4350
+ for (let i0 = 0; i0 < len0; i0++) {
4351
+ let data3 = data2[i0];
4352
+ if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
4353
+ if (data3.events !== void 0) {
4354
+ let data4 = data3.events;
4355
+ if (Array.isArray(data4)) {
4356
+ const len1 = data4.length;
4357
+ for (let i1 = 0; i1 < len1; i1++) {
4358
+ let data5 = data4[i1];
4359
+ if (data5 && typeof data5 == "object" && !Array.isArray(data5)) {
4360
+ if (data5.type !== void 0) {
4361
+ let data6 = data5.type;
4362
+ const _errs12 = errors;
4363
+ const _errs13 = errors;
4364
+ if (!(data6 === "commit" || data6 === "branch")) {
4365
+ const err4 = {};
4366
+ if (vErrors === null) {
4367
+ vErrors = [err4];
4368
+ } else {
4369
+ vErrors.push(err4);
4370
+ }
4371
+ errors++;
4372
+ }
4373
+ var valid10 = _errs13 === errors;
4374
+ if (valid10) {
4375
+ const err5 = { instancePath: instancePath + "/steps/" + i0 + "/events/" + i1 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
4376
+ if (vErrors === null) {
4377
+ vErrors = [err5];
4378
+ } else {
4379
+ vErrors.push(err5);
4380
+ }
4381
+ errors++;
4382
+ } else {
4383
+ errors = _errs12;
4384
+ if (vErrors !== null) {
4385
+ if (_errs12) {
4386
+ vErrors.length = _errs12;
4387
+ } else {
4388
+ vErrors = null;
4389
+ }
4390
+ }
4391
+ }
4392
+ }
4393
+ }
4394
+ }
4395
+ }
4396
+ }
4397
+ }
4398
+ }
3105
4399
  }
3106
4400
  }
3107
- }
3108
- if (data && typeof data == "object" && !Array.isArray(data)) {
3109
- if (data.sequence === void 0) {
3110
- const err4 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
4401
+ if (data.state !== void 0) {
4402
+ const err6 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
3111
4403
  if (vErrors === null) {
3112
- vErrors = [err4];
4404
+ vErrors = [err6];
3113
4405
  } else {
3114
- vErrors.push(err4);
4406
+ vErrors.push(err6);
3115
4407
  }
3116
4408
  errors++;
3117
4409
  }
3118
- }
3119
- var _valid0 = _errs4 === errors;
3120
- valid0 = _valid0;
3121
- ifClause0 = "then";
3122
- } else {
3123
- const _errs7 = errors;
3124
- const _errs8 = errors;
3125
- const _errs9 = errors;
3126
- if (data && typeof data == "object" && !Array.isArray(data)) {
3127
- if (data.sequence === void 0 && ("sequence")) {
3128
- const err5 = {};
4410
+ if (data.git !== void 0) {
4411
+ const err7 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
3129
4412
  if (vErrors === null) {
3130
- vErrors = [err5];
4413
+ vErrors = [err7];
3131
4414
  } else {
3132
- vErrors.push(err5);
4415
+ vErrors.push(err7);
3133
4416
  }
3134
4417
  errors++;
3135
4418
  }
3136
4419
  }
3137
- var valid3 = _errs9 === errors;
3138
- if (valid3) {
3139
- const err6 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
3140
- if (vErrors === null) {
3141
- vErrors = [err6];
3142
- } else {
3143
- vErrors.push(err6);
3144
- }
3145
- errors++;
3146
- } else {
3147
- errors = _errs8;
3148
- if (vErrors !== null) {
3149
- if (_errs8) {
3150
- vErrors.length = _errs8;
3151
- } else {
3152
- vErrors = null;
3153
- }
3154
- }
3155
- }
3156
- const _errs10 = errors;
3157
- let valid4 = true;
3158
- const _errs11 = errors;
4420
+ var _valid0 = _errs4 === errors;
4421
+ valid0 = _valid0;
4422
+ ifClause0 = "then";
4423
+ } else {
4424
+ const _errs20 = errors;
4425
+ const _errs21 = errors;
4426
+ let valid13 = true;
4427
+ const _errs22 = errors;
3159
4428
  if (data && typeof data == "object" && !Array.isArray(data)) {
3160
4429
  if (data.kind === void 0 && ("kind")) {
3161
- const err7 = {};
4430
+ const err8 = {};
3162
4431
  if (vErrors === null) {
3163
- vErrors = [err7];
4432
+ vErrors = [err8];
3164
4433
  } else {
3165
- vErrors.push(err7);
4434
+ vErrors.push(err8);
3166
4435
  }
3167
4436
  errors++;
3168
4437
  } else {
3169
4438
  if (data.kind !== void 0) {
3170
4439
  if ("state" !== data.kind) {
3171
- const err8 = {};
4440
+ const err9 = {};
3172
4441
  if (vErrors === null) {
3173
- vErrors = [err8];
4442
+ vErrors = [err9];
3174
4443
  } else {
3175
- vErrors.push(err8);
4444
+ vErrors.push(err9);
3176
4445
  }
3177
4446
  errors++;
3178
4447
  }
3179
4448
  }
3180
4449
  }
3181
4450
  }
3182
- var _valid1 = _errs11 === errors;
3183
- errors = _errs10;
4451
+ var _valid1 = _errs22 === errors;
4452
+ errors = _errs21;
3184
4453
  if (vErrors !== null) {
3185
- if (_errs10) {
3186
- vErrors.length = _errs10;
4454
+ if (_errs21) {
4455
+ vErrors.length = _errs21;
3187
4456
  } else {
3188
4457
  vErrors = null;
3189
4458
  }
3190
4459
  }
3191
4460
  let ifClause1;
3192
4461
  if (_valid1) {
3193
- const _errs13 = errors;
4462
+ const _errs24 = errors;
3194
4463
  if (data && typeof data == "object" && !Array.isArray(data)) {
3195
4464
  if (data.boxes !== void 0) {
3196
- let data2 = data.boxes;
3197
- if (Array.isArray(data2)) {
3198
- const len0 = data2.length;
3199
- for (let i0 = 0; i0 < len0; i0++) {
3200
- let data3 = data2[i0];
3201
- if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
3202
- if (data3.id !== void 0) {
3203
- let data4 = data3.id;
3204
- const _errs17 = errors;
3205
- const _errs18 = errors;
3206
- if (!(data4 === "start" || data4 === "finish")) {
3207
- const err9 = {};
4465
+ let data10 = data.boxes;
4466
+ if (Array.isArray(data10)) {
4467
+ if (data10.length < 1) {
4468
+ const err10 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4469
+ if (vErrors === null) {
4470
+ vErrors = [err10];
4471
+ } else {
4472
+ vErrors.push(err10);
4473
+ }
4474
+ errors++;
4475
+ }
4476
+ const len2 = data10.length;
4477
+ for (let i2 = 0; i2 < len2; i2++) {
4478
+ let data11 = data10[i2];
4479
+ if (data11 && typeof data11 == "object" && !Array.isArray(data11)) {
4480
+ if (data11.id !== void 0) {
4481
+ let data12 = data11.id;
4482
+ const _errs28 = errors;
4483
+ const _errs29 = errors;
4484
+ if (!(data12 === "start" || data12 === "finish")) {
4485
+ const err11 = {};
3208
4486
  if (vErrors === null) {
3209
- vErrors = [err9];
4487
+ vErrors = [err11];
3210
4488
  } else {
3211
- vErrors.push(err9);
4489
+ vErrors.push(err11);
3212
4490
  }
3213
4491
  errors++;
3214
4492
  }
3215
- var valid10 = _errs18 === errors;
3216
- if (valid10) {
3217
- const err10 = { instancePath: instancePath + "/boxes/" + i0 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
4493
+ var valid19 = _errs29 === errors;
4494
+ if (valid19) {
4495
+ const err12 = { instancePath: instancePath + "/boxes/" + i2 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
3218
4496
  if (vErrors === null) {
3219
- vErrors = [err10];
4497
+ vErrors = [err12];
3220
4498
  } else {
3221
- vErrors.push(err10);
4499
+ vErrors.push(err12);
3222
4500
  }
3223
4501
  errors++;
3224
4502
  } else {
3225
- errors = _errs17;
4503
+ errors = _errs28;
3226
4504
  if (vErrors !== null) {
3227
- if (_errs17) {
3228
- vErrors.length = _errs17;
4505
+ if (_errs28) {
4506
+ vErrors.length = _errs28;
3229
4507
  } else {
3230
4508
  vErrors = null;
3231
4509
  }
@@ -3236,241 +4514,449 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3236
4514
  }
3237
4515
  }
3238
4516
  }
4517
+ if (data.steps !== void 0) {
4518
+ let data13 = data.steps;
4519
+ if (Array.isArray(data13)) {
4520
+ const len3 = data13.length;
4521
+ for (let i3 = 0; i3 < len3; i3++) {
4522
+ let data14 = data13[i3];
4523
+ if (data14 && typeof data14 == "object" && !Array.isArray(data14)) {
4524
+ if (data14.events !== void 0) {
4525
+ let data15 = data14.events;
4526
+ if (Array.isArray(data15)) {
4527
+ const len4 = data15.length;
4528
+ for (let i4 = 0; i4 < len4; i4++) {
4529
+ let data16 = data15[i4];
4530
+ if (data16 && typeof data16 == "object" && !Array.isArray(data16)) {
4531
+ if (data16.type !== void 0) {
4532
+ let data17 = data16.type;
4533
+ const _errs36 = errors;
4534
+ const _errs37 = errors;
4535
+ if (!(data17 === "commit" || data17 === "branch")) {
4536
+ const err13 = {};
4537
+ if (vErrors === null) {
4538
+ vErrors = [err13];
4539
+ } else {
4540
+ vErrors.push(err13);
4541
+ }
4542
+ errors++;
4543
+ }
4544
+ var valid27 = _errs37 === errors;
4545
+ if (valid27) {
4546
+ const err14 = { instancePath: instancePath + "/steps/" + i3 + "/events/" + i4 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
4547
+ if (vErrors === null) {
4548
+ vErrors = [err14];
4549
+ } else {
4550
+ vErrors.push(err14);
4551
+ }
4552
+ errors++;
4553
+ } else {
4554
+ errors = _errs36;
4555
+ if (vErrors !== null) {
4556
+ if (_errs36) {
4557
+ vErrors.length = _errs36;
4558
+ } else {
4559
+ vErrors = null;
4560
+ }
4561
+ }
4562
+ }
4563
+ }
4564
+ }
4565
+ }
4566
+ }
4567
+ }
4568
+ }
4569
+ }
4570
+ }
4571
+ }
4572
+ if (data.git !== void 0) {
4573
+ const err15 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4574
+ if (vErrors === null) {
4575
+ vErrors = [err15];
4576
+ } else {
4577
+ vErrors.push(err15);
4578
+ }
4579
+ errors++;
4580
+ }
3239
4581
  }
3240
- var _valid1 = _errs13 === errors;
3241
- valid4 = _valid1;
4582
+ var _valid1 = _errs24 === errors;
4583
+ valid13 = _valid1;
3242
4584
  ifClause1 = "then";
3243
4585
  } else {
3244
- const _errs19 = errors;
3245
- const _errs20 = errors;
3246
- const _errs21 = errors;
4586
+ const _errs41 = errors;
4587
+ const _errs42 = errors;
4588
+ let valid29 = true;
4589
+ const _errs43 = errors;
3247
4590
  if (data && typeof data == "object" && !Array.isArray(data)) {
3248
- if (data.state === void 0 && ("state")) {
3249
- const err11 = {};
4591
+ if (data.kind === void 0 && ("kind")) {
4592
+ const err16 = {};
3250
4593
  if (vErrors === null) {
3251
- vErrors = [err11];
4594
+ vErrors = [err16];
3252
4595
  } else {
3253
- vErrors.push(err11);
4596
+ vErrors.push(err16);
3254
4597
  }
3255
4598
  errors++;
4599
+ } else {
4600
+ if (data.kind !== void 0) {
4601
+ if ("git" !== data.kind) {
4602
+ const err17 = {};
4603
+ if (vErrors === null) {
4604
+ vErrors = [err17];
4605
+ } else {
4606
+ vErrors.push(err17);
4607
+ }
4608
+ errors++;
4609
+ }
4610
+ }
3256
4611
  }
3257
4612
  }
3258
- var valid11 = _errs21 === errors;
3259
- if (valid11) {
3260
- const err12 = { instancePath, schemaPath: "#/else/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
3261
- if (vErrors === null) {
3262
- vErrors = [err12];
4613
+ var _valid2 = _errs43 === errors;
4614
+ errors = _errs42;
4615
+ if (vErrors !== null) {
4616
+ if (_errs42) {
4617
+ vErrors.length = _errs42;
3263
4618
  } else {
3264
- vErrors.push(err12);
4619
+ vErrors = null;
3265
4620
  }
3266
- errors++;
4621
+ }
4622
+ let ifClause2;
4623
+ if (_valid2) {
4624
+ const _errs45 = errors;
4625
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4626
+ if (data.git === void 0) {
4627
+ const err18 = { instancePath, schemaPath: "#/else/else/then/required", keyword: "required", params: { missingProperty: "git" }, message: "must have required property 'git'" };
4628
+ if (vErrors === null) {
4629
+ vErrors = [err18];
4630
+ } else {
4631
+ vErrors.push(err18);
4632
+ }
4633
+ errors++;
4634
+ }
4635
+ if (data.state !== void 0) {
4636
+ const err19 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4637
+ if (vErrors === null) {
4638
+ vErrors = [err19];
4639
+ } else {
4640
+ vErrors.push(err19);
4641
+ }
4642
+ errors++;
4643
+ }
4644
+ if (data.regions !== void 0) {
4645
+ const err20 = { instancePath: instancePath + "/regions", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4646
+ if (vErrors === null) {
4647
+ vErrors = [err20];
4648
+ } else {
4649
+ vErrors.push(err20);
4650
+ }
4651
+ errors++;
4652
+ }
4653
+ }
4654
+ var _valid2 = _errs45 === errors;
4655
+ valid29 = _valid2;
4656
+ ifClause2 = "then";
3267
4657
  } else {
3268
- errors = _errs20;
3269
- if (vErrors !== null) {
3270
- if (_errs20) {
3271
- vErrors.length = _errs20;
3272
- } else {
3273
- vErrors = null;
4658
+ const _errs52 = errors;
4659
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4660
+ if (data.boxes !== void 0) {
4661
+ let data22 = data.boxes;
4662
+ if (Array.isArray(data22)) {
4663
+ if (data22.length < 1) {
4664
+ const err21 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/else/else/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4665
+ if (vErrors === null) {
4666
+ vErrors = [err21];
4667
+ } else {
4668
+ vErrors.push(err21);
4669
+ }
4670
+ errors++;
4671
+ }
4672
+ }
4673
+ }
4674
+ if (data.steps !== void 0) {
4675
+ let data23 = data.steps;
4676
+ if (Array.isArray(data23)) {
4677
+ const len5 = data23.length;
4678
+ for (let i5 = 0; i5 < len5; i5++) {
4679
+ let data24 = data23[i5];
4680
+ if (data24 && typeof data24 == "object" && !Array.isArray(data24)) {
4681
+ if (data24.events !== void 0) {
4682
+ let data25 = data24.events;
4683
+ if (Array.isArray(data25)) {
4684
+ const len6 = data25.length;
4685
+ for (let i6 = 0; i6 < len6; i6++) {
4686
+ let data26 = data25[i6];
4687
+ if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
4688
+ if (data26.type !== void 0) {
4689
+ let data27 = data26.type;
4690
+ const _errs60 = errors;
4691
+ const _errs61 = errors;
4692
+ if (!(data27 === "commit" || data27 === "branch")) {
4693
+ const err22 = {};
4694
+ if (vErrors === null) {
4695
+ vErrors = [err22];
4696
+ } else {
4697
+ vErrors.push(err22);
4698
+ }
4699
+ errors++;
4700
+ }
4701
+ var valid42 = _errs61 === errors;
4702
+ if (valid42) {
4703
+ const err23 = { instancePath: instancePath + "/steps/" + i5 + "/events/" + i6 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
4704
+ if (vErrors === null) {
4705
+ vErrors = [err23];
4706
+ } else {
4707
+ vErrors.push(err23);
4708
+ }
4709
+ errors++;
4710
+ } else {
4711
+ errors = _errs60;
4712
+ if (vErrors !== null) {
4713
+ if (_errs60) {
4714
+ vErrors.length = _errs60;
4715
+ } else {
4716
+ vErrors = null;
4717
+ }
4718
+ }
4719
+ }
4720
+ }
4721
+ }
4722
+ }
4723
+ }
4724
+ }
4725
+ }
4726
+ }
4727
+ }
4728
+ }
4729
+ if (data.state !== void 0) {
4730
+ const err24 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4731
+ if (vErrors === null) {
4732
+ vErrors = [err24];
4733
+ } else {
4734
+ vErrors.push(err24);
4735
+ }
4736
+ errors++;
4737
+ }
4738
+ if (data.git !== void 0) {
4739
+ const err25 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4740
+ if (vErrors === null) {
4741
+ vErrors = [err25];
4742
+ } else {
4743
+ vErrors.push(err25);
4744
+ }
4745
+ errors++;
3274
4746
  }
3275
4747
  }
4748
+ var _valid2 = _errs52 === errors;
4749
+ valid29 = _valid2;
4750
+ ifClause2 = "else";
4751
+ }
4752
+ if (!valid29) {
4753
+ const err26 = { instancePath, schemaPath: "#/else/else/if", keyword: "if", params: { failingKeyword: ifClause2 }, message: 'must match "' + ifClause2 + '" schema' };
4754
+ if (vErrors === null) {
4755
+ vErrors = [err26];
4756
+ } else {
4757
+ vErrors.push(err26);
4758
+ }
4759
+ errors++;
3276
4760
  }
3277
- var _valid1 = _errs19 === errors;
3278
- valid4 = _valid1;
4761
+ var _valid1 = _errs41 === errors;
4762
+ valid13 = _valid1;
3279
4763
  ifClause1 = "else";
3280
4764
  }
3281
- if (!valid4) {
3282
- const err13 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
4765
+ if (!valid13) {
4766
+ const err27 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
3283
4767
  if (vErrors === null) {
3284
- vErrors = [err13];
4768
+ vErrors = [err27];
3285
4769
  } else {
3286
- vErrors.push(err13);
4770
+ vErrors.push(err27);
3287
4771
  }
3288
4772
  errors++;
3289
4773
  }
3290
- var _valid0 = _errs7 === errors;
4774
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4775
+ if (data.sequence !== void 0) {
4776
+ const err28 = { instancePath: instancePath + "/sequence", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4777
+ if (vErrors === null) {
4778
+ vErrors = [err28];
4779
+ } else {
4780
+ vErrors.push(err28);
4781
+ }
4782
+ errors++;
4783
+ }
4784
+ }
4785
+ var _valid0 = _errs20 === errors;
3291
4786
  valid0 = _valid0;
3292
4787
  ifClause0 = "else";
3293
4788
  }
3294
4789
  if (!valid0) {
3295
- const err14 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
4790
+ const err29 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
3296
4791
  if (vErrors === null) {
3297
- vErrors = [err14];
4792
+ vErrors = [err29];
3298
4793
  } else {
3299
- vErrors.push(err14);
4794
+ vErrors.push(err29);
3300
4795
  }
3301
4796
  errors++;
3302
4797
  }
3303
4798
  if (data && typeof data == "object" && !Array.isArray(data)) {
3304
4799
  if (data.version === void 0) {
3305
- const err15 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
4800
+ const err30 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
3306
4801
  if (vErrors === null) {
3307
- vErrors = [err15];
4802
+ vErrors = [err30];
3308
4803
  } else {
3309
- vErrors.push(err15);
4804
+ vErrors.push(err30);
3310
4805
  }
3311
4806
  errors++;
3312
4807
  }
3313
4808
  if (data.kind === void 0) {
3314
- const err16 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
4809
+ const err31 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
3315
4810
  if (vErrors === null) {
3316
- vErrors = [err16];
4811
+ vErrors = [err31];
3317
4812
  } else {
3318
- vErrors.push(err16);
4813
+ vErrors.push(err31);
3319
4814
  }
3320
4815
  errors++;
3321
4816
  }
3322
4817
  if (data.title === void 0) {
3323
- const err17 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
4818
+ const err32 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
3324
4819
  if (vErrors === null) {
3325
- vErrors = [err17];
4820
+ vErrors = [err32];
3326
4821
  } else {
3327
- vErrors.push(err17);
4822
+ vErrors.push(err32);
3328
4823
  }
3329
4824
  errors++;
3330
4825
  }
3331
4826
  if (data.boxes === void 0) {
3332
- const err18 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
4827
+ const err33 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
3333
4828
  if (vErrors === null) {
3334
- vErrors = [err18];
4829
+ vErrors = [err33];
3335
4830
  } else {
3336
- vErrors.push(err18);
4831
+ vErrors.push(err33);
3337
4832
  }
3338
4833
  errors++;
3339
4834
  }
3340
4835
  if (data.steps === void 0) {
3341
- const err19 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
4836
+ const err34 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
3342
4837
  if (vErrors === null) {
3343
- vErrors = [err19];
4838
+ vErrors = [err34];
3344
4839
  } else {
3345
- vErrors.push(err19);
4840
+ vErrors.push(err34);
3346
4841
  }
3347
4842
  errors++;
3348
4843
  }
3349
4844
  for (const key0 in data) {
3350
4845
  if (!func2.call(schema11.properties, key0)) {
3351
- const err20 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
4846
+ const err35 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
3352
4847
  if (vErrors === null) {
3353
- vErrors = [err20];
4848
+ vErrors = [err35];
3354
4849
  } else {
3355
- vErrors.push(err20);
4850
+ vErrors.push(err35);
3356
4851
  }
3357
4852
  errors++;
3358
4853
  }
3359
4854
  }
3360
4855
  if (data.version !== void 0) {
3361
- let data5 = data.version;
3362
- if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) {
3363
- const err21 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
4856
+ let data31 = data.version;
4857
+ if (!(typeof data31 == "number" && (!(data31 % 1) && !isNaN(data31)) && isFinite(data31))) {
4858
+ const err36 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
3364
4859
  if (vErrors === null) {
3365
- vErrors = [err21];
4860
+ vErrors = [err36];
3366
4861
  } else {
3367
- vErrors.push(err21);
4862
+ vErrors.push(err36);
3368
4863
  }
3369
4864
  errors++;
3370
4865
  }
3371
- if (typeof data5 == "number" && isFinite(data5)) {
3372
- if (data5 < 1 || isNaN(data5)) {
3373
- const err22 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
4866
+ if (typeof data31 == "number" && isFinite(data31)) {
4867
+ if (data31 < 1 || isNaN(data31)) {
4868
+ const err37 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
3374
4869
  if (vErrors === null) {
3375
- vErrors = [err22];
4870
+ vErrors = [err37];
3376
4871
  } else {
3377
- vErrors.push(err22);
4872
+ vErrors.push(err37);
3378
4873
  }
3379
4874
  errors++;
3380
4875
  }
3381
4876
  }
3382
4877
  }
3383
4878
  if (data.kind !== void 0) {
3384
- let data6 = data.kind;
3385
- if (!(data6 === "sequence" || data6 === "architecture" || data6 === "state")) {
3386
- const err23 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema11.properties.kind.enum }, message: "must be equal to one of the allowed values" };
4879
+ let data32 = data.kind;
4880
+ if (!(data32 === "sequence" || data32 === "architecture" || data32 === "state" || data32 === "git")) {
4881
+ const err38 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema11.properties.kind.enum }, message: "must be equal to one of the allowed values" };
3387
4882
  if (vErrors === null) {
3388
- vErrors = [err23];
4883
+ vErrors = [err38];
3389
4884
  } else {
3390
- vErrors.push(err23);
4885
+ vErrors.push(err38);
3391
4886
  }
3392
4887
  errors++;
3393
4888
  }
3394
4889
  }
3395
4890
  if (data.title !== void 0) {
3396
- let data7 = data.title;
3397
- if (typeof data7 === "string") {
3398
- if (func3(data7) < 1) {
3399
- const err24 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
4891
+ let data33 = data.title;
4892
+ if (typeof data33 === "string") {
4893
+ if (func3(data33) < 1) {
4894
+ const err39 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3400
4895
  if (vErrors === null) {
3401
- vErrors = [err24];
4896
+ vErrors = [err39];
3402
4897
  } else {
3403
- vErrors.push(err24);
4898
+ vErrors.push(err39);
3404
4899
  }
3405
4900
  errors++;
3406
4901
  }
3407
4902
  } else {
3408
- const err25 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4903
+ const err40 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3409
4904
  if (vErrors === null) {
3410
- vErrors = [err25];
4905
+ vErrors = [err40];
3411
4906
  } else {
3412
- vErrors.push(err25);
4907
+ vErrors.push(err40);
3413
4908
  }
3414
4909
  errors++;
3415
4910
  }
3416
4911
  }
3417
4912
  if (data.view !== void 0) {
3418
- let data8 = data.view;
3419
- if (!(data8 === "fixed" || data8 === "follow")) {
3420
- const err26 = { instancePath: instancePath + "/view", schemaPath: "#/properties/view/enum", keyword: "enum", params: { allowedValues: schema11.properties.view.enum }, message: "must be equal to one of the allowed values" };
4913
+ let data34 = data.view;
4914
+ if (!(data34 === "fixed" || data34 === "follow")) {
4915
+ const err41 = { instancePath: instancePath + "/view", schemaPath: "#/properties/view/enum", keyword: "enum", params: { allowedValues: schema11.properties.view.enum }, message: "must be equal to one of the allowed values" };
3421
4916
  if (vErrors === null) {
3422
- vErrors = [err26];
4917
+ vErrors = [err41];
3423
4918
  } else {
3424
- vErrors.push(err26);
4919
+ vErrors.push(err41);
3425
4920
  }
3426
4921
  errors++;
3427
4922
  }
3428
4923
  }
3429
4924
  if (data.regions !== void 0) {
3430
- let data9 = data.regions;
3431
- if (Array.isArray(data9)) {
3432
- const len1 = data9.length;
3433
- for (let i1 = 0; i1 < len1; i1++) {
3434
- if (!validate11(data9[i1], { instancePath: instancePath + "/regions/" + i1, parentData: data9, parentDataProperty: i1, rootData })) {
4925
+ let data35 = data.regions;
4926
+ if (Array.isArray(data35)) {
4927
+ const len7 = data35.length;
4928
+ for (let i7 = 0; i7 < len7; i7++) {
4929
+ if (!validate11(data35[i7], { instancePath: instancePath + "/regions/" + i7, parentData: data35, parentDataProperty: i7, rootData })) {
3435
4930
  vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
3436
4931
  errors = vErrors.length;
3437
4932
  }
3438
4933
  }
3439
4934
  } else {
3440
- const err27 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4935
+ const err42 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3441
4936
  if (vErrors === null) {
3442
- vErrors = [err27];
4937
+ vErrors = [err42];
3443
4938
  } else {
3444
- vErrors.push(err27);
4939
+ vErrors.push(err42);
3445
4940
  }
3446
4941
  errors++;
3447
4942
  }
3448
4943
  }
3449
4944
  if (data.boxes !== void 0) {
3450
- let data11 = data.boxes;
3451
- if (Array.isArray(data11)) {
3452
- if (data11.length < 1) {
3453
- const err28 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
3454
- if (vErrors === null) {
3455
- vErrors = [err28];
3456
- } else {
3457
- vErrors.push(err28);
3458
- }
3459
- errors++;
3460
- }
3461
- const len2 = data11.length;
3462
- for (let i2 = 0; i2 < len2; i2++) {
3463
- if (!validate13(data11[i2], { instancePath: instancePath + "/boxes/" + i2, parentData: data11, parentDataProperty: i2, rootData })) {
4945
+ let data37 = data.boxes;
4946
+ if (Array.isArray(data37)) {
4947
+ const len8 = data37.length;
4948
+ for (let i8 = 0; i8 < len8; i8++) {
4949
+ if (!validate13(data37[i8], { instancePath: instancePath + "/boxes/" + i8, parentData: data37, parentDataProperty: i8, rootData })) {
3464
4950
  vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
3465
4951
  errors = vErrors.length;
3466
4952
  }
3467
4953
  }
3468
4954
  } else {
3469
- const err29 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4955
+ const err43 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3470
4956
  if (vErrors === null) {
3471
- vErrors = [err29];
4957
+ vErrors = [err43];
3472
4958
  } else {
3473
- vErrors.push(err29);
4959
+ vErrors.push(err43);
3474
4960
  }
3475
4961
  errors++;
3476
4962
  }
@@ -3482,30 +4968,30 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3482
4968
  }
3483
4969
  }
3484
4970
  if (data.steps !== void 0) {
3485
- let data14 = data.steps;
3486
- if (Array.isArray(data14)) {
3487
- if (data14.length < 1) {
3488
- const err30 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4971
+ let data40 = data.steps;
4972
+ if (Array.isArray(data40)) {
4973
+ if (data40.length < 1) {
4974
+ const err44 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
3489
4975
  if (vErrors === null) {
3490
- vErrors = [err30];
4976
+ vErrors = [err44];
3491
4977
  } else {
3492
- vErrors.push(err30);
4978
+ vErrors.push(err44);
3493
4979
  }
3494
4980
  errors++;
3495
4981
  }
3496
- const len3 = data14.length;
3497
- for (let i3 = 0; i3 < len3; i3++) {
3498
- if (!validate17(data14[i3], { instancePath: instancePath + "/steps/" + i3, parentData: data14, parentDataProperty: i3, rootData })) {
4982
+ const len9 = data40.length;
4983
+ for (let i9 = 0; i9 < len9; i9++) {
4984
+ if (!validate17(data40[i9], { instancePath: instancePath + "/steps/" + i9, parentData: data40, parentDataProperty: i9, rootData })) {
3499
4985
  vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
3500
4986
  errors = vErrors.length;
3501
4987
  }
3502
4988
  }
3503
4989
  } else {
3504
- const err31 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4990
+ const err45 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3505
4991
  if (vErrors === null) {
3506
- vErrors = [err31];
4992
+ vErrors = [err45];
3507
4993
  } else {
3508
- vErrors.push(err31);
4994
+ vErrors.push(err45);
3509
4995
  }
3510
4996
  errors++;
3511
4997
  }
@@ -3522,12 +5008,18 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3522
5008
  errors = vErrors.length;
3523
5009
  }
3524
5010
  }
5011
+ if (data.git !== void 0) {
5012
+ if (!validate29(data.git, { instancePath: instancePath + "/git", parentData: data, parentDataProperty: "git", rootData })) {
5013
+ vErrors = vErrors === null ? validate29.errors : vErrors.concat(validate29.errors);
5014
+ errors = vErrors.length;
5015
+ }
5016
+ }
3525
5017
  } else {
3526
- const err32 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
5018
+ const err46 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3527
5019
  if (vErrors === null) {
3528
- vErrors = [err32];
5020
+ vErrors = [err46];
3529
5021
  } else {
3530
- vErrors.push(err32);
5022
+ vErrors.push(err46);
3531
5023
  }
3532
5024
  errors++;
3533
5025
  }
@@ -3537,17 +5029,17 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3537
5029
 
3538
5030
  // src/schema.ts
3539
5031
  var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
3540
- var EVENT_TYPES = ["edge", "action", "swap", "strip"];
3541
- var ROOT_NOT_ALLOWED = {
3542
- "#/else/not": { field: "sequence", kind: "sequence" },
3543
- "#/then/not": { field: "state", kind: "state" },
3544
- "#/else/else/not": { field: "state", kind: "state" }
3545
- };
5032
+ var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch"];
5033
+ var ABSENT = "#/definitions/absent/not";
5034
+ var ABSENT_KINDS = { regions: "sequence / architecture / state" };
3546
5035
  var NOT_ALLOWED = {
3547
5036
  carry: { field: "text", kind: "tag" }
3548
5037
  };
3549
5038
  var RESERVED_ID = /\/boxes\/items\/properties\/id\/not$/u;
5039
+ var GIT_EVENT = /\/events\/items\/properties\/type\/not$/u;
5040
+ var GIT_EVENTS = ["commit", "branch"];
3550
5041
  var escape = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
5042
+ var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
3551
5043
  function forbiddenOf(pattern) {
3552
5044
  const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
3553
5045
  if (inside === void 0) return void 0;
@@ -3571,7 +5063,10 @@ function toFieldError(error, errors, m) {
3571
5063
  }
3572
5064
  case "not": {
3573
5065
  if (RESERVED_ID.test(error.schemaPath)) return { pointer: at2, message: m.reserved(STATE_ENDS) };
3574
- const allowed = at2 === "" ? ROOT_NOT_ALLOWED[error.schemaPath] : NOT_ALLOWED[at2.slice(at2.lastIndexOf("/") + 1)];
5066
+ if (GIT_EVENT.test(error.schemaPath)) return { pointer: at2, message: m.kindOnly(GIT_EVENTS, "git") };
5067
+ const last = at2.slice(at2.lastIndexOf("/") + 1);
5068
+ if (error.schemaPath === ABSENT) return { pointer: at2, message: m.not({ field: last, kind: ABSENT_KINDS[last] ?? last }) };
5069
+ const allowed = NOT_ALLOWED[last];
3575
5070
  return { pointer: allowed ? `${at2}/${allowed.field}` : at2, message: m.not(allowed) };
3576
5071
  }
3577
5072
  case "anyOf": {
@@ -3589,8 +5084,10 @@ function toFieldError(error, errors, m) {
3589
5084
  return { pointer: at2, message: m.type(String(params.type)) };
3590
5085
  case "minLength":
3591
5086
  return { pointer: at2, message: m.minLength(Number(params.limit)) };
3592
- case "pattern":
3593
- return { pointer: at2, message: m.pattern(forbiddenOf(String(params.pattern))) };
5087
+ case "pattern": {
5088
+ const hex2 = HEX.exec(String(params.pattern));
5089
+ return { pointer: at2, message: hex2 ? m.hex(Number(hex2[1]), Number(hex2[2])) : m.pattern(forbiddenOf(String(params.pattern))) };
5090
+ }
3594
5091
  case "minItems":
3595
5092
  return { pointer: at2, message: m.minItems(Number(params.limit)) };
3596
5093
  case "minimum":
@@ -3638,7 +5135,15 @@ function plan(step) {
3638
5135
  let arrived;
3639
5136
  let changes = 0;
3640
5137
  step.events.forEach((event, e) => {
3641
- if (event.type === "edge") {
5138
+ if (event.type === "commit" || event.type === "branch") {
5139
+ const a = cursor;
5140
+ const b = a + MOTION.draw;
5141
+ out.edges.push({ event: e, a, b, carries: false, coin: false, named: false });
5142
+ cursor = a + MOTION.stagger;
5143
+ arrived = b;
5144
+ changes = 0;
5145
+ out.busy = Math.max(out.busy, b);
5146
+ } else if (event.type === "edge") {
3642
5147
  const carries = event.carry.kind !== "none";
3643
5148
  const a = cursor;
3644
5149
  const b = a + (carries ? MOTION.drawCarry : MOTION.draw);
@@ -3683,7 +5188,9 @@ function buildTimeline(diagram) {
3683
5188
  for (const edge2 of p.edges) {
3684
5189
  const a = span.start + edge2.a;
3685
5190
  edges.push({ step: s, event: edge2.event, start: a, drawn: span.start + edge2.b, end: span.end });
3686
- if (edge2.carries) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
5191
+ const event = diagram.steps[s]?.events[edge2.event];
5192
+ const own = diagram.kind === "git" && event?.type === "edge" && event.carry.kind === "tag" && event.carry.text === event.from;
5193
+ if (edge2.carries && !own) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
3687
5194
  if (edge2.named) named.push({ step: s, event: edge2.event, start: a + MOTION.labelDelay, end: span.end });
3688
5195
  }
3689
5196
  named.forEach((label2, k) => {
@@ -3792,6 +5299,38 @@ var ICONS = {
3792
5299
  block: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2.5 h22 M -6 2.5 h8"
3793
5300
  };
3794
5301
 
5302
+ // src/render/ink.ts
5303
+ var ALWAYS = [[0, Number.POSITIVE_INFINITY]];
5304
+ var BITE = 0.5;
5305
+ var visible = (item, t) => item.shown.some(([a, b]) => a <= t && t < b);
5306
+ var spotOf = (ink) => ({ text: ink.text, rect: { x: ink.rect.x, y: ink.rect.y, w: ink.rect.w, h: ink.rect.h }, badge: ink.badge === true, ...ink.part ? { part: ink.part } : {} });
5307
+ function findOverlaps(inks, stills, traces = []) {
5308
+ const out = [];
5309
+ stills.forEach((t, step) => {
5310
+ const seen = inks.filter((ink) => visible(ink, t));
5311
+ seen.forEach((a, i) => {
5312
+ for (const b of seen.slice(i + 1)) {
5313
+ const w = Math.min(a.rect.x + a.rect.w, b.rect.x + b.rect.w) - Math.max(a.rect.x, b.rect.x);
5314
+ const h = Math.min(a.rect.y + a.rect.h, b.rect.y + b.rect.h) - Math.max(a.rect.y, b.rect.y);
5315
+ if (w > BITE && h > BITE) out.push({ kind: "texts", step, texts: [a.text, b.text], spots: [spotOf(a), spotOf(b)] });
5316
+ }
5317
+ });
5318
+ const lines = traces.filter((trace) => visible(trace, t));
5319
+ for (const ink of seen) {
5320
+ if (ink.boxed) continue;
5321
+ for (const line of lines) if (crossesRect(line.points, ink.rect, BITE)) out.push({ kind: "line", step, text: ink.text, line: { from: line.from, to: line.to }, spots: [spotOf(ink)] });
5322
+ }
5323
+ });
5324
+ return out;
5325
+ }
5326
+ function describeOverlap(overlap, lang = "ja") {
5327
+ const t = FIGURE_TEXT[lang];
5328
+ const partName = (part) => part.kind === "icon" ? t.iconOf(part.box) : part.kind === "coin" ? t.coin : t.envelope;
5329
+ const name = (spot) => spot.badge ? t.badgeName(spot.text) : spot.part ? partName(spot.part) : t.quoted(spot.text);
5330
+ if (overlap.kind === "texts") return t.textsOverlap(name(overlap.spots[0]), name(overlap.spots[1]));
5331
+ return t.lineCrosses(overlap.line.from, overlap.line.to, name(overlap.spots[0]));
5332
+ }
5333
+
3795
5334
  // src/render/parts.ts
3796
5335
  var esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3797
5336
  var r1 = (v) => Math.round(v * 100) / 100;
@@ -3828,6 +5367,10 @@ function arrowHead(points) {
3828
5367
  const { arrow: a, arrowHalf: h } = LOOK.edge;
3829
5368
  return `M ${r1(ex - dx * a - dy * h)} ${r1(ey - dy * a + dx * h)} L ${r1(ex)} ${r1(ey)} L ${r1(ex - dx * a + dy * h)} ${r1(ey - dy * a - dx * h)}`;
3830
5369
  }
5370
+ function write(ink, cls, x, y, text2, style, shown = ALWAYS, anchor) {
5371
+ ink?.push({ text: text2, rect: textBox(text2, x, y, style, anchor), shown });
5372
+ return `<text class="${cls}" x="${r1(x)}" y="${r1(y)}"${anchor ? ` text-anchor="${anchor}"` : ""}>${esc(text2)}</text>`;
5373
+ }
3831
5374
  function rangeKf(m, ranges2) {
3832
5375
  const pts = [[0, { opacity: 0 }]];
3833
5376
  for (const [a, b] of ranges2) pts.push([a, { opacity: 0 }, EASE.out], [a + MOTION.fade, { opacity: 1 }], [b - 0.1, { opacity: 1 }, EASE.inOut], [b + 0.25, { opacity: 0 }]);
@@ -3844,21 +5387,22 @@ function activeKf(ctx, on) {
3844
5387
  }
3845
5388
  return rangeKf(ctx.m, ranges2);
3846
5389
  }
3847
- function band(region) {
5390
+ function band(region, ink) {
3848
5391
  const { radius, icon, iconRadius, iconScale, nameY, line } = LOOK.region;
3849
5392
  const { x, y } = region.header;
3850
- const lines = region.lines.map((t, k) => `<text class="dg-bz" x="${r1(x)}" y="${r1(region.y + nameY + k * line)}">${esc(t)}</text>`).join("");
3851
- const note = region.note ? `<text class="dg-bx" x="${r1(x)}" y="${r1(region.y + nameY + region.lines.length * line + 1)}">${esc(region.note)}</text>` : "";
5393
+ const lines = region.lines.map((t, k) => write(ink, "dg-bz", x, region.y + nameY + k * line, t, TYPE.regionName)).join("");
5394
+ const note = region.note ? write(ink, "dg-bx", x, region.y + nameY + region.lines.length * line + 1, region.note, TYPE.regionNote) : "";
3852
5395
  const mark = region.icon && ICONS[region.icon] ? `<rect class="dg-bi" x="${r1(x)}" y="${r1(y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(region.icon, x + icon / 2, y + icon / 2, iconScale)}` : "";
3853
5396
  return `<g style="${cs(region.color)}"><rect class="dg-band" x="${r1(region.x + 0.5)}" y="${r1(region.y + 0.5)}" width="${r1(region.w - 1)}" height="${r1(region.h - 1)}" rx="${radius}"/>${mark}${lines}${note}</g>`;
3854
5397
  }
3855
- function subLines(box, m, changes, y) {
5398
+ function subLines(box, m, changes, y, ink) {
3856
5399
  const seq = [[0, box.sub ?? "", "dg-ss"], ...changes];
3857
5400
  return seq.map(([t, text2, cls], k) => {
3858
5401
  const next = seq[k + 1]?.[0];
3859
5402
  const anim = k === 0 ? next === void 0 ? "" : m.until(next - MOTION.untilFade) : next === void 0 ? m.rise(t) : m.rise(t, next - MOTION.untilFade);
3860
5403
  if (text2 === "") return "";
3861
- return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}><text class="${cls}" x="${r1(box.cx)}" y="${r1(y)}" text-anchor="middle">${esc(text2)}</text></g>`;
5404
+ const shown = [[k === 0 ? 0 : t, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]];
5405
+ return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}>${write(ink, cls, box.cx, y, text2, cls === "dg-ss" ? TYPE.boxSub : TYPE.boxSubStrong, shown, "middle")}</g>`;
3862
5406
  }).join("");
3863
5407
  }
3864
5408
  function cardFrame(box, ctx, act, y, h) {
@@ -3867,10 +5411,17 @@ function cardFrame(box, ctx, act, y, h) {
3867
5411
  }
3868
5412
  function card(box, ctx, on, changes, lit) {
3869
5413
  const { icon, iconRadius, iconScale, iconY, nameY, subY } = LOOK.box;
3870
- const subs = subLines(box, ctx.m, changes, box.cy + subY);
5414
+ const subs = subLines(box, ctx.m, changes, box.cy + subY, ctx.ink);
3871
5415
  const act = lit ? lit.length > 0 ? rangeKf(ctx.m, lit.map((s) => [s.start, s.end])) : void 0 : on.length > 0 ? activeKf(ctx, on) : void 0;
3872
- const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(box.cx - icon / 2)}" y="${r1(box.cy + iconY - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, box.cx, box.cy + iconY, iconScale)}` : "";
3873
- return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${mark}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(box.cy + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
5416
+ const ix = box.iconX ?? box.cx;
5417
+ const slot = box.slot ? `<rect class="dg-slot" x="${r1(box.slot.x)}" y="${r1(box.slot.y)}" width="${r1(box.slot.w)}" height="${r1(box.slot.h)}" rx="${LOOK.slot.radius}"/>` : "";
5418
+ let mark = "";
5419
+ if (box.icon && ICONS[box.icon]) {
5420
+ const rect = { x: ix - icon / 2, y: box.cy + iconY - icon / 2, w: icon, h: icon };
5421
+ ctx.ink.push({ text: `${box.name} \u306E\u7D75\u67C4`, rect, shown: ALWAYS, boxed: true, part: { kind: "icon", box: box.name } });
5422
+ mark = `<rect class="dg-ic" x="${r1(rect.x)}" y="${r1(rect.y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy + iconY, iconScale)}`;
5423
+ }
5424
+ return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${slot}${mark}${write(ctx.ink, "dg-sn", box.cx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "middle")}${subs}</g>`;
3874
5425
  }
3875
5426
  function headCard(box, ctx, on, changes) {
3876
5427
  const { pad: pad2, h, nameY, subY } = LOOK.follow.head;
@@ -3878,15 +5429,15 @@ function headCard(box, ctx, on, changes) {
3878
5429
  const act = on.length > 0 ? activeKf(ctx, on) : void 0;
3879
5430
  return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, pad2, h)}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(pad2 + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
3880
5431
  }
3881
- function ghostCard(box) {
5432
+ function ghostCard(box, ink) {
3882
5433
  const { icon, iconRadius, iconScale, radius } = LOOK.box;
3883
5434
  const G = LOOK.state.ghost;
3884
5435
  const ix = box.x + G.pad + icon / 2;
3885
5436
  const tx = box.x + G.pad + icon + G.gap;
3886
5437
  const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(ix - icon / 2)}" y="${r1(box.cy - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy, iconScale)}` : "";
3887
5438
  const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
3888
- const sub = box.sub ? `<text class="dg-ss" x="${r1(tx)}" y="${r1(box.cy + G.subY)}" text-anchor="start">${esc(box.sub)}</text>` : "";
3889
- return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}<text class="dg-sn" x="${r1(tx)}" y="${r1(box.cy + nameY)}" text-anchor="start">${esc(box.name)}</text>${sub}</g>`;
5439
+ const sub = box.sub ? write(ink, "dg-ss", tx, box.cy + G.subY, box.sub, TYPE.boxSub, ALWAYS, "start") : "";
5440
+ return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}${write(ink, "dg-sn", tx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "start")}${sub}</g>`;
3890
5441
  }
3891
5442
  function doneMark(box, at2, ctx) {
3892
5443
  const { r, inset } = LOOK.state.done;
@@ -3894,19 +5445,22 @@ function doneMark(box, at2, ctx) {
3894
5445
  const y = box.y + inset;
3895
5446
  return `<g class="dg-popc dg-a" data-done="${esc(box.id)}" style="${cs(box.color)};${ctx.m.pop(at2)}"><circle class="dg-done" cx="${r1(x)}" cy="${r1(y)}" r="${r}"/>${glyph("check", x, y, 0.5, "dg-done-ck")}</g>`;
3896
5447
  }
3897
- function path(p, color) {
3898
- const label2 = p.label ? `<text class="dg-path-t${p.label.family === "sans" ? " dg-path-tj" : ""}" x="${r1(p.label.x + LOOK.label.padX)}" y="${r1(p.label.y + p.label.h / 2 + LOOK.baseline.label)}">${esc(p.label.text)}</text>` : "";
5448
+ function path(p, color, ink, traces) {
5449
+ traces.push({ from: p.from, to: p.to, points: p.points, shown: ALWAYS });
5450
+ const sans = p.label?.family === "sans";
5451
+ const label2 = p.label ? write(ink, `dg-path-t${sans ? " dg-path-tj" : ""}`, p.label.x + LOOK.label.padX, p.label.y + p.label.h / 2 + LOOK.baseline.label, p.label.text, sans ? TYPE.labelJa : TYPE.label) : "";
3899
5452
  return `<g data-path="${esc(`${p.from}->${p.to}`)}" style="${cs(color)}"><path class="dg-path" d="${pathOf(p.points)}"/><path class="dg-path-h" d="${arrowHead(p.points)}"/>${label2}</g>`;
3900
5453
  }
3901
- function side(s, color) {
5454
+ function side(s, color, ink) {
3902
5455
  const { pad: pad2 } = LOOK.state.side;
3903
5456
  const title = s.y + pad2 + TYPE.regionName.size;
3904
- const notes = s.notes.map((note, k) => `<text class="dg-side-n" x="${r1(s.x + pad2)}" y="${r1(title + LOOK.region.line * (k + 1))}">${esc(note)}</text>`).join("");
3905
- return `<g style="${cs(color)}"><rect class="dg-side" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}"/><text class="dg-side-t" x="${r1(s.x + pad2)}" y="${r1(title)}">${esc(s.title)}</text>${notes}</g>`;
5457
+ const notes = s.notes.map((note, k) => write(ink, "dg-side-n", s.x + pad2, title + LOOK.region.line * (k + 1), note, TYPE.regionNote)).join("");
5458
+ return `<g style="${cs(color)}"><rect class="dg-side" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}"/>${write(ink, "dg-side-t", s.x + pad2, title, s.title, TYPE.regionName)}${notes}</g>`;
3906
5459
  }
3907
- function endMark(e, color) {
5460
+ function endMark(e, color, ink) {
3908
5461
  const { end } = LOOK.state;
3909
- const text2 = e.text === "" ? "" : `<text class="dg-mark" x="${r1(e.x + LOOK.state.text)}" y="${r1(e.y + LOOK.baseline.mark)}">${esc(e.text)}</text>`;
5462
+ const at2 = markText(e);
5463
+ const text2 = e.text === "" ? "" : write(ink, "dg-mark", at2[0], at2[1], e.text, TYPE.regionNote);
3910
5464
  const x = r1(e.x);
3911
5465
  const y = r1(e.y);
3912
5466
  if (e.kind === "start") return `<g data-end="start"><circle class="dg-start" cx="${x}" cy="${y}" r="${e.r}"/>${text2}</g>`;
@@ -3918,6 +5472,7 @@ function lifeline(x, y1, y2) {
3918
5472
  }
3919
5473
  function edge(e, time, ctx, past = false) {
3920
5474
  const { m } = ctx;
5475
+ ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: ALWAYS });
3921
5476
  const d = pathOf(e.points);
3922
5477
  const head = arrowHead(e.points);
3923
5478
  const { start: a, drawn: b, end } = time;
@@ -3961,12 +5516,15 @@ function edge(e, time, ctx, past = false) {
3961
5516
  function label(l, time, ctx) {
3962
5517
  const ja3 = l.family === "sans" ? " dg-capj" : "";
3963
5518
  const { radius } = LOOK.label;
5519
+ ctx.ink.push({ text: l.text, rect: l, shown: [[time.start, time.end]], boxed: true });
5520
+ if (time.after) ctx.ink.push({ text: l.text, rect: textBox(l.text, l.x + l.w / 2, l.y + l.h / 2 + LOOK.baseline.label, l.family === "sans" ? TYPE.labelJa : TYPE.label, "middle"), shown: [[time.after.start, time.after.end]] });
3964
5521
  const x = r1(l.x + l.w / 2);
3965
5522
  const y = r1(l.y + l.h / 2 + LOOK.baseline.label);
3966
5523
  const past = time.after ? `<g class="dg-cap-past${l.family === "sans" ? " dg-cap-pastj" : ""} dg-a" style="${ctx.m.vis(time.after.start, time.after.end)}"><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>` : "";
3967
5524
  return `${past}<g class="dg-cap${ja3} dg-a" style="${cs(l.color)};${ctx.m.rise(time.start, time.end, true)}"><rect x="${r1(l.x)}" y="${r1(l.y)}" width="${r1(l.w)}" height="${l.h}" rx="${radius}"/><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>`;
3968
5525
  }
3969
5526
  function action(a, at2, until, ctx) {
5527
+ ctx.ink.push({ text: a.text, rect: a, shown: [[at2, until]], boxed: true });
3970
5528
  return `<g class="dg-act dg-a" style="${cs(a.color)};${ctx.m.rise(at2, until, true)}"><rect x="${r1(a.x)}" y="${r1(a.y)}" width="${r1(a.w)}" height="${a.h}" rx="${LOOK.action.radius}"/><text x="${r1(a.x + a.w / 2)}" y="${r1(a.y + a.h / 2 + LOOK.baseline.action)}" text-anchor="middle">${esc(a.text)}</text></g>`;
3971
5529
  }
3972
5530
  function carrierShape(e, sh) {
@@ -3984,11 +5542,12 @@ var easeInOut = (t) => t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
3984
5542
  function carrier(e, time, ctx) {
3985
5543
  const { m } = ctx;
3986
5544
  const n = LOOK.carrier.samples;
3987
- const length = pathLength(e.points);
5545
+ const route = e.wait ? [e.wait, ...e.points] : e.points;
5546
+ const length = pathLength(route);
3988
5547
  const { depart: a, arrive: b, start: from, end: gone } = time;
3989
5548
  const path2 = [];
3990
5549
  for (let k = 0; k <= n; k++) {
3991
- const [x, y] = along(e.points, easeInOut(k / n) * length);
5550
+ const [x, y] = along(route, easeInOut(k / n) * length);
3992
5551
  path2.push([a + (b - a) * k / n, x, y]);
3993
5552
  }
3994
5553
  const first = path2[0];
@@ -3997,6 +5556,12 @@ function carrier(e, time, ctx) {
3997
5556
  const pts = [[0, first[1], first[2]], ...path2];
3998
5557
  if (e.settle) pts.push([Math.min(b + 0.3, Math.max(gone, b + 0.01)), rest[0], rest[1]]);
3999
5558
  pts.push([gone, rest[0], rest[1]], [m.total, rest[0], rest[1]]);
5559
+ const [hx, hy] = carrierHalf(e.carry);
5560
+ const name = e.carry.kind === "tag" ? e.carry.text : e.carry.kind === "coin" ? "\u786C\u8CA8" : "\u5C01\u7B52";
5561
+ const part = e.carry.kind === "tag" ? {} : { part: { kind: e.carry.kind === "coin" ? "coin" : "envelope" } };
5562
+ const box = (p) => ({ x: p[0] - hx, y: p[1] - hy, w: hx * 2, h: hy * 2 });
5563
+ if (a > from) ctx.ink.push({ text: name, rect: box([first[1], first[2]]), shown: [[from, a]], boxed: true, ...part });
5564
+ ctx.ink.push({ text: name, rect: box(rest), shown: [[b, gone]], boxed: true, ...part });
4000
5565
  const fade = gone < m.last ? 0.05 : 0.18;
4001
5566
  return `<g class="dg-a" style="${m.move(pts, m.blink(from + 0.02, gone, fade))}">${carrierShape(e, ctx.sh)}</g>`;
4002
5567
  }
@@ -4006,15 +5571,30 @@ function badge(b, ctx, grey = false) {
4006
5571
  const a = span.start;
4007
5572
  const e = span.end;
4008
5573
  const { r, ring: rr } = LOOK.badge;
5574
+ const shown = { visibility: "visible" };
5575
+ const hidden = { visibility: "hidden" };
5576
+ const swap = b.until === void 0 ? void 0 : ctx.t.steps[b.until].start;
5577
+ const next = swap !== void 0 && swap <= e + 1e-6;
4009
5578
  const fill = m.kf([
4010
- [0, { opacity: 0, transform: "scale(.5)" }],
4011
- [a, { opacity: 0, transform: "scale(.5)" }, EASE.pop],
4012
- [a + 0.35, { opacity: 1, transform: "scale(1)" }],
4013
- [e, { opacity: 1, transform: "scale(1)" }, EASE.inOut],
4014
- [e + 0.4, { opacity: 0, transform: "scale(1)" }],
4015
- [m.total, { opacity: 0, transform: "scale(.5)" }]
5579
+ [0, { opacity: 0, transform: "scale(.5)", ...hidden }],
5580
+ [a, { opacity: 0, transform: "scale(.5)", ...hidden }, EASE.pop],
5581
+ [a + 0.35, { opacity: 1, transform: "scale(1)", ...shown }],
5582
+ [e, { opacity: 1, transform: "scale(1)", ...shown }, EASE.inOut],
5583
+ [e + (next ? MOTION.untilFade : 0.4), { opacity: 0, transform: "scale(1)", ...hidden }],
5584
+ [m.total, { opacity: 0, transform: "scale(.5)", ...hidden }]
5585
+ ]);
5586
+ const pastEnd = swap ?? m.last;
5587
+ const past = next ? m.kf([
5588
+ [0, { opacity: 0, ...hidden }],
5589
+ [m.total, { opacity: 0, ...hidden }]
5590
+ ]) : m.kf([
5591
+ [0, { opacity: 0, ...hidden }],
5592
+ [e, { opacity: 0, ...hidden }, EASE.inOut],
5593
+ [e + 0.4, { opacity: 1, ...shown }],
5594
+ [pastEnd, { opacity: 1, ...shown }, EASE.inOut],
5595
+ ...swap === void 0 ? [] : [[swap + MOTION.untilFade, { opacity: 0, ...hidden }]],
5596
+ [m.total, { opacity: 0, ...hidden }]
4016
5597
  ]);
4017
- const past = m.kf([[0, { opacity: 0 }], [e, { opacity: 0 }, EASE.inOut], [e + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]);
4018
5598
  const ring = m.kf([
4019
5599
  [0, { opacity: 0, transform: "scale(1)" }],
4020
5600
  [a + 0.05, { opacity: 0, transform: "scale(1)" }],
@@ -4026,6 +5606,7 @@ function badge(b, ctx, grey = false) {
4026
5606
  const y = r1(b.y);
4027
5607
  const ty = r1(b.y + LOOK.baseline.badge);
4028
5608
  const no = b.step + 1;
5609
+ ctx.ink.push({ text: String(no), rect: { x: b.x - r, y: b.y - r, w: r * 2, h: r * 2 }, shown: [[a, pastEnd]], boxed: true, badge: true });
4029
5610
  return `<g class="dg-bd" data-step="${b.step}" style="${cs(b.color)}"><circle class="dg-bdr dg-popc dg-a" cx="${x}" cy="${y}" r="${rr}" style="${ring}"/><g class="dg-a" style="${past}"><circle class="${grey ? "dg-bdp-g" : "dg-bdp"}" cx="${x}" cy="${y}" r="${rr}"/><text class="${grey ? "dg-bdpt-g" : "dg-bdpt"}" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g><g class="dg-popc dg-a" style="${fill}"><circle class="dg-bdf" cx="${x}" cy="${y}" r="${r}"/><text class="dg-bdft" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g></g>`;
4030
5611
  }
4031
5612
  function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map()) {
@@ -4035,7 +5616,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4035
5616
  const parts = [
4036
5617
  `<rect class="dg-strip" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}" ${sh}/>`,
4037
5618
  `<g style="${cs("slate")}"><rect class="dg-bi" x="${r1(s.x + S2.pad)}" y="${r1(my - S2.icon / 2)}" width="${S2.icon}" height="${S2.icon}" rx="${LOOK.box.iconRadius}"/>${glyph("env", s.x + S2.pad + S2.icon / 2, my, 0.78)}</g>`,
4038
- `<text class="dg-sh" x="${r1(s.x + S2.titleX)}" y="${r1(my + LOOK.baseline.stripTitle)}">${esc(s.title)}</text>`
5619
+ write(ctx.ink, "dg-sh", s.x + S2.titleX, my + LOOK.baseline.stripTitle, s.title, TYPE.stripTitle)
4039
5620
  ];
4040
5621
  s.fields.forEach((field, i) => {
4041
5622
  const prev = s.fields[i - 1];
@@ -4043,7 +5624,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4043
5624
  const sx = field.x - S2.fieldGap / 2;
4044
5625
  parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(field.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(field.y + S2.h - S2.sepInset)}"/>`);
4045
5626
  }
4046
- parts.push(`<text class="dg-fl" x="${r1(field.x)}" y="${r1(field.y + S2.nameY)}">${esc(field.name)}</text>`);
5627
+ parts.push(write(ctx.ink, "dg-fl", field.x, field.y + S2.nameY, field.name, TYPE.fieldName));
4047
5628
  const list2 = changes.get(field.name) ?? [];
4048
5629
  const values = list2.filter((c) => c.value !== void 0);
4049
5630
  const tags = list2.filter((c) => c.tag !== void 0);
@@ -4051,6 +5632,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4051
5632
  const next = values[k + 1]?.at;
4052
5633
  const value = c.value;
4053
5634
  const cls = hasWide(value) ? "dg-fvj" : "dg-fv";
5635
+ ctx.ink.push({ text: value, rect: textBox(value, field.x, field.y + S2.valueY, hasWide(value) ? TYPE.fieldValueJa : TYPE.fieldValue), shown: [[c.at, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]] });
4054
5636
  const textOf = (c2) => `<text class="${c2}" x="${r1(field.x)}" y="${r1(field.y + S2.valueY)}">${esc(value)}</text>`;
4055
5637
  const text2 = textOf(cls);
4056
5638
  if (!now) {
@@ -4070,6 +5652,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4070
5652
  const x = field.x + (shown ? textWidth(shown, hasWide(shown) ? TYPE.fieldValueJa : TYPE.fieldValue) + S2.tagGap : 0);
4071
5653
  const w = textWidth(tag, TYPE.tag) + S2.tagPadX * 2;
4072
5654
  const y = field.y + S2.valueY - S2.tagH / 2 - LOOK.baseline.tag;
5655
+ ctx.ink.push({ text: tag, rect: { x, y, w, h: S2.tagH }, shown: [[c.at, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]], boxed: true });
4073
5656
  parts.push(
4074
5657
  `<g class="dg-tg dg-popc dg-a" style="${cs(c.color)};${next === void 0 ? m.pop(c.at) : m.pop(c.at, next - MOTION.untilFade)}"><rect x="${r1(x)}" y="${r1(y)}" width="${r1(w)}" height="${S2.tagH}" rx="${S2.tagH / 2}"/><text x="${r1(x + w / 2)}" y="${r1(y + S2.tagH / 2 + LOOK.baseline.tag)}" text-anchor="middle">${esc(tag)}</text></g>`
4075
5658
  );
@@ -4082,7 +5665,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4082
5665
  const sx = t.x - S2.fieldGap / 2;
4083
5666
  parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(t.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(t.y + S2.h - S2.sepInset)}"/>`);
4084
5667
  }
4085
- parts.push(`<text class="dg-fl" x="${r1(t.x)}" y="${r1(t.y + S2.nameY)}">${esc(t.title)}</text>`);
5668
+ parts.push(write(ctx.ink, "dg-fl", t.x, t.y + S2.nameY, t.title, TYPE.fieldName));
4086
5669
  const dy = t.y + S2.valueY - TYPE.fieldValue.size / 3;
4087
5670
  t.states.forEach((state, k) => {
4088
5671
  const cx = r1(t.x + S2.trail.r + k * S2.trail.step);
@@ -4094,6 +5677,123 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4094
5677
  return parts.join("");
4095
5678
  }
4096
5679
 
5680
+ // src/render/git.ts
5681
+ var r12 = (v) => Math.round(v * 100) / 100;
5682
+ var center = (r) => [r.x + r.w / 2, r.y + r.h / 2];
5683
+ function tagShape(text2, sh) {
5684
+ const C = LOOK.carrier;
5685
+ const ja3 = hasWide(text2);
5686
+ const w = textWidth(text2, ja3 ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
5687
+ return `<rect class="dg-car" x="${r12(-w / 2)}" y="${ -18 / 2}" width="${r12(w)}" height="${C.tagH}" rx="${C.tagH / 2}" ${sh}/><text class="dg-car-t${ja3 ? " dg-car-tj" : ""}" y="${LOOK.baseline.carrier}" text-anchor="middle">${esc(text2)}</text>`;
5688
+ }
5689
+ function drawGit(layout, diagram, timeline, ctx) {
5690
+ const { m } = ctx;
5691
+ const G = LOOK.git;
5692
+ const timeOf = (step, event) => timeline.edges.find((t) => t.step === step && t.event === event);
5693
+ const links = layout.links.map((l) => {
5694
+ const time = timeOf(l.step, l.event);
5695
+ if (!time) return "";
5696
+ ctx.traces.push({ from: l.from, to: l.to, points: l.points, shown: [[time.start, Number.POSITIVE_INFINITY]] });
5697
+ const d = pathOf(l.points);
5698
+ if (l.kind === "copy") return `<g style="${cs(l.color)}"><path class="dg-git-cp dg-a" d="${d}" style="${m.vis(time.start, m.last)}"/></g>`;
5699
+ const kf = m.kf([
5700
+ [0, { opacity: 0, "stroke-dashoffset": 1 }],
5701
+ [time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
5702
+ [time.start + 0.05, { opacity: 1 }],
5703
+ [time.drawn, { "stroke-dashoffset": 0 }],
5704
+ [m.last, { opacity: 1, "stroke-dashoffset": 0 }, EASE.inOut],
5705
+ [m.total, { opacity: 0, "stroke-dashoffset": 0 }]
5706
+ ]);
5707
+ return `<g style="${cs(l.color)}"><path class="dg-git-l dg-a" pathLength="1" d="${d}" style="${kf}"/></g>`;
5708
+ }).join("");
5709
+ const commits = layout.commits.map((c) => {
5710
+ const at2 = timeOf(c.step, c.event)?.drawn ?? 0;
5711
+ const ring = { x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 };
5712
+ ctx.ink.push({ text: c.id, rect: ring, shown: [[at2, Number.POSITIVE_INFINITY]], boxed: true });
5713
+ const lines2 = (c.text?.lines ?? []).map((line, k) => {
5714
+ const hash = k === 0 && c.hash !== void 0;
5715
+ const baseline = c.text?.baselines[k] ?? c.cy;
5716
+ return write(ctx.ink, hash ? "dg-git-h" : "dg-git-n", c.cx, baseline, line, hash ? TYPE.gitHash : TYPE.gitNote, [[at2, Number.POSITIVE_INFINITY]], "middle");
5717
+ }).join("");
5718
+ const id = `<text class="dg-git-id" x="${r12(c.cx)}" y="${r12(c.cy + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text>`;
5719
+ const node = `<g class="dg-popc dg-a" style="${m.pop(at2)}"><circle class="dg-git-c" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${c.r}" ${ctx.sh}/>${id}</g>`;
5720
+ const text2 = lines2 === "" ? "" : `<g class="dg-a" style="${m.vis(at2)}">${lines2}</g>`;
5721
+ const orphanAt = c.orphan === void 0 ? void 0 : timeOf(c.orphan, c.orphanEvent ?? 0)?.drawn;
5722
+ const orphan = orphanAt === void 0 ? "" : `<g class="dg-a" data-orphan="${esc(c.id)}" style="${m.vis(orphanAt, m.last, { f: 0.5 })}"><circle class="dg-git-old" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${G.orphan}"/><text class="dg-git-oldl" x="${r12(c.cx)}" y="${r12(c.cy + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text></g>`;
5723
+ return `<g data-commit="${esc(c.id)}" style="${cs(c.color)}">${node}${text2}${orphan}</g>`;
5724
+ }).join("");
5725
+ const lines = layout.moves.flatMap((mv) => {
5726
+ const time = timeOf(mv.step, mv.event);
5727
+ if (!mv.line || !time) return [];
5728
+ const end = timeline.steps[mv.step].end;
5729
+ ctx.traces.push({ from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, shown: [[time.start, end + 0.4]] });
5730
+ const kf = m.kf([
5731
+ [0, { opacity: 0, "stroke-dashoffset": 1 }],
5732
+ [time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
5733
+ [time.start + 0.05, { opacity: 1 }],
5734
+ [time.drawn, { "stroke-dashoffset": 0 }],
5735
+ [end, { opacity: 1 }, EASE.inOut],
5736
+ [end + 0.4, { opacity: 0 }],
5737
+ [m.total, { opacity: 0, "stroke-dashoffset": 0 }]
5738
+ ]);
5739
+ return [`<g style="${cs(mv.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${pathOf(mv.line)}" style="${kf}"/></g>`];
5740
+ }).join("");
5741
+ const carried = timeline.carriers.flatMap((t) => {
5742
+ const mv = layout.moves.find((x) => x.step === t.step && x.event === t.event && x.line);
5743
+ const source = diagram.steps[t.step]?.events[t.event];
5744
+ if (!mv?.line || source?.type !== "edge") return [];
5745
+ const edge2 = { step: t.step, event: t.event, from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, color: mv.color, carry: source.carry };
5746
+ return [carrier(edge2, { ...t, start: t.depart, end: t.arrive + MOTION.fade }, ctx)];
5747
+ }).join("");
5748
+ const refs = [...new Set(layout.moves.map((mv) => mv.ref))];
5749
+ const tags = refs.map((ref) => tagMotion(ref, layout.moves.filter((mv) => mv.ref === ref), timeOf, ctx)).join("") + carried;
5750
+ return { links, lines, commits, tags };
5751
+ }
5752
+ function tagMotion(ref, list2, timeOf, ctx) {
5753
+ const { m } = ctx;
5754
+ const points = [];
5755
+ const fades = [[0, { opacity: 0 }]];
5756
+ let on = false;
5757
+ let rest;
5758
+ const leave = (t) => {
5759
+ if (rest) ctx.ink.push({ text: ref, rect: rest.rect, shown: [[rest.since, t]], boxed: true });
5760
+ rest = void 0;
5761
+ };
5762
+ for (const mv of list2) {
5763
+ const time = timeOf(mv.step, mv.event);
5764
+ if (!time) continue;
5765
+ const { start: a, drawn: b } = time;
5766
+ const from = mv.from ? center(mv.from) : void 0;
5767
+ const to = mv.to ? center(mv.to) : void 0;
5768
+ leave(a);
5769
+ if (mv.carried && from && to && on) {
5770
+ points.push([a + MOTION.fade, from[0], from[1]], [b - MOTION.fade, to[0], to[1]]);
5771
+ fades.push([a, { opacity: 1 }, EASE.inOut], [a + MOTION.fade, { opacity: 0 }], [b - MOTION.fade, { opacity: 0 }, EASE.out], [b, { opacity: 1 }]);
5772
+ rest = { rect: mv.to, since: b };
5773
+ continue;
5774
+ }
5775
+ if (from) points.push([a, from[0], from[1]]);
5776
+ if (to) points.push([b, to[0], to[1]]);
5777
+ if (to && !on) {
5778
+ const show = from ? a : b - MOTION.fade;
5779
+ fades.push([show, { opacity: 0 }, EASE.out], [show + MOTION.fade, { opacity: 1 }]);
5780
+ on = true;
5781
+ } else if (!to && on) {
5782
+ fades.push([b, { opacity: 1 }, EASE.inOut], [b + MOTION.untilFade, { opacity: 0 }]);
5783
+ on = false;
5784
+ }
5785
+ if (mv.to) rest = { rect: mv.to, since: b };
5786
+ }
5787
+ leave(Number.POSITIVE_INFINITY);
5788
+ if (points.length === 0) return "";
5789
+ const first = points[0];
5790
+ const last = points[points.length - 1];
5791
+ if (on) fades.push([m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]);
5792
+ else fades.push([m.total, { opacity: 0 }]);
5793
+ const style = m.move([[0, first[1], first[2]], ...points, [m.total, last[1], last[2]]], fades);
5794
+ return `<g class="dg-a" data-ref="${esc(ref)}" style="${style}">${tagShape(ref, ctx.sh)}</g>`;
5795
+ }
5796
+
4097
5797
  // src/render/motion.ts
4098
5798
  var r2 = (v) => Math.round(v * 100) / 100;
4099
5799
  var Motion = class {
@@ -4201,6 +5901,7 @@ var PART_CSS = [
4201
5901
  `.dg-halo{fill:none;stroke:var(--c);stroke-width:${S.halo};stroke-opacity:.16}`,
4202
5902
  `.dg-on{fill:none;stroke:var(--c);stroke-width:${S.on}}`,
4203
5903
  `.dg-ic{fill:${mix(X.icon)}}`,
5904
+ `.dg-slot{fill:none;stroke:${mix(X.slot, "transparent")};stroke-width:${S.slot};stroke-dasharray:3 3}`,
4204
5905
  `.dg-gl{fill:none;stroke:var(--c);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
4205
5906
  `.dg-sn{${font(TYPE.boxName)};fill:var(--ink)}`,
4206
5907
  `.dg-ss{${font(TYPE.boxSub)};fill:var(--mute)}`,
@@ -4217,7 +5918,7 @@ var PART_CSS = [
4217
5918
  ".dg-bd{cursor:pointer}",
4218
5919
  ".dg-bdf{fill:var(--c)}",
4219
5920
  `.dg-bdft{${font(TYPE.badge)};fill:var(--on-c)}`,
4220
- `.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing}}`,
5921
+ `.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing};pointer-events:none}`,
4221
5922
  `.dg-bdp{fill:${mix(X.badgePast)};stroke:${mix(X.badgePastEdge, "transparent")};stroke-width:${S.hair}}`,
4222
5923
  `.dg-bdpt{${font(TYPE.badge)};fill:var(--ct)}`,
4223
5924
  `.dg-bdp-g{fill:var(--surf);stroke:${PAST};stroke-width:${S.hair}}`,
@@ -4263,6 +5964,14 @@ var PART_CSS = [
4263
5964
  `.dg-mark{${font(TYPE.regionNote)};fill:var(--mute)}`,
4264
5965
  `.dg-done{fill:var(--ink);stroke:var(--surf);stroke-width:${S.done}}`,
4265
5966
  `.dg-done-ck{fill:none;stroke:var(--surf);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
5967
+ `.dg-git-l{fill:none;stroke:var(--c);stroke-width:${S.git};stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1 2}`,
5968
+ `.dg-git-cp{fill:none;stroke:var(--c);stroke-width:${S.gitOrphan};stroke-linecap:round;stroke-dasharray:3 3;stroke-opacity:.7}`,
5969
+ `.dg-git-c{fill:var(--surf);stroke:var(--c);stroke-width:${S.git}}`,
5970
+ `.dg-git-id{${font(TYPE.gitId)};fill:var(--ct)}`,
5971
+ `.dg-git-h{${font(TYPE.gitHash)};fill:var(--mute)}`,
5972
+ `.dg-git-n{${font(TYPE.gitNote)};fill:var(--ink2)}`,
5973
+ `.dg-git-old{fill:var(--surf);stroke:var(--c);stroke-width:${S.gitOrphan};stroke-dasharray:3 3;stroke-opacity:.6}`,
5974
+ `.dg-git-oldl{${font(TYPE.gitId)};fill:var(--ct);opacity:.55}`,
4266
5975
  ".dg-vp-bg{fill:var(--bg)}",
4267
5976
  ".dg-vp-frame{fill:none;stroke:var(--hair)}",
4268
5977
  ".dg-hd-bg{fill:var(--bg)}",
@@ -4346,23 +6055,36 @@ function fieldChanges(diagram, timeline, layout) {
4346
6055
  }
4347
6056
  return out;
4348
6057
  }
4349
- function drawSvg(diagram, layout, timeline, palette, theme, follow) {
6058
+ function fadeBefore(l, time, steps) {
6059
+ if (l.until === void 0 || !time.after) return time;
6060
+ const cut = steps[l.until].start;
6061
+ const { after, ...rest } = time;
6062
+ return cut > after.start ? { ...rest, after: { start: after.start, end: Math.min(after.end, cut) } } : rest;
6063
+ }
6064
+ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], traces = []) {
4350
6065
  const id = nameOf(`${JSON.stringify(diagram)}|${palette.id}|${theme}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
4351
6066
  const m = new Motion(`dg${id}`, timeline.total, timeline.last);
4352
- const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end };
6067
+ const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end, ink, traces };
4353
6068
  const on = involved(diagram);
4354
6069
  const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
4355
6070
  const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
4356
- for (const region of layout.regions) L.band.push(band(region));
6071
+ for (const region of layout.regions) L.band.push(band(region, ink));
4357
6072
  const ghostColor = layout.boxes.find((b) => b.ghost)?.color ?? "slate";
4358
- if (layout.side) L.band.push(side(layout.side, ghostColor));
6073
+ if (layout.side) L.band.push(side(layout.side, ghostColor, ink));
4359
6074
  const boxColor = (id2, ghost) => layout.boxes.find((b) => b.id === id2 && (ghost === void 0 || b.ghost === ghost))?.color;
4360
- for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor));
4361
- for (const e of layout.ends) L.node.push(endMark(e, ghostColor));
6075
+ for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor, ink, traces));
6076
+ for (const e of layout.ends) L.node.push(endMark(e, ghostColor, ink));
4362
6077
  const isState = layout.kind === "state";
4363
6078
  const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
4364
6079
  if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals));
4365
6080
  for (const line of layout.lifelines) L.base.push(lifeline(line.x, line.y1, line.y2));
6081
+ if (isGitLayout(layout)) {
6082
+ const git = drawGit(layout, diagram, timeline, ctx);
6083
+ L.base.push(git.links);
6084
+ L.lit.push(git.lines);
6085
+ L.node.push(git.commits);
6086
+ L.top.push(git.tags);
6087
+ }
4366
6088
  for (const e of layout.edges) {
4367
6089
  const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
4368
6090
  if (!time) continue;
@@ -4373,7 +6095,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
4373
6095
  const states = new Map((timeline.states ?? []).map((s) => [s.box, s]));
4374
6096
  for (const box of layout.boxes) {
4375
6097
  if (box.ghost) {
4376
- L.node.push(ghostCard(box));
6098
+ L.node.push(ghostCard(box, ink));
4377
6099
  continue;
4378
6100
  }
4379
6101
  const state = states.get(box.id);
@@ -4383,7 +6105,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
4383
6105
  for (const b of layout.badges) L.badge.push(badge(b, ctx, isState));
4384
6106
  for (const l of layout.labels) {
4385
6107
  const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
4386
- if (time) L.top.push(label(l, time, ctx));
6108
+ if (time) L.top.push(label(l, fadeBefore(l, time, timeline.steps), ctx));
4387
6109
  }
4388
6110
  for (const a of layout.actions) {
4389
6111
  const time = timeline.events.find((t) => t.step === a.step && t.event === a.event);
@@ -4401,14 +6123,14 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
4401
6123
  const css = `.dg-${id}{${FONT_VARS};--T:${timeline.total}s;${paletteVars(palette, theme)}}${PART_CSS}${m.frames.join("")}`;
4402
6124
  return `<svg xmlns="http://www.w3.org/2000/svg" class="dg dg-${id}" viewBox="0 0 ${Math.ceil(view.w)} ${Math.ceil(view.h)}" width="${Math.ceil(view.w)}" height="${Math.ceil(view.h)}" role="img" aria-label="${esc(diagram.title)}" data-dragon="figure" data-view="${follow ? "follow" : "fixed"}"><style>${css}</style><defs>${shadow}</defs>${view.body}</svg>`;
4403
6125
  }
4404
- function union(rects) {
6126
+ function union2(rects) {
4405
6127
  const x = Math.min(...rects.map((r) => r.x));
4406
6128
  const y = Math.min(...rects.map((r) => r.y));
4407
6129
  return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
4408
6130
  }
4409
6131
  function focusOf(layout, diagram, step) {
4410
6132
  const rects = focusParts(layout, diagram, step);
4411
- return rects.length === 0 ? void 0 : union(rects);
6133
+ return rects.length === 0 ? void 0 : union2(rects);
4412
6134
  }
4413
6135
  function badgeFocus(badge2, parts, vw, vh) {
4414
6136
  const room = LOOK.badge.r + LOOK.follow.badgeRoom;
@@ -4416,7 +6138,7 @@ function badgeFocus(badge2, parts, vw, vh) {
4416
6138
  const away = (p) => Math.hypot(Math.max(0, p.x - bx, bx - p.x - p.w), Math.max(0, p.y - by, by - p.y - p.h));
4417
6139
  let held = { x: bx - room, y: by - room, w: room * 2, h: room * 2 };
4418
6140
  for (const p of [...parts].sort((a, b) => away(a) - away(b))) {
4419
- const next = union([held, p]);
6141
+ const next = union2([held, p]);
4420
6142
  if (next.w <= vw && next.h <= vh) held = next;
4421
6143
  }
4422
6144
  return held;
@@ -4514,19 +6236,25 @@ function renderDiagram(input, options = {}) {
4514
6236
  const read2 = readDiagram(input, { lang });
4515
6237
  if (!read2.ok) throw new Error(FIGURE_TEXT[lang].cannotDraw(read2.errors.map((e) => `${e.pointer} ${e.message}`).join(" / ")));
4516
6238
  const diagram = read2.diagram;
6239
+ const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : diagram.kind === "git" ? layoutGit(diagram) : layoutArchitecture(diagram);
6240
+ return renderLayout(diagram, layout, buildTimeline(diagram), options);
6241
+ }
6242
+ function renderLayout(diagram, layout, timeline, options = {}) {
4517
6243
  const palette = resolvePalette(options.palette);
4518
6244
  const theme = options.theme === "dark" ? "dark" : "light";
4519
- const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : layoutArchitecture(diagram);
4520
- const timeline = buildTimeline(diagram);
6245
+ const ink = [];
6246
+ const traces = [];
6247
+ const svg = drawSvg(diagram, layout, timeline, palette, theme, void 0, ink, traces);
4521
6248
  return {
4522
- svg: drawSvg(diagram, layout, timeline, palette, theme),
6249
+ svg,
4523
6250
  palette: palette.id,
4524
6251
  theme,
4525
6252
  ...diagram.view ? { view: diagram.view } : {},
4526
6253
  fonts: { ...FONTS },
4527
6254
  layout,
4528
6255
  timeline,
4529
- diagram
6256
+ diagram,
6257
+ overlaps: findOverlaps(ink, timeline.stills, traces)
4530
6258
  };
4531
6259
  }
4532
6260
 
@@ -4860,7 +6588,7 @@ async function exportDiagram(input, options) {
4860
6588
  }
4861
6589
  }
4862
6590
  const files = writeOutputs(options.outDir, options.name ?? "diagram", outputs);
4863
- return { files, view, frames, ...sizeOf(videoSvg) };
6591
+ return { files, view, frames, ...sizeOf(videoSvg), overlaps: rendered.overlaps };
4864
6592
  }
4865
6593
  function writeOutputs(outDir, name, outputs) {
4866
6594
  const created = fs.mkdirSync(outDir, { recursive: true });
@@ -4913,8 +6641,8 @@ var ja2 = () => {
4913
6641
  sayTwice: "1 \u3064\u306E\u6BB5\u306B say \u306F 1 \u3064\u307E\u3067\u3002\u9577\u3044\u672C\u6587\u306F say \u306E\u4E0B\u306B\u5B57\u4E0B\u3052\u3057\u3066\u7D9A\u3051\u308B",
4914
6642
  codeTwice: "1 \u3064\u306E\u6BB5\u306B code \u306F 1 \u884C\u307E\u3067",
4915
6643
  emptyCode: "code \u306E\u5F8C\u308D\u306B\u547D\u4EE4\u3092\u66F8\u304F",
4916
- declarationInStep: "group \u3068 box \u3068 strip \u306F\u6700\u521D\u306E step \u3088\u308A\u524D\u306B\u66F8\u304F",
4917
- stepLineBeforeStep: "\u7DDA\u3068 say \u3068 code \u3068 act \u3068 note \u3068 set \u306F step \u306E\u4E0B\u306B\u66F8\u304F",
6644
+ declarationInStep: "group \u3068 box \u3068 strip \u3068 branch \u306F\u6700\u521D\u306E step \u3088\u308A\u524D\u306B\u66F8\u304F",
6645
+ stepLineBeforeStep: "\u7DDA\u3068 say \u3068 code \u3068 act \u3068 note \u3068 set \u3068 commit \u3068\u679D\u3092\u5207\u308B\u884C\u306F step \u306E\u4E0B\u306B\u66F8\u304F",
4918
6646
  nestedGroup: "group \u306E\u4E2D\u306B group \u306F\u66F8\u3051\u306A\u3044\u3002\u5148\u306B end \u3067\u9589\u3058\u308B",
4919
6647
  strayEnd: "end \u306E\u524D\u306B\u3001\u9589\u3058\u308B group \u304C\u7121\u3044",
4920
6648
  endTakesNothing: "end \u306E\u5F8C\u308D\u306B\u306F\u4F55\u3082\u66F8\u304B\u306A\u3044",
@@ -4946,7 +6674,20 @@ var ja2 = () => {
4946
6674
  reservedId: (id) => `${id} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
4947
6675
  intoStart: "start \u3078\u5165\u308B\u7DDA\u306F\u66F8\u3051\u306A\u3044\u3002start \u306F\u59CB\u307E\u308A\u306E\u5370\u3067\u3001\u7DDA\u306F start \u304B\u3089\u51FA\u308B",
4948
6676
  outOfFinish: "finish \u304B\u3089\u51FA\u308B\u7DDA\u306F\u66F8\u3051\u306A\u3044\u3002finish \u306F\u7D42\u308F\u308A\u306E\u5370\u3067\u3001\u7DDA\u306F finish \u3078\u5165\u308B",
4949
- pathNoAttrs: "\u6700\u521D\u306E step \u3088\u308A\u524D\u306E\u7DDA\u306F\u4ECA\u56DE\u306F\u901A\u3089\u306A\u3044\u9053\u306A\u306E\u3067\u3001\u5C5E\u6027 (carry \u3068 tag \u3068 side) \u3092\u66F8\u3051\u306A\u3044"
6677
+ pathNoAttrs: "\u6700\u521D\u306E step \u3088\u308A\u524D\u306E\u7DDA\u306F\u4ECA\u56DE\u306F\u901A\u3089\u306A\u3044\u9053\u306A\u306E\u3067\u3001\u5C5E\u6027 (carry \u3068 tag \u3068 side) \u3092\u66F8\u3051\u306A\u3044",
6678
+ gitOnly: (word) => `${word} \u306E\u884C\u306F git (\u679D\u5206\u304B\u308C\u306E\u56F3) \u3067\u3060\u3051\u66F8\u3051\u308B`,
6679
+ gitNoGroup: "git (\u679D\u5206\u304B\u308C\u306E\u56F3) \u306B\u306F group \u3092\u66F8\u3051\u306A\u3044\u3002\u679D\u306F branch \u306E\u884C\u3067\u5BA3\u8A00\u3059\u308B",
6680
+ noBranches: "branch \u306E\u884C\u3067\u679D\u3092 1 \u3064\u4EE5\u4E0A\u5BA3\u8A00\u3059\u308B",
6681
+ branchShape: "branch \u306F branch <\u540D\u672D> [note: <\u6DFB\u3048\u66F8\u304D>] \u306E\u5F62\u3067\u66F8\u304F",
6682
+ commitShape: "commit \u306F commit <\u540D\u672D> on <\u679D> [hash: <hash>, note: <\u4E00\u8A00>] \u306E\u5F62\u3067\u66F8\u304F\u3002\u5F53\u3066\u76F4\u3057\u306F copy <commit> \u3092\u3001\u53D6\u308A\u8FBC\u307F\u306F merge <\u679D> \u3092 on <\u679D> \u306E\u5F8C\u308D\u306B\u66F8\u304F",
6683
+ fromShape: "\u679D\u3092\u5207\u308B\u884C\u306F <\u679D> from <commit> \u306E\u5F62\u3067\u66F8\u304F",
6684
+ undeclaredBranch: (id) => `${id} \u3068\u3044\u3046\u679D\u306F\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044`,
6685
+ undeclaredRef: (id) => `${id} \u3068\u3044\u3046\u679D\u306F\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u3002\u672D\u3092\u52D5\u304B\u3059\u7DDA\u306F\u679D\u306E\u540D\u672D\u304B HEAD \u304B\u3089\u5F15\u304F`,
6686
+ noCommit: (id) => `${id} \u3068\u3044\u3046 commit \u306F\u307E\u3060\u7A4D\u3093\u3067\u3044\u306A\u3044`,
6687
+ emptyBranch: (id) => `${id} \u306E\u679D\u306F\u307E\u3060\u3069\u306E commit \u3082\u6307\u3057\u3066\u3044\u306A\u3044\u306E\u3067\u53D6\u308A\u8FBC\u3081\u306A\u3044`,
6688
+ mergeSelf: (id) => `${id} \u306F\u7A4D\u3080\u679D\u306A\u306E\u3067\u3001\u53D6\u308A\u8FBC\u3080\u679D\u306B\u3067\u304D\u306A\u3044`,
6689
+ headReserved: (name) => `${name} \u306F\u679D\u5206\u304B\u308C\u306E\u56F3\u3067\u4ECA\u3044\u308B\u5834\u6240\u306E\u672D\u306E\u540D\u524D\u3067\u3001\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
6690
+ badHash: "hash \u306F 0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 4 \u304B\u3089 40 \u5B57\u306B\u3059\u308B"
4950
6691
  };
4951
6692
  };
4952
6693
  var en2 = () => {
@@ -4982,8 +6723,8 @@ var en2 = () => {
4982
6723
  sayTwice: "A step takes one say. Continue a long body on indented lines below it",
4983
6724
  codeTwice: "A step takes at most one code line",
4984
6725
  emptyCode: "Write the command after code",
4985
- declarationInStep: "Write group, box and strip before the first step",
4986
- stepLineBeforeStep: "Write lines, say, code, act, note and set under a step",
6726
+ declarationInStep: "Write group, box, strip and branch before the first step",
6727
+ stepLineBeforeStep: "Write lines, say, code, act, note, set, commit and branch cuts under a step",
4987
6728
  nestedGroup: "A group cannot hold another group. Close it with end first",
4988
6729
  strayEnd: "There is no group for this end to close",
4989
6730
  endTakesNothing: "Write nothing after end",
@@ -5015,7 +6756,20 @@ var en2 = () => {
5015
6756
  reservedId: (id) => `${id} names the start or end mark of a state diagram and cannot be a box id`,
5016
6757
  intoStart: "A line cannot go into start. start is the start mark, and lines leave it",
5017
6758
  outOfFinish: "A line cannot leave finish. finish is the end mark, and lines go into it",
5018
- pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)"
6759
+ pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)",
6760
+ gitOnly: (word) => `${word} lines can be written only in git diagrams`,
6761
+ gitNoGroup: "A git diagram takes no group. Declare branches with branch lines",
6762
+ noBranches: "Declare at least one branch with a branch line",
6763
+ branchShape: "Write a branch as branch <id> [note: <note>]",
6764
+ commitShape: "Write a commit as commit <id> on <branch> [hash: <hash>, note: <note>]. For a replayed commit add copy <commit>, and for a merge commit add merge <branch>, after on <branch>",
6765
+ fromShape: "Write a branch cut as <branch> from <commit>",
6766
+ undeclaredBranch: (id) => `No branch named ${id} is declared`,
6767
+ undeclaredRef: (id) => `No branch named ${id} is declared. A line that moves a ref starts from a branch id or HEAD`,
6768
+ noCommit: (id) => `No commit named ${id} has been made yet`,
6769
+ emptyBranch: (id) => `Branch ${id} does not point at any commit yet, so it cannot be merged`,
6770
+ mergeSelf: (id) => `${id} is the branch being committed to, so it cannot be the branch merged in`,
6771
+ headReserved: (name) => `${name} names where you are in a git diagram and cannot be an id`,
6772
+ badHash: "Write a hash as 4 to 40 characters of 0-9 and a-f"
5019
6773
  };
5020
6774
  };
5021
6775
  var MESSAGES = { ja: ja2(), en: en2() };
@@ -5046,6 +6800,9 @@ var NotationError = class extends Error {
5046
6800
  var fail = (source, index, message) => new NotationError(source.line, columnOf(source, index), message);
5047
6801
  var ID = /^[^\s[\]「」=:]+$/u;
5048
6802
  var EDGE = /^([^\s:[\]]+?)\s*->\s*([^\s:[\]]+)/du;
6803
+ var COMMIT = new RegExp(`^commit\\s+([^\\s[]+)(?:\\s+${ON}\\s+([^\\s[]+))?(?:\\s+${COPY}\\s+([^\\s[]+))?(?:\\s+${MERGE}\\s+([^\\s[]+))?`, "du");
6804
+ var CUT = new RegExp(`^([^\\s[]+)\\s+${FROM}(?:\\s+([^\\s[]+))?\\s*$`, "du");
6805
+ var HASH = /^[0-9a-f]{4,40}$/u;
5049
6806
  var isOneOf = (list2, word) => list2.includes(word);
5050
6807
  function skipSpaces(text2, at2) {
5051
6808
  let i = at2;
@@ -5194,6 +6951,10 @@ function parseLines(lines, m) {
5194
6951
  if (shown && !isOneOf(VIEWS, shown.value)) throw fail(head, shown.at, m.badView);
5195
6952
  const view = shown?.value;
5196
6953
  const isState = kind === "state";
6954
+ const isGit = kind === "git";
6955
+ const branches = [];
6956
+ const commits = /* @__PURE__ */ new Set();
6957
+ const tips = /* @__PURE__ */ new Map();
5197
6958
  const regions = [];
5198
6959
  const boxes = [];
5199
6960
  const paths = [];
@@ -5210,13 +6971,27 @@ function parseLines(lines, m) {
5210
6971
  if (!boxes.some((box) => box.id === id)) throw fail(source, at2, m.undeclaredBox(id));
5211
6972
  return id;
5212
6973
  };
6974
+ const branchAt = (source, id, at2) => {
6975
+ if (!tips.has(id)) throw fail(source, at2, m.undeclaredBranch(id));
6976
+ return id;
6977
+ };
6978
+ const commitAt = (source, id, at2) => {
6979
+ if (!commits.has(id)) throw fail(source, at2, m.noCommit(id));
6980
+ return id;
6981
+ };
5213
6982
  const endAt = (source, id, at2, side2) => {
6983
+ if (isGit) {
6984
+ if (side2 === "to") return commitAt(source, id, at2);
6985
+ if (id !== HEAD && !tips.has(id)) throw fail(source, at2, m.undeclaredRef(id));
6986
+ return id;
6987
+ }
5214
6988
  if (!isState || !isOneOf(STATE_ENDS, id)) return boxAt(source, id, at2);
5215
6989
  if (id === "start" !== (side2 === "from")) throw fail(source, at2, id === "start" ? m.intoStart : m.outOfFinish);
5216
6990
  return id;
5217
6991
  };
5218
6992
  const notReserved = (source, id, at2) => {
5219
6993
  if (isState && isOneOf(STATE_ENDS, id)) throw fail(source, at2, m.reservedId(id));
6994
+ if (isGit && id === HEAD) throw fail(source, at2, m.headReserved(id));
5220
6995
  };
5221
6996
  const inStep = (source) => {
5222
6997
  if (!building) throw fail(source, 0, m.stepLineBeforeStep);
@@ -5246,7 +7021,13 @@ function parseLines(lines, m) {
5246
7021
  else inStep(source).events.push(readEdge(source, edge2));
5247
7022
  continue;
5248
7023
  }
5249
- const word = text2.split(/\s/u)[0] ?? "";
7024
+ const [word = "", second] = text2.split(/\s+/u);
7025
+ if (isGit && tips.has(word) && second === FROM) {
7026
+ const step = inStep(source);
7027
+ step.events.push(readCut(source));
7028
+ continue;
7029
+ }
7030
+ if (!isGit && (word === "branch" || word === "commit")) throw fail(source, 0, m.gitOnly(word));
5250
7031
  if (!isOneOf(HEADS, word)) {
5251
7032
  const old = oldForm(text2, building !== void 0);
5252
7033
  throw fail(source, 0, old ? m.oldForm(old.word, old.shape) : m.unknownHead(word));
@@ -5300,11 +7081,20 @@ function parseLines(lines, m) {
5300
7081
  case "set":
5301
7082
  inStep(source).events.push(readSet(source));
5302
7083
  break;
7084
+ case "branch":
7085
+ readBranch(source);
7086
+ break;
7087
+ case "commit": {
7088
+ const step = inStep(source);
7089
+ step.events.push(readCommit(source));
7090
+ break;
7091
+ }
5303
7092
  }
5304
7093
  }
5305
7094
  if (group) throw fail(group.source, 0, m.unclosedGroup(group.id));
5306
7095
  finish();
5307
- if (boxes.length === 0) throw fail(head, 0, m.noBoxes);
7096
+ if (isGit && branches.length === 0) throw fail(head, 0, m.noBranches);
7097
+ if (boxes.length === 0 && !isGit) throw fail(head, 0, m.noBoxes);
5308
7098
  if (steps.length === 0) throw fail(head, 0, m.noSteps);
5309
7099
  return {
5310
7100
  version: FORMAT_VERSION,
@@ -5316,10 +7106,12 @@ function parseLines(lines, m) {
5316
7106
  ...strip2 ? { strip: strip2 } : {},
5317
7107
  steps,
5318
7108
  ...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {},
5319
- ...paths.length > 0 ? { state: { paths } } : {}
7109
+ ...paths.length > 0 ? { state: { paths } } : {},
7110
+ ...isGit ? { git: { branches } } : {}
5320
7111
  };
5321
7112
  function readGroup(source) {
5322
7113
  beforeSteps(source);
7114
+ if (isGit) throw fail(source, 0, m.gitNoGroup);
5323
7115
  if (group) throw fail(source, 0, m.nestedGroup);
5324
7116
  const declared = readDeclared(source, "group", ATTRS.group, m);
5325
7117
  if (regions.some((region) => region.id === declared.id)) {
@@ -5345,6 +7137,62 @@ function parseLines(lines, m) {
5345
7137
  ...group ? { region: group.id } : {}
5346
7138
  });
5347
7139
  }
7140
+ function readBranch(source) {
7141
+ beforeSteps(source);
7142
+ const declared = readDeclared(source, "branch", ATTRS.branch, m);
7143
+ if (declared.name !== void 0) throw fail(source, 0, m.branchShape);
7144
+ notReserved(source, declared.id, declared.idAt);
7145
+ declare(source, declared.id, declared.idAt);
7146
+ const note = declared.attrs.get("note")?.value;
7147
+ branches.push({ id: declared.id, ...note !== void 0 ? { note } : {} });
7148
+ tips.set(declared.id, null);
7149
+ }
7150
+ function readCommit(source) {
7151
+ const text2 = source.text;
7152
+ const found = COMMIT.exec(text2);
7153
+ const at2 = (k) => found?.indices?.[k]?.[0] ?? 0;
7154
+ const id = found?.[1];
7155
+ const on = found?.[2];
7156
+ if (!found || id === void 0 || on === void 0) throw fail(source, 0, m.commitShape);
7157
+ const rest2 = skipSpaces(text2, found[0].length);
7158
+ if (rest2 < text2.length && text2[rest2] !== "[") throw fail(source, rest2, m.commitShape);
7159
+ if (!ID.test(id)) throw fail(source, at2(1), m.badId(id));
7160
+ notReserved(source, id, at2(1));
7161
+ declare(source, id, at2(1));
7162
+ const branch = branchAt(source, on, at2(2));
7163
+ const copy = found[3] === void 0 ? void 0 : commitAt(source, found[3], at2(3));
7164
+ const merge = found[4] === void 0 ? void 0 : mergedAt(source, found[4], at2(4), branch);
7165
+ const attrs = rest2 < text2.length ? readAttrs(source, rest2, ATTRS.commit, m) : /* @__PURE__ */ new Map();
7166
+ const hash = attrs.get("hash");
7167
+ if (hash && !HASH.test(hash.value)) throw fail(source, hash.at, m.badHash);
7168
+ const note = attrs.get("note")?.value;
7169
+ commits.add(id);
7170
+ if (copy === void 0) tips.set(branch, id);
7171
+ return {
7172
+ type: "commit",
7173
+ id,
7174
+ branch,
7175
+ ...copy !== void 0 ? { copy } : {},
7176
+ ...merge !== void 0 ? { merge } : {},
7177
+ ...hash ? { hash: hash.value } : {},
7178
+ ...note !== void 0 ? { note } : {}
7179
+ };
7180
+ }
7181
+ function mergedAt(source, id, at2, into) {
7182
+ branchAt(source, id, at2);
7183
+ if (id === into) throw fail(source, at2, m.mergeSelf(id));
7184
+ if (tips.get(id) === null) throw fail(source, at2, m.emptyBranch(id));
7185
+ return id;
7186
+ }
7187
+ function readCut(source) {
7188
+ const found = CUT.exec(source.text);
7189
+ const branch = found?.[1];
7190
+ const from = found?.[2];
7191
+ if (!found || branch === void 0 || from === void 0) throw fail(source, 0, m.fromShape);
7192
+ commitAt(source, from, found.indices?.[2]?.[0] ?? 0);
7193
+ tips.set(branch, from);
7194
+ return { type: "branch", branch, from };
7195
+ }
5348
7196
  function readStrip(source) {
5349
7197
  beforeSteps(source);
5350
7198
  if (strip2) throw fail(source, 0, m.stripTwice);
@@ -5418,9 +7266,10 @@ function parseLines(lines, m) {
5418
7266
  if (carried && !isOneOf(CARRIES, carried.value)) throw fail(source, carried.at, m.badCarry);
5419
7267
  const side2 = attrs.get("side");
5420
7268
  if (side2 && !isOneOf(SIDES, side2.value)) throw fail(source, side2.at, m.badSide);
5421
- let carry = { kind: "envelope" };
7269
+ let carry = isGit ? { kind: "tag", text: from } : { kind: "envelope" };
5422
7270
  if (tag) carry = { kind: "tag", text: tag.value };
5423
7271
  else if (carried) carry = carried.value === "coin" ? { kind: "coin" } : { kind: "none" };
7272
+ if (isGit && from !== HEAD) tips.set(from, to);
5424
7273
  return {
5425
7274
  type: "edge",
5426
7275
  from,
@@ -5508,7 +7357,8 @@ var CLI_TEXT = {
5508
7357
  badJson: (path2, detail2) => `JSON \u3068\u3057\u3066\u8AAD\u3081\u306A\u3044: ${path2} (${detail2})`,
5509
7358
  cannotWrite: (path2, detail2) => `\u66F8\u304D\u51FA\u305B\u306A\u3044: ${path2} (${detail2})`,
5510
7359
  badValue: (option, value, allowed) => `\u4F7F\u3048\u306A\u3044\u5024: ${option} ${value} (${allowed})`,
5511
- allowed: { lang: "ja \u304B en", theme: "light \u304B dark", positive: "0 \u3088\u308A\u5927\u304D\u3044\u6570", format: `${FORMATS.join(" / ")} \u3092 , \u3067\u533A\u5207\u308B` }
7360
+ allowed: { lang: "ja \u304B en", theme: "light \u304B dark", positive: "0 \u3088\u308A\u5927\u304D\u3044\u6570", format: `${FORMATS.join(" / ")} \u3092 , \u3067\u533A\u5207\u308B` },
7361
+ overlap: (step, text2) => `\u6BB5 ${step}: ${text2}`
5512
7362
  },
5513
7363
  en: {
5514
7364
  usage: [
@@ -5530,7 +7380,8 @@ var CLI_TEXT = {
5530
7380
  badJson: (path2, detail2) => `Cannot read as JSON: ${path2} (${detail2})`,
5531
7381
  cannotWrite: (path2, detail2) => `Cannot write: ${path2} (${detail2})`,
5532
7382
  badValue: (option, value, allowed) => `Invalid value: ${option} ${value} (${allowed})`,
5533
- allowed: { lang: "ja or en", theme: "light or dark", positive: "a number above 0", format: `${FORMATS.join(" / ")} separated by ,` }
7383
+ allowed: { lang: "ja or en", theme: "light or dark", positive: "a number above 0", format: `${FORMATS.join(" / ")} separated by ,` },
7384
+ overlap: (step, text2) => `Step ${step}: ${text2}`
5534
7385
  }
5535
7386
  };
5536
7387
  var isLang = (value) => value === "ja" || value === "en";
@@ -5644,6 +7495,8 @@ ${early.usage}`);
5644
7495
  throw error instanceof Error ? error : new Error(String(error));
5645
7496
  }
5646
7497
  for (const path2 of Object.values(result.files)) console.log(path2);
7498
+ const said = lang ?? "ja";
7499
+ for (const overlap of result.overlaps) console.error(CLI_TEXT[said].overlap(overlap.step + 1, describeOverlap(overlap, said)));
5647
7500
  return 0;
5648
7501
  }
5649
7502
  main(process.argv.slice(2)).then(