@cardenelabs/dragon 0.39.0 → 0.41.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 (44) hide show
  1. package/README.md +39 -1
  2. package/dist/cli.cjs +1921 -429
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +1926 -434
  5. package/dist/cli.js.map +1 -1
  6. package/dist/export.cjs +1718 -353
  7. package/dist/export.cjs.map +1 -1
  8. package/dist/export.d.cts +1 -1
  9. package/dist/export.d.ts +1 -1
  10. package/dist/export.js +1723 -358
  11. package/dist/export.js.map +1 -1
  12. package/dist/index.cjs +1835 -342
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +5 -15
  15. package/dist/index.d.ts +5 -15
  16. package/dist/index.js +1836 -342
  17. package/dist/index.js.map +1 -1
  18. package/dist/{ink-Cg-v6XSG.d.cts → ink-B_7OXxtb.d.cts} +27 -2
  19. package/dist/{ink-Cg-v6XSG.d.ts → ink-B_7OXxtb.d.ts} +27 -2
  20. package/dist/node.cjs +2946 -0
  21. package/dist/node.cjs.map +1 -0
  22. package/dist/node.d.cts +9 -0
  23. package/dist/node.d.ts +9 -0
  24. package/dist/node.js +2944 -0
  25. package/dist/node.js.map +1 -0
  26. package/dist/player.global.js +2 -2
  27. package/package.json +11 -1
  28. package/src/field-messages.ts +8 -0
  29. package/src/index.ts +5 -2
  30. package/src/layout/git.ts +728 -0
  31. package/src/look/values.ts +40 -1
  32. package/src/messages.ts +47 -4
  33. package/src/node.ts +23 -0
  34. package/src/parser.ts +142 -7
  35. package/src/printer.ts +16 -4
  36. package/src/render/git.ts +161 -0
  37. package/src/render/parts.ts +1 -1
  38. package/src/render/svg.ts +26 -1
  39. package/src/schema.ts +47 -13
  40. package/src/schemas/diagram.schema.json +75 -8
  41. package/src/schemas/validate-diagram.js +1 -1
  42. package/src/timeline.ts +18 -3
  43. package/src/version.ts +1 -20
  44. package/src/words.ts +19 -3
package/dist/index.cjs CHANGED
@@ -56,6 +56,8 @@ var ja = {
56
56
  const: (value2) => `${value2} \u306B\u3059\u308B`,
57
57
  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",
58
58
  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`,
59
+ kindOnly: (types, kind) => `${types.join(" \u3068 ")} \u306E\u51FA\u6765\u4E8B\u306F kind \u304C ${kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B`,
60
+ hex: (min, max) => `0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 ${min} \u304B\u3089 ${max} \u5B57\u306B\u3059\u308B`,
59
61
  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",
60
62
  oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
61
63
  discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
@@ -73,6 +75,8 @@ var en = {
73
75
  const: (value2) => `Use ${value2}`,
74
76
  not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
75
77
  reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
78
+ kindOnly: (types, kind) => `${types.join(" and ")} events are allowed only when kind is ${kind}`,
79
+ hex: (min, max) => `Use ${min} to ${max} characters of 0-9 and a-f`,
76
80
  anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
77
81
  oneOf: "Match exactly one of the allowed shapes",
78
82
  discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
@@ -87,10 +91,10 @@ function ucs2length(str) {
87
91
  return length;
88
92
  }
89
93
  var validate_diagram_default = validate10;
90
- 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" } }};
94
+ 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" } }};
91
95
  var func2 = Object.prototype.hasOwnProperty;
92
96
  var func3 = ucs2length;
93
- var schema17 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
97
+ var schema28 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
94
98
  var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
95
99
  function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
96
100
  let vErrors = null;
@@ -194,7 +198,7 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
194
198
  if (data.color !== void 0) {
195
199
  let data3 = data.color;
196
200
  if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
197
- 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" };
201
+ 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" };
198
202
  if (vErrors === null) {
199
203
  vErrors = [err9];
200
204
  } else {
@@ -339,7 +343,7 @@ function validate13(data, { instancePath = "", parentData, parentDataProperty, r
339
343
  if (data.color !== void 0) {
340
344
  let data3 = data.color;
341
345
  if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
342
- 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" };
346
+ 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" };
343
347
  if (vErrors === null) {
344
348
  vErrors = [err9];
345
349
  } else {
@@ -516,8 +520,9 @@ function validate15(data, { instancePath = "", parentData, parentDataProperty, r
516
520
  validate15.errors = vErrors;
517
521
  return errors === 0;
518
522
  }
519
- 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" } } }] };
520
- var schema37 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
523
+ 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" } } }] };
524
+ var pattern11 = new RegExp("^[0-9a-f]{4,40}$", "u");
525
+ var schema48 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
521
526
  function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
522
527
  let vErrors = null;
523
528
  let errors = 0;
@@ -644,7 +649,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
644
649
  if (data.kind !== void 0) {
645
650
  let data1 = data.kind;
646
651
  if (!(data1 === "envelope" || data1 === "tag" || data1 === "coin" || data1 === "none")) {
647
- 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" };
652
+ 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" };
648
653
  if (vErrors === null) {
649
654
  vErrors = [err8];
650
655
  } else {
@@ -837,7 +842,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
837
842
  if (data.labelSide !== void 0) {
838
843
  let data5 = data.labelSide;
839
844
  if (!(data5 === "above" || data5 === "below" || data5 === "left" || data5 === "right")) {
840
- 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" };
845
+ 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" };
841
846
  if (vErrors === null) {
842
847
  vErrors = [err13];
843
848
  } else {
@@ -1063,13 +1068,10 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
1063
1068
  }
1064
1069
  errors++;
1065
1070
  }
1066
- } else if (tag0 === "strip") {
1067
- const _errs39 = errors;
1068
- let valid15 = false;
1069
- const _errs40 = errors;
1071
+ } else if (tag0 === "commit") {
1070
1072
  if (data && typeof data == "object" && !Array.isArray(data)) {
1071
- if (data.value === void 0) {
1072
- const err35 = { instancePath, schemaPath: "#/oneOf/3/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
1073
+ if (data.type === void 0) {
1074
+ const err35 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
1073
1075
  if (vErrors === null) {
1074
1076
  vErrors = [err35];
1075
1077
  } else {
@@ -1077,38 +1079,337 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
1077
1079
  }
1078
1080
  errors++;
1079
1081
  }
1082
+ if (data.id === void 0) {
1083
+ const err36 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
1084
+ if (vErrors === null) {
1085
+ vErrors = [err36];
1086
+ } else {
1087
+ vErrors.push(err36);
1088
+ }
1089
+ errors++;
1090
+ }
1091
+ if (data.branch === void 0) {
1092
+ const err37 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
1093
+ if (vErrors === null) {
1094
+ vErrors = [err37];
1095
+ } else {
1096
+ vErrors.push(err37);
1097
+ }
1098
+ errors++;
1099
+ }
1100
+ for (const key3 in data) {
1101
+ if (!(key3 === "type" || key3 === "id" || key3 === "branch" || key3 === "copy" || key3 === "merge" || key3 === "hash" || key3 === "note")) {
1102
+ const err38 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
1103
+ if (vErrors === null) {
1104
+ vErrors = [err38];
1105
+ } else {
1106
+ vErrors.push(err38);
1107
+ }
1108
+ errors++;
1109
+ }
1110
+ }
1111
+ if (data.type !== void 0) {
1112
+ if ("commit" !== data.type) {
1113
+ const err39 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "commit" }, message: "must be equal to constant" };
1114
+ if (vErrors === null) {
1115
+ vErrors = [err39];
1116
+ } else {
1117
+ vErrors.push(err39);
1118
+ }
1119
+ errors++;
1120
+ }
1121
+ }
1122
+ if (data.id !== void 0) {
1123
+ let data13 = data.id;
1124
+ if (typeof data13 === "string") {
1125
+ if (!pattern0.test(data13)) {
1126
+ const err40 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1127
+ if (vErrors === null) {
1128
+ vErrors = [err40];
1129
+ } else {
1130
+ vErrors.push(err40);
1131
+ }
1132
+ errors++;
1133
+ }
1134
+ } else {
1135
+ const err41 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1136
+ if (vErrors === null) {
1137
+ vErrors = [err41];
1138
+ } else {
1139
+ vErrors.push(err41);
1140
+ }
1141
+ errors++;
1142
+ }
1143
+ }
1144
+ if (data.branch !== void 0) {
1145
+ let data14 = data.branch;
1146
+ if (typeof data14 === "string") {
1147
+ if (!pattern0.test(data14)) {
1148
+ const err42 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1149
+ if (vErrors === null) {
1150
+ vErrors = [err42];
1151
+ } else {
1152
+ vErrors.push(err42);
1153
+ }
1154
+ errors++;
1155
+ }
1156
+ } else {
1157
+ const err43 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1158
+ if (vErrors === null) {
1159
+ vErrors = [err43];
1160
+ } else {
1161
+ vErrors.push(err43);
1162
+ }
1163
+ errors++;
1164
+ }
1165
+ }
1166
+ if (data.copy !== void 0) {
1167
+ let data15 = data.copy;
1168
+ if (typeof data15 === "string") {
1169
+ if (!pattern0.test(data15)) {
1170
+ const err44 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1171
+ if (vErrors === null) {
1172
+ vErrors = [err44];
1173
+ } else {
1174
+ vErrors.push(err44);
1175
+ }
1176
+ errors++;
1177
+ }
1178
+ } else {
1179
+ const err45 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1180
+ if (vErrors === null) {
1181
+ vErrors = [err45];
1182
+ } else {
1183
+ vErrors.push(err45);
1184
+ }
1185
+ errors++;
1186
+ }
1187
+ }
1188
+ if (data.merge !== void 0) {
1189
+ let data16 = data.merge;
1190
+ if (typeof data16 === "string") {
1191
+ if (!pattern0.test(data16)) {
1192
+ const err46 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1193
+ if (vErrors === null) {
1194
+ vErrors = [err46];
1195
+ } else {
1196
+ vErrors.push(err46);
1197
+ }
1198
+ errors++;
1199
+ }
1200
+ } else {
1201
+ const err47 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1202
+ if (vErrors === null) {
1203
+ vErrors = [err47];
1204
+ } else {
1205
+ vErrors.push(err47);
1206
+ }
1207
+ errors++;
1208
+ }
1209
+ }
1210
+ if (data.hash !== void 0) {
1211
+ let data17 = data.hash;
1212
+ if (typeof data17 === "string") {
1213
+ if (!pattern11.test(data17)) {
1214
+ 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}$"' };
1215
+ if (vErrors === null) {
1216
+ vErrors = [err48];
1217
+ } else {
1218
+ vErrors.push(err48);
1219
+ }
1220
+ errors++;
1221
+ }
1222
+ } else {
1223
+ const err49 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1224
+ if (vErrors === null) {
1225
+ vErrors = [err49];
1226
+ } else {
1227
+ vErrors.push(err49);
1228
+ }
1229
+ errors++;
1230
+ }
1231
+ }
1232
+ if (data.note !== void 0) {
1233
+ let data18 = data.note;
1234
+ if (typeof data18 === "string") {
1235
+ if (func3(data18) < 1) {
1236
+ const err50 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1237
+ if (vErrors === null) {
1238
+ vErrors = [err50];
1239
+ } else {
1240
+ vErrors.push(err50);
1241
+ }
1242
+ errors++;
1243
+ }
1244
+ } else {
1245
+ const err51 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1246
+ if (vErrors === null) {
1247
+ vErrors = [err51];
1248
+ } else {
1249
+ vErrors.push(err51);
1250
+ }
1251
+ errors++;
1252
+ }
1253
+ }
1254
+ } else {
1255
+ const err52 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1256
+ if (vErrors === null) {
1257
+ vErrors = [err52];
1258
+ } else {
1259
+ vErrors.push(err52);
1260
+ }
1261
+ errors++;
1262
+ }
1263
+ } else if (tag0 === "branch") {
1264
+ if (data && typeof data == "object" && !Array.isArray(data)) {
1265
+ if (data.type === void 0) {
1266
+ const err53 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
1267
+ if (vErrors === null) {
1268
+ vErrors = [err53];
1269
+ } else {
1270
+ vErrors.push(err53);
1271
+ }
1272
+ errors++;
1273
+ }
1274
+ if (data.branch === void 0) {
1275
+ const err54 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
1276
+ if (vErrors === null) {
1277
+ vErrors = [err54];
1278
+ } else {
1279
+ vErrors.push(err54);
1280
+ }
1281
+ errors++;
1282
+ }
1283
+ if (data.from === void 0) {
1284
+ const err55 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
1285
+ if (vErrors === null) {
1286
+ vErrors = [err55];
1287
+ } else {
1288
+ vErrors.push(err55);
1289
+ }
1290
+ errors++;
1291
+ }
1292
+ for (const key4 in data) {
1293
+ if (!(key4 === "type" || key4 === "branch" || key4 === "from")) {
1294
+ const err56 = { instancePath, schemaPath: "#/oneOf/4/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key4 }, message: "must NOT have additional properties" };
1295
+ if (vErrors === null) {
1296
+ vErrors = [err56];
1297
+ } else {
1298
+ vErrors.push(err56);
1299
+ }
1300
+ errors++;
1301
+ }
1302
+ }
1303
+ if (data.type !== void 0) {
1304
+ if ("branch" !== data.type) {
1305
+ const err57 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/4/properties/type/const", keyword: "const", params: { allowedValue: "branch" }, message: "must be equal to constant" };
1306
+ if (vErrors === null) {
1307
+ vErrors = [err57];
1308
+ } else {
1309
+ vErrors.push(err57);
1310
+ }
1311
+ errors++;
1312
+ }
1313
+ }
1314
+ if (data.branch !== void 0) {
1315
+ let data20 = data.branch;
1316
+ if (typeof data20 === "string") {
1317
+ if (!pattern0.test(data20)) {
1318
+ const err58 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1319
+ if (vErrors === null) {
1320
+ vErrors = [err58];
1321
+ } else {
1322
+ vErrors.push(err58);
1323
+ }
1324
+ errors++;
1325
+ }
1326
+ } else {
1327
+ const err59 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1328
+ if (vErrors === null) {
1329
+ vErrors = [err59];
1330
+ } else {
1331
+ vErrors.push(err59);
1332
+ }
1333
+ errors++;
1334
+ }
1335
+ }
1336
+ if (data.from !== void 0) {
1337
+ let data21 = data.from;
1338
+ if (typeof data21 === "string") {
1339
+ if (!pattern0.test(data21)) {
1340
+ const err60 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1341
+ if (vErrors === null) {
1342
+ vErrors = [err60];
1343
+ } else {
1344
+ vErrors.push(err60);
1345
+ }
1346
+ errors++;
1347
+ }
1348
+ } else {
1349
+ const err61 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1350
+ if (vErrors === null) {
1351
+ vErrors = [err61];
1352
+ } else {
1353
+ vErrors.push(err61);
1354
+ }
1355
+ errors++;
1356
+ }
1357
+ }
1358
+ } else {
1359
+ const err62 = { instancePath, schemaPath: "#/oneOf/4/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1360
+ if (vErrors === null) {
1361
+ vErrors = [err62];
1362
+ } else {
1363
+ vErrors.push(err62);
1364
+ }
1365
+ errors++;
1080
1366
  }
1081
- var _valid0 = _errs40 === errors;
1082
- valid15 = valid15 || _valid0;
1083
- if (!valid15) {
1084
- const _errs41 = errors;
1367
+ } else if (tag0 === "strip") {
1368
+ const _errs71 = errors;
1369
+ let valid27 = false;
1370
+ const _errs72 = errors;
1371
+ if (data && typeof data == "object" && !Array.isArray(data)) {
1372
+ if (data.value === void 0) {
1373
+ const err63 = { instancePath, schemaPath: "#/oneOf/5/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
1374
+ if (vErrors === null) {
1375
+ vErrors = [err63];
1376
+ } else {
1377
+ vErrors.push(err63);
1378
+ }
1379
+ errors++;
1380
+ }
1381
+ }
1382
+ var _valid0 = _errs72 === errors;
1383
+ valid27 = valid27 || _valid0;
1384
+ if (!valid27) {
1385
+ const _errs73 = errors;
1085
1386
  if (data && typeof data == "object" && !Array.isArray(data)) {
1086
1387
  if (data.tag === void 0) {
1087
- const err36 = { instancePath, schemaPath: "#/oneOf/3/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
1388
+ const err64 = { instancePath, schemaPath: "#/oneOf/5/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
1088
1389
  if (vErrors === null) {
1089
- vErrors = [err36];
1390
+ vErrors = [err64];
1090
1391
  } else {
1091
- vErrors.push(err36);
1392
+ vErrors.push(err64);
1092
1393
  }
1093
1394
  errors++;
1094
1395
  }
1095
1396
  }
1096
- var _valid0 = _errs41 === errors;
1097
- valid15 = valid15 || _valid0;
1397
+ var _valid0 = _errs73 === errors;
1398
+ valid27 = valid27 || _valid0;
1098
1399
  }
1099
- if (!valid15) {
1100
- const err37 = { instancePath, schemaPath: "#/oneOf/3/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
1400
+ if (!valid27) {
1401
+ const err65 = { instancePath, schemaPath: "#/oneOf/5/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
1101
1402
  if (vErrors === null) {
1102
- vErrors = [err37];
1403
+ vErrors = [err65];
1103
1404
  } else {
1104
- vErrors.push(err37);
1405
+ vErrors.push(err65);
1105
1406
  }
1106
1407
  errors++;
1107
1408
  } else {
1108
- errors = _errs39;
1409
+ errors = _errs71;
1109
1410
  if (vErrors !== null) {
1110
- if (_errs39) {
1111
- vErrors.length = _errs39;
1411
+ if (_errs71) {
1412
+ vErrors.length = _errs71;
1112
1413
  } else {
1113
1414
  vErrors = null;
1114
1415
  }
@@ -1116,144 +1417,144 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
1116
1417
  }
1117
1418
  if (data && typeof data == "object" && !Array.isArray(data)) {
1118
1419
  if (data.type === void 0) {
1119
- const err38 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
1420
+ const err66 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
1120
1421
  if (vErrors === null) {
1121
- vErrors = [err38];
1422
+ vErrors = [err66];
1122
1423
  } else {
1123
- vErrors.push(err38);
1424
+ vErrors.push(err66);
1124
1425
  }
1125
1426
  errors++;
1126
1427
  }
1127
1428
  if (data.field === void 0) {
1128
- const err39 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
1429
+ const err67 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
1129
1430
  if (vErrors === null) {
1130
- vErrors = [err39];
1431
+ vErrors = [err67];
1131
1432
  } else {
1132
- vErrors.push(err39);
1433
+ vErrors.push(err67);
1133
1434
  }
1134
1435
  errors++;
1135
1436
  }
1136
- for (const key3 in data) {
1137
- if (!(key3 === "type" || key3 === "field" || key3 === "value" || key3 === "tag")) {
1138
- const err40 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
1437
+ for (const key5 in data) {
1438
+ if (!(key5 === "type" || key5 === "field" || key5 === "value" || key5 === "tag")) {
1439
+ const err68 = { instancePath, schemaPath: "#/oneOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
1139
1440
  if (vErrors === null) {
1140
- vErrors = [err40];
1441
+ vErrors = [err68];
1141
1442
  } else {
1142
- vErrors.push(err40);
1443
+ vErrors.push(err68);
1143
1444
  }
1144
1445
  errors++;
1145
1446
  }
1146
1447
  }
1147
1448
  if (data.type !== void 0) {
1148
1449
  if ("strip" !== data.type) {
1149
- const err41 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
1450
+ const err69 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/5/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
1150
1451
  if (vErrors === null) {
1151
- vErrors = [err41];
1452
+ vErrors = [err69];
1152
1453
  } else {
1153
- vErrors.push(err41);
1454
+ vErrors.push(err69);
1154
1455
  }
1155
1456
  errors++;
1156
1457
  }
1157
1458
  }
1158
1459
  if (data.field !== void 0) {
1159
- let data13 = data.field;
1160
- if (typeof data13 === "string") {
1161
- if (func3(data13) < 1) {
1162
- const err42 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1460
+ let data23 = data.field;
1461
+ if (typeof data23 === "string") {
1462
+ if (func3(data23) < 1) {
1463
+ const err70 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1163
1464
  if (vErrors === null) {
1164
- vErrors = [err42];
1465
+ vErrors = [err70];
1165
1466
  } else {
1166
- vErrors.push(err42);
1467
+ vErrors.push(err70);
1167
1468
  }
1168
1469
  errors++;
1169
1470
  }
1170
1471
  } else {
1171
- const err43 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1472
+ const err71 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1172
1473
  if (vErrors === null) {
1173
- vErrors = [err43];
1474
+ vErrors = [err71];
1174
1475
  } else {
1175
- vErrors.push(err43);
1476
+ vErrors.push(err71);
1176
1477
  }
1177
1478
  errors++;
1178
1479
  }
1179
1480
  }
1180
1481
  if (data.value !== void 0) {
1181
- let data14 = data.value;
1182
- if (typeof data14 === "string") {
1183
- if (func3(data14) < 1) {
1184
- const err44 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1482
+ let data24 = data.value;
1483
+ if (typeof data24 === "string") {
1484
+ if (func3(data24) < 1) {
1485
+ const err72 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1185
1486
  if (vErrors === null) {
1186
- vErrors = [err44];
1487
+ vErrors = [err72];
1187
1488
  } else {
1188
- vErrors.push(err44);
1489
+ vErrors.push(err72);
1189
1490
  }
1190
1491
  errors++;
1191
1492
  }
1192
1493
  } else {
1193
- const err45 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1494
+ const err73 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1194
1495
  if (vErrors === null) {
1195
- vErrors = [err45];
1496
+ vErrors = [err73];
1196
1497
  } else {
1197
- vErrors.push(err45);
1498
+ vErrors.push(err73);
1198
1499
  }
1199
1500
  errors++;
1200
1501
  }
1201
1502
  }
1202
1503
  if (data.tag !== void 0) {
1203
- let data15 = data.tag;
1204
- if (typeof data15 === "string") {
1205
- if (func3(data15) < 1) {
1206
- const err46 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1504
+ let data25 = data.tag;
1505
+ if (typeof data25 === "string") {
1506
+ if (func3(data25) < 1) {
1507
+ const err74 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1207
1508
  if (vErrors === null) {
1208
- vErrors = [err46];
1509
+ vErrors = [err74];
1209
1510
  } else {
1210
- vErrors.push(err46);
1511
+ vErrors.push(err74);
1211
1512
  }
1212
1513
  errors++;
1213
1514
  }
1214
1515
  } else {
1215
- const err47 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1516
+ const err75 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1216
1517
  if (vErrors === null) {
1217
- vErrors = [err47];
1518
+ vErrors = [err75];
1218
1519
  } else {
1219
- vErrors.push(err47);
1520
+ vErrors.push(err75);
1220
1521
  }
1221
1522
  errors++;
1222
1523
  }
1223
1524
  }
1224
1525
  } else {
1225
- const err48 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1526
+ const err76 = { instancePath, schemaPath: "#/oneOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1226
1527
  if (vErrors === null) {
1227
- vErrors = [err48];
1528
+ vErrors = [err76];
1228
1529
  } else {
1229
- vErrors.push(err48);
1530
+ vErrors.push(err76);
1230
1531
  }
1231
1532
  errors++;
1232
1533
  }
1233
1534
  } else {
1234
- const err49 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
1535
+ const err77 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
1235
1536
  if (vErrors === null) {
1236
- vErrors = [err49];
1537
+ vErrors = [err77];
1237
1538
  } else {
1238
- vErrors.push(err49);
1539
+ vErrors.push(err77);
1239
1540
  }
1240
1541
  errors++;
1241
1542
  }
1242
1543
  } else {
1243
- const err50 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
1544
+ const err78 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
1244
1545
  if (vErrors === null) {
1245
- vErrors = [err50];
1546
+ vErrors = [err78];
1246
1547
  } else {
1247
- vErrors.push(err50);
1548
+ vErrors.push(err78);
1248
1549
  }
1249
1550
  errors++;
1250
1551
  }
1251
1552
  } else {
1252
- const err51 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1553
+ const err79 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1253
1554
  if (vErrors === null) {
1254
- vErrors = [err51];
1555
+ vErrors = [err79];
1255
1556
  } else {
1256
- vErrors.push(err51);
1557
+ vErrors.push(err79);
1257
1558
  }
1258
1559
  errors++;
1259
1560
  }
@@ -1657,6 +1958,151 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
1657
1958
  validate25.errors = vErrors;
1658
1959
  return errors === 0;
1659
1960
  }
1961
+ function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
1962
+ let vErrors = null;
1963
+ let errors = 0;
1964
+ if (data && typeof data == "object" && !Array.isArray(data)) {
1965
+ if (data.id === void 0) {
1966
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
1967
+ if (vErrors === null) {
1968
+ vErrors = [err0];
1969
+ } else {
1970
+ vErrors.push(err0);
1971
+ }
1972
+ errors++;
1973
+ }
1974
+ for (const key0 in data) {
1975
+ if (!(key0 === "id" || key0 === "note")) {
1976
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
1977
+ if (vErrors === null) {
1978
+ vErrors = [err1];
1979
+ } else {
1980
+ vErrors.push(err1);
1981
+ }
1982
+ errors++;
1983
+ }
1984
+ }
1985
+ if (data.id !== void 0) {
1986
+ let data0 = data.id;
1987
+ if (typeof data0 === "string") {
1988
+ if (!pattern0.test(data0)) {
1989
+ const err2 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1990
+ if (vErrors === null) {
1991
+ vErrors = [err2];
1992
+ } else {
1993
+ vErrors.push(err2);
1994
+ }
1995
+ errors++;
1996
+ }
1997
+ } else {
1998
+ const err3 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1999
+ if (vErrors === null) {
2000
+ vErrors = [err3];
2001
+ } else {
2002
+ vErrors.push(err3);
2003
+ }
2004
+ errors++;
2005
+ }
2006
+ }
2007
+ if (data.note !== void 0) {
2008
+ let data1 = data.note;
2009
+ if (typeof data1 === "string") {
2010
+ if (func3(data1) < 1) {
2011
+ const err4 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
2012
+ if (vErrors === null) {
2013
+ vErrors = [err4];
2014
+ } else {
2015
+ vErrors.push(err4);
2016
+ }
2017
+ errors++;
2018
+ }
2019
+ } else {
2020
+ const err5 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2021
+ if (vErrors === null) {
2022
+ vErrors = [err5];
2023
+ } else {
2024
+ vErrors.push(err5);
2025
+ }
2026
+ errors++;
2027
+ }
2028
+ }
2029
+ } else {
2030
+ const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2031
+ if (vErrors === null) {
2032
+ vErrors = [err6];
2033
+ } else {
2034
+ vErrors.push(err6);
2035
+ }
2036
+ errors++;
2037
+ }
2038
+ validate30.errors = vErrors;
2039
+ return errors === 0;
2040
+ }
2041
+ function validate29(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
2042
+ let vErrors = null;
2043
+ let errors = 0;
2044
+ if (data && typeof data == "object" && !Array.isArray(data)) {
2045
+ if (data.branches === void 0) {
2046
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "branches" }, message: "must have required property 'branches'" };
2047
+ if (vErrors === null) {
2048
+ vErrors = [err0];
2049
+ } else {
2050
+ vErrors.push(err0);
2051
+ }
2052
+ errors++;
2053
+ }
2054
+ for (const key0 in data) {
2055
+ if (!(key0 === "branches")) {
2056
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
2057
+ if (vErrors === null) {
2058
+ vErrors = [err1];
2059
+ } else {
2060
+ vErrors.push(err1);
2061
+ }
2062
+ errors++;
2063
+ }
2064
+ }
2065
+ if (data.branches !== void 0) {
2066
+ let data0 = data.branches;
2067
+ if (Array.isArray(data0)) {
2068
+ if (data0.length < 1) {
2069
+ const err2 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2070
+ if (vErrors === null) {
2071
+ vErrors = [err2];
2072
+ } else {
2073
+ vErrors.push(err2);
2074
+ }
2075
+ errors++;
2076
+ }
2077
+ const len0 = data0.length;
2078
+ for (let i0 = 0; i0 < len0; i0++) {
2079
+ if (!validate30(data0[i0], { instancePath: instancePath + "/branches/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
2080
+ vErrors = vErrors === null ? validate30.errors : vErrors.concat(validate30.errors);
2081
+ errors = vErrors.length;
2082
+ }
2083
+ }
2084
+ } else {
2085
+ const err3 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2086
+ if (vErrors === null) {
2087
+ vErrors = [err3];
2088
+ } else {
2089
+ vErrors.push(err3);
2090
+ }
2091
+ errors++;
2092
+ }
2093
+ }
2094
+ } else {
2095
+ const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2096
+ if (vErrors === null) {
2097
+ vErrors = [err4];
2098
+ } else {
2099
+ vErrors.push(err4);
2100
+ }
2101
+ errors++;
2102
+ }
2103
+ validate29.errors = vErrors;
2104
+ return errors === 0;
2105
+ }
1660
2106
  function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
1661
2107
  let vErrors = null;
1662
2108
  let errors = 0;
@@ -1698,11 +2144,9 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
1698
2144
  let ifClause0;
1699
2145
  if (_valid0) {
1700
2146
  const _errs4 = errors;
1701
- const _errs5 = errors;
1702
- const _errs6 = errors;
1703
2147
  if (data && typeof data == "object" && !Array.isArray(data)) {
1704
- if (data.state === void 0 && ("state")) {
1705
- const err2 = {};
2148
+ if (data.sequence === void 0) {
2149
+ const err2 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
1706
2150
  if (vErrors === null) {
1707
2151
  vErrors = [err2];
1708
2152
  } else {
@@ -1710,147 +2154,181 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
1710
2154
  }
1711
2155
  errors++;
1712
2156
  }
1713
- }
1714
- var valid2 = _errs6 === errors;
1715
- if (valid2) {
1716
- const err3 = { instancePath, schemaPath: "#/then/not", keyword: "not", params: {}, message: "must NOT be valid" };
1717
- if (vErrors === null) {
1718
- vErrors = [err3];
1719
- } else {
1720
- vErrors.push(err3);
2157
+ if (data.boxes !== void 0) {
2158
+ let data1 = data.boxes;
2159
+ if (Array.isArray(data1)) {
2160
+ if (data1.length < 1) {
2161
+ const err3 = { instancePath: instancePath + "/boxes", schemaPath: "#/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2162
+ if (vErrors === null) {
2163
+ vErrors = [err3];
2164
+ } else {
2165
+ vErrors.push(err3);
2166
+ }
2167
+ errors++;
2168
+ }
2169
+ }
1721
2170
  }
1722
- errors++;
1723
- } else {
1724
- errors = _errs5;
1725
- if (vErrors !== null) {
1726
- if (_errs5) {
1727
- vErrors.length = _errs5;
1728
- } else {
1729
- vErrors = null;
2171
+ if (data.steps !== void 0) {
2172
+ let data2 = data.steps;
2173
+ if (Array.isArray(data2)) {
2174
+ const len0 = data2.length;
2175
+ for (let i0 = 0; i0 < len0; i0++) {
2176
+ let data3 = data2[i0];
2177
+ if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
2178
+ if (data3.events !== void 0) {
2179
+ let data4 = data3.events;
2180
+ if (Array.isArray(data4)) {
2181
+ const len1 = data4.length;
2182
+ for (let i1 = 0; i1 < len1; i1++) {
2183
+ let data5 = data4[i1];
2184
+ if (data5 && typeof data5 == "object" && !Array.isArray(data5)) {
2185
+ if (data5.type !== void 0) {
2186
+ let data6 = data5.type;
2187
+ const _errs12 = errors;
2188
+ const _errs13 = errors;
2189
+ if (!(data6 === "commit" || data6 === "branch")) {
2190
+ const err4 = {};
2191
+ if (vErrors === null) {
2192
+ vErrors = [err4];
2193
+ } else {
2194
+ vErrors.push(err4);
2195
+ }
2196
+ errors++;
2197
+ }
2198
+ var valid10 = _errs13 === errors;
2199
+ if (valid10) {
2200
+ 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" };
2201
+ if (vErrors === null) {
2202
+ vErrors = [err5];
2203
+ } else {
2204
+ vErrors.push(err5);
2205
+ }
2206
+ errors++;
2207
+ } else {
2208
+ errors = _errs12;
2209
+ if (vErrors !== null) {
2210
+ if (_errs12) {
2211
+ vErrors.length = _errs12;
2212
+ } else {
2213
+ vErrors = null;
2214
+ }
2215
+ }
2216
+ }
2217
+ }
2218
+ }
2219
+ }
2220
+ }
2221
+ }
2222
+ }
2223
+ }
1730
2224
  }
1731
2225
  }
1732
- }
1733
- if (data && typeof data == "object" && !Array.isArray(data)) {
1734
- if (data.sequence === void 0) {
1735
- const err4 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
2226
+ if (data.state !== void 0) {
2227
+ const err6 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
1736
2228
  if (vErrors === null) {
1737
- vErrors = [err4];
2229
+ vErrors = [err6];
1738
2230
  } else {
1739
- vErrors.push(err4);
2231
+ vErrors.push(err6);
1740
2232
  }
1741
2233
  errors++;
1742
2234
  }
1743
- }
1744
- var _valid0 = _errs4 === errors;
1745
- valid0 = _valid0;
1746
- ifClause0 = "then";
1747
- } else {
1748
- const _errs7 = errors;
1749
- const _errs8 = errors;
1750
- const _errs9 = errors;
1751
- if (data && typeof data == "object" && !Array.isArray(data)) {
1752
- if (data.sequence === void 0 && ("sequence")) {
1753
- const err5 = {};
2235
+ if (data.git !== void 0) {
2236
+ const err7 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
1754
2237
  if (vErrors === null) {
1755
- vErrors = [err5];
2238
+ vErrors = [err7];
1756
2239
  } else {
1757
- vErrors.push(err5);
2240
+ vErrors.push(err7);
1758
2241
  }
1759
2242
  errors++;
1760
2243
  }
1761
2244
  }
1762
- var valid3 = _errs9 === errors;
1763
- if (valid3) {
1764
- const err6 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
1765
- if (vErrors === null) {
1766
- vErrors = [err6];
1767
- } else {
1768
- vErrors.push(err6);
1769
- }
1770
- errors++;
1771
- } else {
1772
- errors = _errs8;
1773
- if (vErrors !== null) {
1774
- if (_errs8) {
1775
- vErrors.length = _errs8;
1776
- } else {
1777
- vErrors = null;
1778
- }
1779
- }
1780
- }
1781
- const _errs10 = errors;
1782
- let valid4 = true;
1783
- const _errs11 = errors;
2245
+ var _valid0 = _errs4 === errors;
2246
+ valid0 = _valid0;
2247
+ ifClause0 = "then";
2248
+ } else {
2249
+ const _errs20 = errors;
2250
+ const _errs21 = errors;
2251
+ let valid13 = true;
2252
+ const _errs22 = errors;
1784
2253
  if (data && typeof data == "object" && !Array.isArray(data)) {
1785
2254
  if (data.kind === void 0 && ("kind")) {
1786
- const err7 = {};
2255
+ const err8 = {};
1787
2256
  if (vErrors === null) {
1788
- vErrors = [err7];
2257
+ vErrors = [err8];
1789
2258
  } else {
1790
- vErrors.push(err7);
2259
+ vErrors.push(err8);
1791
2260
  }
1792
2261
  errors++;
1793
2262
  } else {
1794
2263
  if (data.kind !== void 0) {
1795
2264
  if ("state" !== data.kind) {
1796
- const err8 = {};
2265
+ const err9 = {};
1797
2266
  if (vErrors === null) {
1798
- vErrors = [err8];
2267
+ vErrors = [err9];
1799
2268
  } else {
1800
- vErrors.push(err8);
2269
+ vErrors.push(err9);
1801
2270
  }
1802
2271
  errors++;
1803
2272
  }
1804
2273
  }
1805
2274
  }
1806
2275
  }
1807
- var _valid1 = _errs11 === errors;
1808
- errors = _errs10;
2276
+ var _valid1 = _errs22 === errors;
2277
+ errors = _errs21;
1809
2278
  if (vErrors !== null) {
1810
- if (_errs10) {
1811
- vErrors.length = _errs10;
2279
+ if (_errs21) {
2280
+ vErrors.length = _errs21;
1812
2281
  } else {
1813
2282
  vErrors = null;
1814
2283
  }
1815
2284
  }
1816
2285
  let ifClause1;
1817
2286
  if (_valid1) {
1818
- const _errs13 = errors;
2287
+ const _errs24 = errors;
1819
2288
  if (data && typeof data == "object" && !Array.isArray(data)) {
1820
2289
  if (data.boxes !== void 0) {
1821
- let data2 = data.boxes;
1822
- if (Array.isArray(data2)) {
1823
- const len0 = data2.length;
1824
- for (let i0 = 0; i0 < len0; i0++) {
1825
- let data3 = data2[i0];
1826
- if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
1827
- if (data3.id !== void 0) {
1828
- let data4 = data3.id;
1829
- const _errs17 = errors;
1830
- const _errs18 = errors;
1831
- if (!(data4 === "start" || data4 === "finish")) {
1832
- const err9 = {};
2290
+ let data10 = data.boxes;
2291
+ if (Array.isArray(data10)) {
2292
+ if (data10.length < 1) {
2293
+ const err10 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2294
+ if (vErrors === null) {
2295
+ vErrors = [err10];
2296
+ } else {
2297
+ vErrors.push(err10);
2298
+ }
2299
+ errors++;
2300
+ }
2301
+ const len2 = data10.length;
2302
+ for (let i2 = 0; i2 < len2; i2++) {
2303
+ let data11 = data10[i2];
2304
+ if (data11 && typeof data11 == "object" && !Array.isArray(data11)) {
2305
+ if (data11.id !== void 0) {
2306
+ let data12 = data11.id;
2307
+ const _errs28 = errors;
2308
+ const _errs29 = errors;
2309
+ if (!(data12 === "start" || data12 === "finish")) {
2310
+ const err11 = {};
1833
2311
  if (vErrors === null) {
1834
- vErrors = [err9];
2312
+ vErrors = [err11];
1835
2313
  } else {
1836
- vErrors.push(err9);
2314
+ vErrors.push(err11);
1837
2315
  }
1838
2316
  errors++;
1839
2317
  }
1840
- var valid10 = _errs18 === errors;
1841
- if (valid10) {
1842
- const err10 = { instancePath: instancePath + "/boxes/" + i0 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
2318
+ var valid19 = _errs29 === errors;
2319
+ if (valid19) {
2320
+ const err12 = { instancePath: instancePath + "/boxes/" + i2 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
1843
2321
  if (vErrors === null) {
1844
- vErrors = [err10];
2322
+ vErrors = [err12];
1845
2323
  } else {
1846
- vErrors.push(err10);
2324
+ vErrors.push(err12);
1847
2325
  }
1848
2326
  errors++;
1849
2327
  } else {
1850
- errors = _errs17;
2328
+ errors = _errs28;
1851
2329
  if (vErrors !== null) {
1852
- if (_errs17) {
1853
- vErrors.length = _errs17;
2330
+ if (_errs28) {
2331
+ vErrors.length = _errs28;
1854
2332
  } else {
1855
2333
  vErrors = null;
1856
2334
  }
@@ -1861,241 +2339,449 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
1861
2339
  }
1862
2340
  }
1863
2341
  }
2342
+ if (data.steps !== void 0) {
2343
+ let data13 = data.steps;
2344
+ if (Array.isArray(data13)) {
2345
+ const len3 = data13.length;
2346
+ for (let i3 = 0; i3 < len3; i3++) {
2347
+ let data14 = data13[i3];
2348
+ if (data14 && typeof data14 == "object" && !Array.isArray(data14)) {
2349
+ if (data14.events !== void 0) {
2350
+ let data15 = data14.events;
2351
+ if (Array.isArray(data15)) {
2352
+ const len4 = data15.length;
2353
+ for (let i4 = 0; i4 < len4; i4++) {
2354
+ let data16 = data15[i4];
2355
+ if (data16 && typeof data16 == "object" && !Array.isArray(data16)) {
2356
+ if (data16.type !== void 0) {
2357
+ let data17 = data16.type;
2358
+ const _errs36 = errors;
2359
+ const _errs37 = errors;
2360
+ if (!(data17 === "commit" || data17 === "branch")) {
2361
+ const err13 = {};
2362
+ if (vErrors === null) {
2363
+ vErrors = [err13];
2364
+ } else {
2365
+ vErrors.push(err13);
2366
+ }
2367
+ errors++;
2368
+ }
2369
+ var valid27 = _errs37 === errors;
2370
+ if (valid27) {
2371
+ 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" };
2372
+ if (vErrors === null) {
2373
+ vErrors = [err14];
2374
+ } else {
2375
+ vErrors.push(err14);
2376
+ }
2377
+ errors++;
2378
+ } else {
2379
+ errors = _errs36;
2380
+ if (vErrors !== null) {
2381
+ if (_errs36) {
2382
+ vErrors.length = _errs36;
2383
+ } else {
2384
+ vErrors = null;
2385
+ }
2386
+ }
2387
+ }
2388
+ }
2389
+ }
2390
+ }
2391
+ }
2392
+ }
2393
+ }
2394
+ }
2395
+ }
2396
+ }
2397
+ if (data.git !== void 0) {
2398
+ const err15 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
2399
+ if (vErrors === null) {
2400
+ vErrors = [err15];
2401
+ } else {
2402
+ vErrors.push(err15);
2403
+ }
2404
+ errors++;
2405
+ }
1864
2406
  }
1865
- var _valid1 = _errs13 === errors;
1866
- valid4 = _valid1;
2407
+ var _valid1 = _errs24 === errors;
2408
+ valid13 = _valid1;
1867
2409
  ifClause1 = "then";
1868
2410
  } else {
1869
- const _errs19 = errors;
1870
- const _errs20 = errors;
1871
- const _errs21 = errors;
2411
+ const _errs41 = errors;
2412
+ const _errs42 = errors;
2413
+ let valid29 = true;
2414
+ const _errs43 = errors;
1872
2415
  if (data && typeof data == "object" && !Array.isArray(data)) {
1873
- if (data.state === void 0 && ("state")) {
1874
- const err11 = {};
2416
+ if (data.kind === void 0 && ("kind")) {
2417
+ const err16 = {};
1875
2418
  if (vErrors === null) {
1876
- vErrors = [err11];
2419
+ vErrors = [err16];
1877
2420
  } else {
1878
- vErrors.push(err11);
2421
+ vErrors.push(err16);
1879
2422
  }
1880
2423
  errors++;
2424
+ } else {
2425
+ if (data.kind !== void 0) {
2426
+ if ("git" !== data.kind) {
2427
+ const err17 = {};
2428
+ if (vErrors === null) {
2429
+ vErrors = [err17];
2430
+ } else {
2431
+ vErrors.push(err17);
2432
+ }
2433
+ errors++;
2434
+ }
2435
+ }
1881
2436
  }
1882
2437
  }
1883
- var valid11 = _errs21 === errors;
1884
- if (valid11) {
1885
- const err12 = { instancePath, schemaPath: "#/else/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
1886
- if (vErrors === null) {
1887
- vErrors = [err12];
2438
+ var _valid2 = _errs43 === errors;
2439
+ errors = _errs42;
2440
+ if (vErrors !== null) {
2441
+ if (_errs42) {
2442
+ vErrors.length = _errs42;
1888
2443
  } else {
1889
- vErrors.push(err12);
2444
+ vErrors = null;
1890
2445
  }
1891
- errors++;
2446
+ }
2447
+ let ifClause2;
2448
+ if (_valid2) {
2449
+ const _errs45 = errors;
2450
+ if (data && typeof data == "object" && !Array.isArray(data)) {
2451
+ if (data.git === void 0) {
2452
+ const err18 = { instancePath, schemaPath: "#/else/else/then/required", keyword: "required", params: { missingProperty: "git" }, message: "must have required property 'git'" };
2453
+ if (vErrors === null) {
2454
+ vErrors = [err18];
2455
+ } else {
2456
+ vErrors.push(err18);
2457
+ }
2458
+ errors++;
2459
+ }
2460
+ if (data.state !== void 0) {
2461
+ const err19 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
2462
+ if (vErrors === null) {
2463
+ vErrors = [err19];
2464
+ } else {
2465
+ vErrors.push(err19);
2466
+ }
2467
+ errors++;
2468
+ }
2469
+ if (data.regions !== void 0) {
2470
+ const err20 = { instancePath: instancePath + "/regions", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
2471
+ if (vErrors === null) {
2472
+ vErrors = [err20];
2473
+ } else {
2474
+ vErrors.push(err20);
2475
+ }
2476
+ errors++;
2477
+ }
2478
+ }
2479
+ var _valid2 = _errs45 === errors;
2480
+ valid29 = _valid2;
2481
+ ifClause2 = "then";
1892
2482
  } else {
1893
- errors = _errs20;
1894
- if (vErrors !== null) {
1895
- if (_errs20) {
1896
- vErrors.length = _errs20;
1897
- } else {
1898
- vErrors = null;
2483
+ const _errs52 = errors;
2484
+ if (data && typeof data == "object" && !Array.isArray(data)) {
2485
+ if (data.boxes !== void 0) {
2486
+ let data22 = data.boxes;
2487
+ if (Array.isArray(data22)) {
2488
+ if (data22.length < 1) {
2489
+ 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" };
2490
+ if (vErrors === null) {
2491
+ vErrors = [err21];
2492
+ } else {
2493
+ vErrors.push(err21);
2494
+ }
2495
+ errors++;
2496
+ }
2497
+ }
2498
+ }
2499
+ if (data.steps !== void 0) {
2500
+ let data23 = data.steps;
2501
+ if (Array.isArray(data23)) {
2502
+ const len5 = data23.length;
2503
+ for (let i5 = 0; i5 < len5; i5++) {
2504
+ let data24 = data23[i5];
2505
+ if (data24 && typeof data24 == "object" && !Array.isArray(data24)) {
2506
+ if (data24.events !== void 0) {
2507
+ let data25 = data24.events;
2508
+ if (Array.isArray(data25)) {
2509
+ const len6 = data25.length;
2510
+ for (let i6 = 0; i6 < len6; i6++) {
2511
+ let data26 = data25[i6];
2512
+ if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
2513
+ if (data26.type !== void 0) {
2514
+ let data27 = data26.type;
2515
+ const _errs60 = errors;
2516
+ const _errs61 = errors;
2517
+ if (!(data27 === "commit" || data27 === "branch")) {
2518
+ const err22 = {};
2519
+ if (vErrors === null) {
2520
+ vErrors = [err22];
2521
+ } else {
2522
+ vErrors.push(err22);
2523
+ }
2524
+ errors++;
2525
+ }
2526
+ var valid42 = _errs61 === errors;
2527
+ if (valid42) {
2528
+ 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" };
2529
+ if (vErrors === null) {
2530
+ vErrors = [err23];
2531
+ } else {
2532
+ vErrors.push(err23);
2533
+ }
2534
+ errors++;
2535
+ } else {
2536
+ errors = _errs60;
2537
+ if (vErrors !== null) {
2538
+ if (_errs60) {
2539
+ vErrors.length = _errs60;
2540
+ } else {
2541
+ vErrors = null;
2542
+ }
2543
+ }
2544
+ }
2545
+ }
2546
+ }
2547
+ }
2548
+ }
2549
+ }
2550
+ }
2551
+ }
2552
+ }
2553
+ }
2554
+ if (data.state !== void 0) {
2555
+ const err24 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
2556
+ if (vErrors === null) {
2557
+ vErrors = [err24];
2558
+ } else {
2559
+ vErrors.push(err24);
2560
+ }
2561
+ errors++;
2562
+ }
2563
+ if (data.git !== void 0) {
2564
+ const err25 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
2565
+ if (vErrors === null) {
2566
+ vErrors = [err25];
2567
+ } else {
2568
+ vErrors.push(err25);
2569
+ }
2570
+ errors++;
1899
2571
  }
1900
2572
  }
2573
+ var _valid2 = _errs52 === errors;
2574
+ valid29 = _valid2;
2575
+ ifClause2 = "else";
2576
+ }
2577
+ if (!valid29) {
2578
+ const err26 = { instancePath, schemaPath: "#/else/else/if", keyword: "if", params: { failingKeyword: ifClause2 }, message: 'must match "' + ifClause2 + '" schema' };
2579
+ if (vErrors === null) {
2580
+ vErrors = [err26];
2581
+ } else {
2582
+ vErrors.push(err26);
2583
+ }
2584
+ errors++;
1901
2585
  }
1902
- var _valid1 = _errs19 === errors;
1903
- valid4 = _valid1;
2586
+ var _valid1 = _errs41 === errors;
2587
+ valid13 = _valid1;
1904
2588
  ifClause1 = "else";
1905
2589
  }
1906
- if (!valid4) {
1907
- const err13 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
2590
+ if (!valid13) {
2591
+ const err27 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
1908
2592
  if (vErrors === null) {
1909
- vErrors = [err13];
2593
+ vErrors = [err27];
1910
2594
  } else {
1911
- vErrors.push(err13);
2595
+ vErrors.push(err27);
1912
2596
  }
1913
2597
  errors++;
1914
2598
  }
1915
- var _valid0 = _errs7 === errors;
2599
+ if (data && typeof data == "object" && !Array.isArray(data)) {
2600
+ if (data.sequence !== void 0) {
2601
+ const err28 = { instancePath: instancePath + "/sequence", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
2602
+ if (vErrors === null) {
2603
+ vErrors = [err28];
2604
+ } else {
2605
+ vErrors.push(err28);
2606
+ }
2607
+ errors++;
2608
+ }
2609
+ }
2610
+ var _valid0 = _errs20 === errors;
1916
2611
  valid0 = _valid0;
1917
2612
  ifClause0 = "else";
1918
2613
  }
1919
2614
  if (!valid0) {
1920
- const err14 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
2615
+ const err29 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
1921
2616
  if (vErrors === null) {
1922
- vErrors = [err14];
2617
+ vErrors = [err29];
1923
2618
  } else {
1924
- vErrors.push(err14);
2619
+ vErrors.push(err29);
1925
2620
  }
1926
2621
  errors++;
1927
2622
  }
1928
2623
  if (data && typeof data == "object" && !Array.isArray(data)) {
1929
2624
  if (data.version === void 0) {
1930
- const err15 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
2625
+ const err30 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
1931
2626
  if (vErrors === null) {
1932
- vErrors = [err15];
2627
+ vErrors = [err30];
1933
2628
  } else {
1934
- vErrors.push(err15);
2629
+ vErrors.push(err30);
1935
2630
  }
1936
2631
  errors++;
1937
2632
  }
1938
2633
  if (data.kind === void 0) {
1939
- const err16 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
2634
+ const err31 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
1940
2635
  if (vErrors === null) {
1941
- vErrors = [err16];
2636
+ vErrors = [err31];
1942
2637
  } else {
1943
- vErrors.push(err16);
2638
+ vErrors.push(err31);
1944
2639
  }
1945
2640
  errors++;
1946
2641
  }
1947
2642
  if (data.title === void 0) {
1948
- const err17 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
2643
+ const err32 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
1949
2644
  if (vErrors === null) {
1950
- vErrors = [err17];
2645
+ vErrors = [err32];
1951
2646
  } else {
1952
- vErrors.push(err17);
2647
+ vErrors.push(err32);
1953
2648
  }
1954
2649
  errors++;
1955
2650
  }
1956
2651
  if (data.boxes === void 0) {
1957
- const err18 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
2652
+ const err33 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
1958
2653
  if (vErrors === null) {
1959
- vErrors = [err18];
2654
+ vErrors = [err33];
1960
2655
  } else {
1961
- vErrors.push(err18);
2656
+ vErrors.push(err33);
1962
2657
  }
1963
2658
  errors++;
1964
2659
  }
1965
2660
  if (data.steps === void 0) {
1966
- const err19 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
2661
+ const err34 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
1967
2662
  if (vErrors === null) {
1968
- vErrors = [err19];
2663
+ vErrors = [err34];
1969
2664
  } else {
1970
- vErrors.push(err19);
2665
+ vErrors.push(err34);
1971
2666
  }
1972
2667
  errors++;
1973
2668
  }
1974
2669
  for (const key0 in data) {
1975
2670
  if (!func2.call(schema11.properties, key0)) {
1976
- const err20 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
2671
+ const err35 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
1977
2672
  if (vErrors === null) {
1978
- vErrors = [err20];
2673
+ vErrors = [err35];
1979
2674
  } else {
1980
- vErrors.push(err20);
2675
+ vErrors.push(err35);
1981
2676
  }
1982
2677
  errors++;
1983
2678
  }
1984
2679
  }
1985
2680
  if (data.version !== void 0) {
1986
- let data5 = data.version;
1987
- if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) {
1988
- const err21 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
2681
+ let data31 = data.version;
2682
+ if (!(typeof data31 == "number" && (!(data31 % 1) && !isNaN(data31)) && isFinite(data31))) {
2683
+ const err36 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
1989
2684
  if (vErrors === null) {
1990
- vErrors = [err21];
2685
+ vErrors = [err36];
1991
2686
  } else {
1992
- vErrors.push(err21);
2687
+ vErrors.push(err36);
1993
2688
  }
1994
2689
  errors++;
1995
2690
  }
1996
- if (typeof data5 == "number" && isFinite(data5)) {
1997
- if (data5 < 1 || isNaN(data5)) {
1998
- const err22 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
2691
+ if (typeof data31 == "number" && isFinite(data31)) {
2692
+ if (data31 < 1 || isNaN(data31)) {
2693
+ const err37 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
1999
2694
  if (vErrors === null) {
2000
- vErrors = [err22];
2695
+ vErrors = [err37];
2001
2696
  } else {
2002
- vErrors.push(err22);
2697
+ vErrors.push(err37);
2003
2698
  }
2004
2699
  errors++;
2005
2700
  }
2006
2701
  }
2007
2702
  }
2008
2703
  if (data.kind !== void 0) {
2009
- let data6 = data.kind;
2010
- if (!(data6 === "sequence" || data6 === "architecture" || data6 === "state")) {
2011
- 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" };
2704
+ let data32 = data.kind;
2705
+ if (!(data32 === "sequence" || data32 === "architecture" || data32 === "state" || data32 === "git")) {
2706
+ 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" };
2012
2707
  if (vErrors === null) {
2013
- vErrors = [err23];
2708
+ vErrors = [err38];
2014
2709
  } else {
2015
- vErrors.push(err23);
2710
+ vErrors.push(err38);
2016
2711
  }
2017
2712
  errors++;
2018
2713
  }
2019
2714
  }
2020
2715
  if (data.title !== void 0) {
2021
- let data7 = data.title;
2022
- if (typeof data7 === "string") {
2023
- if (func3(data7) < 1) {
2024
- const err24 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
2716
+ let data33 = data.title;
2717
+ if (typeof data33 === "string") {
2718
+ if (func3(data33) < 1) {
2719
+ const err39 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
2025
2720
  if (vErrors === null) {
2026
- vErrors = [err24];
2721
+ vErrors = [err39];
2027
2722
  } else {
2028
- vErrors.push(err24);
2723
+ vErrors.push(err39);
2029
2724
  }
2030
2725
  errors++;
2031
2726
  }
2032
2727
  } else {
2033
- const err25 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2728
+ const err40 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2034
2729
  if (vErrors === null) {
2035
- vErrors = [err25];
2730
+ vErrors = [err40];
2036
2731
  } else {
2037
- vErrors.push(err25);
2732
+ vErrors.push(err40);
2038
2733
  }
2039
2734
  errors++;
2040
2735
  }
2041
2736
  }
2042
2737
  if (data.view !== void 0) {
2043
- let data8 = data.view;
2044
- if (!(data8 === "fixed" || data8 === "follow")) {
2045
- 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" };
2738
+ let data34 = data.view;
2739
+ if (!(data34 === "fixed" || data34 === "follow")) {
2740
+ 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" };
2046
2741
  if (vErrors === null) {
2047
- vErrors = [err26];
2742
+ vErrors = [err41];
2048
2743
  } else {
2049
- vErrors.push(err26);
2744
+ vErrors.push(err41);
2050
2745
  }
2051
2746
  errors++;
2052
2747
  }
2053
2748
  }
2054
2749
  if (data.regions !== void 0) {
2055
- let data9 = data.regions;
2056
- if (Array.isArray(data9)) {
2057
- const len1 = data9.length;
2058
- for (let i1 = 0; i1 < len1; i1++) {
2059
- if (!validate11(data9[i1], { instancePath: instancePath + "/regions/" + i1, parentData: data9, parentDataProperty: i1, rootData })) {
2750
+ let data35 = data.regions;
2751
+ if (Array.isArray(data35)) {
2752
+ const len7 = data35.length;
2753
+ for (let i7 = 0; i7 < len7; i7++) {
2754
+ if (!validate11(data35[i7], { instancePath: instancePath + "/regions/" + i7, parentData: data35, parentDataProperty: i7, rootData })) {
2060
2755
  vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
2061
2756
  errors = vErrors.length;
2062
2757
  }
2063
2758
  }
2064
2759
  } else {
2065
- const err27 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2760
+ const err42 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2066
2761
  if (vErrors === null) {
2067
- vErrors = [err27];
2762
+ vErrors = [err42];
2068
2763
  } else {
2069
- vErrors.push(err27);
2764
+ vErrors.push(err42);
2070
2765
  }
2071
2766
  errors++;
2072
2767
  }
2073
2768
  }
2074
2769
  if (data.boxes !== void 0) {
2075
- let data11 = data.boxes;
2076
- if (Array.isArray(data11)) {
2077
- if (data11.length < 1) {
2078
- const err28 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2079
- if (vErrors === null) {
2080
- vErrors = [err28];
2081
- } else {
2082
- vErrors.push(err28);
2083
- }
2084
- errors++;
2085
- }
2086
- const len2 = data11.length;
2087
- for (let i2 = 0; i2 < len2; i2++) {
2088
- if (!validate13(data11[i2], { instancePath: instancePath + "/boxes/" + i2, parentData: data11, parentDataProperty: i2, rootData })) {
2770
+ let data37 = data.boxes;
2771
+ if (Array.isArray(data37)) {
2772
+ const len8 = data37.length;
2773
+ for (let i8 = 0; i8 < len8; i8++) {
2774
+ if (!validate13(data37[i8], { instancePath: instancePath + "/boxes/" + i8, parentData: data37, parentDataProperty: i8, rootData })) {
2089
2775
  vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
2090
2776
  errors = vErrors.length;
2091
2777
  }
2092
2778
  }
2093
2779
  } else {
2094
- const err29 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2780
+ const err43 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2095
2781
  if (vErrors === null) {
2096
- vErrors = [err29];
2782
+ vErrors = [err43];
2097
2783
  } else {
2098
- vErrors.push(err29);
2784
+ vErrors.push(err43);
2099
2785
  }
2100
2786
  errors++;
2101
2787
  }
@@ -2107,30 +2793,30 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
2107
2793
  }
2108
2794
  }
2109
2795
  if (data.steps !== void 0) {
2110
- let data14 = data.steps;
2111
- if (Array.isArray(data14)) {
2112
- if (data14.length < 1) {
2113
- const err30 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2796
+ let data40 = data.steps;
2797
+ if (Array.isArray(data40)) {
2798
+ if (data40.length < 1) {
2799
+ const err44 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2114
2800
  if (vErrors === null) {
2115
- vErrors = [err30];
2801
+ vErrors = [err44];
2116
2802
  } else {
2117
- vErrors.push(err30);
2803
+ vErrors.push(err44);
2118
2804
  }
2119
2805
  errors++;
2120
2806
  }
2121
- const len3 = data14.length;
2122
- for (let i3 = 0; i3 < len3; i3++) {
2123
- if (!validate17(data14[i3], { instancePath: instancePath + "/steps/" + i3, parentData: data14, parentDataProperty: i3, rootData })) {
2807
+ const len9 = data40.length;
2808
+ for (let i9 = 0; i9 < len9; i9++) {
2809
+ if (!validate17(data40[i9], { instancePath: instancePath + "/steps/" + i9, parentData: data40, parentDataProperty: i9, rootData })) {
2124
2810
  vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
2125
2811
  errors = vErrors.length;
2126
2812
  }
2127
2813
  }
2128
2814
  } else {
2129
- const err31 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2815
+ const err45 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2130
2816
  if (vErrors === null) {
2131
- vErrors = [err31];
2817
+ vErrors = [err45];
2132
2818
  } else {
2133
- vErrors.push(err31);
2819
+ vErrors.push(err45);
2134
2820
  }
2135
2821
  errors++;
2136
2822
  }
@@ -2147,12 +2833,18 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
2147
2833
  errors = vErrors.length;
2148
2834
  }
2149
2835
  }
2836
+ if (data.git !== void 0) {
2837
+ if (!validate29(data.git, { instancePath: instancePath + "/git", parentData: data, parentDataProperty: "git", rootData })) {
2838
+ vErrors = vErrors === null ? validate29.errors : vErrors.concat(validate29.errors);
2839
+ errors = vErrors.length;
2840
+ }
2841
+ }
2150
2842
  } else {
2151
- const err32 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2843
+ const err46 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2152
2844
  if (vErrors === null) {
2153
- vErrors = [err32];
2845
+ vErrors = [err46];
2154
2846
  } else {
2155
- vErrors.push(err32);
2847
+ vErrors.push(err46);
2156
2848
  }
2157
2849
  errors++;
2158
2850
  }
@@ -2162,16 +2854,23 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
2162
2854
 
2163
2855
  // src/words.ts
2164
2856
  var keys = (table) => Object.keys(table);
2165
- var KINDS = keys({ sequence: true, architecture: true, state: true });
2857
+ var KINDS = keys({ sequence: true, architecture: true, state: true, git: true });
2166
2858
  var STATE_ENDS = ["start", "finish"];
2167
- var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
2859
+ var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set", "branch", "commit"];
2168
2860
  var AS = "as";
2861
+ var ON = "on";
2862
+ var COPY = "copy";
2863
+ var MERGE = "merge";
2864
+ var FROM = "from";
2865
+ var HEAD = "HEAD";
2169
2866
  var ATTRS = {
2170
2867
  diagram: ["view"],
2171
2868
  group: ["note", "color", "icon"],
2172
2869
  box: ["note", "color", "icon"],
2173
2870
  edge: ["carry", "tag", "side"],
2174
- set: ["tag"]
2871
+ set: ["tag"],
2872
+ branch: ["note"],
2873
+ commit: ["hash", "note"]
2175
2874
  };
2176
2875
  var CARRIES = keys({ coin: true, none: true });
2177
2876
  var VIEWS = keys({ fixed: true, follow: true });
@@ -2187,17 +2886,17 @@ var OLD_HEADS = {
2187
2886
 
2188
2887
  // src/schema.ts
2189
2888
  var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
2190
- var EVENT_TYPES = ["edge", "action", "swap", "strip"];
2191
- var ROOT_NOT_ALLOWED = {
2192
- "#/else/not": { field: "sequence", kind: "sequence" },
2193
- "#/then/not": { field: "state", kind: "state" },
2194
- "#/else/else/not": { field: "state", kind: "state" }
2195
- };
2889
+ var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch"];
2890
+ var ABSENT = "#/definitions/absent/not";
2891
+ var ABSENT_KINDS = { regions: "sequence / architecture / state" };
2196
2892
  var NOT_ALLOWED = {
2197
2893
  carry: { field: "text", kind: "tag" }
2198
2894
  };
2199
2895
  var RESERVED_ID = /\/boxes\/items\/properties\/id\/not$/u;
2896
+ var GIT_EVENT = /\/events\/items\/properties\/type\/not$/u;
2897
+ var GIT_EVENTS = ["commit", "branch"];
2200
2898
  var escape = (key2) => key2.replaceAll("~", "~0").replaceAll("/", "~1");
2899
+ var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
2201
2900
  function forbiddenOf(pattern) {
2202
2901
  const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
2203
2902
  if (inside === void 0) return void 0;
@@ -2221,7 +2920,10 @@ function toFieldError(error, errors, m) {
2221
2920
  }
2222
2921
  case "not": {
2223
2922
  if (RESERVED_ID.test(error.schemaPath)) return { pointer: at, message: m.reserved(STATE_ENDS) };
2224
- const allowed = at === "" ? ROOT_NOT_ALLOWED[error.schemaPath] : NOT_ALLOWED[at.slice(at.lastIndexOf("/") + 1)];
2923
+ if (GIT_EVENT.test(error.schemaPath)) return { pointer: at, message: m.kindOnly(GIT_EVENTS, "git") };
2924
+ const last = at.slice(at.lastIndexOf("/") + 1);
2925
+ if (error.schemaPath === ABSENT) return { pointer: at, message: m.not({ field: last, kind: ABSENT_KINDS[last] ?? last }) };
2926
+ const allowed = NOT_ALLOWED[last];
2225
2927
  return { pointer: allowed ? `${at}/${allowed.field}` : at, message: m.not(allowed) };
2226
2928
  }
2227
2929
  case "anyOf": {
@@ -2239,8 +2941,10 @@ function toFieldError(error, errors, m) {
2239
2941
  return { pointer: at, message: m.type(String(params.type)) };
2240
2942
  case "minLength":
2241
2943
  return { pointer: at, message: m.minLength(Number(params.limit)) };
2242
- case "pattern":
2243
- return { pointer: at, message: m.pattern(forbiddenOf(String(params.pattern))) };
2944
+ case "pattern": {
2945
+ const hex = HEX.exec(String(params.pattern));
2946
+ return { pointer: at, message: hex ? m.hex(Number(hex[1]), Number(hex[2])) : m.pattern(forbiddenOf(String(params.pattern))) };
2947
+ }
2244
2948
  case "minItems":
2245
2949
  return { pointer: at, message: m.minItems(Number(params.limit)) };
2246
2950
  case "minimum":
@@ -2297,8 +3001,8 @@ var ja2 = () => {
2297
3001
  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",
2298
3002
  codeTwice: "1 \u3064\u306E\u6BB5\u306B code \u306F 1 \u884C\u307E\u3067",
2299
3003
  emptyCode: "code \u306E\u5F8C\u308D\u306B\u547D\u4EE4\u3092\u66F8\u304F",
2300
- declarationInStep: "group \u3068 box \u3068 strip \u306F\u6700\u521D\u306E step \u3088\u308A\u524D\u306B\u66F8\u304F",
2301
- stepLineBeforeStep: "\u7DDA\u3068 say \u3068 code \u3068 act \u3068 note \u3068 set \u306F step \u306E\u4E0B\u306B\u66F8\u304F",
3004
+ declarationInStep: "group \u3068 box \u3068 strip \u3068 branch \u306F\u6700\u521D\u306E step \u3088\u308A\u524D\u306B\u66F8\u304F",
3005
+ 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",
2302
3006
  nestedGroup: "group \u306E\u4E2D\u306B group \u306F\u66F8\u3051\u306A\u3044\u3002\u5148\u306B end \u3067\u9589\u3058\u308B",
2303
3007
  strayEnd: "end \u306E\u524D\u306B\u3001\u9589\u3058\u308B group \u304C\u7121\u3044",
2304
3008
  endTakesNothing: "end \u306E\u5F8C\u308D\u306B\u306F\u4F55\u3082\u66F8\u304B\u306A\u3044",
@@ -2330,7 +3034,20 @@ var ja2 = () => {
2330
3034
  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`,
2331
3035
  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",
2332
3036
  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",
2333
- 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"
3037
+ 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",
3038
+ gitOnly: (word) => `${word} \u306E\u884C\u306F git (\u679D\u5206\u304B\u308C\u306E\u56F3) \u3067\u3060\u3051\u66F8\u3051\u308B`,
3039
+ 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",
3040
+ noBranches: "branch \u306E\u884C\u3067\u679D\u3092 1 \u3064\u4EE5\u4E0A\u5BA3\u8A00\u3059\u308B",
3041
+ branchShape: "branch \u306F branch <\u540D\u672D> [note: <\u6DFB\u3048\u66F8\u304D>] \u306E\u5F62\u3067\u66F8\u304F",
3042
+ 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",
3043
+ fromShape: "\u679D\u3092\u5207\u308B\u884C\u306F <\u679D> from <commit> \u306E\u5F62\u3067\u66F8\u304F",
3044
+ undeclaredBranch: (id) => `${id} \u3068\u3044\u3046\u679D\u306F\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044`,
3045
+ 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`,
3046
+ noCommit: (id) => `${id} \u3068\u3044\u3046 commit \u306F\u307E\u3060\u7A4D\u3093\u3067\u3044\u306A\u3044`,
3047
+ 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`,
3048
+ mergeSelf: (id) => `${id} \u306F\u7A4D\u3080\u679D\u306A\u306E\u3067\u3001\u53D6\u308A\u8FBC\u3080\u679D\u306B\u3067\u304D\u306A\u3044`,
3049
+ headReserved: (name2) => `${name2} \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`,
3050
+ badHash: "hash \u306F 0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 4 \u304B\u3089 40 \u5B57\u306B\u3059\u308B"
2334
3051
  };
2335
3052
  };
2336
3053
  var en2 = () => {
@@ -2366,8 +3083,8 @@ var en2 = () => {
2366
3083
  sayTwice: "A step takes one say. Continue a long body on indented lines below it",
2367
3084
  codeTwice: "A step takes at most one code line",
2368
3085
  emptyCode: "Write the command after code",
2369
- declarationInStep: "Write group, box and strip before the first step",
2370
- stepLineBeforeStep: "Write lines, say, code, act, note and set under a step",
3086
+ declarationInStep: "Write group, box, strip and branch before the first step",
3087
+ stepLineBeforeStep: "Write lines, say, code, act, note, set, commit and branch cuts under a step",
2371
3088
  nestedGroup: "A group cannot hold another group. Close it with end first",
2372
3089
  strayEnd: "There is no group for this end to close",
2373
3090
  endTakesNothing: "Write nothing after end",
@@ -2399,7 +3116,20 @@ var en2 = () => {
2399
3116
  reservedId: (id) => `${id} names the start or end mark of a state diagram and cannot be a box id`,
2400
3117
  intoStart: "A line cannot go into start. start is the start mark, and lines leave it",
2401
3118
  outOfFinish: "A line cannot leave finish. finish is the end mark, and lines go into it",
2402
- pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)"
3119
+ pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)",
3120
+ gitOnly: (word) => `${word} lines can be written only in git diagrams`,
3121
+ gitNoGroup: "A git diagram takes no group. Declare branches with branch lines",
3122
+ noBranches: "Declare at least one branch with a branch line",
3123
+ branchShape: "Write a branch as branch <id> [note: <note>]",
3124
+ 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>",
3125
+ fromShape: "Write a branch cut as <branch> from <commit>",
3126
+ undeclaredBranch: (id) => `No branch named ${id} is declared`,
3127
+ undeclaredRef: (id) => `No branch named ${id} is declared. A line that moves a ref starts from a branch id or HEAD`,
3128
+ noCommit: (id) => `No commit named ${id} has been made yet`,
3129
+ emptyBranch: (id) => `Branch ${id} does not point at any commit yet, so it cannot be merged`,
3130
+ mergeSelf: (id) => `${id} is the branch being committed to, so it cannot be the branch merged in`,
3131
+ headReserved: (name2) => `${name2} names where you are in a git diagram and cannot be an id`,
3132
+ badHash: "Write a hash as 4 to 40 characters of 0-9 and a-f"
2403
3133
  };
2404
3134
  };
2405
3135
  var MESSAGES = { ja: ja2(), en: en2() };
@@ -2435,13 +3165,6 @@ function readDiagram(input, options = {}) {
2435
3165
  if (!checked.ok) return checked;
2436
3166
  return { ok: true, diagram: input, warnings: [] };
2437
3167
  }
2438
- async function migrateFile(path2) {
2439
- const { readFile } = await import('fs/promises');
2440
- const input = JSON.parse(await readFile(path2, "utf8"));
2441
- const read = readDiagram(input);
2442
- if (!read.ok) throw new Error(`${path2} \u3092\u79FB\u305B\u306A\u3044: ${read.errors.map((error) => `${error.pointer} ${error.message}`).join(" / ")}`);
2443
- return { changed: false, from: read.diagram.version, to: FORMAT_VERSION };
2444
- }
2445
3168
 
2446
3169
  // src/parser.ts
2447
3170
  var NotationError = class extends Error {
@@ -2456,6 +3179,9 @@ var NotationError = class extends Error {
2456
3179
  var fail = (source, index, message) => new NotationError(source.line, columnOf(source, index), message);
2457
3180
  var ID = /^[^\s[\]「」=:]+$/u;
2458
3181
  var EDGE = /^([^\s:[\]]+?)\s*->\s*([^\s:[\]]+)/du;
3182
+ var COMMIT = new RegExp(`^commit\\s+([^\\s[]+)(?:\\s+${ON}\\s+([^\\s[]+))?(?:\\s+${COPY}\\s+([^\\s[]+))?(?:\\s+${MERGE}\\s+([^\\s[]+))?`, "du");
3183
+ var CUT = new RegExp(`^([^\\s[]+)\\s+${FROM}(?:\\s+([^\\s[]+))?\\s*$`, "du");
3184
+ var HASH = /^[0-9a-f]{4,40}$/u;
2459
3185
  var isOneOf = (list2, word) => list2.includes(word);
2460
3186
  function skipSpaces(text2, at) {
2461
3187
  let i = at;
@@ -2604,6 +3330,10 @@ function parseLines(lines, m) {
2604
3330
  if (shown2 && !isOneOf(VIEWS, shown2.value)) throw fail(head, shown2.at, m.badView);
2605
3331
  const view = shown2?.value;
2606
3332
  const isState = kind === "state";
3333
+ const isGit = kind === "git";
3334
+ const branches = [];
3335
+ const commits = /* @__PURE__ */ new Set();
3336
+ const tips = /* @__PURE__ */ new Map();
2607
3337
  const regions = [];
2608
3338
  const boxes = [];
2609
3339
  const paths = [];
@@ -2620,13 +3350,27 @@ function parseLines(lines, m) {
2620
3350
  if (!boxes.some((box) => box.id === id)) throw fail(source, at, m.undeclaredBox(id));
2621
3351
  return id;
2622
3352
  };
3353
+ const branchAt = (source, id, at) => {
3354
+ if (!tips.has(id)) throw fail(source, at, m.undeclaredBranch(id));
3355
+ return id;
3356
+ };
3357
+ const commitAt = (source, id, at) => {
3358
+ if (!commits.has(id)) throw fail(source, at, m.noCommit(id));
3359
+ return id;
3360
+ };
2623
3361
  const endAt = (source, id, at, side2) => {
3362
+ if (isGit) {
3363
+ if (side2 === "to") return commitAt(source, id, at);
3364
+ if (id !== HEAD && !tips.has(id)) throw fail(source, at, m.undeclaredRef(id));
3365
+ return id;
3366
+ }
2624
3367
  if (!isState || !isOneOf(STATE_ENDS, id)) return boxAt(source, id, at);
2625
3368
  if (id === "start" !== (side2 === "from")) throw fail(source, at, id === "start" ? m.intoStart : m.outOfFinish);
2626
3369
  return id;
2627
3370
  };
2628
3371
  const notReserved = (source, id, at) => {
2629
3372
  if (isState && isOneOf(STATE_ENDS, id)) throw fail(source, at, m.reservedId(id));
3373
+ if (isGit && id === HEAD) throw fail(source, at, m.headReserved(id));
2630
3374
  };
2631
3375
  const inStep = (source) => {
2632
3376
  if (!building) throw fail(source, 0, m.stepLineBeforeStep);
@@ -2656,7 +3400,13 @@ function parseLines(lines, m) {
2656
3400
  else inStep(source).events.push(readEdge(source, edge2));
2657
3401
  continue;
2658
3402
  }
2659
- const word = text2.split(/\s/u)[0] ?? "";
3403
+ const [word = "", second] = text2.split(/\s+/u);
3404
+ if (isGit && tips.has(word) && second === FROM) {
3405
+ const step = inStep(source);
3406
+ step.events.push(readCut(source));
3407
+ continue;
3408
+ }
3409
+ if (!isGit && (word === "branch" || word === "commit")) throw fail(source, 0, m.gitOnly(word));
2660
3410
  if (!isOneOf(HEADS, word)) {
2661
3411
  const old = oldForm(text2, building !== void 0);
2662
3412
  throw fail(source, 0, old ? m.oldForm(old.word, old.shape) : m.unknownHead(word));
@@ -2710,11 +3460,20 @@ function parseLines(lines, m) {
2710
3460
  case "set":
2711
3461
  inStep(source).events.push(readSet(source));
2712
3462
  break;
3463
+ case "branch":
3464
+ readBranch(source);
3465
+ break;
3466
+ case "commit": {
3467
+ const step = inStep(source);
3468
+ step.events.push(readCommit(source));
3469
+ break;
3470
+ }
2713
3471
  }
2714
3472
  }
2715
3473
  if (group) throw fail(group.source, 0, m.unclosedGroup(group.id));
2716
3474
  finish();
2717
- if (boxes.length === 0) throw fail(head, 0, m.noBoxes);
3475
+ if (isGit && branches.length === 0) throw fail(head, 0, m.noBranches);
3476
+ if (boxes.length === 0 && !isGit) throw fail(head, 0, m.noBoxes);
2718
3477
  if (steps.length === 0) throw fail(head, 0, m.noSteps);
2719
3478
  return {
2720
3479
  version: FORMAT_VERSION,
@@ -2726,10 +3485,12 @@ function parseLines(lines, m) {
2726
3485
  ...strip2 ? { strip: strip2 } : {},
2727
3486
  steps,
2728
3487
  ...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {},
2729
- ...paths.length > 0 ? { state: { paths } } : {}
3488
+ ...paths.length > 0 ? { state: { paths } } : {},
3489
+ ...isGit ? { git: { branches } } : {}
2730
3490
  };
2731
3491
  function readGroup(source) {
2732
3492
  beforeSteps(source);
3493
+ if (isGit) throw fail(source, 0, m.gitNoGroup);
2733
3494
  if (group) throw fail(source, 0, m.nestedGroup);
2734
3495
  const declared = readDeclared(source, "group", ATTRS.group, m);
2735
3496
  if (regions.some((region) => region.id === declared.id)) {
@@ -2755,6 +3516,62 @@ function parseLines(lines, m) {
2755
3516
  ...group ? { region: group.id } : {}
2756
3517
  });
2757
3518
  }
3519
+ function readBranch(source) {
3520
+ beforeSteps(source);
3521
+ const declared = readDeclared(source, "branch", ATTRS.branch, m);
3522
+ if (declared.name !== void 0) throw fail(source, 0, m.branchShape);
3523
+ notReserved(source, declared.id, declared.idAt);
3524
+ declare(source, declared.id, declared.idAt);
3525
+ const note = declared.attrs.get("note")?.value;
3526
+ branches.push({ id: declared.id, ...note !== void 0 ? { note } : {} });
3527
+ tips.set(declared.id, null);
3528
+ }
3529
+ function readCommit(source) {
3530
+ const text2 = source.text;
3531
+ const found = COMMIT.exec(text2);
3532
+ const at = (k) => found?.indices?.[k]?.[0] ?? 0;
3533
+ const id = found?.[1];
3534
+ const on = found?.[2];
3535
+ if (!found || id === void 0 || on === void 0) throw fail(source, 0, m.commitShape);
3536
+ const rest2 = skipSpaces(text2, found[0].length);
3537
+ if (rest2 < text2.length && text2[rest2] !== "[") throw fail(source, rest2, m.commitShape);
3538
+ if (!ID.test(id)) throw fail(source, at(1), m.badId(id));
3539
+ notReserved(source, id, at(1));
3540
+ declare(source, id, at(1));
3541
+ const branch = branchAt(source, on, at(2));
3542
+ const copy = found[3] === void 0 ? void 0 : commitAt(source, found[3], at(3));
3543
+ const merge = found[4] === void 0 ? void 0 : mergedAt(source, found[4], at(4), branch);
3544
+ const attrs2 = rest2 < text2.length ? readAttrs(source, rest2, ATTRS.commit, m) : /* @__PURE__ */ new Map();
3545
+ const hash = attrs2.get("hash");
3546
+ if (hash && !HASH.test(hash.value)) throw fail(source, hash.at, m.badHash);
3547
+ const note = attrs2.get("note")?.value;
3548
+ commits.add(id);
3549
+ if (copy === void 0) tips.set(branch, id);
3550
+ return {
3551
+ type: "commit",
3552
+ id,
3553
+ branch,
3554
+ ...copy !== void 0 ? { copy } : {},
3555
+ ...merge !== void 0 ? { merge } : {},
3556
+ ...hash ? { hash: hash.value } : {},
3557
+ ...note !== void 0 ? { note } : {}
3558
+ };
3559
+ }
3560
+ function mergedAt(source, id, at, into) {
3561
+ branchAt(source, id, at);
3562
+ if (id === into) throw fail(source, at, m.mergeSelf(id));
3563
+ if (tips.get(id) === null) throw fail(source, at, m.emptyBranch(id));
3564
+ return id;
3565
+ }
3566
+ function readCut(source) {
3567
+ const found = CUT.exec(source.text);
3568
+ const branch = found?.[1];
3569
+ const from = found?.[2];
3570
+ if (!found || branch === void 0 || from === void 0) throw fail(source, 0, m.fromShape);
3571
+ commitAt(source, from, found.indices?.[2]?.[0] ?? 0);
3572
+ tips.set(branch, from);
3573
+ return { type: "branch", branch, from };
3574
+ }
2758
3575
  function readStrip(source) {
2759
3576
  beforeSteps(source);
2760
3577
  if (strip2) throw fail(source, 0, m.stripTwice);
@@ -2828,9 +3645,10 @@ function parseLines(lines, m) {
2828
3645
  if (carried && !isOneOf(CARRIES, carried.value)) throw fail(source, carried.at, m.badCarry);
2829
3646
  const side2 = attrs2.get("side");
2830
3647
  if (side2 && !isOneOf(SIDES, side2.value)) throw fail(source, side2.at, m.badSide);
2831
- let carry = { kind: "envelope" };
3648
+ let carry = isGit ? { kind: "tag", text: from } : { kind: "envelope" };
2832
3649
  if (tag) carry = { kind: "tag", text: tag.value };
2833
3650
  else if (carried) carry = carried.value === "coin" ? { kind: "coin" } : { kind: "none" };
3651
+ if (isGit && from !== HEAD) tips.set(from, to);
2834
3652
  return {
2835
3653
  type: "edge",
2836
3654
  from,
@@ -2906,10 +3724,11 @@ var declareBox = (b) => `box ${b.id}${shown(b.id, b.name)}${attrs([
2906
3724
  ["icon", b.icon]
2907
3725
  ])}`;
2908
3726
  var line = (from, to, label2) => `${from} -> ${to}${label2 === void 0 ? "" : `: ${name(label2)}`}`;
2909
- function event(e) {
3727
+ function event(e, git) {
2910
3728
  switch (e.type) {
2911
3729
  case "edge": {
2912
- const carry = e.carry.kind === "tag" ? [["tag", e.carry.text]] : e.carry.kind === "envelope" ? [] : [["carry", e.carry.kind]];
3730
+ const plain = git ? e.carry.kind === "tag" && e.carry.text === e.from : e.carry.kind === "envelope";
3731
+ const carry = plain ? [] : e.carry.kind === "tag" ? [["tag", e.carry.text]] : [["carry", e.carry.kind]];
2913
3732
  return `${line(e.from, e.to, e.label)}${attrs([...carry, ["side", e.labelSide]])}`;
2914
3733
  }
2915
3734
  case "action":
@@ -2918,6 +3737,13 @@ function event(e) {
2918
3737
  return `note ${e.box}: ${e.text}`;
2919
3738
  case "strip":
2920
3739
  return `set ${key(e.field)}${e.value === void 0 ? "" : `: ${name(e.value)}`}${attrs([["tag", e.tag]])}`;
3740
+ case "commit":
3741
+ return `commit ${e.id} ${ON} ${e.branch}${e.copy === void 0 ? "" : ` ${COPY} ${e.copy}`}${e.merge === void 0 ? "" : ` ${MERGE} ${e.merge}`}${attrs([
3742
+ ["hash", e.hash],
3743
+ ["note", e.note]
3744
+ ])}`;
3745
+ case "branch":
3746
+ return `${e.branch} ${FROM} ${e.from}`;
2921
3747
  }
2922
3748
  }
2923
3749
  function declarations(diagram) {
@@ -2953,14 +3779,15 @@ end`);
2953
3779
  return blocks;
2954
3780
  }
2955
3781
  function printNotation(diagram) {
2956
- const blocks = [`${diagram.kind} ${name(diagram.title)}${attrs([["view", diagram.view]])}`, ...declarations(diagram)];
3782
+ const branches = (diagram.git?.branches ?? []).map((b) => `branch ${b.id}${attrs([["note", b.note]])}`);
3783
+ const blocks = [`${diagram.kind} ${name(diagram.title)}${attrs([["view", diagram.view]])}`, ...branches.length > 0 ? [branches.join("\n")] : [], ...declarations(diagram)];
2957
3784
  if (diagram.strip) blocks.push(`strip ${key(diagram.strip.title)}: ${diagram.strip.fields.map(field).join(", ")}`);
2958
3785
  if (diagram.state) blocks.push(diagram.state.paths.map((p) => line(p.from, p.to, p.label)).join("\n"));
2959
3786
  for (const step of diagram.steps) {
2960
3787
  const body = step.body.split("\n");
2961
3788
  const say = body.length === 1 ? [` say ${step.body}`] : [" say", ...body.map((line2) => line2 === "" ? "" : ` ${line2}`)];
2962
3789
  blocks.push(
2963
- [`step ${step.title}`, ...say, ...step.code === void 0 ? [] : [` code ${step.code}`], ...step.events.map((e) => ` ${event(e)}`)].join("\n")
3790
+ [`step ${step.title}`, ...say, ...step.code === void 0 ? [] : [` code ${step.code}`], ...step.events.map((e) => ` ${event(e, diagram.kind === "git")}`)].join("\n")
2964
3791
  );
2965
3792
  }
2966
3793
  return `${blocks.join("\n\n")}
@@ -3226,7 +4053,11 @@ var TYPE = {
3226
4053
  stepTitle: text(15, 700),
3227
4054
  stepBody: text(13.5, 500),
3228
4055
  stepNo: text(13, 700, "mono"),
3229
- button: text(14, 700)
4056
+ button: text(14, 700),
4057
+ /** 枝分かれの図 (#3164) の、丸の中の commit の名札と、丸の外に添える hash と一言 */
4058
+ gitId: text(11, 700),
4059
+ gitHash: text(10.5, 600, "mono"),
4060
+ gitNote: text(10.5, 650)
3230
4061
  };
3231
4062
  var LOOK = {
3232
4063
  /** 部品どうしの最小の隙間 */
@@ -3270,6 +4101,41 @@ var LOOK = {
3270
4101
  done: { r: 6.5, inset: 13 },
3271
4102
  pastLabel: 0.85
3272
4103
  },
4104
+ /**
4105
+ * 枝分かれの図 (#3164)。見本帳の試作 (`scenes/git.js`) の寸法を写す。
4106
+ * commit は列ごとに `pitch` ずつ右へ並べ、一番上でない帯の commit は列の半分だけ右へずらす。`x0` は最初の列の真ん中の x の下限、
4107
+ * `textGap` は隣の列の hash と一言の間に空ける最小の隙間。`r` は丸の半径、`orphan` はどの札からも辿れなくなった commit の点線の丸の半径。
4108
+ * `topLine` と `line` は帯の上端から丸を並べる線まで (一番上の帯と、それより下の帯)、`topBelow` と `below` は線から帯の下端まで。
4109
+ * `bare` は線の名前を下に置かない帯の、線から帯の下端まで。
4110
+ * hash と一言は一番上の帯では丸の上に、ほかの帯では丸の下に置き、`above` と `under` は丸の真ん中から丸に近い行の基準線まで、`lineStep` は行の間。
4111
+ * 札は丸の上に段を重ねて置き、`tagTop` と `tag` は丸の真ん中から 1 段目の札の真ん中まで (一番上の帯と、ほかの帯)、`row` は札の段の間。
4112
+ * 札の段が 2 段より多い commit がある帯は、多い段の分だけ線を下げる。
4113
+ * `turn` は枝へ分かれる線と枝から入る線が曲がり終えて横へ進むまでの長さ、`samples` は曲がりを区切る点の数、`boxGap` は commit の並びと箱の間。
4114
+ * `labelUnder` はほかの帯で、丸の真ん中から線の名前の札の上端まで。`colors` は帯の色を上から配る順
4115
+ */
4116
+ git: {
4117
+ x0: 120,
4118
+ pitch: 90,
4119
+ textGap: 12,
4120
+ r: 12,
4121
+ orphan: 13.5,
4122
+ topLine: 120,
4123
+ line: 90,
4124
+ topBelow: 30,
4125
+ below: 82,
4126
+ bare: 62,
4127
+ above: 18,
4128
+ under: 27,
4129
+ lineStep: 13,
4130
+ tagTop: 58,
4131
+ tag: 30,
4132
+ row: 22,
4133
+ turn: 60,
4134
+ samples: 12,
4135
+ boxGap: 24,
4136
+ labelUnder: 50,
4137
+ colors: ["blue", "violet", "green", "amber", "rose"]
4138
+ },
3273
4139
  /** `bend` は線の曲がりを丸める半径 (#3171) */
3274
4140
  edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
3275
4141
  /** `touch` は線の名前と、同じ時刻に見えている段の番号の丸の間に空ける最小の隙間 (#3175) */
@@ -3290,7 +4156,7 @@ var LOOK = {
3290
4156
  * `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
3291
4157
  */
3292
4158
  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 } },
3293
- stroke: { mark: 1.6, 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 },
4159
+ stroke: { git: 2.25, gitOrphan: 1.5, mark: 1.6, 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 },
3294
4160
  shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
3295
4161
  mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
3296
4162
  /**
@@ -3912,7 +4778,7 @@ function arrange(diagram, groups, slots, rooms) {
3912
4778
  const headerW = Math.max(0, ...headers.map((h) => h ? h.w + R.inset * 2 : 0));
3913
4779
  const colLeft = [];
3914
4780
  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]);
3915
- const center = (c) => colLeft[c] + colW[c] / 2;
4781
+ const center2 = (c) => colLeft[c] + colW[c] / 2;
3916
4782
  const looped = new Set(edges.filter(({ edge: edge2 }) => edge2.from === edge2.to).map(({ edge: edge2 }) => edge2.from));
3917
4783
  const loopRows = new Set([...looped].flatMap((id) => {
3918
4784
  const slot = slots.get(id);
@@ -3932,7 +4798,7 @@ function arrange(diagram, groups, slots, rooms) {
3932
4798
  const slot = slots.get(id);
3933
4799
  const source = diagram.boxes.find((b) => b.id === id);
3934
4800
  const w = widths.get(id) ?? B.minW;
3935
- const cx = center(slot.col);
4801
+ const cx = center2(slot.col);
3936
4802
  const y = top + rowTop[slot.row];
3937
4803
  boxes.push({
3938
4804
  id,
@@ -4156,6 +5022,492 @@ function grow(layout, groups, slots, rooms) {
4156
5022
  return grown;
4157
5023
  }
4158
5024
 
5025
+ // src/layout/git.ts
5026
+ var isGitLayout = (layout) => layout.kind === "git";
5027
+ function walk(diagram) {
5028
+ const branches = (diagram.git?.branches ?? []).map((b) => b.id);
5029
+ const lane = (id) => {
5030
+ if (!branches.includes(id)) branches.push(id);
5031
+ };
5032
+ for (const step of diagram.steps) for (const e of step.events) if (e.type === "commit" || e.type === "branch") lane(e.branch);
5033
+ const tips = new Map(branches.map((b) => [b, null]));
5034
+ let headAt = null;
5035
+ let attached = null;
5036
+ const made = [];
5037
+ const byId = /* @__PURE__ */ new Map();
5038
+ const links = [];
5039
+ const moves = [];
5040
+ const tags = [];
5041
+ const rows = /* @__PURE__ */ new Map();
5042
+ const most = /* @__PURE__ */ new Map();
5043
+ const shown2 = /* @__PURE__ */ new Map();
5044
+ const names = [...branches, HEAD];
5045
+ const at = new Map(names.map((n) => [n, []]));
5046
+ const heads = [];
5047
+ const visible2 = (ref) => ref === HEAD ? attached === null ? headAt : null : tips.get(ref) ?? null;
5048
+ const freeRow = (commit2) => {
5049
+ const list2 = rows.get(commit2) ?? [];
5050
+ const free = list2.indexOf(null);
5051
+ return free < 0 ? list2.length : free;
5052
+ };
5053
+ const settle = (step, event2, change, lineFor) => {
5054
+ const before = new Map(names.map((n) => [n, visible2(n)]));
5055
+ const headBefore = headAt;
5056
+ change();
5057
+ const changed = names.filter((n) => before.get(n) !== visible2(n));
5058
+ const leaving = changed.map((ref) => {
5059
+ const slot = shown2.get(ref);
5060
+ if (slot) {
5061
+ rows.get(slot.commit)[slot.row] = null;
5062
+ shown2.delete(ref);
5063
+ }
5064
+ return { ref, slot };
5065
+ });
5066
+ for (const { ref, slot } of leaving) {
5067
+ const from = slot ?? (ref === HEAD && headBefore !== null ? { commit: headBefore, row: freeRow(headBefore) } : void 0);
5068
+ const target = visible2(ref);
5069
+ let to;
5070
+ if (target !== null) {
5071
+ to = { commit: target, row: freeRow(target) };
5072
+ const list2 = rows.get(target) ?? [];
5073
+ list2[to.row] = ref;
5074
+ rows.set(target, list2);
5075
+ most.set(target, Math.max(most.get(target) ?? 0, list2.filter((r) => r !== null).length));
5076
+ shown2.set(ref, to);
5077
+ }
5078
+ moves.push({ ref, step, event: event2, ...from ? { from } : {}, ...to ? { to } : {}, line: ref === lineFor });
5079
+ }
5080
+ };
5081
+ const prune = (step, event2) => {
5082
+ const reach = /* @__PURE__ */ new Set();
5083
+ const stack = [...tips.values(), headAt].filter((c) => c !== null);
5084
+ while (stack.length > 0) {
5085
+ const id = stack.pop();
5086
+ if (reach.has(id)) continue;
5087
+ reach.add(id);
5088
+ stack.push(...byId.get(id)?.parents ?? []);
5089
+ }
5090
+ for (const c of made) if (!reach.has(c.id) && c.orphan === void 0) c.orphan = { step, event: event2 };
5091
+ };
5092
+ diagram.steps.forEach((step, s) => {
5093
+ step.events.forEach((e, k) => {
5094
+ if (e.type === "commit") commit(e, s, k);
5095
+ else if (e.type === "branch") {
5096
+ if (!byId.has(e.from)) return;
5097
+ if (laneOf(e.from) !== e.branch) links.push({ kind: "branch", from: e.from, to: e.branch, step: s, event: k });
5098
+ settle(s, k, () => {
5099
+ tips.set(e.branch, e.from);
5100
+ attached = e.branch;
5101
+ headAt = e.from;
5102
+ });
5103
+ } else if (e.type === "edge") {
5104
+ const ref = e.from;
5105
+ if (ref !== HEAD && !tips.has(ref) || !byId.has(e.to)) return;
5106
+ settle(
5107
+ s,
5108
+ k,
5109
+ () => {
5110
+ if (ref === HEAD) {
5111
+ attached = null;
5112
+ headAt = e.to;
5113
+ return;
5114
+ }
5115
+ tips.set(ref, e.to);
5116
+ if (attached === ref) headAt = e.to;
5117
+ else if (attached === null && headAt === e.to) attached = ref;
5118
+ },
5119
+ ref
5120
+ );
5121
+ } else return;
5122
+ prune(s, k);
5123
+ });
5124
+ for (const n of names) at.get(n)?.push(n === HEAD ? headAt : tips.get(n) ?? null);
5125
+ heads.push(attached);
5126
+ for (const n of names) {
5127
+ const slot = shown2.get(n);
5128
+ if (slot) tags.push({ ref: n, step: s, slot });
5129
+ }
5130
+ });
5131
+ function laneOf(id) {
5132
+ return byId.get(id)?.branch;
5133
+ }
5134
+ function commit(e, s, k) {
5135
+ if (byId.has(e.id)) return;
5136
+ const copy = e.copy !== void 0 && byId.has(e.copy) ? e.copy : void 0;
5137
+ const base = copy !== void 0 && attached === null && headAt !== null ? headAt : tips.get(e.branch) ?? null;
5138
+ const joined = e.merge !== void 0 && e.merge !== e.branch ? tips.get(e.merge) ?? void 0 : void 0;
5139
+ const parents = [...new Set([base, joined].filter((c2) => c2 !== null && c2 !== void 0))];
5140
+ const c = {
5141
+ id: e.id,
5142
+ branch: e.branch,
5143
+ parents,
5144
+ ...joined !== void 0 && joined !== base ? { joined } : {},
5145
+ ...copy !== void 0 ? { copy } : {},
5146
+ ...e.hash !== void 0 ? { hash: e.hash } : {},
5147
+ ...e.note !== void 0 ? { note: e.note } : {},
5148
+ step: s,
5149
+ event: k
5150
+ };
5151
+ made.push(c);
5152
+ byId.set(c.id, c);
5153
+ for (const p of parents) links.push({ kind: "parent", from: p, to: c.id, step: s, event: k });
5154
+ if (copy !== void 0) links.push({ kind: "copy", from: copy, to: c.id, step: s, event: k });
5155
+ const first = attached === null && headAt === null;
5156
+ settle(s, k, () => {
5157
+ if (copy === void 0) {
5158
+ tips.set(e.branch, c.id);
5159
+ if (attached === e.branch) headAt = c.id;
5160
+ } else if (attached === null) headAt = c.id;
5161
+ if (first) {
5162
+ attached = e.branch;
5163
+ headAt = c.id;
5164
+ }
5165
+ });
5166
+ }
5167
+ const refs = names.map((name2) => ({ name: name2, at: at.get(name2) ?? [], ...name2 === HEAD ? { attached: heads } : {} }));
5168
+ return { branches, made, links, moves, refs, tags, rows: most };
5169
+ }
5170
+ function cubic(p0, c1, c2, p3) {
5171
+ const n = LOOK.git.samples;
5172
+ return Array.from({ length: n }, (_, k) => {
5173
+ const t = (k + 1) / n;
5174
+ const u = 1 - t;
5175
+ const at = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
5176
+ return [at(0), at(1)];
5177
+ });
5178
+ }
5179
+ function elbow(from, to) {
5180
+ if (Math.abs(from[1] - to[1]) < 0.5) return [from, to];
5181
+ return from[1] > to[1] ? [from, [from[0], to[1]], to] : [from, [to[0], from[1]], to];
5182
+ }
5183
+ function fork(p, tx, ty) {
5184
+ const sign = ty > p.cy ? 1 : -1;
5185
+ const p0 = [p.cx, p.cy + sign * p.r];
5186
+ const turn = Math.max(0, Math.min(LOOK.git.turn, tx - p.cx));
5187
+ const p3 = [p.cx + turn, ty];
5188
+ const curve = cubic(p0, [p0[0], p0[1] + (ty - p0[1]) * 0.7], [p.cx + turn * 0.2, ty], p3);
5189
+ return [p0, ...curve, ...tx > p3[0] ? [[tx, ty]] : []];
5190
+ }
5191
+ function join(p, c) {
5192
+ const sign = c.cy < p.cy ? 1 : -1;
5193
+ const p0 = [p.cx + p.r, p.cy];
5194
+ const p3 = [c.cx, c.cy + sign * c.r];
5195
+ const turn = Math.max(0, Math.min(LOOK.git.turn, c.cx - p0[0]));
5196
+ const h = [c.cx - turn, p.cy];
5197
+ const curve = cubic(h, [c.cx - turn * 0.2, p.cy], [c.cx, p3[1] + (p.cy - p3[1]) * 0.7], p3);
5198
+ return [p0, ...h[0] > p0[0] ? [h] : [], ...curve];
5199
+ }
5200
+ function copyLine(p, c) {
5201
+ if (Math.abs(p.cy - c.cy) < 0.5) {
5202
+ const top = p.cy - p.r;
5203
+ const lift = LOOK.git.turn * 0.7;
5204
+ return [[p.cx, top], ...cubic([p.cx, top], [p.cx, top - lift], [c.cx, top - lift], [c.cx, top])];
5205
+ }
5206
+ const sign = c.cy < p.cy ? -1 : 1;
5207
+ const p0 = [p.cx, p.cy + sign * p.r];
5208
+ const p3 = [c.cx, c.cy - sign * c.r];
5209
+ const mid = (p3[1] - p0[1]) * 0.5;
5210
+ return [p0, ...cubic(p0, [p0[0], p0[1] + mid], [p3[0], p3[1] - mid], p3)];
5211
+ }
5212
+ function layoutGit(diagram) {
5213
+ const { margin, gap, box: B, region: R, git: G, carrier: C } = LOOK;
5214
+ const walked = walk(diagram);
5215
+ const notes = new Map((diagram.git?.branches ?? []).map((b) => [b.id, b.note]));
5216
+ const laneIndex = new Map(walked.branches.map((id, i) => [id, i]));
5217
+ const colorOf2 = (branch) => G.colors[(laneIndex.get(branch) ?? 0) % G.colors.length];
5218
+ const col = /* @__PURE__ */ new Map();
5219
+ const laneLast = /* @__PURE__ */ new Map();
5220
+ for (const c of walked.made) {
5221
+ const k = Math.max(0, ...c.parents.map((p) => (col.get(p) ?? -1) + 1), (laneLast.get(c.branch) ?? -1) + 1);
5222
+ col.set(c.id, k);
5223
+ laneLast.set(c.branch, k);
5224
+ }
5225
+ const linesOf = (c) => [
5226
+ ...c.hash !== void 0 ? [{ text: c.hash, style: TYPE.gitHash }] : [],
5227
+ ...c.note !== void 0 ? [{ text: c.note, style: TYPE.gitNote }] : []
5228
+ ];
5229
+ const textW = (c) => Math.max(0, ...linesOf(c).map((line2) => textWidth(line2.text, line2.style)));
5230
+ const tagW = (ref) => textWidth(ref, hasWide(ref) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
5231
+ const refWidth = Math.max(0, ...walked.refs.map((r) => tagW(r.name)));
5232
+ const pitch = Math.max(G.pitch, ...walked.made.map((c) => textW(c) + G.textGap), refWidth + G.textGap);
5233
+ const headers = walked.branches.map((id) => ({ w: Math.max(R.icon, textWidth(id, TYPE.regionName), textWidth(notes.get(id) ?? "", TYPE.regionNote)) }));
5234
+ const headerRight = margin + R.inset + Math.max(0, ...headers.map((h) => h.w));
5235
+ 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);
5236
+ const x0 = Math.max(G.x0, headerRight + gap + firstHalf);
5237
+ const named = new Set(
5238
+ walked.moves.flatMap((mv) => {
5239
+ const source = diagram.steps[mv.step]?.events[mv.event];
5240
+ return mv.line && mv.to && source?.type === "edge" && source.label !== void 0 ? [walked.made.find((c) => c.id === mv.to?.commit)?.branch ?? ""] : [];
5241
+ })
5242
+ );
5243
+ const extraRows = (branch) => Math.max(0, ...walked.made.filter((c) => c.branch === branch).map((c) => (walked.rows.get(c.id) ?? 0) - 2)) * G.row;
5244
+ const topText = walked.made.some((c) => laneIndex.get(c.branch) === 0 && linesOf(c).length > 0);
5245
+ const lanes = [];
5246
+ let y = margin;
5247
+ walked.branches.forEach((id, i) => {
5248
+ const top = i === 0;
5249
+ const tagBase = top && topText ? G.tagTop : G.tag;
5250
+ const line2 = y + (top ? G.topLine - (G.tagTop - tagBase) : G.line) + extraRows(id);
5251
+ const h = line2 - y + (top ? G.topBelow : named.has(id) ? G.below : G.bare);
5252
+ lanes.push({ id, x: margin, y, w: 0, h, line: line2, color: colorOf2(id), tagBase });
5253
+ y += h + R.gap;
5254
+ });
5255
+ const lanesBottom = y - R.gap;
5256
+ const laneOf = new Map(lanes.map((l) => [l.id, l]));
5257
+ const commits = walked.made.map((c) => {
5258
+ const lane = laneOf.get(c.branch);
5259
+ const isTop = laneIndex.get(c.branch) === 0;
5260
+ const cx = x0 + pitch * (col.get(c.id) ?? 0) + (isTop ? 0 : pitch / 2);
5261
+ const cy = lane.line;
5262
+ const lines = linesOf(c);
5263
+ const baselines = lines.map((_, k) => isTop ? cy - G.above - (lines.length - 1 - k) * G.lineStep : cy + G.under + k * G.lineStep);
5264
+ const boxes2 = lines.map((line2, k) => textBox(line2.text, cx, baselines[k], line2.style, "middle"));
5265
+ const text2 = boxes2.length === 0 ? void 0 : { ...union(boxes2), lines: lines.map((line2) => line2.text), baselines };
5266
+ const color = c.copy !== void 0 ? colorOf2(walked.made.find((m) => m.id === c.copy)?.branch ?? c.branch) : colorOf2(c.branch);
5267
+ return {
5268
+ id: c.id,
5269
+ branch: c.branch,
5270
+ color,
5271
+ cx,
5272
+ cy,
5273
+ r: G.r,
5274
+ step: c.step,
5275
+ event: c.event,
5276
+ parents: c.parents,
5277
+ ...c.copy !== void 0 ? { copy: c.copy } : {},
5278
+ ...c.hash !== void 0 ? { hash: c.hash } : {},
5279
+ ...c.note !== void 0 ? { note: c.note } : {},
5280
+ ...text2 ? { text: text2 } : {},
5281
+ ...c.orphan ? { orphan: c.orphan.step, orphanEvent: c.orphan.event } : {}
5282
+ };
5283
+ });
5284
+ const placed = new Map(commits.map((c) => [c.id, c]));
5285
+ const links = walked.links.flatMap((l) => {
5286
+ const from = placed.get(l.from);
5287
+ if (!from) return [];
5288
+ if (l.kind === "branch") {
5289
+ if (!walked.made.some((c) => c.branch === l.to)) return [];
5290
+ const lane = laneOf.get(l.to);
5291
+ return [{ ...l, points: fork(from, from.cx + G.turn, lane.line), color: colorOf2(l.to) }];
5292
+ }
5293
+ const to = placed.get(l.to);
5294
+ const made = walked.made.find((m) => m.id === l.to);
5295
+ let points;
5296
+ if (l.kind === "copy") points = copyLine(from, to);
5297
+ else if (Math.abs(from.cy - to.cy) < 0.5) points = [[from.cx + from.r, from.cy], [to.cx - to.r, to.cy]];
5298
+ else if (made?.joined === l.from) points = join(from, to);
5299
+ else points = fork(from, to.cx - to.r, to.cy);
5300
+ return [{ ...l, points, color: to.color }];
5301
+ });
5302
+ const tagRect = (ref, slot) => {
5303
+ const c = placed.get(slot.commit);
5304
+ const base = laneOf.get(c.branch)?.tagBase ?? G.tag;
5305
+ const w = tagW(ref);
5306
+ return { x: c.cx - w / 2, y: c.cy - base - slot.row * G.row - C.tagH / 2, w, h: C.tagH };
5307
+ };
5308
+ const center2 = (r) => [r.x + r.w / 2, r.y + r.h / 2];
5309
+ const moves = walked.moves.map((m) => {
5310
+ const from = m.from ? tagRect(m.ref, m.from) : void 0;
5311
+ const to = m.to ? tagRect(m.ref, m.to) : void 0;
5312
+ const source = diagram.steps[m.step]?.events[m.event];
5313
+ const carried = m.line && source?.type === "edge" && source.carry.kind !== "none" && !(source.carry.kind === "tag" && source.carry.text === source.from);
5314
+ return {
5315
+ ref: m.ref,
5316
+ step: m.step,
5317
+ event: m.event,
5318
+ ...from ? { from } : {},
5319
+ ...to ? { to } : {},
5320
+ ...m.to ? { target: m.to.commit } : {},
5321
+ ...carried ? { carried: true } : {},
5322
+ ...m.line && from && to ? { line: elbow(center2(from), center2(to)) } : {},
5323
+ color: "slate"
5324
+ };
5325
+ });
5326
+ const tags = walked.tags.map((t) => ({ ...tagRect(t.ref, t.slot), ref: t.ref, step: t.step }));
5327
+ const colors = boxColors(diagram);
5328
+ const right = Math.max(
5329
+ x0,
5330
+ ...commits.flatMap((c) => [c.cx + c.r, ...c.text ? [c.text.x + c.text.w] : []]),
5331
+ ...tags.map((t) => t.x + t.w),
5332
+ ...moves.flatMap((m) => [m.from, m.to].flatMap((r) => r ? [r.x + r.w] : []))
5333
+ );
5334
+ const boxX = right + G.boxGap;
5335
+ const firstCy = (lanes[1] ?? lanes[0])?.line ?? margin + B.h / 2;
5336
+ const boxes = diagram.boxes.map((b, i) => {
5337
+ const w = boxWidth(diagram, b.id, true);
5338
+ const cy = firstCy + i * (B.h + gap);
5339
+ return {
5340
+ id: b.id,
5341
+ name: b.name,
5342
+ ...b.sub !== void 0 ? { sub: b.sub } : {},
5343
+ ...b.icon !== void 0 ? { icon: b.icon } : {},
5344
+ color: colors.get(b.id) ?? "slate",
5345
+ x: boxX,
5346
+ y: cy - B.h / 2,
5347
+ w,
5348
+ h: B.h,
5349
+ cx: boxX + w / 2,
5350
+ cy
5351
+ };
5352
+ });
5353
+ const regions = lanes.map((lane, i) => {
5354
+ const note = notes.get(lane.id);
5355
+ return {
5356
+ id: lane.id,
5357
+ lines: [lane.id],
5358
+ ...note !== void 0 ? { note } : {},
5359
+ icon: "branch",
5360
+ color: lane.color,
5361
+ x: lane.x,
5362
+ y: lane.y,
5363
+ w: 0,
5364
+ h: lane.h,
5365
+ 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 }
5366
+ };
5367
+ });
5368
+ const layout = {
5369
+ kind: "git",
5370
+ width: 0,
5371
+ height: 0,
5372
+ regions,
5373
+ boxes,
5374
+ lifelines: [],
5375
+ edges: [],
5376
+ labels: [],
5377
+ actions: [],
5378
+ badges: [],
5379
+ paths: [],
5380
+ ends: [],
5381
+ lanes,
5382
+ commits,
5383
+ links,
5384
+ tags,
5385
+ refs: walked.refs,
5386
+ moves
5387
+ };
5388
+ layout.badges = badgesOf(diagram, layout);
5389
+ layout.labels = labelsOf(diagram, layout);
5390
+ const contentRight = Math.max(right, ...boxes.map((b) => b.x + b.w), ...layout.labels.map((l) => l.x + l.w)) + R.pad;
5391
+ const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
5392
+ for (const region of regions) region.w = width - margin * 2;
5393
+ for (const lane of lanes) lane.w = width - margin * 2;
5394
+ const bottom = Math.max(lanesBottom, ...boxes.map((b) => b.y + b.h), ...layout.labels.map((l) => l.y + l.h));
5395
+ const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2);
5396
+ layout.width = width;
5397
+ layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
5398
+ if (strip2) layout.strip = strip2;
5399
+ layout.badges = badgesOf(diagram, layout);
5400
+ return layout;
5401
+ }
5402
+ function union(rects) {
5403
+ const x = Math.min(...rects.map((r) => r.x));
5404
+ const y = Math.min(...rects.map((r) => r.y));
5405
+ 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 };
5406
+ }
5407
+ function firstMark(layout, step) {
5408
+ const marks = [
5409
+ ...layout.links.filter((l) => l.step === step && l.kind !== "copy").map((l) => ({ event: l.event, points: l.points, color: l.color })),
5410
+ ...layout.moves.flatMap((m) => {
5411
+ const target = layout.commits.find((c) => c.id === m.target);
5412
+ return m.step === step && m.line && target ? [{ event: m.event, target, color: target.color }] : [];
5413
+ })
5414
+ ].sort((a, b) => a.event - b.event);
5415
+ return marks[0];
5416
+ }
5417
+ function besideCommit(c, taken, avoid) {
5418
+ const { r, inset } = LOOK.badge;
5419
+ const d = c.r + inset + r;
5420
+ const apart = r * 2 + inset;
5421
+ const spots = [
5422
+ [c.cx + d, c.cy],
5423
+ [c.cx, c.cy + d],
5424
+ [c.cx - d, c.cy],
5425
+ [c.cx, c.cy - d]
5426
+ ];
5427
+ 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));
5428
+ }
5429
+ function clearOnPath(points, taken, avoid) {
5430
+ const { r, inset, along: start, short } = LOOK.badge;
5431
+ const length = pathLength(points);
5432
+ const first = length < short ? Math.min(r + 1, length / 2) : start;
5433
+ const apart = r * 2 + inset;
5434
+ for (let d = first; d <= length; d += 1) {
5435
+ const p = along(points, d);
5436
+ const rect = badgeRect(p);
5437
+ 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;
5438
+ }
5439
+ return void 0;
5440
+ }
5441
+ function badgesOf(diagram, layout) {
5442
+ const { inset } = LOOK.badge;
5443
+ const taken = [];
5444
+ const all = [...layout.links.map((l) => l.points), ...layout.moves.flatMap((m) => m.line ? [m.line] : [])];
5445
+ const out = [];
5446
+ const avoid = [
5447
+ ...layout.tags,
5448
+ ...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] : []])
5449
+ ];
5450
+ diagram.steps.forEach((step, s) => {
5451
+ const mark = firstMark(layout, s);
5452
+ const near = mark?.target ? besideCommit(mark.target, taken, avoid) : void 0;
5453
+ if (mark && (mark.points || near)) {
5454
+ const points = mark.points;
5455
+ const point = near ?? (points ? clearOnPath(points, taken, avoid) ?? badgeOnPath(points, taken, all.filter((p) => p !== points)) : [0, 0]);
5456
+ taken.push(point);
5457
+ out.push({ step: s, x: point[0], y: point[1], color: mark.color });
5458
+ return;
5459
+ }
5460
+ const box = step.events.flatMap((e) => e.type === "swap" || e.type === "action" ? [e.box] : []).map((id) => layout.boxes.find((b) => b.id === id))[0];
5461
+ if (box) {
5462
+ out.push({ step: s, x: box.x, y: box.y, color: box.color });
5463
+ return;
5464
+ }
5465
+ if (layout.strip && step.events.some((e) => e.type === "strip")) {
5466
+ out.push({ step: s, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" });
5467
+ return;
5468
+ }
5469
+ const tip = layout.commits.find((c) => c.id === layout.refs[0]?.at[s]);
5470
+ const spot = tip ? besideCommit(tip, taken, avoid) : void 0;
5471
+ if (tip && spot) {
5472
+ taken.push(spot);
5473
+ out.push({ step: s, x: spot[0], y: spot[1], color: tip.color });
5474
+ return;
5475
+ }
5476
+ const before = out[out.length - 1];
5477
+ const lane = layout.lanes[0];
5478
+ 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" });
5479
+ });
5480
+ return replaceSameSpot(out);
5481
+ }
5482
+ function labelsOf(diagram, layout) {
5483
+ const G = LOOK.git;
5484
+ const labels = [];
5485
+ const circles = layout.commits.map((c) => ({ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }));
5486
+ const texts = layout.commits.flatMap((c) => c.text ? [c.text] : []);
5487
+ const headers = layout.regions.map((r) => r.header);
5488
+ for (const move of layout.moves) {
5489
+ const source = diagram.steps[move.step]?.events[move.event];
5490
+ if (source?.type !== "edge" || source.label === void 0 || !move.line) continue;
5491
+ const target = layout.commits.find((c) => c.id === source.to);
5492
+ if (!target) continue;
5493
+ const top = layout.lanes[0]?.id === target.branch;
5494
+ const w = textWidth(source.label, hasWide(source.label) ? TYPE.labelJa : TYPE.label) + LOOK.label.padX * 2;
5495
+ const [mx] = move.line.reduce((sum, p) => [sum[0] + p[0] / move.line.length, 0], [0, 0]);
5496
+ 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));
5497
+ const side2 = source.labelSide ?? (top ? "above" : "below");
5498
+ 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 };
5499
+ const seen = layout.badges.filter((b) => b.step <= move.step).map((b) => badgeRect([b.x, b.y]));
5500
+ const tags = layout.tags.filter((t) => t.step === move.step);
5501
+ labels.push(
5502
+ placeLabel(
5503
+ { step: move.step, event: move.event, text: source.label, points: move.line, color: move.color, side: side2, ...base ? { base } : {} },
5504
+ { hard: [...circles, ...layout.boxes], soft: [...texts, ...tags, ...headers, ...labels.filter((l) => l.step === move.step)], touch: seen }
5505
+ )
5506
+ );
5507
+ }
5508
+ return labels;
5509
+ }
5510
+
4159
5511
  // src/layout/sequence.ts
4160
5512
  function layoutSequence(diagram) {
4161
5513
  const { box: B, sequence: Q, label: L, margin, gap } = LOOK;
@@ -4364,7 +5716,7 @@ function layoutState(diagram, lang) {
4364
5716
  }
4365
5717
  const colLeft = [];
4366
5718
  for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
4367
- const center = (c) => colLeft[c] + colW[c] / 2;
5719
+ const center2 = (c) => colLeft[c] + colW[c] / 2;
4368
5720
  const isGhost = (id) => ghosts.includes(id);
4369
5721
  const enteringFrom = new Set(notTaken.filter((p) => isGhost(p.to) && !isGhost(p.from) && !isEnd(p.from)).map((p) => p.from));
4370
5722
  const notes = [words.sideNote, ...enteringFrom.size > 0 ? [words.sideFrom(enteringFrom.size)] : []];
@@ -4394,7 +5746,7 @@ function layoutState(diagram, lang) {
4394
5746
  };
4395
5747
  const boxes = walked.map((id) => {
4396
5748
  const s = slot.get(id);
4397
- return boxOf(id, center(s.col), rowY(s.row), false);
5749
+ return boxOf(id, center2(s.col), rowY(s.row), false);
4398
5750
  });
4399
5751
  for (const box of boxes) placeSlot(box, carriedIn.get(box.id), doneSide);
4400
5752
  const byId = new Map(boxes.map((b) => [b.id, b]));
@@ -4614,7 +5966,15 @@ function plan(step) {
4614
5966
  let arrived;
4615
5967
  let changes = 0;
4616
5968
  step.events.forEach((event2, e) => {
4617
- if (event2.type === "edge") {
5969
+ if (event2.type === "commit" || event2.type === "branch") {
5970
+ const a = cursor;
5971
+ const b = a + MOTION.draw;
5972
+ out.edges.push({ event: e, a, b, carries: false, coin: false, named: false });
5973
+ cursor = a + MOTION.stagger;
5974
+ arrived = b;
5975
+ changes = 0;
5976
+ out.busy = Math.max(out.busy, b);
5977
+ } else if (event2.type === "edge") {
4618
5978
  const carries = event2.carry.kind !== "none";
4619
5979
  const a = cursor;
4620
5980
  const b = a + (carries ? MOTION.drawCarry : MOTION.draw);
@@ -4659,7 +6019,9 @@ function buildTimeline(diagram) {
4659
6019
  for (const edge2 of p.edges) {
4660
6020
  const a = span.start + edge2.a;
4661
6021
  edges.push({ step: s, event: edge2.event, start: a, drawn: span.start + edge2.b, end: span.end });
4662
- if (edge2.carries) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
6022
+ const event2 = diagram.steps[s]?.events[edge2.event];
6023
+ const own = diagram.kind === "git" && event2?.type === "edge" && event2.carry.kind === "tag" && event2.carry.text === event2.from;
6024
+ if (edge2.carries && !own) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
4663
6025
  if (edge2.named) named.push({ step: s, event: edge2.event, start: a + MOTION.labelDelay, end: span.end });
4664
6026
  }
4665
6027
  named.forEach((label2, k) => {
@@ -5151,6 +6513,123 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
5151
6513
  return parts.join("");
5152
6514
  }
5153
6515
 
6516
+ // src/render/git.ts
6517
+ var r12 = (v) => Math.round(v * 100) / 100;
6518
+ var center = (r) => [r.x + r.w / 2, r.y + r.h / 2];
6519
+ function tagShape(text2, sh) {
6520
+ const C = LOOK.carrier;
6521
+ const ja3 = hasWide(text2);
6522
+ const w = textWidth(text2, ja3 ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
6523
+ 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>`;
6524
+ }
6525
+ function drawGit(layout, diagram, timeline, ctx) {
6526
+ const { m } = ctx;
6527
+ const G = LOOK.git;
6528
+ const timeOf = (step, event2) => timeline.edges.find((t) => t.step === step && t.event === event2);
6529
+ const links = layout.links.map((l) => {
6530
+ const time = timeOf(l.step, l.event);
6531
+ if (!time) return "";
6532
+ ctx.traces.push({ from: l.from, to: l.to, points: l.points, shown: [[time.start, Number.POSITIVE_INFINITY]] });
6533
+ const d = pathOf(l.points);
6534
+ 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>`;
6535
+ const kf = m.kf([
6536
+ [0, { opacity: 0, "stroke-dashoffset": 1 }],
6537
+ [time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
6538
+ [time.start + 0.05, { opacity: 1 }],
6539
+ [time.drawn, { "stroke-dashoffset": 0 }],
6540
+ [m.last, { opacity: 1, "stroke-dashoffset": 0 }, EASE.inOut],
6541
+ [m.total, { opacity: 0, "stroke-dashoffset": 0 }]
6542
+ ]);
6543
+ return `<g style="${cs(l.color)}"><path class="dg-git-l dg-a" pathLength="1" d="${d}" style="${kf}"/></g>`;
6544
+ }).join("");
6545
+ const commits = layout.commits.map((c) => {
6546
+ const at = timeOf(c.step, c.event)?.drawn ?? 0;
6547
+ const ring = { x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 };
6548
+ ctx.ink.push({ text: c.id, rect: ring, shown: [[at, Number.POSITIVE_INFINITY]], boxed: true });
6549
+ const lines2 = (c.text?.lines ?? []).map((line2, k) => {
6550
+ const hash = k === 0 && c.hash !== void 0;
6551
+ const baseline = c.text?.baselines[k] ?? c.cy;
6552
+ return write(ctx.ink, hash ? "dg-git-h" : "dg-git-n", c.cx, baseline, line2, hash ? TYPE.gitHash : TYPE.gitNote, [[at, Number.POSITIVE_INFINITY]], "middle");
6553
+ }).join("");
6554
+ 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>`;
6555
+ const node = `<g class="dg-popc dg-a" style="${m.pop(at)}"><circle class="dg-git-c" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${c.r}" ${ctx.sh}/>${id}</g>`;
6556
+ const text2 = lines2 === "" ? "" : `<g class="dg-a" style="${m.vis(at)}">${lines2}</g>`;
6557
+ const orphanAt = c.orphan === void 0 ? void 0 : timeOf(c.orphan, c.orphanEvent ?? 0)?.drawn;
6558
+ 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>`;
6559
+ return `<g data-commit="${esc(c.id)}" style="${cs(c.color)}">${node}${text2}${orphan}</g>`;
6560
+ }).join("");
6561
+ const lines = layout.moves.flatMap((mv) => {
6562
+ const time = timeOf(mv.step, mv.event);
6563
+ if (!mv.line || !time) return [];
6564
+ const end = timeline.steps[mv.step].end;
6565
+ ctx.traces.push({ from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, shown: [[time.start, end + 0.4]] });
6566
+ const kf = m.kf([
6567
+ [0, { opacity: 0, "stroke-dashoffset": 1 }],
6568
+ [time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
6569
+ [time.start + 0.05, { opacity: 1 }],
6570
+ [time.drawn, { "stroke-dashoffset": 0 }],
6571
+ [end, { opacity: 1 }, EASE.inOut],
6572
+ [end + 0.4, { opacity: 0 }],
6573
+ [m.total, { opacity: 0, "stroke-dashoffset": 0 }]
6574
+ ]);
6575
+ return [`<g style="${cs(mv.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${pathOf(mv.line)}" style="${kf}"/></g>`];
6576
+ }).join("");
6577
+ const carried = timeline.carriers.flatMap((t) => {
6578
+ const mv = layout.moves.find((x) => x.step === t.step && x.event === t.event && x.line);
6579
+ const source = diagram.steps[t.step]?.events[t.event];
6580
+ if (!mv?.line || source?.type !== "edge") return [];
6581
+ 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 };
6582
+ return [carrier(edge2, { ...t, start: t.depart, end: t.arrive + MOTION.fade }, ctx)];
6583
+ }).join("");
6584
+ const refs = [...new Set(layout.moves.map((mv) => mv.ref))];
6585
+ const tags = refs.map((ref) => tagMotion(ref, layout.moves.filter((mv) => mv.ref === ref), timeOf, ctx)).join("") + carried;
6586
+ return { links, lines, commits, tags };
6587
+ }
6588
+ function tagMotion(ref, list2, timeOf, ctx) {
6589
+ const { m } = ctx;
6590
+ const points = [];
6591
+ const fades = [[0, { opacity: 0 }]];
6592
+ let on = false;
6593
+ let rest;
6594
+ const leave = (t) => {
6595
+ if (rest) ctx.ink.push({ text: ref, rect: rest.rect, shown: [[rest.since, t]], boxed: true });
6596
+ rest = void 0;
6597
+ };
6598
+ for (const mv of list2) {
6599
+ const time = timeOf(mv.step, mv.event);
6600
+ if (!time) continue;
6601
+ const { start: a, drawn: b } = time;
6602
+ const from = mv.from ? center(mv.from) : void 0;
6603
+ const to = mv.to ? center(mv.to) : void 0;
6604
+ leave(a);
6605
+ if (mv.carried && from && to && on) {
6606
+ points.push([a + MOTION.fade, from[0], from[1]], [b - MOTION.fade, to[0], to[1]]);
6607
+ fades.push([a, { opacity: 1 }, EASE.inOut], [a + MOTION.fade, { opacity: 0 }], [b - MOTION.fade, { opacity: 0 }, EASE.out], [b, { opacity: 1 }]);
6608
+ rest = { rect: mv.to, since: b };
6609
+ continue;
6610
+ }
6611
+ if (from) points.push([a, from[0], from[1]]);
6612
+ if (to) points.push([b, to[0], to[1]]);
6613
+ if (to && !on) {
6614
+ const show = from ? a : b - MOTION.fade;
6615
+ fades.push([show, { opacity: 0 }, EASE.out], [show + MOTION.fade, { opacity: 1 }]);
6616
+ on = true;
6617
+ } else if (!to && on) {
6618
+ fades.push([b, { opacity: 1 }, EASE.inOut], [b + MOTION.untilFade, { opacity: 0 }]);
6619
+ on = false;
6620
+ }
6621
+ if (mv.to) rest = { rect: mv.to, since: b };
6622
+ }
6623
+ leave(Number.POSITIVE_INFINITY);
6624
+ if (points.length === 0) return "";
6625
+ const first = points[0];
6626
+ const last = points[points.length - 1];
6627
+ if (on) fades.push([m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]);
6628
+ else fades.push([m.total, { opacity: 0 }]);
6629
+ const style = m.move([[0, first[1], first[2]], ...points, [m.total, last[1], last[2]]], fades);
6630
+ return `<g class="dg-a" data-ref="${esc(ref)}" style="${style}">${tagShape(ref, ctx.sh)}</g>`;
6631
+ }
6632
+
5154
6633
  // src/render/motion.ts
5155
6634
  var r2 = (v) => Math.round(v * 100) / 100;
5156
6635
  var Motion = class {
@@ -5321,6 +6800,14 @@ var PART_CSS = [
5321
6800
  `.dg-mark{${font(TYPE.regionNote)};fill:var(--mute)}`,
5322
6801
  `.dg-done{fill:var(--ink);stroke:var(--surf);stroke-width:${S.done}}`,
5323
6802
  `.dg-done-ck{fill:none;stroke:var(--surf);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
6803
+ `.dg-git-l{fill:none;stroke:var(--c);stroke-width:${S.git};stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1 2}`,
6804
+ `.dg-git-cp{fill:none;stroke:var(--c);stroke-width:${S.gitOrphan};stroke-linecap:round;stroke-dasharray:3 3;stroke-opacity:.7}`,
6805
+ `.dg-git-c{fill:var(--surf);stroke:var(--c);stroke-width:${S.git}}`,
6806
+ `.dg-git-id{${font(TYPE.gitId)};fill:var(--ct)}`,
6807
+ `.dg-git-h{${font(TYPE.gitHash)};fill:var(--mute)}`,
6808
+ `.dg-git-n{${font(TYPE.gitNote)};fill:var(--ink2)}`,
6809
+ `.dg-git-old{fill:var(--surf);stroke:var(--c);stroke-width:${S.gitOrphan};stroke-dasharray:3 3;stroke-opacity:.6}`,
6810
+ `.dg-git-oldl{${font(TYPE.gitId)};fill:var(--ct);opacity:.55}`,
5324
6811
  ".dg-vp-bg{fill:var(--bg)}",
5325
6812
  ".dg-vp-frame{fill:none;stroke:var(--hair)}",
5326
6813
  ".dg-hd-bg{fill:var(--bg)}",
@@ -5427,6 +6914,13 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
5427
6914
  const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
5428
6915
  if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals));
5429
6916
  for (const line2 of layout.lifelines) L.base.push(lifeline(line2.x, line2.y1, line2.y2));
6917
+ if (isGitLayout(layout)) {
6918
+ const git = drawGit(layout, diagram, timeline, ctx);
6919
+ L.base.push(git.links);
6920
+ L.lit.push(git.lines);
6921
+ L.node.push(git.commits);
6922
+ L.top.push(git.tags);
6923
+ }
5430
6924
  for (const e of layout.edges) {
5431
6925
  const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
5432
6926
  if (!time) continue;
@@ -5465,14 +6959,14 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
5465
6959
  const css = `.dg-${id}{${FONT_VARS};--T:${timeline.total}s;${paletteVars(palette, theme)}}${PART_CSS}${m.frames.join("")}`;
5466
6960
  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>`;
5467
6961
  }
5468
- function union(rects) {
6962
+ function union2(rects) {
5469
6963
  const x = Math.min(...rects.map((r) => r.x));
5470
6964
  const y = Math.min(...rects.map((r) => r.y));
5471
6965
  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 };
5472
6966
  }
5473
6967
  function focusOf(layout, diagram, step) {
5474
6968
  const rects = focusParts(layout, diagram, step);
5475
- return rects.length === 0 ? void 0 : union(rects);
6969
+ return rects.length === 0 ? void 0 : union2(rects);
5476
6970
  }
5477
6971
  function badgeFocus(badge2, parts, vw, vh) {
5478
6972
  const room = LOOK.badge.r + LOOK.follow.badgeRoom;
@@ -5480,7 +6974,7 @@ function badgeFocus(badge2, parts, vw, vh) {
5480
6974
  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));
5481
6975
  let held = { x: bx - room, y: by - room, w: room * 2, h: room * 2 };
5482
6976
  for (const p of [...parts].sort((a, b) => away(a) - away(b))) {
5483
- const next = union([held, p]);
6977
+ const next = union2([held, p]);
5484
6978
  if (next.w <= vw && next.h <= vh) held = next;
5485
6979
  }
5486
6980
  return held;
@@ -5578,7 +7072,7 @@ function renderDiagram(input, options = {}) {
5578
7072
  const read = readDiagram(input, { lang });
5579
7073
  if (!read.ok) throw new Error(FIGURE_TEXT[lang].cannotDraw(read.errors.map((e) => `${e.pointer} ${e.message}`).join(" / ")));
5580
7074
  const diagram = read.diagram;
5581
- const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : layoutArchitecture(diagram);
7075
+ const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : diagram.kind === "git" ? layoutGit(diagram) : layoutArchitecture(diagram);
5582
7076
  return renderLayout(diagram, layout, buildTimeline(diagram), options);
5583
7077
  }
5584
7078
  function renderLayout(diagram, layout, timeline, options = {}) {
@@ -5912,7 +7406,6 @@ exports.chooseView = chooseView;
5912
7406
  exports.describeOverlap = describeOverlap;
5913
7407
  exports.extractDiagrams = extractDiagrams;
5914
7408
  exports.iconSvg = iconSvg;
5915
- exports.migrateFile = migrateFile;
5916
7409
  exports.mountDiagram = mountDiagram;
5917
7410
  exports.parseNotation = parseNotation;
5918
7411
  exports.printNotation = printNotation;