cogsbox-state 0.5.321 → 0.5.322

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