@voltro/client 0.80.0 → 0.82.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,56 +1,54 @@
1
- import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, j as g, k as _, l as v, m as y, n as b, o as x, p as S, r as C, s as w, t as T, u as E, v as D, w as ee, x as te, y as O } from "./authRefresh-Ds_lYhKr.js";
2
- import { C as k, S as A, _ as ne, a as j, b as re, c as M, d as ie, f as ae, g as oe, h as N, i as se, l as ce, m as le, n as ue, o as de, p as fe, r as pe, s as me, t as he, u as ge, v as _e, w as ve, x as ye, y as be } from "./formData-dGz5aoUR.js";
3
- import { createContext as P, createElement as xe, useCallback as F, useContext as I, useDebugValue as Se, useEffect as L, useId as Ce, useMemo as R, useRef as z, useState as B, useSyncExternalStore as we } from "react";
4
- import { Cause as Te, Duration as Ee, Effect as V, Exit as De, Fiber as Oe, Option as ke, Schedule as Ae, Schema as je, Stream as H } from "effect";
5
- import * as Me from "@effect/platform/Headers";
6
- import { RpcClient as Ne } from "@effect/rpc";
7
- import { fieldIssuesOf as Pe, firstEventValue as Fe, pluginTag as Ie } from "@voltro/protocol";
8
- import { jsx as Le } from "react/jsx-runtime";
9
- import { FormApi as Re } from "@tanstack/form-core";
10
- import { useStore as ze } from "@tanstack/react-store";
11
- import { ArrayFormatter as Be } from "effect/ParseResult";
1
+ import { A as e, C as t, D as n, E as r, F as i, M as a, N as o, O as s, P as c, S as l, T as u, _ as d, a as f, b as p, c as m, d as h, f as g, g as _, h as v, i as y, j as b, k as x, l as S, m as C, n as w, o as T, p as E, r as D, s as O, t as ee, u as k, v as A, w as te, x as j, y as M } from "./authRefresh-Cu2A-H5R.js";
2
+ import { C as N, S as P, _ as ne, a as F, b as re, c as ie, d as ae, f as oe, g as se, h as ce, i as le, l as ue, m as de, n as fe, o as pe, p as me, r as he, s as ge, t as _e, u as ve, v as ye, w as be, x as xe, y as Se } from "./formData-dGz5aoUR.js";
3
+ import { createContext as I, createElement as Ce, useCallback as L, useContext as we, useDebugValue as Te, useEffect as R, useId as Ee, useMemo as z, useRef as B, useState as V, useSyncExternalStore as H } from "react";
4
+ import { Cause as De, Duration as Oe, Effect as U, Exit as ke, Fiber as Ae, Option as je, Schedule as Me, Schema as Ne, Stream as W } from "effect";
5
+ import { PAIRING_HOST as Pe, PAIRING_SCHEME as Fe, PAIRING_STORAGE_KEY as Ie, applyPairing as Le, clearPairing as Re, errorMessage as ze, errorTag as Be, fieldIssuesOf as Ve, firstEventValue as He, pairingLink as Ue, parsePairingLink as We, pluginTag as Ge, readPairing as Ke } from "@voltro/protocol";
6
+ import { jsx as qe } from "react/jsx-runtime";
7
+ import { FormApi as Je } from "@tanstack/form-core";
8
+ import { useStore as Ye } from "@tanstack/react-store";
9
+ import { ArrayFormatter as Xe } from "effect/ParseResult";
12
10
  //#region src/runtimeContext.ts
13
- var Ve = P(null), He = () => {
11
+ var Ze = I(null), Qe = () => {
14
12
  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");
15
- }, Ue = new Proxy(() => He(), {
16
- get: (e, t) => Ue,
13
+ }, $e = new Proxy(() => Qe(), {
14
+ get: (e, t) => $e,
17
15
  has: () => !0,
18
- apply: () => He()
19
- }), We = Symbol.for("@voltro/client/ssrDescriptors"), Ge = globalThis, Ke = Ge[We] ?? (Ge[We] = { byApi: /* @__PURE__ */ new Map() }), qe = (e, t) => {
20
- Ke.byApi.set(e, t);
21
- }, Je = (e) => Ke.byApi.get(e), Ye = () => {
22
- Ke.byApi.clear();
23
- }, Xe = {
24
- runtime: { runPromiseExit: () => Promise.resolve(De.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
25
- cache: new s(),
26
- client: Ue,
16
+ apply: () => Qe()
17
+ }), et = Symbol.for("@voltro/client/ssrDescriptors"), tt = globalThis, nt = tt[et] ?? (tt[et] = { byApi: /* @__PURE__ */ new Map() }), rt = (e, t) => {
18
+ nt.byApi.set(e, t);
19
+ }, it = (e) => nt.byApi.get(e), at = () => {
20
+ nt.byApi.clear();
21
+ }, ot = {
22
+ runtime: { runPromiseExit: () => Promise.resolve(ke.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
23
+ cache: new M(),
24
+ client: $e,
27
25
  descriptors: {},
28
26
  inspectBaseUrl: "",
29
- errorBus: new S(),
30
- recovery: new E("ssr")
31
- }, Ze = {
27
+ errorBus: new v(),
28
+ recovery: new g("ssr")
29
+ }, st = {
32
30
  get: (e) => {
33
- let t = Je(e);
34
- return t === void 0 ? Xe : {
35
- ...Xe,
31
+ let t = it(e);
32
+ return t === void 0 ? ot : {
33
+ ...ot,
36
34
  descriptors: t
37
35
  };
38
36
  },
39
37
  names: []
40
- }, Qe = !1, $e = !1, U = null, et = () => {
41
- Qe = !1, $e = !1, U !== null && (clearTimeout(U), U = null);
42
- }, tt = () => {
43
- let e = I(Ve);
44
- return e ? ($e || ($e = !0, U !== null && (clearTimeout(U), U = null)), e) : (globalThis.window !== void 0 && !Qe && !$e && U === null && process.env.NODE_ENV !== "production" && (U = setTimeout(() => {
45
- U = null, !(Qe || $e) && (Qe = !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>."));
46
- }, 0)), Ze);
47
- }, W = (e) => {
48
- let t = tt(), n = t.demand;
49
- return L(() => {
38
+ }, ct = !1, lt = !1, G = null, ut = () => {
39
+ ct = !1, lt = !1, G !== null && (clearTimeout(G), G = null);
40
+ }, dt = () => {
41
+ let e = we(Ze);
42
+ return e ? (lt || (lt = !0, G !== null && (clearTimeout(G), G = null)), e) : (globalThis.window !== void 0 && !ct && !lt && G === null && process.env.NODE_ENV !== "production" && (G = setTimeout(() => {
43
+ G = null, !(ct || lt) && (ct = !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>."));
44
+ }, 0)), st);
45
+ }, K = (e) => {
46
+ let t = dt(), n = t.demand;
47
+ return R(() => {
50
48
  n?.(e);
51
49
  }, [n, e]), t.get(e);
52
- }, nt = (e) => typeof e.runtime?.runFork != "function", rt = ({ apis: e, children: t, demand: n }) => {
53
- let r = R(() => ({
50
+ }, ft = (e) => typeof e.runtime?.runFork != "function", pt = ({ apis: e, children: t, demand: n }) => {
51
+ let r = z(() => ({
54
52
  get: (t) => {
55
53
  let n = e.get(t);
56
54
  if (!n) {
@@ -62,45 +60,45 @@ var Ve = P(null), He = () => {
62
60
  names: Array.from(e.keys()),
63
61
  ...n === void 0 ? {} : { demand: n }
64
62
  }), [e]);
65
- return /* @__PURE__ */ Le(Ve.Provider, {
63
+ return /* @__PURE__ */ qe(Ze.Provider, {
66
64
  value: r,
67
65
  children: t
68
66
  });
69
- }, it = Symbol.for("@voltro/client/storeStorageProvider"), at = () => {
70
- let e = globalThis, t = e[it];
67
+ }, mt = Symbol.for("@voltro/client/storeStorageProvider"), ht = () => {
68
+ let e = globalThis, t = e[mt];
71
69
  if (t !== void 0) return t;
72
70
  let n = {
73
71
  provider: void 0,
74
72
  used: !1
75
73
  };
76
- return e[it] = n, n;
77
- }, ot = (e) => {
74
+ return e[mt] = n, n;
75
+ }, gt = (e) => {
78
76
  if (typeof window > "u") return null;
79
77
  try {
80
78
  return (e === "session" ? window.sessionStorage : window.localStorage) ?? null;
81
79
  } catch {
82
80
  return null;
83
81
  }
84
- }, st = (e) => {
85
- let t = at();
82
+ }, _t = (e) => {
83
+ let t = ht();
86
84
  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;
87
- }, ct = (e) => {
88
- let t = at();
89
- return t.used = !0, (t.provider ?? ot)(e);
90
- }, lt = () => {
91
- let e = at();
85
+ }, vt = (e) => {
86
+ let t = ht();
87
+ return t.used = !0, (t.provider ?? gt)(e);
88
+ }, yt = () => {
89
+ let e = ht();
92
90
  e.provider = void 0, e.used = !1;
93
- }, ut = (e, t) => {
91
+ }, bt = (e, t) => {
94
92
  if (Object.is(e, t)) return !0;
95
93
  if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
96
94
  let n = Object.keys(e), r = Object.keys(t);
97
95
  if (n.length !== r.length) return !1;
98
96
  for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
99
97
  return !0;
100
- }, dt = 50, ft = /* @__PURE__ */ new Set(), pt = (e, t) => {
101
- ft.has(e) || (ft.add(e), console.warn(t));
102
- }, mt = "\0global", ht = null, gt = (e, t, n) => {
103
- let r = ht?.() ?? null;
98
+ }, xt = 50, St = /* @__PURE__ */ new Set(), Ct = (e, t) => {
99
+ St.has(e) || (St.add(e), console.warn(t));
100
+ }, wt = "\0global", Tt = null, Et = (e, t, n) => {
101
+ let r = Tt?.() ?? null;
104
102
  if (r === null) return n;
105
103
  let i = n;
106
104
  for (let n of r.seeds) n.store === e && n.key === t && (i = {
@@ -108,9 +106,9 @@ var Ve = P(null), He = () => {
108
106
  ...n.value
109
107
  });
110
108
  return i;
111
- }, _t = (e, t) => {
109
+ }, Dt = (e, t) => {
112
110
  let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
113
- if (i >= dt) throw i = 0, Error(`defineStore: notification depth exceeded ${dt} — 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.`);
111
+ if (i >= xt) throw i = 0, Error(`defineStore: notification depth exceeded ${xt} — 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.`);
114
112
  i += 1;
115
113
  try {
116
114
  for (let e of [...r]) e();
@@ -131,20 +129,20 @@ var Ve = P(null), He = () => {
131
129
  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}', () => { … })\`.`);
132
130
  if (--a, a > 0) return;
133
131
  let l = o, u = s;
134
- o = void 0, s = void 0, !ut(l, n) && (t(l, n, u), c());
132
+ o = void 0, s = void 0, !bt(l, n) && (t(l, n, u), c());
135
133
  },
136
134
  set: (e, r) => {
137
135
  let i = typeof e == "function" ? e(n) : {
138
136
  ...n,
139
137
  ...e
140
138
  };
141
- if (ut(i, n)) return;
139
+ if (bt(i, n)) return;
142
140
  let o = n;
143
141
  n = i, !(a > 0) && (t(o, i, r), c());
144
142
  },
145
143
  reset: () => {
146
144
  let r = e();
147
- if (ut(r, n)) return;
145
+ if (bt(r, n)) return;
148
146
  let i = n;
149
147
  n = r, !(a > 0) && (t(i, r, "reset"), c());
150
148
  },
@@ -152,51 +150,51 @@ var Ve = P(null), He = () => {
152
150
  r.delete(e);
153
151
  })
154
152
  };
155
- }, vt = 200, yt = [], bt = /* @__PURE__ */ new Set(), xt = [], St = () => xt, Ct = (e) => (bt.add(e), () => {
156
- bt.delete(e);
157
- }), wt = () => {
158
- yt.length = 0, xt = [];
159
- }, Tt = (e, t) => {
160
- let n = yt[e];
153
+ }, Ot = 200, kt = [], At = /* @__PURE__ */ new Set(), jt = [], Mt = () => jt, Nt = (e) => (At.add(e), () => {
154
+ At.delete(e);
155
+ }), Pt = () => {
156
+ kt.length = 0, jt = [];
157
+ }, Ft = (e, t) => {
158
+ let n = kt[e];
161
159
  if (n === void 0) return !1;
162
- let r = kt.get(n.store);
160
+ let r = zt.get(n.store);
163
161
  if (r === void 0) return !1;
164
162
  let i = t === "before" ? n.prev : n.next;
165
- Dt = !0;
163
+ Lt = !0;
166
164
  try {
167
165
  r.set(() => i, n.key, `travel:${t}`);
168
166
  } finally {
169
- Dt = !1;
167
+ Lt = !1;
170
168
  }
171
169
  return !0;
172
- }, Et = !1, Dt = !1, Ot = (e) => {
173
- yt.push(e), yt.length > vt && yt.shift(), xt = [...yt];
174
- for (let e of [...bt]) e();
175
- }, kt = /* @__PURE__ */ new Map(), At = /* @__PURE__ */ new Map(), jt = 0, Mt = !1, Nt = /* @__PURE__ */ new Map(), Pt = () => (Mt || (Mt = !0, queueMicrotask(() => {
176
- jt += 1, Mt = !1;
177
- })), jt), Ft = It(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
178
- function It(e) {
170
+ }, It = !1, Lt = !1, Rt = (e) => {
171
+ kt.push(e), kt.length > Ot && kt.shift(), jt = [...kt];
172
+ for (let e of [...At]) e();
173
+ }, zt = /* @__PURE__ */ new Map(), Bt = /* @__PURE__ */ new Map(), Vt = 0, Ht = !1, Ut = /* @__PURE__ */ new Map(), Wt = () => (Ht || (Ht = !0, queueMicrotask(() => {
174
+ Vt += 1, Ht = !1;
175
+ })), Vt), Gt = Kt(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
176
+ function Kt(e) {
179
177
  let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
180
178
  return n.length > 0 ? n : void 0;
181
179
  }
182
- var Lt = () => {
180
+ var qt = () => {
183
181
  let e = (/* @__PURE__ */ Error()).stack;
184
182
  if (typeof e != "string") return "<unknown>";
185
183
  for (let t of e.split("\n").slice(1)) {
186
- let e = It(t);
184
+ let e = Kt(t);
187
185
  if (e === void 0) continue;
188
186
  let n = e.replace(/:\d+:\d+$/, "");
189
- if (Ft === "" || n !== Ft.replace(/:\d+:\d+$/, "")) return n;
187
+ if (Gt === "" || n !== Gt.replace(/:\d+:\d+$/, "")) return n;
190
188
  }
191
189
  return "<unknown>";
192
- }, Rt = () => [...kt.values()], zt = (e, t, n) => {
193
- let r = Lt(), i = Pt(), a = kt.get(e);
190
+ }, Jt = () => [...zt.values()], Yt = (e, t, n) => {
191
+ let r = qt(), i = Wt(), a = zt.get(e);
194
192
  if (a !== void 0) {
195
- let t = At.get(e) ?? "<unknown>", n = Nt.get(e) === i;
193
+ let t = Bt.get(e) ?? "<unknown>", n = Ut.get(e) === i;
196
194
  if (r !== "<unknown>" && r === t && !n) return a;
197
195
  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}`);
198
196
  }
199
- let o = n?.persist, s = () => ct(o?.storage === "session" ? "session" : "local"), c = () => {
197
+ let o = n?.persist, s = () => vt(o?.storage === "session" ? "session" : "local"), c = () => {
200
198
  let e = s();
201
199
  if (e === null || o === void 0) return;
202
200
  let t;
@@ -221,28 +219,28 @@ var Lt = () => {
221
219
  t.setItem(o.key, JSON.stringify(n));
222
220
  } catch {}
223
221
  }, u = /* @__PURE__ */ new Map(), d = (n) => {
224
- let r = n ?? mt, i = u.get(r);
222
+ let r = n ?? wt, i = u.get(r);
225
223
  if (i === void 0) {
226
224
  let a = n;
227
- i = _t(o !== void 0 && n === void 0 ? () => {
225
+ i = Dt(o !== void 0 && n === void 0 ? () => {
228
226
  let e = t();
229
227
  return f = e, {
230
228
  ...e,
231
229
  ...c() ?? {}
232
230
  };
233
231
  } : t, (t, n, r) => {
234
- if (o !== void 0 && a === void 0 && l(n), !Et && !Dt) {
232
+ if (o !== void 0 && a === void 0 && l(n), !It && !Lt) {
235
233
  let e = m(a);
236
234
  e.steps.length = e.cursor, e.steps.push({
237
235
  prev: t,
238
236
  next: n
239
237
  }), e.steps.length > h && e.steps.shift(), e.cursor = e.steps.length;
240
238
  }
241
- Ot({
239
+ Rt({
242
240
  store: e,
243
241
  ...a === void 0 ? {} : { key: a },
244
242
  ...r === void 0 ? {} : { label: r },
245
- ...Et || Dt ? { isUndo: !0 } : {},
243
+ ...It || Lt ? { isUndo: !0 } : {},
246
244
  prev: t,
247
245
  next: n,
248
246
  at: Date.now()
@@ -251,7 +249,7 @@ var Lt = () => {
251
249
  }
252
250
  return i;
253
251
  }, f, p = /* @__PURE__ */ new Map(), m = (e) => {
254
- let t = e ?? mt, n = p.get(t);
252
+ let t = e ?? wt, n = p.get(t);
255
253
  return n === void 0 && (n = {
256
254
  steps: [],
257
255
  cursor: 0
@@ -271,24 +269,24 @@ var Lt = () => {
271
269
  }, b = {
272
270
  name: e,
273
271
  use: (t, n) => {
274
- let r = d(n?.key), i = z(t);
272
+ let r = d(n?.key), i = B(t);
275
273
  i.current = t;
276
- let a = z(n?.equals);
274
+ let a = B(n?.equals);
277
275
  a.current = n?.equals;
278
- let o = z({
276
+ let o = B({
279
277
  state: void 0,
280
278
  value: void 0,
281
279
  has: !1
282
- }), s = F((t) => {
280
+ }), s = L((t) => {
283
281
  let n = o.current;
284
282
  if (n.has && Object.is(n.state, t)) return n.value;
285
283
  let r = i.current(t), s = a.current, c = n.has && (s ? s(n.value, r) : Object.is(n.value, r));
286
- if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && ut(n.value, r)) {
284
+ if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && bt(n.value, r)) {
287
285
  let t = !0;
288
286
  try {
289
287
  t = !Object.is(i.current(n.state), n.value);
290
288
  } catch {}
291
- pt(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.`);
289
+ Ct(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.`);
292
290
  }
293
291
  let l = c ? n.value : r;
294
292
  return o.current = {
@@ -296,7 +294,7 @@ var Lt = () => {
296
294
  value: l,
297
295
  has: !0
298
296
  }, l;
299
- }, []), c = n?.key, l = n?.retain === !0, u = F((e) => {
297
+ }, []), c = n?.key, l = n?.retain === !0, u = L((e) => {
300
298
  let t = r.subscribe(e);
301
299
  return c !== void 0 && !l && v(c), () => {
302
300
  t(), c !== void 0 && !l && y(c);
@@ -305,12 +303,12 @@ var Lt = () => {
305
303
  r,
306
304
  c,
307
305
  l
308
- ]), p = F(() => s(r.get()), [r, s]), m = F(() => s(gt(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
306
+ ]), p = L(() => s(r.get()), [r, s]), m = L(() => s(Et(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
309
307
  r,
310
308
  n?.key,
311
309
  s
312
- ]), h = we(u, p, m);
313
- return Se(h), h;
310
+ ]), h = H(u, p, m);
311
+ return Te(h), h;
314
312
  },
315
313
  instance: d,
316
314
  get: (e) => d(e).get(),
@@ -323,11 +321,11 @@ var Lt = () => {
323
321
  undo: (e) => {
324
322
  let t = m(e);
325
323
  if (t.cursor === 0) return !1;
326
- --t.cursor, Et = !0;
324
+ --t.cursor, It = !0;
327
325
  try {
328
326
  d(e).set(() => t.steps[t.cursor].prev, "undo");
329
327
  } finally {
330
- Et = !1;
328
+ It = !1;
331
329
  }
332
330
  return !0;
333
331
  },
@@ -335,11 +333,11 @@ var Lt = () => {
335
333
  let t = m(e);
336
334
  if (t.cursor >= t.steps.length) return !1;
337
335
  let n = t.steps[t.cursor];
338
- t.cursor += 1, Et = !0;
336
+ t.cursor += 1, It = !0;
339
337
  try {
340
338
  d(e).set(() => n.next, "redo");
341
339
  } finally {
342
- Et = !1;
340
+ It = !1;
343
341
  }
344
342
  return !0;
345
343
  },
@@ -351,136 +349,321 @@ var Lt = () => {
351
349
  release: (e) => {
352
350
  u.delete(e), p.delete(e);
353
351
  },
354
- keys: () => [...u.keys()].filter((e) => e !== mt)
352
+ keys: () => [...u.keys()].filter((e) => e !== wt)
355
353
  };
356
- return kt.set(e, b), At.set(e, r), Nt.set(e, i), b;
357
- }, Bt = () => {
358
- kt.clear(), At.clear(), Nt.clear(), ft.clear();
359
- }, Vt = () => ({ seeds: [] }), Ht = (e) => {
360
- ht = e;
361
- }, Ut = (e, t, n) => {
362
- let r = ht?.() ?? null;
354
+ return zt.set(e, b), Bt.set(e, r), Ut.set(e, i), b;
355
+ }, Xt = () => {
356
+ zt.clear(), Bt.clear(), Ut.clear(), St.clear();
357
+ }, Zt = () => ({ seeds: [] }), Qt = (e) => {
358
+ Tt = e;
359
+ }, $t = (e, t, n) => {
360
+ let r = Tt?.() ?? null;
363
361
  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.)`);
364
362
  r.seeds.push({
365
363
  store: e.name,
366
364
  ...n?.key === void 0 ? {} : { key: n.key },
367
365
  value: t
368
366
  });
369
- }, Wt = (e) => {
367
+ }, en = (e) => {
370
368
  if (e !== void 0) for (let t of e) {
371
- let e = kt.get(t.store);
369
+ let e = zt.get(t.store);
372
370
  e !== void 0 && e.set(t.value, t.key);
373
371
  }
374
- }, Gt = Object.freeze({
372
+ }, tn = {
373
+ read: () => typeof navigator > "u" || navigator.onLine,
374
+ subscribe: (e) => {
375
+ if (typeof window > "u") return () => {};
376
+ let t = () => e(!0), n = () => e(!1);
377
+ return window.addEventListener("online", t), window.addEventListener("offline", n), () => {
378
+ window.removeEventListener("online", t), window.removeEventListener("offline", n);
379
+ };
380
+ }
381
+ }, nn = (e, t = {}) => {
382
+ let n = e.platform.shell !== "browser" && e.platform.shell !== "node" && e.platform.shell !== "test";
383
+ return {
384
+ offlineStart: e.platform.installed || n,
385
+ secureTokenStorage: e.secureStorage.kind !== "none",
386
+ push: e.notifications?.pushToken !== void 0,
387
+ localNotifications: e.notifications?.show !== void 0,
388
+ updates: e.updates !== void 0,
389
+ deepLinks: !0,
390
+ biometrics: e.biometrics !== void 0,
391
+ backgroundSync: e.platform.shell === "tauri" || e.platform.shell === "electron",
392
+ installPrompt: e.platform.shell === "browser" && !e.platform.installed,
393
+ ...t
394
+ };
395
+ }, rn = (e) => {
396
+ let { capabilities: t, ...n } = e;
397
+ return {
398
+ ...n,
399
+ capabilities: nn(n, t)
400
+ };
401
+ }, an = (e) => ({
402
+ kind: "none",
403
+ get: async () => null,
404
+ set: async () => {
405
+ throw Error(`secureStorage: ${e}`);
406
+ },
407
+ delete: async () => {}
408
+ }), on = () => {
409
+ let e = /* @__PURE__ */ new Map();
410
+ return {
411
+ kind: "memory",
412
+ get: async (t) => e.get(t) ?? null,
413
+ set: async (t, n) => {
414
+ e.set(t, n);
415
+ },
416
+ delete: async (t) => {
417
+ e.delete(t);
418
+ }
419
+ };
420
+ }, sn = {
421
+ read: () => typeof document > "u" ? "active" : document.visibilityState === "hidden" ? "background" : "active",
422
+ subscribe: (e) => {
423
+ if (typeof document > "u") return () => {};
424
+ let t = () => e(document.visibilityState === "hidden" ? "background" : "active");
425
+ return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
426
+ }
427
+ }, cn = {
428
+ initialUrl: async () => typeof location > "u" ? null : location.href,
429
+ subscribe: () => () => {}
430
+ }, ln = () => {
431
+ if (typeof Notification > "u") return;
432
+ let e = (e) => e === "granted" ? "granted" : e === "denied" ? "denied" : "prompt";
433
+ return {
434
+ permission: async () => e(Notification.permission),
435
+ requestPermission: async () => e(await Notification.requestPermission()),
436
+ show: async (e) => {
437
+ new Notification(e.title, {
438
+ ...e.body === void 0 ? {} : { body: e.body },
439
+ ...e.data === void 0 ? {} : { data: e.data }
440
+ });
441
+ }
442
+ };
443
+ }, un = () => {
444
+ if (typeof window > "u") return !1;
445
+ let e = window.matchMedia;
446
+ return typeof e == "function" && e.call(window, "(display-mode: standalone)").matches ? !0 : navigator.standalone === !0;
447
+ }, dn = (e, t) => {
448
+ let n = globalThis.WebSocket;
449
+ if (n === void 0) throw Error("platform: no global WebSocket in this environment");
450
+ return t === void 0 ? new n(e) : new n(e, t);
451
+ }, fn = (e = {}) => {
452
+ let t = typeof window < "u", n = un(), r = t ? navigator.userAgent : "", i = t ? /jsdom/i.test(r) ? "test" : "browser" : "node", a = ln();
453
+ return rn({
454
+ platform: {
455
+ kind: n ? "pwa" : "web",
456
+ shell: i,
457
+ installed: n
458
+ },
459
+ webSocket: dn,
460
+ storage: gt,
461
+ secureStorage: an("a browser tab has no secure store a page can read; the session is an HttpOnly cookie the server sets"),
462
+ online: tn,
463
+ lifecycle: sn,
464
+ links: cn,
465
+ ...a === void 0 ? {} : { notifications: a },
466
+ clock: { now: () => Date.now() },
467
+ ...e
468
+ });
469
+ }, pn = Symbol.for("@voltro/client/platform"), mn = () => {
470
+ let e = globalThis, t = e[pn];
471
+ if (t !== void 0) return t;
472
+ let n = {
473
+ adapter: void 0,
474
+ fallback: void 0,
475
+ listeners: /* @__PURE__ */ new Set()
476
+ };
477
+ return e[pn] = n, n;
478
+ }, hn = (e) => {
479
+ let t = mn();
480
+ t.adapter = e, _t(e.storage);
481
+ for (let e of t.listeners) e();
482
+ }, gn = () => {
483
+ let e = mn();
484
+ return e.adapter === void 0 ? (e.fallback === void 0 && (e.fallback = fn()), e.fallback) : e.adapter;
485
+ }, _n = () => mn().adapter !== void 0, vn = () => {
486
+ let e = mn();
487
+ e.adapter = void 0, e.fallback = void 0, _t(null);
488
+ for (let t of e.listeners) t();
489
+ }, yn = (e) => {
490
+ let t = mn();
491
+ return t.listeners.add(e), () => {
492
+ t.listeners.delete(e);
493
+ };
494
+ }, bn = () => H(yn, gn, gn), xn = (e) => bn().extensions?.[e] ?? null, Sn = (e) => {
495
+ let t = e.pattern;
496
+ if (t.length === 0 || t[0] !== "/") throw Error(`defineDeepLink: pattern must start with "/" (got "${t}")`);
497
+ return {
498
+ _tag: "VoltroDeepLink",
499
+ pattern: t,
500
+ handler: e.handler
501
+ };
502
+ }, Cn = (e) => {
503
+ let t = e, n = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\//.exec(t);
504
+ if (n) {
505
+ let e = t.slice(n[0].length), r = n[1].toLowerCase();
506
+ if (r === "http" || r === "https") {
507
+ let n = e.indexOf("/");
508
+ t = n === -1 ? "/" : e.slice(n);
509
+ } else t = `/${e}`;
510
+ }
511
+ let r = t.search(/[?#]/);
512
+ return r !== -1 && (t = t.slice(0, r)), t.split("/").filter((e) => e.length > 0).map((e) => {
513
+ try {
514
+ return decodeURIComponent(e);
515
+ } catch {
516
+ return e;
517
+ }
518
+ });
519
+ }, wn = (e, t) => {
520
+ let n = Cn(e), r = Cn(t);
521
+ if (n.length !== r.length) return null;
522
+ let i = {};
523
+ for (let e = 0; e < n.length; e++) {
524
+ let t = n[e], a = r[e];
525
+ if (t.startsWith(":")) {
526
+ let e = t.slice(1);
527
+ if (e.length === 0) return null;
528
+ i[e] = a;
529
+ } else if (t !== "*" && t !== a) return null;
530
+ }
531
+ return i;
532
+ }, Tn = (e, t) => {
533
+ let n = wn(e.pattern, t);
534
+ return n === null ? null : (e.handler(n), n);
535
+ }, En = (e, t) => {
536
+ let n = e.split("/").map((n) => {
537
+ if (!n.startsWith(":")) return n;
538
+ let r = n.slice(1), i = t[r];
539
+ if (i === void 0) throw Error(`deepLinkHref: pattern "${e}" needs a ":${r}" param`);
540
+ return encodeURIComponent(i);
541
+ }).join("/");
542
+ return n.length === 0 ? "/" : n;
543
+ }, Dn = (e, t) => {
544
+ for (let n of e) {
545
+ let e = wn(n.pattern, t);
546
+ if (e !== null) return {
547
+ descriptor: n,
548
+ params: e
549
+ };
550
+ }
551
+ return null;
552
+ }, On = (e, t) => {
553
+ let n = Dn(e, t);
554
+ if (n === null) return null;
555
+ let r = n.descriptor.handler;
556
+ return r(n.params), n.params;
557
+ }, kn = Object.freeze({
375
558
  data: void 0,
376
559
  revision: -1,
377
560
  emittedAt: void 0,
378
561
  error: void 0,
379
562
  pendingPatches: 0
380
- }), Kt = () => Gt;
381
- function G(e, t, n = {}, r = {}) {
382
- let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = W(e), l = c[t]?.source, u = z(n);
563
+ }), An = () => kn;
564
+ function q(e, t, n = {}, r = {}) {
565
+ let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = K(e), l = c[t]?.source, u = B(n);
383
566
  u.current = n;
384
- let d = z(s);
567
+ let d = B(s);
385
568
  d.current = s;
386
- let f = R(() => JSON.stringify(Object.entries(n).sort(([e], [t]) => e.localeCompare(t))), [n]), p = R(() => {
569
+ let f = z(() => JSON.stringify(Object.entries(n).sort(([e], [t]) => e.localeCompare(t))), [n]), p = z(() => {
387
570
  let e = u.current;
388
571
  return {
389
572
  queryKey: [t, e],
390
- fetch: () => h(d.current, t)(e)
573
+ fetch: () => T(d.current, t)(e)
391
574
  };
392
- }, [t, f]), m = p.queryKey, g = F((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
575
+ }, [t, f]), m = p.queryKey, h = L((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
393
576
  o,
394
577
  a,
395
578
  l,
396
579
  i,
397
580
  p
398
- ]), _ = F(() => i ? Gt : o.peek(m), [
581
+ ]), g = L(() => i ? kn : o.peek(m), [
399
582
  o,
400
583
  i,
401
584
  m
402
- ]), v = we(g, _, Kt), y = v.data !== void 0, b = y && (Array.isArray(v.data) ? v.data.length === 0 : v.data === null), x = {
403
- revision: v.revision,
404
- emittedAt: v.emittedAt,
405
- error: v.error,
406
- pendingPatches: v.pendingPatches
585
+ ]), _ = H(h, g, An), v = _.data !== void 0, y = v && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), b = {
586
+ revision: _.revision,
587
+ emittedAt: _.emittedAt,
588
+ error: _.error,
589
+ pendingPatches: _.pendingPatches
407
590
  };
408
591
  if (r.initialSnapshot !== void 0) {
409
592
  let e = Array.isArray(r.initialSnapshot) ? r.initialSnapshot.length === 0 : r.initialSnapshot === null;
410
593
  return {
411
- ...x,
412
- data: y ? v.data : r.initialSnapshot,
594
+ ...b,
595
+ data: v ? _.data : r.initialSnapshot,
413
596
  loading: !1,
414
597
  idle: i,
415
- isEmpty: y ? b : e,
598
+ isEmpty: v ? y : e,
416
599
  failed: !1
417
600
  };
418
601
  }
419
602
  return r.fallback === void 0 ? i ? {
420
- ...x,
603
+ ...b,
421
604
  data: void 0,
422
605
  loading: !1,
423
606
  isEmpty: !1,
424
607
  idle: !0,
425
608
  failed: !1
426
- } : y ? {
427
- ...x,
428
- data: v.data,
609
+ } : v ? {
610
+ ...b,
611
+ data: _.data,
429
612
  loading: !1,
430
- isEmpty: b,
613
+ isEmpty: y,
431
614
  idle: !1,
432
615
  failed: !1
433
- } : x.error === void 0 ? {
434
- ...x,
616
+ } : b.error === void 0 ? {
617
+ ...b,
435
618
  data: void 0,
436
619
  loading: !0,
437
620
  isEmpty: !1,
438
621
  idle: !1,
439
622
  failed: !1
440
623
  } : {
441
- ...x,
624
+ ...b,
442
625
  data: void 0,
443
626
  loading: !1,
444
627
  isEmpty: !1,
445
628
  idle: !1,
446
629
  failed: !0,
447
- error: x.error
630
+ error: b.error
448
631
  } : {
449
- ...x,
450
- data: y ? v.data : r.fallback,
451
- loading: !y && !i,
632
+ ...b,
633
+ data: v ? _.data : r.fallback,
634
+ loading: !v && !i,
452
635
  idle: i,
453
- isEmpty: b,
454
- failed: !y && x.error !== void 0
636
+ isEmpty: y,
637
+ failed: !v && b.error !== void 0
455
638
  };
456
639
  }
457
640
  //#endregion
458
641
  //#region src/awaitResolvedApi.ts
459
- var qt = 15e3, K = async (e, t, n) => {
460
- if (!nt(e.current)) return e.current;
461
- let r = Date.now() + qt;
462
- for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !nt(e.current)) return e.current;
463
- throw Error(`Voltro: the api "${t}" did not resolve within ${qt}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.`);
464
- }, Jt = 100, q = [], Yt = /* @__PURE__ */ new Set(), Xt = [], Zt = () => {
465
- Xt = q.slice();
466
- }, Qt = () => {
467
- Zt();
468
- for (let e of Yt) try {
642
+ var jn = 15e3, J = async (e, t, n) => {
643
+ if (!ft(e.current)) return e.current;
644
+ let r = Date.now() + jn;
645
+ for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !ft(e.current)) return e.current;
646
+ throw Error(`Voltro: the api "${t}" did not resolve within ${jn}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.`);
647
+ }, Mn = 100, Y = [], Nn = /* @__PURE__ */ new Set(), Pn = [], Fn = () => {
648
+ Pn = Y.slice();
649
+ }, In = () => {
650
+ Fn();
651
+ for (let e of Nn) try {
469
652
  e();
470
653
  } catch {}
471
- }, $t = (e) => {
654
+ }, Ln = (e) => {
472
655
  let t = {
473
656
  ...e,
474
657
  kind: e.kind ?? "mutation",
475
658
  status: "pending",
476
659
  startedAt: Date.now()
477
660
  };
478
- q.unshift(t), q.length > Jt && (q.length = Jt), Qt();
479
- }, J = (e, t) => {
480
- let n = q.findIndex((t) => t.id === e);
661
+ Y.unshift(t), Y.length > Mn && (Y.length = Mn), In();
662
+ }, X = (e, t) => {
663
+ let n = Y.findIndex((t) => t.id === e);
481
664
  if (n === -1) return;
482
- let r = q[n], i = Date.now();
483
- q[n] = t.status === "success" ? {
665
+ let r = Y[n], i = Date.now();
666
+ Y[n] = t.status === "success" ? {
484
667
  ...r,
485
668
  status: "success",
486
669
  output: t.output,
@@ -492,45 +675,42 @@ var qt = 15e3, K = async (e, t, n) => {
492
675
  error: t.error,
493
676
  settledAt: i,
494
677
  durationMs: i - r.startedAt
495
- }, Qt();
496
- }, en = () => Xt, tn = (e) => (Yt.add(e), () => {
497
- Yt.delete(e);
498
- }), nn = () => {
499
- q.length !== 0 && (q.length = 0, Qt());
500
- }, rn = /* @__PURE__ */ new WeakMap(), an = (e, t) => {
678
+ }, In();
679
+ }, Rn = () => Pn, zn = (e) => (Nn.add(e), () => {
680
+ Nn.delete(e);
681
+ }), Bn = () => {
682
+ Y.length !== 0 && (Y.length = 0, In());
683
+ }, Vn = /* @__PURE__ */ new WeakMap(), Hn = (e, t) => {
501
684
  let n = Object.freeze({
502
685
  apiName: e,
503
686
  kind: "connection-setup"
504
687
  });
505
- return rn.set(n, t), n;
506
- }, on = (e, t) => {
507
- let n = rn.get(e);
688
+ return Vn.set(n, t), n;
689
+ }, Un = (e, t) => {
690
+ let n = Vn.get(e);
508
691
  if (n === void 0 || e.apiName !== t) throw Error(`Voltro: connection setup must belong to api "${t}"`);
509
692
  return n;
510
- }, sn = /* @__PURE__ */ new WeakMap(), cn = (e, t) => {
511
- sn.set(e, t);
512
- }, ln = (e) => sn.get(e)?.capture(), un = 0, dn = () => {
513
- let e = typeof crypto < "u" ? crypto : void 0;
514
- return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${un += 1}`;
515
- }, fn = (e, t) => e.pipe(V.locallyWith(Ne.currentHeaders, (e) => Me.set(e, "idempotency-key", t))), Y = class extends Error {
693
+ }, Wn = /* @__PURE__ */ new WeakMap(), Gn = (e, t) => {
694
+ Wn.set(e, t);
695
+ }, Kn = (e) => Wn.get(e)?.capture(), qn = class extends Error {
516
696
  reason;
517
697
  _tag = "MutationSerialExecutionError";
518
698
  constructor(e) {
519
699
  super(`Serial mutation cannot start: ${e}`), this.reason = e, this.name = "MutationSerialExecutionError";
520
700
  }
521
- }, pn = (e = 32) => {
701
+ }, Jn = (e = 32) => {
522
702
  if (!Number.isSafeInteger(e) || e < 1) throw RangeError("maxPending must be a positive safe integer");
523
703
  let t = /* @__PURE__ */ new WeakMap(), n = 0;
524
704
  return { reserve(r, i) {
525
- if (typeof r != "string" || r.length === 0) throw new Y("invalid-key");
526
- if (i.aborted) throw new Y("scope-changed");
705
+ if (typeof r != "string" || r.length === 0) throw new qn("invalid-key");
706
+ if (i.aborted) throw new qn("scope-changed");
527
707
  let a = t.get(i);
528
708
  a === void 0 && (a = /* @__PURE__ */ new Map(), t.set(i, a));
529
709
  let o = a, s = a.get(r);
530
- if (s?.blocked.signal.aborted) throw new Y("unknown-predecessor");
531
- if (n >= e) throw new Y("capacity");
710
+ if (s?.blocked.signal.aborted) throw new qn("unknown-predecessor");
711
+ if (n >= e) throw new qn("capacity");
532
712
  s === void 0 && (s = {
533
- semaphore: V.unsafeMakeSemaphore(1),
713
+ semaphore: U.unsafeMakeSemaphore(1),
534
714
  calls: 0,
535
715
  blocked: new AbortController()
536
716
  }, a.set(r, s));
@@ -539,9 +719,9 @@ var qt = 15e3, K = async (e, t, n) => {
539
719
  let l = new AbortController(), u = () => l.abort();
540
720
  i.addEventListener("abort", u, { once: !0 }), c.blocked.signal.addEventListener("abort", u, { once: !0 });
541
721
  let d = () => {
542
- if (i.aborted) throw new Y("scope-changed");
543
- if (c.blocked.signal.aborted) throw new Y("unknown-predecessor");
544
- }, f = V.runPromise(c.semaphore.take(1), { signal: l.signal }), p = f.then(() => {
722
+ if (i.aborted) throw new qn("scope-changed");
723
+ if (c.blocked.signal.aborted) throw new qn("unknown-predecessor");
724
+ }, f = U.runPromise(c.semaphore.take(1), { signal: l.signal }), p = f.then(() => {
545
725
  d();
546
726
  }, (e) => {
547
727
  throw d(), e;
@@ -553,19 +733,19 @@ var qt = 15e3, K = async (e, t, n) => {
553
733
  assertActive: d,
554
734
  release(e) {
555
735
  m || (m = !0, e === "unknown" && c.blocked.abort(), f.then(() => {
556
- V.runSync(c.semaphore.release(1));
736
+ U.runSync(c.semaphore.release(1));
557
737
  }, () => {}).finally(() => {
558
738
  i.removeEventListener("abort", u), c.blocked.signal.removeEventListener("abort", u), --n, --c.calls, c.calls === 0 && !c.blocked.signal.aborted && o.delete(r);
559
739
  }));
560
740
  }
561
741
  };
562
742
  } };
563
- }, mn = /* @__PURE__ */ new WeakMap(), hn = (e, t, n) => {
564
- let r = mn.get(e);
565
- r === void 0 && (r = /* @__PURE__ */ new Map(), mn.set(e, r));
743
+ }, Yn = /* @__PURE__ */ new WeakMap(), Xn = (e, t, n) => {
744
+ let r = Yn.get(e);
745
+ r === void 0 && (r = /* @__PURE__ */ new Map(), Yn.set(e, r));
566
746
  let i = r.get(t);
567
- return i === void 0 && (i = pn(n), r.set(t, i)), i;
568
- }, gn = (e, t) => {
747
+ return i === void 0 && (i = Jn(n), r.set(t, i)), i;
748
+ }, Zn = (e, t) => {
569
749
  if (t === void 0 || typeof e != "object" || !e) return e;
570
750
  try {
571
751
  Object.defineProperty(e, "__voltroTraceId", {
@@ -575,188 +755,188 @@ var qt = 15e3, K = async (e, t, n) => {
575
755
  });
576
756
  } catch {}
577
757
  return e;
578
- }, _n, vn = (e) => {
579
- _n = e;
580
- }, yn = () => _n, bn = (e, t, n) => typeof e == "function" ? e(t, n) : e, xn = 0, Sn = () => `mut_${++xn}`, Cn = (e, t) => ({
758
+ }, Qn, $n = (e) => {
759
+ Qn = e;
760
+ }, er = () => Qn, tr = (e, t, n) => typeof e == "function" ? e(t, n) : e, nr = 0, rr = () => `mut_${++nr}`, ir = (e, t) => ({
581
761
  update: (n, r) => {
582
762
  e.update(n, r, t);
583
763
  },
584
764
  forTag: (n, r) => e.forTag(n, r, t)
585
- }), X = (e, t) => {
586
- let n = W(e), { descriptors: r } = n, a = z(n);
587
- a.current = n;
588
- let o = r[t], s = o?.targets;
765
+ }), ar = (t, n) => {
766
+ let r = K(t), { descriptors: i } = r, a = B(r);
767
+ a.current = r;
768
+ let o = i[n], s = o?.targets;
589
769
  if (process.env.NODE_ENV !== "production") {
590
- let n = o?.kind;
591
- 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.`);
770
+ let e = o?.kind;
771
+ e !== void 0 && e !== "mutation" && console.error(`[@voltro/client] useMutation('${t}', '${n}') targets a ${e}, not a mutation. Use ${e === "action" ? "useAction" : e === "workflow" ? "useWorkflow" : `the ${e} hook`} instead.`);
592
772
  }
593
- let [c, l] = B(!1), [f, p] = B(void 0), [m, g] = B(void 0), v = z(null), y = z(!1), b = z(0), x = F(async (n, r) => {
594
- let o = r?.onError !== void 0 || r?.notify?.error !== void 0, c = (e) => {
595
- r?.onError?.(e, n);
596
- let t = bn(r?.notify?.error, e, n);
597
- t !== void 0 && _n?.error(t);
773
+ let [c, l] = V(!1), [u, d] = V(void 0), [p, m] = V(void 0), h = B(null), g = B(!1), _ = B(0), v = L(async (r, i) => {
774
+ let o = i?.onError !== void 0 || i?.notify?.error !== void 0, c = (e) => {
775
+ i?.onError?.(e, r);
776
+ let t = tr(i?.notify?.error, e, r);
777
+ t !== void 0 && Qn?.error(t);
598
778
  };
599
- b.current += 1;
600
- let f = () => l(--b.current > 0);
601
- l(!0), p(void 0);
602
- let m, S, w, T, E;
779
+ _.current += 1;
780
+ let u = () => l(--_.current > 0);
781
+ l(!0), d(void 0);
782
+ let p, x, S, C, w;
603
783
  try {
604
- T = ln(x);
605
- let r = a.current.descriptors[t]?.serialize;
606
- if (r !== void 0) {
607
- let i = a.current, o = i.recovery ?? d(i.errorBus, e);
608
- E = hn(i.descriptors, t, r.maxPending ?? 32).reserve(r.key(n), o.subjectSignal);
784
+ C = Kn(v);
785
+ let e = a.current.descriptors[n]?.serialize;
786
+ if (e !== void 0) {
787
+ let i = a.current, o = i.recovery ?? E(i.errorBus, t);
788
+ w = Xn(i.descriptors, n, e.maxPending ?? 32).reserve(e.key(r), o.subjectSignal);
609
789
  }
610
- ({runtime: m, cache: S, client: w} = await K(a, e, t));
790
+ ({runtime: p, cache: x, client: S} = await J(a, t, n));
611
791
  } catch (e) {
612
- if (E?.release(), f(), p(e), a.current.errorBus.emit({
792
+ if (w?.release(), u(), d(e), a.current.errorBus.emit({
613
793
  source: "mutation",
614
- tag: t,
794
+ tag: n,
615
795
  error: e,
616
796
  kind: "client",
617
797
  outcome: "not-started"
618
798
  }), o) return c(e);
619
799
  throw e;
620
800
  }
621
- let D = Sn(), ee = r?.idempotencyKey ?? dn();
622
- $t({
623
- id: D,
624
- apiName: e,
625
- tag: t,
626
- input: n
801
+ let O = rr(), ee = i?.idempotencyKey ?? D();
802
+ Ln({
803
+ id: O,
804
+ apiName: t,
805
+ tag: n,
806
+ input: r
627
807
  });
628
- let te = v.current, O = y.current;
808
+ let A = h.current, te = g.current;
629
809
  try {
630
- te ? te(Cn(S, D), n) : !O && s && s.length > 0 && S.autoApply(s, n, D);
810
+ A ? A(ir(x, O), r) : !te && s && s.length > 0 && x.autoApply(s, r, O);
631
811
  } catch (e) {
632
- if (E?.release(), p(e), f(), S.revertByMutation(D), J(D, {
812
+ if (w?.release(), d(e), u(), x.revertByMutation(O), X(O, {
633
813
  status: "error",
634
814
  error: e
635
815
  }), o) return c(e);
636
816
  throw e;
637
817
  }
638
- let k, A = !1, ne, j, re, M = Date.now();
818
+ let j, M = !1, N, P, ne, F = Date.now();
639
819
  try {
640
- if (E) {
641
- await E.ready, E.assertActive();
642
- let n = await K(a, e, t);
643
- m = n.runtime, w = n.client;
820
+ if (w) {
821
+ await w.ready, w.assertActive();
822
+ let e = await J(a, t, n);
823
+ p = e.runtime, S = e.client;
644
824
  }
645
- let o = async (r, i, o, s) => {
646
- let c = u(r), l = c?.getSnapshot();
647
- j = c === void 0 ? void 0 : () => a.current.runtime === r && l !== void 0 && c.getSnapshot() === l, s?.(), E?.assertActive();
648
- let d = T === void 0 ? void 0 : await T.prepare(r, i);
825
+ let o = async (e, i, o, s) => {
826
+ let c = k(e), l = c?.getSnapshot();
827
+ P = c === void 0 ? void 0 : () => a.current.runtime === e && l !== void 0 && c.getSnapshot() === l, s?.(), w?.assertActive();
828
+ let u = C === void 0 ? void 0 : await C.prepare(e, i);
649
829
  l = c?.getSnapshot(), s?.();
650
- let f = fn(h(i, t)(n), ee), p = V.currentSpan.pipe(V.tap((e) => V.sync(() => {
651
- k = e.traceId, _({
830
+ let d = T(i, n), p = y(d(r), ee), m = U.currentSpan.pipe(U.tap((e) => U.sync(() => {
831
+ j = e.traceId, b({
652
832
  traceId: e.traceId,
653
833
  spanId: e.spanId,
654
834
  source: "mutation",
655
- tag: t
835
+ tag: n
656
836
  });
657
- })), V.catchAll(() => V.void), V.zipRight(V.try({
837
+ })), U.catchAll(() => U.void), U.zipRight(U.try({
658
838
  try: () => {
659
- s?.(), E?.assertActive(), A = !0;
839
+ s?.(), w?.assertActive(), M = !0;
660
840
  },
661
841
  catch: (e) => e
662
- })), V.zipRight(f)).pipe(V.withSpan(`client.mutation.${t}`, { attributes: {
663
- "voltro.api": e,
664
- "voltro.mutationId": D,
665
- "rpc.tag": t,
842
+ })), U.zipRight(p)).pipe(U.withSpan(`client.mutation.${n}`, { attributes: {
843
+ "voltro.api": t,
844
+ "voltro.mutationId": O,
845
+ "rpc.tag": n,
666
846
  "voltro.replay": o
667
847
  } }));
668
- return d === void 0 ? C(r, p) : d.run(p);
848
+ return u === void 0 ? f(e, m) : u.run(m);
669
849
  }, s;
670
850
  try {
671
- s = await o(m, w, !1);
672
- } catch (n) {
673
- let r = i(n, A ? "handler" : "client"), c = gn(n, k);
674
- r === "transport" && (a.current.errorBus.emit({
851
+ s = await o(p, S, !1);
852
+ } catch (r) {
853
+ let i = e(r, M ? "handler" : "client"), c = Zn(r, j);
854
+ i === "transport" && (a.current.errorBus.emit({
675
855
  source: "mutation",
676
- tag: t,
856
+ tag: n,
677
857
  error: c,
678
- kind: r,
679
- ...j === void 0 ? {} : { affectsTransport: j() },
680
- outcome: A ? "unknown" : "not-started",
681
- ...k === void 0 ? {} : { traceId: k }
682
- }), ne = c);
683
- let l = a.current, u = l.recovery ?? d(l.errorBus, e), f = r === "transport" ? u.reserveMutationReplay(M) : void 0;
684
- if (f === void 0) throw c;
858
+ kind: i,
859
+ ...P === void 0 ? {} : { affectsTransport: P() },
860
+ outcome: M ? "unknown" : "not-started",
861
+ ...j === void 0 ? {} : { traceId: j }
862
+ }), N = c);
863
+ let l = a.current, u = l.recovery ?? E(l.errorBus, t), d = i === "transport" ? u.reserveMutationReplay(F) : void 0;
864
+ if (d === void 0) throw c;
685
865
  try {
686
- if (!await u.waitForMutationReplaySupport(M) || !await u.waitForProtocolReady(M) || !f.isValid()) throw c;
687
- let n = () => {
688
- if (!f.isValid()) throw c;
866
+ if (!await u.waitForMutationReplaySupport(F) || !await u.waitForProtocolReady(F) || !d.isValid()) throw c;
867
+ let e = () => {
868
+ if (!d.isValid()) throw c;
689
869
  };
690
870
  for (;;) {
691
- n();
692
- let r = await K(a, e, t);
871
+ e();
872
+ let r = await J(a, t, n);
693
873
  try {
694
- s = await o(r.runtime, r.client, !0, n);
874
+ s = await o(r.runtime, r.client, !0, e);
695
875
  break;
696
- } catch (e) {
697
- let t = e;
698
- if (t?._tag !== "MutationInFlight") throw e;
699
- let r = typeof t.retryAfterMs == "number" && Number.isFinite(t.retryAfterMs) && t.retryAfterMs > 0 ? t.retryAfterMs : 1e3;
700
- if (r >= u.replayWindowRemaining(M)) throw e;
701
- await new Promise((e) => setTimeout(e, r)), n();
876
+ } catch (t) {
877
+ let n = t;
878
+ if (n?._tag !== "MutationInFlight") throw t;
879
+ let r = typeof n.retryAfterMs == "number" && Number.isFinite(n.retryAfterMs) && n.retryAfterMs > 0 ? n.retryAfterMs : 1e3;
880
+ if (r >= u.replayWindowRemaining(F)) throw t;
881
+ await new Promise((e) => setTimeout(e, r)), e();
702
882
  }
703
883
  }
704
884
  } finally {
705
- f.release();
885
+ d.release();
706
886
  }
707
887
  }
708
- g(s), J(D, {
888
+ m(s), X(O, {
709
889
  status: "success",
710
890
  output: s
711
891
  }), a.current.errorBus.emitSuccess({
712
892
  source: "mutation",
713
- tag: t
714
- }), S.confirmByMutation(D), r?.onSuccess?.(s, n);
715
- let c = bn(r?.notify?.success, s, n);
716
- return c !== void 0 && _n?.success(c), s;
717
- } catch (e) {
718
- A && (ne !== void 0 || i(e, "handler") === "transport") && (re = "unknown");
719
- let n = gn(e, k);
720
- if (p(n), J(D, {
893
+ tag: n
894
+ }), x.confirmByMutation(O), i?.onSuccess?.(s, r);
895
+ let c = tr(i?.notify?.success, s, r);
896
+ return c !== void 0 && Qn?.success(c), s;
897
+ } catch (t) {
898
+ M && (N !== void 0 || e(t, "handler") === "transport") && (ne = "unknown");
899
+ let r = Zn(t, j);
900
+ if (d(r), X(O, {
721
901
  status: "error",
722
- error: n
723
- }), S.revertByMutation(D), Object.is(ne, n) || a.current.errorBus.emit({
902
+ error: r
903
+ }), x.revertByMutation(O), Object.is(N, r) || a.current.errorBus.emit({
724
904
  source: "mutation",
725
- tag: t,
726
- error: n,
727
- kind: A ? i(e, "handler") : "client",
728
- ...j === void 0 ? {} : { affectsTransport: j() },
729
- outcome: A && i(e, "handler") === "transport" ? "unknown" : A ? "known" : "not-started",
730
- ...k === void 0 ? {} : { traceId: k }
731
- }), o) return c(n);
732
- throw n;
905
+ tag: n,
906
+ error: r,
907
+ kind: M ? e(t, "handler") : "client",
908
+ ...P === void 0 ? {} : { affectsTransport: P() },
909
+ outcome: M && e(t, "handler") === "transport" ? "unknown" : M ? "known" : "not-started",
910
+ ...j === void 0 ? {} : { traceId: j }
911
+ }), o) return c(r);
912
+ throw r;
733
913
  } finally {
734
- E?.release(re), f();
914
+ w?.release(ne), u();
735
915
  }
736
916
  }, [
737
- e,
738
917
  t,
918
+ n,
739
919
  s
740
920
  ]);
741
- return R(() => {
742
- let t = {
743
- mutate: x,
921
+ return z(() => {
922
+ let e = {
923
+ mutate: v,
744
924
  pending: c,
745
- error: f,
746
- data: m,
747
- withOptimistic: (e) => (v.current = e, t),
748
- withoutOptimistic: () => (y.current = !0, t),
749
- withConnectionSetup: (n) => (cn(x, on(n, e)), t)
925
+ error: u,
926
+ data: p,
927
+ withOptimistic: (t) => (h.current = t, e),
928
+ withoutOptimistic: () => (g.current = !0, e),
929
+ withConnectionSetup: (n) => (Gn(v, Un(n, t)), e)
750
930
  };
751
- return t;
931
+ return e;
752
932
  }, [
753
- x,
933
+ v,
754
934
  c,
755
- f,
756
- m,
757
- e
935
+ u,
936
+ p,
937
+ t
758
938
  ]);
759
- }, wn = (e, t) => {
939
+ }, or = (e, t) => {
760
940
  if (t === void 0 || typeof e != "object" || !e) return e;
761
941
  try {
762
942
  Object.defineProperty(e, "__voltroTraceId", {
@@ -766,90 +946,90 @@ var qt = 15e3, K = async (e, t, n) => {
766
946
  });
767
947
  } catch {}
768
948
  return e;
769
- }, Tn = (e, t, n) => typeof e == "function" ? e(t, n) : e, En = 0, Dn = () => `act_${++En}`, On = (e, t) => {
770
- let n = W(e), { descriptors: r } = n, a = z(n);
771
- if (a.current = n, process.env.NODE_ENV !== "production") {
772
- let n = r[t]?.kind;
773
- 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.`);
949
+ }, sr = (e, t, n) => typeof e == "function" ? e(t, n) : e, cr = 0, lr = () => `act_${++cr}`, ur = (t, n) => {
950
+ let r = K(t), { descriptors: i } = r, a = B(r);
951
+ if (a.current = r, process.env.NODE_ENV !== "production") {
952
+ let e = i[n]?.kind;
953
+ e !== void 0 && e !== "action" && console.error(`[@voltro/client] useAction('${t}', '${n}') targets a ${e}, not an action. Use ${e === "mutation" ? "useMutation" : e === "workflow" ? "useWorkflow" : `the ${e} hook`} instead.`);
774
954
  }
775
- let [o, s] = B(!1), [c, l] = B(void 0), [u, d] = B(void 0), f = F(async (n, r) => {
776
- let o = r?.onError !== void 0 || r?.notify?.error !== void 0;
955
+ let [o, s] = V(!1), [c, l] = V(void 0), [u, d] = V(void 0), p = L(async (r, i) => {
956
+ let o = i?.onError !== void 0 || i?.notify?.error !== void 0;
777
957
  s(!0), l(void 0);
778
- let c = Dn(), u = r?.idempotencyKey ?? dn();
779
- $t({
958
+ let c = lr(), u = i?.idempotencyKey ?? D();
959
+ Ln({
780
960
  id: c,
781
- apiName: e,
782
- tag: t,
783
- input: n,
961
+ apiName: t,
962
+ tag: n,
963
+ input: r,
784
964
  kind: "action"
785
965
  });
786
- let f, p = !1;
966
+ let p, m = !1;
787
967
  try {
788
- let { runtime: i, client: o } = await K(a, e, t), s = h(o, t), l = V.currentSpan.pipe(V.tap((e) => V.sync(() => {
789
- f = e.traceId, _({
968
+ let { runtime: e, client: o } = await J(a, t, n), s = T(o, n), l = U.currentSpan.pipe(U.tap((e) => U.sync(() => {
969
+ p = e.traceId, b({
790
970
  traceId: e.traceId,
791
971
  spanId: e.spanId,
792
972
  source: "action",
793
- tag: t
973
+ tag: n
794
974
  });
795
- })), V.catchAll(() => V.void), V.zipRight(fn(s(n), u))).pipe(V.withSpan(`client.action.${t}`, { attributes: {
796
- "voltro.api": e,
975
+ })), U.catchAll(() => U.void), U.zipRight(y(s(r), u))).pipe(U.withSpan(`client.action.${n}`, { attributes: {
976
+ "voltro.api": t,
797
977
  "voltro.actionId": c,
798
- "rpc.tag": t
978
+ "rpc.tag": n
799
979
  } }));
800
- p = !0;
801
- let m = await C(i, l);
802
- d(m), J(c, {
980
+ m = !0;
981
+ let h = await f(e, l);
982
+ d(h), X(c, {
803
983
  status: "success",
804
- output: m
984
+ output: h
805
985
  }), a.current.errorBus.emitSuccess({
806
986
  source: "action",
807
- tag: t
808
- }), r?.onSuccess?.(m, n);
809
- let g = Tn(r?.notify?.success, m, n);
810
- return g !== void 0 && yn()?.success(g), m;
811
- } catch (e) {
812
- let s = wn(e, f);
813
- if (l(s), J(c, {
987
+ tag: n
988
+ }), i?.onSuccess?.(h, r);
989
+ let g = sr(i?.notify?.success, h, r);
990
+ return g !== void 0 && er()?.success(g), h;
991
+ } catch (t) {
992
+ let s = or(t, p);
993
+ if (l(s), X(c, {
814
994
  status: "error",
815
995
  error: s
816
996
  }), a.current.errorBus.emit({
817
997
  source: "action",
818
- tag: t,
998
+ tag: n,
819
999
  error: s,
820
- kind: p ? i(e, "handler") : "client",
821
- outcome: p && i(e, "handler") === "transport" ? "unknown" : p ? "known" : "not-started",
822
- ...f === void 0 ? {} : { traceId: f }
1000
+ kind: m ? e(t, "handler") : "client",
1001
+ outcome: m && e(t, "handler") === "transport" ? "unknown" : m ? "known" : "not-started",
1002
+ ...p === void 0 ? {} : { traceId: p }
823
1003
  }), o) {
824
- r?.onError?.(s, n);
825
- let e = Tn(r?.notify?.error, s, n);
826
- e !== void 0 && yn()?.error(e);
1004
+ i?.onError?.(s, r);
1005
+ let e = sr(i?.notify?.error, s, r);
1006
+ e !== void 0 && er()?.error(e);
827
1007
  return;
828
1008
  }
829
1009
  throw s;
830
1010
  } finally {
831
1011
  s(!1);
832
1012
  }
833
- }, [e, t]);
834
- return R(() => ({
835
- run: f,
1013
+ }, [t, n]);
1014
+ return z(() => ({
1015
+ run: p,
836
1016
  pending: o,
837
1017
  error: c,
838
1018
  lastResult: u
839
1019
  }), [
840
- f,
1020
+ p,
841
1021
  o,
842
1022
  c,
843
1023
  u
844
1024
  ]);
845
- }, kn = P(void 0), An = (e) => xe(kn.Provider, { value: e.messages }, e.children), jn = () => I(kn), Mn = Symbol.for("voltro.client.formEngine"), Nn = P(void 0), Pn = (e, t) => {
1025
+ }, dr = I(void 0), fr = (e) => Ce(dr.Provider, { value: e.messages }, e.children), pr = () => we(dr), mr = Symbol.for("voltro.client.formEngine"), hr = I(void 0), gr = (e, t) => {
846
1026
  let n = e;
847
1027
  for (let e of t.split(".")) {
848
1028
  if (typeof n != "object" || !n) return;
849
1029
  n = n[e];
850
1030
  }
851
1031
  return n;
852
- }, Fn = (e, t, n) => `vf-${e}-${t}-${n}`.replace(/[^a-zA-Z0-9_-]/g, "-"), In = {
1032
+ }, _r = (e, t, n) => `vf-${e}-${t}-${n}`.replace(/[^a-zA-Z0-9_-]/g, "-"), vr = {
853
1033
  isTouched: !1,
854
1034
  isBlurred: !1,
855
1035
  isDirty: !1,
@@ -858,35 +1038,35 @@ var qt = 15e3, K = async (e, t, n) => {
858
1038
  isValidating: !1,
859
1039
  errorMap: {},
860
1040
  errorSourceMap: {}
861
- }, Ln = (e, t) => {
1041
+ }, yr = (e, t) => {
862
1042
  let n = e.find((e) => e.name === t);
863
1043
  if (n !== void 0) return n;
864
1044
  let r = /^(.+?)\.\d+\.(.+)$/.exec(t);
865
1045
  if (r !== null) return e.find((e) => e.name === r[1] && e.widget === "array")?.item?.find((e) => e.name === r[2]);
866
- }, Rn = (e, t, n) => {
867
- let r = W(e), i = z(void 0), a = typeof t == "function" ? t(i.current?.state?.values ?? n.defaults ?? {}) : t, o = z(a).current, s = X(e, a), c = n.schema ?? r.descriptors[a]?.input;
868
- return process.env.NODE_ENV !== "production" && c === 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.`), Bn(e, o, n, c, i, s);
869
- }, zn = (e) => {
870
- let t = z(void 0);
871
- return Bn("local", Ce(), {
1046
+ }, br = (e, t, n) => {
1047
+ let r = K(e), i = B(void 0), a = typeof t == "function" ? t(i.current?.state?.values ?? n.defaults ?? {}) : t, o = B(a).current, s = ar(e, a), c = n.schema ?? r.descriptors[a]?.input;
1048
+ return process.env.NODE_ENV !== "production" && c === 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.`), Sr(e, o, n, c, i, s);
1049
+ }, xr = (e) => {
1050
+ let t = B(void 0);
1051
+ return Sr("local", Ee(), {
872
1052
  ...e,
873
- onSubmit: async ({ input: t }) => e.onSubmit(await je.decodeUnknownPromise(e.schema)(t))
1053
+ onSubmit: async ({ input: t }) => e.onSubmit(await Ne.decodeUnknownPromise(e.schema)(t))
874
1054
  }, e.schema, t);
875
- }, Bn = (e, t, n, r, i, a) => {
876
- let o = R(() => r ? ve(r) : [], [r]), s = jn(), c = n.messages ?? s, l = R(() => ({
1055
+ }, Sr = (e, t, n, r, i, a) => {
1056
+ let o = z(() => r ? be(r) : [], [r]), s = pr(), c = n.messages ?? s, l = z(() => ({
877
1057
  ...n.locale === void 0 ? {} : { locale: n.locale },
878
1058
  ...c === void 0 ? {} : { messages: c }
879
- }), [n.locale, c]), u = z(n.asyncFields);
1059
+ }), [n.locale, c]), u = B(n.asyncFields);
880
1060
  u.current = n.asyncFields;
881
- let d = z(n);
1061
+ let d = B(n);
882
1062
  d.current = n;
883
- let f = z(a);
1063
+ let f = B(a);
884
1064
  f.current = a;
885
- let p = z(l);
1065
+ let p = B(l);
886
1066
  p.current = l;
887
- let m = z(r);
1067
+ let m = B(r);
888
1068
  m.current = r;
889
- let [h, g] = B(() => n.flash?.errors ?? {}), [_, v] = B(n.flash?.formError), [y, b] = B(void 0), x = z(void 0), S = z(!1), C = F((e) => {
1069
+ let [h, g] = V(() => n.flash?.errors ?? {}), [_, v] = V(n.flash?.formError), [y, b] = V(void 0), x = B(void 0), S = B(!1), C = L((e) => {
890
1070
  let t = m.current;
891
1071
  if (t === void 0) return [];
892
1072
  let n = d.current, r = e;
@@ -900,92 +1080,92 @@ var qt = 15e3, K = async (e, t, n) => {
900
1080
  let a = n.errorPath ?? {};
901
1081
  return i.map((t) => {
902
1082
  let n = a[t.path];
903
- return n === void 0 ? (Pn(e, t.path) !== void 0 || t.path.includes("."), t) : {
1083
+ return n === void 0 ? (gr(e, t.path) !== void 0 || t.path.includes("."), t) : {
904
1084
  ...t,
905
1085
  path: n
906
1086
  };
907
1087
  });
908
- }, []), w = F((e) => {
1088
+ }, []), w = L((e) => {
909
1089
  let t = { ...e ?? {} }, n = m.current;
910
- if (n !== void 0) for (let e of ve(n)) (e.widget === "checkbox" || e.widget === "switch") && !(e.name in t) && (t[e.name] = !1);
1090
+ if (n !== void 0) for (let e of be(n)) (e.widget === "checkbox" || e.widget === "switch") && !(e.name in t) && (t[e.name] = !1);
911
1091
  return t;
912
- }, []), T = z(() => Promise.resolve());
1092
+ }, []), T = B(() => Promise.resolve());
913
1093
  if (i.current === void 0) {
914
1094
  let e = n.flash, t = e === void 0 ? w(n.defaults) : {
915
1095
  ...w(n.defaults),
916
1096
  ...e.values
917
1097
  };
918
- i.current = new Re({
1098
+ i.current = new Je({
919
1099
  onSubmit: ({ value: e }) => T.current(e),
920
1100
  defaultValues: t,
921
1101
  validators: { onChange: ({ value: e }) => {
922
1102
  let t = C(e);
923
1103
  if (t.length === 0) return;
924
1104
  let n = {};
925
- for (let e of t) e.path !== "" && !(e.path in n) && (n[e.path] = _e(e, p.current));
1105
+ for (let e of t) e.path !== "" && !(e.path in n) && (n[e.path] = ye(e, p.current));
926
1106
  return { fields: n };
927
1107
  } }
928
1108
  });
929
1109
  }
930
1110
  let E = i.current, D = E;
931
- L(() => D.mount(), [D]);
932
- let ee = n.subscribe ?? "all";
933
- ze(E.store, (e) => ee === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
934
- let te = E.store.state.values, O = E.store.state, k = R(() => C(te), [C, te]), A = n.isLoading === !0, ne = n.validate, j = ne?.onChange ?? "afterTouched", M = ne?.onBlur ?? !0, ie = O.submissionAttempts, ae = O.fieldMetaBase ?? {}, oe = F((e) => {
935
- if (A) return !1;
936
- if (ie > 0 || j === "always") return !0;
937
- if (j === "never") return !1;
938
- let t = ae[e];
939
- return t === void 0 ? !1 : M ? t.isBlurred === !0 : t.isTouched === !0;
1111
+ R(() => D.mount(), [D]);
1112
+ let O = n.subscribe ?? "all";
1113
+ Ye(E.store, (e) => O === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
1114
+ let ee = E.store.state.values, k = E.store.state, A = z(() => C(ee), [C, ee]), te = n.isLoading === !0, j = n.validate, M = j?.onChange ?? "afterTouched", N = j?.onBlur ?? !0, P = k.submissionAttempts, ne = k.fieldMetaBase ?? {}, F = L((e) => {
1115
+ if (te) return !1;
1116
+ if (P > 0 || M === "always") return !0;
1117
+ if (M === "never") return !1;
1118
+ let t = ne[e];
1119
+ return t === void 0 ? !1 : N ? t.isBlurred === !0 : t.isTouched === !0;
940
1120
  }, [
941
- ie,
942
- ae,
943
- A,
944
- j,
945
- M
946
- ]), N = F((e) => {
1121
+ P,
1122
+ ne,
1123
+ te,
1124
+ M,
1125
+ N
1126
+ ]), ie = L((e) => {
947
1127
  let t = h[e];
948
1128
  if (t !== void 0) return t;
949
1129
  let n = u.current?.[e];
950
- if (n !== void 0 && n.status === "invalid") return n.message ?? _e({
1130
+ if (n !== void 0 && n.status === "invalid") return n.message ?? ye({
951
1131
  id: "validation.invalid",
952
1132
  fallback: "Invalid value"
953
1133
  }, p.current);
954
- if (!oe(e)) return;
955
- let r = k.find((t) => t.path === e);
956
- return r === void 0 ? void 0 : _e(r, p.current);
1134
+ if (!F(e)) return;
1135
+ let r = A.find((t) => t.path === e);
1136
+ return r === void 0 ? void 0 : ye(r, p.current);
957
1137
  }, [
958
1138
  h,
959
- oe,
960
- k
961
- ]), se = R(() => {
962
- let e = {}, t = /* @__PURE__ */ new Set([...k.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(h)]);
1139
+ F,
1140
+ A
1141
+ ]), ae = z(() => {
1142
+ let e = {}, t = /* @__PURE__ */ new Set([...A.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(h)]);
963
1143
  for (let [e, n] of Object.entries(u.current ?? {})) n.status === "invalid" && t.add(e);
964
1144
  for (let n of t) {
965
- let t = N(n);
1145
+ let t = ie(n);
966
1146
  t !== void 0 && (e[n] = t);
967
1147
  }
968
1148
  return e;
969
1149
  }, [
970
- k,
1150
+ A,
971
1151
  h,
972
- N
973
- ]), ce = F((e) => {
1152
+ ie
1153
+ ]), oe = L((e) => {
974
1154
  g((t) => {
975
1155
  if (!(e in t)) return t;
976
1156
  let n = { ...t };
977
1157
  return delete n[e], n;
978
1158
  });
979
- }, []), le = F((n) => {
980
- let r = Ln(o, n), i = D.getFieldMeta(n), a = N(n), s = Fn(e, t, n), c = u.current?.[n], l = [a === void 0 ? void 0 : `${s}-error`, r?.description === void 0 ? void 0 : `${s}-help`].filter((e) => e !== void 0);
1159
+ }, []), se = L((n) => {
1160
+ let r = yr(o, n), i = D.getFieldMeta(n), a = ie(n), s = _r(e, t, n), c = u.current?.[n], l = [a === void 0 ? void 0 : `${s}-error`, r?.description === void 0 ? void 0 : `${s}-help`].filter((e) => e !== void 0);
981
1161
  return {
982
1162
  value: D.getFieldValue(n),
983
1163
  setValue: (e) => {
984
- ce(n), !Object.is(D.getFieldValue(n), e) && D.setFieldValue(n, e);
1164
+ oe(n), !Object.is(D.getFieldValue(n), e) && D.setFieldValue(n, e);
985
1165
  },
986
1166
  onBlur: () => {
987
1167
  D.setFieldMeta(n, (e) => ({
988
- ...In,
1168
+ ...vr,
989
1169
  ...e ?? {},
990
1170
  isTouched: !0,
991
1171
  isBlurred: !0
@@ -1012,12 +1192,12 @@ var qt = 15e3, K = async (e, t, n) => {
1012
1192
  }, [
1013
1193
  e,
1014
1194
  t,
1015
- ce,
1195
+ oe,
1016
1196
  D,
1017
1197
  o,
1018
1198
  h,
1019
- N
1020
- ]), ue = F((e) => ({
1199
+ ie
1200
+ ]), ce = L((e) => ({
1021
1201
  items: D.getFieldValue(e) ?? [],
1022
1202
  push: (t) => {
1023
1203
  D.pushFieldValue(e, t);
@@ -1034,14 +1214,14 @@ var qt = 15e3, K = async (e, t, n) => {
1034
1214
  swap: (t, n) => {
1035
1215
  D.swapFieldValues(e, t, n);
1036
1216
  },
1037
- field: (t, n) => le(`${e}.${t}.${n}`)
1038
- }), [D, le]), de = F((e) => o.filter((t) => t.section === e), [o]), fe = F((e, t) => {
1039
- ce(e), !Object.is(D.getFieldValue(e), t) && D.setFieldValue(e, t);
1040
- }, [ce, D]), pe = F((e) => {
1217
+ field: (t, n) => se(`${e}.${t}.${n}`)
1218
+ }), [D, se]), le = L((e) => o.filter((t) => t.section === e), [o]), ue = L((e, t) => {
1219
+ oe(e), !Object.is(D.getFieldValue(e), t) && D.setFieldValue(e, t);
1220
+ }, [oe, D]), de = L((e) => {
1041
1221
  for (let [t, n] of Object.entries(e)) D.setFieldValue(t, n);
1042
- }, [D]), me = F((e) => {
1222
+ }, [D]), fe = L((e) => {
1043
1223
  g({}), v(void 0), b(void 0), x.current = void 0, S.current = !1, e === void 0 ? D.reset() : D.reset(w(e));
1044
- }, [D, w]), he = n.asyncTimeoutMs ?? 5e3, ge = F(async () => {
1224
+ }, [D, w]), pe = n.asyncTimeoutMs ?? 5e3, me = L(async () => {
1045
1225
  let e = Date.now();
1046
1226
  for (;;) {
1047
1227
  let t = u.current;
@@ -1049,23 +1229,23 @@ var qt = 15e3, K = async (e, t, n) => {
1049
1229
  let n = Object.entries(t), r = n.filter(([, e]) => e.status === "checking");
1050
1230
  if (r.length === 0) {
1051
1231
  let e = n.filter(([, e]) => e.status === "invalid");
1052
- return e.length === 0 ? void 0 : Object.fromEntries(e.map(([e, t]) => [e, t.message ?? _e({
1232
+ return e.length === 0 ? void 0 : Object.fromEntries(e.map(([e, t]) => [e, t.message ?? ye({
1053
1233
  id: "validation.invalid",
1054
1234
  fallback: "Invalid value"
1055
1235
  }, p.current)]));
1056
1236
  }
1057
- if (Date.now() - e > he) return Object.fromEntries(r.map(([e]) => [e, _e({
1237
+ if (Date.now() - e > pe) return Object.fromEntries(r.map(([e]) => [e, ye({
1058
1238
  id: "validation.checking",
1059
1239
  fallback: "Still checking…"
1060
1240
  }, p.current)]));
1061
1241
  await new Promise((e) => setTimeout(e, 50));
1062
1242
  }
1063
- }, [he]), ye = F(() => {
1243
+ }, [pe]), he = L(() => {
1064
1244
  let n = globalThis.document;
1065
1245
  if (n?.getElementById === void 0) return;
1066
1246
  let r = [...o.map((e) => e.name), ...Object.keys(h).filter((e) => !o.some((t) => t.name === e))];
1067
- for (let i of r) if (N(i) !== void 0) {
1068
- n.getElementById(Fn(e, t, i))?.focus?.();
1247
+ for (let i of r) if (ie(i) !== void 0) {
1248
+ n.getElementById(_r(e, t, i))?.focus?.();
1069
1249
  return;
1070
1250
  }
1071
1251
  }, [
@@ -1073,17 +1253,17 @@ var qt = 15e3, K = async (e, t, n) => {
1073
1253
  t,
1074
1254
  o,
1075
1255
  h,
1076
- N
1077
- ]), P = z(ye);
1078
- P.current = ye;
1079
- let xe = F(async () => {
1256
+ ie
1257
+ ]), ge = B(he);
1258
+ ge.current = he;
1259
+ let _e = L(async () => {
1080
1260
  v(void 0), g({}), b(void 0), x.current = void 0, S.current = !1;
1081
1261
  let e, t = !1;
1082
1262
  if (await D.handleSubmit().catch((n) => {
1083
1263
  t = !0, e = n;
1084
1264
  }), t) throw e;
1085
1265
  return S.current || queueMicrotask(() => {
1086
- P.current();
1266
+ ge.current();
1087
1267
  }), x.current;
1088
1268
  }, [D]);
1089
1269
  T.current = (async (e) => {
@@ -1096,22 +1276,22 @@ var qt = 15e3, K = async (e, t, n) => {
1096
1276
  }
1097
1277
  if (C(n).length > 0) {
1098
1278
  queueMicrotask(() => {
1099
- P.current();
1279
+ ge.current();
1100
1280
  });
1101
1281
  return;
1102
1282
  }
1103
1283
  let i = m.current;
1104
1284
  if (i !== void 0) {
1105
- let e = be(i, r);
1285
+ let e = Se(i, r);
1106
1286
  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;
1107
1287
  }
1108
- let a = await ge();
1288
+ let a = await me();
1109
1289
  if (a !== void 0) {
1110
1290
  g((e) => ({
1111
1291
  ...e,
1112
1292
  ...a
1113
1293
  })), queueMicrotask(() => {
1114
- P.current();
1294
+ ge.current();
1115
1295
  });
1116
1296
  return;
1117
1297
  }
@@ -1127,13 +1307,13 @@ var qt = 15e3, K = async (e, t, n) => {
1127
1307
  });
1128
1308
  x.current = e, S.current = !0, t.onSuccess?.(e);
1129
1309
  } catch (e) {
1130
- let t = Pe(e);
1310
+ let t = Ve(e);
1131
1311
  if (t.length === 0) {
1132
1312
  b(e), d.current.onError?.(e);
1133
1313
  return;
1134
1314
  }
1135
1315
  let n = {};
1136
- for (let e of t) e.field in n || (n[e.field] = _e({
1316
+ for (let e of t) e.field in n || (n[e.field] = ye({
1137
1317
  id: e.message,
1138
1318
  ...e.params === void 0 ? {} : { params: e.params },
1139
1319
  fallback: e.message
@@ -1142,78 +1322,78 @@ var qt = 15e3, K = async (e, t, n) => {
1142
1322
  ...e,
1143
1323
  ...n
1144
1324
  })), queueMicrotask(() => {
1145
- P.current();
1325
+ ge.current();
1146
1326
  });
1147
1327
  }
1148
1328
  });
1149
- let I = k.length === 0, Se = Object.values(u.current ?? {}).some((e) => e.status === "checking"), Ce = y ?? a?.error, we = Ce !== void 0 && Pe(Ce).length > 0 ? void 0 : Ce, Te = Object.keys(se).length, Ee = (() => {
1150
- for (let e of o) if (se[e.name] !== void 0) return e.name;
1151
- let e = Object.keys(se);
1329
+ let ve = A.length === 0, xe = Object.values(u.current ?? {}).some((e) => e.status === "checking"), I = y ?? a?.error, Ce = I !== void 0 && Ve(I).length > 0 ? void 0 : I, we = Object.keys(ae).length, Te = (() => {
1330
+ for (let e of o) if (ae[e.name] !== void 0) return e.name;
1331
+ let e = Object.keys(ae);
1152
1332
  return e.length > 0 ? e[0] : void 0;
1153
- })(), V = {
1154
- isDirty: !A && O.isDirty,
1155
- isPristine: O.isPristine,
1156
- isTouched: O.isTouched,
1157
- isValid: I,
1158
- isValidating: Se,
1159
- canSubmit: I && !Se && !O.isSubmitting && !A,
1160
- isSubmitting: O.isSubmitting,
1161
- isSubmitted: O.isSubmitted,
1162
- isSubmitSuccessful: O.isSubmitSuccessful && S.current,
1163
- submissionAttempts: O.submissionAttempts,
1164
- errorCount: Te,
1165
- firstInvalidPath: Ee,
1166
- pending: a?.pending ?? O.isSubmitting,
1167
- isLoading: A,
1168
- submitError: we,
1333
+ })(), Ee = {
1334
+ isDirty: !te && k.isDirty,
1335
+ isPristine: k.isPristine,
1336
+ isTouched: k.isTouched,
1337
+ isValid: ve,
1338
+ isValidating: xe,
1339
+ canSubmit: ve && !xe && !k.isSubmitting && !te,
1340
+ isSubmitting: k.isSubmitting,
1341
+ isSubmitted: k.isSubmitted,
1342
+ isSubmitSuccessful: k.isSubmitSuccessful && S.current,
1343
+ submissionAttempts: k.submissionAttempts,
1344
+ errorCount: we,
1345
+ firstInvalidPath: Te,
1346
+ pending: a?.pending ?? k.isSubmitting,
1347
+ isLoading: te,
1348
+ submitError: Ce,
1169
1349
  data: a?.data ?? x.current
1170
- }, De = {
1350
+ }, H = {
1171
1351
  fields: o,
1172
- values: te,
1173
- errors: se,
1174
- issues: k,
1175
- isValid: I,
1176
- pending: a?.pending ?? O.isSubmitting,
1177
- submitError: we,
1352
+ values: ee,
1353
+ errors: ae,
1354
+ issues: A,
1355
+ isValid: ve,
1356
+ pending: a?.pending ?? k.isSubmitting,
1357
+ submitError: Ce,
1178
1358
  formError: _,
1179
1359
  data: a?.data ?? x.current,
1180
- setValue: fe,
1181
- setValues: pe,
1182
- reset: me,
1183
- submit: xe,
1184
- field: le,
1185
- array: ue,
1186
- section: de,
1187
- state: V,
1188
- focusFirstInvalid: ye
1360
+ setValue: ue,
1361
+ setValues: de,
1362
+ reset: fe,
1363
+ submit: _e,
1364
+ field: se,
1365
+ array: ce,
1366
+ section: le,
1367
+ state: Ee,
1368
+ focusFirstInvalid: he
1189
1369
  };
1190
- return Object.defineProperty(De, Mn, {
1370
+ return Object.defineProperty(H, mr, {
1191
1371
  value: {
1192
1372
  store: E.store,
1193
- field: le
1373
+ field: se
1194
1374
  },
1195
1375
  enumerable: !1
1196
- }), De;
1197
- }, Vn = (e) => xe(Nn.Provider, { value: e.binding }, e.children), Hn = () => I(Nn);
1198
- function Un(e, t) {
1199
- let n = I(Nn), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
1376
+ }), H;
1377
+ }, Cr = (e) => Ce(hr.Provider, { value: e.binding }, e.children), wr = () => we(hr);
1378
+ function Tr(e, t) {
1379
+ let n = we(hr), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
1200
1380
  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.");
1201
- let o = a[Mn];
1381
+ let o = a[mr];
1202
1382
  if (o === void 0) throw Error("useFormField: not a useFormBinding result");
1203
- return ze(o.store, (e) => {
1383
+ return Ye(o.store, (e) => {
1204
1384
  let t = e.fieldMetaBase[i];
1205
- return `${JSON.stringify(Pn(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
1385
+ return `${JSON.stringify(gr(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
1206
1386
  }), o.field(i);
1207
1387
  }
1208
1388
  //#endregion
1209
1389
  //#region src/connectionPrerequisite.ts
1210
- var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:connection-setup-superseded" ? "superseded" : "inactive", Z = class extends Error {
1390
+ var Er = "voltro:connection-setup-superseded", Dr = (e) => e.reason === "voltro:connection-setup-superseded" ? "superseded" : "inactive", Z = class extends Error {
1211
1391
  reason;
1212
1392
  _tag = "ConnectionPrerequisiteInvalidated";
1213
1393
  constructor(e) {
1214
- super(`Voltro connection prerequisite: ${e}`), this.reason = e, n(this, e === "connection-unavailable" || e === "connection-changed" ? "transport" : "client");
1394
+ super(`Voltro connection prerequisite: ${e}`), this.reason = e, x(this, e === "connection-unavailable" || e === "connection-changed" ? "transport" : "client");
1215
1395
  }
1216
- }, Kn = class {
1396
+ }, Or = class {
1217
1397
  #e;
1218
1398
  #t;
1219
1399
  #n = /* @__PURE__ */ new WeakMap();
@@ -1223,15 +1403,15 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1223
1403
  this.#e = e, this.#t = t;
1224
1404
  }
1225
1405
  prepare(e, t) {
1226
- let n = u(e)?.getSnapshot();
1227
- if (this.#e.aborted) return Promise.reject(new Z(Gn(this.#e)));
1406
+ let n = k(e)?.getSnapshot();
1407
+ if (this.#e.aborted) return Promise.reject(new Z(Dr(this.#e)));
1228
1408
  if (n === void 0) return Promise.reject(new Z("connection-unavailable"));
1229
1409
  let r = this.#n.get(n);
1230
1410
  if (r !== void 0) return r.then((t) => (this.assertCurrent(e, t), t));
1231
- let i = this.#a(e, n, t).pipe(V.timeoutFail({
1411
+ let i = this.#a(e, n, t).pipe(U.timeoutFail({
1232
1412
  duration: this.#t,
1233
1413
  onTimeout: () => new Z("timeout")
1234
- })), a = C(e, i).then((t) => {
1414
+ })), a = f(e, i).then((t) => {
1235
1415
  let r = Object.freeze({
1236
1416
  lease: n,
1237
1417
  output: t
@@ -1243,33 +1423,33 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1243
1423
  }), a;
1244
1424
  }
1245
1425
  assertCurrent(e, t) {
1246
- if (!this.#r.has(t)) throw new Z(Gn(this.#e));
1426
+ if (!this.#r.has(t)) throw new Z(Dr(this.#e));
1247
1427
  this.#i(e, t.lease);
1248
1428
  }
1249
1429
  #i(e, t) {
1250
- if (this.#e.aborted) throw new Z(Gn(this.#e));
1251
- if (t.signal.aborted || u(e)?.getSnapshot() !== t) throw new Z("connection-changed");
1430
+ if (this.#e.aborted) throw new Z(Dr(this.#e));
1431
+ if (t.signal.aborted || k(e)?.getSnapshot() !== t) throw new Z("connection-changed");
1252
1432
  }
1253
1433
  run(e, t, n) {
1254
- let r = V.try({
1434
+ let r = U.try({
1255
1435
  try: () => this.assertCurrent(e, t),
1256
1436
  catch: (e) => e
1257
- }).pipe(V.zipRight(n));
1258
- return C(e, this.#a(e, t.lease, r));
1437
+ }).pipe(U.zipRight(n));
1438
+ return f(e, this.#a(e, t.lease, r));
1259
1439
  }
1260
1440
  #a(e, t, n) {
1261
- let r = V.try({
1441
+ let r = U.try({
1262
1442
  try: () => this.#i(e, t),
1263
1443
  catch: (e) => e
1264
- }), i = V.async((e) => {
1265
- let n = () => e(V.fail(new Z(this.#e.aborted ? Gn(this.#e) : "connection-changed")));
1266
- return this.#e.addEventListener("abort", n, { once: !0 }), t.signal.addEventListener("abort", n, { once: !0 }), (this.#e.aborted || t.signal.aborted) && n(), V.sync(() => {
1444
+ }), i = U.async((e) => {
1445
+ let n = () => e(U.fail(new Z(this.#e.aborted ? Dr(this.#e) : "connection-changed")));
1446
+ return this.#e.addEventListener("abort", n, { once: !0 }), t.signal.addEventListener("abort", n, { once: !0 }), (this.#e.aborted || t.signal.aborted) && n(), U.sync(() => {
1267
1447
  this.#e.removeEventListener("abort", n), t.signal.removeEventListener("abort", n);
1268
1448
  });
1269
1449
  });
1270
- return r.pipe(V.zipRight(n), V.tap(() => r), V.raceFirst(i));
1450
+ return r.pipe(U.zipRight(n), U.tap(() => r), U.raceFirst(i));
1271
1451
  }
1272
- }, qn = class {
1452
+ }, kr = class {
1273
1453
  #e;
1274
1454
  #t;
1275
1455
  #n;
@@ -1284,7 +1464,7 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1284
1464
  #s;
1285
1465
  handle;
1286
1466
  constructor(e, t, n) {
1287
- this.#e = e, this.#t = t, this.#n = n, this.handle = an(e, { capture: () => this.#f() });
1467
+ this.#e = e, this.#t = t, this.#n = n, this.handle = Hn(e, { capture: () => this.#f() });
1288
1468
  }
1289
1469
  getSnapshot = () => this.#a;
1290
1470
  subscribe = (e) => (this.#r.add(e), () => {
@@ -1292,7 +1472,7 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1292
1472
  });
1293
1473
  clear = (e = !1) => {
1294
1474
  let t = this.#i;
1295
- this.#i = void 0, this.#s = void 0, t?.detachSubject?.(), t?.controller.abort(e ? Wn : void 0), this.#h({
1475
+ this.#i = void 0, this.#s = void 0, t?.detachSubject?.(), t?.controller.abort(e ? Er : void 0), this.#h({
1296
1476
  status: "idle",
1297
1477
  data: void 0,
1298
1478
  error: void 0
@@ -1302,11 +1482,11 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1302
1482
  this.clear(!0);
1303
1483
  let n = new AbortController(), r = {
1304
1484
  input: e,
1305
- key: dn(),
1485
+ key: D(),
1306
1486
  controller: n,
1307
1487
  subject: void 0,
1308
1488
  detachSubject: void 0,
1309
- prerequisite: new Kn(n.signal, this.#c(this.#n()).options.replayWindowMs),
1489
+ prerequisite: new Or(n.signal, this.#c(this.#n()).options.replayWindowMs),
1310
1490
  established: !1
1311
1491
  };
1312
1492
  this.#i = r, this.#h({
@@ -1326,7 +1506,7 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1326
1506
  }
1327
1507
  }
1328
1508
  watch(e) {
1329
- let t = u(e.runtime), n = () => {
1509
+ let t = k(e.runtime), n = () => {
1330
1510
  let n = this.#i;
1331
1511
  if (n === void 0 || !n.established || this.#n().runtime !== e.runtime) return;
1332
1512
  if (n.subject !== this.#c(e).subjectSignal) {
@@ -1343,10 +1523,10 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1343
1523
  return n(), t?.subscribe(n) ?? (() => {});
1344
1524
  }
1345
1525
  #c(e) {
1346
- return e.recovery ?? d(e.errorBus, this.#e);
1526
+ return e.recovery ?? E(e.errorBus, this.#e);
1347
1527
  }
1348
1528
  #l(e) {
1349
- if (this.#i !== e || e.controller.signal.aborted) throw new Z(Gn(e.controller.signal));
1529
+ if (this.#i !== e || e.controller.signal.aborted) throw new Z(Dr(e.controller.signal));
1350
1530
  }
1351
1531
  #u(e, t, n) {
1352
1532
  this.#l(e);
@@ -1369,32 +1549,32 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1369
1549
  if (e === void 0) throw new Z("inactive");
1370
1550
  return { prepare: async (t, n) => {
1371
1551
  let r = await this.#p(e, t, n);
1372
- return { run: (i) => e.prerequisite.run(t, r, V.try({
1552
+ return { run: (i) => e.prerequisite.run(t, r, U.try({
1373
1553
  try: () => this.#u(e, t, n),
1374
1554
  catch: (e) => e
1375
- }).pipe(V.zipRight(i))) };
1555
+ }).pipe(U.zipRight(i))) };
1376
1556
  } };
1377
1557
  }
1378
1558
  async #p(e, t, n) {
1379
1559
  let r = this.#u(e, t, n), i = r.descriptors[this.#t];
1380
1560
  if (i?.kind !== "mutation" || i.idempotencyScope !== "connection") throw Error(`Voltro: useConnectionSetup("${this.#t}") requires a mutation declaring idempotencyScope: 'connection'`);
1381
1561
  this.#d(e, r), this.#l(e);
1382
- let a = u(t);
1562
+ let a = k(t);
1383
1563
  if (a === void 0) throw new Z("connection-unavailable");
1384
1564
  if (a.getSnapshot() === void 0) {
1385
- let n = V.async((t) => {
1565
+ let n = U.async((t) => {
1386
1566
  let n = () => {
1387
1567
  let n = a.getSnapshot();
1388
- e.controller.signal.aborted ? t(V.fail(new Z(Gn(e.controller.signal)))) : n !== void 0 && t(V.succeed(n));
1568
+ e.controller.signal.aborted ? t(U.fail(new Z(Dr(e.controller.signal)))) : n !== void 0 && t(U.succeed(n));
1389
1569
  }, r = a.subscribe(n);
1390
- return e.controller.signal.addEventListener("abort", n, { once: !0 }), n(), V.sync(() => {
1570
+ return e.controller.signal.addEventListener("abort", n, { once: !0 }), n(), U.sync(() => {
1391
1571
  r(), e.controller.signal.removeEventListener("abort", n);
1392
1572
  });
1393
- }).pipe(V.timeoutFail({
1573
+ }).pipe(U.timeoutFail({
1394
1574
  duration: this.#c(r).options.replayWindowMs,
1395
1575
  onTimeout: () => new Z("timeout")
1396
1576
  }));
1397
- await C(t, n);
1577
+ await f(t, n);
1398
1578
  }
1399
1579
  this.#u(e, t, n);
1400
1580
  let o = a.getSnapshot();
@@ -1413,35 +1593,39 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1413
1593
  }), n;
1414
1594
  }
1415
1595
  }
1416
- #m(e, t) {
1417
- return V.suspend(() => {
1418
- let n = `setup_${e.key}_${++this.#o}`;
1419
- return $t({
1420
- id: n,
1596
+ #m(t, n) {
1597
+ return U.suspend(() => {
1598
+ let r = `setup_${t.key}_${++this.#o}`;
1599
+ return Ln({
1600
+ id: r,
1421
1601
  apiName: this.#e,
1422
1602
  tag: this.#t,
1423
- input: e.input
1424
- }), V.suspend(() => (this.#u(e, t.runtime, t.client), fn(h(t.client, this.#t)(e.input), e.key))).pipe(V.withSpan(`client.connectionSetup.${this.#t}`)).pipe(V.onExit((e) => V.sync(() => {
1425
- if (De.isSuccess(e)) J(n, {
1603
+ input: t.input
1604
+ }), U.suspend(() => {
1605
+ this.#u(t, n.runtime, n.client);
1606
+ let e = T(n.client, this.#t);
1607
+ return y(e(t.input), t.key);
1608
+ }).pipe(U.withSpan(`client.connectionSetup.${this.#t}`)).pipe(U.onExit((t) => U.sync(() => {
1609
+ if (ke.isSuccess(t)) X(r, {
1426
1610
  status: "success",
1427
- output: e.value
1428
- }), t.errorBus.emitSuccess({
1611
+ output: t.value
1612
+ }), n.errorBus.emitSuccess({
1429
1613
  source: "mutation",
1430
1614
  tag: this.#t
1431
1615
  });
1432
1616
  else {
1433
- let r = g(e.cause);
1434
- if (J(n, {
1617
+ let i = o(t.cause);
1618
+ if (X(r, {
1435
1619
  status: "error",
1436
- error: r
1437
- }), !Te.isInterruptedOnly(e.cause)) {
1438
- let e = i(r, "handler");
1439
- t.errorBus.emit({
1620
+ error: i
1621
+ }), !De.isInterruptedOnly(t.cause)) {
1622
+ let t = e(i, "handler");
1623
+ n.errorBus.emit({
1440
1624
  source: "mutation",
1441
1625
  tag: this.#t,
1442
- error: r,
1443
- kind: e,
1444
- outcome: e === "transport" ? "unknown" : "known"
1626
+ error: i,
1627
+ kind: t,
1628
+ outcome: t === "transport" ? "unknown" : "known"
1445
1629
  });
1446
1630
  }
1447
1631
  }
@@ -1456,151 +1640,151 @@ var Wn = "voltro:connection-setup-superseded", Gn = (e) => e.reason === "voltro:
1456
1640
  } catch {}
1457
1641
  }
1458
1642
  }
1459
- }, Jn = (e, t) => {
1460
- let n = W(e), r = z(n);
1643
+ }, Ar = (e, t) => {
1644
+ let n = K(e), r = B(n);
1461
1645
  r.current = n;
1462
- let i = R(() => new qn(e, t, () => r.current), [e, t]), a = F((n) => i.activate(n, () => K(r, e, t)), [
1646
+ let i = z(() => new kr(e, t, () => r.current), [e, t]), a = L((n) => i.activate(n, () => J(r, e, t)), [
1463
1647
  i,
1464
1648
  e,
1465
1649
  t
1466
- ]), o = we(i.subscribe, i.getSnapshot, i.getSnapshot);
1467
- return L(() => i.watch(r.current), [
1650
+ ]), o = H(i.subscribe, i.getSnapshot, i.getSnapshot);
1651
+ return R(() => i.watch(r.current), [
1468
1652
  i,
1469
1653
  n.runtime,
1470
1654
  n.client,
1471
1655
  n.recovery
1472
- ]), L(() => () => i.clear(), [i]), {
1656
+ ]), R(() => () => i.clear(), [i]), {
1473
1657
  ...o,
1474
1658
  handle: i.handle,
1475
1659
  activate: a,
1476
1660
  clear: i.clear,
1477
1661
  ready: o.status === "ready"
1478
1662
  };
1479
- }, Yn = G, Xn = (e) => ({
1480
- useSubscription: (t, n, r) => Yn(e, t, n, r),
1481
- useMutation: (t) => X(e, t),
1482
- useConnectionSetup: (t) => Jn(e, t),
1483
- useAction: (t) => On(e, t),
1484
- useFormBinding: (t, n) => Rn(e, t, n ?? {})
1485
- }), Zn = () => ({ seeds: [] }), Qn = null, $n = (e) => {
1486
- Qn = e;
1487
- }, er = /* @__PURE__ */ new Map(), tr = (e, t) => `${e}\u0000${t}`, nr = (e, t, n, r) => {
1488
- let i = Qn?.() ?? null;
1663
+ }, jr = q, Mr = (e) => ({
1664
+ useSubscription: (t, n, r) => jr(e, t, n, r),
1665
+ useMutation: (t) => ar(e, t),
1666
+ useConnectionSetup: (t) => Ar(e, t),
1667
+ useAction: (t) => ur(e, t),
1668
+ useFormBinding: (t, n) => br(e, t, n ?? {})
1669
+ }), Nr = () => ({ seeds: [] }), Pr = null, Fr = (e) => {
1670
+ Pr = e;
1671
+ }, Ir = /* @__PURE__ */ new Map(), Lr = (e, t) => `${e}\u0000${t}`, Rr = (e, t, n, r) => {
1672
+ let i = Pr?.() ?? null;
1489
1673
  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.)`);
1490
1674
  i.seeds.push({
1491
1675
  api: e,
1492
- key: O([t, n]),
1676
+ key: j([t, n]),
1493
1677
  value: r
1494
1678
  });
1495
- }, rr = (e, t, n) => {
1496
- let r = Qn?.() ?? null;
1679
+ }, zr = (e, t, n) => {
1680
+ let r = Pr?.() ?? null;
1497
1681
  r !== null && r.seeds.push({
1498
1682
  api: e,
1499
- key: O([t, n]),
1683
+ key: j([t, n]),
1500
1684
  value: void 0,
1501
1685
  failed: !0
1502
1686
  });
1503
- }, ir = (e) => {
1504
- if (e !== void 0) for (let t of e) er.set(tr(t.api, t.key), {
1687
+ }, Br = (e) => {
1688
+ if (e !== void 0) for (let t of e) Ir.set(Lr(t.api, t.key), {
1505
1689
  value: t.value,
1506
1690
  failed: t.failed === !0
1507
1691
  });
1508
- }, ar = (e, t, n) => {
1509
- let r = O([t, n]), i = Qn?.() ?? null;
1692
+ }, Vr = (e, t, n) => {
1693
+ let r = j([t, n]), i = Pr?.() ?? null;
1510
1694
  if (i !== null) {
1511
1695
  for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? void 0 : t.value;
1512
1696
  return;
1513
1697
  }
1514
- let a = er.get(tr(e, r));
1698
+ let a = Ir.get(Lr(e, r));
1515
1699
  return a === void 0 || a.failed ? void 0 : a.value;
1516
- }, or = (e, t, n) => {
1517
- let r = O([t, n]), i = Qn?.() ?? null;
1700
+ }, Hr = (e, t, n) => {
1701
+ let r = j([t, n]), i = Pr?.() ?? null;
1518
1702
  if (i !== null) {
1519
1703
  for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? "failed" : "seeded";
1520
1704
  return "absent";
1521
1705
  }
1522
- let a = er.get(tr(e, r));
1706
+ let a = Ir.get(Lr(e, r));
1523
1707
  return a === void 0 ? "absent" : a.failed ? "failed" : "seeded";
1524
- }, sr = () => {
1525
- er.clear();
1708
+ }, Ur = () => {
1709
+ Ir.clear();
1526
1710
  };
1527
1711
  //#endregion
1528
1712
  //#region src/usePreloadedSubscription.ts
1529
- function cr(e, t, n = {}, r = {}) {
1530
- let i = ar(e, t, n), a = G(e, t, n, i === void 0 ? r : {
1713
+ function Wr(e, t, n = {}, r = {}) {
1714
+ let i = Vr(e, t, n), a = q(e, t, n, i === void 0 ? r : {
1531
1715
  ...r,
1532
1716
  initialSnapshot: i
1533
1717
  });
1534
- return or(e, t, n) === "failed" ? {
1718
+ return Hr(e, t, n) === "failed" ? {
1535
1719
  ...a,
1536
1720
  preloadFailed: !0
1537
1721
  } : a;
1538
1722
  }
1539
1723
  //#endregion
1540
1724
  //#region src/useEvent.ts
1541
- var lr = {
1725
+ var Gr = {
1542
1726
  status: "idle",
1543
1727
  missed: 0,
1544
1728
  lastMiss: void 0
1545
- }, ur = class {
1729
+ }, Kr = class {
1546
1730
  _tag = "EventStreamClosed";
1547
1731
  };
1548
- function dr(e, t, n, r = {}) {
1549
- let { skip: i = !1, apiName: a = "app", onMissed: s } = r, c = W(a), { runtime: l, client: u } = c, [d, f] = B(lr), p = z(n);
1550
- p.current = n;
1551
- let m = z(s);
1732
+ function qr(e, t, r, i = {}) {
1733
+ let { skip: a = !1, apiName: o = "app", onMissed: s } = i, c = K(o), { runtime: l, client: u } = c, [d, f] = V(Gr), p = B(r);
1734
+ p.current = r;
1735
+ let m = B(s);
1552
1736
  m.current = s;
1553
- let g = z(u);
1554
- g.current = u;
1555
- let _ = z(l);
1556
- _.current = l;
1557
- let v = z(/* @__PURE__ */ new Map()), y = t === null ? null : JSON.stringify(Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1)), b = z(t);
1558
- b.current = t;
1559
- let x = z(null);
1560
- x.current !== y && (x.current = y, v.current = /* @__PURE__ */ new Map());
1561
- let S = F((t, n) => {
1562
- t <= 0 || (o(a, "event.gap", {
1737
+ let h = B(u);
1738
+ h.current = u;
1739
+ let g = B(l);
1740
+ g.current = l;
1741
+ let _ = B(/* @__PURE__ */ new Map()), v = t === null ? null : JSON.stringify(Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1)), y = B(t);
1742
+ y.current = t;
1743
+ let b = B(null);
1744
+ b.current !== v && (b.current = v, _.current = /* @__PURE__ */ new Map());
1745
+ let x = L((t, r) => {
1746
+ t <= 0 || (n(o, "event.gap", {
1563
1747
  tag: e.name,
1564
1748
  missed: t,
1565
- reason: n
1749
+ reason: r
1566
1750
  }), f((e) => ({
1567
1751
  ...e,
1568
1752
  missed: e.missed + t,
1569
1753
  lastMiss: {
1570
1754
  count: t,
1571
- reason: n
1755
+ reason: r
1572
1756
  }
1573
1757
  })), m.current?.({
1574
1758
  count: t,
1575
- reason: n
1759
+ reason: r
1576
1760
  }));
1577
- }, [a, e.name]), C = !i && y !== null && !nt(c);
1578
- return L(() => {
1579
- if (!C) {
1580
- f(lr);
1761
+ }, [o, e.name]), S = !a && v !== null && !ft(c);
1762
+ return R(() => {
1763
+ if (!S) {
1764
+ f(Gr);
1581
1765
  return;
1582
1766
  }
1583
1767
  f((e) => ({
1584
1768
  ...e,
1585
1769
  status: "connecting"
1586
1770
  }));
1587
- let t = 0, n = V.sync(() => {
1588
- let t = [...v.current].map(([e, t]) => ({
1771
+ let t = 0, n = U.sync(() => {
1772
+ let t = [..._.current].map(([e, t]) => ({
1589
1773
  origin: e,
1590
1774
  n: t
1591
1775
  }));
1592
- return h(g.current, e.name)({
1593
- key: b.current,
1776
+ return T(h.current, e.name)({
1777
+ key: y.current,
1594
1778
  ...t.length > 0 ? { resume: t } : {}
1595
1779
  });
1596
- }), r = H.unwrap(n).pipe(H.tap(() => V.sync(() => {
1780
+ }), r = W.unwrap(n).pipe(W.tap(() => U.sync(() => {
1597
1781
  t = 0;
1598
- })), H.concat(H.fail(new ur())), H.retry(Ae.exponential("250 millis", 2).pipe(Ae.either(Ae.spaced("30 seconds")), Ae.jittered, Ae.tapOutput(() => V.sync(() => {
1782
+ })), W.concat(W.fail(new Kr())), W.retry(Me.exponential("250 millis", 2).pipe(Me.either(Me.spaced("30 seconds")), Me.jittered, Me.tapOutput(() => U.sync(() => {
1599
1783
  t += 1, f((e) => ({
1600
1784
  ...e,
1601
1785
  status: "connecting"
1602
1786
  }));
1603
- }))))), i = _.current.runFork(H.runForEach(r, (e) => V.sync(() => {
1787
+ }))))), i = g.current.runFork(W.runForEach(r, (e) => U.sync(() => {
1604
1788
  if (e._tag === "attached") {
1605
1789
  f((e) => ({
1606
1790
  ...e,
@@ -1609,24 +1793,24 @@ function dr(e, t, n, r = {}) {
1609
1793
  return;
1610
1794
  }
1611
1795
  if (e._tag === "gap") {
1612
- S(e.missed, e.reason);
1796
+ x(e.missed, e.reason);
1613
1797
  return;
1614
1798
  }
1615
- v.current.set(e.origin, Math.max(v.current.get(e.origin) ?? 0, e.n)), p.current(e.payload);
1799
+ _.current.set(e.origin, Math.max(_.current.get(e.origin) ?? 0, e.n)), p.current(e.payload);
1616
1800
  })));
1617
1801
  return () => {
1618
- _.current.runFork(i.interruptAsFork(i.id()));
1802
+ g.current.runFork(i.interruptAsFork(i.id()));
1619
1803
  };
1620
1804
  }, [
1621
- C,
1622
- y,
1805
+ S,
1806
+ v,
1623
1807
  e.name,
1624
- S
1625
- ]), C ? d : lr;
1808
+ x
1809
+ ]), S ? d : Gr;
1626
1810
  }
1627
1811
  //#endregion
1628
1812
  //#region src/sequence.ts
1629
- var fr = () => {
1813
+ var Jr = () => {
1630
1814
  let e = (t) => ({
1631
1815
  steps: t,
1632
1816
  step: ((n, r, i) => e([...t, {
@@ -1638,7 +1822,7 @@ var fr = () => {
1638
1822
  }]))
1639
1823
  });
1640
1824
  return e([]);
1641
- }, pr = async (e, t = {}) => {
1825
+ }, Yr = async (e, t = {}) => {
1642
1826
  let n = {}, r = [];
1643
1827
  for (let i of e.steps) {
1644
1828
  if (i.when !== void 0 && !i.when(n)) {
@@ -1698,13 +1882,13 @@ var fr = () => {
1698
1882
  ok: !0,
1699
1883
  data: n
1700
1884
  };
1701
- }, mr = (e = {}) => {
1702
- let [t, n] = B(!1), [r, i] = B(void 0), [a, o] = B(void 0), s = z(e);
1885
+ }, Xr = (e = {}) => {
1886
+ let [t, n] = V(!1), [r, i] = V(void 0), [a, o] = V(void 0), s = B(e);
1703
1887
  return s.current = e, {
1704
- run: F(async (e, t = {}) => {
1888
+ run: L(async (e, t = {}) => {
1705
1889
  n(!0), i(void 0), o(void 0);
1706
1890
  try {
1707
- let n = await pr(e, {
1891
+ let n = await Yr(e, {
1708
1892
  ...s.current,
1709
1893
  ...t
1710
1894
  });
@@ -1717,7 +1901,7 @@ var fr = () => {
1717
1901
  error: r,
1718
1902
  failedStep: a
1719
1903
  };
1720
- }, hr = "@voltro/plugin-storage", Q = (e) => Ie(hr, e), gr = (e, t, n, r) => new Promise((i, a) => {
1904
+ }, Zr = "@voltro/plugin-storage", Q = (e) => Ge(Zr, e), Qr = (e, t, n, r) => new Promise((i, a) => {
1721
1905
  let o = new XMLHttpRequest();
1722
1906
  if (o.open("PUT", e), o.upload.onprogress = (e) => {
1723
1907
  e.lengthComputable && n(e.loaded / e.total);
@@ -1731,7 +1915,7 @@ var fr = () => {
1731
1915
  return;
1732
1916
  }
1733
1917
  r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
1734
- }), _r = (e, t, n, r, i, a) => new Promise((o, s) => {
1918
+ }), $r = (e, t, n, r, i, a) => new Promise((o, s) => {
1735
1919
  let c = new XMLHttpRequest();
1736
1920
  if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
1737
1921
  e.lengthComputable && r(e.loaded / e.total);
@@ -1749,7 +1933,7 @@ var fr = () => {
1749
1933
  return;
1750
1934
  }
1751
1935
  i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
1752
- }), vr = (e, t, n, r, i) => new Promise((a, o) => {
1936
+ }), ei = (e, t, n, r, i) => new Promise((a, o) => {
1753
1937
  let s = new XMLHttpRequest();
1754
1938
  if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
1755
1939
  e.lengthComputable && r(e.loaded / e.total);
@@ -1760,7 +1944,7 @@ var fr = () => {
1760
1944
  return;
1761
1945
  }
1762
1946
  i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
1763
- }), yr = (e, t, n, r, i) => new Promise((a, o) => {
1947
+ }), ti = (e, t, n, r, i) => new Promise((a, o) => {
1764
1948
  let s = new XMLHttpRequest();
1765
1949
  if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
1766
1950
  e.lengthComputable && r(e.loaded / e.total);
@@ -1776,244 +1960,244 @@ var fr = () => {
1776
1960
  return;
1777
1961
  }
1778
1962
  i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
1779
- }), br = (e, t = {}) => {
1780
- let r = W(e), { inspectBaseUrl: a } = r, o = z(r);
1781
- o.current = r;
1782
- let [s, c] = B(0), [l, u] = B("idle"), [d, f] = B(void 0), p = z(null), m = F(() => {
1783
- c(0), u("idle"), f(void 0);
1784
- }, []), g = F(() => {
1963
+ }), ni = (t, n = {}) => {
1964
+ let r = K(t), { inspectBaseUrl: i } = r, a = B(r);
1965
+ a.current = r;
1966
+ let [o, s] = V(0), [c, l] = V("idle"), [u, d] = V(void 0), p = B(null), m = L(() => {
1967
+ s(0), l("idle"), d(void 0);
1968
+ }, []), h = L(() => {
1785
1969
  p.current?.abort();
1786
- }, []), _ = F((e) => /^https?:\/\//.test(e) ? e : `${a}${e}`, [a]), v = F(async (r, i, a, s) => {
1787
- let { runtime: c, client: l } = await K(o, e, "storage.upload").catch((e) => {
1788
- throw n(e, "client");
1789
- }), u = Math.max(0, i.retries ?? t.retries ?? 1), d = (r instanceof File, r.type || "application/octet-stream"), f = r instanceof File ? r.name : "blob", p = i.visibility ?? t.visibility, m = i.key ?? t.key, g = i.folder ?? t.folder, v = i.tags ?? t.tags, y = {
1970
+ }, []), g = L((e) => /^https?:\/\//.test(e) ? e : `${i}${e}`, [i]), _ = L(async (e, r, i, o) => {
1971
+ let { runtime: s, client: c } = await J(a, t, "storage.upload").catch((e) => {
1972
+ throw x(e, "client");
1973
+ }), l = Math.max(0, r.retries ?? n.retries ?? 1), u = (e instanceof File, e.type || "application/octet-stream"), d = e instanceof File ? e.name : "blob", p = r.visibility ?? n.visibility, m = r.key ?? n.key, h = r.folder ?? n.folder, _ = r.tags ?? n.tags, v = {
1790
1974
  ...p ? { visibility: p } : {},
1791
- ...g ? { folder: g } : {},
1792
- ...v ? { tags: v } : {},
1793
- ...i.alt ? { alt: i.alt } : {},
1794
- ...i.caption ? { caption: i.caption } : {}
1795
- }, b = (e) => ({
1975
+ ...h ? { folder: h } : {},
1976
+ ..._ ? { tags: _ } : {},
1977
+ ...r.alt ? { alt: r.alt } : {},
1978
+ ...r.caption ? { caption: r.caption } : {}
1979
+ }, y = (e) => ({
1796
1980
  id: e.id,
1797
- url: _(e.url),
1798
- name: f,
1981
+ url: g(e.url),
1982
+ name: d,
1799
1983
  mime: e.contentType,
1800
1984
  size: e.size,
1801
1985
  ...e.width === void 0 ? {} : { width: e.width },
1802
1986
  ...e.height === void 0 ? {} : { height: e.height }
1803
- }), x = async () => {
1804
- let e = i.mintTag ?? t.mintTag ?? Q("mintUploadTicket"), n = h(l, e), o = await C(c, n({
1805
- contentType: d,
1806
- ...y,
1987
+ }), b = async () => {
1988
+ let t = r.mintTag ?? n.mintTag ?? Q("mintUploadTicket"), a = T(c, t), l = await f(s, a({
1989
+ contentType: u,
1990
+ ...v,
1807
1991
  ...m ? { key: m } : {}
1808
- })), u = await yr(_(o.uploadUrl), d, r, s, a);
1809
- return b(u);
1992
+ })), d = await ti(g(l.uploadUrl), u, e, o, i);
1993
+ return y(d);
1810
1994
  }, S = async () => {
1811
- let e = i.presignMintTag ?? t.presignMintTag ?? Q("mintPresignedUpload"), n = i.finalizeTag ?? t.finalizeTag ?? Q("finalizeUpload"), o;
1995
+ let t = r.presignMintTag ?? n.presignMintTag ?? Q("mintPresignedUpload"), a = r.finalizeTag ?? n.finalizeTag ?? Q("finalizeUpload"), l;
1812
1996
  try {
1813
- let t = h(l, e);
1814
- o = await C(c, t({
1815
- contentType: d,
1816
- ...y
1997
+ let e = T(c, t);
1998
+ l = await f(s, e({
1999
+ contentType: u,
2000
+ ...v
1817
2001
  }));
1818
2002
  } catch {
1819
2003
  return null;
1820
2004
  }
1821
- await vr(o.uploadUrl, d, r, s, a);
1822
- let u = h(l, n), f = await C(c, u({ finalizeToken: o.finalizeToken }));
1823
- return b(f);
1824
- }, w = async () => {
1825
- let e = i.beginResumableTag ?? t.beginResumableTag ?? Q("beginResumableUpload"), n = h(l, e), o = r.size, u = i.chunkSize ?? t.chunkSize, f = await C(c, n({
1826
- contentType: d,
1827
- size: o,
1828
- ...y,
1829
- ...u ? { chunkSize: u } : {}
1830
- })), p = _(f.uploadUrl), m = Math.max(1, f.chunkSize), g = Math.max(1, Math.ceil(o / m)), v = Math.max(0, i.retries ?? t.retries ?? 1), x = 0, S = null;
1831
- for (let e = 0; e < g; e++) {
1832
- let t = e * m, n = Math.min(o, t + m), i = r.slice(t, n), c = e === g - 1, l = n - t, u = 0;
2005
+ await ei(l.uploadUrl, u, e, o, i);
2006
+ let d = T(c, a), p = await f(s, d({ finalizeToken: l.finalizeToken }));
2007
+ return y(p);
2008
+ }, C = async () => {
2009
+ let t = r.beginResumableTag ?? n.beginResumableTag ?? Q("beginResumableUpload"), a = T(c, t), l = e.size, d = r.chunkSize ?? n.chunkSize, p = await f(s, a({
2010
+ contentType: u,
2011
+ size: l,
2012
+ ...v,
2013
+ ...d ? { chunkSize: d } : {}
2014
+ })), m = g(p.uploadUrl), h = Math.max(1, p.chunkSize), _ = Math.max(1, Math.ceil(l / h)), b = Math.max(0, r.retries ?? n.retries ?? 1), x = 0, S = null;
2015
+ for (let t = 0; t < _; t++) {
2016
+ let n = t * h, r = Math.min(l, n + h), a = e.slice(n, r), s = t === _ - 1, c = r - n, d = 0;
1833
2017
  for (;;) {
1834
- if (a.aborted) throw new DOMException("upload aborted", "AbortError");
2018
+ if (i.aborted) throw new DOMException("upload aborted", "AbortError");
1835
2019
  try {
1836
- let t = await _r(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${e}${c ? "&final=1" : ""}`}`, d, i, (e) => s((x + e * l) / o), a, c);
1837
- c && (S = t);
2020
+ let e = await $r(`${m}?${`token=${encodeURIComponent(p.resumableToken)}&index=${t}${s ? "&final=1" : ""}`}`, u, a, (e) => o((x + e * c) / l), i, s);
2021
+ s && (S = e);
1838
2022
  break;
1839
2023
  } catch (e) {
1840
- if (e instanceof DOMException && e.name === "AbortError" || u++ >= v) throw e;
2024
+ if (e instanceof DOMException && e.name === "AbortError" || d++ >= b) throw e;
1841
2025
  }
1842
2026
  }
1843
- x += l, s(x / o);
2027
+ x += c, o(x / l);
1844
2028
  }
1845
2029
  if (!S) throw Error("resumable upload produced no final reply");
1846
- return b(S);
1847
- }, T = async () => {
1848
- let e = i.multipartBeginTag ?? t.multipartBeginTag ?? Q("beginMultipartUpload"), n = i.multipartSignTag ?? t.multipartSignTag ?? Q("signMultipartPart"), o = i.multipartCompleteTag ?? t.multipartCompleteTag ?? Q("completeMultipartUpload"), u = i.multipartAbortTag ?? t.multipartAbortTag ?? Q("abortMultipartUpload"), p = r.size, m = i.chunkSize ?? t.chunkSize, g;
2030
+ return y(S);
2031
+ }, w = async () => {
2032
+ let t = r.multipartBeginTag ?? n.multipartBeginTag ?? Q("beginMultipartUpload"), a = r.multipartSignTag ?? n.multipartSignTag ?? Q("signMultipartPart"), l = r.multipartCompleteTag ?? n.multipartCompleteTag ?? Q("completeMultipartUpload"), p = r.multipartAbortTag ?? n.multipartAbortTag ?? Q("abortMultipartUpload"), m = e.size, h = r.chunkSize ?? n.chunkSize, _;
1849
2033
  try {
1850
- let t = h(l, e);
1851
- g = await C(c, t({
1852
- contentType: d,
1853
- size: p,
1854
- ...y,
1855
- ...m ? { partSize: m } : {}
2034
+ let e = T(c, t);
2035
+ _ = await f(s, e({
2036
+ contentType: u,
2037
+ size: m,
2038
+ ...v,
2039
+ ...h ? { partSize: h } : {}
1856
2040
  }));
1857
2041
  } catch {
1858
2042
  return null;
1859
2043
  }
1860
- let v = h(l, n), b = h(l, o), x = h(l, u), S = Math.max(1, g.partSize), w = Math.max(1, Math.ceil(p / S)), T = Math.max(0, i.retries ?? t.retries ?? 1), E = [], D = 0;
2044
+ let y = T(c, a), b = T(c, l), x = T(c, p), S = Math.max(1, _.partSize), C = Math.max(1, Math.ceil(m / S)), w = Math.max(0, r.retries ?? n.retries ?? 1), E = [], D = 0;
1861
2045
  try {
1862
- for (let e = 0; e < w; e++) {
1863
- let t = e * S, n = Math.min(p, t + S), i = r.slice(t, n), o = e + 1, l = n - t, u = 0;
2046
+ for (let t = 0; t < C; t++) {
2047
+ let n = t * S, r = Math.min(m, n + S), a = e.slice(n, r), c = t + 1, l = r - n, u = 0;
1864
2048
  for (;;) {
1865
- if (a.aborted) throw new DOMException("upload aborted", "AbortError");
2049
+ if (i.aborted) throw new DOMException("upload aborted", "AbortError");
1866
2050
  try {
1867
- let { url: e } = await C(c, v({
1868
- multipartToken: g.multipartToken,
1869
- partNumber: o
1870
- })), t = await gr(e, i, (e) => s((D + e * l) / p), a);
2051
+ let { url: e } = await f(s, y({
2052
+ multipartToken: _.multipartToken,
2053
+ partNumber: c
2054
+ })), t = await Qr(e, a, (e) => o((D + e * l) / m), i);
1871
2055
  E.push({
1872
- partNumber: o,
2056
+ partNumber: c,
1873
2057
  etag: t
1874
2058
  });
1875
2059
  break;
1876
2060
  } catch (e) {
1877
- if (e instanceof DOMException && e.name === "AbortError" || u++ >= T) throw e;
2061
+ if (e instanceof DOMException && e.name === "AbortError" || u++ >= w) throw e;
1878
2062
  }
1879
2063
  }
1880
- D += l, s(D / p);
2064
+ D += l, o(D / m);
1881
2065
  }
1882
- let e = await C(c, b({
1883
- multipartToken: g.multipartToken,
2066
+ let t = await f(s, b({
2067
+ multipartToken: _.multipartToken,
1884
2068
  parts: E
1885
2069
  }));
1886
2070
  return {
1887
- id: e.id,
1888
- url: _(e.url),
1889
- name: f,
1890
- mime: d,
1891
- size: e.size
2071
+ id: t.id,
2072
+ url: g(t.url),
2073
+ name: d,
2074
+ mime: u,
2075
+ size: t.size
1892
2076
  };
1893
2077
  } catch (e) {
1894
2078
  try {
1895
- await C(c, x({ multipartToken: g.multipartToken }));
2079
+ await f(s, x({ multipartToken: _.multipartToken }));
1896
2080
  } catch {}
1897
2081
  throw e;
1898
2082
  }
1899
2083
  };
1900
- if ((i.prefer ?? t.prefer) === "multipart") return await T() || await w();
1901
- if ((i.prefer ?? t.prefer) === "resumable") return await w();
1902
- let E = (i.prefer ?? t.prefer) === "presign", D;
1903
- for (let e = 0; e <= u; e++) {
1904
- if (a.aborted) throw new DOMException("upload aborted", "AbortError");
2084
+ if ((r.prefer ?? n.prefer) === "multipart") return await w() || await C();
2085
+ if ((r.prefer ?? n.prefer) === "resumable") return await C();
2086
+ let E = (r.prefer ?? n.prefer) === "presign", D;
2087
+ for (let e = 0; e <= l; e++) {
2088
+ if (i.aborted) throw new DOMException("upload aborted", "AbortError");
1905
2089
  try {
1906
2090
  if (E) {
1907
2091
  let e = await S();
1908
2092
  if (e) return e;
1909
2093
  }
1910
- return await x();
2094
+ return await b();
1911
2095
  } catch (t) {
1912
- if (t instanceof DOMException && t.name === "AbortError" || (D = t, e === u)) throw t;
2096
+ if (t instanceof DOMException && t.name === "AbortError" || (D = t, e === l)) throw t;
1913
2097
  }
1914
2098
  }
1915
2099
  throw D;
1916
2100
  }, [
1917
- e,
1918
- _,
1919
- t.mintTag,
1920
- t.presignMintTag,
1921
- t.finalizeTag,
1922
- t.beginResumableTag,
1923
- t.multipartBeginTag,
1924
- t.multipartSignTag,
1925
- t.multipartCompleteTag,
1926
- t.multipartAbortTag,
1927
- t.chunkSize,
1928
- t.prefer,
1929
- t.visibility,
1930
- t.key,
1931
- t.folder,
1932
- t.tags,
1933
- t.retries
1934
- ]), y = F(async (e, n = {}) => {
1935
- let r = new AbortController();
1936
- p.current = r, u("uploading"), f(void 0), c(0);
2101
+ t,
2102
+ g,
2103
+ n.mintTag,
2104
+ n.presignMintTag,
2105
+ n.finalizeTag,
2106
+ n.beginResumableTag,
2107
+ n.multipartBeginTag,
2108
+ n.multipartSignTag,
2109
+ n.multipartCompleteTag,
2110
+ n.multipartAbortTag,
2111
+ n.chunkSize,
2112
+ n.prefer,
2113
+ n.visibility,
2114
+ n.key,
2115
+ n.folder,
2116
+ n.tags,
2117
+ n.retries
2118
+ ]), v = L(async (t, r = {}) => {
2119
+ let i = new AbortController();
2120
+ p.current = i, l("uploading"), d(void 0), s(0);
1937
2121
  try {
1938
- let t = await v(e, n, r.signal, c);
1939
- return c(1), u("success"), t;
1940
- } catch (e) {
1941
- throw u("error"), f(e), e instanceof DOMException && e.name === "AbortError" || o.current.errorBus.emit({
2122
+ let e = await _(t, r, i.signal, s);
2123
+ return s(1), l("success"), e;
2124
+ } catch (t) {
2125
+ throw l("error"), d(t), t instanceof DOMException && t.name === "AbortError" || a.current.errorBus.emit({
1942
2126
  source: "action",
1943
- tag: n.mintTag ?? t.mintTag ?? Q("mintUploadTicket"),
1944
- error: e,
1945
- kind: i(e, "unknown"),
1946
- outcome: i(e, "unknown") === "transport" ? "unknown" : "not-applicable"
1947
- }), e;
2127
+ tag: r.mintTag ?? n.mintTag ?? Q("mintUploadTicket"),
2128
+ error: t,
2129
+ kind: e(t, "unknown"),
2130
+ outcome: e(t, "unknown") === "transport" ? "unknown" : "not-applicable"
2131
+ }), t;
1948
2132
  }
1949
- }, [v, t.mintTag]), b = F(async (e, n = {}) => {
1950
- if (e.length === 0) return [];
1951
- let r = new AbortController();
1952
- p.current = r, u("uploading"), f(void 0), c(0);
1953
- let a = Math.max(1, n.concurrency ?? t.concurrency ?? 3), s = Array(e.length), l = Array(e.length).fill(0), d = () => c(l.reduce((e, t) => e + t, 0) / e.length), m = 0, h = async () => {
2133
+ }, [_, n.mintTag]), y = L(async (t, r = {}) => {
2134
+ if (t.length === 0) return [];
2135
+ let i = new AbortController();
2136
+ p.current = i, l("uploading"), d(void 0), s(0);
2137
+ let o = Math.max(1, r.concurrency ?? n.concurrency ?? 3), c = Array(t.length), u = Array(t.length).fill(0), f = () => s(u.reduce((e, t) => e + t, 0) / t.length), m = 0, h = async () => {
1954
2138
  for (;;) {
1955
- let t = m++;
1956
- if (t >= e.length) return;
1957
- s[t] = await v(e[t], n, r.signal, (e) => {
1958
- l[t] = e, d();
1959
- }), l[t] = 1, d();
2139
+ let e = m++;
2140
+ if (e >= t.length) return;
2141
+ c[e] = await _(t[e], r, i.signal, (t) => {
2142
+ u[e] = t, f();
2143
+ }), u[e] = 1, f();
1960
2144
  }
1961
2145
  };
1962
2146
  try {
1963
- return await Promise.all(Array.from({ length: Math.min(a, e.length) }, () => h())), c(1), u("success"), s;
1964
- } catch (e) {
1965
- throw r.abort(), u("error"), f(e), e instanceof DOMException && e.name === "AbortError" || o.current.errorBus.emit({
2147
+ return await Promise.all(Array.from({ length: Math.min(o, t.length) }, () => h())), s(1), l("success"), c;
2148
+ } catch (t) {
2149
+ throw i.abort(), l("error"), d(t), t instanceof DOMException && t.name === "AbortError" || a.current.errorBus.emit({
1966
2150
  source: "action",
1967
- tag: n.mintTag ?? t.mintTag ?? Q("mintUploadTicket"),
1968
- error: e,
1969
- kind: i(e, "unknown"),
1970
- outcome: i(e, "unknown") === "transport" ? "unknown" : "not-applicable"
1971
- }), e;
2151
+ tag: r.mintTag ?? n.mintTag ?? Q("mintUploadTicket"),
2152
+ error: t,
2153
+ kind: e(t, "unknown"),
2154
+ outcome: e(t, "unknown") === "transport" ? "unknown" : "not-applicable"
2155
+ }), t;
1972
2156
  }
1973
2157
  }, [
1974
- v,
1975
- t.concurrency,
1976
- t.mintTag
1977
- ]), x = F((e, t = {}) => {
2158
+ _,
2159
+ n.concurrency,
2160
+ n.mintTag
2161
+ ]), b = L((e, t = {}) => {
1978
2162
  e.preventDefault();
1979
2163
  let n = e.dataTransfer ? Array.from(e.dataTransfer.files) : [];
1980
- return n.length ? b(n, t) : Promise.resolve([]);
1981
- }, [b]), S = F((e, t = {}) => {
2164
+ return n.length ? y(n, t) : Promise.resolve([]);
2165
+ }, [y]), S = L((e, t = {}) => {
1982
2166
  let n = e.clipboardData ? Array.from(e.clipboardData.files) : [];
1983
- return n.length ? b(n, t) : Promise.resolve([]);
1984
- }, [b]), w = R(() => ({
2167
+ return n.length ? y(n, t) : Promise.resolve([]);
2168
+ }, [y]), C = z(() => ({
1985
2169
  onDragOver: (e) => e.preventDefault(),
1986
2170
  onDrop: (e) => {
1987
- x(e);
2171
+ b(e);
1988
2172
  }
1989
- }), [x]);
1990
- return R(() => ({
1991
- upload: y,
1992
- uploadMany: b,
1993
- progress: s,
1994
- status: l,
1995
- error: d,
1996
- cancel: g,
2173
+ }), [b]);
2174
+ return z(() => ({
2175
+ upload: v,
2176
+ uploadMany: y,
2177
+ progress: o,
2178
+ status: c,
2179
+ error: u,
2180
+ cancel: h,
1997
2181
  reset: m,
1998
- onDrop: x,
2182
+ onDrop: b,
1999
2183
  onPaste: S,
2000
- dropzoneProps: w
2184
+ dropzoneProps: C
2001
2185
  }), [
2186
+ v,
2002
2187
  y,
2003
- b,
2004
- s,
2005
- l,
2006
- d,
2007
- g,
2188
+ o,
2189
+ c,
2190
+ u,
2191
+ h,
2008
2192
  m,
2009
- x,
2193
+ b,
2010
2194
  S,
2011
- w
2195
+ C
2012
2196
  ]);
2013
- }, xr = (e, t) => {
2014
- let n = br(e), r = On(e, t.action), [i, a] = B("idle"), [o, s] = B(void 0), [c, l] = B(void 0), u = z(t.extra);
2197
+ }, ri = (e, t) => {
2198
+ let n = ni(e), r = ur(e, t.action), [i, a] = V("idle"), [o, s] = V(void 0), [c, l] = V(void 0), u = B(t.extra);
2015
2199
  u.current = t.extra;
2016
- let d = F(async (e) => {
2200
+ let d = L(async (e) => {
2017
2201
  l(void 0), s(void 0), a("uploading");
2018
2202
  let t;
2019
2203
  try {
@@ -2031,12 +2215,12 @@ var fr = () => {
2031
2215
  } catch (e) {
2032
2216
  throw a("error"), l(e), e;
2033
2217
  }
2034
- }, [n, r]), f = F(() => {
2218
+ }, [n, r]), f = L(() => {
2035
2219
  n.cancel(), a("idle");
2036
- }, [n]), p = F(() => {
2220
+ }, [n]), p = L(() => {
2037
2221
  n.reset(), a("idle"), s(void 0), l(void 0);
2038
2222
  }, [n]);
2039
- return R(() => ({
2223
+ return z(() => ({
2040
2224
  phase: i,
2041
2225
  progress: i === "uploading" ? n.progress : void 0,
2042
2226
  result: o,
@@ -2055,28 +2239,28 @@ var fr = () => {
2055
2239
  p
2056
2240
  ]);
2057
2241
  }, $ = async (e) => {
2058
- let t = h(e.client, e.tag), n = V.currentSpan.pipe(V.tap((t) => V.sync(() => {
2059
- _({
2242
+ let t = T(e.client, e.tag), n = U.currentSpan.pipe(U.tap((t) => U.sync(() => {
2243
+ b({
2060
2244
  traceId: t.traceId,
2061
2245
  spanId: t.spanId,
2062
2246
  source: "mutation",
2063
2247
  tag: e.tag
2064
2248
  });
2065
- })), V.catchAll(() => V.void), V.zipRight(t(e.input)), V.withSpan(`${e.spanPrefix}.${e.tag}`, { attributes: {
2249
+ })), U.catchAll(() => U.void), U.zipRight(t(e.input)), U.withSpan(`${e.spanPrefix}.${e.tag}`, { attributes: {
2066
2250
  "voltro.api": e.apiName,
2067
2251
  "rpc.tag": e.tag
2068
2252
  } }));
2069
- return C(e.runtime, n);
2070
- }, Sr = (e, t) => {
2071
- let n = W(e), { descriptors: r } = n, i = z(n);
2253
+ return f(e.runtime, n);
2254
+ }, ii = (e, t) => {
2255
+ let n = K(e), { descriptors: r } = n, i = B(n);
2072
2256
  if (i.current = n, process.env.NODE_ENV !== "production") {
2073
2257
  let n = r[t]?.kind;
2074
2258
  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.`);
2075
2259
  }
2076
- let [a, o] = B(!1), [s, c] = B(void 0), [l, u] = B(void 0), d = F(async (n) => {
2260
+ let [a, o] = V(!1), [s, c] = V(void 0), [l, u] = V(void 0), d = L(async (n) => {
2077
2261
  o(!0), c(void 0);
2078
2262
  try {
2079
- let { runtime: r, client: a } = await K(i, e, t), o = await $({
2263
+ let { runtime: r, client: a } = await J(i, e, t), o = await $({
2080
2264
  apiName: e,
2081
2265
  runtime: r,
2082
2266
  client: a,
@@ -2090,8 +2274,8 @@ var fr = () => {
2090
2274
  } finally {
2091
2275
  o(!1);
2092
2276
  }
2093
- }, [e, t]), f = F(async (t) => {
2094
- let n = "__voltro.workflow.queued.cancel", { runtime: r, client: a } = await K(i, e, n);
2277
+ }, [e, t]), p = L(async (t) => {
2278
+ let n = "__voltro.workflow.queued.cancel", { runtime: r, client: a } = await J(i, e, n);
2095
2279
  return $({
2096
2280
  apiName: e,
2097
2281
  runtime: r,
@@ -2100,26 +2284,26 @@ var fr = () => {
2100
2284
  input: t,
2101
2285
  spanPrefix: "client.workflow.queued.cancel"
2102
2286
  });
2103
- }, [e]), p = F(async (t) => {
2104
- let n = "__voltro.workflow.queued.control", { runtime: r, client: a } = await K(i, e, n), o = h(a, n);
2105
- return C(r, H.runHead(o(t)).pipe(V.flatMap((e) => {
2106
- if (ke.isSome(e)) {
2107
- if (e.value._tag === "snapshot") return V.succeed(e.value.data);
2108
- if (e.value._tag === "error") return V.fail(e.value.error);
2287
+ }, [e]), m = L(async (t) => {
2288
+ let n = "__voltro.workflow.queued.control", { runtime: r, client: a } = await J(i, e, n), o = T(a, n);
2289
+ return f(r, W.runHead(o(t)).pipe(U.flatMap((e) => {
2290
+ if (je.isSome(e)) {
2291
+ if (e.value._tag === "snapshot") return U.succeed(e.value.data);
2292
+ if (e.value._tag === "error") return U.fail(e.value.error);
2109
2293
  }
2110
- return V.fail(/* @__PURE__ */ Error("queued workflow control query ended without a snapshot"));
2294
+ return U.fail(/* @__PURE__ */ Error("queued workflow control query ended without a snapshot"));
2111
2295
  })));
2112
- }, [e]), m = F(async (t) => {
2113
- let n = "__voltro.workflow.control", { runtime: r, client: a } = await K(i, e, n), o = h(a, n);
2114
- return C(r, H.runHead(o(t)).pipe(V.flatMap((e) => {
2115
- if (ke.isSome(e)) {
2116
- if (e.value._tag === "snapshot") return V.succeed(e.value.data);
2117
- if (e.value._tag === "error") return V.fail(e.value.error);
2296
+ }, [e]), h = L(async (t) => {
2297
+ let n = "__voltro.workflow.control", { runtime: r, client: a } = await J(i, e, n), o = T(a, n);
2298
+ return f(r, W.runHead(o(t)).pipe(U.flatMap((e) => {
2299
+ if (je.isSome(e)) {
2300
+ if (e.value._tag === "snapshot") return U.succeed(e.value.data);
2301
+ if (e.value._tag === "error") return U.fail(e.value.error);
2118
2302
  }
2119
- return V.fail(/* @__PURE__ */ Error("workflow control query ended without a snapshot"));
2303
+ return U.fail(/* @__PURE__ */ Error("workflow control query ended without a snapshot"));
2120
2304
  })));
2121
- }, [e]), g = F(async (t, n) => {
2122
- let { runtime: r, client: a } = await K(i, e, "__voltro.workflow.cancel");
2305
+ }, [e]), g = L(async (t, n) => {
2306
+ let { runtime: r, client: a } = await J(i, e, "__voltro.workflow.cancel");
2123
2307
  return $({
2124
2308
  apiName: e,
2125
2309
  runtime: r,
@@ -2131,8 +2315,8 @@ var fr = () => {
2131
2315
  },
2132
2316
  spanPrefix: "client.workflow.cancel"
2133
2317
  });
2134
- }, [e]), _ = F(async (t, n) => {
2135
- let { runtime: r, client: a } = await K(i, e, "__voltro.workflow.resume");
2318
+ }, [e]), _ = L(async (t, n) => {
2319
+ let { runtime: r, client: a } = await J(i, e, "__voltro.workflow.resume");
2136
2320
  return $({
2137
2321
  apiName: e,
2138
2322
  runtime: r,
@@ -2144,8 +2328,8 @@ var fr = () => {
2144
2328
  },
2145
2329
  spanPrefix: "client.workflow.resume"
2146
2330
  });
2147
- }, [e]), v = F(async (t, n, r) => {
2148
- let { runtime: a, client: o } = await K(i, e, "__voltro.workflow.signal");
2331
+ }, [e]), v = L(async (t, n, r) => {
2332
+ let { runtime: a, client: o } = await J(i, e, "__voltro.workflow.signal");
2149
2333
  return $({
2150
2334
  apiName: e,
2151
2335
  runtime: a,
@@ -2158,8 +2342,8 @@ var fr = () => {
2158
2342
  },
2159
2343
  spanPrefix: "client.workflow.signal"
2160
2344
  });
2161
- }, [e]), y = F(async (t, n, r, a) => {
2162
- let { runtime: o, client: s } = await K(i, e, "__voltro.workflow.update");
2345
+ }, [e]), y = L(async (t, n, r, a) => {
2346
+ let { runtime: o, client: s } = await J(i, e, "__voltro.workflow.update");
2163
2347
  return $({
2164
2348
  apiName: e,
2165
2349
  runtime: o,
@@ -2174,12 +2358,12 @@ var fr = () => {
2174
2358
  spanPrefix: "client.workflow.update"
2175
2359
  });
2176
2360
  }, [e]);
2177
- return R(() => ({
2361
+ return z(() => ({
2178
2362
  start: d,
2179
- cancelQueued: f,
2180
- readQueuedCancellation: p,
2363
+ cancelQueued: p,
2364
+ readQueuedCancellation: m,
2181
2365
  cancel: g,
2182
- readControl: m,
2366
+ readControl: h,
2183
2367
  resume: _,
2184
2368
  signal: v,
2185
2369
  update: y,
@@ -2188,10 +2372,10 @@ var fr = () => {
2188
2372
  data: l
2189
2373
  }), [
2190
2374
  d,
2191
- f,
2192
2375
  p,
2193
- g,
2194
2376
  m,
2377
+ g,
2378
+ h,
2195
2379
  _,
2196
2380
  v,
2197
2381
  y,
@@ -2199,13 +2383,13 @@ var fr = () => {
2199
2383
  s,
2200
2384
  l
2201
2385
  ]);
2202
- }, Cr = (e) => {
2203
- let t = W(e), n = z(t);
2386
+ }, ai = (e) => {
2387
+ let t = K(e), n = B(t);
2204
2388
  n.current = t;
2205
- let [r, i] = B(!1), [a, o] = B(void 0), [s, c] = B(void 0), l = F(async (t, r, a) => {
2389
+ let [r, i] = V(!1), [a, o] = V(void 0), [s, c] = V(void 0), l = L(async (t, r, a) => {
2206
2390
  i(!0), o(void 0);
2207
2391
  try {
2208
- let { runtime: i, client: o } = await K(n, e, "__voltro.workflow.signal"), s = await $({
2392
+ let { runtime: i, client: o } = await J(n, e, "__voltro.workflow.signal"), s = await $({
2209
2393
  apiName: e,
2210
2394
  runtime: i,
2211
2395
  client: o,
@@ -2224,7 +2408,7 @@ var fr = () => {
2224
2408
  i(!1);
2225
2409
  }
2226
2410
  }, [e]);
2227
- return R(() => ({
2411
+ return z(() => ({
2228
2412
  signal: l,
2229
2413
  pending: r,
2230
2414
  error: a,
@@ -2235,13 +2419,13 @@ var fr = () => {
2235
2419
  a,
2236
2420
  s
2237
2421
  ]);
2238
- }, wr = (e) => {
2239
- let t = W(e), n = z(t);
2422
+ }, oi = (e) => {
2423
+ let t = K(e), n = B(t);
2240
2424
  n.current = t;
2241
- let [r, i] = B(!1), [a, o] = B(void 0), [s, c] = B(void 0), l = F(async (t, r, a, s) => {
2425
+ let [r, i] = V(!1), [a, o] = V(void 0), [s, c] = V(void 0), l = L(async (t, r, a, s) => {
2242
2426
  i(!0), o(void 0);
2243
2427
  try {
2244
- let { runtime: i, client: o } = await K(n, e, "__voltro.workflow.update"), l = await $({
2428
+ let { runtime: i, client: o } = await J(n, e, "__voltro.workflow.update"), l = await $({
2245
2429
  apiName: e,
2246
2430
  runtime: i,
2247
2431
  client: o,
@@ -2261,7 +2445,7 @@ var fr = () => {
2261
2445
  i(!1);
2262
2446
  }
2263
2447
  }, [e]);
2264
- return R(() => ({
2448
+ return z(() => ({
2265
2449
  update: l,
2266
2450
  pending: r,
2267
2451
  error: a,
@@ -2272,8 +2456,8 @@ var fr = () => {
2272
2456
  a,
2273
2457
  s
2274
2458
  ]);
2275
- }, Tr = (e, t) => {
2276
- let n = G(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
2459
+ }, si = (e, t) => {
2460
+ let n = q(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
2277
2461
  return n.loading || n.idle || n.failed ? {
2278
2462
  ...n,
2279
2463
  run: void 0
@@ -2281,8 +2465,8 @@ var fr = () => {
2281
2465
  ...n,
2282
2466
  run: n.data[0]
2283
2467
  };
2284
- }, Er = (e, t = {}, n = {}) => {
2285
- let r = G(e, "__voltro.workflow.runs", t, n);
2468
+ }, ci = (e, t = {}, n = {}) => {
2469
+ let r = q(e, "__voltro.workflow.runs", t, n);
2286
2470
  return r.loading || r.idle || r.failed ? {
2287
2471
  ...r,
2288
2472
  runs: []
@@ -2290,8 +2474,8 @@ var fr = () => {
2290
2474
  ...r,
2291
2475
  runs: r.data
2292
2476
  };
2293
- }, Dr = (e, t) => {
2294
- let n = G(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
2477
+ }, li = (e, t) => {
2478
+ let n = q(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
2295
2479
  return n.loading || n.idle || n.failed ? {
2296
2480
  ...n,
2297
2481
  steps: []
@@ -2299,8 +2483,8 @@ var fr = () => {
2299
2483
  ...n,
2300
2484
  steps: n.data
2301
2485
  };
2302
- }, Or = (e, t) => {
2303
- let n = G(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
2486
+ }, ui = (e, t) => {
2487
+ let n = q(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
2304
2488
  return n.loading || n.idle || n.failed ? {
2305
2489
  ...n,
2306
2490
  events: []
@@ -2308,8 +2492,8 @@ var fr = () => {
2308
2492
  ...n,
2309
2493
  events: n.data
2310
2494
  };
2311
- }, kr = Or, Ar = (e, t = {}, n = {}) => {
2312
- let r = G(e, "__voltro.workflow.domainEvents", t, n);
2495
+ }, di = ui, fi = (e, t = {}, n = {}) => {
2496
+ let r = q(e, "__voltro.workflow.domainEvents", t, n);
2313
2497
  return r.loading || r.idle || r.failed ? {
2314
2498
  ...r,
2315
2499
  events: []
@@ -2317,8 +2501,8 @@ var fr = () => {
2317
2501
  ...r,
2318
2502
  events: r.data
2319
2503
  };
2320
- }, jr = (e, t) => {
2321
- let n = G(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
2504
+ }, pi = (e, t) => {
2505
+ let n = q(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
2322
2506
  return n.loading || n.idle || n.failed ? {
2323
2507
  ...n,
2324
2508
  deliveries: []
@@ -2326,42 +2510,42 @@ var fr = () => {
2326
2510
  ...n,
2327
2511
  deliveries: n.data
2328
2512
  };
2329
- }, Mr = (e, t) => {
2513
+ }, mi = (e, t) => {
2330
2514
  let n = e.payload;
2331
2515
  if (!n || typeof n != "object") return;
2332
2516
  let r = n[t];
2333
2517
  return typeof r == "string" ? r : void 0;
2334
- }, Nr = (e) => {
2518
+ }, hi = (e) => {
2335
2519
  let t = e.payload;
2336
2520
  if (!t || typeof t != "object") return;
2337
2521
  let n = t.updateId;
2338
2522
  return typeof n == "string" ? n : void 0;
2339
- }, Pr = (e) => {
2523
+ }, gi = (e) => {
2340
2524
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
2341
2525
  for (let r of e) if (r.eventType === "signal-received") {
2342
- let e = Mr(r, "signalName");
2526
+ let e = mi(r, "signalName");
2343
2527
  e && t.add(e);
2344
2528
  } else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
2345
- let e = Nr(r);
2529
+ let e = hi(r);
2346
2530
  e && n.add(e);
2347
2531
  }
2348
2532
  for (let r = e.length - 1; r >= 0; --r) {
2349
2533
  let i = e[r];
2350
2534
  if (i.eventType === "signal-awaited") {
2351
- let e = Mr(i, "signalName");
2535
+ let e = mi(i, "signalName");
2352
2536
  if (e && !t.has(e)) return {
2353
2537
  name: e,
2354
2538
  kind: "signal"
2355
2539
  };
2356
2540
  } else if (i.eventType === "update-requested") {
2357
- let e = Nr(i), t = Mr(i, "updateName");
2541
+ let e = hi(i), t = mi(i, "updateName");
2358
2542
  if (t && (!e || !n.has(e))) return {
2359
2543
  name: t,
2360
2544
  kind: "update"
2361
2545
  };
2362
2546
  }
2363
2547
  }
2364
- }, Fr = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), Ir = (e, t) => {
2548
+ }, _i = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), vi = (e, t) => {
2365
2549
  if (!e || e.status !== "failed") return;
2366
2550
  let n = t.find((e) => e.status === "failed");
2367
2551
  return {
@@ -2369,34 +2553,34 @@ var fr = () => {
2369
2553
  message: e.errorMessage,
2370
2554
  step: n?.stepName
2371
2555
  };
2372
- }, Lr = (e, t) => {
2373
- let n = Tr(e, t), r = Dr(e, t), i = Or(e, t), a = Sr(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = F(async () => {
2556
+ }, yi = (e, t) => {
2557
+ let n = si(e, t), r = li(e, t), i = ui(e, t), a = ii(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = L(async () => {
2374
2558
  if (!o) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
2375
2559
  await a.cancel({
2376
2560
  workflowName: o.tag,
2377
2561
  executionId: o.executionId
2378
2562
  });
2379
- }, [a, o]), u = F(async () => {
2563
+ }, [a, o]), u = L(async () => {
2380
2564
  if (!o) throw Error("useWorkflowRunState: no run loaded — cannot resume");
2381
2565
  await a.resume({
2382
2566
  workflowName: o.tag,
2383
2567
  executionId: o.executionId
2384
2568
  });
2385
- }, [a, o]), d = F((e, n) => {
2569
+ }, [a, o]), d = L((e, n) => {
2386
2570
  if (t === void 0) throw Error("useWorkflowRunState: no run id — cannot signal");
2387
2571
  return a.signal({ id: t }, e, n);
2388
- }, [a, t]), f = F((e, n, r) => {
2572
+ }, [a, t]), f = L((e, n, r) => {
2389
2573
  if (t === void 0) throw Error("useWorkflowRunState: no run id — cannot update");
2390
2574
  return a.update({ id: t }, e, n, r);
2391
2575
  }, [a, t]);
2392
- return R(() => ({
2576
+ return z(() => ({
2393
2577
  run: o,
2394
2578
  status: o?.status,
2395
2579
  steps: s,
2396
2580
  events: c,
2397
- currentStep: Fr(s),
2398
- waitingFor: o?.status === "suspended" ? Pr(c) : void 0,
2399
- error: Ir(o, s),
2581
+ currentStep: _i(s),
2582
+ waitingFor: o?.status === "suspended" ? gi(c) : void 0,
2583
+ error: vi(o, s),
2400
2584
  traceId: o?.traceId,
2401
2585
  loading: n.data === void 0,
2402
2586
  cancel: l,
@@ -2413,89 +2597,89 @@ var fr = () => {
2413
2597
  d,
2414
2598
  f
2415
2599
  ]);
2416
- }, Rr = (e, t) => {
2417
- let { runtime: n, client: r } = W(e), [i, a] = B([]), [o, s] = B("idle"), [c, l] = B(void 0), u = z(null), d = F(() => {
2418
- let e = u.current;
2419
- e && (u.current = null, n.runFork(Oe.interrupt(e)), s((e) => e === "streaming" ? "idle" : e));
2600
+ }, bi = (e, t) => {
2601
+ let { runtime: n, client: r } = K(e), [i, a] = V([]), [s, c] = V("idle"), [l, u] = V(void 0), d = B(null), f = L(() => {
2602
+ let e = d.current;
2603
+ e && (d.current = null, n.runFork(Ae.interrupt(e)), c((e) => e === "streaming" ? "idle" : e));
2420
2604
  }, [n]);
2421
2605
  return {
2422
2606
  events: i,
2423
- status: o,
2424
- error: c,
2425
- start: F((e = {}) => {
2426
- let i = u.current;
2427
- i && n.runFork(Oe.interrupt(i)), a([]), l(void 0), s("streaming");
2428
- let o = h(r, t)(e), c = H.runForEach(o, (e) => V.sync(() => a((t) => [...t, e]))).pipe(V.matchCause({
2607
+ status: s,
2608
+ error: l,
2609
+ start: L((e = {}) => {
2610
+ let i = d.current;
2611
+ i && n.runFork(Ae.interrupt(i)), a([]), u(void 0), c("streaming");
2612
+ let s = T(r, t)(e), l = W.runForEach(s, (e) => U.sync(() => a((t) => [...t, e]))).pipe(U.matchCause({
2429
2613
  onSuccess: () => {
2430
- s("done");
2614
+ c("done");
2431
2615
  },
2432
2616
  onFailure: (e) => {
2433
- Te.isInterruptedOnly(e) || (l(g(e)), s("error"));
2617
+ De.isInterruptedOnly(e) || (u(o(e)), c("error"));
2434
2618
  }
2435
2619
  }));
2436
- u.current = n.runFork(c);
2620
+ d.current = n.runFork(l);
2437
2621
  }, [
2438
2622
  n,
2439
2623
  r,
2440
2624
  t
2441
2625
  ]),
2442
- cancel: d
2626
+ cancel: f
2443
2627
  };
2444
- }, zr = (e, t, n, r) => {
2445
- let i = 0, a = !1, o = (e) => V.sync(() => {
2628
+ }, xi = (e, t, n, r) => {
2629
+ let i = 0, a = !1, s = (e) => U.sync(() => {
2446
2630
  e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
2447
- }), s = (e) => {
2631
+ }), c = (e) => {
2448
2632
  if (typeof e != "object" || !e) return;
2449
2633
  let t = e.name, n = e.message;
2450
2634
  if (typeof t == "string" || typeof n == "string") return `${typeof t == "string" ? t : ""}::${typeof n == "string" ? n : ""}`;
2451
- }, c, l = (e, t, a) => {
2452
- let o = i > t, l = o ? 0 : e + 1, d = a === void 0 ? void 0 : s(a), f = d !== void 0 && d === c && !o;
2453
- if (c = o ? void 0 : d, f || l > r.maxReconnects) return V.sync(() => {
2635
+ }, l, u = (e, t, a) => {
2636
+ let o = i > t, s = o ? 0 : e + 1, u = a === void 0 ? void 0 : c(a), f = u !== void 0 && u === l && !o;
2637
+ if (l = o ? void 0 : u, f || s > r.maxReconnects) return U.sync(() => {
2454
2638
  n.onError(a ?? /* @__PURE__ */ Error("stream connection lost")), n.onStatus("error");
2455
2639
  });
2456
- let p = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, l - 1));
2457
- return V.sync(() => {
2640
+ let p = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, s - 1));
2641
+ return U.sync(() => {
2458
2642
  n.onStatus("reconnecting"), n.onReconnect();
2459
- }).pipe(V.zipRight(V.sleep(Ee.millis(p))), V.zipRight(V.sync(() => n.onStatus("streaming"))), V.zipRight(u(l)));
2460
- }, u = (r) => V.suspend(() => {
2461
- let s = i, c = e({
2643
+ }).pipe(U.zipRight(U.sleep(Oe.millis(p))), U.zipRight(U.sync(() => n.onStatus("streaming"))), U.zipRight(d(s)));
2644
+ }, d = (r) => U.suspend(() => {
2645
+ let c = i, l = e({
2462
2646
  ...t,
2463
- fromSeq: s
2647
+ fromSeq: c
2464
2648
  });
2465
- return H.runForEach(c, o).pipe(V.matchCauseEffect({
2466
- onSuccess: () => a ? V.sync(() => n.onStatus("done")) : l(r, s, void 0),
2467
- onFailure: (e) => Te.isInterruptedOnly(e) ? V.void : a ? V.sync(() => n.onStatus("done")) : l(r, s, g(e))
2649
+ return W.runForEach(l, s).pipe(U.matchCauseEffect({
2650
+ onSuccess: () => a ? U.sync(() => n.onStatus("done")) : u(r, c, void 0),
2651
+ onFailure: (e) => De.isInterruptedOnly(e) ? U.void : a ? U.sync(() => n.onStatus("done")) : u(r, c, o(e))
2468
2652
  }));
2469
2653
  });
2470
- return u(0);
2471
- }, Br = (e) => {
2654
+ return d(0);
2655
+ }, Si = (e) => {
2472
2656
  let t = e?._tag;
2473
2657
  return t === "done" || t === "error";
2474
- }, Vr = (e, t, n = {}) => {
2475
- let { runtime: r, client: i } = W(e), [a, o] = B([]), [s, c] = B("idle"), [l, u] = B(0), [d, f] = B(void 0), p = z(null), m = {
2658
+ }, Ci = (e, t, n = {}) => {
2659
+ let { runtime: r, client: i } = K(e), [a, o] = V([]), [s, c] = V("idle"), [l, u] = V(0), [d, f] = V(void 0), p = B(null), m = {
2476
2660
  maxReconnects: n.maxReconnects ?? 6,
2477
2661
  backoffMs: n.backoffMs ?? 400,
2478
2662
  maxBackoffMs: n.maxBackoffMs ?? 8e3,
2479
- isTerminal: n.isTerminal ?? Br
2480
- }, g = F(() => {
2663
+ isTerminal: n.isTerminal ?? Si
2664
+ }, h = L(() => {
2481
2665
  let e = p.current;
2482
- e && (p.current = null, r.runFork(Oe.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
2666
+ e && (p.current = null, r.runFork(Ae.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
2483
2667
  }, [r]);
2484
2668
  return {
2485
2669
  events: a,
2486
2670
  status: s,
2487
2671
  reconnects: l,
2488
2672
  error: d,
2489
- start: F((e = {}) => {
2673
+ start: L((e = {}) => {
2490
2674
  let n = p.current;
2491
- n && r.runFork(Oe.interrupt(n)), o([]), f(void 0), u(0), c("streaming");
2492
- let a = h(i, t), s = {
2675
+ n && r.runFork(Ae.interrupt(n)), o([]), f(void 0), u(0), c("streaming");
2676
+ let a = T(i, t), s = {
2493
2677
  onEvent: (e) => o((t) => [...t, e]),
2494
2678
  onStatus: c,
2495
2679
  onReconnect: () => u((e) => e + 1),
2496
2680
  onError: f
2497
2681
  };
2498
- p.current = r.runFork(zr(a, e, s, m));
2682
+ p.current = r.runFork(xi(a, e, s, m));
2499
2683
  }, [
2500
2684
  r,
2501
2685
  i,
@@ -2505,15 +2689,15 @@ var fr = () => {
2505
2689
  m.maxBackoffMs,
2506
2690
  m.isTerminal
2507
2691
  ]),
2508
- cancel: g
2692
+ cancel: h
2509
2693
  };
2510
- }, Hr = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Ur = (e) => {
2694
+ }, wi = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Ti = (e) => {
2511
2695
  for (let t = e.length - 1; t >= 0; --t) {
2512
2696
  let n = e[t];
2513
2697
  if (n.role === "user" && n.content) return n.content;
2514
2698
  }
2515
- }, Wr = (e, t, n) => {
2516
- let { threadId: r } = n, i = G(e, `${t}.messages`, { threadId: r }), a = On(e, `${t}.send`), o = R(() => [...i.data ?? []].sort(Hr), [i.data]), s = F((e, t = {}) => a.run({
2699
+ }, Ei = (e, t, n) => {
2700
+ let { threadId: r } = n, i = q(e, `${t}.messages`, { threadId: r }), a = ur(e, `${t}.send`), o = z(() => [...i.data ?? []].sort(wi), [i.data]), s = L((e, t = {}) => a.run({
2517
2701
  threadId: r,
2518
2702
  order: i.data?.length ?? 0,
2519
2703
  prompt: e,
@@ -2522,11 +2706,11 @@ var fr = () => {
2522
2706
  a,
2523
2707
  r,
2524
2708
  i.data
2525
- ]), c = F(() => {
2526
- let e = Ur(o);
2709
+ ]), c = L(() => {
2710
+ let e = Ti(o);
2527
2711
  return e === void 0 ? void 0 : s(e);
2528
2712
  }, [o, s]);
2529
- return R(() => ({
2713
+ return z(() => ({
2530
2714
  messages: o,
2531
2715
  streaming: o.some((e) => e.streaming),
2532
2716
  loading: i.data === void 0,
@@ -2543,9 +2727,9 @@ var fr = () => {
2543
2727
  s,
2544
2728
  c
2545
2729
  ]);
2546
- }, Gr = (e, t) => {
2547
- let { events: n, status: r, error: i, start: a, cancel: o } = Rr(e, t), [s, c] = B([]), l = z(null), u = R(() => n.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [n]);
2548
- return L(() => {
2730
+ }, Di = (e, t) => {
2731
+ let { events: n, status: r, error: i, start: a, cancel: o } = bi(e, t), [s, c] = V([]), l = B(null), u = z(() => n.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [n]);
2732
+ return R(() => {
2549
2733
  if (r !== "done" || l.current === null) return;
2550
2734
  let e = l.current;
2551
2735
  l.current = null, c((t) => [
@@ -2564,18 +2748,18 @@ var fr = () => {
2564
2748
  history: s,
2565
2749
  status: r,
2566
2750
  error: i,
2567
- send: F((e = {}) => {
2751
+ send: L((e = {}) => {
2568
2752
  let t = e.message;
2569
2753
  l.current = typeof t == "string" ? t : "", a(e);
2570
2754
  }, [a]),
2571
2755
  cancel: o
2572
2756
  };
2573
- }, Kr = (e, t) => {
2574
- let n = On(e, t), [r, i] = B(void 0), a = F(async (e) => {
2757
+ }, Oi = (e, t) => {
2758
+ let n = ur(e, t), [r, i] = V(void 0), a = L(async (e) => {
2575
2759
  let t = await n.run({ question: e });
2576
2760
  return i(t), t;
2577
- }, [n]), o = F(() => i(void 0), []);
2578
- return R(() => ({
2761
+ }, [n]), o = L(() => i(void 0), []);
2762
+ return z(() => ({
2579
2763
  ask: a,
2580
2764
  answer: r,
2581
2765
  pending: n.pending,
@@ -2588,35 +2772,35 @@ var fr = () => {
2588
2772
  n.error,
2589
2773
  o
2590
2774
  ]);
2591
- }, qr = (e) => {
2592
- let { cache: t, runtime: n } = W(e);
2593
- return F(() => {
2775
+ }, ki = (e) => {
2776
+ let { cache: t, runtime: n } = K(e);
2777
+ return L(() => {
2594
2778
  t.refreshAll(n);
2595
2779
  }, [t, n]);
2596
- }, Jr = (e, t, n) => {
2597
- let { cache: r } = W(e), i = O([t, n]), a = z([t, n]);
2598
- return a.current = [t, n], R(() => {
2780
+ }, Ai = (e, t, n) => {
2781
+ let { cache: r } = K(e), i = j([t, n]), a = B([t, n]);
2782
+ return a.current = [t, n], z(() => {
2599
2783
  let e = a.current;
2600
2784
  return () => r.refresh(e);
2601
2785
  }, [r, i]);
2602
- }, Yr = async (e, t, n, r, i) => {
2603
- let { runtime: a, client: o } = await K(e, t, n), s = h(o, n)(r ?? {}), c = V.isEffect(s) ? s : H.runHead(s).pipe(V.map(ke.getOrUndefined)), l = await C(a, c, { signal: i });
2604
- return Fe(n, l, "[loader.query]");
2605
- }, Xr = (e, t) => {
2606
- let n = W(e), r = n.recovery ?? d(n.errorBus, e), i = z(t);
2607
- i.current = t, L(() => r.onVisibleError((e) => i.current(e)), [r]);
2608
- }, Zr = (e, t) => {
2609
- let { errorBus: n } = W(e), r = z(t);
2610
- r.current = t, L(() => n.on((e) => r.current(e)), [n]);
2611
- }, Qr = {
2786
+ }, ji = async (e, t, n, r, i) => {
2787
+ let { runtime: a, client: o } = await J(e, t, n), s = T(o, n)(r ?? {}), c = U.isEffect(s) ? s : W.runHead(s).pipe(U.map(je.getOrUndefined)), l = await f(a, c, { signal: i });
2788
+ return He(n, l, "[loader.query]");
2789
+ }, Mi = (e, t) => {
2790
+ let n = K(e), r = n.recovery ?? E(n.errorBus, e), i = B(t);
2791
+ i.current = t, R(() => r.onVisibleError((e) => i.current(e)), [r]);
2792
+ }, Ni = (e, t) => {
2793
+ let { errorBus: n } = K(e), r = B(t);
2794
+ r.current = t, R(() => n.on((e) => r.current(e)), [n]);
2795
+ }, Pi = {
2612
2796
  failed: [],
2613
2797
  healthy: !0
2614
- }, $r = (e) => {
2615
- let { errorBus: t } = W(e), [n, r] = B(Qr);
2616
- return L(() => {
2798
+ }, Fi = (e) => {
2799
+ let { errorBus: t } = K(e), [n, r] = V(Pi);
2800
+ return R(() => {
2617
2801
  let e = /* @__PURE__ */ new Map(), n = () => {
2618
2802
  let t = [...e.values()].sort((e, t) => t.at - e.at);
2619
- r(t.length === 0 ? Qr : {
2803
+ r(t.length === 0 ? Pi : {
2620
2804
  failed: t,
2621
2805
  healthy: !1
2622
2806
  });
@@ -2634,20 +2818,20 @@ var fr = () => {
2634
2818
  i(), a();
2635
2819
  };
2636
2820
  }, [t]), n;
2637
- }, ei = (e, t) => {
2821
+ }, Ii = (e, t) => {
2638
2822
  let n = globalThis, r = Symbol.for(`@voltro/web/context:${e}`), i = n[r];
2639
2823
  if (i) return i;
2640
- let a = P(t);
2824
+ let a = I(t);
2641
2825
  return n[r] = a, a;
2642
- }, ti = ei("serverRequest", null), ni = () => I(ti), ri = ({ value: e, children: t }) => /* @__PURE__ */ Le(ti.Provider, {
2826
+ }, Li = Ii("serverRequest", null), Ri = () => we(Li), zi = ({ value: e, children: t }) => /* @__PURE__ */ qe(Li.Provider, {
2643
2827
  value: e,
2644
2828
  children: t
2645
- }), ii = (e) => {
2646
- let t = ni();
2647
- return R(() => {
2829
+ }), Bi = (e) => {
2830
+ let t = Ri();
2831
+ return z(() => {
2648
2832
  if (t !== null) return t.formFlash?.formKey === e ? t.formFlash : void 0;
2649
2833
  if (typeof document > "u") return;
2650
- let n = document.getElementById(he);
2834
+ let n = document.getElementById(_e);
2651
2835
  if (n !== null && n.textContent !== null && n.textContent !== "") try {
2652
2836
  let t = JSON.parse(n.textContent);
2653
2837
  return t.formKey === e ? t : void 0;
@@ -2655,15 +2839,15 @@ var fr = () => {
2655
2839
  return;
2656
2840
  }
2657
2841
  }, [t, e]);
2658
- }, ai = (e, t, n) => e.map((e) => {
2842
+ }, Vi = (e, t, n) => e.map((e) => {
2659
2843
  let r = String(e[n] ?? ""), i = e[t];
2660
2844
  return {
2661
2845
  value: r,
2662
2846
  label: i == null ? r : String(i)
2663
2847
  };
2664
- }), oi = (e, t, n = {}) => {
2665
- let r = n.debounceMs ?? 200, i = n.labelField ?? "name", a = n.valueField ?? "id", o = n.input ?? ((e) => ({ q: e })), [s, c] = B(n.initialTerm ?? ""), [l, u] = B(s);
2666
- L(() => {
2848
+ }), Hi = (e, t, n = {}) => {
2849
+ let r = n.debounceMs ?? 200, i = n.labelField ?? "name", a = n.valueField ?? "id", o = n.input ?? ((e) => ({ q: e })), [s, c] = V(n.initialTerm ?? ""), [l, u] = V(s);
2850
+ R(() => {
2667
2851
  if (s === l) return;
2668
2852
  let e = setTimeout(() => u(s), r);
2669
2853
  return () => clearTimeout(e);
@@ -2672,24 +2856,24 @@ var fr = () => {
2672
2856
  l,
2673
2857
  r
2674
2858
  ]);
2675
- let d = n.skipUntilTerm === !0 && l.trim() === "", f = G(e, t, R(() => o(l), [o, l]), { skip: d }), p = R(() => ai(f.data ?? [], i, a), [
2859
+ let d = n.skipUntilTerm === !0 && l.trim() === "", f = q(e, t, z(() => o(l), [o, l]), { skip: d }), p = z(() => Vi(f.data ?? [], i, a), [
2676
2860
  f.data,
2677
2861
  i,
2678
2862
  a
2679
- ]), m = F((e) => c(e), []);
2863
+ ]), m = L((e) => c(e), []);
2680
2864
  return {
2681
2865
  options: p,
2682
2866
  loading: !d && f.data === void 0,
2683
2867
  term: s,
2684
2868
  search: m
2685
2869
  };
2686
- }, si = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, ci = (e, t, n = {}) => {
2687
- let r = W(e), [i, a] = B(n.pageSize), o = G(e, t, R(() => i === void 0 ? n.input ?? {} : {
2870
+ }, Ui = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Wi = (e, t, n = {}) => {
2871
+ let r = K(e), [i, a] = V(n.pageSize), o = q(e, t, z(() => i === void 0 ? n.input ?? {} : {
2688
2872
  ...n.input,
2689
2873
  limit: i
2690
- }, [n.input, i])), s = r.descriptors[t]?.output, c = F(() => {
2874
+ }, [n.input, i])), s = r.descriptors[t]?.output, c = L(() => {
2691
2875
  n.pageSize !== void 0 && a((e) => (e ?? n.pageSize) + n.pageSize);
2692
- }, [n.pageSize]), l = R(() => n.columns ?? (s === void 0 ? [] : k(s)), [n.columns, s]), [u, d] = B(n.initialSort), f = F((e) => {
2876
+ }, [n.pageSize]), l = z(() => n.columns ?? (s === void 0 ? [] : N(s)), [n.columns, s]), [u, d] = V(n.initialSort), f = L((e) => {
2693
2877
  d((t) => t?.column === e ? {
2694
2878
  column: e,
2695
2879
  direction: t.direction === "asc" ? "desc" : "asc"
@@ -2700,11 +2884,11 @@ var fr = () => {
2700
2884
  }, []);
2701
2885
  return {
2702
2886
  columns: l,
2703
- rows: R(() => {
2887
+ rows: z(() => {
2704
2888
  let e = o.data ?? [];
2705
2889
  if (u === void 0) return e;
2706
2890
  let t = u.direction === "asc" ? 1 : -1;
2707
- return [...e].sort((e, n) => si(e[u.column], n[u.column]) * t);
2891
+ return [...e].sort((e, n) => Ui(e[u.column], n[u.column]) * t);
2708
2892
  }, [o.data, u]),
2709
2893
  loading: o.data === void 0,
2710
2894
  error: o.error,
@@ -2713,26 +2897,26 @@ var fr = () => {
2713
2897
  loadMore: c,
2714
2898
  hasMore: i !== void 0 && (o.data?.length ?? 0) >= i
2715
2899
  };
2716
- }, li = (e, t, n, r) => {
2900
+ }, Gi = (e, t, n, r) => {
2717
2901
  let i = e.replace(/\/$/, ""), a = new URLSearchParams({
2718
2902
  table: t,
2719
2903
  id: n
2720
2904
  });
2721
2905
  return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
2722
- }, ui = li, di = (e, t, n, r) => {
2723
- let { inspectBaseUrl: i } = W(e), [a, o] = B({
2906
+ }, Ki = Gi, qi = (e, t, n, r) => {
2907
+ let { inspectBaseUrl: i } = K(e), [a, o] = V({
2724
2908
  data: void 0,
2725
2909
  loading: !0,
2726
2910
  error: void 0
2727
2911
  });
2728
- return L(() => {
2912
+ return R(() => {
2729
2913
  let e = !1;
2730
2914
  o({
2731
2915
  data: void 0,
2732
2916
  loading: !0,
2733
2917
  error: void 0
2734
2918
  });
2735
- let a = li(i ?? "", t, n, r);
2919
+ let a = Gi(i ?? "", t, n, r);
2736
2920
  return fetch(a).then(async (e) => {
2737
2921
  if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
2738
2922
  return await e.json();
@@ -2758,23 +2942,23 @@ var fr = () => {
2758
2942
  n,
2759
2943
  r
2760
2944
  ]), a;
2761
- }, fi = "admin:full", pi = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), mi = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), hi = P({ scopes: [] });
2762
- function gi(e) {
2763
- return xe(hi.Provider, { value: { scopes: e.scopes } }, e.children);
2945
+ }, Ji = "admin:full", Yi = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), Xi = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), Zi = I({ scopes: [] });
2946
+ function Qi(e) {
2947
+ return Ce(Zi.Provider, { value: { scopes: e.scopes } }, e.children);
2764
2948
  }
2765
- var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes, e), bi = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, xi = (e) => {
2766
- let { inspectBaseUrl: t } = W(e), [n, r] = B({
2949
+ var $i = () => we(Zi), ea = (e) => Yi($i().scopes, e), ta = (e) => Xi($i().scopes, e), na = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, ra = (e) => {
2950
+ let { inspectBaseUrl: t } = K(e), [n, r] = V({
2767
2951
  manifest: void 0,
2768
2952
  loading: !0,
2769
2953
  error: void 0
2770
2954
  });
2771
- return L(() => {
2955
+ return R(() => {
2772
2956
  let e = !1;
2773
2957
  return r({
2774
2958
  manifest: void 0,
2775
2959
  loading: !0,
2776
2960
  error: void 0
2777
- }), fetch(bi(t ?? "")).then(async (e) => {
2961
+ }), fetch(na(t ?? "")).then(async (e) => {
2778
2962
  if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
2779
2963
  return await e.json();
2780
2964
  }).then((t) => {
@@ -2793,7 +2977,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2793
2977
  e = !0;
2794
2978
  };
2795
2979
  }, [e, t]), n;
2796
- }, Si = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), Ci = (e, t) => {
2980
+ }, ia = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), aa = (e, t) => {
2797
2981
  if (e === void 0) return "unknown";
2798
2982
  if (t.includes("admin:full") || e.length === 0) return "allowed";
2799
2983
  let n = !1;
@@ -2802,7 +2986,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2802
2986
  n = !0;
2803
2987
  continue;
2804
2988
  }
2805
- if (!Si(t, r)) {
2989
+ if (!ia(t, r)) {
2806
2990
  if (r.resourceScoped) {
2807
2991
  n = !0;
2808
2992
  continue;
@@ -2811,13 +2995,13 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2811
2995
  }
2812
2996
  }
2813
2997
  return n ? "unknown" : "allowed";
2814
- }, wi = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), Ti = (e) => {
2998
+ }, oa = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), sa = (e) => {
2815
2999
  for (let t of e ?? []) if (t.kind === "open") return t.reason;
2816
- }, Ei = (e) => Ci(e, _i().scopes), Di = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, Oi = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, ki = (e) => e === void 0 ? {} : {
3000
+ }, ca = (e) => aa(e, $i().scopes), la = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, ua = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, da = (e) => e === void 0 ? {} : {
2817
3001
  tag: e.tag,
2818
3002
  ...e.guards === void 0 ? {} : { guards: e.guards }
2819
- }, Ai = (e) => e.tables.filter((e) => !e.framework).map((t) => {
2820
- let n = e.procedures.find((e) => e.kind === "query" && Di(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && Oi(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && Oi(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && Oi(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
3003
+ }, fa = (e) => e.tables.filter((e) => !e.framework).map((t) => {
3004
+ let n = e.procedures.find((e) => e.kind === "query" && la(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && ua(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && ua(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && ua(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
2821
3005
  return {
2822
3006
  table: t.name,
2823
3007
  columns: t.columns.filter((e) => e.serverOnly !== !0),
@@ -2826,22 +3010,22 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2826
3010
  reactive: t.reactive,
2827
3011
  ...o === void 0 ? {} : { pkColumn: o },
2828
3012
  editable: (t.editable ?? !0) && o !== void 0,
2829
- list: ki(n),
2830
- create: ki(r),
2831
- update: ki(i),
2832
- delete: ki(a)
3013
+ list: da(n),
3014
+ create: da(r),
3015
+ update: da(i),
3016
+ delete: da(a)
2833
3017
  };
2834
- }), ji = (e) => {
2835
- let [t, n] = B([]), [r, i] = B([]), a = F((e) => {
3018
+ }), pa = (e) => {
3019
+ let [t, n] = V([]), [r, i] = V([]), a = L((e) => {
2836
3020
  n((t) => [...t, e]), i([]);
2837
- }, []), o = F(async () => {
3021
+ }, []), o = L(async () => {
2838
3022
  let r = t[t.length - 1];
2839
3023
  r !== void 0 && r.blockedBy === void 0 && (await e.onUndo(r.invocationId), n((e) => e.slice(0, -1)), i((e) => [...e, r]));
2840
- }, [t, e]), s = F(async () => {
3024
+ }, [t, e]), s = L(async () => {
2841
3025
  let t = r[r.length - 1];
2842
3026
  t !== void 0 && (await e.onRedo(t.invocationId), i((e) => e.slice(0, -1)), n((e) => [...e, t]));
2843
3027
  }, [r, e]);
2844
- return R(() => {
3028
+ return z(() => {
2845
3029
  let e = t[t.length - 1];
2846
3030
  return {
2847
3031
  record: a,
@@ -2859,14 +3043,14 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2859
3043
  o,
2860
3044
  s
2861
3045
  ]);
2862
- }, Mi = "__voltro.undo.log", Ni = "__voltro.undo.apply", Pi = "__voltro.undo.redo", Fi = (e, t) => {
2863
- let n = t?.limit, { data: r } = G(e, Mi, n === void 0 ? {} : { limit: n }), i = X(e, Ni), a = X(e, Pi), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = F(async (e) => {
3046
+ }, ma = "__voltro.undo.log", ha = "__voltro.undo.apply", ga = "__voltro.undo.redo", _a = (e, t) => {
3047
+ let n = t?.limit, { data: r } = q(e, ma, n === void 0 ? {} : { limit: n }), i = ar(e, ha), a = ar(e, ga), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = L(async (e) => {
2864
3048
  await i.mutate({ invocationId: e });
2865
- }, [i]), u = F(async (e) => {
3049
+ }, [i]), u = L(async (e) => {
2866
3050
  await a.mutate({ invocationId: e });
2867
- }, [a]), d = F(async () => {
3051
+ }, [a]), d = L(async () => {
2868
3052
  s && await l(s.id);
2869
- }, [s, l]), f = F(async () => {
3053
+ }, [s, l]), f = L(async () => {
2870
3054
  c && await u(c.id);
2871
3055
  }, [c, u]);
2872
3056
  return {
@@ -2879,22 +3063,22 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2879
3063
  undoLast: d,
2880
3064
  redoLast: f
2881
3065
  };
2882
- }, Ii = (e, t) => ({
3066
+ }, va = (e, t) => ({
2883
3067
  name: e,
2884
3068
  map: t
2885
- }), Li = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), Ri = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), zi = (e, t, n) => {
3069
+ }), ya = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), ba = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), xa = (e, t, n) => {
2886
3070
  let r = { ...t };
2887
3071
  for (let [i, a] of Object.entries(e.map)) {
2888
- if (Ri.has(i) || a === void 0) continue;
3072
+ if (ba.has(i) || a === void 0) continue;
2889
3073
  let e = t[i];
2890
3074
  r[i] = (...r) => {
2891
- let i = Li(a, t);
3075
+ let i = ya(a, t);
2892
3076
  if (i !== null && n(i), typeof e == "function") return e(...r);
2893
3077
  };
2894
3078
  }
2895
3079
  return r;
2896
- }, Bi = (e, t, n) => {
2897
- let r = z({
3080
+ }, Sa = (e, t, n) => {
3081
+ let r = B({
2898
3082
  spec: e,
2899
3083
  props: t,
2900
3084
  sink: n
@@ -2903,47 +3087,47 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2903
3087
  spec: e,
2904
3088
  props: t,
2905
3089
  sink: n
2906
- }, L(() => {
2907
- let e = r.current, t = Li(e.spec.map.onMount, e.props);
3090
+ }, R(() => {
3091
+ let e = r.current, t = ya(e.spec.map.onMount, e.props);
2908
3092
  return t !== null && e.sink(t), () => {
2909
- let e = r.current, t = Li(e.spec.map.onUnmount, e.props);
3093
+ let e = r.current, t = ya(e.spec.map.onUnmount, e.props);
2910
3094
  t !== null && e.sink(t);
2911
3095
  };
2912
- }, []), R(() => zi(e, t, n), [
3096
+ }, []), z(() => xa(e, t, n), [
2913
3097
  e,
2914
3098
  t,
2915
3099
  n
2916
3100
  ]);
2917
- }, Vi = (e, t) => {
2918
- let n = W(e).descriptors[t]?.input;
2919
- return R(() => n === void 0 ? [] : ve(n), [n]);
2920
- }, Hi = (e, t) => {
2921
- let n = W(e).descriptors[t]?.output;
2922
- return R(() => n === void 0 ? [] : k(n), [n]);
2923
- }, Ui = (e, t) => {
3101
+ }, Ca = (e, t) => {
3102
+ let n = K(e).descriptors[t]?.input;
3103
+ return z(() => n === void 0 ? [] : be(n), [n]);
3104
+ }, wa = (e, t) => {
3105
+ let n = K(e).descriptors[t]?.output;
3106
+ return z(() => n === void 0 ? [] : N(n), [n]);
3107
+ }, Ta = (e, t) => {
2924
3108
  if (e === t) return !0;
2925
3109
  if (e.length !== t.length) return !1;
2926
3110
  for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
2927
3111
  return !0;
2928
- }, Wi = (e) => Object.keys(e).sort().map((t) => e[t]), Gi = (e, t) => {
2929
- let n = z(null), r = Wi(e);
2930
- return (n.current === null || !Ui(n.current.key, r)) && (n.current = {
3112
+ }, Ea = (e) => Object.keys(e).sort().map((t) => e[t]), Da = (e, t) => {
3113
+ let n = B(null), r = Ea(e);
3114
+ return (n.current === null || !Ta(n.current.key, r)) && (n.current = {
2931
3115
  key: r,
2932
3116
  value: t(e)
2933
3117
  }), n.current.value;
2934
- }, Ki = (e, t, n, r = {}) => {
2935
- let i = G(e, t, { ...n }, r);
2936
- return R(() => ({
3118
+ }, Oa = (e, t, n, r = {}) => {
3119
+ let i = q(e, t, { ...n }, r);
3120
+ return z(() => ({
2937
3121
  allowed: i.data?.allowed === !0,
2938
3122
  pending: i.data === void 0
2939
3123
  }), [i.data]);
2940
- }, qi = (e, t, n, r = {}) => {
2941
- let i = G(e, t, { ...n }, r);
2942
- return R(() => ({
3124
+ }, ka = (e, t, n, r = {}) => {
3125
+ let i = q(e, t, { ...n }, r);
3126
+ return z(() => ({
2943
3127
  allowedIds: new Set(i.data?.allowedIds ?? []),
2944
3128
  pending: i.data === void 0
2945
3129
  }), [i.data]);
2946
- }, Ji = (e) => {
3130
+ }, Aa = (e) => {
2947
3131
  switch (e) {
2948
3132
  case "select":
2949
3133
  case "radio":
@@ -2959,26 +3143,26 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2959
3143
  case "switch": return "boolean";
2960
3144
  default: return null;
2961
3145
  }
2962
- }, Yi = (e) => ve(e).map((e) => {
3146
+ }, ja = (e) => be(e).map((e) => {
2963
3147
  if (e.name.includes(".")) return null;
2964
- let t = Ji(e.widget);
3148
+ let t = Aa(e.widget);
2965
3149
  return t === null ? null : {
2966
3150
  name: e.name,
2967
3151
  label: e.label,
2968
3152
  kind: t,
2969
3153
  ...e.options ? { options: e.options } : {}
2970
3154
  };
2971
- }).filter((e) => e !== null), Xi = (e) => {
3155
+ }).filter((e) => e !== null), Ma = (e) => {
2972
3156
  let t = {};
2973
3157
  for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
2974
3158
  return t;
2975
- }, Zi = (e, t, n = {}) => {
2976
- let r = W(e).descriptors[t]?.input, i = R(() => r === void 0 ? [] : Yi(r), [r]), [a, o] = B(n.initial ?? {}), s = F((e, t) => {
2977
- o((n) => Xi({
3159
+ }, Na = (e, t, n = {}) => {
3160
+ let r = K(e).descriptors[t]?.input, i = z(() => r === void 0 ? [] : ja(r), [r]), [a, o] = V(n.initial ?? {}), s = L((e, t) => {
3161
+ o((n) => Ma({
2978
3162
  ...n,
2979
3163
  [e]: t
2980
3164
  }));
2981
- }, []), c = F(() => o({}), []), l = G(e, t, R(() => Xi(a), [a]));
3165
+ }, []), c = L(() => o({}), []), l = q(e, t, z(() => Ma(a), [a]));
2982
3166
  return {
2983
3167
  filters: i,
2984
3168
  values: a,
@@ -2989,20 +3173,20 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
2989
3173
  loading: l.data === void 0,
2990
3174
  error: l.error
2991
3175
  };
2992
- }, Qi = (e, t, n = {}) => {
2993
- let r = G(e, t, n), i = r.data;
3176
+ }, Pa = (e, t, n = {}) => {
3177
+ let r = q(e, t, n), i = r.data;
2994
3178
  return {
2995
3179
  record: Array.isArray(i) ? i[0] : i,
2996
3180
  loading: i === void 0,
2997
3181
  error: r.error
2998
3182
  };
2999
- }, $i = (e, t = 300) => {
3000
- let [n, r] = B(e);
3001
- return L(() => {
3183
+ }, Fa = (e, t = 300) => {
3184
+ let [n, r] = V(e);
3185
+ return R(() => {
3002
3186
  let n = setTimeout(() => r(e), t);
3003
3187
  return () => clearTimeout(n);
3004
3188
  }, [e, t]), n;
3005
- }, ea = (e) => {
3189
+ }, Ia = (e) => {
3006
3190
  let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
3007
3191
  if (a && t.trim() === "") return {
3008
3192
  status: "idle",
@@ -3020,39 +3204,39 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3020
3204
  valid: o.valid,
3021
3205
  message: o.message
3022
3206
  };
3023
- }, ta = (e, t, n, r) => {
3024
- let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = $i(n, o), l = s && c.trim() === "", u = G(e, t, R(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
3025
- return ea({
3207
+ }, La = (e, t, n, r) => {
3208
+ let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = Fa(n, o), l = s && c.trim() === "", u = q(e, t, z(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
3209
+ return Ia({
3026
3210
  value: n,
3027
3211
  debouncedValue: c,
3028
3212
  data: l ? null : u.data,
3029
3213
  interpret: a,
3030
3214
  skipEmpty: s
3031
3215
  });
3032
- }, na = (e, t) => ({
3216
+ }, Ra = (e, t) => ({
3033
3217
  name: e,
3034
3218
  payload: t
3035
- }), ra = (e, t) => {
3036
- let n = je.decodeUnknownEither(e.payload, { errors: "all" })(t);
3219
+ }), za = (e, t) => {
3220
+ let n = Ne.decodeUnknownEither(e.payload, { errors: "all" })(t);
3037
3221
  if (n._tag === "Right") return {
3038
3222
  valid: !0,
3039
3223
  errors: {}
3040
3224
  };
3041
3225
  let r = {};
3042
- for (let e of Be.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
3226
+ for (let e of Xe.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
3043
3227
  return {
3044
3228
  valid: !1,
3045
3229
  errors: r
3046
3230
  };
3047
- }, ia = (e) => {
3231
+ }, Ba = (e) => {
3048
3232
  let t = new Map(e.map((e) => [e.name, e]));
3049
3233
  return {
3050
3234
  names: [...t.keys()].sort(),
3051
3235
  get: (e) => t.get(e),
3052
3236
  events: e
3053
3237
  };
3054
- }, aa = (e, t) => {
3055
- let n = ia(e);
3238
+ }, Va = (e, t) => {
3239
+ let n = Ba(e);
3056
3240
  return {
3057
3241
  track: (e, r) => {
3058
3242
  let i = n.get(e);
@@ -3061,7 +3245,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3061
3245
  return;
3062
3246
  }
3063
3247
  if (process.env.NODE_ENV !== "production") {
3064
- let t = ra(i, r);
3248
+ let t = za(i, r);
3065
3249
  t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
3066
3250
  }
3067
3251
  t({
@@ -3072,49 +3256,49 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3072
3256
  names: n.names,
3073
3257
  catalog: n
3074
3258
  };
3075
- }, oa = (e, t) => {
3076
- let n = On(e, t);
3259
+ }, Ha = (e, t) => {
3260
+ let n = ur(e, t);
3077
3261
  return {
3078
- preview: F((e) => n.run(e), [n]),
3262
+ preview: L((e) => n.run(e), [n]),
3079
3263
  diff: n.lastResult,
3080
3264
  pending: n.pending,
3081
3265
  error: n.error
3082
3266
  };
3083
- }, sa = (e, t, n, r) => [...e, {
3267
+ }, Ua = (e, t, n, r) => [...e, {
3084
3268
  id: t,
3085
3269
  tag: n,
3086
3270
  input: r,
3087
3271
  status: "pending",
3088
3272
  attempts: 0
3089
- }], ca = (e, t, n) => e.map((e) => e.id === t ? {
3273
+ }], Wa = (e, t, n) => e.map((e) => e.id === t ? {
3090
3274
  ...e,
3091
3275
  ...n
3092
- } : e), la = (e, t) => ca(e, t, { status: "sent" }), ua = (e, t, n) => e.map((e) => e.id === t ? {
3276
+ } : e), Ga = (e, t) => Wa(e, t, { status: "sent" }), Ka = (e, t, n) => e.map((e) => e.id === t ? {
3093
3277
  ...e,
3094
3278
  status: "failed",
3095
3279
  error: n,
3096
3280
  attempts: e.attempts + 1
3097
- } : e), da = (e, t, n) => ca(e, t, {
3281
+ } : e), qa = (e, t, n) => Wa(e, t, {
3098
3282
  status: "conflict",
3099
3283
  error: n
3100
- }), fa = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
3284
+ }), Ja = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
3101
3285
  ...e,
3102
3286
  input: n,
3103
3287
  status: "pending",
3104
3288
  error: void 0
3105
- } : e), pa = (e) => e.filter((e) => e.status !== "sent"), ma = (e) => {
3289
+ } : e), Ya = (e) => e.filter((e) => e.status !== "sent"), Xa = (e) => {
3106
3290
  let t = [];
3107
3291
  for (let n of e) {
3108
3292
  if (n.status === "conflict") break;
3109
3293
  (n.status === "pending" || n.status === "failed") && t.push(n);
3110
3294
  }
3111
3295
  return t;
3112
- }, ha = (e) => {
3296
+ }, Za = (e) => {
3113
3297
  let t = e;
3114
3298
  return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
3115
- }, ga = (e) => {
3116
- let [t, n] = B(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
3117
- return L(() => {
3299
+ }, Qa = (e) => {
3300
+ let [t, n] = V(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
3301
+ return R(() => {
3118
3302
  if (e !== void 0) {
3119
3303
  n(e);
3120
3304
  return;
@@ -3125,20 +3309,20 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3125
3309
  window.removeEventListener("online", t), window.removeEventListener("offline", r);
3126
3310
  };
3127
3311
  }, [e]), t;
3128
- }, _a = (e) => {
3129
- let { send: t, persistence: n, isConflict: r = ha, idFor: i } = e, [a, o] = B([]), [s, c] = B(0), l = ga(e.online), u = z([]), d = F((e) => {
3312
+ }, $a = (e) => {
3313
+ let { send: t, persistence: n, isConflict: r = Za, idFor: i } = e, [a, o] = V([]), [s, c] = V(0), l = Qa(e.online), u = B([]), d = L((e) => {
3130
3314
  let t = e(u.current);
3131
3315
  u.current = t, o(t);
3132
- }, []), f = z(t);
3316
+ }, []), f = B(t);
3133
3317
  f.current = t;
3134
- let p = z(r);
3318
+ let p = B(r);
3135
3319
  p.current = r;
3136
- let m = z(void 0), h = z(!1), g = z(!0);
3137
- L(() => (g.current = !0, () => {
3320
+ let m = B(void 0), h = B(!1), g = B(!0);
3321
+ R(() => (g.current = !0, () => {
3138
3322
  g.current = !1;
3139
3323
  }), []);
3140
- let _ = z(0), v = z(Math.random().toString(36).slice(2, 8)), y = z(n === void 0);
3141
- L(() => {
3324
+ let _ = B(0), v = B(Math.random().toString(36).slice(2, 8)), y = B(n === void 0);
3325
+ R(() => {
3142
3326
  if (n === void 0 || y.current) return;
3143
3327
  let e = !1;
3144
3328
  return n.load().then((t) => {
@@ -3148,30 +3332,30 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3148
3332
  }), () => {
3149
3333
  e = !0;
3150
3334
  };
3151
- }, [n, d]), L(() => {
3152
- n !== void 0 && y.current && n.save(pa(a)).catch(() => {});
3335
+ }, [n, d]), R(() => {
3336
+ n !== void 0 && y.current && n.save(Ya(a)).catch(() => {});
3153
3337
  }, [
3154
3338
  n,
3155
3339
  a,
3156
3340
  s
3157
3341
  ]);
3158
- let b = F((e, t) => {
3342
+ let b = L((e, t) => {
3159
3343
  let n = i?.() ?? `obx_${v.current}_${_.current++}_${e}`;
3160
- d((r) => sa(r, n, e, t)), c((e) => e + 1);
3161
- }, [i, d]), x = F(() => {
3344
+ d((r) => Ua(r, n, e, t)), c((e) => e + 1);
3345
+ }, [i, d]), x = L(() => {
3162
3346
  if (!y.current || !g.current) return Promise.resolve();
3163
3347
  if (m.current !== void 0) return m.current;
3164
3348
  h.current = !1;
3165
3349
  let e = Promise.resolve().then(async () => {
3166
3350
  for (; g.current;) {
3167
- let e = ma(u.current)[0];
3351
+ let e = Xa(u.current)[0];
3168
3352
  if (e === void 0) break;
3169
3353
  try {
3170
3354
  if (await f.current(e), !g.current) break;
3171
- d((t) => la(t, e.id));
3355
+ d((t) => Ga(t, e.id));
3172
3356
  } catch (t) {
3173
3357
  if (!g.current) break;
3174
- d((n) => p.current(t) ? da(n, e.id, t) : ua(n, e.id, t)), h.current = !0;
3358
+ d((n) => p.current(t) ? qa(n, e.id, t) : Ka(n, e.id, t)), h.current = !0;
3175
3359
  break;
3176
3360
  }
3177
3361
  }
@@ -3180,17 +3364,17 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3180
3364
  });
3181
3365
  return m.current = e, e;
3182
3366
  }, [d]);
3183
- L(() => {
3367
+ R(() => {
3184
3368
  l && x();
3185
- }, [l, x]), L(() => {
3369
+ }, [l, x]), R(() => {
3186
3370
  l && !h.current && x();
3187
3371
  }, [
3188
3372
  s,
3189
3373
  l,
3190
3374
  x
3191
3375
  ]);
3192
- let S = F((e, t) => {
3193
- d((n) => fa(n, e, t)), l && x();
3376
+ let S = L((e, t) => {
3377
+ d((n) => Ja(n, e, t)), l && x();
3194
3378
  }, [
3195
3379
  l,
3196
3380
  x,
@@ -3205,7 +3389,110 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3205
3389
  conflicts: a.filter((e) => e.status === "conflict"),
3206
3390
  resolveConflict: S
3207
3391
  };
3208
- }, va = (e) => {
3392
+ }, eo = (e) => {
3393
+ let t = e;
3394
+ return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
3395
+ }, to = (e) => {
3396
+ let t = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "object" && !!e);
3397
+ for (let e of t) {
3398
+ if (e._tag === "Chunk") {
3399
+ for (let t of e.values ?? []) if (t._tag === "error") return {
3400
+ ok: !1,
3401
+ error: t.error
3402
+ };
3403
+ }
3404
+ if (e._tag === "Exit" && e.exit?._tag === "Failure") return {
3405
+ ok: !1,
3406
+ error: e.exit.cause
3407
+ };
3408
+ }
3409
+ return { ok: !0 };
3410
+ }, no = async (e) => {
3411
+ let t = e.fetch ?? ((e, t) => fetch(e, t)), n = e.isConflict ?? eo, r = e.queue, i = 0, a = 0, o = 0;
3412
+ for (let s of Xa(e.queue)) {
3413
+ let c;
3414
+ try {
3415
+ let n = await t(e.url, {
3416
+ method: "POST",
3417
+ headers: {
3418
+ "content-type": "application/json",
3419
+ ...e.headers
3420
+ },
3421
+ body: JSON.stringify({
3422
+ _tag: "Request",
3423
+ id: s.id,
3424
+ tag: s.tag,
3425
+ payload: s.input,
3426
+ headers: []
3427
+ })
3428
+ });
3429
+ c = n.ok ? to(await n.json().catch(() => null)) : {
3430
+ ok: !1,
3431
+ error: { status: n.status }
3432
+ };
3433
+ } catch (e) {
3434
+ c = {
3435
+ ok: !1,
3436
+ error: e
3437
+ };
3438
+ }
3439
+ if (c.ok) {
3440
+ r = Ga(r, s.id), i++;
3441
+ continue;
3442
+ }
3443
+ if (n(c.error)) {
3444
+ r = qa(r, s.id, c.error), o++;
3445
+ continue;
3446
+ }
3447
+ r = Ka(r, s.id, c.error), a++;
3448
+ break;
3449
+ }
3450
+ return {
3451
+ queue: r,
3452
+ sent: i,
3453
+ failed: a,
3454
+ conflicts: o
3455
+ };
3456
+ }, ro = "voltro-outbox", io = "outbox", ao = "queue", oo = (e, t) => new Promise((n, r) => {
3457
+ let i = e.open(t, 1);
3458
+ i.onupgradeneeded = () => {
3459
+ i.result.objectStoreNames.contains(io) || i.result.createObjectStore(io);
3460
+ }, i.onsuccess = () => n(i.result), i.onerror = () => r(i.error ?? /* @__PURE__ */ Error("indexedDB open failed"));
3461
+ }), so = (e) => new Promise((t, n) => {
3462
+ e.onsuccess = () => t(e.result), e.onerror = () => n(e.error ?? /* @__PURE__ */ Error("indexedDB request failed"));
3463
+ }), co = (e = {}) => {
3464
+ let t = e.name ?? "voltro-outbox", n = () => {
3465
+ let t = e.indexedDB ?? globalThis.indexedDB;
3466
+ if (t === void 0) throw Error("indexedDbOutboxPersistence: no indexedDB in this environment");
3467
+ return t;
3468
+ };
3469
+ return {
3470
+ load: async () => {
3471
+ let e = await oo(n(), t);
3472
+ try {
3473
+ let t = await so(e.transaction(io, "readonly").objectStore(io).get(ao));
3474
+ return Array.isArray(t) ? t : [];
3475
+ } finally {
3476
+ e.close();
3477
+ }
3478
+ },
3479
+ save: async (e) => {
3480
+ let r = await oo(n(), t);
3481
+ try {
3482
+ await so(r.transaction(io, "readwrite").objectStore(io).put(e, ao));
3483
+ } finally {
3484
+ r.close();
3485
+ }
3486
+ }
3487
+ };
3488
+ }, lo = "voltro:outbox", uo = async (e) => {
3489
+ let t = e.persistence ?? co(), n = await t.load(), r = await no({
3490
+ url: e.url,
3491
+ queue: n,
3492
+ ...e.headers ? { headers: e.headers } : {}
3493
+ });
3494
+ return r.sent + r.failed + r.conflicts > 0 && await t.save(r.queue), r;
3495
+ }, fo = (e) => {
3209
3496
  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);
3210
3497
  return {
3211
3498
  startIndex: l,
@@ -3215,8 +3502,8 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3215
3502
  topSpacer: l * r,
3216
3503
  bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
3217
3504
  };
3218
- }, ya = (e, t, n) => {
3219
- let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = B(0), u = R(() => va({
3505
+ }, po = (e, t, n) => {
3506
+ let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = V(0), u = z(() => fo({
3220
3507
  scrollTop: c,
3221
3508
  viewportHeight: i,
3222
3509
  rowHeight: r,
@@ -3228,7 +3515,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3228
3515
  r,
3229
3516
  a,
3230
3517
  o
3231
- ]), d = G(e, t, R(() => ({
3518
+ ]), d = q(e, t, z(() => ({
3232
3519
  ...s,
3233
3520
  offset: u.offset,
3234
3521
  limit: u.limit
@@ -3236,7 +3523,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3236
3523
  s,
3237
3524
  u.offset,
3238
3525
  u.limit
3239
- ])), f = F((e) => {
3526
+ ])), f = L((e) => {
3240
3527
  l(e.currentTarget.scrollTop);
3241
3528
  }, []);
3242
3529
  return {
@@ -3248,37 +3535,37 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3248
3535
  loading: d.data === void 0,
3249
3536
  error: d.error
3250
3537
  };
3251
- }, ba = () => typeof navigator > "u" || navigator.onLine, xa = () => !0, Sa = (e) => typeof window > "u" ? () => {} : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
3538
+ }, mo = () => typeof navigator > "u" || navigator.onLine, ho = () => !0, go = (e) => typeof window > "u" ? () => {} : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
3252
3539
  window.removeEventListener("online", e), window.removeEventListener("offline", e);
3253
- }), Ca = (e) => {
3254
- let t = W(e), n = t.recovery ?? d(t.errorBus, e), r = we(n.subscribe, n.getSnapshot, n.getServerSnapshot ?? (() => v)), i = we(Sa, ba, xa), a = F(() => n.reportExternalSuccess(), [n]), s = i ? r.status : "offline";
3255
- return L(() => {
3256
- o(e, "connection.status", {
3540
+ }), _o = (e) => {
3541
+ let t = K(e), r = t.recovery ?? E(t.errorBus, e), i = H(r.subscribe, r.getSnapshot, r.getServerSnapshot ?? (() => h)), a = H(go, mo, ho), o = L(() => r.reportExternalSuccess(), [r]), s = a ? i.status : "offline";
3542
+ return R(() => {
3543
+ n(e, "connection.status", {
3257
3544
  status: s,
3258
- rawTransport: r.rawTransport,
3259
- online: i,
3260
- failureCount: r.failureCount,
3261
- failedSubscriptions: r.failedSubscriptions.length,
3262
- pendingMutationReplays: r.pendingMutationReplays,
3263
- mutationReplay: r.mutationReplay
3545
+ rawTransport: i.rawTransport,
3546
+ online: a,
3547
+ failureCount: i.failureCount,
3548
+ failedSubscriptions: i.failedSubscriptions.length,
3549
+ pendingMutationReplays: i.pendingMutationReplays,
3550
+ mutationReplay: i.mutationReplay
3264
3551
  });
3265
3552
  }, [
3266
3553
  e,
3267
3554
  s,
3268
- i,
3269
- r
3555
+ a,
3556
+ i
3270
3557
  ]), {
3271
3558
  status: s,
3272
- rawTransport: r.rawTransport,
3273
- online: i,
3274
- failureCount: r.failureCount,
3275
- lastFailureAt: r.lastFailureAt,
3276
- failedSubscriptions: r.failedSubscriptions,
3277
- pendingMutationReplays: r.pendingMutationReplays,
3278
- mutationReplay: r.mutationReplay,
3279
- reportSuccess: a
3559
+ rawTransport: i.rawTransport,
3560
+ online: a,
3561
+ failureCount: i.failureCount,
3562
+ lastFailureAt: i.lastFailureAt,
3563
+ failedSubscriptions: i.failedSubscriptions,
3564
+ pendingMutationReplays: i.pendingMutationReplays,
3565
+ mutationReplay: i.mutationReplay,
3566
+ reportSuccess: o
3280
3567
  };
3281
- }, wa = "__voltro.connections.list", Ta = "__voltro.connections.start", Ea = "__voltro.connections.submitToken", Da = "__voltro.connections.disconnect", Oa = {
3568
+ }, vo = "__voltro.connections.list", yo = "__voltro.connections.start", bo = "__voltro.connections.submitToken", xo = "__voltro.connections.disconnect", So = {
3282
3569
  connectionId: "",
3283
3570
  kind: "oauth2",
3284
3571
  label: "",
@@ -3289,14 +3576,14 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3289
3576
  expiresAt: null,
3290
3577
  lastError: null,
3291
3578
  connectedAt: null
3292
- }, ka = (e, t) => {
3579
+ }, Co = (e, t) => {
3293
3580
  if (t === "redirect") {
3294
3581
  globalThis.location.assign(e);
3295
3582
  return;
3296
3583
  }
3297
3584
  globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
3298
- }, Aa = (e) => {
3299
- let { data: t } = G(e, wa, {}), n = On(e, Ta), r = X(e, Ea), i = X(e, Da), a = t ?? [], o = n.pending || r.pending || i.pending, s = F((e) => ({
3585
+ }, wo = (e) => {
3586
+ let { data: t } = q(e, vo, {}), n = ur(e, yo), r = ar(e, bo), i = ar(e, xo), a = t ?? [], o = n.pending || r.pending || i.pending, s = L((e) => ({
3300
3587
  ...e,
3301
3588
  connected: e.status === "connected",
3302
3589
  needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
@@ -3304,7 +3591,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3304
3591
  connect: async (t) => {
3305
3592
  if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
3306
3593
  let r = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
3307
- ka((await n.run({
3594
+ Co((await n.run({
3308
3595
  connectionId: e.connectionId,
3309
3596
  redirectTo: r
3310
3597
  })).authorizeUrl, t?.mode);
@@ -3324,7 +3611,7 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3324
3611
  n,
3325
3612
  r,
3326
3613
  i
3327
- ]), c = F((e) => {
3614
+ ]), c = L((e) => {
3328
3615
  let t = a.find((t) => t.connectionId === e);
3329
3616
  return t === void 0 ? void 0 : s(t);
3330
3617
  }, [a, s]);
@@ -3334,10 +3621,10 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3334
3621
  get: c,
3335
3622
  pending: o
3336
3623
  };
3337
- }, ja = (e, t) => {
3338
- let n = Aa(e), r = n.get(t);
3339
- return R(() => r === void 0 ? {
3340
- ...Oa,
3624
+ }, To = (e, t) => {
3625
+ let n = wo(e), r = n.get(t);
3626
+ return z(() => r === void 0 ? {
3627
+ ...So,
3341
3628
  connectionId: t,
3342
3629
  label: t,
3343
3630
  connected: !1,
@@ -3362,6 +3649,6 @@ var _i = () => I(hi), vi = (e) => pi(_i().scopes, e), yi = (e) => mi(_i().scopes
3362
3649
  n.loading,
3363
3650
  n.pending
3364
3651
  ]);
3365
- }, Ma = "framework-client";
3652
+ }, Eo = "framework-client";
3366
3653
  //#endregion
3367
- export { fi as ADMIN_SCOPE, Ma as CLIENT_NAME, wa as CONNECTIONS_LIST_TAG, Da as CONNECTION_DISCONNECT_TAG, Ta as CONNECTION_START_TAG, Ea as CONNECTION_SUBMIT_TOKEN_TAG, he as FORM_FLASH_SCRIPT_ID, ue as FORM_KEY_FIELD, pe as FORM_PATH_PREFIX, se as FORM_REDIRECT_FIELD, Vn as FormBindingProvider, Ve as FrameworkRuntimesContext, rt as FrameworkRuntimesProvider, v as INITIAL_RECOVERY_SNAPSHOT, s as LoadingSubscriptionCache, Y as MutationSerialExecutionError, gi as PermissionProvider, me as RICH_TEXT_MARKS, M as RICH_TEXT_MAX_NODES, E as RecoveryCoordinator, ce as RichTextDocument, S as RpcErrorBus, ti as ServerRequestContext, ri as ServerRequestProvider, D as SubscriptionCache, Ni as UNDO_APPLY_TAG, Mi as UNDO_LOG_TAG, Pi as UNDO_REDO_TAG, An as ValidationMessagesProvider, et as _resetFrameworkRuntimesWarning, Ye as _resetSsrDescriptors, ir as applyPreloadSeeds, Wt as applyStoreSeeds, x as buildApiRuntime, pi as canCall, mi as canCallAny, te as clearClientDiagnostics, nn as clearMutations, pa as clearSent, wt as clearStoreHistory, a as clientDiagnosticsSnapshot, va as computeWindow, aa as createAnalytics, Xn as createHooks, Ci as decideAccess, oe as decodeFieldIssues, na as defineEvent, zt as defineStore, Ii as defineTracking, Rt as definedStores, Ai as deriveEntityAdmins, t as disableClientDiagnosticsPersistence, ne as documentLocale, ge as emptyRichTextDocument, ee as enableClientDiagnosticsPersistence, sa as enqueueEntry, ia as eventCatalog, Yi as filtersFromSchema, j as formActionPath, de as formDataToInput, ye as formField, A as formSections, dn as freshIdempotencyKey, yn as getMutationNotifier, en as getMutations, ei as globalContext, ie as isRichTextDocument, ae as isSafeHref, T as isUnauthenticated, nt as isUnresolvedApi, Zn as makePreloadSeedBag, Vt as makeStoreSeedBag, bi as manifestUrl, da as markConflict, ua as markFailed, la as markSent, Ti as openAccessReason, fe as parseRichText, ui as provenanceUrl, y as publishClientError, _ as publishClientTrace, Yr as queryOnce, or as readPreloadedSeedOutcome, ar as readPreloadedSnapshot, o as recordClientDiagnostic, d as recoveryCoordinatorFor, qe as registerSsrDescriptors, ma as replayable, m as reportClientError, wi as requiredScopes, sr as resetPreloadSeeds, Bt as resetStoreRegistryForTests, lt as resetStoreStorageForTest, h as resolveByTag, fa as resolveConflictEntry, f as resolveRecoveryOptions, ct as resolveStoreStorage, Li as resolveTrackingEvent, _e as resolveValidationMessage, be as restrictToSchema, zr as resumableConsumeProgram, le as richTextToPlainText, ai as rowsToOptions, pr as runSequence, k as schemaToColumns, ve as schemaToFields, nr as seedPreloadedSubscription, rr as seedPreloadedSubscriptionFailure, Ut as seedStore, fr as sequence, N as serializeRichText, vn as setMutationNotifier, $n as setPreloadSeedResolver, Ht as setStoreSeedResolver, st as setStoreStorage, J as settleMutation, ut as shallow, Ui as shallowArrayEqual, Wi as sourceValues, Ue as ssrClientProxy, Je as ssrDescriptorsFor, Xe as ssrStubHandle, O as stableKey, c as startApiSupervisor, $t as startMutation, St as storeHistory, r as subscribeClientDiagnostics, p as subscribeClientErrors, e as subscribeClientTraces, tn as subscribeMutations, Ct as subscribeStoreHistory, l as supersedesConfirmedPatches, Tt as travelToStoreState, Ei as useAccessDecision, On as useAction, Gr as useAgent, Wr as useAgentChat, Rr as useAgentStream, ta as useAsyncValidation, vi as useCan, yi as useCanAny, xi as useCapabilityManifest, ja as useConnection, Jn as useConnectionSetup, Ca as useConnectionStatus, Aa as useConnections, Kr as useDataCopilot, ci as useDataTable, $i as useDebounced, Gi as useDerived, dr as useEvent, Rn as useFormBinding, Hn as useFormBindingContext, Un as useFormField, ii as useFormFlash, Vi as useFormSkeleton, W as useFrameworkApi, tt as useFrameworkRuntimes, X as useMutation, Zr as useOnRawRpcError, Xr as useOnRpcError, _a as useOutbox, _i as usePermissions, cr as usePreloadedSubscription, oa as usePreview, di as useProvenance, oi as useQueryField, Zi as useQueryFilters, Qi as useRecord, Jr as useRefreshSubscription, qr as useRefreshSubscriptions, Ki as useResourceCan, qi as useResourceCans, Vr as useResumableAgentStream, zn as useSchemaFormBinding, mr as useSequence, ni as useServerRequest, G as useSubscription, $r as useSubscriptionHealth, Hi as useTableSkeleton, Bi as useTracking, xr as useTranscription, ji as useUndo, Fi as useUndoLog, br as useUpload, jn as useValidationMessages, ya as useWindowedSubscription, Sr as useWorkflow, Ar as useWorkflowDomainEvents, jr as useWorkflowEventDeliveries, kr as useWorkflowEvents, Tr as useWorkflowRun, Or as useWorkflowRunEvents, Lr as useWorkflowRunState, Dr as useWorkflowRunSteps, Er as useWorkflowRuns, Cr as useWorkflowSignal, wr as useWorkflowUpdate, ra as validateEventPayload, re as validateFields, ea as validationStatus, b as wireAuthRefresh, fn as withIdempotencyKey, w as withProtocolOpenRecovery, zi as wrapTrackedCallbacks };
3654
+ export { Ji as ADMIN_SCOPE, Eo as CLIENT_NAME, vo as CONNECTIONS_LIST_TAG, xo as CONNECTION_DISCONNECT_TAG, yo as CONNECTION_START_TAG, bo as CONNECTION_SUBMIT_TOKEN_TAG, _e as FORM_FLASH_SCRIPT_ID, fe as FORM_KEY_FIELD, he as FORM_PATH_PREFIX, le as FORM_REDIRECT_FIELD, Cr as FormBindingProvider, Ze as FrameworkRuntimesContext, pt as FrameworkRuntimesProvider, h as INITIAL_RECOVERY_SNAPSHOT, M as LoadingSubscriptionCache, qn as MutationSerialExecutionError, ro as OUTBOX_DB_NAME, lo as OUTBOX_SYNC_TAG, Pe as PAIRING_HOST, Fe as PAIRING_SCHEME, Ie as PAIRING_STORAGE_KEY, Qi as PermissionProvider, ge as RICH_TEXT_MARKS, ie as RICH_TEXT_MAX_NODES, g as RecoveryCoordinator, ue as RichTextDocument, v as RpcErrorBus, Li as ServerRequestContext, zi as ServerRequestProvider, p as SubscriptionCache, ha as UNDO_APPLY_TAG, ma as UNDO_LOG_TAG, ga as UNDO_REDO_TAG, fr as ValidationMessagesProvider, ut as _resetFrameworkRuntimesWarning, at as _resetSsrDescriptors, Le as applyPairing, Br as applyPreloadSeeds, en as applyStoreSeeds, tn as browserOnlineSource, fn as browserPlatform, gt as browserStoreStorage, m as buildApiRuntime, Yi as canCall, Xi as canCallAny, nn as capabilitiesOf, t as clearClientDiagnostics, Bn as clearMutations, Re as clearPairing, Ya as clearSent, Pt as clearStoreHistory, te as clientDiagnosticsSnapshot, fo as computeWindow, Va as createAnalytics, Mr as createHooks, gn as currentPlatform, aa as decideAccess, se as decodeFieldIssues, En as deepLinkHref, Sn as defineDeepLink, Ra as defineEvent, rn as definePlatform, Yt as defineStore, va as defineTracking, Jt as definedStores, fa as deriveEntityAdmins, u as disableClientDiagnosticsPersistence, On as dispatchDeepLink, ne as documentLocale, uo as drainOutboxInWorker, no as drainOutboxOverHttp, ve as emptyRichTextDocument, r as enableClientDiagnosticsPersistence, Ua as enqueueEntry, ze as errorMessage, Be as errorTag, Ba as eventCatalog, ja as filtersFromSchema, F as formActionPath, pe as formDataToInput, xe as formField, P as formSections, D as freshIdempotencyKey, er as getMutationNotifier, Rn as getMutations, Ii as globalContext, co as indexedDbOutboxPersistence, hn as installPlatform, _n as isPlatformInstalled, ae as isRichTextDocument, oe as isSafeHref, un as isStandaloneDisplay, ee as isUnauthenticated, ft as isUnresolvedApi, Nr as makePreloadSeedBag, Zt as makeStoreSeedBag, na as manifestUrl, qa as markConflict, Ka as markFailed, Ga as markSent, wn as matchDeepLink, Dn as matchFirstDeepLink, on as memoryTokenStore, sa as openAccessReason, Ue as pairingLink, We as parsePairingLink, me as parseRichText, Ki as provenanceUrl, _ as publishClientError, b as publishClientTrace, ji as queryOnce, Ke as readPairing, Hr as readPreloadedSeedOutcome, Vr as readPreloadedSnapshot, n as recordClientDiagnostic, E as recoveryCoordinatorFor, an as refusingTokenStore, c as registerCellMerger, rt as registerSsrDescriptors, i as registeredCellMerger, Xa as replayable, d as reportClientError, oa as requiredScopes, vn as resetPlatformForTest, Ur as resetPreloadSeeds, Xt as resetStoreRegistryForTests, yt as resetStoreStorageForTest, T as resolveByTag, Ja as resolveConflictEntry, C as resolveRecoveryOptions, vt as resolveStoreStorage, ya as resolveTrackingEvent, ye as resolveValidationMessage, Se as restrictToSchema, xi as resumableConsumeProgram, de as richTextToPlainText, Vi as rowsToOptions, to as rpcHttpOutcome, Tn as runDeepLink, Yr as runSequence, N as schemaToColumns, be as schemaToFields, Rr as seedPreloadedSubscription, zr as seedPreloadedSubscriptionFailure, $t as seedStore, Jr as sequence, ce as serializeRichText, $n as setMutationNotifier, Fr as setPreloadSeedResolver, Qt as setStoreSeedResolver, _t as setStoreStorage, X as settleMutation, bt as shallow, Ta as shallowArrayEqual, Ea as sourceValues, $e as ssrClientProxy, it as ssrDescriptorsFor, ot as ssrStubHandle, j as stableKey, O as startApiSupervisor, Ln as startMutation, Mt as storeHistory, s as subscribeClientDiagnostics, A as subscribeClientErrors, a as subscribeClientTraces, zn as subscribeMutations, Nt as subscribeStoreHistory, l as supersedesConfirmedPatches, Ft as travelToStoreState, ca as useAccessDecision, ur as useAction, Di as useAgent, Ei as useAgentChat, bi as useAgentStream, La as useAsyncValidation, ea as useCan, ta as useCanAny, ra as useCapabilityManifest, To as useConnection, Ar as useConnectionSetup, _o as useConnectionStatus, wo as useConnections, Oi as useDataCopilot, Wi as useDataTable, Fa as useDebounced, Da as useDerived, qr as useEvent, br as useFormBinding, wr as useFormBindingContext, Tr as useFormField, Bi as useFormFlash, Ca as useFormSkeleton, K as useFrameworkApi, dt as useFrameworkRuntimes, ar as useMutation, Ni as useOnRawRpcError, Mi as useOnRpcError, $a as useOutbox, $i as usePermissions, bn as usePlatform, Wr as usePreloadedSubscription, Ha as usePreview, qi as useProvenance, Hi as useQueryField, Na as useQueryFilters, Pa as useRecord, Ai as useRefreshSubscription, ki as useRefreshSubscriptions, Oa as useResourceCan, ka as useResourceCans, Ci as useResumableAgentStream, xr as useSchemaFormBinding, Xr as useSequence, Ri as useServerRequest, xn as useShellExtension, q as useSubscription, Fi as useSubscriptionHealth, wa as useTableSkeleton, Sa as useTracking, ri as useTranscription, pa as useUndo, _a as useUndoLog, ni as useUpload, pr as useValidationMessages, po as useWindowedSubscription, ii as useWorkflow, fi as useWorkflowDomainEvents, pi as useWorkflowEventDeliveries, di as useWorkflowEvents, si as useWorkflowRun, ui as useWorkflowRunEvents, yi as useWorkflowRunState, li as useWorkflowRunSteps, ci as useWorkflowRuns, ai as useWorkflowSignal, oi as useWorkflowUpdate, za as validateEventPayload, re as validateFields, Ia as validationStatus, w as wireAuthRefresh, y as withIdempotencyKey, S as withProtocolOpenRecovery, xa as wrapTrackedCallbacks };