@blue-labs/document-processor 2.0.0-rc.0 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,148 +1,148 @@
1
- import { blueIds as p, ContractSchema as Ye, ChannelSchema as Ze, HandlerSchema as Xe, MarkerSchema as et, DocumentUpdateChannelSchema as tt, EmbeddedNodeChannelSchema as nt, LifecycleEventChannelSchema as rt, TriggeredEventChannelSchema as it, ChannelEventCheckpointSchema as st, ProcessingInitializedMarkerSchema as ot, ProcessEmbeddedSchema as at, ProcessingTerminatedMarkerSchema as ct, repository as lt } from "@blue-repository/core";
2
- import { getQuickJS as ut } from "quickjs-emscripten";
3
- import { BlueNode as d, blueNodeField as x, withTypeBlueId as dt, Blue as ht, MergingProcessors as v } from "@blue-labs/language";
4
- import ue from "picomatch";
1
+ import { blueIds as p, ContractSchema as Xe, ChannelSchema as et, HandlerSchema as tt, MarkerSchema as nt, DocumentUpdateChannelSchema as rt, EmbeddedNodeChannelSchema as it, LifecycleEventChannelSchema as st, TriggeredEventChannelSchema as ot, ChannelEventCheckpointSchema as at, ProcessingInitializedMarkerSchema as ct, ProcessEmbeddedSchema as lt, ProcessingTerminatedMarkerSchema as ut, repository as dt } from "@blue-repository/core";
2
+ import { getQuickJS as ht } from "quickjs-emscripten";
3
+ import { BlueNode as d, blueNodeField as z, withTypeBlueId as ft, Blue as pt, MergingProcessors as R } from "@blue-labs/language";
4
+ import de from "picomatch";
5
5
  import { z as S, ZodError as Te } from "zod";
6
- import { TimelineChannelSchema as ft, OperationSchema as $, SequentialWorkflowSchema as pt, SequentialWorkflowOperationSchema as mt, TimelineEntrySchema as P, blueIds as I, TriggerEventSchema as de, JavaScriptCodeSchema as he, UpdateDocumentSchema as fe, OperationRequestSchema as Z, repository as gt } from "@blue-repository/conversation";
7
- import { MyOSTimelineChannelSchema as Et, blueIds as yt, MyOSTimelineEntrySchema as pe, repository as wt } from "@blue-repository/myos";
8
- import { isNullable as X } from "@blue-labs/shared-utils";
9
- function bt(s) {
10
- return { ok: !0, value: s };
6
+ import { TimelineChannelSchema as mt, OperationSchema as x, SequentialWorkflowSchema as gt, SequentialWorkflowOperationSchema as Et, TimelineEntrySchema as k, blueIds as v, TriggerEventSchema as he, JavaScriptCodeSchema as fe, UpdateDocumentSchema as pe, OperationRequestSchema as ee, repository as yt } from "@blue-repository/conversation";
7
+ import { MyOSTimelineChannelSchema as wt, blueIds as bt, MyOSTimelineEntrySchema as me, repository as St } from "@blue-repository/myos";
8
+ import { isNullable as te } from "@blue-labs/shared-utils";
9
+ function Ct(i) {
10
+ return { ok: !0, value: i };
11
11
  }
12
- function St(s) {
13
- return { ok: !1, error: s };
12
+ function kt(i) {
13
+ return { ok: !1, error: i };
14
14
  }
15
- function Ur(s) {
16
- return s.ok;
15
+ function jr(i) {
16
+ return i.ok;
17
17
  }
18
- function Vr(s) {
19
- return !s.ok;
18
+ function Jr(i) {
19
+ return !i.ok;
20
20
  }
21
- function Hr(s, e) {
22
- return s.ok ? bt(e(s.value)) : s;
21
+ function Qr(i, e) {
22
+ return i.ok ? Ct(e(i.value)) : i;
23
23
  }
24
- function Kr(s, e) {
25
- return s.ok ? s : St(e(s.error));
24
+ function Yr(i, e) {
25
+ return i.ok ? i : kt(e(i.error));
26
26
  }
27
- function Wr(s, e) {
28
- return s.ok ? e(s.value) : s;
27
+ function Zr(i, e) {
28
+ return i.ok ? e(i.value) : i;
29
29
  }
30
- function Gr(s, e) {
31
- return s.ok ? s.value : e;
30
+ function Xr(i, e) {
31
+ return i.ok ? i.value : e;
32
32
  }
33
- function qr(s, e) {
34
- return s.ok ? s.value : e(s.error);
33
+ function ei(i, e) {
34
+ return i.ok ? i.value : e(i.error);
35
35
  }
36
- function Jr(s, e) {
37
- return s.ok ? e.ok(s.value) : e.err(s.error);
36
+ function ti(i, e) {
37
+ return i.ok ? e.ok(i.value) : e.err(i.error);
38
38
  }
39
39
  const g = {
40
- capabilityFailure(s, e, t) {
41
- return { kind: "CapabilityFailure", capability: s, reason: e, details: t };
40
+ capabilityFailure(i, e, t) {
41
+ return { kind: "CapabilityFailure", capability: i, reason: e, details: t };
42
42
  },
43
- boundaryViolation(s, e) {
44
- return { kind: "BoundaryViolation", pointer: s, reason: e };
43
+ boundaryViolation(i, e) {
44
+ return { kind: "BoundaryViolation", pointer: i, reason: e };
45
45
  },
46
- runtimeFatal(s, e) {
47
- return { kind: "RuntimeFatal", reason: s, cause: e };
46
+ runtimeFatal(i, e) {
47
+ return { kind: "RuntimeFatal", reason: i, cause: e };
48
48
  },
49
- invalidContract(s, e, t, n) {
50
- return { kind: "InvalidContract", contractId: s, reason: e, pointer: t, details: n };
49
+ invalidContract(i, e, t, n) {
50
+ return { kind: "InvalidContract", contractId: i, reason: e, pointer: t, details: n };
51
51
  },
52
- illegalState(s) {
53
- return { kind: "IllegalState", reason: s };
52
+ illegalState(i) {
53
+ return { kind: "IllegalState", reason: i };
54
54
  },
55
- unsupported(s, e) {
56
- return { kind: "UnsupportedOp", operation: s, reason: e };
55
+ unsupported(i, e) {
56
+ return { kind: "UnsupportedOp", operation: i, reason: e };
57
57
  }
58
58
  };
59
- function Ct(s) {
60
- return Object.freeze([...s]);
59
+ function It(i) {
60
+ return Object.freeze([...i]);
61
61
  }
62
- const kt = {
63
- of(s, e, t) {
62
+ const vt = {
63
+ of(i, e, t) {
64
64
  return {
65
- document: s,
66
- triggeredEvents: Ct(e),
65
+ document: i,
66
+ triggeredEvents: It(e),
67
67
  totalGas: t,
68
68
  capabilityFailure: !1,
69
69
  failureReason: null
70
70
  };
71
71
  },
72
- capabilityFailure(s, e) {
72
+ capabilityFailure(i, e) {
73
73
  return {
74
- document: s,
74
+ document: i,
75
75
  triggeredEvents: Object.freeze([]),
76
76
  totalGas: 0,
77
77
  capabilityFailure: !0,
78
78
  failureReason: e ?? null
79
79
  };
80
80
  }
81
- }, Re = kt, It = [
81
+ }, Pe = vt, Rt = [
82
82
  "embedded",
83
83
  "initialized",
84
84
  "terminated",
85
85
  "checkpoint"
86
- ], vt = [
86
+ ], Tt = [
87
87
  p["Document Update Channel"],
88
88
  p["Triggered Event Channel"],
89
89
  p["Lifecycle Event Channel"],
90
90
  p["Embedded Node Channel"]
91
- ], Pe = "embedded", Me = "initialized", Ne = "terminated", k = "checkpoint", re = new Set(
92
- It
93
- ), Ae = new Set(vt);
94
- function Tt(s) {
95
- return s != null && re.has(s);
96
- }
97
- function ie(s) {
98
- return s != null && Ae.has(
99
- s
91
+ ], Ne = "embedded", Me = "initialized", Ae = "terminated", I = "checkpoint", ie = new Set(
92
+ Rt
93
+ ), Oe = new Set(Tt);
94
+ function Pt(i) {
95
+ return i != null && ie.has(i);
96
+ }
97
+ function se(i) {
98
+ return i != null && Oe.has(
99
+ i
100
100
  );
101
101
  }
102
- const jr = {
103
- KEY_EMBEDDED: Pe,
102
+ const ni = {
103
+ KEY_EMBEDDED: Ne,
104
104
  KEY_INITIALIZED: Me,
105
- KEY_TERMINATED: Ne,
106
- KEY_CHECKPOINT: k,
107
- RESERVED_CONTRACT_KEYS: re,
108
- PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: Ae,
109
- isReservedContractKey: Tt,
110
- isProcessorManagedChannelBlueId: ie
111
- }, A = "/contracts", ee = `${A}/${Me}`, De = `${A}/${Ne}`, Rt = `${A}/${Pe}`, Oe = `${A}/${k}`, Be = "/lastEvents", Le = "/lastSignatures";
112
- function q(s) {
113
- return `${A}/${s}`;
114
- }
115
- function _e(s, e) {
116
- return `${q(s)}${Be}/${e}`;
117
- }
118
- function $e(s, e) {
119
- return `${q(s)}${Le}/${e}`;
120
- }
121
- const Qr = {
105
+ KEY_TERMINATED: Ae,
106
+ KEY_CHECKPOINT: I,
107
+ RESERVED_CONTRACT_KEYS: ie,
108
+ PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: Oe,
109
+ isReservedContractKey: Pt,
110
+ isProcessorManagedChannelBlueId: se
111
+ }, A = "/contracts", ne = `${A}/${Me}`, De = `${A}/${Ae}`, Nt = `${A}/${Ne}`, Be = `${A}/${I}`, Le = "/lastEvents", _e = "/lastSignatures";
112
+ function J(i) {
113
+ return `${A}/${i}`;
114
+ }
115
+ function $e(i, e) {
116
+ return `${J(i)}${Le}/${e}`;
117
+ }
118
+ function xe(i, e) {
119
+ return `${J(i)}${_e}/${e}`;
120
+ }
121
+ const ri = {
122
122
  RELATIVE_CONTRACTS: A,
123
- RELATIVE_INITIALIZED: ee,
123
+ RELATIVE_INITIALIZED: ne,
124
124
  RELATIVE_TERMINATED: De,
125
- RELATIVE_EMBEDDED: Rt,
126
- RELATIVE_CHECKPOINT: Oe,
127
- LAST_EVENTS_SUFFIX: Be,
128
- LAST_SIGNATURES_SUFFIX: Le,
129
- relativeContractsEntry: q,
130
- relativeCheckpointLastEvent: _e,
131
- relativeCheckpointLastSignature: $e
125
+ RELATIVE_EMBEDDED: Nt,
126
+ RELATIVE_CHECKPOINT: Be,
127
+ LAST_EVENTS_SUFFIX: Le,
128
+ LAST_SIGNATURES_SUFFIX: _e,
129
+ relativeContractsEntry: J,
130
+ relativeCheckpointLastEvent: $e,
131
+ relativeCheckpointLastSignature: xe
132
132
  };
133
- function xe(s) {
134
- return s == null || s.length === 0;
133
+ function Fe(i) {
134
+ return i == null || i.length === 0;
135
135
  }
136
- function y(s) {
137
- return xe(s) ? "/" : s.startsWith("/") ? s : `/${s}`;
136
+ function y(i) {
137
+ return Fe(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
138
138
  }
139
- function b(s) {
140
- return xe(s) ? "/" : s.startsWith("/") ? s : `/${s}`;
139
+ function b(i) {
140
+ return Fe(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
141
141
  }
142
- function me(s) {
143
- if (s == null)
142
+ function ge(i) {
143
+ if (i == null)
144
144
  return "";
145
- let e = s.trim();
145
+ let e = i.trim();
146
146
  if (e.length === 0)
147
147
  return "";
148
148
  for (; e.startsWith("/"); )
@@ -151,16 +151,16 @@ function me(s) {
151
151
  e = e.substring(0, e.length - 1);
152
152
  return e;
153
153
  }
154
- function Yr(s, e) {
155
- const t = me(s), n = me(e);
154
+ function ii(i, e) {
155
+ const t = ge(i), n = ge(e);
156
156
  return t.length === 0 && n.length === 0 ? "/" : t.length === 0 ? `/${n}` : n.length === 0 ? `/${t}` : `/${t}/${n}`;
157
157
  }
158
- function w(s, e) {
159
- const t = y(s), n = b(e);
158
+ function w(i, e) {
159
+ const t = y(i), n = b(e);
160
160
  return t === "/" ? n : n === "/" || n.length === 1 ? t : `${t}${n}`;
161
161
  }
162
- function Pt(s, e) {
163
- const t = y(s), n = b(e);
162
+ function Mt(i, e) {
163
+ const t = y(i), n = b(e);
164
164
  if (t === "/" || !n.startsWith(t))
165
165
  return n;
166
166
  if (n.length === t.length)
@@ -168,49 +168,103 @@ function Pt(s, e) {
168
168
  const r = n.substring(t.length);
169
169
  return r.length === 0 ? "/" : r.startsWith("/") ? r : `/${r}`;
170
170
  }
171
- function Mt(s) {
172
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
171
+ function At(i) {
172
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
173
173
  }
174
- var j, ge;
175
- function Nt() {
176
- return ge || (ge = 1, j = function s(e) {
174
+ var Y, Ee;
175
+ function Ot() {
176
+ return Ee || (Ee = 1, Y = function i(e) {
177
177
  if (typeof e == "number" && isNaN(e))
178
178
  throw new Error("NaN is not allowed");
179
179
  if (typeof e == "number" && !isFinite(e))
180
180
  throw new Error("Infinity is not allowed");
181
- return e === null || typeof e != "object" ? JSON.stringify(e) : e.toJSON instanceof Function ? s(e.toJSON()) : Array.isArray(e) ? `[${e.reduce((r, i, o) => `${r}${o === 0 ? "" : ","}${s(i === void 0 || typeof i == "symbol" ? null : i)}`, "")}]` : `{${Object.keys(e).sort().reduce((n, r) => {
181
+ return e === null || typeof e != "object" ? JSON.stringify(e) : e.toJSON instanceof Function ? i(e.toJSON()) : Array.isArray(e) ? `[${e.reduce((r, s, o) => `${r}${o === 0 ? "" : ","}${i(s === void 0 || typeof s == "symbol" ? null : s)}`, "")}]` : `{${Object.keys(e).sort().reduce((n, r) => {
182
182
  if (e[r] === void 0 || typeof e[r] == "symbol")
183
183
  return n;
184
- const i = n.length === 0 ? "" : ",";
185
- return `${n}${i}${s(r)}:${s(e[r])}`;
184
+ const s = n.length === 0 ? "" : ",";
185
+ return `${n}${s}${i(r)}:${i(e[r])}`;
186
186
  }, "")}}`;
187
- }), j;
187
+ }), Y;
188
188
  }
189
- var At = Nt();
190
- const Dt = /* @__PURE__ */ Mt(At);
191
- function Ot(s, e) {
192
- return s.nodeToJson(e, "official");
189
+ var Dt = Ot();
190
+ const Bt = /* @__PURE__ */ At(Dt);
191
+ function Lt(i, e) {
192
+ return i.nodeToJson(e, "official");
193
193
  }
194
- function Bt(s, e) {
195
- const t = Ot(s, e);
196
- return Dt(t);
194
+ function _t(i, e) {
195
+ const t = Lt(i, e);
196
+ return Bt(t);
197
197
  }
198
- function ze(s, e) {
199
- return e ? Bt(s, e) : null;
198
+ function ze(i, e) {
199
+ return e ? _t(i, e) : null;
200
200
  }
201
- function Ee(s, e) {
202
- const t = ze(s, e);
201
+ function ye(i, e) {
202
+ const t = ze(i, e);
203
203
  return t == null ? 0 : new TextEncoder().encode(t).length;
204
204
  }
205
- const Lt = 500, _t = 32 * 1024 * 1024;
206
- class se {
205
+ function He(i) {
206
+ return typeof i == "object" && i !== null && !Array.isArray(i);
207
+ }
208
+ function $t(i) {
209
+ return i.replace(/~1/g, "/").replace(/~0/g, "~");
210
+ }
211
+ function xt(i) {
212
+ if (i.length === 0 || !/^\d+$/.test(i))
213
+ return !1;
214
+ const e = Number(i);
215
+ return Number.isSafeInteger(e);
216
+ }
217
+ function _(i, e = !0) {
218
+ if (Array.isArray(i))
219
+ return e ? i.map((r) => _(r, !0)) : i.slice();
220
+ if (!He(i))
221
+ return i;
222
+ if (Object.prototype.hasOwnProperty.call(i, "value")) {
223
+ const r = i.value;
224
+ return e ? _(r, !0) : r;
225
+ }
226
+ const t = i.items;
227
+ if (Array.isArray(t))
228
+ return e ? t.map((r) => _(r, !0)) : t.slice();
229
+ const n = {};
230
+ for (const [r, s] of Object.entries(i))
231
+ n[r] = e ? _(s, !0) : s;
232
+ return n;
233
+ }
234
+ function Ft(i, e) {
235
+ if (e === "")
236
+ return i;
237
+ if (!e.startsWith("/"))
238
+ throw new TypeError('JSON pointer must start with "/"');
239
+ const t = e.split("/").slice(1).map((r) => $t(r));
240
+ let n = i;
241
+ for (const r of t) {
242
+ if (n == null)
243
+ return;
244
+ if (Array.isArray(n)) {
245
+ if (!xt(r))
246
+ return;
247
+ const s = Number(r);
248
+ n = n[s];
249
+ continue;
250
+ }
251
+ if (He(n)) {
252
+ n = n[r];
253
+ continue;
254
+ }
255
+ return;
256
+ }
257
+ return n;
258
+ }
259
+ const zt = 500, Ht = 32 * 1024 * 1024;
260
+ class oe {
207
261
  modulePromise;
208
262
  moduleInstance;
209
263
  async evaluate({
210
264
  code: e,
211
265
  bindings: t,
212
- timeout: n = Lt,
213
- memoryLimit: r = _t
266
+ timeout: n = zt,
267
+ memoryLimit: r = Ht
214
268
  }) {
215
269
  const o = (await this.ensureModule()).newRuntime();
216
270
  o.setMemoryLimit(r);
@@ -218,7 +272,7 @@ class se {
218
272
  a !== void 0 && o.setInterruptHandler(() => Date.now() > a);
219
273
  const c = o.newContext();
220
274
  try {
221
- this.installConsole(c), this.installDeterministicGlobals(c), this.installBindings(c, t);
275
+ this.installConsole(c), this.installDeterministicGlobals(c), this.installCanonNamespace(c), this.installBindings(c, t);
222
276
  const l = this.wrapCode(e), u = c.evalCode(l), h = c.unwrapResult(u);
223
277
  let f = null;
224
278
  try {
@@ -236,7 +290,7 @@ class se {
236
290
  }
237
291
  }
238
292
  async ensureModule() {
239
- return this.moduleInstance ? this.moduleInstance : (this.modulePromise || (this.modulePromise = ut().then((e) => (this.moduleInstance = e, e))), this.modulePromise);
293
+ return this.moduleInstance ? this.moduleInstance : (this.modulePromise || (this.modulePromise = ht().then((e) => (this.moduleInstance = e, e))), this.modulePromise);
240
294
  }
241
295
  wrapCode(e) {
242
296
  return `(async () => {
@@ -247,10 +301,10 @@ ${e}
247
301
  e.newObject().consume((t) => {
248
302
  const n = ["log", "info", "warn", "error"];
249
303
  for (const r of n) {
250
- const i = console[r] ?? console.log;
304
+ const s = console[r] ?? console.log;
251
305
  e.newFunction(r, (...o) => {
252
306
  const a = o.map((c) => e.dump(c));
253
- return i.apply(console, a), e.undefined;
307
+ return s.apply(console, a), e.undefined;
254
308
  }).consume((o) => e.setProp(t, r, o));
255
309
  }
256
310
  e.setProp(e.global, "console", t);
@@ -259,28 +313,93 @@ ${e}
259
313
  installDeterministicGlobals(e) {
260
314
  e.setProp(e.global, "Date", e.undefined.dup());
261
315
  }
316
+ installCanonNamespace(e) {
317
+ e.newObject().consume((t) => {
318
+ e.newFunction("unwrap", (...n) => {
319
+ try {
320
+ const [r, s] = n, o = r !== void 0 ? e.dump(r) : void 0, a = s === void 0 ? !0 : !!e.dump(s), c = _(o, a);
321
+ return this.createReturnHandle(e, c);
322
+ } catch (r) {
323
+ const s = r instanceof Error ? r.message : String(r);
324
+ return e.newError(s);
325
+ }
326
+ }).consume((n) => e.setProp(t, "unwrap", n)), e.newFunction("at", (...n) => {
327
+ try {
328
+ const [r, s] = n, o = r !== void 0 ? e.dump(r) : void 0;
329
+ if (s === void 0)
330
+ throw new TypeError(
331
+ "canon.at(target, pointer) requires a pointer argument"
332
+ );
333
+ const a = e.dump(s);
334
+ if (typeof a != "string")
335
+ throw new TypeError("canon.at pointer must be a string");
336
+ const c = Ft(o, a);
337
+ return this.createReturnHandle(e, c);
338
+ } catch (r) {
339
+ const s = r instanceof Error ? r.message : String(r);
340
+ return e.newError(s);
341
+ }
342
+ }).consume((n) => e.setProp(t, "at", n)), e.setProp(e.global, "canon", t);
343
+ });
344
+ }
262
345
  installBindings(e, t) {
263
346
  if (t)
264
347
  for (const [n, r] of Object.entries(t))
265
- typeof r == "function" ? e.newFunction(
348
+ typeof r == "function" ? this.createFunctionHandle(
349
+ e,
266
350
  n,
267
- (...o) => {
268
- try {
269
- const a = o.map((l) => e.dump(l)), c = r(...a);
270
- if (c instanceof Promise)
271
- throw new TypeError("Async bindings are not supported");
272
- return this.createReturnHandle(e, c);
273
- } catch (a) {
274
- const c = a instanceof Error ? a.message : String(a);
275
- return e.newError(c);
276
- }
277
- }
351
+ r
278
352
  ).consume(
279
353
  (o) => e.setProp(e.global, n, o)
280
354
  ) : r !== void 0 && this.createOwnedHandle(e, r).consume(
281
355
  (o) => e.setProp(e.global, n, o)
282
356
  );
283
357
  }
358
+ createFunctionHandle(e, t, n) {
359
+ const r = e.newFunction(
360
+ t,
361
+ (...s) => {
362
+ try {
363
+ const o = s.map((c) => e.dump(c)), a = n(...o);
364
+ if (a instanceof Promise)
365
+ throw new TypeError("Async bindings are not supported");
366
+ return this.createReturnHandle(e, a);
367
+ } catch (o) {
368
+ const a = o instanceof Error ? o.message : String(o);
369
+ return e.newError(a);
370
+ }
371
+ }
372
+ );
373
+ return this.applyFunctionProperties(e, r, n), r;
374
+ }
375
+ /**
376
+ * Copies enumerable properties from a host function onto the QuickJS handle.
377
+ * Nested functions (e.g. `document.canonical = () => {}`) are recursively wrapped
378
+ * so they stay callable inside QuickJS; plain values are serialized via
379
+ * `createOwnedHandle`. This preserves helper namespaces on binding functions.
380
+ */
381
+ applyFunctionProperties(e, t, n) {
382
+ if (!(n === null || typeof n != "object" && typeof n != "function"))
383
+ for (const [r, s] of Object.entries(
384
+ n
385
+ )) {
386
+ if (s === void 0)
387
+ continue;
388
+ if (typeof s == "function") {
389
+ this.createFunctionHandle(
390
+ e,
391
+ r,
392
+ s
393
+ ).consume(
394
+ (c) => e.setProp(t, r, c)
395
+ );
396
+ continue;
397
+ }
398
+ this.createOwnedHandle(e, s).consume(
399
+ (a) => e.setProp(t, r, a)
400
+ );
401
+ }
402
+ }
284
403
  createOwnedHandle(e, t) {
285
404
  if (t === void 0)
286
405
  return e.undefined.dup();
@@ -330,12 +449,12 @@ ${e}
330
449
  );
331
450
  }
332
451
  async resolveHandle(e, t, n, r) {
333
- let i = n;
452
+ let s = n;
334
453
  for (; ; ) {
335
- const o = e.getPromiseState(i);
454
+ const o = e.getPromiseState(s);
336
455
  if (o.type === "pending") {
337
456
  if (r !== void 0 && Date.now() > r)
338
- throw i.dispose(), new Error("QuickJS execution timed out while awaiting Promise");
457
+ throw s.dispose(), new Error("QuickJS execution timed out while awaiting Promise");
339
458
  const a = t.executePendingJobs();
340
459
  let c = 0;
341
460
  try {
@@ -345,7 +464,7 @@ ${e}
345
464
  }
346
465
  if (c === 0) {
347
466
  if (r !== void 0 && Date.now() > r)
348
- throw i.dispose(), new Error(
467
+ throw s.dispose(), new Error(
349
468
  "QuickJS execution timed out while awaiting Promise"
350
469
  );
351
470
  await new Promise((l) => setTimeout(l, 0));
@@ -354,8 +473,8 @@ ${e}
354
473
  }
355
474
  if (o.type === "fulfilled") {
356
475
  if (o.notAPromise)
357
- return i;
358
- i.dispose(), i = o.value;
476
+ return s;
477
+ s.dispose(), s = o.value;
359
478
  continue;
360
479
  }
361
480
  if (o.type === "rejected")
@@ -367,50 +486,50 @@ ${e}
367
486
  typeof a == "string" ? a : JSON.stringify(a)
368
487
  );
369
488
  } finally {
370
- o.error.dispose(), i.dispose();
489
+ o.error.dispose(), s.dispose();
371
490
  }
372
491
  }
373
492
  }
374
493
  }
375
- const ye = 120;
376
- function $t(s) {
377
- return s.length <= ye ? s : `${s.slice(0, ye - 3)}...`;
494
+ const we = 120;
495
+ function Ut(i) {
496
+ return i.length <= we ? i : `${i.slice(0, we - 3)}...`;
378
497
  }
379
- class Fe extends Error {
498
+ class Ue extends Error {
380
499
  constructor(e, t) {
381
- super(`Failed to evaluate code block: ${$t(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
500
+ super(`Failed to evaluate code block: ${Ut(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
382
501
  }
383
502
  }
384
- const Ue = /^\$\{([\s\S]*)\}$/, xt = /\$\{([\s\S]+?)\}/, Ve = /\$\{([\s\S]+?)\}/g;
385
- function H(s) {
386
- if (typeof s != "string" || !Ue.test(s))
503
+ const Ve = /^\$\{([\s\S]*)\}$/, Vt = /\$\{([\s\S]+?)\}/, Ke = /\$\{([\s\S]+?)\}/g;
504
+ function W(i) {
505
+ if (typeof i != "string" || !Ve.test(i))
387
506
  return !1;
388
- const e = s.indexOf("${"), t = s.lastIndexOf("${");
507
+ const e = i.indexOf("${"), t = i.lastIndexOf("${");
389
508
  return e === t;
390
509
  }
391
- function zt(s) {
392
- return typeof s != "string" ? !1 : Ue.test(s) ? !0 : xt.test(s);
510
+ function Kt(i) {
511
+ return typeof i != "string" ? !1 : Ve.test(i) ? !0 : Vt.test(i);
393
512
  }
394
- function Ft(s) {
395
- if (!H(s))
396
- throw new Error(`Invalid expression: ${s}`);
397
- return s.slice(2, -1);
513
+ function Wt(i) {
514
+ if (!W(i))
515
+ throw new Error(`Invalid expression: ${i}`);
516
+ return i.slice(2, -1);
398
517
  }
399
- async function He(s, e, t) {
518
+ async function We(i, e, t) {
400
519
  const n = `return await (${e});`;
401
520
  try {
402
- return await s.evaluate({ code: n, bindings: t });
521
+ return await i.evaluate({ code: n, bindings: t });
403
522
  } catch (r) {
404
- throw new Fe(e, r);
523
+ throw new Ue(e, r);
405
524
  }
406
525
  }
407
- async function Ut(s, e, t) {
526
+ async function Gt(i, e, t) {
408
527
  let n = "", r = 0;
409
- for (const i of e.matchAll(Ve)) {
410
- const o = i[0], a = i[1], c = i.index ?? 0;
528
+ for (const s of e.matchAll(Ke)) {
529
+ const o = s[0], a = s[1], c = s.index ?? 0;
411
530
  n += e.slice(r, c);
412
- const l = await He(
413
- s,
531
+ const l = await We(
532
+ i,
414
533
  a,
415
534
  t
416
535
  );
@@ -418,45 +537,45 @@ async function Ut(s, e, t) {
418
537
  }
419
538
  return n += e.slice(r), n;
420
539
  }
421
- function Ke({
422
- include: s,
540
+ function Ge({
541
+ include: i,
423
542
  exclude: e = [],
424
543
  options: t
425
544
  }) {
426
- const n = { dot: !0, ...t ?? {} }, r = s.map(
427
- (o) => ue(o, n)
428
- ), i = e.map(
429
- (o) => ue(o, n)
545
+ const n = { dot: !0, ...t ?? {} }, r = i.map(
546
+ (o) => de(o, n)
547
+ ), s = e.map(
548
+ (o) => de(o, n)
430
549
  );
431
- return (o) => r.some((a) => a(o)) && !i.some((a) => a(o));
550
+ return (o) => r.some((a) => a(o)) && !s.some((a) => a(o));
432
551
  }
433
- async function K(s) {
552
+ async function G(i) {
434
553
  const {
435
554
  evaluator: e,
436
555
  node: t,
437
556
  bindings: n,
438
557
  shouldResolve: r,
439
- context: i,
558
+ context: s,
440
559
  pointer: o = "/"
441
- } = s, a = t.clone(), c = a.getValue();
560
+ } = i, a = t.clone(), c = a.getValue();
442
561
  if (c !== void 0) {
443
562
  if (typeof c == "string" && r(o)) {
444
- if (H(c)) {
445
- const h = Ft(c);
446
- i.gasMeter().chargeExpression(h);
447
- const f = await He(
563
+ if (W(c)) {
564
+ const h = Wt(c);
565
+ s.gasMeter().chargeExpression(h);
566
+ const f = await We(
448
567
  e,
449
568
  h,
450
569
  n
451
570
  );
452
- return i.blue.jsonValueToNode(f ?? null);
453
- } else if (zt(c)) {
454
- const h = new RegExp(Ve);
571
+ return s.blue.jsonValueToNode(f ?? null);
572
+ } else if (Kt(c)) {
573
+ const h = new RegExp(Ke);
455
574
  let f = 0;
456
575
  for (h.lastIndex = 0; h.exec(c); )
457
576
  f += 1;
458
- i.gasMeter().chargeTemplate(f, c);
459
- const E = await Ut(
577
+ s.gasMeter().chargeTemplate(f, c);
578
+ const E = await Gt(
460
579
  e,
461
580
  c,
462
581
  n
@@ -470,8 +589,8 @@ async function K(s) {
470
589
  if (Array.isArray(l)) {
471
590
  const h = await Promise.all(
472
591
  l.map(
473
- (f, E) => K({
474
- ...s,
592
+ (f, E) => G({
593
+ ...i,
475
594
  node: f,
476
595
  pointer: `${o}/${E}`
477
596
  })
@@ -483,84 +602,84 @@ async function K(s) {
483
602
  if (u) {
484
603
  const h = {};
485
604
  for (const [f, E] of Object.entries(u)) {
486
- const O = o === "/" ? `/${f}` : `${o}/${f}`;
487
- h[f] = await K({
488
- ...s,
605
+ const D = o === "/" ? `/${f}` : `${o}/${f}`;
606
+ h[f] = await G({
607
+ ...i,
489
608
  node: E,
490
- pointer: O
609
+ pointer: D
491
610
  });
492
611
  }
493
612
  a.setProperties(h);
494
613
  }
495
614
  return a;
496
615
  }
497
- const oe = Ye, D = Ze.merge(
498
- oe
616
+ const ae = Xe, O = et.merge(
617
+ ae
499
618
  ).extend({
500
619
  path: S.string().optional(),
501
- definition: x().optional()
502
- }), We = Xe.merge(oe), z = et.merge(oe), Vt = S.object({
620
+ definition: z().optional()
621
+ }), qe = tt.merge(ae), H = nt.merge(ae), qt = S.object({
503
622
  op: S.enum(["ADD", "REPLACE", "REMOVE"]),
504
623
  path: S.string(),
505
- val: x().optional()
506
- }), Zr = dt("JsonPatch")(
507
- Vt
508
- ).superRefine((s, e) => {
509
- s.op === "REMOVE" && s.val !== void 0 && e.addIssue({
624
+ val: z().optional()
625
+ }), si = ft("JsonPatch")(
626
+ qt
627
+ ).superRefine((i, e) => {
628
+ i.op === "REMOVE" && i.val !== void 0 && e.addIssue({
510
629
  code: S.ZodIssueCode.custom,
511
630
  message: "REMOVE operations cannot include a value",
512
631
  path: ["val"]
513
- }), s.op !== "REMOVE" && s.val === void 0 && e.addIssue({
632
+ }), i.op !== "REMOVE" && i.val === void 0 && e.addIssue({
514
633
  code: S.ZodIssueCode.custom,
515
- message: `${s.op} operations must include a value`,
634
+ message: `${i.op} operations must include a value`,
516
635
  path: ["val"]
517
636
  });
518
- }), Ht = tt.merge(
519
- D
520
- ), Kt = nt.merge(
521
- D
522
- ), Wt = rt.merge(
523
- D
524
- ), Gt = it.merge(D), qt = ft.merge(
525
- D
526
- ), Jt = Et.merge(D), jt = st.merge(z).extend({
637
+ }), jt = rt.merge(
638
+ O
639
+ ), Jt = it.merge(
640
+ O
641
+ ), Qt = st.merge(
642
+ O
643
+ ), Yt = ot.merge(O), Zt = mt.merge(
644
+ O
645
+ ), Xt = wt.merge(O), en = at.merge(H).extend({
527
646
  lastSignatures: S.record(S.string()).optional()
528
- }), Qt = ot.merge(z), Yt = at.merge(
529
- z
530
- ), Zt = ct.merge(z), Xt = $.merge(
531
- z
532
- ), Xr = x(), en = pt.merge(We).extend({
533
- steps: S.array(x()).optional()
534
- }), tn = mt.merge(
535
- We
647
+ }), tn = ct.merge(H), nn = lt.merge(
648
+ H
649
+ ), rn = ut.merge(H), sn = x.merge(
650
+ H
651
+ ), oi = z(), on = gt.merge(qe).extend({
652
+ steps: S.array(z()).optional()
653
+ }), an = Et.merge(
654
+ qe
536
655
  ).extend({
537
- steps: S.array(x()).optional()
656
+ steps: S.array(z()).optional()
538
657
  });
539
- function nn(s) {
540
- if (!Array.isArray(s.blueIds) || s.blueIds.length === 0)
658
+ function cn(i) {
659
+ if (!Array.isArray(i.blueIds) || i.blueIds.length === 0)
541
660
  throw new Error("Contract processors must declare at least one BlueId");
542
- for (const e of s.blueIds)
661
+ for (const e of i.blueIds)
543
662
  if (typeof e != "string" || e.trim().length === 0)
544
663
  throw new Error("Contract processor BlueIds must be non-empty strings");
545
664
  }
546
- function U(s, e) {
547
- nn(s);
548
- for (const t of s.blueIds)
549
- e.set(t, s);
665
+ function V(i, e) {
666
+ cn(i);
667
+ for (const t of i.blueIds)
668
+ e.set(t, i);
550
669
  }
551
- class rn {
670
+ class ln {
552
671
  processorsByBlueId = /* @__PURE__ */ new Map();
553
672
  handlerProcessors = /* @__PURE__ */ new Map();
554
673
  channelProcessors = /* @__PURE__ */ new Map();
555
674
  markerProcessors = /* @__PURE__ */ new Map();
556
675
  registerHandler(e) {
557
- U(e, this.handlerProcessors), this.registerProcessorMap(e);
676
+ V(e, this.handlerProcessors), this.registerProcessorMap(e);
558
677
  }
559
678
  registerChannel(e) {
560
- U(e, this.channelProcessors), this.registerProcessorMap(e);
679
+ V(e, this.channelProcessors), this.registerProcessorMap(e);
561
680
  }
562
681
  registerMarker(e) {
563
- U(e, this.markerProcessors), this.registerProcessorMap(e);
682
+ V(e, this.markerProcessors), this.registerProcessorMap(e);
564
683
  }
565
684
  register(e) {
566
685
  switch (e.kind) {
@@ -594,114 +713,113 @@ class rn {
594
713
  return new Map(this.processorsByBlueId);
595
714
  }
596
715
  registerProcessorMap(e) {
597
- U(e, this.processorsByBlueId);
716
+ V(e, this.processorsByBlueId);
598
717
  }
599
718
  }
600
- function we(s, e) {
601
- return s.isTypeOf(e, pe) ? s.nodeToSchemaOutput(e, pe) : s.isTypeOf(e, P) ? s.nodeToSchemaOutput(e, P) : null;
719
+ function be(i, e) {
720
+ return i.isTypeOf(e, me) ? i.nodeToSchemaOutput(e, me) : i.isTypeOf(e, k) ? i.nodeToSchemaOutput(e, k) : null;
602
721
  }
603
- class sn {
722
+ class un {
604
723
  kind = "channel";
605
- blueIds = [yt["MyOS Timeline Channel"]];
606
- schema = Jt;
724
+ blueIds = [bt["MyOS Timeline Channel"]];
725
+ schema = Xt;
607
726
  matches(e, t) {
608
727
  const { event: n, blue: r } = t;
609
728
  if (!n)
610
729
  return !1;
611
- const i = we(r, n);
612
- if (!i)
730
+ const s = be(r, n);
731
+ if (!s)
613
732
  return !1;
614
- const o = i.timeline?.timelineId;
733
+ const o = s.timeline?.timelineId;
615
734
  return !o || !e.timelineId ? !1 : o === e.timelineId;
616
735
  }
617
736
  channelize(e, t) {
618
737
  const { event: n, blue: r } = t;
619
- if (!n)
620
- return null;
621
- const i = we(r, n);
622
- if (!i)
623
- return null;
624
- const o = i.message;
625
- return o ? o.clone() : null;
738
+ return !n || !be(r, n) ? null : n.clone();
626
739
  }
627
740
  }
628
- class on {
741
+ class dn {
629
742
  kind = "channel";
630
- blueIds = [I["Timeline Channel"]];
631
- schema = qt;
743
+ blueIds = [v["Timeline Channel"]];
744
+ schema = Zt;
632
745
  matches(e, t) {
633
746
  const { event: n, blue: r } = t;
634
- if (!n || !r.isTypeOf(n, P))
747
+ if (!n || !r.isTypeOf(n, k))
635
748
  return !1;
636
- const o = r.nodeToSchemaOutput(n, P).timeline?.timelineId;
749
+ const o = r.nodeToSchemaOutput(n, k).timeline?.timelineId;
637
750
  return !(!o || !e.timelineId || o !== e.timelineId);
638
751
  }
639
752
  channelize(e, t) {
640
753
  const { event: n, blue: r } = t;
641
- if (!n || !r.isTypeOf(n, P))
642
- return null;
643
- const o = r.nodeToSchemaOutput(n, P).message;
644
- return o ? o.clone() : null;
754
+ return !n || !r.isTypeOf(n, k) ? null : n.clone();
645
755
  }
646
756
  }
647
- function ae(s) {
648
- const { context: e, eventNode: t, stepResults: n } = s;
757
+ function ce(i) {
758
+ const { context: e, eventNode: t, stepResults: n } = i, r = hn(e);
649
759
  return {
650
- event: e.blue.nodeToJson(t, "original"),
760
+ event: e.blue.nodeToJson(t, "simple"),
761
+ eventCanonical: e.blue.nodeToJson(t, "official"),
651
762
  steps: n,
652
- document: (r) => {
653
- const i = r == null ? "/" : typeof r == "string" ? r : (() => {
654
- throw new TypeError("document() expects a string pointer");
655
- })(), o = i.startsWith("/") ? i : e.resolvePointer(i), a = b(o), c = e.documentAt(a);
656
- if (e.gasMeter().chargeDocumentSnapshot(a, c), !!c)
657
- return e.blue.nodeToJson(c, "original");
658
- }
763
+ document: r
659
764
  };
660
765
  }
661
- class an {
662
- supportedBlueIds = [I["Trigger Event"]];
663
- evaluator = new se();
766
+ function hn(i) {
767
+ const e = (r) => {
768
+ const s = r == null ? "/" : typeof r == "string" ? r : (() => {
769
+ throw new TypeError("document() expects a string pointer");
770
+ })(), o = s.startsWith("/") ? s : i.resolvePointer(s), a = b(o), c = i.documentAt(a);
771
+ return i.gasMeter().chargeDocumentSnapshot(a, c), { snapshot: c, normalizedPointer: a };
772
+ }, t = (r, s) => {
773
+ const { snapshot: o } = e(r);
774
+ if (o)
775
+ return i.blue.nodeToJson(o, s);
776
+ }, n = (r) => t(r, "simple");
777
+ return n.canonical = (r) => t(r, "official"), n;
778
+ }
779
+ class fn {
780
+ supportedBlueIds = [v["Trigger Event"]];
781
+ evaluator = new oe();
664
782
  async execute(e) {
665
783
  const { stepNode: t, context: n } = e;
666
- if (!n.blue.isTypeOf(t, de))
784
+ if (!n.blue.isTypeOf(t, he))
667
785
  return n.throwFatal("Trigger Event step payload is invalid");
668
786
  n.gasMeter().chargeTriggerEventBase();
669
- const r = await K({
787
+ const r = await G({
670
788
  evaluator: this.evaluator,
671
789
  node: t,
672
- bindings: ae(e),
673
- shouldResolve: Ke({
790
+ bindings: ce(e),
791
+ shouldResolve: Ge({
674
792
  include: ["/event", "/event/**"]
675
793
  }),
676
794
  context: n
677
795
  }), o = n.blue.nodeToSchemaOutput(
678
796
  r,
679
- de
797
+ he
680
798
  ).event;
681
- if (X(o))
799
+ if (te(o))
682
800
  return n.throwFatal(
683
801
  "Trigger Event step must declare event payload"
684
802
  );
685
803
  n.emitEvent(o.clone());
686
804
  }
687
805
  }
688
- class cn {
689
- supportedBlueIds = [I["JavaScript Code"]];
690
- evaluator = new se();
806
+ class pn {
807
+ supportedBlueIds = [v["JavaScript Code"]];
808
+ evaluator = new oe();
691
809
  async execute(e) {
692
810
  const { context: t, stepNode: n } = e, { blue: r } = t;
693
- if (!r.isTypeOf(n, he))
811
+ if (!r.isTypeOf(n, fe))
694
812
  return t.throwFatal("JavaScript Code step payload is invalid");
695
813
  const o = r.nodeToSchemaOutput(
696
814
  n,
697
- he
815
+ fe
698
816
  ).code;
699
817
  if (!o)
700
818
  return t.throwFatal(
701
819
  "JavaScript Code step must include code to execute"
702
820
  );
703
821
  t.gasMeter().chargeJavaScriptCodeBase(o);
704
- const a = ae(e);
822
+ const a = ce(e);
705
823
  try {
706
824
  const c = await this.evaluator.evaluate({
707
825
  code: o,
@@ -709,7 +827,7 @@ class cn {
709
827
  });
710
828
  return this.handleEvents(c, t), c;
711
829
  } catch (c) {
712
- throw new Fe(o, c);
830
+ throw new Ue(o, c);
713
831
  }
714
832
  }
715
833
  handleEvents(e, t) {
@@ -718,27 +836,27 @@ class cn {
718
836
  const n = e;
719
837
  if (Array.isArray(n.events))
720
838
  for (const r of n.events) {
721
- const i = t.blue.jsonValueToNode(r);
722
- t.emitEvent(i);
839
+ const s = t.blue.jsonValueToNode(r);
840
+ t.emitEvent(s);
723
841
  }
724
842
  }
725
843
  }
726
- class ln {
727
- supportedBlueIds = [I["Update Document"]];
728
- evaluator = new se();
844
+ class mn {
845
+ supportedBlueIds = [v["Update Document"]];
846
+ evaluator = new oe();
729
847
  async execute(e) {
730
848
  const { context: t, stepNode: n } = e, { blue: r } = t;
731
- if (!r.isTypeOf(n, fe))
849
+ if (!r.isTypeOf(n, pe))
732
850
  return t.throwFatal("Update Document step payload is invalid");
733
- const i = await K({
851
+ const s = await G({
734
852
  evaluator: this.evaluator,
735
853
  node: n,
736
- bindings: ae(e),
737
- shouldResolve: Ke({
854
+ bindings: ce(e),
855
+ shouldResolve: Ge({
738
856
  include: ["/changeset", "/changeset/**"]
739
857
  }),
740
858
  context: t
741
- }), o = this.extractChanges(i, t);
859
+ }), o = this.extractChanges(s, t);
742
860
  t.gasMeter().chargeUpdateDocumentBase(o.length);
743
861
  for (const a of o) {
744
862
  const c = this.createPatch(a, t);
@@ -748,12 +866,12 @@ class ln {
748
866
  extractChanges(e, t) {
749
867
  return t.blue.nodeToSchemaOutput(
750
868
  e,
751
- fe
869
+ pe
752
870
  ).changeset ?? [];
753
871
  }
754
872
  createPatch(e, t) {
755
- const n = this.normalizeOperation(e.op, t), r = this.normalizePath(e.path, t), i = t.resolvePointer(r);
756
- return n === "REMOVE" ? { op: n, path: i } : { op: n, path: i, val: e.val };
873
+ const n = this.normalizeOperation(e.op, t), r = this.normalizePath(e.path, t), s = t.resolvePointer(r);
874
+ return n === "REMOVE" ? { op: n, path: s } : { op: n, path: s, val: e.val };
757
875
  }
758
876
  normalizeOperation(e, t) {
759
877
  const n = typeof e == "string" ? e : void 0, r = (n ?? "REPLACE").toUpperCase();
@@ -768,14 +886,14 @@ class ln {
768
886
  return n.length === 0 ? t.throwFatal("Update Document path cannot be empty") : n;
769
887
  }
770
888
  }
771
- const ce = [
772
- new an(),
773
- new cn(),
774
- new ln()
889
+ const le = [
890
+ new fn(),
891
+ new pn(),
892
+ new mn()
775
893
  ];
776
- class Ge {
894
+ class je {
777
895
  executorIndex;
778
- constructor(e = ce) {
896
+ constructor(e = le) {
779
897
  const t = /* @__PURE__ */ new Map();
780
898
  for (const n of e)
781
899
  for (const r of n.supportedBlueIds)
@@ -783,18 +901,18 @@ class Ge {
783
901
  this.executorIndex = t;
784
902
  }
785
903
  async run(e) {
786
- const { workflow: t, eventNode: n, context: r } = e, i = t.steps ?? [];
787
- if (i.length === 0)
904
+ const { workflow: t, eventNode: n, context: r } = e, s = t.steps ?? [];
905
+ if (s.length === 0)
788
906
  return {};
789
907
  const o = {};
790
- for (const [a, c] of i.entries()) {
908
+ for (const [a, c] of s.entries()) {
791
909
  const l = c.getType?.()?.getBlueId();
792
- if (X(l))
910
+ if (te(l))
793
911
  return r.throwFatal(
794
912
  "Sequential workflow step is missing type metadata"
795
913
  );
796
914
  const u = this.executorIndex.get(l);
797
- if (X(u)) {
915
+ if (te(u)) {
798
916
  const E = c.getType?.()?.getName?.() ?? l;
799
917
  return r.throwFatal(
800
918
  `Unsupported workflow step type "${E}"`
@@ -820,13 +938,13 @@ class Ge {
820
938
  return n && typeof n == "string" && n.length > 0 ? n : `Step${t + 1}`;
821
939
  }
822
940
  }
823
- class un {
941
+ class gn {
824
942
  kind = "handler";
825
- blueIds = [I["Sequential Workflow"]];
826
- schema = en;
943
+ blueIds = [v["Sequential Workflow"]];
944
+ schema = on;
827
945
  runner;
828
- constructor(e = ce) {
829
- this.runner = new Ge(e);
946
+ constructor(e = le) {
947
+ this.runner = new je(e);
830
948
  }
831
949
  async matches(e, t) {
832
950
  const n = t.event();
@@ -837,13 +955,13 @@ class un {
837
955
  n && await this.runner.run({ workflow: e, eventNode: n, context: t });
838
956
  }
839
957
  }
840
- class dn {
958
+ class En {
841
959
  kind = "marker";
842
- blueIds = [I.Operation];
843
- schema = Xt;
960
+ blueIds = [v.Operation];
961
+ schema = sn;
844
962
  }
845
- function qe(s) {
846
- const e = s.channel;
963
+ function Je(i) {
964
+ const e = i.channel;
847
965
  if (typeof e == "string") {
848
966
  const t = e.trim();
849
967
  if (t.length > 0)
@@ -851,37 +969,48 @@ function qe(s) {
851
969
  }
852
970
  return null;
853
971
  }
854
- function hn(s, e) {
855
- const t = s.getProperties()?.document;
972
+ function yn(i, e) {
973
+ const t = i.getProperties()?.document;
856
974
  return t instanceof d ? e.blue.calculateBlueIdSync(t) : null;
857
975
  }
858
- function fn(s, e, t) {
859
- const { blue: n } = t;
860
- if (!n.isTypeOf(e, Z, {
976
+ function wn(i, e) {
977
+ if (e.isTypeOf(i, ee, {
861
978
  checkSchemaExtensions: !0
862
979
  }))
863
- return !1;
864
- const r = n.nodeToSchemaOutput(e, Z), i = s.operation;
865
- return !(!i || r.operation !== i || s.event && !n.isTypeOfNode(e, s.event));
980
+ return i;
981
+ if (e.isTypeOf(i, k, {
982
+ checkSchemaExtensions: !0
983
+ })) {
984
+ const n = e.nodeToSchemaOutput(i, k).message;
985
+ if (n && e.isTypeOf(n, ee, {
986
+ checkSchemaExtensions: !0
987
+ }))
988
+ return n;
989
+ }
990
+ return null;
991
+ }
992
+ function bn(i, e, t, n) {
993
+ const { blue: r } = n, s = i.operation;
994
+ return !(!s || t.operation !== s || i.event && !r.isTypeOfNode(e, i.event));
866
995
  }
867
- function pn(s, e) {
868
- const t = s.operation;
996
+ function Sn(i, e) {
997
+ const t = i.operation;
869
998
  if (!t)
870
999
  return null;
871
1000
  const n = e.resolvePointer(`/contracts/${t}`), r = e.documentAt(n);
872
- if (!r || !e.blue.isTypeOf(r, $))
1001
+ if (!r || !e.blue.isTypeOf(r, x))
873
1002
  return null;
874
- const i = e.blue.nodeToSchemaOutput(
1003
+ const s = e.blue.nodeToSchemaOutput(
875
1004
  r,
876
- $
877
- ), o = qe(i);
878
- return { operationNode: r, operation: i, channelKey: o };
1005
+ x
1006
+ ), o = Je(s);
1007
+ return { operationNode: r, operation: s, channelKey: o };
879
1008
  }
880
- function mn(s, e) {
881
- return !(s && e && s !== e);
1009
+ function Cn(i, e) {
1010
+ return !(i && e && i !== e);
882
1011
  }
883
- function gn(s, e, t) {
884
- const n = s.getProperties()?.request, r = e.getProperties()?.request;
1012
+ function kn(i, e, t) {
1013
+ const n = i.getProperties()?.request, r = e.getProperties()?.request;
885
1014
  if (!(n instanceof d) || !(r instanceof d))
886
1015
  return !1;
887
1016
  try {
@@ -892,59 +1021,65 @@ function gn(s, e, t) {
892
1021
  }
893
1022
  return !0;
894
1023
  }
895
- function En(s, e, t) {
896
- if (!s || s.allowNewerVersion !== !1)
1024
+ function In(i, e, t) {
1025
+ if (!i || i.allowNewerVersion !== !1)
897
1026
  return !0;
898
- const n = hn(e, t);
1027
+ const n = yn(e, t);
899
1028
  if (!n)
900
1029
  return !0;
901
- const r = t.resolvePointer("/"), i = t.documentAt(r);
902
- if (!i)
1030
+ const r = t.resolvePointer("/"), s = t.documentAt(r);
1031
+ if (!s)
903
1032
  return !1;
904
- const c = (i.getContracts()?.initialized ?? null)?.get("/documentId") ?? null, l = typeof c == "string" && c.length > 0 ? c : t.blue.calculateBlueIdSync(i);
1033
+ const c = (s.getContracts()?.initialized ?? null)?.get("/documentId") ?? null, l = typeof c == "string" && c.length > 0 ? c : t.blue.calculateBlueIdSync(s);
905
1034
  return n === l;
906
1035
  }
907
- class yn {
1036
+ class vn {
908
1037
  kind = "handler";
909
1038
  blueIds = [
910
- I["Sequential Workflow Operation"]
1039
+ v["Sequential Workflow Operation"]
911
1040
  ];
912
- schema = tn;
1041
+ schema = an;
913
1042
  runner;
914
- constructor(e = ce) {
915
- this.runner = new Ge(e);
1043
+ constructor(e = le) {
1044
+ this.runner = new je(e);
916
1045
  }
917
1046
  deriveChannel(e, t) {
918
1047
  const n = e.operation;
919
1048
  if (!n)
920
1049
  return null;
921
1050
  const r = t.scopeContracts.get(n);
922
- if (!r || !t.blue.isTypeOf(r.node, $, {
1051
+ if (!r || !t.blue.isTypeOf(r.node, x, {
923
1052
  checkSchemaExtensions: !0
924
1053
  }))
925
1054
  return null;
926
- const i = t.blue.nodeToSchemaOutput(r.node, $);
927
- return i ? qe(i) : null;
1055
+ const s = t.blue.nodeToSchemaOutput(r.node, x);
1056
+ return s ? Je(s) : null;
928
1057
  }
929
1058
  async matches(e, t) {
930
1059
  const n = t.event();
931
- if (!n || !fn(e, n, t))
932
- return !1;
933
- const r = pn(e, t);
934
- if (!r)
1060
+ if (!n)
935
1061
  return !1;
936
- const i = typeof e.channel == "string" ? e.channel.trim() : "", o = i.length > 0 ? i : null;
937
- if (!mn(r.channelKey, o) || !gn(
1062
+ const r = wn(
938
1063
  n,
939
- r.operationNode,
940
1064
  t.blue
941
- ))
1065
+ );
1066
+ if (!r)
942
1067
  return !1;
943
- const a = t.blue.nodeToSchemaOutput(
944
- n,
945
- Z
1068
+ const s = t.blue.nodeToSchemaOutput(
1069
+ r,
1070
+ ee
946
1071
  );
947
- return !(a?.allowNewerVersion === !1 && !En(a, n, t));
1072
+ if (!s || !bn(e, n, s, t))
1073
+ return !1;
1074
+ const o = Sn(e, t);
1075
+ if (!o)
1076
+ return !1;
1077
+ const a = typeof e.channel == "string" ? e.channel.trim() : "", c = a.length > 0 ? a : null;
1078
+ return !(!Cn(o.channelKey, c) || !kn(
1079
+ r,
1080
+ o.operationNode,
1081
+ t.blue
1082
+ ) || s?.allowNewerVersion === !1 && !In(s, r, t));
948
1083
  }
949
1084
  async execute(e, t) {
950
1085
  const n = t.event();
@@ -955,17 +1090,17 @@ class yn {
955
1090
  });
956
1091
  }
957
1092
  }
958
- class J {
1093
+ class Q {
959
1094
  constructor(e) {
960
1095
  this.registry = e;
961
1096
  }
962
1097
  static create() {
963
- return new J(
964
- new rn()
1098
+ return new Q(
1099
+ new ln()
965
1100
  );
966
1101
  }
967
1102
  registerDefaults() {
968
- return this.registry.register(new sn()), this.registry.register(new on()), this.registry.register(new un()), this.registry.register(new dn()), this.registry.register(new yn()), this;
1103
+ return this.registry.register(new un()), this.registry.register(new dn()), this.registry.register(new gn()), this.registry.register(new En()), this.registry.register(new vn()), this;
969
1104
  }
970
1105
  register(e) {
971
1106
  return this.registry.register(e), this;
@@ -974,11 +1109,11 @@ class J {
974
1109
  return this.registry;
975
1110
  }
976
1111
  }
977
- const te = p["Channel Event Checkpoint"];
978
- function Je(s) {
979
- return typeof s.order == "number" ? s.order : 0;
1112
+ const re = p["Channel Event Checkpoint"];
1113
+ function Qe(i) {
1114
+ return typeof i.order == "number" ? i.order : 0;
980
1115
  }
981
- class wn {
1116
+ class Rn {
982
1117
  constructor(e, t, n) {
983
1118
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
984
1119
  }
@@ -992,10 +1127,10 @@ class wn {
992
1127
  return this.bindingBlueId;
993
1128
  }
994
1129
  order() {
995
- return Je(this.bindingContract);
1130
+ return Qe(this.bindingContract);
996
1131
  }
997
1132
  }
998
- class bn {
1133
+ class Tn {
999
1134
  constructor(e, t, n) {
1000
1135
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1001
1136
  }
@@ -1009,28 +1144,28 @@ class bn {
1009
1144
  return this.bindingBlueId;
1010
1145
  }
1011
1146
  order() {
1012
- return Je(this.bindingContract);
1147
+ return Qe(this.bindingContract);
1013
1148
  }
1014
1149
  }
1015
- class N {
1016
- constructor(e, t, n, r, i) {
1017
- this.channels = e, this.handlersByChannel = t, this.markerStore = n, this.embeddedPathsInternal = r, this.checkpointDeclared = i;
1150
+ class M {
1151
+ constructor(e, t, n, r, s) {
1152
+ this.channels = e, this.handlersByChannel = t, this.markerStore = n, this.embeddedPathsInternal = r, this.checkpointDeclared = s;
1018
1153
  }
1019
1154
  checkpointDeclared;
1020
- static fromComponents(e, t, n, r, i) {
1021
- return new N(
1155
+ static fromComponents(e, t, n, r, s) {
1156
+ return new M(
1022
1157
  e,
1023
1158
  t,
1024
1159
  n,
1025
1160
  r,
1026
- i
1161
+ s
1027
1162
  );
1028
1163
  }
1029
1164
  static builder() {
1030
- return new Sn();
1165
+ return new Pn();
1031
1166
  }
1032
1167
  static empty() {
1033
- return N.builder().build();
1168
+ return M.builder().build();
1034
1169
  }
1035
1170
  markers() {
1036
1171
  return new Map(
@@ -1060,32 +1195,32 @@ class N {
1060
1195
  throw new Error(
1061
1196
  "Duplicate Channel Event Checkpoint markers detected in same contracts map"
1062
1197
  );
1063
- this.markerStore.set(k, {
1064
- key: k,
1198
+ this.markerStore.set(I, {
1199
+ key: I,
1065
1200
  contract: e,
1066
- blueId: te
1201
+ blueId: re
1067
1202
  }), this.checkpointDeclared = !0;
1068
1203
  }
1069
1204
  handlersFor(e) {
1070
1205
  const t = this.handlersByChannel.get(e);
1071
1206
  return !t || t.length === 0 ? [] : [...t].map(
1072
- (n) => new bn(n.key, n.contract, n.blueId)
1207
+ (n) => new Tn(n.key, n.contract, n.blueId)
1073
1208
  ).sort((n, r) => {
1074
- const i = n.order() - r.order();
1075
- return i !== 0 ? i : n.key().localeCompare(r.key());
1209
+ const s = n.order() - r.order();
1210
+ return s !== 0 ? s : n.key().localeCompare(r.key());
1076
1211
  });
1077
1212
  }
1078
1213
  channelsOfType(...e) {
1079
1214
  const t = e.length > 0 ? new Set(e) : null, n = Array.from(this.channels.values()).filter((r) => !t || t.has(r.blueId)).map(
1080
- (r) => new wn(r.key, r.contract, r.blueId)
1215
+ (r) => new Rn(r.key, r.contract, r.blueId)
1081
1216
  );
1082
- return n.sort((r, i) => {
1083
- const o = r.order() - i.order();
1084
- return o !== 0 ? o : r.key().localeCompare(i.key());
1217
+ return n.sort((r, s) => {
1218
+ const o = r.order() - s.order();
1219
+ return o !== 0 ? o : r.key().localeCompare(s.key());
1085
1220
  }), n;
1086
1221
  }
1087
1222
  }
1088
- class Sn {
1223
+ class Pn {
1089
1224
  channels = /* @__PURE__ */ new Map();
1090
1225
  handlersByChannel = /* @__PURE__ */ new Map();
1091
1226
  markerStore = /* @__PURE__ */ new Map();
@@ -1099,8 +1234,8 @@ class Sn {
1099
1234
  const r = t.channel;
1100
1235
  if (!r)
1101
1236
  throw new Error(`Handler ${e} must declare channel`);
1102
- const i = this.handlersByChannel.get(r) ?? [];
1103
- return i.push({ key: e, contract: t, blueId: n }), this.handlersByChannel.set(r, i), this;
1237
+ const s = this.handlersByChannel.get(r) ?? [];
1238
+ return s.push({ key: e, contract: t, blueId: n }), this.handlersByChannel.set(r, s), this;
1104
1239
  }
1105
1240
  setEmbedded(e) {
1106
1241
  if (this.embeddedDeclared)
@@ -1110,12 +1245,12 @@ class Sn {
1110
1245
  return this.embeddedDeclared = !0, this.embeddedPaths = e.paths ? [...e.paths] : [], this;
1111
1246
  }
1112
1247
  addMarker(e, t, n) {
1113
- if (e === k && n !== te)
1248
+ if (e === I && n !== re)
1114
1249
  throw new Error(
1115
1250
  "Reserved key 'checkpoint' must contain a Channel Event Checkpoint"
1116
1251
  );
1117
- if (n === te) {
1118
- if (e !== k)
1252
+ if (n === re) {
1253
+ if (e !== I)
1119
1254
  throw new Error(
1120
1255
  `Channel Event Checkpoint must use reserved key 'checkpoint' at key '${e}'`
1121
1256
  );
@@ -1128,7 +1263,7 @@ class Sn {
1128
1263
  return this.markerStore.set(e, { key: e, contract: t, blueId: n }), this;
1129
1264
  }
1130
1265
  build() {
1131
- return N.fromComponents(
1266
+ return M.fromComponents(
1132
1267
  new Map(this.channels),
1133
1268
  new Map(
1134
1269
  Array.from(this.handlersByChannel.entries(), ([e, t]) => [
@@ -1147,7 +1282,7 @@ class m extends Error {
1147
1282
  super(e || "Processor fatal error"), this.processorError = t, this.name = "ProcessorFatalError";
1148
1283
  }
1149
1284
  }
1150
- class Cn {
1285
+ class Nn {
1151
1286
  constructor(e, t, n) {
1152
1287
  this.blue = e, this.registry = t, this.builtinChannelSchemas = n;
1153
1288
  }
@@ -1156,7 +1291,7 @@ class Cn {
1156
1291
  key: t,
1157
1292
  node: n,
1158
1293
  processor: r,
1159
- blueId: i,
1294
+ blueId: s,
1160
1295
  scopeContracts: o
1161
1296
  }) {
1162
1297
  try {
@@ -1173,7 +1308,7 @@ class Cn {
1173
1308
  throw new m(
1174
1309
  `Handler ${t} references unknown channel '${l}'`,
1175
1310
  g.invalidContract(
1176
- i,
1311
+ s,
1177
1312
  `Channel '${l}' is not declared in this scope`,
1178
1313
  `/contracts/${l}`
1179
1314
  )
@@ -1187,13 +1322,13 @@ class Cn {
1187
1322
  `/contracts/${l}`
1188
1323
  )
1189
1324
  );
1190
- e.addHandler(t, { ...c, channel: l }, i);
1325
+ e.addHandler(t, { ...c, channel: l }, s);
1191
1326
  } catch (a) {
1192
1327
  if (this.isZodError(a))
1193
1328
  throw new m(
1194
1329
  "Failed to parse handler contract",
1195
1330
  g.invalidContract(
1196
- i,
1331
+ s,
1197
1332
  "Failed to parse handler contract",
1198
1333
  t,
1199
1334
  a
@@ -1212,25 +1347,25 @@ class Cn {
1212
1347
  scopeContracts: n,
1213
1348
  handlerKey: r
1214
1349
  }) {
1215
- let i = typeof e.channel == "string" ? e.channel.trim() : null;
1216
- if (i && i.length === 0 && (i = null), !i) {
1350
+ let s = typeof e.channel == "string" ? e.channel.trim() : null;
1351
+ if (s && s.length === 0 && (s = null), !s) {
1217
1352
  const o = t.deriveChannel?.call(t, e, {
1218
1353
  blue: this.blue,
1219
1354
  scopeContracts: n
1220
1355
  }) ?? null;
1221
1356
  if (typeof o == "string") {
1222
1357
  const a = o.trim();
1223
- a.length > 0 && (i = a);
1358
+ a.length > 0 && (s = a);
1224
1359
  }
1225
1360
  }
1226
- if (!i)
1361
+ if (!s)
1227
1362
  throw new m(
1228
1363
  `Handler ${r} must declare channel (missing explicit channel and derivation failed)`,
1229
1364
  g.illegalState(
1230
1365
  `Handler ${r} must declare channel (missing explicit channel and derivation failed)`
1231
1366
  )
1232
1367
  );
1233
- return i;
1368
+ return s;
1234
1369
  }
1235
1370
  isRegisteredChannel(e) {
1236
1371
  return this.builtinChannelSchemas.has(e) ? !0 : this.registry.lookupChannel(e) != null;
@@ -1239,62 +1374,62 @@ class Cn {
1239
1374
  return e instanceof Te;
1240
1375
  }
1241
1376
  }
1242
- class W extends Error {
1377
+ class F extends Error {
1243
1378
  constructor(e) {
1244
1379
  super(e ?? "MustUnderstand failure"), this.name = "MustUnderstandFailure";
1245
1380
  }
1246
1381
  }
1247
- const kn = p["Document Update Channel"], In = p["Embedded Node Channel"], vn = p["Lifecycle Event Channel"], Tn = p["Triggered Event Channel"], be = p["Process Embedded"], Rn = p["Processing Initialized Marker"], Pn = p["Processing Terminated Marker"], Mn = p["Channel Event Checkpoint"], Se = /* @__PURE__ */ new Map([
1382
+ const Mn = p["Document Update Channel"], An = p["Embedded Node Channel"], On = p["Lifecycle Event Channel"], Dn = p["Triggered Event Channel"], Se = p["Process Embedded"], Bn = p["Processing Initialized Marker"], Ln = p["Processing Terminated Marker"], _n = p["Channel Event Checkpoint"], Ce = /* @__PURE__ */ new Map([
1248
1383
  [
1249
- kn,
1250
- Ht
1384
+ Mn,
1385
+ jt
1251
1386
  ],
1252
1387
  [
1253
- In,
1254
- Kt
1388
+ An,
1389
+ Jt
1255
1390
  ],
1256
1391
  [
1257
- vn,
1258
- Wt
1392
+ On,
1393
+ Qt
1259
1394
  ],
1260
1395
  [
1261
- Tn,
1262
- Gt
1396
+ Dn,
1397
+ Yt
1263
1398
  ]
1264
- ]), Nn = /* @__PURE__ */ new Map([
1399
+ ]), $n = /* @__PURE__ */ new Map([
1265
1400
  [
1266
- Rn,
1267
- Qt
1401
+ Bn,
1402
+ tn
1268
1403
  ],
1269
1404
  [
1270
- Pn,
1271
- Zt
1405
+ Ln,
1406
+ rn
1272
1407
  ],
1273
1408
  [
1274
- Mn,
1275
- jt
1409
+ _n,
1410
+ en
1276
1411
  ]
1277
1412
  ]);
1278
- class An {
1413
+ class xn {
1279
1414
  constructor(e, t) {
1280
- this.registry = e, this.blue = t, this.handlerRegistration = new Cn(
1415
+ this.registry = e, this.blue = t, this.handlerRegistration = new Nn(
1281
1416
  this.blue,
1282
1417
  this.registry,
1283
- Se
1418
+ Ce
1284
1419
  );
1285
1420
  }
1286
1421
  handlerRegistration;
1287
1422
  load(e, t) {
1288
1423
  try {
1289
- const n = N.builder(), r = e.getContracts();
1424
+ const n = M.builder(), r = e.getContracts();
1290
1425
  if (!r)
1291
1426
  return n.build();
1292
- const i = this.buildScopeContractsIndex(r);
1427
+ const s = this.buildScopeContractsIndex(r);
1293
1428
  for (const [o, a] of Object.entries(r))
1294
- a && this.processContract(n, o, a, i);
1429
+ a && this.processContract(n, o, a, s);
1295
1430
  return n.build();
1296
1431
  } catch (n) {
1297
- if (n instanceof W || n instanceof m)
1432
+ if (n instanceof F || n instanceof m)
1298
1433
  throw n;
1299
1434
  const r = n?.message ?? "Failed to load contracts";
1300
1435
  throw new m(
@@ -1307,78 +1442,78 @@ class An {
1307
1442
  }
1308
1443
  }
1309
1444
  processContract(e, t, n, r) {
1310
- const i = n.getType()?.getBlueId();
1311
- if (!i)
1445
+ const s = n.getType()?.getBlueId();
1446
+ if (!s)
1312
1447
  return;
1313
- if (i === be) {
1448
+ if (s === Se) {
1314
1449
  this.handleProcessEmbedded(e, t, n);
1315
1450
  return;
1316
1451
  }
1317
- const o = Nn.get(i);
1452
+ const o = $n.get(s);
1318
1453
  if (o) {
1319
- this.handleMarker(e, t, n, o, i);
1454
+ this.handleMarker(e, t, n, o, s);
1320
1455
  return;
1321
1456
  }
1322
- const a = Se.get(i);
1457
+ const a = Ce.get(s);
1323
1458
  if (a) {
1324
- this.handleChannel(e, t, n, a, i);
1459
+ this.handleChannel(e, t, n, a, s);
1325
1460
  return;
1326
1461
  }
1327
- const c = this.registry.lookupChannel(i);
1462
+ const c = this.registry.lookupChannel(s);
1328
1463
  if (c) {
1329
1464
  this.handleChannel(
1330
1465
  e,
1331
1466
  t,
1332
1467
  n,
1333
1468
  c.schema,
1334
- i
1469
+ s
1335
1470
  );
1336
1471
  return;
1337
1472
  }
1338
- const l = this.registry.lookupHandler(i);
1473
+ const l = this.registry.lookupHandler(s);
1339
1474
  if (l) {
1340
1475
  this.handlerRegistration.register({
1341
1476
  builder: e,
1342
1477
  key: t,
1343
1478
  node: n,
1344
1479
  processor: l,
1345
- blueId: i,
1480
+ blueId: s,
1346
1481
  scopeContracts: r
1347
1482
  });
1348
1483
  return;
1349
1484
  }
1350
- const u = this.registry.lookupMarker(i);
1485
+ const u = this.registry.lookupMarker(s);
1351
1486
  if (u) {
1352
1487
  this.handleMarker(
1353
1488
  e,
1354
1489
  t,
1355
1490
  n,
1356
1491
  u.schema,
1357
- i
1492
+ s
1358
1493
  );
1359
1494
  return;
1360
1495
  }
1361
- throw ie(i) ? new m(
1496
+ throw se(s) ? new m(
1362
1497
  "Built-in processor-managed channel is missing schema registration",
1363
1498
  g.invalidContract(
1364
- i,
1499
+ s,
1365
1500
  "Built-in processor-managed channel is missing schema registration",
1366
1501
  t
1367
1502
  )
1368
- ) : new W(`Unsupported contract type: ${i}`);
1503
+ ) : new F(`Unsupported contract type: ${s}`);
1369
1504
  }
1370
1505
  handleProcessEmbedded(e, t, n) {
1371
1506
  try {
1372
1507
  const r = this.convert(
1373
1508
  n,
1374
- Yt
1509
+ nn
1375
1510
  );
1376
1511
  e.setEmbedded(r);
1377
1512
  } catch (r) {
1378
- throw Q(r) ? new m(
1513
+ throw Z(r) ? new m(
1379
1514
  "Failed to parse ProcessEmbedded marker",
1380
1515
  g.invalidContract(
1381
- be,
1516
+ Se,
1382
1517
  "Failed to parse ProcessEmbedded marker",
1383
1518
  t,
1384
1519
  r
@@ -1391,16 +1526,16 @@ class An {
1391
1526
  );
1392
1527
  }
1393
1528
  }
1394
- handleChannel(e, t, n, r, i) {
1529
+ handleChannel(e, t, n, r, s) {
1395
1530
  try {
1396
1531
  const o = this.convert(n, r);
1397
- e.addChannel(t, o, i);
1532
+ e.addChannel(t, o, s);
1398
1533
  } catch (o) {
1399
- if (Q(o))
1534
+ if (Z(o))
1400
1535
  throw new m(
1401
1536
  "Failed to parse channel contract",
1402
1537
  g.invalidContract(
1403
- i,
1538
+ s,
1404
1539
  "Failed to parse channel contract",
1405
1540
  t,
1406
1541
  o
@@ -1413,16 +1548,16 @@ class An {
1413
1548
  );
1414
1549
  }
1415
1550
  }
1416
- handleMarker(e, t, n, r, i) {
1551
+ handleMarker(e, t, n, r, s) {
1417
1552
  try {
1418
1553
  const o = this.convert(n, r);
1419
- e.addMarker(t, o, i);
1554
+ e.addMarker(t, o, s);
1420
1555
  } catch (o) {
1421
- if (Q(o))
1556
+ if (Z(o))
1422
1557
  throw new m(
1423
1558
  "Failed to parse marker contract",
1424
1559
  g.invalidContract(
1425
- i,
1560
+ s,
1426
1561
  "Failed to parse marker contract",
1427
1562
  t,
1428
1563
  o
@@ -1440,8 +1575,8 @@ class An {
1440
1575
  for (const [n, r] of Object.entries(e)) {
1441
1576
  if (!r)
1442
1577
  continue;
1443
- const i = r.getType()?.getBlueId();
1444
- typeof i == "string" && i.trim().length > 0 && t.set(n, { node: r, nodeTypeBlueId: i });
1578
+ const s = r.getType()?.getBlueId();
1579
+ typeof s == "string" && s.trim().length > 0 && t.set(n, { node: r, nodeTypeBlueId: s });
1445
1580
  }
1446
1581
  return t;
1447
1582
  }
@@ -1449,29 +1584,29 @@ class An {
1449
1584
  return this.blue.nodeToSchemaOutput(e, t);
1450
1585
  }
1451
1586
  }
1452
- function Q(s) {
1453
- return s instanceof Te;
1587
+ function Z(i) {
1588
+ return i instanceof Te;
1454
1589
  }
1455
- const Dn = p["Channel Event Checkpoint"];
1456
- function On(s) {
1457
- return s.jsonValueToNode({
1458
- type: { blueId: Dn },
1590
+ const Fn = p["Channel Event Checkpoint"];
1591
+ function zn(i) {
1592
+ return i.jsonValueToNode({
1593
+ type: { blueId: Fn },
1459
1594
  lastEvents: {},
1460
1595
  lastSignatures: {}
1461
1596
  });
1462
1597
  }
1463
- function Bn() {
1598
+ function Hn() {
1464
1599
  return {
1465
1600
  lastEvents: {},
1466
1601
  lastSignatures: {}
1467
1602
  };
1468
1603
  }
1469
- function Ce(s) {
1470
- return s != null && Object.prototype.hasOwnProperty.call(s, "lastEvents") && Object.prototype.hasOwnProperty.call(s, "lastSignatures");
1604
+ function ke(i) {
1605
+ return i != null && Object.prototype.hasOwnProperty.call(i, "lastEvents") && Object.prototype.hasOwnProperty.call(i, "lastSignatures");
1471
1606
  }
1472
- class Ln {
1473
- constructor(e, t, n, r, i) {
1474
- this.markerKey = e, this.checkpoint = t, this.channelKey = n, this.lastEventNode = r, this.lastEventSignature = i;
1607
+ class Un {
1608
+ constructor(e, t, n, r, s) {
1609
+ this.markerKey = e, this.checkpoint = t, this.channelKey = n, this.lastEventNode = r, this.lastEventSignature = s;
1475
1610
  }
1476
1611
  lastEventNode;
1477
1612
  lastEventSignature;
@@ -1479,28 +1614,28 @@ class Ln {
1479
1614
  return e != null && e === this.lastEventSignature;
1480
1615
  }
1481
1616
  }
1482
- class _n {
1617
+ class Vn {
1483
1618
  constructor(e, t) {
1484
1619
  this.runtime = e, this.signatureFn = t;
1485
1620
  }
1486
1621
  ensureCheckpointMarker(e, t) {
1487
- const n = t.marker(k), r = w(e, Oe);
1622
+ const n = t.marker(I), r = w(e, Be);
1488
1623
  if (!n) {
1489
- const i = On(this.runtime.blue());
1490
- this.runtime.directWrite(r, i), t.registerCheckpointMarker(Bn());
1624
+ const s = zn(this.runtime.blue());
1625
+ this.runtime.directWrite(r, s), t.registerCheckpointMarker(Hn());
1491
1626
  return;
1492
1627
  }
1493
- if (!Ce(n))
1628
+ if (!ke(n))
1494
1629
  throw new Error(
1495
1630
  `Reserved key 'checkpoint' must contain a Channel Event Checkpoint at ${r}`
1496
1631
  );
1497
1632
  }
1498
1633
  findCheckpoint(e, t) {
1499
1634
  for (const [n, r] of e.markerEntries()) {
1500
- if (!Ce(r))
1635
+ if (!ke(r))
1501
1636
  continue;
1502
1637
  const o = (r.lastEvents?.[t] ?? null)?.clone() ?? null, c = r.lastSignatures?.[t] ?? null ?? this.signatureFn(o);
1503
- return new Ln(
1638
+ return new Un(
1504
1639
  n,
1505
1640
  r,
1506
1641
  t,
@@ -1513,22 +1648,22 @@ class _n {
1513
1648
  isDuplicate(e, t) {
1514
1649
  return e != null && e.matches(t);
1515
1650
  }
1516
- persist(e, t, n, r, i) {
1651
+ persist(e, t, n, r, s) {
1517
1652
  if (!n)
1518
1653
  return;
1519
1654
  const o = w(
1520
1655
  e,
1521
- _e(n.markerKey, n.channelKey)
1522
- ), a = i?.clone() ?? null;
1656
+ $e(n.markerKey, n.channelKey)
1657
+ ), a = s?.clone() ?? null;
1523
1658
  this.runtime.gasMeter().chargeCheckpointUpdate(), this.runtime.directWrite(o, a), n.checkpoint.lastEvents || (n.checkpoint.lastEvents = {}), a ? n.checkpoint.lastEvents[n.channelKey] = a.clone() ?? null : delete n.checkpoint.lastEvents[n.channelKey], n.lastEventNode = a?.clone() ?? null;
1524
1659
  const c = w(
1525
1660
  e,
1526
- $e(n.markerKey, n.channelKey)
1661
+ xe(n.markerKey, n.channelKey)
1527
1662
  ), l = r == null ? null : new d().setValue(r);
1528
1663
  this.runtime.directWrite(c, l), n.checkpoint.lastSignatures || (n.checkpoint.lastSignatures = {}), r == null ? delete n.checkpoint.lastSignatures[n.channelKey] : n.checkpoint.lastSignatures[n.channelKey] = r, n.lastEventSignature = r ?? null;
1529
1664
  }
1530
1665
  }
1531
- class $n {
1666
+ class Kn {
1532
1667
  constructor(e, t, n) {
1533
1668
  this.runtime = e, this.checkpointManager = t, this.deps = n;
1534
1669
  }
@@ -1536,20 +1671,20 @@ class $n {
1536
1671
  if (this.deps.isScopeInactive(e))
1537
1672
  return;
1538
1673
  this.runtime.gasMeter().chargeChannelMatchAttempt();
1539
- const i = await this.deps.evaluateChannel(
1674
+ const s = await this.deps.evaluateChannel(
1540
1675
  n,
1541
1676
  t,
1542
1677
  e,
1543
1678
  r
1544
1679
  );
1545
- if (!i.matches)
1680
+ if (!s.matches)
1546
1681
  return;
1547
- const o = i.eventNode ?? r, a = r;
1682
+ const o = s.eventNode ?? r, a = r;
1548
1683
  this.checkpointManager.ensureCheckpointMarker(e, t);
1549
1684
  const c = this.checkpointManager.findCheckpoint(
1550
1685
  t,
1551
1686
  n.key()
1552
- ), l = i.eventId ?? this.deps.canonicalSignature(a);
1687
+ ), l = s.eventId ?? this.deps.canonicalSignature(a);
1553
1688
  this.checkpointManager.isDuplicate(c, l) || (await this.runHandlers(
1554
1689
  e,
1555
1690
  t,
@@ -1564,24 +1699,31 @@ class $n {
1564
1699
  a
1565
1700
  ));
1566
1701
  }
1567
- async runHandlers(e, t, n, r, i) {
1702
+ async runHandlers(e, t, n, r, s) {
1568
1703
  const o = t.handlersFor(n);
1569
1704
  if (o.length !== 0)
1570
1705
  for (const a of o) {
1571
- if (!i && this.deps.isScopeInactive(e))
1572
- break;
1573
- const c = this.deps.createContext(
1574
- e,
1575
- t,
1576
- r,
1577
- i
1578
- );
1579
- if (await this.deps.shouldRunHandler(a, c) && (this.runtime.gasMeter().chargeHandlerOverhead(), await this.deps.executeHandler(a, c), !i && this.deps.isScopeInactive(e)))
1706
+ if (!s && this.deps.isScopeInactive(e))
1580
1707
  break;
1708
+ try {
1709
+ const c = this.deps.createContext(
1710
+ e,
1711
+ t,
1712
+ r,
1713
+ s
1714
+ );
1715
+ if (!await this.deps.shouldRunHandler(a, c))
1716
+ continue;
1717
+ if (this.runtime.gasMeter().chargeHandlerOverhead(), await this.deps.executeHandler(a, c), !s && this.deps.isScopeInactive(e))
1718
+ break;
1719
+ } catch (c) {
1720
+ await this.deps.handleHandlerError(e, t, c);
1721
+ return;
1722
+ }
1581
1723
  }
1582
1724
  }
1583
1725
  }
1584
- class M extends m {
1726
+ class N extends m {
1585
1727
  constructor(e) {
1586
1728
  super(e, g.illegalState(e)), this.name = "IllegalStateException";
1587
1729
  }
@@ -1591,8 +1733,8 @@ class T extends Error {
1591
1733
  super(e), this.name = "BoundaryViolationException";
1592
1734
  }
1593
1735
  }
1594
- const xn = p["Document Update Channel"], zn = p["Embedded Node Channel"], Fn = p["Triggered Event Channel"], Un = p["Lifecycle Event Channel"], ke = p["Processing Initialized Marker"], Vn = p["Document Processing Initiated"];
1595
- class Hn {
1736
+ const Wn = p["Document Update Channel"], Gn = p["Embedded Node Channel"], qn = p["Triggered Event Channel"], jn = p["Lifecycle Event Channel"], Ie = p["Processing Initialized Marker"], Jn = p["Document Processing Initiated"];
1737
+ class Qn {
1596
1738
  runtime;
1597
1739
  contractLoader;
1598
1740
  channelRunner;
@@ -1607,24 +1749,24 @@ class Hn {
1607
1749
  }
1608
1750
  async initializeScope(e, t) {
1609
1751
  const n = y(e), r = /* @__PURE__ */ new Set();
1610
- let i = null, o = null;
1752
+ let s = null, o = null;
1611
1753
  for (t && this.runtime.gasMeter().chargeScopeEntry(n); ; ) {
1612
1754
  const h = this.nodeAt(n);
1613
1755
  if (!h)
1614
1756
  return;
1615
- o || (o = h.clone()), i = this.loadBundle(h, n), this.bundles.set(n, i);
1616
- const f = i.embeddedPaths().find((Qe) => !r.has(Qe)) ?? null;
1757
+ o || (o = h.clone()), s = this.loadBundle(h, n), this.bundles.set(n, s);
1758
+ const f = s.embeddedPaths().find((Ze) => !r.has(Ze)) ?? null;
1617
1759
  if (!f)
1618
1760
  break;
1619
1761
  r.add(f);
1620
1762
  const E = w(n, f);
1621
1763
  this.nodeAt(E) && await this.initializeScope(E, !0);
1622
1764
  }
1623
- if (!i)
1765
+ if (!s)
1624
1766
  return;
1625
1767
  const a = this.hasInitializationMarker(n);
1626
- if (!a && i.hasCheckpoint())
1627
- throw new M(
1768
+ if (!a && s.hasCheckpoint())
1769
+ throw new N(
1628
1770
  `Reserved key 'checkpoint' must not appear before initialization at scope ${n}`
1629
1771
  );
1630
1772
  if (a)
@@ -1632,21 +1774,21 @@ class Hn {
1632
1774
  this.runtime.gasMeter().chargeInitialization();
1633
1775
  const c = this.blueId(o ?? new d()), l = this.createLifecycleEvent(c), u = this.hooks.createContext(
1634
1776
  n,
1635
- i,
1777
+ s,
1636
1778
  l,
1637
1779
  !1,
1638
1780
  !0
1639
1781
  );
1640
- await this.deliverLifecycle(n, i, l, !0), await this.addInitializationMarker(u, c);
1782
+ await this.deliverLifecycle(n, s, l, !0), await this.addInitializationMarker(u, c);
1641
1783
  }
1642
1784
  loadBundles(e) {
1643
1785
  const t = y(e);
1644
1786
  if (this.bundles.has(t))
1645
1787
  return;
1646
- const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : N.empty();
1788
+ const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : M.empty();
1647
1789
  this.bundles.set(t, r);
1648
- for (const i of r.embeddedPaths()) {
1649
- const o = w(t, i);
1790
+ for (const s of r.embeddedPaths()) {
1791
+ const o = w(t, s);
1650
1792
  this.loadBundles(o);
1651
1793
  }
1652
1794
  }
@@ -1658,15 +1800,15 @@ class Hn {
1658
1800
  const r = await this.processEmbeddedChildren(n, t);
1659
1801
  if (!r)
1660
1802
  return;
1661
- const i = r.channelsOfType();
1662
- if (i.length === 0) {
1803
+ const s = r.channelsOfType();
1804
+ if (s.length === 0) {
1663
1805
  this.finalizeScope(n, r);
1664
1806
  return;
1665
1807
  }
1666
- for (const o of i) {
1808
+ for (const o of s) {
1667
1809
  if (this.hooks.isScopeInactive(n))
1668
1810
  break;
1669
- ie(o.blueId()) || await this.channelRunner.runExternalChannel(
1811
+ se(o.blueId()) || await this.channelRunner.runExternalChannel(
1670
1812
  n,
1671
1813
  r,
1672
1814
  o,
@@ -1684,13 +1826,13 @@ class Hn {
1684
1826
  n,
1685
1827
  r
1686
1828
  );
1687
- } catch (i) {
1688
- if (i instanceof T) {
1689
- const o = this.hooks.fatalReason(i, "Boundary violation");
1829
+ } catch (s) {
1830
+ if (s instanceof T) {
1831
+ const o = this.hooks.fatalReason(s, "Boundary violation");
1690
1832
  await this.hooks.enterFatalTermination(e, t, o);
1691
1833
  return;
1692
1834
  }
1693
- throw i;
1835
+ throw s;
1694
1836
  }
1695
1837
  try {
1696
1838
  switch (n.op) {
@@ -1704,23 +1846,23 @@ class Hn {
1704
1846
  default:
1705
1847
  break;
1706
1848
  }
1707
- const i = this.runtime.applyPatch(e, n);
1708
- if (!i)
1849
+ const s = this.runtime.applyPatch(e, n);
1850
+ if (!s)
1709
1851
  return;
1710
- await this.markCutOffChildrenIfNeeded(e, t, i), this.runtime.gasMeter().chargeCascadeRouting(i.cascadeScopes.length);
1711
- for (const o of i.cascadeScopes) {
1852
+ await this.markCutOffChildrenIfNeeded(e, t, s), this.runtime.gasMeter().chargeCascadeRouting(s.cascadeScopes.length);
1853
+ for (const o of s.cascadeScopes) {
1712
1854
  const a = this.bundles.get(o);
1713
1855
  if (!a || this.hooks.isScopeInactive(o))
1714
1856
  continue;
1715
- const c = this.createDocumentUpdateEvent(i, o), l = a.channelsOfType(
1716
- xn
1857
+ const c = this.createDocumentUpdateEvent(s, o), l = a.channelsOfType(
1858
+ Wn
1717
1859
  );
1718
1860
  for (const u of l) {
1719
1861
  const h = u.contract();
1720
1862
  if (this.matchesDocumentUpdate(
1721
1863
  o,
1722
1864
  h.path ?? null,
1723
- i.path
1865
+ s.path
1724
1866
  ) && (await this.channelRunner.runHandlers(
1725
1867
  o,
1726
1868
  a,
@@ -1731,28 +1873,28 @@ class Hn {
1731
1873
  break;
1732
1874
  }
1733
1875
  }
1734
- } catch (i) {
1735
- if (i instanceof T) {
1736
- const o = this.hooks.fatalReason(i, "Boundary violation");
1876
+ } catch (s) {
1877
+ if (s instanceof T) {
1878
+ const o = this.hooks.fatalReason(s, "Boundary violation");
1737
1879
  await this.hooks.enterFatalTermination(e, t, o);
1738
1880
  return;
1739
1881
  }
1740
- if (i instanceof M || i instanceof Error && !(i instanceof m)) {
1741
- const o = this.hooks.fatalReason(i, "Runtime fatal");
1882
+ if (s instanceof N || s instanceof Error && !(s instanceof m)) {
1883
+ const o = this.hooks.fatalReason(s, "Runtime fatal");
1742
1884
  await this.hooks.enterFatalTermination(e, t, o);
1743
1885
  return;
1744
1886
  }
1745
- throw i;
1887
+ throw s;
1746
1888
  }
1747
1889
  }
1748
1890
  }
1749
1891
  async deliverLifecycle(e, t, n, r) {
1750
1892
  if (this.runtime.gasMeter().chargeLifecycleDelivery(), await this.hooks.recordLifecycleForBridging(e, n), !t)
1751
1893
  return;
1752
- const i = t.channelsOfType(
1753
- Un
1894
+ const s = t.channelsOfType(
1895
+ jn
1754
1896
  );
1755
- for (const o of i)
1897
+ for (const o of s)
1756
1898
  if (await this.channelRunner.runHandlers(
1757
1899
  e,
1758
1900
  t,
@@ -1765,18 +1907,18 @@ class Hn {
1765
1907
  }
1766
1908
  async processEmbeddedChildren(e, t) {
1767
1909
  const n = y(e), r = /* @__PURE__ */ new Set();
1768
- let i = this.refreshBundle(n);
1769
- for (; i; ) {
1770
- const o = this.nextEmbeddedPath(i, r);
1910
+ let s = this.refreshBundle(n);
1911
+ for (; s; ) {
1912
+ const o = this.nextEmbeddedPath(s, r);
1771
1913
  if (!o)
1772
- return i;
1914
+ return s;
1773
1915
  r.add(o);
1774
1916
  const a = w(n, o);
1775
1917
  if (a === n || this.hooks.isScopeInactive(a)) {
1776
- i = this.refreshBundle(n);
1918
+ s = this.refreshBundle(n);
1777
1919
  continue;
1778
1920
  }
1779
- this.nodeAt(a) && (await this.initializeScope(a, !1), await this.processExternalEvent(a, t)), i = this.refreshBundle(n);
1921
+ this.nodeAt(a) && (await this.initializeScope(a, !1), await this.processExternalEvent(a, t)), s = this.refreshBundle(n);
1780
1922
  }
1781
1923
  return null;
1782
1924
  }
@@ -1799,7 +1941,7 @@ class Hn {
1799
1941
  try {
1800
1942
  return this.contractLoader.load(e, t);
1801
1943
  } catch (n) {
1802
- if (n instanceof m || n instanceof W)
1944
+ if (n instanceof m || n instanceof F)
1803
1945
  throw n;
1804
1946
  const r = n?.message ?? "Failed to load contracts";
1805
1947
  throw new m(
@@ -1812,7 +1954,7 @@ class Hn {
1812
1954
  }
1813
1955
  }
1814
1956
  async addInitializationMarker(e, t) {
1815
- const n = new d().setType(new d().setBlueId(ke)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(ee);
1957
+ const n = new d().setType(new d().setBlueId(Ie)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(ne);
1816
1958
  await e.applyPatch({
1817
1959
  op: "ADD",
1818
1960
  path: r,
@@ -1826,17 +1968,17 @@ class Hn {
1826
1968
  if (this.hooks.isScopeInactive(e) || t.embeddedPaths().length === 0)
1827
1969
  return;
1828
1970
  const n = t.channelsOfType(
1829
- zn
1971
+ Gn
1830
1972
  );
1831
1973
  if (n.length !== 0)
1832
1974
  for (const r of t.embeddedPaths()) {
1833
- const i = w(e, r), a = this.runtime.scope(i).drainBridgeableEvents();
1975
+ const s = w(e, r), a = this.runtime.scope(s).drainBridgeableEvents();
1834
1976
  if (a.length !== 0)
1835
1977
  for (const c of a) {
1836
1978
  let l = !1;
1837
1979
  for (const u of n) {
1838
1980
  const f = u.contract().childPath ?? "/";
1839
- w(e, f) === i && (l || (this.runtime.gasMeter().chargeBridge(), l = !0), await this.channelRunner.runHandlers(
1981
+ w(e, f) === s && (l || (this.runtime.gasMeter().chargeBridge(), l = !0), await this.channelRunner.runHandlers(
1840
1982
  e,
1841
1983
  t,
1842
1984
  u.key(),
@@ -1851,15 +1993,15 @@ class Hn {
1851
1993
  if (this.hooks.isScopeInactive(e))
1852
1994
  return;
1853
1995
  const n = this.runtime.scope(e), r = t.channelsOfType(
1854
- Fn
1996
+ qn
1855
1997
  );
1856
1998
  if (r.length === 0) {
1857
1999
  n.clearTriggered();
1858
2000
  return;
1859
2001
  }
1860
2002
  for (; !n.triggeredIsEmpty(); ) {
1861
- const i = n.pollTriggered();
1862
- if (!i)
2003
+ const s = n.pollTriggered();
2004
+ if (!s)
1863
2005
  break;
1864
2006
  this.runtime.gasMeter().chargeDrainEvent();
1865
2007
  for (const o of r) {
@@ -1871,7 +2013,7 @@ class Hn {
1871
2013
  e,
1872
2014
  t,
1873
2015
  o.key(),
1874
- i.clone(),
2016
+ s.clone(),
1875
2017
  !1
1876
2018
  ), this.hooks.isScopeInactive(e)) {
1877
2019
  n.clearTriggered();
@@ -1881,33 +2023,33 @@ class Hn {
1881
2023
  }
1882
2024
  }
1883
2025
  validatePatchBoundary(e, t, n) {
1884
- const r = y(e), i = b(n.path);
1885
- if (i === r)
2026
+ const r = y(e), s = b(n.path);
2027
+ if (s === r)
1886
2028
  throw new T(
1887
2029
  `Self-root mutation is forbidden at scope ${r}`
1888
2030
  );
1889
- if (r !== "/" && !i.startsWith(`${r}/`))
2031
+ if (r !== "/" && !s.startsWith(`${r}/`))
1890
2032
  throw new T(
1891
- `Patch path ${i} is outside scope ${r}`
2033
+ `Patch path ${s} is outside scope ${r}`
1892
2034
  );
1893
2035
  for (const o of t.embeddedPaths()) {
1894
2036
  const a = w(r, o);
1895
- if (i.startsWith(`${a}/`))
2037
+ if (s.startsWith(`${a}/`))
1896
2038
  throw new T(
1897
- `Boundary violation: patch ${i} enters embedded scope ${a}`
2039
+ `Boundary violation: patch ${s} enters embedded scope ${a}`
1898
2040
  );
1899
2041
  }
1900
2042
  }
1901
2043
  enforceReservedKeyWriteProtection(e, t, n) {
1902
2044
  if (n)
1903
2045
  return;
1904
- const r = y(e), i = b(t.path);
1905
- for (const o of re) {
2046
+ const r = y(e), s = b(t.path);
2047
+ for (const o of ie) {
1906
2048
  const a = w(
1907
2049
  r,
1908
- q(o)
2050
+ J(o)
1909
2051
  );
1910
- if (i === a || i.startsWith(`${a}/`))
2052
+ if (s === a || s.startsWith(`${a}/`))
1911
2053
  throw new T(
1912
2054
  `Reserved key '${o}' is write-protected at ${a}`
1913
2055
  );
@@ -1917,128 +2059,128 @@ class Hn {
1917
2059
  if (t.embeddedPaths().length === 0)
1918
2060
  return;
1919
2061
  const r = b(n.path);
1920
- for (const i of t.embeddedPaths()) {
1921
- const o = w(e, i);
2062
+ for (const s of t.embeddedPaths()) {
2063
+ const o = w(e, s);
1922
2064
  r === o && (n.op === "remove" || n.op === "replace") && await this.hooks.markCutOff(o);
1923
2065
  }
1924
2066
  }
1925
2067
  hasInitializationMarker(e) {
1926
- const t = w(e, ee), n = this.nodeAt(t);
2068
+ const t = w(e, ne), n = this.nodeAt(t);
1927
2069
  if (!n)
1928
2070
  return !1;
1929
2071
  if (!(n instanceof d)) {
1930
- const i = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
1931
- throw new M(i);
2072
+ const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2073
+ throw new N(s);
1932
2074
  }
1933
- if (n.getType()?.getBlueId() !== ke) {
1934
- const i = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
1935
- throw new M(i);
2075
+ if (n.getType()?.getBlueId() !== Ie) {
2076
+ const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2077
+ throw new N(s);
1936
2078
  }
1937
2079
  return !0;
1938
2080
  }
1939
2081
  createLifecycleEvent(e) {
1940
- return new d().setType(new d().setBlueId(Vn)).setProperties({
2082
+ return new d().setType(new d().setBlueId(Jn)).setProperties({
1941
2083
  type: new d().setValue("Document Processing Initiated"),
1942
2084
  documentId: new d().setValue(e)
1943
2085
  });
1944
2086
  }
1945
2087
  }
1946
- class ne extends Error {
2088
+ class q extends Error {
1947
2089
  constructor(e) {
1948
2090
  super(
1949
2091
  e ? "Processing terminated due to fatal error" : "Processing terminated"
1950
2092
  ), this.fatal = e, this.name = "RunTerminationError";
1951
2093
  }
1952
2094
  }
1953
- const Kn = p["Processing Terminated Marker"], Wn = p["Document Processing Terminated"];
1954
- class Gn {
2095
+ const Yn = p["Processing Terminated Marker"], Zn = p["Document Processing Terminated"];
2096
+ class Xn {
1955
2097
  constructor(e) {
1956
2098
  this.runtime = e;
1957
2099
  }
1958
- async terminateScope(e, t, n, r, i) {
1959
- e.recordPendingTermination(t, r, i ?? null);
2100
+ async terminateScope(e, t, n, r, s) {
2101
+ e.recordPendingTermination(t, r, s ?? null);
1960
2102
  const o = e.normalizeScope(t), a = w(o, De);
1961
2103
  this.runtime.directWrite(
1962
2104
  a,
1963
- qn(this.runtime.blue(), r, i)
2105
+ er(this.runtime.blue(), r, s)
1964
2106
  ), this.runtime.gasMeter().chargeTerminationMarker();
1965
- const c = n ?? e.bundleForScope(o) ?? null, l = Jn(r, i);
2107
+ const c = n ?? e.bundleForScope(o) ?? null, l = tr(r, s);
1966
2108
  if (await e.deliverLifecycle(
1967
2109
  o,
1968
2110
  c,
1969
2111
  l,
1970
2112
  !1
1971
- ), this.runtime.scope(o).finalizeTermination(r, i ?? null), e.clearPendingTermination(t), r === "FATAL" && this.runtime.gasMeter().chargeFatalTerminationOverhead(), r === "FATAL" && o === "/")
1972
- throw this.runtime.markRunTerminated(), new ne(!0);
2113
+ ), this.runtime.scope(o).finalizeTermination(r, s ?? null), e.clearPendingTermination(t), r === "FATAL" && this.runtime.gasMeter().chargeFatalTerminationOverhead(), r === "FATAL" && o === "/")
2114
+ throw this.runtime.markRunTerminated(), new q(!0);
1973
2115
  if (r === "GRACEFUL" && o === "/")
1974
- throw this.runtime.markRunTerminated(), new ne(!1);
2116
+ throw this.runtime.markRunTerminated(), new q(!1);
1975
2117
  }
1976
2118
  }
1977
- function qn(s, e, t) {
1978
- return jn(s, {
1979
- type: { blueId: Kn },
2119
+ function er(i, e, t) {
2120
+ return nr(i, {
2121
+ type: { blueId: Yn },
1980
2122
  cause: e === "GRACEFUL" ? "graceful" : "fatal",
1981
2123
  ...t ? { reason: t } : {}
1982
2124
  });
1983
2125
  }
1984
- function Jn(s, e) {
2126
+ function tr(i, e) {
1985
2127
  const t = new d().setType(
1986
- new d().setBlueId(Wn)
2128
+ new d().setBlueId(Zn)
1987
2129
  );
1988
2130
  return t.addProperty(
1989
2131
  "cause",
1990
- new d().setValue(s === "GRACEFUL" ? "graceful" : "fatal")
2132
+ new d().setValue(i === "GRACEFUL" ? "graceful" : "fatal")
1991
2133
  ), e && t.addProperty("reason", new d().setValue(e)), t;
1992
2134
  }
1993
- function jn(s, e) {
1994
- return s.jsonValueToNode(e);
2135
+ function nr(i, e) {
2136
+ return i.jsonValueToNode(e);
1995
2137
  }
1996
- const _ = "-";
1997
- class Qn {
2138
+ const $ = "-";
2139
+ class rr {
1998
2140
  constructor(e) {
1999
2141
  this.document = e;
2000
2142
  }
2001
2143
  applyPatch(e, t) {
2002
- const n = y(e), r = b(t.path), i = ve(r), o = Ie(this.document, i, "before", r);
2144
+ const n = y(e), r = b(t.path), s = Re(r), o = ve(this.document, s, "before", r);
2003
2145
  switch (t.op) {
2004
2146
  case "ADD":
2005
- this.applyAdd(i, r, t.val ?? null);
2147
+ this.applyAdd(s, r, t.val ?? null);
2006
2148
  break;
2007
2149
  case "REPLACE":
2008
- this.applyReplace(i, r, t.val ?? null);
2150
+ this.applyReplace(s, r, t.val ?? null);
2009
2151
  break;
2010
2152
  case "REMOVE":
2011
- this.applyRemove(i, r);
2153
+ this.applyRemove(s, r);
2012
2154
  break;
2013
2155
  }
2014
- const a = t.op === "REMOVE" ? null : Ie(this.document, i, "after", r);
2156
+ const a = t.op === "REMOVE" ? null : ve(this.document, s, "after", r);
2015
2157
  return {
2016
2158
  path: r,
2017
2159
  before: o,
2018
2160
  after: a,
2019
2161
  op: t.op.toLowerCase(),
2020
2162
  originScope: n,
2021
- cascadeScopes: Yn(n)
2163
+ cascadeScopes: ir(n)
2022
2164
  };
2023
2165
  }
2024
2166
  directWrite(e, t) {
2025
2167
  const n = b(e);
2026
2168
  if (n === "/")
2027
2169
  throw new Error("Direct write cannot target root document");
2028
- const r = ve(n), { parent: i, leaf: o } = this.resolveParent(r);
2029
- if (o === _)
2170
+ const r = Re(n), { parent: s, leaf: o } = this.resolveParent(r);
2171
+ if (o === $)
2030
2172
  throw new Error(
2031
2173
  `Direct write does not support append token '-' for path ${n}`
2032
2174
  );
2033
- const a = i.getItems();
2034
- if (a && R(o)) {
2035
- this.directWriteArray(i, a, o, t, n);
2175
+ const a = s.getItems();
2176
+ if (a && P(o)) {
2177
+ this.directWriteArray(s, a, o, t, n);
2036
2178
  return;
2037
2179
  }
2038
- this.directWriteObject(i, o, t);
2180
+ this.directWriteObject(s, o, t);
2039
2181
  }
2040
- directWriteArray(e, t, n, r, i) {
2041
- const o = Y(e, t), a = C(n, i);
2182
+ directWriteArray(e, t, n, r, s) {
2183
+ const o = X(e, t), a = C(n, s);
2042
2184
  if (r == null) {
2043
2185
  if (a < 0 || a >= o.length)
2044
2186
  return;
@@ -2055,11 +2197,11 @@ class Qn {
2055
2197
  return;
2056
2198
  }
2057
2199
  throw new Error(
2058
- `Array index out of bounds for direct write: ${i}`
2200
+ `Array index out of bounds for direct write: ${s}`
2059
2201
  );
2060
2202
  }
2061
2203
  directWriteObject(e, t, n) {
2062
- const r = V(e);
2204
+ const r = K(e);
2063
2205
  if (n == null) {
2064
2206
  delete r[t], e.setProperties(
2065
2207
  Object.keys(r).length > 0 ? r : void 0
@@ -2079,55 +2221,55 @@ class Qn {
2079
2221
  return { parent: t, leaf: e[e.length - 1] };
2080
2222
  }
2081
2223
  getOrCreateChild(e, t, n, r) {
2082
- if (t === _)
2224
+ if (t === $)
2083
2225
  throw new Error(
2084
2226
  `Append token '-' must be final segment: ${B(n, r)}`
2085
2227
  );
2086
- const i = e.getItems();
2087
- if (i && R(t)) {
2228
+ const s = e.getItems();
2229
+ if (s && P(t)) {
2088
2230
  const c = C(t, B(n, r));
2089
- if (c < 0 || c >= i.length)
2231
+ if (c < 0 || c >= s.length)
2090
2232
  throw new Error(
2091
2233
  `Array index out of bounds: ${B(n, r)}`
2092
2234
  );
2093
- const l = i[c];
2235
+ const l = s[c];
2094
2236
  if (!l)
2095
2237
  throw new Error(
2096
2238
  `Path does not exist: ${B(n, r)}`
2097
2239
  );
2098
2240
  return l;
2099
2241
  }
2100
- const o = V(e);
2242
+ const o = K(e);
2101
2243
  let a = o[t];
2102
2244
  return a || (a = new d(), o[t] = a, e.setProperties(o)), a;
2103
2245
  }
2104
2246
  applyAdd(e, t, n) {
2105
2247
  if (t === "/" || t.length === 0)
2106
2248
  throw new Error("ADD operation cannot target document root");
2107
- const { parent: r, key: i, pointer: o, created: a } = this.resolveParentForPatch(
2249
+ const { parent: r, key: s, pointer: o, created: a } = this.resolveParentForPatch(
2108
2250
  e,
2109
2251
  t,
2110
2252
  "ADD"
2111
2253
  );
2112
2254
  try {
2113
- if (R(i)) {
2114
- const l = r.getItems(), u = i === _;
2255
+ if (P(s)) {
2256
+ const l = r.getItems(), u = s === $;
2115
2257
  if (!l)
2116
2258
  throw new Error(
2117
2259
  u ? `Append token '-' requires array at ${o}` : `Array index segment requires array at ${o}`
2118
2260
  );
2119
2261
  if (u) {
2120
- Y(r, l).push(L(n));
2262
+ X(r, l).push(L(n));
2121
2263
  return;
2122
2264
  }
2123
- const h = C(i, t);
2265
+ const h = C(s, t);
2124
2266
  if (h < 0 || h > l.length)
2125
2267
  throw new Error(`Array index out of bounds in path: ${t}`);
2126
- Y(r, l).splice(h, 0, L(n));
2268
+ X(r, l).splice(h, 0, L(n));
2127
2269
  return;
2128
2270
  }
2129
- const c = V(r);
2130
- c[i] = L(n), r.setProperties(c);
2271
+ const c = K(r);
2272
+ c[s] = L(n), r.setProperties(c);
2131
2273
  } catch (c) {
2132
2274
  throw this.rollbackCreated(a), c;
2133
2275
  }
@@ -2135,24 +2277,24 @@ class Qn {
2135
2277
  applyReplace(e, t, n) {
2136
2278
  if (t === "/" || t.length === 0)
2137
2279
  throw new Error("REPLACE operation cannot target document root");
2138
- const { parent: r, key: i, created: o } = this.resolveParentForPatch(
2280
+ const { parent: r, key: s, created: o } = this.resolveParentForPatch(
2139
2281
  e,
2140
2282
  t,
2141
2283
  "REPLACE"
2142
2284
  );
2143
2285
  try {
2144
- if (R(i)) {
2286
+ if (P(s)) {
2145
2287
  const c = r.getItems();
2146
2288
  if (!c)
2147
2289
  throw new Error(`Array index segment requires array at ${t}`);
2148
- const l = C(i, t);
2290
+ const l = C(s, t);
2149
2291
  if (l < 0 || l >= c.length)
2150
2292
  throw new Error(`Array index out of bounds in path: ${t}`);
2151
2293
  c[l] = L(n), r.setItems(c);
2152
2294
  return;
2153
2295
  }
2154
- const a = V(r);
2155
- a[i] = L(n), r.setProperties(a);
2296
+ const a = K(r);
2297
+ a[s] = L(n), r.setProperties(a);
2156
2298
  } catch (a) {
2157
2299
  throw this.rollbackCreated(o), a;
2158
2300
  }
@@ -2165,7 +2307,7 @@ class Qn {
2165
2307
  t,
2166
2308
  "REMOVE"
2167
2309
  );
2168
- if (R(r)) {
2310
+ if (P(r)) {
2169
2311
  const a = n.getItems();
2170
2312
  if (!a)
2171
2313
  throw new Error(`Array index segment requires array at ${t}`);
@@ -2175,140 +2317,140 @@ class Qn {
2175
2317
  a.splice(c, 1), n.setItems(a);
2176
2318
  return;
2177
2319
  }
2178
- const i = n.getProperties();
2179
- if (!i || !Object.prototype.hasOwnProperty.call(i, r))
2320
+ const s = n.getProperties();
2321
+ if (!s || !Object.prototype.hasOwnProperty.call(s, r))
2180
2322
  throw new Error(`Path does not exist: ${t}`);
2181
- const o = { ...i };
2323
+ const o = { ...s };
2182
2324
  delete o[r], n.setProperties(o);
2183
2325
  }
2184
2326
  resolveParentForPatch(e, t, n) {
2185
2327
  if (e.length === 0)
2186
2328
  throw new Error(`${n} operation cannot target document root`);
2187
2329
  let r = this.document;
2188
- const i = [];
2330
+ const s = [];
2189
2331
  for (let a = 0; a < e.length - 1; a += 1) {
2190
2332
  const c = e[a], l = B(e, a + 1);
2191
- if (R(c)) {
2333
+ if (P(c)) {
2192
2334
  const f = r.getItems();
2193
2335
  if (!f)
2194
2336
  throw new Error(`Array index segment requires array at ${l}`);
2195
2337
  const E = C(c, l);
2196
2338
  if (E < 0 || E >= f.length)
2197
2339
  throw new Error(`Array index out of bounds in path: ${l}`);
2198
- const O = f[E];
2199
- if (!(O instanceof d))
2340
+ const D = f[E];
2341
+ if (!(D instanceof d))
2200
2342
  throw new Error(`Array index out of bounds in path: ${l}`);
2201
- r = O;
2343
+ r = D;
2202
2344
  continue;
2203
2345
  }
2204
2346
  let u = r.getProperties(), h = u?.[c] ?? null;
2205
2347
  if (!(h instanceof d)) {
2206
2348
  if (n === "REMOVE")
2207
2349
  throw new Error(`Path does not exist: ${l}`);
2208
- h = new d(), u || (u = {}), u[c] = h, r.setProperties(u), i.push({ owner: r, key: c });
2350
+ h = new d(), u || (u = {}), u[c] = h, r.setProperties(u), s.push({ owner: r, key: c });
2209
2351
  }
2210
2352
  r = h;
2211
2353
  }
2212
2354
  const o = e[e.length - 1];
2213
- return { parent: r, key: o, pointer: t, created: i };
2355
+ return { parent: r, key: o, pointer: t, created: s };
2214
2356
  }
2215
2357
  rollbackCreated(e) {
2216
2358
  for (let t = e.length - 1; t >= 0; t -= 1) {
2217
- const { owner: n, key: r } = e[t], i = n.getProperties();
2218
- i && (delete i[r], Object.keys(i).length === 0 ? n.setProperties(void 0) : n.setProperties(i));
2359
+ const { owner: n, key: r } = e[t], s = n.getProperties();
2360
+ s && (delete s[r], Object.keys(s).length === 0 ? n.setProperties(void 0) : n.setProperties(s));
2219
2361
  }
2220
2362
  }
2221
2363
  }
2222
- function Yn(s) {
2364
+ function ir(i) {
2223
2365
  const e = [];
2224
- let t = s;
2366
+ let t = i;
2225
2367
  for (; e.push(t), t !== "/"; ) {
2226
2368
  const n = t.lastIndexOf("/");
2227
2369
  t = n <= 0 ? "/" : t.substring(0, n);
2228
2370
  }
2229
2371
  return e;
2230
2372
  }
2231
- function Ie(s, e, t, n) {
2373
+ function ve(i, e, t, n) {
2232
2374
  try {
2233
2375
  if (e.length === 0)
2234
- return s.clone();
2235
- const r = Zn(s, e, t, n);
2376
+ return i.clone();
2377
+ const r = sr(i, e, t, n);
2236
2378
  return r ? r.clone() : null;
2237
2379
  } catch {
2238
2380
  return null;
2239
2381
  }
2240
2382
  }
2241
- function Zn(s, e, t, n) {
2242
- let r = s;
2243
- for (let i = 0; i < e.length; i += 1) {
2244
- const o = e[i] ?? "", a = i === e.length - 1;
2245
- if (r = Xn(r, o, a, t, n), !r)
2383
+ function sr(i, e, t, n) {
2384
+ let r = i;
2385
+ for (let s = 0; s < e.length; s += 1) {
2386
+ const o = e[s] ?? "", a = s === e.length - 1;
2387
+ if (r = or(r, o, a, t, n), !r)
2246
2388
  return null;
2247
2389
  }
2248
2390
  return r;
2249
2391
  }
2250
- function Xn(s, e, t, n, r) {
2251
- if (!s)
2392
+ function or(i, e, t, n, r) {
2393
+ if (!i)
2252
2394
  return null;
2253
- const i = s.getItems();
2254
- if (i) {
2255
- if (e === _) {
2395
+ const s = i.getItems();
2396
+ if (s) {
2397
+ if (e === $) {
2256
2398
  if (!t)
2257
2399
  throw new Error(`Append token '-' must be final segment: ${r}`);
2258
- return n === "before" || i.length === 0 ? null : i[i.length - 1] ?? null;
2400
+ return n === "before" || s.length === 0 ? null : s[s.length - 1] ?? null;
2259
2401
  }
2260
2402
  const c = C(e, r);
2261
- return c < 0 || c >= i.length ? null : i[c] ?? null;
2403
+ return c < 0 || c >= s.length ? null : s[c] ?? null;
2262
2404
  }
2263
- const o = s.getProperties();
2405
+ const o = i.getProperties();
2264
2406
  if (!o)
2265
2407
  return null;
2266
2408
  const a = o[e];
2267
2409
  return a instanceof d ? a : null;
2268
2410
  }
2269
- function ve(s) {
2270
- if (s === "/" || s === "")
2411
+ function Re(i) {
2412
+ if (i === "/" || i === "")
2271
2413
  return [];
2272
- const e = s.startsWith("/") ? s.slice(1) : s;
2414
+ const e = i.startsWith("/") ? i.slice(1) : i;
2273
2415
  return e.length === 0 ? [] : e.split("/");
2274
2416
  }
2275
- function C(s, e) {
2276
- const t = Number.parseInt(s, 10);
2417
+ function C(i, e) {
2418
+ const t = Number.parseInt(i, 10);
2277
2419
  if (Number.isNaN(t))
2278
2420
  throw new Error(`Expected numeric array index in path: ${e}`);
2279
2421
  if (t < 0)
2280
2422
  throw new Error(`Negative array index in path: ${e}`);
2281
2423
  return t;
2282
2424
  }
2283
- function B(s, e) {
2425
+ function B(i, e) {
2284
2426
  if (e <= 0)
2285
2427
  return "/";
2286
- const t = Math.min(e, s.length);
2428
+ const t = Math.min(e, i.length);
2287
2429
  let n = "";
2288
2430
  for (let r = 0; r < t; r += 1)
2289
- n += `/${s[r] ?? ""}`;
2431
+ n += `/${i[r] ?? ""}`;
2290
2432
  return n === "" ? "/" : n;
2291
2433
  }
2292
- function Y(s, e) {
2434
+ function X(i, e) {
2293
2435
  const t = [...e];
2294
- return s.setItems(t), t;
2436
+ return i.setItems(t), t;
2295
2437
  }
2296
- function V(s) {
2297
- const e = s.getProperties();
2438
+ function K(i) {
2439
+ const e = i.getProperties();
2298
2440
  if (!e) {
2299
2441
  const n = {};
2300
- return s.setProperties(n), n;
2442
+ return i.setProperties(n), n;
2301
2443
  }
2302
2444
  const t = { ...e };
2303
- return s.setProperties(t), t;
2445
+ return i.setProperties(t), t;
2304
2446
  }
2305
- function R(s) {
2306
- return s === _ || /^\d+$/.test(s);
2447
+ function P(i) {
2448
+ return i === $ || /^\d+$/.test(i);
2307
2449
  }
2308
- function L(s) {
2309
- return s == null ? new d().setValue(null) : s.clone();
2450
+ function L(i) {
2451
+ return i == null ? new d().setValue(null) : i.clone();
2310
2452
  }
2311
- class er {
2453
+ class ar {
2312
2454
  constructor(e) {
2313
2455
  this.path = e;
2314
2456
  }
@@ -2370,7 +2512,7 @@ class er {
2370
2512
  return this.cutOff;
2371
2513
  }
2372
2514
  }
2373
- class tr {
2515
+ class cr {
2374
2516
  scopesMap = /* @__PURE__ */ new Map();
2375
2517
  rootEmissionList = [];
2376
2518
  scopes() {
@@ -2378,7 +2520,7 @@ class tr {
2378
2520
  }
2379
2521
  scope(e) {
2380
2522
  let t = this.scopesMap.get(e);
2381
- return t || (t = new er(e), this.scopesMap.set(e, t)), t;
2523
+ return t || (t = new ar(e), this.scopesMap.set(e, t)), t;
2382
2524
  }
2383
2525
  existingScope(e) {
2384
2526
  return this.scopesMap.get(e);
@@ -2396,45 +2538,45 @@ class tr {
2396
2538
  this.scopesMap.delete(e);
2397
2539
  }
2398
2540
  }
2399
- function F(s) {
2400
- return Math.floor((s + 99) / 100);
2541
+ function U(i) {
2542
+ return Math.floor((i + 99) / 100);
2401
2543
  }
2402
- function le(s) {
2403
- return new TextEncoder().encode(s).length;
2544
+ function ue(i) {
2545
+ return new TextEncoder().encode(i).length;
2404
2546
  }
2405
- function nr(s) {
2406
- const e = b(s);
2547
+ function lr(i) {
2548
+ const e = b(i);
2407
2549
  return e === "/" ? 0 : e.split("/").length - 1;
2408
2550
  }
2409
- function rr(s) {
2410
- return 100 + F(le(s));
2551
+ function ur(i) {
2552
+ return 100 + U(ue(i));
2411
2553
  }
2412
- function ir(s) {
2413
- return 40 + 5 * Math.max(0, s);
2554
+ function dr(i) {
2555
+ return 40 + 5 * Math.max(0, i);
2414
2556
  }
2415
- function sr(s) {
2416
- return 5 + F(le(s));
2557
+ function hr(i) {
2558
+ return 5 + U(ue(i));
2417
2559
  }
2418
- function or(s, e) {
2419
- return 3 * Math.max(0, s) + F(le(e));
2560
+ function fr(i, e) {
2561
+ return 3 * Math.max(0, i) + U(ue(e));
2420
2562
  }
2421
- function ar(s, e) {
2422
- return 8 + nr(s) + F(e);
2563
+ function pr(i, e) {
2564
+ return 8 + lr(i) + U(e);
2423
2565
  }
2424
- const cr = 1e3, lr = 5, ur = 50, dr = 2, hr = 10, fr = 10, pr = 10, mr = 20, gr = 20, Er = 30, yr = 30, wr = 100;
2425
- function br(s) {
2426
- return 50 + 10 * s;
2566
+ const mr = 1e3, gr = 5, Er = 50, yr = 2, wr = 10, br = 10, Sr = 10, Cr = 20, kr = 20, Ir = 30, vr = 30, Rr = 100;
2567
+ function Tr(i) {
2568
+ return 50 + 10 * i;
2427
2569
  }
2428
- function Sr(s) {
2429
- return 20 + s;
2570
+ function Pr(i) {
2571
+ return 20 + i;
2430
2572
  }
2431
- function Cr(s) {
2432
- return 10 * s;
2573
+ function Nr(i) {
2574
+ return 10 * i;
2433
2575
  }
2434
- function kr(s) {
2435
- return 20 + s;
2576
+ function Mr(i) {
2577
+ return 20 + i;
2436
2578
  }
2437
- class Ir {
2579
+ class Ar {
2438
2580
  constructor(e) {
2439
2581
  this.blue = e;
2440
2582
  }
@@ -2446,74 +2588,74 @@ class Ir {
2446
2588
  this.total += e;
2447
2589
  }
2448
2590
  chargeScopeEntry(e) {
2449
- this.add(br(this.scopeDepth(e)));
2591
+ this.add(Tr(this.scopeDepth(e)));
2450
2592
  }
2451
2593
  chargeInitialization() {
2452
- this.add(cr);
2594
+ this.add(mr);
2453
2595
  }
2454
2596
  chargeChannelMatchAttempt() {
2455
- this.add(lr);
2597
+ this.add(gr);
2456
2598
  }
2457
2599
  chargeHandlerOverhead() {
2458
- this.add(ur);
2600
+ this.add(Er);
2459
2601
  }
2460
2602
  chargeBoundaryCheck() {
2461
- this.add(dr);
2603
+ this.add(yr);
2462
2604
  }
2463
2605
  chargePatchAddOrReplace(e) {
2464
- this.add(Sr(this.payloadSizeCharge(e)));
2606
+ this.add(Pr(this.payloadSizeCharge(e)));
2465
2607
  }
2466
2608
  chargePatchRemove() {
2467
- this.add(hr);
2609
+ this.add(wr);
2468
2610
  }
2469
2611
  chargeCascadeRouting(e) {
2470
- e > 0 && this.add(Cr(e));
2612
+ e > 0 && this.add(Nr(e));
2471
2613
  }
2472
2614
  chargeEmitEvent(e) {
2473
- this.add(kr(this.payloadSizeCharge(e)));
2615
+ this.add(Mr(this.payloadSizeCharge(e)));
2474
2616
  }
2475
2617
  chargeBridge() {
2476
- this.add(fr);
2618
+ this.add(br);
2477
2619
  }
2478
2620
  chargeDrainEvent() {
2479
- this.add(pr);
2621
+ this.add(Sr);
2480
2622
  }
2481
2623
  chargeCheckpointUpdate() {
2482
- this.add(mr);
2624
+ this.add(Cr);
2483
2625
  }
2484
2626
  chargeTerminationMarker() {
2485
- this.add(gr);
2627
+ this.add(kr);
2486
2628
  }
2487
2629
  chargeLifecycleDelivery() {
2488
- this.add(Er);
2630
+ this.add(Ir);
2489
2631
  }
2490
2632
  chargeFatalTerminationOverhead() {
2491
- this.add(wr);
2633
+ this.add(Rr);
2492
2634
  }
2493
2635
  chargeJavaScriptCodeBase(e) {
2494
- this.add(rr(e));
2636
+ this.add(ur(e));
2495
2637
  }
2496
2638
  chargeTriggerEventBase() {
2497
- this.add(yr);
2639
+ this.add(vr);
2498
2640
  }
2499
2641
  chargeUpdateDocumentBase(e) {
2500
- this.add(ir(e));
2642
+ this.add(dr(e));
2501
2643
  }
2502
2644
  chargeExpression(e) {
2503
- this.add(sr(e));
2645
+ this.add(hr(e));
2504
2646
  }
2505
2647
  chargeTemplate(e, t) {
2506
- this.add(or(e, t));
2648
+ this.add(fr(e, t));
2507
2649
  }
2508
2650
  chargeDocumentSnapshot(e, t) {
2509
- const n = t ? Ee(this.blue, t) : 0;
2510
- this.add(ar(e, n));
2651
+ const n = t ? ye(this.blue, t) : 0;
2652
+ this.add(pr(e, n));
2511
2653
  }
2512
2654
  payloadSizeCharge(e) {
2513
2655
  if (!e)
2514
2656
  return 0;
2515
- const t = Ee(this.blue, e);
2516
- return F(t);
2657
+ const t = ye(this.blue, e);
2658
+ return U(t);
2517
2659
  }
2518
2660
  scopeDepth(e) {
2519
2661
  const t = y(e);
@@ -2525,12 +2667,12 @@ class Ir {
2525
2667
  return n;
2526
2668
  }
2527
2669
  }
2528
- class vr {
2670
+ class Or {
2529
2671
  constructor(e, t) {
2530
- this.documentRef = e, this.blueRef = t, this.patchEngine = new Qn(this.documentRef), this.meter = new Ir(this.blueRef);
2672
+ this.documentRef = e, this.blueRef = t, this.patchEngine = new rr(this.documentRef), this.meter = new Ar(this.blueRef);
2531
2673
  }
2532
2674
  patchEngine;
2533
- emissionRegistry = new tr();
2675
+ emissionRegistry = new cr();
2534
2676
  meter;
2535
2677
  runTerminated = !1;
2536
2678
  document() {
@@ -2579,15 +2721,15 @@ class vr {
2579
2721
  return this.patchEngine.applyPatch(e, t);
2580
2722
  }
2581
2723
  }
2582
- const Tr = p["Processing Initialized Marker"], Rr = p["Document Update"];
2583
- class Pr {
2724
+ const Dr = p["Processing Initialized Marker"], Br = p["Document Update"];
2725
+ class Lr {
2584
2726
  constructor(e, t, n, r) {
2585
- this.contractLoader = e, this.registry = t, this.runtimeRef = new vr(r, n);
2586
- const i = (o) => ze(this.runtimeRef.blue(), o);
2587
- this.checkpointManager = new _n(
2727
+ this.contractLoader = e, this.registry = t, this.runtimeRef = new Or(r, n);
2728
+ const s = (o) => ze(this.runtimeRef.blue(), o);
2729
+ this.checkpointManager = new Vn(
2588
2730
  this.runtimeRef,
2589
- i
2590
- ), this.terminationService = new Gn(this.runtimeRef), this.channelRunner = new $n(
2731
+ s
2732
+ ), this.terminationService = new Xn(this.runtimeRef), this.channelRunner = new Kn(
2591
2733
  this.runtimeRef,
2592
2734
  this.checkpointManager,
2593
2735
  {
@@ -2613,9 +2755,10 @@ class Pr {
2613
2755
  return typeof l != "function" ? !0 : await l.call(c, o.contract(), a);
2614
2756
  },
2615
2757
  executeHandler: async (o, a) => this.executeHandler(o, a),
2616
- canonicalSignature: i
2758
+ handleHandlerError: async (o, a, c) => this.handleHandlerError(o, a, c),
2759
+ canonicalSignature: s
2617
2760
  }
2618
- ), this.scopeExecutor = new Hn({
2761
+ ), this.scopeExecutor = new Qn({
2619
2762
  runtime: this.runtimeRef,
2620
2763
  contractLoader: this.contractLoader,
2621
2764
  channelRunner: this.channelRunner,
@@ -2631,7 +2774,7 @@ class Pr {
2631
2774
  ),
2632
2775
  recordLifecycleForBridging: (o, a) => this.recordLifecycleForBridging(o, a),
2633
2776
  enterFatalTermination: (o, a, c) => this.enterFatalTermination(o, a, c ?? null),
2634
- fatalReason: (o, a) => o instanceof Error && o.message || a,
2777
+ fatalReason: (o, a) => this.fatalReason(o, a),
2635
2778
  markCutOff: (o) => this.markCutOff(o)
2636
2779
  },
2637
2780
  blueId: (o) => this.runtimeRef.blue().calculateBlueIdSync(o),
@@ -2665,19 +2808,19 @@ class Pr {
2665
2808
  r
2666
2809
  );
2667
2810
  }
2668
- createContext(e, t, n, r = !1, i = !1) {
2669
- return new Mr(
2811
+ createContext(e, t, n, r = !1, s = !1) {
2812
+ return new _r(
2670
2813
  this,
2671
2814
  t,
2672
2815
  e,
2673
2816
  n.clone(),
2674
2817
  r,
2675
- i
2818
+ s
2676
2819
  );
2677
2820
  }
2678
2821
  result() {
2679
2822
  const e = this.runtimeRef.document().clone(), t = this.runtimeRef.rootEmissions().map((n) => n.clone());
2680
- return Re.of(
2823
+ return Pe.of(
2681
2824
  e,
2682
2825
  t,
2683
2826
  this.runtimeRef.totalGas()
@@ -2727,8 +2870,8 @@ class Pr {
2727
2870
  return w(e, t);
2728
2871
  }
2729
2872
  async terminate(e, t, n, r) {
2730
- const i = y(e);
2731
- this.pendingTerminations.has(i) || this.runtimeRef.isScopeTerminated(i) || (this.pendingTerminations.set(i, { kind: n, reason: r }), await this.terminationService.terminateScope(
2873
+ const s = y(e);
2874
+ this.pendingTerminations.has(s) || this.runtimeRef.isScopeTerminated(s) || (this.pendingTerminations.set(s, { kind: n, reason: r }), await this.terminationService.terminateScope(
2732
2875
  this,
2733
2876
  e,
2734
2877
  t,
@@ -2738,11 +2881,11 @@ class Pr {
2738
2881
  }
2739
2882
  nodeAt(e) {
2740
2883
  const t = y(e);
2741
- return G.nodeAt(this.runtimeRef.document(), t);
2884
+ return j.nodeAt(this.runtimeRef.document(), t);
2742
2885
  }
2743
2886
  async evaluateChannel(e, t, n, r) {
2744
- const i = this.registry.lookupChannel(e.blueId());
2745
- if (!i)
2887
+ const s = this.registry.lookupChannel(e.blueId());
2888
+ if (!s)
2746
2889
  return { matches: !1 };
2747
2890
  const o = this.runtimeRef.blue().calculateBlueIdSync(r), a = r.clone(), c = {
2748
2891
  scopePath: n,
@@ -2751,12 +2894,12 @@ class Pr {
2751
2894
  markers: t.markers(),
2752
2895
  bindingKey: e.key()
2753
2896
  };
2754
- if (!await i.matches(
2897
+ if (!await s.matches(
2755
2898
  e.contract(),
2756
2899
  c
2757
2900
  ))
2758
2901
  return { matches: !1 };
2759
- const u = i.channelize, h = u ? u.call(i, e.contract(), c) : void 0;
2902
+ const u = s.channelize, h = u ? u.call(s, e.contract(), c) : void 0;
2760
2903
  return {
2761
2904
  matches: !0,
2762
2905
  eventId: o,
@@ -2774,31 +2917,45 @@ class Pr {
2774
2917
  }
2775
2918
  await n.execute(e.contract(), t);
2776
2919
  }
2920
+ /**
2921
+ * Converts unexpected handler failures into fatal terminations while allowing
2922
+ * sentinel errors (RunTerminationError/MustUnderstandFailure) to propagate so
2923
+ * the outer run logic can react according to spec (§22).
2924
+ */
2925
+ async handleHandlerError(e, t, n) {
2926
+ if (n instanceof q || n instanceof F)
2927
+ throw n;
2928
+ const r = this.fatalReason(n, "Runtime fatal");
2929
+ await this.enterFatalTermination(e, t, r);
2930
+ }
2931
+ fatalReason(e, t) {
2932
+ return e instanceof Error && typeof e.message == "string" ? e.message : t;
2933
+ }
2777
2934
  createDocumentUpdateEvent(e, t) {
2778
- const n = Pt(t, e.path), r = e.before != null ? e.before.clone() : new d().setValue(null), i = e.after != null ? e.after.clone() : new d().setValue(null), o = new d().setType(
2779
- new d().setBlueId(Rr)
2935
+ const n = Mt(t, e.path), r = e.before != null ? e.before.clone() : new d().setValue(null), s = e.after != null ? e.after.clone() : new d().setValue(null), o = new d().setType(
2936
+ new d().setBlueId(Br)
2780
2937
  );
2781
2938
  return o.setProperties({
2782
2939
  op: new d().setValue(e.op),
2783
2940
  path: new d().setValue(n),
2784
2941
  before: r,
2785
- after: i
2942
+ after: s
2786
2943
  }), o;
2787
2944
  }
2788
2945
  matchesDocumentUpdate(e, t, n) {
2789
2946
  if (!t || t.length === 0)
2790
2947
  return !1;
2791
- const r = b(w(e, t)), i = b(n);
2792
- return r === "/" || i === r ? !0 : i.startsWith(`${r}/`);
2948
+ const r = b(w(e, t)), s = b(n);
2949
+ return r === "/" || s === r ? !0 : s.startsWith(`${r}/`);
2793
2950
  }
2794
2951
  }
2795
- class G {
2952
+ class j {
2796
2953
  constructor(e, t, n) {
2797
2954
  this.contractLoader = e, this.registry = t, this.blue = n;
2798
2955
  }
2799
2956
  async initializeDocument(e) {
2800
2957
  if (this.isInitialized(e))
2801
- throw new M("Document already initialized");
2958
+ throw new N("Document already initialized");
2802
2959
  const t = this.createExecution(e.clone());
2803
2960
  return this.run(e, t, async () => {
2804
2961
  await t.initializeScope("/", !0);
@@ -2806,7 +2963,7 @@ class G {
2806
2963
  }
2807
2964
  async processDocument(e, t) {
2808
2965
  if (!this.isInitialized(e))
2809
- throw new M("Document not initialized");
2966
+ throw new N("Document not initialized");
2810
2967
  const n = this.createExecution(e.clone()), r = t.clone();
2811
2968
  return this.run(e, n, async () => {
2812
2969
  n.loadBundles("/"), await n.processExternalEvent("/", r);
@@ -2816,7 +2973,7 @@ class G {
2816
2973
  return this.initializationMarker(e) != null;
2817
2974
  }
2818
2975
  createExecution(e) {
2819
- return new Pr(
2976
+ return new Lr(
2820
2977
  this.contractLoader,
2821
2978
  this.registry,
2822
2979
  this.blue,
@@ -2827,12 +2984,12 @@ class G {
2827
2984
  try {
2828
2985
  await n();
2829
2986
  } catch (r) {
2830
- if (r instanceof ne)
2987
+ if (r instanceof q)
2831
2988
  return t.result();
2832
- if (r instanceof W) {
2833
- const i = e.clone();
2834
- return Re.capabilityFailure(
2835
- i,
2989
+ if (r instanceof F) {
2990
+ const s = e.clone();
2991
+ return Pe.capabilityFailure(
2992
+ s,
2836
2993
  r.message ?? null
2837
2994
  );
2838
2995
  }
@@ -2851,7 +3008,7 @@ class G {
2851
3008
  "Initialization Marker must be a BlueNode"
2852
3009
  )
2853
3010
  );
2854
- if (n.getType()?.getBlueId() !== Tr)
3011
+ if (n.getType()?.getBlueId() !== Dr)
2855
3012
  throw new m(
2856
3013
  "Initialization Marker must declare type 'Processing Initialized Marker'",
2857
3014
  g.illegalState(
@@ -2867,32 +3024,32 @@ class G {
2867
3024
  if (n === "/")
2868
3025
  return e;
2869
3026
  const r = n.slice(1).split("/");
2870
- let i = e;
3027
+ let s = e;
2871
3028
  for (const o of r) {
2872
- if (!i)
3029
+ if (!s)
2873
3030
  return null;
2874
3031
  if (!o)
2875
3032
  continue;
2876
- const a = i.getItems();
3033
+ const a = s.getItems();
2877
3034
  if (a && /^\d+$/.test(o)) {
2878
3035
  const u = Number.parseInt(o, 10);
2879
- i = a[u] ?? null;
3036
+ s = a[u] ?? null;
2880
3037
  continue;
2881
3038
  }
2882
- const c = i.getProperties();
3039
+ const c = s.getProperties();
2883
3040
  if (!c)
2884
3041
  return null;
2885
3042
  const l = c[o];
2886
3043
  if (!(l instanceof d))
2887
3044
  return null;
2888
- i = l;
3045
+ s = l;
2889
3046
  }
2890
- return i;
3047
+ return s;
2891
3048
  }
2892
3049
  }
2893
- class Mr {
2894
- constructor(e, t, n, r, i, o) {
2895
- this.execution = e, this.bundle = t, this.scopePathValue = n, this.eventNode = r, this.allowTerminatedWork = i, this.allowReservedMutation = o;
3050
+ class _r {
3051
+ constructor(e, t, n, r, s, o) {
3052
+ this.execution = e, this.bundle = t, this.scopePathValue = n, this.eventNode = r, this.allowTerminatedWork = s, this.allowReservedMutation = o;
2896
3053
  }
2897
3054
  get scopePath() {
2898
3055
  return this.scopePathValue;
@@ -2945,7 +3102,7 @@ class Mr {
2945
3102
  if (!e)
2946
3103
  return !1;
2947
3104
  try {
2948
- return G.nodeAt(
3105
+ return j.nodeAt(
2949
3106
  this.execution.runtime().document(),
2950
3107
  e
2951
3108
  ) != null;
@@ -2954,7 +3111,7 @@ class Mr {
2954
3111
  }
2955
3112
  }
2956
3113
  documentNodeAt(e) {
2957
- const t = G.nodeAt(
3114
+ const t = j.nodeAt(
2958
3115
  this.execution.runtime().document(),
2959
3116
  e
2960
3117
  );
@@ -2978,16 +3135,16 @@ class Mr {
2978
3135
  return !this.allowTerminatedWork && this.execution.isScopeInactive(this.scopePathValue);
2979
3136
  }
2980
3137
  }
2981
- const Nr = new ht({
2982
- repositories: [lt, gt, wt]
3138
+ const $r = new pt({
3139
+ repositories: [dt, yt, St]
2983
3140
  });
2984
- class Ar {
3141
+ class xr {
2985
3142
  blue;
2986
3143
  registryRef;
2987
3144
  contractLoaderRef;
2988
3145
  engine;
2989
3146
  constructor(e) {
2990
- this.registryRef = e?.registry ?? J.create().registerDefaults().build(), this.blue = e?.blue ?? Nr, this.contractLoaderRef = new An(this.registryRef, this.blue), this.engine = new G(
3147
+ this.registryRef = e?.registry ?? Q.create().registerDefaults().build(), this.blue = e?.blue ?? $r, this.contractLoaderRef = new xn(this.registryRef, this.blue), this.engine = new j(
2991
3148
  this.contractLoaderRef,
2992
3149
  this.registryRef,
2993
3150
  this.blue
@@ -3020,14 +3177,14 @@ class Ar {
3020
3177
  return this.contractLoaderRef;
3021
3178
  }
3022
3179
  static builder() {
3023
- return new Dr();
3180
+ return new Fr();
3024
3181
  }
3025
3182
  }
3026
- class Dr {
3183
+ class Fr {
3027
3184
  contractRegistry;
3028
3185
  blueInstance;
3029
3186
  constructor() {
3030
- this.contractRegistry = J.create().registerDefaults().build();
3187
+ this.contractRegistry = Q.create().registerDefaults().build();
3031
3188
  }
3032
3189
  withRegistry(e) {
3033
3190
  return this.contractRegistry = e, this;
@@ -3039,16 +3196,16 @@ class Dr {
3039
3196
  return this.blueInstance = e, this;
3040
3197
  }
3041
3198
  build() {
3042
- return new Ar({
3199
+ return new xr({
3043
3200
  registry: this.contractRegistry,
3044
3201
  blue: this.blueInstance
3045
3202
  });
3046
3203
  }
3047
3204
  }
3048
- class je {
3205
+ class Ye {
3049
3206
  process(e, t) {
3050
3207
  const n = t.getValue();
3051
- if (H(n)) {
3208
+ if (W(n)) {
3052
3209
  const r = t.clone();
3053
3210
  return r.setValue(n), r.setProperties(void 0), r.setItems(void 0), r.setType(void 0), r;
3054
3211
  }
@@ -3059,118 +3216,118 @@ class je {
3059
3216
  */
3060
3217
  postProcess(e, t) {
3061
3218
  const n = t.getValue();
3062
- if (H(n) && e.getValue() !== n && n !== void 0) {
3219
+ if (W(n) && e.getValue() !== n && n !== void 0) {
3063
3220
  const r = e.clone();
3064
3221
  return r.setValue(n), r;
3065
3222
  }
3066
3223
  return e;
3067
3224
  }
3068
3225
  }
3069
- const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3226
+ const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3070
3227
  __proto__: null,
3071
- ExpressionPreserver: je
3228
+ ExpressionPreserver: Ye
3072
3229
  }, Symbol.toStringTag, { value: "Module" }));
3073
- function ti() {
3074
- return new v.SequentialMergingProcessor([
3075
- new v.ValuePropagator(),
3076
- new je(),
3077
- new v.TypeAssigner(),
3078
- new v.ListProcessor(),
3079
- new v.DictionaryProcessor(),
3080
- new v.BasicTypesVerifier()
3230
+ function ci() {
3231
+ return new R.SequentialMergingProcessor([
3232
+ new R.ValuePropagator(),
3233
+ new Ye(),
3234
+ new R.TypeAssigner(),
3235
+ new R.ListProcessor(),
3236
+ new R.DictionaryProcessor(),
3237
+ new R.BasicTypesVerifier()
3081
3238
  ]);
3082
3239
  }
3083
3240
  export {
3084
- wn as ChannelBinding,
3085
- $n as ChannelRunner,
3086
- _n as CheckpointManager,
3087
- Ln as CheckpointRecord,
3088
- Fe as CodeBlockEvaluationError,
3089
- N as ContractBundle,
3090
- Sn as ContractBundleBuilder,
3091
- An as ContractLoader,
3092
- rn as ContractProcessorRegistry,
3093
- J as ContractProcessorRegistryBuilder,
3094
- Re as DocumentProcessingResult,
3095
- vr as DocumentProcessingRuntime,
3096
- Ar as DocumentProcessor,
3097
- Dr as DocumentProcessorBuilder,
3098
- tr as EmissionRegistry,
3099
- Ir as GasMeter,
3100
- bn as HandlerBinding,
3101
- k as KEY_CHECKPOINT,
3102
- Pe as KEY_EMBEDDED,
3241
+ Rn as ChannelBinding,
3242
+ Kn as ChannelRunner,
3243
+ Vn as CheckpointManager,
3244
+ Un as CheckpointRecord,
3245
+ Ue as CodeBlockEvaluationError,
3246
+ M as ContractBundle,
3247
+ Pn as ContractBundleBuilder,
3248
+ xn as ContractLoader,
3249
+ ln as ContractProcessorRegistry,
3250
+ Q as ContractProcessorRegistryBuilder,
3251
+ Pe as DocumentProcessingResult,
3252
+ Or as DocumentProcessingRuntime,
3253
+ xr as DocumentProcessor,
3254
+ Fr as DocumentProcessorBuilder,
3255
+ cr as EmissionRegistry,
3256
+ Ar as GasMeter,
3257
+ Tn as HandlerBinding,
3258
+ I as KEY_CHECKPOINT,
3259
+ Ne as KEY_EMBEDDED,
3103
3260
  Me as KEY_INITIALIZED,
3104
- Ne as KEY_TERMINATED,
3105
- ei as MergingProcessors,
3106
- Ae as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3107
- Qn as PatchEngine,
3108
- jr as ProcessorContractConstants,
3109
- G as ProcessorEngine,
3261
+ Ae as KEY_TERMINATED,
3262
+ ai as MergingProcessors,
3263
+ Oe as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3264
+ rr as PatchEngine,
3265
+ ni as ProcessorContractConstants,
3266
+ j as ProcessorEngine,
3110
3267
  g as ProcessorErrors,
3111
- Pr as ProcessorExecution,
3112
- Mr as ProcessorExecutionContext,
3268
+ Lr as ProcessorExecution,
3269
+ _r as ProcessorExecutionContext,
3113
3270
  m as ProcessorFatalError,
3114
- Qr as ProcessorPointerConstants,
3115
- se as QuickJSEvaluator,
3116
- Oe as RELATIVE_CHECKPOINT,
3271
+ ri as ProcessorPointerConstants,
3272
+ oe as QuickJSEvaluator,
3273
+ Be as RELATIVE_CHECKPOINT,
3117
3274
  A as RELATIVE_CONTRACTS,
3118
- Rt as RELATIVE_EMBEDDED,
3119
- ee as RELATIVE_INITIALIZED,
3275
+ Nt as RELATIVE_EMBEDDED,
3276
+ ne as RELATIVE_INITIALIZED,
3120
3277
  De as RELATIVE_TERMINATED,
3121
- re as RESERVED_CONTRACT_KEYS,
3122
- ne as RunTerminationError,
3123
- Hn as ScopeExecutor,
3124
- er as ScopeRuntimeContext,
3125
- Gn as TerminationService,
3126
- Wr as andThen,
3278
+ ie as RESERVED_CONTRACT_KEYS,
3279
+ q as RunTerminationError,
3280
+ Qn as ScopeExecutor,
3281
+ ar as ScopeRuntimeContext,
3282
+ Xn as TerminationService,
3283
+ Zr as andThen,
3127
3284
  ze as canonicalSignature,
3128
- Ee as canonicalSize,
3129
- D as channelContractBaseSchema,
3130
- jt as channelEventCheckpointSchema,
3131
- zt as containsExpression,
3132
- oe as contractBaseSchema,
3133
- ti as createDefaultMergingProcessor,
3134
- Ke as createPicomatchShouldResolve,
3135
- Ht as documentUpdateChannelSchema,
3136
- Kt as embeddedNodeChannelSchema,
3137
- St as err,
3138
- He as evaluateQuickJSExpression,
3139
- Ft as extractExpressionContent,
3140
- We as handlerContractBaseSchema,
3141
- Qt as initializationMarkerSchema,
3142
- Vr as isErr,
3143
- H as isExpression,
3144
- Ur as isOk,
3145
- ie as isProcessorManagedChannelBlueId,
3146
- Tt as isReservedContractKey,
3147
- Yr as joinRelativePointers,
3148
- Zr as jsonPatchSchema,
3149
- Wt as lifecycleChannelSchema,
3150
- Hr as map,
3151
- Kr as mapErr,
3152
- z as markerContractBaseSchema,
3153
- Jr as match,
3154
- Jt as myosTimelineChannelSchema,
3285
+ ye as canonicalSize,
3286
+ O as channelContractBaseSchema,
3287
+ en as channelEventCheckpointSchema,
3288
+ Kt as containsExpression,
3289
+ ae as contractBaseSchema,
3290
+ ci as createDefaultMergingProcessor,
3291
+ Ge as createPicomatchShouldResolve,
3292
+ jt as documentUpdateChannelSchema,
3293
+ Jt as embeddedNodeChannelSchema,
3294
+ kt as err,
3295
+ We as evaluateQuickJSExpression,
3296
+ Wt as extractExpressionContent,
3297
+ qe as handlerContractBaseSchema,
3298
+ tn as initializationMarkerSchema,
3299
+ Jr as isErr,
3300
+ W as isExpression,
3301
+ jr as isOk,
3302
+ se as isProcessorManagedChannelBlueId,
3303
+ Pt as isReservedContractKey,
3304
+ ii as joinRelativePointers,
3305
+ si as jsonPatchSchema,
3306
+ Qt as lifecycleChannelSchema,
3307
+ Qr as map,
3308
+ Yr as mapErr,
3309
+ H as markerContractBaseSchema,
3310
+ ti as match,
3311
+ Xt as myosTimelineChannelSchema,
3155
3312
  b as normalizePointer,
3156
3313
  y as normalizeScope,
3157
- bt as ok,
3158
- Xt as operationMarkerSchema,
3159
- Yt as processEmbeddedMarkerSchema,
3160
- Zt as processingTerminatedMarkerSchema,
3161
- _e as relativeCheckpointLastEvent,
3162
- $e as relativeCheckpointLastSignature,
3163
- q as relativeContractsEntry,
3164
- Pt as relativizePointer,
3165
- K as resolveNodeExpressions,
3314
+ Ct as ok,
3315
+ sn as operationMarkerSchema,
3316
+ nn as processEmbeddedMarkerSchema,
3317
+ rn as processingTerminatedMarkerSchema,
3318
+ $e as relativeCheckpointLastEvent,
3319
+ xe as relativeCheckpointLastSignature,
3320
+ J as relativeContractsEntry,
3321
+ Mt as relativizePointer,
3322
+ G as resolveNodeExpressions,
3166
3323
  w as resolvePointer,
3167
- Ut as resolveTemplateString,
3168
- tn as sequentialWorkflowOperationSchema,
3169
- en as sequentialWorkflowSchema,
3170
- Xr as sequentialWorkflowStepSchema,
3171
- me as stripSlashes,
3172
- qt as timelineChannelSchema,
3173
- Gt as triggeredEventChannelSchema,
3174
- Gr as unwrapOr,
3175
- qr as unwrapOrElse
3324
+ Gt as resolveTemplateString,
3325
+ an as sequentialWorkflowOperationSchema,
3326
+ on as sequentialWorkflowSchema,
3327
+ oi as sequentialWorkflowStepSchema,
3328
+ ge as stripSlashes,
3329
+ Zt as timelineChannelSchema,
3330
+ Yt as triggeredEventChannelSchema,
3331
+ Xr as unwrapOr,
3332
+ ei as unwrapOrElse
3176
3333
  };