cogsbox-state 0.5.475-canary.6 → 0.5.475-canary.8

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,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as Z, Fragment as Me } from "react/jsx-runtime";
3
- import { pluginStore as x } from "./pluginStore.js";
4
- import { useState as ee, useRef as q, useCallback as Ae, useEffect as J, useLayoutEffect as $e, useMemo as ye, createElement as ue, startTransition as Ee } from "react";
3
+ import { pluginStore as q } from "./pluginStore.js";
4
+ import { useState as ee, useRef as x, useCallback as Ae, useEffect as J, useLayoutEffect as $e, useMemo as ye, createElement as ue, startTransition as Ee } from "react";
5
5
  import { transformStateFunc as Ve, isFunction as R, isDeepEqual as Y, isArray as Te, getDifferences as Ie } from "./utility.js";
6
6
  import { ValidationWrapper as be, IsolatedComponentWrapper as Pe, FormElementWrapper as ke, MemoizedCogsItemWrapper as De } from "./Components.jsx";
7
7
  import Ce from "superjson";
@@ -27,20 +27,18 @@ const {
27
27
  addPathComponent: Fe,
28
28
  clearSelectedIndexesForState: ze,
29
29
  addStateLog: Re,
30
- setSyncInfo: wt,
31
30
  clearSelectedIndex: Le,
32
31
  getSyncInfo: We,
33
32
  notifyPathSubscribers: Be,
34
33
  getPluginMetaDataMap: Ge,
35
- setPluginMetaData: xe,
36
- removePluginMetaData: qe
37
- // Note: The old functions are no longer imported under their original names
38
- } = p.getState(), { notifyUpdate: Je } = x.getState();
34
+ setPluginMetaData: qe,
35
+ removePluginMetaData: xe
36
+ } = p.getState(), { notifyUpdate: Je } = q.getState();
39
37
  function j(e, a, l) {
40
38
  const s = A(e, a);
41
39
  if (!!!s?.arrayKeys)
42
40
  return { isArray: !1, value: p.getState().getShadowValue(e, a), keys: [] };
43
- const i = a.length > 0 ? a.join(".") : "root", m = l?.arrayViews?.[i] ?? s.arrayKeys;
41
+ const c = a.length > 0 ? a.join(".") : "root", m = l?.arrayViews?.[c] ?? s.arrayKeys;
44
42
  return Array.isArray(m) && m.length === 0 ? { isArray: !0, value: [], keys: [] } : { isArray: !0, value: p.getState().getShadowValue(e, a, m), keys: m ?? [] };
45
43
  }
46
44
  function oe(e, a, l) {
@@ -65,39 +63,39 @@ function ce({
65
63
  initialOptionsPart: l
66
64
  }) {
67
65
  const s = N(e) || {}, g = l[e] || {};
68
- let i = { ...g, ...s }, m = !1;
66
+ let c = { ...g, ...s }, m = !1;
69
67
  if (a) {
70
68
  const u = (t, o) => {
71
69
  for (const y in o)
72
70
  o.hasOwnProperty(y) && (o[y] instanceof Object && !Array.isArray(o[y]) && t[y] instanceof Object ? Y(t[y], o[y]) || (u(t[y], o[y]), m = !0) : t[y] !== o[y] && (t[y] = o[y], m = !0));
73
71
  return t;
74
72
  };
75
- i = u(i, a);
73
+ c = u(c, a);
76
74
  }
77
- if (i.validation && (a?.validation?.hasOwnProperty("onBlur") || s?.validation?.hasOwnProperty("onBlur") || g?.validation?.hasOwnProperty("onBlur") || (i.validation.onBlur = "error", m = !0)), m) {
78
- de(e, i);
79
- const u = s?.validation?.zodSchemaV4 || s?.validation?.zodSchemaV3, t = i.validation?.zodSchemaV4 && !s?.validation?.zodSchemaV4, o = i.validation?.zodSchemaV3 && !s?.validation?.zodSchemaV3;
75
+ if (c.validation && (a?.validation?.hasOwnProperty("onBlur") || s?.validation?.hasOwnProperty("onBlur") || g?.validation?.hasOwnProperty("onBlur") || (c.validation.onBlur = "error", m = !0)), m) {
76
+ de(e, c);
77
+ const u = s?.validation?.zodSchemaV4 || s?.validation?.zodSchemaV3, t = c.validation?.zodSchemaV4 && !s?.validation?.zodSchemaV4, o = c.validation?.zodSchemaV3 && !s?.validation?.zodSchemaV3;
80
78
  !u && (t || o) && (t ? fe(
81
79
  e,
82
- i.validation.zodSchemaV4,
80
+ c.validation.zodSchemaV4,
83
81
  "zod4"
84
82
  ) : o && fe(
85
83
  e,
86
- i.validation.zodSchemaV3,
84
+ c.validation.zodSchemaV3,
87
85
  "zod3"
88
86
  ), B(e));
89
87
  }
90
- return i;
88
+ return c;
91
89
  }
92
- function pt(e, a) {
90
+ function wt(e, a) {
93
91
  return {
94
92
  ...a,
95
93
  initialState: e,
96
94
  _addStateOptions: !0
97
95
  };
98
96
  }
99
- const Mt = (e, a) => {
100
- a?.plugins && x.getState().setRegisteredPlugins(a.plugins);
97
+ const pt = (e, a) => {
98
+ a?.plugins && q.getState().setRegisteredPlugins(a.plugins);
101
99
  const [l, s] = Ve(e);
102
100
  Object.keys(l).forEach((u) => {
103
101
  let t = s[u] || {};
@@ -133,7 +131,7 @@ const Mt = (e, a) => {
133
131
  stateKey: u,
134
132
  options: t,
135
133
  initialOptionsPart: s
136
- }), $ = q(y);
134
+ }), $ = x(y);
137
135
  $.current = y;
138
136
  const V = D(u, []) || l[u], I = ot(
139
137
  V,
@@ -151,29 +149,29 @@ const Mt = (e, a) => {
151
149
  }
152
150
  );
153
151
  return J(() => {
154
- t && x.getState().setPluginOptionsForState(u, t);
155
- }, [u, t]), J(() => (x.getState().stateHandlers.set(u, I), () => {
156
- x.getState().stateHandlers.delete(u);
152
+ t && q.getState().setPluginOptionsForState(u, t);
153
+ }, [u, t]), J(() => (q.getState().stateHandlers.set(u, I), () => {
154
+ q.getState().stateHandlers.delete(u);
157
155
  }), [u, I]), I;
158
156
  };
159
- function i(u, t) {
157
+ function c(u, t) {
160
158
  if (ce({ stateKey: u, options: t, initialOptionsPart: s }), t.localStorage && Ze(u, t), t.formElements) {
161
- const y = x.getState().registeredPlugins.map(($) => t.formElements.hasOwnProperty($.name) ? {
159
+ const y = q.getState().registeredPlugins.map(($) => t.formElements.hasOwnProperty($.name) ? {
162
160
  ...$,
163
161
  formWrapper: t.formElements[$.name]
164
162
  } : $);
165
- x.getState().setRegisteredPlugins(y);
163
+ q.getState().setRegisteredPlugins(y);
166
164
  }
167
165
  B(u);
168
166
  }
169
167
  function m(u) {
170
168
  Object.keys(l).forEach((o) => {
171
- i(o, u);
169
+ c(o, u);
172
170
  });
173
171
  }
174
172
  return {
175
173
  useCogsState: g,
176
- setCogsOptionsByKey: i,
174
+ setCogsOptionsByKey: c,
177
175
  setCogsOptions: m
178
176
  };
179
177
  }, He = (e, a, l, s, g) => {
@@ -183,9 +181,9 @@ const Mt = (e, a) => {
183
181
  l.localStorage?.key,
184
182
  s
185
183
  );
186
- const i = R(l?.localStorage?.key) ? l.localStorage?.key(e) : l?.localStorage?.key;
187
- if (i && s) {
188
- const m = `${s}-${a}-${i}`;
184
+ const c = R(l?.localStorage?.key) ? l.localStorage?.key(e) : l?.localStorage?.key;
185
+ if (c && s) {
186
+ const m = `${s}-${a}-${c}`;
189
187
  let u;
190
188
  try {
191
189
  u = ae(m)?.lastSyncedWithServer;
@@ -214,10 +212,10 @@ const Mt = (e, a) => {
214
212
  }, Ze = (e, a) => {
215
213
  const l = D(e, []), { sessionId: s } = me(), g = R(a?.localStorage?.key) ? a.localStorage.key(l) : a?.localStorage?.key;
216
214
  if (g && s) {
217
- const i = ae(
215
+ const c = ae(
218
216
  `${s}-${e}-${g}`
219
217
  );
220
- if (i && i.lastUpdated > (i.lastSyncedWithServer || 0))
218
+ if (c && c.lastUpdated > (c.lastSyncedWithServer || 0))
221
219
  return B(e), !0;
222
220
  }
223
221
  return !1;
@@ -239,8 +237,8 @@ function te(e, a, l, s) {
239
237
  stateSource: "server",
240
238
  lastServerSync: s || Date.now()
241
239
  }), Array.isArray(l)) {
242
- const i = A(e, a);
243
- i?.arrayKeys && i.arrayKeys.forEach((m, u) => {
240
+ const c = A(e, a);
241
+ c?.arrayKeys && c.arrayKeys.forEach((m, u) => {
244
242
  const t = [...a, m], o = l[u];
245
243
  o !== void 0 && te(
246
244
  e,
@@ -249,22 +247,22 @@ function te(e, a, l, s) {
249
247
  s
250
248
  );
251
249
  });
252
- } else l && typeof l == "object" && l.constructor === Object && Object.keys(l).forEach((i) => {
253
- const m = [...a, i], u = l[i];
250
+ } else l && typeof l == "object" && l.constructor === Object && Object.keys(l).forEach((c) => {
251
+ const m = [...a, c], u = l[c];
254
252
  te(e, m, u, s);
255
253
  });
256
254
  }
257
255
  let re = [], le = !1;
258
256
  function Qe() {
259
- le || (le = !0, console.log("Scheduling flush"), queueMicrotask(() => {
260
- console.log("Actually flushing"), nt();
257
+ le || (le = !0, queueMicrotask(() => {
258
+ nt();
261
259
  }));
262
260
  }
263
261
  function Ye(e, a) {
264
262
  e?.signals?.length && e.signals.forEach(({ parentId: l, position: s, effect: g }) => {
265
- const i = document.querySelector(`[data-parent-id="${l}"]`);
266
- if (!i) return;
267
- const m = Array.from(i.childNodes);
263
+ const c = document.querySelector(`[data-parent-id="${l}"]`);
264
+ if (!c) return;
265
+ const m = Array.from(c.childNodes);
268
266
  if (!m[s]) return;
269
267
  let u = a;
270
268
  if (g && a !== null)
@@ -284,14 +282,14 @@ function Xe(e, a, l) {
284
282
  return /* @__PURE__ */ new Set();
285
283
  const g = /* @__PURE__ */ new Set();
286
284
  if (l.type === "update") {
287
- let i = [...a];
285
+ let c = [...a];
288
286
  for (; ; ) {
289
- const m = A(e, i);
287
+ const m = A(e, c);
290
288
  if (m?.pathComponents && m.pathComponents.forEach((u) => {
291
289
  const t = s.components?.get(u);
292
290
  t && ((Array.isArray(t.reactiveType) ? t.reactiveType : [t.reactiveType || "component"]).includes("none") || g.add(t));
293
- }), i.length === 0) break;
294
- i.pop();
291
+ }), c.length === 0) break;
292
+ c.pop();
295
293
  }
296
294
  l.newValue && typeof l.newValue == "object" && !Te(l.newValue) && Ie(l.newValue, l.oldValue).forEach((u) => {
297
295
  const t = u.split("."), o = [...a, ...t], y = A(e, o);
@@ -318,12 +316,12 @@ function Ke(e, a, l) {
318
316
  if (Y(s, g))
319
317
  return null;
320
318
  Ue(e, a, g), ne(e, a, { bubble: !0 });
321
- const i = A(e, a);
319
+ const c = A(e, a);
322
320
  return {
323
321
  type: "update",
324
322
  oldValue: s,
325
323
  newValue: g,
326
- shadowMeta: i
324
+ shadowMeta: c
327
325
  };
328
326
  }
329
327
  function et(e, a, l) {
@@ -337,16 +335,16 @@ function et(e, a, l) {
337
335
  };
338
336
  }
339
337
  function tt(e, a, l, s, g) {
340
- let i;
338
+ let c;
341
339
  if (R(l)) {
342
340
  const { value: o } = W(e, a);
343
- i = l({ state: o });
341
+ c = l({ state: o });
344
342
  } else
345
- i = l;
343
+ c = l;
346
344
  const m = je(
347
345
  e,
348
346
  a,
349
- i,
347
+ c,
350
348
  s,
351
349
  g
352
350
  );
@@ -355,7 +353,7 @@ function tt(e, a, l, s, g) {
355
353
  let t;
356
354
  return u?.arrayKeys && s !== void 0 && s > 0 && (t = u.arrayKeys[s - 1]), {
357
355
  type: "insert",
358
- newValue: i,
356
+ newValue: c,
359
357
  shadowMeta: u,
360
358
  path: a,
361
359
  itemId: m,
@@ -373,8 +371,8 @@ function nt() {
373
371
  l.push(s);
374
372
  continue;
375
373
  }
376
- const g = s, i = g.type === "cut" ? null : g.newValue;
377
- g.shadowMeta?.signals?.length > 0 && a.push({ shadowMeta: g.shadowMeta, displayValue: i }), Xe(
374
+ const g = s, c = g.type === "cut" ? null : g.newValue;
375
+ g.shadowMeta?.signals?.length > 0 && a.push({ shadowMeta: g.shadowMeta, displayValue: c }), Xe(
378
376
  g.stateKey,
379
377
  g.path,
380
378
  g
@@ -389,38 +387,38 @@ function nt() {
389
387
  }), re = [], le = !1;
390
388
  }
391
389
  function at(e, a, l) {
392
- return (g, i, m) => {
393
- s(e, i, g, m);
390
+ return (g, c, m) => {
391
+ s(e, c, g, m);
394
392
  };
395
- function s(g, i, m, u) {
393
+ function s(g, c, m, u) {
396
394
  let t;
397
395
  switch (u.updateType) {
398
396
  case "update":
399
- t = Ke(g, i, m);
397
+ t = Ke(g, c, m);
400
398
  break;
401
399
  case "insert":
402
400
  t = tt(
403
401
  g,
404
- i,
402
+ c,
405
403
  m,
406
404
  u.index,
407
405
  u.itemId
408
406
  );
409
407
  break;
410
408
  case "insert_many":
411
- t = et(g, i, m);
409
+ t = et(g, c, m);
412
410
  break;
413
411
  case "cut":
414
- t = rt(g, i);
412
+ t = rt(g, c);
415
413
  break;
416
414
  }
417
415
  if (t === null)
418
416
  return;
419
- t.stateKey = g, t.path = i, re.push(t), Qe();
417
+ t.stateKey = g, t.path = c, re.push(t), Qe();
420
418
  const o = {
421
419
  timeStamp: Date.now(),
422
420
  stateKey: g,
423
- path: i,
421
+ path: c,
424
422
  updateType: u.updateType,
425
423
  status: "new",
426
424
  oldValue: t.oldValue,
@@ -442,7 +440,7 @@ function ot(e, {
442
440
  localStorage: l,
443
441
  formElements: s,
444
442
  reactiveDeps: g,
445
- reactiveType: i,
443
+ reactiveType: c,
446
444
  componentId: m,
447
445
  defaultState: u,
448
446
  dependencies: t,
@@ -450,13 +448,13 @@ function ot(e, {
450
448
  } = {}) {
451
449
  const [y, $] = ee({}), { sessionId: V } = me();
452
450
  let I = !a;
453
- const [v] = ee(a ?? X()), F = q(m ?? X()), C = q(
451
+ const [v] = ee(a ?? X()), F = x(m ?? X()), C = x(
454
452
  null
455
453
  );
456
454
  C.current = N(v) ?? null;
457
455
  const G = Ae(
458
456
  (P) => {
459
- const n = P ? { ...N(v), ...P } : N(v), c = n?.defaultState || u || e;
457
+ const n = P ? { ...N(v), ...P } : N(v), i = n?.defaultState || u || e;
460
458
  if (n?.serverState?.status === "success" && n?.serverState?.data !== void 0)
461
459
  return {
462
460
  value: n.serverState.data,
@@ -464,7 +462,7 @@ function ot(e, {
464
462
  timestamp: n.serverState.timestamp || Date.now()
465
463
  };
466
464
  if (n?.localStorage?.key && V) {
467
- const d = R(n.localStorage.key) ? n.localStorage.key(c) : n.localStorage.key, h = ae(
465
+ const d = R(n.localStorage.key) ? n.localStorage.key(i) : n.localStorage.key, h = ae(
468
466
  `${V}-${v}-${d}`
469
467
  );
470
468
  if (h && h.lastUpdated > (n?.serverState?.timestamp || 0))
@@ -475,7 +473,7 @@ function ot(e, {
475
473
  };
476
474
  }
477
475
  return {
478
- value: c || e,
476
+ value: i || e,
479
477
  source: "default",
480
478
  timestamp: Date.now()
481
479
  };
@@ -490,9 +488,9 @@ function ot(e, {
490
488
  if (n?.status !== "success" || n.data === void 0)
491
489
  return;
492
490
  se(v, { serverState: n });
493
- const c = typeof n.merge == "object" ? n.merge : n.merge === !0 ? { strategy: "append", key: "id" } : null, S = D(v, []), d = n.data;
494
- if (c && c.strategy === "append" && "key" in c && Array.isArray(S) && Array.isArray(d)) {
495
- const h = c.key;
491
+ const i = typeof n.merge == "object" ? n.merge : n.merge === !0 ? { strategy: "append", key: "id" } : null, S = D(v, []), d = n.data;
492
+ if (i && i.strategy === "append" && "key" in i && Array.isArray(S) && Array.isArray(d)) {
493
+ const h = i.key;
496
494
  if (!h) {
497
495
  console.error(
498
496
  "CogsState: Merge strategy 'append' requires a 'key' field."
@@ -537,12 +535,12 @@ function ot(e, {
537
535
  defaultState: h
538
536
  });
539
537
  }
540
- const { value: c, source: S, timestamp: d } = G();
541
- K(v, c), L(v, [], {
538
+ const { value: i, source: S, timestamp: d } = G();
539
+ K(v, i), L(v, [], {
542
540
  stateSource: S,
543
541
  lastServerSync: S === "server" ? d : void 0,
544
542
  isDirty: S === "server" ? !1 : void 0,
545
- baseServerState: S === "server" ? c : void 0
543
+ baseServerState: S === "server" ? i : void 0
546
544
  }), S === "server" && o && ge(v, o), B(v);
547
545
  }, [v, ...t || []]), $e(() => {
548
546
  I && se(v, {
@@ -554,7 +552,7 @@ function ot(e, {
554
552
  const P = `${v}////${F.current}`, r = A(v, []), n = r?.components || /* @__PURE__ */ new Map();
555
553
  return n.set(P, {
556
554
  forceUpdate: () => $({}),
557
- reactiveType: i ?? ["component"],
555
+ reactiveType: c ?? ["component"],
558
556
  paths: /* @__PURE__ */ new Set(),
559
557
  depsFunction: g || void 0,
560
558
  deps: g ? g(D(v, [])) : [],
@@ -563,11 +561,11 @@ function ot(e, {
563
561
  ...r,
564
562
  components: n
565
563
  }), $({}), () => {
566
- const c = A(v, []), S = c?.components?.get(P);
564
+ const i = A(v, []), S = i?.components?.get(P);
567
565
  S?.paths && S.paths.forEach((d) => {
568
566
  const w = d.split(".").slice(1), M = p.getState().getShadowMetadata(v, w);
569
567
  M?.pathComponents && M.pathComponents.size === 0 && (delete M.pathComponents, p.getState().setShadowMetadata(v, w, M));
570
- }), c?.components && L(v, [], c);
568
+ }), i?.components && L(v, [], i);
571
569
  };
572
570
  }, []);
573
571
  const f = at(
@@ -587,21 +585,21 @@ const st = (e, a, l) => {
587
585
  const g = l?.transforms;
588
586
  if (!g || g.length === 0)
589
587
  return s;
590
- for (const i of g)
591
- if (i.type === "filter") {
588
+ for (const c of g)
589
+ if (c.type === "filter") {
592
590
  const m = [];
593
591
  s.forEach((u, t) => {
594
592
  const o = D(e, [...a, u]);
595
- i.fn(o, t) && m.push(u);
593
+ c.fn(o, t) && m.push(u);
596
594
  }), s = m;
597
- } else i.type === "sort" && s.sort((m, u) => {
595
+ } else c.type === "sort" && s.sort((m, u) => {
598
596
  const t = D(e, [...a, m]), o = D(e, [...a, u]);
599
- return i.fn(t, o);
597
+ return c.fn(t, o);
600
598
  });
601
599
  return s;
602
600
  }, ie = (e, a, l) => {
603
- const s = `${e}////${a}`, i = A(e, [])?.components?.get(s);
604
- !i || i.reactiveType === "none" || !(Array.isArray(i.reactiveType) ? i.reactiveType : [i.reactiveType]).includes("component") || Fe(e, l, s);
601
+ const s = `${e}////${a}`, c = A(e, [])?.components?.get(s);
602
+ !c || c.reactiveType === "none" || !(Array.isArray(c.reactiveType) ? c.reactiveType : [c.reactiveType]).includes("component") || Fe(e, l, s);
605
603
  }, Q = (e, a, l) => {
606
604
  const s = A(e, []), g = /* @__PURE__ */ new Set();
607
605
  s?.components && s.components.forEach((m, u) => {
@@ -612,8 +610,8 @@ const st = (e, a, l) => {
612
610
  ])?.pathComponents?.forEach((m) => {
613
611
  s?.components?.get(m)?.forceUpdate();
614
612
  });
615
- const i = A(e, a);
616
- for (let m of i?.arrayKeys || []) {
613
+ const c = A(e, a);
614
+ for (let m of c?.arrayKeys || []) {
617
615
  const u = m + ".selected", t = A(e, u.split(".").slice(1));
618
616
  m == l && t?.pathComponents?.forEach((o) => {
619
617
  s?.components?.get(o)?.forceUpdate();
@@ -621,14 +619,14 @@ const st = (e, a, l) => {
621
619
  }
622
620
  };
623
621
  function W(e, a, l) {
624
- const s = A(e, a), g = a.length > 0 ? a.join(".") : "root", i = l?.arrayViews?.[g];
625
- if (Array.isArray(i) && i.length === 0)
622
+ const s = A(e, a), g = a.length > 0 ? a.join(".") : "root", c = l?.arrayViews?.[g];
623
+ if (Array.isArray(c) && c.length === 0)
626
624
  return {
627
625
  shadowMeta: s,
628
626
  value: [],
629
627
  arrayKeys: s?.arrayKeys
630
628
  };
631
- const m = D(e, a, i);
629
+ const m = D(e, a, c);
632
630
  return {
633
631
  shadowMeta: s,
634
632
  value: m,
@@ -637,7 +635,7 @@ function W(e, a, l) {
637
635
  }
638
636
  function we(e, a, l, s) {
639
637
  const g = /* @__PURE__ */ new Map();
640
- function i({
638
+ function c({
641
639
  path: t = [],
642
640
  meta: o,
643
641
  componentId: y
@@ -664,22 +662,22 @@ function we(e, a, l, s) {
664
662
  return m[f];
665
663
  if (typeof f == "string" && !f.startsWith("$")) {
666
664
  const r = [...t, f];
667
- return i({
665
+ return c({
668
666
  path: r,
669
667
  componentId: y,
670
668
  meta: o
671
669
  });
672
670
  }
673
671
  if (f === "$_rebuildStateShape")
674
- return i;
672
+ return c;
675
673
  if (f === "$sync" && t.length === 0)
676
674
  return async function() {
677
675
  const r = p.getState().getInitialOptions(e), n = r?.sync;
678
676
  if (!n)
679
677
  return console.error(`No mutation defined for state key "${e}"`), { success: !1, error: "No mutation defined" };
680
- const c = p.getState().getShadowValue(e, []), S = r?.validation?.key;
678
+ const i = p.getState().getShadowValue(e, []), S = r?.validation?.key;
681
679
  try {
682
- const d = await n.action(c);
680
+ const d = await n.action(i);
683
681
  if (d && !d.success && d.errors, d?.success) {
684
682
  const h = p.getState().getShadowMetadata(e, []);
685
683
  L(e, [], {
@@ -687,7 +685,7 @@ function we(e, a, l, s) {
687
685
  isDirty: !1,
688
686
  lastServerSync: Date.now(),
689
687
  stateSource: "server",
690
- baseServerState: c
688
+ baseServerState: i
691
689
  // Update base server state
692
690
  }), n.onSuccess && n.onSuccess(d.data);
693
691
  } else !d?.success && n.onError && n.onError(d.error);
@@ -698,19 +696,19 @@ function we(e, a, l, s) {
698
696
  };
699
697
  if (f === "$_status" || f === "$getStatus") {
700
698
  const r = () => {
701
- const { shadowMeta: n, value: c } = W(e, t, o);
702
- return n?.isDirty === !0 ? "dirty" : n?.stateSource === "server" || n?.isDirty === !1 ? "synced" : n?.stateSource === "localStorage" ? "restored" : n?.stateSource === "default" || c !== void 0 ? "fresh" : "unknown";
699
+ const { shadowMeta: n, value: i } = W(e, t, o);
700
+ return n?.isDirty === !0 ? "dirty" : n?.stateSource === "server" || n?.isDirty === !1 ? "synced" : n?.stateSource === "localStorage" ? "restored" : n?.stateSource === "default" || i !== void 0 ? "fresh" : "unknown";
703
701
  };
704
702
  return f === "$_status" ? r() : r;
705
703
  }
706
704
  if (f === "$removeStorage")
707
705
  return () => {
708
- const r = p.getState().initialStateGlobal[e], n = N(e), c = R(n?.localStorage?.key) ? n.localStorage.key(r) : n?.localStorage?.key, S = `${s}-${e}-${c}`;
706
+ const r = p.getState().initialStateGlobal[e], n = N(e), i = R(n?.localStorage?.key) ? n.localStorage.key(r) : n?.localStorage?.key, S = `${s}-${e}-${i}`;
709
707
  S && localStorage.removeItem(S);
710
708
  };
711
709
  if (f === "$validate")
712
710
  return () => {
713
- const r = p.getState(), { value: n } = W(e, t, o), c = r.getInitialOptions(e), S = c?.validation?.zodSchemaV4 || c?.validation?.zodSchemaV3;
711
+ const r = p.getState(), { value: n } = W(e, t, o), i = r.getInitialOptions(e), S = i?.validation?.zodSchemaV4 || i?.validation?.zodSchemaV3;
714
712
  if (!S)
715
713
  return { success: !0, data: n };
716
714
  const d = S.safeParse(n);
@@ -761,12 +759,12 @@ function we(e, a, l, s) {
761
759
  const n = p.getState().selectedIndicesMap.get(r);
762
760
  if (!n)
763
761
  return;
764
- const c = t.join("."), S = o?.arrayViews?.[c], d = n.split(".").pop();
762
+ const i = t.join("."), S = o?.arrayViews?.[i], d = n.split(".").pop();
765
763
  if (!(S && !S.includes(d) || D(
766
764
  e,
767
765
  n.split(".").slice(1)
768
766
  ) === void 0))
769
- return i({
767
+ return c({
770
768
  path: n.split(".").slice(1),
771
769
  componentId: y,
772
770
  meta: o
@@ -779,11 +777,11 @@ function we(e, a, l, s) {
779
777
  const n = p.getState().selectedIndicesMap.get(r);
780
778
  if (!n)
781
779
  return -1;
782
- const { keys: c } = j(e, t, o);
783
- if (!c)
780
+ const { keys: i } = j(e, t, o);
781
+ if (!i)
784
782
  return -1;
785
783
  const S = n.split(".").pop();
786
- return c.indexOf(S);
784
+ return i.indexOf(S);
787
785
  };
788
786
  if (f === "$clearSelected")
789
787
  return Q(e, t), () => {
@@ -793,22 +791,22 @@ function we(e, a, l, s) {
793
791
  };
794
792
  if (f === "$map")
795
793
  return (r) => {
796
- const { value: n, keys: c } = j(
794
+ const { value: n, keys: i } = j(
797
795
  e,
798
796
  t,
799
797
  o
800
798
  );
801
- if (ie(e, y, t), !c || !Array.isArray(n))
799
+ if (ie(e, y, t), !i || !Array.isArray(n))
802
800
  return [];
803
- const S = i({
801
+ const S = c({
804
802
  path: t,
805
803
  componentId: y,
806
804
  meta: o
807
805
  });
808
806
  return n.map((d, h) => {
809
- const w = c[h];
807
+ const w = i[h];
810
808
  if (!w) return;
811
- const M = [...t, w], E = i({
809
+ const M = [...t, w], E = c({
812
810
  path: M,
813
811
  // This now correctly points to the item in the shadow store.
814
812
  componentId: y,
@@ -819,7 +817,7 @@ function we(e, a, l, s) {
819
817
  };
820
818
  if (f === "$filter")
821
819
  return (r) => {
822
- const n = t.length > 0 ? t.join(".") : "root", { keys: c, value: S } = j(
820
+ const n = t.length > 0 ? t.join(".") : "root", { keys: i, value: S } = j(
823
821
  e,
824
822
  t,
825
823
  o
@@ -829,10 +827,10 @@ function we(e, a, l, s) {
829
827
  const d = [];
830
828
  return S.forEach((h, w) => {
831
829
  if (r(h, w)) {
832
- const M = c[w];
830
+ const M = i[w];
833
831
  M && d.push(M);
834
832
  }
835
- }), i({
833
+ }), c({
836
834
  path: t,
837
835
  componentId: y,
838
836
  meta: {
@@ -850,20 +848,20 @@ function we(e, a, l, s) {
850
848
  };
851
849
  if (f === "$sort")
852
850
  return (r) => {
853
- const n = t.length > 0 ? t.join(".") : "root", { value: c, keys: S } = j(
851
+ const n = t.length > 0 ? t.join(".") : "root", { value: i, keys: S } = j(
854
852
  e,
855
853
  t,
856
854
  o
857
855
  );
858
- if (!Array.isArray(c) || !S)
856
+ if (!Array.isArray(i) || !S)
859
857
  throw new Error("No array keys found for sorting");
860
- const d = c.map((w, M) => ({
858
+ const d = i.map((w, M) => ({
861
859
  item: w,
862
860
  key: S[M]
863
861
  }));
864
862
  d.sort((w, M) => r(w.item, M.item));
865
863
  const h = d.map((w) => w.key);
866
- return i({
864
+ return c({
867
865
  path: t,
868
866
  componentId: y,
869
867
  meta: {
@@ -883,7 +881,7 @@ function we(e, a, l, s) {
883
881
  return function(r = {}) {
884
882
  const {
885
883
  bufferSize: n = 100,
886
- flushInterval: c = 100,
884
+ flushInterval: i = 100,
887
885
  bufferStrategy: S = "accumulate",
888
886
  store: d,
889
887
  onFlush: h
@@ -915,7 +913,7 @@ function we(e, a, l, s) {
915
913
  });
916
914
  h?.(T);
917
915
  };
918
- c > 0 && (E = setInterval(k, c));
916
+ i > 0 && (E = setInterval(k, i));
919
917
  const O = X(), _ = A(e, t) || {}, z = _.streams || /* @__PURE__ */ new Map();
920
918
  return z.set(O, { buffer: w, flushTimer: E }), L(e, t, {
921
919
  ..._,
@@ -939,7 +937,7 @@ function we(e, a, l, s) {
939
937
  };
940
938
  if (f === "$list")
941
939
  return (r) => /* @__PURE__ */ Z(() => {
942
- const c = q(/* @__PURE__ */ new Map()), [S, d] = ee({}), h = t.length > 0 ? t.join(".") : "root", w = st(e, t, o), M = ye(() => ({
940
+ const i = x(/* @__PURE__ */ new Map()), [S, d] = ee({}), h = t.length > 0 ? t.join(".") : "root", w = st(e, t, o), M = ye(() => ({
943
941
  ...o,
944
942
  arrayViews: {
945
943
  ...o?.arrayViews || {},
@@ -965,7 +963,7 @@ function we(e, a, l, s) {
965
963
  };
966
964
  }, [y, I]), !Array.isArray(E))
967
965
  return null;
968
- const b = i({
966
+ const b = c({
969
967
  path: t,
970
968
  componentId: y,
971
969
  meta: M
@@ -974,8 +972,8 @@ function we(e, a, l, s) {
974
972
  const z = w[_];
975
973
  if (!z)
976
974
  return null;
977
- let T = c.current.get(z);
978
- T || (T = X(), c.current.set(z, T));
975
+ let T = i.current.get(z);
976
+ T || (T = X(), i.current.set(z, T));
979
977
  const U = [...t, z];
980
978
  return ue(De, {
981
979
  key: z,
@@ -984,7 +982,7 @@ function we(e, a, l, s) {
984
982
  itemPath: U,
985
983
  localIndex: _,
986
984
  arraySetter: b,
987
- rebuildStateShape: i,
985
+ rebuildStateShape: c,
988
986
  renderFn: r
989
987
  });
990
988
  });
@@ -992,8 +990,8 @@ function we(e, a, l, s) {
992
990
  }, {});
993
991
  if (f === "$stateFlattenOn")
994
992
  return (r) => {
995
- const n = t.length > 0 ? t.join(".") : "root", c = o?.arrayViews?.[n], S = p.getState().getShadowValue(e, t, c);
996
- return Array.isArray(S) ? i({
993
+ const n = t.length > 0 ? t.join(".") : "root", i = o?.arrayViews?.[n], S = p.getState().getShadowValue(e, t, i);
994
+ return Array.isArray(S) ? c({
997
995
  path: [...t, "[*]", r],
998
996
  componentId: y,
999
997
  meta: o
@@ -1001,10 +999,10 @@ function we(e, a, l, s) {
1001
999
  };
1002
1000
  if (f === "$index")
1003
1001
  return (r) => {
1004
- const n = t.length > 0 ? t.join(".") : "root", c = o?.arrayViews?.[n];
1005
- if (c) {
1006
- const h = c[r];
1007
- return h ? i({
1002
+ const n = t.length > 0 ? t.join(".") : "root", i = o?.arrayViews?.[n];
1003
+ if (i) {
1004
+ const h = i[r];
1005
+ return h ? c({
1008
1006
  path: [...t, h],
1009
1007
  componentId: y,
1010
1008
  meta: o
@@ -1014,7 +1012,7 @@ function we(e, a, l, s) {
1014
1012
  if (!S?.arrayKeys) return;
1015
1013
  const d = S.arrayKeys[r];
1016
1014
  if (d)
1017
- return i({
1015
+ return c({
1018
1016
  path: [...t, d],
1019
1017
  componentId: y,
1020
1018
  meta: o
@@ -1028,9 +1026,9 @@ function we(e, a, l, s) {
1028
1026
  const n = r[r.length - 1];
1029
1027
  if (!n)
1030
1028
  return;
1031
- const c = [...t, n];
1032
- return i({
1033
- path: c,
1029
+ const i = [...t, n];
1030
+ return c({
1031
+ path: i,
1034
1032
  componentId: y,
1035
1033
  meta: o
1036
1034
  });
@@ -1049,7 +1047,7 @@ function we(e, a, l, s) {
1049
1047
  });
1050
1048
  };
1051
1049
  if (f === "$uniqueInsert")
1052
- return (r, n, c) => {
1050
+ return (r, n, i) => {
1053
1051
  const { value: S } = W(
1054
1052
  e,
1055
1053
  t,
@@ -1063,8 +1061,8 @@ function we(e, a, l, s) {
1063
1061
  return E && (h = M), E;
1064
1062
  }))
1065
1063
  a(d, t, { updateType: "insert" });
1066
- else if (c && h) {
1067
- const M = c(h), E = S.map(
1064
+ else if (i && h) {
1065
+ const M = i(h), E = S.map(
1068
1066
  (b) => Y(b, h) ? M : b
1069
1067
  );
1070
1068
  a(E, t, {
@@ -1074,28 +1072,26 @@ function we(e, a, l, s) {
1074
1072
  };
1075
1073
  if (f === "$cut")
1076
1074
  return (r, n) => {
1077
- const c = A(e, t);
1078
- if (console.log("shadowMeta ->>>>>>>>>>>>>>>>", c), !c?.arrayKeys || c.arrayKeys.length === 0)
1075
+ const i = A(e, t);
1076
+ if (!i?.arrayKeys || i.arrayKeys.length === 0)
1079
1077
  return;
1080
- const S = r === -1 ? c.arrayKeys.length - 1 : r !== void 0 ? r : c.arrayKeys.length - 1;
1081
- console.log("indexToCut ->>>>>>>>>>>>>>>>", S);
1082
- const d = c.arrayKeys[S];
1083
- d && (console.log("idToCut ->>>>>>>>>>>>>>>>", d), a(null, [...t, d], {
1078
+ const S = r === -1 ? i.arrayKeys.length - 1 : r !== void 0 ? r : i.arrayKeys.length - 1, d = i.arrayKeys[S];
1079
+ d && a(null, [...t, d], {
1084
1080
  updateType: "cut"
1085
- }));
1081
+ });
1086
1082
  };
1087
1083
  if (f === "$cutSelected")
1088
1084
  return () => {
1089
1085
  const r = [e, ...t].join("."), { keys: n } = j(e, t, o);
1090
1086
  if (!n || n.length === 0)
1091
1087
  return;
1092
- const c = p.getState().selectedIndicesMap.get(r);
1093
- if (!c)
1088
+ const i = p.getState().selectedIndicesMap.get(r);
1089
+ if (!i)
1094
1090
  return;
1095
- const S = c.split(".").pop();
1091
+ const S = i.split(".").pop();
1096
1092
  if (!n.includes(S))
1097
1093
  return;
1098
- const d = c.split(".").slice(1);
1094
+ const d = i.split(".").slice(1);
1099
1095
  p.getState().clearSelectedIndex({ arrayKey: r });
1100
1096
  const h = d.slice(0, -1);
1101
1097
  Q(e, h), a(null, d, {
@@ -1106,11 +1102,11 @@ function we(e, a, l, s) {
1106
1102
  return (r) => {
1107
1103
  const {
1108
1104
  isArray: n,
1109
- value: c,
1105
+ value: i,
1110
1106
  keys: S
1111
1107
  } = j(e, t, o);
1112
1108
  if (!n) return;
1113
- const d = oe(c, S, (h) => h === r);
1109
+ const d = oe(i, S, (h) => h === r);
1114
1110
  d && a(null, [...t, d.key], {
1115
1111
  updateType: "cut"
1116
1112
  });
@@ -1119,11 +1115,11 @@ function we(e, a, l, s) {
1119
1115
  return (r) => {
1120
1116
  const {
1121
1117
  isArray: n,
1122
- value: c,
1118
+ value: i,
1123
1119
  keys: S
1124
1120
  } = j(e, t, o);
1125
1121
  if (!n) return;
1126
- const d = oe(c, S, (h) => h === r);
1122
+ const d = oe(i, S, (h) => h === r);
1127
1123
  if (d) {
1128
1124
  const h = [...t, d.key];
1129
1125
  a(null, h, {
@@ -1134,15 +1130,15 @@ function we(e, a, l, s) {
1134
1130
  };
1135
1131
  if (f === "$findWith")
1136
1132
  return (r, n) => {
1137
- const { isArray: c, value: S, keys: d } = j(e, t, o);
1138
- if (!c)
1133
+ const { isArray: i, value: S, keys: d } = j(e, t, o);
1134
+ if (!i)
1139
1135
  throw new Error("findWith can only be used on arrays");
1140
1136
  const h = oe(
1141
1137
  S,
1142
1138
  d,
1143
1139
  (w) => w?.[r] === n
1144
1140
  );
1145
- return h ? i({
1141
+ return h ? c({
1146
1142
  path: [...t, h.key],
1147
1143
  componentId: y,
1148
1144
  meta: o
@@ -1178,20 +1174,20 @@ function we(e, a, l, s) {
1178
1174
  if (f === "$isSelected") {
1179
1175
  const r = t.slice(0, -1);
1180
1176
  if (A(e, r)?.arrayKeys) {
1181
- const c = e + "." + r.join("."), S = p.getState().selectedIndicesMap.get(c), d = e + "." + t.join(".");
1177
+ const i = e + "." + r.join("."), S = p.getState().selectedIndicesMap.get(i), d = e + "." + t.join(".");
1182
1178
  return S === d;
1183
1179
  }
1184
1180
  return;
1185
1181
  }
1186
1182
  if (f === "$setSelected")
1187
1183
  return (r) => {
1188
- const n = t.slice(0, -1), c = e + "." + n.join("."), S = e + "." + t.join(".");
1189
- Q(e, n, void 0), p.getState().selectedIndicesMap.get(c), r && p.getState().setSelectedIndex(c, S);
1184
+ const n = t.slice(0, -1), i = e + "." + n.join("."), S = e + "." + t.join(".");
1185
+ Q(e, n, void 0), p.getState().selectedIndicesMap.get(i), r && p.getState().setSelectedIndex(i, S);
1190
1186
  };
1191
1187
  if (f === "$toggleSelected")
1192
1188
  return () => {
1193
- const r = t.slice(0, -1), n = e + "." + r.join("."), c = e + "." + t.join(".");
1194
- p.getState().selectedIndicesMap.get(n) === c ? p.getState().clearSelectedIndex({ arrayKey: n }) : p.getState().setSelectedIndex(n, c), Q(e, r);
1189
+ const r = t.slice(0, -1), n = e + "." + r.join("."), i = e + "." + t.join(".");
1190
+ p.getState().selectedIndicesMap.get(n) === i ? p.getState().clearSelectedIndex({ arrayKey: n }) : p.getState().setSelectedIndex(n, i), Q(e, r);
1195
1191
  };
1196
1192
  if (f === "$_componentId")
1197
1193
  return y;
@@ -1201,31 +1197,31 @@ function we(e, a, l, s) {
1201
1197
  ce({ stateKey: e, options: r, initialOptionsPart: {} });
1202
1198
  };
1203
1199
  if (f === "$_applyUpdate")
1204
- return (r, n, c = "update") => {
1205
- a(r, n, { updateType: c });
1200
+ return (r, n, i = "update") => {
1201
+ a(r, n, { updateType: i });
1206
1202
  };
1207
1203
  if (f === "$_getEffectiveSetState")
1208
1204
  return a;
1209
1205
  if (f === "$getPluginMetaData")
1210
1206
  return (r) => Ge(e, t)?.get(r);
1211
1207
  if (f === "$addPluginMetaData")
1212
- return console.log("$addPluginMetaDat"), (r, n) => xe(e, t, r, n);
1208
+ return (r, n) => qe(e, t, r, n);
1213
1209
  if (f === "$removePluginMetaData")
1214
- return (r) => qe(e, t, r);
1210
+ return (r) => xe(e, t, r);
1215
1211
  if (f === "$addZodValidation")
1216
1212
  return (r, n) => {
1217
- r.forEach((c) => {
1218
- const S = p.getState().getShadowMetadata(e, c.path) || {};
1219
- p.getState().setShadowMetadata(e, c.path, {
1213
+ r.forEach((i) => {
1214
+ const S = p.getState().getShadowMetadata(e, i.path) || {};
1215
+ p.getState().setShadowMetadata(e, i.path, {
1220
1216
  ...S,
1221
1217
  validation: {
1222
1218
  status: "INVALID",
1223
1219
  errors: [
1224
1220
  {
1225
1221
  source: n || "client",
1226
- message: c.message,
1222
+ message: i.message,
1227
1223
  severity: "error",
1228
- code: c.code
1224
+ code: i.code
1229
1225
  }
1230
1226
  ],
1231
1227
  lastValidated: Date.now(),
@@ -1250,32 +1246,28 @@ function we(e, a, l, s) {
1250
1246
  };
1251
1247
  if (f === "$applyOperation")
1252
1248
  return (r, n) => {
1253
- console.log(
1254
- "getGlobalStore",
1255
- p.getState().getShadowMetadata(e, r.path)
1256
- );
1257
- let c;
1249
+ let i;
1258
1250
  if (r.insertAfterId && r.updateType === "insert") {
1259
1251
  const S = A(e, r.path);
1260
1252
  if (S?.arrayKeys) {
1261
1253
  const d = S.arrayKeys.indexOf(
1262
1254
  r.insertAfterId
1263
1255
  );
1264
- d !== -1 && (c = d + 1);
1256
+ d !== -1 && (i = d + 1);
1265
1257
  }
1266
1258
  }
1267
1259
  a(r.newValue, r.path, {
1268
1260
  updateType: r.updateType,
1269
1261
  itemId: r.itemId,
1270
- index: c,
1262
+ index: i,
1271
1263
  // Pass the calculated index
1272
1264
  metaData: n
1273
1265
  });
1274
1266
  };
1275
1267
  if (f === "$applyJsonPatch")
1276
1268
  return (r) => {
1277
- const n = p.getState(), c = n.getShadowMetadata(e, []);
1278
- if (!c?.components) return;
1269
+ const n = p.getState(), i = n.getShadowMetadata(e, []);
1270
+ if (!i?.components) return;
1279
1271
  const S = (h) => !h || h === "/" ? [] : h.split("/").slice(1).map((w) => w.replace(/~1/g, "/").replace(/~0/g, "~")), d = /* @__PURE__ */ new Set();
1280
1272
  for (const h of r) {
1281
1273
  const w = S(h.path);
@@ -1292,7 +1284,7 @@ function we(e, a, l, s) {
1292
1284
  );
1293
1285
  if (b?.pathComponents && b.pathComponents.forEach((k) => {
1294
1286
  if (!d.has(k)) {
1295
- const O = c.components?.get(k);
1287
+ const O = i.components?.get(k);
1296
1288
  O && (O.forceUpdate(), d.add(k));
1297
1289
  }
1298
1290
  }), E.length === 0) break;
@@ -1311,7 +1303,7 @@ function we(e, a, l, s) {
1311
1303
  );
1312
1304
  if (b?.pathComponents && b.pathComponents.forEach((k) => {
1313
1305
  if (!d.has(k)) {
1314
- const O = c.components?.get(k);
1306
+ const O = i.components?.get(k);
1315
1307
  O && (O.forceUpdate(), d.add(k));
1316
1308
  }
1317
1309
  }), E.length === 0) break;
@@ -1350,8 +1342,8 @@ function we(e, a, l, s) {
1350
1342
  stateSource: "server",
1351
1343
  lastServerSync: Date.now()
1352
1344
  });
1353
- const c = [e, ...t].join(".");
1354
- Be(c, {
1345
+ const i = [e, ...t].join(".");
1346
+ Be(i, {
1355
1347
  type: "SYNC_STATUS_CHANGE",
1356
1348
  isDirty: !1
1357
1349
  });
@@ -1372,29 +1364,37 @@ function we(e, a, l, s) {
1372
1364
  };
1373
1365
  }
1374
1366
  if (f === "$isolate")
1375
- return (r) => /* @__PURE__ */ Z(
1376
- Pe,
1377
- {
1378
- stateKey: e,
1379
- path: t,
1380
- rebuildStateShape: i,
1381
- renderFn: r
1382
- }
1383
- );
1367
+ return (r, n) => {
1368
+ const i = Array.isArray(r), S = i ? r : void 0, d = i ? n : r;
1369
+ if (!d || typeof d != "function")
1370
+ throw new Error(
1371
+ "CogsState: $isolate requires a render function."
1372
+ );
1373
+ return /* @__PURE__ */ Z(
1374
+ Pe,
1375
+ {
1376
+ stateKey: e,
1377
+ path: t,
1378
+ dependencies: S,
1379
+ rebuildStateShape: c,
1380
+ renderFn: d
1381
+ }
1382
+ );
1383
+ };
1384
1384
  if (f === "$formElement")
1385
1385
  return (r, n) => /* @__PURE__ */ Z(
1386
1386
  ke,
1387
1387
  {
1388
1388
  stateKey: e,
1389
1389
  path: t,
1390
- rebuildStateShape: i,
1390
+ rebuildStateShape: c,
1391
1391
  setState: a,
1392
1392
  formOpts: n,
1393
1393
  renderFn: r
1394
1394
  }
1395
1395
  );
1396
1396
  const P = [...t, f];
1397
- return i({
1397
+ return c({
1398
1398
  path: P,
1399
1399
  componentId: y,
1400
1400
  meta: o
@@ -1407,7 +1407,7 @@ function we(e, a, l, s) {
1407
1407
  $revertToInitialState: (t) => {
1408
1408
  const o = p.getState().getShadowMetadata(e, []);
1409
1409
  let y;
1410
- o?.stateSource === "server" && o.baseServerState ? y = o.baseServerState : y = p.getState().initialStateGlobal[e], ze(e), K(e, y), i({
1410
+ o?.stateSource === "server" && o.baseServerState ? y = o.baseServerState : y = p.getState().initialStateGlobal[e], ze(e), K(e, y), c({
1411
1411
  path: [],
1412
1412
  componentId: l
1413
1413
  });
@@ -1435,7 +1435,7 @@ function we(e, a, l, s) {
1435
1435
  };
1436
1436
  }
1437
1437
  };
1438
- return i({
1438
+ return c({
1439
1439
  componentId: l,
1440
1440
  path: []
1441
1441
  });
@@ -1446,7 +1446,7 @@ function Se(e) {
1446
1446
  function it({
1447
1447
  proxy: e
1448
1448
  }) {
1449
- const a = q(null), l = q(null), s = q(!1), g = `${e._stateKey}-${e._path.join(".")}`, i = e._path.length > 0 ? e._path.join(".") : "root", m = e._meta?.arrayViews?.[i], u = D(e._stateKey, e._path, m);
1449
+ const a = x(null), l = x(null), s = x(!1), g = `${e._stateKey}-${e._path.join(".")}`, c = e._path.length > 0 ? e._path.join(".") : "root", m = e._meta?.arrayViews?.[c], u = D(e._stateKey, e._path, m);
1450
1450
  return J(() => {
1451
1451
  const t = a.current;
1452
1452
  if (!t || s.current) return;
@@ -1498,8 +1498,8 @@ function it({
1498
1498
  }
1499
1499
  export {
1500
1500
  Se as $cogsSignal,
1501
- pt as addStateOptions,
1502
- Mt as createCogsState,
1501
+ wt as addStateOptions,
1502
+ pt as createCogsState,
1503
1503
  ot as useCogsStateFn
1504
1504
  };
1505
1505
  //# sourceMappingURL=CogsState.jsx.map