cogsbox-state 0.5.119 → 0.5.120

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,57 +1,57 @@
1
1
  "use client";
2
- import { jsx as ct } from "react/jsx-runtime";
3
- import { useState as tt, useRef as Z, useEffect as et, useLayoutEffect as vt, useMemo as It, createElement as X, useSyncExternalStore as _t, startTransition as Et } from "react";
4
- import { transformStateFunc as wt, isFunction as L, getNestedValue as U, isDeepEqual as M, debounce as $t } from "./utility.js";
5
- import { pushFunc as Q, updateFn as B, cutFunc as J, ValidationWrapper as At, FormControlComponent as Nt } from "./Functions.jsx";
2
+ import { jsx as ce } from "react/jsx-runtime";
3
+ import { useState as ee, useRef as Z, useEffect as te, useLayoutEffect as ve, useMemo as Ie, createElement as X, useSyncExternalStore as _e, startTransition as Ee } from "react";
4
+ import { transformStateFunc as we, isFunction as L, getNestedValue as U, isDeepEqual as M, debounce as $e } from "./utility.js";
5
+ import { pushFunc as Q, updateFn as B, cutFunc as J, ValidationWrapper as Ae, FormControlComponent as Ne } from "./Functions.jsx";
6
6
  import "zod";
7
- import { getGlobalStore as r, formRefStore as lt } from "./store.js";
8
- import { useCogsConfig as Vt } from "./CogsStateClient.jsx";
9
- import nt from "./node_modules/uuid/dist/esm-browser/v4.js";
10
- function dt(t, i) {
11
- const y = r.getState().getInitialOptions, v = r.getState().setInitialStateOptions, d = y(t) || {};
12
- v(t, {
7
+ import { getGlobalStore as r, formRefStore as le } from "./store.js";
8
+ import { useCogsConfig as Te } from "./CogsStateClient.jsx";
9
+ import ne from "./node_modules/uuid/dist/esm-browser/v4.js";
10
+ function de(e, i) {
11
+ const v = r.getState().getInitialOptions, S = r.getState().setInitialStateOptions, d = v(e) || {};
12
+ S(e, {
13
13
  ...d,
14
14
  ...i
15
15
  });
16
16
  }
17
- function ut({
18
- stateKey: t,
17
+ function ue({
18
+ stateKey: e,
19
19
  options: i,
20
- initialOptionsPart: y
20
+ initialOptionsPart: v
21
21
  }) {
22
- const v = q(t) || {}, d = y[t] || {}, E = r.getState().setInitialStateOptions, _ = { ...d, ...v };
23
- let S = !1;
22
+ const S = q(e) || {}, d = v[e] || {}, E = r.getState().setInitialStateOptions, _ = { ...d, ...S };
23
+ let m = !1;
24
24
  if (i)
25
25
  for (const c in i)
26
- _.hasOwnProperty(c) ? (c == "localStorage" && i[c] && _[c].key !== i[c]?.key && (S = !0, _[c] = i[c]), c == "initialState" && i[c] && _[c] !== i[c] && (S = !0, _[c] = i[c])) : (S = !0, _[c] = i[c]);
27
- S && E(t, _);
26
+ _.hasOwnProperty(c) ? (c == "localStorage" && i[c] && _[c].key !== i[c]?.key && (m = !0, _[c] = i[c]), c == "initialState" && i[c] && _[c] !== i[c] && (m = !0, _[c] = i[c])) : (m = !0, _[c] = i[c]);
27
+ m && E(e, _);
28
28
  }
29
- function qt(t, { formElements: i, validation: y }) {
30
- return { initialState: t, formElements: i, validation: y };
29
+ function qe(e, { formElements: i, validation: v }) {
30
+ return { initialState: e, formElements: i, validation: v };
31
31
  }
32
- const zt = (t, i) => {
33
- let y = t;
34
- const [v, d] = wt(y);
35
- (Object.keys(d).length > 0 || i && Object.keys(i).length > 0) && Object.keys(d).forEach((S) => {
36
- d[S] = d[S] || {}, d[S].formElements = {
32
+ const ze = (e, i) => {
33
+ let v = e;
34
+ const [S, d] = we(v);
35
+ (Object.keys(d).length > 0 || i && Object.keys(i).length > 0) && Object.keys(d).forEach((m) => {
36
+ d[m] = d[m] || {}, d[m].formElements = {
37
37
  ...i?.formElements,
38
38
  // Global defaults first
39
39
  ...i?.validation,
40
- ...d[S].formElements || {}
40
+ ...d[m].formElements || {}
41
41
  // State-specific overrides
42
- }, q(S) || r.getState().setInitialStateOptions(S, d[S]);
43
- }), r.getState().setInitialStates(v), r.getState().setCreatedState(v);
44
- const E = (S, c) => {
45
- const [f] = tt(c?.componentId ?? nt());
46
- ut({
47
- stateKey: S,
42
+ }, q(m) || r.getState().setInitialStateOptions(m, d[m]);
43
+ }), r.getState().setInitialStates(S), r.getState().setCreatedState(S);
44
+ const E = (m, c) => {
45
+ const [f] = ee(c?.componentId ?? ne());
46
+ ue({
47
+ stateKey: m,
48
48
  options: c,
49
49
  initialOptionsPart: d
50
50
  });
51
- const e = r.getState().cogsStateStore[S] || v[S], m = c?.modifyState ? c.modifyState(e) : e, [k, p] = Ot(
52
- m,
51
+ const t = r.getState().cogsStateStore[m] || S[m], y = c?.modifyState ? c.modifyState(t) : t, [k, V] = Oe(
52
+ y,
53
53
  {
54
- stateKey: S,
54
+ stateKey: m,
55
55
  syncUpdate: c?.syncUpdate,
56
56
  componentId: f,
57
57
  localStorage: c?.localStorage,
@@ -63,145 +63,149 @@ const zt = (t, i) => {
63
63
  dependencies: c?.dependencies
64
64
  }
65
65
  );
66
- return p;
66
+ return V;
67
67
  };
68
- function _(S, c) {
69
- ut({ stateKey: S, options: c, initialOptionsPart: d }), ot(S);
68
+ function _(m, c) {
69
+ ue({ stateKey: m, options: c, initialOptionsPart: d }), oe(m);
70
70
  }
71
71
  return { useCogsState: E, setCogsOptions: _ };
72
72
  }, {
73
73
  setUpdaterState: H,
74
74
  setState: D,
75
75
  getInitialOptions: q,
76
- getKeyState: gt,
77
- getValidationErrors: pt,
78
- setStateLog: Ct,
79
- updateInitialStateGlobal: rt,
80
- addValidationError: Tt,
76
+ getKeyState: ge,
77
+ getValidationErrors: Ve,
78
+ setStateLog: pe,
79
+ updateInitialStateGlobal: re,
80
+ addValidationError: Ce,
81
81
  removeValidationError: P,
82
- setServerSyncActions: ht
83
- } = r.getState(), ft = (t) => {
84
- if (!t) return null;
82
+ setServerSyncActions: he
83
+ } = r.getState(), fe = (e) => {
84
+ if (!e) return null;
85
85
  try {
86
- const i = window.localStorage.getItem(t);
86
+ const i = window.localStorage.getItem(e);
87
87
  return i ? JSON.parse(i) : null;
88
88
  } catch (i) {
89
89
  return console.error("Error loading from localStorage:", i), null;
90
90
  }
91
- }, kt = (t, i, y, v) => {
92
- y?.log && console.log(
91
+ }, ke = (e, i, v, S) => {
92
+ v?.log && console.log(
93
93
  "saving to localstorage",
94
94
  i,
95
- y.localStorage?.key,
96
- v
95
+ v.localStorage?.key,
96
+ S
97
97
  );
98
- const d = L(y?.localStorage?.key) ? y.localStorage?.key(t) : y?.localStorage?.key;
99
- if (d && v) {
98
+ const d = L(v?.localStorage?.key) ? v.localStorage?.key(e) : v?.localStorage?.key;
99
+ if (d && S) {
100
100
  const E = {
101
- state: t,
101
+ state: e,
102
102
  lastUpdated: Date.now(),
103
103
  lastSyncedWithServer: r.getState().serverSyncLog[i]?.[0]?.timeStamp,
104
104
  baseServerState: r.getState().serverState[i]
105
- }, _ = `${v}-${i}-${d}`;
105
+ }, _ = `${S}-${i}-${d}`;
106
106
  window.localStorage.setItem(_, JSON.stringify(E));
107
107
  }
108
- }, xt = (t, i, y, v, d, E) => {
108
+ }, xe = (e, i, v, S, d, E) => {
109
109
  const _ = {
110
110
  initialState: i,
111
111
  updaterState: Y(
112
- t,
113
- v,
112
+ e,
113
+ S,
114
114
  d,
115
115
  E
116
116
  ),
117
- state: y
117
+ state: v
118
118
  };
119
- rt(t, _.initialState), H(t, _.updaterState), D(t, _.state);
120
- }, ot = (t) => {
121
- const i = r.getState().stateComponents.get(t);
119
+ re(e, _.initialState), H(e, _.updaterState), D(e, _.state);
120
+ }, oe = (e) => {
121
+ const i = r.getState().stateComponents.get(e);
122
122
  if (!i) return;
123
- const y = /* @__PURE__ */ new Set();
124
- i.components.forEach((v) => {
125
- y.add(() => v.forceUpdate());
123
+ const v = /* @__PURE__ */ new Set();
124
+ i.components.forEach((S) => {
125
+ (S ? Array.isArray(S.reactiveType) ? S.reactiveType : [S.reactiveType || "component"] : null)?.includes("none") || v.add(() => S.forceUpdate());
126
126
  }), queueMicrotask(() => {
127
- y.forEach((v) => v());
127
+ v.forEach((S) => S());
128
128
  });
129
- }, Bt = (t, i) => {
130
- const y = r.getState().stateComponents.get(t);
131
- if (y) {
132
- const v = `${t}////${i}`, d = y.components.get(v);
129
+ }, Be = (e, i) => {
130
+ const v = r.getState().stateComponents.get(e);
131
+ if (v) {
132
+ const S = `${e}////${i}`, d = v.components.get(S);
133
133
  if ((d ? Array.isArray(d.reactiveType) ? d.reactiveType : [d.reactiveType || "component"] : null)?.includes("none"))
134
134
  return;
135
135
  d && d.forceUpdate();
136
136
  }
137
137
  };
138
- function Ot(t, {
138
+ function Oe(e, {
139
139
  stateKey: i,
140
- serverSync: y,
141
- localStorage: v,
140
+ serverSync: v,
141
+ localStorage: S,
142
142
  formElements: d,
143
143
  middleware: E,
144
144
  reactiveDeps: _,
145
- reactiveType: S,
145
+ reactiveType: m,
146
146
  componentId: c,
147
147
  initialState: f,
148
- syncUpdate: e,
149
- dependencies: m
148
+ syncUpdate: t,
149
+ dependencies: y
150
150
  } = {}) {
151
- const [k, p] = tt({}), { sessionId: x } = Vt();
151
+ const [k, V] = ee({}), { sessionId: x } = Te();
152
152
  let R = !i;
153
- const [g] = tt(i ?? nt()), s = r.getState().stateLog[g], G = Z(/* @__PURE__ */ new Set()), b = Z(c ?? nt()), T = Z(null);
154
- T.current = q(g), et(() => {
155
- if (e && e.stateKey === g && e.path?.[0]) {
153
+ const [g] = ee(i ?? ne()), s = r.getState().stateLog[g], G = Z(/* @__PURE__ */ new Set()), b = Z(c ?? ne()), C = Z(null);
154
+ C.current = q(g), te(() => {
155
+ if (t && t.stateKey === g && t.path?.[0]) {
156
156
  D(g, (o) => ({
157
157
  ...o,
158
- [e.path[0]]: e.newValue
158
+ [t.path[0]]: t.newValue
159
159
  }));
160
- const l = `${e.stateKey}:${e.path.join(".")}`;
160
+ const l = `${t.stateKey}:${t.path.join(".")}`;
161
161
  r.getState().setSyncInfo(l, {
162
- timeStamp: e.timeStamp,
163
- userId: e.userId
162
+ timeStamp: t.timeStamp,
163
+ userId: t.userId
164
164
  });
165
165
  }
166
- }, [e]), et(() => {
167
- f && dt(g, {
166
+ }, [t]), te(() => {
167
+ f && de(g, {
168
168
  initialState: f
169
169
  });
170
- const l = T.current;
170
+ const l = C.current;
171
171
  let o = null;
172
172
  const u = L(l?.localStorage?.key) ? l?.localStorage?.key(f) : l?.localStorage?.key;
173
- console.log("newoptions", l), console.log("localkey", u), console.log("initialState", f), u && x && (o = ft(
173
+ console.log("newoptions", l), console.log("localkey", u), console.log("initialState", f), u && x && (o = fe(
174
174
  x + "-" + g + "-" + u
175
175
  ));
176
176
  const w = r.getState().iniitialCreatedState[g];
177
177
  console.log("createdState - intiual", w, f);
178
178
  let N = null;
179
- f && (N = f, o && o.lastUpdated > (o.lastSyncedWithServer || 0) && (N = o.state, l?.localStorage?.onChange && l?.localStorage?.onChange(N)), console.log("newState thius is newstate", N), xt(
180
- g,
181
- f,
182
- N,
183
- n,
184
- b.current,
185
- x
186
- ), ot(g), (Array.isArray(S) ? S : [S || "component"]).includes("none") || p({}));
187
- }, [f, ...m || []]), vt(() => {
188
- R && dt(g, {
189
- serverSync: y,
179
+ if (f) {
180
+ N = f, o && o.lastUpdated > (o.lastSyncedWithServer || 0) && (N = o.state, l?.localStorage?.onChange && l?.localStorage?.onChange(N)), console.log("newState thius is newstate", N), xe(
181
+ g,
182
+ f,
183
+ N,
184
+ n,
185
+ b.current,
186
+ x
187
+ ), oe(g);
188
+ const $ = Array.isArray(m) ? m : [m || "component"];
189
+ console.log("reactiveTypes.............................", $), $.includes("none") || V({});
190
+ }
191
+ }, [f, ...y || []]), ve(() => {
192
+ R && de(g, {
193
+ serverSync: v,
190
194
  formElements: d,
191
195
  initialState: f,
192
- localStorage: v,
196
+ localStorage: S,
193
197
  middleware: E
194
198
  });
195
199
  const l = `${g}////${b.current}`, o = r.getState().stateComponents.get(g) || {
196
200
  components: /* @__PURE__ */ new Map()
197
201
  };
198
202
  return o.components.set(l, {
199
- forceUpdate: () => p({}),
203
+ forceUpdate: () => V({}),
200
204
  paths: /* @__PURE__ */ new Set(),
201
205
  deps: [],
202
206
  depsFunction: _ || void 0,
203
- reactiveType: S ?? ["component", "deps"]
204
- }), r.getState().stateComponents.set(g, o), p({}), () => {
207
+ reactiveType: m ?? ["component", "deps"]
208
+ }), r.getState().stateComponents.set(g, o), V({}), () => {
205
209
  const u = `${g}////${b.current}`;
206
210
  o && (o.components.delete(u), o.components.size === 0 && r.getState().stateComponents.delete(g));
207
211
  };
@@ -212,98 +216,98 @@ function Ot(t, {
212
216
  G.current.add(N);
213
217
  }
214
218
  D(g, (N) => {
215
- const A = L(l) ? l(N) : l, j = `${g}-${o.join(".")}`;
219
+ const $ = L(l) ? l(N) : l, j = `${g}-${o.join(".")}`;
216
220
  if (j) {
217
221
  let F = !1, I = r.getState().signalDomElements.get(j);
218
222
  if ((!I || I.size === 0) && (u.updateType === "insert" || u.updateType === "cut")) {
219
- const V = o.slice(0, -1), C = U(A, V);
220
- if (Array.isArray(C)) {
223
+ const T = o.slice(0, -1), p = U($, T);
224
+ if (Array.isArray(p)) {
221
225
  F = !0;
222
- const $ = `${g}-${V.join(".")}`;
223
- I = r.getState().signalDomElements.get($);
226
+ const A = `${g}-${T.join(".")}`;
227
+ I = r.getState().signalDomElements.get(A);
224
228
  }
225
229
  }
226
230
  if (I) {
227
- const V = F ? U(A, o.slice(0, -1)) : U(A, o);
228
- I.forEach(({ parentId: C, position: $, effect: W }) => {
231
+ const T = F ? U($, o.slice(0, -1)) : U($, o);
232
+ I.forEach(({ parentId: p, position: A, effect: W }) => {
229
233
  const O = document.querySelector(
230
- `[data-parent-id="${C}"]`
234
+ `[data-parent-id="${p}"]`
231
235
  );
232
236
  if (O) {
233
- const st = Array.from(O.childNodes);
234
- if (st[$]) {
235
- const yt = W ? new Function("state", `return (${W})(state)`)(V) : V;
236
- st[$].textContent = String(yt);
237
+ const se = Array.from(O.childNodes);
238
+ if (se[A]) {
239
+ const ye = W ? new Function("state", `return (${W})(state)`)(T) : T;
240
+ se[A].textContent = String(ye);
237
241
  }
238
242
  }
239
243
  });
240
244
  }
241
245
  }
242
- u.updateType === "update" && (w || T.current?.validationKey) && o && P(
243
- (w || T.current?.validationKey) + "." + o.join(".")
246
+ u.updateType === "update" && (w || C.current?.validationKey) && o && P(
247
+ (w || C.current?.validationKey) + "." + o.join(".")
244
248
  );
245
249
  const h = o.slice(0, o.length - 1);
246
- u.updateType === "cut" && T.current?.validationKey && P(
247
- T.current?.validationKey + "." + h.join(".")
248
- ), u.updateType === "insert" && T.current?.validationKey && pt(
249
- T.current?.validationKey + "." + h.join(".")
250
- ).filter(([I, V]) => {
251
- let C = I?.split(".").length;
252
- if (I == h.join(".") && C == h.length - 1) {
253
- let $ = I + "." + h;
254
- P(I), Tt($, V);
250
+ u.updateType === "cut" && C.current?.validationKey && P(
251
+ C.current?.validationKey + "." + h.join(".")
252
+ ), u.updateType === "insert" && C.current?.validationKey && Ve(
253
+ C.current?.validationKey + "." + h.join(".")
254
+ ).filter(([I, T]) => {
255
+ let p = I?.split(".").length;
256
+ if (I == h.join(".") && p == h.length - 1) {
257
+ let A = I + "." + h;
258
+ P(I), Ce(A, T);
255
259
  }
256
260
  });
257
- const z = U(N, o), St = U(A, o), mt = u.updateType === "update" ? o.join(".") : [...o].slice(0, -1).join("."), at = r.getState().stateComponents.get(g);
258
- if (at)
259
- for (const [F, I] of at.components.entries()) {
260
- let V = !1;
261
- const C = Array.isArray(I.reactiveType) ? I.reactiveType : [I.reactiveType || "component"];
262
- if (!C.includes("none")) {
263
- if (C.includes("all")) {
261
+ const z = U(N, o), Se = U($, o), me = u.updateType === "update" ? o.join(".") : [...o].slice(0, -1).join("."), ae = r.getState().stateComponents.get(g);
262
+ if (ae)
263
+ for (const [F, I] of ae.components.entries()) {
264
+ let T = !1;
265
+ const p = Array.isArray(I.reactiveType) ? I.reactiveType : [I.reactiveType || "component"];
266
+ if (!p.includes("none")) {
267
+ if (p.includes("all")) {
264
268
  I.forceUpdate();
265
269
  continue;
266
270
  }
267
- if (C.includes("component") && I.paths && (I.paths.has(mt) || I.paths.has("")) && (V = !0), !V && C.includes("deps") && I.depsFunction) {
268
- const $ = I.depsFunction(A);
269
- typeof $ == "boolean" ? $ && (V = !0) : M(I.deps, $) || (I.deps = $, V = !0);
271
+ if (p.includes("component") && I.paths && (I.paths.has(me) || I.paths.has("")) && (T = !0), !T && p.includes("deps") && I.depsFunction) {
272
+ const A = I.depsFunction($);
273
+ typeof A == "boolean" ? A && (T = !0) : M(I.deps, A) || (I.deps = A, T = !0);
270
274
  }
271
- V && I.forceUpdate();
275
+ T && I.forceUpdate();
272
276
  }
273
277
  }
274
- const it = {
278
+ const ie = {
275
279
  timeStamp: Date.now(),
276
280
  stateKey: g,
277
281
  path: o,
278
282
  updateType: u.updateType,
279
283
  status: "new",
280
284
  oldValue: z,
281
- newValue: St
285
+ newValue: Se
282
286
  };
283
- if (Ct(g, (F) => {
284
- const V = [...F ?? [], it].reduce((C, $) => {
285
- const W = `${$.stateKey}:${JSON.stringify($.path)}`, O = C.get(W);
286
- return O ? (O.timeStamp = Math.max(O.timeStamp, $.timeStamp), O.newValue = $.newValue, O.oldValue = O.oldValue ?? $.oldValue, O.updateType = $.updateType) : C.set(W, { ...$ }), C;
287
+ if (pe(g, (F) => {
288
+ const T = [...F ?? [], ie].reduce((p, A) => {
289
+ const W = `${A.stateKey}:${JSON.stringify(A.path)}`, O = p.get(W);
290
+ return O ? (O.timeStamp = Math.max(O.timeStamp, A.timeStamp), O.newValue = A.newValue, O.oldValue = O.oldValue ?? A.oldValue, O.updateType = A.updateType) : p.set(W, { ...A }), p;
287
291
  }, /* @__PURE__ */ new Map());
288
- return Array.from(V.values());
289
- }), kt(
290
- A,
292
+ return Array.from(T.values());
293
+ }), ke(
294
+ $,
291
295
  g,
292
- T.current,
296
+ C.current,
293
297
  x
294
298
  ), E && E({
295
299
  updateLog: s,
296
- update: it
297
- }), T.current?.serverSync) {
298
- const F = r.getState().serverState[g], I = T.current?.serverSync;
299
- ht(g, {
300
- syncKey: typeof I.syncKey == "string" ? I.syncKey : I.syncKey({ state: A }),
300
+ update: ie
301
+ }), C.current?.serverSync) {
302
+ const F = r.getState().serverState[g], I = C.current?.serverSync;
303
+ he(g, {
304
+ syncKey: typeof I.syncKey == "string" ? I.syncKey : I.syncKey({ state: $ }),
301
305
  rollBackState: F,
302
306
  actionTimeStamp: Date.now() + (I.debounce ?? 3e3),
303
307
  status: "waiting"
304
308
  });
305
309
  }
306
- return A;
310
+ return $;
307
311
  });
308
312
  };
309
313
  r.getState().updaterState[g] || (H(
@@ -314,133 +318,133 @@ function Ot(t, {
314
318
  b.current,
315
319
  x
316
320
  )
317
- ), r.getState().cogsStateStore[g] || D(g, t), r.getState().initialStateGlobal[g] || rt(g, t));
318
- const a = It(() => Y(
321
+ ), r.getState().cogsStateStore[g] || D(g, e), r.getState().initialStateGlobal[g] || re(g, e));
322
+ const a = Ie(() => Y(
319
323
  g,
320
324
  n,
321
325
  b.current,
322
326
  x
323
327
  ), [g]);
324
- return [gt(g), a];
328
+ return [ge(g), a];
325
329
  }
326
- function Y(t, i, y, v) {
330
+ function Y(e, i, v, S) {
327
331
  const d = /* @__PURE__ */ new Map();
328
332
  let E = 0;
329
333
  const _ = (f) => {
330
- const e = f.join(".");
331
- for (const [m] of d)
332
- (m === e || m.startsWith(e + ".")) && d.delete(m);
334
+ const t = f.join(".");
335
+ for (const [y] of d)
336
+ (y === t || y.startsWith(t + ".")) && d.delete(y);
333
337
  E++;
334
- }, S = {
338
+ }, m = {
335
339
  removeValidation: (f) => {
336
340
  f?.validationKey && P(f.validationKey);
337
341
  },
338
342
  revertToInitialState: (f) => {
339
- const e = r.getState().getInitialOptions(t)?.validation;
340
- e?.key && P(e?.key), f?.validationKey && P(f.validationKey);
341
- const m = r.getState().initialStateGlobal[t];
342
- r.getState().clearSelectedIndexesForState(t), d.clear(), E++;
343
- const k = c(m, []), p = q(t), x = L(p?.localStorage?.key) ? p?.localStorage?.key(m) : p?.localStorage?.key, R = `${v}-${t}-${x}`;
344
- R && localStorage.removeItem(R), H(t, k), D(t, m);
345
- const g = r.getState().stateComponents.get(t);
343
+ const t = r.getState().getInitialOptions(e)?.validation;
344
+ t?.key && P(t?.key), f?.validationKey && P(f.validationKey);
345
+ const y = r.getState().initialStateGlobal[e];
346
+ r.getState().clearSelectedIndexesForState(e), d.clear(), E++;
347
+ const k = c(y, []), V = q(e), x = L(V?.localStorage?.key) ? V?.localStorage?.key(y) : V?.localStorage?.key, R = `${S}-${e}-${x}`;
348
+ R && localStorage.removeItem(R), H(e, k), D(e, y);
349
+ const g = r.getState().stateComponents.get(e);
346
350
  return g && g.components.forEach((s) => {
347
351
  s.forceUpdate();
348
- }), m;
352
+ }), y;
349
353
  },
350
354
  updateInitialState: (f) => {
351
355
  d.clear(), E++;
352
- const e = Y(
353
- t,
356
+ const t = Y(
357
+ e,
354
358
  i,
355
- y,
356
- v
359
+ v,
360
+ S
357
361
  );
358
- return Et(() => {
359
- rt(t, f), H(t, e), D(t, f);
360
- const m = r.getState().stateComponents.get(t);
361
- m && m.components.forEach((k) => {
362
+ return Ee(() => {
363
+ re(e, f), H(e, t), D(e, f);
364
+ const y = r.getState().stateComponents.get(e);
365
+ y && y.components.forEach((k) => {
362
366
  k.forceUpdate();
363
367
  });
364
368
  }), {
365
- fetchId: (m) => e.get()[m]
369
+ fetchId: (y) => t.get()[y]
366
370
  };
367
371
  },
368
- _initialState: r.getState().initialStateGlobal[t],
369
- _serverState: r.getState().serverState[t],
370
- _isLoading: r.getState().isLoadingGlobal[t],
372
+ _initialState: r.getState().initialStateGlobal[e],
373
+ _serverState: r.getState().serverState[e],
374
+ _isLoading: r.getState().isLoadingGlobal[e],
371
375
  _isServerSynced: () => {
372
- const f = r.getState().serverState[t];
373
- return !!(f && M(f, gt(t)));
376
+ const f = r.getState().serverState[e];
377
+ return !!(f && M(f, ge(e)));
374
378
  }
375
379
  };
376
- function c(f, e = [], m) {
377
- const k = e.map(String).join(".");
380
+ function c(f, t = [], y) {
381
+ const k = t.map(String).join(".");
378
382
  d.get(k);
379
- const p = function() {
380
- return r().getNestedState(t, e);
383
+ const V = function() {
384
+ return r().getNestedState(e, t);
381
385
  };
382
- Object.keys(S).forEach((g) => {
383
- p[g] = S[g];
386
+ Object.keys(m).forEach((g) => {
387
+ V[g] = m[g];
384
388
  });
385
389
  const x = {
386
390
  apply(g, s, G) {
387
391
  return console.log(
388
- `PROXY APPLY TRAP HIT: stateKey=${t}, path=${e.join(".")}`
389
- ), console.trace("Apply trap stack trace"), r().getNestedState(t, e);
392
+ `PROXY APPLY TRAP HIT: stateKey=${e}, path=${t.join(".")}`
393
+ ), console.trace("Apply trap stack trace"), r().getNestedState(e, t);
390
394
  },
391
395
  get(g, s) {
392
396
  if (s !== "then" && !s.startsWith("$") && s !== "stateMapNoRender") {
393
- const n = e.join("."), a = `${t}////${y}`, l = r.getState().stateComponents.get(t);
397
+ const n = t.join("."), a = `${e}////${v}`, l = r.getState().stateComponents.get(e);
394
398
  if (l) {
395
399
  const o = l.components.get(a);
396
- o && (e.length > 0 || s === "get") && o.paths.add(n);
400
+ o && (t.length > 0 || s === "get") && o.paths.add(n);
397
401
  }
398
402
  }
399
403
  if (s === "_status") {
400
- const n = r.getState().getNestedState(t, e), a = r.getState().initialStateGlobal[t], l = U(a, e);
404
+ const n = r.getState().getNestedState(e, t), a = r.getState().initialStateGlobal[e], l = U(a, t);
401
405
  return M(n, l) ? "fresh" : "stale";
402
406
  }
403
407
  if (s === "getStatus")
404
408
  return function() {
405
409
  const n = r().getNestedState(
406
- t,
407
- e
408
- ), a = r.getState().initialStateGlobal[t], l = U(a, e);
410
+ e,
411
+ t
412
+ ), a = r.getState().initialStateGlobal[e], l = U(a, t);
409
413
  return M(n, l) ? "fresh" : "stale";
410
414
  };
411
415
  if (s === "removeStorage")
412
416
  return () => {
413
- const n = r.getState().initialStateGlobal[t], a = q(t), l = L(a?.localStorage?.key) ? a?.localStorage?.key(n) : a?.localStorage?.key, o = `${v}-${t}-${l}`;
417
+ const n = r.getState().initialStateGlobal[e], a = q(e), l = L(a?.localStorage?.key) ? a?.localStorage?.key(n) : a?.localStorage?.key, o = `${S}-${e}-${l}`;
414
418
  console.log("removing storage", o), o && localStorage.removeItem(o);
415
419
  };
416
420
  if (s === "showValidationErrors")
417
421
  return () => {
418
- const n = r.getState().getInitialOptions(t)?.validation;
422
+ const n = r.getState().getInitialOptions(e)?.validation;
419
423
  if (!n?.key)
420
424
  throw new Error("Validation key not found");
421
- return r.getState().getValidationErrors(n.key + "." + e.join("."));
425
+ return r.getState().getValidationErrors(n.key + "." + t.join("."));
422
426
  };
423
427
  if (Array.isArray(f)) {
424
428
  if (s === "getSelected")
425
429
  return () => {
426
- const n = r.getState().getSelectedIndex(t, e.join("."));
430
+ const n = r.getState().getSelectedIndex(e, t.join("."));
427
431
  if (n !== void 0)
428
432
  return c(
429
433
  f[n],
430
- [...e, n.toString()],
431
- m
434
+ [...t, n.toString()],
435
+ y
432
436
  );
433
437
  };
434
438
  if (s === "getSelectedIndex")
435
- return () => r.getState().getSelectedIndex(t, e.join(".")) ?? -1;
439
+ return () => r.getState().getSelectedIndex(e, t.join(".")) ?? -1;
436
440
  if (s === "stateSort")
437
441
  return (n) => {
438
- const o = [...r.getState().getNestedState(t, e).map((u, w) => ({
442
+ const o = [...r.getState().getNestedState(e, t).map((u, w) => ({
439
443
  ...u,
440
444
  __origIndex: w.toString()
441
445
  }))].sort(n);
442
- return d.clear(), E++, c(o, e, {
443
- filtered: [...m?.filtered || [], e],
446
+ return d.clear(), E++, c(o, t, {
447
+ filtered: [...y?.filtered || [], t],
444
448
  validIndices: o.map(
445
449
  (u) => parseInt(u.__origIndex)
446
450
  )
@@ -448,29 +452,29 @@ function Y(t, i, y, v) {
448
452
  };
449
453
  if (s === "stateMap" || s === "stateMapNoRender")
450
454
  return (n) => {
451
- const a = m?.filtered?.some(
452
- (o) => o.join(".") === e.join(".")
453
- ), l = a ? f : r.getState().getNestedState(t, e);
455
+ const a = y?.filtered?.some(
456
+ (o) => o.join(".") === t.join(".")
457
+ ), l = a ? f : r.getState().getNestedState(e, t);
454
458
  return s !== "stateMapNoRender" && (d.clear(), E++), l.map((o, u) => {
455
459
  const w = a && o.__origIndex ? o.__origIndex : u, N = c(
456
460
  o,
457
- [...e, w.toString()],
458
- m
461
+ [...t, w.toString()],
462
+ y
459
463
  );
460
464
  return n(
461
465
  o,
462
466
  N,
463
467
  u,
464
468
  f,
465
- c(f, e, m)
469
+ c(f, t, y)
466
470
  );
467
471
  });
468
472
  };
469
473
  if (s === "$stateMap")
470
- return (n) => X(jt, {
474
+ return (n) => X(je, {
471
475
  proxy: {
472
- _stateKey: t,
473
- _path: e,
476
+ _stateKey: e,
477
+ _path: t,
474
478
  _mapFn: n
475
479
  // Pass the actual function, not string
476
480
  },
@@ -478,17 +482,17 @@ function Y(t, i, y, v) {
478
482
  });
479
483
  if (s === "stateFlattenOn")
480
484
  return (n) => {
481
- const l = m?.filtered?.some(
482
- (u) => u.join(".") === e.join(".")
483
- ) ? f : r.getState().getNestedState(t, e);
485
+ const l = y?.filtered?.some(
486
+ (u) => u.join(".") === t.join(".")
487
+ ) ? f : r.getState().getNestedState(e, t);
484
488
  d.clear(), E++;
485
489
  const o = l.flatMap(
486
490
  (u, w) => u[n] ?? []
487
491
  );
488
492
  return c(
489
493
  o,
490
- [...e, "[*]", n],
491
- m
494
+ [...t, "[*]", n],
495
+ y
492
496
  );
493
497
  };
494
498
  if (s === "findWith")
@@ -497,54 +501,54 @@ function Y(t, i, y, v) {
497
501
  (w) => w[n] === a
498
502
  );
499
503
  if (l === -1) return;
500
- const o = f[l], u = [...e, l.toString()];
504
+ const o = f[l], u = [...t, l.toString()];
501
505
  return d.clear(), E++, d.clear(), E++, c(o, u);
502
506
  };
503
507
  if (s === "index")
504
508
  return (n) => {
505
509
  const a = f[n];
506
- return c(a, [...e, n.toString()]);
510
+ return c(a, [...t, n.toString()]);
507
511
  };
508
512
  if (s === "insert")
509
- return (n) => (_(e), Q(i, n, e, t), c(
510
- r.getState().cogsStateStore[t],
513
+ return (n) => (_(t), Q(i, n, t, e), c(
514
+ r.getState().cogsStateStore[e],
511
515
  []
512
516
  ));
513
517
  if (s === "uniqueInsert")
514
518
  return (n, a, l) => {
515
- const o = r.getState().getNestedState(t, e), u = L(n) ? n(o) : n;
519
+ const o = r.getState().getNestedState(e, t), u = L(n) ? n(o) : n;
516
520
  let w = null;
517
- if (!o.some((A) => {
521
+ if (!o.some(($) => {
518
522
  if (a) {
519
523
  const h = a.every(
520
- (z) => M(A[z], u[z])
524
+ (z) => M($[z], u[z])
521
525
  );
522
- return h && (w = A), h;
526
+ return h && (w = $), h;
523
527
  }
524
- const j = M(A, u);
525
- return j && (w = A), j;
528
+ const j = M($, u);
529
+ return j && (w = $), j;
526
530
  }))
527
- _(e), Q(i, u, e, t);
531
+ _(t), Q(i, u, t, e);
528
532
  else if (l && w) {
529
- const A = l(w), j = o.map(
530
- (h) => M(h, w) ? A : h
533
+ const $ = l(w), j = o.map(
534
+ (h) => M(h, w) ? $ : h
531
535
  );
532
- _(e), B(i, j, e);
536
+ _(t), B(i, j, t);
533
537
  }
534
538
  };
535
539
  if (s === "cut")
536
540
  return (n, a) => {
537
- a?.waitForSync || (_(e), J(i, e, t, n));
541
+ a?.waitForSync || (_(t), J(i, t, e, n));
538
542
  };
539
543
  if (s === "cutByValue")
540
544
  return (n) => {
541
545
  for (let a = 0; a < f.length; a++)
542
- f[a] === n && J(i, e, t, a);
546
+ f[a] === n && J(i, t, e, a);
543
547
  };
544
548
  if (s === "toggleByValue")
545
549
  return (n) => {
546
550
  const a = f.findIndex((l) => l === n);
547
- a > -1 ? J(i, e, t, a) : Q(i, n, e, t);
551
+ a > -1 ? J(i, t, e, a) : Q(i, n, t, e);
548
552
  };
549
553
  if (s === "stateFilter")
550
554
  return (n) => {
@@ -554,70 +558,70 @@ function Y(t, i, y, v) {
554
558
  })), l = [], o = [];
555
559
  for (let u = 0; u < a.length; u++)
556
560
  n(a[u], u) && (l.push(u), o.push(a[u]));
557
- return d.clear(), E++, c(o, e, {
558
- filtered: [...m?.filtered || [], e],
561
+ return d.clear(), E++, c(o, t, {
562
+ filtered: [...y?.filtered || [], t],
559
563
  validIndices: l
560
564
  // Always pass validIndices, even if empty
561
565
  });
562
566
  };
563
567
  }
564
- const G = e[e.length - 1];
568
+ const G = t[t.length - 1];
565
569
  if (!isNaN(Number(G))) {
566
- const n = e.slice(0, -1), a = r.getState().getNestedState(t, n);
570
+ const n = t.slice(0, -1), a = r.getState().getNestedState(e, n);
567
571
  if (Array.isArray(a) && s === "cut")
568
572
  return () => J(
569
573
  i,
570
574
  n,
571
- t,
575
+ e,
572
576
  Number(G)
573
577
  );
574
578
  }
575
579
  if (s === "get")
576
- return () => r.getState().getNestedState(t, e);
580
+ return () => r.getState().getNestedState(e, t);
577
581
  if (s === "$derive")
578
582
  return (n) => K({
579
- _stateKey: t,
580
- _path: e,
583
+ _stateKey: e,
584
+ _path: t,
581
585
  _effect: n.toString()
582
586
  });
583
587
  if (s === "$derive")
584
588
  return (n) => K({
585
- _stateKey: t,
586
- _path: e,
589
+ _stateKey: e,
590
+ _path: t,
587
591
  _effect: n.toString()
588
592
  });
589
593
  if (s === "$get")
590
594
  return () => K({
591
- _stateKey: t,
592
- _path: e
595
+ _stateKey: e,
596
+ _path: t
593
597
  });
594
598
  if (s === "lastSynced") {
595
- const n = `${t}:${e.join(".")}`;
599
+ const n = `${e}:${t.join(".")}`;
596
600
  return r.getState().getSyncInfo(n);
597
601
  }
598
602
  if (s == "getLocalStorage")
599
- return (n) => ft(v + "-" + t + "-" + n);
603
+ return (n) => fe(S + "-" + e + "-" + n);
600
604
  if (s === "_selected") {
601
- const n = e.slice(0, -1), a = n.join("."), l = r.getState().getNestedState(t, n);
602
- return Array.isArray(l) ? Number(e[e.length - 1]) === r.getState().getSelectedIndex(t, a) : void 0;
605
+ const n = t.slice(0, -1), a = n.join("."), l = r.getState().getNestedState(e, n);
606
+ return Array.isArray(l) ? Number(t[t.length - 1]) === r.getState().getSelectedIndex(e, a) : void 0;
603
607
  }
604
608
  if (s === "setSelected")
605
609
  return (n) => {
606
- const a = e.slice(0, -1), l = Number(e[e.length - 1]), o = a.join(".");
607
- n ? r.getState().setSelectedIndex(t, o, l) : r.getState().setSelectedIndex(t, o, void 0);
608
- const u = r.getState().getNestedState(t, [...a]);
610
+ const a = t.slice(0, -1), l = Number(t[t.length - 1]), o = a.join(".");
611
+ n ? r.getState().setSelectedIndex(e, o, l) : r.getState().setSelectedIndex(e, o, void 0);
612
+ const u = r.getState().getNestedState(e, [...a]);
609
613
  B(i, u, a), _(a);
610
614
  };
611
- if (e.length == 0) {
615
+ if (t.length == 0) {
612
616
  if (s === "validateZodSchema")
613
617
  return () => {
614
- const n = r.getState().getInitialOptions(t)?.validation, a = r.getState().addValidationError;
618
+ const n = r.getState().getInitialOptions(e)?.validation, a = r.getState().addValidationError;
615
619
  if (!n?.zodSchema)
616
620
  throw new Error("Zod schema not found");
617
621
  if (!n?.key)
618
622
  throw new Error("Validation key not found");
619
623
  P(n.key);
620
- const l = r.getState().cogsStateStore[t];
624
+ const l = r.getState().cogsStateStore[e];
621
625
  try {
622
626
  const o = r.getState().getValidationErrors(n.key);
623
627
  o && o.length > 0 && o.forEach(([w]) => {
@@ -625,163 +629,163 @@ function Y(t, i, y, v) {
625
629
  });
626
630
  const u = n.zodSchema.safeParse(l);
627
631
  return u.success ? !0 : (u.error.errors.forEach((N) => {
628
- const A = N.path, j = N.message, h = [n.key, ...A].join(".");
632
+ const $ = N.path, j = N.message, h = [n.key, ...$].join(".");
629
633
  a(h, j);
630
- }), ot(t), !1);
634
+ }), oe(e), !1);
631
635
  } catch (o) {
632
636
  return console.error("Zod schema validation failed", o), !1;
633
637
  }
634
638
  };
635
- if (s === "_componentId") return y;
639
+ if (s === "_componentId") return v;
636
640
  if (s === "getComponents")
637
- return () => r().stateComponents.get(t);
641
+ return () => r().stateComponents.get(e);
638
642
  if (s === "getAllFormRefs")
639
- return () => lt.getState().getFormRefsByStateKey(t);
643
+ return () => le.getState().getFormRefsByStateKey(e);
640
644
  if (s === "_initialState")
641
- return r.getState().initialStateGlobal[t];
645
+ return r.getState().initialStateGlobal[e];
642
646
  if (s === "_serverState")
643
- return r.getState().serverState[t];
647
+ return r.getState().serverState[e];
644
648
  if (s === "_isLoading")
645
- return r.getState().isLoadingGlobal[t];
649
+ return r.getState().isLoadingGlobal[e];
646
650
  if (s === "revertToInitialState")
647
- return S.revertToInitialState;
648
- if (s === "updateInitialState") return S.updateInitialState;
649
- if (s === "removeValidation") return S.removeValidation;
651
+ return m.revertToInitialState;
652
+ if (s === "updateInitialState") return m.updateInitialState;
653
+ if (s === "removeValidation") return m.removeValidation;
650
654
  }
651
655
  if (s === "getFormRef")
652
- return () => lt.getState().getFormRef(t + "." + e.join("."));
656
+ return () => le.getState().getFormRef(e + "." + t.join("."));
653
657
  if (s === "validationWrapper")
654
658
  return ({
655
659
  children: n,
656
660
  hideMessage: a
657
- }) => /* @__PURE__ */ ct(
658
- At,
661
+ }) => /* @__PURE__ */ ce(
662
+ Ae,
659
663
  {
660
664
  formOpts: a ? { validation: { message: "" } } : void 0,
661
- path: e,
662
- validationKey: r.getState().getInitialOptions(t)?.validation?.key || "",
663
- stateKey: t,
664
- validIndices: m?.validIndices,
665
+ path: t,
666
+ validationKey: r.getState().getInitialOptions(e)?.validation?.key || "",
667
+ stateKey: e,
668
+ validIndices: y?.validIndices,
665
669
  children: n
666
670
  }
667
671
  );
668
- if (s === "_stateKey") return t;
669
- if (s === "_path") return e;
670
- if (s === "_isServerSynced") return S._isServerSynced;
672
+ if (s === "_stateKey") return e;
673
+ if (s === "_path") return t;
674
+ if (s === "_isServerSynced") return m._isServerSynced;
671
675
  if (s === "update")
672
676
  return (n, a) => {
673
677
  if (a?.debounce)
674
- $t(() => {
675
- B(i, n, e, "");
676
- const l = r.getState().getNestedState(t, e);
678
+ $e(() => {
679
+ B(i, n, t, "");
680
+ const l = r.getState().getNestedState(e, t);
677
681
  a?.afterUpdate && a.afterUpdate(l);
678
682
  }, a.debounce);
679
683
  else {
680
- B(i, n, e, "");
681
- const l = r.getState().getNestedState(t, e);
684
+ B(i, n, t, "");
685
+ const l = r.getState().getNestedState(e, t);
682
686
  a?.afterUpdate && a.afterUpdate(l);
683
687
  }
684
- _(e);
688
+ _(t);
685
689
  };
686
690
  if (s === "formElement")
687
- return (n, a) => /* @__PURE__ */ ct(
688
- Nt,
691
+ return (n, a) => /* @__PURE__ */ ce(
692
+ Ne,
689
693
  {
690
694
  setState: i,
691
- stateKey: t,
692
- path: e,
695
+ stateKey: e,
696
+ path: t,
693
697
  child: n,
694
698
  formOpts: a
695
699
  }
696
700
  );
697
- const b = [...e, s], T = r.getState().getNestedState(t, b);
698
- return c(T, b, m);
701
+ const b = [...t, s], C = r.getState().getNestedState(e, b);
702
+ return c(C, b, y);
699
703
  }
700
- }, R = new Proxy(p, x);
704
+ }, R = new Proxy(V, x);
701
705
  return d.set(k, {
702
706
  proxy: R,
703
707
  stateVersion: E
704
708
  }), R;
705
709
  }
706
710
  return c(
707
- r.getState().getNestedState(t, [])
711
+ r.getState().getNestedState(e, [])
708
712
  );
709
713
  }
710
- function K(t) {
711
- return X(bt, { proxy: t });
714
+ function K(e) {
715
+ return X(be, { proxy: e });
712
716
  }
713
- function jt({
714
- proxy: t,
717
+ function je({
718
+ proxy: e,
715
719
  rebuildStateShape: i
716
720
  }) {
717
- const y = r().getNestedState(t._stateKey, t._path);
718
- return Array.isArray(y) ? i(
719
- y,
720
- t._path
721
+ const v = r().getNestedState(e._stateKey, e._path);
722
+ return Array.isArray(v) ? i(
723
+ v,
724
+ e._path
721
725
  ).stateMapNoRender(
722
- (d, E, _, S, c) => t._mapFn(d, E, _, S, c)
726
+ (d, E, _, m, c) => e._mapFn(d, E, _, m, c)
723
727
  ) : null;
724
728
  }
725
- function bt({
726
- proxy: t
729
+ function be({
730
+ proxy: e
727
731
  }) {
728
- const i = Z(null), y = `${t._stateKey}-${t._path.join(".")}`;
729
- return et(() => {
730
- const v = i.current;
731
- if (!v || !v.parentElement) return;
732
- const d = v.parentElement, _ = Array.from(d.childNodes).indexOf(v);
733
- let S = d.getAttribute("data-parent-id");
734
- S || (S = `parent-${crypto.randomUUID()}`, d.setAttribute("data-parent-id", S));
732
+ const i = Z(null), v = `${e._stateKey}-${e._path.join(".")}`;
733
+ return te(() => {
734
+ const S = i.current;
735
+ if (!S || !S.parentElement) return;
736
+ const d = S.parentElement, _ = Array.from(d.childNodes).indexOf(S);
737
+ let m = d.getAttribute("data-parent-id");
738
+ m || (m = `parent-${crypto.randomUUID()}`, d.setAttribute("data-parent-id", m));
735
739
  const f = {
736
740
  instanceId: `instance-${crypto.randomUUID()}`,
737
- parentId: S,
741
+ parentId: m,
738
742
  position: _,
739
- effect: t._effect
743
+ effect: e._effect
740
744
  };
741
- r.getState().addSignalElement(y, f);
742
- const e = r.getState().getNestedState(t._stateKey, t._path);
743
- let m;
744
- if (t._effect)
745
+ r.getState().addSignalElement(v, f);
746
+ const t = r.getState().getNestedState(e._stateKey, e._path);
747
+ let y;
748
+ if (e._effect)
745
749
  try {
746
- m = new Function(
750
+ y = new Function(
747
751
  "state",
748
- `return (${t._effect})(state)`
749
- )(e);
750
- } catch (p) {
751
- console.error("Error evaluating effect function during mount:", p), m = e;
752
+ `return (${e._effect})(state)`
753
+ )(t);
754
+ } catch (V) {
755
+ console.error("Error evaluating effect function during mount:", V), y = t;
752
756
  }
753
757
  else
754
- m = e;
755
- m !== null && typeof m == "object" && (m = JSON.stringify(m));
756
- const k = document.createTextNode(String(m));
757
- v.replaceWith(k);
758
- }, [t._stateKey, t._path.join("."), t._effect]), X("span", {
758
+ y = t;
759
+ y !== null && typeof y == "object" && (y = JSON.stringify(y));
760
+ const k = document.createTextNode(String(y));
761
+ S.replaceWith(k);
762
+ }, [e._stateKey, e._path.join("."), e._effect]), X("span", {
759
763
  ref: i,
760
764
  style: { display: "none" },
761
- "data-signal-id": y
765
+ "data-signal-id": v
762
766
  });
763
767
  }
764
- function Jt(t) {
765
- const i = _t(
766
- (y) => {
767
- const v = r.getState().stateComponents.get(t._stateKey) || {
768
+ function Je(e) {
769
+ const i = _e(
770
+ (v) => {
771
+ const S = r.getState().stateComponents.get(e._stateKey) || {
768
772
  components: /* @__PURE__ */ new Map()
769
773
  };
770
- return v.components.set(t._stateKey, {
771
- forceUpdate: y,
772
- paths: /* @__PURE__ */ new Set([t._path.join(".")])
773
- }), () => v.components.delete(t._stateKey);
774
+ return S.components.set(e._stateKey, {
775
+ forceUpdate: v,
776
+ paths: /* @__PURE__ */ new Set([e._path.join(".")])
777
+ }), () => S.components.delete(e._stateKey);
774
778
  },
775
- () => r.getState().getNestedState(t._stateKey, t._path)
779
+ () => r.getState().getNestedState(e._stateKey, e._path)
776
780
  );
777
781
  return X("text", {}, String(i));
778
782
  }
779
783
  export {
780
784
  K as $cogsSignal,
781
- Jt as $cogsSignalStore,
782
- qt as addStateOptions,
783
- zt as createCogsState,
784
- Bt as notifyComponent,
785
- Ot as useCogsStateFn
785
+ Je as $cogsSignalStore,
786
+ qe as addStateOptions,
787
+ ze as createCogsState,
788
+ Be as notifyComponent,
789
+ Oe as useCogsStateFn
786
790
  };
787
791
  //# sourceMappingURL=CogsState.jsx.map