@dotbep/core 0.2.17 → 0.2.18

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.
package/dist/index.js CHANGED
@@ -227,10 +227,10 @@ const Ge = r.enum([
227
227
  nodes: r.record(r.string(), ft),
228
228
  edges: r.record(r.string(), gt)
229
229
  }).superRefine((n, e) => {
230
- const s = Object.entries(n.nodes), t = s.filter(([, a]) => a.type === "start").length, i = s.filter(([, a]) => a.type === "end").length;
231
- t !== 1 && e.addIssue({
230
+ const t = Object.entries(n.nodes), s = t.filter(([, a]) => a.type === "start").length, i = t.filter(([, a]) => a.type === "end").length;
231
+ s !== 1 && e.addIssue({
232
232
  code: "custom",
233
- message: `Diagram must have exactly one start node (found ${t}).`,
233
+ message: `Diagram must have exactly one start node (found ${s}).`,
234
234
  path: ["nodes"]
235
235
  }), i !== 1 && e.addIssue({
236
236
  code: "custom",
@@ -240,7 +240,7 @@ const Ge = r.enum([
240
240
  const o = {};
241
241
  for (const [a, d] of Object.entries(n.edges))
242
242
  o[d.from] ??= [], o[d.from].push({ edgeId: a, toKey: d.to });
243
- for (const [a, d] of s) {
243
+ for (const [a, d] of t) {
244
244
  const l = o[a] ?? [];
245
245
  d.type === "automation" && (l.length !== 1 ? e.addIssue({
246
246
  code: "custom",
@@ -416,36 +416,36 @@ const Ge = r.enum([
416
416
  current: r.string().regex(/^\d+\.\d+$/).describe('Current version in "{major}.{minor}" format.'),
417
417
  versions: r.array(It)
418
418
  });
419
- function j(n) {
419
+ function A(n) {
420
420
  return n.roles ??= [], n.members ??= [], n.teams ??= [], n.phases ??= [], n.milestones ??= [], n.lbs ??= [], n.disciplines ??= [], n.extensions ??= [], n.assetTypes ??= [], n.softwares ??= [], n.objectives ??= [], n.bimUses ??= [], n.actions ??= [], n.events ??= [], n.effects ??= [], n.workflows ??= [], n.guides ??= [], n.annexes ??= [], n.standards ??= [], n.lods ??= [], n.lois ??= [], n.loin ??= [], n.deliverables ??= [], n.notes ??= [], n.flags ??= [], n.env ??= [], n.automations ??= [], n.resolvers ??= [], n.remoteData ??= [], n;
421
421
  }
422
422
  const Et = "-", kt = "^[A-Z0-9]{3}$";
423
423
  function St(n, e) {
424
424
  if (e) {
425
- const s = e.segments.find((t) => t.type === "field" && t.token === n);
426
- if (s?.type === "field" && s.pattern) return s.pattern;
425
+ const t = e.segments.find((s) => s.type === "field" && s.token === n);
426
+ if (t?.type === "field" && t.pattern) return t.pattern;
427
427
  }
428
428
  return kt;
429
429
  }
430
- function B(n, e, s) {
431
- const t = s?.delimiter ?? Et, i = St(n, s);
432
- return new RegExp(i).test(e) ? e.includes(t) ? `"${e}" contains the naming delimiter "${t}"` : null : `"${e}" does not match naming pattern ${i} for token "${n}"`;
430
+ function O(n, e, t) {
431
+ const s = t?.delimiter ?? Et, i = St(n, t);
432
+ return new RegExp(i).test(e) ? e.includes(s) ? `"${e}" contains the naming delimiter "${s}"` : null : `"${e}" does not match naming pattern ${i} for token "${n}"`;
433
433
  }
434
434
  function Nt(n, e) {
435
- const s = [], t = (i, o) => {
436
- const a = B(i, o, e);
437
- a && s.push(a);
435
+ const t = [], s = (i, o) => {
436
+ const a = O(i, o, e);
437
+ a && t.push(a);
438
438
  };
439
- t("project", n.project.code);
440
- for (const i of n.teams) t("team", i.id);
441
- for (const i of n.disciplines) t("discipline", i.id);
442
- for (const i of n.assetTypes) t("assetType", i.id);
443
- for (const i of n.lbs) t(i.type === "zone" ? "lbsZone" : "lbsLocation", i.id);
444
- return s;
439
+ s("project", n.project.code);
440
+ for (const i of n.teams) s("team", i.id);
441
+ for (const i of n.disciplines) s("discipline", i.id);
442
+ for (const i of n.assetTypes) s("assetType", i.id);
443
+ for (const i of n.lbs) s(i.type === "zone" ? "lbsZone" : "lbsLocation", i.id);
444
+ return t;
445
445
  }
446
446
  class _t {
447
- constructor(e, s, t, i, o) {
448
- this.getItem = e, this.setItem = s, this.schema = t, this.validate = i, this.getBep = o;
447
+ constructor(e, t, s, i, o) {
448
+ this.getItem = e, this.setItem = t, this.schema = s, this.validate = i, this.getBep = o;
449
449
  }
450
450
  getItem;
451
451
  setItem;
@@ -456,12 +456,12 @@ class _t {
456
456
  return this.getItem();
457
457
  }
458
458
  update(e) {
459
- const s = this.schema.parse({ ...this.getItem(), ...e });
459
+ const t = this.schema.parse({ ...this.getItem(), ...e });
460
460
  if (this.validate && this.getBep) {
461
- const t = this.validate(s, this.getBep());
462
- if (t.length) throw new Error(t.join("; "));
461
+ const s = this.validate(t, this.getBep());
462
+ if (s.length) throw new Error(s.join("; "));
463
463
  }
464
- return this.setItem(s), s;
464
+ return this.setItem(t), t;
465
465
  }
466
466
  }
467
467
  const De = [
@@ -504,29 +504,29 @@ const De = [
504
504
  // lbs (self-referential)
505
505
  { entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
506
506
  ];
507
- function $t(n, e, s) {
508
- return De.filter((t) => t.references === e).flatMap((t) => s[t.entity].filter((o) => {
509
- const a = o[t.inField];
510
- return t.array ? Array.isArray(a) && a.includes(n) : a === n;
507
+ function $t(n, e, t) {
508
+ return De.filter((s) => s.references === e).flatMap((s) => t[s.entity].filter((o) => {
509
+ const a = o[s.inField];
510
+ return s.array ? Array.isArray(a) && a.includes(n) : a === n;
511
511
  }).map((o) => {
512
512
  const a = o.id ?? o.email ?? "?";
513
- return `${String(t.entity)}["${a}"].${String(t.inField)}`;
513
+ return `${String(s.entity)}["${a}"].${String(s.inField)}`;
514
514
  }));
515
515
  }
516
- function ie(n, e, s) {
517
- return De.filter((t) => t.entity === e).flatMap((t) => {
518
- const i = n[t.inField];
516
+ function ie(n, e, t) {
517
+ return De.filter((s) => s.entity === e).flatMap((s) => {
518
+ const i = n[s.inField];
519
519
  if (i == null || i === "") return [];
520
- const o = t.array ? i : [i], a = s[t.references];
521
- return o.filter((d) => !a.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(t.references)}["${d}"] not found`);
520
+ const o = s.array ? i : [i], a = t[s.references];
521
+ return o.filter((d) => !a.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(s.references)}["${d}"] not found`);
522
522
  });
523
523
  }
524
524
  function z(n) {
525
525
  return n instanceof We ? n.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : n.message;
526
526
  }
527
527
  class y {
528
- constructor(e, s, t) {
529
- this.getItems = e, this.getBep = s, this.config = t, this.idField = t.idField ?? "id";
528
+ constructor(e, t, s) {
529
+ this.getItems = e, this.getBep = t, this.config = s, this.idField = s.idField ?? "id";
530
530
  }
531
531
  getItems;
532
532
  getBep;
@@ -539,15 +539,15 @@ class y {
539
539
  return this.getItems();
540
540
  }
541
541
  get(e) {
542
- const s = [], t = [];
542
+ const t = [], s = [];
543
543
  for (const i of e) {
544
544
  const o = this.getItems().find((a) => this.getId(a) === i);
545
- o ? s.push(o) : t.push({ id: i, error: `Not found: ${i}` });
545
+ o ? t.push(o) : s.push({ id: i, error: `Not found: ${i}` });
546
546
  }
547
- return { succeeded: s, failed: t };
547
+ return { succeeded: t, failed: s };
548
548
  }
549
549
  add(e) {
550
- const s = [], t = [];
550
+ const t = [], s = [];
551
551
  for (const i of e) {
552
552
  const o = { ...i };
553
553
  this.config.autoId && !o[this.idField] && (o[this.idField] = globalThis.crypto.randomUUID());
@@ -560,53 +560,53 @@ class y {
560
560
  if (l.length) throw new Error(l.join("; "));
561
561
  const c = this.config.validate?.(d, this.getBep()) ?? [];
562
562
  if (c.length) throw new Error(c.join("; "));
563
- this.getItems().push(d), s.push(d);
563
+ this.getItems().push(d), t.push(d);
564
564
  } catch (d) {
565
- t.push({ id: a, error: z(d) });
565
+ s.push({ id: a, error: z(d) });
566
566
  }
567
567
  }
568
- return { succeeded: s, failed: t };
568
+ return { succeeded: t, failed: s };
569
569
  }
570
570
  update(e) {
571
- const s = [], t = [];
571
+ const t = [], s = [];
572
572
  for (const i of e) {
573
573
  const o = String(i[this.idField]), a = this.getItems(), d = a.findIndex((c) => this.getId(c) === o);
574
574
  if (d === -1) {
575
- t.push({ id: o, error: `Not found: ${o}` });
575
+ s.push({ id: o, error: `Not found: ${o}` });
576
576
  continue;
577
577
  }
578
578
  const l = ie(i, this.config.key, this.getBep());
579
579
  if (l.length) {
580
- t.push({ id: o, error: l.join("; ") });
580
+ s.push({ id: o, error: l.join("; ") });
581
581
  continue;
582
582
  }
583
583
  try {
584
584
  const c = this.config.schema.parse({ ...a[d], ...i }), f = this.config.validate?.(c, this.getBep()) ?? [];
585
585
  if (f.length) throw new Error(f.join("; "));
586
- a[d] = c, s.push(a[d]);
586
+ a[d] = c, t.push(a[d]);
587
587
  } catch (c) {
588
- t.push({ id: o, error: z(c) });
588
+ s.push({ id: o, error: z(c) });
589
589
  }
590
590
  }
591
- return { succeeded: s, failed: t };
591
+ return { succeeded: t, failed: s };
592
592
  }
593
593
  remove(e) {
594
- const s = [], t = [];
594
+ const t = [], s = [];
595
595
  for (const i of e) {
596
596
  const o = this.getItems(), a = o.findIndex((d) => this.getId(d) === i);
597
597
  if (a === -1) {
598
- t.push({ id: i, error: `Not found: ${i}` });
598
+ s.push({ id: i, error: `Not found: ${i}` });
599
599
  continue;
600
600
  }
601
601
  try {
602
602
  const d = $t(i, this.config.key, this.getBep());
603
603
  if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
604
- this.config.beforeRemove?.(i, this.getBep()), o.splice(a, 1), s.push(i);
604
+ this.config.beforeRemove?.(i, this.getBep()), o.splice(a, 1), t.push(i);
605
605
  } catch (d) {
606
- t.push({ id: i, error: z(d) });
606
+ s.push({ id: i, error: z(d) });
607
607
  }
608
608
  }
609
- return { succeeded: s, failed: t };
609
+ return { succeeded: t, failed: s };
610
610
  }
611
611
  }
612
612
  class Rt extends y {
@@ -618,10 +618,10 @@ class Rt extends y {
618
618
  key: "actions",
619
619
  schema: Ee,
620
620
  autoId: !0,
621
- beforeRemove: (s, t) => {
622
- for (const i of t.workflows)
621
+ beforeRemove: (t, s) => {
622
+ for (const i of s.workflows)
623
623
  for (const [o, a] of Object.entries(i.diagram.nodes))
624
- if (a.type === "process" && a.actionId === s)
624
+ if (a.type === "process" && a.actionId === t)
625
625
  throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].actionId`);
626
626
  }
627
627
  }
@@ -649,13 +649,13 @@ class At extends y {
649
649
  {
650
650
  key: "effects",
651
651
  schema: Se,
652
- beforeRemove: (s, t) => {
653
- for (const i of t.workflows) {
652
+ beforeRemove: (t, s) => {
653
+ for (const i of s.workflows) {
654
654
  for (const [o, a] of Object.entries(i.diagram.nodes))
655
- if ((a.type === "process" || a.type === "automation") && a.timeouts?.some((d) => d.effectId === s))
655
+ if ((a.type === "process" || a.type === "automation") && a.timeouts?.some((d) => d.effectId === t))
656
656
  throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].timeouts[].effectId`);
657
657
  for (const [o, a] of Object.entries(i.diagram.edges))
658
- if (a.effectIds?.includes(s))
658
+ if (a.effectIds?.includes(t))
659
659
  throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].effectIds`);
660
660
  }
661
661
  }
@@ -671,10 +671,10 @@ class jt extends y {
671
671
  {
672
672
  key: "automations",
673
673
  schema: Ne,
674
- beforeRemove: (s, t) => {
675
- for (const i of t.workflows)
674
+ beforeRemove: (t, s) => {
675
+ for (const i of s.workflows)
676
676
  for (const [o, a] of Object.entries(i.diagram.nodes))
677
- if (a.type === "automation" && a.automationId === s)
677
+ if (a.type === "automation" && a.automationId === t)
678
678
  throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].automationId`);
679
679
  }
680
680
  }
@@ -702,10 +702,10 @@ class Bt extends y {
702
702
  {
703
703
  key: "events",
704
704
  schema: ke,
705
- beforeRemove: (s, t) => {
706
- for (const i of t.workflows)
705
+ beforeRemove: (t, s) => {
706
+ for (const i of s.workflows)
707
707
  for (const [o, a] of Object.entries(i.diagram.edges))
708
- if ("triggerEventId" in a && a.triggerEventId === s)
708
+ if ("triggerEventId" in a && a.triggerEventId === t)
709
709
  throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].trigger`);
710
710
  }
711
711
  }
@@ -714,49 +714,49 @@ class Bt extends y {
714
714
  }
715
715
  function P(n) {
716
716
  const e = /* @__PURE__ */ new Map();
717
- for (const s of n)
718
- for (const t of s.lbsNodeIds ?? [])
719
- e.set(t, s.id);
717
+ for (const t of n)
718
+ for (const s of t.lbsNodeIds ?? [])
719
+ e.set(s, t.id);
720
720
  return e;
721
721
  }
722
722
  function Q(n) {
723
723
  const e = /* @__PURE__ */ new Set();
724
- for (const s of n)
725
- for (const t of s.lbsNodeIds ?? []) e.add(t);
726
- return new Set(n.map((s) => s.id).filter((s) => !e.has(s)));
724
+ for (const t of n)
725
+ for (const s of t.lbsNodeIds ?? []) e.add(s);
726
+ return new Set(n.map((t) => t.id).filter((t) => !e.has(t)));
727
727
  }
728
728
  function Ue(n, e) {
729
729
  if (!n) return { zoneCode: "XXX", locationCode: "XXX" };
730
- const s = new Map(e.map((d) => [d.id, d])), t = P(e), i = Q(e), o = s.get(n);
730
+ const t = new Map(e.map((d) => [d.id, d])), s = P(e), i = Q(e), o = t.get(n);
731
731
  if (!o) return { zoneCode: "XXX", locationCode: "XXX" };
732
732
  if (i.has(o.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
733
733
  if (o.type === "zone") return { zoneCode: o.id, locationCode: "ZZZ" };
734
- let a = t.get(o.id);
734
+ let a = s.get(o.id);
735
735
  for (; a; ) {
736
- const d = s.get(a);
736
+ const d = t.get(a);
737
737
  if (!d) break;
738
738
  if (d.type === "zone" && !i.has(d.id))
739
739
  return { zoneCode: d.id, locationCode: o.id };
740
- a = t.get(a);
740
+ a = s.get(a);
741
741
  }
742
742
  return { zoneCode: "ZZZ", locationCode: o.id };
743
743
  }
744
744
  function xt(n) {
745
- const e = [], s = new Map(n.map((d) => [d.id, d])), t = Q(n);
746
- for (const d of t) {
747
- const l = s.get(d);
745
+ const e = [], t = new Map(n.map((d) => [d.id, d])), s = Q(n);
746
+ for (const d of s) {
747
+ const l = t.get(d);
748
748
  l && l.type !== "zone" && e.push(`Root node "${d}" must be of type "zone".`);
749
749
  }
750
750
  for (const d of n)
751
751
  if (d.type === "location")
752
752
  for (const l of d.lbsNodeIds ?? [])
753
- s.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
753
+ t.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
754
754
  const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
755
755
  function a(d) {
756
756
  if (o.has(d)) return !0;
757
757
  if (i.has(d)) return !1;
758
758
  i.add(d), o.add(d);
759
- for (const l of s.get(d)?.lbsNodeIds ?? [])
759
+ for (const l of t.get(d)?.lbsNodeIds ?? [])
760
760
  if (a(l))
761
761
  return e.push(`Cycle detected in LBS tree at node "${d}".`), !0;
762
762
  return o.delete(d), !1;
@@ -766,24 +766,24 @@ function xt(n) {
766
766
  return e;
767
767
  }
768
768
  function K(n) {
769
- const e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
770
- for (const t of n) {
771
- const i = (s.get(t.responsibleId) ?? 0) + 1;
772
- s.set(t.responsibleId, i), e.set(t.id, i);
769
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
770
+ for (const s of n) {
771
+ const i = (t.get(s.responsibleId) ?? 0) + 1;
772
+ t.set(s.responsibleId, i), e.set(s.id, i);
773
773
  }
774
774
  return e;
775
775
  }
776
776
  const M = "XXX";
777
- function ze(n, e, s, t, i) {
778
- const { zoneCode: o, locationCode: a } = Ue(n.lbsNodeId, t);
777
+ function ze(n, e, t, s, i) {
778
+ const { zoneCode: o, locationCode: a } = Ue(n.lbsNodeId, s);
779
779
  if (!i) {
780
- const l = String(s.get(n.id) ?? 0).padStart(3, "0");
780
+ const l = String(t.get(n.id) ?? 0).padStart(3, "0");
781
781
  return [e, n.responsibleId, o, a, n.assetTypeId, n.disciplineId, l].join("-");
782
782
  }
783
783
  return i.segments.map((l) => {
784
784
  if (l.type === "sequence") {
785
785
  const c = l.padding ?? 3;
786
- return String(s.get(n.id) ?? 0).padStart(c, "0");
786
+ return String(t.get(n.id) ?? 0).padStart(c, "0");
787
787
  }
788
788
  switch (l.token) {
789
789
  case "project":
@@ -801,11 +801,11 @@ function ze(n, e, s, t, i) {
801
801
  }
802
802
  }).join(i.delimiter);
803
803
  }
804
- function Ze(n, e, s, t) {
804
+ function Ze(n, e, t, s) {
805
805
  const i = K(n);
806
806
  return new Map(n.map((o) => [
807
807
  o.id,
808
- ze(o, e, i, s, t)
808
+ ze(o, e, i, t, s)
809
809
  ]));
810
810
  }
811
811
  class Mt {
@@ -822,10 +822,10 @@ class Mt {
822
822
  * Returns null if the deliverable id is not found.
823
823
  */
824
824
  getCode(e) {
825
- const s = this.getBep(), t = s.deliverables.find((o) => o.id === e);
826
- if (!t) return null;
827
- const i = K(s.deliverables);
828
- return ze(t, s.project.code, i, s.lbs, s.deliverableNamingConvention);
825
+ const t = this.getBep(), s = t.deliverables.find((o) => o.id === e);
826
+ if (!s) return null;
827
+ const i = K(t.deliverables);
828
+ return ze(s, t.project.code, i, t.lbs, t.deliverableNamingConvention);
829
829
  }
830
830
  /** Builds the complete map of deliverable.id → nomenclature code. */
831
831
  buildCodeMap() {
@@ -834,7 +834,7 @@ class Mt {
834
834
  }
835
835
  }
836
836
  class Pt extends y {
837
- constructor(e, s, t, i, o) {
837
+ constructor(e, t, s, i, o) {
838
838
  super(
839
839
  () => e().deliverables,
840
840
  e,
@@ -843,25 +843,25 @@ class Pt extends y {
843
843
  schema: Pe,
844
844
  autoId: !0
845
845
  }
846
- ), this.getTeams = s, this.getAssetTypes = t, this.getLBSNodes = i, this.getMilestones = o;
846
+ ), this.getTeams = t, this.getAssetTypes = s, this.getLBSNodes = i, this.getMilestones = o;
847
847
  }
848
848
  getTeams;
849
849
  getAssetTypes;
850
850
  getLBSNodes;
851
851
  getMilestones;
852
852
  listResolved() {
853
- const e = this.getBep(), s = Ze(e.deliverables, e.project.code, e.lbs), t = new Map(this.getTeams().listResolved().map((l) => [l.id, l])), i = new Map(this.getAssetTypes().listResolved().map((l) => [l.id, l])), o = new Map(this.getLBSNodes().listResolved().map((l) => [l.id, l])), a = new Map(this.getMilestones().listResolved().map((l) => [l.id, l])), d = /* @__PURE__ */ new Map();
853
+ const e = this.getBep(), t = Ze(e.deliverables, e.project.code, e.lbs), s = new Map(this.getTeams().listResolved().map((l) => [l.id, l])), i = new Map(this.getAssetTypes().listResolved().map((l) => [l.id, l])), o = new Map(this.getLBSNodes().listResolved().map((l) => [l.id, l])), a = new Map(this.getMilestones().listResolved().map((l) => [l.id, l])), d = /* @__PURE__ */ new Map();
854
854
  for (const l of e.deliverables) {
855
855
  const c = a.get(l.milestoneId) ?? null;
856
856
  d.set(l.id, {
857
857
  ...l,
858
- nomenclatureCode: s.get(l.id) ?? "",
858
+ nomenclatureCode: t.get(l.id) ?? "",
859
859
  effectiveDate: l.dueDate ?? c?.date ?? "",
860
860
  lbsNode: l.lbsNodeId ? o.get(l.lbsNodeId) ?? null : null,
861
861
  discipline: e.disciplines.find((f) => f.id === l.disciplineId) ?? null,
862
862
  assetType: i.get(l.assetTypeId) ?? null,
863
863
  extensions: (l.extensionIds ?? []).map((f) => e.extensions.find((u) => u.id === f)).filter(Boolean),
864
- responsible: t.get(l.responsibleId) ?? null,
864
+ responsible: s.get(l.responsibleId) ?? null,
865
865
  milestone: c,
866
866
  predecessor: null
867
867
  });
@@ -888,7 +888,7 @@ class Ft extends y {
888
888
  }
889
889
  }
890
890
  class Lt extends y {
891
- constructor(e, s) {
891
+ constructor(e, t) {
892
892
  super(
893
893
  () => e().notes,
894
894
  e,
@@ -897,19 +897,19 @@ class Lt extends y {
897
897
  schema: xe,
898
898
  autoId: !0
899
899
  }
900
- ), this.getMembers = s;
900
+ ), this.getMembers = t;
901
901
  }
902
902
  getMembers;
903
903
  listResolved() {
904
- const e = new Map(this.getMembers().listResolved().map((s) => [s.email, s]));
905
- return this.getBep().notes.map((s) => ({
906
- ...s,
907
- member: e.get(s.memberEmail) ?? null
904
+ const e = new Map(this.getMembers().listResolved().map((t) => [t.email, t]));
905
+ return this.getBep().notes.map((t) => ({
906
+ ...t,
907
+ member: e.get(t.memberEmail) ?? null
908
908
  }));
909
909
  }
910
910
  }
911
911
  class Ct extends y {
912
- constructor(e, s) {
912
+ constructor(e, t) {
913
913
  super(
914
914
  () => e().bimUses,
915
915
  e,
@@ -917,30 +917,30 @@ class Ct extends y {
917
917
  key: "bimUses",
918
918
  schema: Ie,
919
919
  autoId: !0,
920
- validate: (t, i) => {
920
+ validate: (s, i) => {
921
921
  const o = [];
922
- for (const a of t.objectiveIds ?? [])
922
+ for (const a of s.objectiveIds ?? [])
923
923
  i.objectives.some((d) => d.id === a) || o.push(`objectives["${a}"] not found`);
924
- for (const a of t.milestoneIds ?? [])
924
+ for (const a of s.milestoneIds ?? [])
925
925
  i.milestones.some((d) => d.id === a) || o.push(`milestones["${a}"] not found`);
926
- for (const a of t.workflowIds ?? [])
926
+ for (const a of s.workflowIds ?? [])
927
927
  i.workflows.some((d) => d.id === a) || o.push(`workflows["${a}"] not found`);
928
928
  return o;
929
929
  }
930
930
  }
931
- ), this.getWorkflows = s;
931
+ ), this.getWorkflows = t;
932
932
  }
933
933
  getWorkflows;
934
934
  listResolved() {
935
- const e = this.getBep(), s = new Map(this.getWorkflows().listResolved().map((t) => [t.id, t]));
936
- return e.bimUses.map((t) => ({
937
- ...t,
938
- objectives: (t.objectiveIds ?? []).map((i) => e.objectives.find((o) => o.id === i)).filter(Boolean),
939
- milestones: (t.milestoneIds ?? []).map((i) => {
935
+ const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((s) => [s.id, s]));
936
+ return e.bimUses.map((s) => ({
937
+ ...s,
938
+ objectives: (s.objectiveIds ?? []).map((i) => e.objectives.find((o) => o.id === i)).filter(Boolean),
939
+ milestones: (s.milestoneIds ?? []).map((i) => {
940
940
  const o = e.milestones.find((a) => a.id === i);
941
941
  return o ? { ...o, phase: e.phases.find((a) => a.id === o.phaseId) ?? null } : null;
942
942
  }).filter(Boolean),
943
- workflows: (t.workflowIds ?? []).map((i) => s.get(i)).filter(Boolean)
943
+ workflows: (s.workflowIds ?? []).map((i) => t.get(i)).filter(Boolean)
944
944
  }));
945
945
  }
946
946
  }
@@ -952,8 +952,8 @@ class Dt extends y {
952
952
  {
953
953
  key: "disciplines",
954
954
  schema: ge,
955
- validate: (s, t) => {
956
- const i = B("discipline", s.id, t.deliverableNamingConvention);
955
+ validate: (t, s) => {
956
+ const i = O("discipline", t.id, s.deliverableNamingConvention);
957
957
  return i ? [i] : [];
958
958
  }
959
959
  }
@@ -974,9 +974,9 @@ class Ut extends y {
974
974
  }
975
975
  listResolved() {
976
976
  const e = this.getBep();
977
- return e.guides.map((s) => ({
978
- ...s,
979
- annexes: (s.annexIds ?? []).map((t) => e.annexes.find((i) => i.id === t)).filter(Boolean)
977
+ return e.guides.map((t) => ({
978
+ ...t,
979
+ annexes: (t.annexIds ?? []).map((s) => e.annexes.find((i) => i.id === s)).filter(Boolean)
980
980
  }));
981
981
  }
982
982
  }
@@ -988,9 +988,9 @@ class zt extends y {
988
988
  {
989
989
  key: "lods",
990
990
  schema: je,
991
- beforeRemove: (s, t) => {
992
- for (const i of t.loin)
993
- if (i.milestones?.find((a) => a.lodId === s)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${s}]`);
991
+ beforeRemove: (t, s) => {
992
+ for (const i of s.loin)
993
+ if (i.milestones?.find((a) => a.lodId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${t}]`);
994
994
  }
995
995
  }
996
996
  );
@@ -1004,9 +1004,9 @@ class Zt extends y {
1004
1004
  {
1005
1005
  key: "lois",
1006
1006
  schema: Oe,
1007
- beforeRemove: (s, t) => {
1008
- for (const i of t.loin)
1009
- if (i.milestones?.find((a) => a.loiId === s)) throw new Error(`Referenced by: loin["${i.id}"].milestones[loiId=${s}]`);
1007
+ beforeRemove: (t, s) => {
1008
+ for (const i of s.loin)
1009
+ if (i.milestones?.find((a) => a.loiId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[loiId=${t}]`);
1010
1010
  }
1011
1011
  }
1012
1012
  );
@@ -1021,48 +1021,48 @@ class Jt extends y {
1021
1021
  key: "loin",
1022
1022
  schema: Be,
1023
1023
  autoId: !0,
1024
- validate: (s, t) => {
1024
+ validate: (t, s) => {
1025
1025
  const i = [];
1026
- for (const o of s.milestones ?? [])
1027
- t.milestones.some((a) => a.id === o.milestoneId) || i.push(`milestones["${o.milestoneId}"] not found`), t.lods.some((a) => a.id === o.lodId) || i.push(`lods[${o.lodId}] not found`), t.lois.some((a) => a.id === o.loiId) || i.push(`lois[${o.loiId}] not found`);
1026
+ for (const o of t.milestones ?? [])
1027
+ s.milestones.some((a) => a.id === o.milestoneId) || i.push(`milestones["${o.milestoneId}"] not found`), s.lods.some((a) => a.id === o.lodId) || i.push(`lods[${o.lodId}] not found`), s.lois.some((a) => a.id === o.loiId) || i.push(`lois[${o.loiId}] not found`);
1028
1028
  return i;
1029
1029
  }
1030
1030
  }
1031
1031
  );
1032
1032
  }
1033
1033
  addMilestones(e) {
1034
- const s = [], t = [];
1034
+ const t = [], s = [];
1035
1035
  for (const i of e) {
1036
1036
  const o = this.getBep().loin.find((c) => c.id === i.loinId);
1037
1037
  if (!o) {
1038
- t.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1038
+ s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1039
1039
  continue;
1040
1040
  }
1041
1041
  const a = i.milestones.find((c) => (o.milestones ?? []).some((f) => f.milestoneId === c.milestoneId));
1042
1042
  if (a) {
1043
- t.push({ loinId: i.loinId, error: `Milestone "${a.milestoneId}" already exists. Use updateMilestones to modify it.` });
1043
+ s.push({ loinId: i.loinId, error: `Milestone "${a.milestoneId}" already exists. Use updateMilestones to modify it.` });
1044
1044
  continue;
1045
1045
  }
1046
1046
  const d = [...o.milestones ?? [], ...i.milestones], l = this.update([{ id: i.loinId, milestones: d }]);
1047
1047
  if (l.failed.length > 0) {
1048
- t.push({ loinId: i.loinId, error: l.failed[0].error });
1048
+ s.push({ loinId: i.loinId, error: l.failed[0].error });
1049
1049
  continue;
1050
1050
  }
1051
- s.push({ loinId: i.loinId, element: o.element, addedMilestones: i.milestones.map((c) => c.milestoneId) });
1051
+ t.push({ loinId: i.loinId, element: o.element, addedMilestones: i.milestones.map((c) => c.milestoneId) });
1052
1052
  }
1053
- return { succeeded: s, failed: t };
1053
+ return { succeeded: t, failed: s };
1054
1054
  }
1055
1055
  updateMilestones(e) {
1056
- const s = [], t = [];
1056
+ const t = [], s = [];
1057
1057
  for (const i of e) {
1058
1058
  const o = this.getBep().loin.find((u) => u.id === i.loinId);
1059
1059
  if (!o) {
1060
- t.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1060
+ s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1061
1061
  continue;
1062
1062
  }
1063
1063
  const a = i.milestones.find((u) => !(o.milestones ?? []).some((m) => m.milestoneId === u.milestoneId));
1064
1064
  if (a) {
1065
- t.push({ loinId: i.loinId, error: `Milestone "${a.milestoneId}" not found. Use addMilestones to create it.` });
1065
+ s.push({ loinId: i.loinId, error: `Milestone "${a.milestoneId}" not found. Use addMilestones to create it.` });
1066
1066
  continue;
1067
1067
  }
1068
1068
  const d = new Map(o.milestones.map((u) => [u.milestoneId, { lodId: u.lodId, loiId: u.loiId, idsPath: u.idsPath }])), l = (o.milestones ?? []).map((u) => {
@@ -1070,48 +1070,48 @@ class Jt extends y {
1070
1070
  return m ? { ...u, ...m } : u;
1071
1071
  }), c = this.update([{ id: i.loinId, milestones: l }]);
1072
1072
  if (c.failed.length > 0) {
1073
- t.push({ loinId: i.loinId, error: c.failed[0].error });
1073
+ s.push({ loinId: i.loinId, error: c.failed[0].error });
1074
1074
  continue;
1075
1075
  }
1076
1076
  const f = this.getBep().loin.find((u) => u.id === i.loinId);
1077
- s.push({
1077
+ t.push({
1078
1078
  loinId: i.loinId,
1079
1079
  element: o.element,
1080
1080
  milestones: i.milestones.map((u) => {
1081
- const m = f.milestones.find((g) => g.milestoneId === u.milestoneId), p = d.get(u.milestoneId);
1081
+ const m = f.milestones.find((w) => w.milestoneId === u.milestoneId), p = d.get(u.milestoneId);
1082
1082
  return { milestoneId: u.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
1083
1083
  })
1084
1084
  });
1085
1085
  }
1086
- return { succeeded: s, failed: t };
1086
+ return { succeeded: t, failed: s };
1087
1087
  }
1088
1088
  removeMilestones(e) {
1089
- const s = [], t = [];
1089
+ const t = [], s = [];
1090
1090
  for (const i of e) {
1091
1091
  const o = this.getBep().loin.find((d) => d.id === i.loinId);
1092
1092
  if (!o) {
1093
- t.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1093
+ s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1094
1094
  continue;
1095
1095
  }
1096
1096
  const a = i.milestoneIds.filter((d) => !(o.milestones ?? []).some((l) => l.milestoneId === d));
1097
1097
  if (a.length > 0) {
1098
- t.push({ loinId: i.loinId, error: `Milestones not found in this LOIN: ${a.join(", ")}` });
1098
+ s.push({ loinId: i.loinId, error: `Milestones not found in this LOIN: ${a.join(", ")}` });
1099
1099
  continue;
1100
1100
  }
1101
- o.milestones = (o.milestones ?? []).filter((d) => !i.milestoneIds.includes(d.milestoneId)), s.push({ loinId: i.loinId, element: o.element, removedMilestones: i.milestoneIds });
1101
+ o.milestones = (o.milestones ?? []).filter((d) => !i.milestoneIds.includes(d.milestoneId)), t.push({ loinId: i.loinId, element: o.element, removedMilestones: i.milestoneIds });
1102
1102
  }
1103
- return { succeeded: s, failed: t };
1103
+ return { succeeded: t, failed: s };
1104
1104
  }
1105
1105
  listResolved() {
1106
1106
  const e = this.getBep();
1107
- return e.loin.map((s) => ({
1108
- ...s,
1109
- discipline: e.disciplines.find((t) => t.id === s.disciplineId) ?? null,
1110
- milestones: (s.milestones ?? []).map((t) => ({
1111
- ...t,
1112
- milestone: e.milestones.find((i) => i.id === t.milestoneId) ?? null,
1113
- lod: e.lods.find((i) => i.id === t.lodId) ?? null,
1114
- loi: e.lois.find((i) => i.id === t.loiId) ?? null
1107
+ return e.loin.map((t) => ({
1108
+ ...t,
1109
+ discipline: e.disciplines.find((s) => s.id === t.disciplineId) ?? null,
1110
+ milestones: (t.milestones ?? []).map((s) => ({
1111
+ ...s,
1112
+ milestone: e.milestones.find((i) => i.id === s.milestoneId) ?? null,
1113
+ lod: e.lods.find((i) => i.id === s.lodId) ?? null,
1114
+ loi: e.lois.find((i) => i.id === s.loiId) ?? null
1115
1115
  }))
1116
1116
  }));
1117
1117
  }
@@ -1124,8 +1124,8 @@ class Kt extends y {
1124
1124
  {
1125
1125
  key: "assetTypes",
1126
1126
  schema: ye,
1127
- validate: (s, t) => {
1128
- const i = B("assetType", s.id, t.deliverableNamingConvention);
1127
+ validate: (t, s) => {
1128
+ const i = O("assetType", t.id, s.deliverableNamingConvention);
1129
1129
  return i ? [i] : [];
1130
1130
  }
1131
1131
  }
@@ -1133,9 +1133,9 @@ class Kt extends y {
1133
1133
  }
1134
1134
  listResolved() {
1135
1135
  const e = this.getBep();
1136
- return e.assetTypes.map((s) => ({
1137
- ...s,
1138
- extensions: (s.extensionIds ?? []).map((t) => e.extensions.find((i) => i.id === t)).filter(Boolean)
1136
+ return e.assetTypes.map((t) => ({
1137
+ ...t,
1138
+ extensions: (t.extensionIds ?? []).map((s) => e.extensions.find((i) => i.id === s)).filter(Boolean)
1139
1139
  }));
1140
1140
  }
1141
1141
  }
@@ -1160,13 +1160,13 @@ class Wt extends y {
1160
1160
  key: "roles",
1161
1161
  schema: le,
1162
1162
  autoId: !0,
1163
- beforeRemove: (s, t) => {
1163
+ beforeRemove: (t, s) => {
1164
1164
  const i = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
1165
- for (const o of t.workflows)
1165
+ for (const o of s.workflows)
1166
1166
  for (const [a, d] of Object.entries(o.diagram.nodes))
1167
1167
  if (d.type === "process") {
1168
1168
  for (const l of i)
1169
- if (d[l]?.includes(s))
1169
+ if (d[l]?.includes(t))
1170
1170
  throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${a}"].${l}`);
1171
1171
  }
1172
1172
  }
@@ -1182,12 +1182,12 @@ class Gt extends y {
1182
1182
  {
1183
1183
  key: "lbs",
1184
1184
  schema: he,
1185
- validate: (s, t) => {
1186
- const i = [], o = s.type === "zone" ? "lbsZone" : "lbsLocation", a = B(o, s.id, t.deliverableNamingConvention);
1187
- if (a && i.push(a), s.type === "location" && s.lbsNodeIds?.length) {
1188
- const d = new Map(t.lbs.map((l) => [l.id, l]));
1189
- for (const l of s.lbsNodeIds ?? [])
1190
- d.get(l)?.type === "zone" && i.push(`Node "${s.id}" (location) cannot have a zone child ("${l}").`);
1185
+ validate: (t, s) => {
1186
+ const i = [], o = t.type === "zone" ? "lbsZone" : "lbsLocation", a = O(o, t.id, s.deliverableNamingConvention);
1187
+ if (a && i.push(a), t.type === "location" && t.lbsNodeIds?.length) {
1188
+ const d = new Map(s.lbs.map((l) => [l.id, l]));
1189
+ for (const l of t.lbsNodeIds ?? [])
1190
+ d.get(l)?.type === "zone" && i.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
1191
1191
  }
1192
1192
  return i;
1193
1193
  }
@@ -1195,25 +1195,25 @@ class Gt extends y {
1195
1195
  );
1196
1196
  }
1197
1197
  listResolved() {
1198
- const e = this.getBep(), s = P(e.lbs), t = Q(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1198
+ const e = this.getBep(), t = P(e.lbs), s = Q(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1199
1199
  return e.lbs.map((o) => {
1200
- const a = s.get(o.id), d = a ? i.get(a) : void 0;
1200
+ const a = t.get(o.id), d = a ? i.get(a) : void 0;
1201
1201
  return {
1202
1202
  ...o,
1203
- isRoot: t.has(o.id),
1203
+ isRoot: s.has(o.id),
1204
1204
  parent: d ? { id: d.id, name: d.name, type: d.type } : null,
1205
1205
  children: (o.lbsNodeIds ?? []).map((l) => i.get(l)).filter(Boolean)
1206
1206
  };
1207
1207
  });
1208
1208
  }
1209
1209
  addNodes(e) {
1210
- const s = this.getBep(), t = [], i = [];
1210
+ const t = this.getBep(), s = [], i = [];
1211
1211
  for (const o of e) {
1212
1212
  if (!o.parentId && o.type !== "zone") {
1213
1213
  i.push({ input: o, error: 'Root nodes (no parentId) must be type "zone".' });
1214
1214
  continue;
1215
1215
  }
1216
- if (o.parentId && !s.lbs.find((u) => u.id === o.parentId)) {
1216
+ if (o.parentId && !t.lbs.find((u) => u.id === o.parentId)) {
1217
1217
  i.push({ input: o, error: `No LBS node found with ID "${o.parentId}".` });
1218
1218
  continue;
1219
1219
  }
@@ -1223,20 +1223,20 @@ class Gt extends y {
1223
1223
  continue;
1224
1224
  }
1225
1225
  let c;
1226
- a && (c = s.lbs.find((u) => u.id === a), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
1226
+ a && (c = t.lbs.find((u) => u.id === a), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
1227
1227
  const f = this.validateTree();
1228
1228
  if (f.length > 0) {
1229
- s.lbs.splice(s.lbs.findIndex((u) => u.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((u) => u !== o.id)), i.push({ input: o, error: f.join("; ") });
1229
+ t.lbs.splice(t.lbs.findIndex((u) => u.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((u) => u !== o.id)), i.push({ input: o, error: f.join("; ") });
1230
1230
  continue;
1231
1231
  }
1232
- t.push({ ...s.lbs.find((u) => u.id === o.id), parentId: a ?? null });
1232
+ s.push({ ...t.lbs.find((u) => u.id === o.id), parentId: a ?? null });
1233
1233
  }
1234
- return { succeeded: t, failed: i };
1234
+ return { succeeded: s, failed: i };
1235
1235
  }
1236
1236
  updateNodes(e) {
1237
- const s = this.getBep(), t = [], i = [];
1237
+ const t = this.getBep(), s = [], i = [];
1238
1238
  for (const o of e) {
1239
- if (o.parentId && !s.lbs.find((h) => h.id === o.parentId)) {
1239
+ if (o.parentId && !t.lbs.find((h) => h.id === o.parentId)) {
1240
1240
  i.push({ id: o.id, error: `No LBS node found with ID "${o.parentId}".` });
1241
1241
  continue;
1242
1242
  }
@@ -1244,37 +1244,37 @@ class Gt extends y {
1244
1244
  i.push({ id: o.id, error: "A node cannot be its own parent." });
1245
1245
  continue;
1246
1246
  }
1247
- const a = s.lbs.find((h) => h.id === o.id), d = P(s.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, f = this.update([c]);
1247
+ const a = t.lbs.find((h) => h.id === o.id), d = P(t.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, f = this.update([c]);
1248
1248
  if (f.failed.length > 0) {
1249
1249
  i.push({ id: o.id, error: f.failed[0].error });
1250
1250
  continue;
1251
1251
  }
1252
- const u = { name: a.name, type: a.type, description: a.description, parentId: d }, m = s.lbs.find((h) => h.id === o.id);
1252
+ const u = { name: a.name, type: a.type, description: a.description, parentId: d }, m = t.lbs.find((h) => h.id === o.id);
1253
1253
  if (l !== void 0) {
1254
- for (const h of s.lbs)
1255
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((k) => k !== o.id));
1254
+ for (const h of t.lbs)
1255
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((v) => v !== o.id));
1256
1256
  if (l) {
1257
- const h = s.lbs.find((k) => k.id === l);
1257
+ const h = t.lbs.find((v) => v.id === l);
1258
1258
  h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id);
1259
1259
  }
1260
1260
  }
1261
1261
  const p = this.validateTree();
1262
1262
  if (p.length > 0) {
1263
1263
  if (m.name = u.name, m.type = u.type, u.description !== void 0 ? m.description = u.description : delete m.description, l !== void 0) {
1264
- for (const h of s.lbs)
1265
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((k) => k !== o.id));
1264
+ for (const h of t.lbs)
1265
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((v) => v !== o.id));
1266
1266
  if (u.parentId) {
1267
- const h = s.lbs.find((k) => k.id === u.parentId);
1267
+ const h = t.lbs.find((v) => v.id === u.parentId);
1268
1268
  h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
1269
1269
  }
1270
1270
  }
1271
1271
  i.push({ id: o.id, error: p.join("; ") });
1272
1272
  continue;
1273
1273
  }
1274
- const g = P(s.lbs).get(m.id) ?? null;
1275
- t.push({ id: o.id, before: u, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1274
+ const w = P(t.lbs).get(m.id) ?? null;
1275
+ s.push({ id: o.id, before: u, after: { name: m.name, type: m.type, description: m.description, parentId: w } });
1276
1276
  }
1277
- return { succeeded: t, failed: i };
1277
+ return { succeeded: s, failed: i };
1278
1278
  }
1279
1279
  /** Resolves zone and location codes for nomenclature given a node id. */
1280
1280
  resolveCodes(e) {
@@ -1299,46 +1299,46 @@ class Xt extends y {
1299
1299
  }
1300
1300
  listResolved() {
1301
1301
  const e = this.getBep();
1302
- return e.members.map((s) => {
1303
- const t = e.teams.find((i) => (i.memberEmails ?? []).includes(s.email));
1302
+ return e.members.map((t) => {
1303
+ const s = e.teams.find((i) => (i.memberEmails ?? []).includes(t.email));
1304
1304
  return {
1305
- ...s,
1306
- role: e.roles.find((i) => i.id === s.roleId) ?? null,
1307
- team: t ? { id: t.id, name: t.name } : null,
1308
- isRepresentative: t?.representativeEmail === s.email
1305
+ ...t,
1306
+ role: e.roles.find((i) => i.id === t.roleId) ?? null,
1307
+ team: s ? { id: s.id, name: s.name } : null,
1308
+ isRepresentative: s?.representativeEmail === t.email
1309
1309
  };
1310
1310
  });
1311
1311
  }
1312
1312
  addToTeam(e) {
1313
- const s = [], t = [];
1313
+ const t = [], s = [];
1314
1314
  for (const i of e) {
1315
1315
  const a = this.getBep().teams.find((m) => m.id === i.teamId);
1316
1316
  if (!a) {
1317
- t.push({ input: i, error: `Team not found: ${i.teamId}` });
1317
+ s.push({ input: i, error: `Team not found: ${i.teamId}` });
1318
1318
  continue;
1319
1319
  }
1320
1320
  const { teamId: d, isRepresentative: l, ...c } = i, f = this.add([c]);
1321
1321
  if (f.failed.length > 0) {
1322
- t.push({ input: i, error: f.failed[0].error });
1322
+ s.push({ input: i, error: f.failed[0].error });
1323
1323
  continue;
1324
1324
  }
1325
1325
  a.memberEmails ??= [], a.memberEmails.includes(i.email) || a.memberEmails.push(i.email), l && (a.representativeEmail = i.email);
1326
1326
  const u = this.listResolved().find((m) => m.email === i.email);
1327
- s.push(u);
1327
+ t.push(u);
1328
1328
  }
1329
- return { succeeded: s, failed: t };
1329
+ return { succeeded: t, failed: s };
1330
1330
  }
1331
1331
  updateInTeam(e) {
1332
- const s = [], t = [];
1332
+ const t = [], s = [];
1333
1333
  for (const i of e) {
1334
1334
  const o = this.getBep(), { teamId: a, isRepresentative: d, ...l } = i;
1335
1335
  if (a !== void 0 && !o.teams.find((u) => u.id === a)) {
1336
- t.push({ email: i.email, error: `Team not found: ${a}` });
1336
+ s.push({ email: i.email, error: `Team not found: ${a}` });
1337
1337
  continue;
1338
1338
  }
1339
1339
  const c = this.update([l]);
1340
1340
  if (c.failed.length > 0) {
1341
- t.push({ email: i.email, error: c.failed[0].error });
1341
+ s.push({ email: i.email, error: c.failed[0].error });
1342
1342
  continue;
1343
1343
  }
1344
1344
  if (a !== void 0) {
@@ -1350,16 +1350,16 @@ class Xt extends y {
1350
1350
  u && (u.representativeEmail = d ? i.email : u.representativeEmail === i.email ? void 0 : u.representativeEmail);
1351
1351
  }
1352
1352
  const f = this.listResolved().find((u) => u.email === i.email);
1353
- s.push({ email: i.email, after: f });
1353
+ t.push({ email: i.email, after: f });
1354
1354
  }
1355
- return { succeeded: s, failed: t };
1355
+ return { succeeded: t, failed: s };
1356
1356
  }
1357
1357
  removeFromBep(e) {
1358
- const s = [], t = [];
1358
+ const t = [], s = [];
1359
1359
  for (const i of e) {
1360
1360
  const o = this.getBep(), a = this.listResolved().find((l) => l.email === i);
1361
1361
  if (!a) {
1362
- t.push({ email: i, error: `Not found: ${i}` });
1362
+ s.push({ email: i, error: `Not found: ${i}` });
1363
1363
  continue;
1364
1364
  }
1365
1365
  for (const l of o.teams)
@@ -1370,12 +1370,12 @@ class Xt extends y {
1370
1370
  const l = o.teams.find((c) => c.id === a.team.id);
1371
1371
  l && (l.memberEmails ??= [], l.memberEmails.includes(i) || l.memberEmails.push(i), a.isRepresentative && (l.representativeEmail = i));
1372
1372
  }
1373
- t.push({ email: i, error: d.failed[0].error });
1373
+ s.push({ email: i, error: d.failed[0].error });
1374
1374
  continue;
1375
1375
  }
1376
- s.push(a);
1376
+ t.push(a);
1377
1377
  }
1378
- return { succeeded: s, failed: t };
1378
+ return { succeeded: t, failed: s };
1379
1379
  }
1380
1380
  }
1381
1381
  class Vt extends y {
@@ -1387,18 +1387,18 @@ class Vt extends y {
1387
1387
  key: "milestones",
1388
1388
  schema: pe,
1389
1389
  autoId: !0,
1390
- beforeRemove: (s, t) => {
1391
- for (const i of t.loin)
1392
- if (i.milestones?.find((a) => a.milestoneId === s)) throw new Error(`Referenced by: loin["${i.id}"].milestones[milestoneId="${s}"]`);
1390
+ beforeRemove: (t, s) => {
1391
+ for (const i of s.loin)
1392
+ if (i.milestones?.find((a) => a.milestoneId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[milestoneId="${t}"]`);
1393
1393
  }
1394
1394
  }
1395
1395
  );
1396
1396
  }
1397
1397
  listResolved() {
1398
1398
  const e = this.getBep();
1399
- return e.milestones.map((s) => ({
1400
- ...s,
1401
- phase: e.phases.find((t) => t.id === s.phaseId) ?? null
1399
+ return e.milestones.map((t) => ({
1400
+ ...t,
1401
+ phase: e.phases.find((s) => s.id === t.phaseId) ?? null
1402
1402
  }));
1403
1403
  }
1404
1404
  }
@@ -1449,8 +1449,8 @@ class es extends y {
1449
1449
  {
1450
1450
  key: "resolvers",
1451
1451
  schema: Le,
1452
- beforeRemove: (s, t) => {
1453
- const i = t.remoteData.find((o) => o.resolverId === s);
1452
+ beforeRemove: (t, s) => {
1453
+ const i = s.remoteData.find((o) => o.resolverId === t);
1454
1454
  if (i) throw new Error(`Referenced by: remoteData["${i.id}"].resolverId`);
1455
1455
  }
1456
1456
  }
@@ -1458,7 +1458,7 @@ class es extends y {
1458
1458
  }
1459
1459
  }
1460
1460
  class ts extends y {
1461
- constructor(e, s) {
1461
+ constructor(e, t) {
1462
1462
  super(
1463
1463
  () => e().softwares,
1464
1464
  e,
@@ -1466,24 +1466,24 @@ class ts extends y {
1466
1466
  key: "softwares",
1467
1467
  schema: ve
1468
1468
  }
1469
- ), this.getAssetTypes = s;
1469
+ ), this.getAssetTypes = t;
1470
1470
  }
1471
1471
  getAssetTypes;
1472
1472
  listResolved() {
1473
- const e = new Map(this.getAssetTypes().listResolved().map((s) => [s.id, s]));
1474
- return this.getBep().softwares.map((s) => ({
1475
- ...s,
1476
- assetTypes: (s.assetTypeIds ?? []).map((t) => e.get(t)).filter(Boolean)
1473
+ const e = new Map(this.getAssetTypes().listResolved().map((t) => [t.id, t]));
1474
+ return this.getBep().softwares.map((t) => ({
1475
+ ...t,
1476
+ assetTypes: (t.assetTypeIds ?? []).map((s) => e.get(s)).filter(Boolean)
1477
1477
  }));
1478
1478
  }
1479
1479
  }
1480
1480
  class ss extends y {
1481
- constructor(e, s) {
1481
+ constructor(e, t) {
1482
1482
  super(
1483
1483
  () => e().standards,
1484
1484
  e,
1485
1485
  { key: "standards", schema: Ae, autoId: !0 }
1486
- ), this.getZip = s;
1486
+ ), this.getZip = t;
1487
1487
  }
1488
1488
  getZip;
1489
1489
  /**
@@ -1493,95 +1493,95 @@ class ss extends y {
1493
1493
  * Union with AddInput<Standard> satisfies the base class contract.
1494
1494
  */
1495
1495
  add(e) {
1496
- const s = e.map((t) => {
1496
+ const t = e.map((s) => {
1497
1497
  const i = `standards/${globalThis.crypto.randomUUID()}.md`;
1498
- if ("content" in t) {
1499
- const { content: o, ...a } = t;
1498
+ if ("content" in s) {
1499
+ const { content: o, ...a } = s;
1500
1500
  return this.getZip().file(i, o), { ...a, contentPath: i };
1501
1501
  }
1502
- return this.getZip().file(i, ""), { ...t, contentPath: i };
1502
+ return this.getZip().file(i, ""), { ...s, contentPath: i };
1503
1503
  });
1504
- return super.add(s);
1504
+ return super.add(t);
1505
1505
  }
1506
1506
  /** Removes standards and deletes their .md files from the zip. */
1507
1507
  remove(e) {
1508
- const s = new Map(
1508
+ const t = new Map(
1509
1509
  e.map((i) => [i, this.list().find((o) => o.id === i)?.contentPath]).filter((i) => i[1] !== void 0)
1510
- ), t = super.remove(e);
1511
- for (const i of t.succeeded) {
1512
- const o = s.get(i);
1510
+ ), s = super.remove(e);
1511
+ for (const i of s.succeeded) {
1512
+ const o = t.get(i);
1513
1513
  o && this.getZip().remove(o);
1514
1514
  }
1515
- return t;
1515
+ return s;
1516
1516
  }
1517
1517
  /** Returns the markdown text content of the given standard. */
1518
1518
  async getContent(e) {
1519
- const s = this.list().find((i) => i.id === e);
1520
- if (!s) throw new Error(`Standard not found: ${e}`);
1521
- const t = this.getZip().file(s.contentPath);
1522
- if (!t) throw new Error(`Content file not found: ${s.contentPath}`);
1523
- return t.async("string");
1524
- }
1525
- /** Writes new markdown text content for the given standard. */
1526
- setContent(e, s) {
1527
1519
  const t = this.list().find((i) => i.id === e);
1528
1520
  if (!t) throw new Error(`Standard not found: ${e}`);
1529
- this.getZip().file(t.contentPath, s);
1521
+ const s = this.getZip().file(t.contentPath);
1522
+ if (!s) throw new Error(`Content file not found: ${t.contentPath}`);
1523
+ return s.async("string");
1524
+ }
1525
+ /** Writes new markdown text content for the given standard. */
1526
+ setContent(e, t) {
1527
+ const s = this.list().find((i) => i.id === e);
1528
+ if (!s) throw new Error(`Standard not found: ${e}`);
1529
+ this.getZip().file(s.contentPath, t);
1530
1530
  }
1531
1531
  }
1532
1532
  class ns extends y {
1533
- constructor(e, s) {
1533
+ constructor(e, t) {
1534
1534
  super(
1535
1535
  () => e().teams,
1536
1536
  e,
1537
1537
  {
1538
1538
  key: "teams",
1539
1539
  schema: fe,
1540
- validate: (t, i) => {
1541
- const o = [], a = B("team", t.id, i.deliverableNamingConvention);
1542
- return a && o.push(a), t.representativeEmail && !(t.memberEmails ?? []).includes(t.representativeEmail) && o.push(`representativeEmail "${t.representativeEmail}" is not a member of this team`), o;
1540
+ validate: (s, i) => {
1541
+ const o = [], a = O("team", s.id, i.deliverableNamingConvention);
1542
+ return a && o.push(a), s.representativeEmail && !(s.memberEmails ?? []).includes(s.representativeEmail) && o.push(`representativeEmail "${s.representativeEmail}" is not a member of this team`), o;
1543
1543
  },
1544
- beforeRemove: (t, i) => {
1545
- if (i.project.clientId === t)
1544
+ beforeRemove: (s, i) => {
1545
+ if (i.project.clientId === s)
1546
1546
  throw new Error("Referenced by: project.clientId");
1547
1547
  }
1548
1548
  }
1549
- ), this.getMembers = s;
1549
+ ), this.getMembers = t;
1550
1550
  }
1551
1551
  getMembers;
1552
1552
  listResolved() {
1553
- const e = this.getBep(), s = new Map(this.getMembers().listResolved().map((t) => [t.email, t]));
1554
- return e.teams.map((t) => ({
1555
- ...t,
1556
- representative: s.get(t.representativeEmail ?? "") ?? null,
1557
- members: (t.memberEmails ?? []).map((i) => s.get(i)).filter(Boolean),
1558
- disciplines: (t.disciplineIds ?? []).map((i) => e.disciplines.find((o) => o.id === i)).filter(Boolean)
1553
+ const e = this.getBep(), t = new Map(this.getMembers().listResolved().map((s) => [s.email, s]));
1554
+ return e.teams.map((s) => ({
1555
+ ...s,
1556
+ representative: t.get(s.representativeEmail ?? "") ?? null,
1557
+ members: (s.memberEmails ?? []).map((i) => t.get(i)).filter(Boolean),
1558
+ disciplines: (s.disciplineIds ?? []).map((i) => e.disciplines.find((o) => o.id === i)).filter(Boolean)
1559
1559
  }));
1560
1560
  }
1561
1561
  }
1562
- function is(n, e, s) {
1563
- const t = [];
1562
+ function is(n, e, t) {
1563
+ const s = [];
1564
1564
  for (const [l, c] of Object.entries(n.nodes))
1565
1565
  if (c.type === "process") {
1566
- c.actionId && !e.actions.some((f) => f.id === c.actionId) && t.push(`actions["${c.actionId}"] not found (node: ${l})`);
1566
+ c.actionId && !e.actions.some((f) => f.id === c.actionId) && s.push(`actions["${c.actionId}"] not found (node: ${l})`);
1567
1567
  for (const f of ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"])
1568
1568
  for (const u of c[f] ?? [])
1569
- e.roles.some((m) => m.id === u) || t.push(`roles["${u}"] not found (node: ${l}.${f})`);
1569
+ e.roles.some((m) => m.id === u) || s.push(`roles["${u}"] not found (node: ${l}.${f})`);
1570
1570
  }
1571
1571
  for (const [l, c] of Object.entries(n.edges)) {
1572
- n.nodes[c.from] || t.push(`edge "${l}": from node "${c.from}" not found`), n.nodes[c.to] || t.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((f) => f.id === c.triggerEventId) && t.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1572
+ n.nodes[c.from] || s.push(`edge "${l}": from node "${c.from}" not found`), n.nodes[c.to] || s.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((f) => f.id === c.triggerEventId) && s.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1573
1573
  for (const f of c.effectIds ?? [])
1574
- e.effects.some((u) => u.id === f) || t.push(`effects["${f}"] not found (edge: ${l})`);
1574
+ e.effects.some((u) => u.id === f) || s.push(`effects["${f}"] not found (edge: ${l})`);
1575
1575
  }
1576
1576
  for (const [l, c] of Object.entries(n.nodes))
1577
- if (c.type === "automation" && !e.automations.some((f) => f.id === c.automationId) && t.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === s ? t.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((f) => f.id === c.workflowId) || t.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1577
+ if (c.type === "automation" && !e.automations.some((f) => f.id === c.automationId) && s.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === t ? s.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((f) => f.id === c.workflowId) || s.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1578
1578
  for (const f of c.timeouts)
1579
- e.effects.some((u) => u.id === f.effectId) || t.push(`effects["${f.effectId}"] not found (node: ${l}.timeouts)`);
1579
+ e.effects.some((u) => u.id === f.effectId) || s.push(`effects["${f.effectId}"] not found (node: ${l}.timeouts)`);
1580
1580
  const i = Object.keys(n.nodes), o = new Set(Object.values(n.edges).map((l) => l.to)), a = new Set(Object.values(n.edges).map((l) => l.from));
1581
1581
  for (const l of i)
1582
- n.nodes[l].type !== "start" && (o.has(l) || t.push(`node "${l}" is unreachable — no edges point to it`));
1582
+ n.nodes[l].type !== "start" && (o.has(l) || s.push(`node "${l}" is unreachable — no edges point to it`));
1583
1583
  for (const l of i)
1584
- n.nodes[l].type !== "end" && (a.has(l) || t.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
1584
+ n.nodes[l].type !== "end" && (a.has(l) || s.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
1585
1585
  const d = {};
1586
1586
  for (const l of Object.keys(n.edges)) {
1587
1587
  const c = n.edges[l];
@@ -1594,23 +1594,23 @@ function is(n, e, s) {
1594
1594
  const m = n.edges[u], p = n.nodes[m.from];
1595
1595
  if (p) {
1596
1596
  if (p.type === "automation") {
1597
- const g = e.automations.find((h) => h.id === p.automationId);
1598
- for (const h of g?.output ?? []) f.add(h.key);
1597
+ const w = e.automations.find((h) => h.id === p.automationId);
1598
+ for (const h of w?.output ?? []) f.add(h.key);
1599
1599
  }
1600
1600
  if (p.type === "process" && "triggerEventId" in m) {
1601
- const g = e.events.find((h) => h.id === m.triggerEventId);
1602
- for (const h of g?.payload ?? []) f.add(h.key);
1601
+ const w = e.events.find((h) => h.id === m.triggerEventId);
1602
+ for (const h of w?.payload ?? []) f.add(h.key);
1603
1603
  }
1604
1604
  }
1605
1605
  }
1606
1606
  if (f.size !== 0)
1607
1607
  for (const [u, m] of Object.entries(n.edges))
1608
- m.from === l && "guard" in m && (f.has(m.guard.field) || t.push(`guard field "${m.guard.field}" on edge "${u}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1608
+ m.from === l && "guard" in m && (f.has(m.guard.field) || s.push(`guard field "${m.guard.field}" on edge "${u}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1609
1609
  }
1610
- return t;
1610
+ return s;
1611
1611
  }
1612
1612
  class os extends y {
1613
- constructor(e, s, t) {
1613
+ constructor(e, t, s) {
1614
1614
  super(
1615
1615
  () => e().workflows,
1616
1616
  e,
@@ -1620,23 +1620,23 @@ class os extends y {
1620
1620
  autoId: !0,
1621
1621
  validate: (i, o) => is(i.diagram, o, i.id)
1622
1622
  }
1623
- ), this.getMembers = s, this.getTeams = t;
1623
+ ), this.getMembers = t, this.getTeams = s;
1624
1624
  }
1625
1625
  getMembers;
1626
1626
  getTeams;
1627
1627
  getRaciMatrix() {
1628
- const e = this.getBep(), s = [], t = /* @__PURE__ */ new Set(), i = this.getMembers().listResolved(), o = this.getTeams().listResolved(), a = (l) => (l ?? []).flatMap((c) => {
1628
+ const e = this.getBep(), t = [], s = /* @__PURE__ */ new Set(), i = this.getMembers().listResolved(), o = this.getTeams().listResolved(), a = (l) => (l ?? []).flatMap((c) => {
1629
1629
  const f = e.roles.find((p) => p.id === c);
1630
1630
  if (!f) return [];
1631
- t.add(c);
1632
- const u = i.filter((p) => p.role?.id === c), m = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1631
+ s.add(c);
1632
+ const u = i.filter((p) => p.role?.id === c), m = o.find((p) => p.members.some((w) => w.role?.id === c)) ?? null;
1633
1633
  return [{ role: f, members: u, team: m }];
1634
1634
  });
1635
1635
  for (const l of e.workflows)
1636
1636
  for (const [c, f] of Object.entries(l.diagram.nodes)) {
1637
1637
  if (f.type !== "process") continue;
1638
1638
  const u = f.actionId ? e.actions.find((m) => m.id === f.actionId) : void 0;
1639
- s.push({
1639
+ t.push({
1640
1640
  workflow: { id: l.id, name: l.name },
1641
1641
  nodeId: c,
1642
1642
  label: u?.name ?? c,
@@ -1648,16 +1648,16 @@ class os extends y {
1648
1648
  informed: a(f.informedRoleIds)
1649
1649
  });
1650
1650
  }
1651
- return { roles: [...t].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: s };
1651
+ return { roles: [...s].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
1652
1652
  }
1653
1653
  getRaciMatrixForWorkflow(e) {
1654
- const s = this.getRaciMatrix(), t = s.rows.filter((o) => o.workflow.id === e), i = new Set(
1655
- t.flatMap((o) => [...o.responsible, ...o.accountable, ...o.consulted, ...o.informed].map((a) => a.role.id))
1654
+ const t = this.getRaciMatrix(), s = t.rows.filter((o) => o.workflow.id === e), i = new Set(
1655
+ s.flatMap((o) => [...o.responsible, ...o.accountable, ...o.consulted, ...o.informed].map((a) => a.role.id))
1656
1656
  );
1657
- return { roles: s.roles.filter((o) => i.has(o.id)), rows: t };
1657
+ return { roles: t.roles.filter((o) => i.has(o.id)), rows: s };
1658
1658
  }
1659
1659
  getConsolidatedRaciMatrix() {
1660
- const e = this.getRaciMatrix(), s = /* @__PURE__ */ new Map(), t = (a, d) => {
1660
+ const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), s = (a, d) => {
1661
1661
  const l = new Map(a.map((c) => [c.role.id, { ...c, members: [...c.members] }]));
1662
1662
  for (const c of d)
1663
1663
  if (!l.has(c.role.id))
@@ -1670,29 +1670,29 @@ class os extends y {
1670
1670
  };
1671
1671
  for (const a of e.rows) {
1672
1672
  const d = a.actionId ?? `node:${a.workflow.id}:${a.nodeId}`;
1673
- if (!s.has(d))
1674
- s.set(d, { ...a, workflow: { id: "", name: "" } });
1673
+ if (!t.has(d))
1674
+ t.set(d, { ...a, workflow: { id: "", name: "" } });
1675
1675
  else {
1676
- const l = s.get(d);
1677
- l.responsible = t(l.responsible, a.responsible), l.accountable = t(l.accountable, a.accountable), l.consulted = t(l.consulted, a.consulted), l.informed = t(l.informed, a.informed);
1676
+ const l = t.get(d);
1677
+ l.responsible = s(l.responsible, a.responsible), l.accountable = s(l.accountable, a.accountable), l.consulted = s(l.consulted, a.consulted), l.informed = s(l.informed, a.informed);
1678
1678
  }
1679
1679
  }
1680
- const i = [...s.values()], o = new Set(
1680
+ const i = [...t.values()], o = new Set(
1681
1681
  i.flatMap((a) => [...a.responsible, ...a.accountable, ...a.consulted, ...a.informed].map((d) => d.role.id))
1682
1682
  );
1683
1683
  return { roles: e.roles.filter((a) => o.has(a.id)), rows: i };
1684
1684
  }
1685
1685
  listResolved() {
1686
1686
  const e = this.getBep();
1687
- return e.workflows.map((s) => {
1688
- const t = {};
1689
- for (const [i, o] of Object.entries(s.diagram.nodes)) {
1687
+ return e.workflows.map((t) => {
1688
+ const s = {};
1689
+ for (const [i, o] of Object.entries(t.diagram.nodes)) {
1690
1690
  const a = (d) => ({
1691
1691
  roles: (d ?? []).map((l) => e.roles.find((c) => c.id === l)).filter(Boolean),
1692
1692
  teams: [],
1693
1693
  members: []
1694
1694
  });
1695
- t[i] = {
1695
+ s[i] = {
1696
1696
  type: o.type,
1697
1697
  label: o.type === "decision" ? o.label : void 0,
1698
1698
  timeouts: o.type === "process" || o.type === "automation" ? o.timeouts : void 0,
@@ -1707,26 +1707,26 @@ class os extends y {
1707
1707
  };
1708
1708
  }
1709
1709
  return {
1710
- ...s,
1711
- diagram: { ...s.diagram, nodes: t }
1710
+ ...t,
1711
+ diagram: { ...t.diagram, nodes: s }
1712
1712
  };
1713
1713
  });
1714
1714
  }
1715
1715
  }
1716
1716
  var rs = /* @__PURE__ */ (function() {
1717
- var n = function(e, s) {
1718
- return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
1719
- t.__proto__ = i;
1720
- } || function(t, i) {
1721
- for (var o in i) i.hasOwnProperty(o) && (t[o] = i[o]);
1722
- }, n(e, s);
1717
+ var n = function(e, t) {
1718
+ return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(s, i) {
1719
+ s.__proto__ = i;
1720
+ } || function(s, i) {
1721
+ for (var o in i) i.hasOwnProperty(o) && (s[o] = i[o]);
1722
+ }, n(e, t);
1723
1723
  };
1724
- return function(e, s) {
1725
- n(e, s);
1726
- function t() {
1724
+ return function(e, t) {
1725
+ n(e, t);
1726
+ function s() {
1727
1727
  this.constructor = e;
1728
1728
  }
1729
- e.prototype = s === null ? Object.create(s) : (t.prototype = s.prototype, new t());
1729
+ e.prototype = t === null ? Object.create(t) : (s.prototype = t.prototype, new s());
1730
1730
  };
1731
1731
  })(), as = Object.prototype.hasOwnProperty;
1732
1732
  function q(n, e) {
@@ -1734,18 +1734,18 @@ function q(n, e) {
1734
1734
  }
1735
1735
  function W(n) {
1736
1736
  if (Array.isArray(n)) {
1737
- for (var e = new Array(n.length), s = 0; s < e.length; s++)
1738
- e[s] = "" + s;
1737
+ for (var e = new Array(n.length), t = 0; t < e.length; t++)
1738
+ e[t] = "" + t;
1739
1739
  return e;
1740
1740
  }
1741
1741
  if (Object.keys)
1742
1742
  return Object.keys(n);
1743
- var t = [];
1743
+ var s = [];
1744
1744
  for (var i in n)
1745
- q(n, i) && t.push(i);
1746
- return t;
1745
+ q(n, i) && s.push(i);
1746
+ return s;
1747
1747
  }
1748
- function _(n) {
1748
+ function N(n) {
1749
1749
  switch (typeof n) {
1750
1750
  case "object":
1751
1751
  return JSON.parse(JSON.stringify(n));
@@ -1758,8 +1758,8 @@ function _(n) {
1758
1758
  }
1759
1759
  }
1760
1760
  function G(n) {
1761
- for (var e = 0, s = n.length, t; e < s; ) {
1762
- if (t = n.charCodeAt(e), t >= 48 && t <= 57) {
1761
+ for (var e = 0, t = n.length, s; e < t; ) {
1762
+ if (s = n.charCodeAt(e), s >= 48 && s <= 57) {
1763
1763
  e++;
1764
1764
  continue;
1765
1765
  }
@@ -1767,7 +1767,7 @@ function G(n) {
1767
1767
  }
1768
1768
  return !0;
1769
1769
  }
1770
- function T(n) {
1770
+ function R(n) {
1771
1771
  return n.indexOf("/") === -1 && n.indexOf("~") === -1 ? n : n.replace(/~/g, "~0").replace(/\//g, "~1");
1772
1772
  }
1773
1773
  function Je(n) {
@@ -1778,89 +1778,89 @@ function X(n) {
1778
1778
  return !0;
1779
1779
  if (n) {
1780
1780
  if (Array.isArray(n)) {
1781
- for (var e = 0, s = n.length; e < s; e++)
1781
+ for (var e = 0, t = n.length; e < t; e++)
1782
1782
  if (X(n[e]))
1783
1783
  return !0;
1784
1784
  } else if (typeof n == "object") {
1785
- for (var t = W(n), i = t.length, o = 0; o < i; o++)
1786
- if (X(n[t[o]]))
1785
+ for (var s = W(n), i = s.length, o = 0; o < i; o++)
1786
+ if (X(n[s[o]]))
1787
1787
  return !0;
1788
1788
  }
1789
1789
  }
1790
1790
  return !1;
1791
1791
  }
1792
1792
  function oe(n, e) {
1793
- var s = [n];
1794
- for (var t in e) {
1795
- var i = typeof e[t] == "object" ? JSON.stringify(e[t], null, 2) : e[t];
1796
- typeof i < "u" && s.push(t + ": " + i);
1793
+ var t = [n];
1794
+ for (var s in e) {
1795
+ var i = typeof e[s] == "object" ? JSON.stringify(e[s], null, 2) : e[s];
1796
+ typeof i < "u" && t.push(s + ": " + i);
1797
1797
  }
1798
- return s.join(`
1798
+ return t.join(`
1799
1799
  `);
1800
1800
  }
1801
1801
  var Ke = (
1802
1802
  /** @class */
1803
1803
  (function(n) {
1804
1804
  rs(e, n);
1805
- function e(s, t, i, o, a) {
1806
- var d = this.constructor, l = n.call(this, oe(s, { name: t, index: i, operation: o, tree: a })) || this;
1807
- return l.name = t, l.index = i, l.operation = o, l.tree = a, Object.setPrototypeOf(l, d.prototype), l.message = oe(s, { name: t, index: i, operation: o, tree: a }), l;
1805
+ function e(t, s, i, o, a) {
1806
+ var d = this.constructor, l = n.call(this, oe(t, { name: s, index: i, operation: o, tree: a })) || this;
1807
+ return l.name = s, l.index = i, l.operation = o, l.tree = a, Object.setPrototypeOf(l, d.prototype), l.message = oe(t, { name: s, index: i, operation: o, tree: a }), l;
1808
1808
  }
1809
1809
  return e;
1810
1810
  })(Error)
1811
- ), E = Ke, ds = _, O = {
1812
- add: function(n, e, s) {
1813
- return n[e] = this.value, { newDocument: s };
1811
+ ), E = Ke, ds = N, j = {
1812
+ add: function(n, e, t) {
1813
+ return n[e] = this.value, { newDocument: t };
1814
1814
  },
1815
- remove: function(n, e, s) {
1816
- var t = n[e];
1817
- return delete n[e], { newDocument: s, removed: t };
1815
+ remove: function(n, e, t) {
1816
+ var s = n[e];
1817
+ return delete n[e], { newDocument: t, removed: s };
1818
1818
  },
1819
- replace: function(n, e, s) {
1820
- var t = n[e];
1821
- return n[e] = this.value, { newDocument: s, removed: t };
1819
+ replace: function(n, e, t) {
1820
+ var s = n[e];
1821
+ return n[e] = this.value, { newDocument: t, removed: s };
1822
1822
  },
1823
- move: function(n, e, s) {
1824
- var t = C(s, this.path);
1825
- t && (t = _(t));
1826
- var i = A(s, { op: "remove", path: this.from }).removed;
1827
- return A(s, { op: "add", path: this.path, value: i }), { newDocument: s, removed: t };
1823
+ move: function(n, e, t) {
1824
+ var s = C(t, this.path);
1825
+ s && (s = N(s));
1826
+ var i = T(t, { op: "remove", path: this.from }).removed;
1827
+ return T(t, { op: "add", path: this.path, value: i }), { newDocument: t, removed: s };
1828
1828
  },
1829
- copy: function(n, e, s) {
1830
- var t = C(s, this.from);
1831
- return A(s, { op: "add", path: this.path, value: _(t) }), { newDocument: s };
1829
+ copy: function(n, e, t) {
1830
+ var s = C(t, this.from);
1831
+ return T(t, { op: "add", path: this.path, value: N(s) }), { newDocument: t };
1832
1832
  },
1833
- test: function(n, e, s) {
1834
- return { newDocument: s, test: x(n[e], this.value) };
1833
+ test: function(n, e, t) {
1834
+ return { newDocument: t, test: x(n[e], this.value) };
1835
1835
  },
1836
- _get: function(n, e, s) {
1837
- return this.value = n[e], { newDocument: s };
1836
+ _get: function(n, e, t) {
1837
+ return this.value = n[e], { newDocument: t };
1838
1838
  }
1839
1839
  }, ls = {
1840
- add: function(n, e, s) {
1841
- return G(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: s, index: e };
1840
+ add: function(n, e, t) {
1841
+ return G(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: t, index: e };
1842
1842
  },
1843
- remove: function(n, e, s) {
1844
- var t = n.splice(e, 1);
1845
- return { newDocument: s, removed: t[0] };
1843
+ remove: function(n, e, t) {
1844
+ var s = n.splice(e, 1);
1845
+ return { newDocument: t, removed: s[0] };
1846
1846
  },
1847
- replace: function(n, e, s) {
1848
- var t = n[e];
1849
- return n[e] = this.value, { newDocument: s, removed: t };
1847
+ replace: function(n, e, t) {
1848
+ var s = n[e];
1849
+ return n[e] = this.value, { newDocument: t, removed: s };
1850
1850
  },
1851
- move: O.move,
1852
- copy: O.copy,
1853
- test: O.test,
1854
- _get: O._get
1851
+ move: j.move,
1852
+ copy: j.copy,
1853
+ test: j.test,
1854
+ _get: j._get
1855
1855
  };
1856
1856
  function C(n, e) {
1857
1857
  if (e == "")
1858
1858
  return n;
1859
- var s = { op: "_get", path: e };
1860
- return A(n, s), s.value;
1859
+ var t = { op: "_get", path: e };
1860
+ return T(n, t), t.value;
1861
1861
  }
1862
- function A(n, e, s, t, i, o) {
1863
- if (s === void 0 && (s = !1), t === void 0 && (t = !0), i === void 0 && (i = !0), o === void 0 && (o = 0), s && (typeof s == "function" ? s(e, 0, n, e.path) : D(e, 0)), e.path === "") {
1862
+ function T(n, e, t, s, i, o) {
1863
+ if (t === void 0 && (t = !1), s === void 0 && (s = !0), i === void 0 && (i = !0), o === void 0 && (o = 0), t && (typeof t == "function" ? t(e, 0, n, e.path) : D(e, 0)), e.path === "") {
1864
1864
  var a = { newDocument: n };
1865
1865
  if (e.op === "add")
1866
1866
  return a.newDocument = e.value, a;
@@ -1877,26 +1877,26 @@ function A(n, e, s, t, i, o) {
1877
1877
  return a.removed = n, a.newDocument = null, a;
1878
1878
  if (e.op === "_get")
1879
1879
  return e.value = n, a;
1880
- if (s)
1880
+ if (t)
1881
1881
  throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, n);
1882
1882
  return a;
1883
1883
  }
1884
1884
  } else {
1885
- t || (n = _(n));
1886
- var d = e.path || "", l = d.split("/"), c = n, f = 1, u = l.length, m = void 0, p = void 0, g = void 0;
1887
- for (typeof s == "function" ? g = s : g = D; ; ) {
1885
+ s || (n = N(n));
1886
+ var d = e.path || "", l = d.split("/"), c = n, f = 1, u = l.length, m = void 0, p = void 0, w = void 0;
1887
+ for (typeof t == "function" ? w = t : w = D; ; ) {
1888
1888
  if (p = l[f], p && p.indexOf("~") != -1 && (p = Je(p)), i && (p == "__proto__" || p == "prototype" && f > 0 && l[f - 1] == "constructor"))
1889
1889
  throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
1890
- if (s && m === void 0 && (c[p] === void 0 ? m = l.slice(0, f).join("/") : f == u - 1 && (m = e.path), m !== void 0 && g(e, 0, n, m)), f++, Array.isArray(c)) {
1890
+ if (t && m === void 0 && (c[p] === void 0 ? m = l.slice(0, f).join("/") : f == u - 1 && (m = e.path), m !== void 0 && w(e, 0, n, m)), f++, Array.isArray(c)) {
1891
1891
  if (p === "-")
1892
1892
  p = c.length;
1893
1893
  else {
1894
- if (s && !G(p))
1894
+ if (t && !G(p))
1895
1895
  throw new E("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", o, e, n);
1896
1896
  G(p) && (p = ~~p);
1897
1897
  }
1898
1898
  if (f >= u) {
1899
- if (s && e.op === "add" && p > c.length)
1899
+ if (t && e.op === "add" && p > c.length)
1900
1900
  throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", o, e, n);
1901
1901
  var a = ls[e.op].call(e, c, p, n);
1902
1902
  if (a.test === !1)
@@ -1904,70 +1904,70 @@ function A(n, e, s, t, i, o) {
1904
1904
  return a;
1905
1905
  }
1906
1906
  } else if (f >= u) {
1907
- var a = O[e.op].call(e, c, p, n);
1907
+ var a = j[e.op].call(e, c, p, n);
1908
1908
  if (a.test === !1)
1909
1909
  throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1910
1910
  return a;
1911
1911
  }
1912
- if (c = c[p], s && f < u && (!c || typeof c != "object"))
1912
+ if (c = c[p], t && f < u && (!c || typeof c != "object"))
1913
1913
  throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, n);
1914
1914
  }
1915
1915
  }
1916
1916
  }
1917
- function U(n, e, s, t, i) {
1918
- if (t === void 0 && (t = !0), i === void 0 && (i = !0), s && !Array.isArray(e))
1917
+ function U(n, e, t, s, i) {
1918
+ if (s === void 0 && (s = !0), i === void 0 && (i = !0), t && !Array.isArray(e))
1919
1919
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1920
- t || (n = _(n));
1920
+ s || (n = N(n));
1921
1921
  for (var o = new Array(e.length), a = 0, d = e.length; a < d; a++)
1922
- o[a] = A(n, e[a], s, !0, i, a), n = o[a].newDocument;
1922
+ o[a] = T(n, e[a], t, !0, i, a), n = o[a].newDocument;
1923
1923
  return o.newDocument = n, o;
1924
1924
  }
1925
- function cs(n, e, s) {
1926
- var t = A(n, e);
1927
- if (t.test === !1)
1928
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", s, e, n);
1929
- return t.newDocument;
1925
+ function cs(n, e, t) {
1926
+ var s = T(n, e);
1927
+ if (s.test === !1)
1928
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", t, e, n);
1929
+ return s.newDocument;
1930
1930
  }
1931
- function D(n, e, s, t) {
1931
+ function D(n, e, t, s) {
1932
1932
  if (typeof n != "object" || n === null || Array.isArray(n))
1933
- throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, n, s);
1934
- if (O[n.op]) {
1933
+ throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, n, t);
1934
+ if (j[n.op]) {
1935
1935
  if (typeof n.path != "string")
1936
- throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, n, s);
1936
+ throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, n, t);
1937
1937
  if (n.path.indexOf("/") !== 0 && n.path.length > 0)
1938
- throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, n, s);
1938
+ throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, n, t);
1939
1939
  if ((n.op === "move" || n.op === "copy") && typeof n.from != "string")
1940
- throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, n, s);
1940
+ throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, n, t);
1941
1941
  if ((n.op === "add" || n.op === "replace" || n.op === "test") && n.value === void 0)
1942
- throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, n, s);
1942
+ throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, n, t);
1943
1943
  if ((n.op === "add" || n.op === "replace" || n.op === "test") && X(n.value))
1944
- throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, s);
1945
- if (s) {
1944
+ throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, t);
1945
+ if (t) {
1946
1946
  if (n.op == "add") {
1947
- var i = n.path.split("/").length, o = t.split("/").length;
1947
+ var i = n.path.split("/").length, o = s.split("/").length;
1948
1948
  if (i !== o + 1 && i !== o)
1949
- throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, n, s);
1949
+ throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, n, t);
1950
1950
  } else if (n.op === "replace" || n.op === "remove" || n.op === "_get") {
1951
- if (n.path !== t)
1952
- throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, n, s);
1951
+ if (n.path !== s)
1952
+ throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, n, t);
1953
1953
  } else if (n.op === "move" || n.op === "copy") {
1954
- var a = { op: "_get", path: n.from, value: void 0 }, d = qe([a], s);
1954
+ var a = { op: "_get", path: n.from, value: void 0 }, d = qe([a], t);
1955
1955
  if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
1956
- throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, n, s);
1956
+ throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, n, t);
1957
1957
  }
1958
1958
  }
1959
- } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, n, s);
1959
+ } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, n, t);
1960
1960
  }
1961
- function qe(n, e, s) {
1961
+ function qe(n, e, t) {
1962
1962
  try {
1963
1963
  if (!Array.isArray(n))
1964
1964
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1965
1965
  if (e)
1966
- U(_(e), _(n), s || !0);
1966
+ U(N(e), N(n), t || !0);
1967
1967
  else {
1968
- s = s || D;
1969
- for (var t = 0; t < n.length; t++)
1970
- s(n[t], t, e, void 0);
1968
+ t = t || D;
1969
+ for (var s = 0; s < n.length; s++)
1970
+ t(n[s], s, e, void 0);
1971
1971
  }
1972
1972
  } catch (i) {
1973
1973
  if (i instanceof E)
@@ -1979,8 +1979,8 @@ function x(n, e) {
1979
1979
  if (n === e)
1980
1980
  return !0;
1981
1981
  if (n && e && typeof n == "object" && typeof e == "object") {
1982
- var s = Array.isArray(n), t = Array.isArray(e), i, o, a;
1983
- if (s && t) {
1982
+ var t = Array.isArray(n), s = Array.isArray(e), i, o, a;
1983
+ if (t && s) {
1984
1984
  if (o = n.length, o != e.length)
1985
1985
  return !1;
1986
1986
  for (i = o; i-- !== 0; )
@@ -1988,7 +1988,7 @@ function x(n, e) {
1988
1988
  return !1;
1989
1989
  return !0;
1990
1990
  }
1991
- if (s != t)
1991
+ if (t != s)
1992
1992
  return !1;
1993
1993
  var d = Object.keys(n);
1994
1994
  if (o = d.length, o !== Object.keys(e).length)
@@ -2007,7 +2007,7 @@ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2007
2007
  __proto__: null,
2008
2008
  JsonPatchError: E,
2009
2009
  _areEquals: x,
2010
- applyOperation: A,
2010
+ applyOperation: T,
2011
2011
  applyPatch: U,
2012
2012
  applyReducer: cs,
2013
2013
  deepClone: ds,
@@ -2026,8 +2026,8 @@ var ee = /* @__PURE__ */ new WeakMap(), us = (
2026
2026
  ), ms = (
2027
2027
  /** @class */
2028
2028
  /* @__PURE__ */ (function() {
2029
- function n(e, s) {
2030
- this.callback = e, this.observer = s;
2029
+ function n(e, t) {
2030
+ this.callback = e, this.observer = t;
2031
2031
  }
2032
2032
  return n;
2033
2033
  })()
@@ -2045,56 +2045,56 @@ function ws(n, e) {
2045
2045
  e.unobserve();
2046
2046
  }
2047
2047
  function ys(n, e) {
2048
- var s = [], t, i = ps(n);
2048
+ var t = [], s, i = ps(n);
2049
2049
  if (!i)
2050
2050
  i = new us(n), ee.set(n, i);
2051
2051
  else {
2052
2052
  var o = hs(i, e);
2053
- t = o && o.observer;
2053
+ s = o && o.observer;
2054
2054
  }
2055
- if (t)
2056
- return t;
2057
- if (t = {}, i.value = _(n), e) {
2058
- t.callback = e, t.next = null;
2055
+ if (s)
2056
+ return s;
2057
+ if (s = {}, i.value = N(n), e) {
2058
+ s.callback = e, s.next = null;
2059
2059
  var a = function() {
2060
- V(t);
2060
+ V(s);
2061
2061
  }, d = function() {
2062
- clearTimeout(t.next), t.next = setTimeout(a);
2062
+ clearTimeout(s.next), s.next = setTimeout(a);
2063
2063
  };
2064
2064
  typeof window < "u" && (window.addEventListener("mouseup", d), window.addEventListener("keyup", d), window.addEventListener("mousedown", d), window.addEventListener("keydown", d), window.addEventListener("change", d));
2065
2065
  }
2066
- return t.patches = s, t.object = n, t.unobserve = function() {
2067
- V(t), clearTimeout(t.next), gs(i, t), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
2068
- }, i.observers.set(e, new ms(e, t)), t;
2066
+ return s.patches = t, s.object = n, s.unobserve = function() {
2067
+ V(s), clearTimeout(s.next), gs(i, s), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
2068
+ }, i.observers.set(e, new ms(e, s)), s;
2069
2069
  }
2070
2070
  function V(n, e) {
2071
2071
  e === void 0 && (e = !1);
2072
- var s = ee.get(n.object);
2073
- te(s.value, n.object, n.patches, "", e), n.patches.length && U(s.value, n.patches);
2074
- var t = n.patches;
2075
- return t.length > 0 && (n.patches = [], n.callback && n.callback(t)), t;
2072
+ var t = ee.get(n.object);
2073
+ te(t.value, n.object, n.patches, "", e), n.patches.length && U(t.value, n.patches);
2074
+ var s = n.patches;
2075
+ return s.length > 0 && (n.patches = [], n.callback && n.callback(s)), s;
2076
2076
  }
2077
- function te(n, e, s, t, i) {
2077
+ function te(n, e, t, s, i) {
2078
2078
  if (e !== n) {
2079
2079
  typeof e.toJSON == "function" && (e = e.toJSON());
2080
2080
  for (var o = W(e), a = W(n), d = !1, l = a.length - 1; l >= 0; l--) {
2081
2081
  var c = a[l], f = n[c];
2082
2082
  if (q(e, c) && !(e[c] === void 0 && f !== void 0 && Array.isArray(e) === !1)) {
2083
2083
  var u = e[c];
2084
- typeof f == "object" && f != null && typeof u == "object" && u != null && Array.isArray(f) === Array.isArray(u) ? te(f, u, s, t + "/" + T(c), i) : f !== u && (i && s.push({ op: "test", path: t + "/" + T(c), value: _(f) }), s.push({ op: "replace", path: t + "/" + T(c), value: _(u) }));
2085
- } else Array.isArray(n) === Array.isArray(e) ? (i && s.push({ op: "test", path: t + "/" + T(c), value: _(f) }), s.push({ op: "remove", path: t + "/" + T(c) }), d = !0) : (i && s.push({ op: "test", path: t, value: n }), s.push({ op: "replace", path: t, value: e }));
2084
+ typeof f == "object" && f != null && typeof u == "object" && u != null && Array.isArray(f) === Array.isArray(u) ? te(f, u, t, s + "/" + R(c), i) : f !== u && (i && t.push({ op: "test", path: s + "/" + R(c), value: N(f) }), t.push({ op: "replace", path: s + "/" + R(c), value: N(u) }));
2085
+ } else Array.isArray(n) === Array.isArray(e) ? (i && t.push({ op: "test", path: s + "/" + R(c), value: N(f) }), t.push({ op: "remove", path: s + "/" + R(c) }), d = !0) : (i && t.push({ op: "test", path: s, value: n }), t.push({ op: "replace", path: s, value: e }));
2086
2086
  }
2087
2087
  if (!(!d && o.length == a.length))
2088
2088
  for (var l = 0; l < o.length; l++) {
2089
2089
  var c = o[l];
2090
- !q(n, c) && e[c] !== void 0 && s.push({ op: "add", path: t + "/" + T(c), value: _(e[c]) });
2090
+ !q(n, c) && e[c] !== void 0 && t.push({ op: "add", path: s + "/" + R(c), value: N(e[c]) });
2091
2091
  }
2092
2092
  }
2093
2093
  }
2094
- function H(n, e, s) {
2095
- s === void 0 && (s = !1);
2096
- var t = [];
2097
- return te(n, e, t, "", s), t;
2094
+ function H(n, e, t) {
2095
+ t === void 0 && (t = !1);
2096
+ var s = [];
2097
+ return te(n, e, s, "", t), s;
2098
2098
  }
2099
2099
  const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2100
2100
  __proto__: null,
@@ -2105,85 +2105,85 @@ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2105
2105
  }, Symbol.toStringTag, { value: "Module" }));
2106
2106
  Object.assign({}, fs, vs, {
2107
2107
  JsonPatchError: Ke,
2108
- deepClone: _,
2109
- escapePathComponent: T,
2108
+ deepClone: N,
2109
+ escapePathComponent: R,
2110
2110
  unescapePathComponent: Je
2111
2111
  });
2112
- function v(n, e, s) {
2113
- return { key: n, getId: (t) => e(t), getLabel: (t) => s(t) };
2112
+ function b(n, e, t) {
2113
+ return { key: n, getId: (s) => e(s), getLabel: (s) => t(s) };
2114
2114
  }
2115
2115
  const bs = [
2116
- v("roles", (n) => n.id, (n) => n.name),
2117
- v("members", (n) => n.email, (n) => `${n.name} (${n.email})`),
2118
- v("teams", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2119
- v("phases", (n) => n.id, (n) => n.name),
2120
- v("milestones", (n) => n.id, (n) => n.name),
2121
- v("lbs", (n) => n.id, (n) => `${n.id} — ${n.name} (${n.type})`),
2122
- v("disciplines", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2123
- v("extensions", (n) => n.id, (n) => n.id),
2124
- v("assetTypes", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2125
- v("softwares", (n) => n.id, (n) => n.name),
2126
- v("objectives", (n) => n.id, (n) => n.description),
2127
- v("bimUses", (n) => n.id, (n) => n.name),
2128
- v("actions", (n) => n.id, (n) => n.name),
2129
- v("events", (n) => n.id, (n) => n.name),
2130
- v("effects", (n) => n.id, (n) => n.name),
2131
- v("automations", (n) => n.id, (n) => n.name),
2132
- v("workflows", (n) => n.id, (n) => n.name),
2133
- v("guides", (n) => n.id, (n) => n.name),
2134
- v("annexes", (n) => n.id, (n) => n.name),
2135
- v("standards", (n) => n.id, (n) => n.name),
2136
- v("lods", (n) => String(n.id), (n) => `${n.id} — ${n.name}`),
2137
- v("lois", (n) => String(n.id), (n) => `${n.id} — ${n.name}`),
2138
- v("loin", (n) => n.id, (n) => n.element),
2139
- v("deliverables", (n) => n.id, (n) => n.description ?? n.id),
2140
- v("notes", (n) => n.id, (n) => n.message),
2141
- v("env", (n) => n.key, (n) => n.key)
2116
+ b("roles", (n) => n.id, (n) => n.name),
2117
+ b("members", (n) => n.email, (n) => `${n.name} (${n.email})`),
2118
+ b("teams", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2119
+ b("phases", (n) => n.id, (n) => n.name),
2120
+ b("milestones", (n) => n.id, (n) => n.name),
2121
+ b("lbs", (n) => n.id, (n) => `${n.id} — ${n.name} (${n.type})`),
2122
+ b("disciplines", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2123
+ b("extensions", (n) => n.id, (n) => n.id),
2124
+ b("assetTypes", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2125
+ b("softwares", (n) => n.id, (n) => n.name),
2126
+ b("objectives", (n) => n.id, (n) => n.description),
2127
+ b("bimUses", (n) => n.id, (n) => n.name),
2128
+ b("actions", (n) => n.id, (n) => n.name),
2129
+ b("events", (n) => n.id, (n) => n.name),
2130
+ b("effects", (n) => n.id, (n) => n.name),
2131
+ b("automations", (n) => n.id, (n) => n.name),
2132
+ b("workflows", (n) => n.id, (n) => n.name),
2133
+ b("guides", (n) => n.id, (n) => n.name),
2134
+ b("annexes", (n) => n.id, (n) => n.name),
2135
+ b("standards", (n) => n.id, (n) => n.name),
2136
+ b("lods", (n) => String(n.id), (n) => `${n.id} — ${n.name}`),
2137
+ b("lois", (n) => String(n.id), (n) => `${n.id} — ${n.name}`),
2138
+ b("loin", (n) => n.id, (n) => n.element),
2139
+ b("deliverables", (n) => n.id, (n) => n.description ?? n.id),
2140
+ b("notes", (n) => n.id, (n) => n.message),
2141
+ b("env", (n) => n.key, (n) => n.key)
2142
2142
  ];
2143
- function Is(n, e, s, t) {
2144
- const i = new Map(n.map((a) => [s(a), a])), o = new Map(e.map((a) => [s(a), a]));
2143
+ function Is(n, e, t, s) {
2144
+ const i = new Map(n.map((a) => [t(a), a])), o = new Map(e.map((a) => [t(a), a]));
2145
2145
  return {
2146
- added: e.filter((a) => !i.has(s(a))).map(t),
2147
- removed: n.filter((a) => !o.has(s(a))).map(t),
2146
+ added: e.filter((a) => !i.has(t(a))).map(s),
2147
+ removed: n.filter((a) => !o.has(t(a))).map(s),
2148
2148
  modified: e.filter((a) => {
2149
- const d = i.get(s(a));
2149
+ const d = i.get(t(a));
2150
2150
  return d !== void 0 && JSON.stringify(d) !== JSON.stringify(a);
2151
- }).map(t)
2151
+ }).map(s)
2152
2152
  };
2153
2153
  }
2154
2154
  function Es(n, e) {
2155
- let s = null;
2156
- JSON.stringify(n.project) !== JSON.stringify(e.project) && (s = { changed: !0, fields: Object.keys({ ...n.project, ...e.project }).filter((a) => {
2155
+ let t = null;
2156
+ JSON.stringify(n.project) !== JSON.stringify(e.project) && (t = { changed: !0, fields: Object.keys({ ...n.project, ...e.project }).filter((a) => {
2157
2157
  const d = n.project[a], l = e.project[a];
2158
2158
  return JSON.stringify(d) !== JSON.stringify(l);
2159
2159
  }) });
2160
- const t = {};
2160
+ const s = {};
2161
2161
  for (const { key: o, getId: a, getLabel: d } of bs) {
2162
2162
  const l = e[o] ?? [], c = n[o] ?? [], f = Is(l, c, a, d);
2163
- (f.added.length || f.removed.length || f.modified.length) && (t[o] = f);
2163
+ (f.added.length || f.removed.length || f.modified.length) && (s[o] = f);
2164
2164
  }
2165
- const i = [...s ? ["project"] : [], ...Object.keys(t)];
2166
- return { project: s, sections: t, changedKeys: i };
2165
+ const i = [...t ? ["project"] : [], ...Object.keys(s)];
2166
+ return { project: t, sections: s, changedKeys: i };
2167
2167
  }
2168
2168
  class S {
2169
- constructor(e, s, t) {
2170
- this.getBep = e, this.setBep = s, this.getZip = t;
2169
+ constructor(e, t, s) {
2170
+ this.getBep = e, this.setBep = t, this.getZip = s;
2171
2171
  }
2172
2172
  getBep;
2173
2173
  setBep;
2174
2174
  getZip;
2175
2175
  // ─── Version helpers ──────────────────────────────────────────────────────
2176
2176
  static parseVersion(e) {
2177
- const [s, t] = e.split(".").map(Number);
2178
- return { major: s, minor: t };
2177
+ const [t, s] = e.split(".").map(Number);
2178
+ return { major: t, minor: s };
2179
2179
  }
2180
- static compareVersions(e, s) {
2181
- const t = S.parseVersion(e), i = S.parseVersion(s);
2182
- return t.major !== i.major ? t.major - i.major : t.minor - i.minor;
2180
+ static compareVersions(e, t) {
2181
+ const s = S.parseVersion(e), i = S.parseVersion(t);
2182
+ return s.major !== i.major ? s.major - i.major : s.minor - i.minor;
2183
2183
  }
2184
- static bumpVersion(e, s) {
2185
- const [t, i] = e.split(".").map(Number);
2186
- return s === "version" ? `${t + 1}.0` : `${t}.${i + 1}`;
2184
+ static bumpVersion(e, t) {
2185
+ const [s, i] = e.split(".").map(Number);
2186
+ return t === "version" ? `${s + 1}.0` : `${s}.${i + 1}`;
2187
2187
  }
2188
2188
  // ─── Zip helpers ──────────────────────────────────────────────────────────
2189
2189
  async readChangelog() {
@@ -2192,25 +2192,25 @@ class S {
2192
2192
  }
2193
2193
  async readBaseline() {
2194
2194
  const e = this.getZip().file("baseline/bep.json");
2195
- return e ? j(JSON.parse(await e.async("string"))) : null;
2195
+ return e ? A(JSON.parse(await e.async("string"))) : null;
2196
2196
  }
2197
2197
  // ─── Standards versioning helpers ─────────────────────────────────────────
2198
2198
  /**
2199
2199
  * At commit time: for each standard whose .md content changed since the last
2200
2200
  * snapshot, saves changelog/standards/{id}/v{version}.md.
2201
2201
  */
2202
- async snapshotChangedStandards(e, s) {
2203
- const t = this.getZip();
2202
+ async snapshotChangedStandards(e, t) {
2203
+ const s = this.getZip();
2204
2204
  for (const i of e.standards) {
2205
- const o = t.file(i.contentPath);
2205
+ const o = s.file(i.contentPath);
2206
2206
  if (!o) continue;
2207
- const a = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(t.files).filter((f) => f.startsWith(d) && f.endsWith(".md") && f.slice(d.length).startsWith("v")).map((f) => f.slice(d.length + 1, -3));
2207
+ const a = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(s.files).filter((f) => f.startsWith(d) && f.endsWith(".md") && f.slice(d.length).startsWith("v")).map((f) => f.slice(d.length + 1, -3));
2208
2208
  let c = null;
2209
2209
  if (l.length > 0) {
2210
- const f = l.sort((m, p) => S.compareVersions(p, m))[0], u = t.file(`${d}v${f}.md`);
2210
+ const f = l.sort((m, p) => S.compareVersions(p, m))[0], u = s.file(`${d}v${f}.md`);
2211
2211
  u && (c = await u.async("string"));
2212
2212
  }
2213
- c !== a && t.file(`${d}v${s}.md`, a);
2213
+ c !== a && s.file(`${d}v${t}.md`, a);
2214
2214
  }
2215
2215
  }
2216
2216
  /**
@@ -2218,12 +2218,12 @@ class S {
2218
2218
  * discard() can restore the .md files to their last committed state.
2219
2219
  */
2220
2220
  async snapshotBaseStandards(e) {
2221
- const s = this.getZip();
2222
- for (const t of e.standards) {
2223
- const i = s.file(t.contentPath);
2221
+ const t = this.getZip();
2222
+ for (const s of e.standards) {
2223
+ const i = t.file(s.contentPath);
2224
2224
  if (!i) continue;
2225
2225
  const o = await i.async("string");
2226
- s.file(`baseline/standards/${t.id}.md`, o);
2226
+ t.file(`baseline/standards/${s.id}.md`, o);
2227
2227
  }
2228
2228
  }
2229
2229
  /**
@@ -2231,13 +2231,13 @@ class S {
2231
2231
  * Finds the latest snapshot in changelog/standards/{id}/ with version ≤ target.
2232
2232
  * Falls back to the current file if no snapshot exists (content never changed).
2233
2233
  */
2234
- async resolveStandardContent(e, s) {
2235
- const t = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(t.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => S.compareVersions(d, s) <= 0).sort((d, l) => S.compareVersions(l, d));
2234
+ async resolveStandardContent(e, t) {
2235
+ const s = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(s.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => S.compareVersions(d, t) <= 0).sort((d, l) => S.compareVersions(l, d));
2236
2236
  if (o.length === 0) {
2237
- const d = t.file(e.contentPath);
2237
+ const d = s.file(e.contentPath);
2238
2238
  return d ? d.async("string") : null;
2239
2239
  }
2240
- const a = t.file(`${i}v${o[0]}.md`);
2240
+ const a = s.file(`${i}v${o[0]}.md`);
2241
2241
  return a ? a.async("string") : null;
2242
2242
  }
2243
2243
  // ─── Public API ───────────────────────────────────────────────────────────
@@ -2247,42 +2247,42 @@ class S {
2247
2247
  async list() {
2248
2248
  return (await this.readChangelog())?.versions ?? [];
2249
2249
  }
2250
- async commit(e, s = !1) {
2251
- const t = this.getZip(), i = this.getBep(), o = await this.readChangelog(), a = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2250
+ async commit(e, t = !1) {
2251
+ const s = this.getZip(), i = this.getBep(), o = await this.readChangelog(), a = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2252
2252
  if (!a) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
2253
2253
  if (e.type === "version") {
2254
- const g = e.approvedBy.filter((h) => !i.members.some((k) => k.email === h));
2255
- if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
2254
+ const w = e.approvedBy.filter((h) => !i.members.some((v) => v.email === h));
2255
+ if (w.length) throw new Error(`Members not found: ${w.join(", ")}`);
2256
2256
  }
2257
- if (!s && !await this.hasPendingChanges())
2257
+ if (!t && !await this.hasPendingChanges())
2258
2258
  throw new Error("No pending changes since last commit");
2259
2259
  const l = o?.current ?? "0.0", c = S.bumpVersion(l, e.type), f = `changelog/v${c}.diff.json`, u = H(i, a), m = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: f } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: f }, p = {
2260
2260
  current: c,
2261
2261
  versions: [...o?.versions ?? [], m]
2262
2262
  };
2263
- return t.file(f, JSON.stringify(u, null, 2)), await this.snapshotChangedStandards(i, c), t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), t.file("changelog.json", JSON.stringify(p, null, 2)), m;
2263
+ return s.file(f, JSON.stringify(u, null, 2)), await this.snapshotChangedStandards(i, c), s.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), s.file("changelog.json", JSON.stringify(p, null, 2)), m;
2264
2264
  }
2265
2265
  /**
2266
2266
  * Reconstructs the BEP state at the given version (read-only).
2267
2267
  * Applies inverse diffs backward from the current state.
2268
2268
  */
2269
2269
  async get(e) {
2270
- const s = await this.readChangelog();
2271
- if (!s) throw new Error("No changelog found — call commit() first");
2272
- if (e === s.current)
2270
+ const t = await this.readChangelog();
2271
+ if (!t) throw new Error("No changelog found — call commit() first");
2272
+ if (e === t.current)
2273
2273
  return JSON.parse(JSON.stringify(this.getBep()));
2274
- const t = s.versions.findIndex((a) => a.version === e);
2275
- if (t === -1) {
2274
+ const s = t.versions.findIndex((a) => a.version === e);
2275
+ if (s === -1) {
2276
2276
  const a = this.getZip().file(`changelog/v${e}.json`);
2277
2277
  if (!a) throw new Error(`Version not found: ${e}`);
2278
- return j(JSON.parse(await a.async("string")));
2278
+ return A(JSON.parse(await a.async("string")));
2279
2279
  }
2280
- if (s.versions[t].diff === null) {
2280
+ if (t.versions[s].diff === null) {
2281
2281
  const a = this.getZip().file(`changelog/v${e}.json`);
2282
2282
  if (!a) throw new Error(`Missing terminus: changelog/v${e}.json`);
2283
- return j(JSON.parse(await a.async("string")));
2283
+ return A(JSON.parse(await a.async("string")));
2284
2284
  }
2285
- const i = s.versions.filter((a) => S.compareVersions(a.version, e) > 0).sort((a, d) => S.compareVersions(d.version, a.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2285
+ const i = t.versions.filter((a) => S.compareVersions(a.version, e) > 0).sort((a, d) => S.compareVersions(d.version, a.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2286
2286
  for (const a of i) {
2287
2287
  if (!a.diff) break;
2288
2288
  const d = this.getZip().file(a.diff);
@@ -2290,70 +2290,70 @@ class S {
2290
2290
  const l = JSON.parse(await d.async("string"));
2291
2291
  U(o, l);
2292
2292
  }
2293
- return j(o);
2293
+ return A(o);
2294
2294
  }
2295
2295
  /** Returns the RFC 6902 diff and standards summary between two versions. */
2296
- async compare(e, s) {
2297
- const [t, i, o] = await Promise.all([
2296
+ async compare(e, t) {
2297
+ const [s, i, o] = await Promise.all([
2298
2298
  this.get(e),
2299
- this.get(s),
2299
+ this.get(t),
2300
2300
  this.readChangelog()
2301
- ]), a = H(t, i), d = new Set(t.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), f = t.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => S.compareVersions(h.version, e) > 0 && S.compareVersions(h.version, s) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2301
+ ]), a = H(s, i), d = new Set(s.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), f = s.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => S.compareVersions(h.version, e) > 0 && S.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), w = (await Promise.all(
2302
2302
  i.standards.filter((h) => d.has(h.id)).map(async (h) => {
2303
- const k = (await Promise.all(
2304
- m.map(async (b) => p.file(`changelog/standards/${h.id}/v${b}.md`) !== null ? b : null)
2305
- )).filter((b) => b !== null);
2306
- return k.length > 0 ? { id: h.id, name: h.name, changedIn: k } : null;
2303
+ const v = (await Promise.all(
2304
+ m.map(async (k) => p.file(`changelog/standards/${h.id}/v${k}.md`) !== null ? k : null)
2305
+ )).filter((k) => k !== null);
2306
+ return v.length > 0 ? { id: h.id, name: h.name, changedIn: v } : null;
2307
2307
  })
2308
2308
  )).filter((h) => h !== null);
2309
- return { diff: a, standards: { added: c, removed: f, contentModified: g } };
2309
+ return { diff: a, standards: { added: c, removed: f, contentModified: w } };
2310
2310
  }
2311
2311
  /**
2312
2312
  * Resets in-memory BEP and restores .md files to the last committed baseline.
2313
2313
  * Standards added since the baseline have their .md deleted.
2314
2314
  */
2315
2315
  async discard() {
2316
- const e = this.getZip(), s = await this.readBaseline();
2317
- if (!s) throw new Error("No baseline found — call commit() first");
2318
- const t = new Set(s.standards.map((i) => i.id));
2316
+ const e = this.getZip(), t = await this.readBaseline();
2317
+ if (!t) throw new Error("No baseline found — call commit() first");
2318
+ const s = new Set(t.standards.map((i) => i.id));
2319
2319
  for (const i of this.getBep().standards)
2320
- t.has(i.id) || e.remove(i.contentPath);
2321
- for (const i of s.standards) {
2320
+ s.has(i.id) || e.remove(i.contentPath);
2321
+ for (const i of t.standards) {
2322
2322
  const o = e.file(`baseline/standards/${i.id}.md`);
2323
2323
  if (!o) continue;
2324
2324
  const a = await o.async("string");
2325
2325
  e.file(i.contentPath, a);
2326
2326
  }
2327
- this.setBep(s);
2327
+ this.setBep(t);
2328
2328
  }
2329
2329
  /**
2330
2330
  * Non-destructive revert: restores BEP state and .md files to a historical
2331
2331
  * version and immediately commits it as a new version.
2332
2332
  */
2333
- async revert(e, s) {
2334
- const t = this.getZip(), i = await this.get(e);
2333
+ async revert(e, t) {
2334
+ const s = this.getZip(), i = await this.get(e);
2335
2335
  for (const o of i.standards) {
2336
2336
  const a = await this.resolveStandardContent(o, e);
2337
- a !== null && t.file(o.contentPath, a);
2337
+ a !== null && s.file(o.contentPath, a);
2338
2338
  }
2339
- return this.setBep(i), this.commit(s);
2339
+ return this.setBep(i), this.commit(t);
2340
2340
  }
2341
2341
  /**
2342
2342
  * Returns a structured diff of the current BEP state vs the last committed baseline.
2343
2343
  * Includes .md content changes for standards (added, removed, modified, content-modified).
2344
2344
  */
2345
2345
  async status() {
2346
- const e = this.getZip(), s = await this.readBaseline();
2347
- if (!s) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
2348
- const t = this.getBep(), i = Es(t, s), o = [], a = new Map(s.standards.map((c) => [c.id, c])), d = new Set(t.standards.map((c) => c.id));
2349
- for (const c of t.standards)
2346
+ const e = this.getZip(), t = await this.readBaseline();
2347
+ if (!t) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
2348
+ const s = this.getBep(), i = Es(s, t), o = [], a = new Map(t.standards.map((c) => [c.id, c])), d = new Set(s.standards.map((c) => c.id));
2349
+ for (const c of s.standards)
2350
2350
  if (!a.has(c.id))
2351
2351
  o.push({ id: c.id, name: c.name, status: "added" });
2352
2352
  else {
2353
- const f = JSON.stringify(a.get(c.id)) !== JSON.stringify(c), u = e.file(`baseline/standards/${c.id}.md`), m = e.file(c.contentPath), p = u ? await u.async("string") : "", g = m ? await m.async("string") : "";
2354
- f ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
2353
+ const f = JSON.stringify(a.get(c.id)) !== JSON.stringify(c), u = e.file(`baseline/standards/${c.id}.md`), m = e.file(c.contentPath), p = u ? await u.async("string") : "", w = m ? await m.async("string") : "";
2354
+ f ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== w && o.push({ id: c.id, name: c.name, status: "content-modified" });
2355
2355
  }
2356
- for (const c of s.standards)
2356
+ for (const c of t.standards)
2357
2357
  d.has(c.id) || o.push({ id: c.id, name: c.name, status: "removed" });
2358
2358
  return { hasPendingChanges: i.changedKeys.length > 0 || o.length > 0, standards: o, ...i };
2359
2359
  }
@@ -2363,19 +2363,19 @@ class S {
2363
2363
  }
2364
2364
  /** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
2365
2365
  async listResolved() {
2366
- const [e, s] = await Promise.all([this.list(), this.current()]), t = this.getBep().members;
2366
+ const [e, t] = await Promise.all([this.list(), this.current()]), s = this.getBep().members;
2367
2367
  return e.sort((i, o) => S.compareVersions(i.version, o.version)).map((i) => ({
2368
2368
  version: i.version,
2369
2369
  type: i.type,
2370
2370
  date: i.date,
2371
2371
  description: i.description,
2372
2372
  diff: i.diff,
2373
- isCurrent: i.version === s,
2374
- author: i.author ? { email: i.author, name: t.find((o) => o.email === i.author)?.name ?? null } : null,
2373
+ isCurrent: i.version === t,
2374
+ author: i.author ? { email: i.author, name: s.find((o) => o.email === i.author)?.name ?? null } : null,
2375
2375
  ...i.type === "version" ? {
2376
2376
  approvedBy: i.approvedBy.map((o) => ({
2377
2377
  email: o,
2378
- name: t.find((a) => a.email === o)?.name ?? null
2378
+ name: s.find((a) => a.email === o)?.name ?? null
2379
2379
  }))
2380
2380
  } : {}
2381
2381
  }));
@@ -2384,35 +2384,35 @@ class S {
2384
2384
  * Resolves the markdown content of a standard at a specific historical version.
2385
2385
  * Returns null if the standard did not exist at that version.
2386
2386
  */
2387
- async getStandardContent(e, s) {
2388
- const i = (await this.get(s)).standards.find((o) => o.id === e);
2389
- return i ? this.resolveStandardContent(i, s) : null;
2387
+ async getStandardContent(e, t) {
2388
+ const i = (await this.get(t)).standards.find((o) => o.id === e);
2389
+ return i ? this.resolveStandardContent(i, t) : null;
2390
2390
  }
2391
2391
  /**
2392
2392
  * ⚠️ Destructive: resets the BEP to a historical version and permanently
2393
2393
  * deletes all subsequent diffs, standard snapshots, and changelog entries.
2394
2394
  */
2395
2395
  async reset(e) {
2396
- const s = this.getZip(), t = await this.readChangelog();
2397
- if (!t) throw new Error("No changelog found");
2398
- const i = t.versions.find((c) => c.version === e), o = !!this.getZip().file(`changelog/v${e}.json`);
2396
+ const t = this.getZip(), s = await this.readChangelog();
2397
+ if (!s) throw new Error("No changelog found");
2398
+ const i = s.versions.find((c) => c.version === e), o = !!this.getZip().file(`changelog/v${e}.json`);
2399
2399
  if (!i && !o)
2400
2400
  throw new Error(`Version not found: ${e}`);
2401
- if (e === t.current)
2401
+ if (e === s.current)
2402
2402
  throw new Error(`Already at version ${e}`);
2403
- const a = t.versions.filter((c) => S.compareVersions(c.version, e) > 0), d = await this.get(e);
2403
+ const a = s.versions.filter((c) => S.compareVersions(c.version, e) > 0), d = await this.get(e);
2404
2404
  for (const c of d.standards) {
2405
2405
  const f = await this.resolveStandardContent(c, e);
2406
- f !== null && s.file(c.contentPath, f);
2406
+ f !== null && t.file(c.contentPath, f);
2407
2407
  }
2408
2408
  await this.snapshotBaseStandards(d);
2409
2409
  for (const c of a)
2410
- c.diff && s.remove(c.diff), Object.keys(s.files).filter((f) => f.startsWith("changelog/standards/") && f.includes(`/v${c.version}.md`)).forEach((f) => s.remove(f));
2410
+ c.diff && t.remove(c.diff), Object.keys(t.files).filter((f) => f.startsWith("changelog/standards/") && f.includes(`/v${c.version}.md`)).forEach((f) => t.remove(f));
2411
2411
  const l = JSON.stringify(d, null, 2);
2412
- s.file("changelog.json", JSON.stringify({
2412
+ t.file("changelog.json", JSON.stringify({
2413
2413
  current: e,
2414
- versions: t.versions.filter((c) => S.compareVersions(c.version, e) <= 0)
2415
- }, null, 2)), s.file("bep.json", l), s.file("baseline/bep.json", l), this.setBep(d);
2414
+ versions: s.versions.filter((c) => S.compareVersions(c.version, e) <= 0)
2415
+ }, null, 2)), t.file("bep.json", l), t.file("baseline/bep.json", l), this.setBep(d);
2416
2416
  }
2417
2417
  /**
2418
2418
  * ⚠️ Destructive: collapses all history into a single new terminus version.
@@ -2420,24 +2420,24 @@ class S {
2420
2420
  * newBase must be in X.0 format and greater than the current version.
2421
2421
  */
2422
2422
  async squash(e) {
2423
- const s = this.getZip(), t = await this.readChangelog();
2424
- if (!t) throw new Error("No changelog found");
2423
+ const t = this.getZip(), s = await this.readChangelog();
2424
+ if (!s) throw new Error("No changelog found");
2425
2425
  if (!/^\d+\.0$/.test(e.newBase))
2426
2426
  throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
2427
- if (S.compareVersions(e.newBase, t.current) <= 0)
2428
- throw new Error(`newBase "${e.newBase}" must be greater than current version "${t.current}"`);
2427
+ if (S.compareVersions(e.newBase, s.current) <= 0)
2428
+ throw new Error(`newBase "${e.newBase}" must be greater than current version "${s.current}"`);
2429
2429
  const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
2430
2430
  if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
2431
- for (const d of t.versions)
2432
- d.diff && s.remove(d.diff);
2433
- Object.keys(s.files).filter((d) => /^changelog\/v[\d.]+\.json$/.test(d)).forEach((d) => s.remove(d)), Object.keys(s.files).filter((d) => d.startsWith("changelog/standards/") && d.endsWith(".md")).forEach((d) => s.remove(d)), s.file(`changelog/v${e.newBase}.json`, JSON.stringify(i, null, 2));
2431
+ for (const d of s.versions)
2432
+ d.diff && t.remove(d.diff);
2433
+ Object.keys(t.files).filter((d) => /^changelog\/v[\d.]+\.json$/.test(d)).forEach((d) => t.remove(d)), Object.keys(t.files).filter((d) => d.startsWith("changelog/standards/") && d.endsWith(".md")).forEach((d) => t.remove(d)), t.file(`changelog/v${e.newBase}.json`, JSON.stringify(i, null, 2));
2434
2434
  for (const d of i.standards) {
2435
- const l = s.file(d.contentPath);
2435
+ const l = t.file(d.contentPath);
2436
2436
  if (!l) continue;
2437
2437
  const c = await l.async("string");
2438
- s.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
2438
+ t.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
2439
2439
  }
2440
- s.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i);
2440
+ t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i);
2441
2441
  const a = {
2442
2442
  version: e.newBase,
2443
2443
  type: "version",
@@ -2447,12 +2447,12 @@ class S {
2447
2447
  approvedBy: e.approvedBy,
2448
2448
  diff: null
2449
2449
  };
2450
- return s.file("changelog.json", JSON.stringify({ current: e.newBase, versions: [a] }, null, 2)), a;
2450
+ return t.file("changelog.json", JSON.stringify({ current: e.newBase, versions: [a] }, null, 2)), a;
2451
2451
  }
2452
2452
  }
2453
2453
  class Z {
2454
- constructor(e, s) {
2455
- this.path = e, this.getZip = s;
2454
+ constructor(e, t) {
2455
+ this.path = e, this.getZip = t;
2456
2456
  }
2457
2457
  path;
2458
2458
  getZip;
@@ -2468,42 +2468,42 @@ class Z {
2468
2468
  }
2469
2469
  const ks = 10;
2470
2470
  function Ss(n, e) {
2471
- const s = e[n.field];
2471
+ const t = e[n.field];
2472
2472
  switch (n.operator) {
2473
2473
  case "exists":
2474
- return s != null;
2474
+ return t != null;
2475
2475
  case "eq":
2476
- return s === n.value;
2476
+ return t === n.value;
2477
2477
  case "neq":
2478
- return s !== n.value;
2478
+ return t !== n.value;
2479
2479
  case "gt":
2480
- return typeof s == "number" && typeof n.value == "number" && s > n.value;
2480
+ return typeof t == "number" && typeof n.value == "number" && t > n.value;
2481
2481
  case "lt":
2482
- return typeof s == "number" && typeof n.value == "number" && s < n.value;
2482
+ return typeof t == "number" && typeof n.value == "number" && t < n.value;
2483
2483
  case "contains":
2484
- return typeof s == "string" && typeof n.value == "string" || Array.isArray(s) ? s.includes(n.value) : !1;
2484
+ return typeof t == "string" && typeof n.value == "string" || Array.isArray(t) ? t.includes(n.value) : !1;
2485
2485
  default:
2486
2486
  return !1;
2487
2487
  }
2488
2488
  }
2489
- function Ns(n, e, s, t) {
2490
- const o = n.workflows.find((m) => m.id === s)?.diagram.nodes[e];
2489
+ function Ns(n, e, t, s) {
2490
+ const o = n.workflows.find((m) => m.id === t)?.diagram.nodes[e];
2491
2491
  if (!o || o.type !== "process") return !0;
2492
2492
  const a = !!(o.responsibleRoleIds?.length || o.responsibleTeamIds?.length || o.responsibleEmails?.length), d = !!(o.accountableRoleIds?.length || o.accountableTeamIds?.length || o.accountableEmails?.length);
2493
2493
  if (!a && !d) return !0;
2494
- const c = n.members.find((m) => m.email === t)?.roleId, f = new Set(n.teams.filter((m) => (m.memberEmails ?? []).includes(t)).map((m) => m.id)), u = (m, p, g) => {
2495
- if (g?.includes(t)) return !0;
2496
- const h = !!m?.length, k = !!p?.length;
2497
- return k && h ? !!c && m.includes(c) && p.some((b) => f.has(b)) : k ? p.some((b) => f.has(b)) : h ? !!c && m.includes(c) : !1;
2494
+ const c = n.members.find((m) => m.email === s)?.roleId, f = new Set(n.teams.filter((m) => (m.memberEmails ?? []).includes(s)).map((m) => m.id)), u = (m, p, w) => {
2495
+ if (w?.includes(s)) return !0;
2496
+ const h = !!m?.length, v = !!p?.length;
2497
+ return v && h ? !!c && m.includes(c) && p.some((k) => f.has(k)) : v ? p.some((k) => f.has(k)) : h ? !!c && m.includes(c) : !1;
2498
2498
  };
2499
2499
  return a && u(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && u(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2500
2500
  }
2501
2501
  const _s = { string: "string", number: "number", boolean: "boolean" };
2502
- function $s(n, e, s) {
2503
- const t = n.events.find((d) => d.id === e);
2504
- if (!t?.payload?.length) return [];
2505
- const i = [], o = s ?? {};
2506
- for (const d of t.payload) {
2502
+ function $s(n, e, t) {
2503
+ const s = n.events.find((d) => d.id === e);
2504
+ if (!s?.payload?.length) return [];
2505
+ const i = [], o = t ?? {};
2506
+ for (const d of s.payload) {
2507
2507
  const l = o[d.key];
2508
2508
  if (l == null)
2509
2509
  d.required && i.push({ field: d.key, reason: "missing" });
@@ -2518,7 +2518,7 @@ function $s(n, e, s) {
2518
2518
  }
2519
2519
  }
2520
2520
  }
2521
- const a = new Set(t.payload.map((d) => d.key));
2521
+ const a = new Set(s.payload.map((d) => d.key));
2522
2522
  for (const d of Object.keys(o))
2523
2523
  a.has(d) || i.push({ field: d, reason: "unknown_field" });
2524
2524
  return i;
@@ -2526,78 +2526,77 @@ function $s(n, e, s) {
2526
2526
  function Rs(n, e) {
2527
2527
  return !(!("triggerEventId" in n) || n.triggerEventId !== e.eventId);
2528
2528
  }
2529
- function Ts(n, e, s, t, i) {
2530
- const o = n.workflows.find((u) => u.id === e);
2531
- if (!o) return null;
2532
- const a = Object.keys(o.diagram.nodes).find(
2533
- (u) => o.diagram.nodes[u].type === "start"
2529
+ function Ts(n, e, t, s) {
2530
+ const i = n.workflows.find((f) => f.id === e);
2531
+ if (!i) return null;
2532
+ const o = Object.keys(i.diagram.nodes).find(
2533
+ (f) => i.diagram.nodes[f].type === "start"
2534
2534
  );
2535
- if (!a) return null;
2536
- const d = Object.entries(o.diagram.edges).find(([, u]) => u.from === a), l = d?.[1].to ?? a, c = d ? (d[1].effectIds ?? []).map((u) => ({ effectId: u, fromEdgeId: d[0], triggerPayload: {} })) : [], f = (/* @__PURE__ */ new Date()).toISOString();
2535
+ if (!o) return null;
2536
+ const a = Object.entries(i.diagram.edges).find(([, f]) => f.from === o), d = a?.[1].to ?? o, l = a ? (a[1].effectIds ?? []).map((f) => ({ effectId: f, fromEdgeId: a[0], triggerPayload: {} })) : [], c = (/* @__PURE__ */ new Date()).toISOString();
2537
2537
  return {
2538
2538
  instance: {
2539
2539
  id: globalThis.crypto.randomUUID(),
2540
2540
  workflowId: e,
2541
- bepVersion: i,
2542
- trackedAsset: s,
2543
- currentNodeId: l,
2541
+ trackedAsset: t,
2542
+ currentNodeId: d,
2544
2543
  status: "active",
2545
2544
  history: [],
2546
- createdAt: f,
2547
- updatedAt: f,
2548
- initiatedBy: t
2545
+ createdAt: c,
2546
+ updatedAt: c,
2547
+ initiatedBy: s
2549
2548
  },
2550
- startEffects: c
2549
+ startEffects: l
2551
2550
  };
2552
2551
  }
2553
- function J(n, e, s, t) {
2552
+ function J(n, e, t, s) {
2554
2553
  if (e.status !== "active")
2555
2554
  return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
2556
- if (!t?.skipRaci && !Ns(n, e.currentNodeId, e.workflowId, s.actor))
2555
+ if (!s?.skipRaci && !Ns(n, e.currentNodeId, e.workflowId, t.actor))
2557
2556
  return { ok: !1, error: "UNAUTHORIZED" };
2558
2557
  const i = n.workflows.find((I) => I.id === e.workflowId);
2559
2558
  if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
2560
2559
  const { nodes: o, edges: a } = i.diagram;
2561
2560
  let d = e.currentNodeId;
2562
2561
  const l = [], c = [], f = [], u = Object.entries(a).filter(
2563
- ([, I]) => I.from === d && Rs(I, s)
2562
+ ([, I]) => I.from === d && Rs(I, t)
2564
2563
  );
2565
2564
  if (u.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2566
2565
  if (u.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2567
2566
  const [m, p] = u[0];
2568
2567
  if ("triggerEventId" in p) {
2569
- const I = $s(n, p.triggerEventId, s.payload);
2568
+ const I = $s(n, p.triggerEventId, t.payload);
2570
2569
  if (I.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: I };
2571
2570
  }
2572
- l.push(re(m, d, p.to, s)), c.push(...(p.effectIds ?? []).map((I) => ({ effectId: I, fromEdgeId: m, triggerPayload: s.payload ?? {} }))), f.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2573
- let g = 0;
2571
+ l.push(re(m, d, p.to, t)), c.push(...(p.effectIds ?? []).map((I) => ({ effectId: I, fromEdgeId: m, triggerPayload: t.payload ?? {} }))), f.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2572
+ let w = 0;
2574
2573
  for (; o[d]?.type === "decision"; ) {
2575
- if (++g > ks) return { ok: !1, error: "DECISION_LOOP" };
2576
- const I = Object.entries(a).filter(([, R]) => R.from !== d || !("guard" in R) ? !1 : Ss(R.guard, s.payload ?? {}));
2574
+ if (++w > ks) return { ok: !1, error: "DECISION_LOOP" };
2575
+ const I = Object.entries(a).filter(([, B]) => B.from !== d || !("guard" in B) ? !1 : Ss(B.guard, t.payload ?? {}));
2577
2576
  if (I.length === 0) break;
2578
- const [$, N] = I[0];
2579
- l.push(re($, d, N.to, s, !0)), c.push(...(N.effectIds ?? []).map((R) => ({ effectId: R, fromEdgeId: $, triggerPayload: s.payload ?? {} }))), f.push({ edgeId: $, fromNodeId: d, toNodeId: N.to }), d = N.to;
2577
+ const [_, $] = I[0];
2578
+ l.push(re(_, d, $.to, t, !0)), c.push(...($.effectIds ?? []).map((B) => ({ effectId: B, fromEdgeId: _, triggerPayload: t.payload ?? {} }))), f.push({ edgeId: _, fromNodeId: d, toNodeId: $.to }), d = $.to;
2580
2579
  }
2581
- const h = o[d], k = h?.type === "end" ? "completed" : "active", b = {
2580
+ const h = o[d], v = h?.type === "end" ? "completed" : "active", k = {
2582
2581
  ...e,
2583
2582
  currentNodeId: d,
2584
- status: k,
2583
+ status: v,
2585
2584
  history: [...e.history, ...l],
2586
2585
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2587
- }, w = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId, triggerPayload: s.payload ?? {} } : void 0;
2588
- return { ok: !0, instance: b, transitionsApplied: f, effectsToFire: c, automationNodePending: w };
2586
+ }, g = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId, triggerPayload: t.payload ?? {} } : void 0;
2587
+ return { ok: !0, instance: k, transitionsApplied: f, effectsToFire: c, automationNodePending: g };
2589
2588
  }
2590
2589
  function As(n, e) {
2591
- const s = n.workflows.find((m) => m.id === e.workflowId), { nodes: t, edges: i } = s.diagram, o = t[e.currentNodeId], a = (m) => (m ?? []).flatMap((p) => {
2592
- const g = n.roles.find((h) => h.id === p);
2593
- return g ? [{ id: g.id, name: g.name }] : [];
2590
+ const t = n.workflows.find((m) => m.id === e.workflowId), { nodes: s, edges: i } = t.diagram, o = s[e.currentNodeId], a = (m) => (m ?? []).flatMap((p) => {
2591
+ const w = n.roles.find((h) => h.id === p);
2592
+ return w ? [{ id: w.id, name: w.name }] : [];
2594
2593
  }), d = (m) => (m ?? []).flatMap((p) => {
2595
- const g = n.teams.find((h) => h.id === p);
2596
- return g ? [{ id: g.id, name: g.name }] : [];
2597
- }), l = (m, p, g) => ({
2594
+ const w = n.teams.find((h) => h.id === p);
2595
+ return w ? [{ id: w.id, name: w.name }] : [];
2596
+ }), l = (m, p, w) => ({
2598
2597
  roles: a(m),
2599
2598
  teams: d(p),
2600
- emails: g ?? []
2599
+ emails: w ?? []
2601
2600
  }), c = (m) => (n.events.find((p) => p.id === m)?.payload ?? []).map((p) => ({
2602
2601
  key: p.key,
2603
2602
  type: p.type,
@@ -2606,12 +2605,12 @@ function As(n, e) {
2606
2605
  })), f = o.type === "process" ? o : null, u = [];
2607
2606
  for (const [m, p] of Object.entries(i)) {
2608
2607
  if (p.from !== e.currentNodeId || !("triggerEventId" in p)) continue;
2609
- const g = p.triggerEventId;
2608
+ const w = p.triggerEventId;
2610
2609
  u.push({
2611
2610
  edgeId: m,
2612
- label: p.label ?? g,
2613
- emits: g,
2614
- requiredPayload: c(g)
2611
+ label: p.label ?? w,
2612
+ emits: w,
2613
+ requiredPayload: c(w)
2615
2614
  });
2616
2615
  }
2617
2616
  return {
@@ -2631,14 +2630,14 @@ function As(n, e) {
2631
2630
  isTerminal: o.type === "end"
2632
2631
  };
2633
2632
  }
2634
- function re(n, e, s, t, i) {
2633
+ function re(n, e, t, s, i) {
2635
2634
  return {
2636
2635
  id: globalThis.crypto.randomUUID(),
2637
2636
  edgeId: n,
2638
2637
  fromNodeId: e,
2639
- toNodeId: s,
2640
- trigger: t,
2641
- actor: t.actor,
2638
+ toNodeId: t,
2639
+ trigger: s,
2640
+ actor: s.actor,
2642
2641
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2643
2642
  ...i ? { auto: !0 } : {}
2644
2643
  };
@@ -2646,8 +2645,8 @@ function re(n, e, s, t, i) {
2646
2645
  class js {
2647
2646
  instances = /* @__PURE__ */ new Map();
2648
2647
  async listInstances(e) {
2649
- let s = [...this.instances.values()];
2650
- return e?.workflowId && (s = s.filter((t) => t.workflowId === e.workflowId)), e?.status && (s = s.filter((t) => t.status === e.status)), e?.trackedAssetTypeId && (s = s.filter((t) => t.trackedAsset.assetTypeId === e.trackedAssetTypeId)), e?.trackedAssetId && (s = s.filter((t) => t.trackedAsset.id === e.trackedAssetId)), s;
2648
+ let t = [...this.instances.values()];
2649
+ return e?.workflowId && (t = t.filter((s) => s.workflowId === e.workflowId)), e?.status && (t = t.filter((s) => s.status === e.status)), e?.trackedAssetId && (t = t.filter((s) => s.trackedAsset.source === "internal" && s.trackedAsset.id === e.trackedAssetId)), t;
2651
2650
  }
2652
2651
  async getInstance(e) {
2653
2652
  return this.instances.get(e) ?? null;
@@ -2662,8 +2661,8 @@ class js {
2662
2661
  function ae(n) {
2663
2662
  if (n == null) return "Unknown error";
2664
2663
  if (typeof n == "string") return n;
2665
- const e = n, s = typeof e.name == "string" ? e.name : "Error", t = typeof e.message == "string" ? e.message : void 0;
2666
- if (t !== void 0) return t ? `${s}: ${t}` : s;
2664
+ const e = n, t = typeof e.name == "string" ? e.name : "Error", s = typeof e.message == "string" ? e.message : void 0;
2665
+ if (s !== void 0) return s ? `${t}: ${s}` : t;
2667
2666
  try {
2668
2667
  return String(n);
2669
2668
  } catch {
@@ -2672,7 +2671,6 @@ function ae(n) {
2672
2671
  }
2673
2672
  class Os {
2674
2673
  getBep;
2675
- getHistoricalBep;
2676
2674
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2677
2675
  _runtime;
2678
2676
  storage;
@@ -2690,10 +2688,10 @@ class Os {
2690
2688
  }
2691
2689
  /** Namespaced workflow instance operations. */
2692
2690
  workflows;
2693
- constructor(e, s) {
2694
- this.getBep = e, this.getHistoricalBep = s, this.workflows = {
2695
- create: (t, i, o) => this._create(t, i, o),
2696
- emit: (t, i) => this._emit(t, i),
2691
+ constructor(e) {
2692
+ this.getBep = e, this.workflows = {
2693
+ create: (t, s, i) => this._create(t, s, i),
2694
+ emit: (t, s) => this._emit(t, s),
2697
2695
  get: (t) => this._get(t),
2698
2696
  list: (t) => this._list(t),
2699
2697
  delete: (t) => this._delete(t),
@@ -2719,52 +2717,52 @@ class Os {
2719
2717
  // ─── Remote data ──────────────────────────────────────────────────────────
2720
2718
  async getRemoteData(e) {
2721
2719
  this._assertInit();
2722
- const t = this.getBep().remoteData.find((i) => i.id === e);
2723
- if (!t) throw new Error(`Remote data "${e}" not found in BEP`);
2724
- if (!t.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
2725
- return this._runtime._runResolver(t.resolverId, t.url);
2720
+ const s = this.getBep().remoteData.find((i) => i.id === e);
2721
+ if (!s) throw new Error(`Remote data "${e}" not found in BEP`);
2722
+ if (!s.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
2723
+ return this._runtime._runResolver(s.resolverId, s.url);
2726
2724
  }
2727
2725
  // ─── Private workflow instance operations ─────────────────────────────────
2728
- async _create(e, s, t) {
2726
+ async _create(e, t, s) {
2729
2727
  this._assertInit();
2730
2728
  let i, o;
2731
- if ("rawPayload" in s) {
2732
- const b = this._runtime.triggers[e];
2733
- if (!b) throw new Error(`No trigger handler declared for software "${e}"`);
2734
- const w = await b(s.rawPayload);
2735
- i = w.trackedAsset, o = w.workflowId, t = "dotBEP";
2729
+ if ("rawPayload" in t) {
2730
+ const v = this._runtime.triggers[e];
2731
+ if (!v) throw new Error(`No trigger handler declared for software "${e}"`);
2732
+ const k = await v(t.rawPayload);
2733
+ i = k.trackedAsset, o = k.workflowId, s = "dotBEP";
2736
2734
  } else
2737
- i = s, o = e;
2738
- const a = this.getBep(), l = Ts(a, o, i, t, "unversioned");
2739
- if (!l) return null;
2740
- const { instance: c, startEffects: f } = l;
2741
- for (const b of f)
2742
- await this._executeEffect(c, b);
2743
- const m = a.workflows.find((b) => b.id === o)?.diagram.nodes[c.currentNodeId];
2744
- let p = m?.type === "automation" && m.automationId ? { automationId: m.automationId, triggerPayload: {} } : void 0, g = c;
2745
- const h = 10;
2746
- let k = 0;
2747
- for (; p && k++ < h; ) {
2748
- const { automationId: b, triggerPayload: w } = p, { eventId: I, ...$ } = await this._executeAutomationNode(g, b, w), N = J(a, g, {
2749
- eventId: I,
2735
+ i = t, o = e;
2736
+ const a = this.getBep(), d = Ts(a, o, i, s);
2737
+ if (!d) return null;
2738
+ const { instance: l, startEffects: c } = d;
2739
+ for (const v of c)
2740
+ await this._executeEffect(l, v);
2741
+ const u = a.workflows.find((v) => v.id === o)?.diagram.nodes[l.currentNodeId];
2742
+ let m = u?.type === "automation" && u.automationId ? { automationId: u.automationId, triggerPayload: {} } : void 0, p = l;
2743
+ const w = 10;
2744
+ let h = 0;
2745
+ for (; m && h++ < w; ) {
2746
+ const { automationId: v, triggerPayload: k } = m, { eventId: g, ...I } = await this._executeAutomationNode(p, v, k), _ = J(a, p, {
2747
+ eventId: g,
2750
2748
  actor: "dotBEP",
2751
2749
  softwareId: "dotBEP",
2752
- payload: $
2750
+ payload: I
2753
2751
  });
2754
- if (!N.ok) break;
2755
- g = N.instance;
2756
- for (const R of N.effectsToFire ?? [])
2757
- await this._executeEffect(g, R);
2758
- p = N.automationNodePending;
2752
+ if (!_.ok) break;
2753
+ p = _.instance;
2754
+ for (const $ of _.effectsToFire ?? [])
2755
+ await this._executeEffect(p, $);
2756
+ m = _.automationNodePending;
2759
2757
  }
2760
- return await this.storage.saveInstance(g), await this._fire(this._createdListeners, g), g;
2758
+ return await this.storage.saveInstance(p), await this._fire(this._createdListeners, p), p;
2761
2759
  }
2762
- async _emit(e, s) {
2760
+ async _emit(e, t) {
2763
2761
  this._assertInit();
2764
- const t = await this.storage.getInstance(e);
2765
- if (!t) return { ok: !1, error: "NO_MATCHING_EDGE" };
2766
- const i = await this._resolveBep(t.bepVersion);
2767
- let o = J(i, t, s, { skipRaci: this.skipRaci });
2762
+ const s = await this.storage.getInstance(e);
2763
+ if (!s) return { ok: !1, error: "NO_MATCHING_EDGE" };
2764
+ const i = this.getBep();
2765
+ let o = J(i, s, t, { skipRaci: this.skipRaci });
2768
2766
  if (!o.ok) return { ok: !1, error: o.error, payloadErrors: o.payloadErrors };
2769
2767
  const a = [...o.transitionsApplied ?? []], d = [];
2770
2768
  let l = o.instance;
@@ -2773,12 +2771,12 @@ class Os {
2773
2771
  const c = 10;
2774
2772
  let f = 0;
2775
2773
  for (; o.automationNodePending && f++ < c; ) {
2776
- const { automationId: u, triggerPayload: m } = o.automationNodePending, { eventId: p, ...g } = await this._executeAutomationNode(l, u, m);
2774
+ const { automationId: u, triggerPayload: m } = o.automationNodePending, { eventId: p, ...w } = await this._executeAutomationNode(l, u, m);
2777
2775
  if (o = J(i, l, {
2778
2776
  eventId: p,
2779
2777
  actor: "dotBEP",
2780
2778
  softwareId: "dotBEP",
2781
- payload: g
2779
+ payload: w
2782
2780
  }), !o.ok) break;
2783
2781
  l = o.instance, a.push(...o.transitionsApplied ?? []);
2784
2782
  for (const h of o.effectsToFire ?? [])
@@ -2796,9 +2794,9 @@ class Os {
2796
2794
  }
2797
2795
  async _list(e) {
2798
2796
  this._assertInit();
2799
- const { pendingActionFor: s, ...t } = e ?? {}, i = await this.storage.listInstances(t);
2800
- if (!s) return i;
2801
- const o = this.getBep(), a = o.members.find((d) => d.email === s);
2797
+ const { pendingActionFor: t, ...s } = e ?? {}, i = await this.storage.listInstances(s);
2798
+ if (!t) return i;
2799
+ const o = this.getBep(), a = o.members.find((d) => d.email === t);
2802
2800
  return a ? i.filter((d) => {
2803
2801
  const l = o.workflows.find((m) => m.id === d.workflowId);
2804
2802
  if (!l) return !1;
@@ -2816,61 +2814,58 @@ class Os {
2816
2814
  }
2817
2815
  async _cancel(e) {
2818
2816
  this._assertInit();
2819
- const s = await this.storage.getInstance(e);
2820
- if (!s || s.status !== "active") return;
2821
- const t = {
2822
- ...s,
2817
+ const t = await this.storage.getInstance(e);
2818
+ if (!t || t.status !== "active") return;
2819
+ const s = {
2820
+ ...t,
2823
2821
  status: "cancelled",
2824
2822
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2825
2823
  };
2826
- await this.storage.saveInstance(t), await this._fire(this._cancelledListeners, t);
2824
+ await this.storage.saveInstance(s), await this._fire(this._cancelledListeners, s);
2827
2825
  }
2828
2826
  async _getStatus(e) {
2829
2827
  this._assertInit();
2830
- const s = await this.storage.getInstance(e);
2831
- if (!s) return null;
2832
- const t = await this._resolveBep(s.bepVersion);
2833
- return As(t, s);
2828
+ const t = await this.storage.getInstance(e);
2829
+ if (!t) return null;
2830
+ const s = this.getBep();
2831
+ return As(s, t);
2834
2832
  }
2835
2833
  async _resolveContext(e) {
2836
2834
  this._assertInit();
2837
- const s = await this.storage.getInstance(e);
2838
- if (!s) return {};
2839
- const t = {};
2840
- for (const i of s.history)
2841
- Object.assign(t, i.trigger.payload ?? {});
2842
- return t;
2835
+ const t = await this.storage.getInstance(e);
2836
+ if (!t) return {};
2837
+ const s = {};
2838
+ for (const i of t.history)
2839
+ Object.assign(s, i.trigger.payload ?? {});
2840
+ return s;
2843
2841
  }
2844
2842
  // ─── Internal helpers ─────────────────────────────────────────────────────
2845
2843
  _assertInit() {
2846
2844
  if (!this._runtime || !this.storage)
2847
2845
  throw new Error("Engine not initialized — call bep.engine.init({ runtime, storage }) first.");
2848
2846
  }
2849
- async _resolveBep(e) {
2850
- return this.getHistoricalBep && e !== "unversioned" ? this.getHistoricalBep(e) : this.getBep();
2851
- }
2852
- async _fire(e, ...s) {
2853
- await Promise.allSettled(e.map((t) => t(...s)));
2847
+ async _fire(e, ...t) {
2848
+ await Promise.allSettled(e.map((s) => s(...t)));
2854
2849
  }
2855
- async _executeAutomationNode(e, s, t) {
2856
- const i = this._runtime.automations[s];
2857
- if (!i) throw new Error(`No handler declared for automation "${s}"`);
2850
+ async _executeAutomationNode(e, t, s) {
2851
+ const i = this._runtime.automations[t];
2852
+ if (!i) throw new Error(`No handler declared for automation "${t}"`);
2858
2853
  try {
2859
- return await i(e, t);
2854
+ return await i(e, s);
2860
2855
  } catch (o) {
2861
- throw await this._fire(this._automationFailedListeners, e, s, ae(o)), o;
2856
+ throw await this._fire(this._automationFailedListeners, e, t, ae(o)), o;
2862
2857
  }
2863
2858
  }
2864
- async _executeEffect(e, s) {
2865
- const t = this._runtime.effects[s.effectId];
2866
- if (!t)
2867
- return { effectId: s.effectId, fromEdgeId: s.fromEdgeId, status: "skipped" };
2859
+ async _executeEffect(e, t) {
2860
+ const s = this._runtime.effects[t.effectId];
2861
+ if (!s)
2862
+ return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped" };
2868
2863
  try {
2869
- return await t(e, s.triggerPayload), { effectId: s.effectId, fromEdgeId: s.fromEdgeId, status: "executed" };
2864
+ return await s(e, t.triggerPayload), { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "executed" };
2870
2865
  } catch (i) {
2871
2866
  const o = {
2872
- effectId: s.effectId,
2873
- fromEdgeId: s.fromEdgeId,
2867
+ effectId: t.effectId,
2868
+ fromEdgeId: t.fromEdgeId,
2874
2869
  status: "failed",
2875
2870
  error: ae(i)
2876
2871
  };
@@ -2879,13 +2874,13 @@ class Os {
2879
2874
  }
2880
2875
  }
2881
2876
  function Ls(n, e) {
2882
- const s = /* @__PURE__ */ new Map();
2883
- for (const t of n) {
2884
- const i = [e(t)].flat();
2877
+ const t = /* @__PURE__ */ new Map();
2878
+ for (const s of n) {
2879
+ const i = [e(s)].flat();
2885
2880
  for (const o of i)
2886
- s.has(o) || s.set(o, []), s.get(o).push(t);
2881
+ t.has(o) || t.set(o, []), t.get(o).push(s);
2887
2882
  }
2888
- return Array.from(s.entries()).map(([t, i]) => ({ key: t, rows: i }));
2883
+ return Array.from(t.entries()).map(([s, i]) => ({ key: s, rows: i }));
2889
2884
  }
2890
2885
  class Cs {
2891
2886
  env;
@@ -2902,29 +2897,29 @@ class Cs {
2902
2897
  constructor({ env: e = {} } = {}) {
2903
2898
  this.env = e;
2904
2899
  }
2905
- effect(e, s) {
2906
- return this.effects[e] = s, this;
2900
+ effect(e, t) {
2901
+ return this.effects[e] = t, this;
2907
2902
  }
2908
- automation(e, s) {
2909
- return this.automations[e] = s, this;
2903
+ automation(e, t) {
2904
+ return this.automations[e] = t, this;
2910
2905
  }
2911
- resolver(e, s) {
2912
- return this.resolvers[e] = s, this;
2906
+ resolver(e, t) {
2907
+ return this.resolvers[e] = t, this;
2913
2908
  }
2914
- trigger(e, s) {
2915
- return this.triggers[e] = s, this;
2909
+ trigger(e, t) {
2910
+ return this.triggers[e] = t, this;
2916
2911
  }
2917
2912
  /** @internal Called by Engine.getRemoteData — keeps env encapsulated inside the Runtime. */
2918
- _runResolver(e, s) {
2919
- const t = this.resolvers[e];
2920
- if (!t) throw new Error(`No handler declared for resolver "${e}"`);
2921
- return t(s, this.env);
2913
+ _runResolver(e, t) {
2914
+ const s = this.resolvers[e];
2915
+ if (!s) throw new Error(`No handler declared for resolver "${e}"`);
2916
+ return s(t, this.env);
2922
2917
  }
2923
2918
  }
2924
2919
  class F {
2925
- constructor(e, s) {
2926
- this._data = e, this._zip = s;
2927
- const t = () => this._data;
2920
+ constructor(e, t) {
2921
+ this._data = e, this._zip = t;
2922
+ const s = () => this._data;
2928
2923
  this.project = new _t(
2929
2924
  () => this._data.project,
2930
2925
  (i) => {
@@ -2932,20 +2927,17 @@ class F {
2932
2927
  },
2933
2928
  de,
2934
2929
  (i, o) => {
2935
- const a = [], d = B("project", i.code, o.deliverableNamingConvention);
2930
+ const a = [], d = O("project", i.code, o.deliverableNamingConvention);
2936
2931
  return d && a.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && a.push(`teams["${i.clientId}"] not found`), a;
2937
2932
  },
2938
- t
2939
- ), this.actions = new Rt(t), this.annexes = new Tt(t), this.env = new Ot(t), this.events = new Bt(t), this.effects = new At(t), this.automations = new jt(t), this.bimUses = new Ct(t, () => this.workflows), this.disciplines = new Dt(t), this.guides = new Ut(t), this.lods = new zt(t), this.lois = new Zt(t), this.loin = new Jt(t), this.lbsNodes = new Gt(t), this.assetTypes = new Kt(t), this.extensions = new qt(t), this.roles = new Wt(t), this.members = new Xt(t), this.milestones = new Vt(t), this.objectives = new Ht(t), this.phases = new Yt(t), this.remoteData = new Qt(t), this.resolvers = new es(t), this.softwares = new ts(t, () => this.assetTypes), this.standards = new ss(t, () => this._zip), this.teams = new ns(t, () => this.members), this.workflows = new os(t, () => this.members, () => this.teams), this.deliverables = new Pt(t, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Lt(t, () => this.members), this.flags = new Ft(t), this.engine = new Os(
2940
- () => this._data,
2941
- (i) => this.history.get(i)
2942
- ), this.history = new S(
2943
- t,
2933
+ s
2934
+ ), this.actions = new Rt(s), this.annexes = new Tt(s), this.env = new Ot(s), this.events = new Bt(s), this.effects = new At(s), this.automations = new jt(s), this.bimUses = new Ct(s, () => this.workflows), this.disciplines = new Dt(s), this.guides = new Ut(s), this.lods = new zt(s), this.lois = new Zt(s), this.loin = new Jt(s), this.lbsNodes = new Gt(s), this.assetTypes = new Kt(s), this.extensions = new qt(s), this.roles = new Wt(s), this.members = new Xt(s), this.milestones = new Vt(s), this.objectives = new Ht(s), this.phases = new Yt(s), this.remoteData = new Qt(s), this.resolvers = new es(s), this.softwares = new ts(s, () => this.assetTypes), this.standards = new ss(s, () => this._zip), this.teams = new ns(s, () => this.members), this.workflows = new os(s, () => this.members, () => this.teams), this.deliverables = new Pt(s, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Lt(s, () => this.members), this.flags = new Ft(s), this.engine = new Os(() => this._data), this.history = new S(
2935
+ s,
2944
2936
  (i) => {
2945
2937
  this._data = i;
2946
2938
  },
2947
2939
  () => this._zip
2948
- ), this.nomenclature = new Mt(t), this.memory = new Z("memory.md", () => this._zip), this.skill = new Z("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new Z("icon.svg", () => this._zip);
2940
+ ), this.nomenclature = new Mt(s), this.memory = new Z("memory.md", () => this._zip), this.skill = new Z("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new Z("icon.svg", () => this._zip);
2949
2941
  }
2950
2942
  _data;
2951
2943
  _zip;
@@ -3002,10 +2994,10 @@ class F {
3002
2994
  * fully operational after open(). Idempotent — existing files are untouched.
3003
2995
  */
3004
2996
  static async open(e) {
3005
- const s = await se.loadAsync(e), t = s.file("bep.json");
3006
- if (!t) throw new Error("Invalid .bep file: missing bep.json");
3007
- const i = await t.async("string"), o = j(JSON.parse(i));
3008
- return await F._initialize(o, s), new F(o, s);
2997
+ const t = await se.loadAsync(e), s = t.file("bep.json");
2998
+ if (!s) throw new Error("Invalid .bep file: missing bep.json");
2999
+ const i = await s.async("string"), o = A(JSON.parse(i));
3000
+ return await F._initialize(o, t), new F(o, t);
3009
3001
  }
3010
3002
  /**
3011
3003
  * Ensures all expected files exist in the zip.
@@ -3018,21 +3010,21 @@ class F {
3018
3010
  * diff against this terminus. The baseline is written so history.status()
3019
3011
  * and history.discard() work before the first commit.
3020
3012
  */
3021
- static async _initialize(e, s) {
3022
- s.file("memory.md") || s.file("memory.md", ""), s.file("skills/bep-authoring/SKILL.md") || s.file("skills/bep-authoring/SKILL.md", "");
3023
- for (const t of e.standards)
3024
- s.file(t.contentPath) || s.file(t.contentPath, "");
3025
- if (!s.file("baseline/bep.json")) {
3026
- const t = JSON.stringify(e, null, 2);
3027
- s.file("baseline/bep.json", t), s.file("changelog/v0.0.json", t);
3013
+ static async _initialize(e, t) {
3014
+ t.file("memory.md") || t.file("memory.md", ""), t.file("skills/bep-authoring/SKILL.md") || t.file("skills/bep-authoring/SKILL.md", "");
3015
+ for (const s of e.standards)
3016
+ t.file(s.contentPath) || t.file(s.contentPath, "");
3017
+ if (!t.file("baseline/bep.json")) {
3018
+ const s = JSON.stringify(e, null, 2);
3019
+ t.file("baseline/bep.json", s), t.file("changelog/v0.0.json", s);
3028
3020
  for (const i of e.standards) {
3029
- const o = await s.file(i.contentPath).async("string");
3030
- s.file(`baseline/standards/${i.id}.md`, o), s.file(`changelog/standards/${i.id}/v0.0.md`, o);
3021
+ const o = await t.file(i.contentPath).async("string");
3022
+ t.file(`baseline/standards/${i.id}.md`, o), t.file(`changelog/standards/${i.id}/v0.0.md`, o);
3031
3023
  }
3032
3024
  }
3033
3025
  }
3034
3026
  static create(e) {
3035
- const s = j({
3027
+ const t = A({
3036
3028
  project: { name: e.name, code: e.code, clientId: e.clientId, description: e.description },
3037
3029
  roles: [],
3038
3030
  members: [],
@@ -3061,8 +3053,8 @@ class F {
3061
3053
  flags: [],
3062
3054
  env: [],
3063
3055
  automations: []
3064
- }), t = new se(), i = JSON.stringify(s, null, 2);
3065
- return t.file("memory.md", ""), t.file("skills/bep-authoring/SKILL.md", ""), t.file("baseline/bep.json", i), t.file("changelog/v0.0.json", i), new F(s, t);
3056
+ }), s = new se(), i = JSON.stringify(t, null, 2);
3057
+ return s.file("memory.md", ""), s.file("skills/bep-authoring/SKILL.md", ""), s.file("baseline/bep.json", i), s.file("changelog/v0.0.json", i), new F(t, s);
3066
3058
  }
3067
3059
  // ─── Accessors ────────────────────────────────────────────────────────────
3068
3060
  get data() {
@@ -3078,62 +3070,62 @@ class F {
3078
3070
  delete this._data.deliverableNamingConvention;
3079
3071
  return;
3080
3072
  }
3081
- const s = ue.parse(e), t = Nt(this._data, s);
3082
- if (t.length) throw new Error(`Naming convention incompatible with existing data:
3083
- ${t.join(`
3073
+ const t = ue.parse(e), s = Nt(this._data, t);
3074
+ if (s.length) throw new Error(`Naming convention incompatible with existing data:
3075
+ ${s.join(`
3084
3076
  `)}`);
3085
- this._data.deliverableNamingConvention = s;
3077
+ this._data.deliverableNamingConvention = t;
3086
3078
  }
3087
3079
  // ─── File access ──────────────────────────────────────────────────────────
3088
3080
  /** Reads any text file stored inside the .bep archive by its zip path. */
3089
3081
  async readFile(e) {
3090
- const s = this._zip.file(e);
3091
- return s ? s.async("string") : null;
3082
+ const t = this._zip.file(e);
3083
+ return t ? t.async("string") : null;
3092
3084
  }
3093
3085
  // ─── Skills ───────────────────────────────────────────────────────────────
3094
3086
  /** Returns the names of all skills present in the archive. */
3095
3087
  listSkills() {
3096
3088
  const e = /* @__PURE__ */ new Set();
3097
- return this._zip.forEach((s) => {
3098
- const t = s.match(/^skills\/([^/]+)\/SKILL\.md$/);
3099
- t && e.add(t[1]);
3089
+ return this._zip.forEach((t) => {
3090
+ const s = t.match(/^skills\/([^/]+)\/SKILL\.md$/);
3091
+ s && e.add(s[1]);
3100
3092
  }), [...e];
3101
3093
  }
3102
3094
  /** Returns the SKILL.md content for the given skill, or null if it does not exist. */
3103
3095
  async getSkill(e) {
3104
- const s = this._zip.file(`skills/${e}/SKILL.md`);
3105
- return s ? s.async("string") : null;
3096
+ const t = this._zip.file(`skills/${e}/SKILL.md`);
3097
+ return t ? t.async("string") : null;
3106
3098
  }
3107
3099
  /** Writes the SKILL.md content for the given skill, creating it if needed. */
3108
- async setSkill(e, s) {
3109
- this._zip.file(`skills/${e}/SKILL.md`, s);
3100
+ async setSkill(e, t) {
3101
+ this._zip.file(`skills/${e}/SKILL.md`, t);
3110
3102
  }
3111
3103
  /** Returns the names of all resource files for the given skill. */
3112
3104
  listSkillResources(e) {
3113
- const s = `skills/${e}/resources/`, t = [];
3105
+ const t = `skills/${e}/resources/`, s = [];
3114
3106
  return this._zip.forEach((i) => {
3115
- i.startsWith(s) && i !== s && t.push(i.slice(s.length));
3116
- }), t;
3107
+ i.startsWith(t) && i !== t && s.push(i.slice(t.length));
3108
+ }), s;
3117
3109
  }
3118
3110
  /** Returns the content of a resource file for the given skill, or null if it does not exist. */
3119
- async getSkillResource(e, s) {
3120
- const t = this._zip.file(`skills/${e}/resources/${s}`);
3121
- return t ? t.async("string") : null;
3111
+ async getSkillResource(e, t) {
3112
+ const s = this._zip.file(`skills/${e}/resources/${t}`);
3113
+ return s ? s.async("string") : null;
3122
3114
  }
3123
3115
  /** Writes a resource file for the given skill, creating it if needed. */
3124
- async setSkillResource(e, s, t) {
3125
- this._zip.file(`skills/${e}/resources/${s}`, t);
3116
+ async setSkillResource(e, t, s) {
3117
+ this._zip.file(`skills/${e}/resources/${t}`, s);
3126
3118
  }
3127
3119
  /** Removes a skill's SKILL.md and all its resources from the archive. No-op if not found. */
3128
3120
  removeSkill(e) {
3129
- const s = `skills/${e}/`, t = [];
3121
+ const t = `skills/${e}/`, s = [];
3130
3122
  this._zip.forEach((i) => {
3131
- i.startsWith(s) && t.push(i);
3132
- }), t.forEach((i) => this._zip.remove(i));
3123
+ i.startsWith(t) && s.push(i);
3124
+ }), s.forEach((i) => this._zip.remove(i));
3133
3125
  }
3134
3126
  /** Removes a single resource file from a skill. No-op if not found. */
3135
- removeSkillResource(e, s) {
3136
- this._zip.remove(`skills/${e}/resources/${s}`);
3127
+ removeSkillResource(e, t) {
3128
+ this._zip.remove(`skills/${e}/resources/${t}`);
3137
3129
  }
3138
3130
  // ─── Type generation ──────────────────────────────────────────────────────
3139
3131
  /**
@@ -3146,24 +3138,24 @@ ${t.join(`
3146
3138
  * writeFileSync('bep.d.ts', bep.generateRuntimeTypes())
3147
3139
  */
3148
3140
  generateRuntimeTypes() {
3149
- const e = (w) => w, s = (w) => ` /** ${w} */
3150
- `, t = (w) => `{ ${w.map((I) => `${I.key}${I.required ? "" : "?"}: ${e(I.type)}`).join("; ")} }`, i = (w) => !w.payload || w.payload.length === 0 ? "() => void" : `(payload: ${t(w.payload)}) => void`, o = (w) => {
3151
- const I = w.payload && w.payload.length > 0 ? `payload: ${t(w.payload)}` : "", $ = w.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${w.output.map((N) => `${N.key}${N.required ? "" : "?"}: ${e(N.type)}`).join("; ")} }`;
3152
- return `(${I}) => ${$}`;
3153
- }, a = (w) => w.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${w.envKeys.map(($) => `${$}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((w) => `${s(w.description)} '${w.id}': ${i(w)}`).join(`
3154
- `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((w) => `${s(w.description)} '${w.id}': ${o(w)}`).join(`
3155
- `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((w) => `${s(w.description)} '${w.id}': ${a(w)}`).join(`
3156
- `) : " [key: string]: (url: string) => unknown", f = this._data.env.length ? this._data.env.map((w) => `${s(w.description)} ${w.key}: string`).join(`
3157
- `) : " [key: string]: string", u = this._data.workflows.length > 0, m = u ? this._data.workflows.map((w) => {
3158
- const I = w.description ? `${w.name} — ${w.description}` : w.name;
3159
- return `${s(I)} '${w.id}': never`;
3141
+ const e = (g) => g, t = (g) => ` /** ${g} */
3142
+ `, s = (g) => `{ ${g.map((I) => `${I.key}${I.required ? "" : "?"}: ${e(I.type)}`).join("; ")} }`, i = (g) => !g.payload || g.payload.length === 0 ? "() => void" : `(payload: ${s(g.payload)}) => void`, o = (g) => {
3143
+ const I = g.payload && g.payload.length > 0 ? `payload: ${s(g.payload)}` : "", _ = g.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${g.output.map(($) => `${$.key}${$.required ? "" : "?"}: ${e($.type)}`).join("; ")} }`;
3144
+ return `(${I}) => ${_}`;
3145
+ }, a = (g) => g.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${g.envKeys.map((_) => `${_}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((g) => `${t(g.description)} '${g.id}': ${i(g)}`).join(`
3146
+ `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((g) => `${t(g.description)} '${g.id}': ${o(g)}`).join(`
3147
+ `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((g) => `${t(g.description)} '${g.id}': ${a(g)}`).join(`
3148
+ `) : " [key: string]: (url: string) => unknown", f = this._data.env.length ? this._data.env.map((g) => `${t(g.description)} ${g.key}: string`).join(`
3149
+ `) : " [key: string]: string", u = this._data.workflows.length > 0, m = u ? this._data.workflows.map((g) => {
3150
+ const I = g.description ? `${g.name} — ${g.description}` : g.name;
3151
+ return `${t(I)} '${g.id}': never`;
3160
3152
  }).join(`
3161
- `) : null, h = `(rawPayload: unknown) => ${`Promise<{ trackedAsset: import('@dotbep/core').WorkflowInstance['trackedAsset']; workflowId: ${u ? "WorkflowId" : "string"} }>`}`, k = this._data.softwares.length ? this._data.softwares.map((w) => `${s(w.name)} '${w.id}': ${h}`).join(`
3162
- `) : ` [key: string]: ${h}`, b = [
3153
+ `) : null, h = `(rawPayload: unknown) => ${`Promise<{ trackedAsset: import('@dotbep/core').WorkflowInstance['trackedAsset']; workflowId: ${u ? "WorkflowId" : "string"} }>`}`, v = this._data.softwares.length ? this._data.softwares.map((g) => `${t(g.name)} '${g.id}': ${h}`).join(`
3154
+ `) : ` [key: string]: ${h}`, k = [
3163
3155
  "// Generated by bep.generateRuntimeTypes() — do not edit manually",
3164
3156
  ""
3165
3157
  ];
3166
- return m && b.push(
3158
+ return m && k.push(
3167
3159
  "// ─── Workflows ───────────────────────────────────────────────────────────────",
3168
3160
  "",
3169
3161
  "export interface BepWorkflows {",
@@ -3171,7 +3163,7 @@ ${t.join(`
3171
3163
  "}",
3172
3164
  "export type WorkflowId = keyof BepWorkflows | (string & {})",
3173
3165
  ""
3174
- ), b.push(
3166
+ ), k.push(
3175
3167
  "// ─── Effects ──────────────────────────────────────────────────────────────────",
3176
3168
  "",
3177
3169
  "export interface BepEffects {",
@@ -3193,7 +3185,7 @@ ${t.join(`
3193
3185
  "// ─── Triggers ─────────────────────────────────────────────────────────────────",
3194
3186
  "",
3195
3187
  "export interface BepTriggers {",
3196
- k,
3188
+ v,
3197
3189
  "}",
3198
3190
  "",
3199
3191
  "// ─── Env ──────────────────────────────────────────────────────────────────────",
@@ -3212,7 +3204,7 @@ ${t.join(`
3212
3204
  " env: BepEnv",
3213
3205
  "}",
3214
3206
  ""
3215
- ), b.join(`
3207
+ ), k.join(`
3216
3208
  `);
3217
3209
  }
3218
3210
  // ─── Serialization ────────────────────────────────────────────────────────
@@ -3339,9 +3331,9 @@ export {
3339
3331
  Q as getRootIds,
3340
3332
  St as getTokenPattern,
3341
3333
  Ls as groupRaciRows,
3342
- j as normalizeBep,
3334
+ A as normalizeBep,
3343
3335
  Ue as resolveLBSCodes,
3344
3336
  Nt as validateAllTokens,
3345
3337
  xt as validateLBS,
3346
- B as validateTokenValue
3338
+ O as validateTokenValue
3347
3339
  };