@dotbep/core 0.2.8 → 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.
Files changed (3) hide show
  1. package/dist/index.d.ts +3 -37
  2. package/dist/index.js +1262 -1286
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import oe from "jszip";
2
- import { z as a, ZodError as He } from "zod";
3
- const Ye = a.enum([
1
+ import re from "jszip";
2
+ import { z as a, ZodError as Ve } from "zod";
3
+ const He = a.enum([
4
4
  "appointing-party",
5
5
  "lead-appointed-party",
6
6
  "appointed-party"
7
- ]), Qe = a.enum(["video", "document"]), et = a.enum(["zone", "location"]), tt = a.enum(["LR", "TB"]), Us = a.enum(["start", "end", "process", "decision", "automation"]), st = a.enum(["info", "warning", "blocking"]), nt = a.enum([
7
+ ]), Ye = a.enum(["video", "document"]), Qe = a.enum(["zone", "location"]), et = a.enum(["LR", "TB"]), Ds = a.enum(["start", "end", "process", "decision", "automation"]), tt = a.enum(["info", "warning", "blocking"]), st = a.enum([
8
8
  "roles",
9
9
  "members",
10
10
  "teams",
@@ -44,15 +44,15 @@ const Ye = a.enum([
44
44
  roleId: a.string(),
45
45
  description: a.string().optional(),
46
46
  bepEditor: a.boolean().optional()
47
- }).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."), it = a.object({
47
+ }).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."), nt = a.object({
48
48
  id: a.string().min(1).describe("Must comply with the naming convention token pattern."),
49
49
  name: a.string().min(1),
50
- isoRole: Ye,
50
+ isoRole: He,
51
51
  description: a.string().optional(),
52
52
  disciplineIds: a.array(a.string()).optional(),
53
53
  representativeEmail: a.email().optional().describe("ref Member.email"),
54
54
  memberEmails: a.array(a.email()).optional()
55
- }).describe("A company or discipline group participating in the project. Teams group members under an ISO role and can be assigned RACI responsibilities at the workflow level."), pe = it.refine((n) => !n.representativeEmail || (n.memberEmails ?? []).includes(n.representativeEmail), {
55
+ }).describe("A company or discipline group participating in the project. Teams group members under an ISO role and can be assigned RACI responsibilities at the workflow level."), pe = nt.refine((s) => !s.representativeEmail || (s.memberEmails ?? []).includes(s.representativeEmail), {
56
56
  message: "representativeEmail must be included in memberEmails.",
57
57
  path: ["representativeEmail"]
58
58
  }), ot = a.enum([
@@ -62,13 +62,13 @@ const Ye = a.enum([
62
62
  "assetType",
63
63
  "lbsZone",
64
64
  "lbsLocation"
65
- ]), rt = a.discriminatedUnion("type", [
65
+ ]), it = a.discriminatedUnion("type", [
66
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(rt).min(1)
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((n) => n.segments.filter((e) => e.type === "sequence").length <= 1, {
70
+ segments: a.array(it).min(1)
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"]
74
74
  }), ge = a.object({
@@ -81,16 +81,16 @@ const Ye = a.enum([
81
81
  date: a.iso.date(),
82
82
  phaseId: a.string(),
83
83
  description: a.string().optional()
84
- }).describe("A named deadline within a phase. Anchors deliverables and information requirements to a specific date in the project timeline."), at = a.object({
84
+ }).describe("A named deadline within a phase. Anchors deliverables and information requirements to a specific date in the project timeline."), rt = a.object({
85
85
  id: a.string().min(1).describe("Used in deliverables nomenclature."),
86
86
  name: a.string().min(1),
87
- type: et,
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 = at.refine((n) => !(n.lbsNodeIds ?? []).includes(n.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({
@@ -142,10 +142,10 @@ const Ye = a.enum([
142
142
  description: a.string().min(1).describe("Describe what this handler checks and what decision it produces: what condition or business rule it evaluates and where that data comes from."),
143
143
  payload: a.array(L).optional().describe("Fields consumed from instance context and passed to the handler."),
144
144
  output: a.array(L).describe("Fields the handler must return. Guards on outgoing edges reference these.")
145
- }).describe("A system-executed node in a workflow. Runs a handler automatically, produces a typed output, and must be followed by a decision node that branches on that output."), dt = a.object({
145
+ }).describe("A system-executed node in a workflow. Runs a handler automatically, produces a typed output, and must be followed by a decision node that branches on that output."), at = a.object({
146
146
  hours: a.number().positive(),
147
147
  effectId: a.string().min(1).describe("ref FlowEffect.id")
148
- }).describe("A time-based escalation on a process or automation node. Fires a declared effect if the node has not been advanced within the given number of hours."), lt = a.object({
148
+ }).describe("A time-based escalation on a process or automation node. Fires a declared effect if the node has not been advanced within the given number of hours."), dt = a.object({
149
149
  responsibleRoleIds: a.array(a.string()).optional().describe("ref Role.id[]"),
150
150
  accountableRoleIds: a.array(a.string()).optional().describe("ref Role.id[]"),
151
151
  consultedRoleIds: a.array(a.string()).optional().describe("ref Role.id[]"),
@@ -158,85 +158,85 @@ const Ye = a.enum([
158
158
  accountableEmails: a.array(a.string()).optional().describe("ref Member.email[]"),
159
159
  consultedEmails: a.array(a.string()).optional().describe("ref Member.email[]"),
160
160
  informedEmails: a.array(a.string()).optional().describe("ref Member.email[]")
161
- }), Ae = a.object({
162
- timeouts: a.array(dt).optional()
163
- }), ct = a.object({
161
+ }), je = a.object({
162
+ timeouts: a.array(at).optional()
163
+ }), lt = a.object({
164
164
  type: a.literal("start")
165
- }), ft = a.object({
165
+ }), ct = a.object({
166
166
  type: a.literal("end")
167
- }), ut = a.object({
167
+ }), ft = a.object({
168
168
  type: a.literal("decision"),
169
169
  label: a.string().min(1)
170
- }), mt = a.object({
170
+ }), ut = a.object({
171
171
  type: a.literal("automation"),
172
172
  automationId: a.string().min(1).describe("ref FlowAutomation.id")
173
- }).extend(Ae.shape), pt = a.object({
173
+ }).extend(je.shape), mt = a.object({
174
174
  type: a.literal("process"),
175
175
  actionId: a.string().optional().describe("ref Action.id"),
176
176
  workflowId: a.string().optional().describe("ref Workflow.id — spawns child instances of this workflow when the node is entered."),
177
177
  blocking: a.boolean().optional().describe("If true, waits for all spawned child instances to complete before accepting outgoing transitions.")
178
- }).extend(lt.shape).extend(Ae.shape).refine((n) => !!n.actionId != !!n.workflowId, {
178
+ }).extend(dt.shape).extend(je.shape).refine((s) => !!s.actionId != !!s.workflowId, {
179
179
  message: "process nodes require exactly one of actionId or workflowId.",
180
180
  path: ["actionId"]
181
- }).refine((n) => !n.blocking || !!n.workflowId, {
181
+ }).refine((s) => !s.blocking || !!s.workflowId, {
182
182
  message: "blocking requires workflowId to be set.",
183
183
  path: ["blocking"]
184
184
  }).refine(
185
- (n) => (n.responsibleRoleIds?.length ?? 0) > 0 || (n.responsibleTeamIds?.length ?? 0) > 0 || (n.responsibleEmails?.length ?? 0) > 0,
185
+ (s) => (s.responsibleRoleIds?.length ?? 0) > 0 || (s.responsibleTeamIds?.length ?? 0) > 0 || (s.responsibleEmails?.length ?? 0) > 0,
186
186
  {
187
187
  message: "process nodes require at least one responsible (role, team, or email).",
188
188
  path: ["responsibleRoleIds"]
189
189
  }
190
- ), ht = a.union([
190
+ ), pt = a.union([
191
+ lt,
191
192
  ct,
192
193
  ft,
193
194
  ut,
194
- mt,
195
- pt
196
- ]).describe("A node in a workflow diagram used to describe steps."), gt = a.object({
195
+ mt
196
+ ]).describe("A node in a workflow diagram used to describe steps."), ht = a.object({
197
197
  field: a.string().min(1),
198
198
  operator: a.enum(["eq", "neq", "gt", "lt", "contains", "exists"]),
199
199
  value: a.union([a.string(), a.number(), a.boolean()]).optional()
200
- }).refine((n) => n.operator === "exists" || n.value !== void 0, {
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(),
207
207
  effectIds: a.array(a.string().min(1)).optional().describe("ref FlowEffect.id[]")
208
- }).refine((n) => n.from !== n.to, {
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
- }), yt = ee.extend({
211
+ }), gt = te.extend({
212
212
  triggerEventId: a.string().min(1).describe("ref FlowEvent.id — the event that fires this transition")
213
- }), bt = ee.extend({
214
- guard: gt.describe("Condition evaluated against the instance context to determine which path to take.")
215
- }), wt = ee, vt = a.union([yt, bt, wt]), It = a.object({
216
- direction: tt.default("LR"),
217
- nodes: a.record(a.string(), ht),
218
- edges: a.record(a.string(), vt)
219
- }).superRefine((n, e) => {
220
- const t = Object.entries(n.nodes), s = t.filter(([, r]) => r.type === "start").length, i = t.filter(([, r]) => r.type === "end").length;
221
- s !== 1 && e.addIssue({
213
+ }), yt = te.extend({
214
+ guard: ht.describe("Condition evaluated against the instance context to determine which path to take.")
215
+ }), wt = te, bt = a.union([gt, yt, wt]), vt = a.object({
216
+ direction: et.default("LR"),
217
+ nodes: a.record(a.string(), pt),
218
+ edges: a.record(a.string(), bt)
219
+ }).superRefine((s, e) => {
220
+ const t = Object.entries(s.nodes), n = t.filter(([, r]) => r.type === "start").length, o = t.filter(([, r]) => r.type === "end").length;
221
+ n !== 1 && e.addIssue({
222
222
  code: "custom",
223
- message: `Diagram must have exactly one start node (found ${s}).`,
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 = {};
231
- for (const [r, d] of Object.entries(n.edges))
232
- o[d.from] ??= [], o[d.from].push({ edgeId: r, toKey: d.to });
230
+ const i = {};
231
+ for (const [r, d] of Object.entries(s.edges))
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}).`,
238
238
  path: ["nodes", r]
239
- }) : n.nodes[l[0].toKey]?.type !== "decision" && e.addIssue({
239
+ }) : s.nodes[l[0].toKey]?.type !== "decision" && e.addIssue({
240
240
  code: "custom",
241
241
  message: "automation node must connect directly to a decision node.",
242
242
  path: ["nodes", r]
@@ -246,8 +246,8 @@ const Ye = a.enum([
246
246
  path: ["nodes", r]
247
247
  });
248
248
  }
249
- for (const [r, d] of Object.entries(n.edges)) {
250
- const l = n.nodes[d.from];
249
+ for (const [r, d] of Object.entries(s.edges)) {
250
+ const l = s.nodes[d.from];
251
251
  if (!l) continue;
252
252
  const c = "triggerEventId" in d, u = "guard" in d;
253
253
  l.type === "start" && (c || u) && e.addIssue({
@@ -272,17 +272,17 @@ const Ye = a.enum([
272
272
  path: ["edges", r, "guard"]
273
273
  });
274
274
  }
275
- }).describe("The visual and structural definition of a workflow."), je = a.object({
275
+ }).describe("The visual and structural definition of a workflow."), Ae = a.object({
276
276
  id: a.uuid(),
277
277
  name: a.string().min(1),
278
278
  description: a.string().optional(),
279
279
  example: a.string().optional().describe("Narrative example showcasing one cycle of this workflow."),
280
280
  trackedAssetTypeId: a.string().optional().describe("ref AssetType.id"),
281
- diagram: It
281
+ diagram: vt
282
282
  }).describe("A reusable process definition associated with one or more BIM uses. Describes the ordered steps, responsibilities, and transitions that govern how work is carried out."), Oe = a.object({
283
283
  id: a.uuid(),
284
284
  name: a.string().min(1),
285
- type: Qe,
285
+ type: Ye,
286
286
  url: a.string().min(1),
287
287
  description: a.string().optional()
288
288
  }).describe("Supporting material attached to the BEP, such as a reference document or instructional video."), _e = a.object({
@@ -303,7 +303,7 @@ const Ye = a.enum([
303
303
  id: a.string().min(1),
304
304
  name: a.string().min(1),
305
305
  checklist: a.array(a.string()).optional()
306
- }).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), Et = a.object({
306
+ }).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), It = a.object({
307
307
  milestoneId: a.string(),
308
308
  lodId: a.string().min(1),
309
309
  loiId: a.string().min(1),
@@ -312,22 +312,22 @@ const Ye = a.enum([
312
312
  id: a.uuid(),
313
313
  element: a.string().min(1),
314
314
  disciplineId: a.string(),
315
- milestones: a.array(Et).optional()
315
+ milestones: a.array(It).optional()
316
316
  }).describe("An information requirement for a model element. Declares what geometric detail and information properties are required for a specific model element and discipline across project milestones."), Fe = a.object({
317
317
  id: a.uuid(),
318
318
  message: a.string().min(1),
319
319
  memberEmail: a.email(),
320
320
  createdAt: a.iso.datetime()
321
- }).describe("A timestamped comment left by a project member on the BEP."), Nt = a.object({
321
+ }).describe("A timestamped comment left by a project member on the BEP."), Et = a.object({
322
322
  id: a.uuid(),
323
- entity: nt.nullable().describe("null = BEP-level flag"),
323
+ entity: st.nullable().describe("null = BEP-level flag"),
324
324
  entityId: a.string().nullable(),
325
- severity: st,
325
+ severity: tt,
326
326
  message: a.string().min(1),
327
327
  generatedAt: a.iso.datetime()
328
- }).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), Ce = Nt.refine((n) => n.entity === null == (n.entityId === null), {
328
+ }).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), Ce = Et.refine((s) => s.entity === null == (s.entityId === null), {
329
329
  message: "entity and entityId must both be null (BEP-level) or both be non-null (entity-level)."
330
- }), St = a.object({
330
+ }), Nt = a.object({
331
331
  id: a.uuid(),
332
332
  description: a.string().optional(),
333
333
  lbsNodeId: a.string().optional(),
@@ -340,7 +340,7 @@ const Ye = a.enum([
340
340
  predecessorId: a.string().optional(),
341
341
  url: a.url().optional(),
342
342
  resolverId: a.string().min(1).optional()
343
- }).describe("A formal output committed by a team at a milestone. Defines what must be delivered, in what format, by whom, and by when."), De = St.refine((n) => !n.predecessorId || n.predecessorId !== n.id, {
343
+ }).describe("A formal output committed by a team at a milestone. Defines what must be delivered, in what format, by whom, and by when."), De = Nt.refine((s) => !s.predecessorId || s.predecessorId !== s.id, {
344
344
  message: "predecessorId cannot reference the deliverable itself.",
345
345
  path: ["predecessorId"]
346
346
  }), Le = a.object({
@@ -350,19 +350,15 @@ const Ye = a.enum([
350
350
  }).describe("A runtime configuration entry for handlers. Used to store credentials, endpoints, or other runtime settings without hardcoding them."), Ue = a.object({
351
351
  id: a.string().min(1).describe('Human-readable slug, e.g. "google-sheet"'),
352
352
  name: a.string().min(1),
353
- description: a.string().min(1).describe("Describe what external data this fetches, from where, and what format it returns: which service or API it calls, what credentials it needs, and the shape of the raw payload it returns so the runtime developer and adapter author know what to expect."),
353
+ description: a.string().min(1).describe("Describe what external data this fetches, from where, and what format it returns: which service or API it calls, what credentials it needs, and the shape of the raw payload it returns."),
354
354
  envKeys: a.array(a.string().min(1)).describe("ref EnvVar.key[] — env vars required by this resolver handler.")
355
355
  }).describe("A server-side handler declared in the BEP bundle that authenticates against an external service, fetches data, and returns a raw payload for a live resource."), ze = a.object({
356
- id: a.string().min(1).describe('Human-readable slug, e.g. "discipline-progress"'),
357
- name: a.string().min(1),
358
- description: a.string().min(1).describe("Describe the input format (resolver output shape), the transformation applied, and the output format (lens-compatible shape) so the runtime developer can implement the correct mapping.")
359
- }).describe("A transformation function declared in the BEP bundle that converts resolver output into a compatible format."), Ze = a.object({
360
356
  id: a.uuid(),
361
357
  name: a.string().min(1),
362
358
  description: a.string().min(1).describe("Describe what this data source represents in the project context: what information it holds, how it is used in the BEP, and who or what system produces it."),
363
359
  url: a.url(),
364
360
  resolverId: a.string().min(1).optional().describe("ref Resolver.id")
365
- }).describe("A reference to an external data source that is fetched at runtime. The BEP does not store the data — it only declares where it lives and how to access it using a resolver."), zs = a.object({
361
+ }).describe("A reference to an external data source that is fetched at runtime. The BEP does not store the data — it only declares where it lives and how to access it using a resolver."), Ls = a.object({
366
362
  project: fe,
367
363
  deliverableNamingConvention: he.optional(),
368
364
  roles: a.array(ue),
@@ -370,8 +366,8 @@ const Ye = a.enum([
370
366
  teams: a.array(pe),
371
367
  phases: a.array(ge),
372
368
  milestones: a.array(ye),
373
- lbs: a.array(be),
374
- disciplines: a.array(we),
369
+ lbs: a.array(we),
370
+ disciplines: a.array(be),
375
371
  extensions: a.array(ve),
376
372
  assetTypes: a.array(Ie),
377
373
  softwares: a.array(Ee),
@@ -383,9 +379,8 @@ const Ye = a.enum([
383
379
  automations: a.array(Te),
384
380
  env: a.array(Le),
385
381
  resolvers: a.array(Ue),
386
- adapters: a.array(ze),
387
- remoteData: a.array(Ze),
388
- workflows: a.array(je),
382
+ remoteData: a.array(ze),
383
+ workflows: a.array(Ae),
389
384
  guides: a.array(_e),
390
385
  annexes: a.array(Oe),
391
386
  standards: a.array(Be),
@@ -395,52 +390,52 @@ const Ye = a.enum([
395
390
  deliverables: a.array(De),
396
391
  notes: a.array(Fe),
397
392
  flags: a.array(Ce)
398
- }), re = a.object({
393
+ }), ae = a.object({
399
394
  version: a.string().regex(/^\d+\.\d+$/).describe('Format: "{major}.{minor}" (e.g. "1.0", "2.3").'),
400
395
  date: a.iso.datetime(),
401
396
  author: a.email().describe("ref Member.email"),
402
397
  description: a.string().min(1),
403
398
  diff: a.string().nullable().describe("Relative path to inverse diff (RFC 6902). null on v0.0.")
404
- }), kt = a.discriminatedUnion("type", [
405
- re.extend({ type: a.literal("patch") }),
406
- re.extend({
399
+ }), St = a.discriminatedUnion("type", [
400
+ ae.extend({ type: a.literal("patch") }),
401
+ ae.extend({
407
402
  type: a.literal("version"),
408
403
  approvedBy: a.array(a.email()).describe("ref Member.email[]")
409
404
  })
410
- ]), Zs = a.object({
405
+ ]), Us = a.object({
411
406
  current: a.string().regex(/^\d+\.\d+$/).describe('Current version in "{major}.{minor}" format.'),
412
- versions: a.array(kt)
407
+ versions: a.array(St)
413
408
  });
414
- function B(n) {
415
- return n.roles ??= [], n.members ??= [], n.teams ??= [], n.phases ??= [], n.milestones ??= [], n.lbs ??= [], n.disciplines ??= [], n.extensions ??= [], n.assetTypes ??= [], n.softwares ??= [], n.objectives ??= [], n.bimUses ??= [], n.actions ??= [], n.events ??= [], n.effects ??= [], n.workflows ??= [], n.guides ??= [], n.annexes ??= [], n.standards ??= [], n.lods ??= [], n.lois ??= [], n.loin ??= [], n.deliverables ??= [], n.notes ??= [], n.flags ??= [], n.env ??= [], n.automations ??= [], n.resolvers ??= [], n.remoteData ??= [], n.adapters ??= [], n;
409
+ function B(s) {
410
+ return s.roles ??= [], s.members ??= [], s.teams ??= [], s.phases ??= [], s.milestones ??= [], s.lbs ??= [], s.disciplines ??= [], s.extensions ??= [], s.assetTypes ??= [], s.softwares ??= [], s.objectives ??= [], s.bimUses ??= [], s.actions ??= [], s.events ??= [], s.effects ??= [], s.workflows ??= [], s.guides ??= [], s.annexes ??= [], s.standards ??= [], s.lods ??= [], s.lois ??= [], s.loin ??= [], s.deliverables ??= [], s.notes ??= [], s.flags ??= [], s.env ??= [], s.automations ??= [], s.resolvers ??= [], s.remoteData ??= [], s;
416
411
  }
417
- const $t = "-", Rt = "^[A-Z0-9]{3}$";
418
- function Tt(n, e) {
412
+ const kt = "-", $t = "^[A-Z0-9]{3}$";
413
+ function Rt(s, e) {
419
414
  if (e) {
420
- const t = e.segments.find((s) => s.type === "field" && s.token === n);
415
+ const t = e.segments.find((n) => n.type === "field" && n.token === s);
421
416
  if (t?.type === "field" && t.pattern) return t.pattern;
422
417
  }
423
- return Rt;
418
+ return $t;
424
419
  }
425
- function x(n, e, t) {
426
- const s = t?.delimiter ?? $t, i = Tt(n, t);
427
- return new RegExp(i).test(e) ? e.includes(s) ? `"${e}" contains the naming delimiter "${s}"` : null : `"${e}" does not match naming pattern ${i} for token "${n}"`;
420
+ function x(s, e, t) {
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}"`;
428
423
  }
429
- function At(n, e) {
430
- const t = [], s = (i, o) => {
431
- const r = x(i, o, e);
424
+ function Tt(s, e) {
425
+ const t = [], n = (o, i) => {
426
+ const r = x(o, i, e);
432
427
  r && t.push(r);
433
428
  };
434
- s("project", n.project.code);
435
- for (const i of n.teams) s("team", i.id);
436
- for (const i of n.disciplines) s("discipline", i.id);
437
- for (const i of n.assetTypes) s("assetType", i.id);
438
- for (const i of n.lbs) s(i.type === "zone" ? "lbsZone" : "lbsLocation", i.id);
429
+ n("project", s.project.code);
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);
439
434
  return t;
440
435
  }
441
436
  class jt {
442
- constructor(e, t, s, i, o) {
443
- this.getItem = e, this.setItem = t, this.schema = s, 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;
444
439
  }
445
440
  getItem;
446
441
  setItem;
@@ -453,13 +448,13 @@ class jt {
453
448
  update(e) {
454
449
  const t = this.schema.parse({ ...this.getItem(), ...e });
455
450
  if (this.validate && this.getBep) {
456
- const s = this.validate(t, this.getBep());
457
- if (s.length) throw new Error(s.join("; "));
451
+ const n = this.validate(t, this.getBep());
452
+ if (n.length) throw new Error(n.join("; "));
458
453
  }
459
454
  return this.setItem(t), t;
460
455
  }
461
456
  }
462
- const Je = [
457
+ const Ze = [
463
458
  // roles
464
459
  { entity: "members", references: "roles", inField: "roleId" },
465
460
  // members
@@ -499,29 +494,29 @@ const Je = [
499
494
  // lbs (self-referential)
500
495
  { entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
501
496
  ];
502
- function Ot(n, e, t) {
503
- return Je.filter((s) => s.references === e).flatMap((s) => t[s.entity].filter((o) => {
504
- const r = o[s.inField];
505
- return s.array ? Array.isArray(r) && r.includes(n) : r === n;
506
- }).map((o) => {
507
- const r = o.id ?? o.email ?? "?";
508
- return `${String(s.entity)}["${r}"].${String(s.inField)}`;
497
+ function At(s, e, t) {
498
+ return Ze.filter((n) => n.references === e).flatMap((n) => t[n.entity].filter((i) => {
499
+ const r = i[n.inField];
500
+ return n.array ? Array.isArray(r) && r.includes(s) : r === s;
501
+ }).map((i) => {
502
+ const r = i.id ?? i.email ?? "?";
503
+ return `${String(n.entity)}["${r}"].${String(n.inField)}`;
509
504
  }));
510
505
  }
511
- function ae(n, e, t) {
512
- return Je.filter((s) => s.entity === e).flatMap((s) => {
513
- const i = n[s.inField];
514
- if (i == null || i === "") return [];
515
- const o = s.array ? i : [i], r = t[s.references];
516
- return o.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(s.references)}["${d}"] not found`);
506
+ function de(s, e, t) {
507
+ return Ze.filter((n) => n.entity === e).flatMap((n) => {
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`);
517
512
  });
518
513
  }
519
- function K(n) {
520
- return n instanceof He ? n.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : n.message;
514
+ function K(s) {
515
+ return s instanceof Ve ? s.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : s.message;
521
516
  }
522
- class y {
523
- constructor(e, t, s) {
524
- this.getItems = e, this.getBep = t, this.config = s, this.idField = s.idField ?? "id";
517
+ class w {
518
+ constructor(e, t, n) {
519
+ this.getItems = e, this.getBep = t, this.config = n, this.idField = n.idField ?? "id";
525
520
  }
526
521
  getItems;
527
522
  getBep;
@@ -534,77 +529,77 @@ class y {
534
529
  return this.getItems();
535
530
  }
536
531
  get(e) {
537
- const t = [], s = [];
538
- for (const i of e) {
539
- const o = this.getItems().find((r) => this.getId(r) === i);
540
- o ? t.push(o) : s.push({ id: i, error: `Not found: ${i}` });
532
+ const t = [], n = [];
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}` });
541
536
  }
542
- return { succeeded: t, failed: s };
537
+ return { succeeded: t, failed: n };
543
538
  }
544
539
  add(e) {
545
- const t = [], s = [];
546
- for (const i of e) {
547
- const o = { ...i };
548
- this.config.autoId && !o[this.idField] && (o[this.idField] = globalThis.crypto.randomUUID());
549
- const r = String(o[this.idField] ?? "(unknown)");
540
+ const t = [], n = [];
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)");
550
545
  try {
551
- const d = this.config.schema.parse(o);
546
+ const d = this.config.schema.parse(i);
552
547
  if (this.getItems().some((u) => this.getId(u) === this.getId(d)))
553
548
  throw new Error(`Already exists: ${this.getId(d)}`);
554
- const l = ae(d, this.config.key, this.getBep());
549
+ const l = de(d, this.config.key, this.getBep());
555
550
  if (l.length) throw new Error(l.join("; "));
556
551
  const c = this.config.validate?.(d, this.getBep()) ?? [];
557
552
  if (c.length) throw new Error(c.join("; "));
558
553
  this.getItems().push(d), t.push(d);
559
554
  } catch (d) {
560
- s.push({ id: r, error: K(d) });
555
+ n.push({ id: r, error: K(d) });
561
556
  }
562
557
  }
563
- return { succeeded: t, failed: s };
558
+ return { succeeded: t, failed: n };
564
559
  }
565
560
  update(e) {
566
- const t = [], s = [];
567
- for (const i of e) {
568
- const o = String(i[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === o);
561
+ const t = [], n = [];
562
+ for (const o of e) {
563
+ const i = String(o[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === i);
569
564
  if (d === -1) {
570
- s.push({ id: o, error: `Not found: ${o}` });
565
+ n.push({ id: i, error: `Not found: ${i}` });
571
566
  continue;
572
567
  }
573
- const l = ae(i, this.config.key, this.getBep());
568
+ const l = de(o, this.config.key, this.getBep());
574
569
  if (l.length) {
575
- s.push({ id: o, error: l.join("; ") });
570
+ n.push({ id: i, error: l.join("; ") });
576
571
  continue;
577
572
  }
578
573
  try {
579
- 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()) ?? [];
580
575
  if (u.length) throw new Error(u.join("; "));
581
576
  r[d] = c, t.push(r[d]);
582
577
  } catch (c) {
583
- s.push({ id: o, error: K(c) });
578
+ n.push({ id: i, error: K(c) });
584
579
  }
585
580
  }
586
- return { succeeded: t, failed: s };
581
+ return { succeeded: t, failed: n };
587
582
  }
588
583
  remove(e) {
589
- const t = [], s = [];
590
- for (const i of e) {
591
- const o = this.getItems(), r = o.findIndex((d) => this.getId(d) === i);
584
+ const t = [], n = [];
585
+ for (const o of e) {
586
+ const i = this.getItems(), r = i.findIndex((d) => this.getId(d) === o);
592
587
  if (r === -1) {
593
- s.push({ id: i, error: `Not found: ${i}` });
588
+ n.push({ id: o, error: `Not found: ${o}` });
594
589
  continue;
595
590
  }
596
591
  try {
597
- const d = Ot(i, this.config.key, this.getBep());
592
+ const d = At(o, this.config.key, this.getBep());
598
593
  if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
599
- 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);
600
595
  } catch (d) {
601
- s.push({ id: i, error: K(d) });
596
+ n.push({ id: o, error: K(d) });
602
597
  }
603
598
  }
604
- return { succeeded: t, failed: s };
599
+ return { succeeded: t, failed: n };
605
600
  }
606
601
  }
607
- class _t extends y {
602
+ class Ot extends w {
608
603
  constructor(e) {
609
604
  super(
610
605
  () => e().actions,
@@ -613,29 +608,17 @@ class _t extends y {
613
608
  key: "actions",
614
609
  schema: ke,
615
610
  autoId: !0,
616
- beforeRemove: (t, s) => {
617
- for (const i of s.workflows)
618
- for (const [o, r] of Object.entries(i.diagram.nodes))
611
+ beforeRemove: (t, n) => {
612
+ for (const o of n.workflows)
613
+ for (const [i, r] of Object.entries(o.diagram.nodes))
619
614
  if (r.type === "process" && r.actionId === t)
620
- 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`);
621
616
  }
622
617
  }
623
618
  );
624
619
  }
625
620
  }
626
- class Bt extends y {
627
- constructor(e) {
628
- super(
629
- () => e().adapters,
630
- e,
631
- {
632
- key: "adapters",
633
- schema: ze
634
- }
635
- );
636
- }
637
- }
638
- class Mt extends y {
621
+ class _t extends w {
639
622
  constructor(e) {
640
623
  super(
641
624
  () => e().annexes,
@@ -648,7 +631,7 @@ class Mt extends y {
648
631
  );
649
632
  }
650
633
  }
651
- class xt extends y {
634
+ class Bt extends w {
652
635
  constructor(e) {
653
636
  super(
654
637
  () => e().effects,
@@ -656,21 +639,21 @@ class xt extends y {
656
639
  {
657
640
  key: "effects",
658
641
  schema: Re,
659
- beforeRemove: (t, s) => {
660
- for (const i of s.workflows) {
661
- for (const [o, r] of Object.entries(i.diagram.nodes))
642
+ beforeRemove: (t, n) => {
643
+ for (const o of n.workflows) {
644
+ for (const [i, r] of Object.entries(o.diagram.nodes))
662
645
  if ((r.type === "process" || r.type === "automation") && r.timeouts?.some((d) => d.effectId === t))
663
- throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].timeouts[].effectId`);
664
- for (const [o, r] of Object.entries(i.diagram.edges))
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))
665
648
  if (r.effectIds?.includes(t))
666
- 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`);
667
650
  }
668
651
  }
669
652
  }
670
653
  );
671
654
  }
672
655
  }
673
- class Pt extends y {
656
+ class Mt extends w {
674
657
  constructor(e) {
675
658
  super(
676
659
  () => e().automations,
@@ -678,17 +661,17 @@ class Pt extends y {
678
661
  {
679
662
  key: "automations",
680
663
  schema: Te,
681
- beforeRemove: (t, s) => {
682
- for (const i of s.workflows)
683
- for (const [o, r] of Object.entries(i.diagram.nodes))
664
+ beforeRemove: (t, n) => {
665
+ for (const o of n.workflows)
666
+ for (const [i, r] of Object.entries(o.diagram.nodes))
684
667
  if (r.type === "automation" && r.automationId === t)
685
- 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`);
686
669
  }
687
670
  }
688
671
  );
689
672
  }
690
673
  }
691
- class Ft extends y {
674
+ class xt extends w {
692
675
  constructor(e) {
693
676
  super(
694
677
  () => e().env,
@@ -701,7 +684,7 @@ class Ft extends y {
701
684
  );
702
685
  }
703
686
  }
704
- class Ct extends y {
687
+ class Pt extends w {
705
688
  constructor(e) {
706
689
  super(
707
690
  () => e().events,
@@ -709,139 +692,139 @@ class Ct extends y {
709
692
  {
710
693
  key: "events",
711
694
  schema: $e,
712
- beforeRemove: (t, s) => {
713
- for (const i of s.workflows)
714
- for (const [o, r] of Object.entries(i.diagram.edges))
695
+ beforeRemove: (t, n) => {
696
+ for (const o of n.workflows)
697
+ for (const [i, r] of Object.entries(o.diagram.edges))
715
698
  if ("triggerEventId" in r && r.triggerEventId === t)
716
- 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`);
717
700
  }
718
701
  }
719
702
  );
720
703
  }
721
704
  }
722
- function C(n) {
705
+ function C(s) {
723
706
  const e = /* @__PURE__ */ new Map();
724
- for (const t of n)
725
- for (const s of t.lbsNodeIds ?? [])
726
- e.set(s, t.id);
707
+ for (const t of s)
708
+ for (const n of t.lbsNodeIds ?? [])
709
+ e.set(n, t.id);
727
710
  return e;
728
711
  }
729
- function te(n) {
712
+ function se(s) {
730
713
  const e = /* @__PURE__ */ new Set();
731
- for (const t of n)
732
- for (const s of t.lbsNodeIds ?? []) e.add(s);
733
- return new Set(n.map((t) => t.id).filter((t) => !e.has(t)));
734
- }
735
- function Ke(n, e) {
736
- if (!n) return { zoneCode: "XXX", locationCode: "XXX" };
737
- const t = new Map(e.map((d) => [d.id, d])), s = C(e), i = te(e), o = t.get(n);
738
- if (!o) return { zoneCode: "XXX", locationCode: "XXX" };
739
- if (i.has(o.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
740
- if (o.type === "zone") return { zoneCode: o.id, locationCode: "ZZZ" };
741
- let r = s.get(o.id);
714
+ for (const t of s)
715
+ for (const n of t.lbsNodeIds ?? []) e.add(n);
716
+ return new Set(s.map((t) => t.id).filter((t) => !e.has(t)));
717
+ }
718
+ function Je(s, e) {
719
+ if (!s) return { zoneCode: "XXX", locationCode: "XXX" };
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);
742
725
  for (; r; ) {
743
726
  const d = t.get(r);
744
727
  if (!d) break;
745
- if (d.type === "zone" && !i.has(d.id))
746
- return { zoneCode: d.id, locationCode: o.id };
747
- r = s.get(r);
728
+ if (d.type === "zone" && !o.has(d.id))
729
+ return { zoneCode: d.id, locationCode: i.id };
730
+ r = n.get(r);
748
731
  }
749
- return { zoneCode: "ZZZ", locationCode: o.id };
732
+ return { zoneCode: "ZZZ", locationCode: i.id };
750
733
  }
751
- function Dt(n) {
752
- const e = [], t = new Map(n.map((d) => [d.id, d])), s = te(n);
753
- for (const d of s) {
734
+ function Ft(s) {
735
+ const e = [], t = new Map(s.map((d) => [d.id, d])), n = se(s);
736
+ for (const d of n) {
754
737
  const l = t.get(d);
755
738
  l && l.type !== "zone" && e.push(`Root node "${d}" must be of type "zone".`);
756
739
  }
757
- for (const d of n)
740
+ for (const d of s)
758
741
  if (d.type === "location")
759
742
  for (const l of d.lbsNodeIds ?? [])
760
743
  t.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
761
- const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
744
+ const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
762
745
  function r(d) {
763
- if (o.has(d)) return !0;
764
- if (i.has(d)) return !1;
765
- 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);
766
749
  for (const l of t.get(d)?.lbsNodeIds ?? [])
767
750
  if (r(l))
768
751
  return e.push(`Cycle detected in LBS tree at node "${d}".`), !0;
769
- return o.delete(d), !1;
752
+ return i.delete(d), !1;
770
753
  }
771
- for (const d of n)
772
- i.has(d.id) || r(d.id);
754
+ for (const d of s)
755
+ o.has(d.id) || r(d.id);
773
756
  return e;
774
757
  }
775
- function W(n) {
758
+ function X(s) {
776
759
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
777
- for (const s of n) {
778
- const i = (t.get(s.responsibleId) ?? 0) + 1;
779
- t.set(s.responsibleId, i), e.set(s.id, i);
760
+ for (const n of s) {
761
+ const o = (t.get(n.responsibleId) ?? 0) + 1;
762
+ t.set(n.responsibleId, o), e.set(n.id, o);
780
763
  }
781
764
  return e;
782
765
  }
783
766
  const F = "XXX";
784
- function qe(n, e, t, s, i) {
785
- const { zoneCode: o, locationCode: r } = Ke(n.lbsNodeId, s);
786
- if (!i) {
787
- const l = String(t.get(n.id) ?? 0).padStart(3, "0");
788
- return [e, n.responsibleId, o, r, n.assetTypeId, n.disciplineId, l].join("-");
767
+ function Ke(s, e, t, n, o) {
768
+ const { zoneCode: i, locationCode: r } = Je(s.lbsNodeId, n);
769
+ if (!o) {
770
+ const l = String(t.get(s.id) ?? 0).padStart(3, "0");
771
+ return [e, s.responsibleId, i, r, s.assetTypeId, s.disciplineId, l].join("-");
789
772
  }
790
- return i.segments.map((l) => {
773
+ return o.segments.map((l) => {
791
774
  if (l.type === "sequence") {
792
775
  const c = l.padding ?? 3;
793
- return String(t.get(n.id) ?? 0).padStart(c, "0");
776
+ return String(t.get(s.id) ?? 0).padStart(c, "0");
794
777
  }
795
778
  switch (l.token) {
796
779
  case "project":
797
780
  return e || F;
798
781
  case "team":
799
- return n.responsibleId || F;
782
+ return s.responsibleId || F;
800
783
  case "discipline":
801
- return n.disciplineId || F;
784
+ return s.disciplineId || F;
802
785
  case "assetType":
803
- return n.assetTypeId || F;
786
+ return s.assetTypeId || F;
804
787
  case "lbsZone":
805
- return o;
788
+ return i;
806
789
  case "lbsLocation":
807
790
  return r;
808
791
  }
809
- }).join(i.delimiter);
792
+ }).join(o.delimiter);
810
793
  }
811
- function We(n, e, t, s) {
812
- const i = W(n);
813
- return new Map(n.map((o) => [
814
- o.id,
815
- qe(o, e, i, t, s)
794
+ function qe(s, e, t, n) {
795
+ const o = X(s);
796
+ return new Map(s.map((i) => [
797
+ i.id,
798
+ Ke(i, e, o, t, n)
816
799
  ]));
817
800
  }
818
- class Lt {
801
+ class Ct {
819
802
  constructor(e) {
820
803
  this.getBep = e;
821
804
  }
822
805
  getBep;
823
806
  /** Maps every deliverable id to its sequence number within its originator team. */
824
807
  buildConsecutivoMap() {
825
- return W(this.getBep().deliverables);
808
+ return X(this.getBep().deliverables);
826
809
  }
827
810
  /**
828
811
  * Returns the nomenclature code for a single deliverable.
829
812
  * Returns null if the deliverable id is not found.
830
813
  */
831
814
  getCode(e) {
832
- const t = this.getBep(), s = t.deliverables.find((o) => o.id === e);
833
- if (!s) return null;
834
- const i = W(t.deliverables);
835
- return qe(s, t.project.code, i, t.lbs, t.deliverableNamingConvention);
815
+ const t = this.getBep(), n = t.deliverables.find((i) => i.id === e);
816
+ if (!n) return null;
817
+ const o = X(t.deliverables);
818
+ return Ke(n, t.project.code, o, t.lbs, t.deliverableNamingConvention);
836
819
  }
837
820
  /** Builds the complete map of deliverable.id → nomenclature code. */
838
821
  buildCodeMap() {
839
822
  const e = this.getBep();
840
- return We(e.deliverables, e.project.code, e.lbs, e.deliverableNamingConvention);
823
+ return qe(e.deliverables, e.project.code, e.lbs, e.deliverableNamingConvention);
841
824
  }
842
825
  }
843
- class Ut extends y {
844
- constructor(e, t, s, i, o) {
826
+ class Dt extends w {
827
+ constructor(e, t, n, o, i) {
845
828
  super(
846
829
  () => e().deliverables,
847
830
  e,
@@ -850,25 +833,25 @@ class Ut extends y {
850
833
  schema: De,
851
834
  autoId: !0
852
835
  }
853
- ), this.getTeams = t, this.getAssetTypes = s, this.getLBSNodes = i, this.getMilestones = o;
836
+ ), this.getTeams = t, this.getAssetTypes = n, this.getLBSNodes = o, this.getMilestones = i;
854
837
  }
855
838
  getTeams;
856
839
  getAssetTypes;
857
840
  getLBSNodes;
858
841
  getMilestones;
859
842
  listResolved() {
860
- const e = this.getBep(), t = We(e.deliverables, e.project.code, e.lbs), s = new Map(this.getTeams().listResolved().map((l) => [l.id, l])), 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();
861
844
  for (const l of e.deliverables) {
862
845
  const c = r.get(l.milestoneId) ?? null;
863
846
  d.set(l.id, {
864
847
  ...l,
865
848
  nomenclatureCode: t.get(l.id) ?? "",
866
849
  effectiveDate: l.dueDate ?? c?.date ?? "",
867
- lbsNode: l.lbsNodeId ? o.get(l.lbsNodeId) ?? null : null,
850
+ lbsNode: l.lbsNodeId ? i.get(l.lbsNodeId) ?? null : null,
868
851
  discipline: e.disciplines.find((u) => u.id === l.disciplineId) ?? null,
869
- assetType: i.get(l.assetTypeId) ?? null,
870
- extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((m) => m.id === u)).filter(Boolean),
871
- responsible: s.get(l.responsibleId) ?? null,
852
+ assetType: o.get(l.assetTypeId) ?? null,
853
+ extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((f) => f.id === u)).filter(Boolean),
854
+ responsible: n.get(l.responsibleId) ?? null,
872
855
  milestone: c,
873
856
  predecessor: null
874
857
  });
@@ -881,7 +864,7 @@ class Ut extends y {
881
864
  return [...d.values()];
882
865
  }
883
866
  }
884
- class zt extends y {
867
+ class Lt extends w {
885
868
  constructor(e) {
886
869
  super(
887
870
  () => e().flags,
@@ -894,7 +877,7 @@ class zt extends y {
894
877
  );
895
878
  }
896
879
  }
897
- class Zt extends y {
880
+ class Ut extends w {
898
881
  constructor(e, t) {
899
882
  super(
900
883
  () => e().notes,
@@ -915,7 +898,7 @@ class Zt extends y {
915
898
  }));
916
899
  }
917
900
  }
918
- class Jt extends y {
901
+ class zt extends w {
919
902
  constructor(e, t) {
920
903
  super(
921
904
  () => e().bimUses,
@@ -924,50 +907,50 @@ class Jt extends y {
924
907
  key: "bimUses",
925
908
  schema: Se,
926
909
  autoId: !0,
927
- validate: (s, i) => {
928
- const o = [];
929
- for (const r of s.objectiveIds ?? [])
930
- i.objectives.some((d) => d.id === r) || o.push(`objectives["${r}"] not found`);
931
- for (const r of s.milestoneIds ?? [])
932
- i.milestones.some((d) => d.id === r) || o.push(`milestones["${r}"] not found`);
933
- for (const r of s.workflowIds ?? [])
934
- i.workflows.some((d) => d.id === r) || o.push(`workflows["${r}"] not found`);
935
- return o;
910
+ validate: (n, o) => {
911
+ const i = [];
912
+ for (const r of n.objectiveIds ?? [])
913
+ o.objectives.some((d) => d.id === r) || i.push(`objectives["${r}"] not found`);
914
+ for (const r of n.milestoneIds ?? [])
915
+ o.milestones.some((d) => d.id === r) || i.push(`milestones["${r}"] not found`);
916
+ for (const r of n.workflowIds ?? [])
917
+ o.workflows.some((d) => d.id === r) || i.push(`workflows["${r}"] not found`);
918
+ return i;
936
919
  }
937
920
  }
938
921
  ), this.getWorkflows = t;
939
922
  }
940
923
  getWorkflows;
941
924
  listResolved() {
942
- const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((s) => [s.id, s]));
943
- return e.bimUses.map((s) => ({
944
- ...s,
945
- objectives: (s.objectiveIds ?? []).map((i) => e.objectives.find((o) => o.id === i)).filter(Boolean),
946
- milestones: (s.milestoneIds ?? []).map((i) => {
947
- const o = e.milestones.find((r) => r.id === i);
948
- return o ? { ...o, phase: e.phases.find((r) => r.id === o.phaseId) ?? null } : null;
925
+ const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((n) => [n.id, n]));
926
+ return e.bimUses.map((n) => ({
927
+ ...n,
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;
949
932
  }).filter(Boolean),
950
- workflows: (s.workflowIds ?? []).map((i) => t.get(i)).filter(Boolean)
933
+ workflows: (n.workflowIds ?? []).map((o) => t.get(o)).filter(Boolean)
951
934
  }));
952
935
  }
953
936
  }
954
- class Kt extends y {
937
+ class Zt extends w {
955
938
  constructor(e) {
956
939
  super(
957
940
  () => e().disciplines,
958
941
  e,
959
942
  {
960
943
  key: "disciplines",
961
- schema: we,
962
- validate: (t, s) => {
963
- const i = x("discipline", t.id, s.deliverableNamingConvention);
964
- return i ? [i] : [];
944
+ schema: be,
945
+ validate: (t, n) => {
946
+ const o = x("discipline", t.id, n.deliverableNamingConvention);
947
+ return o ? [o] : [];
965
948
  }
966
949
  }
967
950
  );
968
951
  }
969
952
  }
970
- class qt extends y {
953
+ class Jt extends w {
971
954
  constructor(e) {
972
955
  super(
973
956
  () => e().guides,
@@ -983,11 +966,11 @@ class qt extends y {
983
966
  const e = this.getBep();
984
967
  return e.guides.map((t) => ({
985
968
  ...t,
986
- annexes: (t.annexIds ?? []).map((s) => e.annexes.find((i) => i.id === s)).filter(Boolean)
969
+ annexes: (t.annexIds ?? []).map((n) => e.annexes.find((o) => o.id === n)).filter(Boolean)
987
970
  }));
988
971
  }
989
972
  }
990
- class Wt extends y {
973
+ class Kt extends w {
991
974
  constructor(e) {
992
975
  super(
993
976
  () => e().lods,
@@ -995,15 +978,15 @@ class Wt extends y {
995
978
  {
996
979
  key: "lods",
997
980
  schema: Me,
998
- beforeRemove: (t, s) => {
999
- for (const i of s.loin)
1000
- if (i.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${t}]`);
981
+ beforeRemove: (t, n) => {
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}]`);
1001
984
  }
1002
985
  }
1003
986
  );
1004
987
  }
1005
988
  }
1006
- class Gt extends y {
989
+ class qt extends w {
1007
990
  constructor(e) {
1008
991
  super(
1009
992
  () => e().lois,
@@ -1011,15 +994,15 @@ class Gt extends y {
1011
994
  {
1012
995
  key: "lois",
1013
996
  schema: xe,
1014
- beforeRemove: (t, s) => {
1015
- for (const i of s.loin)
1016
- if (i.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[loiId=${t}]`);
997
+ beforeRemove: (t, n) => {
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}]`);
1017
1000
  }
1018
1001
  }
1019
1002
  );
1020
1003
  }
1021
1004
  }
1022
- class Xt extends y {
1005
+ class Wt extends w {
1023
1006
  constructor(e) {
1024
1007
  super(
1025
1008
  () => e().loin,
@@ -1028,102 +1011,102 @@ class Xt extends y {
1028
1011
  key: "loin",
1029
1012
  schema: Pe,
1030
1013
  autoId: !0,
1031
- validate: (t, s) => {
1032
- const i = [];
1033
- for (const o of t.milestones ?? [])
1034
- s.milestones.some((r) => r.id === o.milestoneId) || i.push(`milestones["${o.milestoneId}"] not found`), s.lods.some((r) => r.id === o.lodId) || i.push(`lods[${o.lodId}] not found`), s.lois.some((r) => r.id === o.loiId) || i.push(`lois[${o.loiId}] not found`);
1035
- return i;
1014
+ validate: (t, n) => {
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;
1036
1019
  }
1037
1020
  }
1038
1021
  );
1039
1022
  }
1040
1023
  addMilestones(e) {
1041
- const t = [], s = [];
1042
- for (const i of e) {
1043
- const o = this.getBep().loin.find((c) => c.id === i.loinId);
1044
- if (!o) {
1045
- s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1024
+ const t = [], n = [];
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}` });
1046
1029
  continue;
1047
1030
  }
1048
- 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));
1049
1032
  if (r) {
1050
- s.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.` });
1051
1034
  continue;
1052
1035
  }
1053
- 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 }]);
1054
1037
  if (l.failed.length > 0) {
1055
- s.push({ loinId: i.loinId, error: l.failed[0].error });
1038
+ n.push({ loinId: o.loinId, error: l.failed[0].error });
1056
1039
  continue;
1057
1040
  }
1058
- 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) });
1059
1042
  }
1060
- return { succeeded: t, failed: s };
1043
+ return { succeeded: t, failed: n };
1061
1044
  }
1062
1045
  updateMilestones(e) {
1063
- const t = [], s = [];
1064
- for (const i of e) {
1065
- const o = this.getBep().loin.find((m) => m.id === i.loinId);
1066
- if (!o) {
1067
- s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1046
+ const t = [], n = [];
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}` });
1068
1051
  continue;
1069
1052
  }
1070
- const r = i.milestones.find((m) => !(o.milestones ?? []).some((f) => f.milestoneId === m.milestoneId));
1053
+ const r = o.milestones.find((f) => !(i.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
1071
1054
  if (r) {
1072
- s.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.` });
1073
1056
  continue;
1074
1057
  }
1075
- const d = new Map(o.milestones.map((m) => [m.milestoneId, { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath }])), l = (o.milestones ?? []).map((m) => {
1076
- const f = i.milestones.find((p) => p.milestoneId === m.milestoneId);
1077
- return f ? { ...m, ...f } : m;
1078
- }), c = this.update([{ id: i.loinId, milestones: l }]);
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
+ return m ? { ...f, ...m } : f;
1061
+ }), c = this.update([{ id: o.loinId, milestones: l }]);
1079
1062
  if (c.failed.length > 0) {
1080
- s.push({ loinId: i.loinId, error: c.failed[0].error });
1063
+ n.push({ loinId: o.loinId, error: c.failed[0].error });
1081
1064
  continue;
1082
1065
  }
1083
- const u = this.getBep().loin.find((m) => m.id === i.loinId);
1066
+ const u = this.getBep().loin.find((f) => f.id === o.loinId);
1084
1067
  t.push({
1085
- loinId: i.loinId,
1086
- element: o.element,
1087
- milestones: i.milestones.map((m) => {
1088
- const f = u.milestones.find((g) => g.milestoneId === m.milestoneId), p = d.get(m.milestoneId);
1089
- return { milestoneId: m.milestoneId, before: p, after: { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath } };
1068
+ loinId: o.loinId,
1069
+ element: i.element,
1070
+ milestones: o.milestones.map((f) => {
1071
+ const m = u.milestones.find((g) => g.milestoneId === f.milestoneId), p = d.get(f.milestoneId);
1072
+ return { milestoneId: f.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
1090
1073
  })
1091
1074
  });
1092
1075
  }
1093
- return { succeeded: t, failed: s };
1076
+ return { succeeded: t, failed: n };
1094
1077
  }
1095
1078
  removeMilestones(e) {
1096
- const t = [], s = [];
1097
- for (const i of e) {
1098
- const o = this.getBep().loin.find((d) => d.id === i.loinId);
1099
- if (!o) {
1100
- s.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1079
+ const t = [], n = [];
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}` });
1101
1084
  continue;
1102
1085
  }
1103
- 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));
1104
1087
  if (r.length > 0) {
1105
- s.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(", ")}` });
1106
1089
  continue;
1107
1090
  }
1108
- 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 });
1109
1092
  }
1110
- return { succeeded: t, failed: s };
1093
+ return { succeeded: t, failed: n };
1111
1094
  }
1112
1095
  listResolved() {
1113
1096
  const e = this.getBep();
1114
1097
  return e.loin.map((t) => ({
1115
1098
  ...t,
1116
- discipline: e.disciplines.find((s) => s.id === t.disciplineId) ?? null,
1117
- milestones: (t.milestones ?? []).map((s) => ({
1118
- ...s,
1119
- milestone: e.milestones.find((i) => i.id === s.milestoneId) ?? null,
1120
- lod: e.lods.find((i) => i.id === s.lodId) ?? null,
1121
- loi: e.lois.find((i) => i.id === s.loiId) ?? null
1099
+ discipline: e.disciplines.find((n) => n.id === t.disciplineId) ?? null,
1100
+ milestones: (t.milestones ?? []).map((n) => ({
1101
+ ...n,
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
1122
1105
  }))
1123
1106
  }));
1124
1107
  }
1125
1108
  }
1126
- class Vt extends y {
1109
+ class Xt extends w {
1127
1110
  constructor(e) {
1128
1111
  super(
1129
1112
  () => e().assetTypes,
@@ -1131,9 +1114,9 @@ class Vt extends y {
1131
1114
  {
1132
1115
  key: "assetTypes",
1133
1116
  schema: Ie,
1134
- validate: (t, s) => {
1135
- const i = x("assetType", t.id, s.deliverableNamingConvention);
1136
- return i ? [i] : [];
1117
+ validate: (t, n) => {
1118
+ const o = x("assetType", t.id, n.deliverableNamingConvention);
1119
+ return o ? [o] : [];
1137
1120
  }
1138
1121
  }
1139
1122
  );
@@ -1142,11 +1125,11 @@ class Vt extends y {
1142
1125
  const e = this.getBep();
1143
1126
  return e.assetTypes.map((t) => ({
1144
1127
  ...t,
1145
- extensions: (t.extensionIds ?? []).map((s) => e.extensions.find((i) => i.id === s)).filter(Boolean)
1128
+ extensions: (t.extensionIds ?? []).map((n) => e.extensions.find((o) => o.id === n)).filter(Boolean)
1146
1129
  }));
1147
1130
  }
1148
1131
  }
1149
- class Ht extends y {
1132
+ class Gt extends w {
1150
1133
  constructor(e) {
1151
1134
  super(
1152
1135
  () => e().extensions,
@@ -1158,7 +1141,7 @@ class Ht extends y {
1158
1141
  );
1159
1142
  }
1160
1143
  }
1161
- class Yt extends y {
1144
+ class Vt extends w {
1162
1145
  constructor(e) {
1163
1146
  super(
1164
1147
  () => e().roles,
@@ -1167,132 +1150,132 @@ class Yt extends y {
1167
1150
  key: "roles",
1168
1151
  schema: ue,
1169
1152
  autoId: !0,
1170
- beforeRemove: (t, s) => {
1171
- const i = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
1172
- for (const o of s.workflows)
1173
- for (const [r, d] of Object.entries(o.diagram.nodes))
1153
+ beforeRemove: (t, n) => {
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))
1174
1157
  if (d.type === "process") {
1175
- for (const l of i)
1158
+ for (const l of o)
1176
1159
  if (d[l]?.includes(t))
1177
- 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}`);
1178
1161
  }
1179
1162
  }
1180
1163
  }
1181
1164
  );
1182
1165
  }
1183
1166
  }
1184
- class Qt extends y {
1167
+ class Ht extends w {
1185
1168
  constructor(e) {
1186
1169
  super(
1187
1170
  () => e().lbs,
1188
1171
  e,
1189
1172
  {
1190
1173
  key: "lbs",
1191
- schema: be,
1192
- validate: (t, s) => {
1193
- const i = [], o = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(o, t.id, s.deliverableNamingConvention);
1194
- if (r && i.push(r), t.type === "location" && t.lbsNodeIds?.length) {
1195
- const d = new Map(s.lbs.map((l) => [l.id, l]));
1174
+ schema: we,
1175
+ validate: (t, n) => {
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
+ const d = new Map(n.lbs.map((l) => [l.id, l]));
1196
1179
  for (const l of t.lbsNodeIds ?? [])
1197
- 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}").`);
1198
1181
  }
1199
- return i;
1182
+ return o;
1200
1183
  }
1201
1184
  }
1202
1185
  );
1203
1186
  }
1204
1187
  listResolved() {
1205
- const e = this.getBep(), t = C(e.lbs), s = te(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1206
- return e.lbs.map((o) => {
1207
- const r = t.get(o.id), d = r ? i.get(r) : void 0;
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;
1208
1191
  return {
1209
- ...o,
1210
- isRoot: s.has(o.id),
1192
+ ...i,
1193
+ isRoot: n.has(i.id),
1211
1194
  parent: d ? { id: d.id, name: d.name, type: d.type } : null,
1212
- children: (o.lbsNodeIds ?? []).map((l) => i.get(l)).filter(Boolean)
1195
+ children: (i.lbsNodeIds ?? []).map((l) => o.get(l)).filter(Boolean)
1213
1196
  };
1214
1197
  });
1215
1198
  }
1216
1199
  addNodes(e) {
1217
- const t = this.getBep(), s = [], i = [];
1218
- for (const o of e) {
1219
- if (!o.parentId && o.type !== "zone") {
1220
- i.push({ input: o, error: 'Root nodes (no parentId) must be type "zone".' });
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".' });
1221
1204
  continue;
1222
1205
  }
1223
- if (o.parentId && !t.lbs.find((m) => m.id === o.parentId)) {
1224
- i.push({ input: o, error: `No LBS node found with ID "${o.parentId}".` });
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}".` });
1225
1208
  continue;
1226
1209
  }
1227
- const { parentId: r, ...d } = o, l = this.add([d]);
1210
+ const { parentId: r, ...d } = i, l = this.add([d]);
1228
1211
  if (l.failed.length > 0) {
1229
- i.push({ input: o, error: l.failed[0].error });
1212
+ o.push({ input: i, error: l.failed[0].error });
1230
1213
  continue;
1231
1214
  }
1232
1215
  let c;
1233
- r && (c = t.lbs.find((m) => m.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)));
1234
1217
  const u = this.validateTree();
1235
1218
  if (u.length > 0) {
1236
- t.lbs.splice(t.lbs.findIndex((m) => m.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((m) => m !== o.id)), i.push({ input: o, error: u.join("; ") });
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("; ") });
1237
1220
  continue;
1238
1221
  }
1239
- s.push({ ...t.lbs.find((m) => m.id === o.id), parentId: r ?? null });
1222
+ n.push({ ...t.lbs.find((f) => f.id === i.id), parentId: r ?? null });
1240
1223
  }
1241
- return { succeeded: s, failed: i };
1224
+ return { succeeded: n, failed: o };
1242
1225
  }
1243
1226
  updateNodes(e) {
1244
- const t = this.getBep(), s = [], i = [];
1245
- for (const o of e) {
1246
- if (o.parentId && !t.lbs.find((h) => h.id === o.parentId)) {
1247
- i.push({ id: o.id, error: `No LBS node found with ID "${o.parentId}".` });
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}".` });
1248
1231
  continue;
1249
1232
  }
1250
- if (o.parentId === o.id) {
1251
- 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." });
1252
1235
  continue;
1253
1236
  }
1254
- const r = t.lbs.find((h) => h.id === o.id), d = C(t.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, u = this.update([c]);
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]);
1255
1238
  if (u.failed.length > 0) {
1256
- i.push({ id: o.id, error: u.failed[0].error });
1239
+ o.push({ id: i.id, error: u.failed[0].error });
1257
1240
  continue;
1258
1241
  }
1259
- const m = { name: r.name, type: r.type, description: r.description, parentId: d }, f = 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);
1260
1243
  if (l !== void 0) {
1261
1244
  for (const h of t.lbs)
1262
- 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));
1263
1246
  if (l) {
1264
- const h = t.lbs.find((b) => b.id === l);
1265
- 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);
1266
1249
  }
1267
1250
  }
1268
1251
  const p = this.validateTree();
1269
1252
  if (p.length > 0) {
1270
- if (f.name = m.name, f.type = m.type, m.description !== void 0 ? f.description = m.description : delete f.description, l !== void 0) {
1253
+ if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
1271
1254
  for (const h of t.lbs)
1272
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
1273
- if (m.parentId) {
1274
- const h = t.lbs.find((b) => b.id === m.parentId);
1275
- h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
1255
+ h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== i.id));
1256
+ if (f.parentId) {
1257
+ const h = t.lbs.find((y) => y.id === f.parentId);
1258
+ h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id));
1276
1259
  }
1277
1260
  }
1278
- i.push({ id: o.id, error: p.join("; ") });
1261
+ o.push({ id: i.id, error: p.join("; ") });
1279
1262
  continue;
1280
1263
  }
1281
- const g = C(t.lbs).get(f.id) ?? null;
1282
- s.push({ id: o.id, before: m, after: { name: f.name, type: f.type, description: f.description, parentId: g } });
1264
+ const g = C(t.lbs).get(m.id) ?? null;
1265
+ n.push({ id: i.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1283
1266
  }
1284
- return { succeeded: s, failed: i };
1267
+ return { succeeded: n, failed: o };
1285
1268
  }
1286
1269
  /** Resolves zone and location codes for nomenclature given a node id. */
1287
1270
  resolveCodes(e) {
1288
- return Ke(e, this.list());
1271
+ return Je(e, this.list());
1289
1272
  }
1290
1273
  /** Validates the full LBS tree and returns a list of structural errors. */
1291
1274
  validateTree() {
1292
- return Dt(this.list());
1275
+ return Ft(this.list());
1293
1276
  }
1294
1277
  }
1295
- class es extends y {
1278
+ class Yt extends w {
1296
1279
  constructor(e) {
1297
1280
  super(
1298
1281
  () => e().members,
@@ -1307,85 +1290,85 @@ class es extends y {
1307
1290
  listResolved() {
1308
1291
  const e = this.getBep();
1309
1292
  return e.members.map((t) => {
1310
- const s = e.teams.find((i) => (i.memberEmails ?? []).includes(t.email));
1293
+ const n = e.teams.find((o) => (o.memberEmails ?? []).includes(t.email));
1311
1294
  return {
1312
1295
  ...t,
1313
- role: e.roles.find((i) => i.id === t.roleId) ?? null,
1314
- team: s ? { id: s.id, name: s.name } : null,
1315
- isRepresentative: s?.representativeEmail === t.email
1296
+ role: e.roles.find((o) => o.id === t.roleId) ?? null,
1297
+ team: n ? { id: n.id, name: n.name } : null,
1298
+ isRepresentative: n?.representativeEmail === t.email
1316
1299
  };
1317
1300
  });
1318
1301
  }
1319
1302
  addToTeam(e) {
1320
- const t = [], s = [];
1321
- for (const i of e) {
1322
- const r = this.getBep().teams.find((f) => f.id === i.teamId);
1303
+ const t = [], n = [];
1304
+ for (const o of e) {
1305
+ const r = this.getBep().teams.find((m) => m.id === o.teamId);
1323
1306
  if (!r) {
1324
- s.push({ input: i, error: `Team not found: ${i.teamId}` });
1307
+ n.push({ input: o, error: `Team not found: ${o.teamId}` });
1325
1308
  continue;
1326
1309
  }
1327
- const { teamId: d, isRepresentative: l, ...c } = i, u = this.add([c]);
1310
+ const { teamId: d, isRepresentative: l, ...c } = o, u = this.add([c]);
1328
1311
  if (u.failed.length > 0) {
1329
- s.push({ input: i, error: u.failed[0].error });
1312
+ n.push({ input: o, error: u.failed[0].error });
1330
1313
  continue;
1331
1314
  }
1332
- r.memberEmails ??= [], r.memberEmails.includes(i.email) || r.memberEmails.push(i.email), l && (r.representativeEmail = i.email);
1333
- const m = this.listResolved().find((f) => f.email === i.email);
1334
- t.push(m);
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
+ t.push(f);
1335
1318
  }
1336
- return { succeeded: t, failed: s };
1319
+ return { succeeded: t, failed: n };
1337
1320
  }
1338
1321
  updateInTeam(e) {
1339
- const t = [], s = [];
1340
- for (const i of e) {
1341
- const o = this.getBep(), { teamId: r, isRepresentative: d, ...l } = i;
1342
- if (r !== void 0 && !o.teams.find((m) => m.id === r)) {
1343
- s.push({ email: i.email, error: `Team not found: ${r}` });
1322
+ const t = [], n = [];
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}` });
1344
1327
  continue;
1345
1328
  }
1346
1329
  const c = this.update([l]);
1347
1330
  if (c.failed.length > 0) {
1348
- s.push({ email: i.email, error: c.failed[0].error });
1331
+ n.push({ email: o.email, error: c.failed[0].error });
1349
1332
  continue;
1350
1333
  }
1351
1334
  if (r !== void 0) {
1352
- const m = o.teams.find((p) => p.id === r), f = o.teams.find((p) => (p.memberEmails ?? []).includes(i.email));
1353
- f && f.id !== r && (f.memberEmails = (f.memberEmails ?? []).filter((p) => p !== i.email), f.representativeEmail === i.email && (f.representativeEmail = void 0)), m.memberEmails ??= [], m.memberEmails.includes(i.email) || m.memberEmails.push(i.email);
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);
1354
1337
  }
1355
1338
  if (d !== void 0) {
1356
- const m = o.teams.find((f) => (f.memberEmails ?? []).includes(i.email));
1357
- m && (m.representativeEmail = d ? i.email : m.representativeEmail === i.email ? void 0 : m.representativeEmail);
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);
1358
1341
  }
1359
- const u = this.listResolved().find((m) => m.email === i.email);
1360
- 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 });
1361
1344
  }
1362
- return { succeeded: t, failed: s };
1345
+ return { succeeded: t, failed: n };
1363
1346
  }
1364
1347
  removeFromBep(e) {
1365
- const t = [], s = [];
1366
- for (const i of e) {
1367
- const o = this.getBep(), r = this.listResolved().find((l) => l.email === i);
1348
+ const t = [], n = [];
1349
+ for (const o of e) {
1350
+ const i = this.getBep(), r = this.listResolved().find((l) => l.email === o);
1368
1351
  if (!r) {
1369
- s.push({ email: i, error: `Not found: ${i}` });
1352
+ n.push({ email: o, error: `Not found: ${o}` });
1370
1353
  continue;
1371
1354
  }
1372
- for (const l of o.teams)
1373
- l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== i)), l.representativeEmail === i && (l.representativeEmail = void 0);
1374
- const d = this.remove([i]);
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]);
1375
1358
  if (d.failed.length > 0) {
1376
1359
  if (r.team) {
1377
- const l = o.teams.find((c) => c.id === r.team.id);
1378
- l && (l.memberEmails ??= [], l.memberEmails.includes(i) || l.memberEmails.push(i), r.isRepresentative && (l.representativeEmail = i));
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));
1379
1362
  }
1380
- s.push({ email: i, error: d.failed[0].error });
1363
+ n.push({ email: o, error: d.failed[0].error });
1381
1364
  continue;
1382
1365
  }
1383
1366
  t.push(r);
1384
1367
  }
1385
- return { succeeded: t, failed: s };
1368
+ return { succeeded: t, failed: n };
1386
1369
  }
1387
1370
  }
1388
- class ts extends y {
1371
+ class Qt extends w {
1389
1372
  constructor(e) {
1390
1373
  super(
1391
1374
  () => e().milestones,
@@ -1394,9 +1377,9 @@ class ts extends y {
1394
1377
  key: "milestones",
1395
1378
  schema: ye,
1396
1379
  autoId: !0,
1397
- beforeRemove: (t, s) => {
1398
- for (const i of s.loin)
1399
- if (i.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[milestoneId="${t}"]`);
1380
+ beforeRemove: (t, n) => {
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}"]`);
1400
1383
  }
1401
1384
  }
1402
1385
  );
@@ -1405,11 +1388,11 @@ class ts extends y {
1405
1388
  const e = this.getBep();
1406
1389
  return e.milestones.map((t) => ({
1407
1390
  ...t,
1408
- phase: e.phases.find((s) => s.id === t.phaseId) ?? null
1391
+ phase: e.phases.find((n) => n.id === t.phaseId) ?? null
1409
1392
  }));
1410
1393
  }
1411
1394
  }
1412
- class ss extends y {
1395
+ class es extends w {
1413
1396
  constructor(e) {
1414
1397
  super(
1415
1398
  () => e().objectives,
@@ -1422,7 +1405,7 @@ class ss extends y {
1422
1405
  );
1423
1406
  }
1424
1407
  }
1425
- class ns extends y {
1408
+ class ts extends w {
1426
1409
  constructor(e) {
1427
1410
  super(
1428
1411
  () => e().phases,
@@ -1435,20 +1418,20 @@ class ns extends y {
1435
1418
  );
1436
1419
  }
1437
1420
  }
1438
- class is extends y {
1421
+ class ss extends w {
1439
1422
  constructor(e) {
1440
1423
  super(
1441
1424
  () => e().remoteData,
1442
1425
  e,
1443
1426
  {
1444
1427
  key: "remoteData",
1445
- schema: Ze,
1428
+ schema: ze,
1446
1429
  autoId: !0
1447
1430
  }
1448
1431
  );
1449
1432
  }
1450
1433
  }
1451
- class os extends y {
1434
+ class ns extends w {
1452
1435
  constructor(e) {
1453
1436
  super(
1454
1437
  () => e().resolvers,
@@ -1456,15 +1439,15 @@ class os extends y {
1456
1439
  {
1457
1440
  key: "resolvers",
1458
1441
  schema: Ue,
1459
- beforeRemove: (t, s) => {
1460
- const i = s.remoteData.find((o) => o.resolverId === t);
1461
- if (i) throw new Error(`Referenced by: remoteData["${i.id}"].resolverId`);
1442
+ beforeRemove: (t, n) => {
1443
+ const o = n.remoteData.find((i) => i.resolverId === t);
1444
+ if (o) throw new Error(`Referenced by: remoteData["${o.id}"].resolverId`);
1462
1445
  }
1463
1446
  }
1464
1447
  );
1465
1448
  }
1466
1449
  }
1467
- class rs extends y {
1450
+ class os extends w {
1468
1451
  constructor(e, t) {
1469
1452
  super(
1470
1453
  () => e().softwares,
@@ -1480,11 +1463,11 @@ class rs extends y {
1480
1463
  const e = new Map(this.getAssetTypes().listResolved().map((t) => [t.id, t]));
1481
1464
  return this.getBep().softwares.map((t) => ({
1482
1465
  ...t,
1483
- assetTypes: (t.assetTypeIds ?? []).map((s) => e.get(s)).filter(Boolean)
1466
+ assetTypes: (t.assetTypeIds ?? []).map((n) => e.get(n)).filter(Boolean)
1484
1467
  }));
1485
1468
  }
1486
1469
  }
1487
- class as extends y {
1470
+ class is extends w {
1488
1471
  constructor(e, t) {
1489
1472
  super(
1490
1473
  () => e().standards,
@@ -1500,43 +1483,43 @@ class as extends y {
1500
1483
  * Union with AddInput<Standard> satisfies the base class contract.
1501
1484
  */
1502
1485
  add(e) {
1503
- const t = e.map((s) => {
1504
- const i = `standards/${globalThis.crypto.randomUUID()}.md`;
1505
- if ("content" in s) {
1506
- const { content: o, ...r } = s;
1507
- return this.getZip().file(i, o), { ...r, contentPath: i };
1486
+ const t = e.map((n) => {
1487
+ const o = `standards/${globalThis.crypto.randomUUID()}.md`;
1488
+ if ("content" in n) {
1489
+ const { content: i, ...r } = n;
1490
+ return this.getZip().file(o, i), { ...r, contentPath: o };
1508
1491
  }
1509
- return this.getZip().file(i, ""), { ...s, contentPath: i };
1492
+ return this.getZip().file(o, ""), { ...n, contentPath: o };
1510
1493
  });
1511
1494
  return super.add(t);
1512
1495
  }
1513
1496
  /** Removes standards and deletes their .md files from the zip. */
1514
1497
  remove(e) {
1515
1498
  const t = new Map(
1516
- e.map((i) => [i, this.list().find((o) => o.id === i)?.contentPath]).filter((i) => i[1] !== void 0)
1517
- ), s = super.remove(e);
1518
- for (const i of s.succeeded) {
1519
- const o = t.get(i);
1520
- o && this.getZip().remove(o);
1499
+ e.map((o) => [o, this.list().find((i) => i.id === o)?.contentPath]).filter((o) => o[1] !== void 0)
1500
+ ), n = super.remove(e);
1501
+ for (const o of n.succeeded) {
1502
+ const i = t.get(o);
1503
+ i && this.getZip().remove(i);
1521
1504
  }
1522
- return s;
1505
+ return n;
1523
1506
  }
1524
1507
  /** Returns the markdown text content of the given standard. */
1525
1508
  async getContent(e) {
1526
- const t = this.list().find((i) => i.id === e);
1509
+ const t = this.list().find((o) => o.id === e);
1527
1510
  if (!t) throw new Error(`Standard not found: ${e}`);
1528
- const s = this.getZip().file(t.contentPath);
1529
- if (!s) throw new Error(`Content file not found: ${t.contentPath}`);
1530
- return s.async("string");
1511
+ const n = this.getZip().file(t.contentPath);
1512
+ if (!n) throw new Error(`Content file not found: ${t.contentPath}`);
1513
+ return n.async("string");
1531
1514
  }
1532
1515
  /** Writes new markdown text content for the given standard. */
1533
1516
  setContent(e, t) {
1534
- const s = this.list().find((i) => i.id === e);
1535
- if (!s) throw new Error(`Standard not found: ${e}`);
1536
- this.getZip().file(s.contentPath, t);
1517
+ const n = this.list().find((o) => o.id === e);
1518
+ if (!n) throw new Error(`Standard not found: ${e}`);
1519
+ this.getZip().file(n.contentPath, t);
1537
1520
  }
1538
1521
  }
1539
- class ds extends y {
1522
+ class rs extends w {
1540
1523
  constructor(e, t) {
1541
1524
  super(
1542
1525
  () => e().teams,
@@ -1544,12 +1527,12 @@ class ds extends y {
1544
1527
  {
1545
1528
  key: "teams",
1546
1529
  schema: pe,
1547
- validate: (s, i) => {
1548
- const o = [], r = x("team", s.id, i.deliverableNamingConvention);
1549
- return r && o.push(r), s.representativeEmail && !(s.memberEmails ?? []).includes(s.representativeEmail) && o.push(`representativeEmail "${s.representativeEmail}" is not a member of this team`), o;
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;
1550
1533
  },
1551
- beforeRemove: (s, i) => {
1552
- if (i.project.clientId === s)
1534
+ beforeRemove: (n, o) => {
1535
+ if (o.project.clientId === n)
1553
1536
  throw new Error("Referenced by: project.clientId");
1554
1537
  }
1555
1538
  }
@@ -1557,97 +1540,97 @@ class ds extends y {
1557
1540
  }
1558
1541
  getMembers;
1559
1542
  listResolved() {
1560
- const e = this.getBep(), t = new Map(this.getMembers().listResolved().map((s) => [s.email, s]));
1561
- return e.teams.map((s) => ({
1562
- ...s,
1563
- representative: t.get(s.representativeEmail ?? "") ?? null,
1564
- members: (s.memberEmails ?? []).map((i) => t.get(i)).filter(Boolean),
1565
- disciplines: (s.disciplineIds ?? []).map((i) => e.disciplines.find((o) => o.id === i)).filter(Boolean)
1543
+ const e = this.getBep(), t = new Map(this.getMembers().listResolved().map((n) => [n.email, n]));
1544
+ return e.teams.map((n) => ({
1545
+ ...n,
1546
+ representative: t.get(n.representativeEmail ?? "") ?? null,
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)
1566
1549
  }));
1567
1550
  }
1568
1551
  }
1569
- function ls(n, e, t) {
1570
- const s = [];
1571
- for (const [l, c] of Object.entries(n.nodes))
1552
+ function as(s, e, t) {
1553
+ const n = [];
1554
+ for (const [l, c] of Object.entries(s.nodes))
1572
1555
  if (c.type === "process") {
1573
- c.actionId && !e.actions.some((u) => u.id === c.actionId) && s.push(`actions["${c.actionId}"] not found (node: ${l})`);
1556
+ c.actionId && !e.actions.some((u) => u.id === c.actionId) && n.push(`actions["${c.actionId}"] not found (node: ${l})`);
1574
1557
  for (const u of ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"])
1575
- for (const m of c[u] ?? [])
1576
- e.roles.some((f) => f.id === m) || s.push(`roles["${m}"] not found (node: ${l}.${u})`);
1558
+ for (const f of c[u] ?? [])
1559
+ e.roles.some((m) => m.id === f) || n.push(`roles["${f}"] not found (node: ${l}.${u})`);
1577
1560
  }
1578
- for (const [l, c] of Object.entries(n.edges)) {
1579
- n.nodes[c.from] || s.push(`edge "${l}": from node "${c.from}" not found`), n.nodes[c.to] || s.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((u) => u.id === c.triggerEventId) && s.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1561
+ for (const [l, c] of Object.entries(s.edges)) {
1562
+ s.nodes[c.from] || n.push(`edge "${l}": from node "${c.from}" not found`), s.nodes[c.to] || n.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((u) => u.id === c.triggerEventId) && n.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1580
1563
  for (const u of c.effectIds ?? [])
1581
- e.effects.some((m) => m.id === u) || s.push(`effects["${u}"] not found (edge: ${l})`);
1564
+ e.effects.some((f) => f.id === u) || n.push(`effects["${u}"] not found (edge: ${l})`);
1582
1565
  }
1583
- for (const [l, c] of Object.entries(n.nodes))
1584
- if (c.type === "automation" && !e.automations.some((u) => u.id === c.automationId) && s.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === t ? s.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((u) => u.id === c.workflowId) || s.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1566
+ for (const [l, c] of Object.entries(s.nodes))
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)
1585
1568
  for (const u of c.timeouts)
1586
- e.effects.some((m) => m.id === u.effectId) || s.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
1587
- const i = Object.keys(n.nodes), o = new Set(Object.values(n.edges).map((l) => l.to)), r = new Set(Object.values(n.edges).map((l) => l.from));
1588
- for (const l of i)
1589
- n.nodes[l].type !== "start" && (o.has(l) || s.push(`node "${l}" is unreachable — no edges point to it`));
1590
- for (const l of i)
1591
- n.nodes[l].type !== "end" && (r.has(l) || s.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
1569
+ e.effects.some((f) => f.id === u.effectId) || n.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
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
+ s.nodes[l].type !== "end" && (r.has(l) || n.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
1592
1575
  const d = {};
1593
- for (const l of Object.keys(n.edges)) {
1594
- const c = n.edges[l];
1576
+ for (const l of Object.keys(s.edges)) {
1577
+ const c = s.edges[l];
1595
1578
  d[c.to] ??= [], d[c.to].push(l);
1596
1579
  }
1597
- for (const [l, c] of Object.entries(n.nodes)) {
1580
+ for (const [l, c] of Object.entries(s.nodes)) {
1598
1581
  if (c.type !== "decision") continue;
1599
1582
  const u = /* @__PURE__ */ new Set();
1600
- for (const m of d[l] ?? []) {
1601
- const f = n.edges[m], p = n.nodes[f.from];
1583
+ for (const f of d[l] ?? []) {
1584
+ const m = s.edges[f], p = s.nodes[m.from];
1602
1585
  if (p) {
1603
1586
  if (p.type === "automation") {
1604
1587
  const g = e.automations.find((h) => h.id === p.automationId);
1605
1588
  for (const h of g?.output ?? []) u.add(h.key);
1606
1589
  }
1607
- if (p.type === "process" && "triggerEventId" in f) {
1608
- const g = e.events.find((h) => h.id === f.triggerEventId);
1590
+ if (p.type === "process" && "triggerEventId" in m) {
1591
+ const g = e.events.find((h) => h.id === m.triggerEventId);
1609
1592
  for (const h of g?.payload ?? []) u.add(h.key);
1610
1593
  }
1611
1594
  }
1612
1595
  }
1613
1596
  if (u.size !== 0)
1614
- for (const [m, f] of Object.entries(n.edges))
1615
- f.from === l && "guard" in f && (u.has(f.guard.field) || s.push(`guard field "${f.guard.field}" on edge "${m}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1597
+ for (const [f, m] of Object.entries(s.edges))
1598
+ m.from === l && "guard" in m && (u.has(m.guard.field) || n.push(`guard field "${m.guard.field}" on edge "${f}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1616
1599
  }
1617
- return s;
1600
+ return n;
1618
1601
  }
1619
- class cs extends y {
1620
- constructor(e, t, s) {
1602
+ class ds extends w {
1603
+ constructor(e, t, n) {
1621
1604
  super(
1622
1605
  () => e().workflows,
1623
1606
  e,
1624
1607
  {
1625
1608
  key: "workflows",
1626
- schema: je,
1609
+ schema: Ae,
1627
1610
  autoId: !0,
1628
- validate: (i, o) => ls(i.diagram, o, i.id)
1611
+ validate: (o, i) => as(o.diagram, i, o.id)
1629
1612
  }
1630
- ), this.getMembers = t, this.getTeams = s;
1613
+ ), this.getMembers = t, this.getTeams = n;
1631
1614
  }
1632
1615
  getMembers;
1633
1616
  getTeams;
1634
1617
  getRaciMatrix() {
1635
- const e = this.getBep(), t = [], s = /* @__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) => {
1636
1619
  const u = e.roles.find((p) => p.id === c);
1637
1620
  if (!u) return [];
1638
- s.add(c);
1639
- const m = i.filter((p) => p.role?.id === c), f = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1640
- return [{ role: u, members: m, team: f }];
1621
+ n.add(c);
1622
+ const f = o.filter((p) => p.role?.id === c), m = i.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1623
+ return [{ role: u, members: f, team: m }];
1641
1624
  });
1642
1625
  for (const l of e.workflows)
1643
1626
  for (const [c, u] of Object.entries(l.diagram.nodes)) {
1644
1627
  if (u.type !== "process") continue;
1645
- const m = u.actionId ? e.actions.find((f) => f.id === u.actionId) : void 0;
1628
+ const f = u.actionId ? e.actions.find((m) => m.id === u.actionId) : void 0;
1646
1629
  t.push({
1647
1630
  workflow: { id: l.id, name: l.name },
1648
1631
  nodeId: c,
1649
- label: m?.name ?? c,
1650
- ...m?.description ? { description: m.description } : {},
1632
+ label: f?.name ?? c,
1633
+ ...f?.description ? { description: f.description } : {},
1651
1634
  ...u.actionId ? { actionId: u.actionId } : {},
1652
1635
  responsible: r(u.responsibleRoleIds),
1653
1636
  accountable: r(u.accountableRoleIds),
@@ -1655,23 +1638,23 @@ class cs extends y {
1655
1638
  informed: r(u.informedRoleIds)
1656
1639
  });
1657
1640
  }
1658
- return { roles: [...s].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
1641
+ return { roles: [...n].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
1659
1642
  }
1660
1643
  getRaciMatrixForWorkflow(e) {
1661
- const t = this.getRaciMatrix(), s = t.rows.filter((o) => o.workflow.id === e), i = new Set(
1662
- s.flatMap((o) => [...o.responsible, ...o.accountable, ...o.consulted, ...o.informed].map((r) => r.role.id))
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))
1663
1646
  );
1664
- return { roles: t.roles.filter((o) => i.has(o.id)), rows: s };
1647
+ return { roles: t.roles.filter((i) => o.has(i.id)), rows: n };
1665
1648
  }
1666
1649
  getConsolidatedRaciMatrix() {
1667
- const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), s = (r, d) => {
1650
+ const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), n = (r, d) => {
1668
1651
  const l = new Map(r.map((c) => [c.role.id, { ...c, members: [...c.members] }]));
1669
1652
  for (const c of d)
1670
1653
  if (!l.has(c.role.id))
1671
1654
  l.set(c.role.id, { ...c, members: [...c.members] });
1672
1655
  else {
1673
- const u = l.get(c.role.id), m = new Set(u.members.map((f) => f.email));
1674
- for (const f of c.members) m.has(f.email) || u.members.push(f);
1656
+ const u = l.get(c.role.id), f = new Set(u.members.map((m) => m.email));
1657
+ for (const m of c.members) f.has(m.email) || u.members.push(m);
1675
1658
  }
1676
1659
  return [...l.values()];
1677
1660
  };
@@ -1681,92 +1664,92 @@ class cs extends y {
1681
1664
  t.set(d, { ...r, workflow: { id: "", name: "" } });
1682
1665
  else {
1683
1666
  const l = t.get(d);
1684
- l.responsible = s(l.responsible, r.responsible), l.accountable = s(l.accountable, r.accountable), l.consulted = s(l.consulted, r.consulted), l.informed = s(l.informed, r.informed);
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);
1685
1668
  }
1686
1669
  }
1687
- const i = [...t.values()], o = new Set(
1688
- i.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
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))
1689
1672
  );
1690
- 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 };
1691
1674
  }
1692
1675
  listResolved() {
1693
1676
  const e = this.getBep();
1694
1677
  return e.workflows.map((t) => {
1695
- const s = {};
1696
- for (const [i, o] of Object.entries(t.diagram.nodes)) {
1678
+ const n = {};
1679
+ for (const [o, i] of Object.entries(t.diagram.nodes)) {
1697
1680
  const r = (d) => ({
1698
1681
  roles: (d ?? []).map((l) => e.roles.find((c) => c.id === l)).filter(Boolean),
1699
1682
  teams: [],
1700
1683
  members: []
1701
1684
  });
1702
- s[i] = {
1703
- type: o.type,
1704
- label: o.type === "decision" ? o.label : void 0,
1705
- timeouts: o.type === "process" || o.type === "automation" ? o.timeouts : void 0,
1706
- workflowId: o.type === "process" ? o.workflowId : void 0,
1707
- blocking: o.type === "process" ? o.blocking : void 0,
1708
- action: o.type === "process" && o.actionId ? e.actions.find((d) => d.id === o.actionId) ?? null : null,
1709
- automation: o.type === "automation" ? e.automations.find((d) => d.id === o.automationId) ?? null : null,
1710
- responsible: r(o.type === "process" ? o.responsibleRoleIds : void 0),
1711
- accountable: r(o.type === "process" ? o.accountableRoleIds : void 0),
1712
- consulted: r(o.type === "process" ? o.consultedRoleIds : void 0),
1713
- informed: r(o.type === "process" ? o.informedRoleIds : void 0)
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)
1714
1697
  };
1715
1698
  }
1716
1699
  return {
1717
1700
  ...t,
1718
- diagram: { ...t.diagram, nodes: s }
1701
+ diagram: { ...t.diagram, nodes: n }
1719
1702
  };
1720
1703
  });
1721
1704
  }
1722
1705
  }
1723
- var fs = /* @__PURE__ */ (function() {
1724
- var n = function(e, t) {
1725
- return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(s, i) {
1726
- s.__proto__ = i;
1727
- } || function(s, i) {
1728
- for (var o in i) i.hasOwnProperty(o) && (s[o] = i[o]);
1729
- }, n(e, t);
1706
+ var ls = /* @__PURE__ */ (function() {
1707
+ var s = function(e, t) {
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
+ }, s(e, t);
1730
1713
  };
1731
1714
  return function(e, t) {
1732
- n(e, t);
1733
- function s() {
1715
+ s(e, t);
1716
+ function n() {
1734
1717
  this.constructor = e;
1735
1718
  }
1736
- e.prototype = t === null ? Object.create(t) : (s.prototype = t.prototype, new s());
1719
+ e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
1737
1720
  };
1738
- })(), us = Object.prototype.hasOwnProperty;
1739
- function G(n, e) {
1740
- return us.call(n, e);
1721
+ })(), cs = Object.prototype.hasOwnProperty;
1722
+ function G(s, e) {
1723
+ return cs.call(s, e);
1741
1724
  }
1742
- function X(n) {
1743
- if (Array.isArray(n)) {
1744
- for (var e = new Array(n.length), t = 0; t < e.length; t++)
1725
+ function V(s) {
1726
+ if (Array.isArray(s)) {
1727
+ for (var e = new Array(s.length), t = 0; t < e.length; t++)
1745
1728
  e[t] = "" + t;
1746
1729
  return e;
1747
1730
  }
1748
1731
  if (Object.keys)
1749
- return Object.keys(n);
1750
- var s = [];
1751
- for (var i in n)
1752
- G(n, i) && s.push(i);
1753
- return s;
1754
- }
1755
- function R(n) {
1756
- switch (typeof n) {
1732
+ return Object.keys(s);
1733
+ var n = [];
1734
+ for (var o in s)
1735
+ G(s, o) && n.push(o);
1736
+ return n;
1737
+ }
1738
+ function T(s) {
1739
+ switch (typeof s) {
1757
1740
  case "object":
1758
- return JSON.parse(JSON.stringify(n));
1741
+ return JSON.parse(JSON.stringify(s));
1759
1742
  //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
1760
1743
  case "undefined":
1761
1744
  return null;
1762
1745
  //this is how JSON.stringify behaves for array items
1763
1746
  default:
1764
- return n;
1747
+ return s;
1765
1748
  }
1766
1749
  }
1767
- function V(n) {
1768
- for (var e = 0, t = n.length, s; e < t; ) {
1769
- if (s = n.charCodeAt(e), s >= 48 && s <= 57) {
1750
+ function H(s) {
1751
+ for (var e = 0, t = s.length, n; e < t; ) {
1752
+ if (n = s.charCodeAt(e), n >= 48 && n <= 57) {
1770
1753
  e++;
1771
1754
  continue;
1772
1755
  }
@@ -1774,423 +1757,423 @@ function V(n) {
1774
1757
  }
1775
1758
  return !0;
1776
1759
  }
1777
- function j(n) {
1778
- return n.indexOf("/") === -1 && n.indexOf("~") === -1 ? n : n.replace(/~/g, "~0").replace(/\//g, "~1");
1760
+ function A(s) {
1761
+ return s.indexOf("/") === -1 && s.indexOf("~") === -1 ? s : s.replace(/~/g, "~0").replace(/\//g, "~1");
1779
1762
  }
1780
- function Ge(n) {
1781
- return n.replace(/~1/g, "/").replace(/~0/g, "~");
1763
+ function We(s) {
1764
+ return s.replace(/~1/g, "/").replace(/~0/g, "~");
1782
1765
  }
1783
- function H(n) {
1784
- if (n === void 0)
1766
+ function Y(s) {
1767
+ if (s === void 0)
1785
1768
  return !0;
1786
- if (n) {
1787
- if (Array.isArray(n)) {
1788
- for (var e = 0, t = n.length; e < t; e++)
1789
- if (H(n[e]))
1769
+ if (s) {
1770
+ if (Array.isArray(s)) {
1771
+ for (var e = 0, t = s.length; e < t; e++)
1772
+ if (Y(s[e]))
1790
1773
  return !0;
1791
- } else if (typeof n == "object") {
1792
- for (var s = X(n), i = s.length, o = 0; o < i; o++)
1793
- if (H(n[s[o]]))
1774
+ } else if (typeof s == "object") {
1775
+ for (var n = V(s), o = n.length, i = 0; i < o; i++)
1776
+ if (Y(s[n[i]]))
1794
1777
  return !0;
1795
1778
  }
1796
1779
  }
1797
1780
  return !1;
1798
1781
  }
1799
- function de(n, e) {
1800
- var t = [n];
1801
- for (var s in e) {
1802
- var i = typeof e[s] == "object" ? JSON.stringify(e[s], null, 2) : e[s];
1803
- typeof i < "u" && t.push(s + ": " + i);
1782
+ function le(s, e) {
1783
+ var t = [s];
1784
+ for (var n in e) {
1785
+ var o = typeof e[n] == "object" ? JSON.stringify(e[n], null, 2) : e[n];
1786
+ typeof o < "u" && t.push(n + ": " + o);
1804
1787
  }
1805
1788
  return t.join(`
1806
1789
  `);
1807
1790
  }
1808
1791
  var Xe = (
1809
1792
  /** @class */
1810
- (function(n) {
1811
- fs(e, n);
1812
- function e(t, s, i, o, r) {
1813
- var d = this.constructor, l = n.call(this, de(t, { name: s, index: i, operation: o, tree: r })) || this;
1814
- return l.name = s, l.index = i, l.operation = o, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = de(t, { name: s, index: i, operation: o, tree: r }), l;
1793
+ (function(s) {
1794
+ ls(e, s);
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;
1815
1798
  }
1816
1799
  return e;
1817
1800
  })(Error)
1818
- ), E = Xe, ms = R, M = {
1819
- add: function(n, e, t) {
1820
- return n[e] = this.value, { newDocument: t };
1801
+ ), E = Xe, fs = T, M = {
1802
+ add: function(s, e, t) {
1803
+ return s[e] = this.value, { newDocument: t };
1821
1804
  },
1822
- remove: function(n, e, t) {
1823
- var s = n[e];
1824
- return delete n[e], { newDocument: t, removed: s };
1805
+ remove: function(s, e, t) {
1806
+ var n = s[e];
1807
+ return delete s[e], { newDocument: t, removed: n };
1825
1808
  },
1826
- replace: function(n, e, t) {
1827
- var s = n[e];
1828
- return n[e] = this.value, { newDocument: t, removed: s };
1809
+ replace: function(s, e, t) {
1810
+ var n = s[e];
1811
+ return s[e] = this.value, { newDocument: t, removed: n };
1829
1812
  },
1830
- move: function(n, e, t) {
1831
- var s = U(t, this.path);
1832
- s && (s = R(s));
1833
- var i = O(t, { op: "remove", path: this.from }).removed;
1834
- return O(t, { op: "add", path: this.path, value: i }), { newDocument: t, removed: s };
1813
+ move: function(s, e, t) {
1814
+ var n = U(t, this.path);
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 };
1835
1818
  },
1836
- copy: function(n, e, t) {
1837
- var s = U(t, this.from);
1838
- return O(t, { op: "add", path: this.path, value: R(s) }), { newDocument: t };
1819
+ copy: function(s, e, t) {
1820
+ var n = U(t, this.from);
1821
+ return O(t, { op: "add", path: this.path, value: T(n) }), { newDocument: t };
1839
1822
  },
1840
- test: function(n, e, t) {
1841
- return { newDocument: t, test: P(n[e], this.value) };
1823
+ test: function(s, e, t) {
1824
+ return { newDocument: t, test: P(s[e], this.value) };
1842
1825
  },
1843
- _get: function(n, e, t) {
1844
- return this.value = n[e], { newDocument: t };
1826
+ _get: function(s, e, t) {
1827
+ return this.value = s[e], { newDocument: t };
1845
1828
  }
1846
- }, ps = {
1847
- add: function(n, e, t) {
1848
- return V(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: t, index: e };
1829
+ }, us = {
1830
+ add: function(s, e, t) {
1831
+ return H(e) ? s.splice(e, 0, this.value) : s[e] = this.value, { newDocument: t, index: e };
1849
1832
  },
1850
- remove: function(n, e, t) {
1851
- var s = n.splice(e, 1);
1852
- return { newDocument: t, removed: s[0] };
1833
+ remove: function(s, e, t) {
1834
+ var n = s.splice(e, 1);
1835
+ return { newDocument: t, removed: n[0] };
1853
1836
  },
1854
- replace: function(n, e, t) {
1855
- var s = n[e];
1856
- return n[e] = this.value, { newDocument: t, removed: s };
1837
+ replace: function(s, e, t) {
1838
+ var n = s[e];
1839
+ return s[e] = this.value, { newDocument: t, removed: n };
1857
1840
  },
1858
1841
  move: M.move,
1859
1842
  copy: M.copy,
1860
1843
  test: M.test,
1861
1844
  _get: M._get
1862
1845
  };
1863
- function U(n, e) {
1846
+ function U(s, e) {
1864
1847
  if (e == "")
1865
- return n;
1848
+ return s;
1866
1849
  var t = { op: "_get", path: e };
1867
- return O(n, t), t.value;
1850
+ return O(s, t), t.value;
1868
1851
  }
1869
- function O(n, e, t, s, i, o) {
1870
- if (t === void 0 && (t = !1), s === void 0 && (s = !0), i === void 0 && (i = !0), o === void 0 && (o = 0), t && (typeof t == "function" ? t(e, 0, n, e.path) : z(e, 0)), e.path === "") {
1871
- var r = { newDocument: n };
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
+ var r = { newDocument: s };
1872
1855
  if (e.op === "add")
1873
1856
  return r.newDocument = e.value, r;
1874
1857
  if (e.op === "replace")
1875
- return r.newDocument = e.value, r.removed = n, r;
1858
+ return r.newDocument = e.value, r.removed = s, r;
1876
1859
  if (e.op === "move" || e.op === "copy")
1877
- return r.newDocument = U(n, e.from), e.op === "move" && (r.removed = n), r;
1860
+ return r.newDocument = U(s, e.from), e.op === "move" && (r.removed = s), r;
1878
1861
  if (e.op === "test") {
1879
- if (r.test = P(n, e.value), r.test === !1)
1880
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1881
- return r.newDocument = n, r;
1862
+ if (r.test = P(s, e.value), r.test === !1)
1863
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
1864
+ return r.newDocument = s, r;
1882
1865
  } else {
1883
1866
  if (e.op === "remove")
1884
- return r.removed = n, r.newDocument = null, r;
1867
+ return r.removed = s, r.newDocument = null, r;
1885
1868
  if (e.op === "_get")
1886
- return e.value = n, r;
1869
+ return e.value = s, r;
1887
1870
  if (t)
1888
- throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, n);
1871
+ throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", i, e, s);
1889
1872
  return r;
1890
1873
  }
1891
1874
  } else {
1892
- s || (n = R(n));
1893
- var d = e.path || "", l = d.split("/"), c = n, u = 1, m = l.length, f = void 0, p = void 0, g = void 0;
1875
+ n || (s = T(s));
1876
+ var d = e.path || "", l = d.split("/"), c = s, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
1894
1877
  for (typeof t == "function" ? g = t : g = z; ; ) {
1895
- if (p = l[u], p && p.indexOf("~") != -1 && (p = Ge(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"))
1896
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");
1897
- if (t && f === void 0 && (c[p] === void 0 ? f = l.slice(0, u).join("/") : u == m - 1 && (f = e.path), f !== void 0 && g(e, 0, n, f)), u++, Array.isArray(c)) {
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)) {
1898
1881
  if (p === "-")
1899
1882
  p = c.length;
1900
1883
  else {
1901
- if (t && !V(p))
1902
- throw new E("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", o, e, n);
1903
- V(p) && (p = ~~p);
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);
1904
1887
  }
1905
- if (u >= m) {
1888
+ if (u >= f) {
1906
1889
  if (t && e.op === "add" && p > c.length)
1907
- throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", o, e, n);
1908
- var r = ps[e.op].call(e, c, p, n);
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
+ var r = us[e.op].call(e, c, p, s);
1909
1892
  if (r.test === !1)
1910
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1893
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
1911
1894
  return r;
1912
1895
  }
1913
- } else if (u >= m) {
1914
- var r = M[e.op].call(e, c, p, n);
1896
+ } else if (u >= f) {
1897
+ var r = M[e.op].call(e, c, p, s);
1915
1898
  if (r.test === !1)
1916
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1899
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
1917
1900
  return r;
1918
1901
  }
1919
- if (c = c[p], t && u < m && (!c || typeof c != "object"))
1920
- throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, n);
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", i, e, s);
1921
1904
  }
1922
1905
  }
1923
1906
  }
1924
- function Z(n, e, t, s, i) {
1925
- if (s === void 0 && (s = !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))
1926
1909
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1927
- s || (n = R(n));
1928
- for (var o = new Array(e.length), r = 0, d = e.length; r < d; r++)
1929
- o[r] = O(n, e[r], t, !0, i, r), n = o[r].newDocument;
1930
- return o.newDocument = n, o;
1931
- }
1932
- function hs(n, e, t) {
1933
- var s = O(n, e);
1934
- if (s.test === !1)
1935
- throw new E("Test operation failed", "TEST_OPERATION_FAILED", t, e, n);
1936
- return s.newDocument;
1937
- }
1938
- function z(n, e, t, s) {
1939
- if (typeof n != "object" || n === null || Array.isArray(n))
1940
- throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, n, t);
1941
- if (M[n.op]) {
1942
- if (typeof n.path != "string")
1943
- throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, n, t);
1944
- if (n.path.indexOf("/") !== 0 && n.path.length > 0)
1945
- throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, n, t);
1946
- if ((n.op === "move" || n.op === "copy") && typeof n.from != "string")
1947
- throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, n, t);
1948
- if ((n.op === "add" || n.op === "replace" || n.op === "test") && n.value === void 0)
1949
- throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, n, t);
1950
- if ((n.op === "add" || n.op === "replace" || n.op === "test") && H(n.value))
1951
- throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, t);
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
+ }
1915
+ function ms(s, e, t) {
1916
+ var n = O(s, e);
1917
+ if (n.test === !1)
1918
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", t, e, s);
1919
+ return n.newDocument;
1920
+ }
1921
+ function z(s, e, t, n) {
1922
+ if (typeof s != "object" || s === null || Array.isArray(s))
1923
+ throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, s, t);
1924
+ if (M[s.op]) {
1925
+ if (typeof s.path != "string")
1926
+ throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, s, t);
1927
+ if (s.path.indexOf("/") !== 0 && s.path.length > 0)
1928
+ throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, s, t);
1929
+ if ((s.op === "move" || s.op === "copy") && typeof s.from != "string")
1930
+ throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, s, t);
1931
+ if ((s.op === "add" || s.op === "replace" || s.op === "test") && s.value === void 0)
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") && Y(s.value))
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);
1952
1935
  if (t) {
1953
- if (n.op == "add") {
1954
- var i = n.path.split("/").length, o = s.split("/").length;
1955
- if (i !== o + 1 && i !== o)
1956
- throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, n, t);
1957
- } else if (n.op === "replace" || n.op === "remove" || n.op === "_get") {
1958
- if (n.path !== s)
1959
- throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, n, t);
1960
- } else if (n.op === "move" || n.op === "copy") {
1961
- var r = { op: "_get", path: n.from, value: void 0 }, d = Ve([r], t);
1936
+ if (s.op == "add") {
1937
+ var o = s.path.split("/").length, i = n.split("/").length;
1938
+ if (o !== i + 1 && o !== i)
1939
+ throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, s, t);
1940
+ } else if (s.op === "replace" || s.op === "remove" || s.op === "_get") {
1941
+ if (s.path !== n)
1942
+ throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, s, t);
1943
+ } else if (s.op === "move" || s.op === "copy") {
1944
+ var r = { op: "_get", path: s.from, value: void 0 }, d = Ge([r], t);
1962
1945
  if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
1963
- throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, n, t);
1946
+ throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, s, t);
1964
1947
  }
1965
1948
  }
1966
- } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, n, t);
1949
+ } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, s, t);
1967
1950
  }
1968
- function Ve(n, e, t) {
1951
+ function Ge(s, e, t) {
1969
1952
  try {
1970
- if (!Array.isArray(n))
1953
+ if (!Array.isArray(s))
1971
1954
  throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1972
1955
  if (e)
1973
- Z(R(e), R(n), t || !0);
1956
+ Z(T(e), T(s), t || !0);
1974
1957
  else {
1975
1958
  t = t || z;
1976
- for (var s = 0; s < n.length; s++)
1977
- t(n[s], s, e, void 0);
1959
+ for (var n = 0; n < s.length; n++)
1960
+ t(s[n], n, e, void 0);
1978
1961
  }
1979
- } catch (i) {
1980
- if (i instanceof E)
1981
- return i;
1982
- throw i;
1962
+ } catch (o) {
1963
+ if (o instanceof E)
1964
+ return o;
1965
+ throw o;
1983
1966
  }
1984
1967
  }
1985
- function P(n, e) {
1986
- if (n === e)
1968
+ function P(s, e) {
1969
+ if (s === e)
1987
1970
  return !0;
1988
- if (n && e && typeof n == "object" && typeof e == "object") {
1989
- var t = Array.isArray(n), s = Array.isArray(e), i, o, r;
1990
- if (t && s) {
1991
- if (o = n.length, o != e.length)
1971
+ if (s && e && typeof s == "object" && typeof e == "object") {
1972
+ var t = Array.isArray(s), n = Array.isArray(e), o, i, r;
1973
+ if (t && n) {
1974
+ if (i = s.length, i != e.length)
1992
1975
  return !1;
1993
- for (i = o; i-- !== 0; )
1994
- if (!P(n[i], e[i]))
1976
+ for (o = i; o-- !== 0; )
1977
+ if (!P(s[o], e[o]))
1995
1978
  return !1;
1996
1979
  return !0;
1997
1980
  }
1998
- if (t != s)
1981
+ if (t != n)
1999
1982
  return !1;
2000
- var d = Object.keys(n);
2001
- if (o = d.length, o !== Object.keys(e).length)
1983
+ var d = Object.keys(s);
1984
+ if (i = d.length, i !== Object.keys(e).length)
2002
1985
  return !1;
2003
- for (i = o; i-- !== 0; )
2004
- if (!e.hasOwnProperty(d[i]))
1986
+ for (o = i; o-- !== 0; )
1987
+ if (!e.hasOwnProperty(d[o]))
2005
1988
  return !1;
2006
- for (i = o; i-- !== 0; )
2007
- if (r = d[i], !P(n[r], e[r]))
1989
+ for (o = i; o-- !== 0; )
1990
+ if (r = d[o], !P(s[r], e[r]))
2008
1991
  return !1;
2009
1992
  return !0;
2010
1993
  }
2011
- return n !== n && e !== e;
1994
+ return s !== s && e !== e;
2012
1995
  }
2013
- const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1996
+ const ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2014
1997
  __proto__: null,
2015
1998
  JsonPatchError: E,
2016
1999
  _areEquals: P,
2017
2000
  applyOperation: O,
2018
2001
  applyPatch: Z,
2019
- applyReducer: hs,
2020
- deepClone: ms,
2002
+ applyReducer: ms,
2003
+ deepClone: fs,
2021
2004
  getValueByPointer: U,
2022
- validate: Ve,
2005
+ validate: Ge,
2023
2006
  validator: z
2024
2007
  }, Symbol.toStringTag, { value: "Module" }));
2025
- var se = /* @__PURE__ */ new WeakMap(), ys = (
2008
+ var ne = /* @__PURE__ */ new WeakMap(), hs = (
2026
2009
  /** @class */
2027
2010
  /* @__PURE__ */ (function() {
2028
- function n(e) {
2011
+ function s(e) {
2029
2012
  this.observers = /* @__PURE__ */ new Map(), this.obj = e;
2030
2013
  }
2031
- return n;
2014
+ return s;
2032
2015
  })()
2033
- ), bs = (
2016
+ ), gs = (
2034
2017
  /** @class */
2035
2018
  /* @__PURE__ */ (function() {
2036
- function n(e, t) {
2019
+ function s(e, t) {
2037
2020
  this.callback = e, this.observer = t;
2038
2021
  }
2039
- return n;
2022
+ return s;
2040
2023
  })()
2041
2024
  );
2042
- function ws(n) {
2043
- return se.get(n);
2025
+ function ys(s) {
2026
+ return ne.get(s);
2044
2027
  }
2045
- function vs(n, e) {
2046
- return n.observers.get(e);
2028
+ function ws(s, e) {
2029
+ return s.observers.get(e);
2047
2030
  }
2048
- function Is(n, e) {
2049
- n.observers.delete(e.callback);
2031
+ function bs(s, e) {
2032
+ s.observers.delete(e.callback);
2050
2033
  }
2051
- function Es(n, e) {
2034
+ function vs(s, e) {
2052
2035
  e.unobserve();
2053
2036
  }
2054
- function Ns(n, e) {
2055
- var t = [], s, i = ws(n);
2056
- if (!i)
2057
- i = new ys(n), se.set(n, i);
2037
+ function Is(s, e) {
2038
+ var t = [], n, o = ys(s);
2039
+ if (!o)
2040
+ o = new hs(s), ne.set(s, o);
2058
2041
  else {
2059
- var o = vs(i, e);
2060
- s = o && o.observer;
2042
+ var i = ws(o, e);
2043
+ n = i && i.observer;
2061
2044
  }
2062
- if (s)
2063
- return s;
2064
- if (s = {}, i.value = R(n), e) {
2065
- s.callback = e, s.next = null;
2045
+ if (n)
2046
+ return n;
2047
+ if (n = {}, o.value = T(s), e) {
2048
+ n.callback = e, n.next = null;
2066
2049
  var r = function() {
2067
- Y(s);
2050
+ Q(n);
2068
2051
  }, d = function() {
2069
- clearTimeout(s.next), s.next = setTimeout(r);
2052
+ clearTimeout(n.next), n.next = setTimeout(r);
2070
2053
  };
2071
2054
  typeof window < "u" && (window.addEventListener("mouseup", d), window.addEventListener("keyup", d), window.addEventListener("mousedown", d), window.addEventListener("keydown", d), window.addEventListener("change", d));
2072
2055
  }
2073
- return s.patches = t, s.object = n, s.unobserve = function() {
2074
- Y(s), clearTimeout(s.next), Is(i, s), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
2075
- }, i.observers.set(e, new bs(e, s)), s;
2056
+ return n.patches = t, n.object = s, n.unobserve = function() {
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;
2076
2059
  }
2077
- function Y(n, e) {
2060
+ function Q(s, e) {
2078
2061
  e === void 0 && (e = !1);
2079
- var t = se.get(n.object);
2080
- ne(t.value, n.object, n.patches, "", e), n.patches.length && Z(t.value, n.patches);
2081
- var s = n.patches;
2082
- return s.length > 0 && (n.patches = [], n.callback && n.callback(s)), s;
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
+ var n = s.patches;
2065
+ return n.length > 0 && (s.patches = [], s.callback && s.callback(n)), n;
2083
2066
  }
2084
- function ne(n, e, t, s, i) {
2085
- if (e !== n) {
2067
+ function oe(s, e, t, n, o) {
2068
+ if (e !== s) {
2086
2069
  typeof e.toJSON == "function" && (e = e.toJSON());
2087
- for (var o = X(e), r = X(n), d = !1, l = r.length - 1; l >= 0; l--) {
2088
- var c = r[l], u = n[c];
2070
+ for (var i = V(e), r = V(s), d = !1, l = r.length - 1; l >= 0; l--) {
2071
+ var c = r[l], u = s[c];
2089
2072
  if (G(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
2090
- var m = e[c];
2091
- typeof u == "object" && u != null && typeof m == "object" && m != null && Array.isArray(u) === Array.isArray(m) ? ne(u, m, t, s + "/" + j(c), i) : u !== m && (i && t.push({ op: "test", path: s + "/" + j(c), value: R(u) }), t.push({ op: "replace", path: s + "/" + j(c), value: R(m) }));
2092
- } else Array.isArray(n) === Array.isArray(e) ? (i && t.push({ op: "test", path: s + "/" + j(c), value: R(u) }), t.push({ op: "remove", path: s + "/" + j(c) }), d = !0) : (i && t.push({ op: "test", path: s, value: n }), t.push({ op: "replace", path: s, value: e }));
2073
+ var f = e[c];
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 }));
2093
2076
  }
2094
- if (!(!d && o.length == r.length))
2095
- for (var l = 0; l < o.length; l++) {
2096
- var c = o[l];
2097
- !G(n, c) && e[c] !== void 0 && t.push({ op: "add", path: s + "/" + j(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]) });
2098
2081
  }
2099
2082
  }
2100
2083
  }
2101
- function Q(n, e, t) {
2084
+ function ee(s, e, t) {
2102
2085
  t === void 0 && (t = !1);
2103
- var s = [];
2104
- return ne(n, e, s, "", t), s;
2086
+ var n = [];
2087
+ return oe(s, e, n, "", t), n;
2105
2088
  }
2106
- const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2089
+ const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2107
2090
  __proto__: null,
2108
- compare: Q,
2109
- generate: Y,
2110
- observe: Ns,
2111
- unobserve: Es
2091
+ compare: ee,
2092
+ generate: Q,
2093
+ observe: Is,
2094
+ unobserve: vs
2112
2095
  }, Symbol.toStringTag, { value: "Module" }));
2113
- Object.assign({}, gs, Ss, {
2096
+ Object.assign({}, ps, Es, {
2114
2097
  JsonPatchError: Xe,
2115
- deepClone: R,
2116
- escapePathComponent: j,
2117
- unescapePathComponent: Ge
2098
+ deepClone: T,
2099
+ escapePathComponent: A,
2100
+ unescapePathComponent: We
2118
2101
  });
2119
- function I(n, e, t) {
2120
- return { key: n, getId: (s) => e(s), getLabel: (s) => t(s) };
2121
- }
2122
- const ks = [
2123
- I("roles", (n) => n.id, (n) => n.name),
2124
- I("members", (n) => n.email, (n) => `${n.name} (${n.email})`),
2125
- I("teams", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2126
- I("phases", (n) => n.id, (n) => n.name),
2127
- I("milestones", (n) => n.id, (n) => n.name),
2128
- I("lbs", (n) => n.id, (n) => `${n.id} — ${n.name} (${n.type})`),
2129
- I("disciplines", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2130
- I("extensions", (n) => n.id, (n) => n.id),
2131
- I("assetTypes", (n) => n.id, (n) => `${n.id} — ${n.name}`),
2132
- I("softwares", (n) => n.id, (n) => n.name),
2133
- I("objectives", (n) => n.id, (n) => n.description),
2134
- I("bimUses", (n) => n.id, (n) => n.name),
2135
- I("actions", (n) => n.id, (n) => n.name),
2136
- I("events", (n) => n.id, (n) => n.name),
2137
- I("effects", (n) => n.id, (n) => n.name),
2138
- I("automations", (n) => n.id, (n) => n.name),
2139
- I("workflows", (n) => n.id, (n) => n.name),
2140
- I("guides", (n) => n.id, (n) => n.name),
2141
- I("annexes", (n) => n.id, (n) => n.name),
2142
- I("standards", (n) => n.id, (n) => n.name),
2143
- I("lods", (n) => String(n.id), (n) => `${n.id} — ${n.name}`),
2144
- I("lois", (n) => String(n.id), (n) => `${n.id} — ${n.name}`),
2145
- I("loin", (n) => n.id, (n) => n.element),
2146
- I("deliverables", (n) => n.id, (n) => n.description ?? n.id),
2147
- I("notes", (n) => n.id, (n) => n.message),
2148
- I("env", (n) => n.key, (n) => n.key)
2102
+ function I(s, e, t) {
2103
+ return { key: s, getId: (n) => e(n), getLabel: (n) => t(n) };
2104
+ }
2105
+ const Ns = [
2106
+ I("roles", (s) => s.id, (s) => s.name),
2107
+ I("members", (s) => s.email, (s) => `${s.name} (${s.email})`),
2108
+ I("teams", (s) => s.id, (s) => `${s.id} — ${s.name}`),
2109
+ I("phases", (s) => s.id, (s) => s.name),
2110
+ I("milestones", (s) => s.id, (s) => s.name),
2111
+ I("lbs", (s) => s.id, (s) => `${s.id} — ${s.name} (${s.type})`),
2112
+ I("disciplines", (s) => s.id, (s) => `${s.id} — ${s.name}`),
2113
+ I("extensions", (s) => s.id, (s) => s.id),
2114
+ I("assetTypes", (s) => s.id, (s) => `${s.id} — ${s.name}`),
2115
+ I("softwares", (s) => s.id, (s) => s.name),
2116
+ I("objectives", (s) => s.id, (s) => s.description),
2117
+ I("bimUses", (s) => s.id, (s) => s.name),
2118
+ I("actions", (s) => s.id, (s) => s.name),
2119
+ I("events", (s) => s.id, (s) => s.name),
2120
+ I("effects", (s) => s.id, (s) => s.name),
2121
+ I("automations", (s) => s.id, (s) => s.name),
2122
+ I("workflows", (s) => s.id, (s) => s.name),
2123
+ I("guides", (s) => s.id, (s) => s.name),
2124
+ I("annexes", (s) => s.id, (s) => s.name),
2125
+ I("standards", (s) => s.id, (s) => s.name),
2126
+ I("lods", (s) => String(s.id), (s) => `${s.id} — ${s.name}`),
2127
+ I("lois", (s) => String(s.id), (s) => `${s.id} — ${s.name}`),
2128
+ I("loin", (s) => s.id, (s) => s.element),
2129
+ I("deliverables", (s) => s.id, (s) => s.description ?? s.id),
2130
+ I("notes", (s) => s.id, (s) => s.message),
2131
+ I("env", (s) => s.key, (s) => s.key)
2149
2132
  ];
2150
- function $s(n, e, t, s) {
2151
- const i = new Map(n.map((r) => [t(r), r])), o = new Map(e.map((r) => [t(r), r]));
2133
+ function Ss(s, e, t, n) {
2134
+ const o = new Map(s.map((r) => [t(r), r])), i = new Map(e.map((r) => [t(r), r]));
2152
2135
  return {
2153
- added: e.filter((r) => !i.has(t(r))).map(s),
2154
- removed: n.filter((r) => !o.has(t(r))).map(s),
2136
+ added: e.filter((r) => !o.has(t(r))).map(n),
2137
+ removed: s.filter((r) => !i.has(t(r))).map(n),
2155
2138
  modified: e.filter((r) => {
2156
- const d = i.get(t(r));
2139
+ const d = o.get(t(r));
2157
2140
  return d !== void 0 && JSON.stringify(d) !== JSON.stringify(r);
2158
- }).map(s)
2141
+ }).map(n)
2159
2142
  };
2160
2143
  }
2161
- function Rs(n, e) {
2144
+ function ks(s, e) {
2162
2145
  let t = null;
2163
- JSON.stringify(n.project) !== JSON.stringify(e.project) && (t = { changed: !0, fields: Object.keys({ ...n.project, ...e.project }).filter((r) => {
2164
- const d = n.project[r], l = e.project[r];
2146
+ JSON.stringify(s.project) !== JSON.stringify(e.project) && (t = { changed: !0, fields: Object.keys({ ...s.project, ...e.project }).filter((r) => {
2147
+ const d = s.project[r], l = e.project[r];
2165
2148
  return JSON.stringify(d) !== JSON.stringify(l);
2166
2149
  }) });
2167
- const s = {};
2168
- for (const { key: o, getId: r, getLabel: d } of ks) {
2169
- const l = e[o] ?? [], c = n[o] ?? [], u = $s(l, c, r, d);
2170
- (u.added.length || u.removed.length || u.modified.length) && (s[o] = u);
2150
+ const n = {};
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);
2171
2154
  }
2172
- const i = [...t ? ["project"] : [], ...Object.keys(s)];
2173
- return { project: t, sections: s, changedKeys: i };
2155
+ const o = [...t ? ["project"] : [], ...Object.keys(n)];
2156
+ return { project: t, sections: n, changedKeys: o };
2174
2157
  }
2175
- class k {
2176
- constructor(e, t, s) {
2177
- this.getBep = e, this.setBep = t, this.getZip = s;
2158
+ class $ {
2159
+ constructor(e, t, n) {
2160
+ this.getBep = e, this.setBep = t, this.getZip = n;
2178
2161
  }
2179
2162
  getBep;
2180
2163
  setBep;
2181
2164
  getZip;
2182
2165
  // ─── Version helpers ──────────────────────────────────────────────────────
2183
2166
  static parseVersion(e) {
2184
- const [t, s] = e.split(".").map(Number);
2185
- return { major: t, minor: s };
2167
+ const [t, n] = e.split(".").map(Number);
2168
+ return { major: t, minor: n };
2186
2169
  }
2187
2170
  static compareVersions(e, t) {
2188
- const s = k.parseVersion(e), i = k.parseVersion(t);
2189
- return s.major !== i.major ? s.major - i.major : s.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;
2190
2173
  }
2191
2174
  static bumpVersion(e, t) {
2192
- const [s, i] = e.split(".").map(Number);
2193
- return t === "version" ? `${s + 1}.0` : `${s}.${i + 1}`;
2175
+ const [n, o] = e.split(".").map(Number);
2176
+ return t === "version" ? `${n + 1}.0` : `${n}.${o + 1}`;
2194
2177
  }
2195
2178
  // ─── Zip helpers ──────────────────────────────────────────────────────────
2196
2179
  async readChangelog() {
@@ -2207,17 +2190,17 @@ class k {
2207
2190
  * snapshot, saves changelog/standards/{id}/v{version}.md.
2208
2191
  */
2209
2192
  async snapshotChangedStandards(e, t) {
2210
- const s = this.getZip();
2211
- for (const i of e.standards) {
2212
- const o = s.file(i.contentPath);
2213
- if (!o) continue;
2214
- const r = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(s.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2193
+ const n = this.getZip();
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));
2215
2198
  let c = null;
2216
2199
  if (l.length > 0) {
2217
- const u = l.sort((f, p) => k.compareVersions(p, f))[0], m = s.file(`${d}v${u}.md`);
2218
- m && (c = await m.async("string"));
2200
+ const u = l.sort((m, p) => $.compareVersions(p, m))[0], f = n.file(`${d}v${u}.md`);
2201
+ f && (c = await f.async("string"));
2219
2202
  }
2220
- c !== r && s.file(`${d}v${t}.md`, r);
2203
+ c !== r && n.file(`${d}v${t}.md`, r);
2221
2204
  }
2222
2205
  }
2223
2206
  /**
@@ -2226,11 +2209,11 @@ class k {
2226
2209
  */
2227
2210
  async snapshotBaseStandards(e) {
2228
2211
  const t = this.getZip();
2229
- for (const s of e.standards) {
2230
- const i = t.file(s.contentPath);
2231
- if (!i) continue;
2232
- const o = await i.async("string");
2233
- t.file(`baseline/standards/${s.id}.md`, o);
2212
+ for (const n of e.standards) {
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);
2234
2217
  }
2235
2218
  }
2236
2219
  /**
@@ -2239,12 +2222,12 @@ class k {
2239
2222
  * Falls back to the current file if no snapshot exists (content never changed).
2240
2223
  */
2241
2224
  async resolveStandardContent(e, t) {
2242
- const s = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(s.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => k.compareVersions(d, t) <= 0).sort((d, l) => k.compareVersions(l, d));
2243
- if (o.length === 0) {
2244
- const d = s.file(e.contentPath);
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
+ const d = n.file(e.contentPath);
2245
2228
  return d ? d.async("string") : null;
2246
2229
  }
2247
- const r = s.file(`${i}v${o[0]}.md`);
2230
+ const r = n.file(`${o}v${i[0]}.md`);
2248
2231
  return r ? r.async("string") : null;
2249
2232
  }
2250
2233
  // ─── Public API ───────────────────────────────────────────────────────────
@@ -2255,19 +2238,19 @@ class k {
2255
2238
  return (await this.readChangelog())?.versions ?? [];
2256
2239
  }
2257
2240
  async commit(e, t = !1) {
2258
- const s = 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();
2259
2242
  if (!r) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
2260
2243
  if (e.type === "version") {
2261
- 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));
2262
2245
  if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
2263
2246
  }
2264
2247
  if (!t && !await this.hasPendingChanges())
2265
2248
  throw new Error("No pending changes since last commit");
2266
- const l = o?.current ?? "0.0", c = k.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, m = Q(i, r), f = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: u } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: u }, p = {
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 = {
2267
2250
  current: c,
2268
- versions: [...o?.versions ?? [], f]
2251
+ versions: [...i?.versions ?? [], m]
2269
2252
  };
2270
- return s.file(u, JSON.stringify(m, null, 2)), await this.snapshotChangedStandards(i, c), s.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), s.file("changelog.json", JSON.stringify(p, null, 2)), f;
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;
2271
2254
  }
2272
2255
  /**
2273
2256
  * Reconstructs the BEP state at the given version (read-only).
@@ -2278,39 +2261,39 @@ class k {
2278
2261
  if (!t) throw new Error("No changelog found — call commit() first");
2279
2262
  if (e === t.current)
2280
2263
  return JSON.parse(JSON.stringify(this.getBep()));
2281
- const s = t.versions.findIndex((r) => r.version === e);
2282
- if (s === -1) {
2264
+ const n = t.versions.findIndex((r) => r.version === e);
2265
+ if (n === -1) {
2283
2266
  const r = this.getZip().file(`changelog/v${e}.json`);
2284
2267
  if (!r) throw new Error(`Version not found: ${e}`);
2285
2268
  return B(JSON.parse(await r.async("string")));
2286
2269
  }
2287
- if (t.versions[s].diff === null) {
2270
+ if (t.versions[n].diff === null) {
2288
2271
  const r = this.getZip().file(`changelog/v${e}.json`);
2289
2272
  if (!r) throw new Error(`Missing terminus: changelog/v${e}.json`);
2290
2273
  return B(JSON.parse(await r.async("string")));
2291
2274
  }
2292
- const i = t.versions.filter((r) => k.compareVersions(r.version, e) > 0).sort((r, d) => k.compareVersions(d.version, r.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2293
- for (const r of i) {
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) {
2294
2277
  if (!r.diff) break;
2295
2278
  const d = this.getZip().file(r.diff);
2296
2279
  if (!d) throw new Error(`Missing diff file: ${r.diff}`);
2297
2280
  const l = JSON.parse(await d.async("string"));
2298
- Z(o, l);
2281
+ Z(i, l);
2299
2282
  }
2300
- return B(o);
2283
+ return B(i);
2301
2284
  }
2302
2285
  /** Returns the RFC 6902 diff and standards summary between two versions. */
2303
2286
  async compare(e, t) {
2304
- const [s, i, o] = await Promise.all([
2287
+ const [n, o, i] = await Promise.all([
2305
2288
  this.get(e),
2306
2289
  this.get(t),
2307
2290
  this.readChangelog()
2308
- ]), r = Q(s, i), d = new Set(s.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), u = s.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), f = (o?.versions ?? []).filter((h) => k.compareVersions(h.version, e) > 0 && k.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2309
- i.standards.filter((h) => d.has(h.id)).map(async (h) => {
2310
- const b = (await Promise.all(
2311
- f.map(async ($) => p.file(`changelog/standards/${h.id}/v${$}.md`) !== null ? $ : null)
2312
- )).filter(($) => $ !== null);
2313
- 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;
2314
2297
  })
2315
2298
  )).filter((h) => h !== null);
2316
2299
  return { diff: r, standards: { added: c, removed: u, contentModified: g } };
@@ -2322,14 +2305,14 @@ class k {
2322
2305
  async discard() {
2323
2306
  const e = this.getZip(), t = await this.readBaseline();
2324
2307
  if (!t) throw new Error("No baseline found — call commit() first");
2325
- const s = new Set(t.standards.map((i) => i.id));
2326
- for (const i of this.getBep().standards)
2327
- s.has(i.id) || e.remove(i.contentPath);
2328
- for (const i of t.standards) {
2329
- const o = e.file(`baseline/standards/${i.id}.md`);
2330
- if (!o) continue;
2331
- const r = await o.async("string");
2332
- e.file(i.contentPath, r);
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);
2333
2316
  }
2334
2317
  this.setBep(t);
2335
2318
  }
@@ -2338,12 +2321,12 @@ class k {
2338
2321
  * version and immediately commits it as a new version.
2339
2322
  */
2340
2323
  async revert(e, t) {
2341
- const s = this.getZip(), i = await this.get(e);
2342
- for (const o of i.standards) {
2343
- const r = await this.resolveStandardContent(o, e);
2344
- r !== null && s.file(o.contentPath, r);
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);
2345
2328
  }
2346
- return this.setBep(i), this.commit(t);
2329
+ return this.setBep(o), this.commit(t);
2347
2330
  }
2348
2331
  /**
2349
2332
  * Returns a structured diff of the current BEP state vs the last committed baseline.
@@ -2352,17 +2335,17 @@ class k {
2352
2335
  async status() {
2353
2336
  const e = this.getZip(), t = await this.readBaseline();
2354
2337
  if (!t) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
2355
- const s = this.getBep(), i = Rs(s, t), o = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(s.standards.map((c) => c.id));
2356
- for (const c of s.standards)
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
+ for (const c of n.standards)
2357
2340
  if (!r.has(c.id))
2358
- o.push({ id: c.id, name: c.name, status: "added" });
2341
+ i.push({ id: c.id, name: c.name, status: "added" });
2359
2342
  else {
2360
- const u = JSON.stringify(r.get(c.id)) !== JSON.stringify(c), m = e.file(`baseline/standards/${c.id}.md`), f = e.file(c.contentPath), p = m ? await m.async("string") : "", g = f ? await f.async("string") : "";
2361
- u ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
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 ? i.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && i.push({ id: c.id, name: c.name, status: "content-modified" });
2362
2345
  }
2363
2346
  for (const c of t.standards)
2364
- d.has(c.id) || o.push({ id: c.id, name: c.name, status: "removed" });
2365
- return { hasPendingChanges: i.changedKeys.length > 0 || o.length > 0, standards: o, ...i };
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 };
2366
2349
  }
2367
2350
  /** Shorthand — true if there are uncommitted changes since the last commit. */
2368
2351
  async hasPendingChanges() {
@@ -2370,19 +2353,19 @@ class k {
2370
2353
  }
2371
2354
  /** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
2372
2355
  async listResolved() {
2373
- const [e, t] = await Promise.all([this.list(), this.current()]), s = this.getBep().members;
2374
- return e.sort((i, o) => k.compareVersions(i.version, o.version)).map((i) => ({
2375
- version: i.version,
2376
- type: i.type,
2377
- date: i.date,
2378
- description: i.description,
2379
- diff: i.diff,
2380
- isCurrent: i.version === t,
2381
- author: i.author ? { email: i.author, name: s.find((o) => o.email === i.author)?.name ?? null } : null,
2382
- ...i.type === "version" ? {
2383
- approvedBy: i.approvedBy.map((o) => ({
2384
- email: o,
2385
- name: s.find((r) => r.email === o)?.name ?? null
2356
+ const [e, t] = await Promise.all([this.list(), this.current()]), n = this.getBep().members;
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
2386
2369
  }))
2387
2370
  } : {}
2388
2371
  }));
@@ -2392,22 +2375,22 @@ class k {
2392
2375
  * Returns null if the standard did not exist at that version.
2393
2376
  */
2394
2377
  async getStandardContent(e, t) {
2395
- const i = (await this.get(t)).standards.find((o) => o.id === e);
2396
- 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;
2397
2380
  }
2398
2381
  /**
2399
2382
  * ⚠️ Destructive: resets the BEP to a historical version and permanently
2400
2383
  * deletes all subsequent diffs, standard snapshots, and changelog entries.
2401
2384
  */
2402
2385
  async reset(e) {
2403
- const t = this.getZip(), s = await this.readChangelog();
2404
- if (!s) throw new Error("No changelog found");
2405
- const i = s.versions.find((c) => c.version === e), o = !!this.getZip().file(`changelog/v${e}.json`);
2406
- if (!i && !o)
2386
+ const t = this.getZip(), n = await this.readChangelog();
2387
+ if (!n) throw new Error("No changelog found");
2388
+ const o = n.versions.find((c) => c.version === e), i = !!this.getZip().file(`changelog/v${e}.json`);
2389
+ if (!o && !i)
2407
2390
  throw new Error(`Version not found: ${e}`);
2408
- if (e === s.current)
2391
+ if (e === n.current)
2409
2392
  throw new Error(`Already at version ${e}`);
2410
- const r = s.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);
2411
2394
  for (const c of d.standards) {
2412
2395
  const u = await this.resolveStandardContent(c, e);
2413
2396
  u !== null && t.file(c.contentPath, u);
@@ -2418,7 +2401,7 @@ class k {
2418
2401
  const l = JSON.stringify(d, null, 2);
2419
2402
  t.file("changelog.json", JSON.stringify({
2420
2403
  current: e,
2421
- versions: s.versions.filter((c) => k.compareVersions(c.version, e) <= 0)
2404
+ versions: n.versions.filter((c) => $.compareVersions(c.version, e) <= 0)
2422
2405
  }, null, 2)), t.file("bep.json", l), t.file("baseline/bep.json", l), this.setBep(d);
2423
2406
  }
2424
2407
  /**
@@ -2427,24 +2410,24 @@ class k {
2427
2410
  * newBase must be in X.0 format and greater than the current version.
2428
2411
  */
2429
2412
  async squash(e) {
2430
- const t = this.getZip(), s = await this.readChangelog();
2431
- if (!s) throw new Error("No changelog found");
2413
+ const t = this.getZip(), n = await this.readChangelog();
2414
+ if (!n) throw new Error("No changelog found");
2432
2415
  if (!/^\d+\.0$/.test(e.newBase))
2433
2416
  throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
2434
- if (k.compareVersions(e.newBase, s.current) <= 0)
2435
- throw new Error(`newBase "${e.newBase}" must be greater than current version "${s.current}"`);
2436
- const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
2437
- if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
2438
- for (const d of s.versions)
2417
+ if ($.compareVersions(e.newBase, n.current) <= 0)
2418
+ throw new Error(`newBase "${e.newBase}" must be greater than current version "${n.current}"`);
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
+ for (const d of n.versions)
2439
2422
  d.diff && t.remove(d.diff);
2440
- Object.keys(t.files).filter((d) => /^changelog\/v[\d.]+\.json$/.test(d)).forEach((d) => t.remove(d)), Object.keys(t.files).filter((d) => d.startsWith("changelog/standards/") && d.endsWith(".md")).forEach((d) => t.remove(d)), t.file(`changelog/v${e.newBase}.json`, JSON.stringify(i, null, 2));
2441
- 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) {
2442
2425
  const l = t.file(d.contentPath);
2443
2426
  if (!l) continue;
2444
2427
  const c = await l.async("string");
2445
2428
  t.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
2446
2429
  }
2447
- 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);
2448
2431
  const r = {
2449
2432
  version: e.newBase,
2450
2433
  type: "version",
@@ -2473,156 +2456,156 @@ class q {
2473
2456
  this.getZip().file(this.path, e);
2474
2457
  }
2475
2458
  }
2476
- const Ts = 10;
2477
- function As(n, e) {
2478
- const t = e[n.field];
2479
- switch (n.operator) {
2459
+ const $s = 10;
2460
+ function Rs(s, e) {
2461
+ const t = e[s.field];
2462
+ switch (s.operator) {
2480
2463
  case "exists":
2481
2464
  return t != null;
2482
2465
  case "eq":
2483
- return t === n.value;
2466
+ return t === s.value;
2484
2467
  case "neq":
2485
- return t !== n.value;
2468
+ return t !== s.value;
2486
2469
  case "gt":
2487
- return typeof t == "number" && typeof n.value == "number" && t > n.value;
2470
+ return typeof t == "number" && typeof s.value == "number" && t > s.value;
2488
2471
  case "lt":
2489
- return typeof t == "number" && typeof n.value == "number" && t < n.value;
2472
+ return typeof t == "number" && typeof s.value == "number" && t < s.value;
2490
2473
  case "contains":
2491
- return typeof t == "string" && typeof n.value == "string" || Array.isArray(t) ? t.includes(n.value) : !1;
2474
+ return typeof t == "string" && typeof s.value == "string" || Array.isArray(t) ? t.includes(s.value) : !1;
2492
2475
  default:
2493
2476
  return !1;
2494
2477
  }
2495
2478
  }
2496
- function js(n, e, t, s) {
2497
- const o = n.workflows.find((f) => f.id === t)?.diagram.nodes[e];
2498
- if (!o || o.type !== "process") return !0;
2499
- const r = !!(o.responsibleRoleIds?.length || o.responsibleTeamIds?.length || o.responsibleEmails?.length), d = !!(o.accountableRoleIds?.length || o.accountableTeamIds?.length || o.accountableEmails?.length);
2479
+ function Ts(s, e, t, n) {
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);
2500
2483
  if (!r && !d) return !0;
2501
- const c = n.members.find((f) => f.email === s)?.roleId, u = new Set(n.teams.filter((f) => (f.memberEmails ?? []).includes(s)).map((f) => f.id)), m = (f, p, g) => {
2502
- if (g?.includes(s)) return !0;
2503
- const h = !!f?.length, b = !!p?.length;
2504
- return b && h ? !!c && f.includes(c) && p.some(($) => u.has($)) : b ? p.some(($) => u.has($)) : h ? !!c && f.includes(c) : !1;
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
+ if (g?.includes(n)) return !0;
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;
2505
2488
  };
2506
- return r && m(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && m(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2507
- }
2508
- const Os = { string: "string", number: "number", boolean: "boolean" };
2509
- function _s(n, e, t) {
2510
- const s = n.events.find((d) => d.id === e);
2511
- if (!s?.payload?.length) return [];
2512
- const i = [], o = t ?? {};
2513
- for (const d of s.payload) {
2514
- const l = o[d.key];
2489
+ return r && f(i.responsibleRoleIds, i.responsibleTeamIds, i.responsibleEmails) || d && f(i.accountableRoleIds, i.accountableTeamIds, i.accountableEmails);
2490
+ }
2491
+ const js = { string: "string", number: "number", boolean: "boolean" };
2492
+ function As(s, e, t) {
2493
+ const n = s.events.find((d) => d.id === e);
2494
+ if (!n?.payload?.length) return [];
2495
+ const o = [], i = t ?? {};
2496
+ for (const d of n.payload) {
2497
+ const l = i[d.key];
2515
2498
  if (l == null)
2516
- d.required && i.push({ field: d.key, reason: "missing" });
2499
+ d.required && o.push({ field: d.key, reason: "missing" });
2517
2500
  else {
2518
- const c = Os[d.type];
2519
- c && typeof l !== c && i.push({ field: d.key, reason: "wrong_type" });
2501
+ const c = js[d.type];
2502
+ c && typeof l !== c && o.push({ field: d.key, reason: "wrong_type" });
2520
2503
  }
2521
2504
  }
2522
- const r = new Set(s.payload.map((d) => d.key));
2523
- for (const d of Object.keys(o))
2524
- r.has(d) || i.push({ field: d, reason: "unknown_field" });
2525
- return i;
2505
+ const r = new Set(n.payload.map((d) => d.key));
2506
+ for (const d of Object.keys(i))
2507
+ r.has(d) || o.push({ field: d, reason: "unknown_field" });
2508
+ return o;
2526
2509
  }
2527
- function Bs(n, e) {
2528
- return !(!("triggerEventId" in n) || n.triggerEventId !== e.eventId);
2510
+ function Os(s, e) {
2511
+ return !(!("triggerEventId" in s) || s.triggerEventId !== e.eventId);
2529
2512
  }
2530
- function Ms(n, e, t, s, i) {
2531
- const o = n.workflows.find((m) => m.id === e);
2532
- if (!o) return null;
2533
- const r = Object.keys(o.diagram.nodes).find(
2534
- (m) => o.diagram.nodes[m].type === "start"
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"
2535
2518
  );
2536
2519
  if (!r) return null;
2537
- const d = Object.entries(o.diagram.edges).find(([, m]) => m.from === r), l = d?.[1].to ?? r, c = d ? (d[1].effectIds ?? []).map((m) => ({ effectId: m, fromEdgeId: d[0] })) : [], u = (/* @__PURE__ */ new Date()).toISOString();
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();
2538
2521
  return {
2539
2522
  instance: {
2540
2523
  id: globalThis.crypto.randomUUID(),
2541
2524
  workflowId: e,
2542
- bepVersion: i,
2525
+ bepVersion: o,
2543
2526
  trackedAsset: t,
2544
2527
  currentNodeId: l,
2545
2528
  status: "active",
2546
2529
  history: [],
2547
2530
  createdAt: u,
2548
2531
  updatedAt: u,
2549
- initiatedBy: s
2532
+ initiatedBy: n
2550
2533
  },
2551
2534
  startEffects: c
2552
2535
  };
2553
2536
  }
2554
- function le(n, e, t, s) {
2537
+ function W(s, e, t, n) {
2555
2538
  if (e.status !== "active")
2556
2539
  return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
2557
- if (!s?.skipRaci && !js(n, e.currentNodeId, e.workflowId, t.actor))
2540
+ if (!n?.skipRaci && !Ts(s, e.currentNodeId, e.workflowId, t.actor))
2558
2541
  return { ok: !1, error: "UNAUTHORIZED" };
2559
- const i = n.workflows.find((N) => N.id === e.workflowId);
2560
- if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
2561
- const { nodes: o, edges: r } = i.diagram;
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;
2562
2545
  let d = e.currentNodeId;
2563
- const l = [], c = [], u = [], m = Object.entries(r).filter(
2564
- ([, N]) => N.from === d && Bs(N, t)
2546
+ const l = [], c = [], u = [], f = Object.entries(r).filter(
2547
+ ([, N]) => N.from === d && Os(N, t)
2565
2548
  );
2566
- if (m.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2567
- if (m.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2568
- const [f, p] = m[0];
2549
+ if (f.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2550
+ if (f.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2551
+ const [m, p] = f[0];
2569
2552
  if ("triggerEventId" in p) {
2570
- const N = _s(n, p.triggerEventId, t.payload);
2553
+ const N = As(s, p.triggerEventId, t.payload);
2571
2554
  if (N.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: N };
2572
2555
  }
2573
- l.push(ce(f, d, p.to, t)), c.push(...(p.effectIds ?? []).map((N) => ({ effectId: N, fromEdgeId: f }))), u.push({ edgeId: f, fromNodeId: d, toNodeId: p.to }), d = p.to;
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;
2574
2557
  let g = 0;
2575
- for (; o[d]?.type === "decision"; ) {
2576
- if (++g > Ts) return { ok: !1, error: "DECISION_LOOP" };
2577
- const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 : As(v.guard, t.payload ?? {}));
2558
+ for (; i[d]?.type === "decision"; ) {
2559
+ if (++g > $s) return { ok: !1, error: "DECISION_LOOP" };
2560
+ const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 : Rs(v.guard, t.payload ?? {}));
2578
2561
  if (N.length === 0) break;
2579
- const [A, w] = N[0];
2580
- l.push(ce(A, d, w.to, t, !0)), c.push(...(w.effectIds ?? []).map((v) => ({ effectId: v, fromEdgeId: A }))), u.push({ edgeId: A, fromNodeId: d, toNodeId: w.to }), d = w.to;
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;
2581
2564
  }
2582
- const h = o[d], b = h?.type === "end" ? "completed" : "active", $ = {
2565
+ const h = i[d], y = h?.type === "end" ? "completed" : "active", S = {
2583
2566
  ...e,
2584
2567
  currentNodeId: d,
2585
- status: b,
2568
+ status: y,
2586
2569
  history: [...e.history, ...l],
2587
2570
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2588
- }, T = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId } : void 0;
2589
- return { ok: !0, instance: $, transitionsApplied: u, effectsToFire: c, automationNodePending: T };
2590
- }
2591
- function xs(n, e, t) {
2592
- const s = n.workflows.find((w) => w.id === e.workflowId), { nodes: i, edges: o } = s.diagram, r = i[e.currentNodeId], l = n.members.find((w) => w.email === t)?.roleId, c = new Set(
2593
- n.teams.filter((w) => (w.memberEmails ?? []).includes(t)).map((w) => w.id)
2594
- ), u = (w) => (w ?? []).flatMap((v) => {
2595
- const S = n.roles.find((_) => _.id === v);
2596
- return S ? [{ id: S.id, name: S.name }] : [];
2597
- }), m = (w) => (w ?? []).flatMap((v) => {
2598
- const S = n.teams.find((_) => _.id === v);
2599
- return S ? [{ id: S.id, name: S.name }] : [];
2600
- }), f = (w, v, S) => ({
2601
- roles: u(w),
2602
- teams: m(v),
2603
- emails: S ?? []
2604
- }), p = (w, v, S) => {
2605
- if (S?.includes(t)) return !0;
2606
- const _ = !!w?.length, ie = !!v?.length;
2607
- return ie && _ ? !!l && w.includes(l) && v.some((J) => c.has(J)) : ie ? v.some((J) => c.has(J)) : _ ? !!l && w.includes(l) : !1;
2608
- }, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length), b = !!(g?.accountableRoleIds?.length || g?.accountableTeamIds?.length || g?.accountableEmails?.length), $ = !h && !b || h && p(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails) || b && p(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails), T = (w) => (n.events.find((v) => v.id === w)?.payload ?? []).map((v) => ({
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
+ }
2574
+ function Bs(s, e, t) {
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
+ teams: f(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) => ({
2609
2592
  key: v.key,
2610
2593
  type: v.type,
2611
2594
  required: v.required
2612
- })), N = [], A = [];
2613
- for (const [w, v] of Object.entries(o)) {
2595
+ })), N = [], j = [];
2596
+ for (const [b, v] of Object.entries(i)) {
2614
2597
  if (v.from !== e.currentNodeId || !("triggerEventId" in v)) continue;
2615
- const S = v.triggerEventId;
2616
- $ ? N.push({
2617
- edgeId: w,
2618
- label: v.label ?? S,
2619
- emits: S,
2620
- requiredPayload: T(S)
2621
- }) : A.push({
2622
- edgeId: w,
2623
- label: v.label ?? 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
+ }) : j.push({
2605
+ edgeId: b,
2606
+ label: v.label ?? k,
2624
2607
  reason: "UNAUTHORIZED",
2625
- required: f(
2608
+ required: m(
2626
2609
  [...g?.responsibleRoleIds ?? [], ...g?.accountableRoleIds ?? []],
2627
2610
  [...g?.responsibleTeamIds ?? [], ...g?.accountableTeamIds ?? []],
2628
2611
  [...g?.responsibleEmails ?? [], ...g?.accountableEmails ?? []]
@@ -2636,33 +2619,33 @@ function xs(n, e, t) {
2636
2619
  label: e.currentNodeId
2637
2620
  },
2638
2621
  availableTransitions: N,
2639
- blockedTransitions: A,
2622
+ blockedTransitions: j,
2640
2623
  raci: {
2641
- responsible: f(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails),
2642
- accountable: f(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails),
2643
- consulted: f(g?.consultedRoleIds, g?.consultedTeamIds, g?.consultedEmails),
2644
- informed: f(g?.informedRoleIds, g?.informedTeamIds, g?.informedEmails)
2624
+ responsible: m(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails),
2625
+ accountable: m(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails),
2626
+ consulted: m(g?.consultedRoleIds, g?.consultedTeamIds, g?.consultedEmails),
2627
+ informed: m(g?.informedRoleIds, g?.informedTeamIds, g?.informedEmails)
2645
2628
  },
2646
2629
  isTerminal: r.type === "end"
2647
2630
  };
2648
2631
  }
2649
- function ce(n, e, t, s, i) {
2632
+ function ce(s, e, t, n, o) {
2650
2633
  return {
2651
2634
  id: globalThis.crypto.randomUUID(),
2652
- edgeId: n,
2635
+ edgeId: s,
2653
2636
  fromNodeId: e,
2654
2637
  toNodeId: t,
2655
- trigger: s,
2656
- actor: s.actor,
2638
+ trigger: n,
2639
+ actor: n.actor,
2657
2640
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2658
- ...i ? { auto: !0 } : {}
2641
+ ...o ? { auto: !0 } : {}
2659
2642
  };
2660
2643
  }
2661
- class Ps {
2644
+ class Ms {
2662
2645
  instances = /* @__PURE__ */ new Map();
2663
2646
  async listInstances(e) {
2664
2647
  let t = [...this.instances.values()];
2665
- return e?.workflowId && (t = t.filter((s) => s.workflowId === e.workflowId)), e?.status && (t = t.filter((s) => s.status === e.status)), e?.trackedAssetTypeId && (t = t.filter((s) => s.trackedAsset.assetTypeId === e.trackedAssetTypeId)), e?.trackedAssetId && (t = t.filter((s) => s.trackedAsset.id === e.trackedAssetId)), t;
2648
+ return e?.workflowId && (t = t.filter((n) => n.workflowId === e.workflowId)), e?.status && (t = t.filter((n) => n.status === e.status)), e?.trackedAssetTypeId && (t = t.filter((n) => n.trackedAsset.assetTypeId === e.trackedAssetTypeId)), e?.trackedAssetId && (t = t.filter((n) => n.trackedAsset.id === e.trackedAssetId)), t;
2666
2649
  }
2667
2650
  async getInstance(e) {
2668
2651
  return this.instances.get(e) ?? null;
@@ -2674,23 +2657,27 @@ class Ps {
2674
2657
  this.instances.delete(e);
2675
2658
  }
2676
2659
  }
2677
- function Fs(n) {
2678
- if (n == null) return "Unknown error";
2679
- if (typeof n == "string") return n;
2680
- const e = n, t = typeof e.name == "string" ? e.name : "Error", s = typeof e.message == "string" ? e.message : void 0;
2681
- if (s !== void 0) return s ? `${t}: ${s}` : t;
2660
+ function xs(s) {
2661
+ if (s == null) return "Unknown error";
2662
+ if (typeof s == "string") return s;
2663
+ const e = s, t = typeof e.name == "string" ? e.name : "Error", n = typeof e.message == "string" ? e.message : void 0;
2664
+ if (n !== void 0) return n ? `${t}: ${n}` : t;
2682
2665
  try {
2683
- return String(n);
2666
+ return String(s);
2684
2667
  } catch {
2685
2668
  return "Unknown error";
2686
2669
  }
2687
2670
  }
2688
- class Cs {
2671
+ class Ps {
2689
2672
  getBep;
2690
2673
  getHistoricalBep;
2691
2674
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2692
- runtime;
2675
+ _runtime;
2693
2676
  storage;
2677
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2678
+ get runtime() {
2679
+ return this._runtime;
2680
+ }
2694
2681
  skipRaci = !1;
2695
2682
  transitionListeners = [];
2696
2683
  createdListeners = [];
@@ -2709,7 +2696,7 @@ class Cs {
2709
2696
  * Returns `this` for chaining.
2710
2697
  */
2711
2698
  init(e) {
2712
- return this.runtime = e.runtime, this.storage = e.storage ?? new Ps(), 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;
2713
2700
  }
2714
2701
  // ─── Lifecycle listeners ─────────────────────────────────────────────────────
2715
2702
  /** Fires after every successful emit() — all listeners run concurrently. */
@@ -2734,14 +2721,31 @@ class Cs {
2734
2721
  * Records the current BEP version on the instance for historical resolution.
2735
2722
  * Returns null if the workflowId does not exist or has no start node.
2736
2723
  */
2737
- async createInstance(e, t, s) {
2724
+ async createInstance(e, t, n) {
2738
2725
  this._assertInit();
2739
- const i = this.getBep(), r = Ms(i, e, t, s, "unversioned");
2726
+ const o = this.getBep(), r = _s(o, e, t, n, "unversioned");
2740
2727
  if (!r) return null;
2741
2728
  const { instance: d, startEffects: l } = r;
2742
- for (const c of l)
2743
- await this._executeEffect(d, c);
2744
- 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;
2745
2749
  }
2746
2750
  /**
2747
2751
  * Emits an event against a workflow instance.
@@ -2756,27 +2760,27 @@ class Cs {
2756
2760
  */
2757
2761
  async emit(e, t) {
2758
2762
  this._assertInit();
2759
- const s = await this.storage.getInstance(e);
2760
- if (!s) return { ok: !1, error: "NO_MATCHING_EDGE" };
2761
- const i = await this._resolveBep(s.bepVersion);
2762
- let o = le(i, s, t, { skipRaci: this.skipRaci });
2763
- if (!o.ok) return { ok: !1, error: o.error, payloadErrors: o.payloadErrors };
2764
- const r = [...o.transitionsApplied ?? []], d = [];
2765
- let l = o.instance;
2766
- for (const m of o.effectsToFire ?? [])
2767
- d.push(await this._executeEffect(l, m));
2763
+ const n = await this.storage.getInstance(e);
2764
+ if (!n) return { ok: !1, error: "NO_MATCHING_EDGE" };
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 ?? [])
2771
+ d.push(await this._executeEffect(l, f));
2768
2772
  const c = 10;
2769
2773
  let u = 0;
2770
- for (; o.automationNodePending && u++ < c; ) {
2771
- const { automationId: m } = o.automationNodePending, { eventId: f, ...p } = await this._executeAutomationNode(l, m);
2772
- if (o = le(i, l, {
2773
- eventId: f,
2774
+ 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, {
2777
+ eventId: m,
2774
2778
  actor: "_system",
2775
2779
  softwareId: "_system",
2776
2780
  payload: p
2777
- }), !o.ok) break;
2778
- l = o.instance, r.push(...o.transitionsApplied ?? []);
2779
- 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 ?? [])
2780
2784
  d.push(await this._executeEffect(l, g));
2781
2785
  }
2782
2786
  return await this.storage.saveInstance(l), await this._fire(this.transitionListeners, l, r, d), l.status === "completed" && await this._fire(this.completedListeners, l), {
@@ -2797,19 +2801,19 @@ class Cs {
2797
2801
  */
2798
2802
  async getInstances(e) {
2799
2803
  this._assertInit();
2800
- const { pendingActionFor: t, ...s } = e ?? {}, i = await this.storage.listInstances(s);
2801
- if (!t) return i;
2802
- const o = this.getBep(), r = o.members.find((d) => d.email === t);
2803
- return r ? i.filter((d) => {
2804
- const l = o.workflows.find((f) => f.id === d.workflowId);
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);
2805
2809
  if (!l) return !1;
2806
2810
  const c = l.diagram.nodes[d.currentNodeId];
2807
2811
  if (!c) return !1;
2808
- const u = c.type === "process" ? c : null, m = [
2812
+ const u = c.type === "process" ? c : null, f = [
2809
2813
  ...u?.responsibleRoleIds ?? [],
2810
2814
  ...u?.accountableRoleIds ?? []
2811
2815
  ];
2812
- return m.length === 0 || m.includes(r.roleId);
2816
+ return f.length === 0 || f.includes(r.roleId);
2813
2817
  }) : [];
2814
2818
  }
2815
2819
  /**
@@ -2818,10 +2822,10 @@ class Cs {
2818
2822
  */
2819
2823
  async getNodeConfig(e, t) {
2820
2824
  this._assertInit();
2821
- const s = await this.storage.getInstance(e);
2822
- if (!s) return null;
2823
- const i = await this._resolveBep(s.bepVersion);
2824
- return xs(i, s, t);
2825
+ const n = await this.storage.getInstance(e);
2826
+ if (!n) return null;
2827
+ const o = await this._resolveBep(n.bepVersion);
2828
+ return Bs(o, n, t);
2825
2829
  }
2826
2830
  async deleteInstance(e) {
2827
2831
  this._assertInit(), await this.storage.deleteInstance(e);
@@ -2832,17 +2836,10 @@ class Cs {
2832
2836
  */
2833
2837
  async getRemoteData(e) {
2834
2838
  this._assertInit();
2835
- const s = this.getBep().remoteData.find((i) => i.id === e);
2836
- if (!s) throw new Error(`Remote data "${e}" not found in BEP`);
2837
- if (!s.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
2838
- return this.runtime._runResolver(s.resolverId, s.url);
2839
- }
2840
- /**
2841
- * Runs an adapter to transform data into a lens-compatible format.
2842
- * Throws if the adapterId has no registered handler.
2843
- */
2844
- useAdapter(e, t) {
2845
- return this._assertInit(), this.runtime._runAdapter(e, t);
2839
+ const n = this.getBep().remoteData.find((o) => o.id === e);
2840
+ if (!n) throw new Error(`Remote data "${e}" not found in BEP`);
2841
+ if (!n.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
2842
+ return this._runtime._runResolver(n.resolverId, n.url);
2846
2843
  }
2847
2844
  // ─── Internal ────────────────────────────────────────────────────────────────
2848
2845
  _assertInit() {
@@ -2853,89 +2850,88 @@ class Cs {
2853
2850
  return this.getHistoricalBep && e !== "unversioned" ? this.getHistoricalBep(e) : this.getBep();
2854
2851
  }
2855
2852
  async _fire(e, ...t) {
2856
- await Promise.allSettled(e.map((s) => s(...t)));
2853
+ await Promise.allSettled(e.map((n) => n(...t)));
2857
2854
  }
2858
2855
  _resolveFromHistory(e, t) {
2859
- for (let s = t.length - 1; s >= 0; s--) {
2860
- const i = t[s].trigger.payload ?? {};
2861
- if (e in i) return i[e];
2856
+ for (let n = t.length - 1; n >= 0; n--) {
2857
+ const o = t[n].trigger.payload ?? {};
2858
+ if (e in o) return o[e];
2862
2859
  }
2863
2860
  }
2864
2861
  async _executeAutomationNode(e, t) {
2865
- const o = this.getBep().automations.find((l) => l.id === t)?.payload ?? [], r = Object.fromEntries(o.map((l) => [l.key, this._resolveFromHistory(l.key, e.history)])), d = this.runtime.automations[t];
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];
2866
2863
  if (!d) throw new Error(`No handler declared for automation "${t}"`);
2867
2864
  return d(e, r);
2868
2865
  }
2869
2866
  async _executeEffect(e, t) {
2870
- const o = this.getBep().effects.find((c) => c.id === t.effectId)?.payload ?? [], r = o.filter((c) => c.required && this._resolveFromHistory(c.key, e.history) === void 0).map((c) => c.key);
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);
2871
2868
  if (r.length > 0)
2872
2869
  return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped", missingFields: r };
2873
- const d = this.runtime.effects[t.effectId];
2870
+ const d = this._runtime.effects[t.effectId];
2874
2871
  if (!d)
2875
2872
  return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped" };
2876
- 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)]));
2877
2874
  try {
2878
2875
  return await d(e, l), { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "executed" };
2879
2876
  } catch (c) {
2880
- const u = { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "failed", error: Fs(c) };
2877
+ const u = { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "failed", error: xs(c) };
2881
2878
  return await this._fire(this.effectFailedListeners, e, u), u;
2882
2879
  }
2883
2880
  }
2884
2881
  }
2885
- function Js(n, e) {
2882
+ function zs(s, e) {
2886
2883
  const t = /* @__PURE__ */ new Map();
2887
- for (const s of n) {
2888
- const i = [e(s)].flat();
2889
- for (const o of i)
2890
- t.has(o) || t.set(o, []), t.get(o).push(s);
2884
+ for (const n of s) {
2885
+ const o = [e(n)].flat();
2886
+ for (const i of o)
2887
+ t.has(i) || t.set(i, []), t.get(i).push(n);
2891
2888
  }
2892
- return Array.from(t.entries()).map(([s, i]) => ({ key: s, rows: i }));
2889
+ return Array.from(t.entries()).map(([n, o]) => ({ key: n, rows: o }));
2893
2890
  }
2894
- function Ks(n, e = "responsible", t = {}) {
2895
- const { topologicalSort: s = !1 } = t, i = (f) => `_${f}`, o = "#444444", r = Object.entries(n.nodes), d = r.find(([, f]) => f.type === "start")?.[0], l = r.find(([, f]) => f.type === "end")?.[0];
2891
+ function Zs(s, e = "responsible", t = {}) {
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];
2896
2893
  let c;
2897
- if (s && d) {
2898
- const f = /* @__PURE__ */ new Set(), p = [d], g = [];
2894
+ if (n && d) {
2895
+ const m = /* @__PURE__ */ new Set(), p = [d], g = [];
2899
2896
  for (; p.length; ) {
2900
2897
  const h = p.shift();
2901
- if (!f.has(h)) {
2902
- f.add(h), g.push(h);
2903
- for (const b of Object.values(n.edges))
2904
- b.from === h && !f.has(b.to) && p.push(b.to);
2898
+ if (!m.has(h)) {
2899
+ m.add(h), g.push(h);
2900
+ for (const y of Object.values(s.edges))
2901
+ y.from === h && !m.has(y.to) && p.push(y.to);
2905
2902
  }
2906
2903
  }
2907
2904
  for (const [h] of r)
2908
- f.has(h) || g.push(h);
2905
+ m.has(h) || g.push(h);
2909
2906
  c = g;
2910
2907
  } else {
2911
- const f = r.map(([p]) => p).filter((p) => p !== d && p !== l);
2908
+ const m = r.map(([p]) => p).filter((p) => p !== d && p !== l);
2912
2909
  c = [
2913
2910
  ...d ? [d] : [],
2914
- ...f,
2911
+ ...m,
2915
2912
  ...l ? [l] : []
2916
2913
  ];
2917
2914
  }
2918
- const u = [`flowchart ${n.direction}`];
2919
- for (const f of c) {
2920
- const p = n.nodes[f];
2915
+ const u = [`flowchart ${s.direction}`];
2916
+ for (const m of c) {
2917
+ const p = s.nodes[m];
2921
2918
  if (!p) continue;
2922
- const g = p.type === "start" || p.type === "end", b = (p.type === "decision" ? p.label ?? f : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, "&quot;"), $ = g || p.type === "decision" ? [] : p[e].roles.map((A) => A.name), T = $.length > 0 ? `"<b>${$.join(" · ")}</b><br/>${b}"` : `"${b || f}"`;
2923
- g ? u.push(` ${i(f)}([${b || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${i(f)}{${T}}`) : p.type === "automation" ? u.push(` ${i(f)}[[${T}]]`) : u.push(` ${i(f)}(${T})`);
2924
- const N = p[e].roles[0]?.color ?? o;
2925
- g ? u.push(` style ${i(f)} fill:#2962FF,stroke:none`) : u.push(` style ${i(f)} fill:none,stroke:${N},stroke-width:3px`);
2926
- }
2927
- const m = s ? c.flatMap((f) => Object.values(n.edges).filter((p) => p.from === f)) : Object.values(n.edges);
2928
- for (const f of m)
2929
- f.label ? u.push(` ${i(f.from)} -->|${f.label}| ${i(f.to)}`) : u.push(` ${i(f.from)} --> ${i(f.to)}`);
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`);
2923
+ }
2924
+ const f = n ? c.flatMap((m) => Object.values(s.edges).filter((p) => p.from === m)) : Object.values(s.edges);
2925
+ for (const m of f)
2926
+ m.label ? u.push(` ${o(m.from)} -->|${m.label}| ${o(m.to)}`) : u.push(` ${o(m.from)} --> ${o(m.to)}`);
2930
2927
  return u.join(`
2931
2928
  `);
2932
2929
  }
2933
- class qs {
2930
+ class Js {
2934
2931
  env;
2935
2932
  effects = {};
2936
2933
  automations = {};
2937
2934
  resolvers = {};
2938
- adapters = {};
2939
2935
  constructor({ env: e = {} } = {}) {
2940
2936
  this.env = e;
2941
2937
  }
@@ -2948,47 +2944,38 @@ class qs {
2948
2944
  resolver(e, t) {
2949
2945
  return this.resolvers[e] = t, this;
2950
2946
  }
2951
- adapter(e, t) {
2952
- return this.adapters[e] = t, this;
2953
- }
2954
2947
  /** @internal Called by Engine.getRemoteData — keeps env encapsulated inside the Runtime. */
2955
2948
  _runResolver(e, t) {
2956
- const s = this.resolvers[e];
2957
- if (!s) throw new Error(`No handler declared for resolver "${e}"`);
2958
- return s(t, this.env);
2959
- }
2960
- /** @internal Called by Engine.useAdapter — keeps handler lookup inside the Runtime. */
2961
- _runAdapter(e, t) {
2962
- const s = this.adapters[e];
2963
- if (!s) throw new Error(`No handler declared for adapter "${e}"`);
2964
- return s(t);
2949
+ const n = this.resolvers[e];
2950
+ if (!n) throw new Error(`No handler declared for resolver "${e}"`);
2951
+ return n(t, this.env);
2965
2952
  }
2966
2953
  }
2967
2954
  class D {
2968
2955
  constructor(e, t) {
2969
2956
  this._data = e, this._zip = t;
2970
- const s = () => this._data;
2957
+ const n = () => this._data;
2971
2958
  this.project = new jt(
2972
2959
  () => this._data.project,
2973
- (i) => {
2974
- this._data.project = i;
2960
+ (o) => {
2961
+ this._data.project = o;
2975
2962
  },
2976
2963
  fe,
2977
- (i, o) => {
2978
- const r = [], d = x("project", i.code, o.deliverableNamingConvention);
2979
- return d && r.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && r.push(`teams["${i.clientId}"] not found`), r;
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;
2980
2967
  },
2981
- s
2982
- ), this.actions = new _t(s), this.adapters = new Bt(s), this.annexes = new Mt(s), this.env = new Ft(s), this.events = new Ct(s), this.effects = new xt(s), this.automations = new Pt(s), this.bimUses = new Jt(s, () => this.workflows), this.disciplines = new Kt(s), this.guides = new qt(s), this.lods = new Wt(s), this.lois = new Gt(s), this.loin = new Xt(s), this.lbsNodes = new Qt(s), this.assetTypes = new Vt(s), this.extensions = new Ht(s), this.roles = new Yt(s), this.members = new es(s), this.milestones = new ts(s), this.objectives = new ss(s), this.phases = new ns(s), this.remoteData = new is(s), this.resolvers = new os(s), this.softwares = new rs(s, () => this.assetTypes), this.standards = new as(s, () => this._zip), this.teams = new ds(s, () => this.members), this.workflows = new cs(s, () => this.members, () => this.teams), this.deliverables = new Ut(s, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Zt(s, () => this.members), this.flags = new zt(s), this.engine = new Cs(
2968
+ n
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(
2983
2970
  () => this._data,
2984
- (i) => this.history.get(i)
2985
- ), this.history = new k(
2986
- s,
2987
- (i) => {
2988
- this._data = i;
2971
+ (o) => this.history.get(o)
2972
+ ), this.history = new $(
2973
+ n,
2974
+ (o) => {
2975
+ this._data = o;
2989
2976
  },
2990
2977
  () => this._zip
2991
- ), this.nomenclature = new Lt(s), this.memory = new q("memory.md", () => this._zip), this.skill = new q("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new q("icon.svg", () => this._zip);
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);
2992
2979
  }
2993
2980
  _data;
2994
2981
  _zip;
@@ -2996,7 +2983,6 @@ class D {
2996
2983
  project;
2997
2984
  // ─── Entities ─────────────────────────────────────────────────────────────
2998
2985
  actions;
2999
- adapters;
3000
2986
  annexes;
3001
2987
  deliverables;
3002
2988
  effects;
@@ -3046,10 +3032,10 @@ class D {
3046
3032
  * fully operational after open(). Idempotent — existing files are untouched.
3047
3033
  */
3048
3034
  static async open(e) {
3049
- const t = await oe.loadAsync(e), s = t.file("bep.json");
3050
- if (!s) throw new Error("Invalid .bep file: missing bep.json");
3051
- const i = await s.async("string"), o = B(JSON.parse(i));
3052
- return await D._initialize(o, t), new D(o, t);
3035
+ const t = await re.loadAsync(e), n = t.file("bep.json");
3036
+ if (!n) throw new Error("Invalid .bep file: missing bep.json");
3037
+ const o = await n.async("string"), i = B(JSON.parse(o));
3038
+ return await D._initialize(i, t), new D(i, t);
3053
3039
  }
3054
3040
  /**
3055
3041
  * Ensures all expected files exist in the zip.
@@ -3064,14 +3050,14 @@ class D {
3064
3050
  */
3065
3051
  static async _initialize(e, t) {
3066
3052
  t.file("memory.md") || t.file("memory.md", ""), t.file("skills/bep-authoring/SKILL.md") || t.file("skills/bep-authoring/SKILL.md", "");
3067
- for (const s of e.standards)
3068
- t.file(s.contentPath) || t.file(s.contentPath, "");
3053
+ for (const n of e.standards)
3054
+ t.file(n.contentPath) || t.file(n.contentPath, "");
3069
3055
  if (!t.file("baseline/bep.json")) {
3070
- const s = JSON.stringify(e, null, 2);
3071
- t.file("baseline/bep.json", s), t.file("changelog/v0.0.json", s);
3072
- for (const i of e.standards) {
3073
- const o = await t.file(i.contentPath).async("string");
3074
- t.file(`baseline/standards/${i.id}.md`, o), t.file(`changelog/standards/${i.id}/v0.0.md`, o);
3056
+ const n = JSON.stringify(e, null, 2);
3057
+ t.file("baseline/bep.json", n), t.file("changelog/v0.0.json", n);
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);
3075
3061
  }
3076
3062
  }
3077
3063
  }
@@ -3105,8 +3091,8 @@ class D {
3105
3091
  flags: [],
3106
3092
  env: [],
3107
3093
  automations: []
3108
- }), s = new oe(), i = JSON.stringify(t, null, 2);
3109
- return s.file("memory.md", ""), s.file("skills/bep-authoring/SKILL.md", ""), s.file("baseline/bep.json", i), s.file("changelog/v0.0.json", i), new D(t, s);
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);
3110
3096
  }
3111
3097
  // ─── Accessors ────────────────────────────────────────────────────────────
3112
3098
  get data() {
@@ -3122,9 +3108,9 @@ class D {
3122
3108
  delete this._data.deliverableNamingConvention;
3123
3109
  return;
3124
3110
  }
3125
- const t = he.parse(e), s = At(this._data, t);
3126
- if (s.length) throw new Error(`Naming convention incompatible with existing data:
3127
- ${s.join(`
3111
+ const t = he.parse(e), n = Tt(this._data, t);
3112
+ if (n.length) throw new Error(`Naming convention incompatible with existing data:
3113
+ ${n.join(`
3128
3114
  `)}`);
3129
3115
  this._data.deliverableNamingConvention = t;
3130
3116
  }
@@ -3139,8 +3125,8 @@ ${s.join(`
3139
3125
  listSkills() {
3140
3126
  const e = /* @__PURE__ */ new Set();
3141
3127
  return this._zip.forEach((t) => {
3142
- const s = t.match(/^skills\/([^/]+)\/SKILL\.md$/);
3143
- s && e.add(s[1]);
3128
+ const n = t.match(/^skills\/([^/]+)\/SKILL\.md$/);
3129
+ n && e.add(n[1]);
3144
3130
  }), [...e];
3145
3131
  }
3146
3132
  /** Returns the SKILL.md content for the given skill, or null if it does not exist. */
@@ -3154,26 +3140,26 @@ ${s.join(`
3154
3140
  }
3155
3141
  /** Returns the names of all resource files for the given skill. */
3156
3142
  listSkillResources(e) {
3157
- const t = `skills/${e}/resources/`, s = [];
3158
- return this._zip.forEach((i) => {
3159
- i.startsWith(t) && i !== t && s.push(i.slice(t.length));
3160
- }), s;
3143
+ const t = `skills/${e}/resources/`, n = [];
3144
+ return this._zip.forEach((o) => {
3145
+ o.startsWith(t) && o !== t && n.push(o.slice(t.length));
3146
+ }), n;
3161
3147
  }
3162
3148
  /** Returns the content of a resource file for the given skill, or null if it does not exist. */
3163
3149
  async getSkillResource(e, t) {
3164
- const s = this._zip.file(`skills/${e}/resources/${t}`);
3165
- return s ? s.async("string") : null;
3150
+ const n = this._zip.file(`skills/${e}/resources/${t}`);
3151
+ return n ? n.async("string") : null;
3166
3152
  }
3167
3153
  /** Writes a resource file for the given skill, creating it if needed. */
3168
- async setSkillResource(e, t, s) {
3169
- this._zip.file(`skills/${e}/resources/${t}`, s);
3154
+ async setSkillResource(e, t, n) {
3155
+ this._zip.file(`skills/${e}/resources/${t}`, n);
3170
3156
  }
3171
3157
  /** Removes a skill's SKILL.md and all its resources from the archive. No-op if not found. */
3172
3158
  removeSkill(e) {
3173
- const t = `skills/${e}/`, s = [];
3174
- this._zip.forEach((i) => {
3175
- i.startsWith(t) && s.push(i);
3176
- }), s.forEach((i) => this._zip.remove(i));
3159
+ const t = `skills/${e}/`, n = [];
3160
+ this._zip.forEach((o) => {
3161
+ o.startsWith(t) && n.push(o);
3162
+ }), n.forEach((o) => this._zip.remove(o));
3177
3163
  }
3178
3164
  /** Removes a single resource file from a skill. No-op if not found. */
3179
3165
  removeSkillResource(e, t) {
@@ -3191,14 +3177,13 @@ ${s.join(`
3191
3177
  */
3192
3178
  generateRuntimeTypes() {
3193
3179
  const e = (f) => f === "url" ? "string" : f, t = (f) => ` /** ${f} */
3194
- `, s = (f) => `{ ${f.map((p) => `${p.key}${p.required ? "" : "?"}: ${e(p.type)}`).join("; ")} }`, i = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${s(f.payload)}) => void`, o = (f) => {
3195
- const p = f.payload && f.payload.length > 0 ? `payload: ${s(f.payload)}` : "", g = f.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${f.output.map((h) => `${h.key}${h.required ? "" : "?"}: ${e(h.type)}`).join("; ")} }`;
3196
- return `(${p}) => ${g}`;
3197
- }, r = (f) => f.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${f.envKeys.map((g) => `${g}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((f) => `${t(f.description)} '${f.id}': ${i(f)}`).join(`
3198
- `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${o(f)}`).join(`
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) => {
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("; ")} }`;
3182
+ return `(${m}) => ${p}`;
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(`
3199
3185
  `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((f) => `${t(f.description)} '${f.id}': ${r(f)}`).join(`
3200
- `) : " [key: string]: (url: string) => unknown", u = this._data.adapters.length ? this._data.adapters.map((f) => `${t(f.description)} '${f.id}': (data: unknown) => unknown`).join(`
3201
- `) : " [key: string]: (data: unknown) => unknown", m = this._data.env.length ? this._data.env.map((f) => `${t(f.description)} ${f.key}: string`).join(`
3186
+ `) : " [key: string]: (url: string) => unknown", u = this._data.env.length ? this._data.env.map((f) => `${t(f.description)} ${f.key}: string`).join(`
3202
3187
  `) : " [key: string]: string";
3203
3188
  return [
3204
3189
  "// Generated by bep.generateRuntimeTypes() — do not edit manually",
@@ -3221,16 +3206,10 @@ ${s.join(`
3221
3206
  c,
3222
3207
  "}",
3223
3208
  "",
3224
- "// ─── Adapters ─────────────────────────────────────────────────────────────────",
3225
- "",
3226
- "export interface BepAdapters {",
3227
- u,
3228
- "}",
3229
- "",
3230
3209
  "// ─── Env ──────────────────────────────────────────────────────────────────────",
3231
3210
  "",
3232
3211
  "export interface BepEnv {",
3233
- m,
3212
+ u,
3234
3213
  "}",
3235
3214
  "",
3236
3215
  "// ─── Combined ─────────────────────────────────────────────────────────────────",
@@ -3239,7 +3218,6 @@ ${s.join(`
3239
3218
  " effects: BepEffects",
3240
3219
  " automations: BepAutomations",
3241
3220
  " resolvers: BepResolvers",
3242
- " adapters: BepAdapters",
3243
3221
  " env: BepEnv",
3244
3222
  "}",
3245
3223
  ""
@@ -3258,124 +3236,122 @@ ${s.join(`
3258
3236
  }
3259
3237
  export {
3260
3238
  ke as ActionSchema,
3261
- _t as Actions,
3262
- ze as AdapterSchema,
3263
- Bt as Adapters,
3239
+ Ot as Actions,
3264
3240
  Oe as AnnexSchema,
3265
- Qe as AnnexType,
3266
- Mt as Annexes,
3241
+ Ye as AnnexType,
3242
+ _t as Annexes,
3267
3243
  Ie as AssetTypeSchema,
3268
- Vt as AssetTypes,
3269
- Pt as Automations,
3270
- zs as BEPSchema,
3271
- re as BEPVersionBase,
3272
- kt as BEPVersionSchema,
3244
+ Xt as AssetTypes,
3245
+ Mt as Automations,
3246
+ Ls as BEPSchema,
3247
+ ae as BEPVersionBase,
3248
+ St as BEPVersionSchema,
3273
3249
  Se as BIMUseSchema,
3274
- Jt as BIMUses,
3250
+ zt as BIMUses,
3275
3251
  D as Bep,
3276
- Zs as ChangelogSchema,
3277
- $t as DEFAULT_DELIMITER,
3278
- Rt as DEFAULT_TOKEN_PATTERN,
3279
- St as DeliverableBaseSchema,
3252
+ Us as ChangelogSchema,
3253
+ kt as DEFAULT_DELIMITER,
3254
+ $t as DEFAULT_TOKEN_PATTERN,
3255
+ Nt as DeliverableBaseSchema,
3280
3256
  De as DeliverableSchema,
3281
- Ut as Deliverables,
3282
- we as DisciplineSchema,
3283
- Kt as Disciplines,
3284
- gt as EdgeGuardSchema,
3285
- xt as Effects,
3286
- Cs as Engine,
3287
- y as Entity,
3288
- Ft as Env,
3257
+ Dt as Deliverables,
3258
+ be as DisciplineSchema,
3259
+ Zt as Disciplines,
3260
+ ht as EdgeGuardSchema,
3261
+ Bt as Effects,
3262
+ Ps as Engine,
3263
+ w as Entity,
3264
+ xt as Env,
3289
3265
  Le as EnvVarSchema,
3290
- Ct as Events,
3266
+ Pt as Events,
3291
3267
  ve as ExtensionSchema,
3292
- Ht as Extensions,
3293
- Nt as FlagBaseSchema,
3294
- nt as FlagEntityType,
3268
+ Gt as Extensions,
3269
+ Et as FlagBaseSchema,
3270
+ st as FlagEntityType,
3295
3271
  Ce as FlagSchema,
3296
- st as FlagSeverity,
3297
- zt as Flags,
3298
- mt as FlowAutomationNodeSchema,
3272
+ tt as FlagSeverity,
3273
+ Lt as Flags,
3274
+ ut as FlowAutomationNodeSchema,
3299
3275
  Te as FlowAutomationSchema,
3300
- bt as FlowDecisionEdgeSchema,
3301
- ut as FlowDecisionNodeSchema,
3302
- It as FlowDiagramSchema,
3276
+ yt as FlowDecisionEdgeSchema,
3277
+ ft as FlowDecisionNodeSchema,
3278
+ vt as FlowDiagramSchema,
3303
3279
  wt as FlowDirectEdgeSchema,
3304
- tt as FlowDirection,
3305
- vt as FlowEdgeSchema,
3280
+ et as FlowDirection,
3281
+ bt as FlowEdgeSchema,
3306
3282
  Re as FlowEffectSchema,
3307
- ft as FlowEndNodeSchema,
3283
+ ct as FlowEndNodeSchema,
3308
3284
  $e as FlowEventSchema,
3309
- ht as FlowNodeSchema,
3285
+ pt as FlowNodeSchema,
3310
3286
  L as FlowPayloadFieldSchema,
3311
- pt as FlowProcessNodeSchema,
3312
- ct as FlowStartNodeSchema,
3313
- yt as FlowTransitionEdgeSchema,
3287
+ mt as FlowProcessNodeSchema,
3288
+ lt as FlowStartNodeSchema,
3289
+ gt as FlowTransitionEdgeSchema,
3314
3290
  _e as GuideSchema,
3315
- qt as Guides,
3316
- k as History,
3317
- Ye as ISORole,
3318
- at as LBSNodeBaseSchema,
3319
- be as LBSNodeSchema,
3320
- et as LBSNodeType,
3321
- Qt as LBSNodes,
3291
+ Jt as Guides,
3292
+ $ as History,
3293
+ He as ISORole,
3294
+ rt as LBSNodeBaseSchema,
3295
+ we as LBSNodeSchema,
3296
+ Qe as LBSNodeType,
3297
+ Ht as LBSNodes,
3322
3298
  Me as LODSchema,
3323
- Wt as LODs,
3324
- Xt as LOINEntity,
3325
- Et as LOINMilestoneSchema,
3299
+ Kt as LODs,
3300
+ Wt as LOINEntity,
3301
+ It as LOINMilestoneSchema,
3326
3302
  Pe as LOINSchema,
3327
3303
  xe as LOISchema,
3328
- Gt as LOIs,
3304
+ qt as LOIs,
3329
3305
  me as MemberSchema,
3330
- es as Members,
3331
- Ps as MemoryStorage,
3306
+ Yt as Members,
3307
+ Ms as MemoryStorage,
3332
3308
  ye as MilestoneSchema,
3333
- ts as Milestones,
3309
+ Qt as Milestones,
3334
3310
  he as NamingConventionSchema,
3335
- rt as NamingSegmentSchema,
3311
+ it as NamingSegmentSchema,
3336
3312
  ot as NamingTokenSchema,
3337
- dt as NodeTimeoutSchema,
3338
- Us as NodeType,
3339
- Lt as Nomenclature,
3313
+ at as NodeTimeoutSchema,
3314
+ Ds as NodeType,
3315
+ Ct as Nomenclature,
3340
3316
  Fe as NoteSchema,
3341
- Zt as Notes,
3317
+ Ut as Notes,
3342
3318
  Ne as ObjectiveSchema,
3343
- ss as Objectives,
3319
+ es as Objectives,
3344
3320
  ge as PhaseSchema,
3345
- ns as Phases,
3321
+ ts as Phases,
3346
3322
  fe as ProjectSchema,
3347
- is as RemoteDataEntity,
3348
- Ze as RemoteDataSchema,
3323
+ ss as RemoteDataEntity,
3324
+ ze as RemoteDataSchema,
3349
3325
  Ue as ResolverSchema,
3350
- os as Resolvers,
3326
+ ns as Resolvers,
3351
3327
  ue as RoleSchema,
3352
- Yt as Roles,
3353
- qs as Runtime,
3328
+ Vt as Roles,
3329
+ Js as Runtime,
3354
3330
  jt as Singleton,
3355
3331
  Ee as SoftwareSchema,
3356
- rs as Softwares,
3332
+ os as Softwares,
3357
3333
  Be as StandardSchema,
3358
- as as Standards,
3359
- it as TeamBaseSchema,
3334
+ is as Standards,
3335
+ nt as TeamBaseSchema,
3360
3336
  pe as TeamSchema,
3361
- ds as Teams,
3337
+ rs as Teams,
3362
3338
  q as TextFile,
3363
- je as WorkflowSchema,
3364
- cs as Workflows,
3365
- ks as arrayDefs,
3366
- We as buildCodeMap,
3367
- W as buildConsecutivoMap,
3339
+ Ae as WorkflowSchema,
3340
+ ds as Workflows,
3341
+ Ns as arrayDefs,
3342
+ qe as buildCodeMap,
3343
+ X as buildConsecutivoMap,
3368
3344
  C as buildParentMap,
3369
- Rs as diffBep,
3370
- $s as diffEntities,
3371
- Ks as flowDiagramToMermaid,
3372
- qe as getNomenCode,
3373
- te as getRootIds,
3374
- Tt as getTokenPattern,
3375
- Js as groupRaciRows,
3345
+ ks as diffBep,
3346
+ Ss as diffEntities,
3347
+ Zs as flowDiagramToMermaid,
3348
+ Ke as getNomenCode,
3349
+ se as getRootIds,
3350
+ Rt as getTokenPattern,
3351
+ zs as groupRaciRows,
3376
3352
  B as normalizeBep,
3377
- Ke as resolveLBSCodes,
3378
- At as validateAllTokens,
3379
- Dt as validateLBS,
3353
+ Je as resolveLBSCodes,
3354
+ Tt as validateAllTokens,
3355
+ Ft as validateLBS,
3380
3356
  x as validateTokenValue
3381
3357
  };