@dotbep/core 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/index.d.ts +7 -5
  2. package/dist/index.js +604 -596
  3. package/package.json +4 -1
  4. package/examples/01-participants.ts +0 -127
  5. package/examples/02-files.ts +0 -100
  6. package/examples/03-workflows.ts +0 -149
  7. package/examples/04-bim-uses.ts +0 -70
  8. package/examples/05-standards.ts +0 -60
  9. package/examples/06-schedule.ts +0 -124
  10. package/examples/07-loin.ts +0 -133
  11. package/examples/08-deliverables.ts +0 -126
  12. package/examples/09-notes.ts +0 -73
  13. package/examples/10-llm.ts +0 -109
  14. package/examples/11-resolved.ts +0 -133
  15. package/examples/12-history.ts +0 -166
  16. package/examples/13-engine.ts +0 -152
  17. package/examples/bep.d.ts +0 -38
  18. package/examples/example.bep +0 -0
  19. package/examples/run-all.ts +0 -38
  20. package/src/base/entity.ts +0 -148
  21. package/src/base/history.ts +0 -497
  22. package/src/base/index.ts +0 -5
  23. package/src/base/singleton.ts +0 -26
  24. package/src/entities/actions.ts +0 -25
  25. package/src/entities/adapters.ts +0 -16
  26. package/src/entities/annexes.ts +0 -17
  27. package/src/entities/assetTypes.ts +0 -30
  28. package/src/entities/automations.ts +0 -24
  29. package/src/entities/bimUses.ts +0 -50
  30. package/src/entities/deliverables.ts +0 -66
  31. package/src/entities/disciplines.ts +0 -21
  32. package/src/entities/effects.ts +0 -28
  33. package/src/entities/env.ts +0 -17
  34. package/src/entities/events.ts +0 -24
  35. package/src/entities/extensions.ts +0 -16
  36. package/src/entities/flags.ts +0 -17
  37. package/src/entities/guides.ts +0 -26
  38. package/src/entities/index.ts +0 -32
  39. package/src/entities/lbsNodes.ts +0 -193
  40. package/src/entities/lods.ts +0 -22
  41. package/src/entities/loin.ts +0 -127
  42. package/src/entities/lois.ts +0 -22
  43. package/src/entities/members.ts +0 -137
  44. package/src/entities/milestones.ts +0 -32
  45. package/src/entities/notes.ts +0 -27
  46. package/src/entities/objectives.ts +0 -17
  47. package/src/entities/phases.ts +0 -17
  48. package/src/entities/remoteData.ts +0 -17
  49. package/src/entities/resolvers.ts +0 -20
  50. package/src/entities/roles.ts +0 -29
  51. package/src/entities/softwares.ts +0 -26
  52. package/src/entities/standards.ts +0 -68
  53. package/src/entities/teams.ts +0 -42
  54. package/src/entities/workflows.ts +0 -256
  55. package/src/index.ts +0 -464
  56. package/src/runtime/Engine.ts +0 -352
  57. package/src/runtime/MemoryStorage.ts +0 -31
  58. package/src/runtime/Runtime.ts +0 -106
  59. package/src/runtime/index.ts +0 -4
  60. package/src/runtime/transitions.ts +0 -456
  61. package/src/runtime/types.ts +0 -279
  62. package/src/types/history.ts +0 -37
  63. package/src/types/index.ts +0 -24
  64. package/src/types/resolved.ts +0 -137
  65. package/src/types/schema.ts +0 -757
  66. package/src/utils/diff.ts +0 -109
  67. package/src/utils/index.ts +0 -9
  68. package/src/utils/integrity.ts +0 -108
  69. package/src/utils/lbs.ts +0 -116
  70. package/src/utils/mermaid.ts +0 -110
  71. package/src/utils/naming.ts +0 -62
  72. package/src/utils/nomenclature.ts +0 -107
  73. package/src/utils/normalize.ts +0 -35
  74. package/src/utils/raci.ts +0 -25
  75. package/src/utils/textFile.ts +0 -24
  76. package/tsconfig.json +0 -12
  77. package/vite.config.ts +0 -24
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import ie from "jszip";
1
+ import oe from "jszip";
2
2
  import { z as a, ZodError as He } from "zod";
3
3
  const Ye = a.enum([
4
4
  "appointing-party",
@@ -44,7 +44,7 @@ const Ye = a.enum([
44
44
  roleId: a.string(),
45
45
  description: a.string().optional(),
46
46
  bepEditor: a.boolean().optional()
47
- }).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."), ot = a.object({
47
+ }).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."), it = a.object({
48
48
  id: a.string().min(1).describe("Must comply with the naming convention token pattern."),
49
49
  name: a.string().min(1),
50
50
  isoRole: Ye,
@@ -52,10 +52,10 @@ const Ye = a.enum([
52
52
  disciplineIds: a.array(a.string()).optional(),
53
53
  representativeEmail: a.email().optional().describe("ref Member.email"),
54
54
  memberEmails: a.array(a.email()).optional()
55
- }).describe("A company or discipline group participating in the project. Teams group members under an ISO role and can be assigned RACI responsibilities at the workflow level."), pe = ot.refine((n) => !n.representativeEmail || (n.memberEmails ?? []).includes(n.representativeEmail), {
55
+ }).describe("A company or discipline group participating in the project. Teams group members under an ISO role and can be assigned RACI responsibilities at the workflow level."), pe = it.refine((n) => !n.representativeEmail || (n.memberEmails ?? []).includes(n.representativeEmail), {
56
56
  message: "representativeEmail must be included in memberEmails.",
57
57
  path: ["representativeEmail"]
58
- }), it = a.enum([
58
+ }), ot = a.enum([
59
59
  "project",
60
60
  "team",
61
61
  "discipline",
@@ -63,7 +63,7 @@ const Ye = a.enum([
63
63
  "lbsZone",
64
64
  "lbsLocation"
65
65
  ]), rt = a.discriminatedUnion("type", [
66
- a.object({ type: a.literal("field"), token: it, pattern: a.string().optional() }),
66
+ a.object({ type: a.literal("field"), token: ot, pattern: a.string().optional() }),
67
67
  a.object({ type: a.literal("sequence"), padding: a.number().int().min(1).optional() })
68
68
  ]), he = a.object({
69
69
  delimiter: a.string().min(1),
@@ -217,21 +217,21 @@ const Ye = a.enum([
217
217
  nodes: a.record(a.string(), ht),
218
218
  edges: a.record(a.string(), vt)
219
219
  }).superRefine((n, e) => {
220
- const t = Object.entries(n.nodes), s = t.filter(([, r]) => r.type === "start").length, o = t.filter(([, r]) => r.type === "end").length;
220
+ const t = Object.entries(n.nodes), s = t.filter(([, r]) => r.type === "start").length, i = t.filter(([, r]) => r.type === "end").length;
221
221
  s !== 1 && e.addIssue({
222
222
  code: "custom",
223
223
  message: `Diagram must have exactly one start node (found ${s}).`,
224
224
  path: ["nodes"]
225
- }), o !== 1 && e.addIssue({
225
+ }), i !== 1 && e.addIssue({
226
226
  code: "custom",
227
- message: `Diagram must have exactly one end node (found ${o}).`,
227
+ message: `Diagram must have exactly one end node (found ${i}).`,
228
228
  path: ["nodes"]
229
229
  });
230
- const i = {};
230
+ const o = {};
231
231
  for (const [r, d] of Object.entries(n.edges))
232
- i[d.from] ??= [], i[d.from].push({ edgeId: r, toKey: d.to });
232
+ o[d.from] ??= [], o[d.from].push({ edgeId: r, toKey: d.to });
233
233
  for (const [r, d] of t) {
234
- const l = i[r] ?? [];
234
+ const l = o[r] ?? [];
235
235
  d.type === "automation" && (l.length !== 1 ? e.addIssue({
236
236
  code: "custom",
237
237
  message: `automation node must have exactly one outgoing edge (found ${l.length}).`,
@@ -344,10 +344,10 @@ const Ye = a.enum([
344
344
  message: "predecessorId cannot reference the deliverable itself.",
345
345
  path: ["predecessorId"]
346
346
  }), Le = a.object({
347
- key: a.string().min(1).describe("Variable name referenced in effect handlers as config.KEY."),
348
- description: a.string().optional(),
349
- secret: a.boolean().optional()
350
- }).describe("A runtime configuration entry for effect and automation handlers. Used to store credentials, endpoints, or other runtime settings without hardcoding them."), Ue = a.object({
347
+ key: a.string().min(1),
348
+ description: a.string().min(1).describe("Describe what this variable holds and which service it belongs to."),
349
+ sensitive: a.boolean().optional()
350
+ }).describe("A runtime configuration entry for handlers. Used to store credentials, endpoints, or other runtime settings without hardcoding them."), Ue = a.object({
351
351
  id: a.string().min(1).describe('Human-readable slug, e.g. "google-sheet"'),
352
352
  name: a.string().min(1),
353
353
  description: a.string().min(1).describe("Describe what external data this fetches, from where, and what format it returns: which service or API it calls, what credentials it needs, and the shape of the raw payload it returns so the runtime developer and adapter author know what to expect."),
@@ -423,24 +423,24 @@ function Tt(n, e) {
423
423
  return Rt;
424
424
  }
425
425
  function x(n, e, t) {
426
- const s = t?.delimiter ?? $t, o = Tt(n, t);
427
- return new RegExp(o).test(e) ? e.includes(s) ? `"${e}" contains the naming delimiter "${s}"` : null : `"${e}" does not match naming pattern ${o} for token "${n}"`;
426
+ const s = t?.delimiter ?? $t, i = Tt(n, t);
427
+ 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}"`;
428
428
  }
429
429
  function At(n, e) {
430
- const t = [], s = (o, i) => {
431
- const r = x(o, i, e);
430
+ const t = [], s = (i, o) => {
431
+ const r = x(i, o, e);
432
432
  r && t.push(r);
433
433
  };
434
434
  s("project", n.project.code);
435
- for (const o of n.teams) s("team", o.id);
436
- for (const o of n.disciplines) s("discipline", o.id);
437
- for (const o of n.assetTypes) s("assetType", o.id);
438
- for (const o of n.lbs) s(o.type === "zone" ? "lbsZone" : "lbsLocation", o.id);
435
+ for (const i of n.teams) s("team", i.id);
436
+ for (const i of n.disciplines) s("discipline", i.id);
437
+ for (const i of n.assetTypes) s("assetType", i.id);
438
+ for (const i of n.lbs) s(i.type === "zone" ? "lbsZone" : "lbsLocation", i.id);
439
439
  return t;
440
440
  }
441
441
  class jt {
442
- constructor(e, t, s, o, i) {
443
- this.getItem = e, this.setItem = t, this.schema = s, this.validate = o, this.getBep = i;
442
+ constructor(e, t, s, i, o) {
443
+ this.getItem = e, this.setItem = t, this.schema = s, this.validate = i, this.getBep = o;
444
444
  }
445
445
  getItem;
446
446
  setItem;
@@ -500,20 +500,20 @@ const Je = [
500
500
  { entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
501
501
  ];
502
502
  function Ot(n, e, t) {
503
- return Je.filter((s) => s.references === e).flatMap((s) => t[s.entity].filter((i) => {
504
- const r = i[s.inField];
503
+ return Je.filter((s) => s.references === e).flatMap((s) => t[s.entity].filter((o) => {
504
+ const r = o[s.inField];
505
505
  return s.array ? Array.isArray(r) && r.includes(n) : r === n;
506
- }).map((i) => {
507
- const r = i.id ?? i.email ?? "?";
506
+ }).map((o) => {
507
+ const r = o.id ?? o.email ?? "?";
508
508
  return `${String(s.entity)}["${r}"].${String(s.inField)}`;
509
509
  }));
510
510
  }
511
511
  function ae(n, e, t) {
512
512
  return Je.filter((s) => s.entity === e).flatMap((s) => {
513
- const o = n[s.inField];
514
- if (o == null || o === "") return [];
515
- const i = s.array ? o : [o], r = t[s.references];
516
- return i.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(s.references)}["${d}"] not found`);
513
+ const i = n[s.inField];
514
+ if (i == null || i === "") return [];
515
+ const o = s.array ? i : [i], r = t[s.references];
516
+ return o.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(s.references)}["${d}"] not found`);
517
517
  });
518
518
  }
519
519
  function K(n) {
@@ -535,20 +535,20 @@ class y {
535
535
  }
536
536
  get(e) {
537
537
  const t = [], s = [];
538
- for (const o of e) {
539
- const i = this.getItems().find((r) => this.getId(r) === o);
540
- i ? t.push(i) : s.push({ id: o, error: `Not found: ${o}` });
538
+ for (const i of e) {
539
+ const o = this.getItems().find((r) => this.getId(r) === i);
540
+ o ? t.push(o) : s.push({ id: i, error: `Not found: ${i}` });
541
541
  }
542
542
  return { succeeded: t, failed: s };
543
543
  }
544
544
  add(e) {
545
545
  const t = [], s = [];
546
- for (const o of e) {
547
- const i = { ...o };
548
- this.config.autoId && !i[this.idField] && (i[this.idField] = globalThis.crypto.randomUUID());
549
- const r = String(i[this.idField] ?? "(unknown)");
546
+ for (const i of e) {
547
+ const o = { ...i };
548
+ this.config.autoId && !o[this.idField] && (o[this.idField] = globalThis.crypto.randomUUID());
549
+ const r = String(o[this.idField] ?? "(unknown)");
550
550
  try {
551
- const d = this.config.schema.parse(i);
551
+ const d = this.config.schema.parse(o);
552
552
  if (this.getItems().some((u) => this.getId(u) === this.getId(d)))
553
553
  throw new Error(`Already exists: ${this.getId(d)}`);
554
554
  const l = ae(d, this.config.key, this.getBep());
@@ -564,41 +564,41 @@ class y {
564
564
  }
565
565
  update(e) {
566
566
  const t = [], s = [];
567
- for (const o of e) {
568
- const i = String(o[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === i);
567
+ for (const i of e) {
568
+ const o = String(i[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === o);
569
569
  if (d === -1) {
570
- s.push({ id: i, error: `Not found: ${i}` });
570
+ s.push({ id: o, error: `Not found: ${o}` });
571
571
  continue;
572
572
  }
573
- const l = ae(o, this.config.key, this.getBep());
573
+ const l = ae(i, this.config.key, this.getBep());
574
574
  if (l.length) {
575
- s.push({ id: i, error: l.join("; ") });
575
+ s.push({ id: o, error: l.join("; ") });
576
576
  continue;
577
577
  }
578
578
  try {
579
- const c = this.config.schema.parse({ ...r[d], ...o }), u = this.config.validate?.(c, this.getBep()) ?? [];
579
+ const c = this.config.schema.parse({ ...r[d], ...i }), u = this.config.validate?.(c, this.getBep()) ?? [];
580
580
  if (u.length) throw new Error(u.join("; "));
581
581
  r[d] = c, t.push(r[d]);
582
582
  } catch (c) {
583
- s.push({ id: i, error: K(c) });
583
+ s.push({ id: o, error: K(c) });
584
584
  }
585
585
  }
586
586
  return { succeeded: t, failed: s };
587
587
  }
588
588
  remove(e) {
589
589
  const t = [], s = [];
590
- for (const o of e) {
591
- const i = this.getItems(), r = i.findIndex((d) => this.getId(d) === o);
590
+ for (const i of e) {
591
+ const o = this.getItems(), r = o.findIndex((d) => this.getId(d) === i);
592
592
  if (r === -1) {
593
- s.push({ id: o, error: `Not found: ${o}` });
593
+ s.push({ id: i, error: `Not found: ${i}` });
594
594
  continue;
595
595
  }
596
596
  try {
597
- const d = Ot(o, this.config.key, this.getBep());
597
+ const d = Ot(i, this.config.key, this.getBep());
598
598
  if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
599
- this.config.beforeRemove?.(o, this.getBep()), i.splice(r, 1), t.push(o);
599
+ this.config.beforeRemove?.(i, this.getBep()), o.splice(r, 1), t.push(i);
600
600
  } catch (d) {
601
- s.push({ id: o, error: K(d) });
601
+ s.push({ id: i, error: K(d) });
602
602
  }
603
603
  }
604
604
  return { succeeded: t, failed: s };
@@ -614,10 +614,10 @@ class _t extends y {
614
614
  schema: ke,
615
615
  autoId: !0,
616
616
  beforeRemove: (t, s) => {
617
- for (const o of s.workflows)
618
- for (const [i, r] of Object.entries(o.diagram.nodes))
617
+ for (const i of s.workflows)
618
+ for (const [o, r] of Object.entries(i.diagram.nodes))
619
619
  if (r.type === "process" && r.actionId === t)
620
- throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].actionId`);
620
+ throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].actionId`);
621
621
  }
622
622
  }
623
623
  );
@@ -657,13 +657,13 @@ class xt extends y {
657
657
  key: "effects",
658
658
  schema: Re,
659
659
  beforeRemove: (t, s) => {
660
- for (const o of s.workflows) {
661
- for (const [i, r] of Object.entries(o.diagram.nodes))
660
+ for (const i of s.workflows) {
661
+ for (const [o, r] of Object.entries(i.diagram.nodes))
662
662
  if ((r.type === "process" || r.type === "automation") && r.timeouts?.some((d) => d.effectId === t))
663
- throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].timeouts[].effectId`);
664
- for (const [i, r] of Object.entries(o.diagram.edges))
663
+ throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].timeouts[].effectId`);
664
+ for (const [o, r] of Object.entries(i.diagram.edges))
665
665
  if (r.effectIds?.includes(t))
666
- throw new Error(`Referenced by: workflows["${o.id}"].diagram.edges["${i}"].effectIds`);
666
+ throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].effectIds`);
667
667
  }
668
668
  }
669
669
  }
@@ -679,10 +679,10 @@ class Pt extends y {
679
679
  key: "automations",
680
680
  schema: Te,
681
681
  beforeRemove: (t, s) => {
682
- for (const o of s.workflows)
683
- for (const [i, r] of Object.entries(o.diagram.nodes))
682
+ for (const i of s.workflows)
683
+ for (const [o, r] of Object.entries(i.diagram.nodes))
684
684
  if (r.type === "automation" && r.automationId === t)
685
- throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].automationId`);
685
+ throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].automationId`);
686
686
  }
687
687
  }
688
688
  );
@@ -710,10 +710,10 @@ class Ct extends y {
710
710
  key: "events",
711
711
  schema: $e,
712
712
  beforeRemove: (t, s) => {
713
- for (const o of s.workflows)
714
- for (const [i, r] of Object.entries(o.diagram.edges))
713
+ for (const i of s.workflows)
714
+ for (const [o, r] of Object.entries(i.diagram.edges))
715
715
  if ("triggerEventId" in r && r.triggerEventId === t)
716
- throw new Error(`Referenced by: workflows["${o.id}"].diagram.edges["${i}"].trigger`);
716
+ throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].trigger`);
717
717
  }
718
718
  }
719
719
  );
@@ -734,19 +734,19 @@ function te(n) {
734
734
  }
735
735
  function Ke(n, e) {
736
736
  if (!n) return { zoneCode: "XXX", locationCode: "XXX" };
737
- const t = new Map(e.map((d) => [d.id, d])), s = C(e), o = te(e), i = t.get(n);
738
- if (!i) return { zoneCode: "XXX", locationCode: "XXX" };
739
- if (o.has(i.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
740
- if (i.type === "zone") return { zoneCode: i.id, locationCode: "ZZZ" };
741
- let r = s.get(i.id);
737
+ const t = new Map(e.map((d) => [d.id, d])), s = C(e), i = te(e), o = t.get(n);
738
+ if (!o) return { zoneCode: "XXX", locationCode: "XXX" };
739
+ if (i.has(o.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
740
+ if (o.type === "zone") return { zoneCode: o.id, locationCode: "ZZZ" };
741
+ let r = s.get(o.id);
742
742
  for (; r; ) {
743
743
  const d = t.get(r);
744
744
  if (!d) break;
745
- if (d.type === "zone" && !o.has(d.id))
746
- return { zoneCode: d.id, locationCode: i.id };
745
+ if (d.type === "zone" && !i.has(d.id))
746
+ return { zoneCode: d.id, locationCode: o.id };
747
747
  r = s.get(r);
748
748
  }
749
- return { zoneCode: "ZZZ", locationCode: i.id };
749
+ return { zoneCode: "ZZZ", locationCode: o.id };
750
750
  }
751
751
  function Dt(n) {
752
752
  const e = [], t = new Map(n.map((d) => [d.id, d])), s = te(n);
@@ -758,36 +758,36 @@ function Dt(n) {
758
758
  if (d.type === "location")
759
759
  for (const l of d.lbsNodeIds ?? [])
760
760
  t.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
761
- const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
761
+ const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
762
762
  function r(d) {
763
- if (i.has(d)) return !0;
764
- if (o.has(d)) return !1;
765
- o.add(d), i.add(d);
763
+ if (o.has(d)) return !0;
764
+ if (i.has(d)) return !1;
765
+ i.add(d), o.add(d);
766
766
  for (const l of t.get(d)?.lbsNodeIds ?? [])
767
767
  if (r(l))
768
768
  return e.push(`Cycle detected in LBS tree at node "${d}".`), !0;
769
- return i.delete(d), !1;
769
+ return o.delete(d), !1;
770
770
  }
771
771
  for (const d of n)
772
- o.has(d.id) || r(d.id);
772
+ i.has(d.id) || r(d.id);
773
773
  return e;
774
774
  }
775
775
  function W(n) {
776
776
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
777
777
  for (const s of n) {
778
- const o = (t.get(s.responsibleId) ?? 0) + 1;
779
- t.set(s.responsibleId, o), e.set(s.id, o);
778
+ const i = (t.get(s.responsibleId) ?? 0) + 1;
779
+ t.set(s.responsibleId, i), e.set(s.id, i);
780
780
  }
781
781
  return e;
782
782
  }
783
783
  const F = "XXX";
784
- function qe(n, e, t, s, o) {
785
- const { zoneCode: i, locationCode: r } = Ke(n.lbsNodeId, s);
786
- if (!o) {
784
+ function qe(n, e, t, s, i) {
785
+ const { zoneCode: o, locationCode: r } = Ke(n.lbsNodeId, s);
786
+ if (!i) {
787
787
  const l = String(t.get(n.id) ?? 0).padStart(3, "0");
788
- return [e, n.responsibleId, i, r, n.assetTypeId, n.disciplineId, l].join("-");
788
+ return [e, n.responsibleId, o, r, n.assetTypeId, n.disciplineId, l].join("-");
789
789
  }
790
- return o.segments.map((l) => {
790
+ return i.segments.map((l) => {
791
791
  if (l.type === "sequence") {
792
792
  const c = l.padding ?? 3;
793
793
  return String(t.get(n.id) ?? 0).padStart(c, "0");
@@ -802,17 +802,17 @@ function qe(n, e, t, s, o) {
802
802
  case "assetType":
803
803
  return n.assetTypeId || F;
804
804
  case "lbsZone":
805
- return i;
805
+ return o;
806
806
  case "lbsLocation":
807
807
  return r;
808
808
  }
809
- }).join(o.delimiter);
809
+ }).join(i.delimiter);
810
810
  }
811
811
  function We(n, e, t, s) {
812
- const o = W(n);
813
- return new Map(n.map((i) => [
814
- i.id,
815
- qe(i, e, o, t, s)
812
+ const i = W(n);
813
+ return new Map(n.map((o) => [
814
+ o.id,
815
+ qe(o, e, i, t, s)
816
816
  ]));
817
817
  }
818
818
  class Lt {
@@ -829,10 +829,10 @@ class Lt {
829
829
  * Returns null if the deliverable id is not found.
830
830
  */
831
831
  getCode(e) {
832
- const t = this.getBep(), s = t.deliverables.find((i) => i.id === e);
832
+ const t = this.getBep(), s = t.deliverables.find((o) => o.id === e);
833
833
  if (!s) return null;
834
- const o = W(t.deliverables);
835
- return qe(s, t.project.code, o, t.lbs, t.deliverableNamingConvention);
834
+ const i = W(t.deliverables);
835
+ return qe(s, t.project.code, i, t.lbs, t.deliverableNamingConvention);
836
836
  }
837
837
  /** Builds the complete map of deliverable.id → nomenclature code. */
838
838
  buildCodeMap() {
@@ -841,7 +841,7 @@ class Lt {
841
841
  }
842
842
  }
843
843
  class Ut extends y {
844
- constructor(e, t, s, o, i) {
844
+ constructor(e, t, s, i, o) {
845
845
  super(
846
846
  () => e().deliverables,
847
847
  e,
@@ -850,24 +850,24 @@ class Ut extends y {
850
850
  schema: De,
851
851
  autoId: !0
852
852
  }
853
- ), this.getTeams = t, this.getAssetTypes = s, this.getLBSNodes = o, this.getMilestones = i;
853
+ ), this.getTeams = t, this.getAssetTypes = s, this.getLBSNodes = i, this.getMilestones = o;
854
854
  }
855
855
  getTeams;
856
856
  getAssetTypes;
857
857
  getLBSNodes;
858
858
  getMilestones;
859
859
  listResolved() {
860
- const e = this.getBep(), t = We(e.deliverables, e.project.code, e.lbs), s = new Map(this.getTeams().listResolved().map((l) => [l.id, l])), o = new Map(this.getAssetTypes().listResolved().map((l) => [l.id, l])), i = new Map(this.getLBSNodes().listResolved().map((l) => [l.id, l])), r = new Map(this.getMilestones().listResolved().map((l) => [l.id, l])), d = /* @__PURE__ */ new Map();
860
+ const e = this.getBep(), t = We(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])), r = new Map(this.getMilestones().listResolved().map((l) => [l.id, l])), d = /* @__PURE__ */ new Map();
861
861
  for (const l of e.deliverables) {
862
862
  const c = r.get(l.milestoneId) ?? null;
863
863
  d.set(l.id, {
864
864
  ...l,
865
865
  nomenclatureCode: t.get(l.id) ?? "",
866
866
  effectiveDate: l.dueDate ?? c?.date ?? "",
867
- lbsNode: l.lbsNodeId ? i.get(l.lbsNodeId) ?? null : null,
867
+ lbsNode: l.lbsNodeId ? o.get(l.lbsNodeId) ?? null : null,
868
868
  discipline: e.disciplines.find((u) => u.id === l.disciplineId) ?? null,
869
- assetType: o.get(l.assetTypeId) ?? null,
870
- extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((f) => f.id === u)).filter(Boolean),
869
+ assetType: i.get(l.assetTypeId) ?? null,
870
+ extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((m) => m.id === u)).filter(Boolean),
871
871
  responsible: s.get(l.responsibleId) ?? null,
872
872
  milestone: c,
873
873
  predecessor: null
@@ -924,15 +924,15 @@ class Jt extends y {
924
924
  key: "bimUses",
925
925
  schema: Se,
926
926
  autoId: !0,
927
- validate: (s, o) => {
928
- const i = [];
927
+ validate: (s, i) => {
928
+ const o = [];
929
929
  for (const r of s.objectiveIds ?? [])
930
- o.objectives.some((d) => d.id === r) || i.push(`objectives["${r}"] not found`);
930
+ i.objectives.some((d) => d.id === r) || o.push(`objectives["${r}"] not found`);
931
931
  for (const r of s.milestoneIds ?? [])
932
- o.milestones.some((d) => d.id === r) || i.push(`milestones["${r}"] not found`);
932
+ i.milestones.some((d) => d.id === r) || o.push(`milestones["${r}"] not found`);
933
933
  for (const r of s.workflowIds ?? [])
934
- o.workflows.some((d) => d.id === r) || i.push(`workflows["${r}"] not found`);
935
- return i;
934
+ i.workflows.some((d) => d.id === r) || o.push(`workflows["${r}"] not found`);
935
+ return o;
936
936
  }
937
937
  }
938
938
  ), this.getWorkflows = t;
@@ -942,12 +942,12 @@ class Jt extends y {
942
942
  const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((s) => [s.id, s]));
943
943
  return e.bimUses.map((s) => ({
944
944
  ...s,
945
- objectives: (s.objectiveIds ?? []).map((o) => e.objectives.find((i) => i.id === o)).filter(Boolean),
946
- milestones: (s.milestoneIds ?? []).map((o) => {
947
- const i = e.milestones.find((r) => r.id === o);
948
- return i ? { ...i, phase: e.phases.find((r) => r.id === i.phaseId) ?? null } : null;
945
+ objectives: (s.objectiveIds ?? []).map((i) => e.objectives.find((o) => o.id === i)).filter(Boolean),
946
+ milestones: (s.milestoneIds ?? []).map((i) => {
947
+ const o = e.milestones.find((r) => r.id === i);
948
+ return o ? { ...o, phase: e.phases.find((r) => r.id === o.phaseId) ?? null } : null;
949
949
  }).filter(Boolean),
950
- workflows: (s.workflowIds ?? []).map((o) => t.get(o)).filter(Boolean)
950
+ workflows: (s.workflowIds ?? []).map((i) => t.get(i)).filter(Boolean)
951
951
  }));
952
952
  }
953
953
  }
@@ -960,8 +960,8 @@ class Kt extends y {
960
960
  key: "disciplines",
961
961
  schema: we,
962
962
  validate: (t, s) => {
963
- const o = x("discipline", t.id, s.deliverableNamingConvention);
964
- return o ? [o] : [];
963
+ const i = x("discipline", t.id, s.deliverableNamingConvention);
964
+ return i ? [i] : [];
965
965
  }
966
966
  }
967
967
  );
@@ -983,7 +983,7 @@ class qt extends y {
983
983
  const e = this.getBep();
984
984
  return e.guides.map((t) => ({
985
985
  ...t,
986
- annexes: (t.annexIds ?? []).map((s) => e.annexes.find((o) => o.id === s)).filter(Boolean)
986
+ annexes: (t.annexIds ?? []).map((s) => e.annexes.find((i) => i.id === s)).filter(Boolean)
987
987
  }));
988
988
  }
989
989
  }
@@ -996,8 +996,8 @@ class Wt extends y {
996
996
  key: "lods",
997
997
  schema: Me,
998
998
  beforeRemove: (t, s) => {
999
- for (const o of s.loin)
1000
- if (o.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[lodId=${t}]`);
999
+ for (const i of s.loin)
1000
+ if (i.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${t}]`);
1001
1001
  }
1002
1002
  }
1003
1003
  );
@@ -1012,14 +1012,14 @@ class Gt extends y {
1012
1012
  key: "lois",
1013
1013
  schema: xe,
1014
1014
  beforeRemove: (t, s) => {
1015
- for (const o of s.loin)
1016
- if (o.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[loiId=${t}]`);
1015
+ for (const i of s.loin)
1016
+ if (i.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[loiId=${t}]`);
1017
1017
  }
1018
1018
  }
1019
1019
  );
1020
1020
  }
1021
1021
  }
1022
- class Vt extends y {
1022
+ class Xt extends y {
1023
1023
  constructor(e) {
1024
1024
  super(
1025
1025
  () => e().loin,
@@ -1029,64 +1029,64 @@ class Vt extends y {
1029
1029
  schema: Pe,
1030
1030
  autoId: !0,
1031
1031
  validate: (t, s) => {
1032
- const o = [];
1033
- for (const i of t.milestones ?? [])
1034
- s.milestones.some((r) => r.id === i.milestoneId) || o.push(`milestones["${i.milestoneId}"] not found`), s.lods.some((r) => r.id === i.lodId) || o.push(`lods[${i.lodId}] not found`), s.lois.some((r) => r.id === i.loiId) || o.push(`lois[${i.loiId}] not found`);
1035
- return o;
1032
+ const i = [];
1033
+ for (const o of t.milestones ?? [])
1034
+ s.milestones.some((r) => r.id === o.milestoneId) || i.push(`milestones["${o.milestoneId}"] not found`), s.lods.some((r) => r.id === o.lodId) || i.push(`lods[${o.lodId}] not found`), s.lois.some((r) => r.id === o.loiId) || i.push(`lois[${o.loiId}] not found`);
1035
+ return i;
1036
1036
  }
1037
1037
  }
1038
1038
  );
1039
1039
  }
1040
1040
  addMilestones(e) {
1041
1041
  const t = [], s = [];
1042
- for (const o of e) {
1043
- const i = this.getBep().loin.find((c) => c.id === o.loinId);
1044
- if (!i) {
1045
- s.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
1042
+ for (const i of e) {
1043
+ const o = this.getBep().loin.find((c) => c.id === i.loinId);
1044
+ if (!o) {
1045
+ s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1046
1046
  continue;
1047
1047
  }
1048
- const r = o.milestones.find((c) => (i.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
1048
+ const r = i.milestones.find((c) => (o.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
1049
1049
  if (r) {
1050
- s.push({ loinId: o.loinId, error: `Milestone "${r.milestoneId}" already exists. Use updateMilestones to modify it.` });
1050
+ s.push({ loinId: i.loinId, error: `Milestone "${r.milestoneId}" already exists. Use updateMilestones to modify it.` });
1051
1051
  continue;
1052
1052
  }
1053
- const d = [...i.milestones ?? [], ...o.milestones], l = this.update([{ id: o.loinId, milestones: d }]);
1053
+ const d = [...o.milestones ?? [], ...i.milestones], l = this.update([{ id: i.loinId, milestones: d }]);
1054
1054
  if (l.failed.length > 0) {
1055
- s.push({ loinId: o.loinId, error: l.failed[0].error });
1055
+ s.push({ loinId: i.loinId, error: l.failed[0].error });
1056
1056
  continue;
1057
1057
  }
1058
- t.push({ loinId: o.loinId, element: i.element, addedMilestones: o.milestones.map((c) => c.milestoneId) });
1058
+ t.push({ loinId: i.loinId, element: o.element, addedMilestones: i.milestones.map((c) => c.milestoneId) });
1059
1059
  }
1060
1060
  return { succeeded: t, failed: s };
1061
1061
  }
1062
1062
  updateMilestones(e) {
1063
1063
  const t = [], s = [];
1064
- for (const o of e) {
1065
- const i = this.getBep().loin.find((f) => f.id === o.loinId);
1066
- if (!i) {
1067
- s.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
1064
+ for (const i of e) {
1065
+ const o = this.getBep().loin.find((m) => m.id === i.loinId);
1066
+ if (!o) {
1067
+ s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1068
1068
  continue;
1069
1069
  }
1070
- const r = o.milestones.find((f) => !(i.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
1070
+ const r = i.milestones.find((m) => !(o.milestones ?? []).some((f) => f.milestoneId === m.milestoneId));
1071
1071
  if (r) {
1072
- s.push({ loinId: o.loinId, error: `Milestone "${r.milestoneId}" not found. Use addMilestones to create it.` });
1072
+ s.push({ loinId: i.loinId, error: `Milestone "${r.milestoneId}" not found. Use addMilestones to create it.` });
1073
1073
  continue;
1074
1074
  }
1075
- const d = new Map(i.milestones.map((f) => [f.milestoneId, { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath }])), l = (i.milestones ?? []).map((f) => {
1076
- const m = o.milestones.find((p) => p.milestoneId === f.milestoneId);
1077
- return m ? { ...f, ...m } : f;
1078
- }), c = this.update([{ id: o.loinId, milestones: l }]);
1075
+ const d = new Map(o.milestones.map((m) => [m.milestoneId, { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath }])), l = (o.milestones ?? []).map((m) => {
1076
+ const f = i.milestones.find((p) => p.milestoneId === m.milestoneId);
1077
+ return f ? { ...m, ...f } : m;
1078
+ }), c = this.update([{ id: i.loinId, milestones: l }]);
1079
1079
  if (c.failed.length > 0) {
1080
- s.push({ loinId: o.loinId, error: c.failed[0].error });
1080
+ s.push({ loinId: i.loinId, error: c.failed[0].error });
1081
1081
  continue;
1082
1082
  }
1083
- const u = this.getBep().loin.find((f) => f.id === o.loinId);
1083
+ const u = this.getBep().loin.find((m) => m.id === i.loinId);
1084
1084
  t.push({
1085
- loinId: o.loinId,
1086
- element: i.element,
1087
- milestones: o.milestones.map((f) => {
1088
- const m = u.milestones.find((g) => g.milestoneId === f.milestoneId), p = d.get(f.milestoneId);
1089
- return { milestoneId: f.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
1085
+ loinId: i.loinId,
1086
+ element: o.element,
1087
+ milestones: i.milestones.map((m) => {
1088
+ const f = u.milestones.find((g) => g.milestoneId === m.milestoneId), p = d.get(m.milestoneId);
1089
+ return { milestoneId: m.milestoneId, before: p, after: { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath } };
1090
1090
  })
1091
1091
  });
1092
1092
  }
@@ -1094,18 +1094,18 @@ class Vt extends y {
1094
1094
  }
1095
1095
  removeMilestones(e) {
1096
1096
  const t = [], s = [];
1097
- for (const o of e) {
1098
- const i = this.getBep().loin.find((d) => d.id === o.loinId);
1099
- if (!i) {
1100
- s.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
1097
+ for (const i of e) {
1098
+ const o = this.getBep().loin.find((d) => d.id === i.loinId);
1099
+ if (!o) {
1100
+ s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1101
1101
  continue;
1102
1102
  }
1103
- const r = o.milestoneIds.filter((d) => !(i.milestones ?? []).some((l) => l.milestoneId === d));
1103
+ const r = i.milestoneIds.filter((d) => !(o.milestones ?? []).some((l) => l.milestoneId === d));
1104
1104
  if (r.length > 0) {
1105
- s.push({ loinId: o.loinId, error: `Milestones not found in this LOIN: ${r.join(", ")}` });
1105
+ s.push({ loinId: i.loinId, error: `Milestones not found in this LOIN: ${r.join(", ")}` });
1106
1106
  continue;
1107
1107
  }
1108
- i.milestones = (i.milestones ?? []).filter((d) => !o.milestoneIds.includes(d.milestoneId)), t.push({ loinId: o.loinId, element: i.element, removedMilestones: o.milestoneIds });
1108
+ o.milestones = (o.milestones ?? []).filter((d) => !i.milestoneIds.includes(d.milestoneId)), t.push({ loinId: i.loinId, element: o.element, removedMilestones: i.milestoneIds });
1109
1109
  }
1110
1110
  return { succeeded: t, failed: s };
1111
1111
  }
@@ -1116,14 +1116,14 @@ class Vt extends y {
1116
1116
  discipline: e.disciplines.find((s) => s.id === t.disciplineId) ?? null,
1117
1117
  milestones: (t.milestones ?? []).map((s) => ({
1118
1118
  ...s,
1119
- milestone: e.milestones.find((o) => o.id === s.milestoneId) ?? null,
1120
- lod: e.lods.find((o) => o.id === s.lodId) ?? null,
1121
- loi: e.lois.find((o) => o.id === s.loiId) ?? null
1119
+ milestone: e.milestones.find((i) => i.id === s.milestoneId) ?? null,
1120
+ lod: e.lods.find((i) => i.id === s.lodId) ?? null,
1121
+ loi: e.lois.find((i) => i.id === s.loiId) ?? null
1122
1122
  }))
1123
1123
  }));
1124
1124
  }
1125
1125
  }
1126
- class Xt extends y {
1126
+ class Vt extends y {
1127
1127
  constructor(e) {
1128
1128
  super(
1129
1129
  () => e().assetTypes,
@@ -1132,8 +1132,8 @@ class Xt extends y {
1132
1132
  key: "assetTypes",
1133
1133
  schema: Ie,
1134
1134
  validate: (t, s) => {
1135
- const o = x("assetType", t.id, s.deliverableNamingConvention);
1136
- return o ? [o] : [];
1135
+ const i = x("assetType", t.id, s.deliverableNamingConvention);
1136
+ return i ? [i] : [];
1137
1137
  }
1138
1138
  }
1139
1139
  );
@@ -1142,7 +1142,7 @@ class Xt extends y {
1142
1142
  const e = this.getBep();
1143
1143
  return e.assetTypes.map((t) => ({
1144
1144
  ...t,
1145
- extensions: (t.extensionIds ?? []).map((s) => e.extensions.find((o) => o.id === s)).filter(Boolean)
1145
+ extensions: (t.extensionIds ?? []).map((s) => e.extensions.find((i) => i.id === s)).filter(Boolean)
1146
1146
  }));
1147
1147
  }
1148
1148
  }
@@ -1168,13 +1168,13 @@ class Yt extends y {
1168
1168
  schema: ue,
1169
1169
  autoId: !0,
1170
1170
  beforeRemove: (t, s) => {
1171
- const o = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
1172
- for (const i of s.workflows)
1173
- for (const [r, d] of Object.entries(i.diagram.nodes))
1171
+ const i = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
1172
+ for (const o of s.workflows)
1173
+ for (const [r, d] of Object.entries(o.diagram.nodes))
1174
1174
  if (d.type === "process") {
1175
- for (const l of o)
1175
+ for (const l of i)
1176
1176
  if (d[l]?.includes(t))
1177
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${r}"].${l}`);
1177
+ throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${r}"].${l}`);
1178
1178
  }
1179
1179
  }
1180
1180
  }
@@ -1190,98 +1190,98 @@ class Qt extends y {
1190
1190
  key: "lbs",
1191
1191
  schema: be,
1192
1192
  validate: (t, s) => {
1193
- const o = [], i = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(i, t.id, s.deliverableNamingConvention);
1194
- if (r && o.push(r), t.type === "location" && t.lbsNodeIds?.length) {
1193
+ const i = [], o = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(o, t.id, s.deliverableNamingConvention);
1194
+ if (r && i.push(r), t.type === "location" && t.lbsNodeIds?.length) {
1195
1195
  const d = new Map(s.lbs.map((l) => [l.id, l]));
1196
1196
  for (const l of t.lbsNodeIds ?? [])
1197
- d.get(l)?.type === "zone" && o.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
1197
+ d.get(l)?.type === "zone" && i.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
1198
1198
  }
1199
- return o;
1199
+ return i;
1200
1200
  }
1201
1201
  }
1202
1202
  );
1203
1203
  }
1204
1204
  listResolved() {
1205
- const e = this.getBep(), t = C(e.lbs), s = te(e.lbs), o = new Map(e.lbs.map((i) => [i.id, i]));
1206
- return e.lbs.map((i) => {
1207
- const r = t.get(i.id), d = r ? o.get(r) : void 0;
1205
+ const e = this.getBep(), t = C(e.lbs), s = te(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1206
+ return e.lbs.map((o) => {
1207
+ const r = t.get(o.id), d = r ? i.get(r) : void 0;
1208
1208
  return {
1209
- ...i,
1210
- isRoot: s.has(i.id),
1209
+ ...o,
1210
+ isRoot: s.has(o.id),
1211
1211
  parent: d ? { id: d.id, name: d.name, type: d.type } : null,
1212
- children: (i.lbsNodeIds ?? []).map((l) => o.get(l)).filter(Boolean)
1212
+ children: (o.lbsNodeIds ?? []).map((l) => i.get(l)).filter(Boolean)
1213
1213
  };
1214
1214
  });
1215
1215
  }
1216
1216
  addNodes(e) {
1217
- const t = this.getBep(), s = [], o = [];
1218
- for (const i of e) {
1219
- if (!i.parentId && i.type !== "zone") {
1220
- o.push({ input: i, error: 'Root nodes (no parentId) must be type "zone".' });
1217
+ const t = this.getBep(), s = [], i = [];
1218
+ for (const o of e) {
1219
+ if (!o.parentId && o.type !== "zone") {
1220
+ i.push({ input: o, error: 'Root nodes (no parentId) must be type "zone".' });
1221
1221
  continue;
1222
1222
  }
1223
- if (i.parentId && !t.lbs.find((f) => f.id === i.parentId)) {
1224
- o.push({ input: i, error: `No LBS node found with ID "${i.parentId}".` });
1223
+ if (o.parentId && !t.lbs.find((m) => m.id === o.parentId)) {
1224
+ i.push({ input: o, error: `No LBS node found with ID "${o.parentId}".` });
1225
1225
  continue;
1226
1226
  }
1227
- const { parentId: r, ...d } = i, l = this.add([d]);
1227
+ const { parentId: r, ...d } = o, l = this.add([d]);
1228
1228
  if (l.failed.length > 0) {
1229
- o.push({ input: i, error: l.failed[0].error });
1229
+ i.push({ input: o, error: l.failed[0].error });
1230
1230
  continue;
1231
1231
  }
1232
1232
  let c;
1233
- r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(i.id)));
1233
+ r && (c = t.lbs.find((m) => m.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
1234
1234
  const u = this.validateTree();
1235
1235
  if (u.length > 0) {
1236
- t.lbs.splice(t.lbs.findIndex((f) => f.id === i.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((f) => f !== i.id)), o.push({ input: i, error: u.join("; ") });
1236
+ t.lbs.splice(t.lbs.findIndex((m) => m.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((m) => m !== o.id)), i.push({ input: o, error: u.join("; ") });
1237
1237
  continue;
1238
1238
  }
1239
- s.push({ ...t.lbs.find((f) => f.id === i.id), parentId: r ?? null });
1239
+ s.push({ ...t.lbs.find((m) => m.id === o.id), parentId: r ?? null });
1240
1240
  }
1241
- return { succeeded: s, failed: o };
1241
+ return { succeeded: s, failed: i };
1242
1242
  }
1243
1243
  updateNodes(e) {
1244
- const t = this.getBep(), s = [], o = [];
1245
- for (const i of e) {
1246
- if (i.parentId && !t.lbs.find((h) => h.id === i.parentId)) {
1247
- o.push({ id: i.id, error: `No LBS node found with ID "${i.parentId}".` });
1244
+ const t = this.getBep(), s = [], i = [];
1245
+ for (const o of e) {
1246
+ if (o.parentId && !t.lbs.find((h) => h.id === o.parentId)) {
1247
+ i.push({ id: o.id, error: `No LBS node found with ID "${o.parentId}".` });
1248
1248
  continue;
1249
1249
  }
1250
- if (i.parentId === i.id) {
1251
- o.push({ id: i.id, error: "A node cannot be its own parent." });
1250
+ if (o.parentId === o.id) {
1251
+ i.push({ id: o.id, error: "A node cannot be its own parent." });
1252
1252
  continue;
1253
1253
  }
1254
- const r = t.lbs.find((h) => h.id === i.id), d = C(t.lbs).get(i.id) ?? null, { parentId: l, ...c } = i, u = this.update([c]);
1254
+ const r = t.lbs.find((h) => h.id === o.id), d = C(t.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, u = this.update([c]);
1255
1255
  if (u.failed.length > 0) {
1256
- o.push({ id: i.id, error: u.failed[0].error });
1256
+ i.push({ id: o.id, error: u.failed[0].error });
1257
1257
  continue;
1258
1258
  }
1259
- const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id === i.id);
1259
+ const m = { name: r.name, type: r.type, description: r.description, parentId: d }, f = t.lbs.find((h) => h.id === o.id);
1260
1260
  if (l !== void 0) {
1261
1261
  for (const h of t.lbs)
1262
- h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== i.id));
1262
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
1263
1263
  if (l) {
1264
1264
  const h = t.lbs.find((b) => b.id === l);
1265
- h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id);
1265
+ h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id);
1266
1266
  }
1267
1267
  }
1268
1268
  const p = this.validateTree();
1269
1269
  if (p.length > 0) {
1270
- if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
1270
+ if (f.name = m.name, f.type = m.type, m.description !== void 0 ? f.description = m.description : delete f.description, l !== void 0) {
1271
1271
  for (const h of t.lbs)
1272
- h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== i.id));
1273
- if (f.parentId) {
1274
- const h = t.lbs.find((b) => b.id === f.parentId);
1275
- h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id));
1272
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
1273
+ if (m.parentId) {
1274
+ const h = t.lbs.find((b) => b.id === m.parentId);
1275
+ h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
1276
1276
  }
1277
1277
  }
1278
- o.push({ id: i.id, error: p.join("; ") });
1278
+ i.push({ id: o.id, error: p.join("; ") });
1279
1279
  continue;
1280
1280
  }
1281
- const g = C(t.lbs).get(m.id) ?? null;
1282
- s.push({ id: i.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1281
+ const g = C(t.lbs).get(f.id) ?? null;
1282
+ s.push({ id: o.id, before: m, after: { name: f.name, type: f.type, description: f.description, parentId: g } });
1283
1283
  }
1284
- return { succeeded: s, failed: o };
1284
+ return { succeeded: s, failed: i };
1285
1285
  }
1286
1286
  /** Resolves zone and location codes for nomenclature given a node id. */
1287
1287
  resolveCodes(e) {
@@ -1307,10 +1307,10 @@ class es extends y {
1307
1307
  listResolved() {
1308
1308
  const e = this.getBep();
1309
1309
  return e.members.map((t) => {
1310
- const s = e.teams.find((o) => (o.memberEmails ?? []).includes(t.email));
1310
+ const s = e.teams.find((i) => (i.memberEmails ?? []).includes(t.email));
1311
1311
  return {
1312
1312
  ...t,
1313
- role: e.roles.find((o) => o.id === t.roleId) ?? null,
1313
+ role: e.roles.find((i) => i.id === t.roleId) ?? null,
1314
1314
  team: s ? { id: s.id, name: s.name } : null,
1315
1315
  isRepresentative: s?.representativeEmail === t.email
1316
1316
  };
@@ -1318,66 +1318,66 @@ class es extends y {
1318
1318
  }
1319
1319
  addToTeam(e) {
1320
1320
  const t = [], s = [];
1321
- for (const o of e) {
1322
- const r = this.getBep().teams.find((m) => m.id === o.teamId);
1321
+ for (const i of e) {
1322
+ const r = this.getBep().teams.find((f) => f.id === i.teamId);
1323
1323
  if (!r) {
1324
- s.push({ input: o, error: `Team not found: ${o.teamId}` });
1324
+ s.push({ input: i, error: `Team not found: ${i.teamId}` });
1325
1325
  continue;
1326
1326
  }
1327
- const { teamId: d, isRepresentative: l, ...c } = o, u = this.add([c]);
1327
+ const { teamId: d, isRepresentative: l, ...c } = i, u = this.add([c]);
1328
1328
  if (u.failed.length > 0) {
1329
- s.push({ input: o, error: u.failed[0].error });
1329
+ s.push({ input: i, error: u.failed[0].error });
1330
1330
  continue;
1331
1331
  }
1332
- r.memberEmails ??= [], r.memberEmails.includes(o.email) || r.memberEmails.push(o.email), l && (r.representativeEmail = o.email);
1333
- const f = this.listResolved().find((m) => m.email === o.email);
1334
- t.push(f);
1332
+ r.memberEmails ??= [], r.memberEmails.includes(i.email) || r.memberEmails.push(i.email), l && (r.representativeEmail = i.email);
1333
+ const m = this.listResolved().find((f) => f.email === i.email);
1334
+ t.push(m);
1335
1335
  }
1336
1336
  return { succeeded: t, failed: s };
1337
1337
  }
1338
1338
  updateInTeam(e) {
1339
1339
  const t = [], s = [];
1340
- for (const o of e) {
1341
- const i = this.getBep(), { teamId: r, isRepresentative: d, ...l } = o;
1342
- if (r !== void 0 && !i.teams.find((f) => f.id === r)) {
1343
- s.push({ email: o.email, error: `Team not found: ${r}` });
1340
+ for (const i of e) {
1341
+ const o = this.getBep(), { teamId: r, isRepresentative: d, ...l } = i;
1342
+ if (r !== void 0 && !o.teams.find((m) => m.id === r)) {
1343
+ s.push({ email: i.email, error: `Team not found: ${r}` });
1344
1344
  continue;
1345
1345
  }
1346
1346
  const c = this.update([l]);
1347
1347
  if (c.failed.length > 0) {
1348
- s.push({ email: o.email, error: c.failed[0].error });
1348
+ s.push({ email: i.email, error: c.failed[0].error });
1349
1349
  continue;
1350
1350
  }
1351
1351
  if (r !== void 0) {
1352
- const f = i.teams.find((p) => p.id === r), m = i.teams.find((p) => (p.memberEmails ?? []).includes(o.email));
1353
- m && m.id !== r && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !== o.email), m.representativeEmail === o.email && (m.representativeEmail = void 0)), f.memberEmails ??= [], f.memberEmails.includes(o.email) || f.memberEmails.push(o.email);
1352
+ const m = o.teams.find((p) => p.id === r), f = o.teams.find((p) => (p.memberEmails ?? []).includes(i.email));
1353
+ f && f.id !== r && (f.memberEmails = (f.memberEmails ?? []).filter((p) => p !== i.email), f.representativeEmail === i.email && (f.representativeEmail = void 0)), m.memberEmails ??= [], m.memberEmails.includes(i.email) || m.memberEmails.push(i.email);
1354
1354
  }
1355
1355
  if (d !== void 0) {
1356
- const f = i.teams.find((m) => (m.memberEmails ?? []).includes(o.email));
1357
- f && (f.representativeEmail = d ? o.email : f.representativeEmail === o.email ? void 0 : f.representativeEmail);
1356
+ const m = o.teams.find((f) => (f.memberEmails ?? []).includes(i.email));
1357
+ m && (m.representativeEmail = d ? i.email : m.representativeEmail === i.email ? void 0 : m.representativeEmail);
1358
1358
  }
1359
- const u = this.listResolved().find((f) => f.email === o.email);
1360
- t.push({ email: o.email, after: u });
1359
+ const u = this.listResolved().find((m) => m.email === i.email);
1360
+ t.push({ email: i.email, after: u });
1361
1361
  }
1362
1362
  return { succeeded: t, failed: s };
1363
1363
  }
1364
1364
  removeFromBep(e) {
1365
1365
  const t = [], s = [];
1366
- for (const o of e) {
1367
- const i = this.getBep(), r = this.listResolved().find((l) => l.email === o);
1366
+ for (const i of e) {
1367
+ const o = this.getBep(), r = this.listResolved().find((l) => l.email === i);
1368
1368
  if (!r) {
1369
- s.push({ email: o, error: `Not found: ${o}` });
1369
+ s.push({ email: i, error: `Not found: ${i}` });
1370
1370
  continue;
1371
1371
  }
1372
- for (const l of i.teams)
1373
- l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== o)), l.representativeEmail === o && (l.representativeEmail = void 0);
1374
- const d = this.remove([o]);
1372
+ for (const l of o.teams)
1373
+ l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== i)), l.representativeEmail === i && (l.representativeEmail = void 0);
1374
+ const d = this.remove([i]);
1375
1375
  if (d.failed.length > 0) {
1376
1376
  if (r.team) {
1377
- const l = i.teams.find((c) => c.id === r.team.id);
1378
- l && (l.memberEmails ??= [], l.memberEmails.includes(o) || l.memberEmails.push(o), r.isRepresentative && (l.representativeEmail = o));
1377
+ const l = o.teams.find((c) => c.id === r.team.id);
1378
+ l && (l.memberEmails ??= [], l.memberEmails.includes(i) || l.memberEmails.push(i), r.isRepresentative && (l.representativeEmail = i));
1379
1379
  }
1380
- s.push({ email: o, error: d.failed[0].error });
1380
+ s.push({ email: i, error: d.failed[0].error });
1381
1381
  continue;
1382
1382
  }
1383
1383
  t.push(r);
@@ -1395,8 +1395,8 @@ class ts extends y {
1395
1395
  schema: ye,
1396
1396
  autoId: !0,
1397
1397
  beforeRemove: (t, s) => {
1398
- for (const o of s.loin)
1399
- if (o.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[milestoneId="${t}"]`);
1398
+ for (const i of s.loin)
1399
+ if (i.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[milestoneId="${t}"]`);
1400
1400
  }
1401
1401
  }
1402
1402
  );
@@ -1435,7 +1435,7 @@ class ns extends y {
1435
1435
  );
1436
1436
  }
1437
1437
  }
1438
- class os extends y {
1438
+ class is extends y {
1439
1439
  constructor(e) {
1440
1440
  super(
1441
1441
  () => e().remoteData,
@@ -1448,7 +1448,7 @@ class os extends y {
1448
1448
  );
1449
1449
  }
1450
1450
  }
1451
- class is extends y {
1451
+ class os extends y {
1452
1452
  constructor(e) {
1453
1453
  super(
1454
1454
  () => e().resolvers,
@@ -1457,8 +1457,8 @@ class is extends y {
1457
1457
  key: "resolvers",
1458
1458
  schema: Ue,
1459
1459
  beforeRemove: (t, s) => {
1460
- const o = s.remoteData.find((i) => i.resolverId === t);
1461
- if (o) throw new Error(`Referenced by: remoteData["${o.id}"].resolverId`);
1460
+ const i = s.remoteData.find((o) => o.resolverId === t);
1461
+ if (i) throw new Error(`Referenced by: remoteData["${i.id}"].resolverId`);
1462
1462
  }
1463
1463
  }
1464
1464
  );
@@ -1501,29 +1501,29 @@ class as extends y {
1501
1501
  */
1502
1502
  add(e) {
1503
1503
  const t = e.map((s) => {
1504
- const o = `standards/${globalThis.crypto.randomUUID()}.md`;
1504
+ const i = `standards/${globalThis.crypto.randomUUID()}.md`;
1505
1505
  if ("content" in s) {
1506
- const { content: i, ...r } = s;
1507
- return this.getZip().file(o, i), { ...r, contentPath: o };
1506
+ const { content: o, ...r } = s;
1507
+ return this.getZip().file(i, o), { ...r, contentPath: i };
1508
1508
  }
1509
- return this.getZip().file(o, ""), { ...s, contentPath: o };
1509
+ return this.getZip().file(i, ""), { ...s, contentPath: i };
1510
1510
  });
1511
1511
  return super.add(t);
1512
1512
  }
1513
1513
  /** Removes standards and deletes their .md files from the zip. */
1514
1514
  remove(e) {
1515
1515
  const t = new Map(
1516
- e.map((o) => [o, this.list().find((i) => i.id === o)?.contentPath]).filter((o) => o[1] !== void 0)
1516
+ e.map((i) => [i, this.list().find((o) => o.id === i)?.contentPath]).filter((i) => i[1] !== void 0)
1517
1517
  ), s = super.remove(e);
1518
- for (const o of s.succeeded) {
1519
- const i = t.get(o);
1520
- i && this.getZip().remove(i);
1518
+ for (const i of s.succeeded) {
1519
+ const o = t.get(i);
1520
+ o && this.getZip().remove(o);
1521
1521
  }
1522
1522
  return s;
1523
1523
  }
1524
1524
  /** Returns the markdown text content of the given standard. */
1525
1525
  async getContent(e) {
1526
- const t = this.list().find((o) => o.id === e);
1526
+ const t = this.list().find((i) => i.id === e);
1527
1527
  if (!t) throw new Error(`Standard not found: ${e}`);
1528
1528
  const s = this.getZip().file(t.contentPath);
1529
1529
  if (!s) throw new Error(`Content file not found: ${t.contentPath}`);
@@ -1531,7 +1531,7 @@ class as extends y {
1531
1531
  }
1532
1532
  /** Writes new markdown text content for the given standard. */
1533
1533
  setContent(e, t) {
1534
- const s = this.list().find((o) => o.id === e);
1534
+ const s = this.list().find((i) => i.id === e);
1535
1535
  if (!s) throw new Error(`Standard not found: ${e}`);
1536
1536
  this.getZip().file(s.contentPath, t);
1537
1537
  }
@@ -1544,12 +1544,12 @@ class ds extends y {
1544
1544
  {
1545
1545
  key: "teams",
1546
1546
  schema: pe,
1547
- validate: (s, o) => {
1548
- const i = [], r = x("team", s.id, o.deliverableNamingConvention);
1549
- return r && i.push(r), s.representativeEmail && !(s.memberEmails ?? []).includes(s.representativeEmail) && i.push(`representativeEmail "${s.representativeEmail}" is not a member of this team`), i;
1547
+ validate: (s, i) => {
1548
+ const o = [], r = x("team", s.id, i.deliverableNamingConvention);
1549
+ return r && o.push(r), s.representativeEmail && !(s.memberEmails ?? []).includes(s.representativeEmail) && o.push(`representativeEmail "${s.representativeEmail}" is not a member of this team`), o;
1550
1550
  },
1551
- beforeRemove: (s, o) => {
1552
- if (o.project.clientId === s)
1551
+ beforeRemove: (s, i) => {
1552
+ if (i.project.clientId === s)
1553
1553
  throw new Error("Referenced by: project.clientId");
1554
1554
  }
1555
1555
  }
@@ -1561,8 +1561,8 @@ class ds extends y {
1561
1561
  return e.teams.map((s) => ({
1562
1562
  ...s,
1563
1563
  representative: t.get(s.representativeEmail ?? "") ?? null,
1564
- members: (s.memberEmails ?? []).map((o) => t.get(o)).filter(Boolean),
1565
- disciplines: (s.disciplineIds ?? []).map((o) => e.disciplines.find((i) => i.id === o)).filter(Boolean)
1564
+ members: (s.memberEmails ?? []).map((i) => t.get(i)).filter(Boolean),
1565
+ disciplines: (s.disciplineIds ?? []).map((i) => e.disciplines.find((o) => o.id === i)).filter(Boolean)
1566
1566
  }));
1567
1567
  }
1568
1568
  }
@@ -1572,22 +1572,22 @@ function ls(n, e, t) {
1572
1572
  if (c.type === "process") {
1573
1573
  c.actionId && !e.actions.some((u) => u.id === c.actionId) && s.push(`actions["${c.actionId}"] not found (node: ${l})`);
1574
1574
  for (const u of ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"])
1575
- for (const f of c[u] ?? [])
1576
- e.roles.some((m) => m.id === f) || s.push(`roles["${f}"] not found (node: ${l}.${u})`);
1575
+ for (const m of c[u] ?? [])
1576
+ e.roles.some((f) => f.id === m) || s.push(`roles["${m}"] not found (node: ${l}.${u})`);
1577
1577
  }
1578
1578
  for (const [l, c] of Object.entries(n.edges)) {
1579
1579
  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((u) => u.id === c.triggerEventId) && s.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1580
1580
  for (const u of c.effectIds ?? [])
1581
- e.effects.some((f) => f.id === u) || s.push(`effects["${u}"] not found (edge: ${l})`);
1581
+ e.effects.some((m) => m.id === u) || s.push(`effects["${u}"] not found (edge: ${l})`);
1582
1582
  }
1583
1583
  for (const [l, c] of Object.entries(n.nodes))
1584
1584
  if (c.type === "automation" && !e.automations.some((u) => u.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((u) => u.id === c.workflowId) || s.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1585
1585
  for (const u of c.timeouts)
1586
- e.effects.some((f) => f.id === u.effectId) || s.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
1587
- const o = Object.keys(n.nodes), i = new Set(Object.values(n.edges).map((l) => l.to)), r = new Set(Object.values(n.edges).map((l) => l.from));
1588
- for (const l of o)
1589
- n.nodes[l].type !== "start" && (i.has(l) || s.push(`node "${l}" is unreachable — no edges point to it`));
1590
- for (const l of o)
1586
+ e.effects.some((m) => m.id === u.effectId) || s.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
1587
+ const i = Object.keys(n.nodes), o = new Set(Object.values(n.edges).map((l) => l.to)), r = new Set(Object.values(n.edges).map((l) => l.from));
1588
+ for (const l of i)
1589
+ n.nodes[l].type !== "start" && (o.has(l) || s.push(`node "${l}" is unreachable — no edges point to it`));
1590
+ for (const l of i)
1591
1591
  n.nodes[l].type !== "end" && (r.has(l) || s.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
1592
1592
  const d = {};
1593
1593
  for (const l of Object.keys(n.edges)) {
@@ -1597,22 +1597,22 @@ function ls(n, e, t) {
1597
1597
  for (const [l, c] of Object.entries(n.nodes)) {
1598
1598
  if (c.type !== "decision") continue;
1599
1599
  const u = /* @__PURE__ */ new Set();
1600
- for (const f of d[l] ?? []) {
1601
- const m = n.edges[f], p = n.nodes[m.from];
1600
+ for (const m of d[l] ?? []) {
1601
+ const f = n.edges[m], p = n.nodes[f.from];
1602
1602
  if (p) {
1603
1603
  if (p.type === "automation") {
1604
1604
  const g = e.automations.find((h) => h.id === p.automationId);
1605
1605
  for (const h of g?.output ?? []) u.add(h.key);
1606
1606
  }
1607
- if (p.type === "process" && "triggerEventId" in m) {
1608
- const g = e.events.find((h) => h.id === m.triggerEventId);
1607
+ if (p.type === "process" && "triggerEventId" in f) {
1608
+ const g = e.events.find((h) => h.id === f.triggerEventId);
1609
1609
  for (const h of g?.payload ?? []) u.add(h.key);
1610
1610
  }
1611
1611
  }
1612
1612
  }
1613
1613
  if (u.size !== 0)
1614
- for (const [f, m] of Object.entries(n.edges))
1615
- m.from === l && "guard" in m && (u.has(m.guard.field) || s.push(`guard field "${m.guard.field}" on edge "${f}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1614
+ for (const [m, f] of Object.entries(n.edges))
1615
+ f.from === l && "guard" in f && (u.has(f.guard.field) || s.push(`guard field "${f.guard.field}" on edge "${m}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1616
1616
  }
1617
1617
  return s;
1618
1618
  }
@@ -1625,29 +1625,29 @@ class cs extends y {
1625
1625
  key: "workflows",
1626
1626
  schema: je,
1627
1627
  autoId: !0,
1628
- validate: (o, i) => ls(o.diagram, i, o.id)
1628
+ validate: (i, o) => ls(i.diagram, o, i.id)
1629
1629
  }
1630
1630
  ), this.getMembers = t, this.getTeams = s;
1631
1631
  }
1632
1632
  getMembers;
1633
1633
  getTeams;
1634
1634
  getRaciMatrix() {
1635
- const e = this.getBep(), t = [], s = /* @__PURE__ */ new Set(), o = this.getMembers().listResolved(), i = this.getTeams().listResolved(), r = (l) => (l ?? []).flatMap((c) => {
1635
+ const e = this.getBep(), t = [], s = /* @__PURE__ */ new Set(), i = this.getMembers().listResolved(), o = this.getTeams().listResolved(), r = (l) => (l ?? []).flatMap((c) => {
1636
1636
  const u = e.roles.find((p) => p.id === c);
1637
1637
  if (!u) return [];
1638
1638
  s.add(c);
1639
- const f = o.filter((p) => p.role?.id === c), m = i.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1640
- return [{ role: u, members: f, team: m }];
1639
+ const m = i.filter((p) => p.role?.id === c), f = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1640
+ return [{ role: u, members: m, team: f }];
1641
1641
  });
1642
1642
  for (const l of e.workflows)
1643
1643
  for (const [c, u] of Object.entries(l.diagram.nodes)) {
1644
1644
  if (u.type !== "process") continue;
1645
- const f = u.actionId ? e.actions.find((m) => m.id === u.actionId) : void 0;
1645
+ const m = u.actionId ? e.actions.find((f) => f.id === u.actionId) : void 0;
1646
1646
  t.push({
1647
1647
  workflow: { id: l.id, name: l.name },
1648
1648
  nodeId: c,
1649
- label: f?.name ?? c,
1650
- ...f?.description ? { description: f.description } : {},
1649
+ label: m?.name ?? c,
1650
+ ...m?.description ? { description: m.description } : {},
1651
1651
  ...u.actionId ? { actionId: u.actionId } : {},
1652
1652
  responsible: r(u.responsibleRoleIds),
1653
1653
  accountable: r(u.accountableRoleIds),
@@ -1658,10 +1658,10 @@ class cs extends y {
1658
1658
  return { roles: [...s].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
1659
1659
  }
1660
1660
  getRaciMatrixForWorkflow(e) {
1661
- const t = this.getRaciMatrix(), s = t.rows.filter((i) => i.workflow.id === e), o = new Set(
1662
- s.flatMap((i) => [...i.responsible, ...i.accountable, ...i.consulted, ...i.informed].map((r) => r.role.id))
1661
+ const t = this.getRaciMatrix(), s = t.rows.filter((o) => o.workflow.id === e), i = new Set(
1662
+ s.flatMap((o) => [...o.responsible, ...o.accountable, ...o.consulted, ...o.informed].map((r) => r.role.id))
1663
1663
  );
1664
- return { roles: t.roles.filter((i) => o.has(i.id)), rows: s };
1664
+ return { roles: t.roles.filter((o) => i.has(o.id)), rows: s };
1665
1665
  }
1666
1666
  getConsolidatedRaciMatrix() {
1667
1667
  const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), s = (r, d) => {
@@ -1670,8 +1670,8 @@ class cs extends y {
1670
1670
  if (!l.has(c.role.id))
1671
1671
  l.set(c.role.id, { ...c, members: [...c.members] });
1672
1672
  else {
1673
- const u = l.get(c.role.id), f = new Set(u.members.map((m) => m.email));
1674
- for (const m of c.members) f.has(m.email) || u.members.push(m);
1673
+ const u = l.get(c.role.id), m = new Set(u.members.map((f) => f.email));
1674
+ for (const f of c.members) m.has(f.email) || u.members.push(f);
1675
1675
  }
1676
1676
  return [...l.values()];
1677
1677
  };
@@ -1684,33 +1684,33 @@ class cs extends y {
1684
1684
  l.responsible = s(l.responsible, r.responsible), l.accountable = s(l.accountable, r.accountable), l.consulted = s(l.consulted, r.consulted), l.informed = s(l.informed, r.informed);
1685
1685
  }
1686
1686
  }
1687
- const o = [...t.values()], i = new Set(
1688
- o.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
1687
+ const i = [...t.values()], o = new Set(
1688
+ i.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
1689
1689
  );
1690
- return { roles: e.roles.filter((r) => i.has(r.id)), rows: o };
1690
+ return { roles: e.roles.filter((r) => o.has(r.id)), rows: i };
1691
1691
  }
1692
1692
  listResolved() {
1693
1693
  const e = this.getBep();
1694
1694
  return e.workflows.map((t) => {
1695
1695
  const s = {};
1696
- for (const [o, i] of Object.entries(t.diagram.nodes)) {
1696
+ for (const [i, o] of Object.entries(t.diagram.nodes)) {
1697
1697
  const r = (d) => ({
1698
1698
  roles: (d ?? []).map((l) => e.roles.find((c) => c.id === l)).filter(Boolean),
1699
1699
  teams: [],
1700
1700
  members: []
1701
1701
  });
1702
- s[o] = {
1703
- type: i.type,
1704
- label: i.type === "decision" ? i.label : void 0,
1705
- timeouts: i.type === "process" || i.type === "automation" ? i.timeouts : void 0,
1706
- workflowId: i.type === "process" ? i.workflowId : void 0,
1707
- blocking: i.type === "process" ? i.blocking : void 0,
1708
- action: i.type === "process" && i.actionId ? e.actions.find((d) => d.id === i.actionId) ?? null : null,
1709
- automation: i.type === "automation" ? e.automations.find((d) => d.id === i.automationId) ?? null : null,
1710
- responsible: r(i.type === "process" ? i.responsibleRoleIds : void 0),
1711
- accountable: r(i.type === "process" ? i.accountableRoleIds : void 0),
1712
- consulted: r(i.type === "process" ? i.consultedRoleIds : void 0),
1713
- informed: r(i.type === "process" ? i.informedRoleIds : void 0)
1702
+ s[i] = {
1703
+ type: o.type,
1704
+ label: o.type === "decision" ? o.label : void 0,
1705
+ timeouts: o.type === "process" || o.type === "automation" ? o.timeouts : void 0,
1706
+ workflowId: o.type === "process" ? o.workflowId : void 0,
1707
+ blocking: o.type === "process" ? o.blocking : void 0,
1708
+ action: o.type === "process" && o.actionId ? e.actions.find((d) => d.id === o.actionId) ?? null : null,
1709
+ automation: o.type === "automation" ? e.automations.find((d) => d.id === o.automationId) ?? null : null,
1710
+ responsible: r(o.type === "process" ? o.responsibleRoleIds : void 0),
1711
+ accountable: r(o.type === "process" ? o.accountableRoleIds : void 0),
1712
+ consulted: r(o.type === "process" ? o.consultedRoleIds : void 0),
1713
+ informed: r(o.type === "process" ? o.informedRoleIds : void 0)
1714
1714
  };
1715
1715
  }
1716
1716
  return {
@@ -1722,10 +1722,10 @@ class cs extends y {
1722
1722
  }
1723
1723
  var fs = /* @__PURE__ */ (function() {
1724
1724
  var n = function(e, t) {
1725
- return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(s, o) {
1726
- s.__proto__ = o;
1727
- } || function(s, o) {
1728
- for (var i in o) o.hasOwnProperty(i) && (s[i] = o[i]);
1725
+ return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(s, i) {
1726
+ s.__proto__ = i;
1727
+ } || function(s, i) {
1728
+ for (var o in i) i.hasOwnProperty(o) && (s[o] = i[o]);
1729
1729
  }, n(e, t);
1730
1730
  };
1731
1731
  return function(e, t) {
@@ -1739,7 +1739,7 @@ var fs = /* @__PURE__ */ (function() {
1739
1739
  function G(n, e) {
1740
1740
  return us.call(n, e);
1741
1741
  }
1742
- function V(n) {
1742
+ function X(n) {
1743
1743
  if (Array.isArray(n)) {
1744
1744
  for (var e = new Array(n.length), t = 0; t < e.length; t++)
1745
1745
  e[t] = "" + t;
@@ -1748,8 +1748,8 @@ function V(n) {
1748
1748
  if (Object.keys)
1749
1749
  return Object.keys(n);
1750
1750
  var s = [];
1751
- for (var o in n)
1752
- G(n, o) && s.push(o);
1751
+ for (var i in n)
1752
+ G(n, i) && s.push(i);
1753
1753
  return s;
1754
1754
  }
1755
1755
  function R(n) {
@@ -1764,7 +1764,7 @@ function R(n) {
1764
1764
  return n;
1765
1765
  }
1766
1766
  }
1767
- function X(n) {
1767
+ function V(n) {
1768
1768
  for (var e = 0, t = n.length, s; e < t; ) {
1769
1769
  if (s = n.charCodeAt(e), s >= 48 && s <= 57) {
1770
1770
  e++;
@@ -1789,8 +1789,8 @@ function H(n) {
1789
1789
  if (H(n[e]))
1790
1790
  return !0;
1791
1791
  } else if (typeof n == "object") {
1792
- for (var s = V(n), o = s.length, i = 0; i < o; i++)
1793
- if (H(n[s[i]]))
1792
+ for (var s = X(n), i = s.length, o = 0; o < i; o++)
1793
+ if (H(n[s[o]]))
1794
1794
  return !0;
1795
1795
  }
1796
1796
  }
@@ -1799,23 +1799,23 @@ function H(n) {
1799
1799
  function de(n, e) {
1800
1800
  var t = [n];
1801
1801
  for (var s in e) {
1802
- var o = typeof e[s] == "object" ? JSON.stringify(e[s], null, 2) : e[s];
1803
- typeof o < "u" && t.push(s + ": " + o);
1802
+ var i = typeof e[s] == "object" ? JSON.stringify(e[s], null, 2) : e[s];
1803
+ typeof i < "u" && t.push(s + ": " + i);
1804
1804
  }
1805
1805
  return t.join(`
1806
1806
  `);
1807
1807
  }
1808
- var Ve = (
1808
+ var Xe = (
1809
1809
  /** @class */
1810
1810
  (function(n) {
1811
1811
  fs(e, n);
1812
- function e(t, s, o, i, r) {
1813
- var d = this.constructor, l = n.call(this, de(t, { name: s, index: o, operation: i, tree: r })) || this;
1814
- return l.name = s, l.index = o, l.operation = i, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = de(t, { name: s, index: o, operation: i, tree: r }), l;
1812
+ function e(t, s, i, o, r) {
1813
+ var d = this.constructor, l = n.call(this, de(t, { name: s, index: i, operation: o, tree: r })) || this;
1814
+ return l.name = s, l.index = i, l.operation = o, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = de(t, { name: s, index: i, operation: o, tree: r }), l;
1815
1815
  }
1816
1816
  return e;
1817
1817
  })(Error)
1818
- ), E = Ve, ms = R, M = {
1818
+ ), E = Xe, ms = R, M = {
1819
1819
  add: function(n, e, t) {
1820
1820
  return n[e] = this.value, { newDocument: t };
1821
1821
  },
@@ -1830,8 +1830,8 @@ var Ve = (
1830
1830
  move: function(n, e, t) {
1831
1831
  var s = U(t, this.path);
1832
1832
  s && (s = R(s));
1833
- var o = O(t, { op: "remove", path: this.from }).removed;
1834
- return O(t, { op: "add", path: this.path, value: o }), { newDocument: t, removed: s };
1833
+ var i = O(t, { op: "remove", path: this.from }).removed;
1834
+ return O(t, { op: "add", path: this.path, value: i }), { newDocument: t, removed: s };
1835
1835
  },
1836
1836
  copy: function(n, e, t) {
1837
1837
  var s = U(t, this.from);
@@ -1845,7 +1845,7 @@ var Ve = (
1845
1845
  }
1846
1846
  }, ps = {
1847
1847
  add: function(n, e, t) {
1848
- return X(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: t, index: e };
1848
+ return V(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: t, index: e };
1849
1849
  },
1850
1850
  remove: function(n, e, t) {
1851
1851
  var s = n.splice(e, 1);
@@ -1866,8 +1866,8 @@ function U(n, e) {
1866
1866
  var t = { op: "_get", path: e };
1867
1867
  return O(n, t), t.value;
1868
1868
  }
1869
- function O(n, e, t, s, o, i) {
1870
- if (t === void 0 && (t = !1), s === void 0 && (s = !0), o === void 0 && (o = !0), i === void 0 && (i = 0), t && (typeof t == "function" ? t(e, 0, n, e.path) : z(e, 0)), e.path === "") {
1869
+ function O(n, e, t, s, i, o) {
1870
+ 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) : z(e, 0)), e.path === "") {
1871
1871
  var r = { newDocument: n };
1872
1872
  if (e.op === "add")
1873
1873
  return r.newDocument = e.value, r;
@@ -1877,7 +1877,7 @@ function O(n, e, t, s, o, i) {
1877
1877
  return r.newDocument = U(n, e.from), e.op === "move" && (r.removed = n), r;
1878
1878
  if (e.op === "test") {
1879
1879
  if (r.test = P(n, e.value), r.test === !1)
1880
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, n);
1880
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1881
1881
  return r.newDocument = n, r;
1882
1882
  } else {
1883
1883
  if (e.op === "remove")
@@ -1885,49 +1885,49 @@ function O(n, e, t, s, o, i) {
1885
1885
  if (e.op === "_get")
1886
1886
  return e.value = n, r;
1887
1887
  if (t)
1888
- throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", i, e, n);
1888
+ throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, n);
1889
1889
  return r;
1890
1890
  }
1891
1891
  } else {
1892
1892
  s || (n = R(n));
1893
- var d = e.path || "", l = d.split("/"), c = n, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
1893
+ var d = e.path || "", l = d.split("/"), c = n, u = 1, m = l.length, f = void 0, p = void 0, g = void 0;
1894
1894
  for (typeof t == "function" ? g = t : g = z; ; ) {
1895
- if (p = l[u], p && p.indexOf("~") != -1 && (p = Ge(p)), o && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
1895
+ if (p = l[u], p && p.indexOf("~") != -1 && (p = Ge(p)), i && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
1896
1896
  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");
1897
- if (t && m === void 0 && (c[p] === void 0 ? m = l.slice(0, u).join("/") : u == f - 1 && (m = e.path), m !== void 0 && g(e, 0, n, m)), u++, Array.isArray(c)) {
1897
+ if (t && f === void 0 && (c[p] === void 0 ? f = l.slice(0, u).join("/") : u == m - 1 && (f = e.path), f !== void 0 && g(e, 0, n, f)), u++, Array.isArray(c)) {
1898
1898
  if (p === "-")
1899
1899
  p = c.length;
1900
1900
  else {
1901
- if (t && !X(p))
1902
- 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", i, e, n);
1903
- X(p) && (p = ~~p);
1901
+ if (t && !V(p))
1902
+ 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);
1903
+ V(p) && (p = ~~p);
1904
1904
  }
1905
- if (u >= f) {
1905
+ if (u >= m) {
1906
1906
  if (t && e.op === "add" && p > c.length)
1907
- throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", i, e, n);
1907
+ 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);
1908
1908
  var r = ps[e.op].call(e, c, p, n);
1909
1909
  if (r.test === !1)
1910
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, n);
1910
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1911
1911
  return r;
1912
1912
  }
1913
- } else if (u >= f) {
1913
+ } else if (u >= m) {
1914
1914
  var r = M[e.op].call(e, c, p, n);
1915
1915
  if (r.test === !1)
1916
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, n);
1916
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1917
1917
  return r;
1918
1918
  }
1919
- if (c = c[p], t && u < f && (!c || typeof c != "object"))
1920
- throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", i, e, n);
1919
+ if (c = c[p], t && u < m && (!c || typeof c != "object"))
1920
+ throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, n);
1921
1921
  }
1922
1922
  }
1923
1923
  }
1924
- function Z(n, e, t, s, o) {
1925
- if (s === void 0 && (s = !0), o === void 0 && (o = !0), t && !Array.isArray(e))
1924
+ function Z(n, e, t, s, i) {
1925
+ if (s === void 0 && (s = !0), i === void 0 && (i = !0), t && !Array.isArray(e))
1926
1926
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1927
1927
  s || (n = R(n));
1928
- for (var i = new Array(e.length), r = 0, d = e.length; r < d; r++)
1929
- i[r] = O(n, e[r], t, !0, o, r), n = i[r].newDocument;
1930
- return i.newDocument = n, i;
1928
+ for (var o = new Array(e.length), r = 0, d = e.length; r < d; r++)
1929
+ o[r] = O(n, e[r], t, !0, i, r), n = o[r].newDocument;
1930
+ return o.newDocument = n, o;
1931
1931
  }
1932
1932
  function hs(n, e, t) {
1933
1933
  var s = O(n, e);
@@ -1951,21 +1951,21 @@ function z(n, e, t, s) {
1951
1951
  throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, t);
1952
1952
  if (t) {
1953
1953
  if (n.op == "add") {
1954
- var o = n.path.split("/").length, i = s.split("/").length;
1955
- if (o !== i + 1 && o !== i)
1954
+ var i = n.path.split("/").length, o = s.split("/").length;
1955
+ if (i !== o + 1 && i !== o)
1956
1956
  throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, n, t);
1957
1957
  } else if (n.op === "replace" || n.op === "remove" || n.op === "_get") {
1958
1958
  if (n.path !== s)
1959
1959
  throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, n, t);
1960
1960
  } else if (n.op === "move" || n.op === "copy") {
1961
- var r = { op: "_get", path: n.from, value: void 0 }, d = Xe([r], t);
1961
+ var r = { op: "_get", path: n.from, value: void 0 }, d = Ve([r], t);
1962
1962
  if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
1963
1963
  throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, n, t);
1964
1964
  }
1965
1965
  }
1966
1966
  } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, n, t);
1967
1967
  }
1968
- function Xe(n, e, t) {
1968
+ function Ve(n, e, t) {
1969
1969
  try {
1970
1970
  if (!Array.isArray(n))
1971
1971
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
@@ -1976,35 +1976,35 @@ function Xe(n, e, t) {
1976
1976
  for (var s = 0; s < n.length; s++)
1977
1977
  t(n[s], s, e, void 0);
1978
1978
  }
1979
- } catch (o) {
1980
- if (o instanceof E)
1981
- return o;
1982
- throw o;
1979
+ } catch (i) {
1980
+ if (i instanceof E)
1981
+ return i;
1982
+ throw i;
1983
1983
  }
1984
1984
  }
1985
1985
  function P(n, e) {
1986
1986
  if (n === e)
1987
1987
  return !0;
1988
1988
  if (n && e && typeof n == "object" && typeof e == "object") {
1989
- var t = Array.isArray(n), s = Array.isArray(e), o, i, r;
1989
+ var t = Array.isArray(n), s = Array.isArray(e), i, o, r;
1990
1990
  if (t && s) {
1991
- if (i = n.length, i != e.length)
1991
+ if (o = n.length, o != e.length)
1992
1992
  return !1;
1993
- for (o = i; o-- !== 0; )
1994
- if (!P(n[o], e[o]))
1993
+ for (i = o; i-- !== 0; )
1994
+ if (!P(n[i], e[i]))
1995
1995
  return !1;
1996
1996
  return !0;
1997
1997
  }
1998
1998
  if (t != s)
1999
1999
  return !1;
2000
2000
  var d = Object.keys(n);
2001
- if (i = d.length, i !== Object.keys(e).length)
2001
+ if (o = d.length, o !== Object.keys(e).length)
2002
2002
  return !1;
2003
- for (o = i; o-- !== 0; )
2004
- if (!e.hasOwnProperty(d[o]))
2003
+ for (i = o; i-- !== 0; )
2004
+ if (!e.hasOwnProperty(d[i]))
2005
2005
  return !1;
2006
- for (o = i; o-- !== 0; )
2007
- if (r = d[o], !P(n[r], e[r]))
2006
+ for (i = o; i-- !== 0; )
2007
+ if (r = d[i], !P(n[r], e[r]))
2008
2008
  return !1;
2009
2009
  return !0;
2010
2010
  }
@@ -2019,7 +2019,7 @@ const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2019
2019
  applyReducer: hs,
2020
2020
  deepClone: ms,
2021
2021
  getValueByPointer: U,
2022
- validate: Xe,
2022
+ validate: Ve,
2023
2023
  validator: z
2024
2024
  }, Symbol.toStringTag, { value: "Module" }));
2025
2025
  var se = /* @__PURE__ */ new WeakMap(), ys = (
@@ -2052,16 +2052,16 @@ function Es(n, e) {
2052
2052
  e.unobserve();
2053
2053
  }
2054
2054
  function Ns(n, e) {
2055
- var t = [], s, o = ws(n);
2056
- if (!o)
2057
- o = new ys(n), se.set(n, o);
2055
+ var t = [], s, i = ws(n);
2056
+ if (!i)
2057
+ i = new ys(n), se.set(n, i);
2058
2058
  else {
2059
- var i = vs(o, e);
2060
- s = i && i.observer;
2059
+ var o = vs(i, e);
2060
+ s = o && o.observer;
2061
2061
  }
2062
2062
  if (s)
2063
2063
  return s;
2064
- if (s = {}, o.value = R(n), e) {
2064
+ if (s = {}, i.value = R(n), e) {
2065
2065
  s.callback = e, s.next = null;
2066
2066
  var r = function() {
2067
2067
  Y(s);
@@ -2071,8 +2071,8 @@ function Ns(n, e) {
2071
2071
  typeof window < "u" && (window.addEventListener("mouseup", d), window.addEventListener("keyup", d), window.addEventListener("mousedown", d), window.addEventListener("keydown", d), window.addEventListener("change", d));
2072
2072
  }
2073
2073
  return s.patches = t, s.object = n, s.unobserve = function() {
2074
- Y(s), clearTimeout(s.next), Is(o, s), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
2075
- }, o.observers.set(e, new bs(e, s)), s;
2074
+ Y(s), clearTimeout(s.next), Is(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));
2075
+ }, i.observers.set(e, new bs(e, s)), s;
2076
2076
  }
2077
2077
  function Y(n, e) {
2078
2078
  e === void 0 && (e = !1);
@@ -2081,19 +2081,19 @@ function Y(n, e) {
2081
2081
  var s = n.patches;
2082
2082
  return s.length > 0 && (n.patches = [], n.callback && n.callback(s)), s;
2083
2083
  }
2084
- function ne(n, e, t, s, o) {
2084
+ function ne(n, e, t, s, i) {
2085
2085
  if (e !== n) {
2086
2086
  typeof e.toJSON == "function" && (e = e.toJSON());
2087
- for (var i = V(e), r = V(n), d = !1, l = r.length - 1; l >= 0; l--) {
2087
+ for (var o = X(e), r = X(n), d = !1, l = r.length - 1; l >= 0; l--) {
2088
2088
  var c = r[l], u = n[c];
2089
2089
  if (G(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
2090
- var f = e[c];
2091
- typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? ne(u, f, t, s + "/" + j(c), o) : u !== f && (o && t.push({ op: "test", path: s + "/" + j(c), value: R(u) }), t.push({ op: "replace", path: s + "/" + j(c), value: R(f) }));
2092
- } else Array.isArray(n) === Array.isArray(e) ? (o && t.push({ op: "test", path: s + "/" + j(c), value: R(u) }), t.push({ op: "remove", path: s + "/" + j(c) }), d = !0) : (o && t.push({ op: "test", path: s, value: n }), t.push({ op: "replace", path: s, value: e }));
2090
+ var m = e[c];
2091
+ typeof u == "object" && u != null && typeof m == "object" && m != null && Array.isArray(u) === Array.isArray(m) ? ne(u, m, t, s + "/" + j(c), i) : u !== m && (i && t.push({ op: "test", path: s + "/" + j(c), value: R(u) }), t.push({ op: "replace", path: s + "/" + j(c), value: R(m) }));
2092
+ } else Array.isArray(n) === Array.isArray(e) ? (i && t.push({ op: "test", path: s + "/" + j(c), value: R(u) }), t.push({ op: "remove", path: s + "/" + j(c) }), d = !0) : (i && t.push({ op: "test", path: s, value: n }), t.push({ op: "replace", path: s, value: e }));
2093
2093
  }
2094
- if (!(!d && i.length == r.length))
2095
- for (var l = 0; l < i.length; l++) {
2096
- var c = i[l];
2094
+ if (!(!d && o.length == r.length))
2095
+ for (var l = 0; l < o.length; l++) {
2096
+ var c = o[l];
2097
2097
  !G(n, c) && e[c] !== void 0 && t.push({ op: "add", path: s + "/" + j(c), value: R(e[c]) });
2098
2098
  }
2099
2099
  }
@@ -2111,7 +2111,7 @@ const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2111
2111
  unobserve: Es
2112
2112
  }, Symbol.toStringTag, { value: "Module" }));
2113
2113
  Object.assign({}, gs, Ss, {
2114
- JsonPatchError: Ve,
2114
+ JsonPatchError: Xe,
2115
2115
  deepClone: R,
2116
2116
  escapePathComponent: j,
2117
2117
  unescapePathComponent: Ge
@@ -2148,12 +2148,12 @@ const ks = [
2148
2148
  I("env", (n) => n.key, (n) => n.key)
2149
2149
  ];
2150
2150
  function $s(n, e, t, s) {
2151
- const o = new Map(n.map((r) => [t(r), r])), i = new Map(e.map((r) => [t(r), r]));
2151
+ const i = new Map(n.map((r) => [t(r), r])), o = new Map(e.map((r) => [t(r), r]));
2152
2152
  return {
2153
- added: e.filter((r) => !o.has(t(r))).map(s),
2154
- removed: n.filter((r) => !i.has(t(r))).map(s),
2153
+ added: e.filter((r) => !i.has(t(r))).map(s),
2154
+ removed: n.filter((r) => !o.has(t(r))).map(s),
2155
2155
  modified: e.filter((r) => {
2156
- const d = o.get(t(r));
2156
+ const d = i.get(t(r));
2157
2157
  return d !== void 0 && JSON.stringify(d) !== JSON.stringify(r);
2158
2158
  }).map(s)
2159
2159
  };
@@ -2165,12 +2165,12 @@ function Rs(n, e) {
2165
2165
  return JSON.stringify(d) !== JSON.stringify(l);
2166
2166
  }) });
2167
2167
  const s = {};
2168
- for (const { key: i, getId: r, getLabel: d } of ks) {
2169
- const l = e[i] ?? [], c = n[i] ?? [], u = $s(l, c, r, d);
2170
- (u.added.length || u.removed.length || u.modified.length) && (s[i] = u);
2168
+ for (const { key: o, getId: r, getLabel: d } of ks) {
2169
+ const l = e[o] ?? [], c = n[o] ?? [], u = $s(l, c, r, d);
2170
+ (u.added.length || u.removed.length || u.modified.length) && (s[o] = u);
2171
2171
  }
2172
- const o = [...t ? ["project"] : [], ...Object.keys(s)];
2173
- return { project: t, sections: s, changedKeys: o };
2172
+ const i = [...t ? ["project"] : [], ...Object.keys(s)];
2173
+ return { project: t, sections: s, changedKeys: i };
2174
2174
  }
2175
2175
  class k {
2176
2176
  constructor(e, t, s) {
@@ -2185,12 +2185,12 @@ class k {
2185
2185
  return { major: t, minor: s };
2186
2186
  }
2187
2187
  static compareVersions(e, t) {
2188
- const s = k.parseVersion(e), o = k.parseVersion(t);
2189
- return s.major !== o.major ? s.major - o.major : s.minor - o.minor;
2188
+ const s = k.parseVersion(e), i = k.parseVersion(t);
2189
+ return s.major !== i.major ? s.major - i.major : s.minor - i.minor;
2190
2190
  }
2191
2191
  static bumpVersion(e, t) {
2192
- const [s, o] = e.split(".").map(Number);
2193
- return t === "version" ? `${s + 1}.0` : `${s}.${o + 1}`;
2192
+ const [s, i] = e.split(".").map(Number);
2193
+ return t === "version" ? `${s + 1}.0` : `${s}.${i + 1}`;
2194
2194
  }
2195
2195
  // ─── Zip helpers ──────────────────────────────────────────────────────────
2196
2196
  async readChangelog() {
@@ -2208,14 +2208,14 @@ class k {
2208
2208
  */
2209
2209
  async snapshotChangedStandards(e, t) {
2210
2210
  const s = this.getZip();
2211
- for (const o of e.standards) {
2212
- const i = s.file(o.contentPath);
2213
- if (!i) continue;
2214
- const r = await i.async("string"), d = `changelog/standards/${o.id}/`, l = Object.keys(s.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2211
+ for (const i of e.standards) {
2212
+ const o = s.file(i.contentPath);
2213
+ if (!o) continue;
2214
+ const r = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(s.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2215
2215
  let c = null;
2216
2216
  if (l.length > 0) {
2217
- const u = l.sort((m, p) => k.compareVersions(p, m))[0], f = s.file(`${d}v${u}.md`);
2218
- f && (c = await f.async("string"));
2217
+ const u = l.sort((f, p) => k.compareVersions(p, f))[0], m = s.file(`${d}v${u}.md`);
2218
+ m && (c = await m.async("string"));
2219
2219
  }
2220
2220
  c !== r && s.file(`${d}v${t}.md`, r);
2221
2221
  }
@@ -2227,10 +2227,10 @@ class k {
2227
2227
  async snapshotBaseStandards(e) {
2228
2228
  const t = this.getZip();
2229
2229
  for (const s of e.standards) {
2230
- const o = t.file(s.contentPath);
2231
- if (!o) continue;
2232
- const i = await o.async("string");
2233
- t.file(`baseline/standards/${s.id}.md`, i);
2230
+ const i = t.file(s.contentPath);
2231
+ if (!i) continue;
2232
+ const o = await i.async("string");
2233
+ t.file(`baseline/standards/${s.id}.md`, o);
2234
2234
  }
2235
2235
  }
2236
2236
  /**
@@ -2239,12 +2239,12 @@ class k {
2239
2239
  * Falls back to the current file if no snapshot exists (content never changed).
2240
2240
  */
2241
2241
  async resolveStandardContent(e, t) {
2242
- const s = this.getZip(), o = `changelog/standards/${e.id}/`, i = Object.keys(s.files).filter((d) => d.startsWith(o) && d.endsWith(".md") && d.slice(o.length).startsWith("v")).map((d) => d.slice(o.length + 1, -3)).filter((d) => k.compareVersions(d, t) <= 0).sort((d, l) => k.compareVersions(l, d));
2243
- if (i.length === 0) {
2242
+ 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) => k.compareVersions(d, t) <= 0).sort((d, l) => k.compareVersions(l, d));
2243
+ if (o.length === 0) {
2244
2244
  const d = s.file(e.contentPath);
2245
2245
  return d ? d.async("string") : null;
2246
2246
  }
2247
- const r = s.file(`${o}v${i[0]}.md`);
2247
+ const r = s.file(`${i}v${o[0]}.md`);
2248
2248
  return r ? r.async("string") : null;
2249
2249
  }
2250
2250
  // ─── Public API ───────────────────────────────────────────────────────────
@@ -2255,19 +2255,19 @@ class k {
2255
2255
  return (await this.readChangelog())?.versions ?? [];
2256
2256
  }
2257
2257
  async commit(e, t = !1) {
2258
- const s = this.getZip(), o = this.getBep(), i = await this.readChangelog(), r = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2258
+ const s = this.getZip(), i = this.getBep(), o = await this.readChangelog(), r = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2259
2259
  if (!r) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
2260
2260
  if (e.type === "version") {
2261
- const g = e.approvedBy.filter((h) => !o.members.some((b) => b.email === h));
2261
+ const g = e.approvedBy.filter((h) => !i.members.some((b) => b.email === h));
2262
2262
  if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
2263
2263
  }
2264
2264
  if (!t && !await this.hasPendingChanges())
2265
2265
  throw new Error("No pending changes since last commit");
2266
- const l = i?.current ?? "0.0", c = k.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = Q(o, r), m = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: u } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: u }, p = {
2266
+ const l = o?.current ?? "0.0", c = k.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, m = Q(i, r), f = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: u } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: u }, p = {
2267
2267
  current: c,
2268
- versions: [...i?.versions ?? [], m]
2268
+ versions: [...o?.versions ?? [], f]
2269
2269
  };
2270
- return s.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(o, c), s.file("baseline/bep.json", JSON.stringify(o, null, 2)), await this.snapshotBaseStandards(o), s.file("changelog.json", JSON.stringify(p, null, 2)), m;
2270
+ return s.file(u, JSON.stringify(m, 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)), f;
2271
2271
  }
2272
2272
  /**
2273
2273
  * Reconstructs the BEP state at the given version (read-only).
@@ -2289,26 +2289,26 @@ class k {
2289
2289
  if (!r) throw new Error(`Missing terminus: changelog/v${e}.json`);
2290
2290
  return B(JSON.parse(await r.async("string")));
2291
2291
  }
2292
- const o = t.versions.filter((r) => k.compareVersions(r.version, e) > 0).sort((r, d) => k.compareVersions(d.version, r.version)), i = JSON.parse(JSON.stringify(this.getBep()));
2293
- for (const r of o) {
2292
+ const i = t.versions.filter((r) => k.compareVersions(r.version, e) > 0).sort((r, d) => k.compareVersions(d.version, r.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2293
+ for (const r of i) {
2294
2294
  if (!r.diff) break;
2295
2295
  const d = this.getZip().file(r.diff);
2296
2296
  if (!d) throw new Error(`Missing diff file: ${r.diff}`);
2297
2297
  const l = JSON.parse(await d.async("string"));
2298
- Z(i, l);
2298
+ Z(o, l);
2299
2299
  }
2300
- return B(i);
2300
+ return B(o);
2301
2301
  }
2302
2302
  /** Returns the RFC 6902 diff and standards summary between two versions. */
2303
2303
  async compare(e, t) {
2304
- const [s, o, i] = await Promise.all([
2304
+ const [s, i, o] = await Promise.all([
2305
2305
  this.get(e),
2306
2306
  this.get(t),
2307
2307
  this.readChangelog()
2308
- ]), r = Q(s, o), d = new Set(s.standards.map((h) => h.id)), l = new Set(o.standards.map((h) => h.id)), c = o.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), u = s.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (i?.versions ?? []).filter((h) => k.compareVersions(h.version, e) > 0 && k.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2309
- o.standards.filter((h) => d.has(h.id)).map(async (h) => {
2308
+ ]), r = Q(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 })), u = s.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), f = (o?.versions ?? []).filter((h) => k.compareVersions(h.version, e) > 0 && k.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2309
+ i.standards.filter((h) => d.has(h.id)).map(async (h) => {
2310
2310
  const b = (await Promise.all(
2311
- m.map(async ($) => p.file(`changelog/standards/${h.id}/v${$}.md`) !== null ? $ : null)
2311
+ f.map(async ($) => p.file(`changelog/standards/${h.id}/v${$}.md`) !== null ? $ : null)
2312
2312
  )).filter(($) => $ !== null);
2313
2313
  return b.length > 0 ? { id: h.id, name: h.name, changedIn: b } : null;
2314
2314
  })
@@ -2322,14 +2322,14 @@ class k {
2322
2322
  async discard() {
2323
2323
  const e = this.getZip(), t = await this.readBaseline();
2324
2324
  if (!t) throw new Error("No baseline found — call commit() first");
2325
- const s = new Set(t.standards.map((o) => o.id));
2326
- for (const o of this.getBep().standards)
2327
- s.has(o.id) || e.remove(o.contentPath);
2328
- for (const o of t.standards) {
2329
- const i = e.file(`baseline/standards/${o.id}.md`);
2330
- if (!i) continue;
2331
- const r = await i.async("string");
2332
- e.file(o.contentPath, r);
2325
+ const s = new Set(t.standards.map((i) => i.id));
2326
+ for (const i of this.getBep().standards)
2327
+ s.has(i.id) || e.remove(i.contentPath);
2328
+ for (const i of t.standards) {
2329
+ const o = e.file(`baseline/standards/${i.id}.md`);
2330
+ if (!o) continue;
2331
+ const r = await o.async("string");
2332
+ e.file(i.contentPath, r);
2333
2333
  }
2334
2334
  this.setBep(t);
2335
2335
  }
@@ -2338,12 +2338,12 @@ class k {
2338
2338
  * version and immediately commits it as a new version.
2339
2339
  */
2340
2340
  async revert(e, t) {
2341
- const s = this.getZip(), o = await this.get(e);
2342
- for (const i of o.standards) {
2343
- const r = await this.resolveStandardContent(i, e);
2344
- r !== null && s.file(i.contentPath, r);
2341
+ const s = this.getZip(), i = await this.get(e);
2342
+ for (const o of i.standards) {
2343
+ const r = await this.resolveStandardContent(o, e);
2344
+ r !== null && s.file(o.contentPath, r);
2345
2345
  }
2346
- return this.setBep(o), this.commit(t);
2346
+ return this.setBep(i), this.commit(t);
2347
2347
  }
2348
2348
  /**
2349
2349
  * Returns a structured diff of the current BEP state vs the last committed baseline.
@@ -2352,17 +2352,17 @@ class k {
2352
2352
  async status() {
2353
2353
  const e = this.getZip(), t = await this.readBaseline();
2354
2354
  if (!t) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
2355
- const s = this.getBep(), o = Rs(s, t), i = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(s.standards.map((c) => c.id));
2355
+ const s = this.getBep(), i = Rs(s, t), o = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(s.standards.map((c) => c.id));
2356
2356
  for (const c of s.standards)
2357
2357
  if (!r.has(c.id))
2358
- i.push({ id: c.id, name: c.name, status: "added" });
2358
+ o.push({ id: c.id, name: c.name, status: "added" });
2359
2359
  else {
2360
- const u = JSON.stringify(r.get(c.id)) !== JSON.stringify(c), f = e.file(`baseline/standards/${c.id}.md`), m = e.file(c.contentPath), p = f ? await f.async("string") : "", g = m ? await m.async("string") : "";
2361
- u ? i.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && i.push({ id: c.id, name: c.name, status: "content-modified" });
2360
+ const u = JSON.stringify(r.get(c.id)) !== JSON.stringify(c), m = e.file(`baseline/standards/${c.id}.md`), f = e.file(c.contentPath), p = m ? await m.async("string") : "", g = f ? await f.async("string") : "";
2361
+ u ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
2362
2362
  }
2363
2363
  for (const c of t.standards)
2364
- d.has(c.id) || i.push({ id: c.id, name: c.name, status: "removed" });
2365
- return { hasPendingChanges: o.changedKeys.length > 0 || i.length > 0, standards: i, ...o };
2364
+ d.has(c.id) || o.push({ id: c.id, name: c.name, status: "removed" });
2365
+ return { hasPendingChanges: i.changedKeys.length > 0 || o.length > 0, standards: o, ...i };
2366
2366
  }
2367
2367
  /** Shorthand — true if there are uncommitted changes since the last commit. */
2368
2368
  async hasPendingChanges() {
@@ -2371,18 +2371,18 @@ class k {
2371
2371
  /** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
2372
2372
  async listResolved() {
2373
2373
  const [e, t] = await Promise.all([this.list(), this.current()]), s = this.getBep().members;
2374
- return e.sort((o, i) => k.compareVersions(o.version, i.version)).map((o) => ({
2375
- version: o.version,
2376
- type: o.type,
2377
- date: o.date,
2378
- description: o.description,
2379
- diff: o.diff,
2380
- isCurrent: o.version === t,
2381
- author: o.author ? { email: o.author, name: s.find((i) => i.email === o.author)?.name ?? null } : null,
2382
- ...o.type === "version" ? {
2383
- approvedBy: o.approvedBy.map((i) => ({
2384
- email: i,
2385
- name: s.find((r) => r.email === i)?.name ?? null
2374
+ return e.sort((i, o) => k.compareVersions(i.version, o.version)).map((i) => ({
2375
+ version: i.version,
2376
+ type: i.type,
2377
+ date: i.date,
2378
+ description: i.description,
2379
+ diff: i.diff,
2380
+ isCurrent: i.version === t,
2381
+ author: i.author ? { email: i.author, name: s.find((o) => o.email === i.author)?.name ?? null } : null,
2382
+ ...i.type === "version" ? {
2383
+ approvedBy: i.approvedBy.map((o) => ({
2384
+ email: o,
2385
+ name: s.find((r) => r.email === o)?.name ?? null
2386
2386
  }))
2387
2387
  } : {}
2388
2388
  }));
@@ -2392,8 +2392,8 @@ class k {
2392
2392
  * Returns null if the standard did not exist at that version.
2393
2393
  */
2394
2394
  async getStandardContent(e, t) {
2395
- const o = (await this.get(t)).standards.find((i) => i.id === e);
2396
- return o ? this.resolveStandardContent(o, t) : null;
2395
+ const i = (await this.get(t)).standards.find((o) => o.id === e);
2396
+ return i ? this.resolveStandardContent(i, t) : null;
2397
2397
  }
2398
2398
  /**
2399
2399
  * ⚠️ Destructive: resets the BEP to a historical version and permanently
@@ -2402,8 +2402,8 @@ class k {
2402
2402
  async reset(e) {
2403
2403
  const t = this.getZip(), s = await this.readChangelog();
2404
2404
  if (!s) throw new Error("No changelog found");
2405
- const o = s.versions.find((c) => c.version === e), i = !!this.getZip().file(`changelog/v${e}.json`);
2406
- if (!o && !i)
2405
+ const i = s.versions.find((c) => c.version === e), o = !!this.getZip().file(`changelog/v${e}.json`);
2406
+ if (!i && !o)
2407
2407
  throw new Error(`Version not found: ${e}`);
2408
2408
  if (e === s.current)
2409
2409
  throw new Error(`Already at version ${e}`);
@@ -2433,18 +2433,18 @@ class k {
2433
2433
  throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
2434
2434
  if (k.compareVersions(e.newBase, s.current) <= 0)
2435
2435
  throw new Error(`newBase "${e.newBase}" must be greater than current version "${s.current}"`);
2436
- const o = this.getBep(), i = e.approvedBy.filter((d) => !o.members.some((l) => l.email === d));
2437
- if (i.length) throw new Error(`Members not found: ${i.join(", ")}`);
2436
+ const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
2437
+ if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
2438
2438
  for (const d of s.versions)
2439
2439
  d.diff && t.remove(d.diff);
2440
- 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(o, null, 2));
2441
- for (const d of o.standards) {
2440
+ 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));
2441
+ for (const d of i.standards) {
2442
2442
  const l = t.file(d.contentPath);
2443
2443
  if (!l) continue;
2444
2444
  const c = await l.async("string");
2445
2445
  t.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
2446
2446
  }
2447
- t.file("baseline/bep.json", JSON.stringify(o, null, 2)), await this.snapshotBaseStandards(o);
2447
+ t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i);
2448
2448
  const r = {
2449
2449
  version: e.newBase,
2450
2450
  type: "version",
@@ -2494,52 +2494,52 @@ function As(n, e) {
2494
2494
  }
2495
2495
  }
2496
2496
  function js(n, e, t, s) {
2497
- const i = n.workflows.find((m) => m.id === t)?.diagram.nodes[e];
2498
- if (!i || i.type !== "process") return !0;
2499
- const r = !!(i.responsibleRoleIds?.length || i.responsibleTeamIds?.length || i.responsibleEmails?.length), d = !!(i.accountableRoleIds?.length || i.accountableTeamIds?.length || i.accountableEmails?.length);
2497
+ const o = n.workflows.find((f) => f.id === t)?.diagram.nodes[e];
2498
+ if (!o || o.type !== "process") return !0;
2499
+ const r = !!(o.responsibleRoleIds?.length || o.responsibleTeamIds?.length || o.responsibleEmails?.length), d = !!(o.accountableRoleIds?.length || o.accountableTeamIds?.length || o.accountableEmails?.length);
2500
2500
  if (!r && !d) return !0;
2501
- const c = n.members.find((m) => m.email === s)?.roleId, u = new Set(n.teams.filter((m) => (m.memberEmails ?? []).includes(s)).map((m) => m.id)), f = (m, p, g) => {
2501
+ const c = n.members.find((f) => f.email === s)?.roleId, u = new Set(n.teams.filter((f) => (f.memberEmails ?? []).includes(s)).map((f) => f.id)), m = (f, p, g) => {
2502
2502
  if (g?.includes(s)) return !0;
2503
- const h = !!m?.length, b = !!p?.length;
2504
- return b && h ? !!c && m.includes(c) && p.some(($) => u.has($)) : b ? p.some(($) => u.has($)) : h ? !!c && m.includes(c) : !1;
2503
+ const h = !!f?.length, b = !!p?.length;
2504
+ return b && h ? !!c && f.includes(c) && p.some(($) => u.has($)) : b ? p.some(($) => u.has($)) : h ? !!c && f.includes(c) : !1;
2505
2505
  };
2506
- return r && f(i.responsibleRoleIds, i.responsibleTeamIds, i.responsibleEmails) || d && f(i.accountableRoleIds, i.accountableTeamIds, i.accountableEmails);
2506
+ return r && m(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && m(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2507
2507
  }
2508
2508
  const Os = { string: "string", number: "number", boolean: "boolean" };
2509
2509
  function _s(n, e, t) {
2510
2510
  const s = n.events.find((d) => d.id === e);
2511
2511
  if (!s?.payload?.length) return [];
2512
- const o = [], i = t ?? {};
2512
+ const i = [], o = t ?? {};
2513
2513
  for (const d of s.payload) {
2514
- const l = i[d.key];
2514
+ const l = o[d.key];
2515
2515
  if (l == null)
2516
- d.required && o.push({ field: d.key, reason: "missing" });
2516
+ d.required && i.push({ field: d.key, reason: "missing" });
2517
2517
  else {
2518
2518
  const c = Os[d.type];
2519
- c && typeof l !== c && o.push({ field: d.key, reason: "wrong_type" });
2519
+ c && typeof l !== c && i.push({ field: d.key, reason: "wrong_type" });
2520
2520
  }
2521
2521
  }
2522
2522
  const r = new Set(s.payload.map((d) => d.key));
2523
- for (const d of Object.keys(i))
2524
- r.has(d) || o.push({ field: d, reason: "unknown_field" });
2525
- return o;
2523
+ for (const d of Object.keys(o))
2524
+ r.has(d) || i.push({ field: d, reason: "unknown_field" });
2525
+ return i;
2526
2526
  }
2527
2527
  function Bs(n, e) {
2528
2528
  return !(!("triggerEventId" in n) || n.triggerEventId !== e.eventId);
2529
2529
  }
2530
- function Ms(n, e, t, s, o) {
2531
- const i = n.workflows.find((f) => f.id === e);
2532
- if (!i) return null;
2533
- const r = Object.keys(i.diagram.nodes).find(
2534
- (f) => i.diagram.nodes[f].type === "start"
2530
+ function Ms(n, e, t, s, i) {
2531
+ const o = n.workflows.find((m) => m.id === e);
2532
+ if (!o) return null;
2533
+ const r = Object.keys(o.diagram.nodes).find(
2534
+ (m) => o.diagram.nodes[m].type === "start"
2535
2535
  );
2536
2536
  if (!r) return null;
2537
- const d = Object.entries(i.diagram.edges).find(([, f]) => f.from === r), l = d?.[1].to ?? r, c = d ? (d[1].effectIds ?? []).map((f) => ({ effectId: f, fromEdgeId: d[0] })) : [], u = (/* @__PURE__ */ new Date()).toISOString();
2537
+ const d = Object.entries(o.diagram.edges).find(([, m]) => m.from === r), l = d?.[1].to ?? r, c = d ? (d[1].effectIds ?? []).map((m) => ({ effectId: m, fromEdgeId: d[0] })) : [], u = (/* @__PURE__ */ new Date()).toISOString();
2538
2538
  return {
2539
2539
  instance: {
2540
2540
  id: globalThis.crypto.randomUUID(),
2541
2541
  workflowId: e,
2542
- bepVersion: o,
2542
+ bepVersion: i,
2543
2543
  trackedAsset: t,
2544
2544
  currentNodeId: l,
2545
2545
  status: "active",
@@ -2556,30 +2556,30 @@ function le(n, e, t, s) {
2556
2556
  return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
2557
2557
  if (!s?.skipRaci && !js(n, e.currentNodeId, e.workflowId, t.actor))
2558
2558
  return { ok: !1, error: "UNAUTHORIZED" };
2559
- const o = n.workflows.find((N) => N.id === e.workflowId);
2560
- if (!o) return { ok: !1, error: "NO_MATCHING_EDGE" };
2561
- const { nodes: i, edges: r } = o.diagram;
2559
+ const i = n.workflows.find((N) => N.id === e.workflowId);
2560
+ if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
2561
+ const { nodes: o, edges: r } = i.diagram;
2562
2562
  let d = e.currentNodeId;
2563
- const l = [], c = [], u = [], f = Object.entries(r).filter(
2563
+ const l = [], c = [], u = [], m = Object.entries(r).filter(
2564
2564
  ([, N]) => N.from === d && Bs(N, t)
2565
2565
  );
2566
- if (f.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2567
- if (f.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2568
- const [m, p] = f[0];
2566
+ if (m.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2567
+ if (m.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2568
+ const [f, p] = m[0];
2569
2569
  if ("triggerEventId" in p) {
2570
2570
  const N = _s(n, p.triggerEventId, t.payload);
2571
2571
  if (N.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: N };
2572
2572
  }
2573
- l.push(ce(m, d, p.to, t)), c.push(...(p.effectIds ?? []).map((N) => ({ effectId: N, fromEdgeId: m }))), u.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2573
+ l.push(ce(f, d, p.to, t)), c.push(...(p.effectIds ?? []).map((N) => ({ effectId: N, fromEdgeId: f }))), u.push({ edgeId: f, fromNodeId: d, toNodeId: p.to }), d = p.to;
2574
2574
  let g = 0;
2575
- for (; i[d]?.type === "decision"; ) {
2575
+ for (; o[d]?.type === "decision"; ) {
2576
2576
  if (++g > Ts) return { ok: !1, error: "DECISION_LOOP" };
2577
2577
  const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 : As(v.guard, t.payload ?? {}));
2578
2578
  if (N.length === 0) break;
2579
2579
  const [A, w] = N[0];
2580
2580
  l.push(ce(A, d, w.to, t, !0)), c.push(...(w.effectIds ?? []).map((v) => ({ effectId: v, fromEdgeId: A }))), u.push({ edgeId: A, fromNodeId: d, toNodeId: w.to }), d = w.to;
2581
2581
  }
2582
- const h = i[d], b = h?.type === "end" ? "completed" : "active", $ = {
2582
+ const h = o[d], b = h?.type === "end" ? "completed" : "active", $ = {
2583
2583
  ...e,
2584
2584
  currentNodeId: d,
2585
2585
  status: b,
@@ -2589,28 +2589,28 @@ function le(n, e, t, s) {
2589
2589
  return { ok: !0, instance: $, transitionsApplied: u, effectsToFire: c, automationNodePending: T };
2590
2590
  }
2591
2591
  function xs(n, e, t) {
2592
- const s = n.workflows.find((w) => w.id === e.workflowId), { nodes: o, edges: i } = s.diagram, r = o[e.currentNodeId], l = n.members.find((w) => w.email === t)?.roleId, c = new Set(
2592
+ const s = n.workflows.find((w) => w.id === e.workflowId), { nodes: i, edges: o } = s.diagram, r = i[e.currentNodeId], l = n.members.find((w) => w.email === t)?.roleId, c = new Set(
2593
2593
  n.teams.filter((w) => (w.memberEmails ?? []).includes(t)).map((w) => w.id)
2594
2594
  ), u = (w) => (w ?? []).flatMap((v) => {
2595
2595
  const S = n.roles.find((_) => _.id === v);
2596
2596
  return S ? [{ id: S.id, name: S.name }] : [];
2597
- }), f = (w) => (w ?? []).flatMap((v) => {
2597
+ }), m = (w) => (w ?? []).flatMap((v) => {
2598
2598
  const S = n.teams.find((_) => _.id === v);
2599
2599
  return S ? [{ id: S.id, name: S.name }] : [];
2600
- }), m = (w, v, S) => ({
2600
+ }), f = (w, v, S) => ({
2601
2601
  roles: u(w),
2602
- teams: f(v),
2602
+ teams: m(v),
2603
2603
  emails: S ?? []
2604
2604
  }), p = (w, v, S) => {
2605
2605
  if (S?.includes(t)) return !0;
2606
- const _ = !!w?.length, oe = !!v?.length;
2607
- return oe && _ ? !!l && w.includes(l) && v.some((J) => c.has(J)) : oe ? v.some((J) => c.has(J)) : _ ? !!l && w.includes(l) : !1;
2606
+ const _ = !!w?.length, ie = !!v?.length;
2607
+ return ie && _ ? !!l && w.includes(l) && v.some((J) => c.has(J)) : ie ? v.some((J) => c.has(J)) : _ ? !!l && w.includes(l) : !1;
2608
2608
  }, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length), b = !!(g?.accountableRoleIds?.length || g?.accountableTeamIds?.length || g?.accountableEmails?.length), $ = !h && !b || h && p(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails) || b && p(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails), T = (w) => (n.events.find((v) => v.id === w)?.payload ?? []).map((v) => ({
2609
2609
  key: v.key,
2610
2610
  type: v.type,
2611
2611
  required: v.required
2612
2612
  })), N = [], A = [];
2613
- for (const [w, v] of Object.entries(i)) {
2613
+ for (const [w, v] of Object.entries(o)) {
2614
2614
  if (v.from !== e.currentNodeId || !("triggerEventId" in v)) continue;
2615
2615
  const S = v.triggerEventId;
2616
2616
  $ ? N.push({
@@ -2622,7 +2622,7 @@ function xs(n, e, t) {
2622
2622
  edgeId: w,
2623
2623
  label: v.label ?? S,
2624
2624
  reason: "UNAUTHORIZED",
2625
- required: m(
2625
+ required: f(
2626
2626
  [...g?.responsibleRoleIds ?? [], ...g?.accountableRoleIds ?? []],
2627
2627
  [...g?.responsibleTeamIds ?? [], ...g?.accountableTeamIds ?? []],
2628
2628
  [...g?.responsibleEmails ?? [], ...g?.accountableEmails ?? []]
@@ -2638,15 +2638,15 @@ function xs(n, e, t) {
2638
2638
  availableTransitions: N,
2639
2639
  blockedTransitions: A,
2640
2640
  raci: {
2641
- responsible: m(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails),
2642
- accountable: m(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails),
2643
- consulted: m(g?.consultedRoleIds, g?.consultedTeamIds, g?.consultedEmails),
2644
- informed: m(g?.informedRoleIds, g?.informedTeamIds, g?.informedEmails)
2641
+ responsible: f(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails),
2642
+ accountable: f(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails),
2643
+ consulted: f(g?.consultedRoleIds, g?.consultedTeamIds, g?.consultedEmails),
2644
+ informed: f(g?.informedRoleIds, g?.informedTeamIds, g?.informedEmails)
2645
2645
  },
2646
2646
  isTerminal: r.type === "end"
2647
2647
  };
2648
2648
  }
2649
- function ce(n, e, t, s, o) {
2649
+ function ce(n, e, t, s, i) {
2650
2650
  return {
2651
2651
  id: globalThis.crypto.randomUUID(),
2652
2652
  edgeId: n,
@@ -2655,7 +2655,7 @@ function ce(n, e, t, s, o) {
2655
2655
  trigger: s,
2656
2656
  actor: s.actor,
2657
2657
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2658
- ...o ? { auto: !0 } : {}
2658
+ ...i ? { auto: !0 } : {}
2659
2659
  };
2660
2660
  }
2661
2661
  class Ps {
@@ -2736,7 +2736,7 @@ class Cs {
2736
2736
  */
2737
2737
  async createInstance(e, t, s) {
2738
2738
  this._assertInit();
2739
- const o = this.getBep(), r = Ms(o, e, t, s, "unversioned");
2739
+ const i = this.getBep(), r = Ms(i, e, t, s, "unversioned");
2740
2740
  if (!r) return null;
2741
2741
  const { instance: d, startEffects: l } = r;
2742
2742
  for (const c of l)
@@ -2758,25 +2758,25 @@ class Cs {
2758
2758
  this._assertInit();
2759
2759
  const s = await this.storage.getInstance(e);
2760
2760
  if (!s) return { ok: !1, error: "NO_MATCHING_EDGE" };
2761
- const o = await this._resolveBep(s.bepVersion);
2762
- let i = le(o, s, t, { skipRaci: this.skipRaci });
2763
- if (!i.ok) return { ok: !1, error: i.error, payloadErrors: i.payloadErrors };
2764
- const r = [...i.transitionsApplied ?? []], d = [];
2765
- let l = i.instance;
2766
- for (const f of i.effectsToFire ?? [])
2767
- d.push(await this._executeEffect(l, f));
2761
+ const i = await this._resolveBep(s.bepVersion);
2762
+ let o = le(i, s, t, { skipRaci: this.skipRaci });
2763
+ if (!o.ok) return { ok: !1, error: o.error, payloadErrors: o.payloadErrors };
2764
+ const r = [...o.transitionsApplied ?? []], d = [];
2765
+ let l = o.instance;
2766
+ for (const m of o.effectsToFire ?? [])
2767
+ d.push(await this._executeEffect(l, m));
2768
2768
  const c = 10;
2769
2769
  let u = 0;
2770
- for (; i.automationNodePending && u++ < c; ) {
2771
- const { automationId: f } = i.automationNodePending, { eventId: m, ...p } = await this._executeAutomationNode(l, f);
2772
- if (i = le(o, l, {
2773
- eventId: m,
2770
+ for (; o.automationNodePending && u++ < c; ) {
2771
+ const { automationId: m } = o.automationNodePending, { eventId: f, ...p } = await this._executeAutomationNode(l, m);
2772
+ if (o = le(i, l, {
2773
+ eventId: f,
2774
2774
  actor: "_system",
2775
2775
  softwareId: "_system",
2776
2776
  payload: p
2777
- }), !i.ok) break;
2778
- l = i.instance, r.push(...i.transitionsApplied ?? []);
2779
- for (const g of i.effectsToFire ?? [])
2777
+ }), !o.ok) break;
2778
+ l = o.instance, r.push(...o.transitionsApplied ?? []);
2779
+ for (const g of o.effectsToFire ?? [])
2780
2780
  d.push(await this._executeEffect(l, g));
2781
2781
  }
2782
2782
  return await this.storage.saveInstance(l), await this._fire(this.transitionListeners, l, r, d), l.status === "completed" && await this._fire(this.completedListeners, l), {
@@ -2797,19 +2797,19 @@ class Cs {
2797
2797
  */
2798
2798
  async getInstances(e) {
2799
2799
  this._assertInit();
2800
- const { pendingActionFor: t, ...s } = e ?? {}, o = await this.storage.listInstances(s);
2801
- if (!t) return o;
2802
- const i = this.getBep(), r = i.members.find((d) => d.email === t);
2803
- return r ? o.filter((d) => {
2804
- const l = i.workflows.find((m) => m.id === d.workflowId);
2800
+ const { pendingActionFor: t, ...s } = e ?? {}, i = await this.storage.listInstances(s);
2801
+ if (!t) return i;
2802
+ const o = this.getBep(), r = o.members.find((d) => d.email === t);
2803
+ return r ? i.filter((d) => {
2804
+ const l = o.workflows.find((f) => f.id === d.workflowId);
2805
2805
  if (!l) return !1;
2806
2806
  const c = l.diagram.nodes[d.currentNodeId];
2807
2807
  if (!c) return !1;
2808
- const u = c.type === "process" ? c : null, f = [
2808
+ const u = c.type === "process" ? c : null, m = [
2809
2809
  ...u?.responsibleRoleIds ?? [],
2810
2810
  ...u?.accountableRoleIds ?? []
2811
2811
  ];
2812
- return f.length === 0 || f.includes(r.roleId);
2812
+ return m.length === 0 || m.includes(r.roleId);
2813
2813
  }) : [];
2814
2814
  }
2815
2815
  /**
@@ -2820,8 +2820,8 @@ class Cs {
2820
2820
  this._assertInit();
2821
2821
  const s = await this.storage.getInstance(e);
2822
2822
  if (!s) return null;
2823
- const o = await this._resolveBep(s.bepVersion);
2824
- return xs(o, s, t);
2823
+ const i = await this._resolveBep(s.bepVersion);
2824
+ return xs(i, s, t);
2825
2825
  }
2826
2826
  async deleteInstance(e) {
2827
2827
  this._assertInit(), await this.storage.deleteInstance(e);
@@ -2832,7 +2832,7 @@ class Cs {
2832
2832
  */
2833
2833
  async getRemoteData(e) {
2834
2834
  this._assertInit();
2835
- const s = this.getBep().remoteData.find((o) => o.id === e);
2835
+ const s = this.getBep().remoteData.find((i) => i.id === e);
2836
2836
  if (!s) throw new Error(`Remote data "${e}" not found in BEP`);
2837
2837
  if (!s.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
2838
2838
  return this.runtime._runResolver(s.resolverId, s.url);
@@ -2857,23 +2857,23 @@ class Cs {
2857
2857
  }
2858
2858
  _resolveFromHistory(e, t) {
2859
2859
  for (let s = t.length - 1; s >= 0; s--) {
2860
- const o = t[s].trigger.payload ?? {};
2861
- if (e in o) return o[e];
2860
+ const i = t[s].trigger.payload ?? {};
2861
+ if (e in i) return i[e];
2862
2862
  }
2863
2863
  }
2864
2864
  async _executeAutomationNode(e, t) {
2865
- const i = this.getBep().automations.find((l) => l.id === t)?.payload ?? [], r = Object.fromEntries(i.map((l) => [l.key, this._resolveFromHistory(l.key, e.history)])), d = this.runtime.automations[t];
2865
+ const o = this.getBep().automations.find((l) => l.id === t)?.payload ?? [], r = Object.fromEntries(o.map((l) => [l.key, this._resolveFromHistory(l.key, e.history)])), d = this.runtime.automations[t];
2866
2866
  if (!d) throw new Error(`No handler declared for automation "${t}"`);
2867
2867
  return d(e, r);
2868
2868
  }
2869
2869
  async _executeEffect(e, t) {
2870
- const i = this.getBep().effects.find((c) => c.id === t.effectId)?.payload ?? [], r = i.filter((c) => c.required && this._resolveFromHistory(c.key, e.history) === void 0).map((c) => c.key);
2870
+ const o = this.getBep().effects.find((c) => c.id === t.effectId)?.payload ?? [], r = o.filter((c) => c.required && this._resolveFromHistory(c.key, e.history) === void 0).map((c) => c.key);
2871
2871
  if (r.length > 0)
2872
2872
  return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped", missingFields: r };
2873
2873
  const d = this.runtime.effects[t.effectId];
2874
2874
  if (!d)
2875
2875
  return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped" };
2876
- const l = Object.fromEntries(i.map((c) => [c.key, this._resolveFromHistory(c.key, e.history)]));
2876
+ const l = Object.fromEntries(o.map((c) => [c.key, this._resolveFromHistory(c.key, e.history)]));
2877
2877
  try {
2878
2878
  return await d(e, l), { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "executed" };
2879
2879
  } catch (c) {
@@ -2885,48 +2885,48 @@ class Cs {
2885
2885
  function Js(n, e) {
2886
2886
  const t = /* @__PURE__ */ new Map();
2887
2887
  for (const s of n) {
2888
- const o = [e(s)].flat();
2889
- for (const i of o)
2890
- t.has(i) || t.set(i, []), t.get(i).push(s);
2888
+ const i = [e(s)].flat();
2889
+ for (const o of i)
2890
+ t.has(o) || t.set(o, []), t.get(o).push(s);
2891
2891
  }
2892
- return Array.from(t.entries()).map(([s, o]) => ({ key: s, rows: o }));
2892
+ return Array.from(t.entries()).map(([s, i]) => ({ key: s, rows: i }));
2893
2893
  }
2894
2894
  function Ks(n, e = "responsible", t = {}) {
2895
- const { topologicalSort: s = !1 } = t, o = (m) => `_${m}`, i = "#444444", r = Object.entries(n.nodes), d = r.find(([, m]) => m.type === "start")?.[0], l = r.find(([, m]) => m.type === "end")?.[0];
2895
+ const { topologicalSort: s = !1 } = t, i = (f) => `_${f}`, o = "#444444", r = Object.entries(n.nodes), d = r.find(([, f]) => f.type === "start")?.[0], l = r.find(([, f]) => f.type === "end")?.[0];
2896
2896
  let c;
2897
2897
  if (s && d) {
2898
- const m = /* @__PURE__ */ new Set(), p = [d], g = [];
2898
+ const f = /* @__PURE__ */ new Set(), p = [d], g = [];
2899
2899
  for (; p.length; ) {
2900
2900
  const h = p.shift();
2901
- if (!m.has(h)) {
2902
- m.add(h), g.push(h);
2901
+ if (!f.has(h)) {
2902
+ f.add(h), g.push(h);
2903
2903
  for (const b of Object.values(n.edges))
2904
- b.from === h && !m.has(b.to) && p.push(b.to);
2904
+ b.from === h && !f.has(b.to) && p.push(b.to);
2905
2905
  }
2906
2906
  }
2907
2907
  for (const [h] of r)
2908
- m.has(h) || g.push(h);
2908
+ f.has(h) || g.push(h);
2909
2909
  c = g;
2910
2910
  } else {
2911
- const m = r.map(([p]) => p).filter((p) => p !== d && p !== l);
2911
+ const f = r.map(([p]) => p).filter((p) => p !== d && p !== l);
2912
2912
  c = [
2913
2913
  ...d ? [d] : [],
2914
- ...m,
2914
+ ...f,
2915
2915
  ...l ? [l] : []
2916
2916
  ];
2917
2917
  }
2918
2918
  const u = [`flowchart ${n.direction}`];
2919
- for (const m of c) {
2920
- const p = n.nodes[m];
2919
+ for (const f of c) {
2920
+ const p = n.nodes[f];
2921
2921
  if (!p) continue;
2922
- const g = p.type === "start" || p.type === "end", b = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, "&quot;"), $ = g || p.type === "decision" ? [] : p[e].roles.map((A) => A.name), T = $.length > 0 ? `"<b>${$.join(" · ")}</b><br/>${b}"` : `"${b || m}"`;
2923
- g ? u.push(` ${o(m)}([${b || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${o(m)}{${T}}`) : p.type === "automation" ? u.push(` ${o(m)}[[${T}]]`) : u.push(` ${o(m)}(${T})`);
2924
- const N = p[e].roles[0]?.color ?? i;
2925
- g ? u.push(` style ${o(m)} fill:#2962FF,stroke:none`) : u.push(` style ${o(m)} fill:none,stroke:${N},stroke-width:3px`);
2926
- }
2927
- const f = s ? c.flatMap((m) => Object.values(n.edges).filter((p) => p.from === m)) : Object.values(n.edges);
2928
- for (const m of f)
2929
- m.label ? u.push(` ${o(m.from)} -->|${m.label}| ${o(m.to)}`) : u.push(` ${o(m.from)} --> ${o(m.to)}`);
2922
+ const g = p.type === "start" || p.type === "end", b = (p.type === "decision" ? p.label ?? f : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, "&quot;"), $ = g || p.type === "decision" ? [] : p[e].roles.map((A) => A.name), T = $.length > 0 ? `"<b>${$.join(" · ")}</b><br/>${b}"` : `"${b || f}"`;
2923
+ g ? u.push(` ${i(f)}([${b || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${i(f)}{${T}}`) : p.type === "automation" ? u.push(` ${i(f)}[[${T}]]`) : u.push(` ${i(f)}(${T})`);
2924
+ const N = p[e].roles[0]?.color ?? o;
2925
+ g ? u.push(` style ${i(f)} fill:#2962FF,stroke:none`) : u.push(` style ${i(f)} fill:none,stroke:${N},stroke-width:3px`);
2926
+ }
2927
+ const m = s ? c.flatMap((f) => Object.values(n.edges).filter((p) => p.from === f)) : Object.values(n.edges);
2928
+ for (const f of m)
2929
+ f.label ? u.push(` ${i(f.from)} -->|${f.label}| ${i(f.to)}`) : u.push(` ${i(f.from)} --> ${i(f.to)}`);
2930
2930
  return u.join(`
2931
2931
  `);
2932
2932
  }
@@ -2970,22 +2970,22 @@ class D {
2970
2970
  const s = () => this._data;
2971
2971
  this.project = new jt(
2972
2972
  () => this._data.project,
2973
- (o) => {
2974
- this._data.project = o;
2973
+ (i) => {
2974
+ this._data.project = i;
2975
2975
  },
2976
2976
  fe,
2977
- (o, i) => {
2978
- const r = [], d = x("project", o.code, i.deliverableNamingConvention);
2979
- return d && r.push(d), o.clientId && !i.teams.some((l) => l.id === o.clientId) && r.push(`teams["${o.clientId}"] not found`), r;
2977
+ (i, o) => {
2978
+ const r = [], d = x("project", i.code, o.deliverableNamingConvention);
2979
+ return d && r.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && r.push(`teams["${i.clientId}"] not found`), r;
2980
2980
  },
2981
2981
  s
2982
- ), this.actions = new _t(s), this.adapters = new Bt(s), this.annexes = new Mt(s), this.env = new Ft(s), this.events = new Ct(s), this.effects = new xt(s), this.automations = new Pt(s), this.bimUses = new Jt(s, () => this.workflows), this.disciplines = new Kt(s), this.guides = new qt(s), this.lods = new Wt(s), this.lois = new Gt(s), this.loin = new Vt(s), this.lbsNodes = new Qt(s), this.assetTypes = new Xt(s), this.extensions = new Ht(s), this.roles = new Yt(s), this.members = new es(s), this.milestones = new ts(s), this.objectives = new ss(s), this.phases = new ns(s), this.remoteData = new os(s), this.resolvers = new is(s), this.softwares = new rs(s, () => this.assetTypes), this.standards = new as(s, () => this._zip), this.teams = new ds(s, () => this.members), this.workflows = new cs(s, () => this.members, () => this.teams), this.deliverables = new Ut(s, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Zt(s, () => this.members), this.flags = new zt(s), this.engine = new Cs(
2982
+ ), this.actions = new _t(s), this.adapters = new Bt(s), this.annexes = new Mt(s), this.env = new Ft(s), this.events = new Ct(s), this.effects = new xt(s), this.automations = new Pt(s), this.bimUses = new Jt(s, () => this.workflows), this.disciplines = new Kt(s), this.guides = new qt(s), this.lods = new Wt(s), this.lois = new Gt(s), this.loin = new Xt(s), this.lbsNodes = new Qt(s), this.assetTypes = new Vt(s), this.extensions = new Ht(s), this.roles = new Yt(s), this.members = new es(s), this.milestones = new ts(s), this.objectives = new ss(s), this.phases = new ns(s), this.remoteData = new is(s), this.resolvers = new os(s), this.softwares = new rs(s, () => this.assetTypes), this.standards = new as(s, () => this._zip), this.teams = new ds(s, () => this.members), this.workflows = new cs(s, () => this.members, () => this.teams), this.deliverables = new Ut(s, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Zt(s, () => this.members), this.flags = new zt(s), this.engine = new Cs(
2983
2983
  () => this._data,
2984
- (o) => this.history.get(o)
2984
+ (i) => this.history.get(i)
2985
2985
  ), this.history = new k(
2986
2986
  s,
2987
- (o) => {
2988
- this._data = o;
2987
+ (i) => {
2988
+ this._data = i;
2989
2989
  },
2990
2990
  () => this._zip
2991
2991
  ), this.nomenclature = new Lt(s), this.memory = new q("memory.md", () => this._zip), this.skill = new q("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new q("icon.svg", () => this._zip);
@@ -3046,10 +3046,10 @@ class D {
3046
3046
  * fully operational after open(). Idempotent — existing files are untouched.
3047
3047
  */
3048
3048
  static async open(e) {
3049
- const t = await ie.loadAsync(e), s = t.file("bep.json");
3049
+ const t = await oe.loadAsync(e), s = t.file("bep.json");
3050
3050
  if (!s) throw new Error("Invalid .bep file: missing bep.json");
3051
- const o = await s.async("string"), i = B(JSON.parse(o));
3052
- return await D._initialize(i, t), new D(i, t);
3051
+ const i = await s.async("string"), o = B(JSON.parse(i));
3052
+ return await D._initialize(o, t), new D(o, t);
3053
3053
  }
3054
3054
  /**
3055
3055
  * Ensures all expected files exist in the zip.
@@ -3069,9 +3069,9 @@ class D {
3069
3069
  if (!t.file("baseline/bep.json")) {
3070
3070
  const s = JSON.stringify(e, null, 2);
3071
3071
  t.file("baseline/bep.json", s), t.file("changelog/v0.0.json", s);
3072
- for (const o of e.standards) {
3073
- const i = await t.file(o.contentPath).async("string");
3074
- t.file(`baseline/standards/${o.id}.md`, i), t.file(`changelog/standards/${o.id}/v0.0.md`, i);
3072
+ for (const i of e.standards) {
3073
+ const o = await t.file(i.contentPath).async("string");
3074
+ t.file(`baseline/standards/${i.id}.md`, o), t.file(`changelog/standards/${i.id}/v0.0.md`, o);
3075
3075
  }
3076
3076
  }
3077
3077
  }
@@ -3105,8 +3105,8 @@ class D {
3105
3105
  flags: [],
3106
3106
  env: [],
3107
3107
  automations: []
3108
- }), s = new ie(), o = JSON.stringify(t, null, 2);
3109
- return s.file("memory.md", ""), s.file("skills/bep-authoring/SKILL.md", ""), s.file("baseline/bep.json", o), s.file("changelog/v0.0.json", o), new D(t, s);
3108
+ }), s = new oe(), i = JSON.stringify(t, null, 2);
3109
+ 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 D(t, s);
3110
3110
  }
3111
3111
  // ─── Accessors ────────────────────────────────────────────────────────────
3112
3112
  get data() {
@@ -3155,8 +3155,8 @@ ${s.join(`
3155
3155
  /** Returns the names of all resource files for the given skill. */
3156
3156
  listSkillResources(e) {
3157
3157
  const t = `skills/${e}/resources/`, s = [];
3158
- return this._zip.forEach((o) => {
3159
- o.startsWith(t) && o !== t && s.push(o.slice(t.length));
3158
+ return this._zip.forEach((i) => {
3159
+ i.startsWith(t) && i !== t && s.push(i.slice(t.length));
3160
3160
  }), s;
3161
3161
  }
3162
3162
  /** Returns the content of a resource file for the given skill, or null if it does not exist. */
@@ -3171,9 +3171,9 @@ ${s.join(`
3171
3171
  /** Removes a skill's SKILL.md and all its resources from the archive. No-op if not found. */
3172
3172
  removeSkill(e) {
3173
3173
  const t = `skills/${e}/`, s = [];
3174
- this._zip.forEach((o) => {
3175
- o.startsWith(t) && s.push(o);
3176
- }), s.forEach((o) => this._zip.remove(o));
3174
+ this._zip.forEach((i) => {
3175
+ i.startsWith(t) && s.push(i);
3176
+ }), s.forEach((i) => this._zip.remove(i));
3177
3177
  }
3178
3178
  /** Removes a single resource file from a skill. No-op if not found. */
3179
3179
  removeSkillResource(e, t) {
@@ -3191,14 +3191,15 @@ ${s.join(`
3191
3191
  */
3192
3192
  generateRuntimeTypes() {
3193
3193
  const e = (f) => f === "url" ? "string" : f, t = (f) => ` /** ${f} */
3194
- `, s = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`, o = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${s(f.payload)}) => void`, i = (f) => {
3195
- const m = f.payload && f.payload.length > 0 ? `payload: ${s(f.payload)}` : "", p = f.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${f.output.map((g) => `${g.key}${g.required ? "" : "?"}: ${e(g.type)}`).join("; ")} }`;
3196
- return `(${m}) => ${p}`;
3197
- }, r = (f) => f.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${f.envKeys.map((p) => `${p}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((f) => `${t(f.description)} '${f.id}': ${o(f)}`).join(`
3198
- `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${i(f)}`).join(`
3194
+ `, s = (f) => `{ ${f.map((p) => `${p.key}${p.required ? "" : "?"}: ${e(p.type)}`).join("; ")} }`, i = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${s(f.payload)}) => void`, o = (f) => {
3195
+ const p = f.payload && f.payload.length > 0 ? `payload: ${s(f.payload)}` : "", g = f.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${f.output.map((h) => `${h.key}${h.required ? "" : "?"}: ${e(h.type)}`).join("; ")} }`;
3196
+ return `(${p}) => ${g}`;
3197
+ }, r = (f) => f.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${f.envKeys.map((g) => `${g}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((f) => `${t(f.description)} '${f.id}': ${i(f)}`).join(`
3198
+ `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${o(f)}`).join(`
3199
3199
  `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((f) => `${t(f.description)} '${f.id}': ${r(f)}`).join(`
3200
3200
  `) : " [key: string]: (url: string) => unknown", u = this._data.adapters.length ? this._data.adapters.map((f) => `${t(f.description)} '${f.id}': (data: unknown) => unknown`).join(`
3201
- `) : " [key: string]: (data: unknown) => unknown";
3201
+ `) : " [key: string]: (data: unknown) => unknown", m = this._data.env.length ? this._data.env.map((f) => `${t(f.description)} ${f.key}: string`).join(`
3202
+ `) : " [key: string]: string";
3202
3203
  return [
3203
3204
  "// Generated by bep.generateRuntimeTypes() — do not edit manually",
3204
3205
  "",
@@ -3226,6 +3227,12 @@ ${s.join(`
3226
3227
  u,
3227
3228
  "}",
3228
3229
  "",
3230
+ "// ─── Env ──────────────────────────────────────────────────────────────────────",
3231
+ "",
3232
+ "export interface BepEnv {",
3233
+ m,
3234
+ "}",
3235
+ "",
3229
3236
  "// ─── Combined ─────────────────────────────────────────────────────────────────",
3230
3237
  "",
3231
3238
  "export interface BepTypes {",
@@ -3233,6 +3240,7 @@ ${s.join(`
3233
3240
  " automations: BepAutomations",
3234
3241
  " resolvers: BepResolvers",
3235
3242
  " adapters: BepAdapters",
3243
+ " env: BepEnv",
3236
3244
  "}",
3237
3245
  ""
3238
3246
  ].join(`
@@ -3257,7 +3265,7 @@ export {
3257
3265
  Qe as AnnexType,
3258
3266
  Mt as Annexes,
3259
3267
  Ie as AssetTypeSchema,
3260
- Xt as AssetTypes,
3268
+ Vt as AssetTypes,
3261
3269
  Pt as Automations,
3262
3270
  zs as BEPSchema,
3263
3271
  re as BEPVersionBase,
@@ -3313,7 +3321,7 @@ export {
3313
3321
  Qt as LBSNodes,
3314
3322
  Me as LODSchema,
3315
3323
  Wt as LODs,
3316
- Vt as LOINEntity,
3324
+ Xt as LOINEntity,
3317
3325
  Et as LOINMilestoneSchema,
3318
3326
  Pe as LOINSchema,
3319
3327
  xe as LOISchema,
@@ -3325,7 +3333,7 @@ export {
3325
3333
  ts as Milestones,
3326
3334
  he as NamingConventionSchema,
3327
3335
  rt as NamingSegmentSchema,
3328
- it as NamingTokenSchema,
3336
+ ot as NamingTokenSchema,
3329
3337
  dt as NodeTimeoutSchema,
3330
3338
  Us as NodeType,
3331
3339
  Lt as Nomenclature,
@@ -3336,10 +3344,10 @@ export {
3336
3344
  ge as PhaseSchema,
3337
3345
  ns as Phases,
3338
3346
  fe as ProjectSchema,
3339
- os as RemoteDataEntity,
3347
+ is as RemoteDataEntity,
3340
3348
  Ze as RemoteDataSchema,
3341
3349
  Ue as ResolverSchema,
3342
- is as Resolvers,
3350
+ os as Resolvers,
3343
3351
  ue as RoleSchema,
3344
3352
  Yt as Roles,
3345
3353
  qs as Runtime,
@@ -3348,7 +3356,7 @@ export {
3348
3356
  rs as Softwares,
3349
3357
  Be as StandardSchema,
3350
3358
  as as Standards,
3351
- ot as TeamBaseSchema,
3359
+ it as TeamBaseSchema,
3352
3360
  pe as TeamSchema,
3353
3361
  ds as Teams,
3354
3362
  q as TextFile,