cogsbox-state 0.5.489 → 0.5.491

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.
package/dist/store.js CHANGED
@@ -1,79 +1,79 @@
1
- import { create as N } from "zustand";
1
+ import { create as z } from "zustand";
2
2
  function A(f, o = "zod4") {
3
3
  if (!f) return null;
4
- let t = f, e = !1, n = !1, a, s = !1;
4
+ let t = f, e = !1, n = !1, a, i = !1;
5
5
  for (let l = 0; l < 20; l++) {
6
6
  const d = t?.def || t?._def;
7
7
  if (!d) break;
8
- const y = d.typeName || d.type || t._type;
9
- if (y === "ZodUnion" || y === "union")
8
+ const m = d.typeName || d.type || t._type;
9
+ if (m === "ZodUnion" || m === "union")
10
10
  if (d.options && d.options.length > 0) {
11
11
  t = d.options.find((c) => {
12
- const h = c?.def || c?._def, m = h?.typeName || h?.type || c?._type;
13
- return m !== "ZodNull" && m !== "null" && m !== "ZodUndefined" && m !== "undefined";
12
+ const y = c?.def || c?._def, h = y?.typeName || y?.type || c?._type;
13
+ return h !== "ZodNull" && h !== "null" && h !== "ZodUndefined" && h !== "undefined";
14
14
  }) ?? d.options[0];
15
15
  continue;
16
16
  } else
17
17
  break;
18
- if (y === "ZodOptional" || y === "optional")
18
+ if (m === "ZodOptional" || m === "optional")
19
19
  n = !0;
20
- else if (y === "ZodNullable" || y === "nullable")
20
+ else if (m === "ZodNullable" || m === "nullable")
21
21
  e = !0;
22
- else if (y === "ZodDefault" || y === "default")
23
- s = !0, a = typeof d.defaultValue == "function" ? d.defaultValue() : d.defaultValue;
24
- else if (y !== "ZodEffects" && y !== "effects")
22
+ else if (m === "ZodDefault" || m === "default")
23
+ i = !0, a = typeof d.defaultValue == "function" ? d.defaultValue() : d.defaultValue;
24
+ else if (m !== "ZodEffects" && m !== "effects")
25
25
  break;
26
26
  const b = d.innerType || d.schema || t._inner;
27
27
  if (!b || b === t)
28
28
  break;
29
29
  t = b;
30
30
  }
31
- const i = t, r = i?.def || i?._def, u = r?.typeName || r?.type || i?._type;
31
+ const s = t, r = s?.def || s?._def, u = r?.typeName || r?.type || s?._type;
32
32
  return u === "ZodNumber" || u === "number" ? {
33
33
  type: "number",
34
34
  schema: f,
35
35
  source: o,
36
- default: s ? a : 0,
36
+ default: i ? a : 0,
37
37
  nullable: e,
38
38
  optional: n
39
39
  } : u === "ZodString" || u === "string" ? {
40
40
  type: "string",
41
41
  schema: f,
42
42
  source: o,
43
- default: s ? a : "",
43
+ default: i ? a : "",
44
44
  nullable: e,
45
45
  optional: n
46
46
  } : u === "ZodBoolean" || u === "boolean" ? {
47
47
  type: "boolean",
48
48
  schema: f,
49
49
  source: o,
50
- default: s ? a : !1,
50
+ default: i ? a : !1,
51
51
  nullable: e,
52
52
  optional: n
53
53
  } : u === "ZodArray" || u === "array" ? {
54
54
  type: "array",
55
55
  schema: f,
56
56
  source: o,
57
- default: s ? a : [],
57
+ default: i ? a : [],
58
58
  nullable: e,
59
59
  optional: n
60
60
  } : u === "ZodObject" || u === "object" ? {
61
61
  type: "object",
62
62
  schema: f,
63
63
  source: o,
64
- default: s ? a : {},
64
+ default: i ? a : {},
65
65
  nullable: e,
66
66
  optional: n
67
67
  } : u === "ZodDate" || u === "date" ? {
68
68
  type: "date",
69
69
  schema: f,
70
70
  source: o,
71
- default: s ? a : /* @__PURE__ */ new Date(),
71
+ default: i ? a : /* @__PURE__ */ new Date(),
72
72
  nullable: e,
73
73
  optional: n
74
74
  } : null;
75
75
  }
76
- function O(f) {
76
+ function j(f) {
77
77
  if (f === null)
78
78
  return {
79
79
  type: "unknown",
@@ -96,21 +96,21 @@ function O(f) {
96
96
  function g(f, o, t) {
97
97
  if (o == null || typeof o != "object") {
98
98
  const e = { _meta: { value: o } };
99
- return e._meta.typeInfo = v(o, t), e;
99
+ return e._meta.typeInfo = O(o, t), e;
100
100
  }
101
101
  if (Array.isArray(o)) {
102
102
  const e = { _meta: { arrayKeys: [] } };
103
- return e._meta.typeInfo = v(o, t), o.forEach((n, a) => {
104
- const s = I(), i = t ? {
103
+ return e._meta.typeInfo = O(o, t), o.forEach((n, a) => {
104
+ const i = I(), s = t ? {
105
105
  ...t,
106
106
  path: [...t.path, a.toString()]
107
107
  } : void 0;
108
- e[s] = g(f, n, i), e._meta.arrayKeys.push(s);
108
+ e[i] = g(f, n, s), e._meta.arrayKeys.push(i);
109
109
  }), e;
110
110
  }
111
111
  if (o.constructor === Object) {
112
112
  const e = { _meta: {} };
113
- e._meta.typeInfo = v(o, t);
113
+ e._meta.typeInfo = O(o, t);
114
114
  for (const n in o)
115
115
  if (Object.prototype.hasOwnProperty.call(o, n)) {
116
116
  const a = t ? {
@@ -124,47 +124,47 @@ function g(f, o, t) {
124
124
  return {
125
125
  _meta: {
126
126
  value: o,
127
- typeInfo: O(o)
127
+ typeInfo: j(o)
128
128
  }
129
129
  };
130
130
  }
131
- function v(f, o) {
131
+ function O(f, o) {
132
132
  if (o) {
133
133
  let t = null;
134
134
  if (o.schemas.zodV4) {
135
- const e = o.path.length === 0 ? o.schemas.zodV4 : E(o.schemas.zodV4, o.path);
135
+ const e = o.path.length === 0 ? o.schemas.zodV4 : v(o.schemas.zodV4, o.path);
136
136
  e && (t = A(e, "zod4"));
137
137
  }
138
138
  if (!t && o.schemas.zodV3) {
139
- const e = o.path.length === 0 ? o.schemas.zodV3 : E(o.schemas.zodV3, o.path);
139
+ const e = o.path.length === 0 ? o.schemas.zodV3 : v(o.schemas.zodV3, o.path);
140
140
  e && (t = A(e, "zod3"));
141
141
  }
142
- if (!t && o.schemas.sync?.[o.stateKey] && (t = O(f), t.source = "sync"), t) return t;
142
+ if (!t && o.schemas.sync?.[o.stateKey] && (t = j(f), t.source = "sync"), t) return t;
143
143
  }
144
- return O(f);
144
+ return j(f);
145
145
  }
146
146
  function w(f, o, t) {
147
147
  const e = S.get(f) || S.get(`[${f}`);
148
148
  if (!e) return;
149
- function n(a, s) {
149
+ function n(a, i) {
150
150
  if (!a || typeof a != "object") return;
151
- const i = E(o, s);
152
- if (i) {
153
- const r = A(i, t);
151
+ const s = v(o, i);
152
+ if (s) {
153
+ const r = A(s, t);
154
154
  r && (a._meta || (a._meta = {}), a._meta.typeInfo = {
155
155
  ...r,
156
- schema: i
156
+ schema: s
157
157
  });
158
158
  }
159
159
  a._meta?.arrayKeys ? a._meta.arrayKeys.forEach((r) => {
160
- a[r] && n(a[r], [...s, "0"]);
160
+ a[r] && n(a[r], [...i, "0"]);
161
161
  }) : a._meta?.hasOwnProperty("value") || Object.keys(a).forEach((r) => {
162
- r !== "_meta" && n(a[r], [...s, r]);
162
+ r !== "_meta" && n(a[r], [...i, r]);
163
163
  });
164
164
  }
165
165
  n(e, []);
166
166
  }
167
- function z(f) {
167
+ function N(f) {
168
168
  let o = f;
169
169
  for (; o; ) {
170
170
  const t = o.def || o._def, e = t?.typeName || t?.type || o._type;
@@ -175,18 +175,18 @@ function z(f) {
175
175
  }
176
176
  return o;
177
177
  }
178
- function E(f, o) {
178
+ function v(f, o) {
179
179
  if (!f) return null;
180
180
  if (o.length === 0) return f;
181
181
  let t = f;
182
182
  for (const e of o) {
183
- const n = z(t);
183
+ const n = N(t);
184
184
  if (!n) return null;
185
- const a = n.def || n._def, s = a?.typeName || a?.type || n._type;
186
- if (s === "ZodObject" || s === "object") {
187
- const i = a?.shape ?? n.shape ?? n._shape;
188
- t = (typeof i == "function" ? i() : i)?.[e];
189
- } else if (s === "ZodArray" || s === "array")
185
+ const a = n.def || n._def, i = a?.typeName || a?.type || n._type;
186
+ if (i === "ZodObject" || i === "object") {
187
+ const s = a?.shape ?? n.shape ?? n._shape;
188
+ t = (typeof s == "function" ? s() : s)?.[e];
189
+ } else if (i === "ZodArray" || i === "array")
190
190
  t = n.element || a?.type;
191
191
  else
192
192
  return null;
@@ -201,82 +201,79 @@ const V = Date.now().toString(36);
201
201
  function I(f) {
202
202
  return `id:local_${V}_${(K++).toString(36)}`;
203
203
  }
204
- const C = N((f, o) => ({
204
+ const C = z((f, o) => ({
205
205
  getPluginMetaDataMap: (t, e) => o().getShadowMetadata(t, e)?.pluginMetaData,
206
206
  setPluginMetaData: (t, e, n, a) => {
207
- const s = o().getShadowMetadata(t, e) || {}, i = new Map(s.pluginMetaData || []), r = i.get(n) || {};
208
- i.set(n, { ...r, ...a }), o().setShadowMetadata(t, e, { ...s, pluginMetaData: i }), o().notifyPathSubscribers([t, ...e].join("."), {
207
+ const i = o().getShadowMetadata(t, e) || {}, s = new Map(i.pluginMetaData || []), r = s.get(n) || {};
208
+ s.set(n, { ...r, ...a }), o().setShadowMetadata(t, e, { ...i, pluginMetaData: s }), o().notifyPathSubscribers([t, ...e].join("."), {
209
209
  type: "METADATA_UPDATE"
210
210
  });
211
211
  },
212
212
  removePluginMetaData: (t, e, n) => {
213
213
  const a = o().getShadowMetadata(t, e);
214
214
  if (!a?.pluginMetaData) return;
215
- const s = new Map(a.pluginMetaData);
216
- s.delete(n), o().setShadowMetadata(t, e, { ...a, pluginMetaData: s });
215
+ const i = new Map(a.pluginMetaData);
216
+ i.delete(n), o().setShadowMetadata(t, e, { ...a, pluginMetaData: i });
217
217
  },
218
218
  setTransformCache: (t, e, n, a) => {
219
- const s = o().getShadowMetadata(t, e) || {};
220
- s.transformCaches || (s.transformCaches = /* @__PURE__ */ new Map()), s.transformCaches.set(n, a), o().setShadowMetadata(t, e, {
221
- transformCaches: s.transformCaches
219
+ const i = o().getShadowMetadata(t, e) || {};
220
+ i.transformCaches || (i.transformCaches = /* @__PURE__ */ new Map()), i.transformCaches.set(n, a), o().setShadowMetadata(t, e, {
221
+ transformCaches: i.transformCaches
222
222
  });
223
223
  },
224
224
  // Replace your entire `initializeAndMergeShadowState` function with this one.
225
225
  initializeAndMergeShadowState: (t, e) => {
226
- const a = e?._meta?.arrayKeys !== void 0 ? `[${t}` : t, s = S.get(a) || S.get(t) || S.get(`[${t}`);
227
- let i = {};
228
- if (s?._meta) {
226
+ const a = e?._meta?.arrayKeys !== void 0 ? `[${t}` : t, i = S.get(a) || S.get(t) || S.get(`[${t}`);
227
+ let s = {};
228
+ if (i?._meta) {
229
229
  const {
230
230
  components: d,
231
- features: y,
232
- lastServerSync: b,
233
- stateSource: p,
234
- baseServerState: c,
235
- pathComponents: h,
236
- signals: m,
237
- validation: _
238
- } = s._meta;
239
- d && (i.components = d), y && (i.features = y), b && (i.lastServerSync = b), p && (i.stateSource = p), c && (i.baseServerState = c), h && (i.pathComponents = h), m && (i.signals = m), _ && (i.validation = _);
231
+ features: m,
232
+ pathComponents: b,
233
+ signals: p,
234
+ validation: c
235
+ } = i._meta;
236
+ d && (s.components = d), m && (s.features = m), b && (s.pathComponents = b), p && (s.signals = p), c && (s.validation = c);
240
237
  }
241
- function r(d, y) {
242
- if (y._meta || d._meta) {
243
- const c = d._meta || {}, h = y._meta || {}, m = { ...c, ...h };
244
- c.typeInfo?.schema && !h.typeInfo?.schema && (m.typeInfo = c.typeInfo), c.validation && !h.validation && (m.validation = c.validation), c.components && (m.components = c.components), c.clientActivityState && !h.clientActivityState && (m.clientActivityState = c.clientActivityState), c.pluginMetaData && !h.pluginMetaData && (m.pluginMetaData = c.pluginMetaData), d._meta = m;
238
+ function r(d, m) {
239
+ if (m._meta || d._meta) {
240
+ const c = d._meta || {}, y = m._meta || {}, h = { ...c, ...y };
241
+ c.typeInfo?.schema && !y.typeInfo?.schema && (h.typeInfo = c.typeInfo), c.validation && !y.validation && (h.validation = c.validation), c.components && (h.components = c.components), c.clientActivityState && !y.clientActivityState && (h.clientActivityState = c.clientActivityState), c.pluginMetaData && !y.pluginMetaData && (h.pluginMetaData = c.pluginMetaData), d._meta = h;
245
242
  }
246
- if (y._meta?.hasOwnProperty("value")) {
243
+ if (m._meta?.hasOwnProperty("value")) {
247
244
  for (const c in d)
248
245
  c !== "_meta" && delete d[c];
249
246
  return;
250
247
  }
251
248
  const b = new Set(
252
- Object.keys(y).filter((c) => c !== "_meta")
249
+ Object.keys(m).filter((c) => c !== "_meta")
253
250
  ), p = new Set(
254
251
  Object.keys(d).filter((c) => c !== "_meta")
255
252
  );
256
253
  for (const c of p)
257
254
  b.has(c) || delete d[c];
258
255
  for (const c of b) {
259
- const h = y[c], m = d[c];
260
- m && typeof m == "object" && h && typeof h == "object" ? r(m, h) : d[c] = h;
256
+ const y = m[c], h = d[c];
257
+ h && typeof h == "object" && y && typeof y == "object" ? r(h, y) : d[c] = y;
261
258
  }
262
259
  }
263
- s ? (r(s, e), s._meta || (s._meta = {}), Object.assign(s._meta, i), S.set(a, s)) : (i && Object.keys(i).length > 0 && (e._meta || (e._meta = {}), Object.assign(e._meta, i)), S.set(a, e));
260
+ i ? (r(i, e), i._meta || (i._meta = {}), Object.assign(i._meta, s), S.set(a, i)) : (s && Object.keys(s).length > 0 && (e._meta || (e._meta = {}), Object.assign(e._meta, s)), S.set(a, e));
264
261
  const u = o().getInitialOptions(t);
265
262
  (u?.validation?.zodSchemaV4 || u?.validation?.zodSchemaV3) && (u.validation?.zodSchemaV4 ? w(t, u.validation.zodSchemaV4, "zod4") : u.validation?.zodSchemaV3 && w(t, u.validation.zodSchemaV3, "zod3")), a === t ? S.delete(`[${t}`) : S.delete(t);
266
263
  },
267
264
  initializeShadowState: (t, e) => {
268
265
  const n = S.get(t) || S.get(`[${t}`);
269
266
  let a = {};
270
- const s = /* @__PURE__ */ new Map();
267
+ const i = /* @__PURE__ */ new Map();
271
268
  if (n) {
272
- const p = (c, h) => {
269
+ const p = (c, y) => {
273
270
  if (!(!c || typeof c != "object")) {
274
- (c._meta?.clientActivityState || c._meta?.pluginMetaData) && s.set(h.join("\0"), {
271
+ (c._meta?.clientActivityState || c._meta?.pluginMetaData) && i.set(y.join("\0"), {
275
272
  clientActivityState: c._meta.clientActivityState,
276
273
  pluginMetaData: c._meta.pluginMetaData
277
274
  });
278
- for (const m in c)
279
- m !== "_meta" && p(c[m], [...h, m]);
275
+ for (const h in c)
276
+ h !== "_meta" && p(c[h], [...y, h]);
280
277
  }
281
278
  };
282
279
  p(n, []);
@@ -284,34 +281,31 @@ const C = N((f, o) => ({
284
281
  if (n?._meta) {
285
282
  const {
286
283
  components: p,
287
- features: c,
288
- lastServerSync: h,
289
- stateSource: m,
290
- baseServerState: _
284
+ features: c
291
285
  } = n._meta;
292
- p && (a.components = p), c && (a.features = c), h && (a.lastServerSync = h), m && (a.stateSource = m), _ && (a.baseServerState = _);
286
+ p && (a.components = p), c && (a.features = c);
293
287
  }
294
288
  S.delete(t), S.delete(`[${t}`);
295
- const i = o().getInitialOptions(t), r = o().getInitialOptions("__syncSchemas"), u = {
289
+ const s = o().getInitialOptions(t), r = o().getInitialOptions("__syncSchemas"), u = {
296
290
  stateKey: t,
297
291
  path: [],
298
292
  schemas: {
299
293
  sync: r,
300
- zodV4: i?.validation?.zodSchemaV4,
301
- zodV3: i?.validation?.zodSchemaV3
294
+ zodV4: s?.validation?.zodSchemaV4,
295
+ zodV3: s?.validation?.zodSchemaV3
302
296
  }
303
297
  }, l = g(t, e, u);
304
298
  l._meta || (l._meta = {}), Object.assign(l._meta, a);
305
299
  const d = (p, c) => {
306
300
  if (!p || typeof p != "object") return;
307
- const h = c.join("\0"), m = s.get(h);
308
- m && (p._meta || (p._meta = {}), m.clientActivityState && (p._meta.clientActivityState = m.clientActivityState), m.pluginMetaData && (p._meta.pluginMetaData = m.pluginMetaData));
301
+ const y = c.join("\0"), h = i.get(y);
302
+ h && (p._meta || (p._meta = {}), h.clientActivityState && (p._meta.clientActivityState = h.clientActivityState), h.pluginMetaData && (p._meta.pluginMetaData = h.pluginMetaData));
309
303
  for (const _ in p)
310
304
  _ !== "_meta" && d(p[_], [...c, _]);
311
305
  };
312
306
  d(l, []);
313
- const y = Array.isArray(e) ? `[${t}` : t;
314
- S.set(y, l);
307
+ const m = Array.isArray(e) ? `[${t}` : t;
308
+ S.set(m, l);
315
309
  const b = o().getInitialOptions(t);
316
310
  b?.validation?.zodSchemaV4 ? w(t, b.validation.zodSchemaV4, "zod4") : b?.validation?.zodSchemaV3 && w(t, b.validation.zodSchemaV3, "zod3");
317
311
  },
@@ -327,25 +321,25 @@ const C = N((f, o) => ({
327
321
  getShadowMetadata: (t, e) => o().getShadowNode(t, e)?._meta,
328
322
  setShadowMetadata: (t, e, n) => {
329
323
  const a = S.has(`[${t}`) ? `[${t}` : t;
330
- let s = S.get(a);
331
- if (!s) {
332
- s = { _meta: n }, S.set(a, s);
324
+ let i = S.get(a);
325
+ if (!i) {
326
+ i = { _meta: n }, S.set(a, i);
333
327
  return;
334
328
  }
335
- let i = s;
329
+ let s = i;
336
330
  for (const r of e)
337
- i[r] || (i[r] = {}), i = i[r];
338
- i._meta || (i._meta = {}), Object.assign(i._meta, n);
331
+ s[r] || (s[r] = {}), s = s[r];
332
+ s._meta || (s._meta = {}), Object.assign(s._meta, n);
339
333
  },
340
334
  getShadowValue: (t, e, n) => {
341
335
  const a = o().getShadowNode(t, e);
342
336
  if (!a)
343
337
  return;
344
- const s = {}, i = [
345
- [a, s, "final"]
338
+ const i = {}, s = [
339
+ [a, i, "final"]
346
340
  ];
347
- for (; i.length > 0; ) {
348
- const [r, u, l] = i.pop();
341
+ for (; s.length > 0; ) {
342
+ const [r, u, l] = s.pop();
349
343
  if (r._meta?.hasOwnProperty("value")) {
350
344
  u[l] = r._meta.value;
351
345
  continue;
@@ -354,28 +348,28 @@ const C = N((f, o) => ({
354
348
  const b = n || r._meta.arrayKeys, p = [];
355
349
  u[l] = p;
356
350
  for (let c = b.length - 1; c >= 0; c--) {
357
- const h = b[c];
358
- r[h] && i.push([r[h], p, c]);
351
+ const y = b[c];
352
+ r[y] && s.push([r[y], p, c]);
359
353
  }
360
354
  continue;
361
355
  }
362
356
  const d = {};
363
357
  u[l] = d;
364
- const y = Object.keys(r);
365
- for (const b of y)
366
- b !== "_meta" && i.push([r[b], d, b]);
358
+ const m = Object.keys(r);
359
+ for (const b of m)
360
+ b !== "_meta" && s.push([r[b], d, b]);
367
361
  }
368
- return s.final;
362
+ return i.final;
369
363
  },
370
364
  updateShadowAtPath: (t, e, n) => {
371
365
  const a = S.has(`[${t}`) ? `[${t}` : t;
372
- let s = S.get(a);
373
- if (!s) return;
374
- let i = s;
366
+ let i = S.get(a);
367
+ if (!i) return;
368
+ let s = i;
375
369
  for (let l = 0; l < e.length - 1; l++)
376
- i[e[l]] || (i[e[l]] = {}), i = i[e[l]];
377
- const r = e.length === 0 ? i : i[e[e.length - 1]];
378
- function u(l, d, y) {
370
+ s[e[l]] || (s[e[l]] = {}), s = s[e[l]];
371
+ const r = e.length === 0 ? s : s[e[e.length - 1]];
372
+ function u(l, d, m) {
379
373
  if (typeof d != "object" || d === null || d instanceof Date) {
380
374
  const p = l._meta || {};
381
375
  for (const c in l)
@@ -385,35 +379,35 @@ const C = N((f, o) => ({
385
379
  }
386
380
  if (Array.isArray(d)) {
387
381
  l._meta || (l._meta = {}), l._meta.arrayKeys || (l._meta.arrayKeys = []);
388
- const p = l._meta.arrayKeys, c = d, h = [];
389
- for (let m = 0; m < c.length; m++) {
390
- const _ = c[m];
391
- if (m < p.length) {
392
- const M = p[m];
382
+ const p = l._meta.arrayKeys, c = d, y = [];
383
+ for (let h = 0; h < c.length; h++) {
384
+ const _ = c[h];
385
+ if (h < p.length) {
386
+ const M = p[h];
393
387
  u(l[M], _, [
394
- ...y,
388
+ ...m,
395
389
  M
396
- ]), h.push(M);
390
+ ]), y.push(M);
397
391
  } else {
398
- const M = I(), D = o().getInitialOptions(t), j = {
392
+ const M = I(), E = o().getInitialOptions(t), D = {
399
393
  stateKey: t,
400
- path: [...y, "0"],
394
+ path: [...m, "0"],
401
395
  // Use '0' for array element schema lookup
402
396
  schemas: {
403
- zodV4: D?.validation?.zodSchemaV4,
404
- zodV3: D?.validation?.zodSchemaV3
397
+ zodV4: E?.validation?.zodSchemaV4,
398
+ zodV3: E?.validation?.zodSchemaV3
405
399
  }
406
400
  };
407
401
  l[M] = g(
408
402
  t,
409
403
  _,
410
- j
411
- ), h.push(M);
404
+ D
405
+ ), y.push(M);
412
406
  }
413
407
  }
414
408
  p.length > c.length && p.slice(c.length).forEach((_) => {
415
409
  delete l[_];
416
- }), l._meta.arrayKeys = h;
410
+ }), l._meta.arrayKeys = y;
417
411
  return;
418
412
  }
419
413
  const b = new Set(Object.keys(d));
@@ -422,50 +416,50 @@ const C = N((f, o) => ({
422
416
  const c = d[p];
423
417
  if (l[p])
424
418
  u(l[p], c, [
425
- ...y,
419
+ ...m,
426
420
  p
427
421
  ]);
428
422
  else {
429
- const h = o().getInitialOptions(t), m = {
423
+ const y = o().getInitialOptions(t), h = {
430
424
  stateKey: t,
431
- path: [...y, p],
425
+ path: [...m, p],
432
426
  schemas: {
433
- zodV4: h?.validation?.zodSchemaV4,
434
- zodV3: h?.validation?.zodSchemaV3
427
+ zodV4: y?.validation?.zodSchemaV4,
428
+ zodV3: y?.validation?.zodSchemaV3
435
429
  }
436
430
  };
437
- l[p] = g(t, c, m);
431
+ l[p] = g(t, c, h);
438
432
  }
439
433
  }
440
434
  for (const p in l)
441
435
  p === "_meta" || !Object.prototype.hasOwnProperty.call(l, p) || b.has(p) || delete l[p];
442
436
  }
443
- r ? u(r, n, e) : i[e[e.length - 1]] = g(t, n), o().notifyPathSubscribers([t, ...e].join("."), {
437
+ r ? u(r, n, e) : s[e[e.length - 1]] = g(t, n), o().notifyPathSubscribers([t, ...e].join("."), {
444
438
  type: "UPDATE",
445
439
  newValue: n
446
440
  });
447
441
  },
448
442
  addItemsToArrayNode: (t, e, n) => {
449
443
  const a = S.has(`[${t}`) ? `[${t}` : t;
450
- let s = S.get(a);
451
- if (!s) {
444
+ let i = S.get(a);
445
+ if (!i) {
452
446
  console.error("Root not found for state key:", t);
453
447
  return;
454
448
  }
455
- let i = s;
449
+ let s = i;
456
450
  for (const r of e)
457
- i[r] || (i[r] = {}), i = i[r];
458
- Object.assign(i, n);
451
+ s[r] || (s[r] = {}), s = s[r];
452
+ Object.assign(s, n);
459
453
  },
460
- insertShadowArrayElement: (t, e, n, a, s) => {
461
- const i = o().getShadowNode(t, e);
462
- if (!i?._meta?.arrayKeys)
454
+ insertShadowArrayElement: (t, e, n, a, i) => {
455
+ const s = o().getShadowNode(t, e);
456
+ if (!s?._meta?.arrayKeys)
463
457
  throw new Error(
464
458
  `Array not found at path: ${[t, ...e].join(".")}`
465
459
  );
466
- const r = s || `${I()}`;
467
- i[r] = g(t, n);
468
- const u = i._meta.arrayKeys, l = a !== void 0 && a >= 0 && a <= u.length ? a : u.length;
460
+ const r = i || `${I()}`;
461
+ s[r] = g(t, n);
462
+ const u = s._meta.arrayKeys, l = a !== void 0 && a >= 0 && a <= u.length ? a : u.length;
469
463
  l >= u.length ? u.push(r) : u.splice(l, 0, r);
470
464
  const d = [t, ...e].join(".");
471
465
  return o().notifyPathSubscribers(d, {
@@ -478,20 +472,20 @@ const C = N((f, o) => ({
478
472
  insertManyShadowArrayElements: (t, e, n, a) => {
479
473
  if (!n || n.length === 0)
480
474
  return;
481
- const s = o().getShadowNode(t, e);
482
- if (!s?._meta?.arrayKeys) {
475
+ const i = o().getShadowNode(t, e);
476
+ if (!i?._meta?.arrayKeys) {
483
477
  console.error(
484
478
  `Array not found at path: ${[t, ...e].join(".")}`
485
479
  );
486
480
  return;
487
481
  }
488
- const i = [];
482
+ const s = [];
489
483
  n.forEach((d) => {
490
- const y = `${I()}`;
491
- i.push(y), s[y] = g(t, d);
484
+ const m = `${I()}`;
485
+ s.push(m), i[m] = g(t, d);
492
486
  });
493
- const r = s._meta.arrayKeys, u = a !== void 0 && a >= 0 && a <= r.length ? a : r.length;
494
- u >= r.length ? r.push(...i) : r.splice(u, 0, ...i);
487
+ const r = i._meta.arrayKeys, u = a !== void 0 && a >= 0 && a <= r.length ? a : r.length;
488
+ u >= r.length ? r.push(...s) : r.splice(u, 0, ...s);
495
489
  const l = [t, ...e].join(".");
496
490
  o().notifyPathSubscribers(l, {
497
491
  type: "INSERT_MANY",
@@ -504,11 +498,11 @@ const C = N((f, o) => ({
504
498
  if (e.length === 0) return;
505
499
  const n = e.slice(0, -1), a = e[e.length - 1];
506
500
  if (!a?.startsWith("id:")) return;
507
- const s = o().getShadowNode(t, n);
508
- if (!s?._meta?.arrayKeys) return;
509
- const i = s._meta.arrayKeys, r = i.indexOf(a);
501
+ const i = o().getShadowNode(t, n);
502
+ if (!i?._meta?.arrayKeys) return;
503
+ const s = i._meta.arrayKeys, r = s.indexOf(a);
510
504
  if (r === -1) return;
511
- r === i.length - 1 ? i.pop() : r === 0 ? i.shift() : i.splice(r, 1), delete s[a];
505
+ r === s.length - 1 ? s.pop() : r === 0 ? s.shift() : s.splice(r, 1), delete i[a];
512
506
  const u = [t, ...n].join(".");
513
507
  o().notifyPathSubscribers(u, {
514
508
  type: "REMOVE",
@@ -517,8 +511,8 @@ const C = N((f, o) => ({
517
511
  });
518
512
  },
519
513
  registerComponent: (t, e, n) => {
520
- const a = o().getShadowMetadata(t, []) || {}, s = new Map(a.components);
521
- s.set(e, n), o().setShadowMetadata(t, [], { components: s });
514
+ const a = o().getShadowMetadata(t, []) || {}, i = new Map(a.components);
515
+ i.set(e, n), o().setShadowMetadata(t, [], { components: i });
522
516
  },
523
517
  unregisterComponent: (t, e) => {
524
518
  const n = o().getShadowMetadata(t, []);
@@ -527,59 +521,32 @@ const C = N((f, o) => ({
527
521
  a.delete(e) && o().setShadowMetadata(t, [], { components: a });
528
522
  },
529
523
  addPathComponent: (t, e, n) => {
530
- const a = o().getShadowMetadata(t, e) || {}, s = new Set(a.pathComponents);
531
- s.add(n), o().setShadowMetadata(t, e, {
532
- pathComponents: s
524
+ const a = o().getShadowMetadata(t, e) || {}, i = new Set(a.pathComponents);
525
+ i.add(n), o().setShadowMetadata(t, e, {
526
+ pathComponents: i
533
527
  });
534
- const i = o().getShadowMetadata(t, []);
535
- if (i?.components) {
536
- const r = i.components.get(n);
528
+ const s = o().getShadowMetadata(t, []);
529
+ if (s?.components) {
530
+ const r = s.components.get(n);
537
531
  if (r) {
538
532
  const u = [t, ...e].join("."), l = new Set(r.paths);
539
533
  l.add(u);
540
- const d = { ...r, paths: l }, y = new Map(i.components);
541
- y.set(n, d), o().setShadowMetadata(t, [], { components: y });
534
+ const d = { ...r, paths: l }, m = new Map(s.components);
535
+ m.set(n, d), o().setShadowMetadata(t, [], { components: m });
542
536
  }
543
537
  }
544
538
  },
545
- markAsDirty: (t, e, n = { bubble: !0 }) => {
546
- let a = o().getShadowNode(t, []);
547
- if (!a) return;
548
- let s = a;
549
- for (const r of e)
550
- if (s = s[r], !s) return;
551
- if (s._meta || (s._meta = {}), s._meta.isDirty = !0, !n.bubble) return;
552
- let i = a;
553
- for (let r = 0; r < e.length; r++) {
554
- if (i._meta?.isDirty)
555
- return;
556
- i._meta || (i._meta = {}), i._meta.isDirty = !0, i = i[e[r]];
557
- }
558
- },
559
- // Keep these in Zustand as they need React reactivity
560
- serverStateUpdates: /* @__PURE__ */ new Map(),
561
- setServerStateUpdate: (t, e) => {
562
- f((n) => ({
563
- serverStateUpdates: new Map(n.serverStateUpdates).set(
564
- t,
565
- e
566
- )
567
- })), o().notifyPathSubscribers(t, {
568
- type: "SERVER_STATE_UPDATE",
569
- serverState: e
570
- });
571
- },
572
539
  pathSubscribers: /* @__PURE__ */ new Map(),
573
540
  subscribeToPath: (t, e) => {
574
541
  const n = o().pathSubscribers, a = n.get(t) || /* @__PURE__ */ new Set();
575
542
  return a.add(e), n.set(t, a), () => {
576
- const s = o().pathSubscribers.get(t);
577
- s && (s.delete(e), s.size === 0 && o().pathSubscribers.delete(t));
543
+ const i = o().pathSubscribers.get(t);
544
+ i && (i.delete(e), i.size === 0 && o().pathSubscribers.delete(t));
578
545
  };
579
546
  },
580
547
  notifyPathSubscribers: (t, e) => {
581
548
  const a = o().pathSubscribers.get(t);
582
- a && a.forEach((s) => s(e));
549
+ a && a.forEach((i) => i(e));
583
550
  },
584
551
  selectedIndicesMap: /* @__PURE__ */ new Map(),
585
552
  getSelectedIndex: (t, e) => {
@@ -588,8 +555,8 @@ const C = N((f, o) => ({
588
555
  const a = o().getShadowMetadata(
589
556
  t.split(".")[0],
590
557
  t.split(".").slice(1)
591
- ), s = e || a?.arrayKeys;
592
- return s ? s.indexOf(n) : -1;
558
+ ), i = e || a?.arrayKeys;
559
+ return i ? i.indexOf(n) : -1;
593
560
  },
594
561
  setSelectedIndex: (t, e) => {
595
562
  f((n) => {
@@ -619,8 +586,8 @@ const C = N((f, o) => ({
619
586
  f((e) => {
620
587
  const n = new Map(e.selectedIndicesMap);
621
588
  let a = !1;
622
- for (const s of n.keys())
623
- (s === t || s.startsWith(t + ".")) && (n.delete(s), a = !0);
589
+ for (const i of n.keys())
590
+ (i === t || i.startsWith(t + ".")) && (n.delete(i), a = !0);
624
591
  return a ? { selectedIndicesMap: n } : {};
625
592
  });
626
593
  },
@@ -630,15 +597,15 @@ const C = N((f, o) => ({
630
597
  addStateLog: (t) => {
631
598
  !t || t.length === 0 || f((e) => {
632
599
  const n = new Map(e.stateLog), a = /* @__PURE__ */ new Map();
633
- for (const s of t) {
634
- const i = a.get(s.stateKey) || [];
635
- i.push(s), a.set(s.stateKey, i);
600
+ for (const i of t) {
601
+ const s = a.get(i.stateKey) || [];
602
+ s.push(i), a.set(i.stateKey, s);
636
603
  }
637
- for (const [s, i] of a.entries()) {
638
- const r = new Map(n.get(s));
639
- for (const u of i)
604
+ for (const [i, s] of a.entries()) {
605
+ const r = new Map(n.get(i));
606
+ for (const u of s)
640
607
  r.set(JSON.stringify(u.path), { ...u });
641
- n.set(s, r);
608
+ n.set(i, r);
642
609
  }
643
610
  return { stateLog: n };
644
611
  });
@@ -653,13 +620,8 @@ const C = N((f, o) => ({
653
620
  f((n) => ({
654
621
  initialStateGlobal: { ...n.initialStateGlobal, [t]: e }
655
622
  }));
656
- },
657
- syncInfoStore: /* @__PURE__ */ new Map(),
658
- setSyncInfo: (t, e) => f((n) => {
659
- const a = new Map(n.syncInfoStore);
660
- return a.set(t, e), { syncInfoStore: a };
661
- }),
662
- getSyncInfo: (t) => o().syncInfoStore.get(t) || null
623
+ }
624
+ // Removed: syncInfo is now owned by Shape Plugin
663
625
  }));
664
626
  function P(f) {
665
627
  const o = [], t = S.get(f) || S.get(`[${f}`);
@@ -675,14 +637,14 @@ function P(f) {
675
637
  };
676
638
  return e(t), o;
677
639
  }
678
- function R(f, o) {
640
+ function Z(f, o) {
679
641
  const t = S.get(f) || S.get(`[${f}`);
680
642
  if (!t) return;
681
643
  const e = (n) => {
682
644
  if (!(!n || typeof n != "object")) {
683
645
  n._meta?.clientActivityState?.elements && n._meta.clientActivityState.elements.forEach((a) => {
684
- const s = a.domRef?.current;
685
- s && ("disabled" in s ? s.disabled = o : (s.style.pointerEvents = o ? "none" : "", s.setAttribute("aria-disabled", String(o))));
646
+ const i = a.domRef?.current;
647
+ i && ("disabled" in i ? i.disabled = o : (i.style.pointerEvents = o ? "none" : "", i.setAttribute("aria-disabled", String(o))));
686
648
  });
687
649
  for (const a in n)
688
650
  a !== "_meta" && e(n[a]);
@@ -695,7 +657,7 @@ export {
695
657
  I as generateId,
696
658
  P as getAllFieldElements,
697
659
  C as getGlobalStore,
698
- R as setAllFieldsDisabled,
660
+ Z as setAllFieldsDisabled,
699
661
  S as shadowStateStore,
700
662
  w as updateShadowTypeInfo
701
663
  };