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

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,42 +1,42 @@
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";
1
+ import { blueIds as m, 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
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
- import { z as S, ZodError as Te } from "zod";
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";
3
+ import { BlueNode as d, blueNodeField as z, withTypeBlueId as ft, Blue as pt, MergingProcessors as T } from "@blue-labs/language";
4
+ import he from "picomatch";
5
+ import { z as S, ZodError as Pe } from "zod";
6
+ import { TimelineChannelSchema as mt, OperationSchema as x, SequentialWorkflowSchema as gt, SequentialWorkflowOperationSchema as Et, TimelineEntrySchema as k, blueIds as R, TriggerEventSchema as fe, JavaScriptCodeSchema as pe, UpdateDocumentSchema as me, OperationRequestSchema as te, repository as yt } from "@blue-repository/conversation";
7
+ import { MyOSTimelineChannelSchema as wt, blueIds as bt, MyOSTimelineEntrySchema as ge, repository as St } from "@blue-repository/myos";
8
+ import { isNullable as ne } from "@blue-labs/shared-utils";
9
9
  function Ct(i) {
10
10
  return { ok: !0, value: i };
11
11
  }
12
- function kt(i) {
12
+ function vt(i) {
13
13
  return { ok: !1, error: i };
14
14
  }
15
- function jr(i) {
15
+ function Yr(i) {
16
16
  return i.ok;
17
17
  }
18
- function Jr(i) {
18
+ function Zr(i) {
19
19
  return !i.ok;
20
20
  }
21
- function Qr(i, e) {
21
+ function Xr(i, e) {
22
22
  return i.ok ? Ct(e(i.value)) : i;
23
23
  }
24
- function Yr(i, e) {
25
- return i.ok ? i : kt(e(i.error));
24
+ function ei(i, e) {
25
+ return i.ok ? i : vt(e(i.error));
26
26
  }
27
- function Zr(i, e) {
27
+ function ti(i, e) {
28
28
  return i.ok ? e(i.value) : i;
29
29
  }
30
- function Xr(i, e) {
30
+ function ni(i, e) {
31
31
  return i.ok ? i.value : e;
32
32
  }
33
- function ei(i, e) {
33
+ function ri(i, e) {
34
34
  return i.ok ? i.value : e(i.error);
35
35
  }
36
- function ti(i, e) {
36
+ function ii(i, e) {
37
37
  return i.ok ? e.ok(i.value) : e.err(i.error);
38
38
  }
39
- const g = {
39
+ const E = {
40
40
  capabilityFailure(i, e, t) {
41
41
  return { kind: "CapabilityFailure", capability: i, reason: e, details: t };
42
42
  },
@@ -56,14 +56,14 @@ const g = {
56
56
  return { kind: "UnsupportedOp", operation: i, reason: e };
57
57
  }
58
58
  };
59
- function It(i) {
59
+ function kt(i) {
60
60
  return Object.freeze([...i]);
61
61
  }
62
- const vt = {
62
+ const It = {
63
63
  of(i, e, t) {
64
64
  return {
65
65
  document: i,
66
- triggeredEvents: It(e),
66
+ triggeredEvents: kt(e),
67
67
  totalGas: t,
68
68
  capabilityFailure: !1,
69
69
  failureReason: null
@@ -78,68 +78,68 @@ const vt = {
78
78
  failureReason: e ?? null
79
79
  };
80
80
  }
81
- }, Pe = vt, Rt = [
81
+ }, Ne = It, Rt = [
82
82
  "embedded",
83
83
  "initialized",
84
84
  "terminated",
85
85
  "checkpoint"
86
86
  ], Tt = [
87
- p["Document Update Channel"],
88
- p["Triggered Event Channel"],
89
- p["Lifecycle Event Channel"],
90
- p["Embedded Node Channel"]
91
- ], Ne = "embedded", Me = "initialized", Ae = "terminated", I = "checkpoint", ie = new Set(
87
+ m["Document Update Channel"],
88
+ m["Triggered Event Channel"],
89
+ m["Lifecycle Event Channel"],
90
+ m["Embedded Node Channel"]
91
+ ], Me = "embedded", Ae = "initialized", De = "terminated", I = "checkpoint", se = new Set(
92
92
  Rt
93
93
  ), Oe = new Set(Tt);
94
94
  function Pt(i) {
95
- return i != null && ie.has(i);
95
+ return i != null && se.has(i);
96
96
  }
97
- function se(i) {
97
+ function oe(i) {
98
98
  return i != null && Oe.has(
99
99
  i
100
100
  );
101
101
  }
102
- const ni = {
103
- KEY_EMBEDDED: Ne,
104
- KEY_INITIALIZED: Me,
105
- KEY_TERMINATED: Ae,
102
+ const si = {
103
+ KEY_EMBEDDED: Me,
104
+ KEY_INITIALIZED: Ae,
105
+ KEY_TERMINATED: De,
106
106
  KEY_CHECKPOINT: I,
107
- RESERVED_CONTRACT_KEYS: ie,
107
+ RESERVED_CONTRACT_KEYS: se,
108
108
  PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: Oe,
109
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";
110
+ isProcessorManagedChannelBlueId: oe
111
+ }, D = "/contracts", re = `${D}/${Ae}`, Be = `${D}/${De}`, Nt = `${D}/${Me}`, Le = `${D}/${I}`, _e = "/lastEvents", $e = "/lastSignatures";
112
112
  function J(i) {
113
- return `${A}/${i}`;
114
- }
115
- function $e(i, e) {
116
- return `${J(i)}${Le}/${e}`;
113
+ return `${D}/${i}`;
117
114
  }
118
115
  function xe(i, e) {
119
116
  return `${J(i)}${_e}/${e}`;
120
117
  }
121
- const ri = {
122
- RELATIVE_CONTRACTS: A,
123
- RELATIVE_INITIALIZED: ne,
124
- RELATIVE_TERMINATED: De,
118
+ function Fe(i, e) {
119
+ return `${J(i)}${$e}/${e}`;
120
+ }
121
+ const oi = {
122
+ RELATIVE_CONTRACTS: D,
123
+ RELATIVE_INITIALIZED: re,
124
+ RELATIVE_TERMINATED: Be,
125
125
  RELATIVE_EMBEDDED: Nt,
126
- RELATIVE_CHECKPOINT: Be,
127
- LAST_EVENTS_SUFFIX: Le,
128
- LAST_SIGNATURES_SUFFIX: _e,
126
+ RELATIVE_CHECKPOINT: Le,
127
+ LAST_EVENTS_SUFFIX: _e,
128
+ LAST_SIGNATURES_SUFFIX: $e,
129
129
  relativeContractsEntry: J,
130
- relativeCheckpointLastEvent: $e,
131
- relativeCheckpointLastSignature: xe
130
+ relativeCheckpointLastEvent: xe,
131
+ relativeCheckpointLastSignature: Fe
132
132
  };
133
- function Fe(i) {
133
+ function ze(i) {
134
134
  return i == null || i.length === 0;
135
135
  }
136
136
  function y(i) {
137
- return Fe(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
137
+ return ze(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
138
138
  }
139
139
  function b(i) {
140
- return Fe(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
140
+ return ze(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
141
141
  }
142
- function ge(i) {
142
+ function Ee(i) {
143
143
  if (i == null)
144
144
  return "";
145
145
  let e = i.trim();
@@ -151,8 +151,8 @@ function ge(i) {
151
151
  e = e.substring(0, e.length - 1);
152
152
  return e;
153
153
  }
154
- function ii(i, e) {
155
- const t = ge(i), n = ge(e);
154
+ function ai(i, e) {
155
+ const t = Ee(i), n = Ee(e);
156
156
  return t.length === 0 && n.length === 0 ? "/" : t.length === 0 ? `/${n}` : n.length === 0 ? `/${t}` : `/${t}/${n}`;
157
157
  }
158
158
  function w(i, e) {
@@ -171,9 +171,9 @@ function Mt(i, e) {
171
171
  function At(i) {
172
172
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
173
173
  }
174
- var Y, Ee;
175
- function Ot() {
176
- return Ee || (Ee = 1, Y = function i(e) {
174
+ var Z, ye;
175
+ function Dt() {
176
+ return ye || (ye = 1, Z = 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))
@@ -184,10 +184,10 @@ function Ot() {
184
184
  const s = n.length === 0 ? "" : ",";
185
185
  return `${n}${s}${i(r)}:${i(e[r])}`;
186
186
  }, "")}}`;
187
- }), Y;
187
+ }), Z;
188
188
  }
189
- var Dt = Ot();
190
- const Bt = /* @__PURE__ */ At(Dt);
189
+ var Ot = Dt();
190
+ const Bt = /* @__PURE__ */ At(Ot);
191
191
  function Lt(i, e) {
192
192
  return i.nodeToJson(e, "official");
193
193
  }
@@ -195,14 +195,14 @@ function _t(i, e) {
195
195
  const t = Lt(i, e);
196
196
  return Bt(t);
197
197
  }
198
- function ze(i, e) {
198
+ function He(i, e) {
199
199
  return e ? _t(i, e) : null;
200
200
  }
201
- function ye(i, e) {
202
- const t = ze(i, e);
201
+ function we(i, e) {
202
+ const t = He(i, e);
203
203
  return t == null ? 0 : new TextEncoder().encode(t).length;
204
204
  }
205
- function He(i) {
205
+ function Ue(i) {
206
206
  return typeof i == "object" && i !== null && !Array.isArray(i);
207
207
  }
208
208
  function $t(i) {
@@ -217,7 +217,7 @@ function xt(i) {
217
217
  function _(i, e = !0) {
218
218
  if (Array.isArray(i))
219
219
  return e ? i.map((r) => _(r, !0)) : i.slice();
220
- if (!He(i))
220
+ if (!Ue(i))
221
221
  return i;
222
222
  if (Object.prototype.hasOwnProperty.call(i, "value")) {
223
223
  const r = i.value;
@@ -248,7 +248,7 @@ function Ft(i, e) {
248
248
  n = n[s];
249
249
  continue;
250
250
  }
251
- if (He(n)) {
251
+ if (Ue(n)) {
252
252
  n = n[r];
253
253
  continue;
254
254
  }
@@ -257,7 +257,7 @@ function Ft(i, e) {
257
257
  return n;
258
258
  }
259
259
  const zt = 500, Ht = 32 * 1024 * 1024;
260
- class oe {
260
+ class ae {
261
261
  modulePromise;
262
262
  moduleInstance;
263
263
  async evaluate({
@@ -273,17 +273,17 @@ class oe {
273
273
  const c = o.newContext();
274
274
  try {
275
275
  this.installConsole(c), this.installDeterministicGlobals(c), this.installCanonNamespace(c), this.installBindings(c, t);
276
- const l = this.wrapCode(e), u = c.evalCode(l), h = c.unwrapResult(u);
277
- let f = null;
276
+ const l = this.wrapCode(e), u = c.evalCode(l), f = c.unwrapResult(u);
277
+ let h = null;
278
278
  try {
279
- return f = await this.resolveHandle(
279
+ return h = await this.resolveHandle(
280
280
  c,
281
281
  o,
282
- h,
282
+ f,
283
283
  a
284
- ), c.dump(f);
284
+ ), c.dump(h);
285
285
  } finally {
286
- f ? f.dispose() : h.dispose();
286
+ h ? h.dispose() : f.dispose();
287
287
  }
288
288
  } finally {
289
289
  c.dispose(), o.removeInterruptHandler?.(), o.dispose();
@@ -491,44 +491,44 @@ ${e}
491
491
  }
492
492
  }
493
493
  }
494
- const we = 120;
494
+ const be = 120;
495
495
  function Ut(i) {
496
- return i.length <= we ? i : `${i.slice(0, we - 3)}...`;
496
+ return i.length <= be ? i : `${i.slice(0, be - 3)}...`;
497
497
  }
498
- class Ue extends Error {
498
+ class Ve extends Error {
499
499
  constructor(e, t) {
500
500
  super(`Failed to evaluate code block: ${Ut(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
501
501
  }
502
502
  }
503
- const Ve = /^\$\{([\s\S]*)\}$/, Vt = /\$\{([\s\S]+?)\}/, Ke = /\$\{([\s\S]+?)\}/g;
503
+ const Ke = /^\$\{([\s\S]*)\}$/, Vt = /\$\{([\s\S]+?)\}/, We = /\$\{([\s\S]+?)\}/g;
504
504
  function W(i) {
505
- if (typeof i != "string" || !Ve.test(i))
505
+ if (typeof i != "string" || !Ke.test(i))
506
506
  return !1;
507
507
  const e = i.indexOf("${"), t = i.lastIndexOf("${");
508
508
  return e === t;
509
509
  }
510
510
  function Kt(i) {
511
- return typeof i != "string" ? !1 : Ve.test(i) ? !0 : Vt.test(i);
511
+ return typeof i != "string" ? !1 : Ke.test(i) ? !0 : Vt.test(i);
512
512
  }
513
513
  function Wt(i) {
514
514
  if (!W(i))
515
515
  throw new Error(`Invalid expression: ${i}`);
516
516
  return i.slice(2, -1);
517
517
  }
518
- async function We(i, e, t) {
518
+ async function Ge(i, e, t) {
519
519
  const n = `return await (${e});`;
520
520
  try {
521
521
  return await i.evaluate({ code: n, bindings: t });
522
522
  } catch (r) {
523
- throw new Ue(e, r);
523
+ throw new Ve(e, r);
524
524
  }
525
525
  }
526
526
  async function Gt(i, e, t) {
527
527
  let n = "", r = 0;
528
- for (const s of e.matchAll(Ke)) {
528
+ for (const s of e.matchAll(We)) {
529
529
  const o = s[0], a = s[1], c = s.index ?? 0;
530
530
  n += e.slice(r, c);
531
- const l = await We(
531
+ const l = await Ge(
532
532
  i,
533
533
  a,
534
534
  t
@@ -537,15 +537,15 @@ async function Gt(i, e, t) {
537
537
  }
538
538
  return n += e.slice(r), n;
539
539
  }
540
- function Ge({
540
+ function qe({
541
541
  include: i,
542
542
  exclude: e = [],
543
543
  options: t
544
544
  }) {
545
545
  const n = { dot: !0, ...t ?? {} }, r = i.map(
546
- (o) => de(o, n)
546
+ (o) => he(o, n)
547
547
  ), s = e.map(
548
- (o) => de(o, n)
548
+ (o) => he(o, n)
549
549
  );
550
550
  return (o) => r.some((a) => a(o)) && !s.some((a) => a(o));
551
551
  }
@@ -555,74 +555,78 @@ async function G(i) {
555
555
  node: t,
556
556
  bindings: n,
557
557
  shouldResolve: r,
558
- context: s,
559
- pointer: o = "/"
560
- } = i, a = t.clone(), c = a.getValue();
561
- if (c !== void 0) {
562
- if (typeof c == "string" && r(o)) {
563
- if (W(c)) {
564
- const h = Wt(c);
565
- s.gasMeter().chargeExpression(h);
566
- const f = await We(
558
+ shouldDescend: s = () => !0,
559
+ context: o,
560
+ pointer: a = "/"
561
+ } = i, c = t.clone();
562
+ if (!s(a, c))
563
+ return c;
564
+ const l = c.getValue();
565
+ if (l !== void 0) {
566
+ if (typeof l == "string" && r(a)) {
567
+ if (W(l)) {
568
+ const h = Wt(l);
569
+ o.gasMeter().chargeExpression(h);
570
+ const p = await Ge(
567
571
  e,
568
572
  h,
569
573
  n
570
574
  );
571
- return s.blue.jsonValueToNode(f ?? null);
572
- } else if (Kt(c)) {
573
- const h = new RegExp(Ke);
574
- let f = 0;
575
- for (h.lastIndex = 0; h.exec(c); )
576
- f += 1;
577
- s.gasMeter().chargeTemplate(f, c);
578
- const E = await Gt(
575
+ return o.blue.jsonValueToNode(p ?? null);
576
+ } else if (Kt(l)) {
577
+ const h = new RegExp(We);
578
+ let p = 0;
579
+ for (h.lastIndex = 0; h.exec(l); )
580
+ p += 1;
581
+ o.gasMeter().chargeTemplate(p, l);
582
+ const C = await Gt(
579
583
  e,
580
- c,
584
+ l,
581
585
  n
582
586
  );
583
- return new d().setValue(E);
587
+ return new d().setValue(C);
584
588
  }
585
589
  }
586
- return a;
590
+ return c;
587
591
  }
588
- const l = a.getItems?.();
589
- if (Array.isArray(l)) {
592
+ const u = c.getItems?.();
593
+ if (Array.isArray(u)) {
590
594
  const h = await Promise.all(
591
- l.map(
592
- (f, E) => G({
595
+ u.map(
596
+ (p, C) => G({
593
597
  ...i,
594
- node: f,
595
- pointer: `${o}/${E}`
598
+ node: p,
599
+ pointer: `${a}/${C}`
596
600
  })
597
601
  )
598
602
  );
599
- return a.setItems(h), a;
603
+ return c.setItems(h), c;
600
604
  }
601
- const u = a.getProperties?.();
602
- if (u) {
605
+ const f = c.getProperties?.();
606
+ if (f) {
603
607
  const h = {};
604
- for (const [f, E] of Object.entries(u)) {
605
- const D = o === "/" ? `/${f}` : `${o}/${f}`;
606
- h[f] = await G({
608
+ for (const [p, C] of Object.entries(f)) {
609
+ const Y = a === "/" ? `/${p}` : `${a}/${p}`;
610
+ h[p] = await G({
607
611
  ...i,
608
- node: E,
609
- pointer: D
612
+ node: C,
613
+ pointer: Y
610
614
  });
611
615
  }
612
- a.setProperties(h);
616
+ c.setProperties(h);
613
617
  }
614
- return a;
618
+ return c;
615
619
  }
616
- const ae = Xe, O = et.merge(
617
- ae
620
+ const ce = Xe, O = et.merge(
621
+ ce
618
622
  ).extend({
619
623
  path: S.string().optional(),
620
624
  definition: z().optional()
621
- }), qe = tt.merge(ae), H = nt.merge(ae), qt = S.object({
625
+ }), je = tt.merge(ce), H = nt.merge(ce), qt = S.object({
622
626
  op: S.enum(["ADD", "REPLACE", "REMOVE"]),
623
627
  path: S.string(),
624
628
  val: z().optional()
625
- }), si = ft("JsonPatch")(
629
+ }), ci = ft("JsonPatch")(
626
630
  qt
627
631
  ).superRefine((i, e) => {
628
632
  i.op === "REMOVE" && i.val !== void 0 && e.addIssue({
@@ -648,10 +652,10 @@ const ae = Xe, O = et.merge(
648
652
  H
649
653
  ), rn = ut.merge(H), sn = x.merge(
650
654
  H
651
- ), oi = z(), on = gt.merge(qe).extend({
655
+ ), li = z(), on = gt.merge(je).extend({
652
656
  steps: S.array(z()).optional()
653
657
  }), an = Et.merge(
654
- qe
658
+ je
655
659
  ).extend({
656
660
  steps: S.array(z()).optional()
657
661
  });
@@ -716,8 +720,8 @@ class ln {
716
720
  V(e, this.processorsByBlueId);
717
721
  }
718
722
  }
719
- function be(i, e) {
720
- return i.isTypeOf(e, me) ? i.nodeToSchemaOutput(e, me) : i.isTypeOf(e, k) ? i.nodeToSchemaOutput(e, k) : null;
723
+ function Se(i, e) {
724
+ return i.isTypeOf(e, ge) ? i.nodeToSchemaOutput(e, ge) : i.isTypeOf(e, k) ? i.nodeToSchemaOutput(e, k) : null;
721
725
  }
722
726
  class un {
723
727
  kind = "channel";
@@ -727,7 +731,7 @@ class un {
727
731
  const { event: n, blue: r } = t;
728
732
  if (!n)
729
733
  return !1;
730
- const s = be(r, n);
734
+ const s = Se(r, n);
731
735
  if (!s)
732
736
  return !1;
733
737
  const o = s.timeline?.timelineId;
@@ -735,12 +739,12 @@ class un {
735
739
  }
736
740
  channelize(e, t) {
737
741
  const { event: n, blue: r } = t;
738
- return !n || !be(r, n) ? null : n.clone();
742
+ return !n || !Se(r, n) ? null : n.clone();
739
743
  }
740
744
  }
741
745
  class dn {
742
746
  kind = "channel";
743
- blueIds = [v["Timeline Channel"]];
747
+ blueIds = [R["Timeline Channel"]];
744
748
  schema = Zt;
745
749
  matches(e, t) {
746
750
  const { event: n, blue: r } = t;
@@ -754,7 +758,7 @@ class dn {
754
758
  return !n || !r.isTypeOf(n, k) ? null : n.clone();
755
759
  }
756
760
  }
757
- function ce(i) {
761
+ function le(i) {
758
762
  const { context: e, eventNode: t, stepResults: n } = i, r = hn(e);
759
763
  return {
760
764
  event: e.blue.nodeToJson(t, "simple"),
@@ -777,49 +781,57 @@ function hn(i) {
777
781
  return n.canonical = (r) => t(r, "official"), n;
778
782
  }
779
783
  class fn {
780
- supportedBlueIds = [v["Trigger Event"]];
781
- evaluator = new oe();
784
+ supportedBlueIds = [R["Trigger Event"]];
785
+ evaluator = new ae();
782
786
  async execute(e) {
783
787
  const { stepNode: t, context: n } = e;
784
- if (!n.blue.isTypeOf(t, he))
788
+ if (!n.blue.isTypeOf(t, fe))
785
789
  return n.throwFatal("Trigger Event step payload is invalid");
786
790
  n.gasMeter().chargeTriggerEventBase();
787
791
  const r = await G({
788
792
  evaluator: this.evaluator,
789
793
  node: t,
790
- bindings: ce(e),
791
- shouldResolve: Ge({
794
+ bindings: le(e),
795
+ shouldResolve: qe({
792
796
  include: ["/event", "/event/**"]
793
797
  }),
798
+ shouldDescend: pn(),
794
799
  context: n
795
800
  }), o = n.blue.nodeToSchemaOutput(
796
801
  r,
797
- he
802
+ fe
798
803
  ).event;
799
- if (te(o))
804
+ if (ne(o))
800
805
  return n.throwFatal(
801
806
  "Trigger Event step must declare event payload"
802
807
  );
803
808
  n.emitEvent(o.clone());
804
809
  }
805
810
  }
806
- class pn {
807
- supportedBlueIds = [v["JavaScript Code"]];
808
- evaluator = new oe();
811
+ function pn() {
812
+ return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !mn(e);
813
+ }
814
+ function mn(i) {
815
+ const e = i.getProperties?.();
816
+ return e ? !!e.contracts : !1;
817
+ }
818
+ class gn {
819
+ supportedBlueIds = [R["JavaScript Code"]];
820
+ evaluator = new ae();
809
821
  async execute(e) {
810
822
  const { context: t, stepNode: n } = e, { blue: r } = t;
811
- if (!r.isTypeOf(n, fe))
823
+ if (!r.isTypeOf(n, pe))
812
824
  return t.throwFatal("JavaScript Code step payload is invalid");
813
825
  const o = r.nodeToSchemaOutput(
814
826
  n,
815
- fe
827
+ pe
816
828
  ).code;
817
829
  if (!o)
818
830
  return t.throwFatal(
819
831
  "JavaScript Code step must include code to execute"
820
832
  );
821
833
  t.gasMeter().chargeJavaScriptCodeBase(o);
822
- const a = ce(e);
834
+ const a = le(e);
823
835
  try {
824
836
  const c = await this.evaluator.evaluate({
825
837
  code: o,
@@ -827,7 +839,7 @@ class pn {
827
839
  });
828
840
  return this.handleEvents(c, t), c;
829
841
  } catch (c) {
830
- throw new Ue(o, c);
842
+ throw new Ve(o, c);
831
843
  }
832
844
  }
833
845
  handleEvents(e, t) {
@@ -841,18 +853,18 @@ class pn {
841
853
  }
842
854
  }
843
855
  }
844
- class mn {
845
- supportedBlueIds = [v["Update Document"]];
846
- evaluator = new oe();
856
+ class En {
857
+ supportedBlueIds = [R["Update Document"]];
858
+ evaluator = new ae();
847
859
  async execute(e) {
848
860
  const { context: t, stepNode: n } = e, { blue: r } = t;
849
- if (!r.isTypeOf(n, pe))
861
+ if (!r.isTypeOf(n, me))
850
862
  return t.throwFatal("Update Document step payload is invalid");
851
863
  const s = await G({
852
864
  evaluator: this.evaluator,
853
865
  node: n,
854
- bindings: ce(e),
855
- shouldResolve: Ge({
866
+ bindings: le(e),
867
+ shouldResolve: qe({
856
868
  include: ["/changeset", "/changeset/**"]
857
869
  }),
858
870
  context: t
@@ -866,7 +878,7 @@ class mn {
866
878
  extractChanges(e, t) {
867
879
  return t.blue.nodeToSchemaOutput(
868
880
  e,
869
- pe
881
+ me
870
882
  ).changeset ?? [];
871
883
  }
872
884
  createPatch(e, t) {
@@ -886,14 +898,14 @@ class mn {
886
898
  return n.length === 0 ? t.throwFatal("Update Document path cannot be empty") : n;
887
899
  }
888
900
  }
889
- const le = [
901
+ const ue = [
890
902
  new fn(),
891
- new pn(),
892
- new mn()
903
+ new gn(),
904
+ new En()
893
905
  ];
894
- class je {
906
+ class Je {
895
907
  executorIndex;
896
- constructor(e = le) {
908
+ constructor(e = ue) {
897
909
  const t = /* @__PURE__ */ new Map();
898
910
  for (const n of e)
899
911
  for (const r of n.supportedBlueIds)
@@ -907,28 +919,28 @@ class je {
907
919
  const o = {};
908
920
  for (const [a, c] of s.entries()) {
909
921
  const l = c.getType?.()?.getBlueId();
910
- if (te(l))
922
+ if (ne(l))
911
923
  return r.throwFatal(
912
924
  "Sequential workflow step is missing type metadata"
913
925
  );
914
926
  const u = this.executorIndex.get(l);
915
- if (te(u)) {
916
- const E = c.getType?.()?.getName?.() ?? l;
927
+ if (ne(u)) {
928
+ const p = c.getType?.()?.getName?.() ?? l;
917
929
  return r.throwFatal(
918
- `Unsupported workflow step type "${E}"`
930
+ `Unsupported workflow step type "${p}"`
919
931
  );
920
932
  }
921
- const h = {
933
+ const f = {
922
934
  workflow: t,
923
935
  stepNode: c,
924
936
  eventNode: n,
925
937
  context: r,
926
938
  stepResults: o,
927
939
  stepIndex: a
928
- }, f = await u.execute(h);
929
- if (f !== void 0) {
930
- const E = this.stepResultKey(c, a);
931
- o[E] = f;
940
+ }, h = await u.execute(f);
941
+ if (h !== void 0) {
942
+ const p = this.stepResultKey(c, a);
943
+ o[p] = h;
932
944
  }
933
945
  }
934
946
  return o;
@@ -938,13 +950,13 @@ class je {
938
950
  return n && typeof n == "string" && n.length > 0 ? n : `Step${t + 1}`;
939
951
  }
940
952
  }
941
- class gn {
953
+ class yn {
942
954
  kind = "handler";
943
- blueIds = [v["Sequential Workflow"]];
955
+ blueIds = [R["Sequential Workflow"]];
944
956
  schema = on;
945
957
  runner;
946
- constructor(e = le) {
947
- this.runner = new je(e);
958
+ constructor(e = ue) {
959
+ this.runner = new Je(e);
948
960
  }
949
961
  async matches(e, t) {
950
962
  const n = t.event();
@@ -955,12 +967,12 @@ class gn {
955
967
  n && await this.runner.run({ workflow: e, eventNode: n, context: t });
956
968
  }
957
969
  }
958
- class En {
970
+ class wn {
959
971
  kind = "marker";
960
- blueIds = [v.Operation];
972
+ blueIds = [R.Operation];
961
973
  schema = sn;
962
974
  }
963
- function Je(i) {
975
+ function Qe(i) {
964
976
  const e = i.channel;
965
977
  if (typeof e == "string") {
966
978
  const t = e.trim();
@@ -969,12 +981,12 @@ function Je(i) {
969
981
  }
970
982
  return null;
971
983
  }
972
- function yn(i, e) {
984
+ function bn(i, e) {
973
985
  const t = i.getProperties()?.document;
974
986
  return t instanceof d ? e.blue.calculateBlueIdSync(t) : null;
975
987
  }
976
- function wn(i, e) {
977
- if (e.isTypeOf(i, ee, {
988
+ function Sn(i, e) {
989
+ if (e.isTypeOf(i, te, {
978
990
  checkSchemaExtensions: !0
979
991
  }))
980
992
  return i;
@@ -982,18 +994,18 @@ function wn(i, e) {
982
994
  checkSchemaExtensions: !0
983
995
  })) {
984
996
  const n = e.nodeToSchemaOutput(i, k).message;
985
- if (n && e.isTypeOf(n, ee, {
997
+ if (n && e.isTypeOf(n, te, {
986
998
  checkSchemaExtensions: !0
987
999
  }))
988
1000
  return n;
989
1001
  }
990
1002
  return null;
991
1003
  }
992
- function bn(i, e, t, n) {
1004
+ function Cn(i, e, t, n) {
993
1005
  const { blue: r } = n, s = i.operation;
994
1006
  return !(!s || t.operation !== s || i.event && !r.isTypeOfNode(e, i.event));
995
1007
  }
996
- function Sn(i, e) {
1008
+ function vn(i, e) {
997
1009
  const t = i.operation;
998
1010
  if (!t)
999
1011
  return null;
@@ -1003,13 +1015,13 @@ function Sn(i, e) {
1003
1015
  const s = e.blue.nodeToSchemaOutput(
1004
1016
  r,
1005
1017
  x
1006
- ), o = Je(s);
1018
+ ), o = Qe(s);
1007
1019
  return { operationNode: r, operation: s, channelKey: o };
1008
1020
  }
1009
- function Cn(i, e) {
1021
+ function kn(i, e) {
1010
1022
  return !(i && e && i !== e);
1011
1023
  }
1012
- function kn(i, e, t) {
1024
+ function In(i, e, t) {
1013
1025
  const n = i.getProperties()?.request, r = e.getProperties()?.request;
1014
1026
  if (!(n instanceof d) || !(r instanceof d))
1015
1027
  return !1;
@@ -1021,10 +1033,10 @@ function kn(i, e, t) {
1021
1033
  }
1022
1034
  return !0;
1023
1035
  }
1024
- function In(i, e, t) {
1036
+ function Rn(i, e, t) {
1025
1037
  if (!i || i.allowNewerVersion !== !1)
1026
1038
  return !0;
1027
- const n = yn(e, t);
1039
+ const n = bn(e, t);
1028
1040
  if (!n)
1029
1041
  return !0;
1030
1042
  const r = t.resolvePointer("/"), s = t.documentAt(r);
@@ -1033,15 +1045,15 @@ function In(i, e, t) {
1033
1045
  const c = (s.getContracts()?.initialized ?? null)?.get("/documentId") ?? null, l = typeof c == "string" && c.length > 0 ? c : t.blue.calculateBlueIdSync(s);
1034
1046
  return n === l;
1035
1047
  }
1036
- class vn {
1048
+ class Tn {
1037
1049
  kind = "handler";
1038
1050
  blueIds = [
1039
- v["Sequential Workflow Operation"]
1051
+ R["Sequential Workflow Operation"]
1040
1052
  ];
1041
1053
  schema = an;
1042
1054
  runner;
1043
- constructor(e = le) {
1044
- this.runner = new je(e);
1055
+ constructor(e = ue) {
1056
+ this.runner = new Je(e);
1045
1057
  }
1046
1058
  deriveChannel(e, t) {
1047
1059
  const n = e.operation;
@@ -1053,13 +1065,13 @@ class vn {
1053
1065
  }))
1054
1066
  return null;
1055
1067
  const s = t.blue.nodeToSchemaOutput(r.node, x);
1056
- return s ? Je(s) : null;
1068
+ return s ? Qe(s) : null;
1057
1069
  }
1058
1070
  async matches(e, t) {
1059
1071
  const n = t.event();
1060
1072
  if (!n)
1061
1073
  return !1;
1062
- const r = wn(
1074
+ const r = Sn(
1063
1075
  n,
1064
1076
  t.blue
1065
1077
  );
@@ -1067,19 +1079,19 @@ class vn {
1067
1079
  return !1;
1068
1080
  const s = t.blue.nodeToSchemaOutput(
1069
1081
  r,
1070
- ee
1082
+ te
1071
1083
  );
1072
- if (!s || !bn(e, n, s, t))
1084
+ if (!s || !Cn(e, n, s, t))
1073
1085
  return !1;
1074
- const o = Sn(e, t);
1086
+ const o = vn(e, t);
1075
1087
  if (!o)
1076
1088
  return !1;
1077
1089
  const a = typeof e.channel == "string" ? e.channel.trim() : "", c = a.length > 0 ? a : null;
1078
- return !(!Cn(o.channelKey, c) || !kn(
1090
+ return !(!kn(o.channelKey, c) || !In(
1079
1091
  r,
1080
1092
  o.operationNode,
1081
1093
  t.blue
1082
- ) || s?.allowNewerVersion === !1 && !In(s, r, t));
1094
+ ) || s?.allowNewerVersion === !1 && !Rn(s, r, t));
1083
1095
  }
1084
1096
  async execute(e, t) {
1085
1097
  const n = t.event();
@@ -1100,7 +1112,7 @@ class Q {
1100
1112
  );
1101
1113
  }
1102
1114
  registerDefaults() {
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;
1115
+ return this.registry.register(new un()), this.registry.register(new dn()), this.registry.register(new yn()), this.registry.register(new wn()), this.registry.register(new Tn()), this;
1104
1116
  }
1105
1117
  register(e) {
1106
1118
  return this.registry.register(e), this;
@@ -1109,11 +1121,11 @@ class Q {
1109
1121
  return this.registry;
1110
1122
  }
1111
1123
  }
1112
- const re = p["Channel Event Checkpoint"];
1113
- function Qe(i) {
1124
+ const ie = m["Channel Event Checkpoint"];
1125
+ function Ye(i) {
1114
1126
  return typeof i.order == "number" ? i.order : 0;
1115
1127
  }
1116
- class Rn {
1128
+ class Pn {
1117
1129
  constructor(e, t, n) {
1118
1130
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1119
1131
  }
@@ -1127,10 +1139,10 @@ class Rn {
1127
1139
  return this.bindingBlueId;
1128
1140
  }
1129
1141
  order() {
1130
- return Qe(this.bindingContract);
1142
+ return Ye(this.bindingContract);
1131
1143
  }
1132
1144
  }
1133
- class Tn {
1145
+ class Nn {
1134
1146
  constructor(e, t, n) {
1135
1147
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1136
1148
  }
@@ -1144,16 +1156,16 @@ class Tn {
1144
1156
  return this.bindingBlueId;
1145
1157
  }
1146
1158
  order() {
1147
- return Qe(this.bindingContract);
1159
+ return Ye(this.bindingContract);
1148
1160
  }
1149
1161
  }
1150
- class M {
1162
+ class A {
1151
1163
  constructor(e, t, n, r, s) {
1152
1164
  this.channels = e, this.handlersByChannel = t, this.markerStore = n, this.embeddedPathsInternal = r, this.checkpointDeclared = s;
1153
1165
  }
1154
1166
  checkpointDeclared;
1155
1167
  static fromComponents(e, t, n, r, s) {
1156
- return new M(
1168
+ return new A(
1157
1169
  e,
1158
1170
  t,
1159
1171
  n,
@@ -1162,10 +1174,10 @@ class M {
1162
1174
  );
1163
1175
  }
1164
1176
  static builder() {
1165
- return new Pn();
1177
+ return new Mn();
1166
1178
  }
1167
1179
  static empty() {
1168
- return M.builder().build();
1180
+ return A.builder().build();
1169
1181
  }
1170
1182
  markers() {
1171
1183
  return new Map(
@@ -1198,13 +1210,13 @@ class M {
1198
1210
  this.markerStore.set(I, {
1199
1211
  key: I,
1200
1212
  contract: e,
1201
- blueId: re
1213
+ blueId: ie
1202
1214
  }), this.checkpointDeclared = !0;
1203
1215
  }
1204
1216
  handlersFor(e) {
1205
1217
  const t = this.handlersByChannel.get(e);
1206
1218
  return !t || t.length === 0 ? [] : [...t].map(
1207
- (n) => new Tn(n.key, n.contract, n.blueId)
1219
+ (n) => new Nn(n.key, n.contract, n.blueId)
1208
1220
  ).sort((n, r) => {
1209
1221
  const s = n.order() - r.order();
1210
1222
  return s !== 0 ? s : n.key().localeCompare(r.key());
@@ -1212,7 +1224,7 @@ class M {
1212
1224
  }
1213
1225
  channelsOfType(...e) {
1214
1226
  const t = e.length > 0 ? new Set(e) : null, n = Array.from(this.channels.values()).filter((r) => !t || t.has(r.blueId)).map(
1215
- (r) => new Rn(r.key, r.contract, r.blueId)
1227
+ (r) => new Pn(r.key, r.contract, r.blueId)
1216
1228
  );
1217
1229
  return n.sort((r, s) => {
1218
1230
  const o = r.order() - s.order();
@@ -1220,7 +1232,7 @@ class M {
1220
1232
  }), n;
1221
1233
  }
1222
1234
  }
1223
- class Pn {
1235
+ class Mn {
1224
1236
  channels = /* @__PURE__ */ new Map();
1225
1237
  handlersByChannel = /* @__PURE__ */ new Map();
1226
1238
  markerStore = /* @__PURE__ */ new Map();
@@ -1245,11 +1257,11 @@ class Pn {
1245
1257
  return this.embeddedDeclared = !0, this.embeddedPaths = e.paths ? [...e.paths] : [], this;
1246
1258
  }
1247
1259
  addMarker(e, t, n) {
1248
- if (e === I && n !== re)
1260
+ if (e === I && n !== ie)
1249
1261
  throw new Error(
1250
1262
  "Reserved key 'checkpoint' must contain a Channel Event Checkpoint"
1251
1263
  );
1252
- if (n === re) {
1264
+ if (n === ie) {
1253
1265
  if (e !== I)
1254
1266
  throw new Error(
1255
1267
  `Channel Event Checkpoint must use reserved key 'checkpoint' at key '${e}'`
@@ -1263,7 +1275,7 @@ class Pn {
1263
1275
  return this.markerStore.set(e, { key: e, contract: t, blueId: n }), this;
1264
1276
  }
1265
1277
  build() {
1266
- return M.fromComponents(
1278
+ return A.fromComponents(
1267
1279
  new Map(this.channels),
1268
1280
  new Map(
1269
1281
  Array.from(this.handlersByChannel.entries(), ([e, t]) => [
@@ -1277,12 +1289,12 @@ class Pn {
1277
1289
  );
1278
1290
  }
1279
1291
  }
1280
- class m extends Error {
1292
+ class g extends Error {
1281
1293
  constructor(e, t) {
1282
1294
  super(e || "Processor fatal error"), this.processorError = t, this.name = "ProcessorFatalError";
1283
1295
  }
1284
1296
  }
1285
- class Nn {
1297
+ class An {
1286
1298
  constructor(e, t, n) {
1287
1299
  this.blue = e, this.registry = t, this.builtinChannelSchemas = n;
1288
1300
  }
@@ -1305,18 +1317,18 @@ class Nn {
1305
1317
  handlerKey: t
1306
1318
  }), u = o.get(l);
1307
1319
  if (!u)
1308
- throw new m(
1320
+ throw new g(
1309
1321
  `Handler ${t} references unknown channel '${l}'`,
1310
- g.invalidContract(
1322
+ E.invalidContract(
1311
1323
  s,
1312
1324
  `Channel '${l}' is not declared in this scope`,
1313
1325
  `/contracts/${l}`
1314
1326
  )
1315
1327
  );
1316
1328
  if (!this.isRegisteredChannel(u.nodeTypeBlueId))
1317
- throw new m(
1329
+ throw new g(
1318
1330
  `Contract '${l}' is not a channel`,
1319
- g.invalidContract(
1331
+ E.invalidContract(
1320
1332
  u.nodeTypeBlueId,
1321
1333
  `Contract '${l}' is not a channel`,
1322
1334
  `/contracts/${l}`
@@ -1325,9 +1337,9 @@ class Nn {
1325
1337
  e.addHandler(t, { ...c, channel: l }, s);
1326
1338
  } catch (a) {
1327
1339
  if (this.isZodError(a))
1328
- throw new m(
1340
+ throw new g(
1329
1341
  "Failed to parse handler contract",
1330
- g.invalidContract(
1342
+ E.invalidContract(
1331
1343
  s,
1332
1344
  "Failed to parse handler contract",
1333
1345
  t,
@@ -1335,9 +1347,9 @@ class Nn {
1335
1347
  )
1336
1348
  );
1337
1349
  const c = a?.message ?? "Failed to register handler contract";
1338
- throw new m(
1350
+ throw new g(
1339
1351
  c,
1340
- g.illegalState(c)
1352
+ E.illegalState(c)
1341
1353
  );
1342
1354
  }
1343
1355
  }
@@ -1359,9 +1371,9 @@ class Nn {
1359
1371
  }
1360
1372
  }
1361
1373
  if (!s)
1362
- throw new m(
1374
+ throw new g(
1363
1375
  `Handler ${r} must declare channel (missing explicit channel and derivation failed)`,
1364
- g.illegalState(
1376
+ E.illegalState(
1365
1377
  `Handler ${r} must declare channel (missing explicit channel and derivation failed)`
1366
1378
  )
1367
1379
  );
@@ -1371,7 +1383,7 @@ class Nn {
1371
1383
  return this.builtinChannelSchemas.has(e) ? !0 : this.registry.lookupChannel(e) != null;
1372
1384
  }
1373
1385
  isZodError(e) {
1374
- return e instanceof Te;
1386
+ return e instanceof Pe;
1375
1387
  }
1376
1388
  }
1377
1389
  class F extends Error {
@@ -1379,49 +1391,49 @@ class F extends Error {
1379
1391
  super(e ?? "MustUnderstand failure"), this.name = "MustUnderstandFailure";
1380
1392
  }
1381
1393
  }
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([
1394
+ const Dn = m["Document Update Channel"], On = m["Embedded Node Channel"], Bn = m["Lifecycle Event Channel"], Ln = m["Triggered Event Channel"], Ce = m["Process Embedded"], _n = m["Processing Initialized Marker"], $n = m["Processing Terminated Marker"], xn = m["Channel Event Checkpoint"], ve = /* @__PURE__ */ new Map([
1383
1395
  [
1384
- Mn,
1396
+ Dn,
1385
1397
  jt
1386
1398
  ],
1387
1399
  [
1388
- An,
1400
+ On,
1389
1401
  Jt
1390
1402
  ],
1391
1403
  [
1392
- On,
1404
+ Bn,
1393
1405
  Qt
1394
1406
  ],
1395
1407
  [
1396
- Dn,
1408
+ Ln,
1397
1409
  Yt
1398
1410
  ]
1399
- ]), $n = /* @__PURE__ */ new Map([
1411
+ ]), Fn = /* @__PURE__ */ new Map([
1400
1412
  [
1401
- Bn,
1413
+ _n,
1402
1414
  tn
1403
1415
  ],
1404
1416
  [
1405
- Ln,
1417
+ $n,
1406
1418
  rn
1407
1419
  ],
1408
1420
  [
1409
- _n,
1421
+ xn,
1410
1422
  en
1411
1423
  ]
1412
1424
  ]);
1413
- class xn {
1425
+ class zn {
1414
1426
  constructor(e, t) {
1415
- this.registry = e, this.blue = t, this.handlerRegistration = new Nn(
1427
+ this.registry = e, this.blue = t, this.handlerRegistration = new An(
1416
1428
  this.blue,
1417
1429
  this.registry,
1418
- Ce
1430
+ ve
1419
1431
  );
1420
1432
  }
1421
1433
  handlerRegistration;
1422
1434
  load(e, t) {
1423
1435
  try {
1424
- const n = M.builder(), r = e.getContracts();
1436
+ const n = A.builder(), r = e.getContracts();
1425
1437
  if (!r)
1426
1438
  return n.build();
1427
1439
  const s = this.buildScopeContractsIndex(r);
@@ -1429,12 +1441,12 @@ class xn {
1429
1441
  a && this.processContract(n, o, a, s);
1430
1442
  return n.build();
1431
1443
  } catch (n) {
1432
- if (n instanceof F || n instanceof m)
1444
+ if (n instanceof F || n instanceof g)
1433
1445
  throw n;
1434
1446
  const r = n?.message ?? "Failed to load contracts";
1435
- throw new m(
1447
+ throw new g(
1436
1448
  `Failed to load contracts for scope ${t}: ${r}`,
1437
- g.runtimeFatal(
1449
+ E.runtimeFatal(
1438
1450
  `Failed to load contracts for scope ${t}`,
1439
1451
  n
1440
1452
  )
@@ -1445,16 +1457,16 @@ class xn {
1445
1457
  const s = n.getType()?.getBlueId();
1446
1458
  if (!s)
1447
1459
  return;
1448
- if (s === Se) {
1460
+ if (s === Ce) {
1449
1461
  this.handleProcessEmbedded(e, t, n);
1450
1462
  return;
1451
1463
  }
1452
- const o = $n.get(s);
1464
+ const o = Fn.get(s);
1453
1465
  if (o) {
1454
1466
  this.handleMarker(e, t, n, o, s);
1455
1467
  return;
1456
1468
  }
1457
- const a = Ce.get(s);
1469
+ const a = ve.get(s);
1458
1470
  if (a) {
1459
1471
  this.handleChannel(e, t, n, a, s);
1460
1472
  return;
@@ -1493,9 +1505,9 @@ class xn {
1493
1505
  );
1494
1506
  return;
1495
1507
  }
1496
- throw se(s) ? new m(
1508
+ throw oe(s) ? new g(
1497
1509
  "Built-in processor-managed channel is missing schema registration",
1498
- g.invalidContract(
1510
+ E.invalidContract(
1499
1511
  s,
1500
1512
  "Built-in processor-managed channel is missing schema registration",
1501
1513
  t
@@ -1510,17 +1522,17 @@ class xn {
1510
1522
  );
1511
1523
  e.setEmbedded(r);
1512
1524
  } catch (r) {
1513
- throw Z(r) ? new m(
1525
+ throw X(r) ? new g(
1514
1526
  "Failed to parse ProcessEmbedded marker",
1515
- g.invalidContract(
1516
- Se,
1527
+ E.invalidContract(
1528
+ Ce,
1517
1529
  "Failed to parse ProcessEmbedded marker",
1518
1530
  t,
1519
1531
  r
1520
1532
  )
1521
- ) : new m(
1533
+ ) : new g(
1522
1534
  r?.message ?? "Failed to register ProcessEmbedded marker",
1523
- g.illegalState(
1535
+ E.illegalState(
1524
1536
  r?.message ?? "Failed to register ProcessEmbedded marker"
1525
1537
  )
1526
1538
  );
@@ -1531,10 +1543,10 @@ class xn {
1531
1543
  const o = this.convert(n, r);
1532
1544
  e.addChannel(t, o, s);
1533
1545
  } catch (o) {
1534
- if (Z(o))
1535
- throw new m(
1546
+ if (X(o))
1547
+ throw new g(
1536
1548
  "Failed to parse channel contract",
1537
- g.invalidContract(
1549
+ E.invalidContract(
1538
1550
  s,
1539
1551
  "Failed to parse channel contract",
1540
1552
  t,
@@ -1542,9 +1554,9 @@ class xn {
1542
1554
  )
1543
1555
  );
1544
1556
  const a = o?.message ?? "Failed to register channel contract";
1545
- throw new m(
1557
+ throw new g(
1546
1558
  a,
1547
- g.illegalState(a)
1559
+ E.illegalState(a)
1548
1560
  );
1549
1561
  }
1550
1562
  }
@@ -1553,10 +1565,10 @@ class xn {
1553
1565
  const o = this.convert(n, r);
1554
1566
  e.addMarker(t, o, s);
1555
1567
  } catch (o) {
1556
- if (Z(o))
1557
- throw new m(
1568
+ if (X(o))
1569
+ throw new g(
1558
1570
  "Failed to parse marker contract",
1559
- g.invalidContract(
1571
+ E.invalidContract(
1560
1572
  s,
1561
1573
  "Failed to parse marker contract",
1562
1574
  t,
@@ -1564,9 +1576,9 @@ class xn {
1564
1576
  )
1565
1577
  );
1566
1578
  const a = o?.message ?? "Failed to register marker contract";
1567
- throw new m(
1579
+ throw new g(
1568
1580
  a,
1569
- g.illegalState(a)
1581
+ E.illegalState(a)
1570
1582
  );
1571
1583
  }
1572
1584
  }
@@ -1584,18 +1596,18 @@ class xn {
1584
1596
  return this.blue.nodeToSchemaOutput(e, t);
1585
1597
  }
1586
1598
  }
1587
- function Z(i) {
1588
- return i instanceof Te;
1599
+ function X(i) {
1600
+ return i instanceof Pe;
1589
1601
  }
1590
- const Fn = p["Channel Event Checkpoint"];
1591
- function zn(i) {
1602
+ const Hn = m["Channel Event Checkpoint"];
1603
+ function Un(i) {
1592
1604
  return i.jsonValueToNode({
1593
- type: { blueId: Fn },
1605
+ type: { blueId: Hn },
1594
1606
  lastEvents: {},
1595
1607
  lastSignatures: {}
1596
1608
  });
1597
1609
  }
1598
- function Hn() {
1610
+ function Vn() {
1599
1611
  return {
1600
1612
  lastEvents: {},
1601
1613
  lastSignatures: {}
@@ -1604,7 +1616,7 @@ function Hn() {
1604
1616
  function ke(i) {
1605
1617
  return i != null && Object.prototype.hasOwnProperty.call(i, "lastEvents") && Object.prototype.hasOwnProperty.call(i, "lastSignatures");
1606
1618
  }
1607
- class Un {
1619
+ class Kn {
1608
1620
  constructor(e, t, n, r, s) {
1609
1621
  this.markerKey = e, this.checkpoint = t, this.channelKey = n, this.lastEventNode = r, this.lastEventSignature = s;
1610
1622
  }
@@ -1614,15 +1626,15 @@ class Un {
1614
1626
  return e != null && e === this.lastEventSignature;
1615
1627
  }
1616
1628
  }
1617
- class Vn {
1629
+ class Wn {
1618
1630
  constructor(e, t) {
1619
1631
  this.runtime = e, this.signatureFn = t;
1620
1632
  }
1621
1633
  ensureCheckpointMarker(e, t) {
1622
- const n = t.marker(I), r = w(e, Be);
1634
+ const n = t.marker(I), r = w(e, Le);
1623
1635
  if (!n) {
1624
- const s = zn(this.runtime.blue());
1625
- this.runtime.directWrite(r, s), t.registerCheckpointMarker(Hn());
1636
+ const s = Un(this.runtime.blue());
1637
+ this.runtime.directWrite(r, s), t.registerCheckpointMarker(Vn());
1626
1638
  return;
1627
1639
  }
1628
1640
  if (!ke(n))
@@ -1635,7 +1647,7 @@ class Vn {
1635
1647
  if (!ke(r))
1636
1648
  continue;
1637
1649
  const o = (r.lastEvents?.[t] ?? null)?.clone() ?? null, c = r.lastSignatures?.[t] ?? null ?? this.signatureFn(o);
1638
- return new Un(
1650
+ return new Kn(
1639
1651
  n,
1640
1652
  r,
1641
1653
  t,
@@ -1653,17 +1665,17 @@ class Vn {
1653
1665
  return;
1654
1666
  const o = w(
1655
1667
  e,
1656
- $e(n.markerKey, n.channelKey)
1668
+ xe(n.markerKey, n.channelKey)
1657
1669
  ), a = s?.clone() ?? null;
1658
1670
  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;
1659
1671
  const c = w(
1660
1672
  e,
1661
- xe(n.markerKey, n.channelKey)
1673
+ Fe(n.markerKey, n.channelKey)
1662
1674
  ), l = r == null ? null : new d().setValue(r);
1663
1675
  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;
1664
1676
  }
1665
1677
  }
1666
- class Kn {
1678
+ class Gn {
1667
1679
  constructor(e, t, n) {
1668
1680
  this.runtime = e, this.checkpointManager = t, this.deps = n;
1669
1681
  }
@@ -1671,32 +1683,32 @@ class Kn {
1671
1683
  if (this.deps.isScopeInactive(e))
1672
1684
  return;
1673
1685
  this.runtime.gasMeter().chargeChannelMatchAttempt();
1674
- const s = await this.deps.evaluateChannel(
1686
+ const s = r, o = await this.deps.evaluateChannel(
1675
1687
  n,
1676
1688
  t,
1677
1689
  e,
1678
1690
  r
1679
1691
  );
1680
- if (!s.matches)
1692
+ if (!o.matches)
1681
1693
  return;
1682
- const o = s.eventNode ?? r, a = r;
1694
+ const a = o.eventNode ?? r;
1683
1695
  this.checkpointManager.ensureCheckpointMarker(e, t);
1684
1696
  const c = this.checkpointManager.findCheckpoint(
1685
1697
  t,
1686
1698
  n.key()
1687
- ), l = s.eventId ?? this.deps.canonicalSignature(a);
1699
+ ), l = o.eventId ?? this.deps.canonicalSignature(s);
1688
1700
  this.checkpointManager.isDuplicate(c, l) || (await this.runHandlers(
1689
1701
  e,
1690
1702
  t,
1691
1703
  n.key(),
1692
- o,
1704
+ a,
1693
1705
  !1
1694
1706
  ), !this.deps.isScopeInactive(e) && this.checkpointManager.persist(
1695
1707
  e,
1696
1708
  t,
1697
1709
  c,
1698
1710
  l ?? null,
1699
- a
1711
+ s
1700
1712
  ));
1701
1713
  }
1702
1714
  async runHandlers(e, t, n, r, s) {
@@ -1723,18 +1735,21 @@ class Kn {
1723
1735
  }
1724
1736
  }
1725
1737
  }
1726
- class N extends m {
1738
+ function qn(i, e) {
1739
+ return e.isResolved() ? i.createResolvedNode(e) : i.resolve(e);
1740
+ }
1741
+ class M extends g {
1727
1742
  constructor(e) {
1728
- super(e, g.illegalState(e)), this.name = "IllegalStateException";
1743
+ super(e, E.illegalState(e)), this.name = "IllegalStateException";
1729
1744
  }
1730
1745
  }
1731
- class T extends Error {
1746
+ class P extends Error {
1732
1747
  constructor(e) {
1733
1748
  super(e), this.name = "BoundaryViolationException";
1734
1749
  }
1735
1750
  }
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 {
1751
+ const jn = m["Document Update Channel"], Jn = m["Embedded Node Channel"], Qn = m["Triggered Event Channel"], Yn = m["Lifecycle Event Channel"], Ie = m["Processing Initialized Marker"], Zn = m["Document Processing Initiated"];
1752
+ class Xn {
1738
1753
  runtime;
1739
1754
  contractLoader;
1740
1755
  channelRunner;
@@ -1751,22 +1766,22 @@ class Qn {
1751
1766
  const n = y(e), r = /* @__PURE__ */ new Set();
1752
1767
  let s = null, o = null;
1753
1768
  for (t && this.runtime.gasMeter().chargeScopeEntry(n); ; ) {
1754
- const h = this.nodeAt(n);
1755
- if (!h)
1756
- return;
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;
1769
+ const f = this.nodeAt(n);
1759
1770
  if (!f)
1771
+ return;
1772
+ o || (o = f.clone()), s = this.loadBundle(f, n), this.bundles.set(n, s);
1773
+ const h = s.embeddedPaths().find((Y) => !r.has(Y)) ?? null;
1774
+ if (!h)
1760
1775
  break;
1761
- r.add(f);
1762
- const E = w(n, f);
1763
- this.nodeAt(E) && await this.initializeScope(E, !0);
1776
+ r.add(h);
1777
+ const p = w(n, h);
1778
+ this.nodeAt(p) && await this.initializeScope(p, !0);
1764
1779
  }
1765
1780
  if (!s)
1766
1781
  return;
1767
1782
  const a = this.hasInitializationMarker(n);
1768
1783
  if (!a && s.hasCheckpoint())
1769
- throw new N(
1784
+ throw new M(
1770
1785
  `Reserved key 'checkpoint' must not appear before initialization at scope ${n}`
1771
1786
  );
1772
1787
  if (a)
@@ -1785,7 +1800,7 @@ class Qn {
1785
1800
  const t = y(e);
1786
1801
  if (this.bundles.has(t))
1787
1802
  return;
1788
- const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : M.empty();
1803
+ const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : A.empty();
1789
1804
  this.bundles.set(t, r);
1790
1805
  for (const s of r.embeddedPaths()) {
1791
1806
  const o = w(t, s);
@@ -1793,6 +1808,10 @@ class Qn {
1793
1808
  }
1794
1809
  }
1795
1810
  async processExternalEvent(e, t) {
1811
+ const n = qn(this.runtime.blue(), t);
1812
+ await this.processPreparedExternalEvent(e, n);
1813
+ }
1814
+ async processPreparedExternalEvent(e, t) {
1796
1815
  const n = y(e);
1797
1816
  if (this.hooks.isScopeInactive(n))
1798
1817
  return;
@@ -1808,7 +1827,7 @@ class Qn {
1808
1827
  for (const o of s) {
1809
1828
  if (this.hooks.isScopeInactive(n))
1810
1829
  break;
1811
- se(o.blueId()) || await this.channelRunner.runExternalChannel(
1830
+ oe(o.blueId()) || await this.channelRunner.runExternalChannel(
1812
1831
  n,
1813
1832
  r,
1814
1833
  o,
@@ -1827,7 +1846,7 @@ class Qn {
1827
1846
  r
1828
1847
  );
1829
1848
  } catch (s) {
1830
- if (s instanceof T) {
1849
+ if (s instanceof P) {
1831
1850
  const o = this.hooks.fatalReason(s, "Boundary violation");
1832
1851
  await this.hooks.enterFatalTermination(e, t, o);
1833
1852
  return;
@@ -1855,13 +1874,13 @@ class Qn {
1855
1874
  if (!a || this.hooks.isScopeInactive(o))
1856
1875
  continue;
1857
1876
  const c = this.createDocumentUpdateEvent(s, o), l = a.channelsOfType(
1858
- Wn
1877
+ jn
1859
1878
  );
1860
1879
  for (const u of l) {
1861
- const h = u.contract();
1880
+ const f = u.contract();
1862
1881
  if (this.matchesDocumentUpdate(
1863
1882
  o,
1864
- h.path ?? null,
1883
+ f.path ?? null,
1865
1884
  s.path
1866
1885
  ) && (await this.channelRunner.runHandlers(
1867
1886
  o,
@@ -1874,12 +1893,12 @@ class Qn {
1874
1893
  }
1875
1894
  }
1876
1895
  } catch (s) {
1877
- if (s instanceof T) {
1896
+ if (s instanceof P) {
1878
1897
  const o = this.hooks.fatalReason(s, "Boundary violation");
1879
1898
  await this.hooks.enterFatalTermination(e, t, o);
1880
1899
  return;
1881
1900
  }
1882
- if (s instanceof N || s instanceof Error && !(s instanceof m)) {
1901
+ if (s instanceof M || s instanceof Error && !(s instanceof g)) {
1883
1902
  const o = this.hooks.fatalReason(s, "Runtime fatal");
1884
1903
  await this.hooks.enterFatalTermination(e, t, o);
1885
1904
  return;
@@ -1892,7 +1911,7 @@ class Qn {
1892
1911
  if (this.runtime.gasMeter().chargeLifecycleDelivery(), await this.hooks.recordLifecycleForBridging(e, n), !t)
1893
1912
  return;
1894
1913
  const s = t.channelsOfType(
1895
- jn
1914
+ Yn
1896
1915
  );
1897
1916
  for (const o of s)
1898
1917
  if (await this.channelRunner.runHandlers(
@@ -1918,7 +1937,7 @@ class Qn {
1918
1937
  s = this.refreshBundle(n);
1919
1938
  continue;
1920
1939
  }
1921
- this.nodeAt(a) && (await this.initializeScope(a, !1), await this.processExternalEvent(a, t)), s = this.refreshBundle(n);
1940
+ this.nodeAt(a) && (await this.initializeScope(a, !1), await this.processPreparedExternalEvent(a, t)), s = this.refreshBundle(n);
1922
1941
  }
1923
1942
  return null;
1924
1943
  }
@@ -1941,12 +1960,12 @@ class Qn {
1941
1960
  try {
1942
1961
  return this.contractLoader.load(e, t);
1943
1962
  } catch (n) {
1944
- if (n instanceof m || n instanceof F)
1963
+ if (n instanceof g || n instanceof F)
1945
1964
  throw n;
1946
1965
  const r = n?.message ?? "Failed to load contracts";
1947
- throw new m(
1966
+ throw new g(
1948
1967
  r,
1949
- g.runtimeFatal(
1968
+ E.runtimeFatal(
1950
1969
  `Failed to load contracts for scope ${t}`,
1951
1970
  n
1952
1971
  )
@@ -1954,7 +1973,7 @@ class Qn {
1954
1973
  }
1955
1974
  }
1956
1975
  async addInitializationMarker(e, t) {
1957
- const n = new d().setType(new d().setBlueId(Ie)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(ne);
1976
+ const n = new d().setType(new d().setBlueId(Ie)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(re);
1958
1977
  await e.applyPatch({
1959
1978
  op: "ADD",
1960
1979
  path: r,
@@ -1968,7 +1987,7 @@ class Qn {
1968
1987
  if (this.hooks.isScopeInactive(e) || t.embeddedPaths().length === 0)
1969
1988
  return;
1970
1989
  const n = t.channelsOfType(
1971
- Gn
1990
+ Jn
1972
1991
  );
1973
1992
  if (n.length !== 0)
1974
1993
  for (const r of t.embeddedPaths()) {
@@ -1977,8 +1996,8 @@ class Qn {
1977
1996
  for (const c of a) {
1978
1997
  let l = !1;
1979
1998
  for (const u of n) {
1980
- const f = u.contract().childPath ?? "/";
1981
- w(e, f) === s && (l || (this.runtime.gasMeter().chargeBridge(), l = !0), await this.channelRunner.runHandlers(
1999
+ const h = u.contract().childPath ?? "/";
2000
+ w(e, h) === s && (l || (this.runtime.gasMeter().chargeBridge(), l = !0), await this.channelRunner.runHandlers(
1982
2001
  e,
1983
2002
  t,
1984
2003
  u.key(),
@@ -1993,7 +2012,7 @@ class Qn {
1993
2012
  if (this.hooks.isScopeInactive(e))
1994
2013
  return;
1995
2014
  const n = this.runtime.scope(e), r = t.channelsOfType(
1996
- qn
2015
+ Qn
1997
2016
  );
1998
2017
  if (r.length === 0) {
1999
2018
  n.clearTriggered();
@@ -2025,17 +2044,17 @@ class Qn {
2025
2044
  validatePatchBoundary(e, t, n) {
2026
2045
  const r = y(e), s = b(n.path);
2027
2046
  if (s === r)
2028
- throw new T(
2047
+ throw new P(
2029
2048
  `Self-root mutation is forbidden at scope ${r}`
2030
2049
  );
2031
2050
  if (r !== "/" && !s.startsWith(`${r}/`))
2032
- throw new T(
2051
+ throw new P(
2033
2052
  `Patch path ${s} is outside scope ${r}`
2034
2053
  );
2035
2054
  for (const o of t.embeddedPaths()) {
2036
2055
  const a = w(r, o);
2037
2056
  if (s.startsWith(`${a}/`))
2038
- throw new T(
2057
+ throw new P(
2039
2058
  `Boundary violation: patch ${s} enters embedded scope ${a}`
2040
2059
  );
2041
2060
  }
@@ -2044,13 +2063,13 @@ class Qn {
2044
2063
  if (n)
2045
2064
  return;
2046
2065
  const r = y(e), s = b(t.path);
2047
- for (const o of ie) {
2066
+ for (const o of se) {
2048
2067
  const a = w(
2049
2068
  r,
2050
2069
  J(o)
2051
2070
  );
2052
2071
  if (s === a || s.startsWith(`${a}/`))
2053
- throw new T(
2072
+ throw new P(
2054
2073
  `Reserved key '${o}' is write-protected at ${a}`
2055
2074
  );
2056
2075
  }
@@ -2065,21 +2084,21 @@ class Qn {
2065
2084
  }
2066
2085
  }
2067
2086
  hasInitializationMarker(e) {
2068
- const t = w(e, ne), n = this.nodeAt(t);
2087
+ const t = w(e, re), n = this.nodeAt(t);
2069
2088
  if (!n)
2070
2089
  return !1;
2071
2090
  if (!(n instanceof d)) {
2072
2091
  const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2073
- throw new N(s);
2092
+ throw new M(s);
2074
2093
  }
2075
2094
  if (n.getType()?.getBlueId() !== Ie) {
2076
2095
  const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2077
- throw new N(s);
2096
+ throw new M(s);
2078
2097
  }
2079
2098
  return !0;
2080
2099
  }
2081
2100
  createLifecycleEvent(e) {
2082
- return new d().setType(new d().setBlueId(Jn)).setProperties({
2101
+ return new d().setType(new d().setBlueId(Zn)).setProperties({
2083
2102
  type: new d().setValue("Document Processing Initiated"),
2084
2103
  documentId: new d().setValue(e)
2085
2104
  });
@@ -2092,19 +2111,19 @@ class q extends Error {
2092
2111
  ), this.fatal = e, this.name = "RunTerminationError";
2093
2112
  }
2094
2113
  }
2095
- const Yn = p["Processing Terminated Marker"], Zn = p["Document Processing Terminated"];
2096
- class Xn {
2114
+ const er = m["Processing Terminated Marker"], tr = m["Document Processing Terminated"];
2115
+ class nr {
2097
2116
  constructor(e) {
2098
2117
  this.runtime = e;
2099
2118
  }
2100
2119
  async terminateScope(e, t, n, r, s) {
2101
2120
  e.recordPendingTermination(t, r, s ?? null);
2102
- const o = e.normalizeScope(t), a = w(o, De);
2121
+ const o = e.normalizeScope(t), a = w(o, Be);
2103
2122
  this.runtime.directWrite(
2104
2123
  a,
2105
- er(this.runtime.blue(), r, s)
2124
+ rr(this.runtime.blue(), r, s)
2106
2125
  ), this.runtime.gasMeter().chargeTerminationMarker();
2107
- const c = n ?? e.bundleForScope(o) ?? null, l = tr(r, s);
2126
+ const c = n ?? e.bundleForScope(o) ?? null, l = ir(r, s);
2108
2127
  if (await e.deliverLifecycle(
2109
2128
  o,
2110
2129
  c,
@@ -2116,32 +2135,32 @@ class Xn {
2116
2135
  throw this.runtime.markRunTerminated(), new q(!1);
2117
2136
  }
2118
2137
  }
2119
- function er(i, e, t) {
2120
- return nr(i, {
2121
- type: { blueId: Yn },
2138
+ function rr(i, e, t) {
2139
+ return sr(i, {
2140
+ type: { blueId: er },
2122
2141
  cause: e === "GRACEFUL" ? "graceful" : "fatal",
2123
2142
  ...t ? { reason: t } : {}
2124
2143
  });
2125
2144
  }
2126
- function tr(i, e) {
2145
+ function ir(i, e) {
2127
2146
  const t = new d().setType(
2128
- new d().setBlueId(Zn)
2147
+ new d().setBlueId(tr)
2129
2148
  );
2130
2149
  return t.addProperty(
2131
2150
  "cause",
2132
2151
  new d().setValue(i === "GRACEFUL" ? "graceful" : "fatal")
2133
2152
  ), e && t.addProperty("reason", new d().setValue(e)), t;
2134
2153
  }
2135
- function nr(i, e) {
2154
+ function sr(i, e) {
2136
2155
  return i.jsonValueToNode(e);
2137
2156
  }
2138
2157
  const $ = "-";
2139
- class rr {
2158
+ class or {
2140
2159
  constructor(e) {
2141
2160
  this.document = e;
2142
2161
  }
2143
2162
  applyPatch(e, t) {
2144
- const n = y(e), r = b(t.path), s = Re(r), o = ve(this.document, s, "before", r);
2163
+ const n = y(e), r = b(t.path), s = Te(r), o = Re(this.document, s, "before", r);
2145
2164
  switch (t.op) {
2146
2165
  case "ADD":
2147
2166
  this.applyAdd(s, r, t.val ?? null);
@@ -2153,34 +2172,34 @@ class rr {
2153
2172
  this.applyRemove(s, r);
2154
2173
  break;
2155
2174
  }
2156
- const a = t.op === "REMOVE" ? null : ve(this.document, s, "after", r);
2175
+ const a = t.op === "REMOVE" ? null : Re(this.document, s, "after", r);
2157
2176
  return {
2158
2177
  path: r,
2159
2178
  before: o,
2160
2179
  after: a,
2161
2180
  op: t.op.toLowerCase(),
2162
2181
  originScope: n,
2163
- cascadeScopes: ir(n)
2182
+ cascadeScopes: ar(n)
2164
2183
  };
2165
2184
  }
2166
2185
  directWrite(e, t) {
2167
2186
  const n = b(e);
2168
2187
  if (n === "/")
2169
2188
  throw new Error("Direct write cannot target root document");
2170
- const r = Re(n), { parent: s, leaf: o } = this.resolveParent(r);
2189
+ const r = Te(n), { parent: s, leaf: o } = this.resolveParent(r);
2171
2190
  if (o === $)
2172
2191
  throw new Error(
2173
2192
  `Direct write does not support append token '-' for path ${n}`
2174
2193
  );
2175
2194
  const a = s.getItems();
2176
- if (a && P(o)) {
2195
+ if (a && N(o)) {
2177
2196
  this.directWriteArray(s, a, o, t, n);
2178
2197
  return;
2179
2198
  }
2180
2199
  this.directWriteObject(s, o, t);
2181
2200
  }
2182
2201
  directWriteArray(e, t, n, r, s) {
2183
- const o = X(e, t), a = C(n, s);
2202
+ const o = ee(e, t), a = v(n, s);
2184
2203
  if (r == null) {
2185
2204
  if (a < 0 || a >= o.length)
2186
2205
  return;
@@ -2226,8 +2245,8 @@ class rr {
2226
2245
  `Append token '-' must be final segment: ${B(n, r)}`
2227
2246
  );
2228
2247
  const s = e.getItems();
2229
- if (s && P(t)) {
2230
- const c = C(t, B(n, r));
2248
+ if (s && N(t)) {
2249
+ const c = v(t, B(n, r));
2231
2250
  if (c < 0 || c >= s.length)
2232
2251
  throw new Error(
2233
2252
  `Array index out of bounds: ${B(n, r)}`
@@ -2252,20 +2271,20 @@ class rr {
2252
2271
  "ADD"
2253
2272
  );
2254
2273
  try {
2255
- if (P(s)) {
2274
+ if (N(s)) {
2256
2275
  const l = r.getItems(), u = s === $;
2257
2276
  if (!l)
2258
2277
  throw new Error(
2259
2278
  u ? `Append token '-' requires array at ${o}` : `Array index segment requires array at ${o}`
2260
2279
  );
2261
2280
  if (u) {
2262
- X(r, l).push(L(n));
2281
+ ee(r, l).push(L(n));
2263
2282
  return;
2264
2283
  }
2265
- const h = C(s, t);
2266
- if (h < 0 || h > l.length)
2284
+ const f = v(s, t);
2285
+ if (f < 0 || f > l.length)
2267
2286
  throw new Error(`Array index out of bounds in path: ${t}`);
2268
- X(r, l).splice(h, 0, L(n));
2287
+ ee(r, l).splice(f, 0, L(n));
2269
2288
  return;
2270
2289
  }
2271
2290
  const c = K(r);
@@ -2283,11 +2302,11 @@ class rr {
2283
2302
  "REPLACE"
2284
2303
  );
2285
2304
  try {
2286
- if (P(s)) {
2305
+ if (N(s)) {
2287
2306
  const c = r.getItems();
2288
2307
  if (!c)
2289
2308
  throw new Error(`Array index segment requires array at ${t}`);
2290
- const l = C(s, t);
2309
+ const l = v(s, t);
2291
2310
  if (l < 0 || l >= c.length)
2292
2311
  throw new Error(`Array index out of bounds in path: ${t}`);
2293
2312
  c[l] = L(n), r.setItems(c);
@@ -2307,11 +2326,11 @@ class rr {
2307
2326
  t,
2308
2327
  "REMOVE"
2309
2328
  );
2310
- if (P(r)) {
2329
+ if (N(r)) {
2311
2330
  const a = n.getItems();
2312
2331
  if (!a)
2313
2332
  throw new Error(`Array index segment requires array at ${t}`);
2314
- const c = C(r, t);
2333
+ const c = v(r, t);
2315
2334
  if (c < 0 || c >= a.length)
2316
2335
  throw new Error(`Array index out of bounds in path: ${t}`);
2317
2336
  a.splice(c, 1), n.setItems(a);
@@ -2330,26 +2349,26 @@ class rr {
2330
2349
  const s = [];
2331
2350
  for (let a = 0; a < e.length - 1; a += 1) {
2332
2351
  const c = e[a], l = B(e, a + 1);
2333
- if (P(c)) {
2334
- const f = r.getItems();
2335
- if (!f)
2352
+ if (N(c)) {
2353
+ const h = r.getItems();
2354
+ if (!h)
2336
2355
  throw new Error(`Array index segment requires array at ${l}`);
2337
- const E = C(c, l);
2338
- if (E < 0 || E >= f.length)
2356
+ const p = v(c, l);
2357
+ if (p < 0 || p >= h.length)
2339
2358
  throw new Error(`Array index out of bounds in path: ${l}`);
2340
- const D = f[E];
2341
- if (!(D instanceof d))
2359
+ const C = h[p];
2360
+ if (!(C instanceof d))
2342
2361
  throw new Error(`Array index out of bounds in path: ${l}`);
2343
- r = D;
2362
+ r = C;
2344
2363
  continue;
2345
2364
  }
2346
- let u = r.getProperties(), h = u?.[c] ?? null;
2347
- if (!(h instanceof d)) {
2365
+ let u = r.getProperties(), f = u?.[c] ?? null;
2366
+ if (!(f instanceof d)) {
2348
2367
  if (n === "REMOVE")
2349
2368
  throw new Error(`Path does not exist: ${l}`);
2350
- h = new d(), u || (u = {}), u[c] = h, r.setProperties(u), s.push({ owner: r, key: c });
2369
+ f = new d(), u || (u = {}), u[c] = f, r.setProperties(u), s.push({ owner: r, key: c });
2351
2370
  }
2352
- r = h;
2371
+ r = f;
2353
2372
  }
2354
2373
  const o = e[e.length - 1];
2355
2374
  return { parent: r, key: o, pointer: t, created: s };
@@ -2361,7 +2380,7 @@ class rr {
2361
2380
  }
2362
2381
  }
2363
2382
  }
2364
- function ir(i) {
2383
+ function ar(i) {
2365
2384
  const e = [];
2366
2385
  let t = i;
2367
2386
  for (; e.push(t), t !== "/"; ) {
@@ -2370,26 +2389,26 @@ function ir(i) {
2370
2389
  }
2371
2390
  return e;
2372
2391
  }
2373
- function ve(i, e, t, n) {
2392
+ function Re(i, e, t, n) {
2374
2393
  try {
2375
2394
  if (e.length === 0)
2376
2395
  return i.clone();
2377
- const r = sr(i, e, t, n);
2396
+ const r = cr(i, e, t, n);
2378
2397
  return r ? r.clone() : null;
2379
2398
  } catch {
2380
2399
  return null;
2381
2400
  }
2382
2401
  }
2383
- function sr(i, e, t, n) {
2402
+ function cr(i, e, t, n) {
2384
2403
  let r = i;
2385
2404
  for (let s = 0; s < e.length; s += 1) {
2386
2405
  const o = e[s] ?? "", a = s === e.length - 1;
2387
- if (r = or(r, o, a, t, n), !r)
2406
+ if (r = lr(r, o, a, t, n), !r)
2388
2407
  return null;
2389
2408
  }
2390
2409
  return r;
2391
2410
  }
2392
- function or(i, e, t, n, r) {
2411
+ function lr(i, e, t, n, r) {
2393
2412
  if (!i)
2394
2413
  return null;
2395
2414
  const s = i.getItems();
@@ -2399,7 +2418,7 @@ function or(i, e, t, n, r) {
2399
2418
  throw new Error(`Append token '-' must be final segment: ${r}`);
2400
2419
  return n === "before" || s.length === 0 ? null : s[s.length - 1] ?? null;
2401
2420
  }
2402
- const c = C(e, r);
2421
+ const c = v(e, r);
2403
2422
  return c < 0 || c >= s.length ? null : s[c] ?? null;
2404
2423
  }
2405
2424
  const o = i.getProperties();
@@ -2408,13 +2427,13 @@ function or(i, e, t, n, r) {
2408
2427
  const a = o[e];
2409
2428
  return a instanceof d ? a : null;
2410
2429
  }
2411
- function Re(i) {
2430
+ function Te(i) {
2412
2431
  if (i === "/" || i === "")
2413
2432
  return [];
2414
2433
  const e = i.startsWith("/") ? i.slice(1) : i;
2415
2434
  return e.length === 0 ? [] : e.split("/");
2416
2435
  }
2417
- function C(i, e) {
2436
+ function v(i, e) {
2418
2437
  const t = Number.parseInt(i, 10);
2419
2438
  if (Number.isNaN(t))
2420
2439
  throw new Error(`Expected numeric array index in path: ${e}`);
@@ -2431,7 +2450,7 @@ function B(i, e) {
2431
2450
  n += `/${i[r] ?? ""}`;
2432
2451
  return n === "" ? "/" : n;
2433
2452
  }
2434
- function X(i, e) {
2453
+ function ee(i, e) {
2435
2454
  const t = [...e];
2436
2455
  return i.setItems(t), t;
2437
2456
  }
@@ -2444,13 +2463,13 @@ function K(i) {
2444
2463
  const t = { ...e };
2445
2464
  return i.setProperties(t), t;
2446
2465
  }
2447
- function P(i) {
2466
+ function N(i) {
2448
2467
  return i === $ || /^\d+$/.test(i);
2449
2468
  }
2450
2469
  function L(i) {
2451
2470
  return i == null ? new d().setValue(null) : i.clone();
2452
2471
  }
2453
- class ar {
2472
+ class ur {
2454
2473
  constructor(e) {
2455
2474
  this.path = e;
2456
2475
  }
@@ -2512,7 +2531,7 @@ class ar {
2512
2531
  return this.cutOff;
2513
2532
  }
2514
2533
  }
2515
- class cr {
2534
+ class dr {
2516
2535
  scopesMap = /* @__PURE__ */ new Map();
2517
2536
  rootEmissionList = [];
2518
2537
  scopes() {
@@ -2520,7 +2539,7 @@ class cr {
2520
2539
  }
2521
2540
  scope(e) {
2522
2541
  let t = this.scopesMap.get(e);
2523
- return t || (t = new ar(e), this.scopesMap.set(e, t)), t;
2542
+ return t || (t = new ur(e), this.scopesMap.set(e, t)), t;
2524
2543
  }
2525
2544
  existingScope(e) {
2526
2545
  return this.scopesMap.get(e);
@@ -2541,42 +2560,42 @@ class cr {
2541
2560
  function U(i) {
2542
2561
  return Math.floor((i + 99) / 100);
2543
2562
  }
2544
- function ue(i) {
2563
+ function de(i) {
2545
2564
  return new TextEncoder().encode(i).length;
2546
2565
  }
2547
- function lr(i) {
2566
+ function hr(i) {
2548
2567
  const e = b(i);
2549
2568
  return e === "/" ? 0 : e.split("/").length - 1;
2550
2569
  }
2551
- function ur(i) {
2552
- return 100 + U(ue(i));
2570
+ function fr(i) {
2571
+ return 100 + U(de(i));
2553
2572
  }
2554
- function dr(i) {
2573
+ function pr(i) {
2555
2574
  return 40 + 5 * Math.max(0, i);
2556
2575
  }
2557
- function hr(i) {
2558
- return 5 + U(ue(i));
2576
+ function mr(i) {
2577
+ return 5 + U(de(i));
2559
2578
  }
2560
- function fr(i, e) {
2561
- return 3 * Math.max(0, i) + U(ue(e));
2579
+ function gr(i, e) {
2580
+ return 3 * Math.max(0, i) + U(de(e));
2562
2581
  }
2563
- function pr(i, e) {
2564
- return 8 + lr(i) + U(e);
2582
+ function Er(i, e) {
2583
+ return 8 + hr(i) + U(e);
2565
2584
  }
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) {
2585
+ const yr = 1e3, wr = 5, br = 50, Sr = 2, Cr = 10, vr = 10, kr = 10, Ir = 20, Rr = 20, Tr = 30, Pr = 30, Nr = 100;
2586
+ function Mr(i) {
2568
2587
  return 50 + 10 * i;
2569
2588
  }
2570
- function Pr(i) {
2589
+ function Ar(i) {
2571
2590
  return 20 + i;
2572
2591
  }
2573
- function Nr(i) {
2592
+ function Dr(i) {
2574
2593
  return 10 * i;
2575
2594
  }
2576
- function Mr(i) {
2595
+ function Or(i) {
2577
2596
  return 20 + i;
2578
2597
  }
2579
- class Ar {
2598
+ class Br {
2580
2599
  constructor(e) {
2581
2600
  this.blue = e;
2582
2601
  }
@@ -2588,73 +2607,73 @@ class Ar {
2588
2607
  this.total += e;
2589
2608
  }
2590
2609
  chargeScopeEntry(e) {
2591
- this.add(Tr(this.scopeDepth(e)));
2610
+ this.add(Mr(this.scopeDepth(e)));
2592
2611
  }
2593
2612
  chargeInitialization() {
2594
- this.add(mr);
2613
+ this.add(yr);
2595
2614
  }
2596
2615
  chargeChannelMatchAttempt() {
2597
- this.add(gr);
2616
+ this.add(wr);
2598
2617
  }
2599
2618
  chargeHandlerOverhead() {
2600
- this.add(Er);
2619
+ this.add(br);
2601
2620
  }
2602
2621
  chargeBoundaryCheck() {
2603
- this.add(yr);
2622
+ this.add(Sr);
2604
2623
  }
2605
2624
  chargePatchAddOrReplace(e) {
2606
- this.add(Pr(this.payloadSizeCharge(e)));
2625
+ this.add(Ar(this.payloadSizeCharge(e)));
2607
2626
  }
2608
2627
  chargePatchRemove() {
2609
- this.add(wr);
2628
+ this.add(Cr);
2610
2629
  }
2611
2630
  chargeCascadeRouting(e) {
2612
- e > 0 && this.add(Nr(e));
2631
+ e > 0 && this.add(Dr(e));
2613
2632
  }
2614
2633
  chargeEmitEvent(e) {
2615
- this.add(Mr(this.payloadSizeCharge(e)));
2634
+ this.add(Or(this.payloadSizeCharge(e)));
2616
2635
  }
2617
2636
  chargeBridge() {
2618
- this.add(br);
2637
+ this.add(vr);
2619
2638
  }
2620
2639
  chargeDrainEvent() {
2621
- this.add(Sr);
2640
+ this.add(kr);
2622
2641
  }
2623
2642
  chargeCheckpointUpdate() {
2624
- this.add(Cr);
2643
+ this.add(Ir);
2625
2644
  }
2626
2645
  chargeTerminationMarker() {
2627
- this.add(kr);
2646
+ this.add(Rr);
2628
2647
  }
2629
2648
  chargeLifecycleDelivery() {
2630
- this.add(Ir);
2649
+ this.add(Tr);
2631
2650
  }
2632
2651
  chargeFatalTerminationOverhead() {
2633
- this.add(Rr);
2652
+ this.add(Nr);
2634
2653
  }
2635
2654
  chargeJavaScriptCodeBase(e) {
2636
- this.add(ur(e));
2655
+ this.add(fr(e));
2637
2656
  }
2638
2657
  chargeTriggerEventBase() {
2639
- this.add(vr);
2658
+ this.add(Pr);
2640
2659
  }
2641
2660
  chargeUpdateDocumentBase(e) {
2642
- this.add(dr(e));
2661
+ this.add(pr(e));
2643
2662
  }
2644
2663
  chargeExpression(e) {
2645
- this.add(hr(e));
2664
+ this.add(mr(e));
2646
2665
  }
2647
2666
  chargeTemplate(e, t) {
2648
- this.add(fr(e, t));
2667
+ this.add(gr(e, t));
2649
2668
  }
2650
2669
  chargeDocumentSnapshot(e, t) {
2651
- const n = t ? ye(this.blue, t) : 0;
2652
- this.add(pr(e, n));
2670
+ const n = t ? we(this.blue, t) : 0;
2671
+ this.add(Er(e, n));
2653
2672
  }
2654
2673
  payloadSizeCharge(e) {
2655
2674
  if (!e)
2656
2675
  return 0;
2657
- const t = ye(this.blue, e);
2676
+ const t = we(this.blue, e);
2658
2677
  return U(t);
2659
2678
  }
2660
2679
  scopeDepth(e) {
@@ -2667,12 +2686,12 @@ class Ar {
2667
2686
  return n;
2668
2687
  }
2669
2688
  }
2670
- class Or {
2689
+ class Lr {
2671
2690
  constructor(e, t) {
2672
- this.documentRef = e, this.blueRef = t, this.patchEngine = new rr(this.documentRef), this.meter = new Ar(this.blueRef);
2691
+ this.documentRef = e, this.blueRef = t, this.patchEngine = new or(this.documentRef), this.meter = new Br(this.blueRef);
2673
2692
  }
2674
2693
  patchEngine;
2675
- emissionRegistry = new cr();
2694
+ emissionRegistry = new dr();
2676
2695
  meter;
2677
2696
  runTerminated = !1;
2678
2697
  document() {
@@ -2721,15 +2740,15 @@ class Or {
2721
2740
  return this.patchEngine.applyPatch(e, t);
2722
2741
  }
2723
2742
  }
2724
- const Dr = p["Processing Initialized Marker"], Br = p["Document Update"];
2725
- class Lr {
2743
+ const _r = m["Processing Initialized Marker"], $r = m["Document Update"];
2744
+ class xr {
2726
2745
  constructor(e, t, n, r) {
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(
2746
+ this.contractLoader = e, this.registry = t, this.runtimeRef = new Lr(r, n);
2747
+ const s = (o) => He(this.runtimeRef.blue(), o);
2748
+ this.checkpointManager = new Wn(
2730
2749
  this.runtimeRef,
2731
2750
  s
2732
- ), this.terminationService = new Xn(this.runtimeRef), this.channelRunner = new Kn(
2751
+ ), this.terminationService = new nr(this.runtimeRef), this.channelRunner = new Gn(
2733
2752
  this.runtimeRef,
2734
2753
  this.checkpointManager,
2735
2754
  {
@@ -2746,9 +2765,9 @@ class Lr {
2746
2765
  const c = this.registry.lookupHandler(o.blueId());
2747
2766
  if (!c) {
2748
2767
  const u = `No processor registered for handler contract ${o.blueId()}`;
2749
- throw new m(
2768
+ throw new g(
2750
2769
  u,
2751
- g.illegalState(u)
2770
+ E.illegalState(u)
2752
2771
  );
2753
2772
  }
2754
2773
  const l = c.matches;
@@ -2758,7 +2777,7 @@ class Lr {
2758
2777
  handleHandlerError: async (o, a, c) => this.handleHandlerError(o, a, c),
2759
2778
  canonicalSignature: s
2760
2779
  }
2761
- ), this.scopeExecutor = new Qn({
2780
+ ), this.scopeExecutor = new Xn({
2762
2781
  runtime: this.runtimeRef,
2763
2782
  contractLoader: this.contractLoader,
2764
2783
  channelRunner: this.channelRunner,
@@ -2809,7 +2828,7 @@ class Lr {
2809
2828
  );
2810
2829
  }
2811
2830
  createContext(e, t, n, r = !1, s = !1) {
2812
- return new _r(
2831
+ return new Fr(
2813
2832
  this,
2814
2833
  t,
2815
2834
  e,
@@ -2820,7 +2839,7 @@ class Lr {
2820
2839
  }
2821
2840
  result() {
2822
2841
  const e = this.runtimeRef.document().clone(), t = this.runtimeRef.rootEmissions().map((n) => n.clone());
2823
- return Pe.of(
2842
+ return Ne.of(
2824
2843
  e,
2825
2844
  t,
2826
2845
  this.runtimeRef.totalGas()
@@ -2899,20 +2918,20 @@ class Lr {
2899
2918
  c
2900
2919
  ))
2901
2920
  return { matches: !1 };
2902
- const u = s.channelize, h = u ? u.call(s, e.contract(), c) : void 0;
2921
+ const u = s.channelize, f = u ? u.call(s, e.contract(), c) : void 0;
2903
2922
  return {
2904
2923
  matches: !0,
2905
2924
  eventId: o,
2906
- eventNode: h ?? a.clone()
2925
+ eventNode: f ?? a.clone()
2907
2926
  };
2908
2927
  }
2909
2928
  async executeHandler(e, t) {
2910
2929
  const n = this.registry.lookupHandler(e.blueId());
2911
2930
  if (!n) {
2912
2931
  const r = `No processor registered for handler contract ${e.blueId()}`;
2913
- throw new m(
2932
+ throw new g(
2914
2933
  r,
2915
- g.illegalState(r)
2934
+ E.illegalState(r)
2916
2935
  );
2917
2936
  }
2918
2937
  await n.execute(e.contract(), t);
@@ -2933,7 +2952,7 @@ class Lr {
2933
2952
  }
2934
2953
  createDocumentUpdateEvent(e, t) {
2935
2954
  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)
2955
+ new d().setBlueId($r)
2937
2956
  );
2938
2957
  return o.setProperties({
2939
2958
  op: new d().setValue(e.op),
@@ -2955,7 +2974,7 @@ class j {
2955
2974
  }
2956
2975
  async initializeDocument(e) {
2957
2976
  if (this.isInitialized(e))
2958
- throw new N("Document already initialized");
2977
+ throw new M("Document already initialized");
2959
2978
  const t = this.createExecution(e.clone());
2960
2979
  return this.run(e, t, async () => {
2961
2980
  await t.initializeScope("/", !0);
@@ -2963,7 +2982,7 @@ class j {
2963
2982
  }
2964
2983
  async processDocument(e, t) {
2965
2984
  if (!this.isInitialized(e))
2966
- throw new N("Document not initialized");
2985
+ throw new M("Document not initialized");
2967
2986
  const n = this.createExecution(e.clone()), r = t.clone();
2968
2987
  return this.run(e, n, async () => {
2969
2988
  n.loadBundles("/"), await n.processExternalEvent("/", r);
@@ -2973,7 +2992,7 @@ class j {
2973
2992
  return this.initializationMarker(e) != null;
2974
2993
  }
2975
2994
  createExecution(e) {
2976
- return new Lr(
2995
+ return new xr(
2977
2996
  this.contractLoader,
2978
2997
  this.registry,
2979
2998
  this.blue,
@@ -2988,7 +3007,7 @@ class j {
2988
3007
  return t.result();
2989
3008
  if (r instanceof F) {
2990
3009
  const s = e.clone();
2991
- return Pe.capabilityFailure(
3010
+ return Ne.capabilityFailure(
2992
3011
  s,
2993
3012
  r.message ?? null
2994
3013
  );
@@ -3002,16 +3021,16 @@ class j {
3002
3021
  if (!n)
3003
3022
  return null;
3004
3023
  if (!(n instanceof d))
3005
- throw new m(
3024
+ throw new g(
3006
3025
  "Initialization Marker must be a BlueNode",
3007
- g.illegalState(
3026
+ E.illegalState(
3008
3027
  "Initialization Marker must be a BlueNode"
3009
3028
  )
3010
3029
  );
3011
- if (n.getType()?.getBlueId() !== Dr)
3012
- throw new m(
3030
+ if (n.getType()?.getBlueId() !== _r)
3031
+ throw new g(
3013
3032
  "Initialization Marker must declare type 'Processing Initialized Marker'",
3014
- g.illegalState(
3033
+ E.illegalState(
3015
3034
  "Initialization Marker must declare type 'Processing Initialized Marker'"
3016
3035
  )
3017
3036
  );
@@ -3032,22 +3051,28 @@ class j {
3032
3051
  continue;
3033
3052
  const a = s.getItems();
3034
3053
  if (a && /^\d+$/.test(o)) {
3035
- const u = Number.parseInt(o, 10);
3036
- s = a[u] ?? null;
3054
+ const l = Number.parseInt(o, 10);
3055
+ s = a[l] ?? null;
3037
3056
  continue;
3038
3057
  }
3039
3058
  const c = s.getProperties();
3040
- if (!c)
3041
- return null;
3042
- const l = c[o];
3043
- if (!(l instanceof d))
3044
- return null;
3045
- s = l;
3059
+ if (c && o in c) {
3060
+ const l = c[o];
3061
+ if (!(l instanceof d))
3062
+ return null;
3063
+ s = l;
3064
+ continue;
3065
+ }
3066
+ if (o === "blueId") {
3067
+ s = new d().setValue(s.getBlueId() ?? null);
3068
+ continue;
3069
+ }
3070
+ return null;
3046
3071
  }
3047
3072
  return s;
3048
3073
  }
3049
3074
  }
3050
- class _r {
3075
+ class Fr {
3051
3076
  constructor(e, t, n, r, s, o) {
3052
3077
  this.execution = e, this.bundle = t, this.scopePathValue = n, this.eventNode = r, this.allowTerminatedWork = s, this.allowReservedMutation = o;
3053
3078
  }
@@ -3083,7 +3108,7 @@ class _r {
3083
3108
  this.shouldSkipTerminatedWork() || this.execution.runtime().addGas(e);
3084
3109
  }
3085
3110
  throwFatal(e) {
3086
- throw new m(e, g.runtimeFatal(e));
3111
+ throw new g(e, E.runtimeFatal(e));
3087
3112
  }
3088
3113
  resolvePointer(e) {
3089
3114
  return this.execution.resolvePointer(this.scopePathValue, e);
@@ -3135,16 +3160,16 @@ class _r {
3135
3160
  return !this.allowTerminatedWork && this.execution.isScopeInactive(this.scopePathValue);
3136
3161
  }
3137
3162
  }
3138
- const $r = new pt({
3163
+ const zr = new pt({
3139
3164
  repositories: [dt, yt, St]
3140
3165
  });
3141
- class xr {
3166
+ class Hr {
3142
3167
  blue;
3143
3168
  registryRef;
3144
3169
  contractLoaderRef;
3145
3170
  engine;
3146
3171
  constructor(e) {
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(
3172
+ this.registryRef = e?.registry ?? Q.create().registerDefaults().build(), this.blue = e?.blue ?? zr, this.contractLoaderRef = new zn(this.registryRef, this.blue), this.engine = new j(
3148
3173
  this.contractLoaderRef,
3149
3174
  this.registryRef,
3150
3175
  this.blue
@@ -3177,10 +3202,10 @@ class xr {
3177
3202
  return this.contractLoaderRef;
3178
3203
  }
3179
3204
  static builder() {
3180
- return new Fr();
3205
+ return new Ur();
3181
3206
  }
3182
3207
  }
3183
- class Fr {
3208
+ class Ur {
3184
3209
  contractRegistry;
3185
3210
  blueInstance;
3186
3211
  constructor() {
@@ -3196,13 +3221,13 @@ class Fr {
3196
3221
  return this.blueInstance = e, this;
3197
3222
  }
3198
3223
  build() {
3199
- return new xr({
3224
+ return new Hr({
3200
3225
  registry: this.contractRegistry,
3201
3226
  blue: this.blueInstance
3202
3227
  });
3203
3228
  }
3204
3229
  }
3205
- class Ye {
3230
+ class Ze {
3206
3231
  process(e, t) {
3207
3232
  const n = t.getValue();
3208
3233
  if (W(n)) {
@@ -3223,91 +3248,91 @@ class Ye {
3223
3248
  return e;
3224
3249
  }
3225
3250
  }
3226
- const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3251
+ const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3227
3252
  __proto__: null,
3228
- ExpressionPreserver: Ye
3253
+ ExpressionPreserver: Ze
3229
3254
  }, Symbol.toStringTag, { value: "Module" }));
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()
3255
+ function di() {
3256
+ return new T.SequentialMergingProcessor([
3257
+ new T.ValuePropagator(),
3258
+ new Ze(),
3259
+ new T.TypeAssigner(),
3260
+ new T.ListProcessor(),
3261
+ new T.DictionaryProcessor(),
3262
+ new T.BasicTypesVerifier()
3238
3263
  ]);
3239
3264
  }
3240
3265
  export {
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,
3266
+ Pn as ChannelBinding,
3267
+ Gn as ChannelRunner,
3268
+ Wn as CheckpointManager,
3269
+ Kn as CheckpointRecord,
3270
+ Ve as CodeBlockEvaluationError,
3271
+ A as ContractBundle,
3272
+ Mn as ContractBundleBuilder,
3273
+ zn as ContractLoader,
3249
3274
  ln as ContractProcessorRegistry,
3250
3275
  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,
3276
+ Ne as DocumentProcessingResult,
3277
+ Lr as DocumentProcessingRuntime,
3278
+ Hr as DocumentProcessor,
3279
+ Ur as DocumentProcessorBuilder,
3280
+ dr as EmissionRegistry,
3281
+ Br as GasMeter,
3282
+ Nn as HandlerBinding,
3258
3283
  I as KEY_CHECKPOINT,
3259
- Ne as KEY_EMBEDDED,
3260
- Me as KEY_INITIALIZED,
3261
- Ae as KEY_TERMINATED,
3262
- ai as MergingProcessors,
3284
+ Me as KEY_EMBEDDED,
3285
+ Ae as KEY_INITIALIZED,
3286
+ De as KEY_TERMINATED,
3287
+ ui as MergingProcessors,
3263
3288
  Oe as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3264
- rr as PatchEngine,
3265
- ni as ProcessorContractConstants,
3289
+ or as PatchEngine,
3290
+ si as ProcessorContractConstants,
3266
3291
  j as ProcessorEngine,
3267
- g as ProcessorErrors,
3268
- Lr as ProcessorExecution,
3269
- _r as ProcessorExecutionContext,
3270
- m as ProcessorFatalError,
3271
- ri as ProcessorPointerConstants,
3272
- oe as QuickJSEvaluator,
3273
- Be as RELATIVE_CHECKPOINT,
3274
- A as RELATIVE_CONTRACTS,
3292
+ E as ProcessorErrors,
3293
+ xr as ProcessorExecution,
3294
+ Fr as ProcessorExecutionContext,
3295
+ g as ProcessorFatalError,
3296
+ oi as ProcessorPointerConstants,
3297
+ ae as QuickJSEvaluator,
3298
+ Le as RELATIVE_CHECKPOINT,
3299
+ D as RELATIVE_CONTRACTS,
3275
3300
  Nt as RELATIVE_EMBEDDED,
3276
- ne as RELATIVE_INITIALIZED,
3277
- De as RELATIVE_TERMINATED,
3278
- ie as RESERVED_CONTRACT_KEYS,
3301
+ re as RELATIVE_INITIALIZED,
3302
+ Be as RELATIVE_TERMINATED,
3303
+ se as RESERVED_CONTRACT_KEYS,
3279
3304
  q as RunTerminationError,
3280
- Qn as ScopeExecutor,
3281
- ar as ScopeRuntimeContext,
3282
- Xn as TerminationService,
3283
- Zr as andThen,
3284
- ze as canonicalSignature,
3285
- ye as canonicalSize,
3305
+ Xn as ScopeExecutor,
3306
+ ur as ScopeRuntimeContext,
3307
+ nr as TerminationService,
3308
+ ti as andThen,
3309
+ He as canonicalSignature,
3310
+ we as canonicalSize,
3286
3311
  O as channelContractBaseSchema,
3287
3312
  en as channelEventCheckpointSchema,
3288
3313
  Kt as containsExpression,
3289
- ae as contractBaseSchema,
3290
- ci as createDefaultMergingProcessor,
3291
- Ge as createPicomatchShouldResolve,
3314
+ ce as contractBaseSchema,
3315
+ di as createDefaultMergingProcessor,
3316
+ qe as createPicomatchShouldResolve,
3292
3317
  jt as documentUpdateChannelSchema,
3293
3318
  Jt as embeddedNodeChannelSchema,
3294
- kt as err,
3295
- We as evaluateQuickJSExpression,
3319
+ vt as err,
3320
+ Ge as evaluateQuickJSExpression,
3296
3321
  Wt as extractExpressionContent,
3297
- qe as handlerContractBaseSchema,
3322
+ je as handlerContractBaseSchema,
3298
3323
  tn as initializationMarkerSchema,
3299
- Jr as isErr,
3324
+ Zr as isErr,
3300
3325
  W as isExpression,
3301
- jr as isOk,
3302
- se as isProcessorManagedChannelBlueId,
3326
+ Yr as isOk,
3327
+ oe as isProcessorManagedChannelBlueId,
3303
3328
  Pt as isReservedContractKey,
3304
- ii as joinRelativePointers,
3305
- si as jsonPatchSchema,
3329
+ ai as joinRelativePointers,
3330
+ ci as jsonPatchSchema,
3306
3331
  Qt as lifecycleChannelSchema,
3307
- Qr as map,
3308
- Yr as mapErr,
3332
+ Xr as map,
3333
+ ei as mapErr,
3309
3334
  H as markerContractBaseSchema,
3310
- ti as match,
3335
+ ii as match,
3311
3336
  Xt as myosTimelineChannelSchema,
3312
3337
  b as normalizePointer,
3313
3338
  y as normalizeScope,
@@ -3315,8 +3340,8 @@ export {
3315
3340
  sn as operationMarkerSchema,
3316
3341
  nn as processEmbeddedMarkerSchema,
3317
3342
  rn as processingTerminatedMarkerSchema,
3318
- $e as relativeCheckpointLastEvent,
3319
- xe as relativeCheckpointLastSignature,
3343
+ xe as relativeCheckpointLastEvent,
3344
+ Fe as relativeCheckpointLastSignature,
3320
3345
  J as relativeContractsEntry,
3321
3346
  Mt as relativizePointer,
3322
3347
  G as resolveNodeExpressions,
@@ -3324,10 +3349,10 @@ export {
3324
3349
  Gt as resolveTemplateString,
3325
3350
  an as sequentialWorkflowOperationSchema,
3326
3351
  on as sequentialWorkflowSchema,
3327
- oi as sequentialWorkflowStepSchema,
3328
- ge as stripSlashes,
3352
+ li as sequentialWorkflowStepSchema,
3353
+ Ee as stripSlashes,
3329
3354
  Zt as timelineChannelSchema,
3330
3355
  Yt as triggeredEventChannelSchema,
3331
- Xr as unwrapOr,
3332
- ei as unwrapOrElse
3356
+ ni as unwrapOr,
3357
+ ri as unwrapOrElse
3333
3358
  };