@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
  2. package/dist/core-cPQWYD4K.cjs +1 -0
  3. package/dist/debug/api/Raph.cjs +1 -1
  4. package/dist/debug/api/Raph.js +46 -47
  5. package/dist/debug/api/RaphFacadeSession.cjs +1 -1
  6. package/dist/debug/api/RaphFacadeSession.js +85 -89
  7. package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
  8. package/dist/debug/api/RaphReactivityInstance.js +27 -30
  9. package/dist/debug/path/DataPath.cjs +1 -1
  10. package/dist/debug/path/DataPath.js +198 -202
  11. package/dist/debug/path/PathRouter.cjs +1 -1
  12. package/dist/debug/path/PathRouter.js +44 -50
  13. package/dist/debug/path/RaphKernel.cjs +1 -1
  14. package/dist/debug/path/RaphKernel.js +257 -228
  15. package/dist/debug/path/data-path.utils.cjs +1 -1
  16. package/dist/debug/path/data-path.utils.js +41 -41
  17. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
  18. package/dist/debug/path/derived/DerivedRegistry.js +52 -66
  19. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
  20. package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
  21. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
  22. package/dist/debug/path/derived/derived-collection.utils.js +70 -70
  23. package/dist/debug/path/meta/MetaController.cjs +1 -1
  24. package/dist/debug/path/meta/MetaController.js +57 -65
  25. package/dist/debug/path/meta/RaphMeta.cjs +1 -1
  26. package/dist/debug/path/meta/RaphMeta.js +26 -32
  27. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
  28. package/dist/debug/path/meta/RaphMetaStore.js +24 -30
  29. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
  30. package/dist/debug/path/storage/AdapterPathStore.js +49 -54
  31. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
  32. package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
  33. package/dist/debug/path/storage/PathEventHub.cjs +1 -1
  34. package/dist/debug/path/storage/PathEventHub.js +74 -61
  35. package/dist/debug/path/storage/PathStore.cjs +1 -1
  36. package/dist/debug/path/storage/PathStore.js +89 -99
  37. package/dist/debug/path/storage/createDataDraft.cjs +1 -1
  38. package/dist/debug/path/storage/createDataDraft.js +24 -28
  39. package/dist/debug/reactivity/disposal.cjs +1 -0
  40. package/dist/debug/reactivity/disposal.js +32 -0
  41. package/dist/debug/reactivity/engine.cjs +1 -1
  42. package/dist/debug/reactivity/engine.js +787 -392
  43. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  44. package/dist/debug/reactivity/reactive-object.js +81 -96
  45. package/dist/debug/reactivity/scope.cjs +1 -1
  46. package/dist/debug/reactivity/scope.js +221 -117
  47. package/dist/debug/reactivity/watch.cjs +1 -1
  48. package/dist/debug/reactivity/watch.js +1 -1
  49. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  50. package/dist/debug/runtime/RaphRuntime.js +764 -411
  51. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  52. package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
  53. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
  54. package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
  55. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  56. package/dist/debug/runtime/ownership/RaphNode.js +595 -136
  57. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  58. package/dist/debug/runtime/ownership/RaphScope.js +203 -68
  59. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
  60. package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
  61. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  62. package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
  63. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  64. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  65. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  67. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
  68. package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
  69. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
  70. package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
  71. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
  79. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  81. package/dist/entrypoints/runtime.d.ts +2 -1
  82. package/dist/machine-testing.cjs +1 -1
  83. package/dist/machine-testing.js +1 -1
  84. package/dist/machine.cjs +1 -1
  85. package/dist/machine.js +216 -231
  86. package/dist/path/RaphKernel.d.ts +24 -0
  87. package/dist/path/storage/PathEventHub.d.ts +14 -0
  88. package/dist/path/storage/PathStore.d.ts +4 -4
  89. package/dist/reactivity/disposal.d.ts +14 -0
  90. package/dist/reactivity/engine.d.ts +177 -4
  91. package/dist/reactivity/scope.d.ts +108 -30
  92. package/dist/runtime/RaphRuntime.d.ts +236 -17
  93. package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
  94. package/dist/runtime/ownership/RaphNode.d.ts +276 -6
  95. package/dist/runtime/ownership/RaphScope.d.ts +144 -14
  96. package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
  97. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  98. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  99. package/dist/runtime/phases/phase.types.d.ts +83 -4
  100. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  101. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
  102. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
  103. package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
  104. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  105. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
  106. package/package.json +10 -2
  107. package/dist/core-ugchZNqC.cjs +0 -1
package/dist/machine.js CHANGED
@@ -1,66 +1,66 @@
1
- import { b as B, g as N, h as L, c as J, r as Q, d as W, s as H } from "./core-CyilRD7s.js";
2
- import { e as rt, a as st, t as nt } from "./core-CyilRD7s.js";
3
- import { RaphScope as F } from "./debug/runtime/ownership/RaphScope.js";
4
- class m extends Error {
1
+ import { b as I, g as M, h as j, c as P, r as k, d as A, s as z } from "./core-CClhT8WR.js";
2
+ import { e as K, a as U, t as X } from "./core-CClhT8WR.js";
3
+ import { RaphScope as D } from "./debug/runtime/ownership/RaphScope.js";
4
+ class _ extends Error {
5
5
  }
6
- function V(o, t) {
7
- return B(
6
+ function N(o, t) {
7
+ return I(
8
8
  o,
9
9
  t
10
- ), y(t.context, "context"), t.output !== void 0 && y(t.output, "output"), Object.freeze({
10
+ ), v(t.context, "context"), t.output !== void 0 && v(t.output, "output"), Object.freeze({
11
11
  active: Object.freeze([...t.active]),
12
- context: P(t.context),
12
+ context: O(t.context),
13
13
  history: Object.freeze(Object.fromEntries(
14
14
  Object.entries(t.history).map(([e, r]) => [e, Object.freeze([...r])])
15
15
  )),
16
16
  modelId: o.id,
17
- ...t.output === void 0 ? {} : { output: P(t.output) },
17
+ ...t.output === void 0 ? {} : { output: O(t.output) },
18
18
  revision: t.revision,
19
19
  status: t.status,
20
20
  version: o.version
21
21
  });
22
22
  }
23
- function G(o, t, e) {
24
- const r = N(o);
23
+ function B(o, t, e) {
24
+ const r = M(o);
25
25
  try {
26
26
  if (typeof t != "object" || t === null || Array.isArray(t))
27
- throw new m("[Raph machine] Persisted snapshot must be an object.");
27
+ throw new _("[Raph machine] Persisted snapshot must be an object.");
28
28
  if (t.modelId !== o.id)
29
- throw new m(
29
+ throw new _(
30
30
  `[Raph machine] Snapshot model "${t.modelId}" is incompatible with "${o.id}".`
31
31
  );
32
32
  if (!Number.isSafeInteger(t.version) || t.version < 1)
33
- throw new m("[Raph machine] Persisted version must be a positive integer.");
33
+ throw new _("[Raph machine] Persisted version must be a positive integer.");
34
34
  let i = t;
35
35
  for (; i.version < o.version; ) {
36
36
  const s = r.migrations.get(i.version);
37
37
  if (s === void 0)
38
- throw new m(
38
+ throw new _(
39
39
  `[Raph machine] Missing migration from version ${i.version} for "${o.id}".`
40
40
  );
41
41
  const n = s(i);
42
42
  if (n.version !== i.version + 1 || n.modelId !== o.id)
43
- throw new m(
43
+ throw new _(
44
44
  `[Raph machine] Migration from version ${i.version} must produce version ${i.version + 1}.`
45
45
  );
46
46
  i = n;
47
47
  }
48
48
  if (i.version !== o.version)
49
- throw new m(
49
+ throw new _(
50
50
  `[Raph machine] Snapshot version ${i.version} is newer than model version ${o.version}.`
51
51
  );
52
- return y(i.context, "context"), i.output !== void 0 && y(i.output, "output"), L(
52
+ return v(i.context, "context"), i.output !== void 0 && v(i.output, "output"), j(
53
53
  o,
54
54
  i,
55
55
  e
56
56
  );
57
57
  } catch (i) {
58
- throw i instanceof m ? i : new m(
58
+ throw i instanceof _ ? i : new _(
59
59
  `[Raph machine] Persisted snapshot is invalid: ${i instanceof Error ? i.message : String(i)}`
60
60
  );
61
61
  }
62
62
  }
63
- function y(o, t, e = /* @__PURE__ */ new Set()) {
63
+ function v(o, t, e = /* @__PURE__ */ new Set()) {
64
64
  if (o === null)
65
65
  return;
66
66
  const r = typeof o;
@@ -68,101 +68,99 @@ function y(o, t, e = /* @__PURE__ */ new Set()) {
68
68
  return;
69
69
  if (r === "number") {
70
70
  if (!Number.isFinite(o))
71
- throw new m(`[Raph machine] ${t} contains a non-finite number.`);
71
+ throw new _(`[Raph machine] ${t} contains a non-finite number.`);
72
72
  return;
73
73
  }
74
74
  if (r !== "object")
75
- throw new m(`[Raph machine] ${t} is not JSON-safe.`);
75
+ throw new _(`[Raph machine] ${t} is not JSON-safe.`);
76
76
  const i = o;
77
77
  if (e.has(i))
78
- throw new m(`[Raph machine] ${t} contains a cycle.`);
78
+ throw new _(`[Raph machine] ${t} contains a cycle.`);
79
79
  if (e.add(i), Array.isArray(o))
80
- o.forEach((s, n) => y(s, `${t}[${n}]`, e));
80
+ o.forEach((s, n) => v(s, `${t}[${n}]`, e));
81
81
  else {
82
82
  const s = Object.getPrototypeOf(o);
83
83
  if (s !== Object.prototype && s !== null)
84
- throw new m(`[Raph machine] ${t} contains a non-plain object.`);
85
- for (const [n, a] of Object.entries(o))
86
- y(a, `${t}.${n}`, e);
84
+ throw new _(`[Raph machine] ${t} contains a non-plain object.`);
85
+ for (const [n, h] of Object.entries(o))
86
+ v(h, `${t}.${n}`, e);
87
87
  }
88
88
  e.delete(i);
89
89
  }
90
- function P(o) {
90
+ function O(o) {
91
91
  return JSON.parse(JSON.stringify(o));
92
92
  }
93
- const k = /* @__PURE__ */ new WeakMap(), S = Symbol("RaphMachineActivationCancelled"), A = Object.freeze({ type: "@@init" }), K = Object.freeze({
93
+ const E = /* @__PURE__ */ new WeakMap(), y = Symbol("RaphMachineActivationCancelled"), C = Object.freeze({ type: "@@init" }), L = Object.freeze({
94
94
  clearTimeout: (o) => clearTimeout(o),
95
95
  now: () => Date.now(),
96
96
  setTimeout: (o, t) => setTimeout(o, t)
97
97
  });
98
- class E {
98
+ class S {
99
99
  constructor(t, e, r, i) {
100
- if (this.id = void 0, this.model = void 0, this.snapshot = void 0, this._owner = void 0, this._runtime = void 0, this._compiled = void 0, this._bindings = void 0, this._clock = void 0, this._input = void 0, this._errorPolicy = void 0, this._releaseSnapshot = O, this._writeSnapshotInBoundary = void 0, this._currentSnapshot = void 0, this._queue = void 0, this._listeners = void 0, this._stateCleanups = void 0, this._invocations = void 0, this._actors = void 0, this._releaseOwnership = O, this._releaseDebug = O, this._restored = !1, this._initialPlan = void 0, this._onError = void 0, this._queueCursor = 0, this._processing = !1, this._started = !1, this._stopped = !1, this._lastIgnoredSnapshot = void 0, this._lastIgnoredResult = void 0, !(t instanceof F))
100
+ if (this.id = void 0, this.model = void 0, this.snapshot = void 0, this._owner = void 0, this._runtime = void 0, this._compiled = void 0, this._bindings = void 0, this._clock = void 0, this._input = void 0, this._errorPolicy = void 0, this._releaseSnapshot = R, this._writeSnapshotInBoundary = void 0, this._currentSnapshot = void 0, this._queue = void 0, this._listeners = void 0, this._stateCleanups = void 0, this._invocations = void 0, this._actors = void 0, this._releaseOwnership = R, this._releaseDebug = R, this._restored = !1, this._initialPlan = void 0, this._onError = void 0, this._queueCursor = 0, this._processing = !1, this._started = !1, this._stopped = !1, this._lastIgnoredSnapshot = void 0, this._lastIgnoredResult = void 0, !(t instanceof D))
101
101
  throw new TypeError("[Raph machine] Machine owner must be a Raph Runtime scope or node.");
102
- if (t._assertAlive(), this._owner = t, this._runtime = t.runtime, this._compiled = N(
102
+ if (t._assertAlive(), this._owner = t, this._runtime = t.runtime, this._compiled = M(
103
103
  e
104
- ), this.model = e, this._bindings = r, this._clock = i.clock ?? K, this._input = i.input, this._errorPolicy = i.errorPolicy ?? "throw", this._errorPolicy !== "ignore" && this._errorPolicy !== "stop" && this._errorPolicy !== "throw")
104
+ ), this.model = e, this._bindings = r, this._clock = i.clock ?? L, this._input = i.input, this._errorPolicy = i.errorPolicy ?? "throw", this._errorPolicy !== "ignore" && this._errorPolicy !== "stop" && this._errorPolicy !== "throw")
105
105
  throw new TypeError(`[Raph machine] Unknown error policy "${String(this._errorPolicy)}".`);
106
106
  this._onError = i.onError;
107
- const s = (k.get(this._runtime) ?? 0) + 1;
108
- if (k.set(this._runtime, s), this.id = i.id ?? `${e.id}#${s}`, !this.id.trim())
107
+ const s = (E.get(this._runtime) ?? 0) + 1;
108
+ if (E.set(this._runtime, s), this.id = i.id ?? `${e.id}#${s}`, !this.id.trim())
109
109
  throw new TypeError("[Raph machine] Instance id must not be empty.");
110
110
  if (this._runtime._hasMachineDebug(this.id))
111
111
  throw new Error(`[Raph] Machine diagnostic id "${this.id}" is already registered.`);
112
- const n = i.persisted === void 0 ? this._runtime.untracked(() => J(
112
+ const n = i.persisted === void 0 ? this._runtime.untracked(() => P(
113
113
  e,
114
114
  this._input,
115
115
  r,
116
116
  this._runtime._traces("machine") ? this._traceHooks() : void 0
117
- )) : void 0, a = (n == null ? void 0 : n.snapshot) ?? G(e, i.persisted, this._input);
118
- this._initialPlan = n == null ? void 0 : n.plan, this._restored = i.persisted !== void 0;
119
- const c = U(this._runtime, t, a);
120
- this._releaseSnapshot = c.dispose, this._writeSnapshotInBoundary = c.writeInBoundary, this._currentSnapshot = a, this.snapshot = c.source;
117
+ )) : void 0, h = n?.snapshot ?? B(e, i.persisted, this._input);
118
+ this._initialPlan = n?.plan, this._restored = i.persisted !== void 0;
119
+ const c = J(this._runtime, t, h);
120
+ this._releaseSnapshot = c.dispose, this._writeSnapshotInBoundary = c.writeInBoundary, this._currentSnapshot = h, this.snapshot = c.source;
121
121
  try {
122
122
  this._releaseDebug = this._runtime._registerMachineDebug({
123
123
  id: this.id,
124
124
  ownerId: t.id,
125
125
  ...i.parentId === void 0 ? {} : { parentId: i.parentId },
126
126
  snapshot: () => {
127
- var _;
128
- const h = this._currentSnapshot, u = Object.fromEntries(this._activeClosure(h).flatMap((f) => {
129
- const d = this._compiled.states[f].meta;
130
- return d === void 0 ? [] : [[this._compiled.states[f].path, d]];
127
+ const a = this._currentSnapshot, u = Object.fromEntries(this._activeClosure(a).flatMap((d) => {
128
+ const g = this._compiled.states[d].meta;
129
+ return g === void 0 ? [] : [[this._compiled.states[d].path, g]];
131
130
  }));
132
131
  return Object.freeze({
133
- active: h.active,
134
- actors: Object.freeze([...((_ = this._actors) == null ? void 0 : _.keys()) ?? []]),
135
- contextKeys: Object.freeze(D(h.context) ? Object.keys(h.context) : []),
132
+ active: a.active,
133
+ actors: Object.freeze([...this._actors?.keys() ?? []]),
134
+ contextKeys: Object.freeze(T(a.context) ? Object.keys(a.context) : []),
136
135
  id: this.id,
137
136
  meta: Object.freeze(u),
138
137
  modelId: e.id,
139
138
  ownerId: t.id,
140
139
  ...i.parentId === void 0 ? {} : { parentId: i.parentId },
141
- revision: h.revision,
142
- status: h.status
140
+ revision: a.revision,
141
+ status: a.status
143
142
  });
144
143
  }
145
144
  }), this._releaseOwnership = t.own(() => this._dispose(!1));
146
- } catch (h) {
147
- const u = [h];
145
+ } catch (a) {
146
+ const u = [a];
148
147
  try {
149
148
  this._releaseDebug();
150
- } catch (_) {
151
- u.push(_);
149
+ } catch (d) {
150
+ u.push(d);
152
151
  }
153
152
  try {
154
153
  this._releaseSnapshot();
155
- } catch (_) {
156
- u.push(_);
154
+ } catch (d) {
155
+ u.push(d);
157
156
  }
158
- throw u.length > 1 ? new AggregateError(u, `[Raph machine] Machine "${this.id}" construction rollback failed.`) : h;
157
+ throw u.length > 1 ? new AggregateError(u, `[Raph machine] Machine "${this.id}" construction rollback failed.`) : a;
159
158
  }
160
159
  }
161
160
  get started() {
162
161
  return this._started && !this._stopped;
163
162
  }
164
163
  start() {
165
- var s, n;
166
164
  if (this._stopped)
167
165
  throw new Error(`[Raph machine] Machine "${this.id}" is stopped.`);
168
166
  if (this._started)
@@ -173,56 +171,56 @@ class E {
173
171
  throw new Error(`[Raph machine] Persisted machine "${this.id}" is stopped.`);
174
172
  if (this._started = !0, this._compiled.flat)
175
173
  return this;
176
- const e = this._activeClosure(t).sort((a, c) => this._compiled.states[a].depth - this._compiled.states[c].depth);
174
+ const e = this._activeClosure(t).sort((s, n) => this._compiled.states[s].depth - this._compiled.states[n].depth);
177
175
  let r = !1, i;
178
176
  this._processing = !0;
179
177
  try {
180
- const a = [];
178
+ const s = [];
181
179
  if (!this._restored) {
182
180
  try {
183
181
  this._runOutputs(
184
- ((s = this._initialPlan) == null ? void 0 : s.exitOutputs) ?? [],
182
+ this._initialPlan?.exitOutputs ?? [],
185
183
  t,
186
184
  this._runtime._currentTraceCauseId()
187
185
  );
188
- } catch (c) {
189
- a.push(c);
186
+ } catch (n) {
187
+ s.push(n);
190
188
  }
191
189
  if (this.started)
192
190
  try {
193
191
  this._runOutputs(
194
- ((n = this._initialPlan) == null ? void 0 : n.transitionOutputs) ?? [],
192
+ this._initialPlan?.transitionOutputs ?? [],
195
193
  t,
196
194
  this._runtime._currentTraceCauseId()
197
195
  );
198
- } catch (c) {
199
- a.push(c);
196
+ } catch (n) {
197
+ s.push(n);
200
198
  }
201
199
  if (this.started) {
202
- const c = e.flatMap((h) => this._compiled.states[h].entry.map((u) => ({ event: A, ref: u })));
200
+ const n = e.flatMap((h) => this._compiled.states[h].entry.map((c) => ({ event: C, ref: c })));
203
201
  try {
204
- this._runOutputs(c, t, this._runtime._currentTraceCauseId());
202
+ this._runOutputs(n, t, this._runtime._currentTraceCauseId());
205
203
  } catch (h) {
206
- a.push(h);
204
+ s.push(h);
207
205
  }
208
206
  }
209
207
  }
210
208
  if (this.started && t.status === "active")
211
- for (const c of e) {
209
+ for (const n of e) {
212
210
  if (!this.started)
213
211
  break;
214
212
  try {
215
- this._activateState(c, A, t);
213
+ this._activateState(n, C, t);
216
214
  } catch (h) {
217
- a.push(h);
215
+ s.push(h);
218
216
  }
219
217
  }
220
- g(a, `[Raph machine] Machine "${this.id}" start work failed.`);
221
- } catch (a) {
218
+ l(s, `[Raph machine] Machine "${this.id}" start work failed.`);
219
+ } catch (s) {
222
220
  try {
223
- this._handlePostCommitError(a, "start", this._runtime._currentTraceCauseId());
224
- } catch (c) {
225
- r = !0, i = c;
221
+ this._handlePostCommitError(s, "start", this._runtime._currentTraceCauseId());
222
+ } catch (n) {
223
+ r = !0, i = n;
226
224
  }
227
225
  } finally {
228
226
  this._processing = !1, r ? (this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0) : this._drainQueued();
@@ -235,8 +233,7 @@ class E {
235
233
  return this._enqueue(t);
236
234
  }
237
235
  sendTo(t, e) {
238
- var i;
239
- const r = (i = this._actors) == null ? void 0 : i.get(t);
236
+ const r = this._actors?.get(t);
240
237
  if (r === void 0)
241
238
  throw new Error(`[Raph machine] Actor "${t}" is not active in "${this.id}".`);
242
239
  return r.send(e);
@@ -260,27 +257,27 @@ class E {
260
257
  return this._listeners = r === void 0 ? [e] : [...r, e], () => this._removeListener(e);
261
258
  }
262
259
  persist() {
263
- return V(this.model, this.snapshot.get());
260
+ return N(this.model, this.snapshot.get());
264
261
  }
265
262
  stop() {
266
263
  let t;
267
264
  try {
268
265
  this._dispose(!0);
269
266
  } catch (e) {
270
- (t ?? (t = [])).push(e);
267
+ (t ??= []).push(e);
271
268
  }
272
269
  try {
273
270
  this._releaseOwnership();
274
271
  } catch (e) {
275
- (t ?? (t = [])).push(e);
272
+ (t ??= []).push(e);
276
273
  }
277
- g(t, `[Raph machine] Machine "${this.id}" stop failed.`);
274
+ l(t, `[Raph machine] Machine "${this.id}" stop failed.`);
278
275
  }
279
276
  _enqueue(t, e) {
280
277
  if (!this.started)
281
278
  throw new Error(`[Raph machine] Machine "${this.id}" must be started before send().`);
282
- if (X(t), this._processing)
283
- return (this._queue ?? (this._queue = [])).push({ event: t, ...e === void 0 ? {} : { transitions: e } }), { snapshot: this._currentSnapshot, status: "queued" };
279
+ if (Q(t), this._processing)
280
+ return (this._queue ??= []).push({ event: t, ...e === void 0 ? {} : { transitions: e } }), { snapshot: this._currentSnapshot, status: "queued" };
284
281
  this._processing = !0;
285
282
  let r;
286
283
  try {
@@ -295,50 +292,50 @@ class E {
295
292
  let n;
296
293
  i !== void 0 && this._trace(t.type, "start", i, s, r);
297
294
  try {
298
- const a = e === void 0 ? this._compiled.eventIndexes.get(t.type) : void 0;
299
- if (e === void 0 && a === void 0)
295
+ const h = e === void 0 ? this._compiled.eventIndexes.get(t.type) : void 0;
296
+ if (e === void 0 && h === void 0)
300
297
  return i !== void 0 && this._trace(t.type, "ignored", i, s, r), this._ignored(r);
301
- const c = i === void 0 ? void 0 : this._traceHooks(i, s), h = this._runtime._hasActiveReactiveContext() ? this._runtime.untracked(() => this._evaluate(r, t, a, e, c)) : this._evaluate(r, t, a, e, c);
302
- if (!h.changed)
298
+ const c = i === void 0 ? void 0 : this._traceHooks(i, s), a = this._runtime._hasActiveReactiveContext() ? this._runtime.untracked(() => this._evaluate(r, t, h, e, c)) : this._evaluate(r, t, h, e, c);
299
+ if (!a.changed)
303
300
  return i !== void 0 && this._trace(t.type, "ignored", i, s, r), this._ignored(r);
304
301
  this._runtime._batchReactive(() => {
305
- this._writeSnapshotInBoundary(h.snapshot), this._currentSnapshot = h.snapshot, n = h.snapshot;
302
+ this._writeSnapshotInBoundary(a.snapshot), this._currentSnapshot = a.snapshot, n = a.snapshot;
306
303
  });
307
304
  let u;
308
305
  try {
309
- this._applyPlan(h.plan, h.snapshot, s);
310
- } catch (d) {
311
- (u ?? (u = [])).push(d);
306
+ this._applyPlan(a.plan, a.snapshot, s);
307
+ } catch (m) {
308
+ (u ??= []).push(m);
312
309
  }
313
- const _ = this._listeners;
314
- if (this.started && _ !== void 0) {
315
- const d = this._notifyListeners(_, h.snapshot);
316
- d !== void 0 && (u ?? (u = [])).push(...d);
310
+ const d = this._listeners;
311
+ if (this.started && d !== void 0) {
312
+ const m = this._notifyListeners(d, a.snapshot);
313
+ m !== void 0 && (u ??= []).push(...m);
317
314
  }
318
- if (this.started && h.snapshot.status === "done")
315
+ if (this.started && a.snapshot.status === "done")
319
316
  try {
320
317
  this._stopStateResources();
321
- } catch (d) {
322
- (u ?? (u = [])).push(d);
318
+ } catch (m) {
319
+ (u ??= []).push(m);
323
320
  }
324
- u !== void 0 && g(u, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
325
- const f = this.started ? h.snapshot : this._currentSnapshot;
326
- return i !== void 0 && this._trace(t.type, "end", i, s, f), { snapshot: f, status: "transitioned" };
327
- } catch (a) {
321
+ u !== void 0 && l(u, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
322
+ const g = this.started ? a.snapshot : this._currentSnapshot;
323
+ return i !== void 0 && this._trace(t.type, "end", i, s, g), { snapshot: g, status: "transitioned" };
324
+ } catch (h) {
328
325
  if (n !== void 0)
329
- return this._handlePostCommitError(a, t.type, s), { snapshot: this._currentSnapshot, status: "transitioned" };
330
- if (this._traceError(t.type, a, i, s), this._onError !== void 0)
331
- return this._onError(a), this._ignored(this._currentSnapshot);
326
+ return this._handlePostCommitError(h, t.type, s), { snapshot: this._currentSnapshot, status: "transitioned" };
327
+ if (this._traceError(t.type, h, i, s), this._onError !== void 0)
328
+ return this._onError(h), this._ignored(this._currentSnapshot);
332
329
  if (this._errorPolicy === "stop" && this._dispose(!0), this._errorPolicy === "ignore")
333
330
  return this._ignored(this._currentSnapshot);
334
- throw a;
331
+ throw h;
335
332
  }
336
333
  }
337
334
  _ignored(t) {
338
335
  return this._lastIgnoredSnapshot !== t && (this._lastIgnoredSnapshot = t, this._lastIgnoredResult = { snapshot: t, status: "ignored" }), this._lastIgnoredResult;
339
336
  }
340
337
  _evaluate(t, e, r, i, s) {
341
- return i === void 0 ? Q(
338
+ return i === void 0 ? k(
342
339
  this.model,
343
340
  t,
344
341
  e,
@@ -347,7 +344,7 @@ class E {
347
344
  s,
348
345
  this._compiled,
349
346
  r
350
- ) : W(
347
+ ) : A(
351
348
  this.model,
352
349
  t,
353
350
  e,
@@ -424,165 +421,154 @@ class E {
424
421
  i.push(n);
425
422
  }
426
423
  }
427
- g(i, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
424
+ l(i, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
428
425
  }
429
426
  _activateState(t, e, r) {
430
- var a, c;
431
- if (!this.started || (a = this._stateCleanups) != null && a.has(t))
427
+ if (!this.started || this._stateCleanups?.has(t))
432
428
  return;
433
429
  const i = this._compiled.states[t];
434
430
  if (i.resources.length === 0 && i.after.size === 0 && i.invokes.length === 0)
435
431
  return;
436
- const s = [], n = this._stateCleanups ?? (this._stateCleanups = /* @__PURE__ */ new Map());
432
+ const s = [], n = this._stateCleanups ??= /* @__PURE__ */ new Map();
437
433
  n.set(t, s);
438
434
  try {
439
435
  for (const h of i.resources) {
440
- const u = (c = this._bindings.resources) == null ? void 0 : c[h];
441
- if (u === void 0)
436
+ const c = this._bindings.resources?.[h];
437
+ if (c === void 0)
442
438
  throw new Error(`[Raph machine] Resource binding "${h}" is not defined.`);
443
- const _ = new AbortController();
444
- let f;
439
+ const a = new AbortController();
440
+ let u;
445
441
  try {
446
- const d = this._runtime.untracked(() => u({
442
+ const d = this._runtime.untracked(() => c({
447
443
  context: r.context,
448
444
  event: e,
449
445
  input: this._input,
450
446
  owner: this._owner,
451
- signal: _.signal,
447
+ signal: a.signal,
452
448
  snapshot: r
453
449
  }));
454
- typeof d == "function" && (f = d);
450
+ typeof d == "function" && (u = d);
455
451
  } catch (d) {
456
- throw _.abort(), d;
452
+ throw a.abort(), d;
457
453
  }
458
- if (s.push(R(() => {
459
- _.abort(), f == null || f();
454
+ if (s.push(b(() => {
455
+ a.abort(), u?.();
460
456
  })), !this.started)
461
- throw S;
457
+ throw y;
462
458
  }
463
- for (const [h, u] of i.after) {
464
- const _ = this._resolveDelay(h, r, e);
459
+ for (const [h, c] of i.after) {
460
+ const a = this._resolveDelay(h, r, e);
465
461
  if (!this.started)
466
- throw S;
467
- const f = this._clock.setTimeout(() => {
468
- var d;
469
- !this.started || !((d = this._stateCleanups) != null && d.has(t)) || this._enqueue(Object.freeze({ type: `@@after:${i.path}:${h}` }), u);
470
- }, _);
471
- if (s.push(R(() => this._clock.clearTimeout(f))), !this.started)
472
- throw S;
462
+ throw y;
463
+ const u = this._clock.setTimeout(() => {
464
+ !this.started || !this._stateCleanups?.has(t) || this._enqueue(Object.freeze({ type: `@@after:${i.path}:${h}` }), c);
465
+ }, a);
466
+ if (s.push(b(() => this._clock.clearTimeout(u))), !this.started)
467
+ throw y;
473
468
  }
474
469
  for (const h of i.invokes)
475
470
  if (this._startInvoke(i, h, e, r, s), !this.started)
476
- throw S;
471
+ throw y;
477
472
  } catch (h) {
478
473
  n.get(t) === s && n.delete(t), n.size === 0 && this._stateCleanups === n && (this._stateCleanups = void 0);
479
- const u = z(s);
480
- g(
481
- h === S ? u : [h, ...u],
474
+ const c = x(s);
475
+ l(
476
+ h === y ? c : [h, ...c],
482
477
  `[Raph machine] State "${i.path}" activation failed.`
483
478
  );
484
479
  }
485
480
  }
486
481
  _startInvoke(t, e, r, i, s) {
487
- var C, x, T, M, q, I;
488
- const n = this._invocations ?? (this._invocations = /* @__PURE__ */ new Map());
482
+ const n = this._invocations ??= /* @__PURE__ */ new Map();
489
483
  if (n.has(e.id))
490
484
  throw new Error(`[Raph machine] Invoke id "${e.id}" is already active.`);
491
- const a = new AbortController(), c = {}, h = { controller: a, invoke: e, token: c };
492
- n.set(e.id, h);
485
+ const h = new AbortController(), c = {}, a = { controller: h, invoke: e, token: c };
486
+ n.set(e.id, a);
493
487
  const u = () => {
494
- var v;
495
- a.abort();
496
- const l = n.get(e.id);
497
- (l == null ? void 0 : l.token) === c && n.delete(e.id), n.size === 0 && this._invocations === n && (this._invocations = void 0);
488
+ h.abort(), n.get(e.id)?.token === c && n.delete(e.id), n.size === 0 && this._invocations === n && (this._invocations = void 0);
498
489
  const p = this._actors;
499
- p == null || p.delete(e.id), (p == null ? void 0 : p.size) === 0 && this._actors === p && (this._actors = void 0), (v = h.actor) == null || v.stop();
490
+ p?.delete(e.id), p?.size === 0 && this._actors === p && (this._actors = void 0), a.actor?.stop();
500
491
  };
501
- s.push(R(u));
502
- const _ = typeof e.input == "function" ? e.input({ context: i.context, event: r, input: this._input }) : e.input;
492
+ s.push(b(u));
493
+ const d = typeof e.input == "function" ? e.input({ context: i.context, event: r, input: this._input }) : e.input;
503
494
  if (!this.started)
504
495
  return;
505
496
  if (e.type === "machine") {
506
- const l = typeof e.src == "string" ? (C = this._bindings.actors) == null ? void 0 : C[e.src] : e.src;
507
- if (l === void 0)
497
+ const f = typeof e.src == "string" ? this._bindings.actors?.[e.src] : e.src;
498
+ if (f === void 0)
508
499
  throw new Error(`[Raph machine] Actor source "${String(e.src)}" is not defined.`);
509
- const p = new E(
500
+ const p = new S(
510
501
  this._owner,
511
- l,
502
+ f,
512
503
  {},
513
504
  {
514
505
  errorPolicy: e.onError.length === 0 ? "throw" : "ignore",
515
506
  id: `${this.id}/${e.id}`,
516
- input: _,
517
- onError: e.onError.length === 0 ? void 0 : ($) => {
518
- var w, b;
519
- !this.started || ((b = (w = this._invocations) == null ? void 0 : w.get(e.id)) == null ? void 0 : b.token) !== c || this._enqueue(
520
- Object.freeze({ error: $, type: `@@error.actor:${e.id}` }),
507
+ input: d,
508
+ onError: e.onError.length === 0 ? void 0 : (w) => {
509
+ !this.started || this._invocations?.get(e.id)?.token !== c || this._enqueue(
510
+ Object.freeze({ error: w, type: `@@error.actor:${e.id}` }),
521
511
  e.onError
522
512
  );
523
513
  },
524
514
  parentId: this.id
525
515
  }
526
516
  );
527
- if (!this.started || ((T = (x = this._invocations) == null ? void 0 : x.get(e.id)) == null ? void 0 : T.token) !== c || a.signal.aborted) {
517
+ if (!this.started || this._invocations?.get(e.id)?.token !== c || h.signal.aborted) {
528
518
  p.stop();
529
519
  return;
530
520
  }
531
- h.actor = p, (this._actors ?? (this._actors = /* @__PURE__ */ new Map())).set(e.id, p);
532
- const v = p.subscribe(($) => {
533
- var w, b;
534
- $.status === "done" && ((b = (w = this._invocations) == null ? void 0 : w.get(e.id)) == null ? void 0 : b.token) === c && this._enqueue(
535
- Object.freeze({ output: $.output, type: `@@done.actor:${e.id}` }),
521
+ a.actor = p, (this._actors ??= /* @__PURE__ */ new Map()).set(e.id, p);
522
+ const q = p.subscribe((w) => {
523
+ w.status === "done" && this._invocations?.get(e.id)?.token === c && this._enqueue(
524
+ Object.freeze({ output: w.output, type: `@@done.actor:${e.id}` }),
536
525
  e.onDone
537
526
  );
538
527
  });
539
- if (s.push(R(v)), p.start(), !this.started)
528
+ if (s.push(b(q)), p.start(), !this.started)
540
529
  return;
541
- const j = p.snapshot.peek();
542
- j.status === "done" && ((q = (M = this._invocations) == null ? void 0 : M.get(e.id)) == null ? void 0 : q.token) === c && this._enqueue(
543
- Object.freeze({ output: j.output, type: `@@done.actor:${e.id}` }),
530
+ const $ = p.snapshot.peek();
531
+ $.status === "done" && this._invocations?.get(e.id)?.token === c && this._enqueue(
532
+ Object.freeze({ output: $.output, type: `@@done.actor:${e.id}` }),
544
533
  e.onDone
545
534
  );
546
535
  return;
547
536
  }
548
537
  if (typeof e.src != "string")
549
538
  throw new TypeError(`[Raph machine] Task invoke "${e.id}" requires a string source.`);
550
- const f = (I = this._bindings.tasks) == null ? void 0 : I[e.src];
551
- if (f === void 0)
539
+ const g = this._bindings.tasks?.[e.src];
540
+ if (g === void 0)
552
541
  throw new Error(`[Raph machine] Task binding "${e.src}" is not defined.`);
553
- let d;
542
+ let m;
554
543
  try {
555
- d = this._runtime.untracked(() => f({
544
+ m = this._runtime.untracked(() => g({
556
545
  context: i.context,
557
546
  event: r,
558
547
  input: this._input,
559
- send: (l) => {
560
- var v;
561
- const p = (v = this._invocations) == null ? void 0 : v.get(e.id);
562
- !this.started || (p == null ? void 0 : p.token) !== c || a.signal.aborted || this.send(l);
548
+ send: (f) => {
549
+ const p = this._invocations?.get(e.id);
550
+ !this.started || p?.token !== c || h.signal.aborted || this.send(f);
563
551
  },
564
- signal: a.signal
552
+ signal: h.signal
565
553
  }));
566
- } catch (l) {
567
- this._completeInvoke(e, c, !1, l);
554
+ } catch (f) {
555
+ this._completeInvoke(e, c, !1, f);
568
556
  return;
569
557
  }
570
- this.started && Promise.resolve(d).then(
571
- (l) => this._completeInvoke(e, c, !0, l),
572
- (l) => this._completeInvoke(e, c, !1, l)
558
+ this.started && Promise.resolve(m).then(
559
+ (f) => this._completeInvoke(e, c, !0, f),
560
+ (f) => this._completeInvoke(e, c, !1, f)
573
561
  );
574
562
  }
575
563
  _completeInvoke(t, e, r, i) {
576
- var n;
577
- const s = (n = this._invocations) == null ? void 0 : n.get(t.id);
578
- !this.started || (s == null ? void 0 : s.token) !== e || s.controller.signal.aborted || this._enqueue(
564
+ const s = this._invocations?.get(t.id);
565
+ !this.started || s?.token !== e || s.controller.signal.aborted || this._enqueue(
579
566
  Object.freeze(r ? { data: i, type: `@@done.invoke:${t.id}` } : { error: i, type: `@@error.invoke:${t.id}` }),
580
567
  r ? t.onDone : t.onError
581
568
  );
582
569
  }
583
570
  _resolveDelay(t, e, r) {
584
- var a;
585
- const i = Number(t), s = Number.isFinite(i) && t.trim() !== "" ? i : (a = this._bindings.delays) == null ? void 0 : a[t];
571
+ const i = Number(t), s = Number.isFinite(i) && t.trim() !== "" ? i : this._bindings.delays?.[t];
586
572
  if (s === void 0)
587
573
  throw new Error(`[Raph machine] Delay binding "${t}" is not defined.`);
588
574
  const n = typeof s == "function" ? s({ context: e.context, event: r, input: this._input }) : s;
@@ -604,12 +590,12 @@ class E {
604
590
  snapshot: e
605
591
  })));
606
592
  } catch (n) {
607
- (i ?? (i = [])).push(n);
593
+ (i ??= []).push(n);
608
594
  }
609
595
  if (!this.started)
610
596
  break;
611
597
  }
612
- i !== void 0 && g(i, `[Raph machine] Machine "${this.id}" output work failed.`);
598
+ i !== void 0 && l(i, `[Raph machine] Machine "${this.id}" output work failed.`);
613
599
  }
614
600
  _notifyListeners(t, e) {
615
601
  let r;
@@ -617,7 +603,7 @@ class E {
617
603
  try {
618
604
  t[i].listener(e);
619
605
  } catch (s) {
620
- (r ?? (r = [])).push(s);
606
+ (r ??= []).push(s);
621
607
  }
622
608
  return r;
623
609
  }
@@ -632,34 +618,33 @@ class E {
632
618
  let s;
633
619
  for (const n of t) {
634
620
  try {
635
- const a = this._resolveOutput(n);
636
- this._runtime._runWithTraceCause(i, () => this._runtime.untracked(() => a({
621
+ const h = this._resolveOutput(n);
622
+ this._runtime._runWithTraceCause(i, () => this._runtime.untracked(() => h({
637
623
  context: r.context,
638
624
  event: e,
639
625
  input: this._input,
640
626
  snapshot: r
641
627
  })));
642
- } catch (a) {
643
- (s ?? (s = [])).push(a);
628
+ } catch (h) {
629
+ (s ??= []).push(h);
644
630
  }
645
631
  if (!this.started)
646
632
  break;
647
633
  }
648
- s !== void 0 && g(s, `[Raph machine] Machine "${this.id}" output work failed.`);
634
+ s !== void 0 && l(s, `[Raph machine] Machine "${this.id}" output work failed.`);
649
635
  }
650
636
  _resolveOutput(t) {
651
- var r;
652
637
  if (typeof t == "function")
653
638
  return t;
654
- const e = (r = this._bindings.outputs) == null ? void 0 : r[t];
639
+ const e = this._bindings.outputs?.[t];
655
640
  if (e === void 0)
656
641
  throw new Error(`[Raph machine] Output binding "${t}" is not defined.`);
657
642
  return e;
658
643
  }
659
644
  _cleanupState(t) {
660
- const e = this._stateCleanups, r = e == null ? void 0 : e.get(t);
661
- e === void 0 || r === void 0 || (e.delete(t), e.size === 0 && this._stateCleanups === e && (this._stateCleanups = void 0), g(
662
- z(r),
645
+ const e = this._stateCleanups, r = e?.get(t);
646
+ e === void 0 || r === void 0 || (e.delete(t), e.size === 0 && this._stateCleanups === e && (this._stateCleanups = void 0), l(
647
+ x(r),
663
648
  `[Raph machine] State "${this._compiled.states[t].path}" cleanup failed.`
664
649
  ));
665
650
  }
@@ -673,7 +658,7 @@ class E {
673
658
  } catch (i) {
674
659
  e.push(i);
675
660
  }
676
- g(e, `[Raph machine] Machine "${this.id}" final cleanup failed.`);
661
+ l(e, `[Raph machine] Machine "${this.id}" final cleanup failed.`);
677
662
  }
678
663
  _dispose(t) {
679
664
  if (this._stopped)
@@ -683,30 +668,30 @@ class E {
683
668
  try {
684
669
  this._stopStateResources();
685
670
  } catch (r) {
686
- (e ?? (e = [])).push(r);
671
+ (e ??= []).push(r);
687
672
  }
688
673
  this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0, this._listeners = void 0;
689
674
  try {
690
675
  this._releaseDebug();
691
676
  } catch (r) {
692
- (e ?? (e = [])).push(r);
677
+ (e ??= []).push(r);
693
678
  }
694
679
  if (t && !this._runtime.disposed) {
695
- const r = this._currentSnapshot, i = H(this.model, r);
680
+ const r = this._currentSnapshot, i = z(this.model, r);
696
681
  try {
697
682
  this._runtime._batchReactive(() => {
698
683
  this._writeSnapshotInBoundary(i), this._currentSnapshot = i;
699
684
  });
700
685
  } catch (s) {
701
- (e ?? (e = [])).push(s);
686
+ (e ??= []).push(s);
702
687
  }
703
688
  }
704
689
  try {
705
690
  this._releaseSnapshot();
706
691
  } catch (r) {
707
- (e ?? (e = [])).push(r);
692
+ (e ??= []).push(r);
708
693
  }
709
- g(e, `[Raph machine] Machine "${this.id}" stop failed.`);
694
+ l(e, `[Raph machine] Machine "${this.id}" stop failed.`);
710
695
  }
711
696
  _activeClosure(t) {
712
697
  const e = /* @__PURE__ */ new Set();
@@ -739,7 +724,7 @@ class E {
739
724
  _trace(t, e, r, i, s) {
740
725
  this._runtime._recordTrace({
741
726
  ...i === void 0 ? {} : { causeId: i },
742
- context: D(s.context) ? s.context : void 0,
727
+ context: T(s.context) ? s.context : void 0,
743
728
  details: { active: s.active, revision: s.revision },
744
729
  kind: "machine",
745
730
  name: `${this.id}:${t}`,
@@ -774,28 +759,28 @@ class E {
774
759
  throw t;
775
760
  }
776
761
  }
777
- function tt(o, t, e = {}, r = {}) {
778
- return new E(o, t, e, r);
762
+ function F(o, t, e = {}, r = {}) {
763
+ return new S(o, t, e, r);
779
764
  }
780
- function U(o, t, e) {
765
+ function J(o, t, e) {
781
766
  const r = o._getWorkGraph(), i = r.createProducer(t), s = o._getReactivity()._ownedSignal(e, r.producerHooks(i));
782
- let n = s.source, a = e;
767
+ let n = s.source, h = e;
783
768
  const c = Object.freeze({
784
- get: () => (o._assertSourceReadable(t), n === void 0 ? a : n.get()),
785
- peek: () => (t._assertAlive(), n === void 0 ? a : n.peek())
769
+ get: () => (o._assertSourceReadable(t), n === void 0 ? h : n.get()),
770
+ peek: () => (t._assertAlive(), n === void 0 ? h : n.peek())
786
771
  });
787
772
  return r.attachProducer(i, c), {
788
773
  dispose: () => {
789
- const h = n;
790
- h !== void 0 && (a = h.peek(), n = void 0, s.dispose());
774
+ const a = n;
775
+ a !== void 0 && (h = a.peek(), n = void 0, s.dispose());
791
776
  },
792
777
  source: c,
793
- writeInBoundary: (h) => {
794
- t._assertAlive(), n.set(h), a = h;
778
+ writeInBoundary: (a) => {
779
+ t._assertAlive(), n.set(a), h = a;
795
780
  }
796
781
  };
797
782
  }
798
- function z(o) {
783
+ function x(o) {
799
784
  const t = [];
800
785
  for (let e = o.length - 1; e >= 0; e--)
801
786
  try {
@@ -805,33 +790,33 @@ function z(o) {
805
790
  }
806
791
  return t;
807
792
  }
808
- function g(o, t) {
809
- if ((o == null ? void 0 : o.length) === 1)
793
+ function l(o, t) {
794
+ if (o?.length === 1)
810
795
  throw o[0];
811
796
  if (o !== void 0 && o.length > 1)
812
797
  throw new AggregateError(o, t);
813
798
  }
814
- function X(o) {
799
+ function Q(o) {
815
800
  if (typeof o != "object" || o === null || typeof o.type != "string" || !o.type)
816
801
  throw new TypeError("[Raph machine] Event must contain a non-empty string type.");
817
802
  }
818
- function D(o) {
803
+ function T(o) {
819
804
  return typeof o == "object" && o !== null && !Array.isArray(o);
820
805
  }
821
- function O() {
806
+ function R() {
822
807
  }
823
- function R(o) {
808
+ function b(o) {
824
809
  let t = !0;
825
810
  return () => {
826
811
  t && (t = !1, o());
827
812
  };
828
813
  }
829
814
  export {
830
- m as MachinePersistenceError,
831
- tt as createMachine,
832
- rt as defineMachine,
833
- st as getInitialSnapshot,
834
- V as persistMachineSnapshot,
835
- G as restoreMachineSnapshot,
836
- nt as transition
815
+ _ as MachinePersistenceError,
816
+ F as createMachine,
817
+ K as defineMachine,
818
+ U as getInitialSnapshot,
819
+ N as persistMachineSnapshot,
820
+ B as restoreMachineSnapshot,
821
+ X as transition
837
822
  };