cogsbox-state 0.5.472 → 0.5.474

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