@voltro/client 0.56.0 → 0.57.0

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,31 +1,31 @@
1
- import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, x as ee, y as te } from "./formData-DtlF8t8h.js";
2
- import { createContext as S, createElement as C, useCallback as w, useContext as T, useDebugValue as ne, useEffect as E, useMemo as D, useRef as O, useState as k, useSyncExternalStore as re } from "react";
3
- import { Cause as A, Context as ie, Duration as j, Effect as M, Exit as N, Fiber as P, Layer as F, ManagedRuntime as ae, Schedule as I, Schema as oe, Stream as L } from "effect";
4
- import * as se from "@effect/platform/Headers";
5
- import { RpcClient as R, RpcSerialization as ce } from "@effect/rpc";
6
- import { applyRowPatch as z, fieldIssuesOf as le, pluginTag as ue } from "@voltro/protocol";
7
- import * as de from "@effect/platform/Socket";
8
- import { jsx as fe } from "react/jsx-runtime";
9
- import { FormApi as pe } from "@tanstack/form-core";
10
- import { useStore as me } from "@tanstack/react-store";
11
- import { ArrayFormatter as he } from "effect/ParseResult";
1
+ import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, x as S, y as ee } from "./formData-He_L4ozH.js";
2
+ import { createContext as C, createElement as w, useCallback as T, useContext as te, useDebugValue as ne, useEffect as E, useMemo as D, useRef as O, useState as k, useSyncExternalStore as A } from "react";
3
+ import { Cause as j, Context as re, Duration as ie, Effect as M, Exit as N, Fiber as P, Layer as F, ManagedRuntime as I, Schedule as L, Schema as ae, Stream as R } from "effect";
4
+ import * as oe from "@effect/platform/Headers";
5
+ import { RpcClient as z, RpcSerialization as se } from "@effect/rpc";
6
+ import { applyRowPatch as ce, fieldIssuesOf as le, pluginTag as ue } from "@voltro/protocol";
7
+ import * as B from "@effect/platform/Socket";
8
+ import { jsx as de } from "react/jsx-runtime";
9
+ import { FormApi as fe } from "@tanstack/form-core";
10
+ import { useStore as pe } from "@tanstack/react-store";
11
+ import { ArrayFormatter as me } from "effect/ParseResult";
12
12
  //#region src/traceBus.ts
13
- var ge = /* @__PURE__ */ new Set(), _e = (e) => {
14
- for (let t of ge) try {
13
+ var V = /* @__PURE__ */ new Set(), he = (e) => {
14
+ for (let t of V) try {
15
15
  t(e);
16
16
  } catch {}
17
- }, ve = (e) => (ge.add(e), () => {
18
- ge.delete(e);
19
- }), B = (e) => {
17
+ }, ge = (e) => (V.add(e), () => {
18
+ V.delete(e);
19
+ }), H = (e) => {
20
20
  let t = (e) => e == null ? "null" : typeof e == "string" ? JSON.stringify(e) : typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? `[${e.map(t).join(",")}]` : typeof e == "object" ? `{${Object.keys(e).sort().map((n) => `${JSON.stringify(n)}:${t(e[n])}`).join(",")}}` : String(e);
21
21
  return t(e);
22
- }, ye = Object.freeze({
22
+ }, _e = Object.freeze({
23
23
  data: void 0,
24
24
  revision: -1,
25
25
  emittedAt: void 0,
26
26
  error: void 0,
27
27
  pendingPatches: 0
28
- }), be = 5e3, xe = (e, t, n) => {
28
+ }), ve = 5e3, ye = (e, t, n) => {
29
29
  if (e._tag === "error") return !1;
30
30
  if (e._tag === "delta") return !0;
31
31
  try {
@@ -33,21 +33,21 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
33
33
  } catch {
34
34
  return !1;
35
35
  }
36
- }, V = 0, Se = () => `patch_${++V}`, H = (e, t) => {
36
+ }, be = 0, xe = () => `patch_${++be}`, U = (e, t) => {
37
37
  let n = e;
38
38
  for (let e of t.split(".")) {
39
39
  if (typeof n != "object" || !n) return;
40
40
  n = n[e];
41
41
  }
42
42
  return n;
43
- }, U = (e, t, n) => {
43
+ }, Se = (e, t, n) => {
44
44
  let r = t.split("."), i = (e) => typeof e == "object" && e && !Array.isArray(e) ? { ...e } : {}, a = i(e), o = a;
45
45
  for (let e = 0; e < r.length - 1; e += 1) o[r[e]] = i(o[r[e]]), o = o[r[e]];
46
46
  return o[r[r.length - 1]] = n, a;
47
- }, W = (e, t) => {
47
+ }, Ce = (e, t) => {
48
48
  let n = e.by ?? "id", r = e.identify ? e.identify(t) : typeof t[n] == "string" ? t[n] : typeof t.id == "string" ? t.id : void 0, i = r === void 0 ? [] : Array.isArray(r) ? r : [r];
49
49
  return i.length === 0 ? null : new Set(i);
50
- }, Ce = (e, t, n) => {
50
+ }, we = (e, t, n) => {
51
51
  let r = e.path, i = e.by ?? "id";
52
52
  if (e.op === "insert") {
53
53
  let a = e.shapeItem ?? e.shape, o = a ? {
@@ -60,11 +60,11 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
60
60
  optimistic: !0
61
61
  }, s = e.order ?? "append";
62
62
  return (e) => {
63
- let t = Array.isArray(H(e, r)) ? H(e, r) : [];
64
- return U(e ?? {}, r, s === "append" ? [...t, o] : [o, ...t]);
63
+ let t = Array.isArray(U(e, r)) ? U(e, r) : [];
64
+ return Se(e ?? {}, r, s === "append" ? [...t, o] : [o, ...t]);
65
65
  };
66
66
  }
67
- let a = W(e, t);
67
+ let a = Ce(e, t);
68
68
  if (a === null) return null;
69
69
  if (e.op === "update") {
70
70
  let n = e.shapeItem ?? e.shape, o = n ? (e) => ({
@@ -78,24 +78,24 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
78
78
  optimistic: !0
79
79
  });
80
80
  return (e) => {
81
- let t = H(e, r);
81
+ let t = U(e, r);
82
82
  if (!Array.isArray(t)) {
83
83
  if (typeof t != "object" || !t) return e;
84
84
  let n = t;
85
- return a.has(n[i]) ? U(e, r, o(n)) : e;
85
+ return a.has(n[i]) ? Se(e, r, o(n)) : e;
86
86
  }
87
- return U(e, r, t.map((e) => a.has(e[i]) ? o(e) : e));
87
+ return Se(e, r, t.map((e) => a.has(e[i]) ? o(e) : e));
88
88
  };
89
89
  }
90
90
  return (e) => {
91
- let t = Array.isArray(H(e, r)) ? H(e, r) : [];
92
- return U(e, r, t.filter((e) => !a.has(e[i])));
91
+ let t = Array.isArray(U(e, r)) ? U(e, r) : [];
92
+ return Se(e, r, t.filter((e) => !a.has(e[i])));
93
93
  };
94
- }, we = (e, t, n) => {
94
+ }, Te = (e, t, n) => {
95
95
  if (e.op === "insert") return n;
96
96
  let r = t.id;
97
97
  return typeof r == "string" && r.length > 0 ? r : null;
98
- }, Te = (e, t, n, r) => {
98
+ }, Ee = (e, t, n, r) => {
99
99
  let { anchorColumn: i, targetColumn: a } = e, o = new Set(n.map((e) => String(e)));
100
100
  return (e) => {
101
101
  if (!Array.isArray(e)) return e;
@@ -126,8 +126,8 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
126
126
  }));
127
127
  return c ? n : e;
128
128
  };
129
- }, Ee = (e, t, n) => {
130
- if (e.path !== void 0) return Ce(e, t, n);
129
+ }, De = (e, t, n) => {
130
+ if (e.path !== void 0) return we(e, t, n);
131
131
  switch (e.op) {
132
132
  case "insert": {
133
133
  let r = e.shape ? {
@@ -145,7 +145,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
145
145
  };
146
146
  }
147
147
  case "update": {
148
- let n = W(e, t);
148
+ let n = Ce(e, t);
149
149
  if (n === null) return null;
150
150
  let r = e.shape, i = r ? (e) => ({
151
151
  ...r(t, e),
@@ -168,7 +168,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
168
168
  };
169
169
  }
170
170
  case "delete": {
171
- let n = W(e, t);
171
+ let n = Ce(e, t);
172
172
  return n === null ? null : (e) => {
173
173
  if (!Array.isArray(e)) {
174
174
  let t = e;
@@ -178,7 +178,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
178
178
  };
179
179
  }
180
180
  }
181
- }, De = 5e3, Oe = class {
181
+ }, Oe = 5e3, ke = class {
182
182
  entries = /* @__PURE__ */ new Map();
183
183
  inactiveTtlMs;
184
184
  onChangeHook;
@@ -186,20 +186,20 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
186
186
  mirror;
187
187
  mergeCell;
188
188
  constructor(e = {}) {
189
- this.inactiveTtlMs = e.inactiveTtlMs ?? De, this.onChangeHook = e.onChange, this.errorBus = e.errorBus, this.mirror = e.mirror, this.mergeCell = e.mergeCell;
189
+ this.inactiveTtlMs = e.inactiveTtlMs ?? Oe, this.onChangeHook = e.onChange, this.errorBus = e.errorBus, this.mirror = e.mirror, this.mergeCell = e.mergeCell;
190
190
  }
191
191
  subscribe(e, t, n, r, i = {}) {
192
- let a = B(e), o = typeof e[0] == "string" ? e[0] : void 0, s = this.entries.get(a);
192
+ let a = H(e), o = typeof e[0] == "string" ? e[0] : void 0, s = this.entries.get(a);
193
193
  return s && s.evictionTimer !== null && (clearTimeout(s.evictionTimer), s.evictionTimer = null), s ? (s.fiber === null && (s.fetch = t, s.runtime = n, this.startFiber(s, t, n)), s.source === void 0 && i.source !== void 0 && (s.source = i.source)) : s = this.create(a, o, t, n, i.source), s.subscribers.add(r), {
194
194
  getSnapshot: () => this.getSnapshot(a),
195
195
  unsubscribe: () => this.unsubscribe(a, r)
196
196
  };
197
197
  }
198
198
  update(e, t, n) {
199
- let r = B(e), i = typeof e[0] == "string" ? e[0] : void 0, a = this.entries.get(r);
199
+ let r = H(e), i = typeof e[0] == "string" ? e[0] : void 0, a = this.entries.get(r);
200
200
  a ||= this.createStub(r, i);
201
201
  let o = {
202
- id: Se(),
202
+ id: xe(),
203
203
  mutationId: n,
204
204
  reducer: t
205
205
  };
@@ -213,7 +213,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
213
213
  for (let i of this.entries.values()) {
214
214
  if (i.tag !== e) continue;
215
215
  let a = {
216
- id: `forTag-${++V}`,
216
+ id: `forTag-${++be}`,
217
217
  mutationId: n,
218
218
  reducer: t
219
219
  };
@@ -230,12 +230,12 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
230
230
  confirmByMutation(e) {
231
231
  let t = !1;
232
232
  for (let n of this.entries.values()) for (let r of n.state.patches) r.mutationId === e && r.confirmed !== !0 && (r.confirmed = !0, t = !0);
233
- t && setTimeout(() => this.resyncUnechoedMutation(e), be);
233
+ t && setTimeout(() => this.resyncUnechoedMutation(e), ve);
234
234
  }
235
235
  resyncUnechoedMutation(e) {
236
236
  for (let t of this.entries.values()) {
237
237
  if (!t.state.patches.some((t) => t.mutationId === e && t.confirmed === !0)) continue;
238
- let n = t.tag ?? t.key, r = `optimistic patch for ${n} got no superseding server event within ${be}ms — the write is confirmed, so the preview is KEPT. Check reactivity for this query's source table.`;
238
+ let n = t.tag ?? t.key, r = `optimistic patch for ${n} got no superseding server event within ${ve}ms — the write is confirmed, so the preview is KEPT. Check reactivity for this query's source table.`;
239
239
  this.errorBus?.emit({
240
240
  source: "subscription",
241
241
  tag: n,
@@ -248,7 +248,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
248
248
  }
249
249
  }
250
250
  autoApply(e, t, n) {
251
- let r = `optimistic-${n}-${++V}`;
251
+ let r = `optimistic-${n}-${++be}`;
252
252
  for (let i of e) {
253
253
  for (let e of this.entries.values()) {
254
254
  if (!(Array.isArray(e.source) ? e.source.includes(i.table) : e.source === i.table)) continue;
@@ -262,7 +262,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
262
262
  if (!n) continue;
263
263
  }
264
264
  if (e.computed && i.op === "insert" && i.path === void 0) continue;
265
- let a = Ee(i, t, r);
265
+ let a = De(i, t, r);
266
266
  if (a === null) continue;
267
267
  let o = {
268
268
  id: `${r}-${e.key}`,
@@ -275,10 +275,10 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
275
275
  if (e !== void 0) for (let [a, o] of Object.entries(e)) {
276
276
  let e = t[a];
277
277
  if (!Array.isArray(e)) continue;
278
- let s = we(i, t, r);
278
+ let s = Te(i, t, r);
279
279
  if (s !== null) for (let t of this.entries.values()) {
280
280
  if (!(Array.isArray(t.source) ? t.source.includes(o.junction) : t.source === o.junction) || t.computed) continue;
281
- let i = Te(o, s, e.map((e) => String(e)), `${r}-${a}`);
281
+ let i = Ee(o, s, e.map((e) => String(e)), `${r}-${a}`);
282
282
  t.state.patches.push({
283
283
  id: `${r}-${a}-${t.key}`,
284
284
  mutationId: n,
@@ -295,10 +295,10 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
295
295
  n.state.patches = n.state.patches.filter((e) => e.id !== t), n.state.patches.length !== r && this.invalidate(n);
296
296
  }
297
297
  peek(e) {
298
- return this.getSnapshot(B(e));
298
+ return this.getSnapshot(H(e));
299
299
  }
300
300
  getEntry(e) {
301
- return this.entries.get(B(e));
301
+ return this.entries.get(H(e));
302
302
  }
303
303
  size() {
304
304
  return this.entries.size;
@@ -399,28 +399,31 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
399
399
  };
400
400
  }
401
401
  startFiber(e, t, n) {
402
- let r = e.tag ?? e.key, i = t(), a = L.unwrapScoped(M.currentSpan.pipe(M.catchAll(() => M.succeed(void 0)), M.map((t) => (t && (e.traceId = t.traceId, _e({
402
+ let r = e.tag ?? e.key, i = t(), a = R.unwrapScoped(M.currentSpan.pipe(M.catchAll(() => M.succeed(void 0)), M.map((t) => (t && (e.traceId = t.traceId, he({
403
403
  traceId: t.traceId,
404
404
  spanId: t.spanId,
405
405
  source: "subscription",
406
406
  tag: r
407
- })), i)))).pipe(L.withSpan(`client.subscription.${r}`, { attributes: { "rpc.tag": r } })), o = e.state.baseRevision >= 0 ? e.state.baseRevision : void 0, s = a.pipe(L.runForEach((t) => M.sync(() => {
407
+ })), i)))).pipe(R.withSpan(`client.subscription.${r}`, { attributes: { "rpc.tag": r } })), o = e.state.baseRevision >= 0 ? e.state.baseRevision : void 0, s = a.pipe(R.runForEach((t) => M.sync(() => {
408
408
  let n = e.state.base;
409
- if (t._tag === "snapshot") e.state.base = t.data, e.state.baseRevision = t.revision, e.state.baseEmittedAt = void 0, e.state.baseError = void 0, t.computed === !0 && (e.computed = !0);
410
- else if (t._tag === "error") e.state.baseError = A.fail(t.error), typeof t.revision == "number" && (e.state.baseRevision = t.revision);
409
+ if (t._tag === "snapshot") e.state.base = t.data, e.state.baseRevision = t.revision, e.state.baseEmittedAt = void 0, e.state.baseError = void 0, this.errorBus?.emitSuccess({
410
+ source: "subscription",
411
+ tag: e.tag ?? e.key
412
+ }), t.computed === !0 && (e.computed = !0);
413
+ else if (t._tag === "error") e.state.baseError = j.fail(t.error), typeof t.revision == "number" && (e.state.baseRevision = t.revision);
411
414
  else {
412
415
  let n = e.state.base;
413
- Array.isArray(n) && (e.state.base = z(n, t.patch, this.mergeCell === void 0 ? {} : { mergeCell: this.mergeCell })), e.state.baseRevision = t.revision, e.state.baseEmittedAt = t.emittedAt, e.state.baseError = void 0;
416
+ Array.isArray(n) && (e.state.base = ce(n, t.patch, this.mergeCell === void 0 ? {} : { mergeCell: this.mergeCell })), e.state.baseRevision = t.revision, e.state.baseEmittedAt = t.emittedAt, e.state.baseError = void 0;
414
417
  }
415
- e.state.patches.some((e) => e.confirmed === !0) && xe(t, n, e.state.base) && (e.state.patches = e.state.patches.filter((e) => e.confirmed !== !0)), this.mirror !== void 0 && t._tag !== "error" && this.mirror.save(e.key, {
418
+ e.state.patches.some((e) => e.confirmed === !0) && ye(t, n, e.state.base) && (e.state.patches = e.state.patches.filter((e) => e.confirmed !== !0)), this.mirror !== void 0 && t._tag !== "error" && this.mirror.save(e.key, {
416
419
  tag: e.tag,
417
420
  data: e.state.base,
418
421
  revision: e.state.baseRevision
419
422
  }).catch(() => {}), this.invalidate(e);
420
423
  })));
421
- e.fiber = n.runFork(o === void 0 ? s : s.pipe(M.locallyWith(R.currentHeaders, (e) => se.set(e, "voltro-resume-from", String(o))))), e.fiber.addObserver((t) => {
424
+ e.fiber = n.runFork(o === void 0 ? s : s.pipe(M.locallyWith(z.currentHeaders, (e) => oe.set(e, "voltro-resume-from", String(o))))), e.fiber.addObserver((t) => {
422
425
  if (N.isFailure(t) && !N.isInterrupted(t) && (e.state.baseRevision === -1 && (e.state.baseError = t.cause, this.invalidate(e)), this.errorBus)) {
423
- let n = A.squash(t.cause);
426
+ let n = j.squash(t.cause);
424
427
  this.errorBus.emit({
425
428
  source: "subscription",
426
429
  tag: e.tag ?? e.key,
@@ -437,7 +440,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
437
440
  }
438
441
  getSnapshot(e) {
439
442
  let t = this.entries.get(e);
440
- if (!t) return ye;
443
+ if (!t) return _e;
441
444
  if (t.state.cachedSnapshot !== null) return t.state.cachedSnapshot;
442
445
  let n = t.state.base;
443
446
  if (n !== void 0 && t.state.patches.length > 0) for (let e of t.state.patches) n = e.reducer(n);
@@ -460,15 +463,16 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
460
463
  t && t.subscribers.size === 0 && (t.fiber && M.runFork(P.interrupt(t.fiber)), this.entries.delete(e.key));
461
464
  }, this.inactiveTtlMs);
462
465
  }
463
- }, ke = class extends Oe {
466
+ }, Ae = class extends ke {
464
467
  subscribe(e, t, n, r, i = {}) {
465
468
  return {
466
469
  getSnapshot: () => this.peek(e),
467
470
  unsubscribe: () => {}
468
471
  };
469
472
  }
470
- }, Ae = class {
473
+ }, je = class {
471
474
  #e = /* @__PURE__ */ new Set();
475
+ #t = /* @__PURE__ */ new Set();
472
476
  on(e) {
473
477
  return this.#e.add(e), () => {
474
478
  this.#e.delete(e);
@@ -479,60 +483,70 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
479
483
  t(e);
480
484
  } catch {}
481
485
  }
482
- }, je = S(null), Me = () => {
486
+ onSuccess(e) {
487
+ return this.#t.add(e), () => {
488
+ this.#t.delete(e);
489
+ };
490
+ }
491
+ emitSuccess(e) {
492
+ for (let t of this.#t) try {
493
+ t(e);
494
+ } catch {}
495
+ }
496
+ }, Me = C(null), Ne = () => {
483
497
  throw Error("Voltro: rpc / cache calls are not invokable on a not-yet-resolved api — either during SSR, or in the client boot window before the api client resolves");
484
- }, Ne = new Proxy(() => Me(), {
485
- get: (e, t) => Ne,
498
+ }, Pe = new Proxy(() => Ne(), {
499
+ get: (e, t) => Pe,
486
500
  has: () => !0,
487
- apply: () => Me()
488
- }), Pe = Symbol.for("@voltro/client/ssrDescriptors"), Fe = globalThis, Ie = Fe[Pe] ?? (Fe[Pe] = { byApi: /* @__PURE__ */ new Map() }), Le = (e, t) => {
489
- Ie.byApi.set(e, t);
490
- }, Re = (e) => Ie.byApi.get(e), ze = () => {
491
- Ie.byApi.clear();
492
- }, Be = {
501
+ apply: () => Ne()
502
+ }), Fe = Symbol.for("@voltro/client/ssrDescriptors"), Ie = globalThis, Le = Ie[Fe] ?? (Ie[Fe] = { byApi: /* @__PURE__ */ new Map() }), Re = (e, t) => {
503
+ Le.byApi.set(e, t);
504
+ }, ze = (e) => Le.byApi.get(e), Be = () => {
505
+ Le.byApi.clear();
506
+ }, Ve = {
493
507
  runtime: { runPromiseExit: () => Promise.resolve(N.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
494
- cache: new ke(),
495
- client: Ne,
508
+ cache: new Ae(),
509
+ client: Pe,
496
510
  descriptors: {},
497
511
  inspectBaseUrl: "",
498
- errorBus: new Ae()
499
- }, Ve = {
512
+ errorBus: new je()
513
+ }, He = {
500
514
  get: (e) => {
501
- let t = Re(e);
502
- return t === void 0 ? Be : {
503
- ...Be,
515
+ let t = ze(e);
516
+ return t === void 0 ? Ve : {
517
+ ...Ve,
504
518
  descriptors: t
505
519
  };
506
520
  },
507
521
  names: []
508
- }, He = !1, Ue = !1, G = null, We = () => {
509
- He = !1, Ue = !1, G !== null && (clearTimeout(G), G = null);
510
- }, Ge = () => {
511
- let e = T(je);
512
- return e ? (Ue || (Ue = !0, G !== null && (clearTimeout(G), G = null)), e) : (typeof window < "u" && !He && !Ue && G === null && process.env.NODE_ENV !== "production" && (G = setTimeout(() => {
513
- G = null, !(He || Ue) && (He = !0, console.warn("useFrameworkRuntimes: no <FrameworkRuntimesProvider> in the tree — returning a loading baseline (subscriptions read `undefined`, mutations are no-ops). If this is not an intentional lazy/conditional mount, mount your app via @voltro/web mount() or wrap the subtree in <VoltroRuntimeProvider>."));
514
- }, 0)), Ve);
515
- }, K = (e) => {
516
- let t = Ge(), n = t.demand;
522
+ }, Ue = !1, We = !1, W = null, Ge = () => {
523
+ Ue = !1, We = !1, W !== null && (clearTimeout(W), W = null);
524
+ }, Ke = () => {
525
+ let e = te(Me);
526
+ return e ? (We || (We = !0, W !== null && (clearTimeout(W), W = null)), e) : (typeof window < "u" && !Ue && !We && W === null && process.env.NODE_ENV !== "production" && (W = setTimeout(() => {
527
+ W = null, !(Ue || We) && (Ue = !0, console.warn("useFrameworkRuntimes: no <FrameworkRuntimesProvider> in the tree — returning a loading baseline (subscriptions read `undefined`, mutations are no-ops). If this is not an intentional lazy/conditional mount, mount your app via @voltro/web mount() or wrap the subtree in <VoltroRuntimeProvider>."));
528
+ }, 0)), He);
529
+ }, G = (e) => {
530
+ let t = Ke(), n = t.demand;
517
531
  return E(() => {
518
532
  n?.(e);
519
533
  }, [n, e]), t.get(e);
520
- }, Ke = (e) => typeof e.runtime?.runFork != "function", qe = async (e) => {
534
+ }, qe = (e) => typeof e.runtime?.runFork != "function", Je = async (e) => {
521
535
  let { name: t, wsUrl: n, group: r, headers: i, webSocketConstructor: a } = e;
522
- class o extends ie.Tag(`@voltro/client/AppClient/${t}`)() {}
523
- let s = F.succeed(de.WebSocketConstructor, (e, t) => a(e, t)), c = R.layerProtocolSocket().pipe(F.provide(ce.layerJson), F.provide(de.layerWebSocket(n)), F.provide(s)), l = typeof i == "function" ? await i() : i, u = F.scoped(o, R.make(r)).pipe(F.provide(c)), d = l ? F.locallyScoped(R.currentHeaders, se.fromInput(l)) : F.empty, f = ae.make(F.merge(u, d));
536
+ class o extends re.Tag(`@voltro/client/AppClient/${t}`)() {}
537
+ let s = F.succeed(B.WebSocketConstructor, (e, t) => a(e, t)), c = z.layerProtocolSocket().pipe(F.provide(se.layerJson), F.provide(B.layerWebSocket(n)), F.provide(s)), l = typeof i == "function" ? await i() : i, u = F.scoped(o, z.make(r)).pipe(F.provide(c)), d = l ? F.locallyScoped(z.currentHeaders, oe.fromInput(l)) : F.empty, f = I.make(F.merge(u, d));
524
538
  try {
525
- let e = await f.runPromise(o), t = new Ae();
539
+ let e = await f.runPromise(o), t = new je();
526
540
  return {
527
541
  runtime: f,
528
542
  client: e,
529
- cache: new Oe({ errorBus: t }),
543
+ cache: new ke({ errorBus: t }),
530
544
  errorBus: t
531
545
  };
532
546
  } catch (e) {
533
547
  throw f.dispose(), e;
534
548
  }
535
- }, Je = (e) => Math.min(500 * 2 ** Math.min(e - 1, 4), 5e3), Ye = () => ({
549
+ }, Ye = (e) => Math.min(500 * 2 ** Math.min(e - 1, 4), 5e3), Xe = () => ({
536
550
  resolved: null,
537
551
  retryToken: 0,
538
552
  failureCount: 0,
@@ -541,15 +555,15 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
541
555
  everOpened: !1,
542
556
  wedgeStop: null,
543
557
  subjectMayHaveChanged: !1
544
- }), Xe = (e) => {
558
+ }), Ze = (e) => {
545
559
  e.wedgeStop !== null && (e.wedgeStop(), e.wedgeStop = null);
546
- }, Ze = (e) => {
547
- e.cache.destroy(e.runtime), e.runtime.dispose();
548
560
  }, Qe = (e) => {
549
- let t = e.apis, n = e.buildClient, r = e.onChange, i = e.retryDelayMs ?? Je, a = e.stableWindowMs ?? 5e3, o = e.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), s = e.scheduler?.clearTimeout ?? ((e) => {
561
+ e.cache.destroy(e.runtime), e.runtime.dispose();
562
+ }, $e = (e) => {
563
+ let t = e.apis, n = e.buildClient, r = e.onChange, i = e.retryDelayMs ?? Ye, a = e.stableWindowMs ?? 5e3, o = e.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), s = e.scheduler?.clearTimeout ?? ((e) => {
550
564
  clearTimeout(e);
551
565
  }), c = e.scheduler?.queueMicrotask ?? queueMicrotask, l = e.onReconnecting, u = e.wedgeBackstop, d = /* @__PURE__ */ new Map();
552
- for (let e of t) d.set(e.name, Ye());
566
+ for (let e of t) d.set(e.name, Xe());
553
567
  let f = !1, p = /* @__PURE__ */ new Set(), m = (e, t) => {
554
568
  let n = o(() => {
555
569
  p.delete(n), e();
@@ -575,7 +589,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
575
589
  if (!t) return;
576
590
  let r = t.generation, i = () => {
577
591
  if (f || t.generation !== r) return;
578
- t.everOpened = !0, Xe(t), t.retryToken++;
592
+ t.everOpened = !0, Ze(t), t.retryToken++;
579
593
  let e = t.failureCount;
580
594
  m(() => {
581
595
  f || t.failureCount === e && (t.failureCount = 0);
@@ -586,11 +600,11 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
586
600
  try {
587
601
  let a = await n(e, r, i, o);
588
602
  if (f || t.generation !== r) {
589
- Ze(a);
603
+ Qe(a);
590
604
  return;
591
605
  }
592
606
  let s = t.resolved;
593
- s && !t.subjectMayHaveChanged && a.cache.seedStaleFrom(s.cache), t.subjectMayHaveChanged = !1, t.resolved = a, t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), h(), s && Ze(s);
607
+ s && !t.subjectMayHaveChanged && a.cache.seedStaleFrom(s.cache), t.subjectMayHaveChanged = !1, t.resolved = a, t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), h(), s && Qe(s);
594
608
  } catch {
595
609
  if (f || t.generation !== r) return;
596
610
  g(e);
@@ -598,7 +612,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
598
612
  }, v = (e) => {
599
613
  if (!f) for (let n of t) {
600
614
  let t = d.get(n.name);
601
- t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, t.failureCount = 0, Xe(t), _(n));
615
+ t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, t.failureCount = 0, Ze(t), _(n));
602
616
  }
603
617
  };
604
618
  return t.length === 0 ? (r(/* @__PURE__ */ new Map(), !0), {
@@ -615,7 +629,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
615
629
  f = !0;
616
630
  for (let e of p) s(e);
617
631
  p.clear();
618
- for (let [, e] of d) e.resolved && Ze(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), Xe(e);
632
+ for (let [, e] of d) e.resolved && Qe(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), Ze(e);
619
633
  d.clear();
620
634
  }
621
635
  },
@@ -626,7 +640,7 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
626
640
  v(!1);
627
641
  }
628
642
  });
629
- }, $e = ({ apis: e, children: t, demand: n }) => {
643
+ }, et = ({ apis: e, children: t, demand: n }) => {
630
644
  let r = D(() => ({
631
645
  get: (t) => {
632
646
  let n = e.get(t);
@@ -639,45 +653,45 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
639
653
  names: Array.from(e.keys()),
640
654
  ...n === void 0 ? {} : { demand: n }
641
655
  }), [e]);
642
- return /* @__PURE__ */ fe(je.Provider, {
656
+ return /* @__PURE__ */ de(Me.Provider, {
643
657
  value: r,
644
658
  children: t
645
659
  });
646
- }, et = Symbol.for("@voltro/client/storeStorageProvider"), tt = () => {
647
- let e = globalThis, t = e[et];
660
+ }, tt = Symbol.for("@voltro/client/storeStorageProvider"), nt = () => {
661
+ let e = globalThis, t = e[tt];
648
662
  if (t !== void 0) return t;
649
663
  let n = {
650
664
  provider: void 0,
651
665
  used: !1
652
666
  };
653
- return e[et] = n, n;
654
- }, nt = (e) => {
667
+ return e[tt] = n, n;
668
+ }, rt = (e) => {
655
669
  if (typeof window > "u") return null;
656
670
  try {
657
671
  return (e === "session" ? window.sessionStorage : window.localStorage) ?? null;
658
672
  } catch {
659
673
  return null;
660
674
  }
661
- }, rt = (e) => {
662
- let t = tt();
663
- t.used && e !== null && console.warn("[voltro] setStoreStorage() was called after a persisted store had already read. That store booted against the previous backing store and will not be re-read. Install storage before the first render — on React Native, after awaiting hydrate()."), t.provider = e ?? void 0;
664
675
  }, it = (e) => {
665
- let t = tt();
666
- return t.used = !0, (t.provider ?? nt)(e);
667
- }, at = () => {
668
- let e = tt();
676
+ let t = nt();
677
+ t.used && e !== null && console.warn("[voltro] setStoreStorage() was called after a persisted store had already read. That store booted against the previous backing store and will not be re-read. Install storage before the first render — on React Native, after awaiting hydrate()."), t.provider = e ?? void 0;
678
+ }, at = (e) => {
679
+ let t = nt();
680
+ return t.used = !0, (t.provider ?? rt)(e);
681
+ }, ot = () => {
682
+ let e = nt();
669
683
  e.provider = void 0, e.used = !1;
670
- }, ot = (e, t) => {
684
+ }, st = (e, t) => {
671
685
  if (Object.is(e, t)) return !0;
672
686
  if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
673
687
  let n = Object.keys(e), r = Object.keys(t);
674
688
  if (n.length !== r.length) return !1;
675
689
  for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
676
690
  return !0;
677
- }, st = 50, ct = /* @__PURE__ */ new Set(), lt = (e, t) => {
678
- ct.has(e) || (ct.add(e), console.warn(t));
679
- }, ut = "\0global", dt = null, ft = (e, t, n) => {
680
- let r = dt?.() ?? null;
691
+ }, ct = 50, lt = /* @__PURE__ */ new Set(), ut = (e, t) => {
692
+ lt.has(e) || (lt.add(e), console.warn(t));
693
+ }, dt = "\0global", ft = null, pt = (e, t, n) => {
694
+ let r = ft?.() ?? null;
681
695
  if (r === null) return n;
682
696
  let i = n;
683
697
  for (let n of r.seeds) n.store === e && n.key === t && (i = {
@@ -685,9 +699,9 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
685
699
  ...n.value
686
700
  });
687
701
  return i;
688
- }, pt = (e, t) => {
702
+ }, mt = (e, t) => {
689
703
  let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
690
- if (i >= st) throw i = 0, Error(`defineStore: notification depth exceeded ${st} — a subscriber writes a NEW value every time it is notified, so the store can never settle. Look for a listener calling set() with something derived from the current state without converging.`);
704
+ if (i >= ct) throw i = 0, Error(`defineStore: notification depth exceeded ${ct} — a subscriber writes a NEW value every time it is notified, so the store can never settle. Look for a listener calling set() with something derived from the current state without converging.`);
691
705
  i += 1;
692
706
  try {
693
707
  for (let e of [...r]) e();
@@ -708,20 +722,20 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
708
722
  if (typeof i?.then == "function") throw a === 1 && o !== void 0 && (n = o), --a, a === 0 && (o = void 0, s = void 0), Error(`defineStore: batch('${e}') was given an async function. A batch is synchronous — everything after the first await would land outside it. Await the work first, then batch the writes: \`const r = await load(); store.batch('${e}', () => { … })\`.`);
709
723
  if (--a, a > 0) return;
710
724
  let l = o, u = s;
711
- o = void 0, s = void 0, !ot(l, n) && (t(l, n, u), c());
725
+ o = void 0, s = void 0, !st(l, n) && (t(l, n, u), c());
712
726
  },
713
727
  set: (e, r) => {
714
728
  let i = typeof e == "function" ? e(n) : {
715
729
  ...n,
716
730
  ...e
717
731
  };
718
- if (ot(i, n)) return;
732
+ if (st(i, n)) return;
719
733
  let o = n;
720
734
  n = i, !(a > 0) && (t(o, i, r), c());
721
735
  },
722
736
  reset: () => {
723
737
  let r = e();
724
- if (ot(r, n)) return;
738
+ if (st(r, n)) return;
725
739
  let i = n;
726
740
  n = r, !(a > 0) && (t(i, r, "reset"), c());
727
741
  },
@@ -729,51 +743,51 @@ var ge = /* @__PURE__ */ new Set(), _e = (e) => {
729
743
  r.delete(e);
730
744
  })
731
745
  };
732
- }, mt = 200, ht = [], gt = /* @__PURE__ */ new Set(), _t = [], vt = () => _t, yt = (e) => (gt.add(e), () => {
733
- gt.delete(e);
734
- }), bt = () => {
735
- ht.length = 0, _t = [];
736
- }, xt = (e, t) => {
737
- let n = ht[e];
746
+ }, ht = 200, gt = [], _t = /* @__PURE__ */ new Set(), vt = [], yt = () => vt, bt = (e) => (_t.add(e), () => {
747
+ _t.delete(e);
748
+ }), xt = () => {
749
+ gt.length = 0, vt = [];
750
+ }, St = (e, t) => {
751
+ let n = gt[e];
738
752
  if (n === void 0) return !1;
739
- let r = Tt.get(n.store);
753
+ let r = Et.get(n.store);
740
754
  if (r === void 0) return !1;
741
755
  let i = t === "before" ? n.prev : n.next;
742
- Ct = !0;
756
+ wt = !0;
743
757
  try {
744
758
  r.set(() => i, n.key, `travel:${t}`);
745
759
  } finally {
746
- Ct = !1;
760
+ wt = !1;
747
761
  }
748
762
  return !0;
749
- }, St = !1, Ct = !1, wt = (e) => {
750
- ht.push(e), ht.length > mt && ht.shift(), _t = [...ht];
751
- for (let e of [...gt]) e();
752
- }, Tt = /* @__PURE__ */ new Map(), Et = /* @__PURE__ */ new Map(), Dt = 0, Ot = !1, kt = /* @__PURE__ */ new Map(), At = () => (Ot || (Ot = !0, queueMicrotask(() => {
753
- Dt += 1, Ot = !1;
754
- })), Dt), jt = Mt(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
755
- function Mt(e) {
763
+ }, Ct = !1, wt = !1, Tt = (e) => {
764
+ gt.push(e), gt.length > ht && gt.shift(), vt = [...gt];
765
+ for (let e of [..._t]) e();
766
+ }, Et = /* @__PURE__ */ new Map(), Dt = /* @__PURE__ */ new Map(), Ot = 0, kt = !1, At = /* @__PURE__ */ new Map(), jt = () => (kt || (kt = !0, queueMicrotask(() => {
767
+ Ot += 1, kt = !1;
768
+ })), Ot), Mt = Nt(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
769
+ function Nt(e) {
756
770
  let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
757
771
  return n.length > 0 ? n : void 0;
758
772
  }
759
- var Nt = () => {
773
+ var Pt = () => {
760
774
  let e = (/* @__PURE__ */ Error()).stack;
761
775
  if (typeof e != "string") return "<unknown>";
762
776
  for (let t of e.split("\n").slice(1)) {
763
- let e = Mt(t);
777
+ let e = Nt(t);
764
778
  if (e === void 0) continue;
765
779
  let n = e.replace(/:\d+:\d+$/, "");
766
- if (jt === "" || n !== jt.replace(/:\d+:\d+$/, "")) return n;
780
+ if (Mt === "" || n !== Mt.replace(/:\d+:\d+$/, "")) return n;
767
781
  }
768
782
  return "<unknown>";
769
- }, Pt = () => [...Tt.values()], Ft = (e, t, n) => {
770
- let r = Nt(), i = At(), a = Tt.get(e);
783
+ }, Ft = () => [...Et.values()], It = (e, t, n) => {
784
+ let r = Pt(), i = jt(), a = Et.get(e);
771
785
  if (a !== void 0) {
772
- let t = Et.get(e) ?? "<unknown>", n = kt.get(e) === i;
786
+ let t = Dt.get(e) ?? "<unknown>", n = At.get(e) === i;
773
787
  if (r !== "<unknown>" && r === t && !n) return a;
774
788
  throw Error(`defineStore: '${e}' is already defined. Store names are the devtools + seed key, so two stores sharing one name would silently share state. Rename one.\n first: ${t}\n second: ${r}`);
775
789
  }
776
- let o = n?.persist, s = () => it(o?.storage === "session" ? "session" : "local"), c = () => {
790
+ let o = n?.persist, s = () => at(o?.storage === "session" ? "session" : "local"), c = () => {
777
791
  let e = s();
778
792
  if (e === null || o === void 0) return;
779
793
  let t;
@@ -798,28 +812,28 @@ var Nt = () => {
798
812
  t.setItem(o.key, JSON.stringify(n));
799
813
  } catch {}
800
814
  }, u = /* @__PURE__ */ new Map(), d = (n) => {
801
- let r = n ?? ut, i = u.get(r);
815
+ let r = n ?? dt, i = u.get(r);
802
816
  if (i === void 0) {
803
817
  let a = n;
804
- i = pt(o !== void 0 && n === void 0 ? () => {
818
+ i = mt(o !== void 0 && n === void 0 ? () => {
805
819
  let e = t();
806
820
  return f = e, {
807
821
  ...e,
808
822
  ...c() ?? {}
809
823
  };
810
824
  } : t, (t, n, r) => {
811
- if (o !== void 0 && a === void 0 && l(n), !St && !Ct) {
825
+ if (o !== void 0 && a === void 0 && l(n), !Ct && !wt) {
812
826
  let e = m(a);
813
827
  e.steps.length = e.cursor, e.steps.push({
814
828
  prev: t,
815
829
  next: n
816
830
  }), e.steps.length > h && e.steps.shift(), e.cursor = e.steps.length;
817
831
  }
818
- wt({
832
+ Tt({
819
833
  store: e,
820
834
  ...a === void 0 ? {} : { key: a },
821
835
  ...r === void 0 ? {} : { label: r },
822
- ...St || Ct ? { isUndo: !0 } : {},
836
+ ...Ct || wt ? { isUndo: !0 } : {},
823
837
  prev: t,
824
838
  next: n,
825
839
  at: Date.now()
@@ -828,7 +842,7 @@ var Nt = () => {
828
842
  }
829
843
  return i;
830
844
  }, f, p = /* @__PURE__ */ new Map(), m = (e) => {
831
- let t = e ?? ut, n = p.get(t);
845
+ let t = e ?? dt, n = p.get(t);
832
846
  return n === void 0 && (n = {
833
847
  steps: [],
834
848
  cursor: 0
@@ -856,18 +870,24 @@ var Nt = () => {
856
870
  state: void 0,
857
871
  value: void 0,
858
872
  has: !1
859
- }), s = w((t) => {
873
+ }), s = T((t) => {
860
874
  let n = o.current;
861
875
  if (n.has && Object.is(n.state, t)) return n.value;
862
876
  let r = i.current(t), s = a.current, c = n.has && (s ? s(n.value, r) : Object.is(n.value, r));
863
- process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && ot(n.value, r) && lt(e, `[@voltro/client] ${e}.use(): the selector returns a NEW object each call, so the default identity check never sees it as unchanged and this component re-renders on EVERY store change.\n Pass \`{ equals: shallow }\` (exported from @voltro/client), or select a primitive.`);
877
+ if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && st(n.value, r)) {
878
+ let t = !0;
879
+ try {
880
+ t = !Object.is(i.current(n.state), n.value);
881
+ } catch {}
882
+ ut(e, t ? `[@voltro/client] ${e}.use(): the selector returns a NEW object each call, so the default identity check never sees it as unchanged and this component re-renders on EVERY store change.\n Pass \`{ equals: shallow }\` (exported from @voltro/client), or select a primitive.` : `[@voltro/client] ${e}.use(): this component re-renders on store changes that do not change what it selects. The selector is stable — it returns the same reference for the same state — and the STORE is writing a new value that is equal one level deep (a fresh \`[]\` or \`{}\`, say).\n Pass \`{ equals: shallow }\` (exported from @voltro/client), or stop writing an equal value.`);
883
+ }
864
884
  let l = c ? n.value : r;
865
885
  return o.current = {
866
886
  state: t,
867
887
  value: l,
868
888
  has: !0
869
889
  }, l;
870
- }, []), c = n?.key, l = n?.retain === !0, u = w((e) => {
890
+ }, []), c = n?.key, l = n?.retain === !0, u = T((e) => {
871
891
  let t = r.subscribe(e);
872
892
  return c !== void 0 && !l && v(c), () => {
873
893
  t(), c !== void 0 && !l && y(c);
@@ -876,11 +896,11 @@ var Nt = () => {
876
896
  r,
877
897
  c,
878
898
  l
879
- ]), p = w(() => s(r.get()), [r, s]), m = w(() => s(ft(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
899
+ ]), p = T(() => s(r.get()), [r, s]), m = T(() => s(pt(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
880
900
  r,
881
901
  n?.key,
882
902
  s
883
- ]), h = re(u, p, m);
903
+ ]), h = A(u, p, m);
884
904
  return ne(h), h;
885
905
  },
886
906
  instance: d,
@@ -894,11 +914,11 @@ var Nt = () => {
894
914
  undo: (e) => {
895
915
  let t = m(e);
896
916
  if (t.cursor === 0) return !1;
897
- --t.cursor, St = !0;
917
+ --t.cursor, Ct = !0;
898
918
  try {
899
919
  d(e).set(() => t.steps[t.cursor].prev, "undo");
900
920
  } finally {
901
- St = !1;
921
+ Ct = !1;
902
922
  }
903
923
  return !0;
904
924
  },
@@ -906,11 +926,11 @@ var Nt = () => {
906
926
  let t = m(e);
907
927
  if (t.cursor >= t.steps.length) return !1;
908
928
  let n = t.steps[t.cursor];
909
- t.cursor += 1, St = !0;
929
+ t.cursor += 1, Ct = !0;
910
930
  try {
911
931
  d(e).set(() => n.next, "redo");
912
932
  } finally {
913
- St = !1;
933
+ Ct = !1;
914
934
  }
915
935
  return !0;
916
936
  },
@@ -922,27 +942,27 @@ var Nt = () => {
922
942
  release: (e) => {
923
943
  u.delete(e), p.delete(e);
924
944
  },
925
- keys: () => [...u.keys()].filter((e) => e !== ut)
945
+ keys: () => [...u.keys()].filter((e) => e !== dt)
926
946
  };
927
- return Tt.set(e, b), Et.set(e, r), kt.set(e, i), b;
928
- }, It = () => {
929
- Tt.clear(), Et.clear(), kt.clear(), ct.clear();
930
- }, Lt = () => ({ seeds: [] }), Rt = (e) => {
931
- dt = e;
932
- }, zt = (e, t, n) => {
933
- let r = dt?.() ?? null;
947
+ return Et.set(e, b), Dt.set(e, r), At.set(e, i), b;
948
+ }, Lt = () => {
949
+ Et.clear(), Dt.clear(), At.clear(), lt.clear();
950
+ }, Rt = () => ({ seeds: [] }), zt = (e) => {
951
+ ft = e;
952
+ }, Bt = (e, t, n) => {
953
+ let r = ft?.() ?? null;
934
954
  if (r === null) throw Error(`seedStore('${e.name}') was called outside a server render. Seeding exists to put a value into the SSR hydration payload; on the client, set the store directly instead. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
935
955
  r.seeds.push({
936
956
  store: e.name,
937
957
  ...n?.key === void 0 ? {} : { key: n.key },
938
958
  value: t
939
959
  });
940
- }, Bt = (e) => {
960
+ }, Vt = (e) => {
941
961
  if (e !== void 0) for (let t of e) {
942
- let e = Tt.get(t.store);
962
+ let e = Et.get(t.store);
943
963
  e !== void 0 && e.set(t.value, t.key);
944
964
  }
945
- }, q = (e, t) => {
965
+ }, K = (e, t) => {
946
966
  let n = t.split("."), r = e;
947
967
  for (let e = 0; e < n.length; e++) {
948
968
  let i = n[e];
@@ -961,15 +981,15 @@ var Nt = () => {
961
981
  }
962
982
  if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
963
983
  return r;
964
- }, Vt = Object.freeze({
984
+ }, Ht = Object.freeze({
965
985
  data: void 0,
966
986
  revision: -1,
967
987
  emittedAt: void 0,
968
988
  error: void 0,
969
989
  pendingPatches: 0
970
- }), Ht = () => Vt;
971
- function J(e, t, n = {}, r = {}) {
972
- let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = K(e), l = c[t]?.source, u = O(n);
990
+ }), Ut = () => Ht;
991
+ function q(e, t, n = {}, r = {}) {
992
+ let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = G(e), l = c[t]?.source, u = O(n);
973
993
  u.current = n;
974
994
  let d = O(s);
975
995
  d.current = s;
@@ -977,19 +997,19 @@ function J(e, t, n = {}, r = {}) {
977
997
  let e = u.current;
978
998
  return {
979
999
  queryKey: [t, e],
980
- fetch: () => q(d.current, t)(e)
1000
+ fetch: () => K(d.current, t)(e)
981
1001
  };
982
- }, [t, f]), m = p.queryKey, h = w((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
1002
+ }, [t, f]), m = p.queryKey, h = T((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
983
1003
  o,
984
1004
  a,
985
1005
  l,
986
1006
  i,
987
1007
  p
988
- ]), g = w(() => i ? Vt : o.peek(m), [
1008
+ ]), g = T(() => i ? Ht : o.peek(m), [
989
1009
  o,
990
1010
  i,
991
1011
  m
992
- ]), _ = re(h, g, Ht), v = _.data !== void 0, y = v && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), b = {
1012
+ ]), _ = A(h, g, Ut), v = _.data !== void 0, y = v && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), b = {
993
1013
  revision: _.revision,
994
1014
  emittedAt: _.emittedAt,
995
1015
  error: _.error,
@@ -1045,26 +1065,31 @@ function J(e, t, n = {}, r = {}) {
1045
1065
  };
1046
1066
  }
1047
1067
  //#endregion
1048
- //#region src/runRpc.ts
1049
- var Y = async (e, t) => {
1068
+ //#region src/awaitResolvedApi.ts
1069
+ var Wt = 15e3, J = async (e, t, n) => {
1070
+ if (!qe(e.current)) return e.current;
1071
+ let r = Date.now() + Wt;
1072
+ for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !qe(e.current)) return e.current;
1073
+ throw Error(`Voltro: the api "${t}" did not resolve within ${Wt}ms, so ${n} was never sent. This is not the boot window — that is waited out. Check that "${t}" is a configured api name and that its client could connect.`);
1074
+ }, Y = async (e, t) => {
1050
1075
  let n = await e.runPromiseExit(t);
1051
1076
  if (N.isSuccess(n)) return n.value;
1052
- throw A.squash(n.cause);
1053
- }, Ut = 100, X = [], Wt = /* @__PURE__ */ new Set(), Gt = [], Kt = () => {
1054
- Gt = X.slice();
1055
- }, qt = () => {
1056
- Kt();
1057
- for (let e of Wt) try {
1077
+ throw j.squash(n.cause);
1078
+ }, Gt = 100, X = [], Kt = /* @__PURE__ */ new Set(), qt = [], Jt = () => {
1079
+ qt = X.slice();
1080
+ }, Yt = () => {
1081
+ Jt();
1082
+ for (let e of Kt) try {
1058
1083
  e();
1059
1084
  } catch {}
1060
- }, Jt = (e) => {
1085
+ }, Xt = (e) => {
1061
1086
  let t = {
1062
1087
  ...e,
1063
1088
  status: "pending",
1064
1089
  startedAt: Date.now()
1065
1090
  };
1066
- X.unshift(t), X.length > Ut && (X.length = Ut), qt();
1067
- }, Yt = (e, t) => {
1091
+ X.unshift(t), X.length > Gt && (X.length = Gt), Yt();
1092
+ }, Zt = (e, t) => {
1068
1093
  let n = X.findIndex((t) => t.id === e);
1069
1094
  if (n === -1) return;
1070
1095
  let r = X[n], i = Date.now();
@@ -1080,12 +1105,12 @@ var Y = async (e, t) => {
1080
1105
  error: t.error,
1081
1106
  settledAt: i,
1082
1107
  durationMs: i - r.startedAt
1083
- }, qt();
1084
- }, Xt = () => Gt, Zt = (e) => (Wt.add(e), () => {
1085
- Wt.delete(e);
1086
- }), Qt = () => {
1087
- X.length !== 0 && (X.length = 0, qt());
1088
- }, $t = (e, t) => {
1108
+ }, Yt();
1109
+ }, Qt = () => qt, $t = (e) => (Kt.add(e), () => {
1110
+ Kt.delete(e);
1111
+ }), en = () => {
1112
+ X.length !== 0 && (X.length = 0, Yt());
1113
+ }, tn = (e, t) => {
1089
1114
  if (t === void 0 || typeof e != "object" || !e) return e;
1090
1115
  try {
1091
1116
  Object.defineProperty(e, "__voltroTraceId", {
@@ -1095,107 +1120,117 @@ var Y = async (e, t) => {
1095
1120
  });
1096
1121
  } catch {}
1097
1122
  return e;
1098
- }, en, tn = (e) => {
1099
- en = e;
1100
- }, nn = () => en, rn = (e, t, n) => typeof e == "function" ? e(t, n) : e, an = 0, on = () => `mut_${++an}`, sn = 0, cn = () => {
1123
+ }, nn, rn = (e) => {
1124
+ nn = e;
1125
+ }, an = () => nn, on = (e, t, n) => typeof e == "function" ? e(t, n) : e, sn = 0, cn = () => `mut_${++sn}`, ln = 0, un = () => {
1101
1126
  let e = typeof crypto < "u" ? crypto : void 0;
1102
- return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${sn += 1}`;
1103
- }, ln = (e, t) => e.pipe(M.locallyWith(R.currentHeaders, (e) => se.set(e, "idempotency-key", t))), un = (e, t) => ({
1127
+ return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${ln += 1}`;
1128
+ }, dn = (e, t) => e.pipe(M.locallyWith(z.currentHeaders, (e) => oe.set(e, "idempotency-key", t))), fn = (e, t) => ({
1104
1129
  update: (n, r) => {
1105
1130
  e.update(n, r, t);
1106
1131
  },
1107
1132
  forTag: (n, r) => e.forTag(n, r, t)
1108
1133
  }), Z = (e, t) => {
1109
- let { runtime: n, cache: r, client: i, descriptors: a, errorBus: o } = K(e), s = a[t], c = s?.targets;
1134
+ let n = G(e), { descriptors: r, errorBus: i } = n, a = O(n);
1135
+ a.current = n;
1136
+ let o = r[t], s = o?.targets;
1110
1137
  if (process.env.NODE_ENV !== "production") {
1111
- let n = s?.kind;
1138
+ let n = o?.kind;
1112
1139
  n !== void 0 && n !== "mutation" && console.error(`[@voltro/client] useMutation('${e}', '${t}') targets a ${n}, not a mutation. Use ${n === "action" ? "useAction" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
1113
1140
  }
1114
- let [l, u] = k(!1), [d, f] = k(void 0), [p, m] = k(void 0), h = O(null), g = O(!1), _ = w(async (a, s) => {
1115
- let l = s?.onError !== void 0 || s?.notify?.error !== void 0, d = (e) => {
1116
- s?.onError?.(e, a);
1117
- let t = rn(s?.notify?.error, e, a);
1118
- t !== void 0 && en?.error(t);
1141
+ let [c, l] = k(!1), [u, d] = k(void 0), [f, p] = k(void 0), m = O(null), h = O(!1), g = T(async (n, r) => {
1142
+ let o = r?.onError !== void 0 || r?.notify?.error !== void 0, c = (e) => {
1143
+ r?.onError?.(e, n);
1144
+ let t = on(r?.notify?.error, e, n);
1145
+ t !== void 0 && nn?.error(t);
1119
1146
  };
1120
- u(!0), f(void 0);
1121
- let p = on(), _ = s?.idempotencyKey ?? cn();
1122
- Jt({
1123
- id: p,
1147
+ l(!0), d(void 0);
1148
+ let u, f, g;
1149
+ try {
1150
+ ({runtime: u, cache: f, client: g} = await J(a, e, t));
1151
+ } catch (e) {
1152
+ if (l(!1), d(e), o) return c(e);
1153
+ throw e;
1154
+ }
1155
+ let _ = cn(), v = r?.idempotencyKey ?? un();
1156
+ Xt({
1157
+ id: _,
1124
1158
  apiName: e,
1125
1159
  tag: t,
1126
- input: a
1160
+ input: n
1127
1161
  });
1128
- let v = h.current, y = g.current;
1129
- if (v) try {
1130
- v(un(r, p), a);
1162
+ let y = m.current, b = h.current;
1163
+ if (y) try {
1164
+ y(fn(f, _), n);
1131
1165
  } catch (e) {
1132
- if (f(e), u(!1), r.revertByMutation(p), Yt(p, {
1166
+ if (d(e), l(!1), f.revertByMutation(_), Zt(_, {
1133
1167
  status: "error",
1134
1168
  error: e
1135
- }), l) return d(e);
1169
+ }), o) return c(e);
1136
1170
  throw e;
1137
1171
  }
1138
- else !y && c && c.length > 0 && r.autoApply(c, a, p);
1139
- let b;
1172
+ else !b && s && s.length > 0 && f.autoApply(s, n, _);
1173
+ let x;
1140
1174
  try {
1141
- let o = q(i, t), c = M.currentSpan.pipe(M.tap((e) => M.sync(() => {
1142
- b = e.traceId, _e({
1175
+ let a = K(g, t), o = M.currentSpan.pipe(M.tap((e) => M.sync(() => {
1176
+ x = e.traceId, he({
1143
1177
  traceId: e.traceId,
1144
1178
  spanId: e.spanId,
1145
1179
  source: "mutation",
1146
1180
  tag: t
1147
1181
  });
1148
- })), M.catchAll(() => M.void), M.zipRight(ln(o(a), _))).pipe(M.withSpan(`client.mutation.${t}`, { attributes: {
1182
+ })), M.catchAll(() => M.void), M.zipRight(dn(a(n), v))).pipe(M.withSpan(`client.mutation.${t}`, { attributes: {
1149
1183
  "voltro.api": e,
1150
- "voltro.mutationId": p,
1184
+ "voltro.mutationId": _,
1151
1185
  "rpc.tag": t
1152
- } })), l = await Y(n, c);
1153
- m(l), Yt(p, {
1186
+ } })), s = await Y(u, o);
1187
+ p(s), Zt(_, {
1154
1188
  status: "success",
1155
- output: l
1156
- }), r.confirmByMutation(p), s?.onSuccess?.(l, a);
1157
- let u = rn(s?.notify?.success, l, a);
1158
- return u !== void 0 && en?.success(u), l;
1189
+ output: s
1190
+ }), i.emitSuccess({
1191
+ source: "mutation",
1192
+ tag: t
1193
+ }), f.confirmByMutation(_), r?.onSuccess?.(s, n);
1194
+ let c = on(r?.notify?.success, s, n);
1195
+ return c !== void 0 && nn?.success(c), s;
1159
1196
  } catch (e) {
1160
- let n = $t(e, b);
1161
- if (f(n), Yt(p, {
1197
+ let n = tn(e, x);
1198
+ if (d(n), Zt(_, {
1162
1199
  status: "error",
1163
1200
  error: n
1164
- }), r.revertByMutation(p), o.emit({
1201
+ }), f.revertByMutation(_), i.emit({
1165
1202
  source: "mutation",
1166
1203
  tag: t,
1167
1204
  error: n,
1168
- ...b === void 0 ? {} : { traceId: b }
1169
- }), l) return d(n);
1205
+ ...x === void 0 ? {} : { traceId: x }
1206
+ }), o) return c(n);
1170
1207
  throw n;
1171
1208
  } finally {
1172
- u(!1);
1209
+ l(!1);
1173
1210
  }
1174
1211
  }, [
1175
- n,
1176
- r,
1177
- i,
1178
1212
  e,
1179
1213
  t,
1180
- c
1214
+ s,
1215
+ i
1181
1216
  ]);
1182
1217
  return D(() => {
1183
1218
  let e = {
1184
- mutate: _,
1185
- pending: l,
1186
- error: d,
1187
- data: p,
1188
- withOptimistic: (t) => (h.current = t, e),
1189
- withoutOptimistic: () => (g.current = !0, e)
1219
+ mutate: g,
1220
+ pending: c,
1221
+ error: u,
1222
+ data: f,
1223
+ withOptimistic: (t) => (m.current = t, e),
1224
+ withoutOptimistic: () => (h.current = !0, e)
1190
1225
  };
1191
1226
  return e;
1192
1227
  }, [
1193
- _,
1194
- l,
1195
- d,
1196
- p
1228
+ g,
1229
+ c,
1230
+ u,
1231
+ f
1197
1232
  ]);
1198
- }, dn = (e, t) => {
1233
+ }, pn = (e, t) => {
1199
1234
  if (t === void 0 || typeof e != "object" || !e) return e;
1200
1235
  try {
1201
1236
  Object.defineProperty(e, "__voltroTraceId", {
@@ -1205,22 +1240,17 @@ var Y = async (e, t) => {
1205
1240
  });
1206
1241
  } catch {}
1207
1242
  return e;
1208
- }, fn = (e, t, n) => typeof e == "function" ? e(t, n) : e, pn = 0, mn = () => `act_${++pn}`, hn = 15e3, gn = async (e, t, n) => {
1209
- if (!Ke(e.current)) return e.current;
1210
- let r = Date.now() + hn;
1211
- for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !Ke(e.current)) return e.current;
1212
- throw Error(`Voltro: the api "${t}" did not resolve within ${hn}ms, so ${n} was never sent. This is not the boot window — that is waited out. Check that "${t}" is a configured api name and that its client could connect.`);
1213
- }, _n = (e, t) => {
1214
- let n = K(e), { descriptors: r, errorBus: i } = n, a = O(n);
1243
+ }, mn = (e, t, n) => typeof e == "function" ? e(t, n) : e, hn = 0, gn = () => `act_${++hn}`, _n = (e, t) => {
1244
+ let n = G(e), { descriptors: r, errorBus: i } = n, a = O(n);
1215
1245
  if (a.current = n, process.env.NODE_ENV !== "production") {
1216
1246
  let n = r[t]?.kind;
1217
1247
  n !== void 0 && n !== "action" && console.error(`[@voltro/client] useAction('${e}', '${t}') targets a ${n}, not an action. Use ${n === "mutation" ? "useMutation" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
1218
1248
  }
1219
- let [o, s] = k(!1), [c, l] = k(void 0), [u, d] = k(void 0), f = w(async (n, r) => {
1249
+ let [o, s] = k(!1), [c, l] = k(void 0), [u, d] = k(void 0), f = T(async (n, r) => {
1220
1250
  let o = r?.onError !== void 0 || r?.notify?.error !== void 0;
1221
1251
  s(!0), l(void 0);
1222
- let c = mn(), u = r?.idempotencyKey ?? cn();
1223
- Jt({
1252
+ let c = gn(), u = r?.idempotencyKey ?? un();
1253
+ Xt({
1224
1254
  id: c,
1225
1255
  apiName: e,
1226
1256
  tag: t,
@@ -1228,27 +1258,30 @@ var Y = async (e, t) => {
1228
1258
  });
1229
1259
  let f;
1230
1260
  try {
1231
- let { runtime: i, client: o } = await gn(a, e, t), s = q(o, t), l = await Y(i, M.currentSpan.pipe(M.tap((e) => M.sync(() => {
1232
- f = e.traceId, _e({
1261
+ let { runtime: o, client: s } = await J(a, e, t), l = K(s, t), p = await Y(o, M.currentSpan.pipe(M.tap((e) => M.sync(() => {
1262
+ f = e.traceId, he({
1233
1263
  traceId: e.traceId,
1234
1264
  spanId: e.spanId,
1235
1265
  source: "action",
1236
1266
  tag: t
1237
1267
  });
1238
- })), M.catchAll(() => M.void), M.zipRight(ln(s(n), u))).pipe(M.withSpan(`client.action.${t}`, { attributes: {
1268
+ })), M.catchAll(() => M.void), M.zipRight(dn(l(n), u))).pipe(M.withSpan(`client.action.${t}`, { attributes: {
1239
1269
  "voltro.api": e,
1240
1270
  "voltro.actionId": c,
1241
1271
  "rpc.tag": t
1242
1272
  } })));
1243
- d(l), Yt(c, {
1273
+ d(p), Zt(c, {
1244
1274
  status: "success",
1245
- output: l
1246
- }), r?.onSuccess?.(l, n);
1247
- let p = fn(r?.notify?.success, l, n);
1248
- return p !== void 0 && nn()?.success(p), l;
1275
+ output: p
1276
+ }), i.emitSuccess({
1277
+ source: "action",
1278
+ tag: t
1279
+ }), r?.onSuccess?.(p, n);
1280
+ let m = mn(r?.notify?.success, p, n);
1281
+ return m !== void 0 && an()?.success(m), p;
1249
1282
  } catch (e) {
1250
- let a = dn(e, f);
1251
- if (l(a), Yt(c, {
1283
+ let a = pn(e, f);
1284
+ if (l(a), Zt(c, {
1252
1285
  status: "error",
1253
1286
  error: a
1254
1287
  }), i.emit({
@@ -1258,8 +1291,8 @@ var Y = async (e, t) => {
1258
1291
  ...f === void 0 ? {} : { traceId: f }
1259
1292
  }), o) {
1260
1293
  r?.onError?.(a, n);
1261
- let e = fn(r?.notify?.error, a, n);
1262
- e !== void 0 && nn()?.error(e);
1294
+ let e = mn(r?.notify?.error, a, n);
1295
+ e !== void 0 && an()?.error(e);
1263
1296
  return;
1264
1297
  }
1265
1298
  throw a;
@@ -1282,7 +1315,7 @@ var Y = async (e, t) => {
1282
1315
  c,
1283
1316
  u
1284
1317
  ]);
1285
- }, vn = S(void 0), yn = (e) => C(vn.Provider, { value: e.messages }, e.children), bn = () => T(vn), xn = Symbol.for("voltro.client.formEngine"), Sn = S(void 0), Cn = (e, t) => {
1318
+ }, vn = C(void 0), yn = (e) => w(vn.Provider, { value: e.messages }, e.children), bn = () => te(vn), xn = Symbol.for("voltro.client.formEngine"), Sn = C(void 0), Cn = (e, t) => {
1286
1319
  let n = e;
1287
1320
  for (let e of t.split(".")) {
1288
1321
  if (typeof n != "object" || !n) return;
@@ -1304,31 +1337,31 @@ var Y = async (e, t) => {
1304
1337
  let r = /^(.+?)\.\d+\.(.+)$/.exec(t);
1305
1338
  if (r !== null) return e.find((e) => e.name === r[1] && e.widget === "array")?.item?.find((e) => e.name === r[2]);
1306
1339
  }, Dn = (e, t, n) => {
1307
- let r = K(e), a = Z(e, t), o = n.schema ?? r.descriptors[t]?.input;
1308
- process.env.NODE_ENV !== "production" && o === void 0 && console.error(`[@voltro/client] useFormBinding('${e}', '${t}'): no input schema. Pass options.schema, or mount the descriptor so its input reaches the client. Rendering no fields; submit skips client-side validation.`);
1309
- let s = D(() => o ? x(o) : [], [o]), c = bn(), l = n.messages ?? c, u = D(() => ({
1340
+ let r = G(e), a = O(void 0), o = typeof t == "function" ? t(a.current?.state?.values ?? n.defaults ?? {}) : t, s = O(o).current, c = Z(e, o), l = n.schema ?? r.descriptors[o]?.input;
1341
+ process.env.NODE_ENV !== "production" && l === void 0 && console.error(`[@voltro/client] useFormBinding('${e}', '${t}'): no input schema. Pass options.schema, or mount the descriptor so its input reaches the client. Rendering no fields; submit skips client-side validation.`);
1342
+ let u = D(() => l ? x(l) : [], [l]), d = bn(), f = n.messages ?? d, p = D(() => ({
1310
1343
  ...n.locale === void 0 ? {} : { locale: n.locale },
1311
- ...l === void 0 ? {} : { messages: l }
1312
- }), [n.locale, l]), d = O(n.asyncFields);
1313
- d.current = n.asyncFields;
1314
- let f = O(n);
1315
- f.current = n;
1316
- let p = O(a);
1317
- p.current = a;
1318
- let m = O(u);
1319
- m.current = u;
1320
- let h = O(o);
1321
- h.current = o;
1322
- let [g, _] = k(() => n.flash?.errors ?? {}), [v, y] = k(n.flash?.formError), [ee, S] = k(void 0), C = O(void 0), T = w((e) => {
1323
- let t = h.current;
1344
+ ...f === void 0 ? {} : { messages: f }
1345
+ }), [n.locale, f]), m = O(n.asyncFields);
1346
+ m.current = n.asyncFields;
1347
+ let h = O(n);
1348
+ h.current = n;
1349
+ let g = O(c);
1350
+ g.current = c;
1351
+ let _ = O(p);
1352
+ _.current = p;
1353
+ let v = O(l);
1354
+ v.current = l;
1355
+ let [y, S] = k(() => n.flash?.errors ?? {}), [C, w] = k(n.flash?.formError), [te, ne] = k(void 0), A = O(void 0), j = T((e) => {
1356
+ let t = v.current;
1324
1357
  if (t === void 0) return [];
1325
- let n = f.current, r = e;
1358
+ let n = h.current, r = e;
1326
1359
  if (n.toInput !== void 0) try {
1327
1360
  r = n.toInput(e);
1328
1361
  } catch {
1329
1362
  r = e;
1330
1363
  }
1331
- let a = i(t, r, m.current).issues;
1364
+ let a = i(t, r, _.current).issues;
1332
1365
  if (n.toInput === void 0) return a;
1333
1366
  let o = n.errorPath ?? {};
1334
1367
  return a.map((t) => {
@@ -1338,146 +1371,146 @@ var Y = async (e, t) => {
1338
1371
  path: n
1339
1372
  };
1340
1373
  });
1341
- }, []), ne = w((e) => {
1342
- let t = { ...e ?? {} }, n = h.current;
1374
+ }, []), re = T((e) => {
1375
+ let t = { ...e ?? {} }, n = v.current;
1343
1376
  if (n !== void 0) for (let e of x(n)) (e.widget === "checkbox" || e.widget === "switch") && !(e.name in t) && (t[e.name] = !1);
1344
1377
  return t;
1345
- }, []), re = O(() => Promise.resolve()), A = O(void 0);
1346
- if (A.current === void 0) {
1347
- let e = n.flash, t = e === void 0 ? ne(n.defaults) : {
1348
- ...ne(n.defaults),
1378
+ }, []), ie = O(() => Promise.resolve());
1379
+ if (a.current === void 0) {
1380
+ let e = n.flash, t = e === void 0 ? re(n.defaults) : {
1381
+ ...re(n.defaults),
1349
1382
  ...e.values
1350
1383
  };
1351
- A.current = new pe({
1352
- onSubmit: ({ value: e }) => re.current(e),
1384
+ a.current = new fe({
1385
+ onSubmit: ({ value: e }) => ie.current(e),
1353
1386
  defaultValues: t,
1354
1387
  validators: { onChange: ({ value: e }) => {
1355
- let t = T(e);
1388
+ let t = j(e);
1356
1389
  if (t.length === 0) return;
1357
1390
  let n = {};
1358
- for (let e of t) e.path !== "" && !(e.path in n) && (n[e.path] = b(e, m.current));
1391
+ for (let e of t) e.path !== "" && !(e.path in n) && (n[e.path] = b(e, _.current));
1359
1392
  return { fields: n };
1360
1393
  } }
1361
1394
  });
1362
1395
  }
1363
- let ie = A.current, j = ie;
1364
- E(() => j.mount(), [j]);
1365
- let M = n.subscribe ?? "all";
1366
- me(ie.store, (e) => M === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
1367
- let N = ie.store.state.values, P = ie.store.state, F = D(() => T(N), [T, N]), ae = n.isLoading === !0, I = n.validate, oe = I?.onChange ?? "afterTouched", L = I?.onBlur ?? !0, se = P.submissionAttempts, R = P.fieldMetaBase ?? {}, ce = w((e) => {
1396
+ let M = a.current, N = M;
1397
+ E(() => N.mount(), [N]);
1398
+ let P = n.subscribe ?? "all";
1399
+ pe(M.store, (e) => P === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
1400
+ let F = M.store.state.values, I = M.store.state, L = D(() => j(F), [j, F]), ae = n.isLoading === !0, R = n.validate, oe = R?.onChange ?? "afterTouched", z = R?.onBlur ?? !0, se = I.submissionAttempts, ce = I.fieldMetaBase ?? {}, ue = T((e) => {
1368
1401
  if (ae) return !1;
1369
1402
  if (se > 0 || oe === "always") return !0;
1370
1403
  if (oe === "never") return !1;
1371
- let t = R[e];
1372
- return t === void 0 ? !1 : L ? t.isBlurred === !0 : t.isTouched === !0;
1404
+ let t = ce[e];
1405
+ return t === void 0 ? !1 : z ? t.isBlurred === !0 : t.isTouched === !0;
1373
1406
  }, [
1374
1407
  se,
1375
- R,
1408
+ ce,
1376
1409
  ae,
1377
1410
  oe,
1378
- L
1379
- ]), z = w((e) => {
1380
- let t = g[e];
1411
+ z
1412
+ ]), B = T((e) => {
1413
+ let t = y[e];
1381
1414
  if (t !== void 0) return t;
1382
- let n = d.current?.[e];
1415
+ let n = m.current?.[e];
1383
1416
  if (n !== void 0 && n.status === "invalid") return n.message ?? b({
1384
1417
  id: "validation.invalid",
1385
1418
  fallback: "Invalid value"
1386
- }, m.current);
1387
- if (!ce(e)) return;
1388
- let r = F.find((t) => t.path === e);
1389
- return r === void 0 ? void 0 : b(r, m.current);
1419
+ }, _.current);
1420
+ if (!ue(e)) return;
1421
+ let r = L.find((t) => t.path === e);
1422
+ return r === void 0 ? void 0 : b(r, _.current);
1390
1423
  }, [
1391
- g,
1392
- ce,
1393
- F
1394
- ]), ue = D(() => {
1395
- let e = {}, t = /* @__PURE__ */ new Set([...F.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(g)]);
1396
- for (let [e, n] of Object.entries(d.current ?? {})) n.status === "invalid" && t.add(e);
1424
+ y,
1425
+ ue,
1426
+ L
1427
+ ]), de = D(() => {
1428
+ let e = {}, t = /* @__PURE__ */ new Set([...L.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(y)]);
1429
+ for (let [e, n] of Object.entries(m.current ?? {})) n.status === "invalid" && t.add(e);
1397
1430
  for (let n of t) {
1398
- let t = z(n);
1431
+ let t = B(n);
1399
1432
  t !== void 0 && (e[n] = t);
1400
1433
  }
1401
1434
  return e;
1402
1435
  }, [
1403
- F,
1404
- g,
1405
- z
1406
- ]), de = w((e) => {
1407
- _((t) => {
1436
+ L,
1437
+ y,
1438
+ B
1439
+ ]), me = T((e) => {
1440
+ S((t) => {
1408
1441
  if (!(e in t)) return t;
1409
1442
  let n = { ...t };
1410
1443
  return delete n[e], n;
1411
1444
  });
1412
- }, []), fe = w((n) => {
1413
- let r = En(s, n), i = j.getFieldMeta(n), a = z(n), o = wn(e, t, n), c = d.current?.[n], l = [a === void 0 ? void 0 : `${o}-error`, r?.description === void 0 ? void 0 : `${o}-help`].filter((e) => e !== void 0);
1445
+ }, []), V = T((t) => {
1446
+ let n = En(u, t), r = N.getFieldMeta(t), i = B(t), a = wn(e, s, t), o = m.current?.[t], c = [i === void 0 ? void 0 : `${a}-error`, n?.description === void 0 ? void 0 : `${a}-help`].filter((e) => e !== void 0);
1414
1447
  return {
1415
- value: j.getFieldValue(n),
1448
+ value: N.getFieldValue(t),
1416
1449
  setValue: (e) => {
1417
- de(n), !Object.is(j.getFieldValue(n), e) && j.setFieldValue(n, e);
1450
+ me(t), !Object.is(N.getFieldValue(t), e) && N.setFieldValue(t, e);
1418
1451
  },
1419
1452
  onBlur: () => {
1420
- j.setFieldMeta(n, (e) => ({
1453
+ N.setFieldMeta(t, (e) => ({
1421
1454
  ...Tn,
1422
1455
  ...e ?? {},
1423
1456
  isTouched: !0,
1424
1457
  isBlurred: !0
1425
1458
  }));
1426
1459
  },
1427
- error: a,
1428
- serverError: g[n],
1429
- touched: i?.isTouched === !0,
1430
- blurred: i?.isBlurred === !0,
1431
- dirty: i?.isDirty === !0,
1432
- required: r?.required === !0,
1433
- label: r?.label ?? n,
1434
- widget: r?.widget ?? "text",
1435
- options: r?.options,
1436
- description: r?.description,
1437
- asyncStatus: c?.status ?? "idle",
1460
+ error: i,
1461
+ serverError: y[t],
1462
+ touched: r?.isTouched === !0,
1463
+ blurred: r?.isBlurred === !0,
1464
+ dirty: r?.isDirty === !0,
1465
+ required: n?.required === !0,
1466
+ label: n?.label ?? t,
1467
+ widget: n?.widget ?? "text",
1468
+ options: n?.options,
1469
+ description: n?.description,
1470
+ asyncStatus: o?.status ?? "idle",
1438
1471
  a11y: {
1439
- id: o,
1440
- "aria-invalid": a !== void 0 || void 0,
1441
- "aria-required": r?.required === !0 || void 0,
1442
- "aria-describedby": l.length > 0 ? l.join(" ") : void 0
1472
+ id: a,
1473
+ "aria-invalid": i !== void 0 || void 0,
1474
+ "aria-required": n?.required === !0 || void 0,
1475
+ "aria-describedby": c.length > 0 ? c.join(" ") : void 0
1443
1476
  }
1444
1477
  };
1445
1478
  }, [
1446
1479
  e,
1447
- de,
1448
- j,
1449
1480
  s,
1450
- t,
1451
- g,
1452
- z
1453
- ]), he = w((e) => ({
1454
- items: j.getFieldValue(e) ?? [],
1481
+ me,
1482
+ N,
1483
+ u,
1484
+ y,
1485
+ B
1486
+ ]), he = T((e) => ({
1487
+ items: N.getFieldValue(e) ?? [],
1455
1488
  push: (t) => {
1456
- j.pushFieldValue(e, t);
1489
+ N.pushFieldValue(e, t);
1457
1490
  },
1458
1491
  insert: (t, n) => {
1459
- j.insertFieldValue(e, t, n);
1492
+ N.insertFieldValue(e, t, n);
1460
1493
  },
1461
1494
  remove: (t) => {
1462
- j.removeFieldValue(e, t);
1495
+ N.removeFieldValue(e, t);
1463
1496
  },
1464
1497
  move: (t, n) => {
1465
- j.moveFieldValues(e, t, n);
1498
+ N.moveFieldValues(e, t, n);
1466
1499
  },
1467
1500
  swap: (t, n) => {
1468
- j.swapFieldValues(e, t, n);
1501
+ N.swapFieldValues(e, t, n);
1469
1502
  },
1470
- field: (t, n) => fe(`${e}.${t}.${n}`)
1471
- }), [j, fe]), ge = w((e) => s.filter((t) => t.section === e), [s]), _e = w((e, t) => {
1472
- de(e), !Object.is(j.getFieldValue(e), t) && j.setFieldValue(e, t);
1473
- }, [de, j]), ve = w((e) => {
1474
- for (let [t, n] of Object.entries(e)) j.setFieldValue(t, n);
1475
- }, [j]), B = w((e) => {
1476
- _({}), y(void 0), S(void 0), C.current = void 0, e === void 0 ? j.reset() : j.reset(ne(e));
1477
- }, [j, ne]), ye = n.asyncTimeoutMs ?? 5e3, be = w(async () => {
1503
+ field: (t, n) => V(`${e}.${t}.${n}`)
1504
+ }), [N, V]), ge = T((e) => u.filter((t) => t.section === e), [u]), H = T((e, t) => {
1505
+ me(e), !Object.is(N.getFieldValue(e), t) && N.setFieldValue(e, t);
1506
+ }, [me, N]), _e = T((e) => {
1507
+ for (let [t, n] of Object.entries(e)) N.setFieldValue(t, n);
1508
+ }, [N]), ve = T((e) => {
1509
+ S({}), w(void 0), ne(void 0), A.current = void 0, e === void 0 ? N.reset() : N.reset(re(e));
1510
+ }, [N, re]), ye = n.asyncTimeoutMs ?? 5e3, be = T(async () => {
1478
1511
  let e = Date.now();
1479
1512
  for (;;) {
1480
- let t = d.current;
1513
+ let t = m.current;
1481
1514
  if (t === void 0) return;
1482
1515
  let n = Object.entries(t), r = n.filter(([, e]) => e.status === "checking");
1483
1516
  if (r.length === 0) {
@@ -1485,81 +1518,81 @@ var Y = async (e, t) => {
1485
1518
  return e.length === 0 ? void 0 : Object.fromEntries(e.map(([e, t]) => [e, t.message ?? b({
1486
1519
  id: "validation.invalid",
1487
1520
  fallback: "Invalid value"
1488
- }, m.current)]));
1521
+ }, _.current)]));
1489
1522
  }
1490
1523
  if (Date.now() - e > ye) return Object.fromEntries(r.map(([e]) => [e, b({
1491
1524
  id: "validation.checking",
1492
1525
  fallback: "Still checking…"
1493
- }, m.current)]));
1526
+ }, _.current)]));
1494
1527
  await new Promise((e) => setTimeout(e, 50));
1495
1528
  }
1496
- }, [ye]), xe = w(() => {
1497
- let n = globalThis.document;
1498
- if (n?.getElementById === void 0) return;
1499
- let r = [...s.map((e) => e.name), ...Object.keys(g).filter((e) => !s.some((t) => t.name === e))];
1500
- for (let i of r) if (z(i) !== void 0) {
1501
- n.getElementById(wn(e, t, i))?.focus?.();
1529
+ }, [ye]), xe = T(() => {
1530
+ let t = globalThis.document;
1531
+ if (t?.getElementById === void 0) return;
1532
+ let n = [...u.map((e) => e.name), ...Object.keys(y).filter((e) => !u.some((t) => t.name === e))];
1533
+ for (let r of n) if (B(r) !== void 0) {
1534
+ t.getElementById(wn(e, s, r))?.focus?.();
1502
1535
  return;
1503
1536
  }
1504
1537
  }, [
1505
1538
  e,
1506
1539
  s,
1507
- t,
1508
- g,
1509
- z
1510
- ]), V = O(xe);
1511
- V.current = xe;
1512
- let Se = w(async () => {
1513
- y(void 0), _({}), S(void 0), C.current = void 0;
1540
+ u,
1541
+ y,
1542
+ B
1543
+ ]), U = O(xe);
1544
+ U.current = xe;
1545
+ let Se = T(async () => {
1546
+ w(void 0), S({}), ne(void 0), A.current = void 0;
1514
1547
  let e, t = !1;
1515
- if (await j.handleSubmit().catch((n) => {
1548
+ if (await N.handleSubmit().catch((n) => {
1516
1549
  t = !0, e = n;
1517
1550
  }), t) throw e;
1518
- return C.current === void 0 && queueMicrotask(() => {
1519
- V.current();
1520
- }), C.current;
1521
- }, [j]);
1522
- re.current = (async (e) => {
1523
- let t = f.current, n = e, r = n;
1551
+ return A.current === void 0 && queueMicrotask(() => {
1552
+ U.current();
1553
+ }), A.current;
1554
+ }, [N]);
1555
+ ie.current = (async (e) => {
1556
+ let t = h.current, n = e, r = n;
1524
1557
  if (t.toInput !== void 0) try {
1525
1558
  r = t.toInput(n);
1526
1559
  } catch (e) {
1527
- y(e instanceof Error ? e.message : String(e));
1560
+ w(e instanceof Error ? e.message : String(e));
1528
1561
  return;
1529
1562
  }
1530
- if (T(n).length > 0) {
1563
+ if (j(n).length > 0) {
1531
1564
  queueMicrotask(() => {
1532
- V.current();
1565
+ U.current();
1533
1566
  });
1534
1567
  return;
1535
1568
  }
1536
- let i = h.current;
1569
+ let i = v.current;
1537
1570
  if (i !== void 0) {
1538
- let e = te(i, r);
1571
+ let e = ee(i, r);
1539
1572
  e.dropped.length > 0 && process.env.NODE_ENV !== "production" && console.warn(`[@voltro/client] useFormBinding: dropped ${e.dropped.length} value(s) the mutation's input does not declare (${e.dropped.join(", ")}). The server refuses undeclared fields, so they are not sent. Map them with \`toInput\` if they belong in the write; ignore this if they are form-only state.`), r = e.input;
1540
1573
  }
1541
1574
  let a = await be();
1542
1575
  if (a !== void 0) {
1543
- _((e) => ({
1576
+ S((e) => ({
1544
1577
  ...e,
1545
1578
  ...a
1546
1579
  })), queueMicrotask(() => {
1547
- V.current();
1580
+ U.current();
1548
1581
  });
1549
1582
  return;
1550
1583
  }
1551
- let o = (e) => p.current.mutate(e);
1584
+ let o = (e) => g.current.mutate(e);
1552
1585
  try {
1553
1586
  let e = t.onSubmit === void 0 ? await o(r) : await t.onSubmit({
1554
1587
  input: r,
1555
1588
  values: n,
1556
1589
  mutate: o
1557
1590
  });
1558
- C.current = e, t.onSuccess?.(e);
1591
+ A.current = e, t.onSuccess?.(e);
1559
1592
  } catch (e) {
1560
1593
  let t = le(e);
1561
1594
  if (t.length === 0) {
1562
- S(e), f.current.onError?.(e);
1595
+ ne(e), h.current.onError?.(e);
1563
1596
  return;
1564
1597
  }
1565
1598
  let n = {};
@@ -1567,77 +1600,77 @@ var Y = async (e, t) => {
1567
1600
  id: e.message,
1568
1601
  ...e.params === void 0 ? {} : { params: e.params },
1569
1602
  fallback: e.message
1570
- }, m.current));
1571
- _((e) => ({
1603
+ }, _.current));
1604
+ S((e) => ({
1572
1605
  ...e,
1573
1606
  ...n
1574
1607
  })), queueMicrotask(() => {
1575
- V.current();
1608
+ U.current();
1576
1609
  });
1577
1610
  }
1578
1611
  });
1579
- let H = F.length === 0, U = Object.values(d.current ?? {}).some((e) => e.status === "checking"), W = ee ?? a.error, Ce = W !== void 0 && le(W).length > 0 ? void 0 : W, we = Object.keys(ue).length, Te = (() => {
1580
- for (let e of s) if (ue[e.name] !== void 0) return e.name;
1581
- let e = Object.keys(ue);
1612
+ let Ce = L.length === 0, we = Object.values(m.current ?? {}).some((e) => e.status === "checking"), Te = te ?? c.error, Ee = Te !== void 0 && le(Te).length > 0 ? void 0 : Te, De = Object.keys(de).length, Oe = (() => {
1613
+ for (let e of u) if (de[e.name] !== void 0) return e.name;
1614
+ let e = Object.keys(de);
1582
1615
  return e.length > 0 ? e[0] : void 0;
1583
- })(), Ee = {
1584
- isDirty: !ae && P.isDirty,
1585
- isPristine: P.isPristine,
1586
- isTouched: P.isTouched,
1587
- isValid: H,
1588
- isValidating: U,
1589
- canSubmit: H && !U && !P.isSubmitting && !ae,
1590
- isSubmitting: P.isSubmitting,
1591
- isSubmitted: P.isSubmitted,
1592
- isSubmitSuccessful: P.isSubmitSuccessful && C.current !== void 0,
1593
- submissionAttempts: P.submissionAttempts,
1594
- errorCount: we,
1595
- firstInvalidPath: Te,
1596
- pending: a.pending,
1616
+ })(), ke = {
1617
+ isDirty: !ae && I.isDirty,
1618
+ isPristine: I.isPristine,
1619
+ isTouched: I.isTouched,
1620
+ isValid: Ce,
1621
+ isValidating: we,
1622
+ canSubmit: Ce && !we && !I.isSubmitting && !ae,
1623
+ isSubmitting: I.isSubmitting,
1624
+ isSubmitted: I.isSubmitted,
1625
+ isSubmitSuccessful: I.isSubmitSuccessful && A.current !== void 0,
1626
+ submissionAttempts: I.submissionAttempts,
1627
+ errorCount: De,
1628
+ firstInvalidPath: Oe,
1629
+ pending: c.pending,
1597
1630
  isLoading: ae,
1598
- submitError: Ce,
1599
- data: a.data
1600
- }, De = {
1601
- fields: s,
1602
- values: N,
1603
- errors: ue,
1604
- issues: F,
1605
- isValid: H,
1606
- pending: a.pending,
1607
- submitError: Ce,
1608
- formError: v,
1609
- data: a.data,
1610
- setValue: _e,
1611
- setValues: ve,
1612
- reset: B,
1631
+ submitError: Ee,
1632
+ data: c.data
1633
+ }, Ae = {
1634
+ fields: u,
1635
+ values: F,
1636
+ errors: de,
1637
+ issues: L,
1638
+ isValid: Ce,
1639
+ pending: c.pending,
1640
+ submitError: Ee,
1641
+ formError: C,
1642
+ data: c.data,
1643
+ setValue: H,
1644
+ setValues: _e,
1645
+ reset: ve,
1613
1646
  submit: Se,
1614
- field: fe,
1647
+ field: V,
1615
1648
  array: he,
1616
1649
  section: ge,
1617
- state: Ee,
1650
+ state: ke,
1618
1651
  focusFirstInvalid: xe
1619
1652
  };
1620
- return Object.defineProperty(De, xn, {
1653
+ return Object.defineProperty(Ae, xn, {
1621
1654
  value: {
1622
- store: ie.store,
1623
- field: fe
1655
+ store: M.store,
1656
+ field: V
1624
1657
  },
1625
1658
  enumerable: !1
1626
- }), De;
1627
- }, On = (e) => C(Sn.Provider, { value: e.binding }, e.children), kn = () => T(Sn);
1659
+ }), Ae;
1660
+ }, On = (e) => w(Sn.Provider, { value: e.binding }, e.children), kn = () => te(Sn);
1628
1661
  function An(e, t) {
1629
- let n = T(Sn), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
1662
+ let n = te(Sn), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
1630
1663
  if (a === void 0) throw Error("useFormField(path) found no form binding — mount <FormBindingProvider binding={form}> above this field, or call useFormField(form, path) with the binding in hand.");
1631
1664
  let o = a[xn];
1632
1665
  if (o === void 0) throw Error("useFormField: not a useFormBinding result");
1633
- return me(o.store, (e) => {
1666
+ return pe(o.store, (e) => {
1634
1667
  let t = e.fieldMetaBase[i];
1635
1668
  return `${JSON.stringify(Cn(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
1636
1669
  }), o.field(i);
1637
1670
  }
1638
1671
  //#endregion
1639
1672
  //#region src/createHooks.ts
1640
- var jn = J, Mn = (e) => ({
1673
+ var jn = q, Mn = (e) => ({
1641
1674
  useSubscription: (t, n, r) => jn(e, t, n, r),
1642
1675
  useMutation: (t) => Z(e, t),
1643
1676
  useAction: (t) => _n(e, t),
@@ -1649,14 +1682,14 @@ var jn = J, Mn = (e) => ({
1649
1682
  if (i === null) throw Error(`seedPreloadedSubscription('${e}', '${t}') was called outside a server render. Preload seeds exist to put a subscription's first value into the SSR hydration payload; on the client the live subscription already provides it. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
1650
1683
  i.seeds.push({
1651
1684
  api: e,
1652
- key: B([t, n]),
1685
+ key: H([t, n]),
1653
1686
  value: r
1654
1687
  });
1655
1688
  }, zn = (e, t, n) => {
1656
1689
  let r = Pn?.() ?? null;
1657
1690
  r !== null && r.seeds.push({
1658
1691
  api: e,
1659
- key: B([t, n]),
1692
+ key: H([t, n]),
1660
1693
  value: void 0,
1661
1694
  failed: !0
1662
1695
  });
@@ -1666,7 +1699,7 @@ var jn = J, Mn = (e) => ({
1666
1699
  failed: t.failed === !0
1667
1700
  });
1668
1701
  }, Vn = (e, t, n) => {
1669
- let r = B([t, n]), i = Pn?.() ?? null;
1702
+ let r = H([t, n]), i = Pn?.() ?? null;
1670
1703
  if (i !== null) {
1671
1704
  for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? void 0 : t.value;
1672
1705
  return;
@@ -1674,7 +1707,7 @@ var jn = J, Mn = (e) => ({
1674
1707
  let a = In.get(Ln(e, r));
1675
1708
  return a === void 0 || a.failed ? void 0 : a.value;
1676
1709
  }, Hn = (e, t, n) => {
1677
- let r = B([t, n]), i = Pn?.() ?? null;
1710
+ let r = H([t, n]), i = Pn?.() ?? null;
1678
1711
  if (i !== null) {
1679
1712
  for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? "failed" : "seeded";
1680
1713
  return "absent";
@@ -1687,7 +1720,7 @@ var jn = J, Mn = (e) => ({
1687
1720
  //#endregion
1688
1721
  //#region src/usePreloadedSubscription.ts
1689
1722
  function Wn(e, t, n = {}, r = {}) {
1690
- let i = Vn(e, t, n), a = J(e, t, n, i === void 0 ? r : {
1723
+ let i = Vn(e, t, n), a = q(e, t, n, i === void 0 ? r : {
1691
1724
  ...r,
1692
1725
  initialSnapshot: i
1693
1726
  });
@@ -1706,7 +1739,7 @@ var Gn = {
1706
1739
  _tag = "EventStreamClosed";
1707
1740
  };
1708
1741
  function qn(e, t, n, r = {}) {
1709
- let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s = K(a), { runtime: c, client: l } = s, [u, d] = k(Gn), f = O(n);
1742
+ let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s = G(a), { runtime: c, client: l } = s, [u, d] = k(Gn), f = O(n);
1710
1743
  f.current = n;
1711
1744
  let p = O(o);
1712
1745
  p.current = o;
@@ -1718,7 +1751,7 @@ function qn(e, t, n, r = {}) {
1718
1751
  v.current = t;
1719
1752
  let y = O(null);
1720
1753
  y.current !== _ && (y.current = _, g.current = /* @__PURE__ */ new Map());
1721
- let b = w((e, t) => {
1754
+ let b = T((e, t) => {
1722
1755
  e <= 0 || (d((n) => ({
1723
1756
  ...n,
1724
1757
  missed: n.missed + e,
@@ -1730,7 +1763,7 @@ function qn(e, t, n, r = {}) {
1730
1763
  count: e,
1731
1764
  reason: t
1732
1765
  }));
1733
- }, []), x = !i && _ !== null && !Ke(s);
1766
+ }, []), x = !i && _ !== null && !qe(s);
1734
1767
  return E(() => {
1735
1768
  if (!x) {
1736
1769
  d(Gn);
@@ -1745,18 +1778,18 @@ function qn(e, t, n, r = {}) {
1745
1778
  origin: e,
1746
1779
  n: t
1747
1780
  }));
1748
- return q(m.current, e.name)({
1781
+ return K(m.current, e.name)({
1749
1782
  key: v.current,
1750
1783
  ...t.length > 0 ? { resume: t } : {}
1751
1784
  });
1752
- }), r = L.unwrap(n).pipe(L.tap(() => M.sync(() => {
1785
+ }), r = R.unwrap(n).pipe(R.tap(() => M.sync(() => {
1753
1786
  t = 0;
1754
- })), L.concat(L.fail(new Kn())), L.retry(I.exponential("250 millis", 2).pipe(I.either(I.spaced("30 seconds")), I.jittered, I.tapOutput(() => M.sync(() => {
1787
+ })), R.concat(R.fail(new Kn())), R.retry(L.exponential("250 millis", 2).pipe(L.either(L.spaced("30 seconds")), L.jittered, L.tapOutput(() => M.sync(() => {
1755
1788
  t += 1, d((e) => ({
1756
1789
  ...e,
1757
1790
  status: "connecting"
1758
1791
  }));
1759
- }))))), i = h.current.runFork(L.runForEach(r, (e) => M.sync(() => {
1792
+ }))))), i = h.current.runFork(R.runForEach(r, (e) => M.sync(() => {
1760
1793
  if (e._tag === "attached") {
1761
1794
  d((e) => ({
1762
1795
  ...e,
@@ -1857,7 +1890,7 @@ var Jn = () => {
1857
1890
  }, Xn = (e = {}) => {
1858
1891
  let [t, n] = k(!1), [r, i] = k(void 0), [a, o] = k(void 0), s = O(e);
1859
1892
  return s.current = e, {
1860
- run: w(async (e, t = {}) => {
1893
+ run: T(async (e, t = {}) => {
1861
1894
  n(!0), i(void 0), o(void 0);
1862
1895
  try {
1863
1896
  let n = await Yn(e, {
@@ -1933,141 +1966,142 @@ var Jn = () => {
1933
1966
  }
1934
1967
  i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
1935
1968
  }), nr = (e, t = {}) => {
1936
- let { runtime: n, client: r, inspectBaseUrl: i, errorBus: a } = K(e), [o, s] = k(0), [c, l] = k("idle"), [u, d] = k(void 0), f = O(null), p = w(() => {
1969
+ let n = G(e), { inspectBaseUrl: r, errorBus: i } = n, a = O(n);
1970
+ a.current = n;
1971
+ let [o, s] = k(0), [c, l] = k("idle"), [u, d] = k(void 0), f = O(null), p = T(() => {
1937
1972
  s(0), l("idle"), d(void 0);
1938
- }, []), m = w(() => {
1973
+ }, []), m = T(() => {
1939
1974
  f.current?.abort();
1940
- }, []), h = w((e) => /^https?:\/\//.test(e) ? e : `${i}${e}`, [i]), g = w(async (e, i, a, o) => {
1941
- let s = Math.max(0, i.retries ?? t.retries ?? 1), c = (e instanceof File, e.type || "application/octet-stream"), l = e instanceof File ? e.name : "blob", u = i.visibility ?? t.visibility, d = i.key ?? t.key, f = i.folder ?? t.folder, p = i.tags ?? t.tags, m = {
1942
- ...u ? { visibility: u } : {},
1943
- ...f ? { folder: f } : {},
1944
- ...p ? { tags: p } : {},
1945
- ...i.alt ? { alt: i.alt } : {},
1946
- ...i.caption ? { caption: i.caption } : {}
1947
- }, g = (e) => ({
1975
+ }, []), h = T((e) => /^https?:\/\//.test(e) ? e : `${r}${e}`, [r]), g = T(async (n, r, i, o) => {
1976
+ let { runtime: s, client: c } = await J(a, e, "storage.upload"), l = Math.max(0, r.retries ?? t.retries ?? 1), u = (n instanceof File, n.type || "application/octet-stream"), d = n instanceof File ? n.name : "blob", f = r.visibility ?? t.visibility, p = r.key ?? t.key, m = r.folder ?? t.folder, g = r.tags ?? t.tags, _ = {
1977
+ ...f ? { visibility: f } : {},
1978
+ ...m ? { folder: m } : {},
1979
+ ...g ? { tags: g } : {},
1980
+ ...r.alt ? { alt: r.alt } : {},
1981
+ ...r.caption ? { caption: r.caption } : {}
1982
+ }, v = (e) => ({
1948
1983
  id: e.id,
1949
1984
  url: h(e.url),
1950
- name: l,
1985
+ name: d,
1951
1986
  mime: e.contentType,
1952
1987
  size: e.size,
1953
1988
  ...e.width === void 0 ? {} : { width: e.width },
1954
1989
  ...e.height === void 0 ? {} : { height: e.height }
1955
- }), _ = async () => {
1956
- let s = i.mintTag ?? t.mintTag ?? Q("mintUploadTicket"), l = q(r, s), u = await Y(n, l({
1957
- contentType: c,
1958
- ...m,
1959
- ...d ? { key: d } : {}
1960
- })), f = await tr(h(u.uploadUrl), c, e, o, a);
1961
- return g(f);
1962
- }, v = async () => {
1963
- let s = i.presignMintTag ?? t.presignMintTag ?? Q("mintPresignedUpload"), l = i.finalizeTag ?? t.finalizeTag ?? Q("finalizeUpload"), u;
1990
+ }), y = async () => {
1991
+ let e = r.mintTag ?? t.mintTag ?? Q("mintUploadTicket"), a = K(c, e), l = await Y(s, a({
1992
+ contentType: u,
1993
+ ..._,
1994
+ ...p ? { key: p } : {}
1995
+ })), d = await tr(h(l.uploadUrl), u, n, o, i);
1996
+ return v(d);
1997
+ }, b = async () => {
1998
+ let e = r.presignMintTag ?? t.presignMintTag ?? Q("mintPresignedUpload"), a = r.finalizeTag ?? t.finalizeTag ?? Q("finalizeUpload"), l;
1964
1999
  try {
1965
- let e = q(r, s);
1966
- u = await Y(n, e({
1967
- contentType: c,
1968
- ...m
2000
+ let t = K(c, e);
2001
+ l = await Y(s, t({
2002
+ contentType: u,
2003
+ ..._
1969
2004
  }));
1970
2005
  } catch {
1971
2006
  return null;
1972
2007
  }
1973
- await er(u.uploadUrl, c, e, o, a);
1974
- let d = q(r, l), f = await Y(n, d({ finalizeToken: u.finalizeToken }));
1975
- return g(f);
1976
- }, y = async () => {
1977
- let s = i.beginResumableTag ?? t.beginResumableTag ?? Q("beginResumableUpload"), l = q(r, s), u = e.size, d = i.chunkSize ?? t.chunkSize, f = await Y(n, l({
1978
- contentType: c,
1979
- size: u,
1980
- ...m,
2008
+ await er(l.uploadUrl, u, n, o, i);
2009
+ let d = K(c, a), f = await Y(s, d({ finalizeToken: l.finalizeToken }));
2010
+ return v(f);
2011
+ }, x = async () => {
2012
+ let e = r.beginResumableTag ?? t.beginResumableTag ?? Q("beginResumableUpload"), a = K(c, e), l = n.size, d = r.chunkSize ?? t.chunkSize, f = await Y(s, a({
2013
+ contentType: u,
2014
+ size: l,
2015
+ ..._,
1981
2016
  ...d ? { chunkSize: d } : {}
1982
- })), p = h(f.uploadUrl), _ = Math.max(1, f.chunkSize), v = Math.max(1, Math.ceil(u / _)), y = Math.max(0, i.retries ?? t.retries ?? 1), b = 0, x = null;
1983
- for (let t = 0; t < v; t++) {
1984
- let n = t * _, r = Math.min(u, n + _), i = e.slice(n, r), s = t === v - 1, l = r - n, d = 0;
2017
+ })), p = h(f.uploadUrl), m = Math.max(1, f.chunkSize), g = Math.max(1, Math.ceil(l / m)), y = Math.max(0, r.retries ?? t.retries ?? 1), b = 0, x = null;
2018
+ for (let e = 0; e < g; e++) {
2019
+ let t = e * m, r = Math.min(l, t + m), a = n.slice(t, r), s = e === g - 1, c = r - t, d = 0;
1985
2020
  for (;;) {
1986
- if (a.aborted) throw new DOMException("upload aborted", "AbortError");
2021
+ if (i.aborted) throw new DOMException("upload aborted", "AbortError");
1987
2022
  try {
1988
- let e = await $n(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${t}${s ? "&final=1" : ""}`}`, c, i, (e) => o((b + e * l) / u), a, s);
1989
- s && (x = e);
2023
+ let t = await $n(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${e}${s ? "&final=1" : ""}`}`, u, a, (e) => o((b + e * c) / l), i, s);
2024
+ s && (x = t);
1990
2025
  break;
1991
2026
  } catch (e) {
1992
2027
  if (e instanceof DOMException && e.name === "AbortError" || d++ >= y) throw e;
1993
2028
  }
1994
2029
  }
1995
- b += l, o(b / u);
2030
+ b += c, o(b / l);
1996
2031
  }
1997
2032
  if (!x) throw Error("resumable upload produced no final reply");
1998
- return g(x);
1999
- }, b = async () => {
2000
- let s = i.multipartBeginTag ?? t.multipartBeginTag ?? Q("beginMultipartUpload"), u = i.multipartSignTag ?? t.multipartSignTag ?? Q("signMultipartPart"), d = i.multipartCompleteTag ?? t.multipartCompleteTag ?? Q("completeMultipartUpload"), f = i.multipartAbortTag ?? t.multipartAbortTag ?? Q("abortMultipartUpload"), p = e.size, g = i.chunkSize ?? t.chunkSize, _;
2033
+ return v(x);
2034
+ }, S = async () => {
2035
+ let e = r.multipartBeginTag ?? t.multipartBeginTag ?? Q("beginMultipartUpload"), a = r.multipartSignTag ?? t.multipartSignTag ?? Q("signMultipartPart"), l = r.multipartCompleteTag ?? t.multipartCompleteTag ?? Q("completeMultipartUpload"), f = r.multipartAbortTag ?? t.multipartAbortTag ?? Q("abortMultipartUpload"), p = n.size, m = r.chunkSize ?? t.chunkSize, g;
2001
2036
  try {
2002
- let e = q(r, s);
2003
- _ = await Y(n, e({
2004
- contentType: c,
2037
+ let t = K(c, e);
2038
+ g = await Y(s, t({
2039
+ contentType: u,
2005
2040
  size: p,
2006
- ...m,
2007
- ...g ? { partSize: g } : {}
2041
+ ..._,
2042
+ ...m ? { partSize: m } : {}
2008
2043
  }));
2009
2044
  } catch {
2010
2045
  return null;
2011
2046
  }
2012
- let v = q(r, u), y = q(r, d), b = q(r, f), x = Math.max(1, _.partSize), ee = Math.max(1, Math.ceil(p / x)), te = Math.max(0, i.retries ?? t.retries ?? 1), S = [], C = 0;
2047
+ let v = K(c, a), y = K(c, l), b = K(c, f), x = Math.max(1, g.partSize), S = Math.max(1, Math.ceil(p / x)), ee = Math.max(0, r.retries ?? t.retries ?? 1), C = [], w = 0;
2013
2048
  try {
2014
- for (let t = 0; t < ee; t++) {
2015
- let r = t * x, i = Math.min(p, r + x), s = e.slice(r, i), c = t + 1, l = i - r, u = 0;
2049
+ for (let e = 0; e < S; e++) {
2050
+ let t = e * x, r = Math.min(p, t + x), a = n.slice(t, r), c = e + 1, l = r - t, u = 0;
2016
2051
  for (;;) {
2017
- if (a.aborted) throw new DOMException("upload aborted", "AbortError");
2052
+ if (i.aborted) throw new DOMException("upload aborted", "AbortError");
2018
2053
  try {
2019
- let { url: e } = await Y(n, v({
2020
- multipartToken: _.multipartToken,
2054
+ let { url: e } = await Y(s, v({
2055
+ multipartToken: g.multipartToken,
2021
2056
  partNumber: c
2022
- })), t = await Qn(e, s, (e) => o((C + e * l) / p), a);
2023
- S.push({
2057
+ })), t = await Qn(e, a, (e) => o((w + e * l) / p), i);
2058
+ C.push({
2024
2059
  partNumber: c,
2025
2060
  etag: t
2026
2061
  });
2027
2062
  break;
2028
2063
  } catch (e) {
2029
- if (e instanceof DOMException && e.name === "AbortError" || u++ >= te) throw e;
2064
+ if (e instanceof DOMException && e.name === "AbortError" || u++ >= ee) throw e;
2030
2065
  }
2031
2066
  }
2032
- C += l, o(C / p);
2067
+ w += l, o(w / p);
2033
2068
  }
2034
- let t = await Y(n, y({
2035
- multipartToken: _.multipartToken,
2036
- parts: S
2069
+ let e = await Y(s, y({
2070
+ multipartToken: g.multipartToken,
2071
+ parts: C
2037
2072
  }));
2038
2073
  return {
2039
- id: t.id,
2040
- url: h(t.url),
2041
- name: l,
2042
- mime: c,
2043
- size: t.size
2074
+ id: e.id,
2075
+ url: h(e.url),
2076
+ name: d,
2077
+ mime: u,
2078
+ size: e.size
2044
2079
  };
2045
2080
  } catch (e) {
2046
2081
  try {
2047
- await Y(n, b({ multipartToken: _.multipartToken }));
2082
+ await Y(s, b({ multipartToken: g.multipartToken }));
2048
2083
  } catch {}
2049
2084
  throw e;
2050
2085
  }
2051
2086
  };
2052
- if ((i.prefer ?? t.prefer) === "multipart") return await b() || await y();
2053
- if ((i.prefer ?? t.prefer) === "resumable") return await y();
2054
- let x = (i.prefer ?? t.prefer) === "presign", ee;
2055
- for (let e = 0; e <= s; e++) {
2056
- if (a.aborted) throw new DOMException("upload aborted", "AbortError");
2087
+ if ((r.prefer ?? t.prefer) === "multipart") return await S() || await x();
2088
+ if ((r.prefer ?? t.prefer) === "resumable") return await x();
2089
+ let ee = (r.prefer ?? t.prefer) === "presign", C;
2090
+ for (let e = 0; e <= l; e++) {
2091
+ if (i.aborted) throw new DOMException("upload aborted", "AbortError");
2057
2092
  try {
2058
- if (x) {
2059
- let e = await v();
2093
+ if (ee) {
2094
+ let e = await b();
2060
2095
  if (e) return e;
2061
2096
  }
2062
- return await _();
2097
+ return await y();
2063
2098
  } catch (t) {
2064
- if (t instanceof DOMException && t.name === "AbortError" || (ee = t, e === s)) throw t;
2099
+ if (t instanceof DOMException && t.name === "AbortError" || (C = t, e === l)) throw t;
2065
2100
  }
2066
2101
  }
2067
- throw ee;
2102
+ throw C;
2068
2103
  }, [
2069
- n,
2070
- r,
2104
+ e,
2071
2105
  h,
2072
2106
  t.mintTag,
2073
2107
  t.presignMintTag,
@@ -2084,14 +2118,14 @@ var Jn = () => {
2084
2118
  t.folder,
2085
2119
  t.tags,
2086
2120
  t.retries
2087
- ]), _ = w(async (e, n = {}) => {
2121
+ ]), _ = T(async (e, n = {}) => {
2088
2122
  let r = new AbortController();
2089
2123
  f.current = r, l("uploading"), d(void 0), s(0);
2090
2124
  try {
2091
2125
  let t = await g(e, n, r.signal, s);
2092
2126
  return s(1), l("success"), t;
2093
2127
  } catch (e) {
2094
- throw l("error"), d(e), e instanceof DOMException && e.name === "AbortError" || a.emit({
2128
+ throw l("error"), d(e), e instanceof DOMException && e.name === "AbortError" || i.emit({
2095
2129
  source: "action",
2096
2130
  tag: n.mintTag ?? t.mintTag ?? Q("mintUploadTicket"),
2097
2131
  error: e
@@ -2099,13 +2133,13 @@ var Jn = () => {
2099
2133
  }
2100
2134
  }, [
2101
2135
  g,
2102
- a,
2136
+ i,
2103
2137
  t.mintTag
2104
- ]), v = w(async (e, n = {}) => {
2138
+ ]), v = T(async (e, n = {}) => {
2105
2139
  if (e.length === 0) return [];
2106
2140
  let r = new AbortController();
2107
2141
  f.current = r, l("uploading"), d(void 0), s(0);
2108
- let i = Math.max(1, n.concurrency ?? t.concurrency ?? 3), o = Array(e.length), c = Array(e.length).fill(0), u = () => s(c.reduce((e, t) => e + t, 0) / e.length), p = 0, m = async () => {
2142
+ let a = Math.max(1, n.concurrency ?? t.concurrency ?? 3), o = Array(e.length), c = Array(e.length).fill(0), u = () => s(c.reduce((e, t) => e + t, 0) / e.length), p = 0, m = async () => {
2109
2143
  for (;;) {
2110
2144
  let t = p++;
2111
2145
  if (t >= e.length) return;
@@ -2115,9 +2149,9 @@ var Jn = () => {
2115
2149
  }
2116
2150
  };
2117
2151
  try {
2118
- return await Promise.all(Array.from({ length: Math.min(i, e.length) }, () => m())), s(1), l("success"), o;
2152
+ return await Promise.all(Array.from({ length: Math.min(a, e.length) }, () => m())), s(1), l("success"), o;
2119
2153
  } catch (e) {
2120
- throw r.abort(), l("error"), d(e), e instanceof DOMException && e.name === "AbortError" || a.emit({
2154
+ throw r.abort(), l("error"), d(e), e instanceof DOMException && e.name === "AbortError" || i.emit({
2121
2155
  source: "action",
2122
2156
  tag: n.mintTag ?? t.mintTag ?? Q("mintUploadTicket"),
2123
2157
  error: e
@@ -2125,14 +2159,14 @@ var Jn = () => {
2125
2159
  }
2126
2160
  }, [
2127
2161
  g,
2128
- a,
2162
+ i,
2129
2163
  t.concurrency,
2130
2164
  t.mintTag
2131
- ]), y = w((e, t = {}) => {
2165
+ ]), y = T((e, t = {}) => {
2132
2166
  e.preventDefault();
2133
2167
  let n = e.dataTransfer ? Array.from(e.dataTransfer.files) : [];
2134
2168
  return n.length ? v(n, t) : Promise.resolve([]);
2135
- }, [v]), b = w((e, t = {}) => {
2169
+ }, [v]), b = T((e, t = {}) => {
2136
2170
  let n = e.clipboardData ? Array.from(e.clipboardData.files) : [];
2137
2171
  return n.length ? v(n, t) : Promise.resolve([]);
2138
2172
  }, [v]), x = D(() => ({
@@ -2165,8 +2199,8 @@ var Jn = () => {
2165
2199
  x
2166
2200
  ]);
2167
2201
  }, $ = async (e) => {
2168
- let t = q(e.client, e.tag), n = M.currentSpan.pipe(M.tap((t) => M.sync(() => {
2169
- _e({
2202
+ let t = K(e.client, e.tag), n = M.currentSpan.pipe(M.tap((t) => M.sync(() => {
2203
+ he({
2170
2204
  traceId: t.traceId,
2171
2205
  spanId: t.spanId,
2172
2206
  source: "mutation",
@@ -2178,34 +2212,30 @@ var Jn = () => {
2178
2212
  } }));
2179
2213
  return Y(e.runtime, n);
2180
2214
  }, rr = (e, t) => {
2181
- let { runtime: n, client: r, descriptors: i } = K(e);
2182
- if (process.env.NODE_ENV !== "production") {
2183
- let n = i[t]?.kind;
2215
+ let n = G(e), { descriptors: r } = n, i = O(n);
2216
+ if (i.current = n, process.env.NODE_ENV !== "production") {
2217
+ let n = r[t]?.kind;
2184
2218
  n !== void 0 && n !== "workflow" && console.error(`[@voltro/client] useWorkflow('${e}', '${t}') targets a ${n}, not a workflow. Use ${n === "mutation" ? "useMutation" : n === "action" ? "useAction" : `the ${n} hook`} instead.`);
2185
2219
  }
2186
- let [a, o] = k(!1), [s, c] = k(void 0), [l, u] = k(void 0), d = w(async (i) => {
2220
+ let [a, o] = k(!1), [s, c] = k(void 0), [l, u] = k(void 0), d = T(async (n) => {
2187
2221
  o(!0), c(void 0);
2188
2222
  try {
2189
- let a = await $({
2223
+ let { runtime: r, client: a } = await J(i, e, t), o = await $({
2190
2224
  apiName: e,
2191
- runtime: n,
2192
- client: r,
2225
+ runtime: r,
2226
+ client: a,
2193
2227
  tag: t,
2194
- input: i,
2228
+ input: n,
2195
2229
  spanPrefix: "client.workflow.start"
2196
2230
  });
2197
- return u(a), a;
2231
+ return u(o), o;
2198
2232
  } catch (e) {
2199
2233
  throw c(e), e;
2200
2234
  } finally {
2201
2235
  o(!1);
2202
2236
  }
2203
- }, [
2204
- e,
2205
- n,
2206
- r,
2207
- t
2208
- ]), f = w(async (t) => {
2237
+ }, [e, t]), f = T(async (t) => {
2238
+ let { runtime: n, client: r } = await J(i, e, "__voltro.workflow.cancel");
2209
2239
  await $({
2210
2240
  apiName: e,
2211
2241
  runtime: n,
@@ -2214,11 +2244,8 @@ var Jn = () => {
2214
2244
  input: t,
2215
2245
  spanPrefix: "client.workflow.cancel"
2216
2246
  });
2217
- }, [
2218
- e,
2219
- n,
2220
- r
2221
- ]), p = w(async (t) => {
2247
+ }, [e]), p = T(async (t) => {
2248
+ let { runtime: n, client: r } = await J(i, e, "__voltro.workflow.resume");
2222
2249
  await $({
2223
2250
  apiName: e,
2224
2251
  runtime: n,
@@ -2227,42 +2254,36 @@ var Jn = () => {
2227
2254
  input: t,
2228
2255
  spanPrefix: "client.workflow.resume"
2229
2256
  });
2230
- }, [
2231
- e,
2232
- n,
2233
- r
2234
- ]), m = w(async (t, i, a) => $({
2235
- apiName: e,
2236
- runtime: n,
2237
- client: r,
2238
- tag: "__voltro.workflow.signal",
2239
- input: {
2240
- id: t.id,
2241
- signalName: i,
2242
- ...a === void 0 ? {} : { payload: a }
2243
- },
2244
- spanPrefix: "client.workflow.signal"
2245
- }), [
2246
- e,
2247
- n,
2248
- r
2249
- ]), h = w(async (t, i, a, o) => $({
2250
- apiName: e,
2251
- runtime: n,
2252
- client: r,
2253
- tag: "__voltro.workflow.update",
2254
- input: {
2255
- id: t.id,
2256
- updateName: i,
2257
- ...a === void 0 ? {} : { payload: a },
2258
- ...o?.timeoutMs === void 0 ? {} : { timeoutMs: o.timeoutMs }
2259
- },
2260
- spanPrefix: "client.workflow.update"
2261
- }), [
2262
- e,
2263
- n,
2264
- r
2265
- ]);
2257
+ }, [e]), m = T(async (t, n, r) => {
2258
+ let { runtime: a, client: o } = await J(i, e, "__voltro.workflow.signal");
2259
+ return $({
2260
+ apiName: e,
2261
+ runtime: a,
2262
+ client: o,
2263
+ tag: "__voltro.workflow.signal",
2264
+ input: {
2265
+ id: t.id,
2266
+ signalName: n,
2267
+ ...r === void 0 ? {} : { payload: r }
2268
+ },
2269
+ spanPrefix: "client.workflow.signal"
2270
+ });
2271
+ }, [e]), h = T(async (t, n, r, a) => {
2272
+ let { runtime: o, client: s } = await J(i, e, "__voltro.workflow.update");
2273
+ return $({
2274
+ apiName: e,
2275
+ runtime: o,
2276
+ client: s,
2277
+ tag: "__voltro.workflow.update",
2278
+ input: {
2279
+ id: t.id,
2280
+ updateName: n,
2281
+ ...r === void 0 ? {} : { payload: r },
2282
+ ...a?.timeoutMs === void 0 ? {} : { timeoutMs: a.timeoutMs }
2283
+ },
2284
+ spanPrefix: "client.workflow.update"
2285
+ });
2286
+ }, [e]);
2266
2287
  return D(() => ({
2267
2288
  start: d,
2268
2289
  cancel: f,
@@ -2283,32 +2304,30 @@ var Jn = () => {
2283
2304
  l
2284
2305
  ]);
2285
2306
  }, ir = (e) => {
2286
- let { runtime: t, client: n } = K(e), [r, i] = k(!1), [a, o] = k(void 0), [s, c] = k(void 0), l = w(async (r, a, s) => {
2307
+ let t = G(e), n = O(t);
2308
+ n.current = t;
2309
+ let [r, i] = k(!1), [a, o] = k(void 0), [s, c] = k(void 0), l = T(async (t, r, a) => {
2287
2310
  i(!0), o(void 0);
2288
2311
  try {
2289
- let i = await $({
2312
+ let { runtime: i, client: o } = await J(n, e, "__voltro.workflow.signal"), s = await $({
2290
2313
  apiName: e,
2291
- runtime: t,
2292
- client: n,
2314
+ runtime: i,
2315
+ client: o,
2293
2316
  tag: "__voltro.workflow.signal",
2294
2317
  input: {
2295
- id: r.id,
2296
- signalName: a,
2297
- ...s === void 0 ? {} : { payload: s }
2318
+ id: t.id,
2319
+ signalName: r,
2320
+ ...a === void 0 ? {} : { payload: a }
2298
2321
  },
2299
2322
  spanPrefix: "client.workflow.signal"
2300
2323
  });
2301
- return c(i), i;
2324
+ return c(s), s;
2302
2325
  } catch (e) {
2303
2326
  throw o(e), e;
2304
2327
  } finally {
2305
2328
  i(!1);
2306
2329
  }
2307
- }, [
2308
- e,
2309
- t,
2310
- n
2311
- ]);
2330
+ }, [e]);
2312
2331
  return D(() => ({
2313
2332
  signal: l,
2314
2333
  pending: r,
@@ -2321,33 +2340,31 @@ var Jn = () => {
2321
2340
  s
2322
2341
  ]);
2323
2342
  }, ar = (e) => {
2324
- let { runtime: t, client: n } = K(e), [r, i] = k(!1), [a, o] = k(void 0), [s, c] = k(void 0), l = w(async (r, a, s, l) => {
2343
+ let t = G(e), n = O(t);
2344
+ n.current = t;
2345
+ let [r, i] = k(!1), [a, o] = k(void 0), [s, c] = k(void 0), l = T(async (t, r, a, s) => {
2325
2346
  i(!0), o(void 0);
2326
2347
  try {
2327
- let i = await $({
2348
+ let { runtime: i, client: o } = await J(n, e, "__voltro.workflow.update"), l = await $({
2328
2349
  apiName: e,
2329
- runtime: t,
2330
- client: n,
2350
+ runtime: i,
2351
+ client: o,
2331
2352
  tag: "__voltro.workflow.update",
2332
2353
  input: {
2333
- id: r.id,
2334
- updateName: a,
2335
- ...s === void 0 ? {} : { payload: s },
2336
- ...l?.timeoutMs === void 0 ? {} : { timeoutMs: l.timeoutMs }
2354
+ id: t.id,
2355
+ updateName: r,
2356
+ ...a === void 0 ? {} : { payload: a },
2357
+ ...s?.timeoutMs === void 0 ? {} : { timeoutMs: s.timeoutMs }
2337
2358
  },
2338
2359
  spanPrefix: "client.workflow.update"
2339
2360
  });
2340
- return c(i), i;
2361
+ return c(l), l;
2341
2362
  } catch (e) {
2342
2363
  throw o(e), e;
2343
2364
  } finally {
2344
2365
  i(!1);
2345
2366
  }
2346
- }, [
2347
- e,
2348
- t,
2349
- n
2350
- ]);
2367
+ }, [e]);
2351
2368
  return D(() => ({
2352
2369
  update: l,
2353
2370
  pending: r,
@@ -2360,7 +2377,7 @@ var Jn = () => {
2360
2377
  s
2361
2378
  ]);
2362
2379
  }, or = (e, t) => {
2363
- let n = J(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
2380
+ let n = q(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
2364
2381
  return n.loading || n.idle || n.failed ? {
2365
2382
  ...n,
2366
2383
  run: void 0
@@ -2369,7 +2386,7 @@ var Jn = () => {
2369
2386
  run: n.data[0]
2370
2387
  };
2371
2388
  }, sr = (e, t = {}, n = {}) => {
2372
- let r = J(e, "__voltro.workflow.runs", t, n);
2389
+ let r = q(e, "__voltro.workflow.runs", t, n);
2373
2390
  return r.loading || r.idle || r.failed ? {
2374
2391
  ...r,
2375
2392
  runs: []
@@ -2378,7 +2395,7 @@ var Jn = () => {
2378
2395
  runs: r.data
2379
2396
  };
2380
2397
  }, cr = (e, t) => {
2381
- let n = J(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
2398
+ let n = q(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
2382
2399
  return n.loading || n.idle || n.failed ? {
2383
2400
  ...n,
2384
2401
  steps: []
@@ -2387,7 +2404,7 @@ var Jn = () => {
2387
2404
  steps: n.data
2388
2405
  };
2389
2406
  }, lr = (e, t) => {
2390
- let n = J(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
2407
+ let n = q(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
2391
2408
  return n.loading || n.idle || n.failed ? {
2392
2409
  ...n,
2393
2410
  events: []
@@ -2396,7 +2413,7 @@ var Jn = () => {
2396
2413
  events: n.data
2397
2414
  };
2398
2415
  }, ur = lr, dr = (e, t = {}, n = {}) => {
2399
- let r = J(e, "__voltro.workflow.domainEvents", t, n);
2416
+ let r = q(e, "__voltro.workflow.domainEvents", t, n);
2400
2417
  return r.loading || r.idle || r.failed ? {
2401
2418
  ...r,
2402
2419
  events: []
@@ -2405,7 +2422,7 @@ var Jn = () => {
2405
2422
  events: r.data
2406
2423
  };
2407
2424
  }, fr = (e, t) => {
2408
- let n = J(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
2425
+ let n = q(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
2409
2426
  return n.loading || n.idle || n.failed ? {
2410
2427
  ...n,
2411
2428
  deliveries: []
@@ -2457,22 +2474,22 @@ var Jn = () => {
2457
2474
  step: n?.stepName
2458
2475
  };
2459
2476
  }, vr = (e, t) => {
2460
- let n = or(e, t), r = cr(e, t), i = lr(e, t), a = rr(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = w(async () => {
2477
+ let n = or(e, t), r = cr(e, t), i = lr(e, t), a = rr(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = T(async () => {
2461
2478
  if (!o) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
2462
2479
  await a.cancel({
2463
2480
  workflowName: o.tag,
2464
2481
  executionId: o.executionId
2465
2482
  });
2466
- }, [a, o]), u = w(async () => {
2483
+ }, [a, o]), u = T(async () => {
2467
2484
  if (!o) throw Error("useWorkflowRunState: no run loaded — cannot resume");
2468
2485
  await a.resume({
2469
2486
  workflowName: o.tag,
2470
2487
  executionId: o.executionId
2471
2488
  });
2472
- }, [a, o]), d = w((e, n) => {
2489
+ }, [a, o]), d = T((e, n) => {
2473
2490
  if (t === void 0) throw Error("useWorkflowRunState: no run id — cannot signal");
2474
2491
  return a.signal({ id: t }, e, n);
2475
- }, [a, t]), f = w((e, n, r) => {
2492
+ }, [a, t]), f = T((e, n, r) => {
2476
2493
  if (t === void 0) throw Error("useWorkflowRunState: no run id — cannot update");
2477
2494
  return a.update({ id: t }, e, n, r);
2478
2495
  }, [a, t]);
@@ -2501,7 +2518,7 @@ var Jn = () => {
2501
2518
  f
2502
2519
  ]);
2503
2520
  }, yr = (e, t) => {
2504
- let { runtime: n, client: r } = K(e), [i, a] = k([]), [o, s] = k("idle"), [c, l] = k(void 0), u = O(null), d = w(() => {
2521
+ let { runtime: n, client: r } = G(e), [i, a] = k([]), [o, s] = k("idle"), [c, l] = k(void 0), u = O(null), d = T(() => {
2505
2522
  let e = u.current;
2506
2523
  e && (u.current = null, n.runFork(P.interrupt(e)), s((e) => e === "streaming" ? "idle" : e));
2507
2524
  }, [n]);
@@ -2509,15 +2526,15 @@ var Jn = () => {
2509
2526
  events: i,
2510
2527
  status: o,
2511
2528
  error: c,
2512
- start: w((e = {}) => {
2529
+ start: T((e = {}) => {
2513
2530
  let i = u.current;
2514
2531
  i && n.runFork(P.interrupt(i)), a([]), l(void 0), s("streaming");
2515
- let o = q(r, t)(e), c = L.runForEach(o, (e) => M.sync(() => a((t) => [...t, e]))).pipe(M.matchCause({
2532
+ let o = K(r, t)(e), c = R.runForEach(o, (e) => M.sync(() => a((t) => [...t, e]))).pipe(M.matchCause({
2516
2533
  onSuccess: () => {
2517
2534
  s("done");
2518
2535
  },
2519
2536
  onFailure: (e) => {
2520
- A.isInterruptedOnly(e) || (l(A.squash(e)), s("error"));
2537
+ j.isInterruptedOnly(e) || (l(j.squash(e)), s("error"));
2521
2538
  }
2522
2539
  }));
2523
2540
  u.current = n.runFork(c);
@@ -2531,36 +2548,40 @@ var Jn = () => {
2531
2548
  }, br = (e, t, n, r) => {
2532
2549
  let i = 0, a = !1, o = (e) => M.sync(() => {
2533
2550
  e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
2534
- }), s = (e, t, a) => {
2535
- let o = i > t ? 0 : e + 1;
2536
- if (o > r.maxReconnects) return M.sync(() => {
2551
+ }), s = (e) => {
2552
+ if (typeof e != "object" || !e) return;
2553
+ let t = e.name, n = e.message;
2554
+ if (typeof t == "string" || typeof n == "string") return `${typeof t == "string" ? t : ""}::${typeof n == "string" ? n : ""}`;
2555
+ }, c, l = (e, t, a) => {
2556
+ let o = i > t, l = o ? 0 : e + 1, d = a === void 0 ? void 0 : s(a), f = d !== void 0 && d === c && !o;
2557
+ if (c = o ? void 0 : d, f || l > r.maxReconnects) return M.sync(() => {
2537
2558
  n.onError(a ?? /* @__PURE__ */ Error("stream connection lost")), n.onStatus("error");
2538
2559
  });
2539
- let s = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, o - 1));
2560
+ let p = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, l - 1));
2540
2561
  return M.sync(() => {
2541
2562
  n.onStatus("reconnecting"), n.onReconnect();
2542
- }).pipe(M.zipRight(M.sleep(j.millis(s))), M.zipRight(M.sync(() => n.onStatus("streaming"))), M.zipRight(c(o)));
2543
- }, c = (r) => M.suspend(() => {
2544
- let c = i, l = e({
2563
+ }).pipe(M.zipRight(M.sleep(ie.millis(p))), M.zipRight(M.sync(() => n.onStatus("streaming"))), M.zipRight(u(l)));
2564
+ }, u = (r) => M.suspend(() => {
2565
+ let s = i, c = e({
2545
2566
  ...t,
2546
- fromSeq: c
2567
+ fromSeq: s
2547
2568
  });
2548
- return L.runForEach(l, o).pipe(M.matchCauseEffect({
2549
- onSuccess: () => a ? M.sync(() => n.onStatus("done")) : s(r, c, void 0),
2550
- onFailure: (e) => A.isInterruptedOnly(e) ? M.void : a ? M.sync(() => n.onStatus("done")) : s(r, c, A.squash(e))
2569
+ return R.runForEach(c, o).pipe(M.matchCauseEffect({
2570
+ onSuccess: () => a ? M.sync(() => n.onStatus("done")) : l(r, s, void 0),
2571
+ onFailure: (e) => j.isInterruptedOnly(e) ? M.void : a ? M.sync(() => n.onStatus("done")) : l(r, s, j.squash(e))
2551
2572
  }));
2552
2573
  });
2553
- return c(0);
2574
+ return u(0);
2554
2575
  }, xr = (e) => {
2555
2576
  let t = e?._tag;
2556
2577
  return t === "done" || t === "error";
2557
2578
  }, Sr = (e, t, n = {}) => {
2558
- let { runtime: r, client: i } = K(e), [a, o] = k([]), [s, c] = k("idle"), [l, u] = k(0), [d, f] = k(void 0), p = O(null), m = {
2579
+ let { runtime: r, client: i } = G(e), [a, o] = k([]), [s, c] = k("idle"), [l, u] = k(0), [d, f] = k(void 0), p = O(null), m = {
2559
2580
  maxReconnects: n.maxReconnects ?? 6,
2560
2581
  backoffMs: n.backoffMs ?? 400,
2561
2582
  maxBackoffMs: n.maxBackoffMs ?? 8e3,
2562
2583
  isTerminal: n.isTerminal ?? xr
2563
- }, h = w(() => {
2584
+ }, h = T(() => {
2564
2585
  let e = p.current;
2565
2586
  e && (p.current = null, r.runFork(P.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
2566
2587
  }, [r]);
@@ -2569,10 +2590,10 @@ var Jn = () => {
2569
2590
  status: s,
2570
2591
  reconnects: l,
2571
2592
  error: d,
2572
- start: w((e = {}) => {
2593
+ start: T((e = {}) => {
2573
2594
  let n = p.current;
2574
2595
  n && r.runFork(P.interrupt(n)), o([]), f(void 0), u(0), c("streaming");
2575
- let a = q(i, t), s = {
2596
+ let a = K(i, t), s = {
2576
2597
  onEvent: (e) => o((t) => [...t, e]),
2577
2598
  onStatus: c,
2578
2599
  onReconnect: () => u((e) => e + 1),
@@ -2596,7 +2617,7 @@ var Jn = () => {
2596
2617
  if (n.role === "user" && n.content) return n.content;
2597
2618
  }
2598
2619
  }, Tr = (e, t, n) => {
2599
- let { threadId: r } = n, i = J(e, `${t}.messages`, { threadId: r }), a = _n(e, `${t}.send`), o = D(() => [...i.data ?? []].sort(Cr), [i.data]), s = w((e, t = {}) => a.run({
2620
+ let { threadId: r } = n, i = q(e, `${t}.messages`, { threadId: r }), a = _n(e, `${t}.send`), o = D(() => [...i.data ?? []].sort(Cr), [i.data]), s = T((e, t = {}) => a.run({
2600
2621
  threadId: r,
2601
2622
  order: i.data?.length ?? 0,
2602
2623
  prompt: e,
@@ -2605,7 +2626,7 @@ var Jn = () => {
2605
2626
  a,
2606
2627
  r,
2607
2628
  i.data
2608
- ]), c = w(() => {
2629
+ ]), c = T(() => {
2609
2630
  let e = wr(o);
2610
2631
  return e === void 0 ? void 0 : s(e);
2611
2632
  }, [o, s]);
@@ -2647,17 +2668,17 @@ var Jn = () => {
2647
2668
  history: s,
2648
2669
  status: r,
2649
2670
  error: i,
2650
- send: w((e = {}) => {
2671
+ send: T((e = {}) => {
2651
2672
  let t = e.message;
2652
2673
  l.current = typeof t == "string" ? t : "", a(e);
2653
2674
  }, [a]),
2654
2675
  cancel: o
2655
2676
  };
2656
2677
  }, Dr = (e, t) => {
2657
- let n = _n(e, t), [r, i] = k(void 0), a = w(async (e) => {
2678
+ let n = _n(e, t), [r, i] = k(void 0), a = T(async (e) => {
2658
2679
  let t = await n.run({ question: e });
2659
2680
  return i(t), t;
2660
- }, [n]), o = w(() => i(void 0), []);
2681
+ }, [n]), o = T(() => i(void 0), []);
2661
2682
  return D(() => ({
2662
2683
  ask: a,
2663
2684
  answer: r,
@@ -2672,18 +2693,22 @@ var Jn = () => {
2672
2693
  o
2673
2694
  ]);
2674
2695
  }, Or = (e) => {
2675
- let { cache: t, runtime: n } = K(e);
2676
- return w(() => {
2696
+ let { cache: t, runtime: n } = G(e);
2697
+ return T(() => {
2677
2698
  t.refreshAll(n);
2678
2699
  }, [t, n]);
2679
2700
  }, kr = (e) => e?._tag === "Unauthenticated", Ar = (e, t, n = {}) => {
2680
- let r = n.cooldownMs ?? 15e3, i = n.maxConsecutive ?? 3, a = n.now ?? (() => Date.now()), o = -Infinity, s = 0;
2701
+ let r = n.cooldownMs ?? 15e3, i = n.maxConsecutive ?? 3, a = n.now ?? (() => Date.now()), o = -Infinity, s = 0, c = e.on((e) => {
2702
+ if (!kr(e.error) || s >= i) return;
2703
+ let n = a();
2704
+ n - o < r || (o = n, s += 1, t());
2705
+ }), l = e.onSuccess(() => {
2706
+ s = 0;
2707
+ });
2681
2708
  return {
2682
- dispose: e.on((e) => {
2683
- if (!kr(e.error) || s >= i) return;
2684
- let n = a();
2685
- n - o < r || (o = n, s += 1, t());
2686
- }),
2709
+ dispose: () => {
2710
+ c(), l();
2711
+ },
2687
2712
  noteSuccess: () => {
2688
2713
  s = 0;
2689
2714
  }
@@ -2701,18 +2726,44 @@ var Jn = () => {
2701
2726
  ...t ? { context: t } : {}
2702
2727
  });
2703
2728
  }, Fr = (e, t) => {
2704
- let { errorBus: n } = K(e);
2729
+ let { errorBus: n } = G(e);
2705
2730
  E(() => n.on(t), [n, t]);
2706
- }, Ir = (e, t) => {
2731
+ }, Ir = {
2732
+ failed: [],
2733
+ healthy: !0
2734
+ }, Lr = (e) => {
2735
+ let { errorBus: t } = G(e), [n, r] = k(Ir);
2736
+ return E(() => {
2737
+ let e = /* @__PURE__ */ new Map(), n = () => {
2738
+ let t = [...e.values()].sort((e, t) => t.at - e.at);
2739
+ r(t.length === 0 ? Ir : {
2740
+ failed: t,
2741
+ healthy: !1
2742
+ });
2743
+ }, i = t.on((t) => {
2744
+ e.set(t.tag, {
2745
+ tag: t.tag,
2746
+ source: t.source,
2747
+ error: t.error,
2748
+ at: Date.now()
2749
+ }), n();
2750
+ }), a = t.onSuccess((t) => {
2751
+ e.delete(t.tag) && n();
2752
+ });
2753
+ return () => {
2754
+ i(), a();
2755
+ };
2756
+ }, [t]), n;
2757
+ }, Rr = (e, t) => {
2707
2758
  let n = globalThis, r = Symbol.for(`@voltro/web/context:${e}`), i = n[r];
2708
2759
  if (i) return i;
2709
- let a = S(t);
2760
+ let a = C(t);
2710
2761
  return n[r] = a, a;
2711
- }, Lr = Ir("serverRequest", null), Rr = () => T(Lr), zr = ({ value: e, children: t }) => /* @__PURE__ */ fe(Lr.Provider, {
2762
+ }, zr = Rr("serverRequest", null), Br = () => te(zr), Vr = ({ value: e, children: t }) => /* @__PURE__ */ de(zr.Provider, {
2712
2763
  value: e,
2713
2764
  children: t
2714
- }), Br = (e) => {
2715
- let t = Rr();
2765
+ }), Hr = (e) => {
2766
+ let t = Br();
2716
2767
  return D(() => {
2717
2768
  if (t !== null) return t.formFlash?.formKey === e ? t.formFlash : void 0;
2718
2769
  if (typeof document > "u") return;
@@ -2724,13 +2775,13 @@ var Jn = () => {
2724
2775
  return;
2725
2776
  }
2726
2777
  }, [t, e]);
2727
- }, Vr = (e, t, n) => e.map((e) => {
2778
+ }, Ur = (e, t, n) => e.map((e) => {
2728
2779
  let r = String(e[n] ?? ""), i = e[t];
2729
2780
  return {
2730
2781
  value: r,
2731
2782
  label: i == null ? r : String(i)
2732
2783
  };
2733
- }), Hr = (e, t, n = {}) => {
2784
+ }), Wr = (e, t, n = {}) => {
2734
2785
  let r = n.debounceMs ?? 200, i = n.labelField ?? "name", a = n.valueField ?? "id", o = n.input ?? ((e) => ({ q: e })), [s, c] = k(n.initialTerm ?? ""), [l, u] = k(s);
2735
2786
  E(() => {
2736
2787
  if (s === l) return;
@@ -2741,24 +2792,24 @@ var Jn = () => {
2741
2792
  l,
2742
2793
  r
2743
2794
  ]);
2744
- let d = n.skipUntilTerm === !0 && l.trim() === "", f = J(e, t, D(() => o(l), [o, l]), { skip: d }), p = D(() => Vr(f.data ?? [], i, a), [
2795
+ let d = n.skipUntilTerm === !0 && l.trim() === "", f = q(e, t, D(() => o(l), [o, l]), { skip: d }), p = D(() => Ur(f.data ?? [], i, a), [
2745
2796
  f.data,
2746
2797
  i,
2747
2798
  a
2748
- ]), m = w((e) => c(e), []);
2799
+ ]), m = T((e) => c(e), []);
2749
2800
  return {
2750
2801
  options: p,
2751
2802
  loading: !d && f.data === void 0,
2752
2803
  term: s,
2753
2804
  search: m
2754
2805
  };
2755
- }, Ur = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Wr = (t, n, r = {}) => {
2756
- let i = K(t), [a, o] = k(r.pageSize), s = J(t, n, D(() => a === void 0 ? r.input ?? {} : {
2806
+ }, Gr = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Kr = (t, n, r = {}) => {
2807
+ let i = G(t), [a, o] = k(r.pageSize), s = q(t, n, D(() => a === void 0 ? r.input ?? {} : {
2757
2808
  ...r.input,
2758
2809
  limit: a
2759
- }, [r.input, a])), c = i.descriptors[n]?.output, l = w(() => {
2810
+ }, [r.input, a])), c = i.descriptors[n]?.output, l = T(() => {
2760
2811
  r.pageSize !== void 0 && o((e) => (e ?? r.pageSize) + r.pageSize);
2761
- }, [r.pageSize]), u = D(() => r.columns ?? (c === void 0 ? [] : e(c)), [r.columns, c]), [d, f] = k(r.initialSort), p = w((e) => {
2812
+ }, [r.pageSize]), u = D(() => r.columns ?? (c === void 0 ? [] : e(c)), [r.columns, c]), [d, f] = k(r.initialSort), p = T((e) => {
2762
2813
  f((t) => t?.column === e ? {
2763
2814
  column: e,
2764
2815
  direction: t.direction === "asc" ? "desc" : "asc"
@@ -2773,7 +2824,7 @@ var Jn = () => {
2773
2824
  let e = s.data ?? [];
2774
2825
  if (d === void 0) return e;
2775
2826
  let t = d.direction === "asc" ? 1 : -1;
2776
- return [...e].sort((e, n) => Ur(e[d.column], n[d.column]) * t);
2827
+ return [...e].sort((e, n) => Gr(e[d.column], n[d.column]) * t);
2777
2828
  }, [s.data, d]),
2778
2829
  loading: s.data === void 0,
2779
2830
  error: s.error,
@@ -2782,14 +2833,14 @@ var Jn = () => {
2782
2833
  loadMore: l,
2783
2834
  hasMore: a !== void 0 && (s.data?.length ?? 0) >= a
2784
2835
  };
2785
- }, Gr = (e, t, n, r) => {
2836
+ }, qr = (e, t, n, r) => {
2786
2837
  let i = e.replace(/\/$/, ""), a = new URLSearchParams({
2787
2838
  table: t,
2788
2839
  id: n
2789
2840
  });
2790
2841
  return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
2791
- }, Kr = Gr, qr = (e, t, n, r) => {
2792
- let { inspectBaseUrl: i } = K(e), [a, o] = k({
2842
+ }, Jr = qr, Yr = (e, t, n, r) => {
2843
+ let { inspectBaseUrl: i } = G(e), [a, o] = k({
2793
2844
  data: void 0,
2794
2845
  loading: !0,
2795
2846
  error: void 0
@@ -2801,7 +2852,7 @@ var Jn = () => {
2801
2852
  loading: !0,
2802
2853
  error: void 0
2803
2854
  });
2804
- let a = Gr(i ?? "", t, n, r);
2855
+ let a = qr(i ?? "", t, n, r);
2805
2856
  return fetch(a).then(async (e) => {
2806
2857
  if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
2807
2858
  return await e.json();
@@ -2827,12 +2878,12 @@ var Jn = () => {
2827
2878
  n,
2828
2879
  r
2829
2880
  ]), a;
2830
- }, Jr = "admin:full", Yr = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), Xr = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), Zr = S({ scopes: [] });
2831
- function Qr(e) {
2832
- return C(Zr.Provider, { value: { scopes: e.scopes } }, e.children);
2881
+ }, Xr = "admin:full", Zr = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), Qr = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), $r = C({ scopes: [] });
2882
+ function ei(e) {
2883
+ return w($r.Provider, { value: { scopes: e.scopes } }, e.children);
2833
2884
  }
2834
- var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes, e), ni = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, ri = (e) => {
2835
- let { inspectBaseUrl: t } = K(e), [n, r] = k({
2885
+ var ti = () => te($r), ni = (e) => Zr(ti().scopes, e), ri = (e) => Qr(ti().scopes, e), ii = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, ai = (e) => {
2886
+ let { inspectBaseUrl: t } = G(e), [n, r] = k({
2836
2887
  manifest: void 0,
2837
2888
  loading: !0,
2838
2889
  error: void 0
@@ -2843,7 +2894,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2843
2894
  manifest: void 0,
2844
2895
  loading: !0,
2845
2896
  error: void 0
2846
- }), fetch(ni(t ?? "")).then(async (e) => {
2897
+ }), fetch(ii(t ?? "")).then(async (e) => {
2847
2898
  if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
2848
2899
  return await e.json();
2849
2900
  }).then((t) => {
@@ -2862,7 +2913,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2862
2913
  e = !0;
2863
2914
  };
2864
2915
  }, [e, t]), n;
2865
- }, ii = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), ai = (e, t) => {
2916
+ }, oi = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), si = (e, t) => {
2866
2917
  if (e === void 0) return "unknown";
2867
2918
  if (t.includes("admin:full") || e.length === 0) return "allowed";
2868
2919
  let n = !1;
@@ -2871,7 +2922,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2871
2922
  n = !0;
2872
2923
  continue;
2873
2924
  }
2874
- if (!ii(t, r)) {
2925
+ if (!oi(t, r)) {
2875
2926
  if (r.resourceScoped) {
2876
2927
  n = !0;
2877
2928
  continue;
@@ -2880,13 +2931,13 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2880
2931
  }
2881
2932
  }
2882
2933
  return n ? "unknown" : "allowed";
2883
- }, oi = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), si = (e) => {
2934
+ }, ci = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), li = (e) => {
2884
2935
  for (let t of e ?? []) if (t.kind === "open") return t.reason;
2885
- }, ci = (e) => ai(e, $r().scopes), li = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, ui = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, di = (e) => e === void 0 ? {} : {
2936
+ }, ui = (e) => si(e, ti().scopes), di = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, fi = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, pi = (e) => e === void 0 ? {} : {
2886
2937
  tag: e.tag,
2887
2938
  ...e.guards === void 0 ? {} : { guards: e.guards }
2888
- }, fi = (e) => e.tables.filter((e) => !e.framework).map((t) => {
2889
- let n = e.procedures.find((e) => e.kind === "query" && li(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && ui(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && ui(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && ui(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
2939
+ }, mi = (e) => e.tables.filter((e) => !e.framework).map((t) => {
2940
+ let n = e.procedures.find((e) => e.kind === "query" && di(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && fi(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && fi(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && fi(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
2890
2941
  return {
2891
2942
  table: t.name,
2892
2943
  columns: t.columns.filter((e) => e.serverOnly !== !0),
@@ -2895,18 +2946,18 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2895
2946
  reactive: t.reactive,
2896
2947
  ...o === void 0 ? {} : { pkColumn: o },
2897
2948
  editable: (t.editable ?? !0) && o !== void 0,
2898
- list: di(n),
2899
- create: di(r),
2900
- update: di(i),
2901
- delete: di(a)
2949
+ list: pi(n),
2950
+ create: pi(r),
2951
+ update: pi(i),
2952
+ delete: pi(a)
2902
2953
  };
2903
- }), pi = (e) => {
2904
- let [t, n] = k([]), [r, i] = k([]), a = w((e) => {
2954
+ }), hi = (e) => {
2955
+ let [t, n] = k([]), [r, i] = k([]), a = T((e) => {
2905
2956
  n((t) => [...t, e]), i([]);
2906
- }, []), o = w(async () => {
2957
+ }, []), o = T(async () => {
2907
2958
  let r = t[t.length - 1];
2908
2959
  r !== void 0 && r.blockedBy === void 0 && (await e.onUndo(r.invocationId), n((e) => e.slice(0, -1)), i((e) => [...e, r]));
2909
- }, [t, e]), s = w(async () => {
2960
+ }, [t, e]), s = T(async () => {
2910
2961
  let t = r[r.length - 1];
2911
2962
  t !== void 0 && (await e.onRedo(t.invocationId), i((e) => e.slice(0, -1)), n((e) => [...e, t]));
2912
2963
  }, [r, e]);
@@ -2928,14 +2979,14 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2928
2979
  o,
2929
2980
  s
2930
2981
  ]);
2931
- }, mi = "__voltro.undo.log", hi = "__voltro.undo.apply", gi = "__voltro.undo.redo", _i = (e, t) => {
2932
- let n = t?.limit, { data: r } = J(e, mi, n === void 0 ? {} : { limit: n }), i = Z(e, hi), a = Z(e, gi), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = w(async (e) => {
2982
+ }, gi = "__voltro.undo.log", _i = "__voltro.undo.apply", vi = "__voltro.undo.redo", yi = (e, t) => {
2983
+ let n = t?.limit, { data: r } = q(e, gi, n === void 0 ? {} : { limit: n }), i = Z(e, _i), a = Z(e, vi), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = T(async (e) => {
2933
2984
  await i.mutate({ invocationId: e });
2934
- }, [i]), u = w(async (e) => {
2985
+ }, [i]), u = T(async (e) => {
2935
2986
  await a.mutate({ invocationId: e });
2936
- }, [a]), d = w(async () => {
2987
+ }, [a]), d = T(async () => {
2937
2988
  s && await l(s.id);
2938
- }, [s, l]), f = w(async () => {
2989
+ }, [s, l]), f = T(async () => {
2939
2990
  c && await u(c.id);
2940
2991
  }, [c, u]);
2941
2992
  return {
@@ -2948,21 +2999,21 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2948
2999
  undoLast: d,
2949
3000
  redoLast: f
2950
3001
  };
2951
- }, vi = (e, t) => ({
3002
+ }, bi = (e, t) => ({
2952
3003
  name: e,
2953
3004
  map: t
2954
- }), yi = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), bi = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), xi = (e, t, n) => {
3005
+ }), xi = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), Si = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), Ci = (e, t, n) => {
2955
3006
  let r = { ...t };
2956
3007
  for (let [i, a] of Object.entries(e.map)) {
2957
- if (bi.has(i) || a === void 0) continue;
3008
+ if (Si.has(i) || a === void 0) continue;
2958
3009
  let e = t[i];
2959
3010
  r[i] = (...r) => {
2960
- let i = yi(a, t);
3011
+ let i = xi(a, t);
2961
3012
  if (i !== null && n(i), typeof e == "function") return e(...r);
2962
3013
  };
2963
3014
  }
2964
3015
  return r;
2965
- }, Si = (e, t, n) => {
3016
+ }, wi = (e, t, n) => {
2966
3017
  let r = O({
2967
3018
  spec: e,
2968
3019
  props: t,
@@ -2973,46 +3024,46 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
2973
3024
  props: t,
2974
3025
  sink: n
2975
3026
  }, E(() => {
2976
- let e = r.current, t = yi(e.spec.map.onMount, e.props);
3027
+ let e = r.current, t = xi(e.spec.map.onMount, e.props);
2977
3028
  return t !== null && e.sink(t), () => {
2978
- let e = r.current, t = yi(e.spec.map.onUnmount, e.props);
3029
+ let e = r.current, t = xi(e.spec.map.onUnmount, e.props);
2979
3030
  t !== null && e.sink(t);
2980
3031
  };
2981
- }, []), D(() => xi(e, t, n), [
3032
+ }, []), D(() => Ci(e, t, n), [
2982
3033
  e,
2983
3034
  t,
2984
3035
  n
2985
3036
  ]);
2986
- }, Ci = (e, t) => {
2987
- let n = K(e).descriptors[t]?.input;
3037
+ }, Ti = (e, t) => {
3038
+ let n = G(e).descriptors[t]?.input;
2988
3039
  return D(() => n === void 0 ? [] : x(n), [n]);
2989
- }, wi = (t, n) => {
2990
- let r = K(t).descriptors[n]?.output;
3040
+ }, Ei = (t, n) => {
3041
+ let r = G(t).descriptors[n]?.output;
2991
3042
  return D(() => r === void 0 ? [] : e(r), [r]);
2992
- }, Ti = (e, t) => {
3043
+ }, Di = (e, t) => {
2993
3044
  if (e === t) return !0;
2994
3045
  if (e.length !== t.length) return !1;
2995
3046
  for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
2996
3047
  return !0;
2997
- }, Ei = (e) => Object.keys(e).sort().map((t) => e[t]), Di = (e, t) => {
2998
- let n = O(null), r = Ei(e);
2999
- return (n.current === null || !Ti(n.current.key, r)) && (n.current = {
3048
+ }, Oi = (e) => Object.keys(e).sort().map((t) => e[t]), ki = (e, t) => {
3049
+ let n = O(null), r = Oi(e);
3050
+ return (n.current === null || !Di(n.current.key, r)) && (n.current = {
3000
3051
  key: r,
3001
3052
  value: t(e)
3002
3053
  }), n.current.value;
3003
- }, Oi = (e, t, n, r = {}) => {
3004
- let i = J(e, t, { ...n }, r);
3054
+ }, Ai = (e, t, n, r = {}) => {
3055
+ let i = q(e, t, { ...n }, r);
3005
3056
  return D(() => ({
3006
3057
  allowed: i.data?.allowed === !0,
3007
3058
  pending: i.data === void 0
3008
3059
  }), [i.data]);
3009
- }, ki = (e, t, n, r = {}) => {
3010
- let i = J(e, t, { ...n }, r);
3060
+ }, ji = (e, t, n, r = {}) => {
3061
+ let i = q(e, t, { ...n }, r);
3011
3062
  return D(() => ({
3012
3063
  allowedIds: new Set(i.data?.allowedIds ?? []),
3013
3064
  pending: i.data === void 0
3014
3065
  }), [i.data]);
3015
- }, Ai = (e) => {
3066
+ }, Mi = (e) => {
3016
3067
  switch (e) {
3017
3068
  case "select":
3018
3069
  case "radio":
@@ -3028,26 +3079,26 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3028
3079
  case "switch": return "boolean";
3029
3080
  default: return null;
3030
3081
  }
3031
- }, ji = (e) => x(e).map((e) => {
3082
+ }, Ni = (e) => x(e).map((e) => {
3032
3083
  if (e.name.includes(".")) return null;
3033
- let t = Ai(e.widget);
3084
+ let t = Mi(e.widget);
3034
3085
  return t === null ? null : {
3035
3086
  name: e.name,
3036
3087
  label: e.label,
3037
3088
  kind: t,
3038
3089
  ...e.options ? { options: e.options } : {}
3039
3090
  };
3040
- }).filter((e) => e !== null), Mi = (e) => {
3091
+ }).filter((e) => e !== null), Pi = (e) => {
3041
3092
  let t = {};
3042
3093
  for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
3043
3094
  return t;
3044
- }, Ni = (e, t, n = {}) => {
3045
- let r = K(e).descriptors[t]?.input, i = D(() => r === void 0 ? [] : ji(r), [r]), [a, o] = k(n.initial ?? {}), s = w((e, t) => {
3046
- o((n) => Mi({
3095
+ }, Fi = (e, t, n = {}) => {
3096
+ let r = G(e).descriptors[t]?.input, i = D(() => r === void 0 ? [] : Ni(r), [r]), [a, o] = k(n.initial ?? {}), s = T((e, t) => {
3097
+ o((n) => Pi({
3047
3098
  ...n,
3048
3099
  [e]: t
3049
3100
  }));
3050
- }, []), c = w(() => o({}), []), l = J(e, t, D(() => Mi(a), [a]));
3101
+ }, []), c = T(() => o({}), []), l = q(e, t, D(() => Pi(a), [a]));
3051
3102
  return {
3052
3103
  filters: i,
3053
3104
  values: a,
@@ -3058,20 +3109,20 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3058
3109
  loading: l.data === void 0,
3059
3110
  error: l.error
3060
3111
  };
3061
- }, Pi = (e, t, n = {}) => {
3062
- let r = J(e, t, n), i = r.data;
3112
+ }, Ii = (e, t, n = {}) => {
3113
+ let r = q(e, t, n), i = r.data;
3063
3114
  return {
3064
3115
  record: Array.isArray(i) ? i[0] : i,
3065
3116
  loading: i === void 0,
3066
3117
  error: r.error
3067
3118
  };
3068
- }, Fi = (e, t = 300) => {
3119
+ }, Li = (e, t = 300) => {
3069
3120
  let [n, r] = k(e);
3070
3121
  return E(() => {
3071
3122
  let n = setTimeout(() => r(e), t);
3072
3123
  return () => clearTimeout(n);
3073
3124
  }, [e, t]), n;
3074
- }, Ii = (e) => {
3125
+ }, Ri = (e) => {
3075
3126
  let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
3076
3127
  if (a && t.trim() === "") return {
3077
3128
  status: "idle",
@@ -3089,39 +3140,39 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3089
3140
  valid: o.valid,
3090
3141
  message: o.message
3091
3142
  };
3092
- }, Li = (e, t, n, r) => {
3093
- let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = Fi(n, o), l = s && c.trim() === "", u = J(e, t, D(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
3094
- return Ii({
3143
+ }, zi = (e, t, n, r) => {
3144
+ let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = Li(n, o), l = s && c.trim() === "", u = q(e, t, D(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
3145
+ return Ri({
3095
3146
  value: n,
3096
3147
  debouncedValue: c,
3097
3148
  data: l ? null : u.data,
3098
3149
  interpret: a,
3099
3150
  skipEmpty: s
3100
3151
  });
3101
- }, Ri = (e, t) => ({
3152
+ }, Bi = (e, t) => ({
3102
3153
  name: e,
3103
3154
  payload: t
3104
- }), zi = (e, t) => {
3105
- let n = oe.decodeUnknownEither(e.payload, { errors: "all" })(t);
3155
+ }), Vi = (e, t) => {
3156
+ let n = ae.decodeUnknownEither(e.payload, { errors: "all" })(t);
3106
3157
  if (n._tag === "Right") return {
3107
3158
  valid: !0,
3108
3159
  errors: {}
3109
3160
  };
3110
3161
  let r = {};
3111
- for (let e of he.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
3162
+ for (let e of me.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
3112
3163
  return {
3113
3164
  valid: !1,
3114
3165
  errors: r
3115
3166
  };
3116
- }, Bi = (e) => {
3167
+ }, Hi = (e) => {
3117
3168
  let t = new Map(e.map((e) => [e.name, e]));
3118
3169
  return {
3119
3170
  names: [...t.keys()].sort(),
3120
3171
  get: (e) => t.get(e),
3121
3172
  events: e
3122
3173
  };
3123
- }, Vi = (e, t) => {
3124
- let n = Bi(e);
3174
+ }, Ui = (e, t) => {
3175
+ let n = Hi(e);
3125
3176
  return {
3126
3177
  track: (e, r) => {
3127
3178
  let i = n.get(e);
@@ -3130,7 +3181,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3130
3181
  return;
3131
3182
  }
3132
3183
  if (process.env.NODE_ENV !== "production") {
3133
- let t = zi(i, r);
3184
+ let t = Vi(i, r);
3134
3185
  t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
3135
3186
  }
3136
3187
  t({
@@ -3141,47 +3192,47 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3141
3192
  names: n.names,
3142
3193
  catalog: n
3143
3194
  };
3144
- }, Hi = (e, t) => {
3195
+ }, Wi = (e, t) => {
3145
3196
  let n = _n(e, t);
3146
3197
  return {
3147
- preview: w((e) => n.run(e), [n]),
3198
+ preview: T((e) => n.run(e), [n]),
3148
3199
  diff: n.lastResult,
3149
3200
  pending: n.pending,
3150
3201
  error: n.error
3151
3202
  };
3152
- }, Ui = (e, t, n, r) => [...e, {
3203
+ }, Gi = (e, t, n, r) => [...e, {
3153
3204
  id: t,
3154
3205
  tag: n,
3155
3206
  input: r,
3156
3207
  status: "pending",
3157
3208
  attempts: 0
3158
- }], Wi = (e, t, n) => e.map((e) => e.id === t ? {
3209
+ }], Ki = (e, t, n) => e.map((e) => e.id === t ? {
3159
3210
  ...e,
3160
3211
  ...n
3161
- } : e), Gi = (e, t) => Wi(e, t, { status: "sent" }), Ki = (e, t, n) => e.map((e) => e.id === t ? {
3212
+ } : e), qi = (e, t) => Ki(e, t, { status: "sent" }), Ji = (e, t, n) => e.map((e) => e.id === t ? {
3162
3213
  ...e,
3163
3214
  status: "failed",
3164
3215
  error: n,
3165
3216
  attempts: e.attempts + 1
3166
- } : e), qi = (e, t, n) => Wi(e, t, {
3217
+ } : e), Yi = (e, t, n) => Ki(e, t, {
3167
3218
  status: "conflict",
3168
3219
  error: n
3169
- }), Ji = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
3220
+ }), Xi = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
3170
3221
  ...e,
3171
3222
  input: n,
3172
3223
  status: "pending",
3173
3224
  error: void 0
3174
- } : e), Yi = (e) => e.filter((e) => e.status !== "sent"), Xi = (e) => {
3225
+ } : e), Zi = (e) => e.filter((e) => e.status !== "sent"), Qi = (e) => {
3175
3226
  let t = [];
3176
3227
  for (let n of e) {
3177
3228
  if (n.status === "conflict") break;
3178
3229
  (n.status === "pending" || n.status === "failed") && t.push(n);
3179
3230
  }
3180
3231
  return t;
3181
- }, Zi = (e) => {
3232
+ }, $i = (e) => {
3182
3233
  let t = e;
3183
3234
  return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
3184
- }, Qi = (e) => {
3235
+ }, ea = (e) => {
3185
3236
  let [t, n] = k(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
3186
3237
  return E(() => {
3187
3238
  if (e !== void 0) {
@@ -3194,8 +3245,8 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3194
3245
  window.removeEventListener("online", t), window.removeEventListener("offline", r);
3195
3246
  };
3196
3247
  }, [e]), t;
3197
- }, $i = (e) => {
3198
- let { send: t, persistence: n, isConflict: r = Zi, idFor: i } = e, [a, o] = k([]), s = Qi(e.online), c = O(a);
3248
+ }, ta = (e) => {
3249
+ let { send: t, persistence: n, isConflict: r = $i, idFor: i } = e, [a, o] = k([]), s = ea(e.online), c = O(a);
3199
3250
  c.current = a;
3200
3251
  let l = O(0), u = O(Math.random().toString(36).slice(2, 8)), d = O(n === void 0);
3201
3252
  E(() => {
@@ -3209,27 +3260,27 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3209
3260
  e = !0;
3210
3261
  };
3211
3262
  }, [n]), E(() => {
3212
- n === void 0 || !d.current || n.save(Yi(a)).catch(() => {});
3263
+ n === void 0 || !d.current || n.save(Zi(a)).catch(() => {});
3213
3264
  }, [n, a]);
3214
- let f = w((e, t) => {
3265
+ let f = T((e, t) => {
3215
3266
  let n = i?.() ?? `obx_${u.current}_${l.current++}_${e}`;
3216
- o((r) => Ui(r, n, e, t));
3217
- }, [i]), p = w(async () => {
3218
- for (let e of Xi(c.current)) try {
3219
- await t(e), o((t) => Gi(t, e.id));
3267
+ o((r) => Gi(r, n, e, t));
3268
+ }, [i]), p = T(async () => {
3269
+ for (let e of Qi(c.current)) try {
3270
+ await t(e), o((t) => qi(t, e.id));
3220
3271
  } catch (t) {
3221
3272
  if (r(t)) {
3222
- o((n) => qi(n, e.id, t));
3273
+ o((n) => Yi(n, e.id, t));
3223
3274
  break;
3224
3275
  }
3225
- o((n) => Ki(n, e.id, t));
3276
+ o((n) => Ji(n, e.id, t));
3226
3277
  }
3227
3278
  }, [t, r]);
3228
3279
  E(() => {
3229
3280
  s && p();
3230
3281
  }, [s, p]);
3231
- let m = w((e, t) => {
3232
- let n = Ji(c.current, e, t);
3282
+ let m = T((e, t) => {
3283
+ let n = Xi(c.current, e, t);
3233
3284
  c.current = n, o(n), s && p();
3234
3285
  }, [s, p]);
3235
3286
  return {
@@ -3241,7 +3292,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3241
3292
  conflicts: a.filter((e) => e.status === "conflict"),
3242
3293
  resolveConflict: m
3243
3294
  };
3244
- }, ea = (e) => {
3295
+ }, na = (e) => {
3245
3296
  let { scrollTop: t, viewportHeight: n, rowHeight: r, overscan: i = 5, total: a } = e, o = r > 0 ? r : 1, s = Math.max(0, Math.floor(t / o)), c = Math.ceil(n / o), l = Math.max(0, s - i), u = s + c + i, d = a === void 0 ? u : Math.min(u, a);
3246
3297
  return {
3247
3298
  startIndex: l,
@@ -3251,8 +3302,8 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3251
3302
  topSpacer: l * r,
3252
3303
  bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
3253
3304
  };
3254
- }, ta = (e, t, n) => {
3255
- let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = k(0), u = D(() => ea({
3305
+ }, ra = (e, t, n) => {
3306
+ let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = k(0), u = D(() => na({
3256
3307
  scrollTop: c,
3257
3308
  viewportHeight: i,
3258
3309
  rowHeight: r,
@@ -3264,7 +3315,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3264
3315
  r,
3265
3316
  a,
3266
3317
  o
3267
- ]), d = J(e, t, D(() => ({
3318
+ ]), d = q(e, t, D(() => ({
3268
3319
  ...s,
3269
3320
  offset: u.offset,
3270
3321
  limit: u.limit
@@ -3272,7 +3323,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3272
3323
  s,
3273
3324
  u.offset,
3274
3325
  u.limit
3275
- ])), f = w((e) => {
3326
+ ])), f = T((e) => {
3276
3327
  l(e.currentTarget.scrollTop);
3277
3328
  }, []);
3278
3329
  return {
@@ -3284,8 +3335,8 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3284
3335
  loading: d.data === void 0,
3285
3336
  error: d.error
3286
3337
  };
3287
- }, na = () => typeof navigator > "u" || navigator.onLine, ra = (e) => {
3288
- let { errorBus: t } = K(e), [n, r] = k(na), [i, a] = k(0), [o, s] = k(void 0), c = O(!0);
3338
+ }, ia = () => typeof navigator > "u" || navigator.onLine, aa = (e) => {
3339
+ let { errorBus: t } = G(e), [n, r] = k(ia), [i, a] = k(0), [o, s] = k(void 0), c = O(!0);
3289
3340
  E(() => (c.current = !0, () => {
3290
3341
  c.current = !1;
3291
3342
  }), []), E(() => {
@@ -3301,7 +3352,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3301
3352
  c.current && (a((e) => e + 1), s(Date.now()));
3302
3353
  });
3303
3354
  }, [t]);
3304
- let l = w(() => {
3355
+ let l = T(() => {
3305
3356
  a(0);
3306
3357
  }, []);
3307
3358
  return {
@@ -3311,7 +3362,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3311
3362
  lastFailureAt: o,
3312
3363
  reportSuccess: l
3313
3364
  };
3314
- }, ia = "__voltro.connections.list", aa = "__voltro.connections.start", oa = "__voltro.connections.submitToken", sa = "__voltro.connections.disconnect", ca = {
3365
+ }, oa = "__voltro.connections.list", sa = "__voltro.connections.start", ca = "__voltro.connections.submitToken", la = "__voltro.connections.disconnect", ua = {
3315
3366
  connectionId: "",
3316
3367
  kind: "oauth2",
3317
3368
  label: "",
@@ -3322,14 +3373,14 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3322
3373
  expiresAt: null,
3323
3374
  lastError: null,
3324
3375
  connectedAt: null
3325
- }, la = (e, t) => {
3376
+ }, da = (e, t) => {
3326
3377
  if (t === "redirect") {
3327
3378
  globalThis.location.assign(e);
3328
3379
  return;
3329
3380
  }
3330
3381
  globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
3331
- }, ua = (e) => {
3332
- let { data: t } = J(e, ia, {}), n = _n(e, aa), r = Z(e, oa), i = Z(e, sa), a = t ?? [], o = n.pending || r.pending || i.pending, s = w((e) => ({
3382
+ }, fa = (e) => {
3383
+ let { data: t } = q(e, oa, {}), n = _n(e, sa), r = Z(e, ca), i = Z(e, la), a = t ?? [], o = n.pending || r.pending || i.pending, s = T((e) => ({
3333
3384
  ...e,
3334
3385
  connected: e.status === "connected",
3335
3386
  needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
@@ -3337,7 +3388,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3337
3388
  connect: async (t) => {
3338
3389
  if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
3339
3390
  let r = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
3340
- la((await n.run({
3391
+ da((await n.run({
3341
3392
  connectionId: e.connectionId,
3342
3393
  redirectTo: r
3343
3394
  })).authorizeUrl, t?.mode);
@@ -3357,7 +3408,7 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3357
3408
  n,
3358
3409
  r,
3359
3410
  i
3360
- ]), c = w((e) => {
3411
+ ]), c = T((e) => {
3361
3412
  let t = a.find((t) => t.connectionId === e);
3362
3413
  return t === void 0 ? void 0 : s(t);
3363
3414
  }, [a, s]);
@@ -3367,10 +3418,10 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3367
3418
  get: c,
3368
3419
  pending: o
3369
3420
  };
3370
- }, da = (e, t) => {
3371
- let n = ua(e), r = n.get(t);
3421
+ }, pa = (e, t) => {
3422
+ let n = fa(e), r = n.get(t);
3372
3423
  return D(() => r === void 0 ? {
3373
- ...ca,
3424
+ ...ua,
3374
3425
  connectionId: t,
3375
3426
  label: t,
3376
3427
  connected: !1,
@@ -3395,6 +3446,6 @@ var $r = () => T(Zr), ei = (e) => Yr($r().scopes, e), ti = (e) => Xr($r().scopes
3395
3446
  n.loading,
3396
3447
  n.pending
3397
3448
  ]);
3398
- }, fa = "framework-client";
3449
+ }, ma = "framework-client";
3399
3450
  //#endregion
3400
- export { Jr as ADMIN_SCOPE, fa as CLIENT_NAME, ia as CONNECTIONS_LIST_TAG, sa as CONNECTION_DISCONNECT_TAG, aa as CONNECTION_START_TAG, oa as CONNECTION_SUBMIT_TOKEN_TAG, v as FORM_FLASH_SCRIPT_ID, p as FORM_KEY_FIELD, g as FORM_PATH_PREFIX, u as FORM_REDIRECT_FIELD, On as FormBindingProvider, je as FrameworkRuntimesContext, $e as FrameworkRuntimesProvider, ke as LoadingSubscriptionCache, Qr as PermissionProvider, _ as RICH_TEXT_MARKS, a as RICH_TEXT_MAX_NODES, d as RichTextDocument, Ae as RpcErrorBus, Lr as ServerRequestContext, zr as ServerRequestProvider, Oe as SubscriptionCache, hi as UNDO_APPLY_TAG, mi as UNDO_LOG_TAG, gi as UNDO_REDO_TAG, yn as ValidationMessagesProvider, We as _resetFrameworkRuntimesWarning, ze as _resetSsrDescriptors, Bn as applyPreloadSeeds, Bt as applyStoreSeeds, qe as buildApiRuntime, Yr as canCall, Xr as canCallAny, Qt as clearMutations, Yi as clearSent, bt as clearStoreHistory, ea as computeWindow, Vi as createAnalytics, Mn as createHooks, ai as decideAccess, c as decodeFieldIssues, Ri as defineEvent, Ft as defineStore, vi as defineTracking, Pt as definedStores, fi as deriveEntityAdmins, n as documentLocale, y as emptyRichTextDocument, Ui as enqueueEntry, Bi as eventCatalog, ji as filtersFromSchema, r as formActionPath, m as formDataToInput, ee as formField, t as formSections, cn as freshIdempotencyKey, nn as getMutationNotifier, Xt as getMutations, Ir as globalContext, o as isRichTextDocument, s as isSafeHref, kr as isUnauthenticated, Ke as isUnresolvedApi, Nn as makePreloadSeedBag, Lt as makeStoreSeedBag, ni as manifestUrl, qi as markConflict, Ki as markFailed, Gi as markSent, si as openAccessReason, h as parseRichText, Kr as provenanceUrl, Mr as publishClientError, _e as publishClientTrace, Hn as readPreloadedSeedOutcome, Vn as readPreloadedSnapshot, Le as registerSsrDescriptors, Xi as replayable, Pr as reportClientError, oi as requiredScopes, Un as resetPreloadSeeds, It as resetStoreRegistryForTests, at as resetStoreStorageForTest, q as resolveByTag, Ji as resolveConflictEntry, it as resolveStoreStorage, yi as resolveTrackingEvent, b as resolveValidationMessage, te as restrictToSchema, br as resumableConsumeProgram, f as richTextToPlainText, Vr as rowsToOptions, Yn as runSequence, e as schemaToColumns, x as schemaToFields, Rn as seedPreloadedSubscription, zn as seedPreloadedSubscriptionFailure, zt as seedStore, Jn as sequence, l as serializeRichText, tn as setMutationNotifier, Fn as setPreloadSeedResolver, Rt as setStoreSeedResolver, rt as setStoreStorage, Yt as settleMutation, ot as shallow, Ti as shallowArrayEqual, Ei as sourceValues, Ne as ssrClientProxy, Re as ssrDescriptorsFor, Be as ssrStubHandle, B as stableKey, Qe as startApiSupervisor, Jt as startMutation, vt as storeHistory, Nr as subscribeClientErrors, ve as subscribeClientTraces, Zt as subscribeMutations, yt as subscribeStoreHistory, xe as supersedesConfirmedPatches, xt as travelToStoreState, ci as useAccessDecision, _n as useAction, Er as useAgent, Tr as useAgentChat, yr as useAgentStream, Li as useAsyncValidation, ei as useCan, ti as useCanAny, ri as useCapabilityManifest, da as useConnection, ra as useConnectionStatus, ua as useConnections, Dr as useDataCopilot, Wr as useDataTable, Fi as useDebounced, Di as useDerived, qn as useEvent, Dn as useFormBinding, kn as useFormBindingContext, An as useFormField, Br as useFormFlash, Ci as useFormSkeleton, K as useFrameworkApi, Ge as useFrameworkRuntimes, Z as useMutation, Fr as useOnRpcError, $i as useOutbox, $r as usePermissions, Wn as usePreloadedSubscription, Hi as usePreview, qr as useProvenance, Hr as useQueryField, Ni as useQueryFilters, Pi as useRecord, Or as useRefreshSubscriptions, Oi as useResourceCan, ki as useResourceCans, Sr as useResumableAgentStream, Xn as useSequence, Rr as useServerRequest, J as useSubscription, wi as useTableSkeleton, Si as useTracking, pi as useUndo, _i as useUndoLog, nr as useUpload, bn as useValidationMessages, ta as useWindowedSubscription, rr as useWorkflow, dr as useWorkflowDomainEvents, fr as useWorkflowEventDeliveries, ur as useWorkflowEvents, or as useWorkflowRun, lr as useWorkflowRunEvents, vr as useWorkflowRunState, cr as useWorkflowRunSteps, sr as useWorkflowRuns, ir as useWorkflowSignal, ar as useWorkflowUpdate, zi as validateEventPayload, i as validateFields, Ii as validationStatus, Ar as wireAuthRefresh, ln as withIdempotencyKey, xi as wrapTrackedCallbacks };
3451
+ export { Xr as ADMIN_SCOPE, ma as CLIENT_NAME, oa as CONNECTIONS_LIST_TAG, la as CONNECTION_DISCONNECT_TAG, sa as CONNECTION_START_TAG, ca as CONNECTION_SUBMIT_TOKEN_TAG, v as FORM_FLASH_SCRIPT_ID, p as FORM_KEY_FIELD, g as FORM_PATH_PREFIX, u as FORM_REDIRECT_FIELD, On as FormBindingProvider, Me as FrameworkRuntimesContext, et as FrameworkRuntimesProvider, Ae as LoadingSubscriptionCache, ei as PermissionProvider, _ as RICH_TEXT_MARKS, a as RICH_TEXT_MAX_NODES, d as RichTextDocument, je as RpcErrorBus, zr as ServerRequestContext, Vr as ServerRequestProvider, ke as SubscriptionCache, _i as UNDO_APPLY_TAG, gi as UNDO_LOG_TAG, vi as UNDO_REDO_TAG, yn as ValidationMessagesProvider, Ge as _resetFrameworkRuntimesWarning, Be as _resetSsrDescriptors, Bn as applyPreloadSeeds, Vt as applyStoreSeeds, Je as buildApiRuntime, Zr as canCall, Qr as canCallAny, en as clearMutations, Zi as clearSent, xt as clearStoreHistory, na as computeWindow, Ui as createAnalytics, Mn as createHooks, si as decideAccess, c as decodeFieldIssues, Bi as defineEvent, It as defineStore, bi as defineTracking, Ft as definedStores, mi as deriveEntityAdmins, n as documentLocale, y as emptyRichTextDocument, Gi as enqueueEntry, Hi as eventCatalog, Ni as filtersFromSchema, r as formActionPath, m as formDataToInput, S as formField, t as formSections, un as freshIdempotencyKey, an as getMutationNotifier, Qt as getMutations, Rr as globalContext, o as isRichTextDocument, s as isSafeHref, kr as isUnauthenticated, qe as isUnresolvedApi, Nn as makePreloadSeedBag, Rt as makeStoreSeedBag, ii as manifestUrl, Yi as markConflict, Ji as markFailed, qi as markSent, li as openAccessReason, h as parseRichText, Jr as provenanceUrl, Mr as publishClientError, he as publishClientTrace, Hn as readPreloadedSeedOutcome, Vn as readPreloadedSnapshot, Re as registerSsrDescriptors, Qi as replayable, Pr as reportClientError, ci as requiredScopes, Un as resetPreloadSeeds, Lt as resetStoreRegistryForTests, ot as resetStoreStorageForTest, K as resolveByTag, Xi as resolveConflictEntry, at as resolveStoreStorage, xi as resolveTrackingEvent, b as resolveValidationMessage, ee as restrictToSchema, br as resumableConsumeProgram, f as richTextToPlainText, Ur as rowsToOptions, Yn as runSequence, e as schemaToColumns, x as schemaToFields, Rn as seedPreloadedSubscription, zn as seedPreloadedSubscriptionFailure, Bt as seedStore, Jn as sequence, l as serializeRichText, rn as setMutationNotifier, Fn as setPreloadSeedResolver, zt as setStoreSeedResolver, it as setStoreStorage, Zt as settleMutation, st as shallow, Di as shallowArrayEqual, Oi as sourceValues, Pe as ssrClientProxy, ze as ssrDescriptorsFor, Ve as ssrStubHandle, H as stableKey, $e as startApiSupervisor, Xt as startMutation, yt as storeHistory, Nr as subscribeClientErrors, ge as subscribeClientTraces, $t as subscribeMutations, bt as subscribeStoreHistory, ye as supersedesConfirmedPatches, St as travelToStoreState, ui as useAccessDecision, _n as useAction, Er as useAgent, Tr as useAgentChat, yr as useAgentStream, zi as useAsyncValidation, ni as useCan, ri as useCanAny, ai as useCapabilityManifest, pa as useConnection, aa as useConnectionStatus, fa as useConnections, Dr as useDataCopilot, Kr as useDataTable, Li as useDebounced, ki as useDerived, qn as useEvent, Dn as useFormBinding, kn as useFormBindingContext, An as useFormField, Hr as useFormFlash, Ti as useFormSkeleton, G as useFrameworkApi, Ke as useFrameworkRuntimes, Z as useMutation, Fr as useOnRpcError, ta as useOutbox, ti as usePermissions, Wn as usePreloadedSubscription, Wi as usePreview, Yr as useProvenance, Wr as useQueryField, Fi as useQueryFilters, Ii as useRecord, Or as useRefreshSubscriptions, Ai as useResourceCan, ji as useResourceCans, Sr as useResumableAgentStream, Xn as useSequence, Br as useServerRequest, q as useSubscription, Lr as useSubscriptionHealth, Ei as useTableSkeleton, wi as useTracking, hi as useUndo, yi as useUndoLog, nr as useUpload, bn as useValidationMessages, ra as useWindowedSubscription, rr as useWorkflow, dr as useWorkflowDomainEvents, fr as useWorkflowEventDeliveries, ur as useWorkflowEvents, or as useWorkflowRun, lr as useWorkflowRunEvents, vr as useWorkflowRunState, cr as useWorkflowRunSteps, sr as useWorkflowRuns, ir as useWorkflowSignal, ar as useWorkflowUpdate, Vi as validateEventPayload, i as validateFields, Ri as validationStatus, Ar as wireAuthRefresh, dn as withIdempotencyKey, Ci as wrapTrackedCallbacks };