cogsbox-state 0.5.356 → 0.5.357

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