cogsbox-state 0.5.474 → 0.5.475-canary.0

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,7 +1,7 @@
1
1
  import { create as A } from "zustand";
2
- function I(u, a = "zod4") {
2
+ function O(u, o = "zod4") {
3
3
  if (!u) return null;
4
- let e = u, t = !1, o = !1, n, s = !1;
4
+ let e = u, t = !1, a = !1, n, s = !1;
5
5
  for (let l = 0; l < 20; l++) {
6
6
  const f = e?.def || e?._def;
7
7
  if (!f) break;
@@ -13,7 +13,7 @@ function I(u, a = "zod4") {
13
13
  } else
14
14
  break;
15
15
  if (p === "ZodOptional" || p === "optional")
16
- o = !0;
16
+ a = !0;
17
17
  else if (p === "ZodNullable" || p === "nullable")
18
18
  t = !0;
19
19
  else if (p === "ZodDefault" || p === "default")
@@ -29,45 +29,45 @@ function I(u, a = "zod4") {
29
29
  return c === "ZodNumber" || c === "number" ? {
30
30
  type: "number",
31
31
  schema: u,
32
- source: a,
32
+ source: o,
33
33
  default: s ? n : 0,
34
34
  nullable: t,
35
- optional: o
35
+ optional: a
36
36
  } : c === "ZodString" || c === "string" ? {
37
37
  type: "string",
38
38
  schema: u,
39
- source: a,
39
+ source: o,
40
40
  default: s ? n : "",
41
41
  nullable: t,
42
- optional: o
42
+ optional: a
43
43
  } : c === "ZodBoolean" || c === "boolean" ? {
44
44
  type: "boolean",
45
45
  schema: u,
46
- source: a,
46
+ source: o,
47
47
  default: s ? n : !1,
48
48
  nullable: t,
49
- optional: o
49
+ optional: a
50
50
  } : c === "ZodArray" || c === "array" ? {
51
51
  type: "array",
52
52
  schema: u,
53
- source: a,
53
+ source: o,
54
54
  default: s ? n : [],
55
55
  nullable: t,
56
- optional: o
56
+ optional: a
57
57
  } : c === "ZodObject" || c === "object" ? {
58
58
  type: "object",
59
59
  schema: u,
60
- source: a,
60
+ source: o,
61
61
  default: s ? n : {},
62
62
  nullable: t,
63
- optional: o
63
+ optional: a
64
64
  } : c === "ZodDate" || c === "date" ? {
65
65
  type: "date",
66
66
  schema: u,
67
- source: a,
67
+ source: o,
68
68
  default: s ? n : /* @__PURE__ */ new Date(),
69
69
  nullable: t,
70
- optional: o
70
+ optional: a
71
71
  } : null;
72
72
  }
73
73
  function E(u) {
@@ -87,103 +87,103 @@ function E(u) {
87
87
  default: void 0,
88
88
  optional: !0
89
89
  };
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 };
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 };
92
92
  }
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;
93
+ function _(u, o, e) {
94
+ if (o == null || typeof o != "object") {
95
+ const t = { _meta: { value: o } };
96
+ return t._meta.typeInfo = I(o, e), t;
97
97
  }
98
- if (Array.isArray(a)) {
98
+ if (Array.isArray(o)) {
99
99
  const t = { _meta: { arrayKeys: [] } };
100
- return t._meta.typeInfo = M(a, e), a.forEach((o, n) => {
101
- const s = O(), r = e ? {
100
+ return t._meta.typeInfo = I(o, e), o.forEach((a, n) => {
101
+ const s = M(), r = e ? {
102
102
  ...e,
103
103
  path: [...e.path, n.toString()]
104
104
  } : void 0;
105
- t[s] = _(u, o, r), t._meta.arrayKeys.push(s);
105
+ t[s] = _(u, a, r), t._meta.arrayKeys.push(s);
106
106
  }), t;
107
107
  }
108
- if (a.constructor === Object) {
108
+ if (o.constructor === Object) {
109
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)) {
110
+ t._meta.typeInfo = I(o, e);
111
+ for (const a in o)
112
+ if (Object.prototype.hasOwnProperty.call(o, a)) {
113
113
  const n = e ? {
114
114
  ...e,
115
- path: [...e.path, o]
115
+ path: [...e.path, a]
116
116
  } : void 0;
117
- t[o] = _(u, a[o], n);
117
+ t[a] = _(u, o[a], n);
118
118
  }
119
119
  return t;
120
120
  }
121
121
  return {
122
122
  _meta: {
123
- value: a,
124
- typeInfo: E(a)
123
+ value: o,
124
+ typeInfo: E(o)
125
125
  }
126
126
  };
127
127
  }
128
- function M(u, a) {
129
- if (a) {
128
+ function I(u, o) {
129
+ if (o) {
130
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"));
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"));
134
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"));
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"));
138
138
  }
139
- if (!e && a.schemas.sync?.[a.stateKey] && (e = E(u), e.source = "sync"), e) return e;
139
+ if (!e && o.schemas.sync?.[o.stateKey] && (e = E(u), e.source = "sync"), e) return e;
140
140
  }
141
141
  return E(u);
142
142
  }
143
- function N(u, a, e) {
143
+ function N(u, o, e) {
144
144
  const t = h.get(u) || h.get(`[${u}`);
145
145
  if (!t) return;
146
- function o(n, s) {
146
+ function a(n, s) {
147
147
  if (!n || typeof n != "object") return;
148
- const r = j(a, s);
148
+ const r = j(o, s);
149
149
  if (r) {
150
- const i = I(r, e);
150
+ const i = O(r, e);
151
151
  i && (n._meta || (n._meta = {}), n._meta.typeInfo = {
152
152
  ...i,
153
153
  schema: r
154
154
  });
155
155
  }
156
156
  n._meta?.arrayKeys ? n._meta.arrayKeys.forEach((i) => {
157
- n[i] && o(n[i], [...s, "0"]);
157
+ n[i] && a(n[i], [...s, "0"]);
158
158
  }) : n._meta?.hasOwnProperty("value") || Object.keys(n).forEach((i) => {
159
- i !== "_meta" && o(n[i], [...s, i]);
159
+ i !== "_meta" && a(n[i], [...s, i]);
160
160
  });
161
161
  }
162
- o(t, []);
162
+ a(t, []);
163
163
  }
164
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;
165
+ let o = u;
166
+ for (; o; ) {
167
+ const e = o.def || o._def, t = e?.typeName || e?.type || o._type;
168
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?.();
169
+ o = e.innerType || e.schema || o._inner || o.unwrap?.();
170
170
  else
171
171
  break;
172
172
  }
173
- return a;
173
+ return o;
174
174
  }
175
- function j(u, a) {
175
+ function j(u, o) {
176
176
  if (!u) return null;
177
- if (a.length === 0) return u;
177
+ if (o.length === 0) return u;
178
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;
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;
183
183
  if (s === "ZodObject" || s === "object")
184
- e = (n?.shape || o.shape || o._shape)?.[t];
184
+ e = (n?.shape || a.shape || a._shape)?.[t];
185
185
  else if (s === "ZodArray" || s === "array")
186
- e = o.element || n?.type;
186
+ e = a.element || n?.type;
187
187
  else
188
188
  return null;
189
189
  if (!e)
@@ -194,26 +194,26 @@ function j(u, a) {
194
194
  const h = /* @__PURE__ */ new Map();
195
195
  let D = 0;
196
196
  const V = Date.now().toString(36);
197
- function O(u) {
197
+ function M(u) {
198
198
  return `id:local_${V}_${(D++).toString(36)}`;
199
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("."), {
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("."), {
205
205
  type: "METADATA_UPDATE"
206
206
  });
207
207
  },
208
- removePluginMetaData: (e, t, o) => {
209
- const n = a().getShadowMetadata(e, t);
208
+ removePluginMetaData: (e, t, a) => {
209
+ const n = o().getShadowMetadata(e, t);
210
210
  if (!n?.pluginMetaData) return;
211
211
  const s = new Map(n.pluginMetaData);
212
- s.delete(o), a().setShadowMetadata(e, t, { ...n, pluginMetaData: s });
212
+ s.delete(a), o().setShadowMetadata(e, t, { ...n, pluginMetaData: s });
213
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, {
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, {
217
217
  transformCaches: s.transformCaches
218
218
  });
219
219
  },
@@ -257,24 +257,24 @@ const $ = A((u, a) => ({
257
257
  }
258
258
  }
259
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);
260
+ const c = o().getInitialOptions(e);
261
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
262
  },
263
263
  initializeShadowState: (e, t) => {
264
- const o = h.get(e) || h.get(`[${e}`);
264
+ const a = h.get(e) || h.get(`[${e}`);
265
265
  let n = {};
266
- if (o?._meta) {
266
+ if (a?._meta) {
267
267
  const {
268
268
  components: f,
269
269
  features: p,
270
270
  lastServerSync: y,
271
271
  stateSource: m,
272
272
  baseServerState: d
273
- } = o._meta;
273
+ } = a._meta;
274
274
  f && (n.components = f), p && (n.features = p), y && (n.lastServerSync = y), m && (n.stateSource = m), d && (n.baseServerState = d);
275
275
  }
276
276
  h.delete(e), h.delete(`[${e}`);
277
- const s = a().getInitialOptions(e), r = a().getInitialOptions("__syncSchemas"), i = {
277
+ const s = o().getInitialOptions(e), r = o().getInitialOptions("__syncSchemas"), i = {
278
278
  stateKey: e,
279
279
  path: [],
280
280
  schemas: {
@@ -288,29 +288,29 @@ const $ = A((u, a) => ({
288
288
  h.set(l, c);
289
289
  },
290
290
  getShadowNode: (e, t) => {
291
- let o = h.get(e) || h.get(`[${e}`);
292
- if (o) {
293
- if (t.length === 0) return o;
291
+ let a = h.get(e) || h.get(`[${e}`);
292
+ if (a) {
293
+ if (t.length === 0) return a;
294
294
  for (const n of t)
295
- if (typeof o != "object" || o === null || (o = o[n], o === void 0)) return;
296
- return o;
295
+ if (typeof a != "object" || a === null || (a = a[n], a === void 0)) return;
296
+ return a;
297
297
  }
298
298
  },
299
- getShadowMetadata: (e, t) => a().getShadowNode(e, t)?._meta,
300
- setShadowMetadata: (e, t, o) => {
299
+ getShadowMetadata: (e, t) => o().getShadowNode(e, t)?._meta,
300
+ setShadowMetadata: (e, t, a) => {
301
301
  const n = h.has(`[${e}`) ? `[${e}` : e;
302
302
  let s = h.get(n);
303
303
  if (!s) {
304
- s = { _meta: o }, h.set(n, s);
304
+ s = { _meta: a }, h.set(n, s);
305
305
  return;
306
306
  }
307
307
  let r = s;
308
308
  for (const i of t)
309
309
  r[i] || (r[i] = {}), r = r[i];
310
- r._meta || (r._meta = {}), Object.assign(r._meta, o);
310
+ r._meta || (r._meta = {}), Object.assign(r._meta, a);
311
311
  },
312
- getShadowValue: (e, t, o) => {
313
- const n = a().getShadowNode(e, t);
312
+ getShadowValue: (e, t, a) => {
313
+ const n = o().getShadowNode(e, t);
314
314
  if (!n)
315
315
  return;
316
316
  const s = {}, r = [
@@ -323,7 +323,7 @@ const $ = A((u, a) => ({
323
323
  continue;
324
324
  }
325
325
  if (i._meta?.arrayKeys) {
326
- const y = o || i._meta.arrayKeys, m = [];
326
+ const y = a || i._meta.arrayKeys, m = [];
327
327
  c[l] = m;
328
328
  for (let d = y.length - 1; d >= 0; d--) {
329
329
  const S = y[d];
@@ -339,7 +339,7 @@ const $ = A((u, a) => ({
339
339
  }
340
340
  return s.final;
341
341
  },
342
- updateShadowAtPath: (e, t, o) => {
342
+ updateShadowAtPath: (e, t, a) => {
343
343
  const n = h.has(`[${e}`) ? `[${e}` : e;
344
344
  let s = h.get(n);
345
345
  if (!s) return;
@@ -367,7 +367,7 @@ const $ = A((u, a) => ({
367
367
  w
368
368
  ]), S.push(w);
369
369
  } else {
370
- const w = O(), K = a().getInitialOptions(e), v = {
370
+ const w = M(), K = o().getInitialOptions(e), v = {
371
371
  stateKey: e,
372
372
  path: [...p, "0"],
373
373
  // Use '0' for array element schema lookup
@@ -398,7 +398,7 @@ const $ = A((u, a) => ({
398
398
  m
399
399
  ]);
400
400
  else {
401
- const S = a().getInitialOptions(e), b = {
401
+ const S = o().getInitialOptions(e), b = {
402
402
  stateKey: e,
403
403
  path: [...p, m],
404
404
  schemas: {
@@ -412,12 +412,12 @@ const $ = A((u, a) => ({
412
412
  for (const m in l)
413
413
  m === "_meta" || !Object.prototype.hasOwnProperty.call(l, m) || y.has(m) || delete l[m];
414
414
  }
415
- i ? c(i, o, t) : r[t[t.length - 1]] = _(e, o), a().notifyPathSubscribers([e, ...t].join("."), {
415
+ i ? c(i, a, t) : r[t[t.length - 1]] = _(e, a), o().notifyPathSubscribers([e, ...t].join("."), {
416
416
  type: "UPDATE",
417
- newValue: o
417
+ newValue: a
418
418
  });
419
419
  },
420
- addItemsToArrayNode: (e, t, o) => {
420
+ addItemsToArrayNode: (e, t, a) => {
421
421
  const n = h.has(`[${e}`) ? `[${e}` : e;
422
422
  let s = h.get(n);
423
423
  if (!s) {
@@ -427,31 +427,30 @@ const $ = A((u, a) => ({
427
427
  let r = s;
428
428
  for (const i of t)
429
429
  r[i] || (r[i] = {}), r = r[i];
430
- Object.assign(r, o);
430
+ Object.assign(r, a);
431
431
  },
432
- insertShadowArrayElement: (e, t, o, n, s) => {
433
- const r = a().getShadowNode(e, t);
432
+ insertShadowArrayElement: (e, t, a, n, s) => {
433
+ const r = o().getShadowNode(e, t);
434
434
  if (!r?._meta?.arrayKeys)
435
435
  throw new Error(
436
436
  `Array not found at path: ${[e, ...t].join(".")}`
437
437
  );
438
- console.log("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
439
- const i = s || `${O()}`;
440
- r[i] = _(e, o);
438
+ const i = s || `${M()}`;
439
+ r[i] = _(e, a);
441
440
  const c = r._meta.arrayKeys, l = n !== void 0 && n >= 0 && n <= c.length ? n : c.length;
442
441
  l >= c.length ? c.push(i) : c.splice(l, 0, i);
443
442
  const f = [e, ...t].join(".");
444
- return a().notifyPathSubscribers(f, {
443
+ return o().notifyPathSubscribers(f, {
445
444
  type: "INSERT",
446
445
  path: f,
447
446
  itemKey: `${f}.${i}`,
448
447
  index: l
449
448
  }), i;
450
449
  },
451
- insertManyShadowArrayElements: (e, t, o, n) => {
452
- if (!o || o.length === 0)
450
+ insertManyShadowArrayElements: (e, t, a, n) => {
451
+ if (!a || a.length === 0)
453
452
  return;
454
- const s = a().getShadowNode(e, t);
453
+ const s = o().getShadowNode(e, t);
455
454
  if (!s?._meta?.arrayKeys) {
456
455
  console.error(
457
456
  `Array not found at path: ${[e, ...t].join(".")}`
@@ -459,69 +458,69 @@ const $ = A((u, a) => ({
459
458
  return;
460
459
  }
461
460
  const r = [];
462
- o.forEach((f) => {
463
- const p = `${O()}`;
461
+ a.forEach((f) => {
462
+ const p = `${M()}`;
464
463
  r.push(p), s[p] = _(e, f);
465
464
  });
466
465
  const i = s._meta.arrayKeys, c = n !== void 0 && n >= 0 && n <= i.length ? n : i.length;
467
466
  c >= i.length ? i.push(...r) : i.splice(c, 0, ...r);
468
467
  const l = [e, ...t].join(".");
469
- a().notifyPathSubscribers(l, {
468
+ o().notifyPathSubscribers(l, {
470
469
  type: "INSERT_MANY",
471
470
  path: l,
472
- count: o.length,
471
+ count: a.length,
473
472
  index: c
474
473
  });
475
474
  },
476
475
  removeShadowArrayElement: (e, t) => {
477
476
  if (t.length === 0) return;
478
- const o = t.slice(0, -1), n = t[t.length - 1];
477
+ const a = t.slice(0, -1), n = t[t.length - 1];
479
478
  if (!n?.startsWith("id:")) return;
480
- const s = a().getShadowNode(e, o);
479
+ const s = o().getShadowNode(e, a);
481
480
  if (!s?._meta?.arrayKeys) return;
482
481
  const r = s._meta.arrayKeys, i = r.indexOf(n);
483
482
  if (i === -1) return;
484
483
  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, {
484
+ const c = [e, ...a].join(".");
485
+ o().notifyPathSubscribers(c, {
487
486
  type: "REMOVE",
488
487
  path: c,
489
488
  itemKey: `${c}.${n}`
490
489
  });
491
490
  },
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 });
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 });
495
494
  },
496
495
  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 });
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 });
501
500
  },
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, {
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, {
505
504
  pathComponents: s
506
505
  });
507
- const r = a().getShadowMetadata(e, []);
506
+ const r = o().getShadowMetadata(e, []);
508
507
  if (r?.components) {
509
- const i = r.components.get(o);
508
+ const i = r.components.get(a);
510
509
  if (i) {
511
510
  const c = [e, ...t].join("."), l = new Set(i.paths);
512
511
  l.add(c);
513
512
  const f = { ...i, paths: l }, p = new Map(r.components);
514
- p.set(o, f), a().setShadowMetadata(e, [], { components: p });
513
+ p.set(a, f), o().setShadowMetadata(e, [], { components: p });
515
514
  }
516
515
  }
517
516
  },
518
- markAsDirty: (e, t, o = { bubble: !0 }) => {
519
- let n = a().getShadowNode(e, []);
517
+ markAsDirty: (e, t, a = { bubble: !0 }) => {
518
+ let n = o().getShadowNode(e, []);
520
519
  if (!n) return;
521
520
  let s = n;
522
521
  for (const i of t)
523
522
  if (s = s[i], !s) return;
524
- if (s._meta || (s._meta = {}), s._meta.isDirty = !0, !o.bubble) return;
523
+ if (s._meta || (s._meta = {}), s._meta.isDirty = !0, !a.bubble) return;
525
524
  let r = n;
526
525
  for (let i = 0; i < t.length; i++) {
527
526
  if (r._meta?.isDirty)
@@ -532,69 +531,69 @@ const $ = A((u, a) => ({
532
531
  // Keep these in Zustand as they need React reactivity
533
532
  serverStateUpdates: /* @__PURE__ */ new Map(),
534
533
  setServerStateUpdate: (e, t) => {
535
- u((o) => ({
536
- serverStateUpdates: new Map(o.serverStateUpdates).set(
534
+ u((a) => ({
535
+ serverStateUpdates: new Map(a.serverStateUpdates).set(
537
536
  e,
538
537
  t
539
538
  )
540
- })), a().notifyPathSubscribers(e, {
539
+ })), o().notifyPathSubscribers(e, {
541
540
  type: "SERVER_STATE_UPDATE",
542
541
  serverState: t
543
542
  });
544
543
  },
545
544
  pathSubscribers: /* @__PURE__ */ new Map(),
546
545
  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));
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));
551
550
  };
552
551
  },
553
552
  notifyPathSubscribers: (e, t) => {
554
- const n = a().pathSubscribers.get(e);
553
+ const n = o().pathSubscribers.get(e);
555
554
  n && n.forEach((s) => s(t));
556
555
  },
557
556
  selectedIndicesMap: /* @__PURE__ */ new Map(),
558
557
  getSelectedIndex: (e, t) => {
559
- const o = a().selectedIndicesMap.get(e);
560
- if (!o) return -1;
561
- const n = a().getShadowMetadata(
558
+ const a = o().selectedIndicesMap.get(e);
559
+ if (!a) return -1;
560
+ const n = o().getShadowMetadata(
562
561
  e.split(".")[0],
563
562
  e.split(".").slice(1)
564
563
  ), s = t || n?.arrayKeys;
565
- return s ? s.indexOf(o) : -1;
564
+ return s ? s.indexOf(a) : -1;
566
565
  },
567
566
  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), {
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), {
571
570
  type: "THIS_UNSELECTED"
572
- }), n.set(e, t), a().notifyPathSubscribers(t, { type: "THIS_SELECTED" })), a().notifyPathSubscribers(e, { type: "GET_SELECTED" }), {
573
- ...o,
571
+ }), n.set(e, t), o().notifyPathSubscribers(t, { type: "THIS_SELECTED" })), o().notifyPathSubscribers(e, { type: "GET_SELECTED" }), {
572
+ ...a,
574
573
  selectedIndicesMap: n
575
574
  };
576
575
  });
577
576
  },
578
577
  clearSelectedIndex: ({ arrayKey: e }) => {
579
578
  u((t) => {
580
- const o = new Map(t.selectedIndicesMap), n = o.get(e);
581
- return n && a().notifyPathSubscribers(n, {
579
+ const a = new Map(t.selectedIndicesMap), n = a.get(e);
580
+ return n && o().notifyPathSubscribers(n, {
582
581
  type: "CLEAR_SELECTION"
583
- }), o.delete(e), a().notifyPathSubscribers(e, {
582
+ }), a.delete(e), o().notifyPathSubscribers(e, {
584
583
  type: "CLEAR_SELECTION"
585
584
  }), {
586
585
  ...t,
587
- selectedIndicesMap: o
586
+ selectedIndicesMap: a
588
587
  };
589
588
  });
590
589
  },
591
590
  clearSelectedIndexesForState: (e) => {
592
591
  u((t) => {
593
- const o = new Map(t.selectedIndicesMap);
592
+ const a = new Map(t.selectedIndicesMap);
594
593
  let n = !1;
595
- for (const s of o.keys())
596
- (s === e || s.startsWith(e + ".")) && (o.delete(s), n = !0);
597
- return n ? { selectedIndicesMap: o } : {};
594
+ for (const s of a.keys())
595
+ (s === e || s.startsWith(e + ".")) && (a.delete(s), n = !0);
596
+ return n ? { selectedIndicesMap: a } : {};
598
597
  });
599
598
  },
600
599
  initialStateOptions: {},
@@ -602,41 +601,41 @@ const $ = A((u, a) => ({
602
601
  initialStateGlobal: {},
603
602
  addStateLog: (e) => {
604
603
  !e || e.length === 0 || u((t) => {
605
- const o = new Map(t.stateLog), n = /* @__PURE__ */ new Map();
604
+ const a = new Map(t.stateLog), n = /* @__PURE__ */ new Map();
606
605
  for (const s of e) {
607
606
  const r = n.get(s.stateKey) || [];
608
607
  r.push(s), n.set(s.stateKey, r);
609
608
  }
610
609
  for (const [s, r] of n.entries()) {
611
- const i = new Map(o.get(s));
610
+ const i = new Map(a.get(s));
612
611
  for (const c of r)
613
612
  i.set(JSON.stringify(c.path), { ...c });
614
- o.set(s, i);
613
+ a.set(s, i);
615
614
  }
616
- return { stateLog: o };
615
+ return { stateLog: a };
617
616
  });
618
617
  },
619
- getInitialOptions: (e) => a().initialStateOptions[e],
618
+ getInitialOptions: (e) => o().initialStateOptions[e],
620
619
  setInitialStateOptions: (e, t) => {
621
- u((o) => ({
622
- initialStateOptions: { ...o.initialStateOptions, [e]: t }
620
+ u((a) => ({
621
+ initialStateOptions: { ...a.initialStateOptions, [e]: t }
623
622
  }));
624
623
  },
625
624
  updateInitialStateGlobal: (e, t) => {
626
- u((o) => ({
627
- initialStateGlobal: { ...o.initialStateGlobal, [e]: t }
625
+ u((a) => ({
626
+ initialStateGlobal: { ...a.initialStateGlobal, [e]: t }
628
627
  }));
629
628
  },
630
629
  syncInfoStore: /* @__PURE__ */ new Map(),
631
- setSyncInfo: (e, t) => u((o) => {
632
- const n = new Map(o.syncInfoStore);
630
+ setSyncInfo: (e, t) => u((a) => {
631
+ const n = new Map(a.syncInfoStore);
633
632
  return n.set(e, t), { syncInfoStore: n };
634
633
  }),
635
- getSyncInfo: (e) => a().syncInfoStore.get(e) || null
634
+ getSyncInfo: (e) => o().syncInfoStore.get(e) || null
636
635
  }));
637
636
  export {
638
637
  _ as buildShadowNode,
639
- O as generateId,
638
+ M as generateId,
640
639
  $ as getGlobalStore,
641
640
  h as shadowStateStore,
642
641
  N as updateShadowTypeInfo