cogsbox-state 0.5.389 → 0.5.390

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,63 +1,63 @@
1
1
  "use client";
2
- import { jsx as Oe } from "react/jsx-runtime";
3
- import { useState as K, useRef as q, useEffect as oe, useLayoutEffect as ce, useMemo as we, createElement as le, useSyncExternalStore as je, startTransition as He, useCallback as ke } from "react";
4
- import { transformStateFunc as Fe, isDeepEqual as J, isFunction as ee, getNestedValue as Z, getDifferences as _e, debounce as Be } from "./utility.js";
5
- import { pushFunc as Ee, updateFn as ie, cutFunc as me, ValidationWrapper as We, FormControlComponent as ze } from "./Functions.jsx";
6
- import qe from "superjson";
7
- import { v4 as Ae } from "uuid";
2
+ import { jsx as Ot } from "react/jsx-runtime";
3
+ import { useState as K, useRef as q, useEffect as ot, useLayoutEffect as ct, useMemo as wt, createElement as lt, useSyncExternalStore as Ht, startTransition as Ft, useCallback as kt } from "react";
4
+ import { transformStateFunc as Bt, isDeepEqual as J, isFunction as tt, getNestedValue as Z, getDifferences as _t, debounce as Wt } from "./utility.js";
5
+ import { pushFunc as Et, updateFn as it, cutFunc as ht, ValidationWrapper as zt, FormControlComponent as qt } from "./Functions.jsx";
6
+ import Jt from "superjson";
7
+ import { v4 as At } from "uuid";
8
8
  import "zod";
9
- import { getGlobalStore as o, formRefStore as be } from "./store.js";
10
- import { useCogsConfig as Ge } from "./CogsStateClient.jsx";
11
- import { applyPatch as Je } from "fast-json-patch";
12
- import Ye from "react-use-measure";
13
- function Me(e, i) {
14
- const m = o.getState().getInitialOptions, g = o.getState().setInitialStateOptions, I = m(e) || {};
15
- g(e, {
16
- ...I,
9
+ import { getGlobalStore as o, formRefStore as bt } from "./store.js";
10
+ import { useCogsConfig as Gt } from "./CogsStateClient.jsx";
11
+ import { applyPatch as Yt } from "fast-json-patch";
12
+ import Zt from "react-use-measure";
13
+ function Mt(t, i) {
14
+ const m = o.getState().getInitialOptions, g = o.getState().setInitialStateOptions, T = m(t) || {};
15
+ g(t, {
16
+ ...T,
17
17
  ...i
18
18
  });
19
19
  }
20
- function xe({
21
- stateKey: e,
20
+ function xt({
21
+ stateKey: t,
22
22
  options: i,
23
23
  initialOptionsPart: m
24
24
  }) {
25
- const g = re(e) || {}, I = m[e] || {}, N = o.getState().setInitialStateOptions, p = { ...I, ...g };
25
+ const g = rt(t) || {}, T = m[t] || {}, N = o.getState().setInitialStateOptions, p = { ...T, ...g };
26
26
  let v = !1;
27
27
  if (i)
28
28
  for (const s in i)
29
29
  p.hasOwnProperty(s) ? (s == "localStorage" && i[s] && p[s].key !== i[s]?.key && (v = !0, p[s] = i[s]), s == "initialState" && i[s] && p[s] !== i[s] && // Different references
30
30
  !J(p[s], i[s]) && (v = !0, p[s] = i[s])) : (v = !0, p[s] = i[s]);
31
- v && N(e, p);
31
+ v && N(t, p);
32
32
  }
33
- function It(e, { formElements: i, validation: m }) {
34
- return { initialState: e, formElements: i, validation: m };
33
+ function Te(t, { formElements: i, validation: m }) {
34
+ return { initialState: t, formElements: i, validation: m };
35
35
  }
36
- const vt = (e, i) => {
37
- let m = e;
38
- const [g, I] = Fe(m);
39
- (Object.keys(I).length > 0 || i && Object.keys(i).length > 0) && Object.keys(I).forEach((v) => {
40
- I[v] = I[v] || {}, I[v].formElements = {
36
+ const ve = (t, i) => {
37
+ let m = t;
38
+ const [g, T] = Bt(m);
39
+ (Object.keys(T).length > 0 || i && Object.keys(i).length > 0) && Object.keys(T).forEach((v) => {
40
+ T[v] = T[v] || {}, T[v].formElements = {
41
41
  ...i?.formElements,
42
42
  // Global defaults first
43
43
  ...i?.validation,
44
- ...I[v].formElements || {}
44
+ ...T[v].formElements || {}
45
45
  // State-specific overrides
46
- }, re(v) || o.getState().setInitialStateOptions(v, I[v]);
46
+ }, rt(v) || o.getState().setInitialStateOptions(v, T[v]);
47
47
  }), o.getState().setInitialStates(g), o.getState().setCreatedState(g);
48
48
  const N = (v, s) => {
49
- const [T] = K(s?.componentId ?? Ae());
50
- xe({
49
+ const [I] = K(s?.componentId ?? At());
50
+ xt({
51
51
  stateKey: v,
52
52
  options: s,
53
- initialOptionsPart: I
53
+ initialOptionsPart: T
54
54
  });
55
- const n = o.getState().cogsStateStore[v] || g[v], S = s?.modifyState ? s.modifyState(n) : n, [W, U] = nt(
55
+ const r = o.getState().cogsStateStore[v] || g[v], S = s?.modifyState ? s.modifyState(r) : r, [W, j] = ne(
56
56
  S,
57
57
  {
58
58
  stateKey: v,
59
59
  syncUpdate: s?.syncUpdate,
60
- componentId: T,
60
+ componentId: I,
61
61
  localStorage: s?.localStorage,
62
62
  middleware: s?.middleware,
63
63
  enabledSync: s?.enabledSync,
@@ -68,80 +68,80 @@ const vt = (e, i) => {
68
68
  serverState: s?.serverState
69
69
  }
70
70
  );
71
- return U;
71
+ return j;
72
72
  };
73
73
  function p(v, s) {
74
- xe({ stateKey: v, options: s, initialOptionsPart: I }), s.localStorage && et(v, s), ve(v);
74
+ xt({ stateKey: v, options: s, initialOptionsPart: T }), s.localStorage && te(v, s), dt(v);
75
75
  }
76
76
  return { useCogsState: N, setCogsOptions: p };
77
77
  }, {
78
- setUpdaterState: he,
79
- setState: ne,
80
- getInitialOptions: re,
81
- getKeyState: Le,
82
- getValidationErrors: Ze,
83
- setStateLog: Xe,
84
- updateInitialStateGlobal: Ne,
85
- addValidationError: Qe,
86
- removeValidationError: Q,
87
- setServerSyncActions: Ke
88
- } = o.getState(), Pe = (e, i, m, g, I) => {
78
+ setUpdaterState: It,
79
+ setState: nt,
80
+ getInitialOptions: rt,
81
+ getKeyState: Lt,
82
+ getValidationErrors: Xt,
83
+ setStateLog: Qt,
84
+ updateInitialStateGlobal: Nt,
85
+ addValidationError: Rt,
86
+ removeValidationError: X,
87
+ setServerSyncActions: Kt
88
+ } = o.getState(), Pt = (t, i, m, g, T) => {
89
89
  m?.log && console.log(
90
90
  "saving to localstorage",
91
91
  i,
92
92
  m.localStorage?.key,
93
93
  g
94
94
  );
95
- const N = ee(m?.localStorage?.key) ? m.localStorage?.key(e) : m?.localStorage?.key;
95
+ const N = tt(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
96
96
  if (N && g) {
97
97
  const p = `${g}-${i}-${N}`;
98
98
  let v;
99
99
  try {
100
- v = Ie(p)?.lastSyncedWithServer;
100
+ v = vt(p)?.lastSyncedWithServer;
101
101
  } catch {
102
102
  }
103
103
  const s = {
104
- state: e,
104
+ state: t,
105
105
  lastUpdated: Date.now(),
106
- lastSyncedWithServer: I ?? v
107
- }, T = qe.serialize(s);
106
+ lastSyncedWithServer: T ?? v
107
+ }, I = Jt.serialize(s);
108
108
  window.localStorage.setItem(
109
109
  p,
110
- JSON.stringify(T.json)
110
+ JSON.stringify(I.json)
111
111
  );
112
112
  }
113
- }, Ie = (e) => {
114
- if (!e) return null;
113
+ }, vt = (t) => {
114
+ if (!t) return null;
115
115
  try {
116
- const i = window.localStorage.getItem(e);
116
+ const i = window.localStorage.getItem(t);
117
117
  return i ? JSON.parse(i) : null;
118
118
  } catch (i) {
119
119
  return console.error("Error loading from localStorage:", i), null;
120
120
  }
121
- }, et = (e, i) => {
122
- const m = o.getState().cogsStateStore[e], { sessionId: g } = Ge(), I = ee(i?.localStorage?.key) ? i.localStorage.key(m) : i?.localStorage?.key;
123
- if (I && g) {
124
- const N = Ie(
125
- `${g}-${e}-${I}`
121
+ }, te = (t, i) => {
122
+ const m = o.getState().cogsStateStore[t], { sessionId: g } = Gt(), T = tt(i?.localStorage?.key) ? i.localStorage.key(m) : i?.localStorage?.key;
123
+ if (T && g) {
124
+ const N = vt(
125
+ `${g}-${t}-${T}`
126
126
  );
127
127
  if (N && N.lastUpdated > (N.lastSyncedWithServer || 0))
128
- return ne(e, N.state), ve(e), !0;
128
+ return nt(t, N.state), dt(t), !0;
129
129
  }
130
130
  return !1;
131
- }, Re = (e, i, m, g, I, N) => {
131
+ }, Dt = (t, i, m, g, T, N) => {
132
132
  const p = {
133
133
  initialState: i,
134
- updaterState: Te(
135
- e,
134
+ updaterState: Tt(
135
+ t,
136
136
  g,
137
- I,
137
+ T,
138
138
  N
139
139
  ),
140
140
  state: m
141
141
  };
142
- Ne(e, p.initialState), he(e, p.updaterState), ne(e, p.state);
143
- }, ve = (e) => {
144
- const i = o.getState().stateComponents.get(e);
142
+ Nt(t, p.initialState), It(t, p.updaterState), nt(t, p.state);
143
+ }, dt = (t) => {
144
+ const i = o.getState().stateComponents.get(t);
145
145
  if (!i) return;
146
146
  const m = /* @__PURE__ */ new Set();
147
147
  i.components.forEach((g) => {
@@ -149,16 +149,16 @@ const vt = (e, i) => {
149
149
  }), queueMicrotask(() => {
150
150
  m.forEach((g) => g());
151
151
  });
152
- }, yt = (e, i) => {
153
- const m = o.getState().stateComponents.get(e);
152
+ }, ye = (t, i) => {
153
+ const m = o.getState().stateComponents.get(t);
154
154
  if (m) {
155
- const g = `${e}////${i}`, I = m.components.get(g);
156
- if ((I ? Array.isArray(I.reactiveType) ? I.reactiveType : [I.reactiveType || "component"] : null)?.includes("none"))
155
+ const g = `${t}////${i}`, T = m.components.get(g);
156
+ if ((T ? Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"] : null)?.includes("none"))
157
157
  return;
158
- I && I.forceUpdate();
158
+ T && T.forceUpdate();
159
159
  }
160
- }, tt = (e, i, m, g) => {
161
- switch (e) {
160
+ }, ee = (t, i, m, g) => {
161
+ switch (t) {
162
162
  case "update":
163
163
  return {
164
164
  oldValue: Z(i, g),
@@ -180,96 +180,96 @@ const vt = (e, i) => {
180
180
  return { oldValue: null, newValue: null };
181
181
  }
182
182
  };
183
- function nt(e, {
183
+ function ne(t, {
184
184
  stateKey: i,
185
185
  serverSync: m,
186
186
  localStorage: g,
187
- formElements: I,
187
+ formElements: T,
188
188
  reactiveDeps: N,
189
189
  reactiveType: p,
190
190
  componentId: v,
191
191
  initialState: s,
192
- syncUpdate: T,
193
- dependencies: n,
192
+ syncUpdate: I,
193
+ dependencies: r,
194
194
  serverState: S
195
195
  } = {}) {
196
- const [W, U] = K({}), { sessionId: j } = Ge();
196
+ const [W, j] = K({}), { sessionId: U } = Gt();
197
197
  let z = !i;
198
- const [h] = K(i ?? Ae()), l = o.getState().stateLog[h], de = q(/* @__PURE__ */ new Set()), te = q(v ?? Ae()), L = q(
198
+ const [h] = K(i ?? At()), l = o.getState().stateLog[h], ut = q(/* @__PURE__ */ new Set()), et = q(v ?? At()), L = q(
199
199
  null
200
200
  );
201
- L.current = re(h) ?? null, oe(() => {
202
- if (T && T.stateKey === h && T.path?.[0]) {
203
- ne(h, (r) => ({
204
- ...r,
205
- [T.path[0]]: T.newValue
201
+ L.current = rt(h) ?? null, ot(() => {
202
+ if (I && I.stateKey === h && I.path?.[0]) {
203
+ nt(h, (n) => ({
204
+ ...n,
205
+ [I.path[0]]: I.newValue
206
206
  }));
207
- const t = `${T.stateKey}:${T.path.join(".")}`;
208
- o.getState().setSyncInfo(t, {
209
- timeStamp: T.timeStamp,
210
- userId: T.userId
207
+ const e = `${I.stateKey}:${I.path.join(".")}`;
208
+ o.getState().setSyncInfo(e, {
209
+ timeStamp: I.timeStamp,
210
+ userId: I.userId
211
211
  });
212
212
  }
213
- }, [T]), oe(() => {
213
+ }, [I]), ot(() => {
214
214
  if (s) {
215
- Me(h, {
215
+ Mt(h, {
216
216
  initialState: s
217
217
  });
218
- const t = L.current, a = t?.serverState?.id !== void 0 && t?.serverState?.status === "success" && t?.serverState?.data, c = o.getState().initialStateGlobal[h];
218
+ const e = L.current, a = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, c = o.getState().initialStateGlobal[h];
219
219
  if (!(c && !J(c, s) || !c) && !a)
220
220
  return;
221
221
  let u = null;
222
- const E = ee(t?.localStorage?.key) ? t?.localStorage?.key(s) : t?.localStorage?.key;
223
- E && j && (u = Ie(`${j}-${h}-${E}`));
222
+ const E = tt(e?.localStorage?.key) ? e?.localStorage?.key(s) : e?.localStorage?.key;
223
+ E && U && (u = vt(`${U}-${h}-${E}`));
224
224
  let y = s, w = !1;
225
225
  const C = a ? Date.now() : 0, A = u?.lastUpdated || 0, b = u?.lastSyncedWithServer || 0;
226
- a && C > A ? (y = t.serverState.data, w = !0) : u && A > b && (y = u.state, t?.localStorage?.onChange && t?.localStorage?.onChange(y)), o.getState().initializeShadowState(h, s), Re(
226
+ a && C > A ? (y = e.serverState.data, w = !0) : u && A > b && (y = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(y)), o.getState().initializeShadowState(h, s), Dt(
227
227
  h,
228
228
  s,
229
229
  y,
230
- ae,
231
- te.current,
232
- j
233
- ), w && E && j && Pe(y, h, t, j, Date.now()), ve(h), (Array.isArray(p) ? p : [p || "component"]).includes("none") || U({});
230
+ at,
231
+ et.current,
232
+ U
233
+ ), w && E && U && Pt(y, h, e, U, Date.now()), dt(h), (Array.isArray(p) ? p : [p || "component"]).includes("none") || j({});
234
234
  }
235
235
  }, [
236
236
  s,
237
237
  S?.status,
238
238
  S?.data,
239
- ...n || []
240
- ]), ce(() => {
241
- z && Me(h, {
239
+ ...r || []
240
+ ]), ct(() => {
241
+ z && Mt(h, {
242
242
  serverSync: m,
243
- formElements: I,
243
+ formElements: T,
244
244
  initialState: s,
245
245
  localStorage: g,
246
246
  middleware: L.current?.middleware
247
247
  });
248
- const t = `${h}////${te.current}`, r = o.getState().stateComponents.get(h) || {
248
+ const e = `${h}////${et.current}`, n = o.getState().stateComponents.get(h) || {
249
249
  components: /* @__PURE__ */ new Map()
250
250
  };
251
- return r.components.set(t, {
252
- forceUpdate: () => U({}),
251
+ return n.components.set(e, {
252
+ forceUpdate: () => j({}),
253
253
  paths: /* @__PURE__ */ new Set(),
254
254
  deps: [],
255
255
  depsFunction: N || void 0,
256
256
  reactiveType: p ?? ["component", "deps"]
257
- }), o.getState().stateComponents.set(h, r), U({}), () => {
258
- r && (r.components.delete(t), r.components.size === 0 && o.getState().stateComponents.delete(h));
257
+ }), o.getState().stateComponents.set(h, n), j({}), () => {
258
+ n && (n.components.delete(e), n.components.size === 0 && o.getState().stateComponents.delete(h));
259
259
  };
260
260
  }, []);
261
- const ae = (t, r, a, c) => {
262
- if (Array.isArray(r)) {
263
- const u = `${h}-${r.join(".")}`;
264
- de.current.add(u);
261
+ const at = (e, n, a, c) => {
262
+ if (Array.isArray(n)) {
263
+ const u = `${h}-${n.join(".")}`;
264
+ ut.current.add(u);
265
265
  }
266
266
  const f = o.getState();
267
- ne(h, (u) => {
268
- const E = ee(t) ? t(u) : t, y = `${h}-${r.join(".")}`;
267
+ nt(h, (u) => {
268
+ const E = tt(e) ? e(u) : e, y = `${h}-${n.join(".")}`;
269
269
  if (y) {
270
270
  let M = !1, $ = f.signalDomElements.get(y);
271
271
  if ((!$ || $.size === 0) && (a.updateType === "insert" || a.updateType === "cut")) {
272
- const R = r.slice(0, -1), V = Z(E, R);
272
+ const R = n.slice(0, -1), V = Z(E, R);
273
273
  if (Array.isArray(V)) {
274
274
  M = !0;
275
275
  const O = `${h}-${R.join(".")}`;
@@ -277,7 +277,7 @@ function nt(e, {
277
277
  }
278
278
  }
279
279
  if ($) {
280
- const R = M ? Z(E, r.slice(0, -1)) : Z(E, r);
280
+ const R = M ? Z(E, n.slice(0, -1)) : Z(E, n);
281
281
  $.forEach(({ parentId: V, position: O, effect: _ }) => {
282
282
  const D = document.querySelector(
283
283
  `[data-parent-id="${V}"]`
@@ -292,24 +292,24 @@ function nt(e, {
292
292
  });
293
293
  }
294
294
  }
295
- console.log("shadowState", f.shadowStateStore), a.updateType === "update" && (c || L.current?.validation?.key) && r && Q(
296
- (c || L.current?.validation?.key) + "." + r.join(".")
295
+ console.log("shadowState", f.shadowStateStore), a.updateType === "update" && (c || L.current?.validation?.key) && n && X(
296
+ (c || L.current?.validation?.key) + "." + n.join(".")
297
297
  );
298
- const w = r.slice(0, r.length - 1);
299
- a.updateType === "cut" && L.current?.validation?.key && Q(
298
+ const w = n.slice(0, n.length - 1);
299
+ a.updateType === "cut" && L.current?.validation?.key && X(
300
300
  L.current?.validation?.key + "." + w.join(".")
301
- ), a.updateType === "insert" && L.current?.validation?.key && Ze(
301
+ ), a.updateType === "insert" && L.current?.validation?.key && Xt(
302
302
  L.current?.validation?.key + "." + w.join(".")
303
303
  ).filter(([$, R]) => {
304
304
  let V = $?.split(".").length;
305
305
  if ($ == w.join(".") && V == w.length - 1) {
306
306
  let O = $ + "." + w;
307
- Q($), Qe(O, R);
307
+ X($), Rt(O, R);
308
308
  }
309
309
  });
310
310
  const C = f.stateComponents.get(h);
311
311
  if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", C), C) {
312
- const M = _e(u, E), $ = new Set(M), R = a.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
312
+ const M = _t(u, E), $ = new Set(M), R = a.updateType === "update" ? n.join(".") : n.slice(0, -1).join(".") || "";
313
313
  for (const [
314
314
  V,
315
315
  O
@@ -329,19 +329,19 @@ function nt(e, {
329
329
  _ = !0;
330
330
  break;
331
331
  }
332
- const se = B.lastIndexOf(".");
333
- if (se !== -1) {
334
- const ue = B.substring(
332
+ const st = B.lastIndexOf(".");
333
+ if (st !== -1) {
334
+ const gt = B.substring(
335
335
  0,
336
- se
336
+ st
337
337
  );
338
338
  if (!isNaN(
339
- Number(B.substring(se + 1))
340
- ) && O.paths.has(ue)) {
339
+ Number(B.substring(st + 1))
340
+ ) && O.paths.has(gt)) {
341
341
  _ = !0;
342
342
  break;
343
343
  }
344
- B = ue;
344
+ B = gt;
345
345
  } else
346
346
  B = "";
347
347
  if (B === "")
@@ -359,19 +359,19 @@ function nt(e, {
359
359
  }
360
360
  }
361
361
  const A = Date.now();
362
- r = r.map((M, $) => {
363
- const R = r.slice(0, -1), V = Z(E, R);
364
- return $ === r.length - 1 && ["insert", "cut"].includes(a.updateType) ? (V.length - 1).toString() : M;
362
+ n = n.map((M, $) => {
363
+ const R = n.slice(0, -1), V = Z(E, R);
364
+ return $ === n.length - 1 && ["insert", "cut"].includes(a.updateType) ? (V.length - 1).toString() : M;
365
365
  });
366
- const { oldValue: b, newValue: F } = tt(
366
+ const { oldValue: b, newValue: F } = ee(
367
367
  a.updateType,
368
368
  u,
369
369
  E,
370
- r
370
+ n
371
371
  ), Y = {
372
372
  timeStamp: A,
373
373
  stateKey: h,
374
- path: r,
374
+ path: n,
375
375
  updateType: a.updateType,
376
376
  status: "new",
377
377
  oldValue: b,
@@ -379,34 +379,34 @@ function nt(e, {
379
379
  };
380
380
  switch (a.updateType) {
381
381
  case "update":
382
- f.updateShadowAtPath(h, r, E);
382
+ f.updateShadowAtPath(h, n, E);
383
383
  break;
384
384
  case "insert":
385
- const M = r.slice(0, -1);
385
+ const M = n.slice(0, -1);
386
386
  f.insertShadowArrayElement(h, M, F);
387
387
  break;
388
388
  case "cut":
389
- const $ = r.slice(0, -1), R = parseInt(r[r.length - 1]);
389
+ const $ = n.slice(0, -1), R = parseInt(n[n.length - 1]);
390
390
  f.removeShadowArrayElement(h, $, R);
391
391
  break;
392
392
  }
393
- if (Xe(h, (M) => {
393
+ if (Qt(h, (M) => {
394
394
  const R = [...M ?? [], Y].reduce((V, O) => {
395
395
  const _ = `${O.stateKey}:${JSON.stringify(O.path)}`, D = V.get(_);
396
396
  return D ? (D.timeStamp = Math.max(D.timeStamp, O.timeStamp), D.newValue = O.newValue, D.oldValue = D.oldValue ?? O.oldValue, D.updateType = O.updateType) : V.set(_, { ...O }), V;
397
397
  }, /* @__PURE__ */ new Map());
398
398
  return Array.from(R.values());
399
- }), Pe(
399
+ }), Pt(
400
400
  E,
401
401
  h,
402
402
  L.current,
403
- j
403
+ U
404
404
  ), L.current?.middleware && L.current.middleware({
405
405
  updateLog: l,
406
406
  update: Y
407
407
  }), L.current?.serverSync) {
408
408
  const M = f.serverState[h], $ = L.current?.serverSync;
409
- Ke(h, {
409
+ Kt(h, {
410
410
  syncKey: typeof $.syncKey == "string" ? $.syncKey : $.syncKey({ state: E }),
411
411
  rollBackState: M,
412
412
  actionTimeStamp: Date.now() + ($.debounce ?? 3e3),
@@ -416,91 +416,91 @@ function nt(e, {
416
416
  return E;
417
417
  });
418
418
  };
419
- o.getState().updaterState[h] || (he(
419
+ o.getState().updaterState[h] || (It(
420
420
  h,
421
- Te(
421
+ Tt(
422
422
  h,
423
- ae,
424
- te.current,
425
- j
423
+ at,
424
+ et.current,
425
+ U
426
426
  )
427
- ), o.getState().cogsStateStore[h] || ne(h, e), o.getState().initialStateGlobal[h] || Ne(h, e));
428
- const d = we(() => Te(
427
+ ), o.getState().cogsStateStore[h] || nt(h, t), o.getState().initialStateGlobal[h] || Nt(h, t));
428
+ const d = wt(() => Tt(
429
429
  h,
430
- ae,
431
- te.current,
432
- j
433
- ), [h, j]);
434
- return [Le(h), d];
430
+ at,
431
+ et.current,
432
+ U
433
+ ), [h, U]);
434
+ return [Lt(h), d];
435
435
  }
436
- function Te(e, i, m, g) {
437
- const I = /* @__PURE__ */ new Map();
436
+ function Tt(t, i, m, g) {
437
+ const T = /* @__PURE__ */ new Map();
438
438
  let N = 0;
439
- const p = (T) => {
440
- const n = T.join(".");
441
- for (const [S] of I)
442
- (S === n || S.startsWith(n + ".")) && I.delete(S);
439
+ const p = (I) => {
440
+ const r = I.join(".");
441
+ for (const [S] of T)
442
+ (S === r || S.startsWith(r + ".")) && T.delete(S);
443
443
  N++;
444
444
  }, v = {
445
- removeValidation: (T) => {
446
- T?.validationKey && Q(T.validationKey);
445
+ removeValidation: (I) => {
446
+ I?.validationKey && X(I.validationKey);
447
447
  },
448
- revertToInitialState: (T) => {
449
- const n = o.getState().getInitialOptions(e)?.validation;
450
- n?.key && Q(n?.key), T?.validationKey && Q(T.validationKey);
451
- const S = o.getState().initialStateGlobal[e];
452
- o.getState().clearSelectedIndexesForState(e), I.clear(), N++;
453
- const W = s(S, []), U = re(e), j = ee(U?.localStorage?.key) ? U?.localStorage?.key(S) : U?.localStorage?.key, z = `${g}-${e}-${j}`;
454
- z && localStorage.removeItem(z), he(e, W), ne(e, S);
455
- const h = o.getState().stateComponents.get(e);
448
+ revertToInitialState: (I) => {
449
+ const r = o.getState().getInitialOptions(t)?.validation;
450
+ r?.key && X(r?.key), I?.validationKey && X(I.validationKey);
451
+ const S = o.getState().initialStateGlobal[t];
452
+ o.getState().clearSelectedIndexesForState(t), T.clear(), N++;
453
+ const W = s(S, []), j = rt(t), U = tt(j?.localStorage?.key) ? j?.localStorage?.key(S) : j?.localStorage?.key, z = `${g}-${t}-${U}`;
454
+ z && localStorage.removeItem(z), It(t, W), nt(t, S);
455
+ const h = o.getState().stateComponents.get(t);
456
456
  return h && h.components.forEach((l) => {
457
457
  l.forceUpdate();
458
458
  }), S;
459
459
  },
460
- updateInitialState: (T) => {
461
- I.clear(), N++;
462
- const n = Te(
463
- e,
460
+ updateInitialState: (I) => {
461
+ T.clear(), N++;
462
+ const r = Tt(
463
+ t,
464
464
  i,
465
465
  m,
466
466
  g
467
- ), S = o.getState().initialStateGlobal[e], W = re(e), U = ee(W?.localStorage?.key) ? W?.localStorage?.key(S) : W?.localStorage?.key, j = `${g}-${e}-${U}`;
468
- return localStorage.getItem(j) && localStorage.removeItem(j), He(() => {
469
- Ne(e, T), o.getState().initializeShadowState(e, T), he(e, n), ne(e, T);
470
- const z = o.getState().stateComponents.get(e);
467
+ ), S = o.getState().initialStateGlobal[t], W = rt(t), j = tt(W?.localStorage?.key) ? W?.localStorage?.key(S) : W?.localStorage?.key, U = `${g}-${t}-${j}`;
468
+ return localStorage.getItem(U) && localStorage.removeItem(U), Ft(() => {
469
+ Nt(t, I), o.getState().initializeShadowState(t, I), It(t, r), nt(t, I);
470
+ const z = o.getState().stateComponents.get(t);
471
471
  z && z.components.forEach((h) => {
472
472
  h.forceUpdate();
473
473
  });
474
474
  }), {
475
- fetchId: (z) => n.get()[z]
475
+ fetchId: (z) => r.get()[z]
476
476
  };
477
477
  },
478
- _initialState: o.getState().initialStateGlobal[e],
479
- _serverState: o.getState().serverState[e],
480
- _isLoading: o.getState().isLoadingGlobal[e],
478
+ _initialState: o.getState().initialStateGlobal[t],
479
+ _serverState: o.getState().serverState[t],
480
+ _isLoading: o.getState().isLoadingGlobal[t],
481
481
  _isServerSynced: () => {
482
- const T = o.getState().serverState[e];
483
- return !!(T && J(T, Le(e)));
482
+ const I = o.getState().serverState[t];
483
+ return !!(I && J(I, Lt(t)));
484
484
  }
485
485
  };
486
- function s(T, n = [], S) {
487
- const W = n.map(String).join(".");
488
- I.get(W);
489
- const U = function() {
490
- return o().getNestedState(e, n);
486
+ function s(I, r = [], S) {
487
+ const W = r.map(String).join(".");
488
+ T.get(W);
489
+ const j = function() {
490
+ return o().getNestedState(t, r);
491
491
  };
492
492
  Object.keys(v).forEach((h) => {
493
- U[h] = v[h];
493
+ j[h] = v[h];
494
494
  });
495
- const j = {
496
- apply(h, l, de) {
495
+ const U = {
496
+ apply(h, l, ut) {
497
497
  return console.log(
498
- `PROXY APPLY TRAP HIT: stateKey=${e}, path=${n.join(".")}`
499
- ), console.trace("Apply trap stack trace"), o().getNestedState(e, n);
498
+ `PROXY APPLY TRAP HIT: stateKey=${t}, path=${r.join(".")}`
499
+ ), console.trace("Apply trap stack trace"), o().getNestedState(t, r);
500
500
  },
501
501
  get(h, l) {
502
- S?.validIndices && !Array.isArray(T) && (S = { ...S, validIndices: void 0 });
503
- const de = /* @__PURE__ */ new Set([
502
+ S?.validIndices && !Array.isArray(I) && (S = { ...S, validIndices: void 0 });
503
+ const ut = /* @__PURE__ */ new Set([
504
504
  "insert",
505
505
  "cut",
506
506
  "cutByValue",
@@ -523,142 +523,142 @@ function Te(e, i, m, g) {
523
523
  "_stateKey",
524
524
  "getComponents"
525
525
  ]);
526
- if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !de.has(l)) {
527
- const d = `${e}////${m}`, t = o.getState().stateComponents.get(e);
528
- if (t) {
529
- const r = t.components.get(d);
530
- if (r && !r.paths.has("")) {
531
- const a = n.join(".");
526
+ if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !ut.has(l)) {
527
+ const d = `${t}////${m}`, e = o.getState().stateComponents.get(t);
528
+ if (e) {
529
+ const n = e.components.get(d);
530
+ if (n && !n.paths.has("")) {
531
+ const a = r.join(".");
532
532
  let c = !0;
533
- for (const f of r.paths)
533
+ for (const f of n.paths)
534
534
  if (a.startsWith(f) && (a === f || a[f.length] === ".")) {
535
535
  c = !1;
536
536
  break;
537
537
  }
538
- c && r.paths.add(a);
538
+ c && n.paths.add(a);
539
539
  }
540
540
  }
541
541
  }
542
542
  if (l === "getDifferences")
543
- return () => _e(
544
- o.getState().cogsStateStore[e],
545
- o.getState().initialStateGlobal[e]
543
+ return () => _t(
544
+ o.getState().cogsStateStore[t],
545
+ o.getState().initialStateGlobal[t]
546
546
  );
547
- if (l === "sync" && n.length === 0)
547
+ if (l === "sync" && r.length === 0)
548
548
  return async function() {
549
- const d = o.getState().getInitialOptions(e), t = d?.sync;
550
- if (!t)
551
- return console.error(`No mutation defined for state key "${e}"`), { success: !1, error: "No mutation defined" };
552
- const r = o.getState().getNestedState(e, []), a = d?.validation?.key;
549
+ const d = o.getState().getInitialOptions(t), e = d?.sync;
550
+ if (!e)
551
+ return console.error(`No mutation defined for state key "${t}"`), { success: !1, error: "No mutation defined" };
552
+ const n = o.getState().getNestedState(t, []), a = d?.validation?.key;
553
553
  try {
554
- const c = await t.action(r);
554
+ const c = await e.action(n);
555
555
  if (c && !c.success && c.errors && a) {
556
556
  o.getState().removeValidationError(a), c.errors.forEach((u) => {
557
557
  const E = [a, ...u.path].join(".");
558
558
  o.getState().addValidationError(E, u.message);
559
559
  });
560
- const f = o.getState().stateComponents.get(e);
560
+ const f = o.getState().stateComponents.get(t);
561
561
  f && f.components.forEach((u) => {
562
562
  u.forceUpdate();
563
563
  });
564
564
  }
565
- return c?.success && t.onSuccess ? t.onSuccess(c.data) : !c?.success && t.onError && t.onError(c.error), c;
565
+ return c?.success && e.onSuccess ? e.onSuccess(c.data) : !c?.success && e.onError && e.onError(c.error), c;
566
566
  } catch (c) {
567
- return t.onError && t.onError(c), { success: !1, error: c };
567
+ return e.onError && e.onError(c), { success: !1, error: c };
568
568
  }
569
569
  };
570
570
  if (l === "_status") {
571
- const d = o.getState().getNestedState(e, n), t = o.getState().initialStateGlobal[e], r = Z(t, n);
572
- return J(d, r) ? "fresh" : "stale";
571
+ const d = o.getState().getNestedState(t, r), e = o.getState().initialStateGlobal[t], n = Z(e, r);
572
+ return J(d, n) ? "fresh" : "stale";
573
573
  }
574
574
  if (l === "getStatus")
575
575
  return function() {
576
576
  const d = o().getNestedState(
577
- e,
578
- n
579
- ), t = o.getState().initialStateGlobal[e], r = Z(t, n);
580
- return J(d, r) ? "fresh" : "stale";
577
+ t,
578
+ r
579
+ ), e = o.getState().initialStateGlobal[t], n = Z(e, r);
580
+ return J(d, n) ? "fresh" : "stale";
581
581
  };
582
582
  if (l === "removeStorage")
583
583
  return () => {
584
- const d = o.getState().initialStateGlobal[e], t = re(e), r = ee(t?.localStorage?.key) ? t?.localStorage?.key(d) : t?.localStorage?.key, a = `${g}-${e}-${r}`;
584
+ const d = o.getState().initialStateGlobal[t], e = rt(t), n = tt(e?.localStorage?.key) ? e?.localStorage?.key(d) : e?.localStorage?.key, a = `${g}-${t}-${n}`;
585
585
  a && localStorage.removeItem(a);
586
586
  };
587
587
  if (l === "showValidationErrors")
588
588
  return () => {
589
- const d = o.getState().getInitialOptions(e)?.validation;
589
+ const d = o.getState().getInitialOptions(t)?.validation;
590
590
  if (!d?.key)
591
591
  throw new Error("Validation key not found");
592
- return o.getState().getValidationErrors(d.key + "." + n.join("."));
592
+ return o.getState().getValidationErrors(d.key + "." + r.join("."));
593
593
  };
594
- if (Array.isArray(T)) {
595
- const d = () => S?.validIndices ? T.map((r, a) => ({
596
- item: r,
594
+ if (Array.isArray(I)) {
595
+ const d = () => S?.validIndices ? I.map((n, a) => ({
596
+ item: n,
597
597
  originalIndex: S.validIndices[a]
598
- })) : o.getState().getNestedState(e, n).map((r, a) => ({
599
- item: r,
598
+ })) : o.getState().getNestedState(t, r).map((n, a) => ({
599
+ item: n,
600
600
  originalIndex: a
601
601
  }));
602
602
  if (l === "getSelected")
603
603
  return () => {
604
- const t = o.getState().getSelectedIndex(e, n.join("."));
605
- if (t !== void 0)
604
+ const e = o.getState().getSelectedIndex(t, r.join("."));
605
+ if (e !== void 0)
606
606
  return s(
607
- T[t],
608
- [...n, t.toString()],
607
+ I[e],
608
+ [...r, e.toString()],
609
609
  S
610
610
  );
611
611
  };
612
612
  if (l === "clearSelected")
613
613
  return () => {
614
- o.getState().clearSelectedIndex({ stateKey: e, path: n });
614
+ o.getState().clearSelectedIndex({ stateKey: t, path: r });
615
615
  };
616
616
  if (l === "getSelectedIndex")
617
- return () => o.getState().getSelectedIndex(e, n.join(".")) ?? -1;
617
+ return () => o.getState().getSelectedIndex(t, r.join(".")) ?? -1;
618
618
  if (l === "useVirtualView")
619
- return (t) => {
619
+ return (e) => {
620
620
  const {
621
- itemHeight: r = 50,
621
+ itemHeight: n = 50,
622
622
  overscan: a = 6,
623
623
  stickToBottom: c = !1,
624
624
  dependencies: f = []
625
- } = t, u = q(!1), E = q(null), [y, w] = K({
625
+ } = e, u = q(!1), E = q(null), [y, w] = K({
626
626
  startIndex: 0,
627
627
  endIndex: 10
628
628
  }), [C, A] = K("IDLE_AT_TOP"), b = q(!1), F = q(0), Y = q(f), M = q(0), [$, R] = K(0), V = q(null);
629
- oe(() => o.getState().subscribeToShadowState(e, () => {
629
+ ot(() => o.getState().subscribeToShadowState(t, () => {
630
630
  R((x) => x + 1);
631
- }), [e]);
631
+ }), [t]);
632
632
  const O = o().getNestedState(
633
- e,
634
- n
635
- ), _ = O.length, { totalHeight: D, positions: G } = we(() => {
636
- const k = o.getState().getShadowMetadata(e, n) || [];
633
+ t,
634
+ r
635
+ ), _ = O.length, { totalHeight: D, positions: G } = wt(() => {
636
+ const k = o.getState().getShadowMetadata(t, r) || [];
637
637
  let x = 0;
638
638
  const H = [];
639
639
  for (let P = 0; P < _; P++) {
640
640
  H[P] = x;
641
- const X = k[P]?.virtualizer?.itemHeight;
642
- x += X || r;
641
+ const Q = k[P]?.virtualizer?.itemHeight;
642
+ x += Q || n;
643
643
  }
644
644
  return { totalHeight: x, positions: H };
645
645
  }, [
646
646
  _,
647
- e,
648
- n.join("."),
649
- r,
647
+ t,
648
+ r.join("."),
649
+ n,
650
650
  $
651
- ]), B = we(() => {
651
+ ]), B = wt(() => {
652
652
  const k = Math.max(0, y.startIndex), x = Math.min(_, y.endIndex), H = Array.from(
653
653
  { length: x - k },
654
- (X, ge) => k + ge
655
- ), P = H.map((X) => O[X]);
656
- return s(P, n, {
654
+ (Q, ft) => k + ft
655
+ ), P = H.map((Q) => O[Q]);
656
+ return s(P, r, {
657
657
  ...S,
658
658
  validIndices: H
659
659
  });
660
660
  }, [y.startIndex, y.endIndex, O, _]);
661
- ce(() => {
661
+ ct(() => {
662
662
  const k = E.current;
663
663
  if (!k) return;
664
664
  const x = _ > F.current;
@@ -682,7 +682,7 @@ function Te(e, i, m, g) {
682
682
  ), A("GETTING_HEIGHTS"));
683
683
  }
684
684
  F.current = _, Y.current = f;
685
- }, [_, ...f]), ce(() => {
685
+ }, [_, ...f]), ct(() => {
686
686
  const k = E.current;
687
687
  if (!k) return;
688
688
  let x;
@@ -698,7 +698,7 @@ function Te(e, i, m, g) {
698
698
  endIndex: _
699
699
  }), x = setInterval(() => {
700
700
  const H = _ - 1;
701
- ((o.getState().getShadowMetadata(e, n) || [])[H]?.virtualizer?.itemHeight || 0) > 0 && (clearInterval(x), u.current || (console.log(
701
+ ((o.getState().getShadowMetadata(t, r) || [])[H]?.virtualizer?.itemHeight || 0) > 0 && (clearInterval(x), u.current || (console.log(
702
702
  "ACTION (GETTING_HEIGHTS): Measurement success -> SCROLLING_TO_BOTTOM"
703
703
  ), A("SCROLLING_TO_BOTTOM")));
704
704
  }, 100);
@@ -724,45 +724,45 @@ function Te(e, i, m, g) {
724
724
  return () => {
725
725
  x && clearInterval(x);
726
726
  };
727
- }, [C, _, G]), oe(() => {
727
+ }, [C, _, G]), ot(() => {
728
728
  const k = E.current;
729
729
  if (!k) return;
730
- const x = r, H = () => {
730
+ const x = n, H = () => {
731
731
  if (b.current)
732
732
  return;
733
- const { scrollTop: P, scrollHeight: X, clientHeight: ge } = k;
734
- if (X - P - ge < 10 ? (C !== "LOCKED_AT_BOTTOM" && A("LOCKED_AT_BOTTOM"), V.current = null) : (C !== "IDLE_NOT_AT_BOTTOM" && A("IDLE_NOT_AT_BOTTOM"), V.current = {
733
+ const { scrollTop: P, scrollHeight: Q, clientHeight: ft } = k;
734
+ if (Q - P - ft < 10 ? (C !== "LOCKED_AT_BOTTOM" && A("LOCKED_AT_BOTTOM"), V.current = null) : (C !== "IDLE_NOT_AT_BOTTOM" && A("IDLE_NOT_AT_BOTTOM"), V.current = {
735
735
  top: P,
736
- height: X
736
+ height: Q
737
737
  }), Math.abs(P - M.current) < x)
738
738
  return;
739
739
  console.log(
740
740
  `Threshold passed at ${P}px. Recalculating range...`
741
741
  );
742
- let ye = _ - 1, pe = 0, Ce = 0;
743
- for (; pe <= ye; ) {
744
- const Se = Math.floor((pe + ye) / 2);
745
- G[Se] < P ? (Ce = Se, pe = Se + 1) : ye = Se - 1;
742
+ let yt = _ - 1, pt = 0, Ct = 0;
743
+ for (; pt <= yt; ) {
744
+ const mt = Math.floor((pt + yt) / 2);
745
+ G[mt] < P ? (Ct = mt, pt = mt + 1) : yt = mt - 1;
746
746
  }
747
- const $e = Math.max(0, Ce - a);
748
- let fe = $e;
749
- const Ue = P + ge;
750
- for (; fe < _ && G[fe] < Ue; )
751
- fe++;
747
+ const $t = Math.max(0, Ct - a);
748
+ let St = $t;
749
+ const Ut = P + ft;
750
+ for (; St < _ && G[St] < Ut; )
751
+ St++;
752
752
  w({
753
- startIndex: $e,
754
- endIndex: Math.min(_, fe + a)
753
+ startIndex: $t,
754
+ endIndex: Math.min(_, St + a)
755
755
  }), M.current = P;
756
756
  };
757
757
  return k.addEventListener("scroll", H, {
758
758
  passive: !0
759
759
  }), () => k.removeEventListener("scroll", H);
760
- }, [_, G, r, a, C]);
761
- const se = ke(() => {
760
+ }, [_, G, n, a, C]);
761
+ const st = kt(() => {
762
762
  console.log(
763
763
  "USER ACTION: Clicked scroll button -> SCROLLING_TO_BOTTOM"
764
764
  ), A("SCROLLING_TO_BOTTOM");
765
- }, []), ue = ke(
765
+ }, []), gt = kt(
766
766
  (k, x = "smooth") => {
767
767
  E.current && G[k] !== void 0 && (A("IDLE_NOT_AT_BOTTOM"), E.current.scrollTo({
768
768
  top: G[k],
@@ -770,7 +770,7 @@ function Te(e, i, m, g) {
770
770
  }));
771
771
  },
772
772
  [G]
773
- ), De = {
773
+ ), jt = {
774
774
  outer: {
775
775
  ref: E,
776
776
  style: { overflowY: "auto", height: "100%" }
@@ -789,146 +789,146 @@ function Te(e, i, m, g) {
789
789
  };
790
790
  return {
791
791
  virtualState: B,
792
- virtualizerProps: De,
793
- scrollToBottom: se,
794
- scrollToIndex: ue
792
+ virtualizerProps: jt,
793
+ scrollToBottom: st,
794
+ scrollToIndex: gt
795
795
  };
796
796
  };
797
797
  if (l === "stateSort")
798
- return (t) => {
798
+ return (e) => {
799
799
  const a = [...d()].sort(
800
- (u, E) => t(u.item, E.item)
800
+ (u, E) => e(u.item, E.item)
801
801
  ), c = a.map(({ item: u }) => u), f = {
802
802
  ...S,
803
803
  validIndices: a.map(
804
804
  ({ originalIndex: u }) => u
805
805
  )
806
806
  };
807
- return s(c, n, f);
807
+ return s(c, r, f);
808
808
  };
809
809
  if (l === "stateFilter")
810
- return (t) => {
810
+ return (e) => {
811
811
  const a = d().filter(
812
- ({ item: u }, E) => t(u, E)
812
+ ({ item: u }, E) => e(u, E)
813
813
  ), c = a.map(({ item: u }) => u), f = {
814
814
  ...S,
815
815
  validIndices: a.map(
816
816
  ({ originalIndex: u }) => u
817
817
  )
818
818
  };
819
- return s(c, n, f);
819
+ return s(c, r, f);
820
820
  };
821
821
  if (l === "stateMap")
822
- return (t) => {
823
- const r = o.getState().getNestedState(e, n);
824
- return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (c, f) => f)).map((c, f) => {
825
- const u = r[c], E = [...n, c.toString()], y = s(u, E, S);
826
- return t(u, y, {
822
+ return (e) => {
823
+ const n = o.getState().getNestedState(t, r);
824
+ return Array.isArray(n) ? (S?.validIndices || Array.from({ length: n.length }, (c, f) => f)).map((c, f) => {
825
+ const u = n[c], E = [...r, c.toString()], y = s(u, E, S);
826
+ return e(u, y, {
827
827
  register: () => {
828
- const [, C] = K({}), A = `${m}-${n.join(".")}-${c}`;
829
- ce(() => {
830
- const b = `${e}////${A}`, F = o.getState().stateComponents.get(e) || {
828
+ const [, C] = K({}), A = `${m}-${r.join(".")}-${c}`;
829
+ ct(() => {
830
+ const b = `${t}////${A}`, F = o.getState().stateComponents.get(t) || {
831
831
  components: /* @__PURE__ */ new Map()
832
832
  };
833
833
  return F.components.set(b, {
834
834
  forceUpdate: () => C({}),
835
835
  paths: /* @__PURE__ */ new Set([E.join(".")])
836
- }), o.getState().stateComponents.set(e, F), () => {
837
- const Y = o.getState().stateComponents.get(e);
836
+ }), o.getState().stateComponents.set(t, F), () => {
837
+ const Y = o.getState().stateComponents.get(t);
838
838
  Y && Y.components.delete(b);
839
839
  };
840
- }, [e, A]);
840
+ }, [t, A]);
841
841
  },
842
842
  index: f,
843
843
  originalIndex: c
844
844
  });
845
845
  }) : (console.warn(
846
- `stateMap called on a non-array value at path: ${n.join(".")}. The current value is:`,
847
- r
846
+ `stateMap called on a non-array value at path: ${r.join(".")}. The current value is:`,
847
+ n
848
848
  ), null);
849
849
  };
850
850
  if (l === "stateMapNoRender")
851
- return (t) => T.map((a, c) => {
851
+ return (e) => I.map((a, c) => {
852
852
  let f;
853
853
  S?.validIndices && S.validIndices[c] !== void 0 ? f = S.validIndices[c] : f = c;
854
- const u = [...n, f.toString()], E = s(a, u, S);
855
- return t(
854
+ const u = [...r, f.toString()], E = s(a, u, S);
855
+ return e(
856
856
  a,
857
857
  E,
858
858
  c,
859
- T,
860
- s(T, n, S)
859
+ I,
860
+ s(I, r, S)
861
861
  );
862
862
  });
863
863
  if (l === "$stateMap")
864
- return (t) => le(rt, {
864
+ return (e) => lt(re, {
865
865
  proxy: {
866
- _stateKey: e,
867
- _path: n,
868
- _mapFn: t
866
+ _stateKey: t,
867
+ _path: r,
868
+ _mapFn: e
869
869
  // Pass the actual function, not string
870
870
  },
871
871
  rebuildStateShape: s
872
872
  });
873
873
  if (l === "stateList")
874
- return (t) => {
875
- const r = o.getState().getNestedState(e, n);
876
- return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (c, f) => f)).map((c, f) => {
877
- const u = r[c], E = [...n, c.toString()], y = s(u, E, S), w = `${m}-${n.join(".")}-${c}`;
878
- return le(at, {
874
+ return (e) => {
875
+ const n = o.getState().getNestedState(t, r);
876
+ return Array.isArray(n) ? (S?.validIndices || Array.from({ length: n.length }, (c, f) => f)).map((c, f) => {
877
+ const u = n[c], E = [...r, c.toString()], y = s(u, E, S), w = `${m}-${r.join(".")}-${c}`;
878
+ return lt(ae, {
879
879
  key: c,
880
- stateKey: e,
880
+ stateKey: t,
881
881
  itemComponentId: w,
882
882
  itemPath: E,
883
- children: t(
883
+ children: e(
884
884
  u,
885
885
  y,
886
886
  f,
887
- r,
888
- s(r, n, S)
887
+ n,
888
+ s(n, r, S)
889
889
  )
890
890
  });
891
891
  }) : (console.warn(
892
- `stateList called on a non-array value at path: ${n.join(".")}.`
892
+ `stateList called on a non-array value at path: ${r.join(".")}.`
893
893
  ), null);
894
894
  };
895
895
  if (l === "stateFlattenOn")
896
- return (t) => {
897
- const r = T;
898
- I.clear(), N++;
899
- const a = r.flatMap(
900
- (c) => c[t] ?? []
896
+ return (e) => {
897
+ const n = I;
898
+ T.clear(), N++;
899
+ const a = n.flatMap(
900
+ (c) => c[e] ?? []
901
901
  );
902
902
  return s(
903
903
  a,
904
- [...n, "[*]", t],
904
+ [...r, "[*]", e],
905
905
  S
906
906
  );
907
907
  };
908
908
  if (l === "index")
909
- return (t) => {
910
- const r = T[t];
911
- return s(r, [...n, t.toString()]);
909
+ return (e) => {
910
+ const n = I[e];
911
+ return s(n, [...r, e.toString()]);
912
912
  };
913
913
  if (l === "last")
914
914
  return () => {
915
- const t = o.getState().getNestedState(e, n);
916
- if (t.length === 0) return;
917
- const r = t.length - 1, a = t[r], c = [...n, r.toString()];
915
+ const e = o.getState().getNestedState(t, r);
916
+ if (e.length === 0) return;
917
+ const n = e.length - 1, a = e[n], c = [...r, n.toString()];
918
918
  return s(a, c);
919
919
  };
920
920
  if (l === "insert")
921
- return (t) => (p(n), Ee(i, t, n, e), s(
922
- o.getState().getNestedState(e, n),
923
- n
921
+ return (e) => (p(r), Et(i, e, r, t), s(
922
+ o.getState().getNestedState(t, r),
923
+ r
924
924
  ));
925
925
  if (l === "uniqueInsert")
926
- return (t, r, a) => {
927
- const c = o.getState().getNestedState(e, n), f = ee(t) ? t(c) : t;
926
+ return (e, n, a) => {
927
+ const c = o.getState().getNestedState(t, r), f = tt(e) ? e(c) : e;
928
928
  let u = null;
929
929
  if (!c.some((y) => {
930
- if (r) {
931
- const C = r.every(
930
+ if (n) {
931
+ const C = n.every(
932
932
  (A) => J(y[A], f[A])
933
933
  );
934
934
  return C && (u = y), C;
@@ -936,124 +936,134 @@ function Te(e, i, m, g) {
936
936
  const w = J(y, f);
937
937
  return w && (u = y), w;
938
938
  }))
939
- p(n), Ee(i, f, n, e);
939
+ p(r), Et(i, f, r, t);
940
940
  else if (a && u) {
941
941
  const y = a(u), w = c.map(
942
942
  (C) => J(C, u) ? y : C
943
943
  );
944
- p(n), ie(i, w, n);
944
+ p(r), it(i, w, r);
945
945
  }
946
946
  };
947
947
  if (l === "cut")
948
- return (t, r) => {
949
- if (!r?.waitForSync)
950
- return p(n), me(i, n, e, t), s(
951
- o.getState().getNestedState(e, n),
952
- n
948
+ return (e, n) => {
949
+ if (!n?.waitForSync)
950
+ return p(r), ht(i, r, t, e), s(
951
+ o.getState().getNestedState(t, r),
952
+ r
953
953
  );
954
954
  };
955
955
  if (l === "cutByValue")
956
- return (t) => {
957
- for (let r = 0; r < T.length; r++)
958
- T[r] === t && me(i, n, e, r);
956
+ return (e) => {
957
+ for (let n = 0; n < I.length; n++)
958
+ I[n] === e && ht(i, r, t, n);
959
959
  };
960
960
  if (l === "toggleByValue")
961
- return (t) => {
962
- const r = T.findIndex((a) => a === t);
963
- r > -1 ? me(i, n, e, r) : Ee(i, t, n, e);
961
+ return (e) => {
962
+ const n = I.findIndex((a) => a === e);
963
+ n > -1 ? ht(i, r, t, n) : Et(i, e, r, t);
964
964
  };
965
965
  if (l === "stateFind")
966
- return (t) => {
966
+ return (e) => {
967
967
  const a = d().find(
968
- ({ item: f }, u) => t(f, u)
968
+ ({ item: f }, u) => e(f, u)
969
969
  );
970
970
  if (!a) return;
971
- const c = [...n, a.originalIndex.toString()];
971
+ const c = [...r, a.originalIndex.toString()];
972
972
  return s(a.item, c, S);
973
973
  };
974
974
  if (l === "findWith")
975
- return (t, r) => {
975
+ return (e, n) => {
976
976
  const c = d().find(
977
- ({ item: u }) => u[t] === r
977
+ ({ item: u }) => u[e] === n
978
978
  );
979
979
  if (!c) return;
980
- const f = [...n, c.originalIndex.toString()];
980
+ const f = [...r, c.originalIndex.toString()];
981
981
  return s(c.item, f, S);
982
982
  };
983
983
  }
984
- const te = n[n.length - 1];
985
- if (!isNaN(Number(te))) {
986
- const d = n.slice(0, -1), t = o.getState().getNestedState(e, d);
987
- if (Array.isArray(t) && l === "cut")
988
- return () => me(
984
+ const et = r[r.length - 1];
985
+ if (!isNaN(Number(et))) {
986
+ const d = r.slice(0, -1), e = o.getState().getNestedState(t, d);
987
+ if (Array.isArray(e) && l === "cut")
988
+ return () => ht(
989
989
  i,
990
990
  d,
991
- e,
992
- Number(te)
991
+ t,
992
+ Number(et)
993
993
  );
994
994
  }
995
995
  if (l === "get")
996
996
  return () => {
997
- if (S?.validIndices && Array.isArray(T)) {
998
- const d = o.getState().getNestedState(e, n);
999
- return S.validIndices.map((t) => d[t]);
997
+ if (S?.validIndices && Array.isArray(I)) {
998
+ const d = o.getState().getNestedState(t, r);
999
+ return S.validIndices.map((e) => d[e]);
1000
1000
  }
1001
- return o.getState().getNestedState(e, n);
1001
+ return o.getState().getNestedState(t, r);
1002
1002
  };
1003
1003
  if (l === "$derive")
1004
- return (d) => Ve({
1005
- _stateKey: e,
1006
- _path: n,
1004
+ return (d) => Vt({
1005
+ _stateKey: t,
1006
+ _path: r,
1007
1007
  _effect: d.toString()
1008
1008
  });
1009
1009
  if (l === "$get")
1010
- return () => Ve({
1011
- _stateKey: e,
1012
- _path: n
1010
+ return () => Vt({
1011
+ _stateKey: t,
1012
+ _path: r
1013
1013
  });
1014
1014
  if (l === "lastSynced") {
1015
- const d = `${e}:${n.join(".")}`;
1015
+ const d = `${t}:${r.join(".")}`;
1016
1016
  return o.getState().getSyncInfo(d);
1017
1017
  }
1018
1018
  if (l == "getLocalStorage")
1019
- return (d) => Ie(g + "-" + e + "-" + d);
1019
+ return (d) => vt(g + "-" + t + "-" + d);
1020
1020
  if (l === "_selected") {
1021
- const d = n.slice(0, -1), t = d.join("."), r = o.getState().getNestedState(e, d);
1022
- return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(e, t) : void 0;
1021
+ const d = r.slice(0, -1), e = d.join("."), n = o.getState().getNestedState(t, d);
1022
+ return Array.isArray(n) ? Number(r[r.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
1023
1023
  }
1024
1024
  if (l === "setSelected")
1025
1025
  return (d) => {
1026
- const t = n.slice(0, -1), r = Number(n[n.length - 1]), a = t.join(".");
1027
- d ? o.getState().setSelectedIndex(e, a, r) : o.getState().setSelectedIndex(e, a, void 0);
1028
- const c = o.getState().getNestedState(e, [...t]);
1029
- ie(i, c, t), p(t);
1026
+ const e = r.slice(0, -1), n = Number(r[r.length - 1]), a = e.join(".");
1027
+ d ? o.getState().setSelectedIndex(t, a, n) : o.getState().setSelectedIndex(t, a, void 0);
1028
+ const c = o.getState().getNestedState(t, [...e]);
1029
+ it(i, c, e), p(e);
1030
1030
  };
1031
1031
  if (l === "toggleSelected")
1032
1032
  return () => {
1033
- const d = n.slice(0, -1), t = Number(n[n.length - 1]), r = d.join("."), a = o.getState().getSelectedIndex(e, r);
1033
+ const d = r.slice(0, -1), e = Number(r[r.length - 1]), n = d.join("."), a = o.getState().getSelectedIndex(t, n);
1034
1034
  o.getState().setSelectedIndex(
1035
- e,
1036
- r,
1037
- a === t ? void 0 : t
1035
+ t,
1036
+ n,
1037
+ a === e ? void 0 : e
1038
1038
  );
1039
- const c = o.getState().getNestedState(e, [...d]);
1040
- ie(i, c, d), p(d);
1039
+ const c = o.getState().getNestedState(t, [...d]);
1040
+ it(i, c, d), p(d);
1041
1041
  };
1042
- if (n.length == 0) {
1042
+ if (r.length == 0) {
1043
+ if (l === "addValidation")
1044
+ return (d) => {
1045
+ const e = o.getState().getInitialOptions(t)?.validation;
1046
+ if (!e?.key)
1047
+ throw new Error("Validation key not found");
1048
+ X(e.key), d.forEach((n) => {
1049
+ const a = [e.key, ...n.path].join(".");
1050
+ Rt(a, n.message);
1051
+ }), dt(t);
1052
+ };
1043
1053
  if (l === "applyJsonPatch")
1044
1054
  return (d) => {
1045
- const t = o.getState().cogsStateStore[e], a = Je(t, d).newDocument;
1046
- Re(
1047
- e,
1048
- o.getState().initialStateGlobal[e],
1055
+ const e = o.getState().cogsStateStore[t], a = Yt(e, d).newDocument;
1056
+ Dt(
1057
+ t,
1058
+ o.getState().initialStateGlobal[t],
1049
1059
  a,
1050
1060
  i,
1051
1061
  m,
1052
1062
  g
1053
1063
  );
1054
- const c = o.getState().stateComponents.get(e);
1064
+ const c = o.getState().stateComponents.get(t);
1055
1065
  if (c) {
1056
- const f = _e(t, a), u = new Set(f);
1066
+ const f = _t(e, a), u = new Set(f);
1057
1067
  for (const [
1058
1068
  E,
1059
1069
  y
@@ -1110,203 +1120,203 @@ function Te(e, i, m, g) {
1110
1120
  };
1111
1121
  if (l === "validateZodSchema")
1112
1122
  return () => {
1113
- const d = o.getState().getInitialOptions(e)?.validation, t = o.getState().addValidationError;
1123
+ const d = o.getState().getInitialOptions(t)?.validation, e = o.getState().addValidationError;
1114
1124
  if (!d?.zodSchema)
1115
1125
  throw new Error("Zod schema not found");
1116
1126
  if (!d?.key)
1117
1127
  throw new Error("Validation key not found");
1118
- Q(d.key);
1119
- const r = o.getState().cogsStateStore[e];
1128
+ X(d.key);
1129
+ const n = o.getState().cogsStateStore[t];
1120
1130
  try {
1121
1131
  const a = o.getState().getValidationErrors(d.key);
1122
1132
  a && a.length > 0 && a.forEach(([f]) => {
1123
- f && f.startsWith(d.key) && Q(f);
1133
+ f && f.startsWith(d.key) && X(f);
1124
1134
  });
1125
- const c = d.zodSchema.safeParse(r);
1135
+ const c = d.zodSchema.safeParse(n);
1126
1136
  return c.success ? !0 : (c.error.errors.forEach((u) => {
1127
1137
  const E = u.path, y = u.message, w = [d.key, ...E].join(".");
1128
- t(w, y);
1129
- }), ve(e), !1);
1138
+ e(w, y);
1139
+ }), dt(t), !1);
1130
1140
  } catch (a) {
1131
1141
  return console.error("Zod schema validation failed", a), !1;
1132
1142
  }
1133
1143
  };
1134
1144
  if (l === "_componentId") return m;
1135
1145
  if (l === "getComponents")
1136
- return () => o().stateComponents.get(e);
1146
+ return () => o().stateComponents.get(t);
1137
1147
  if (l === "getAllFormRefs")
1138
- return () => be.getState().getFormRefsByStateKey(e);
1148
+ return () => bt.getState().getFormRefsByStateKey(t);
1139
1149
  if (l === "_initialState")
1140
- return o.getState().initialStateGlobal[e];
1150
+ return o.getState().initialStateGlobal[t];
1141
1151
  if (l === "_serverState")
1142
- return o.getState().serverState[e];
1152
+ return o.getState().serverState[t];
1143
1153
  if (l === "_isLoading")
1144
- return o.getState().isLoadingGlobal[e];
1154
+ return o.getState().isLoadingGlobal[t];
1145
1155
  if (l === "revertToInitialState")
1146
1156
  return v.revertToInitialState;
1147
1157
  if (l === "updateInitialState") return v.updateInitialState;
1148
1158
  if (l === "removeValidation") return v.removeValidation;
1149
1159
  }
1150
1160
  if (l === "getFormRef")
1151
- return () => be.getState().getFormRef(e + "." + n.join("."));
1161
+ return () => bt.getState().getFormRef(t + "." + r.join("."));
1152
1162
  if (l === "validationWrapper")
1153
1163
  return ({
1154
1164
  children: d,
1155
- hideMessage: t
1156
- }) => /* @__PURE__ */ Oe(
1157
- We,
1165
+ hideMessage: e
1166
+ }) => /* @__PURE__ */ Ot(
1167
+ zt,
1158
1168
  {
1159
- formOpts: t ? { validation: { message: "" } } : void 0,
1160
- path: n,
1161
- validationKey: o.getState().getInitialOptions(e)?.validation?.key || "",
1162
- stateKey: e,
1169
+ formOpts: e ? { validation: { message: "" } } : void 0,
1170
+ path: r,
1171
+ validationKey: o.getState().getInitialOptions(t)?.validation?.key || "",
1172
+ stateKey: t,
1163
1173
  validIndices: S?.validIndices,
1164
1174
  children: d
1165
1175
  }
1166
1176
  );
1167
- if (l === "_stateKey") return e;
1168
- if (l === "_path") return n;
1177
+ if (l === "_stateKey") return t;
1178
+ if (l === "_path") return r;
1169
1179
  if (l === "_isServerSynced") return v._isServerSynced;
1170
1180
  if (l === "update")
1171
- return (d, t) => {
1172
- if (t?.debounce)
1173
- Be(() => {
1174
- ie(i, d, n, "");
1175
- const r = o.getState().getNestedState(e, n);
1176
- t?.afterUpdate && t.afterUpdate(r);
1177
- }, t.debounce);
1181
+ return (d, e) => {
1182
+ if (e?.debounce)
1183
+ Wt(() => {
1184
+ it(i, d, r, "");
1185
+ const n = o.getState().getNestedState(t, r);
1186
+ e?.afterUpdate && e.afterUpdate(n);
1187
+ }, e.debounce);
1178
1188
  else {
1179
- ie(i, d, n, "");
1180
- const r = o.getState().getNestedState(e, n);
1181
- t?.afterUpdate && t.afterUpdate(r);
1189
+ it(i, d, r, "");
1190
+ const n = o.getState().getNestedState(t, r);
1191
+ e?.afterUpdate && e.afterUpdate(n);
1182
1192
  }
1183
- p(n);
1193
+ p(r);
1184
1194
  };
1185
1195
  if (l === "formElement")
1186
- return (d, t) => /* @__PURE__ */ Oe(
1187
- ze,
1196
+ return (d, e) => /* @__PURE__ */ Ot(
1197
+ qt,
1188
1198
  {
1189
1199
  setState: i,
1190
- stateKey: e,
1191
- path: n,
1200
+ stateKey: t,
1201
+ path: r,
1192
1202
  child: d,
1193
- formOpts: t
1203
+ formOpts: e
1194
1204
  }
1195
1205
  );
1196
- const L = [...n, l], ae = o.getState().getNestedState(e, L);
1197
- return s(ae, L, S);
1206
+ const L = [...r, l], at = o.getState().getNestedState(t, L);
1207
+ return s(at, L, S);
1198
1208
  }
1199
- }, z = new Proxy(U, j);
1200
- return I.set(W, {
1209
+ }, z = new Proxy(j, U);
1210
+ return T.set(W, {
1201
1211
  proxy: z,
1202
1212
  stateVersion: N
1203
1213
  }), z;
1204
1214
  }
1205
1215
  return s(
1206
- o.getState().getNestedState(e, [])
1216
+ o.getState().getNestedState(t, [])
1207
1217
  );
1208
1218
  }
1209
- function Ve(e) {
1210
- return le(ot, { proxy: e });
1219
+ function Vt(t) {
1220
+ return lt(oe, { proxy: t });
1211
1221
  }
1212
- function rt({
1213
- proxy: e,
1222
+ function re({
1223
+ proxy: t,
1214
1224
  rebuildStateShape: i
1215
1225
  }) {
1216
- const m = o().getNestedState(e._stateKey, e._path);
1226
+ const m = o().getNestedState(t._stateKey, t._path);
1217
1227
  return Array.isArray(m) ? i(
1218
1228
  m,
1219
- e._path
1229
+ t._path
1220
1230
  ).stateMapNoRender(
1221
- (I, N, p, v, s) => e._mapFn(I, N, p, v, s)
1231
+ (T, N, p, v, s) => t._mapFn(T, N, p, v, s)
1222
1232
  ) : null;
1223
1233
  }
1224
- function ot({
1225
- proxy: e
1234
+ function oe({
1235
+ proxy: t
1226
1236
  }) {
1227
- const i = q(null), m = `${e._stateKey}-${e._path.join(".")}`;
1228
- return oe(() => {
1237
+ const i = q(null), m = `${t._stateKey}-${t._path.join(".")}`;
1238
+ return ot(() => {
1229
1239
  const g = i.current;
1230
1240
  if (!g || !g.parentElement) return;
1231
- const I = g.parentElement, p = Array.from(I.childNodes).indexOf(g);
1232
- let v = I.getAttribute("data-parent-id");
1233
- v || (v = `parent-${crypto.randomUUID()}`, I.setAttribute("data-parent-id", v));
1234
- const T = {
1241
+ const T = g.parentElement, p = Array.from(T.childNodes).indexOf(g);
1242
+ let v = T.getAttribute("data-parent-id");
1243
+ v || (v = `parent-${crypto.randomUUID()}`, T.setAttribute("data-parent-id", v));
1244
+ const I = {
1235
1245
  instanceId: `instance-${crypto.randomUUID()}`,
1236
1246
  parentId: v,
1237
1247
  position: p,
1238
- effect: e._effect
1248
+ effect: t._effect
1239
1249
  };
1240
- o.getState().addSignalElement(m, T);
1241
- const n = o.getState().getNestedState(e._stateKey, e._path);
1250
+ o.getState().addSignalElement(m, I);
1251
+ const r = o.getState().getNestedState(t._stateKey, t._path);
1242
1252
  let S;
1243
- if (e._effect)
1253
+ if (t._effect)
1244
1254
  try {
1245
1255
  S = new Function(
1246
1256
  "state",
1247
- `return (${e._effect})(state)`
1248
- )(n);
1249
- } catch (U) {
1250
- console.error("Error evaluating effect function during mount:", U), S = n;
1257
+ `return (${t._effect})(state)`
1258
+ )(r);
1259
+ } catch (j) {
1260
+ console.error("Error evaluating effect function during mount:", j), S = r;
1251
1261
  }
1252
1262
  else
1253
- S = n;
1263
+ S = r;
1254
1264
  S !== null && typeof S == "object" && (S = JSON.stringify(S));
1255
1265
  const W = document.createTextNode(String(S));
1256
1266
  g.replaceWith(W);
1257
- }, [e._stateKey, e._path.join("."), e._effect]), le("span", {
1267
+ }, [t._stateKey, t._path.join("."), t._effect]), lt("span", {
1258
1268
  ref: i,
1259
1269
  style: { display: "none" },
1260
1270
  "data-signal-id": m
1261
1271
  });
1262
1272
  }
1263
- function pt(e) {
1264
- const i = je(
1273
+ function pe(t) {
1274
+ const i = Ht(
1265
1275
  (m) => {
1266
- const g = o.getState().stateComponents.get(e._stateKey) || {
1276
+ const g = o.getState().stateComponents.get(t._stateKey) || {
1267
1277
  components: /* @__PURE__ */ new Map()
1268
1278
  };
1269
- return g.components.set(e._stateKey, {
1279
+ return g.components.set(t._stateKey, {
1270
1280
  forceUpdate: m,
1271
- paths: /* @__PURE__ */ new Set([e._path.join(".")])
1272
- }), () => g.components.delete(e._stateKey);
1281
+ paths: /* @__PURE__ */ new Set([t._path.join(".")])
1282
+ }), () => g.components.delete(t._stateKey);
1273
1283
  },
1274
- () => o.getState().getNestedState(e._stateKey, e._path)
1284
+ () => o.getState().getNestedState(t._stateKey, t._path)
1275
1285
  );
1276
- return le("text", {}, String(i));
1286
+ return lt("text", {}, String(i));
1277
1287
  }
1278
- function at({
1279
- stateKey: e,
1288
+ function ae({
1289
+ stateKey: t,
1280
1290
  itemComponentId: i,
1281
1291
  itemPath: m,
1282
1292
  children: g
1283
1293
  }) {
1284
- const [, I] = K({}), [N, p] = Ye(), v = q(null);
1285
- return oe(() => {
1286
- p.height > 0 && p.height !== v.current && (v.current = p.height, o.getState().setShadowMetadata(e, m, {
1294
+ const [, T] = K({}), [N, p] = Zt(), v = q(null);
1295
+ return ot(() => {
1296
+ p.height > 0 && p.height !== v.current && (v.current = p.height, o.getState().setShadowMetadata(t, m, {
1287
1297
  virtualizer: {
1288
1298
  itemHeight: p.height
1289
1299
  }
1290
1300
  }));
1291
- }, [p.height, e, m]), ce(() => {
1292
- const s = `${e}////${i}`, T = o.getState().stateComponents.get(e) || {
1301
+ }, [p.height, t, m]), ct(() => {
1302
+ const s = `${t}////${i}`, I = o.getState().stateComponents.get(t) || {
1293
1303
  components: /* @__PURE__ */ new Map()
1294
1304
  };
1295
- return T.components.set(s, {
1296
- forceUpdate: () => I({}),
1305
+ return I.components.set(s, {
1306
+ forceUpdate: () => T({}),
1297
1307
  paths: /* @__PURE__ */ new Set([m.join(".")])
1298
- }), o.getState().stateComponents.set(e, T), () => {
1299
- const n = o.getState().stateComponents.get(e);
1300
- n && n.components.delete(s);
1308
+ }), o.getState().stateComponents.set(t, I), () => {
1309
+ const r = o.getState().stateComponents.get(t);
1310
+ r && r.components.delete(s);
1301
1311
  };
1302
- }, [e, i, m.join(".")]), /* @__PURE__ */ Oe("div", { ref: N, children: g });
1312
+ }, [t, i, m.join(".")]), /* @__PURE__ */ Ot("div", { ref: N, children: g });
1303
1313
  }
1304
1314
  export {
1305
- Ve as $cogsSignal,
1306
- pt as $cogsSignalStore,
1307
- It as addStateOptions,
1308
- vt as createCogsState,
1309
- yt as notifyComponent,
1310
- nt as useCogsStateFn
1315
+ Vt as $cogsSignal,
1316
+ pe as $cogsSignalStore,
1317
+ Te as addStateOptions,
1318
+ ve as createCogsState,
1319
+ ye as notifyComponent,
1320
+ ne as useCogsStateFn
1311
1321
  };
1312
1322
  //# sourceMappingURL=CogsState.jsx.map