cogsbox-state 0.5.476 → 0.5.478

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