cogsbox-state 0.5.276 → 0.5.278

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.
@@ -1,17 +1,17 @@
1
1
  "use client";
2
- import { jsx as vt } from "react/jsx-runtime";
3
- import { useState as et, useRef as H, useEffect as ut, useLayoutEffect as ft, useMemo as At, createElement as st, useSyncExternalStore as Nt, startTransition as Vt, useCallback as ht } from "react";
4
- import { transformStateFunc as bt, isDeepEqual as L, isFunction as J, getNestedValue as B, getDifferences as gt, debounce as Ct } from "./utility.js";
5
- import { pushFunc as dt, updateFn as tt, cutFunc as rt, ValidationWrapper as Pt, FormControlComponent as _t } from "./Functions.jsx";
2
+ import { jsx as ht } from "react/jsx-runtime";
3
+ import { useState as nt, useRef as H, useEffect as gt, useLayoutEffect as ft, useMemo as Tt, createElement as it, useSyncExternalStore as Nt, startTransition as Vt, useCallback as vt } from "react";
4
+ import { transformStateFunc as bt, isDeepEqual as L, isFunction as J, getNestedValue as B, getDifferences as St, debounce as Pt } from "./utility.js";
5
+ import { pushFunc as ut, updateFn as et, cutFunc as at, ValidationWrapper as Ct, FormControlComponent as _t } from "./Functions.jsx";
6
6
  import Mt from "superjson";
7
- import { v4 as St } from "uuid";
7
+ import { v4 as mt } from "uuid";
8
8
  import "zod";
9
9
  import { getGlobalStore as r, formRefStore as It } from "./store.js";
10
10
  import { useCogsConfig as $t } from "./CogsStateClient.jsx";
11
11
  import { applyPatch as Ot } from "fast-json-patch";
12
12
  function pt(t, i) {
13
- const h = r.getState().getInitialOptions, f = r.getState().setInitialStateOptions, y = h(t) || {};
14
- f(t, {
13
+ const v = r.getState().getInitialOptions, g = r.getState().setInitialStateOptions, y = v(t) || {};
14
+ g(t, {
15
15
  ...y,
16
16
  ...i
17
17
  });
@@ -19,22 +19,22 @@ function pt(t, i) {
19
19
  function wt({
20
20
  stateKey: t,
21
21
  options: i,
22
- initialOptionsPart: h
22
+ initialOptionsPart: v
23
23
  }) {
24
- const f = Z(t) || {}, y = h[t] || {}, $ = r.getState().setInitialStateOptions, E = { ...y, ...f };
24
+ const g = Q(t) || {}, y = v[t] || {}, k = r.getState().setInitialStateOptions, p = { ...y, ...g };
25
25
  let I = !1;
26
26
  if (i)
27
27
  for (const s in i)
28
- E.hasOwnProperty(s) ? (s == "localStorage" && i[s] && E[s].key !== i[s]?.key && (I = !0, E[s] = i[s]), s == "initialState" && i[s] && E[s] !== i[s] && // Different references
29
- !L(E[s], i[s]) && (I = !0, E[s] = i[s])) : (I = !0, E[s] = i[s]);
30
- I && $(t, E);
28
+ p.hasOwnProperty(s) ? (s == "localStorage" && i[s] && p[s].key !== i[s]?.key && (I = !0, p[s] = i[s]), s == "initialState" && i[s] && p[s] !== i[s] && // Different references
29
+ !L(p[s], i[s]) && (I = !0, p[s] = i[s])) : (I = !0, p[s] = i[s]);
30
+ I && k(t, p);
31
31
  }
32
- function ee(t, { formElements: i, validation: h }) {
33
- return { initialState: t, formElements: i, validation: h };
32
+ function ee(t, { formElements: i, validation: v }) {
33
+ return { initialState: t, formElements: i, validation: v };
34
34
  }
35
35
  const ne = (t, i) => {
36
- let h = t;
37
- const [f, y] = bt(h);
36
+ let v = t;
37
+ const [g, y] = bt(v);
38
38
  (Object.keys(y).length > 0 || i && Object.keys(i).length > 0) && Object.keys(y).forEach((I) => {
39
39
  y[I] = y[I] || {}, y[I].formElements = {
40
40
  ...i?.formElements,
@@ -42,21 +42,21 @@ const ne = (t, i) => {
42
42
  ...i?.validation,
43
43
  ...y[I].formElements || {}
44
44
  // State-specific overrides
45
- }, Z(I) || r.getState().setInitialStateOptions(I, y[I]);
46
- }), r.getState().setInitialStates(f), r.getState().setCreatedState(f);
47
- const $ = (I, s) => {
48
- const [v] = et(s?.componentId ?? St());
45
+ }, Q(I) || r.getState().setInitialStateOptions(I, y[I]);
46
+ }), r.getState().setInitialStates(g), r.getState().setCreatedState(g);
47
+ const k = (I, s) => {
48
+ const [h] = nt(s?.componentId ?? mt());
49
49
  wt({
50
50
  stateKey: I,
51
51
  options: s,
52
52
  initialOptionsPart: y
53
53
  });
54
- const o = r.getState().cogsStateStore[I] || f[I], g = s?.modifyState ? s.modifyState(o) : o, [G, j] = Wt(
55
- g,
54
+ const a = r.getState().cogsStateStore[I] || g[I], S = s?.modifyState ? s.modifyState(a) : a, [D, R] = Wt(
55
+ S,
56
56
  {
57
57
  stateKey: I,
58
58
  syncUpdate: s?.syncUpdate,
59
- componentId: v,
59
+ componentId: h,
60
60
  localStorage: s?.localStorage,
61
61
  middleware: s?.middleware,
62
62
  enabledSync: s?.enabledSync,
@@ -67,49 +67,49 @@ const ne = (t, i) => {
67
67
  serverState: s?.serverState
68
68
  }
69
69
  );
70
- return j;
70
+ return R;
71
71
  };
72
- function E(I, s) {
73
- wt({ stateKey: I, options: s, initialOptionsPart: y }), s.localStorage && Dt(I, s), ct(I);
72
+ function p(I, s) {
73
+ wt({ stateKey: I, options: s, initialOptionsPart: y }), s.localStorage && Dt(I, s), lt(I);
74
74
  }
75
- return { useCogsState: $, setCogsOptions: E };
75
+ return { useCogsState: k, setCogsOptions: p };
76
76
  }, {
77
77
  setUpdaterState: ot,
78
- setState: Y,
79
- getInitialOptions: Z,
78
+ setState: Z,
79
+ getInitialOptions: Q,
80
80
  getKeyState: kt,
81
81
  getValidationErrors: Rt,
82
- setStateLog: jt,
83
- updateInitialStateGlobal: mt,
84
- addValidationError: Ft,
82
+ setStateLog: Ft,
83
+ updateInitialStateGlobal: yt,
84
+ addValidationError: Ut,
85
85
  removeValidationError: z,
86
- setServerSyncActions: Ut
87
- } = r.getState(), Et = (t, i, h, f, y) => {
88
- h?.log && console.log(
86
+ setServerSyncActions: jt
87
+ } = r.getState(), Et = (t, i, v, g, y) => {
88
+ v?.log && console.log(
89
89
  "saving to localstorage",
90
90
  i,
91
- h.localStorage?.key,
92
- f
91
+ v.localStorage?.key,
92
+ g
93
93
  );
94
- const $ = J(h?.localStorage?.key) ? h.localStorage?.key(t) : h?.localStorage?.key;
95
- if ($ && f) {
96
- const E = `${f}-${i}-${$}`;
94
+ const k = J(v?.localStorage?.key) ? v.localStorage?.key(t) : v?.localStorage?.key;
95
+ if (k && g) {
96
+ const p = `${g}-${i}-${k}`;
97
97
  let I;
98
98
  try {
99
- I = it(E)?.lastSyncedWithServer;
99
+ I = ct(p)?.lastSyncedWithServer;
100
100
  } catch {
101
101
  }
102
102
  const s = {
103
103
  state: t,
104
104
  lastUpdated: Date.now(),
105
105
  lastSyncedWithServer: y ?? I
106
- }, v = Mt.serialize(s);
106
+ }, h = Mt.serialize(s);
107
107
  window.localStorage.setItem(
108
- E,
109
- JSON.stringify(v.json)
108
+ p,
109
+ JSON.stringify(h.json)
110
110
  );
111
111
  }
112
- }, it = (t) => {
112
+ }, ct = (t) => {
113
113
  if (!t) return null;
114
114
  try {
115
115
  const i = window.localStorage.getItem(t);
@@ -118,60 +118,60 @@ const ne = (t, i) => {
118
118
  return console.error("Error loading from localStorage:", i), null;
119
119
  }
120
120
  }, Dt = (t, i) => {
121
- const h = r.getState().cogsStateStore[t], { sessionId: f } = $t(), y = J(i?.localStorage?.key) ? i.localStorage.key(h) : i?.localStorage?.key;
122
- if (y && f) {
123
- const $ = it(
124
- `${f}-${t}-${y}`
121
+ const v = r.getState().cogsStateStore[t], { sessionId: g } = $t(), y = J(i?.localStorage?.key) ? i.localStorage.key(v) : i?.localStorage?.key;
122
+ if (y && g) {
123
+ const k = ct(
124
+ `${g}-${t}-${y}`
125
125
  );
126
- if ($ && $.lastUpdated > ($.lastSyncedWithServer || 0))
127
- return Y(t, $.state), ct(t), !0;
126
+ if (k && k.lastUpdated > (k.lastSyncedWithServer || 0))
127
+ return Z(t, k.state), lt(t), !0;
128
128
  }
129
129
  return !1;
130
- }, xt = (t, i, h, f, y, $) => {
131
- const E = {
130
+ }, xt = (t, i, v, g, y, k) => {
131
+ const p = {
132
132
  initialState: i,
133
- updaterState: at(
133
+ updaterState: st(
134
134
  t,
135
- f,
135
+ g,
136
136
  y,
137
- $
137
+ k
138
138
  ),
139
- state: h
139
+ state: v
140
140
  };
141
- mt(t, E.initialState), ot(t, E.updaterState), Y(t, E.state);
142
- }, ct = (t) => {
141
+ yt(t, p.initialState), ot(t, p.updaterState), Z(t, p.state);
142
+ }, lt = (t) => {
143
143
  const i = r.getState().stateComponents.get(t);
144
144
  if (!i) return;
145
- const h = /* @__PURE__ */ new Set();
146
- i.components.forEach((f) => {
147
- (f ? Array.isArray(f.reactiveType) ? f.reactiveType : [f.reactiveType || "component"] : null)?.includes("none") || h.add(() => f.forceUpdate());
145
+ const v = /* @__PURE__ */ new Set();
146
+ i.components.forEach((g) => {
147
+ (g ? Array.isArray(g.reactiveType) ? g.reactiveType : [g.reactiveType || "component"] : null)?.includes("none") || v.add(() => g.forceUpdate());
148
148
  }), queueMicrotask(() => {
149
- h.forEach((f) => f());
149
+ v.forEach((g) => g());
150
150
  });
151
151
  }, re = (t, i) => {
152
- const h = r.getState().stateComponents.get(t);
153
- if (h) {
154
- const f = `${t}////${i}`, y = h.components.get(f);
152
+ const v = r.getState().stateComponents.get(t);
153
+ if (v) {
154
+ const g = `${t}////${i}`, y = v.components.get(g);
155
155
  if ((y ? Array.isArray(y.reactiveType) ? y.reactiveType : [y.reactiveType || "component"] : null)?.includes("none"))
156
156
  return;
157
157
  y && y.forceUpdate();
158
158
  }
159
- }, Gt = (t, i, h, f) => {
159
+ }, Gt = (t, i, v, g) => {
160
160
  switch (t) {
161
161
  case "update":
162
162
  return {
163
- oldValue: B(i, f),
164
- newValue: B(h, f)
163
+ oldValue: B(i, g),
164
+ newValue: B(v, g)
165
165
  };
166
166
  case "insert":
167
167
  return {
168
168
  oldValue: null,
169
169
  // or undefined
170
- newValue: B(h, f)
170
+ newValue: B(v, g)
171
171
  };
172
172
  case "cut":
173
173
  return {
174
- oldValue: B(i, f),
174
+ oldValue: B(i, g),
175
175
  newValue: null
176
176
  // or undefined
177
177
  };
@@ -181,312 +181,326 @@ const ne = (t, i) => {
181
181
  };
182
182
  function Wt(t, {
183
183
  stateKey: i,
184
- serverSync: h,
185
- localStorage: f,
184
+ serverSync: v,
185
+ localStorage: g,
186
186
  formElements: y,
187
- reactiveDeps: $,
188
- reactiveType: E,
187
+ reactiveDeps: k,
188
+ reactiveType: p,
189
189
  componentId: I,
190
190
  initialState: s,
191
- syncUpdate: v,
192
- dependencies: o,
193
- serverState: g
191
+ syncUpdate: h,
192
+ dependencies: a,
193
+ serverState: S
194
194
  } = {}) {
195
- const [G, j] = et({}), { sessionId: F } = $t();
196
- let W = !i;
197
- const [m] = et(i ?? St()), l = r.getState().stateLog[m], nt = H(/* @__PURE__ */ new Set()), q = H(I ?? St()), O = H(
195
+ const [D, R] = nt({}), { sessionId: F } = $t();
196
+ let G = !i;
197
+ const [f] = nt(i ?? mt()), l = r.getState().stateLog[f], rt = H(/* @__PURE__ */ new Set()), Y = H(I ?? mt()), O = H(
198
198
  null
199
199
  );
200
- O.current = Z(m) ?? null, ut(() => {
201
- if (v && v.stateKey === m && v.path?.[0]) {
202
- Y(m, (n) => ({
200
+ O.current = Q(f) ?? null, gt(() => {
201
+ if (h && h.stateKey === f && h.path?.[0]) {
202
+ Z(f, (n) => ({
203
203
  ...n,
204
- [v.path[0]]: v.newValue
204
+ [h.path[0]]: h.newValue
205
205
  }));
206
- const e = `${v.stateKey}:${v.path.join(".")}`;
206
+ const e = `${h.stateKey}:${h.path.join(".")}`;
207
207
  r.getState().setSyncInfo(e, {
208
- timeStamp: v.timeStamp,
209
- userId: v.userId
208
+ timeStamp: h.timeStamp,
209
+ userId: h.userId
210
210
  });
211
211
  }
212
- }, [v]), ut(() => {
212
+ }, [h]), gt(() => {
213
213
  if (s) {
214
- pt(m, {
214
+ pt(f, {
215
215
  initialState: s
216
216
  });
217
- const e = O.current, a = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, c = r.getState().initialStateGlobal[m];
218
- if (!(c && !L(c, s) || !c) && !a)
217
+ const e = O.current, o = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, c = r.getState().initialStateGlobal[f];
218
+ if (!(c && !L(c, s) || !c) && !o)
219
219
  return;
220
- let u = null;
220
+ let d = null;
221
221
  const N = J(e?.localStorage?.key) ? e?.localStorage?.key(s) : e?.localStorage?.key;
222
- N && F && (u = it(`${F}-${m}-${N}`));
223
- let p = s, A = !1;
224
- const C = a ? Date.now() : 0, x = u?.lastUpdated || 0, V = u?.lastSyncedWithServer || 0;
225
- a && C > x ? (p = e.serverState.data, A = !0) : u && x > V && (p = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), xt(
226
- m,
222
+ N && F && (d = ct(`${F}-${f}-${N}`));
223
+ let w = s, T = !1;
224
+ const P = o ? Date.now() : 0, x = d?.lastUpdated || 0, V = d?.lastSyncedWithServer || 0;
225
+ o && P > x ? (w = e.serverState.data, T = !0) : d && x > V && (w = d.state, e?.localStorage?.onChange && e?.localStorage?.onChange(w)), r.getState().initializeShadowState(f, s), xt(
226
+ f,
227
227
  s,
228
- p,
229
- X,
230
- q.current,
228
+ w,
229
+ K,
230
+ Y.current,
231
231
  F
232
- ), A && N && F && Et(p, m, e, F, Date.now()), ct(m), (Array.isArray(E) ? E : [E || "component"]).includes("none") || j({});
232
+ ), T && N && F && Et(w, f, e, F, Date.now()), lt(f), (Array.isArray(p) ? p : [p || "component"]).includes("none") || R({});
233
233
  }
234
234
  }, [
235
235
  s,
236
- g?.status,
237
- g?.data,
238
- ...o || []
236
+ S?.status,
237
+ S?.data,
238
+ ...a || []
239
239
  ]), ft(() => {
240
- W && pt(m, {
241
- serverSync: h,
240
+ G && pt(f, {
241
+ serverSync: v,
242
242
  formElements: y,
243
243
  initialState: s,
244
- localStorage: f,
244
+ localStorage: g,
245
245
  middleware: O.current?.middleware
246
246
  });
247
- const e = `${m}////${q.current}`, n = r.getState().stateComponents.get(m) || {
247
+ const e = `${f}////${Y.current}`, n = r.getState().stateComponents.get(f) || {
248
248
  components: /* @__PURE__ */ new Map()
249
249
  };
250
250
  return n.components.set(e, {
251
- forceUpdate: () => j({}),
251
+ forceUpdate: () => R({}),
252
252
  paths: /* @__PURE__ */ new Set(),
253
253
  deps: [],
254
- depsFunction: $ || void 0,
255
- reactiveType: E ?? ["component", "deps"]
256
- }), r.getState().stateComponents.set(m, n), j({}), () => {
257
- const a = `${m}////${q.current}`;
258
- n && (n.components.delete(a), n.components.size === 0 && r.getState().stateComponents.delete(m));
254
+ depsFunction: k || void 0,
255
+ reactiveType: p ?? ["component", "deps"]
256
+ }), r.getState().stateComponents.set(f, n), R({}), () => {
257
+ n && (n.components.delete(e), n.components.size === 0 && r.getState().stateComponents.delete(f));
259
258
  };
260
259
  }, []);
261
- const X = (e, n, a, c) => {
260
+ const K = (e, n, o, c) => {
262
261
  if (Array.isArray(n)) {
263
- const S = `${m}-${n.join(".")}`;
264
- nt.current.add(S);
262
+ const m = `${f}-${n.join(".")}`;
263
+ rt.current.add(m);
265
264
  }
266
- Y(m, (S) => {
267
- const u = J(e) ? e(S) : e, N = `${m}-${n.join(".")}`;
265
+ Z(f, (m) => {
266
+ const d = J(e) ? e(m) : e, N = `${f}-${n.join(".")}`;
268
267
  if (N) {
269
- let _ = !1, k = r.getState().signalDomElements.get(N);
270
- if ((!k || k.size === 0) && (a.updateType === "insert" || a.updateType === "cut")) {
271
- const R = n.slice(0, -1), T = B(u, R);
272
- if (Array.isArray(T)) {
273
- _ = !0;
274
- const w = `${m}-${R.join(".")}`;
275
- k = r.getState().signalDomElements.get(w);
268
+ let C = !1, $ = r.getState().signalDomElements.get(N);
269
+ if ((!$ || $.size === 0) && (o.updateType === "insert" || o.updateType === "cut")) {
270
+ const A = n.slice(0, -1), _ = B(d, A);
271
+ if (Array.isArray(_)) {
272
+ C = !0;
273
+ const E = `${f}-${A.join(".")}`;
274
+ $ = r.getState().signalDomElements.get(E);
276
275
  }
277
276
  }
278
- if (k) {
279
- const R = _ ? B(u, n.slice(0, -1)) : B(u, n);
280
- k.forEach(({ parentId: T, position: w, effect: P }) => {
277
+ if ($) {
278
+ const A = C ? B(d, n.slice(0, -1)) : B(d, n);
279
+ $.forEach(({ parentId: _, position: E, effect: M }) => {
281
280
  const b = document.querySelector(
282
- `[data-parent-id="${T}"]`
281
+ `[data-parent-id="${_}"]`
283
282
  );
284
283
  if (b) {
285
- const U = Array.from(b.childNodes);
286
- if (U[w]) {
287
- const M = P ? new Function("state", `return (${P})(state)`)(R) : R;
288
- U[w].textContent = String(M);
284
+ const j = Array.from(b.childNodes);
285
+ if (j[E]) {
286
+ const U = M ? new Function("state", `return (${M})(state)`)(A) : A;
287
+ j[E].textContent = String(U);
289
288
  }
290
289
  }
291
290
  });
292
291
  }
293
292
  }
294
- a.updateType === "update" && (c || O.current?.validation?.key) && n && z(
293
+ (() => {
294
+ const C = r.getState();
295
+ switch (o.updateType) {
296
+ case "update":
297
+ C.updateShadowAtPath(f, n, d);
298
+ break;
299
+ case "insert":
300
+ const $ = n.slice(0, -1);
301
+ C.insertShadowArrayElement(f, $);
302
+ break;
303
+ case "cut":
304
+ const A = n.slice(0, -1), _ = parseInt(n[n.length - 1]);
305
+ C.removeShadowArrayElement(f, A, _);
306
+ break;
307
+ }
308
+ })(), console.log("shadowState", r.getState().shadowStateStore), o.updateType === "update" && (c || O.current?.validation?.key) && n && z(
295
309
  (c || O.current?.validation?.key) + "." + n.join(".")
296
310
  );
297
- const p = n.slice(0, n.length - 1);
298
- a.updateType === "cut" && O.current?.validation?.key && z(
299
- O.current?.validation?.key + "." + p.join(".")
300
- ), a.updateType === "insert" && O.current?.validation?.key && Rt(
301
- O.current?.validation?.key + "." + p.join(".")
302
- ).filter(([k, R]) => {
303
- let T = k?.split(".").length;
304
- if (k == p.join(".") && T == p.length - 1) {
305
- let w = k + "." + p;
306
- z(k), Ft(w, R);
311
+ const T = n.slice(0, n.length - 1);
312
+ o.updateType === "cut" && O.current?.validation?.key && z(
313
+ O.current?.validation?.key + "." + T.join(".")
314
+ ), o.updateType === "insert" && O.current?.validation?.key && Rt(
315
+ O.current?.validation?.key + "." + T.join(".")
316
+ ).filter(([$, A]) => {
317
+ let _ = $?.split(".").length;
318
+ if ($ == T.join(".") && _ == T.length - 1) {
319
+ let E = $ + "." + T;
320
+ z($), Ut(E, A);
307
321
  }
308
322
  });
309
- const A = r.getState().stateComponents.get(m);
310
- if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", A), A) {
311
- const _ = gt(S, u), k = new Set(_), R = a.updateType === "update" ? n.join(".") : n.slice(0, -1).join(".") || "";
323
+ const P = r.getState().stateComponents.get(f);
324
+ if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", P), P) {
325
+ const C = St(m, d), $ = new Set(C), A = o.updateType === "update" ? n.join(".") : n.slice(0, -1).join(".") || "";
312
326
  for (const [
313
- T,
314
- w
315
- ] of A.components.entries()) {
316
- let P = !1;
317
- const b = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
318
- if (console.log("component", w), !b.includes("none")) {
327
+ _,
328
+ E
329
+ ] of P.components.entries()) {
330
+ let M = !1;
331
+ const b = Array.isArray(E.reactiveType) ? E.reactiveType : [E.reactiveType || "component"];
332
+ if (console.log("component", E), !b.includes("none")) {
319
333
  if (b.includes("all")) {
320
- w.forceUpdate();
334
+ E.forceUpdate();
321
335
  continue;
322
336
  }
323
- if (b.includes("component") && ((w.paths.has(R) || w.paths.has("")) && (P = !0), !P))
324
- for (const U of k) {
325
- let M = U;
337
+ if (b.includes("component") && ((E.paths.has(A) || E.paths.has("")) && (M = !0), !M))
338
+ for (const j of $) {
339
+ let U = j;
326
340
  for (; ; ) {
327
- if (w.paths.has(M)) {
328
- P = !0;
341
+ if (E.paths.has(U)) {
342
+ M = !0;
329
343
  break;
330
344
  }
331
- const Q = M.lastIndexOf(".");
332
- if (Q !== -1) {
333
- const K = M.substring(
345
+ const X = U.lastIndexOf(".");
346
+ if (X !== -1) {
347
+ const tt = U.substring(
334
348
  0,
335
- Q
349
+ X
336
350
  );
337
351
  if (!isNaN(
338
- Number(M.substring(Q + 1))
339
- ) && w.paths.has(K)) {
340
- P = !0;
352
+ Number(U.substring(X + 1))
353
+ ) && E.paths.has(tt)) {
354
+ M = !0;
341
355
  break;
342
356
  }
343
- M = K;
357
+ U = tt;
344
358
  } else
345
- M = "";
346
- if (M === "")
359
+ U = "";
360
+ if (U === "")
347
361
  break;
348
362
  }
349
- if (P) break;
363
+ if (M) break;
350
364
  }
351
- if (!P && b.includes("deps") && w.depsFunction) {
352
- const U = w.depsFunction(u);
353
- let M = !1;
354
- typeof U == "boolean" ? U && (M = !0) : L(w.deps, U) || (w.deps = U, M = !0), M && (P = !0);
365
+ if (!M && b.includes("deps") && E.depsFunction) {
366
+ const j = E.depsFunction(d);
367
+ let U = !1;
368
+ typeof j == "boolean" ? j && (U = !0) : L(E.deps, j) || (E.deps = j, U = !0), U && (M = !0);
355
369
  }
356
- P && w.forceUpdate();
370
+ M && E.forceUpdate();
357
371
  }
358
372
  }
359
373
  }
360
- const C = Date.now();
361
- n = n.map((_, k) => {
362
- const R = n.slice(0, -1), T = B(u, R);
363
- return k === n.length - 1 && ["insert", "cut"].includes(a.updateType) ? (T.length - 1).toString() : _;
374
+ const x = Date.now();
375
+ n = n.map((C, $) => {
376
+ const A = n.slice(0, -1), _ = B(d, A);
377
+ return $ === n.length - 1 && ["insert", "cut"].includes(o.updateType) ? (_.length - 1).toString() : C;
364
378
  });
365
- const { oldValue: x, newValue: V } = Gt(
366
- a.updateType,
367
- S,
368
- u,
379
+ const { oldValue: V, newValue: W } = Gt(
380
+ o.updateType,
381
+ m,
382
+ d,
369
383
  n
370
- ), D = {
371
- timeStamp: C,
372
- stateKey: m,
384
+ ), q = {
385
+ timeStamp: x,
386
+ stateKey: f,
373
387
  path: n,
374
- updateType: a.updateType,
388
+ updateType: o.updateType,
375
389
  status: "new",
376
- oldValue: x,
377
- newValue: V
390
+ oldValue: V,
391
+ newValue: W
378
392
  };
379
- if (jt(m, (_) => {
380
- const R = [..._ ?? [], D].reduce((T, w) => {
381
- const P = `${w.stateKey}:${JSON.stringify(w.path)}`, b = T.get(P);
382
- return b ? (b.timeStamp = Math.max(b.timeStamp, w.timeStamp), b.newValue = w.newValue, b.oldValue = b.oldValue ?? w.oldValue, b.updateType = w.updateType) : T.set(P, { ...w }), T;
393
+ if (Ft(f, (C) => {
394
+ const A = [...C ?? [], q].reduce((_, E) => {
395
+ const M = `${E.stateKey}:${JSON.stringify(E.path)}`, b = _.get(M);
396
+ return b ? (b.timeStamp = Math.max(b.timeStamp, E.timeStamp), b.newValue = E.newValue, b.oldValue = b.oldValue ?? E.oldValue, b.updateType = E.updateType) : _.set(M, { ...E }), _;
383
397
  }, /* @__PURE__ */ new Map());
384
- return Array.from(R.values());
398
+ return Array.from(A.values());
385
399
  }), Et(
386
- u,
387
- m,
400
+ d,
401
+ f,
388
402
  O.current,
389
403
  F
390
404
  ), O.current?.middleware && O.current.middleware({
391
405
  updateLog: l,
392
- update: D
406
+ update: q
393
407
  }), O.current?.serverSync) {
394
- const _ = r.getState().serverState[m], k = O.current?.serverSync;
395
- Ut(m, {
396
- syncKey: typeof k.syncKey == "string" ? k.syncKey : k.syncKey({ state: u }),
397
- rollBackState: _,
398
- actionTimeStamp: Date.now() + (k.debounce ?? 3e3),
408
+ const C = r.getState().serverState[f], $ = O.current?.serverSync;
409
+ jt(f, {
410
+ syncKey: typeof $.syncKey == "string" ? $.syncKey : $.syncKey({ state: d }),
411
+ rollBackState: C,
412
+ actionTimeStamp: Date.now() + ($.debounce ?? 3e3),
399
413
  status: "waiting"
400
414
  });
401
415
  }
402
- return u;
416
+ return d;
403
417
  });
404
418
  };
405
- r.getState().updaterState[m] || (ot(
406
- m,
407
- at(
408
- m,
409
- X,
410
- q.current,
419
+ r.getState().updaterState[f] || (ot(
420
+ f,
421
+ st(
422
+ f,
423
+ K,
424
+ Y.current,
411
425
  F
412
426
  )
413
- ), r.getState().cogsStateStore[m] || Y(m, t), r.getState().initialStateGlobal[m] || mt(m, t));
414
- const d = At(() => at(
415
- m,
416
- X,
417
- q.current,
427
+ ), r.getState().cogsStateStore[f] || Z(f, t), r.getState().initialStateGlobal[f] || yt(f, t));
428
+ const u = Tt(() => st(
429
+ f,
430
+ K,
431
+ Y.current,
418
432
  F
419
- ), [m, F]);
420
- return [kt(m), d];
433
+ ), [f, F]);
434
+ return [kt(f), u];
421
435
  }
422
- function at(t, i, h, f) {
436
+ function st(t, i, v, g) {
423
437
  const y = /* @__PURE__ */ new Map();
424
- let $ = 0;
425
- const E = (v) => {
426
- const o = v.join(".");
427
- for (const [g] of y)
428
- (g === o || g.startsWith(o + ".")) && y.delete(g);
429
- $++;
438
+ let k = 0;
439
+ const p = (h) => {
440
+ const a = h.join(".");
441
+ for (const [S] of y)
442
+ (S === a || S.startsWith(a + ".")) && y.delete(S);
443
+ k++;
430
444
  }, I = {
431
- removeValidation: (v) => {
432
- v?.validationKey && z(v.validationKey);
445
+ removeValidation: (h) => {
446
+ h?.validationKey && z(h.validationKey);
433
447
  },
434
- revertToInitialState: (v) => {
435
- const o = r.getState().getInitialOptions(t)?.validation;
436
- o?.key && z(o?.key), v?.validationKey && z(v.validationKey);
437
- const g = r.getState().initialStateGlobal[t];
438
- r.getState().clearSelectedIndexesForState(t), y.clear(), $++;
439
- const G = s(g, []), j = Z(t), F = J(j?.localStorage?.key) ? j?.localStorage?.key(g) : j?.localStorage?.key, W = `${f}-${t}-${F}`;
440
- W && localStorage.removeItem(W), ot(t, G), Y(t, g);
441
- const m = r.getState().stateComponents.get(t);
442
- return m && m.components.forEach((l) => {
448
+ revertToInitialState: (h) => {
449
+ const a = r.getState().getInitialOptions(t)?.validation;
450
+ a?.key && z(a?.key), h?.validationKey && z(h.validationKey);
451
+ const S = r.getState().initialStateGlobal[t];
452
+ r.getState().clearSelectedIndexesForState(t), y.clear(), k++;
453
+ const D = s(S, []), R = Q(t), F = J(R?.localStorage?.key) ? R?.localStorage?.key(S) : R?.localStorage?.key, G = `${g}-${t}-${F}`;
454
+ G && localStorage.removeItem(G), ot(t, D), Z(t, S);
455
+ const f = r.getState().stateComponents.get(t);
456
+ return f && f.components.forEach((l) => {
443
457
  l.forceUpdate();
444
- }), g;
458
+ }), S;
445
459
  },
446
- updateInitialState: (v) => {
447
- y.clear(), $++;
448
- const o = at(
460
+ updateInitialState: (h) => {
461
+ y.clear(), k++;
462
+ const a = st(
449
463
  t,
450
464
  i,
451
- h,
452
- f
453
- ), g = r.getState().initialStateGlobal[t], G = Z(t), j = J(G?.localStorage?.key) ? G?.localStorage?.key(g) : G?.localStorage?.key, F = `${f}-${t}-${j}`;
465
+ v,
466
+ g
467
+ ), S = r.getState().initialStateGlobal[t], D = Q(t), R = J(D?.localStorage?.key) ? D?.localStorage?.key(S) : D?.localStorage?.key, F = `${g}-${t}-${R}`;
454
468
  return localStorage.getItem(F) && localStorage.removeItem(F), Vt(() => {
455
- mt(t, v), ot(t, o), Y(t, v);
456
- const W = r.getState().stateComponents.get(t);
457
- W && W.components.forEach((m) => {
458
- m.forceUpdate();
469
+ yt(t, h), ot(t, a), Z(t, h);
470
+ const G = r.getState().stateComponents.get(t);
471
+ G && G.components.forEach((f) => {
472
+ f.forceUpdate();
459
473
  });
460
474
  }), {
461
- fetchId: (W) => o.get()[W]
475
+ fetchId: (G) => a.get()[G]
462
476
  };
463
477
  },
464
478
  _initialState: r.getState().initialStateGlobal[t],
465
479
  _serverState: r.getState().serverState[t],
466
480
  _isLoading: r.getState().isLoadingGlobal[t],
467
481
  _isServerSynced: () => {
468
- const v = r.getState().serverState[t];
469
- return !!(v && L(v, kt(t)));
482
+ const h = r.getState().serverState[t];
483
+ return !!(h && L(h, kt(t)));
470
484
  }
471
485
  };
472
- function s(v, o = [], g) {
473
- const G = o.map(String).join(".");
474
- y.get(G);
475
- const j = function() {
476
- return r().getNestedState(t, o);
486
+ function s(h, a = [], S) {
487
+ const D = a.map(String).join(".");
488
+ y.get(D);
489
+ const R = function() {
490
+ return r().getNestedState(t, a);
477
491
  };
478
- Object.keys(I).forEach((m) => {
479
- j[m] = I[m];
492
+ Object.keys(I).forEach((f) => {
493
+ R[f] = I[f];
480
494
  });
481
495
  const F = {
482
- apply(m, l, nt) {
496
+ apply(f, l, rt) {
483
497
  return console.log(
484
- `PROXY APPLY TRAP HIT: stateKey=${t}, path=${o.join(".")}`
485
- ), console.trace("Apply trap stack trace"), r().getNestedState(t, o);
498
+ `PROXY APPLY TRAP HIT: stateKey=${t}, path=${a.join(".")}`
499
+ ), console.trace("Apply trap stack trace"), r().getNestedState(t, a);
486
500
  },
487
- get(m, l) {
488
- g?.validIndices && !Array.isArray(v) && (g = { ...g, validIndices: void 0 });
489
- const nt = /* @__PURE__ */ new Set([
501
+ get(f, l) {
502
+ S?.validIndices && !Array.isArray(h) && (S = { ...S, validIndices: void 0 });
503
+ const rt = /* @__PURE__ */ new Set([
490
504
  "insert",
491
505
  "cut",
492
506
  "cutByValue",
@@ -509,43 +523,43 @@ function at(t, i, h, f) {
509
523
  "_stateKey",
510
524
  "getComponents"
511
525
  ]);
512
- if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !nt.has(l)) {
513
- const d = `${t}////${h}`, e = r.getState().stateComponents.get(t);
526
+ if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !rt.has(l)) {
527
+ const u = `${t}////${v}`, e = r.getState().stateComponents.get(t);
514
528
  if (e) {
515
- const n = e.components.get(d);
529
+ const n = e.components.get(u);
516
530
  if (n && !n.paths.has("")) {
517
- const a = o.join(".");
531
+ const o = a.join(".");
518
532
  let c = !0;
519
- for (const S of n.paths)
520
- if (a.startsWith(S) && (a === S || a[S.length] === ".")) {
533
+ for (const m of n.paths)
534
+ if (o.startsWith(m) && (o === m || o[m.length] === ".")) {
521
535
  c = !1;
522
536
  break;
523
537
  }
524
- c && n.paths.add(a);
538
+ c && n.paths.add(o);
525
539
  }
526
540
  }
527
541
  }
528
542
  if (l === "getDifferences")
529
- return () => gt(
543
+ return () => St(
530
544
  r.getState().cogsStateStore[t],
531
545
  r.getState().initialStateGlobal[t]
532
546
  );
533
- if (l === "sync" && o.length === 0)
547
+ if (l === "sync" && a.length === 0)
534
548
  return async function() {
535
- const d = r.getState().getInitialOptions(t), e = d?.sync;
549
+ const u = r.getState().getInitialOptions(t), e = u?.sync;
536
550
  if (!e)
537
551
  return console.error(`No mutation defined for state key "${t}"`), { success: !1, error: "No mutation defined" };
538
- const n = r.getState().getNestedState(t, []), a = d?.validation?.key;
552
+ const n = r.getState().getNestedState(t, []), o = u?.validation?.key;
539
553
  try {
540
554
  const c = await e.action(n);
541
- if (c && !c.success && c.errors && a) {
542
- r.getState().removeValidationError(a), c.errors.forEach((u) => {
543
- const N = [a, ...u.path].join(".");
544
- r.getState().addValidationError(N, u.message);
555
+ if (c && !c.success && c.errors && o) {
556
+ r.getState().removeValidationError(o), c.errors.forEach((d) => {
557
+ const N = [o, ...d.path].join(".");
558
+ r.getState().addValidationError(N, d.message);
545
559
  });
546
- const S = r.getState().stateComponents.get(t);
547
- S && S.components.forEach((u) => {
548
- u.forceUpdate();
560
+ const m = r.getState().stateComponents.get(t);
561
+ m && m.components.forEach((d) => {
562
+ d.forceUpdate();
549
563
  });
550
564
  }
551
565
  return c?.success && e.onSuccess ? e.onSuccess(c.data) : !c?.success && e.onError && e.onError(c.error), c;
@@ -554,123 +568,123 @@ function at(t, i, h, f) {
554
568
  }
555
569
  };
556
570
  if (l === "_status") {
557
- const d = r.getState().getNestedState(t, o), e = r.getState().initialStateGlobal[t], n = B(e, o);
558
- return L(d, n) ? "fresh" : "stale";
571
+ const u = r.getState().getNestedState(t, a), e = r.getState().initialStateGlobal[t], n = B(e, a);
572
+ return L(u, n) ? "fresh" : "stale";
559
573
  }
560
574
  if (l === "getStatus")
561
575
  return function() {
562
- const d = r().getNestedState(
576
+ const u = r().getNestedState(
563
577
  t,
564
- o
565
- ), e = r.getState().initialStateGlobal[t], n = B(e, o);
566
- return L(d, n) ? "fresh" : "stale";
578
+ a
579
+ ), e = r.getState().initialStateGlobal[t], n = B(e, a);
580
+ return L(u, n) ? "fresh" : "stale";
567
581
  };
568
582
  if (l === "removeStorage")
569
583
  return () => {
570
- const d = r.getState().initialStateGlobal[t], e = Z(t), n = J(e?.localStorage?.key) ? e?.localStorage?.key(d) : e?.localStorage?.key, a = `${f}-${t}-${n}`;
571
- a && localStorage.removeItem(a);
584
+ const u = r.getState().initialStateGlobal[t], e = Q(t), n = J(e?.localStorage?.key) ? e?.localStorage?.key(u) : e?.localStorage?.key, o = `${g}-${t}-${n}`;
585
+ o && localStorage.removeItem(o);
572
586
  };
573
587
  if (l === "showValidationErrors")
574
588
  return () => {
575
- const d = r.getState().getInitialOptions(t)?.validation;
576
- if (!d?.key)
589
+ const u = r.getState().getInitialOptions(t)?.validation;
590
+ if (!u?.key)
577
591
  throw new Error("Validation key not found");
578
- return r.getState().getValidationErrors(d.key + "." + o.join("."));
592
+ return r.getState().getValidationErrors(u.key + "." + a.join("."));
579
593
  };
580
- if (Array.isArray(v)) {
581
- const d = () => g?.validIndices ? v.map((n, a) => ({
594
+ if (Array.isArray(h)) {
595
+ const u = () => S?.validIndices ? h.map((n, o) => ({
582
596
  item: n,
583
- originalIndex: g.validIndices[a]
584
- })) : r.getState().getNestedState(t, o).map((n, a) => ({
597
+ originalIndex: S.validIndices[o]
598
+ })) : r.getState().getNestedState(t, a).map((n, o) => ({
585
599
  item: n,
586
- originalIndex: a
600
+ originalIndex: o
587
601
  }));
588
602
  if (l === "getSelected")
589
603
  return () => {
590
- const e = r.getState().getSelectedIndex(t, o.join("."));
604
+ const e = r.getState().getSelectedIndex(t, a.join("."));
591
605
  if (e !== void 0)
592
606
  return s(
593
- v[e],
594
- [...o, e.toString()],
595
- g
607
+ h[e],
608
+ [...a, e.toString()],
609
+ S
596
610
  );
597
611
  };
598
612
  if (l === "clearSelected")
599
613
  return () => {
600
- r.getState().clearSelectedIndex({ stateKey: t, path: o });
614
+ r.getState().clearSelectedIndex({ stateKey: t, path: a });
601
615
  };
602
616
  if (l === "getSelectedIndex")
603
- return () => r.getState().getSelectedIndex(t, o.join(".")) ?? -1;
617
+ return () => r.getState().getSelectedIndex(t, a.join(".")) ?? -1;
604
618
  if (l === "useVirtualView")
605
619
  return (e) => {
606
620
  const {
607
621
  itemHeight: n,
608
- overscan: a = 5,
622
+ overscan: o = 5,
609
623
  stickToBottom: c = !1
610
- } = e, S = H(null), [u, N] = et({
624
+ } = e, m = H(null), [d, N] = nt({
611
625
  startIndex: 0,
612
626
  endIndex: 10
613
- }), p = H(c), A = H(0), C = H(!0), x = r().getNestedState(
627
+ }), w = H(c), T = H(0), P = H(!0), x = r().getNestedState(
614
628
  t,
615
- o
616
- ), V = x.length, D = At(() => {
617
- const T = Math.max(0, u.startIndex), w = Math.min(V, u.endIndex), P = Array.from(
618
- { length: w - T },
619
- (U, M) => T + M
620
- ), b = P.map((U) => x[U]);
621
- return s(b, o, {
622
- ...g,
623
- validIndices: P
629
+ a
630
+ ), V = x.length, W = Tt(() => {
631
+ const A = Math.max(0, d.startIndex), _ = Math.min(V, d.endIndex), E = Array.from(
632
+ { length: _ - A },
633
+ (b, j) => A + j
634
+ ), M = E.map((b) => x[b]);
635
+ return s(M, a, {
636
+ ...S,
637
+ validIndices: E
624
638
  });
625
- }, [u.startIndex, u.endIndex, x, V]);
639
+ }, [d.startIndex, d.endIndex, x, V]);
626
640
  ft(() => {
627
- const T = S.current;
628
- if (!T) return;
629
- const w = p.current, P = V > A.current;
630
- A.current = V;
631
- const b = () => {
632
- const { scrollTop: U, clientHeight: M, scrollHeight: Q } = T;
633
- p.current = Q - U - M < 10;
634
- const K = Math.max(
641
+ const A = m.current;
642
+ if (!A) return;
643
+ const _ = w.current, E = V > T.current;
644
+ T.current = V;
645
+ const M = () => {
646
+ const { scrollTop: b, clientHeight: j, scrollHeight: U } = A;
647
+ w.current = U - b - j < 10;
648
+ const X = Math.max(
635
649
  0,
636
- Math.floor(U / n) - a
637
- ), yt = Math.min(
650
+ Math.floor(b / n) - o
651
+ ), tt = Math.min(
638
652
  V,
639
- Math.ceil((U + M) / n) + a
653
+ Math.ceil((b + j) / n) + o
640
654
  );
641
- N((lt) => lt.startIndex !== K || lt.endIndex !== yt ? { startIndex: K, endIndex: yt } : lt);
655
+ N((dt) => dt.startIndex !== X || dt.endIndex !== tt ? { startIndex: X, endIndex: tt } : dt);
642
656
  };
643
- return T.addEventListener("scroll", b, {
657
+ return A.addEventListener("scroll", M, {
644
658
  passive: !0
645
- }), c && (C.current ? T.scrollTo({
646
- top: T.scrollHeight,
659
+ }), c && (P.current ? A.scrollTo({
660
+ top: A.scrollHeight,
647
661
  behavior: "auto"
648
- }) : w && P && requestAnimationFrame(() => {
649
- T.scrollTo({
650
- top: T.scrollHeight,
662
+ }) : _ && E && requestAnimationFrame(() => {
663
+ A.scrollTo({
664
+ top: A.scrollHeight,
651
665
  behavior: "smooth"
652
666
  });
653
- })), C.current = !1, b(), () => T.removeEventListener("scroll", b);
654
- }, [V, n, a, c]);
655
- const _ = ht(
656
- (T = "smooth") => {
657
- S.current && S.current.scrollTo({
658
- top: S.current.scrollHeight,
659
- behavior: T
667
+ })), P.current = !1, M(), () => A.removeEventListener("scroll", M);
668
+ }, [V, n, o, c]);
669
+ const q = vt(
670
+ (A = "smooth") => {
671
+ m.current && m.current.scrollTo({
672
+ top: m.current.scrollHeight,
673
+ behavior: A
660
674
  });
661
675
  },
662
676
  []
663
- ), k = ht(
664
- (T, w = "smooth") => {
665
- S.current && S.current.scrollTo({
666
- top: T * n,
667
- behavior: w
677
+ ), C = vt(
678
+ (A, _ = "smooth") => {
679
+ m.current && m.current.scrollTo({
680
+ top: A * n,
681
+ behavior: _
668
682
  });
669
683
  },
670
684
  [n]
671
- ), R = {
685
+ ), $ = {
672
686
  outer: {
673
- ref: S,
687
+ ref: m,
674
688
  style: { overflowY: "auto", height: "100%" }
675
689
  },
676
690
  inner: {
@@ -681,88 +695,88 @@ function at(t, i, h, f) {
681
695
  },
682
696
  list: {
683
697
  style: {
684
- transform: `translateY(${u.startIndex * n}px)`
698
+ transform: `translateY(${d.startIndex * n}px)`
685
699
  }
686
700
  }
687
701
  };
688
702
  return {
689
- virtualState: D,
690
- virtualizerProps: R,
691
- scrollToBottom: _,
692
- scrollToIndex: k
703
+ virtualState: W,
704
+ virtualizerProps: $,
705
+ scrollToBottom: q,
706
+ scrollToIndex: C
693
707
  };
694
708
  };
695
709
  if (l === "stateSort")
696
710
  return (e) => {
697
- const a = [...d()].sort(
698
- (u, N) => e(u.item, N.item)
699
- ), c = a.map(({ item: u }) => u), S = {
700
- ...g,
701
- validIndices: a.map(
702
- ({ originalIndex: u }) => u
711
+ const o = [...u()].sort(
712
+ (d, N) => e(d.item, N.item)
713
+ ), c = o.map(({ item: d }) => d), m = {
714
+ ...S,
715
+ validIndices: o.map(
716
+ ({ originalIndex: d }) => d
703
717
  )
704
718
  };
705
- return s(c, o, S);
719
+ return s(c, a, m);
706
720
  };
707
721
  if (l === "stateFilter")
708
722
  return (e) => {
709
- const a = d().filter(
710
- ({ item: u }, N) => e(u, N)
711
- ), c = a.map(({ item: u }) => u), S = {
712
- ...g,
713
- validIndices: a.map(
714
- ({ originalIndex: u }) => u
723
+ const o = u().filter(
724
+ ({ item: d }, N) => e(d, N)
725
+ ), c = o.map(({ item: d }) => d), m = {
726
+ ...S,
727
+ validIndices: o.map(
728
+ ({ originalIndex: d }) => d
715
729
  )
716
730
  };
717
- return s(c, o, S);
731
+ return s(c, a, m);
718
732
  };
719
733
  if (l === "stateMap")
720
734
  return (e) => {
721
- const n = r.getState().getNestedState(t, o);
722
- return Array.isArray(n) ? (g?.validIndices || Array.from({ length: n.length }, (c, S) => S)).map((c, S) => {
723
- const u = n[c], N = [...o, c.toString()], p = s(u, N, g);
724
- return e(u, p, {
735
+ const n = r.getState().getNestedState(t, a);
736
+ return Array.isArray(n) ? (S?.validIndices || Array.from({ length: n.length }, (c, m) => m)).map((c, m) => {
737
+ const d = n[c], N = [...a, c.toString()], w = s(d, N, S);
738
+ return e(d, w, {
725
739
  register: () => {
726
- const [, C] = et({}), x = `${h}-${o.join(".")}-${c}`;
740
+ const [, P] = nt({}), x = `${v}-${a.join(".")}-${c}`;
727
741
  ft(() => {
728
- const V = `${t}////${x}`, D = r.getState().stateComponents.get(t) || {
742
+ const V = `${t}////${x}`, W = r.getState().stateComponents.get(t) || {
729
743
  components: /* @__PURE__ */ new Map()
730
744
  };
731
- return D.components.set(V, {
732
- forceUpdate: () => C({}),
745
+ return W.components.set(V, {
746
+ forceUpdate: () => P({}),
733
747
  paths: /* @__PURE__ */ new Set([N.join(".")])
734
- }), r.getState().stateComponents.set(t, D), () => {
735
- const _ = r.getState().stateComponents.get(t);
736
- _ && _.components.delete(V);
748
+ }), r.getState().stateComponents.set(t, W), () => {
749
+ const q = r.getState().stateComponents.get(t);
750
+ q && q.components.delete(V);
737
751
  };
738
752
  }, [t, x]);
739
753
  },
740
- index: S,
754
+ index: m,
741
755
  originalIndex: c
742
756
  });
743
757
  }) : (console.warn(
744
- `stateMap called on a non-array value at path: ${o.join(".")}. The current value is:`,
758
+ `stateMap called on a non-array value at path: ${a.join(".")}. The current value is:`,
745
759
  n
746
760
  ), null);
747
761
  };
748
762
  if (l === "stateMapNoRender")
749
- return (e) => v.map((a, c) => {
750
- let S;
751
- g?.validIndices && g.validIndices[c] !== void 0 ? S = g.validIndices[c] : S = c;
752
- const u = [...o, S.toString()], N = s(a, u, g);
763
+ return (e) => h.map((o, c) => {
764
+ let m;
765
+ S?.validIndices && S.validIndices[c] !== void 0 ? m = S.validIndices[c] : m = c;
766
+ const d = [...a, m.toString()], N = s(o, d, S);
753
767
  return e(
754
- a,
768
+ o,
755
769
  N,
756
770
  c,
757
- v,
758
- s(v, o, g)
771
+ h,
772
+ s(h, a, S)
759
773
  );
760
774
  });
761
775
  if (l === "$stateMap")
762
- return (e) => st(Lt, {
776
+ return (e) => it(Lt, {
763
777
  proxy: {
764
778
  _stateKey: t,
765
- _path: o,
779
+ _path: a,
766
780
  _mapFn: e
767
781
  // Pass the actual function, not string
768
782
  },
@@ -770,244 +784,244 @@ function at(t, i, h, f) {
770
784
  });
771
785
  if (l === "stateFlattenOn")
772
786
  return (e) => {
773
- const n = v;
774
- y.clear(), $++;
775
- const a = n.flatMap(
787
+ const n = h;
788
+ y.clear(), k++;
789
+ const o = n.flatMap(
776
790
  (c) => c[e] ?? []
777
791
  );
778
792
  return s(
779
- a,
780
- [...o, "[*]", e],
781
- g
793
+ o,
794
+ [...a, "[*]", e],
795
+ S
782
796
  );
783
797
  };
784
798
  if (l === "index")
785
799
  return (e) => {
786
- const n = v[e];
787
- return s(n, [...o, e.toString()]);
800
+ const n = h[e];
801
+ return s(n, [...a, e.toString()]);
788
802
  };
789
803
  if (l === "last")
790
804
  return () => {
791
- const e = r.getState().getNestedState(t, o);
805
+ const e = r.getState().getNestedState(t, a);
792
806
  if (e.length === 0) return;
793
- const n = e.length - 1, a = e[n], c = [...o, n.toString()];
794
- return s(a, c);
807
+ const n = e.length - 1, o = e[n], c = [...a, n.toString()];
808
+ return s(o, c);
795
809
  };
796
810
  if (l === "insert")
797
- return (e) => (E(o), dt(i, e, o, t), s(
798
- r.getState().getNestedState(t, o),
799
- o
811
+ return (e) => (p(a), ut(i, e, a, t), s(
812
+ r.getState().getNestedState(t, a),
813
+ a
800
814
  ));
801
815
  if (l === "uniqueInsert")
802
- return (e, n, a) => {
803
- const c = r.getState().getNestedState(t, o), S = J(e) ? e(c) : e;
804
- let u = null;
805
- if (!c.some((p) => {
816
+ return (e, n, o) => {
817
+ const c = r.getState().getNestedState(t, a), m = J(e) ? e(c) : e;
818
+ let d = null;
819
+ if (!c.some((w) => {
806
820
  if (n) {
807
- const C = n.every(
808
- (x) => L(p[x], S[x])
821
+ const P = n.every(
822
+ (x) => L(w[x], m[x])
809
823
  );
810
- return C && (u = p), C;
824
+ return P && (d = w), P;
811
825
  }
812
- const A = L(p, S);
813
- return A && (u = p), A;
826
+ const T = L(w, m);
827
+ return T && (d = w), T;
814
828
  }))
815
- E(o), dt(i, S, o, t);
816
- else if (a && u) {
817
- const p = a(u), A = c.map(
818
- (C) => L(C, u) ? p : C
829
+ p(a), ut(i, m, a, t);
830
+ else if (o && d) {
831
+ const w = o(d), T = c.map(
832
+ (P) => L(P, d) ? w : P
819
833
  );
820
- E(o), tt(i, A, o);
834
+ p(a), et(i, T, a);
821
835
  }
822
836
  };
823
837
  if (l === "cut")
824
838
  return (e, n) => {
825
839
  if (!n?.waitForSync)
826
- return E(o), rt(i, o, t, e), s(
827
- r.getState().getNestedState(t, o),
828
- o
840
+ return p(a), at(i, a, t, e), s(
841
+ r.getState().getNestedState(t, a),
842
+ a
829
843
  );
830
844
  };
831
845
  if (l === "cutByValue")
832
846
  return (e) => {
833
- for (let n = 0; n < v.length; n++)
834
- v[n] === e && rt(i, o, t, n);
847
+ for (let n = 0; n < h.length; n++)
848
+ h[n] === e && at(i, a, t, n);
835
849
  };
836
850
  if (l === "toggleByValue")
837
851
  return (e) => {
838
- const n = v.findIndex((a) => a === e);
839
- n > -1 ? rt(i, o, t, n) : dt(i, e, o, t);
852
+ const n = h.findIndex((o) => o === e);
853
+ n > -1 ? at(i, a, t, n) : ut(i, e, a, t);
840
854
  };
841
855
  if (l === "stateFind")
842
856
  return (e) => {
843
- const a = d().find(
844
- ({ item: S }, u) => e(S, u)
857
+ const o = u().find(
858
+ ({ item: m }, d) => e(m, d)
845
859
  );
846
- if (!a) return;
847
- const c = [...o, a.originalIndex.toString()];
848
- return s(a.item, c, g);
860
+ if (!o) return;
861
+ const c = [...a, o.originalIndex.toString()];
862
+ return s(o.item, c, S);
849
863
  };
850
864
  if (l === "findWith")
851
865
  return (e, n) => {
852
- const c = d().find(
853
- ({ item: u }) => u[e] === n
866
+ const c = u().find(
867
+ ({ item: d }) => d[e] === n
854
868
  );
855
869
  if (!c) return;
856
- const S = [...o, c.originalIndex.toString()];
857
- return s(c.item, S, g);
870
+ const m = [...a, c.originalIndex.toString()];
871
+ return s(c.item, m, S);
858
872
  };
859
873
  }
860
- const q = o[o.length - 1];
861
- if (!isNaN(Number(q))) {
862
- const d = o.slice(0, -1), e = r.getState().getNestedState(t, d);
874
+ const Y = a[a.length - 1];
875
+ if (!isNaN(Number(Y))) {
876
+ const u = a.slice(0, -1), e = r.getState().getNestedState(t, u);
863
877
  if (Array.isArray(e) && l === "cut")
864
- return () => rt(
878
+ return () => at(
865
879
  i,
866
- d,
880
+ u,
867
881
  t,
868
- Number(q)
882
+ Number(Y)
869
883
  );
870
884
  }
871
885
  if (l === "get")
872
886
  return () => {
873
- if (g?.validIndices && Array.isArray(v)) {
874
- const d = r.getState().getNestedState(t, o);
875
- return g.validIndices.map((e) => d[e]);
887
+ if (S?.validIndices && Array.isArray(h)) {
888
+ const u = r.getState().getNestedState(t, a);
889
+ return S.validIndices.map((e) => u[e]);
876
890
  }
877
- return r.getState().getNestedState(t, o);
891
+ return r.getState().getNestedState(t, a);
878
892
  };
879
893
  if (l === "$derive")
880
- return (d) => Tt({
894
+ return (u) => At({
881
895
  _stateKey: t,
882
- _path: o,
883
- _effect: d.toString()
896
+ _path: a,
897
+ _effect: u.toString()
884
898
  });
885
899
  if (l === "$get")
886
- return () => Tt({
900
+ return () => At({
887
901
  _stateKey: t,
888
- _path: o
902
+ _path: a
889
903
  });
890
904
  if (l === "lastSynced") {
891
- const d = `${t}:${o.join(".")}`;
892
- return r.getState().getSyncInfo(d);
905
+ const u = `${t}:${a.join(".")}`;
906
+ return r.getState().getSyncInfo(u);
893
907
  }
894
908
  if (l == "getLocalStorage")
895
- return (d) => it(f + "-" + t + "-" + d);
909
+ return (u) => ct(g + "-" + t + "-" + u);
896
910
  if (l === "_selected") {
897
- const d = o.slice(0, -1), e = d.join("."), n = r.getState().getNestedState(t, d);
898
- return Array.isArray(n) ? Number(o[o.length - 1]) === r.getState().getSelectedIndex(t, e) : void 0;
911
+ const u = a.slice(0, -1), e = u.join("."), n = r.getState().getNestedState(t, u);
912
+ return Array.isArray(n) ? Number(a[a.length - 1]) === r.getState().getSelectedIndex(t, e) : void 0;
899
913
  }
900
914
  if (l === "setSelected")
901
- return (d) => {
902
- const e = o.slice(0, -1), n = Number(o[o.length - 1]), a = e.join(".");
903
- d ? r.getState().setSelectedIndex(t, a, n) : r.getState().setSelectedIndex(t, a, void 0);
915
+ return (u) => {
916
+ const e = a.slice(0, -1), n = Number(a[a.length - 1]), o = e.join(".");
917
+ u ? r.getState().setSelectedIndex(t, o, n) : r.getState().setSelectedIndex(t, o, void 0);
904
918
  const c = r.getState().getNestedState(t, [...e]);
905
- tt(i, c, e), E(e);
919
+ et(i, c, e), p(e);
906
920
  };
907
921
  if (l === "toggleSelected")
908
922
  return () => {
909
- const d = o.slice(0, -1), e = Number(o[o.length - 1]), n = d.join("."), a = r.getState().getSelectedIndex(t, n);
923
+ const u = a.slice(0, -1), e = Number(a[a.length - 1]), n = u.join("."), o = r.getState().getSelectedIndex(t, n);
910
924
  r.getState().setSelectedIndex(
911
925
  t,
912
926
  n,
913
- a === e ? void 0 : e
927
+ o === e ? void 0 : e
914
928
  );
915
- const c = r.getState().getNestedState(t, [...d]);
916
- tt(i, c, d), E(d);
929
+ const c = r.getState().getNestedState(t, [...u]);
930
+ et(i, c, u), p(u);
917
931
  };
918
- if (o.length == 0) {
932
+ if (a.length == 0) {
919
933
  if (l === "applyJsonPatch")
920
- return (d) => {
921
- const e = r.getState().cogsStateStore[t], a = Ot(e, d).newDocument;
934
+ return (u) => {
935
+ const e = r.getState().cogsStateStore[t], o = Ot(e, u).newDocument;
922
936
  xt(
923
937
  t,
924
938
  r.getState().initialStateGlobal[t],
925
- a,
939
+ o,
926
940
  i,
927
- h,
928
- f
941
+ v,
942
+ g
929
943
  );
930
944
  const c = r.getState().stateComponents.get(t);
931
945
  if (c) {
932
- const S = gt(e, a), u = new Set(S);
946
+ const m = St(e, o), d = new Set(m);
933
947
  for (const [
934
948
  N,
935
- p
949
+ w
936
950
  ] of c.components.entries()) {
937
- let A = !1;
938
- const C = Array.isArray(p.reactiveType) ? p.reactiveType : [p.reactiveType || "component"];
939
- if (!C.includes("none")) {
940
- if (C.includes("all")) {
941
- p.forceUpdate();
951
+ let T = !1;
952
+ const P = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
953
+ if (!P.includes("none")) {
954
+ if (P.includes("all")) {
955
+ w.forceUpdate();
942
956
  continue;
943
957
  }
944
- if (C.includes("component") && (p.paths.has("") && (A = !0), !A))
945
- for (const x of u) {
946
- if (p.paths.has(x)) {
947
- A = !0;
958
+ if (P.includes("component") && (w.paths.has("") && (T = !0), !T))
959
+ for (const x of d) {
960
+ if (w.paths.has(x)) {
961
+ T = !0;
948
962
  break;
949
963
  }
950
964
  let V = x.lastIndexOf(".");
951
965
  for (; V !== -1; ) {
952
- const D = x.substring(0, V);
953
- if (p.paths.has(D)) {
954
- A = !0;
966
+ const W = x.substring(0, V);
967
+ if (w.paths.has(W)) {
968
+ T = !0;
955
969
  break;
956
970
  }
957
- const _ = x.substring(
971
+ const q = x.substring(
958
972
  V + 1
959
973
  );
960
- if (!isNaN(Number(_))) {
961
- const k = D.lastIndexOf(".");
962
- if (k !== -1) {
963
- const R = D.substring(
974
+ if (!isNaN(Number(q))) {
975
+ const C = W.lastIndexOf(".");
976
+ if (C !== -1) {
977
+ const $ = W.substring(
964
978
  0,
965
- k
979
+ C
966
980
  );
967
- if (p.paths.has(R)) {
968
- A = !0;
981
+ if (w.paths.has($)) {
982
+ T = !0;
969
983
  break;
970
984
  }
971
985
  }
972
986
  }
973
- V = D.lastIndexOf(".");
987
+ V = W.lastIndexOf(".");
974
988
  }
975
- if (A) break;
989
+ if (T) break;
976
990
  }
977
- if (!A && C.includes("deps") && p.depsFunction) {
978
- const x = p.depsFunction(a);
991
+ if (!T && P.includes("deps") && w.depsFunction) {
992
+ const x = w.depsFunction(o);
979
993
  let V = !1;
980
- typeof x == "boolean" ? x && (V = !0) : L(p.deps, x) || (p.deps = x, V = !0), V && (A = !0);
994
+ typeof x == "boolean" ? x && (V = !0) : L(w.deps, x) || (w.deps = x, V = !0), V && (T = !0);
981
995
  }
982
- A && p.forceUpdate();
996
+ T && w.forceUpdate();
983
997
  }
984
998
  }
985
999
  }
986
1000
  };
987
1001
  if (l === "validateZodSchema")
988
1002
  return () => {
989
- const d = r.getState().getInitialOptions(t)?.validation, e = r.getState().addValidationError;
990
- if (!d?.zodSchema)
1003
+ const u = r.getState().getInitialOptions(t)?.validation, e = r.getState().addValidationError;
1004
+ if (!u?.zodSchema)
991
1005
  throw new Error("Zod schema not found");
992
- if (!d?.key)
1006
+ if (!u?.key)
993
1007
  throw new Error("Validation key not found");
994
- z(d.key);
1008
+ z(u.key);
995
1009
  const n = r.getState().cogsStateStore[t];
996
1010
  try {
997
- const a = r.getState().getValidationErrors(d.key);
998
- a && a.length > 0 && a.forEach(([S]) => {
999
- S && S.startsWith(d.key) && z(S);
1011
+ const o = r.getState().getValidationErrors(u.key);
1012
+ o && o.length > 0 && o.forEach(([m]) => {
1013
+ m && m.startsWith(u.key) && z(m);
1000
1014
  });
1001
- const c = d.zodSchema.safeParse(n);
1002
- return c.success ? !0 : (c.error.errors.forEach((u) => {
1003
- const N = u.path, p = u.message, A = [d.key, ...N].join(".");
1004
- e(A, p);
1005
- }), ct(t), !1);
1006
- } catch (a) {
1007
- return console.error("Zod schema validation failed", a), !1;
1015
+ const c = u.zodSchema.safeParse(n);
1016
+ return c.success ? !0 : (c.error.errors.forEach((d) => {
1017
+ const N = d.path, w = d.message, T = [u.key, ...N].join(".");
1018
+ e(T, w);
1019
+ }), lt(t), !1);
1020
+ } catch (o) {
1021
+ return console.error("Zod schema validation failed", o), !1;
1008
1022
  }
1009
1023
  };
1010
- if (l === "_componentId") return h;
1024
+ if (l === "_componentId") return v;
1011
1025
  if (l === "getComponents")
1012
1026
  return () => r().stateComponents.get(t);
1013
1027
  if (l === "getAllFormRefs")
@@ -1024,136 +1038,136 @@ function at(t, i, h, f) {
1024
1038
  if (l === "removeValidation") return I.removeValidation;
1025
1039
  }
1026
1040
  if (l === "getFormRef")
1027
- return () => It.getState().getFormRef(t + "." + o.join("."));
1041
+ return () => It.getState().getFormRef(t + "." + a.join("."));
1028
1042
  if (l === "validationWrapper")
1029
1043
  return ({
1030
- children: d,
1044
+ children: u,
1031
1045
  hideMessage: e
1032
- }) => /* @__PURE__ */ vt(
1033
- Pt,
1046
+ }) => /* @__PURE__ */ ht(
1047
+ Ct,
1034
1048
  {
1035
1049
  formOpts: e ? { validation: { message: "" } } : void 0,
1036
- path: o,
1050
+ path: a,
1037
1051
  validationKey: r.getState().getInitialOptions(t)?.validation?.key || "",
1038
1052
  stateKey: t,
1039
- validIndices: g?.validIndices,
1040
- children: d
1053
+ validIndices: S?.validIndices,
1054
+ children: u
1041
1055
  }
1042
1056
  );
1043
1057
  if (l === "_stateKey") return t;
1044
- if (l === "_path") return o;
1058
+ if (l === "_path") return a;
1045
1059
  if (l === "_isServerSynced") return I._isServerSynced;
1046
1060
  if (l === "update")
1047
- return (d, e) => {
1061
+ return (u, e) => {
1048
1062
  if (e?.debounce)
1049
- Ct(() => {
1050
- tt(i, d, o, "");
1051
- const n = r.getState().getNestedState(t, o);
1063
+ Pt(() => {
1064
+ et(i, u, a, "");
1065
+ const n = r.getState().getNestedState(t, a);
1052
1066
  e?.afterUpdate && e.afterUpdate(n);
1053
1067
  }, e.debounce);
1054
1068
  else {
1055
- tt(i, d, o, "");
1056
- const n = r.getState().getNestedState(t, o);
1069
+ et(i, u, a, "");
1070
+ const n = r.getState().getNestedState(t, a);
1057
1071
  e?.afterUpdate && e.afterUpdate(n);
1058
1072
  }
1059
- E(o);
1073
+ p(a);
1060
1074
  };
1061
1075
  if (l === "formElement")
1062
- return (d, e) => /* @__PURE__ */ vt(
1076
+ return (u, e) => /* @__PURE__ */ ht(
1063
1077
  _t,
1064
1078
  {
1065
1079
  setState: i,
1066
1080
  stateKey: t,
1067
- path: o,
1068
- child: d,
1081
+ path: a,
1082
+ child: u,
1069
1083
  formOpts: e
1070
1084
  }
1071
1085
  );
1072
- const O = [...o, l], X = r.getState().getNestedState(t, O);
1073
- return s(X, O, g);
1086
+ const O = [...a, l], K = r.getState().getNestedState(t, O);
1087
+ return s(K, O, S);
1074
1088
  }
1075
- }, W = new Proxy(j, F);
1076
- return y.set(G, {
1077
- proxy: W,
1078
- stateVersion: $
1079
- }), W;
1089
+ }, G = new Proxy(R, F);
1090
+ return y.set(D, {
1091
+ proxy: G,
1092
+ stateVersion: k
1093
+ }), G;
1080
1094
  }
1081
1095
  return s(
1082
1096
  r.getState().getNestedState(t, [])
1083
1097
  );
1084
1098
  }
1085
- function Tt(t) {
1086
- return st(Bt, { proxy: t });
1099
+ function At(t) {
1100
+ return it(Bt, { proxy: t });
1087
1101
  }
1088
1102
  function Lt({
1089
1103
  proxy: t,
1090
1104
  rebuildStateShape: i
1091
1105
  }) {
1092
- const h = r().getNestedState(t._stateKey, t._path);
1093
- return Array.isArray(h) ? i(
1094
- h,
1106
+ const v = r().getNestedState(t._stateKey, t._path);
1107
+ return Array.isArray(v) ? i(
1108
+ v,
1095
1109
  t._path
1096
1110
  ).stateMapNoRender(
1097
- (y, $, E, I, s) => t._mapFn(y, $, E, I, s)
1111
+ (y, k, p, I, s) => t._mapFn(y, k, p, I, s)
1098
1112
  ) : null;
1099
1113
  }
1100
1114
  function Bt({
1101
1115
  proxy: t
1102
1116
  }) {
1103
- const i = H(null), h = `${t._stateKey}-${t._path.join(".")}`;
1104
- return ut(() => {
1105
- const f = i.current;
1106
- if (!f || !f.parentElement) return;
1107
- const y = f.parentElement, E = Array.from(y.childNodes).indexOf(f);
1117
+ const i = H(null), v = `${t._stateKey}-${t._path.join(".")}`;
1118
+ return gt(() => {
1119
+ const g = i.current;
1120
+ if (!g || !g.parentElement) return;
1121
+ const y = g.parentElement, p = Array.from(y.childNodes).indexOf(g);
1108
1122
  let I = y.getAttribute("data-parent-id");
1109
1123
  I || (I = `parent-${crypto.randomUUID()}`, y.setAttribute("data-parent-id", I));
1110
- const v = {
1124
+ const h = {
1111
1125
  instanceId: `instance-${crypto.randomUUID()}`,
1112
1126
  parentId: I,
1113
- position: E,
1127
+ position: p,
1114
1128
  effect: t._effect
1115
1129
  };
1116
- r.getState().addSignalElement(h, v);
1117
- const o = r.getState().getNestedState(t._stateKey, t._path);
1118
- let g;
1130
+ r.getState().addSignalElement(v, h);
1131
+ const a = r.getState().getNestedState(t._stateKey, t._path);
1132
+ let S;
1119
1133
  if (t._effect)
1120
1134
  try {
1121
- g = new Function(
1135
+ S = new Function(
1122
1136
  "state",
1123
1137
  `return (${t._effect})(state)`
1124
- )(o);
1125
- } catch (j) {
1126
- console.error("Error evaluating effect function during mount:", j), g = o;
1138
+ )(a);
1139
+ } catch (R) {
1140
+ console.error("Error evaluating effect function during mount:", R), S = a;
1127
1141
  }
1128
1142
  else
1129
- g = o;
1130
- g !== null && typeof g == "object" && (g = JSON.stringify(g));
1131
- const G = document.createTextNode(String(g));
1132
- f.replaceWith(G);
1133
- }, [t._stateKey, t._path.join("."), t._effect]), st("span", {
1143
+ S = a;
1144
+ S !== null && typeof S == "object" && (S = JSON.stringify(S));
1145
+ const D = document.createTextNode(String(S));
1146
+ g.replaceWith(D);
1147
+ }, [t._stateKey, t._path.join("."), t._effect]), it("span", {
1134
1148
  ref: i,
1135
1149
  style: { display: "none" },
1136
- "data-signal-id": h
1150
+ "data-signal-id": v
1137
1151
  });
1138
1152
  }
1139
- function oe(t) {
1153
+ function ae(t) {
1140
1154
  const i = Nt(
1141
- (h) => {
1142
- const f = r.getState().stateComponents.get(t._stateKey) || {
1155
+ (v) => {
1156
+ const g = r.getState().stateComponents.get(t._stateKey) || {
1143
1157
  components: /* @__PURE__ */ new Map()
1144
1158
  };
1145
- return f.components.set(t._stateKey, {
1146
- forceUpdate: h,
1159
+ return g.components.set(t._stateKey, {
1160
+ forceUpdate: v,
1147
1161
  paths: /* @__PURE__ */ new Set([t._path.join(".")])
1148
- }), () => f.components.delete(t._stateKey);
1162
+ }), () => g.components.delete(t._stateKey);
1149
1163
  },
1150
1164
  () => r.getState().getNestedState(t._stateKey, t._path)
1151
1165
  );
1152
- return st("text", {}, String(i));
1166
+ return it("text", {}, String(i));
1153
1167
  }
1154
1168
  export {
1155
- Tt as $cogsSignal,
1156
- oe as $cogsSignalStore,
1169
+ At as $cogsSignal,
1170
+ ae as $cogsSignalStore,
1157
1171
  ee as addStateOptions,
1158
1172
  ne as createCogsState,
1159
1173
  re as notifyComponent,