@dotbep/core 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import oe from "jszip";
1
+ import re from "jszip";
2
2
  import { z as a, ZodError as Ve } from "zod";
3
3
  const He = a.enum([
4
4
  "appointing-party",
@@ -55,19 +55,19 @@ const He = a.enum([
55
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 = nt.refine((s) => !s.representativeEmail || (s.memberEmails ?? []).includes(s.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",
62
62
  "assetType",
63
63
  "lbsZone",
64
64
  "lbsLocation"
65
- ]), ot = a.discriminatedUnion("type", [
66
- a.object({ type: a.literal("field"), token: it, pattern: a.string().optional() }),
65
+ ]), it = a.discriminatedUnion("type", [
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),
70
- segments: a.array(ot).min(1)
70
+ segments: a.array(it).min(1)
71
71
  }).describe("A structured rule for generating deliverable names. Specifies a delimiter and a sequence of segments that are joined to produce consistent, parseable file names.").refine((s) => s.segments.filter((e) => e.type === "sequence").length <= 1, {
72
72
  message: "segments can contain at most one sequence.",
73
73
  path: ["segments"]
@@ -87,10 +87,10 @@ const He = a.enum([
87
87
  type: Qe,
88
88
  description: a.string().optional(),
89
89
  lbsNodeIds: a.array(a.string()).optional().describe("ref LBSNode.id[]")
90
- }).describe("A spatial or functional subdivision of the project. LBS nodes form a hierarchy that scopes deliverables to specific spatial or functional areas."), be = rt.refine((s) => !(s.lbsNodeIds ?? []).includes(s.id), {
90
+ }).describe("A spatial or functional subdivision of the project. LBS nodes form a hierarchy that scopes deliverables to specific spatial or functional areas."), we = rt.refine((s) => !(s.lbsNodeIds ?? []).includes(s.id), {
91
91
  message: "A node cannot reference itself in lbsNodeIds.",
92
92
  path: ["lbsNodeIds"]
93
- }), we = a.object({
93
+ }), be = a.object({
94
94
  id: a.string().min(1).describe("Used in deliverables nomenclature."),
95
95
  name: a.string().min(1)
96
96
  }).describe("A project discipline used to classify deliverables and information requirements. Represents a technical domain such as structure, architecture, or MEP."), ve = a.object({
@@ -200,7 +200,7 @@ const He = a.enum([
200
200
  }).refine((s) => s.operator === "exists" || s.value !== void 0, {
201
201
  message: 'value is required when operator is not "exists".',
202
202
  path: ["value"]
203
- }), ee = a.object({
203
+ }), te = a.object({
204
204
  from: a.string().describe("ref FlowNode key"),
205
205
  to: a.string().describe("ref FlowNode key"),
206
206
  label: a.string().optional(),
@@ -208,30 +208,30 @@ const He = a.enum([
208
208
  }).refine((s) => s.from !== s.to, {
209
209
  message: "A flow edge cannot point from a node to itself.",
210
210
  path: ["to"]
211
- }), gt = ee.extend({
211
+ }), gt = te.extend({
212
212
  triggerEventId: a.string().min(1).describe("ref FlowEvent.id — the event that fires this transition")
213
- }), yt = ee.extend({
213
+ }), yt = te.extend({
214
214
  guard: ht.describe("Condition evaluated against the instance context to determine which path to take.")
215
- }), bt = ee, wt = a.union([gt, yt, bt]), vt = a.object({
215
+ }), wt = te, bt = a.union([gt, yt, wt]), vt = a.object({
216
216
  direction: et.default("LR"),
217
217
  nodes: a.record(a.string(), pt),
218
- edges: a.record(a.string(), wt)
218
+ edges: a.record(a.string(), bt)
219
219
  }).superRefine((s, e) => {
220
- const t = Object.entries(s.nodes), n = t.filter(([, r]) => r.type === "start").length, i = t.filter(([, r]) => r.type === "end").length;
220
+ const t = Object.entries(s.nodes), n = t.filter(([, r]) => r.type === "start").length, o = t.filter(([, r]) => r.type === "end").length;
221
221
  n !== 1 && e.addIssue({
222
222
  code: "custom",
223
223
  message: `Diagram must have exactly one start node (found ${n}).`,
224
224
  path: ["nodes"]
225
- }), i !== 1 && e.addIssue({
225
+ }), o !== 1 && e.addIssue({
226
226
  code: "custom",
227
- message: `Diagram must have exactly one end node (found ${i}).`,
227
+ message: `Diagram must have exactly one end node (found ${o}).`,
228
228
  path: ["nodes"]
229
229
  });
230
- const o = {};
230
+ const i = {};
231
231
  for (const [r, d] of Object.entries(s.edges))
232
- o[d.from] ??= [], o[d.from].push({ edgeId: r, toKey: d.to });
232
+ i[d.from] ??= [], i[d.from].push({ edgeId: r, toKey: d.to });
233
233
  for (const [r, d] of t) {
234
- const l = o[r] ?? [];
234
+ const l = i[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}).`,
@@ -366,8 +366,8 @@ const He = a.enum([
366
366
  teams: a.array(pe),
367
367
  phases: a.array(ge),
368
368
  milestones: a.array(ye),
369
- lbs: a.array(be),
370
- disciplines: a.array(we),
369
+ lbs: a.array(we),
370
+ disciplines: a.array(be),
371
371
  extensions: a.array(ve),
372
372
  assetTypes: a.array(Ie),
373
373
  softwares: a.array(Ee),
@@ -390,15 +390,15 @@ const He = a.enum([
390
390
  deliverables: a.array(De),
391
391
  notes: a.array(Fe),
392
392
  flags: a.array(Ce)
393
- }), re = a.object({
393
+ }), ae = a.object({
394
394
  version: a.string().regex(/^\d+\.\d+$/).describe('Format: "{major}.{minor}" (e.g. "1.0", "2.3").'),
395
395
  date: a.iso.datetime(),
396
396
  author: a.email().describe("ref Member.email"),
397
397
  description: a.string().min(1),
398
398
  diff: a.string().nullable().describe("Relative path to inverse diff (RFC 6902). null on v0.0.")
399
399
  }), St = a.discriminatedUnion("type", [
400
- re.extend({ type: a.literal("patch") }),
401
- re.extend({
400
+ ae.extend({ type: a.literal("patch") }),
401
+ ae.extend({
402
402
  type: a.literal("version"),
403
403
  approvedBy: a.array(a.email()).describe("ref Member.email[]")
404
404
  })
@@ -418,24 +418,24 @@ function Rt(s, e) {
418
418
  return $t;
419
419
  }
420
420
  function x(s, e, t) {
421
- const n = t?.delimiter ?? kt, i = Rt(s, t);
422
- return new RegExp(i).test(e) ? e.includes(n) ? `"${e}" contains the naming delimiter "${n}"` : null : `"${e}" does not match naming pattern ${i} for token "${s}"`;
421
+ const n = t?.delimiter ?? kt, o = Rt(s, t);
422
+ return new RegExp(o).test(e) ? e.includes(n) ? `"${e}" contains the naming delimiter "${n}"` : null : `"${e}" does not match naming pattern ${o} for token "${s}"`;
423
423
  }
424
424
  function Tt(s, e) {
425
- const t = [], n = (i, o) => {
426
- const r = x(i, o, e);
425
+ const t = [], n = (o, i) => {
426
+ const r = x(o, i, e);
427
427
  r && t.push(r);
428
428
  };
429
429
  n("project", s.project.code);
430
- for (const i of s.teams) n("team", i.id);
431
- for (const i of s.disciplines) n("discipline", i.id);
432
- for (const i of s.assetTypes) n("assetType", i.id);
433
- for (const i of s.lbs) n(i.type === "zone" ? "lbsZone" : "lbsLocation", i.id);
430
+ for (const o of s.teams) n("team", o.id);
431
+ for (const o of s.disciplines) n("discipline", o.id);
432
+ for (const o of s.assetTypes) n("assetType", o.id);
433
+ for (const o of s.lbs) n(o.type === "zone" ? "lbsZone" : "lbsLocation", o.id);
434
434
  return t;
435
435
  }
436
436
  class jt {
437
- constructor(e, t, n, i, o) {
438
- this.getItem = e, this.setItem = t, this.schema = n, this.validate = i, this.getBep = o;
437
+ constructor(e, t, n, o, i) {
438
+ this.getItem = e, this.setItem = t, this.schema = n, this.validate = o, this.getBep = i;
439
439
  }
440
440
  getItem;
441
441
  setItem;
@@ -495,26 +495,26 @@ const Ze = [
495
495
  { entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
496
496
  ];
497
497
  function At(s, e, t) {
498
- return Ze.filter((n) => n.references === e).flatMap((n) => t[n.entity].filter((o) => {
499
- const r = o[n.inField];
498
+ return Ze.filter((n) => n.references === e).flatMap((n) => t[n.entity].filter((i) => {
499
+ const r = i[n.inField];
500
500
  return n.array ? Array.isArray(r) && r.includes(s) : r === s;
501
- }).map((o) => {
502
- const r = o.id ?? o.email ?? "?";
501
+ }).map((i) => {
502
+ const r = i.id ?? i.email ?? "?";
503
503
  return `${String(n.entity)}["${r}"].${String(n.inField)}`;
504
504
  }));
505
505
  }
506
- function ae(s, e, t) {
506
+ function de(s, e, t) {
507
507
  return Ze.filter((n) => n.entity === e).flatMap((n) => {
508
- const i = s[n.inField];
509
- if (i == null || i === "") return [];
510
- const o = n.array ? i : [i], r = t[n.references];
511
- return o.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(n.references)}["${d}"] not found`);
508
+ const o = s[n.inField];
509
+ if (o == null || o === "") return [];
510
+ const i = n.array ? o : [o], r = t[n.references];
511
+ return i.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(n.references)}["${d}"] not found`);
512
512
  });
513
513
  }
514
514
  function K(s) {
515
515
  return s instanceof Ve ? s.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : s.message;
516
516
  }
517
- class y {
517
+ class w {
518
518
  constructor(e, t, n) {
519
519
  this.getItems = e, this.getBep = t, this.config = n, this.idField = n.idField ?? "id";
520
520
  }
@@ -530,23 +530,23 @@ class y {
530
530
  }
531
531
  get(e) {
532
532
  const t = [], n = [];
533
- for (const i of e) {
534
- const o = this.getItems().find((r) => this.getId(r) === i);
535
- o ? t.push(o) : n.push({ id: i, error: `Not found: ${i}` });
533
+ for (const o of e) {
534
+ const i = this.getItems().find((r) => this.getId(r) === o);
535
+ i ? t.push(i) : n.push({ id: o, error: `Not found: ${o}` });
536
536
  }
537
537
  return { succeeded: t, failed: n };
538
538
  }
539
539
  add(e) {
540
540
  const t = [], n = [];
541
- for (const i of e) {
542
- const o = { ...i };
543
- this.config.autoId && !o[this.idField] && (o[this.idField] = globalThis.crypto.randomUUID());
544
- const r = String(o[this.idField] ?? "(unknown)");
541
+ for (const o of e) {
542
+ const i = { ...o };
543
+ this.config.autoId && !i[this.idField] && (i[this.idField] = globalThis.crypto.randomUUID());
544
+ const r = String(i[this.idField] ?? "(unknown)");
545
545
  try {
546
- const d = this.config.schema.parse(o);
546
+ const d = this.config.schema.parse(i);
547
547
  if (this.getItems().some((u) => this.getId(u) === this.getId(d)))
548
548
  throw new Error(`Already exists: ${this.getId(d)}`);
549
- const l = ae(d, this.config.key, this.getBep());
549
+ const l = de(d, this.config.key, this.getBep());
550
550
  if (l.length) throw new Error(l.join("; "));
551
551
  const c = this.config.validate?.(d, this.getBep()) ?? [];
552
552
  if (c.length) throw new Error(c.join("; "));
@@ -559,47 +559,47 @@ class y {
559
559
  }
560
560
  update(e) {
561
561
  const t = [], n = [];
562
- for (const i of e) {
563
- const o = String(i[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === o);
562
+ for (const o of e) {
563
+ const i = String(o[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === i);
564
564
  if (d === -1) {
565
- n.push({ id: o, error: `Not found: ${o}` });
565
+ n.push({ id: i, error: `Not found: ${i}` });
566
566
  continue;
567
567
  }
568
- const l = ae(i, this.config.key, this.getBep());
568
+ const l = de(o, this.config.key, this.getBep());
569
569
  if (l.length) {
570
- n.push({ id: o, error: l.join("; ") });
570
+ n.push({ id: i, error: l.join("; ") });
571
571
  continue;
572
572
  }
573
573
  try {
574
- const c = this.config.schema.parse({ ...r[d], ...i }), u = this.config.validate?.(c, this.getBep()) ?? [];
574
+ const c = this.config.schema.parse({ ...r[d], ...o }), u = this.config.validate?.(c, this.getBep()) ?? [];
575
575
  if (u.length) throw new Error(u.join("; "));
576
576
  r[d] = c, t.push(r[d]);
577
577
  } catch (c) {
578
- n.push({ id: o, error: K(c) });
578
+ n.push({ id: i, error: K(c) });
579
579
  }
580
580
  }
581
581
  return { succeeded: t, failed: n };
582
582
  }
583
583
  remove(e) {
584
584
  const t = [], n = [];
585
- for (const i of e) {
586
- const o = this.getItems(), r = o.findIndex((d) => this.getId(d) === i);
585
+ for (const o of e) {
586
+ const i = this.getItems(), r = i.findIndex((d) => this.getId(d) === o);
587
587
  if (r === -1) {
588
- n.push({ id: i, error: `Not found: ${i}` });
588
+ n.push({ id: o, error: `Not found: ${o}` });
589
589
  continue;
590
590
  }
591
591
  try {
592
- const d = At(i, this.config.key, this.getBep());
592
+ const d = At(o, this.config.key, this.getBep());
593
593
  if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
594
- this.config.beforeRemove?.(i, this.getBep()), o.splice(r, 1), t.push(i);
594
+ this.config.beforeRemove?.(o, this.getBep()), i.splice(r, 1), t.push(o);
595
595
  } catch (d) {
596
- n.push({ id: i, error: K(d) });
596
+ n.push({ id: o, error: K(d) });
597
597
  }
598
598
  }
599
599
  return { succeeded: t, failed: n };
600
600
  }
601
601
  }
602
- class Ot extends y {
602
+ class Ot extends w {
603
603
  constructor(e) {
604
604
  super(
605
605
  () => e().actions,
@@ -609,16 +609,16 @@ class Ot extends y {
609
609
  schema: ke,
610
610
  autoId: !0,
611
611
  beforeRemove: (t, n) => {
612
- for (const i of n.workflows)
613
- for (const [o, r] of Object.entries(i.diagram.nodes))
612
+ for (const o of n.workflows)
613
+ for (const [i, r] of Object.entries(o.diagram.nodes))
614
614
  if (r.type === "process" && r.actionId === t)
615
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].actionId`);
615
+ throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].actionId`);
616
616
  }
617
617
  }
618
618
  );
619
619
  }
620
620
  }
621
- class _t extends y {
621
+ class _t extends w {
622
622
  constructor(e) {
623
623
  super(
624
624
  () => e().annexes,
@@ -631,7 +631,7 @@ class _t extends y {
631
631
  );
632
632
  }
633
633
  }
634
- class Bt extends y {
634
+ class Bt extends w {
635
635
  constructor(e) {
636
636
  super(
637
637
  () => e().effects,
@@ -640,20 +640,20 @@ class Bt extends y {
640
640
  key: "effects",
641
641
  schema: Re,
642
642
  beforeRemove: (t, n) => {
643
- for (const i of n.workflows) {
644
- for (const [o, r] of Object.entries(i.diagram.nodes))
643
+ for (const o of n.workflows) {
644
+ for (const [i, r] of Object.entries(o.diagram.nodes))
645
645
  if ((r.type === "process" || r.type === "automation") && r.timeouts?.some((d) => d.effectId === t))
646
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].timeouts[].effectId`);
647
- for (const [o, r] of Object.entries(i.diagram.edges))
646
+ throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].timeouts[].effectId`);
647
+ for (const [i, r] of Object.entries(o.diagram.edges))
648
648
  if (r.effectIds?.includes(t))
649
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].effectIds`);
649
+ throw new Error(`Referenced by: workflows["${o.id}"].diagram.edges["${i}"].effectIds`);
650
650
  }
651
651
  }
652
652
  }
653
653
  );
654
654
  }
655
655
  }
656
- class Mt extends y {
656
+ class Mt extends w {
657
657
  constructor(e) {
658
658
  super(
659
659
  () => e().automations,
@@ -662,16 +662,16 @@ class Mt extends y {
662
662
  key: "automations",
663
663
  schema: Te,
664
664
  beforeRemove: (t, n) => {
665
- for (const i of n.workflows)
666
- for (const [o, r] of Object.entries(i.diagram.nodes))
665
+ for (const o of n.workflows)
666
+ for (const [i, r] of Object.entries(o.diagram.nodes))
667
667
  if (r.type === "automation" && r.automationId === t)
668
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].automationId`);
668
+ throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].automationId`);
669
669
  }
670
670
  }
671
671
  );
672
672
  }
673
673
  }
674
- class xt extends y {
674
+ class xt extends w {
675
675
  constructor(e) {
676
676
  super(
677
677
  () => e().env,
@@ -684,7 +684,7 @@ class xt extends y {
684
684
  );
685
685
  }
686
686
  }
687
- class Pt extends y {
687
+ class Pt extends w {
688
688
  constructor(e) {
689
689
  super(
690
690
  () => e().events,
@@ -693,10 +693,10 @@ class Pt extends y {
693
693
  key: "events",
694
694
  schema: $e,
695
695
  beforeRemove: (t, n) => {
696
- for (const i of n.workflows)
697
- for (const [o, r] of Object.entries(i.diagram.edges))
696
+ for (const o of n.workflows)
697
+ for (const [i, r] of Object.entries(o.diagram.edges))
698
698
  if ("triggerEventId" in r && r.triggerEventId === t)
699
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].trigger`);
699
+ throw new Error(`Referenced by: workflows["${o.id}"].diagram.edges["${i}"].trigger`);
700
700
  }
701
701
  }
702
702
  );
@@ -709,7 +709,7 @@ function C(s) {
709
709
  e.set(n, t.id);
710
710
  return e;
711
711
  }
712
- function te(s) {
712
+ function se(s) {
713
713
  const e = /* @__PURE__ */ new Set();
714
714
  for (const t of s)
715
715
  for (const n of t.lbsNodeIds ?? []) e.add(n);
@@ -717,22 +717,22 @@ function te(s) {
717
717
  }
718
718
  function Je(s, e) {
719
719
  if (!s) return { zoneCode: "XXX", locationCode: "XXX" };
720
- const t = new Map(e.map((d) => [d.id, d])), n = C(e), i = te(e), o = t.get(s);
721
- if (!o) return { zoneCode: "XXX", locationCode: "XXX" };
722
- if (i.has(o.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
723
- if (o.type === "zone") return { zoneCode: o.id, locationCode: "ZZZ" };
724
- let r = n.get(o.id);
720
+ const t = new Map(e.map((d) => [d.id, d])), n = C(e), o = se(e), i = t.get(s);
721
+ if (!i) return { zoneCode: "XXX", locationCode: "XXX" };
722
+ if (o.has(i.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
723
+ if (i.type === "zone") return { zoneCode: i.id, locationCode: "ZZZ" };
724
+ let r = n.get(i.id);
725
725
  for (; r; ) {
726
726
  const d = t.get(r);
727
727
  if (!d) break;
728
- if (d.type === "zone" && !i.has(d.id))
729
- return { zoneCode: d.id, locationCode: o.id };
728
+ if (d.type === "zone" && !o.has(d.id))
729
+ return { zoneCode: d.id, locationCode: i.id };
730
730
  r = n.get(r);
731
731
  }
732
- return { zoneCode: "ZZZ", locationCode: o.id };
732
+ return { zoneCode: "ZZZ", locationCode: i.id };
733
733
  }
734
734
  function Ft(s) {
735
- const e = [], t = new Map(s.map((d) => [d.id, d])), n = te(s);
735
+ const e = [], t = new Map(s.map((d) => [d.id, d])), n = se(s);
736
736
  for (const d of n) {
737
737
  const l = t.get(d);
738
738
  l && l.type !== "zone" && e.push(`Root node "${d}" must be of type "zone".`);
@@ -741,36 +741,36 @@ function Ft(s) {
741
741
  if (d.type === "location")
742
742
  for (const l of d.lbsNodeIds ?? [])
743
743
  t.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
744
- const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
744
+ const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
745
745
  function r(d) {
746
- if (o.has(d)) return !0;
747
- if (i.has(d)) return !1;
748
- i.add(d), o.add(d);
746
+ if (i.has(d)) return !0;
747
+ if (o.has(d)) return !1;
748
+ o.add(d), i.add(d);
749
749
  for (const l of t.get(d)?.lbsNodeIds ?? [])
750
750
  if (r(l))
751
751
  return e.push(`Cycle detected in LBS tree at node "${d}".`), !0;
752
- return o.delete(d), !1;
752
+ return i.delete(d), !1;
753
753
  }
754
754
  for (const d of s)
755
- i.has(d.id) || r(d.id);
755
+ o.has(d.id) || r(d.id);
756
756
  return e;
757
757
  }
758
- function W(s) {
758
+ function X(s) {
759
759
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
760
760
  for (const n of s) {
761
- const i = (t.get(n.responsibleId) ?? 0) + 1;
762
- t.set(n.responsibleId, i), e.set(n.id, i);
761
+ const o = (t.get(n.responsibleId) ?? 0) + 1;
762
+ t.set(n.responsibleId, o), e.set(n.id, o);
763
763
  }
764
764
  return e;
765
765
  }
766
766
  const F = "XXX";
767
- function Ke(s, e, t, n, i) {
768
- const { zoneCode: o, locationCode: r } = Je(s.lbsNodeId, n);
769
- if (!i) {
767
+ function Ke(s, e, t, n, o) {
768
+ const { zoneCode: i, locationCode: r } = Je(s.lbsNodeId, n);
769
+ if (!o) {
770
770
  const l = String(t.get(s.id) ?? 0).padStart(3, "0");
771
- return [e, s.responsibleId, o, r, s.assetTypeId, s.disciplineId, l].join("-");
771
+ return [e, s.responsibleId, i, r, s.assetTypeId, s.disciplineId, l].join("-");
772
772
  }
773
- return i.segments.map((l) => {
773
+ return o.segments.map((l) => {
774
774
  if (l.type === "sequence") {
775
775
  const c = l.padding ?? 3;
776
776
  return String(t.get(s.id) ?? 0).padStart(c, "0");
@@ -785,17 +785,17 @@ function Ke(s, e, t, n, i) {
785
785
  case "assetType":
786
786
  return s.assetTypeId || F;
787
787
  case "lbsZone":
788
- return o;
788
+ return i;
789
789
  case "lbsLocation":
790
790
  return r;
791
791
  }
792
- }).join(i.delimiter);
792
+ }).join(o.delimiter);
793
793
  }
794
794
  function qe(s, e, t, n) {
795
- const i = W(s);
796
- return new Map(s.map((o) => [
797
- o.id,
798
- Ke(o, e, i, t, n)
795
+ const o = X(s);
796
+ return new Map(s.map((i) => [
797
+ i.id,
798
+ Ke(i, e, o, t, n)
799
799
  ]));
800
800
  }
801
801
  class Ct {
@@ -805,17 +805,17 @@ class Ct {
805
805
  getBep;
806
806
  /** Maps every deliverable id to its sequence number within its originator team. */
807
807
  buildConsecutivoMap() {
808
- return W(this.getBep().deliverables);
808
+ return X(this.getBep().deliverables);
809
809
  }
810
810
  /**
811
811
  * Returns the nomenclature code for a single deliverable.
812
812
  * Returns null if the deliverable id is not found.
813
813
  */
814
814
  getCode(e) {
815
- const t = this.getBep(), n = t.deliverables.find((o) => o.id === e);
815
+ const t = this.getBep(), n = t.deliverables.find((i) => i.id === e);
816
816
  if (!n) return null;
817
- const i = W(t.deliverables);
818
- return Ke(n, t.project.code, i, t.lbs, t.deliverableNamingConvention);
817
+ const o = X(t.deliverables);
818
+ return Ke(n, t.project.code, o, t.lbs, t.deliverableNamingConvention);
819
819
  }
820
820
  /** Builds the complete map of deliverable.id → nomenclature code. */
821
821
  buildCodeMap() {
@@ -823,8 +823,8 @@ class Ct {
823
823
  return qe(e.deliverables, e.project.code, e.lbs, e.deliverableNamingConvention);
824
824
  }
825
825
  }
826
- class Dt extends y {
827
- constructor(e, t, n, i, o) {
826
+ class Dt extends w {
827
+ constructor(e, t, n, o, i) {
828
828
  super(
829
829
  () => e().deliverables,
830
830
  e,
@@ -833,23 +833,23 @@ class Dt extends y {
833
833
  schema: De,
834
834
  autoId: !0
835
835
  }
836
- ), this.getTeams = t, this.getAssetTypes = n, this.getLBSNodes = i, this.getMilestones = o;
836
+ ), this.getTeams = t, this.getAssetTypes = n, this.getLBSNodes = o, this.getMilestones = i;
837
837
  }
838
838
  getTeams;
839
839
  getAssetTypes;
840
840
  getLBSNodes;
841
841
  getMilestones;
842
842
  listResolved() {
843
- const e = this.getBep(), t = qe(e.deliverables, e.project.code, e.lbs), n = 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();
843
+ const e = this.getBep(), t = qe(e.deliverables, e.project.code, e.lbs), n = 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();
844
844
  for (const l of e.deliverables) {
845
845
  const c = r.get(l.milestoneId) ?? null;
846
846
  d.set(l.id, {
847
847
  ...l,
848
848
  nomenclatureCode: t.get(l.id) ?? "",
849
849
  effectiveDate: l.dueDate ?? c?.date ?? "",
850
- lbsNode: l.lbsNodeId ? o.get(l.lbsNodeId) ?? null : null,
850
+ lbsNode: l.lbsNodeId ? i.get(l.lbsNodeId) ?? null : null,
851
851
  discipline: e.disciplines.find((u) => u.id === l.disciplineId) ?? null,
852
- assetType: i.get(l.assetTypeId) ?? null,
852
+ assetType: o.get(l.assetTypeId) ?? null,
853
853
  extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((f) => f.id === u)).filter(Boolean),
854
854
  responsible: n.get(l.responsibleId) ?? null,
855
855
  milestone: c,
@@ -864,7 +864,7 @@ class Dt extends y {
864
864
  return [...d.values()];
865
865
  }
866
866
  }
867
- class Lt extends y {
867
+ class Lt extends w {
868
868
  constructor(e) {
869
869
  super(
870
870
  () => e().flags,
@@ -877,7 +877,7 @@ class Lt extends y {
877
877
  );
878
878
  }
879
879
  }
880
- class Ut extends y {
880
+ class Ut extends w {
881
881
  constructor(e, t) {
882
882
  super(
883
883
  () => e().notes,
@@ -898,7 +898,7 @@ class Ut extends y {
898
898
  }));
899
899
  }
900
900
  }
901
- class zt extends y {
901
+ class zt extends w {
902
902
  constructor(e, t) {
903
903
  super(
904
904
  () => e().bimUses,
@@ -907,15 +907,15 @@ class zt extends y {
907
907
  key: "bimUses",
908
908
  schema: Se,
909
909
  autoId: !0,
910
- validate: (n, i) => {
911
- const o = [];
910
+ validate: (n, o) => {
911
+ const i = [];
912
912
  for (const r of n.objectiveIds ?? [])
913
- i.objectives.some((d) => d.id === r) || o.push(`objectives["${r}"] not found`);
913
+ o.objectives.some((d) => d.id === r) || i.push(`objectives["${r}"] not found`);
914
914
  for (const r of n.milestoneIds ?? [])
915
- i.milestones.some((d) => d.id === r) || o.push(`milestones["${r}"] not found`);
915
+ o.milestones.some((d) => d.id === r) || i.push(`milestones["${r}"] not found`);
916
916
  for (const r of n.workflowIds ?? [])
917
- i.workflows.some((d) => d.id === r) || o.push(`workflows["${r}"] not found`);
918
- return o;
917
+ o.workflows.some((d) => d.id === r) || i.push(`workflows["${r}"] not found`);
918
+ return i;
919
919
  }
920
920
  }
921
921
  ), this.getWorkflows = t;
@@ -925,32 +925,32 @@ class zt extends y {
925
925
  const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((n) => [n.id, n]));
926
926
  return e.bimUses.map((n) => ({
927
927
  ...n,
928
- objectives: (n.objectiveIds ?? []).map((i) => e.objectives.find((o) => o.id === i)).filter(Boolean),
929
- milestones: (n.milestoneIds ?? []).map((i) => {
930
- const o = e.milestones.find((r) => r.id === i);
931
- return o ? { ...o, phase: e.phases.find((r) => r.id === o.phaseId) ?? null } : null;
928
+ objectives: (n.objectiveIds ?? []).map((o) => e.objectives.find((i) => i.id === o)).filter(Boolean),
929
+ milestones: (n.milestoneIds ?? []).map((o) => {
930
+ const i = e.milestones.find((r) => r.id === o);
931
+ return i ? { ...i, phase: e.phases.find((r) => r.id === i.phaseId) ?? null } : null;
932
932
  }).filter(Boolean),
933
- workflows: (n.workflowIds ?? []).map((i) => t.get(i)).filter(Boolean)
933
+ workflows: (n.workflowIds ?? []).map((o) => t.get(o)).filter(Boolean)
934
934
  }));
935
935
  }
936
936
  }
937
- class Zt extends y {
937
+ class Zt extends w {
938
938
  constructor(e) {
939
939
  super(
940
940
  () => e().disciplines,
941
941
  e,
942
942
  {
943
943
  key: "disciplines",
944
- schema: we,
944
+ schema: be,
945
945
  validate: (t, n) => {
946
- const i = x("discipline", t.id, n.deliverableNamingConvention);
947
- return i ? [i] : [];
946
+ const o = x("discipline", t.id, n.deliverableNamingConvention);
947
+ return o ? [o] : [];
948
948
  }
949
949
  }
950
950
  );
951
951
  }
952
952
  }
953
- class Jt extends y {
953
+ class Jt extends w {
954
954
  constructor(e) {
955
955
  super(
956
956
  () => e().guides,
@@ -966,11 +966,11 @@ class Jt extends y {
966
966
  const e = this.getBep();
967
967
  return e.guides.map((t) => ({
968
968
  ...t,
969
- annexes: (t.annexIds ?? []).map((n) => e.annexes.find((i) => i.id === n)).filter(Boolean)
969
+ annexes: (t.annexIds ?? []).map((n) => e.annexes.find((o) => o.id === n)).filter(Boolean)
970
970
  }));
971
971
  }
972
972
  }
973
- class Kt extends y {
973
+ class Kt extends w {
974
974
  constructor(e) {
975
975
  super(
976
976
  () => e().lods,
@@ -979,14 +979,14 @@ class Kt extends y {
979
979
  key: "lods",
980
980
  schema: Me,
981
981
  beforeRemove: (t, n) => {
982
- for (const i of n.loin)
983
- if (i.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${t}]`);
982
+ for (const o of n.loin)
983
+ if (o.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[lodId=${t}]`);
984
984
  }
985
985
  }
986
986
  );
987
987
  }
988
988
  }
989
- class qt extends y {
989
+ class qt extends w {
990
990
  constructor(e) {
991
991
  super(
992
992
  () => e().lois,
@@ -995,14 +995,14 @@ class qt extends y {
995
995
  key: "lois",
996
996
  schema: xe,
997
997
  beforeRemove: (t, n) => {
998
- for (const i of n.loin)
999
- if (i.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[loiId=${t}]`);
998
+ for (const o of n.loin)
999
+ if (o.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[loiId=${t}]`);
1000
1000
  }
1001
1001
  }
1002
1002
  );
1003
1003
  }
1004
1004
  }
1005
- class Wt extends y {
1005
+ class Wt extends w {
1006
1006
  constructor(e) {
1007
1007
  super(
1008
1008
  () => e().loin,
@@ -1012,62 +1012,62 @@ class Wt extends y {
1012
1012
  schema: Pe,
1013
1013
  autoId: !0,
1014
1014
  validate: (t, n) => {
1015
- const i = [];
1016
- for (const o of t.milestones ?? [])
1017
- n.milestones.some((r) => r.id === o.milestoneId) || i.push(`milestones["${o.milestoneId}"] not found`), n.lods.some((r) => r.id === o.lodId) || i.push(`lods[${o.lodId}] not found`), n.lois.some((r) => r.id === o.loiId) || i.push(`lois[${o.loiId}] not found`);
1018
- return i;
1015
+ const o = [];
1016
+ for (const i of t.milestones ?? [])
1017
+ n.milestones.some((r) => r.id === i.milestoneId) || o.push(`milestones["${i.milestoneId}"] not found`), n.lods.some((r) => r.id === i.lodId) || o.push(`lods[${i.lodId}] not found`), n.lois.some((r) => r.id === i.loiId) || o.push(`lois[${i.loiId}] not found`);
1018
+ return o;
1019
1019
  }
1020
1020
  }
1021
1021
  );
1022
1022
  }
1023
1023
  addMilestones(e) {
1024
1024
  const t = [], n = [];
1025
- for (const i of e) {
1026
- const o = this.getBep().loin.find((c) => c.id === i.loinId);
1027
- if (!o) {
1028
- n.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1025
+ for (const o of e) {
1026
+ const i = this.getBep().loin.find((c) => c.id === o.loinId);
1027
+ if (!i) {
1028
+ n.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
1029
1029
  continue;
1030
1030
  }
1031
- const r = i.milestones.find((c) => (o.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
1031
+ const r = o.milestones.find((c) => (i.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
1032
1032
  if (r) {
1033
- n.push({ loinId: i.loinId, error: `Milestone "${r.milestoneId}" already exists. Use updateMilestones to modify it.` });
1033
+ n.push({ loinId: o.loinId, error: `Milestone "${r.milestoneId}" already exists. Use updateMilestones to modify it.` });
1034
1034
  continue;
1035
1035
  }
1036
- const d = [...o.milestones ?? [], ...i.milestones], l = this.update([{ id: i.loinId, milestones: d }]);
1036
+ const d = [...i.milestones ?? [], ...o.milestones], l = this.update([{ id: o.loinId, milestones: d }]);
1037
1037
  if (l.failed.length > 0) {
1038
- n.push({ loinId: i.loinId, error: l.failed[0].error });
1038
+ n.push({ loinId: o.loinId, error: l.failed[0].error });
1039
1039
  continue;
1040
1040
  }
1041
- t.push({ loinId: i.loinId, element: o.element, addedMilestones: i.milestones.map((c) => c.milestoneId) });
1041
+ t.push({ loinId: o.loinId, element: i.element, addedMilestones: o.milestones.map((c) => c.milestoneId) });
1042
1042
  }
1043
1043
  return { succeeded: t, failed: n };
1044
1044
  }
1045
1045
  updateMilestones(e) {
1046
1046
  const t = [], n = [];
1047
- for (const i of e) {
1048
- const o = this.getBep().loin.find((f) => f.id === i.loinId);
1049
- if (!o) {
1050
- n.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1047
+ for (const o of e) {
1048
+ const i = this.getBep().loin.find((f) => f.id === o.loinId);
1049
+ if (!i) {
1050
+ n.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
1051
1051
  continue;
1052
1052
  }
1053
- const r = i.milestones.find((f) => !(o.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
1053
+ const r = o.milestones.find((f) => !(i.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
1054
1054
  if (r) {
1055
- n.push({ loinId: i.loinId, error: `Milestone "${r.milestoneId}" not found. Use addMilestones to create it.` });
1055
+ n.push({ loinId: o.loinId, error: `Milestone "${r.milestoneId}" not found. Use addMilestones to create it.` });
1056
1056
  continue;
1057
1057
  }
1058
- const d = new Map(o.milestones.map((f) => [f.milestoneId, { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath }])), l = (o.milestones ?? []).map((f) => {
1059
- const m = i.milestones.find((p) => p.milestoneId === f.milestoneId);
1058
+ const d = new Map(i.milestones.map((f) => [f.milestoneId, { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath }])), l = (i.milestones ?? []).map((f) => {
1059
+ const m = o.milestones.find((p) => p.milestoneId === f.milestoneId);
1060
1060
  return m ? { ...f, ...m } : f;
1061
- }), c = this.update([{ id: i.loinId, milestones: l }]);
1061
+ }), c = this.update([{ id: o.loinId, milestones: l }]);
1062
1062
  if (c.failed.length > 0) {
1063
- n.push({ loinId: i.loinId, error: c.failed[0].error });
1063
+ n.push({ loinId: o.loinId, error: c.failed[0].error });
1064
1064
  continue;
1065
1065
  }
1066
- const u = this.getBep().loin.find((f) => f.id === i.loinId);
1066
+ const u = this.getBep().loin.find((f) => f.id === o.loinId);
1067
1067
  t.push({
1068
- loinId: i.loinId,
1069
- element: o.element,
1070
- milestones: i.milestones.map((f) => {
1068
+ loinId: o.loinId,
1069
+ element: i.element,
1070
+ milestones: o.milestones.map((f) => {
1071
1071
  const m = u.milestones.find((g) => g.milestoneId === f.milestoneId), p = d.get(f.milestoneId);
1072
1072
  return { milestoneId: f.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
1073
1073
  })
@@ -1077,18 +1077,18 @@ class Wt extends y {
1077
1077
  }
1078
1078
  removeMilestones(e) {
1079
1079
  const t = [], n = [];
1080
- for (const i of e) {
1081
- const o = this.getBep().loin.find((d) => d.id === i.loinId);
1082
- if (!o) {
1083
- n.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1080
+ for (const o of e) {
1081
+ const i = this.getBep().loin.find((d) => d.id === o.loinId);
1082
+ if (!i) {
1083
+ n.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
1084
1084
  continue;
1085
1085
  }
1086
- const r = i.milestoneIds.filter((d) => !(o.milestones ?? []).some((l) => l.milestoneId === d));
1086
+ const r = o.milestoneIds.filter((d) => !(i.milestones ?? []).some((l) => l.milestoneId === d));
1087
1087
  if (r.length > 0) {
1088
- n.push({ loinId: i.loinId, error: `Milestones not found in this LOIN: ${r.join(", ")}` });
1088
+ n.push({ loinId: o.loinId, error: `Milestones not found in this LOIN: ${r.join(", ")}` });
1089
1089
  continue;
1090
1090
  }
1091
- o.milestones = (o.milestones ?? []).filter((d) => !i.milestoneIds.includes(d.milestoneId)), t.push({ loinId: i.loinId, element: o.element, removedMilestones: i.milestoneIds });
1091
+ i.milestones = (i.milestones ?? []).filter((d) => !o.milestoneIds.includes(d.milestoneId)), t.push({ loinId: o.loinId, element: i.element, removedMilestones: o.milestoneIds });
1092
1092
  }
1093
1093
  return { succeeded: t, failed: n };
1094
1094
  }
@@ -1099,14 +1099,14 @@ class Wt extends y {
1099
1099
  discipline: e.disciplines.find((n) => n.id === t.disciplineId) ?? null,
1100
1100
  milestones: (t.milestones ?? []).map((n) => ({
1101
1101
  ...n,
1102
- milestone: e.milestones.find((i) => i.id === n.milestoneId) ?? null,
1103
- lod: e.lods.find((i) => i.id === n.lodId) ?? null,
1104
- loi: e.lois.find((i) => i.id === n.loiId) ?? null
1102
+ milestone: e.milestones.find((o) => o.id === n.milestoneId) ?? null,
1103
+ lod: e.lods.find((o) => o.id === n.lodId) ?? null,
1104
+ loi: e.lois.find((o) => o.id === n.loiId) ?? null
1105
1105
  }))
1106
1106
  }));
1107
1107
  }
1108
1108
  }
1109
- class Gt extends y {
1109
+ class Xt extends w {
1110
1110
  constructor(e) {
1111
1111
  super(
1112
1112
  () => e().assetTypes,
@@ -1115,8 +1115,8 @@ class Gt extends y {
1115
1115
  key: "assetTypes",
1116
1116
  schema: Ie,
1117
1117
  validate: (t, n) => {
1118
- const i = x("assetType", t.id, n.deliverableNamingConvention);
1119
- return i ? [i] : [];
1118
+ const o = x("assetType", t.id, n.deliverableNamingConvention);
1119
+ return o ? [o] : [];
1120
1120
  }
1121
1121
  }
1122
1122
  );
@@ -1125,11 +1125,11 @@ class Gt extends y {
1125
1125
  const e = this.getBep();
1126
1126
  return e.assetTypes.map((t) => ({
1127
1127
  ...t,
1128
- extensions: (t.extensionIds ?? []).map((n) => e.extensions.find((i) => i.id === n)).filter(Boolean)
1128
+ extensions: (t.extensionIds ?? []).map((n) => e.extensions.find((o) => o.id === n)).filter(Boolean)
1129
1129
  }));
1130
1130
  }
1131
1131
  }
1132
- class Xt extends y {
1132
+ class Gt extends w {
1133
1133
  constructor(e) {
1134
1134
  super(
1135
1135
  () => e().extensions,
@@ -1141,7 +1141,7 @@ class Xt extends y {
1141
1141
  );
1142
1142
  }
1143
1143
  }
1144
- class Vt extends y {
1144
+ class Vt extends w {
1145
1145
  constructor(e) {
1146
1146
  super(
1147
1147
  () => e().roles,
@@ -1151,120 +1151,120 @@ class Vt extends y {
1151
1151
  schema: ue,
1152
1152
  autoId: !0,
1153
1153
  beforeRemove: (t, n) => {
1154
- const i = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
1155
- for (const o of n.workflows)
1156
- for (const [r, d] of Object.entries(o.diagram.nodes))
1154
+ const o = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
1155
+ for (const i of n.workflows)
1156
+ for (const [r, d] of Object.entries(i.diagram.nodes))
1157
1157
  if (d.type === "process") {
1158
- for (const l of i)
1158
+ for (const l of o)
1159
1159
  if (d[l]?.includes(t))
1160
- throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${r}"].${l}`);
1160
+ throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${r}"].${l}`);
1161
1161
  }
1162
1162
  }
1163
1163
  }
1164
1164
  );
1165
1165
  }
1166
1166
  }
1167
- class Ht extends y {
1167
+ class Ht extends w {
1168
1168
  constructor(e) {
1169
1169
  super(
1170
1170
  () => e().lbs,
1171
1171
  e,
1172
1172
  {
1173
1173
  key: "lbs",
1174
- schema: be,
1174
+ schema: we,
1175
1175
  validate: (t, n) => {
1176
- const i = [], o = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(o, t.id, n.deliverableNamingConvention);
1177
- if (r && i.push(r), t.type === "location" && t.lbsNodeIds?.length) {
1176
+ const o = [], i = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(i, t.id, n.deliverableNamingConvention);
1177
+ if (r && o.push(r), t.type === "location" && t.lbsNodeIds?.length) {
1178
1178
  const d = new Map(n.lbs.map((l) => [l.id, l]));
1179
1179
  for (const l of t.lbsNodeIds ?? [])
1180
- d.get(l)?.type === "zone" && i.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
1180
+ d.get(l)?.type === "zone" && o.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
1181
1181
  }
1182
- return i;
1182
+ return o;
1183
1183
  }
1184
1184
  }
1185
1185
  );
1186
1186
  }
1187
1187
  listResolved() {
1188
- const e = this.getBep(), t = C(e.lbs), n = te(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1189
- return e.lbs.map((o) => {
1190
- const r = t.get(o.id), d = r ? i.get(r) : void 0;
1188
+ const e = this.getBep(), t = C(e.lbs), n = se(e.lbs), o = new Map(e.lbs.map((i) => [i.id, i]));
1189
+ return e.lbs.map((i) => {
1190
+ const r = t.get(i.id), d = r ? o.get(r) : void 0;
1191
1191
  return {
1192
- ...o,
1193
- isRoot: n.has(o.id),
1192
+ ...i,
1193
+ isRoot: n.has(i.id),
1194
1194
  parent: d ? { id: d.id, name: d.name, type: d.type } : null,
1195
- children: (o.lbsNodeIds ?? []).map((l) => i.get(l)).filter(Boolean)
1195
+ children: (i.lbsNodeIds ?? []).map((l) => o.get(l)).filter(Boolean)
1196
1196
  };
1197
1197
  });
1198
1198
  }
1199
1199
  addNodes(e) {
1200
- const t = this.getBep(), n = [], i = [];
1201
- for (const o of e) {
1202
- if (!o.parentId && o.type !== "zone") {
1203
- i.push({ input: o, error: 'Root nodes (no parentId) must be type "zone".' });
1200
+ const t = this.getBep(), n = [], o = [];
1201
+ for (const i of e) {
1202
+ if (!i.parentId && i.type !== "zone") {
1203
+ o.push({ input: i, error: 'Root nodes (no parentId) must be type "zone".' });
1204
1204
  continue;
1205
1205
  }
1206
- if (o.parentId && !t.lbs.find((f) => f.id === o.parentId)) {
1207
- i.push({ input: o, error: `No LBS node found with ID "${o.parentId}".` });
1206
+ if (i.parentId && !t.lbs.find((f) => f.id === i.parentId)) {
1207
+ o.push({ input: i, error: `No LBS node found with ID "${i.parentId}".` });
1208
1208
  continue;
1209
1209
  }
1210
- const { parentId: r, ...d } = o, l = this.add([d]);
1210
+ const { parentId: r, ...d } = i, l = this.add([d]);
1211
1211
  if (l.failed.length > 0) {
1212
- i.push({ input: o, error: l.failed[0].error });
1212
+ o.push({ input: i, error: l.failed[0].error });
1213
1213
  continue;
1214
1214
  }
1215
1215
  let c;
1216
- r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
1216
+ r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(i.id)));
1217
1217
  const u = this.validateTree();
1218
1218
  if (u.length > 0) {
1219
- t.lbs.splice(t.lbs.findIndex((f) => f.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((f) => f !== o.id)), i.push({ input: o, error: u.join("; ") });
1219
+ 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("; ") });
1220
1220
  continue;
1221
1221
  }
1222
- n.push({ ...t.lbs.find((f) => f.id === o.id), parentId: r ?? null });
1222
+ n.push({ ...t.lbs.find((f) => f.id === i.id), parentId: r ?? null });
1223
1223
  }
1224
- return { succeeded: n, failed: i };
1224
+ return { succeeded: n, failed: o };
1225
1225
  }
1226
1226
  updateNodes(e) {
1227
- const t = this.getBep(), n = [], i = [];
1228
- for (const o of e) {
1229
- if (o.parentId && !t.lbs.find((h) => h.id === o.parentId)) {
1230
- i.push({ id: o.id, error: `No LBS node found with ID "${o.parentId}".` });
1227
+ const t = this.getBep(), n = [], o = [];
1228
+ for (const i of e) {
1229
+ if (i.parentId && !t.lbs.find((h) => h.id === i.parentId)) {
1230
+ o.push({ id: i.id, error: `No LBS node found with ID "${i.parentId}".` });
1231
1231
  continue;
1232
1232
  }
1233
- if (o.parentId === o.id) {
1234
- i.push({ id: o.id, error: "A node cannot be its own parent." });
1233
+ if (i.parentId === i.id) {
1234
+ o.push({ id: i.id, error: "A node cannot be its own parent." });
1235
1235
  continue;
1236
1236
  }
1237
- 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]);
1237
+ 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]);
1238
1238
  if (u.failed.length > 0) {
1239
- i.push({ id: o.id, error: u.failed[0].error });
1239
+ o.push({ id: i.id, error: u.failed[0].error });
1240
1240
  continue;
1241
1241
  }
1242
- const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id === o.id);
1242
+ const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id === i.id);
1243
1243
  if (l !== void 0) {
1244
1244
  for (const h of t.lbs)
1245
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
1245
+ h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== i.id));
1246
1246
  if (l) {
1247
- const h = t.lbs.find((b) => b.id === l);
1248
- h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id);
1247
+ const h = t.lbs.find((y) => y.id === l);
1248
+ h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id);
1249
1249
  }
1250
1250
  }
1251
1251
  const p = this.validateTree();
1252
1252
  if (p.length > 0) {
1253
1253
  if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
1254
1254
  for (const h of t.lbs)
1255
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
1255
+ h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== i.id));
1256
1256
  if (f.parentId) {
1257
- const h = t.lbs.find((b) => b.id === f.parentId);
1258
- h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
1257
+ const h = t.lbs.find((y) => y.id === f.parentId);
1258
+ h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id));
1259
1259
  }
1260
1260
  }
1261
- i.push({ id: o.id, error: p.join("; ") });
1261
+ o.push({ id: i.id, error: p.join("; ") });
1262
1262
  continue;
1263
1263
  }
1264
1264
  const g = C(t.lbs).get(m.id) ?? null;
1265
- n.push({ id: o.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1265
+ n.push({ id: i.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1266
1266
  }
1267
- return { succeeded: n, failed: i };
1267
+ return { succeeded: n, failed: o };
1268
1268
  }
1269
1269
  /** Resolves zone and location codes for nomenclature given a node id. */
1270
1270
  resolveCodes(e) {
@@ -1275,7 +1275,7 @@ class Ht extends y {
1275
1275
  return Ft(this.list());
1276
1276
  }
1277
1277
  }
1278
- class Yt extends y {
1278
+ class Yt extends w {
1279
1279
  constructor(e) {
1280
1280
  super(
1281
1281
  () => e().members,
@@ -1290,10 +1290,10 @@ class Yt extends y {
1290
1290
  listResolved() {
1291
1291
  const e = this.getBep();
1292
1292
  return e.members.map((t) => {
1293
- const n = e.teams.find((i) => (i.memberEmails ?? []).includes(t.email));
1293
+ const n = e.teams.find((o) => (o.memberEmails ?? []).includes(t.email));
1294
1294
  return {
1295
1295
  ...t,
1296
- role: e.roles.find((i) => i.id === t.roleId) ?? null,
1296
+ role: e.roles.find((o) => o.id === t.roleId) ?? null,
1297
1297
  team: n ? { id: n.id, name: n.name } : null,
1298
1298
  isRepresentative: n?.representativeEmail === t.email
1299
1299
  };
@@ -1301,66 +1301,66 @@ class Yt extends y {
1301
1301
  }
1302
1302
  addToTeam(e) {
1303
1303
  const t = [], n = [];
1304
- for (const i of e) {
1305
- const r = this.getBep().teams.find((m) => m.id === i.teamId);
1304
+ for (const o of e) {
1305
+ const r = this.getBep().teams.find((m) => m.id === o.teamId);
1306
1306
  if (!r) {
1307
- n.push({ input: i, error: `Team not found: ${i.teamId}` });
1307
+ n.push({ input: o, error: `Team not found: ${o.teamId}` });
1308
1308
  continue;
1309
1309
  }
1310
- const { teamId: d, isRepresentative: l, ...c } = i, u = this.add([c]);
1310
+ const { teamId: d, isRepresentative: l, ...c } = o, u = this.add([c]);
1311
1311
  if (u.failed.length > 0) {
1312
- n.push({ input: i, error: u.failed[0].error });
1312
+ n.push({ input: o, error: u.failed[0].error });
1313
1313
  continue;
1314
1314
  }
1315
- r.memberEmails ??= [], r.memberEmails.includes(i.email) || r.memberEmails.push(i.email), l && (r.representativeEmail = i.email);
1316
- const f = this.listResolved().find((m) => m.email === i.email);
1315
+ r.memberEmails ??= [], r.memberEmails.includes(o.email) || r.memberEmails.push(o.email), l && (r.representativeEmail = o.email);
1316
+ const f = this.listResolved().find((m) => m.email === o.email);
1317
1317
  t.push(f);
1318
1318
  }
1319
1319
  return { succeeded: t, failed: n };
1320
1320
  }
1321
1321
  updateInTeam(e) {
1322
1322
  const t = [], n = [];
1323
- for (const i of e) {
1324
- const o = this.getBep(), { teamId: r, isRepresentative: d, ...l } = i;
1325
- if (r !== void 0 && !o.teams.find((f) => f.id === r)) {
1326
- n.push({ email: i.email, error: `Team not found: ${r}` });
1323
+ for (const o of e) {
1324
+ const i = this.getBep(), { teamId: r, isRepresentative: d, ...l } = o;
1325
+ if (r !== void 0 && !i.teams.find((f) => f.id === r)) {
1326
+ n.push({ email: o.email, error: `Team not found: ${r}` });
1327
1327
  continue;
1328
1328
  }
1329
1329
  const c = this.update([l]);
1330
1330
  if (c.failed.length > 0) {
1331
- n.push({ email: i.email, error: c.failed[0].error });
1331
+ n.push({ email: o.email, error: c.failed[0].error });
1332
1332
  continue;
1333
1333
  }
1334
1334
  if (r !== void 0) {
1335
- const f = o.teams.find((p) => p.id === r), m = o.teams.find((p) => (p.memberEmails ?? []).includes(i.email));
1336
- m && m.id !== r && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !== i.email), m.representativeEmail === i.email && (m.representativeEmail = void 0)), f.memberEmails ??= [], f.memberEmails.includes(i.email) || f.memberEmails.push(i.email);
1335
+ const f = i.teams.find((p) => p.id === r), m = i.teams.find((p) => (p.memberEmails ?? []).includes(o.email));
1336
+ 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);
1337
1337
  }
1338
1338
  if (d !== void 0) {
1339
- const f = o.teams.find((m) => (m.memberEmails ?? []).includes(i.email));
1340
- f && (f.representativeEmail = d ? i.email : f.representativeEmail === i.email ? void 0 : f.representativeEmail);
1339
+ const f = i.teams.find((m) => (m.memberEmails ?? []).includes(o.email));
1340
+ f && (f.representativeEmail = d ? o.email : f.representativeEmail === o.email ? void 0 : f.representativeEmail);
1341
1341
  }
1342
- const u = this.listResolved().find((f) => f.email === i.email);
1343
- t.push({ email: i.email, after: u });
1342
+ const u = this.listResolved().find((f) => f.email === o.email);
1343
+ t.push({ email: o.email, after: u });
1344
1344
  }
1345
1345
  return { succeeded: t, failed: n };
1346
1346
  }
1347
1347
  removeFromBep(e) {
1348
1348
  const t = [], n = [];
1349
- for (const i of e) {
1350
- const o = this.getBep(), r = this.listResolved().find((l) => l.email === i);
1349
+ for (const o of e) {
1350
+ const i = this.getBep(), r = this.listResolved().find((l) => l.email === o);
1351
1351
  if (!r) {
1352
- n.push({ email: i, error: `Not found: ${i}` });
1352
+ n.push({ email: o, error: `Not found: ${o}` });
1353
1353
  continue;
1354
1354
  }
1355
- for (const l of o.teams)
1356
- l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== i)), l.representativeEmail === i && (l.representativeEmail = void 0);
1357
- const d = this.remove([i]);
1355
+ for (const l of i.teams)
1356
+ l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== o)), l.representativeEmail === o && (l.representativeEmail = void 0);
1357
+ const d = this.remove([o]);
1358
1358
  if (d.failed.length > 0) {
1359
1359
  if (r.team) {
1360
- const l = o.teams.find((c) => c.id === r.team.id);
1361
- l && (l.memberEmails ??= [], l.memberEmails.includes(i) || l.memberEmails.push(i), r.isRepresentative && (l.representativeEmail = i));
1360
+ const l = i.teams.find((c) => c.id === r.team.id);
1361
+ l && (l.memberEmails ??= [], l.memberEmails.includes(o) || l.memberEmails.push(o), r.isRepresentative && (l.representativeEmail = o));
1362
1362
  }
1363
- n.push({ email: i, error: d.failed[0].error });
1363
+ n.push({ email: o, error: d.failed[0].error });
1364
1364
  continue;
1365
1365
  }
1366
1366
  t.push(r);
@@ -1368,7 +1368,7 @@ class Yt extends y {
1368
1368
  return { succeeded: t, failed: n };
1369
1369
  }
1370
1370
  }
1371
- class Qt extends y {
1371
+ class Qt extends w {
1372
1372
  constructor(e) {
1373
1373
  super(
1374
1374
  () => e().milestones,
@@ -1378,8 +1378,8 @@ class Qt extends y {
1378
1378
  schema: ye,
1379
1379
  autoId: !0,
1380
1380
  beforeRemove: (t, n) => {
1381
- for (const i of n.loin)
1382
- if (i.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[milestoneId="${t}"]`);
1381
+ for (const o of n.loin)
1382
+ if (o.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[milestoneId="${t}"]`);
1383
1383
  }
1384
1384
  }
1385
1385
  );
@@ -1392,7 +1392,7 @@ class Qt extends y {
1392
1392
  }));
1393
1393
  }
1394
1394
  }
1395
- class es extends y {
1395
+ class es extends w {
1396
1396
  constructor(e) {
1397
1397
  super(
1398
1398
  () => e().objectives,
@@ -1405,7 +1405,7 @@ class es extends y {
1405
1405
  );
1406
1406
  }
1407
1407
  }
1408
- class ts extends y {
1408
+ class ts extends w {
1409
1409
  constructor(e) {
1410
1410
  super(
1411
1411
  () => e().phases,
@@ -1418,7 +1418,7 @@ class ts extends y {
1418
1418
  );
1419
1419
  }
1420
1420
  }
1421
- class ss extends y {
1421
+ class ss extends w {
1422
1422
  constructor(e) {
1423
1423
  super(
1424
1424
  () => e().remoteData,
@@ -1431,7 +1431,7 @@ class ss extends y {
1431
1431
  );
1432
1432
  }
1433
1433
  }
1434
- class ns extends y {
1434
+ class ns extends w {
1435
1435
  constructor(e) {
1436
1436
  super(
1437
1437
  () => e().resolvers,
@@ -1440,14 +1440,14 @@ class ns extends y {
1440
1440
  key: "resolvers",
1441
1441
  schema: Ue,
1442
1442
  beforeRemove: (t, n) => {
1443
- const i = n.remoteData.find((o) => o.resolverId === t);
1444
- if (i) throw new Error(`Referenced by: remoteData["${i.id}"].resolverId`);
1443
+ const o = n.remoteData.find((i) => i.resolverId === t);
1444
+ if (o) throw new Error(`Referenced by: remoteData["${o.id}"].resolverId`);
1445
1445
  }
1446
1446
  }
1447
1447
  );
1448
1448
  }
1449
1449
  }
1450
- class is extends y {
1450
+ class os extends w {
1451
1451
  constructor(e, t) {
1452
1452
  super(
1453
1453
  () => e().softwares,
@@ -1467,7 +1467,7 @@ class is extends y {
1467
1467
  }));
1468
1468
  }
1469
1469
  }
1470
- class os extends y {
1470
+ class is extends w {
1471
1471
  constructor(e, t) {
1472
1472
  super(
1473
1473
  () => e().standards,
@@ -1484,29 +1484,29 @@ class os extends y {
1484
1484
  */
1485
1485
  add(e) {
1486
1486
  const t = e.map((n) => {
1487
- const i = `standards/${globalThis.crypto.randomUUID()}.md`;
1487
+ const o = `standards/${globalThis.crypto.randomUUID()}.md`;
1488
1488
  if ("content" in n) {
1489
- const { content: o, ...r } = n;
1490
- return this.getZip().file(i, o), { ...r, contentPath: i };
1489
+ const { content: i, ...r } = n;
1490
+ return this.getZip().file(o, i), { ...r, contentPath: o };
1491
1491
  }
1492
- return this.getZip().file(i, ""), { ...n, contentPath: i };
1492
+ return this.getZip().file(o, ""), { ...n, contentPath: o };
1493
1493
  });
1494
1494
  return super.add(t);
1495
1495
  }
1496
1496
  /** Removes standards and deletes their .md files from the zip. */
1497
1497
  remove(e) {
1498
1498
  const t = new Map(
1499
- e.map((i) => [i, this.list().find((o) => o.id === i)?.contentPath]).filter((i) => i[1] !== void 0)
1499
+ e.map((o) => [o, this.list().find((i) => i.id === o)?.contentPath]).filter((o) => o[1] !== void 0)
1500
1500
  ), n = super.remove(e);
1501
- for (const i of n.succeeded) {
1502
- const o = t.get(i);
1503
- o && this.getZip().remove(o);
1501
+ for (const o of n.succeeded) {
1502
+ const i = t.get(o);
1503
+ i && this.getZip().remove(i);
1504
1504
  }
1505
1505
  return n;
1506
1506
  }
1507
1507
  /** Returns the markdown text content of the given standard. */
1508
1508
  async getContent(e) {
1509
- const t = this.list().find((i) => i.id === e);
1509
+ const t = this.list().find((o) => o.id === e);
1510
1510
  if (!t) throw new Error(`Standard not found: ${e}`);
1511
1511
  const n = this.getZip().file(t.contentPath);
1512
1512
  if (!n) throw new Error(`Content file not found: ${t.contentPath}`);
@@ -1514,12 +1514,12 @@ class os extends y {
1514
1514
  }
1515
1515
  /** Writes new markdown text content for the given standard. */
1516
1516
  setContent(e, t) {
1517
- const n = this.list().find((i) => i.id === e);
1517
+ const n = this.list().find((o) => o.id === e);
1518
1518
  if (!n) throw new Error(`Standard not found: ${e}`);
1519
1519
  this.getZip().file(n.contentPath, t);
1520
1520
  }
1521
1521
  }
1522
- class rs extends y {
1522
+ class rs extends w {
1523
1523
  constructor(e, t) {
1524
1524
  super(
1525
1525
  () => e().teams,
@@ -1527,12 +1527,12 @@ class rs extends y {
1527
1527
  {
1528
1528
  key: "teams",
1529
1529
  schema: pe,
1530
- validate: (n, i) => {
1531
- const o = [], r = x("team", n.id, i.deliverableNamingConvention);
1532
- return r && o.push(r), n.representativeEmail && !(n.memberEmails ?? []).includes(n.representativeEmail) && o.push(`representativeEmail "${n.representativeEmail}" is not a member of this team`), o;
1530
+ validate: (n, o) => {
1531
+ const i = [], r = x("team", n.id, o.deliverableNamingConvention);
1532
+ return r && i.push(r), n.representativeEmail && !(n.memberEmails ?? []).includes(n.representativeEmail) && i.push(`representativeEmail "${n.representativeEmail}" is not a member of this team`), i;
1533
1533
  },
1534
- beforeRemove: (n, i) => {
1535
- if (i.project.clientId === n)
1534
+ beforeRemove: (n, o) => {
1535
+ if (o.project.clientId === n)
1536
1536
  throw new Error("Referenced by: project.clientId");
1537
1537
  }
1538
1538
  }
@@ -1544,8 +1544,8 @@ class rs extends y {
1544
1544
  return e.teams.map((n) => ({
1545
1545
  ...n,
1546
1546
  representative: t.get(n.representativeEmail ?? "") ?? null,
1547
- members: (n.memberEmails ?? []).map((i) => t.get(i)).filter(Boolean),
1548
- disciplines: (n.disciplineIds ?? []).map((i) => e.disciplines.find((o) => o.id === i)).filter(Boolean)
1547
+ members: (n.memberEmails ?? []).map((o) => t.get(o)).filter(Boolean),
1548
+ disciplines: (n.disciplineIds ?? []).map((o) => e.disciplines.find((i) => i.id === o)).filter(Boolean)
1549
1549
  }));
1550
1550
  }
1551
1551
  }
@@ -1567,10 +1567,10 @@ function as(s, e, t) {
1567
1567
  if (c.type === "automation" && !e.automations.some((u) => u.id === c.automationId) && n.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === t ? n.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((u) => u.id === c.workflowId) || n.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1568
1568
  for (const u of c.timeouts)
1569
1569
  e.effects.some((f) => f.id === u.effectId) || n.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
1570
- const i = Object.keys(s.nodes), o = new Set(Object.values(s.edges).map((l) => l.to)), r = new Set(Object.values(s.edges).map((l) => l.from));
1571
- for (const l of i)
1572
- s.nodes[l].type !== "start" && (o.has(l) || n.push(`node "${l}" is unreachable — no edges point to it`));
1573
- for (const l of i)
1570
+ const o = Object.keys(s.nodes), i = new Set(Object.values(s.edges).map((l) => l.to)), r = new Set(Object.values(s.edges).map((l) => l.from));
1571
+ for (const l of o)
1572
+ s.nodes[l].type !== "start" && (i.has(l) || n.push(`node "${l}" is unreachable — no edges point to it`));
1573
+ for (const l of o)
1574
1574
  s.nodes[l].type !== "end" && (r.has(l) || n.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
1575
1575
  const d = {};
1576
1576
  for (const l of Object.keys(s.edges)) {
@@ -1599,7 +1599,7 @@ function as(s, e, t) {
1599
1599
  }
1600
1600
  return n;
1601
1601
  }
1602
- class ds extends y {
1602
+ class ds extends w {
1603
1603
  constructor(e, t, n) {
1604
1604
  super(
1605
1605
  () => e().workflows,
@@ -1608,18 +1608,18 @@ class ds extends y {
1608
1608
  key: "workflows",
1609
1609
  schema: Ae,
1610
1610
  autoId: !0,
1611
- validate: (i, o) => as(i.diagram, o, i.id)
1611
+ validate: (o, i) => as(o.diagram, i, o.id)
1612
1612
  }
1613
1613
  ), this.getMembers = t, this.getTeams = n;
1614
1614
  }
1615
1615
  getMembers;
1616
1616
  getTeams;
1617
1617
  getRaciMatrix() {
1618
- const e = this.getBep(), t = [], n = /* @__PURE__ */ new Set(), i = this.getMembers().listResolved(), o = this.getTeams().listResolved(), r = (l) => (l ?? []).flatMap((c) => {
1618
+ const e = this.getBep(), t = [], n = /* @__PURE__ */ new Set(), o = this.getMembers().listResolved(), i = this.getTeams().listResolved(), r = (l) => (l ?? []).flatMap((c) => {
1619
1619
  const u = e.roles.find((p) => p.id === c);
1620
1620
  if (!u) return [];
1621
1621
  n.add(c);
1622
- const f = i.filter((p) => p.role?.id === c), m = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1622
+ const f = o.filter((p) => p.role?.id === c), m = i.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1623
1623
  return [{ role: u, members: f, team: m }];
1624
1624
  });
1625
1625
  for (const l of e.workflows)
@@ -1641,10 +1641,10 @@ class ds extends y {
1641
1641
  return { roles: [...n].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
1642
1642
  }
1643
1643
  getRaciMatrixForWorkflow(e) {
1644
- const t = this.getRaciMatrix(), n = t.rows.filter((o) => o.workflow.id === e), i = new Set(
1645
- n.flatMap((o) => [...o.responsible, ...o.accountable, ...o.consulted, ...o.informed].map((r) => r.role.id))
1644
+ const t = this.getRaciMatrix(), n = t.rows.filter((i) => i.workflow.id === e), o = new Set(
1645
+ n.flatMap((i) => [...i.responsible, ...i.accountable, ...i.consulted, ...i.informed].map((r) => r.role.id))
1646
1646
  );
1647
- return { roles: t.roles.filter((o) => i.has(o.id)), rows: n };
1647
+ return { roles: t.roles.filter((i) => o.has(i.id)), rows: n };
1648
1648
  }
1649
1649
  getConsolidatedRaciMatrix() {
1650
1650
  const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), n = (r, d) => {
@@ -1667,33 +1667,33 @@ class ds extends y {
1667
1667
  l.responsible = n(l.responsible, r.responsible), l.accountable = n(l.accountable, r.accountable), l.consulted = n(l.consulted, r.consulted), l.informed = n(l.informed, r.informed);
1668
1668
  }
1669
1669
  }
1670
- const i = [...t.values()], o = new Set(
1671
- i.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
1670
+ const o = [...t.values()], i = new Set(
1671
+ o.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
1672
1672
  );
1673
- return { roles: e.roles.filter((r) => o.has(r.id)), rows: i };
1673
+ return { roles: e.roles.filter((r) => i.has(r.id)), rows: o };
1674
1674
  }
1675
1675
  listResolved() {
1676
1676
  const e = this.getBep();
1677
1677
  return e.workflows.map((t) => {
1678
1678
  const n = {};
1679
- for (const [i, o] of Object.entries(t.diagram.nodes)) {
1679
+ for (const [o, i] of Object.entries(t.diagram.nodes)) {
1680
1680
  const r = (d) => ({
1681
1681
  roles: (d ?? []).map((l) => e.roles.find((c) => c.id === l)).filter(Boolean),
1682
1682
  teams: [],
1683
1683
  members: []
1684
1684
  });
1685
- n[i] = {
1686
- type: o.type,
1687
- label: o.type === "decision" ? o.label : void 0,
1688
- timeouts: o.type === "process" || o.type === "automation" ? o.timeouts : void 0,
1689
- workflowId: o.type === "process" ? o.workflowId : void 0,
1690
- blocking: o.type === "process" ? o.blocking : void 0,
1691
- action: o.type === "process" && o.actionId ? e.actions.find((d) => d.id === o.actionId) ?? null : null,
1692
- automation: o.type === "automation" ? e.automations.find((d) => d.id === o.automationId) ?? null : null,
1693
- responsible: r(o.type === "process" ? o.responsibleRoleIds : void 0),
1694
- accountable: r(o.type === "process" ? o.accountableRoleIds : void 0),
1695
- consulted: r(o.type === "process" ? o.consultedRoleIds : void 0),
1696
- informed: r(o.type === "process" ? o.informedRoleIds : void 0)
1685
+ n[o] = {
1686
+ type: i.type,
1687
+ label: i.type === "decision" ? i.label : void 0,
1688
+ timeouts: i.type === "process" || i.type === "automation" ? i.timeouts : void 0,
1689
+ workflowId: i.type === "process" ? i.workflowId : void 0,
1690
+ blocking: i.type === "process" ? i.blocking : void 0,
1691
+ action: i.type === "process" && i.actionId ? e.actions.find((d) => d.id === i.actionId) ?? null : null,
1692
+ automation: i.type === "automation" ? e.automations.find((d) => d.id === i.automationId) ?? null : null,
1693
+ responsible: r(i.type === "process" ? i.responsibleRoleIds : void 0),
1694
+ accountable: r(i.type === "process" ? i.accountableRoleIds : void 0),
1695
+ consulted: r(i.type === "process" ? i.consultedRoleIds : void 0),
1696
+ informed: r(i.type === "process" ? i.informedRoleIds : void 0)
1697
1697
  };
1698
1698
  }
1699
1699
  return {
@@ -1705,10 +1705,10 @@ class ds extends y {
1705
1705
  }
1706
1706
  var ls = /* @__PURE__ */ (function() {
1707
1707
  var s = function(e, t) {
1708
- return s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, i) {
1709
- n.__proto__ = i;
1710
- } || function(n, i) {
1711
- for (var o in i) i.hasOwnProperty(o) && (n[o] = i[o]);
1708
+ return s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, o) {
1709
+ n.__proto__ = o;
1710
+ } || function(n, o) {
1711
+ for (var i in o) o.hasOwnProperty(i) && (n[i] = o[i]);
1712
1712
  }, s(e, t);
1713
1713
  };
1714
1714
  return function(e, t) {
@@ -1722,7 +1722,7 @@ var ls = /* @__PURE__ */ (function() {
1722
1722
  function G(s, e) {
1723
1723
  return cs.call(s, e);
1724
1724
  }
1725
- function X(s) {
1725
+ function V(s) {
1726
1726
  if (Array.isArray(s)) {
1727
1727
  for (var e = new Array(s.length), t = 0; t < e.length; t++)
1728
1728
  e[t] = "" + t;
@@ -1731,11 +1731,11 @@ function X(s) {
1731
1731
  if (Object.keys)
1732
1732
  return Object.keys(s);
1733
1733
  var n = [];
1734
- for (var i in s)
1735
- G(s, i) && n.push(i);
1734
+ for (var o in s)
1735
+ G(s, o) && n.push(o);
1736
1736
  return n;
1737
1737
  }
1738
- function R(s) {
1738
+ function T(s) {
1739
1739
  switch (typeof s) {
1740
1740
  case "object":
1741
1741
  return JSON.parse(JSON.stringify(s));
@@ -1747,7 +1747,7 @@ function R(s) {
1747
1747
  return s;
1748
1748
  }
1749
1749
  }
1750
- function V(s) {
1750
+ function H(s) {
1751
1751
  for (var e = 0, t = s.length, n; e < t; ) {
1752
1752
  if (n = s.charCodeAt(e), n >= 48 && n <= 57) {
1753
1753
  e++;
@@ -1763,42 +1763,42 @@ function A(s) {
1763
1763
  function We(s) {
1764
1764
  return s.replace(/~1/g, "/").replace(/~0/g, "~");
1765
1765
  }
1766
- function H(s) {
1766
+ function Y(s) {
1767
1767
  if (s === void 0)
1768
1768
  return !0;
1769
1769
  if (s) {
1770
1770
  if (Array.isArray(s)) {
1771
1771
  for (var e = 0, t = s.length; e < t; e++)
1772
- if (H(s[e]))
1772
+ if (Y(s[e]))
1773
1773
  return !0;
1774
1774
  } else if (typeof s == "object") {
1775
- for (var n = X(s), i = n.length, o = 0; o < i; o++)
1776
- if (H(s[n[o]]))
1775
+ for (var n = V(s), o = n.length, i = 0; i < o; i++)
1776
+ if (Y(s[n[i]]))
1777
1777
  return !0;
1778
1778
  }
1779
1779
  }
1780
1780
  return !1;
1781
1781
  }
1782
- function de(s, e) {
1782
+ function le(s, e) {
1783
1783
  var t = [s];
1784
1784
  for (var n in e) {
1785
- var i = typeof e[n] == "object" ? JSON.stringify(e[n], null, 2) : e[n];
1786
- typeof i < "u" && t.push(n + ": " + i);
1785
+ var o = typeof e[n] == "object" ? JSON.stringify(e[n], null, 2) : e[n];
1786
+ typeof o < "u" && t.push(n + ": " + o);
1787
1787
  }
1788
1788
  return t.join(`
1789
1789
  `);
1790
1790
  }
1791
- var Ge = (
1791
+ var Xe = (
1792
1792
  /** @class */
1793
1793
  (function(s) {
1794
1794
  ls(e, s);
1795
- function e(t, n, i, o, r) {
1796
- var d = this.constructor, l = s.call(this, de(t, { name: n, index: i, operation: o, tree: r })) || this;
1797
- return l.name = n, l.index = i, l.operation = o, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = de(t, { name: n, index: i, operation: o, tree: r }), l;
1795
+ function e(t, n, o, i, r) {
1796
+ var d = this.constructor, l = s.call(this, le(t, { name: n, index: o, operation: i, tree: r })) || this;
1797
+ return l.name = n, l.index = o, l.operation = i, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = le(t, { name: n, index: o, operation: i, tree: r }), l;
1798
1798
  }
1799
1799
  return e;
1800
1800
  })(Error)
1801
- ), E = Ge, fs = R, M = {
1801
+ ), E = Xe, fs = T, M = {
1802
1802
  add: function(s, e, t) {
1803
1803
  return s[e] = this.value, { newDocument: t };
1804
1804
  },
@@ -1812,13 +1812,13 @@ var Ge = (
1812
1812
  },
1813
1813
  move: function(s, e, t) {
1814
1814
  var n = U(t, this.path);
1815
- n && (n = R(n));
1816
- var i = O(t, { op: "remove", path: this.from }).removed;
1817
- return O(t, { op: "add", path: this.path, value: i }), { newDocument: t, removed: n };
1815
+ n && (n = T(n));
1816
+ var o = O(t, { op: "remove", path: this.from }).removed;
1817
+ return O(t, { op: "add", path: this.path, value: o }), { newDocument: t, removed: n };
1818
1818
  },
1819
1819
  copy: function(s, e, t) {
1820
1820
  var n = U(t, this.from);
1821
- return O(t, { op: "add", path: this.path, value: R(n) }), { newDocument: t };
1821
+ return O(t, { op: "add", path: this.path, value: T(n) }), { newDocument: t };
1822
1822
  },
1823
1823
  test: function(s, e, t) {
1824
1824
  return { newDocument: t, test: P(s[e], this.value) };
@@ -1828,7 +1828,7 @@ var Ge = (
1828
1828
  }
1829
1829
  }, us = {
1830
1830
  add: function(s, e, t) {
1831
- return V(e) ? s.splice(e, 0, this.value) : s[e] = this.value, { newDocument: t, index: e };
1831
+ return H(e) ? s.splice(e, 0, this.value) : s[e] = this.value, { newDocument: t, index: e };
1832
1832
  },
1833
1833
  remove: function(s, e, t) {
1834
1834
  var n = s.splice(e, 1);
@@ -1849,8 +1849,8 @@ function U(s, e) {
1849
1849
  var t = { op: "_get", path: e };
1850
1850
  return O(s, t), t.value;
1851
1851
  }
1852
- function O(s, e, t, n, i, o) {
1853
- if (t === void 0 && (t = !1), n === void 0 && (n = !0), i === void 0 && (i = !0), o === void 0 && (o = 0), t && (typeof t == "function" ? t(e, 0, s, e.path) : z(e, 0)), e.path === "") {
1852
+ function O(s, e, t, n, o, i) {
1853
+ if (t === void 0 && (t = !1), n === void 0 && (n = !0), o === void 0 && (o = !0), i === void 0 && (i = 0), t && (typeof t == "function" ? t(e, 0, s, e.path) : z(e, 0)), e.path === "") {
1854
1854
  var r = { newDocument: s };
1855
1855
  if (e.op === "add")
1856
1856
  return r.newDocument = e.value, r;
@@ -1860,7 +1860,7 @@ function O(s, e, t, n, i, o) {
1860
1860
  return r.newDocument = U(s, e.from), e.op === "move" && (r.removed = s), r;
1861
1861
  if (e.op === "test") {
1862
1862
  if (r.test = P(s, e.value), r.test === !1)
1863
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, s);
1863
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
1864
1864
  return r.newDocument = s, r;
1865
1865
  } else {
1866
1866
  if (e.op === "remove")
@@ -1868,49 +1868,49 @@ function O(s, e, t, n, i, o) {
1868
1868
  if (e.op === "_get")
1869
1869
  return e.value = s, r;
1870
1870
  if (t)
1871
- throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, s);
1871
+ throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", i, e, s);
1872
1872
  return r;
1873
1873
  }
1874
1874
  } else {
1875
- n || (s = R(s));
1875
+ n || (s = T(s));
1876
1876
  var d = e.path || "", l = d.split("/"), c = s, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
1877
1877
  for (typeof t == "function" ? g = t : g = z; ; ) {
1878
- if (p = l[u], p && p.indexOf("~") != -1 && (p = We(p)), i && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
1878
+ if (p = l[u], p && p.indexOf("~") != -1 && (p = We(p)), o && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
1879
1879
  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");
1880
1880
  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, s, m)), u++, Array.isArray(c)) {
1881
1881
  if (p === "-")
1882
1882
  p = c.length;
1883
1883
  else {
1884
- if (t && !V(p))
1885
- 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, s);
1886
- V(p) && (p = ~~p);
1884
+ if (t && !H(p))
1885
+ 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, s);
1886
+ H(p) && (p = ~~p);
1887
1887
  }
1888
1888
  if (u >= f) {
1889
1889
  if (t && e.op === "add" && p > c.length)
1890
- 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, s);
1890
+ 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, s);
1891
1891
  var r = us[e.op].call(e, c, p, s);
1892
1892
  if (r.test === !1)
1893
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, s);
1893
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
1894
1894
  return r;
1895
1895
  }
1896
1896
  } else if (u >= f) {
1897
1897
  var r = M[e.op].call(e, c, p, s);
1898
1898
  if (r.test === !1)
1899
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, s);
1899
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
1900
1900
  return r;
1901
1901
  }
1902
1902
  if (c = c[p], t && u < f && (!c || typeof c != "object"))
1903
- throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, s);
1903
+ throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", i, e, s);
1904
1904
  }
1905
1905
  }
1906
1906
  }
1907
- function Z(s, e, t, n, i) {
1908
- if (n === void 0 && (n = !0), i === void 0 && (i = !0), t && !Array.isArray(e))
1907
+ function Z(s, e, t, n, o) {
1908
+ if (n === void 0 && (n = !0), o === void 0 && (o = !0), t && !Array.isArray(e))
1909
1909
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1910
- n || (s = R(s));
1911
- for (var o = new Array(e.length), r = 0, d = e.length; r < d; r++)
1912
- o[r] = O(s, e[r], t, !0, i, r), s = o[r].newDocument;
1913
- return o.newDocument = s, o;
1910
+ n || (s = T(s));
1911
+ for (var i = new Array(e.length), r = 0, d = e.length; r < d; r++)
1912
+ i[r] = O(s, e[r], t, !0, o, r), s = i[r].newDocument;
1913
+ return i.newDocument = s, i;
1914
1914
  }
1915
1915
  function ms(s, e, t) {
1916
1916
  var n = O(s, e);
@@ -1930,64 +1930,64 @@ function z(s, e, t, n) {
1930
1930
  throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, s, t);
1931
1931
  if ((s.op === "add" || s.op === "replace" || s.op === "test") && s.value === void 0)
1932
1932
  throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, s, t);
1933
- if ((s.op === "add" || s.op === "replace" || s.op === "test") && H(s.value))
1933
+ if ((s.op === "add" || s.op === "replace" || s.op === "test") && Y(s.value))
1934
1934
  throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, s, t);
1935
1935
  if (t) {
1936
1936
  if (s.op == "add") {
1937
- var i = s.path.split("/").length, o = n.split("/").length;
1938
- if (i !== o + 1 && i !== o)
1937
+ var o = s.path.split("/").length, i = n.split("/").length;
1938
+ if (o !== i + 1 && o !== i)
1939
1939
  throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, s, t);
1940
1940
  } else if (s.op === "replace" || s.op === "remove" || s.op === "_get") {
1941
1941
  if (s.path !== n)
1942
1942
  throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, s, t);
1943
1943
  } else if (s.op === "move" || s.op === "copy") {
1944
- var r = { op: "_get", path: s.from, value: void 0 }, d = Xe([r], t);
1944
+ var r = { op: "_get", path: s.from, value: void 0 }, d = Ge([r], t);
1945
1945
  if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
1946
1946
  throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, s, t);
1947
1947
  }
1948
1948
  }
1949
1949
  } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, s, t);
1950
1950
  }
1951
- function Xe(s, e, t) {
1951
+ function Ge(s, e, t) {
1952
1952
  try {
1953
1953
  if (!Array.isArray(s))
1954
1954
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1955
1955
  if (e)
1956
- Z(R(e), R(s), t || !0);
1956
+ Z(T(e), T(s), t || !0);
1957
1957
  else {
1958
1958
  t = t || z;
1959
1959
  for (var n = 0; n < s.length; n++)
1960
1960
  t(s[n], n, e, void 0);
1961
1961
  }
1962
- } catch (i) {
1963
- if (i instanceof E)
1964
- return i;
1965
- throw i;
1962
+ } catch (o) {
1963
+ if (o instanceof E)
1964
+ return o;
1965
+ throw o;
1966
1966
  }
1967
1967
  }
1968
1968
  function P(s, e) {
1969
1969
  if (s === e)
1970
1970
  return !0;
1971
1971
  if (s && e && typeof s == "object" && typeof e == "object") {
1972
- var t = Array.isArray(s), n = Array.isArray(e), i, o, r;
1972
+ var t = Array.isArray(s), n = Array.isArray(e), o, i, r;
1973
1973
  if (t && n) {
1974
- if (o = s.length, o != e.length)
1974
+ if (i = s.length, i != e.length)
1975
1975
  return !1;
1976
- for (i = o; i-- !== 0; )
1977
- if (!P(s[i], e[i]))
1976
+ for (o = i; o-- !== 0; )
1977
+ if (!P(s[o], e[o]))
1978
1978
  return !1;
1979
1979
  return !0;
1980
1980
  }
1981
1981
  if (t != n)
1982
1982
  return !1;
1983
1983
  var d = Object.keys(s);
1984
- if (o = d.length, o !== Object.keys(e).length)
1984
+ if (i = d.length, i !== Object.keys(e).length)
1985
1985
  return !1;
1986
- for (i = o; i-- !== 0; )
1987
- if (!e.hasOwnProperty(d[i]))
1986
+ for (o = i; o-- !== 0; )
1987
+ if (!e.hasOwnProperty(d[o]))
1988
1988
  return !1;
1989
- for (i = o; i-- !== 0; )
1990
- if (r = d[i], !P(s[r], e[r]))
1989
+ for (o = i; o-- !== 0; )
1990
+ if (r = d[o], !P(s[r], e[r]))
1991
1991
  return !1;
1992
1992
  return !0;
1993
1993
  }
@@ -2002,10 +2002,10 @@ const ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2002
2002
  applyReducer: ms,
2003
2003
  deepClone: fs,
2004
2004
  getValueByPointer: U,
2005
- validate: Xe,
2005
+ validate: Ge,
2006
2006
  validator: z
2007
2007
  }, Symbol.toStringTag, { value: "Module" }));
2008
- var se = /* @__PURE__ */ new WeakMap(), hs = (
2008
+ var ne = /* @__PURE__ */ new WeakMap(), hs = (
2009
2009
  /** @class */
2010
2010
  /* @__PURE__ */ (function() {
2011
2011
  function s(e) {
@@ -2023,79 +2023,79 @@ var se = /* @__PURE__ */ new WeakMap(), hs = (
2023
2023
  })()
2024
2024
  );
2025
2025
  function ys(s) {
2026
- return se.get(s);
2026
+ return ne.get(s);
2027
2027
  }
2028
- function bs(s, e) {
2028
+ function ws(s, e) {
2029
2029
  return s.observers.get(e);
2030
2030
  }
2031
- function ws(s, e) {
2031
+ function bs(s, e) {
2032
2032
  s.observers.delete(e.callback);
2033
2033
  }
2034
2034
  function vs(s, e) {
2035
2035
  e.unobserve();
2036
2036
  }
2037
2037
  function Is(s, e) {
2038
- var t = [], n, i = ys(s);
2039
- if (!i)
2040
- i = new hs(s), se.set(s, i);
2038
+ var t = [], n, o = ys(s);
2039
+ if (!o)
2040
+ o = new hs(s), ne.set(s, o);
2041
2041
  else {
2042
- var o = bs(i, e);
2043
- n = o && o.observer;
2042
+ var i = ws(o, e);
2043
+ n = i && i.observer;
2044
2044
  }
2045
2045
  if (n)
2046
2046
  return n;
2047
- if (n = {}, i.value = R(s), e) {
2047
+ if (n = {}, o.value = T(s), e) {
2048
2048
  n.callback = e, n.next = null;
2049
2049
  var r = function() {
2050
- Y(n);
2050
+ Q(n);
2051
2051
  }, d = function() {
2052
2052
  clearTimeout(n.next), n.next = setTimeout(r);
2053
2053
  };
2054
2054
  typeof window < "u" && (window.addEventListener("mouseup", d), window.addEventListener("keyup", d), window.addEventListener("mousedown", d), window.addEventListener("keydown", d), window.addEventListener("change", d));
2055
2055
  }
2056
2056
  return n.patches = t, n.object = s, n.unobserve = function() {
2057
- Y(n), clearTimeout(n.next), ws(i, n), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
2058
- }, i.observers.set(e, new gs(e, n)), n;
2057
+ Q(n), clearTimeout(n.next), bs(o, n), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
2058
+ }, o.observers.set(e, new gs(e, n)), n;
2059
2059
  }
2060
- function Y(s, e) {
2060
+ function Q(s, e) {
2061
2061
  e === void 0 && (e = !1);
2062
- var t = se.get(s.object);
2063
- ne(t.value, s.object, s.patches, "", e), s.patches.length && Z(t.value, s.patches);
2062
+ var t = ne.get(s.object);
2063
+ oe(t.value, s.object, s.patches, "", e), s.patches.length && Z(t.value, s.patches);
2064
2064
  var n = s.patches;
2065
2065
  return n.length > 0 && (s.patches = [], s.callback && s.callback(n)), n;
2066
2066
  }
2067
- function ne(s, e, t, n, i) {
2067
+ function oe(s, e, t, n, o) {
2068
2068
  if (e !== s) {
2069
2069
  typeof e.toJSON == "function" && (e = e.toJSON());
2070
- for (var o = X(e), r = X(s), d = !1, l = r.length - 1; l >= 0; l--) {
2070
+ for (var i = V(e), r = V(s), d = !1, l = r.length - 1; l >= 0; l--) {
2071
2071
  var c = r[l], u = s[c];
2072
2072
  if (G(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
2073
2073
  var f = e[c];
2074
- typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? ne(u, f, t, n + "/" + A(c), i) : u !== f && (i && t.push({ op: "test", path: n + "/" + A(c), value: R(u) }), t.push({ op: "replace", path: n + "/" + A(c), value: R(f) }));
2075
- } else Array.isArray(s) === Array.isArray(e) ? (i && t.push({ op: "test", path: n + "/" + A(c), value: R(u) }), t.push({ op: "remove", path: n + "/" + A(c) }), d = !0) : (i && t.push({ op: "test", path: n, value: s }), t.push({ op: "replace", path: n, value: e }));
2074
+ typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? oe(u, f, t, n + "/" + A(c), o) : u !== f && (o && t.push({ op: "test", path: n + "/" + A(c), value: T(u) }), t.push({ op: "replace", path: n + "/" + A(c), value: T(f) }));
2075
+ } else Array.isArray(s) === Array.isArray(e) ? (o && t.push({ op: "test", path: n + "/" + A(c), value: T(u) }), t.push({ op: "remove", path: n + "/" + A(c) }), d = !0) : (o && t.push({ op: "test", path: n, value: s }), t.push({ op: "replace", path: n, value: e }));
2076
2076
  }
2077
- if (!(!d && o.length == r.length))
2078
- for (var l = 0; l < o.length; l++) {
2079
- var c = o[l];
2080
- !G(s, c) && e[c] !== void 0 && t.push({ op: "add", path: n + "/" + A(c), value: R(e[c]) });
2077
+ if (!(!d && i.length == r.length))
2078
+ for (var l = 0; l < i.length; l++) {
2079
+ var c = i[l];
2080
+ !G(s, c) && e[c] !== void 0 && t.push({ op: "add", path: n + "/" + A(c), value: T(e[c]) });
2081
2081
  }
2082
2082
  }
2083
2083
  }
2084
- function Q(s, e, t) {
2084
+ function ee(s, e, t) {
2085
2085
  t === void 0 && (t = !1);
2086
2086
  var n = [];
2087
- return ne(s, e, n, "", t), n;
2087
+ return oe(s, e, n, "", t), n;
2088
2088
  }
2089
2089
  const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2090
2090
  __proto__: null,
2091
- compare: Q,
2092
- generate: Y,
2091
+ compare: ee,
2092
+ generate: Q,
2093
2093
  observe: Is,
2094
2094
  unobserve: vs
2095
2095
  }, Symbol.toStringTag, { value: "Module" }));
2096
2096
  Object.assign({}, ps, Es, {
2097
- JsonPatchError: Ge,
2098
- deepClone: R,
2097
+ JsonPatchError: Xe,
2098
+ deepClone: T,
2099
2099
  escapePathComponent: A,
2100
2100
  unescapePathComponent: We
2101
2101
  });
@@ -2131,12 +2131,12 @@ const Ns = [
2131
2131
  I("env", (s) => s.key, (s) => s.key)
2132
2132
  ];
2133
2133
  function Ss(s, e, t, n) {
2134
- const i = new Map(s.map((r) => [t(r), r])), o = new Map(e.map((r) => [t(r), r]));
2134
+ const o = new Map(s.map((r) => [t(r), r])), i = new Map(e.map((r) => [t(r), r]));
2135
2135
  return {
2136
- added: e.filter((r) => !i.has(t(r))).map(n),
2137
- removed: s.filter((r) => !o.has(t(r))).map(n),
2136
+ added: e.filter((r) => !o.has(t(r))).map(n),
2137
+ removed: s.filter((r) => !i.has(t(r))).map(n),
2138
2138
  modified: e.filter((r) => {
2139
- const d = i.get(t(r));
2139
+ const d = o.get(t(r));
2140
2140
  return d !== void 0 && JSON.stringify(d) !== JSON.stringify(r);
2141
2141
  }).map(n)
2142
2142
  };
@@ -2148,14 +2148,14 @@ function ks(s, e) {
2148
2148
  return JSON.stringify(d) !== JSON.stringify(l);
2149
2149
  }) });
2150
2150
  const n = {};
2151
- for (const { key: o, getId: r, getLabel: d } of Ns) {
2152
- const l = e[o] ?? [], c = s[o] ?? [], u = Ss(l, c, r, d);
2153
- (u.added.length || u.removed.length || u.modified.length) && (n[o] = u);
2151
+ for (const { key: i, getId: r, getLabel: d } of Ns) {
2152
+ const l = e[i] ?? [], c = s[i] ?? [], u = Ss(l, c, r, d);
2153
+ (u.added.length || u.removed.length || u.modified.length) && (n[i] = u);
2154
2154
  }
2155
- const i = [...t ? ["project"] : [], ...Object.keys(n)];
2156
- return { project: t, sections: n, changedKeys: i };
2155
+ const o = [...t ? ["project"] : [], ...Object.keys(n)];
2156
+ return { project: t, sections: n, changedKeys: o };
2157
2157
  }
2158
- class k {
2158
+ class $ {
2159
2159
  constructor(e, t, n) {
2160
2160
  this.getBep = e, this.setBep = t, this.getZip = n;
2161
2161
  }
@@ -2168,12 +2168,12 @@ class k {
2168
2168
  return { major: t, minor: n };
2169
2169
  }
2170
2170
  static compareVersions(e, t) {
2171
- const n = k.parseVersion(e), i = k.parseVersion(t);
2172
- return n.major !== i.major ? n.major - i.major : n.minor - i.minor;
2171
+ const n = $.parseVersion(e), o = $.parseVersion(t);
2172
+ return n.major !== o.major ? n.major - o.major : n.minor - o.minor;
2173
2173
  }
2174
2174
  static bumpVersion(e, t) {
2175
- const [n, i] = e.split(".").map(Number);
2176
- return t === "version" ? `${n + 1}.0` : `${n}.${i + 1}`;
2175
+ const [n, o] = e.split(".").map(Number);
2176
+ return t === "version" ? `${n + 1}.0` : `${n}.${o + 1}`;
2177
2177
  }
2178
2178
  // ─── Zip helpers ──────────────────────────────────────────────────────────
2179
2179
  async readChangelog() {
@@ -2191,13 +2191,13 @@ class k {
2191
2191
  */
2192
2192
  async snapshotChangedStandards(e, t) {
2193
2193
  const n = this.getZip();
2194
- for (const i of e.standards) {
2195
- const o = n.file(i.contentPath);
2196
- if (!o) continue;
2197
- const r = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(n.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2194
+ for (const o of e.standards) {
2195
+ const i = n.file(o.contentPath);
2196
+ if (!i) continue;
2197
+ const r = await i.async("string"), d = `changelog/standards/${o.id}/`, l = Object.keys(n.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2198
2198
  let c = null;
2199
2199
  if (l.length > 0) {
2200
- const u = l.sort((m, p) => k.compareVersions(p, m))[0], f = n.file(`${d}v${u}.md`);
2200
+ const u = l.sort((m, p) => $.compareVersions(p, m))[0], f = n.file(`${d}v${u}.md`);
2201
2201
  f && (c = await f.async("string"));
2202
2202
  }
2203
2203
  c !== r && n.file(`${d}v${t}.md`, r);
@@ -2210,10 +2210,10 @@ class k {
2210
2210
  async snapshotBaseStandards(e) {
2211
2211
  const t = this.getZip();
2212
2212
  for (const n of e.standards) {
2213
- const i = t.file(n.contentPath);
2214
- if (!i) continue;
2215
- const o = await i.async("string");
2216
- t.file(`baseline/standards/${n.id}.md`, o);
2213
+ const o = t.file(n.contentPath);
2214
+ if (!o) continue;
2215
+ const i = await o.async("string");
2216
+ t.file(`baseline/standards/${n.id}.md`, i);
2217
2217
  }
2218
2218
  }
2219
2219
  /**
@@ -2222,12 +2222,12 @@ class k {
2222
2222
  * Falls back to the current file if no snapshot exists (content never changed).
2223
2223
  */
2224
2224
  async resolveStandardContent(e, t) {
2225
- const n = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(n.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));
2226
- if (o.length === 0) {
2225
+ const n = this.getZip(), o = `changelog/standards/${e.id}/`, i = Object.keys(n.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) => $.compareVersions(d, t) <= 0).sort((d, l) => $.compareVersions(l, d));
2226
+ if (i.length === 0) {
2227
2227
  const d = n.file(e.contentPath);
2228
2228
  return d ? d.async("string") : null;
2229
2229
  }
2230
- const r = n.file(`${i}v${o[0]}.md`);
2230
+ const r = n.file(`${o}v${i[0]}.md`);
2231
2231
  return r ? r.async("string") : null;
2232
2232
  }
2233
2233
  // ─── Public API ───────────────────────────────────────────────────────────
@@ -2238,19 +2238,19 @@ class k {
2238
2238
  return (await this.readChangelog())?.versions ?? [];
2239
2239
  }
2240
2240
  async commit(e, t = !1) {
2241
- const n = this.getZip(), i = this.getBep(), o = await this.readChangelog(), r = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2241
+ const n = this.getZip(), o = this.getBep(), i = await this.readChangelog(), r = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2242
2242
  if (!r) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
2243
2243
  if (e.type === "version") {
2244
- const g = e.approvedBy.filter((h) => !i.members.some((b) => b.email === h));
2244
+ const g = e.approvedBy.filter((h) => !o.members.some((y) => y.email === h));
2245
2245
  if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
2246
2246
  }
2247
2247
  if (!t && !await this.hasPendingChanges())
2248
2248
  throw new Error("No pending changes since last commit");
2249
- const l = o?.current ?? "0.0", c = k.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = Q(i, 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 = {
2249
+ const l = i?.current ?? "0.0", c = $.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = ee(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 = {
2250
2250
  current: c,
2251
- versions: [...o?.versions ?? [], m]
2251
+ versions: [...i?.versions ?? [], m]
2252
2252
  };
2253
- return n.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(i, c), n.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), n.file("changelog.json", JSON.stringify(p, null, 2)), m;
2253
+ return n.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(o, c), n.file("baseline/bep.json", JSON.stringify(o, null, 2)), await this.snapshotBaseStandards(o), n.file("changelog.json", JSON.stringify(p, null, 2)), m;
2254
2254
  }
2255
2255
  /**
2256
2256
  * Reconstructs the BEP state at the given version (read-only).
@@ -2272,28 +2272,28 @@ class k {
2272
2272
  if (!r) throw new Error(`Missing terminus: changelog/v${e}.json`);
2273
2273
  return B(JSON.parse(await r.async("string")));
2274
2274
  }
2275
- 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()));
2276
- for (const r of i) {
2275
+ const o = t.versions.filter((r) => $.compareVersions(r.version, e) > 0).sort((r, d) => $.compareVersions(d.version, r.version)), i = JSON.parse(JSON.stringify(this.getBep()));
2276
+ for (const r of o) {
2277
2277
  if (!r.diff) break;
2278
2278
  const d = this.getZip().file(r.diff);
2279
2279
  if (!d) throw new Error(`Missing diff file: ${r.diff}`);
2280
2280
  const l = JSON.parse(await d.async("string"));
2281
- Z(o, l);
2281
+ Z(i, l);
2282
2282
  }
2283
- return B(o);
2283
+ return B(i);
2284
2284
  }
2285
2285
  /** Returns the RFC 6902 diff and standards summary between two versions. */
2286
2286
  async compare(e, t) {
2287
- const [n, i, o] = await Promise.all([
2287
+ const [n, o, i] = await Promise.all([
2288
2288
  this.get(e),
2289
2289
  this.get(t),
2290
2290
  this.readChangelog()
2291
- ]), r = Q(n, i), d = new Set(n.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 = n.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (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(
2292
- i.standards.filter((h) => d.has(h.id)).map(async (h) => {
2293
- const b = (await Promise.all(
2294
- m.map(async ($) => p.file(`changelog/standards/${h.id}/v${$}.md`) !== null ? $ : null)
2295
- )).filter(($) => $ !== null);
2296
- return b.length > 0 ? { id: h.id, name: h.name, changedIn: b } : null;
2291
+ ]), r = ee(n, o), d = new Set(n.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 = n.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (i?.versions ?? []).filter((h) => $.compareVersions(h.version, e) > 0 && $.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2292
+ o.standards.filter((h) => d.has(h.id)).map(async (h) => {
2293
+ const y = (await Promise.all(
2294
+ m.map(async (S) => p.file(`changelog/standards/${h.id}/v${S}.md`) !== null ? S : null)
2295
+ )).filter((S) => S !== null);
2296
+ return y.length > 0 ? { id: h.id, name: h.name, changedIn: y } : null;
2297
2297
  })
2298
2298
  )).filter((h) => h !== null);
2299
2299
  return { diff: r, standards: { added: c, removed: u, contentModified: g } };
@@ -2305,14 +2305,14 @@ class k {
2305
2305
  async discard() {
2306
2306
  const e = this.getZip(), t = await this.readBaseline();
2307
2307
  if (!t) throw new Error("No baseline found — call commit() first");
2308
- const n = new Set(t.standards.map((i) => i.id));
2309
- for (const i of this.getBep().standards)
2310
- n.has(i.id) || e.remove(i.contentPath);
2311
- for (const i of t.standards) {
2312
- const o = e.file(`baseline/standards/${i.id}.md`);
2313
- if (!o) continue;
2314
- const r = await o.async("string");
2315
- e.file(i.contentPath, r);
2308
+ const n = new Set(t.standards.map((o) => o.id));
2309
+ for (const o of this.getBep().standards)
2310
+ n.has(o.id) || e.remove(o.contentPath);
2311
+ for (const o of t.standards) {
2312
+ const i = e.file(`baseline/standards/${o.id}.md`);
2313
+ if (!i) continue;
2314
+ const r = await i.async("string");
2315
+ e.file(o.contentPath, r);
2316
2316
  }
2317
2317
  this.setBep(t);
2318
2318
  }
@@ -2321,12 +2321,12 @@ class k {
2321
2321
  * version and immediately commits it as a new version.
2322
2322
  */
2323
2323
  async revert(e, t) {
2324
- const n = this.getZip(), i = await this.get(e);
2325
- for (const o of i.standards) {
2326
- const r = await this.resolveStandardContent(o, e);
2327
- r !== null && n.file(o.contentPath, r);
2324
+ const n = this.getZip(), o = await this.get(e);
2325
+ for (const i of o.standards) {
2326
+ const r = await this.resolveStandardContent(i, e);
2327
+ r !== null && n.file(i.contentPath, r);
2328
2328
  }
2329
- return this.setBep(i), this.commit(t);
2329
+ return this.setBep(o), this.commit(t);
2330
2330
  }
2331
2331
  /**
2332
2332
  * Returns a structured diff of the current BEP state vs the last committed baseline.
@@ -2335,17 +2335,17 @@ class k {
2335
2335
  async status() {
2336
2336
  const e = this.getZip(), t = await this.readBaseline();
2337
2337
  if (!t) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
2338
- const n = this.getBep(), i = ks(n, t), o = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(n.standards.map((c) => c.id));
2338
+ const n = this.getBep(), o = ks(n, t), i = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(n.standards.map((c) => c.id));
2339
2339
  for (const c of n.standards)
2340
2340
  if (!r.has(c.id))
2341
- o.push({ id: c.id, name: c.name, status: "added" });
2341
+ i.push({ id: c.id, name: c.name, status: "added" });
2342
2342
  else {
2343
2343
  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") : "";
2344
- u ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
2344
+ u ? i.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && i.push({ id: c.id, name: c.name, status: "content-modified" });
2345
2345
  }
2346
2346
  for (const c of t.standards)
2347
- d.has(c.id) || o.push({ id: c.id, name: c.name, status: "removed" });
2348
- return { hasPendingChanges: i.changedKeys.length > 0 || o.length > 0, standards: o, ...i };
2347
+ d.has(c.id) || i.push({ id: c.id, name: c.name, status: "removed" });
2348
+ return { hasPendingChanges: o.changedKeys.length > 0 || i.length > 0, standards: i, ...o };
2349
2349
  }
2350
2350
  /** Shorthand — true if there are uncommitted changes since the last commit. */
2351
2351
  async hasPendingChanges() {
@@ -2354,18 +2354,18 @@ class k {
2354
2354
  /** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
2355
2355
  async listResolved() {
2356
2356
  const [e, t] = await Promise.all([this.list(), this.current()]), n = this.getBep().members;
2357
- return e.sort((i, o) => k.compareVersions(i.version, o.version)).map((i) => ({
2358
- version: i.version,
2359
- type: i.type,
2360
- date: i.date,
2361
- description: i.description,
2362
- diff: i.diff,
2363
- isCurrent: i.version === t,
2364
- author: i.author ? { email: i.author, name: n.find((o) => o.email === i.author)?.name ?? null } : null,
2365
- ...i.type === "version" ? {
2366
- approvedBy: i.approvedBy.map((o) => ({
2367
- email: o,
2368
- name: n.find((r) => r.email === o)?.name ?? null
2357
+ return e.sort((o, i) => $.compareVersions(o.version, i.version)).map((o) => ({
2358
+ version: o.version,
2359
+ type: o.type,
2360
+ date: o.date,
2361
+ description: o.description,
2362
+ diff: o.diff,
2363
+ isCurrent: o.version === t,
2364
+ author: o.author ? { email: o.author, name: n.find((i) => i.email === o.author)?.name ?? null } : null,
2365
+ ...o.type === "version" ? {
2366
+ approvedBy: o.approvedBy.map((i) => ({
2367
+ email: i,
2368
+ name: n.find((r) => r.email === i)?.name ?? null
2369
2369
  }))
2370
2370
  } : {}
2371
2371
  }));
@@ -2375,8 +2375,8 @@ class k {
2375
2375
  * Returns null if the standard did not exist at that version.
2376
2376
  */
2377
2377
  async getStandardContent(e, t) {
2378
- const i = (await this.get(t)).standards.find((o) => o.id === e);
2379
- return i ? this.resolveStandardContent(i, t) : null;
2378
+ const o = (await this.get(t)).standards.find((i) => i.id === e);
2379
+ return o ? this.resolveStandardContent(o, t) : null;
2380
2380
  }
2381
2381
  /**
2382
2382
  * ⚠️ Destructive: resets the BEP to a historical version and permanently
@@ -2385,12 +2385,12 @@ class k {
2385
2385
  async reset(e) {
2386
2386
  const t = this.getZip(), n = await this.readChangelog();
2387
2387
  if (!n) throw new Error("No changelog found");
2388
- const i = n.versions.find((c) => c.version === e), o = !!this.getZip().file(`changelog/v${e}.json`);
2389
- if (!i && !o)
2388
+ const o = n.versions.find((c) => c.version === e), i = !!this.getZip().file(`changelog/v${e}.json`);
2389
+ if (!o && !i)
2390
2390
  throw new Error(`Version not found: ${e}`);
2391
2391
  if (e === n.current)
2392
2392
  throw new Error(`Already at version ${e}`);
2393
- const r = n.versions.filter((c) => k.compareVersions(c.version, e) > 0), d = await this.get(e);
2393
+ const r = n.versions.filter((c) => $.compareVersions(c.version, e) > 0), d = await this.get(e);
2394
2394
  for (const c of d.standards) {
2395
2395
  const u = await this.resolveStandardContent(c, e);
2396
2396
  u !== null && t.file(c.contentPath, u);
@@ -2401,7 +2401,7 @@ class k {
2401
2401
  const l = JSON.stringify(d, null, 2);
2402
2402
  t.file("changelog.json", JSON.stringify({
2403
2403
  current: e,
2404
- versions: n.versions.filter((c) => k.compareVersions(c.version, e) <= 0)
2404
+ versions: n.versions.filter((c) => $.compareVersions(c.version, e) <= 0)
2405
2405
  }, null, 2)), t.file("bep.json", l), t.file("baseline/bep.json", l), this.setBep(d);
2406
2406
  }
2407
2407
  /**
@@ -2414,20 +2414,20 @@ class k {
2414
2414
  if (!n) throw new Error("No changelog found");
2415
2415
  if (!/^\d+\.0$/.test(e.newBase))
2416
2416
  throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
2417
- if (k.compareVersions(e.newBase, n.current) <= 0)
2417
+ if ($.compareVersions(e.newBase, n.current) <= 0)
2418
2418
  throw new Error(`newBase "${e.newBase}" must be greater than current version "${n.current}"`);
2419
- const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
2420
- if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
2419
+ const o = this.getBep(), i = e.approvedBy.filter((d) => !o.members.some((l) => l.email === d));
2420
+ if (i.length) throw new Error(`Members not found: ${i.join(", ")}`);
2421
2421
  for (const d of n.versions)
2422
2422
  d.diff && t.remove(d.diff);
2423
- 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));
2424
- for (const d of i.standards) {
2423
+ 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));
2424
+ for (const d of o.standards) {
2425
2425
  const l = t.file(d.contentPath);
2426
2426
  if (!l) continue;
2427
2427
  const c = await l.async("string");
2428
2428
  t.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
2429
2429
  }
2430
- t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i);
2430
+ t.file("baseline/bep.json", JSON.stringify(o, null, 2)), await this.snapshotBaseStandards(o);
2431
2431
  const r = {
2432
2432
  version: e.newBase,
2433
2433
  type: "version",
@@ -2477,52 +2477,52 @@ function Rs(s, e) {
2477
2477
  }
2478
2478
  }
2479
2479
  function Ts(s, e, t, n) {
2480
- const o = s.workflows.find((m) => m.id === t)?.diagram.nodes[e];
2481
- if (!o || o.type !== "process") return !0;
2482
- const r = !!(o.responsibleRoleIds?.length || o.responsibleTeamIds?.length || o.responsibleEmails?.length), d = !!(o.accountableRoleIds?.length || o.accountableTeamIds?.length || o.accountableEmails?.length);
2480
+ const i = s.workflows.find((m) => m.id === t)?.diagram.nodes[e];
2481
+ if (!i || i.type !== "process") return !0;
2482
+ const r = !!(i.responsibleRoleIds?.length || i.responsibleTeamIds?.length || i.responsibleEmails?.length), d = !!(i.accountableRoleIds?.length || i.accountableTeamIds?.length || i.accountableEmails?.length);
2483
2483
  if (!r && !d) return !0;
2484
2484
  const c = s.members.find((m) => m.email === n)?.roleId, u = new Set(s.teams.filter((m) => (m.memberEmails ?? []).includes(n)).map((m) => m.id)), f = (m, p, g) => {
2485
2485
  if (g?.includes(n)) return !0;
2486
- const h = !!m?.length, b = !!p?.length;
2487
- return b && h ? !!c && m.includes(c) && p.some(($) => u.has($)) : b ? p.some(($) => u.has($)) : h ? !!c && m.includes(c) : !1;
2486
+ const h = !!m?.length, y = !!p?.length;
2487
+ return y && h ? !!c && m.includes(c) && p.some((S) => u.has(S)) : y ? p.some((S) => u.has(S)) : h ? !!c && m.includes(c) : !1;
2488
2488
  };
2489
- return r && f(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && f(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2489
+ return r && f(i.responsibleRoleIds, i.responsibleTeamIds, i.responsibleEmails) || d && f(i.accountableRoleIds, i.accountableTeamIds, i.accountableEmails);
2490
2490
  }
2491
2491
  const js = { string: "string", number: "number", boolean: "boolean" };
2492
2492
  function As(s, e, t) {
2493
2493
  const n = s.events.find((d) => d.id === e);
2494
2494
  if (!n?.payload?.length) return [];
2495
- const i = [], o = t ?? {};
2495
+ const o = [], i = t ?? {};
2496
2496
  for (const d of n.payload) {
2497
- const l = o[d.key];
2497
+ const l = i[d.key];
2498
2498
  if (l == null)
2499
- d.required && i.push({ field: d.key, reason: "missing" });
2499
+ d.required && o.push({ field: d.key, reason: "missing" });
2500
2500
  else {
2501
2501
  const c = js[d.type];
2502
- c && typeof l !== c && i.push({ field: d.key, reason: "wrong_type" });
2502
+ c && typeof l !== c && o.push({ field: d.key, reason: "wrong_type" });
2503
2503
  }
2504
2504
  }
2505
2505
  const r = new Set(n.payload.map((d) => d.key));
2506
- for (const d of Object.keys(o))
2507
- r.has(d) || i.push({ field: d, reason: "unknown_field" });
2508
- return i;
2506
+ for (const d of Object.keys(i))
2507
+ r.has(d) || o.push({ field: d, reason: "unknown_field" });
2508
+ return o;
2509
2509
  }
2510
2510
  function Os(s, e) {
2511
2511
  return !(!("triggerEventId" in s) || s.triggerEventId !== e.eventId);
2512
2512
  }
2513
- function _s(s, e, t, n, i) {
2514
- const o = s.workflows.find((f) => f.id === e);
2515
- if (!o) return null;
2516
- const r = Object.keys(o.diagram.nodes).find(
2517
- (f) => o.diagram.nodes[f].type === "start"
2513
+ function _s(s, e, t, n, o) {
2514
+ const i = s.workflows.find((f) => f.id === e);
2515
+ if (!i) return null;
2516
+ const r = Object.keys(i.diagram.nodes).find(
2517
+ (f) => i.diagram.nodes[f].type === "start"
2518
2518
  );
2519
2519
  if (!r) return null;
2520
- const d = Object.entries(o.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();
2520
+ 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();
2521
2521
  return {
2522
2522
  instance: {
2523
2523
  id: globalThis.crypto.randomUUID(),
2524
2524
  workflowId: e,
2525
- bepVersion: i,
2525
+ bepVersion: o,
2526
2526
  trackedAsset: t,
2527
2527
  currentNodeId: l,
2528
2528
  status: "active",
@@ -2534,14 +2534,14 @@ function _s(s, e, t, n, i) {
2534
2534
  startEffects: c
2535
2535
  };
2536
2536
  }
2537
- function le(s, e, t, n) {
2537
+ function W(s, e, t, n) {
2538
2538
  if (e.status !== "active")
2539
2539
  return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
2540
2540
  if (!n?.skipRaci && !Ts(s, e.currentNodeId, e.workflowId, t.actor))
2541
2541
  return { ok: !1, error: "UNAUTHORIZED" };
2542
- const i = s.workflows.find((N) => N.id === e.workflowId);
2543
- if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
2544
- const { nodes: o, edges: r } = i.diagram;
2542
+ const o = s.workflows.find((N) => N.id === e.workflowId);
2543
+ if (!o) return { ok: !1, error: "NO_MATCHING_EDGE" };
2544
+ const { nodes: i, edges: r } = o.diagram;
2545
2545
  let d = e.currentNodeId;
2546
2546
  const l = [], c = [], u = [], f = Object.entries(r).filter(
2547
2547
  ([, N]) => N.from === d && Os(N, t)
@@ -2555,55 +2555,55 @@ function le(s, e, t, n) {
2555
2555
  }
2556
2556
  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;
2557
2557
  let g = 0;
2558
- for (; o[d]?.type === "decision"; ) {
2558
+ for (; i[d]?.type === "decision"; ) {
2559
2559
  if (++g > $s) return { ok: !1, error: "DECISION_LOOP" };
2560
2560
  const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 : Rs(v.guard, t.payload ?? {}));
2561
2561
  if (N.length === 0) break;
2562
- const [j, w] = N[0];
2563
- l.push(ce(j, d, w.to, t, !0)), c.push(...(w.effectIds ?? []).map((v) => ({ effectId: v, fromEdgeId: j }))), u.push({ edgeId: j, fromNodeId: d, toNodeId: w.to }), d = w.to;
2562
+ const [j, b] = N[0];
2563
+ l.push(ce(j, d, b.to, t, !0)), c.push(...(b.effectIds ?? []).map((v) => ({ effectId: v, fromEdgeId: j }))), u.push({ edgeId: j, fromNodeId: d, toNodeId: b.to }), d = b.to;
2564
2564
  }
2565
- const h = o[d], b = h?.type === "end" ? "completed" : "active", $ = {
2565
+ const h = i[d], y = h?.type === "end" ? "completed" : "active", S = {
2566
2566
  ...e,
2567
2567
  currentNodeId: d,
2568
- status: b,
2568
+ status: y,
2569
2569
  history: [...e.history, ...l],
2570
2570
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2571
- }, T = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId } : void 0;
2572
- return { ok: !0, instance: $, transitionsApplied: u, effectsToFire: c, automationNodePending: T };
2571
+ }, R = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId } : void 0;
2572
+ return { ok: !0, instance: S, transitionsApplied: u, effectsToFire: c, automationNodePending: R };
2573
2573
  }
2574
2574
  function Bs(s, e, t) {
2575
- const n = s.workflows.find((w) => w.id === e.workflowId), { nodes: i, edges: o } = n.diagram, r = i[e.currentNodeId], l = s.members.find((w) => w.email === t)?.roleId, c = new Set(
2576
- s.teams.filter((w) => (w.memberEmails ?? []).includes(t)).map((w) => w.id)
2577
- ), u = (w) => (w ?? []).flatMap((v) => {
2578
- const S = s.roles.find((_) => _.id === v);
2579
- return S ? [{ id: S.id, name: S.name }] : [];
2580
- }), f = (w) => (w ?? []).flatMap((v) => {
2581
- const S = s.teams.find((_) => _.id === v);
2582
- return S ? [{ id: S.id, name: S.name }] : [];
2583
- }), m = (w, v, S) => ({
2584
- roles: u(w),
2575
+ const n = s.workflows.find((b) => b.id === e.workflowId), { nodes: o, edges: i } = n.diagram, r = o[e.currentNodeId], l = s.members.find((b) => b.email === t)?.roleId, c = new Set(
2576
+ s.teams.filter((b) => (b.memberEmails ?? []).includes(t)).map((b) => b.id)
2577
+ ), u = (b) => (b ?? []).flatMap((v) => {
2578
+ const k = s.roles.find((_) => _.id === v);
2579
+ return k ? [{ id: k.id, name: k.name }] : [];
2580
+ }), f = (b) => (b ?? []).flatMap((v) => {
2581
+ const k = s.teams.find((_) => _.id === v);
2582
+ return k ? [{ id: k.id, name: k.name }] : [];
2583
+ }), m = (b, v, k) => ({
2584
+ roles: u(b),
2585
2585
  teams: f(v),
2586
- emails: S ?? []
2587
- }), p = (w, v, S) => {
2588
- if (S?.includes(t)) return !0;
2589
- const _ = !!w?.length, ie = !!v?.length;
2590
- return ie && _ ? !!l && w.includes(l) && v.some((J) => c.has(J)) : ie ? v.some((J) => c.has(J)) : _ ? !!l && w.includes(l) : !1;
2591
- }, 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) => (s.events.find((v) => v.id === w)?.payload ?? []).map((v) => ({
2586
+ emails: k ?? []
2587
+ }), p = (b, v, k) => {
2588
+ if (k?.includes(t)) return !0;
2589
+ const _ = !!b?.length, ie = !!v?.length;
2590
+ return ie && _ ? !!l && b.includes(l) && v.some((J) => c.has(J)) : ie ? v.some((J) => c.has(J)) : _ ? !!l && b.includes(l) : !1;
2591
+ }, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length), y = !!(g?.accountableRoleIds?.length || g?.accountableTeamIds?.length || g?.accountableEmails?.length), S = !h && !y || h && p(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails) || y && p(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails), R = (b) => (s.events.find((v) => v.id === b)?.payload ?? []).map((v) => ({
2592
2592
  key: v.key,
2593
2593
  type: v.type,
2594
2594
  required: v.required
2595
2595
  })), N = [], j = [];
2596
- for (const [w, v] of Object.entries(o)) {
2596
+ for (const [b, v] of Object.entries(i)) {
2597
2597
  if (v.from !== e.currentNodeId || !("triggerEventId" in v)) continue;
2598
- const S = v.triggerEventId;
2599
- $ ? N.push({
2600
- edgeId: w,
2601
- label: v.label ?? S,
2602
- emits: S,
2603
- requiredPayload: T(S)
2598
+ const k = v.triggerEventId;
2599
+ S ? N.push({
2600
+ edgeId: b,
2601
+ label: v.label ?? k,
2602
+ emits: k,
2603
+ requiredPayload: R(k)
2604
2604
  }) : j.push({
2605
- edgeId: w,
2606
- label: v.label ?? S,
2605
+ edgeId: b,
2606
+ label: v.label ?? k,
2607
2607
  reason: "UNAUTHORIZED",
2608
2608
  required: m(
2609
2609
  [...g?.responsibleRoleIds ?? [], ...g?.accountableRoleIds ?? []],
@@ -2629,7 +2629,7 @@ function Bs(s, e, t) {
2629
2629
  isTerminal: r.type === "end"
2630
2630
  };
2631
2631
  }
2632
- function ce(s, e, t, n, i) {
2632
+ function ce(s, e, t, n, o) {
2633
2633
  return {
2634
2634
  id: globalThis.crypto.randomUUID(),
2635
2635
  edgeId: s,
@@ -2638,7 +2638,7 @@ function ce(s, e, t, n, i) {
2638
2638
  trigger: n,
2639
2639
  actor: n.actor,
2640
2640
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2641
- ...i ? { auto: !0 } : {}
2641
+ ...o ? { auto: !0 } : {}
2642
2642
  };
2643
2643
  }
2644
2644
  class Ms {
@@ -2672,8 +2672,12 @@ class Ps {
2672
2672
  getBep;
2673
2673
  getHistoricalBep;
2674
2674
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2675
- runtime;
2675
+ _runtime;
2676
2676
  storage;
2677
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2678
+ get runtime() {
2679
+ return this._runtime;
2680
+ }
2677
2681
  skipRaci = !1;
2678
2682
  transitionListeners = [];
2679
2683
  createdListeners = [];
@@ -2692,7 +2696,7 @@ class Ps {
2692
2696
  * Returns `this` for chaining.
2693
2697
  */
2694
2698
  init(e) {
2695
- return this.runtime = e.runtime, this.storage = e.storage ?? new Ms(), this.skipRaci = e.events?.skipRaci ?? !1, this;
2699
+ return this._runtime = e.runtime, this.storage = e.storage ?? new Ms(), this.skipRaci = e.events?.skipRaci ?? !1, this;
2696
2700
  }
2697
2701
  // ─── Lifecycle listeners ─────────────────────────────────────────────────────
2698
2702
  /** Fires after every successful emit() — all listeners run concurrently. */
@@ -2719,12 +2723,29 @@ class Ps {
2719
2723
  */
2720
2724
  async createInstance(e, t, n) {
2721
2725
  this._assertInit();
2722
- const i = this.getBep(), r = _s(i, e, t, n, "unversioned");
2726
+ const o = this.getBep(), r = _s(o, e, t, n, "unversioned");
2723
2727
  if (!r) return null;
2724
2728
  const { instance: d, startEffects: l } = r;
2725
- for (const c of l)
2726
- await this._executeEffect(d, c);
2727
- return await this.storage.saveInstance(d), await this._fire(this.createdListeners, d), d;
2729
+ for (const h of l)
2730
+ await this._executeEffect(d, h);
2731
+ const u = o.workflows.find((h) => h.id === e)?.diagram.nodes[d.currentNodeId];
2732
+ let f = u?.type === "automation" && u.automationId ? { automationId: u.automationId } : void 0, m = d;
2733
+ const p = 10;
2734
+ let g = 0;
2735
+ for (; f && g++ < p; ) {
2736
+ const { automationId: h } = f, { eventId: y, ...S } = await this._executeAutomationNode(m, h), R = W(o, m, {
2737
+ eventId: y,
2738
+ actor: "_system",
2739
+ softwareId: "_system",
2740
+ payload: S
2741
+ });
2742
+ if (!R.ok) break;
2743
+ m = R.instance;
2744
+ for (const N of R.effectsToFire ?? [])
2745
+ await this._executeEffect(m, N);
2746
+ f = R.automationNodePending;
2747
+ }
2748
+ return await this.storage.saveInstance(m), await this._fire(this.createdListeners, m), m;
2728
2749
  }
2729
2750
  /**
2730
2751
  * Emits an event against a workflow instance.
@@ -2741,25 +2762,25 @@ class Ps {
2741
2762
  this._assertInit();
2742
2763
  const n = await this.storage.getInstance(e);
2743
2764
  if (!n) return { ok: !1, error: "NO_MATCHING_EDGE" };
2744
- const i = await this._resolveBep(n.bepVersion);
2745
- let o = le(i, n, t, { skipRaci: this.skipRaci });
2746
- if (!o.ok) return { ok: !1, error: o.error, payloadErrors: o.payloadErrors };
2747
- const r = [...o.transitionsApplied ?? []], d = [];
2748
- let l = o.instance;
2749
- for (const f of o.effectsToFire ?? [])
2765
+ const o = await this._resolveBep(n.bepVersion);
2766
+ let i = W(o, n, t, { skipRaci: this.skipRaci });
2767
+ if (!i.ok) return { ok: !1, error: i.error, payloadErrors: i.payloadErrors };
2768
+ const r = [...i.transitionsApplied ?? []], d = [];
2769
+ let l = i.instance;
2770
+ for (const f of i.effectsToFire ?? [])
2750
2771
  d.push(await this._executeEffect(l, f));
2751
2772
  const c = 10;
2752
2773
  let u = 0;
2753
- for (; o.automationNodePending && u++ < c; ) {
2754
- const { automationId: f } = o.automationNodePending, { eventId: m, ...p } = await this._executeAutomationNode(l, f);
2755
- if (o = le(i, l, {
2774
+ for (; i.automationNodePending && u++ < c; ) {
2775
+ const { automationId: f } = i.automationNodePending, { eventId: m, ...p } = await this._executeAutomationNode(l, f);
2776
+ if (i = W(o, l, {
2756
2777
  eventId: m,
2757
2778
  actor: "_system",
2758
2779
  softwareId: "_system",
2759
2780
  payload: p
2760
- }), !o.ok) break;
2761
- l = o.instance, r.push(...o.transitionsApplied ?? []);
2762
- for (const g of o.effectsToFire ?? [])
2781
+ }), !i.ok) break;
2782
+ l = i.instance, r.push(...i.transitionsApplied ?? []);
2783
+ for (const g of i.effectsToFire ?? [])
2763
2784
  d.push(await this._executeEffect(l, g));
2764
2785
  }
2765
2786
  return await this.storage.saveInstance(l), await this._fire(this.transitionListeners, l, r, d), l.status === "completed" && await this._fire(this.completedListeners, l), {
@@ -2780,11 +2801,11 @@ class Ps {
2780
2801
  */
2781
2802
  async getInstances(e) {
2782
2803
  this._assertInit();
2783
- const { pendingActionFor: t, ...n } = e ?? {}, i = await this.storage.listInstances(n);
2784
- if (!t) return i;
2785
- const o = this.getBep(), r = o.members.find((d) => d.email === t);
2786
- return r ? i.filter((d) => {
2787
- const l = o.workflows.find((m) => m.id === d.workflowId);
2804
+ const { pendingActionFor: t, ...n } = e ?? {}, o = await this.storage.listInstances(n);
2805
+ if (!t) return o;
2806
+ const i = this.getBep(), r = i.members.find((d) => d.email === t);
2807
+ return r ? o.filter((d) => {
2808
+ const l = i.workflows.find((m) => m.id === d.workflowId);
2788
2809
  if (!l) return !1;
2789
2810
  const c = l.diagram.nodes[d.currentNodeId];
2790
2811
  if (!c) return !1;
@@ -2803,8 +2824,8 @@ class Ps {
2803
2824
  this._assertInit();
2804
2825
  const n = await this.storage.getInstance(e);
2805
2826
  if (!n) return null;
2806
- const i = await this._resolveBep(n.bepVersion);
2807
- return Bs(i, n, t);
2827
+ const o = await this._resolveBep(n.bepVersion);
2828
+ return Bs(o, n, t);
2808
2829
  }
2809
2830
  async deleteInstance(e) {
2810
2831
  this._assertInit(), await this.storage.deleteInstance(e);
@@ -2815,10 +2836,10 @@ class Ps {
2815
2836
  */
2816
2837
  async getRemoteData(e) {
2817
2838
  this._assertInit();
2818
- const n = this.getBep().remoteData.find((i) => i.id === e);
2839
+ const n = this.getBep().remoteData.find((o) => o.id === e);
2819
2840
  if (!n) throw new Error(`Remote data "${e}" not found in BEP`);
2820
2841
  if (!n.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
2821
- return this.runtime._runResolver(n.resolverId, n.url);
2842
+ return this._runtime._runResolver(n.resolverId, n.url);
2822
2843
  }
2823
2844
  // ─── Internal ────────────────────────────────────────────────────────────────
2824
2845
  _assertInit() {
@@ -2833,23 +2854,23 @@ class Ps {
2833
2854
  }
2834
2855
  _resolveFromHistory(e, t) {
2835
2856
  for (let n = t.length - 1; n >= 0; n--) {
2836
- const i = t[n].trigger.payload ?? {};
2837
- if (e in i) return i[e];
2857
+ const o = t[n].trigger.payload ?? {};
2858
+ if (e in o) return o[e];
2838
2859
  }
2839
2860
  }
2840
2861
  async _executeAutomationNode(e, t) {
2841
- 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];
2862
+ 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];
2842
2863
  if (!d) throw new Error(`No handler declared for automation "${t}"`);
2843
2864
  return d(e, r);
2844
2865
  }
2845
2866
  async _executeEffect(e, t) {
2846
- 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);
2867
+ 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);
2847
2868
  if (r.length > 0)
2848
2869
  return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped", missingFields: r };
2849
- const d = this.runtime.effects[t.effectId];
2870
+ const d = this._runtime.effects[t.effectId];
2850
2871
  if (!d)
2851
2872
  return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped" };
2852
- const l = Object.fromEntries(o.map((c) => [c.key, this._resolveFromHistory(c.key, e.history)]));
2873
+ const l = Object.fromEntries(i.map((c) => [c.key, this._resolveFromHistory(c.key, e.history)]));
2853
2874
  try {
2854
2875
  return await d(e, l), { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "executed" };
2855
2876
  } catch (c) {
@@ -2861,14 +2882,14 @@ class Ps {
2861
2882
  function zs(s, e) {
2862
2883
  const t = /* @__PURE__ */ new Map();
2863
2884
  for (const n of s) {
2864
- const i = [e(n)].flat();
2865
- for (const o of i)
2866
- t.has(o) || t.set(o, []), t.get(o).push(n);
2885
+ const o = [e(n)].flat();
2886
+ for (const i of o)
2887
+ t.has(i) || t.set(i, []), t.get(i).push(n);
2867
2888
  }
2868
- return Array.from(t.entries()).map(([n, i]) => ({ key: n, rows: i }));
2889
+ return Array.from(t.entries()).map(([n, o]) => ({ key: n, rows: o }));
2869
2890
  }
2870
2891
  function Zs(s, e = "responsible", t = {}) {
2871
- const { topologicalSort: n = !1 } = t, i = (m) => `_${m}`, o = "#444444", r = Object.entries(s.nodes), d = r.find(([, m]) => m.type === "start")?.[0], l = r.find(([, m]) => m.type === "end")?.[0];
2892
+ const { topologicalSort: n = !1 } = t, o = (m) => `_${m}`, i = "#444444", r = Object.entries(s.nodes), d = r.find(([, m]) => m.type === "start")?.[0], l = r.find(([, m]) => m.type === "end")?.[0];
2872
2893
  let c;
2873
2894
  if (n && d) {
2874
2895
  const m = /* @__PURE__ */ new Set(), p = [d], g = [];
@@ -2876,8 +2897,8 @@ function Zs(s, e = "responsible", t = {}) {
2876
2897
  const h = p.shift();
2877
2898
  if (!m.has(h)) {
2878
2899
  m.add(h), g.push(h);
2879
- for (const b of Object.values(s.edges))
2880
- b.from === h && !m.has(b.to) && p.push(b.to);
2900
+ for (const y of Object.values(s.edges))
2901
+ y.from === h && !m.has(y.to) && p.push(y.to);
2881
2902
  }
2882
2903
  }
2883
2904
  for (const [h] of r)
@@ -2895,14 +2916,14 @@ function Zs(s, e = "responsible", t = {}) {
2895
2916
  for (const m of c) {
2896
2917
  const p = s.nodes[m];
2897
2918
  if (!p) continue;
2898
- 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((j) => j.name), T = $.length > 0 ? `"<b>${$.join(" · ")}</b><br/>${b}"` : `"${b || m}"`;
2899
- g ? u.push(` ${i(m)}([${b || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${i(m)}{${T}}`) : p.type === "automation" ? u.push(` ${i(m)}[[${T}]]`) : u.push(` ${i(m)}(${T})`);
2900
- const N = p[e].roles[0]?.color ?? o;
2901
- g ? u.push(` style ${i(m)} fill:#2962FF,stroke:none`) : u.push(` style ${i(m)} fill:none,stroke:${N},stroke-width:3px`);
2919
+ const g = p.type === "start" || p.type === "end", y = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, "&quot;"), S = g || p.type === "decision" ? [] : p[e].roles.map((j) => j.name), R = S.length > 0 ? `"<b>${S.join(" · ")}</b><br/>${y}"` : `"${y || m}"`;
2920
+ g ? u.push(` ${o(m)}([${y || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${o(m)}{${R}}`) : p.type === "automation" ? u.push(` ${o(m)}[[${R}]]`) : u.push(` ${o(m)}(${R})`);
2921
+ const N = p[e].roles[0]?.color ?? i;
2922
+ g ? u.push(` style ${o(m)} fill:#2962FF,stroke:none`) : u.push(` style ${o(m)} fill:none,stroke:${N},stroke-width:3px`);
2902
2923
  }
2903
2924
  const f = n ? c.flatMap((m) => Object.values(s.edges).filter((p) => p.from === m)) : Object.values(s.edges);
2904
2925
  for (const m of f)
2905
- m.label ? u.push(` ${i(m.from)} -->|${m.label}| ${i(m.to)}`) : u.push(` ${i(m.from)} --> ${i(m.to)}`);
2926
+ m.label ? u.push(` ${o(m.from)} -->|${m.label}| ${o(m.to)}`) : u.push(` ${o(m.from)} --> ${o(m.to)}`);
2906
2927
  return u.join(`
2907
2928
  `);
2908
2929
  }
@@ -2936,22 +2957,22 @@ class D {
2936
2957
  const n = () => this._data;
2937
2958
  this.project = new jt(
2938
2959
  () => this._data.project,
2939
- (i) => {
2940
- this._data.project = i;
2960
+ (o) => {
2961
+ this._data.project = o;
2941
2962
  },
2942
2963
  fe,
2943
- (i, o) => {
2944
- const r = [], d = x("project", i.code, o.deliverableNamingConvention);
2945
- return d && r.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && r.push(`teams["${i.clientId}"] not found`), r;
2964
+ (o, i) => {
2965
+ const r = [], d = x("project", o.code, i.deliverableNamingConvention);
2966
+ return d && r.push(d), o.clientId && !i.teams.some((l) => l.id === o.clientId) && r.push(`teams["${o.clientId}"] not found`), r;
2946
2967
  },
2947
2968
  n
2948
- ), this.actions = new Ot(n), this.annexes = new _t(n), this.env = new xt(n), this.events = new Pt(n), this.effects = new Bt(n), this.automations = new Mt(n), this.bimUses = new zt(n, () => this.workflows), this.disciplines = new Zt(n), this.guides = new Jt(n), this.lods = new Kt(n), this.lois = new qt(n), this.loin = new Wt(n), this.lbsNodes = new Ht(n), this.assetTypes = new Gt(n), this.extensions = new Xt(n), this.roles = new Vt(n), this.members = new Yt(n), this.milestones = new Qt(n), this.objectives = new es(n), this.phases = new ts(n), this.remoteData = new ss(n), this.resolvers = new ns(n), this.softwares = new is(n, () => this.assetTypes), this.standards = new os(n, () => this._zip), this.teams = new rs(n, () => this.members), this.workflows = new ds(n, () => this.members, () => this.teams), this.deliverables = new Dt(n, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Ut(n, () => this.members), this.flags = new Lt(n), this.engine = new Ps(
2969
+ ), this.actions = new Ot(n), this.annexes = new _t(n), this.env = new xt(n), this.events = new Pt(n), this.effects = new Bt(n), this.automations = new Mt(n), this.bimUses = new zt(n, () => this.workflows), this.disciplines = new Zt(n), this.guides = new Jt(n), this.lods = new Kt(n), this.lois = new qt(n), this.loin = new Wt(n), this.lbsNodes = new Ht(n), this.assetTypes = new Xt(n), this.extensions = new Gt(n), this.roles = new Vt(n), this.members = new Yt(n), this.milestones = new Qt(n), this.objectives = new es(n), this.phases = new ts(n), this.remoteData = new ss(n), this.resolvers = new ns(n), this.softwares = new os(n, () => this.assetTypes), this.standards = new is(n, () => this._zip), this.teams = new rs(n, () => this.members), this.workflows = new ds(n, () => this.members, () => this.teams), this.deliverables = new Dt(n, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Ut(n, () => this.members), this.flags = new Lt(n), this.engine = new Ps(
2949
2970
  () => this._data,
2950
- (i) => this.history.get(i)
2951
- ), this.history = new k(
2971
+ (o) => this.history.get(o)
2972
+ ), this.history = new $(
2952
2973
  n,
2953
- (i) => {
2954
- this._data = i;
2974
+ (o) => {
2975
+ this._data = o;
2955
2976
  },
2956
2977
  () => this._zip
2957
2978
  ), this.nomenclature = new Ct(n), 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);
@@ -3011,10 +3032,10 @@ class D {
3011
3032
  * fully operational after open(). Idempotent — existing files are untouched.
3012
3033
  */
3013
3034
  static async open(e) {
3014
- const t = await oe.loadAsync(e), n = t.file("bep.json");
3035
+ const t = await re.loadAsync(e), n = t.file("bep.json");
3015
3036
  if (!n) throw new Error("Invalid .bep file: missing bep.json");
3016
- const i = await n.async("string"), o = B(JSON.parse(i));
3017
- return await D._initialize(o, t), new D(o, t);
3037
+ const o = await n.async("string"), i = B(JSON.parse(o));
3038
+ return await D._initialize(i, t), new D(i, t);
3018
3039
  }
3019
3040
  /**
3020
3041
  * Ensures all expected files exist in the zip.
@@ -3034,9 +3055,9 @@ class D {
3034
3055
  if (!t.file("baseline/bep.json")) {
3035
3056
  const n = JSON.stringify(e, null, 2);
3036
3057
  t.file("baseline/bep.json", n), t.file("changelog/v0.0.json", n);
3037
- for (const i of e.standards) {
3038
- const o = await t.file(i.contentPath).async("string");
3039
- t.file(`baseline/standards/${i.id}.md`, o), t.file(`changelog/standards/${i.id}/v0.0.md`, o);
3058
+ for (const o of e.standards) {
3059
+ const i = await t.file(o.contentPath).async("string");
3060
+ t.file(`baseline/standards/${o.id}.md`, i), t.file(`changelog/standards/${o.id}/v0.0.md`, i);
3040
3061
  }
3041
3062
  }
3042
3063
  }
@@ -3070,8 +3091,8 @@ class D {
3070
3091
  flags: [],
3071
3092
  env: [],
3072
3093
  automations: []
3073
- }), n = new oe(), i = JSON.stringify(t, null, 2);
3074
- return n.file("memory.md", ""), n.file("skills/bep-authoring/SKILL.md", ""), n.file("baseline/bep.json", i), n.file("changelog/v0.0.json", i), new D(t, n);
3094
+ }), n = new re(), o = JSON.stringify(t, null, 2);
3095
+ return n.file("memory.md", ""), n.file("skills/bep-authoring/SKILL.md", ""), n.file("baseline/bep.json", o), n.file("changelog/v0.0.json", o), new D(t, n);
3075
3096
  }
3076
3097
  // ─── Accessors ────────────────────────────────────────────────────────────
3077
3098
  get data() {
@@ -3120,8 +3141,8 @@ ${n.join(`
3120
3141
  /** Returns the names of all resource files for the given skill. */
3121
3142
  listSkillResources(e) {
3122
3143
  const t = `skills/${e}/resources/`, n = [];
3123
- return this._zip.forEach((i) => {
3124
- i.startsWith(t) && i !== t && n.push(i.slice(t.length));
3144
+ return this._zip.forEach((o) => {
3145
+ o.startsWith(t) && o !== t && n.push(o.slice(t.length));
3125
3146
  }), n;
3126
3147
  }
3127
3148
  /** Returns the content of a resource file for the given skill, or null if it does not exist. */
@@ -3136,9 +3157,9 @@ ${n.join(`
3136
3157
  /** Removes a skill's SKILL.md and all its resources from the archive. No-op if not found. */
3137
3158
  removeSkill(e) {
3138
3159
  const t = `skills/${e}/`, n = [];
3139
- this._zip.forEach((i) => {
3140
- i.startsWith(t) && n.push(i);
3141
- }), n.forEach((i) => this._zip.remove(i));
3160
+ this._zip.forEach((o) => {
3161
+ o.startsWith(t) && n.push(o);
3162
+ }), n.forEach((o) => this._zip.remove(o));
3142
3163
  }
3143
3164
  /** Removes a single resource file from a skill. No-op if not found. */
3144
3165
  removeSkillResource(e, t) {
@@ -3156,11 +3177,11 @@ ${n.join(`
3156
3177
  */
3157
3178
  generateRuntimeTypes() {
3158
3179
  const e = (f) => f === "url" ? "string" : f, t = (f) => ` /** ${f} */
3159
- `, n = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`, i = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${n(f.payload)}) => void`, o = (f) => {
3180
+ `, n = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`, o = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${n(f.payload)}) => void`, i = (f) => {
3160
3181
  const m = f.payload && f.payload.length > 0 ? `payload: ${n(f.payload)}` : "", p = f.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${f.output.map((g) => `${g.key}${g.required ? "" : "?"}: ${e(g.type)}`).join("; ")} }`;
3161
3182
  return `(${m}) => ${p}`;
3162
- }, 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}': ${i(f)}`).join(`
3163
- `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${o(f)}`).join(`
3183
+ }, 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(`
3184
+ `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${i(f)}`).join(`
3164
3185
  `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((f) => `${t(f.description)} '${f.id}': ${r(f)}`).join(`
3165
3186
  `) : " [key: string]: (url: string) => unknown", u = this._data.env.length ? this._data.env.map((f) => `${t(f.description)} ${f.key}: string`).join(`
3166
3187
  `) : " [key: string]: string";
@@ -3220,10 +3241,10 @@ export {
3220
3241
  Ye as AnnexType,
3221
3242
  _t as Annexes,
3222
3243
  Ie as AssetTypeSchema,
3223
- Gt as AssetTypes,
3244
+ Xt as AssetTypes,
3224
3245
  Mt as Automations,
3225
3246
  Ls as BEPSchema,
3226
- re as BEPVersionBase,
3247
+ ae as BEPVersionBase,
3227
3248
  St as BEPVersionSchema,
3228
3249
  Se as BIMUseSchema,
3229
3250
  zt as BIMUses,
@@ -3234,17 +3255,17 @@ export {
3234
3255
  Nt as DeliverableBaseSchema,
3235
3256
  De as DeliverableSchema,
3236
3257
  Dt as Deliverables,
3237
- we as DisciplineSchema,
3258
+ be as DisciplineSchema,
3238
3259
  Zt as Disciplines,
3239
3260
  ht as EdgeGuardSchema,
3240
3261
  Bt as Effects,
3241
3262
  Ps as Engine,
3242
- y as Entity,
3263
+ w as Entity,
3243
3264
  xt as Env,
3244
3265
  Le as EnvVarSchema,
3245
3266
  Pt as Events,
3246
3267
  ve as ExtensionSchema,
3247
- Xt as Extensions,
3268
+ Gt as Extensions,
3248
3269
  Et as FlagBaseSchema,
3249
3270
  st as FlagEntityType,
3250
3271
  Ce as FlagSchema,
@@ -3255,9 +3276,9 @@ export {
3255
3276
  yt as FlowDecisionEdgeSchema,
3256
3277
  ft as FlowDecisionNodeSchema,
3257
3278
  vt as FlowDiagramSchema,
3258
- bt as FlowDirectEdgeSchema,
3279
+ wt as FlowDirectEdgeSchema,
3259
3280
  et as FlowDirection,
3260
- wt as FlowEdgeSchema,
3281
+ bt as FlowEdgeSchema,
3261
3282
  Re as FlowEffectSchema,
3262
3283
  ct as FlowEndNodeSchema,
3263
3284
  $e as FlowEventSchema,
@@ -3268,10 +3289,10 @@ export {
3268
3289
  gt as FlowTransitionEdgeSchema,
3269
3290
  _e as GuideSchema,
3270
3291
  Jt as Guides,
3271
- k as History,
3292
+ $ as History,
3272
3293
  He as ISORole,
3273
3294
  rt as LBSNodeBaseSchema,
3274
- be as LBSNodeSchema,
3295
+ we as LBSNodeSchema,
3275
3296
  Qe as LBSNodeType,
3276
3297
  Ht as LBSNodes,
3277
3298
  Me as LODSchema,
@@ -3287,8 +3308,8 @@ export {
3287
3308
  ye as MilestoneSchema,
3288
3309
  Qt as Milestones,
3289
3310
  he as NamingConventionSchema,
3290
- ot as NamingSegmentSchema,
3291
- it as NamingTokenSchema,
3311
+ it as NamingSegmentSchema,
3312
+ ot as NamingTokenSchema,
3292
3313
  at as NodeTimeoutSchema,
3293
3314
  Ds as NodeType,
3294
3315
  Ct as Nomenclature,
@@ -3308,9 +3329,9 @@ export {
3308
3329
  Js as Runtime,
3309
3330
  jt as Singleton,
3310
3331
  Ee as SoftwareSchema,
3311
- is as Softwares,
3332
+ os as Softwares,
3312
3333
  Be as StandardSchema,
3313
- os as Standards,
3334
+ is as Standards,
3314
3335
  nt as TeamBaseSchema,
3315
3336
  pe as TeamSchema,
3316
3337
  rs as Teams,
@@ -3319,13 +3340,13 @@ export {
3319
3340
  ds as Workflows,
3320
3341
  Ns as arrayDefs,
3321
3342
  qe as buildCodeMap,
3322
- W as buildConsecutivoMap,
3343
+ X as buildConsecutivoMap,
3323
3344
  C as buildParentMap,
3324
3345
  ks as diffBep,
3325
3346
  Ss as diffEntities,
3326
3347
  Zs as flowDiagramToMermaid,
3327
3348
  Ke as getNomenCode,
3328
- te as getRootIds,
3349
+ se as getRootIds,
3329
3350
  Rt as getTokenPattern,
3330
3351
  zs as groupRaciRows,
3331
3352
  B as normalizeBep,