react-state-custom 1.0.12 → 1.0.13

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/index.es.js CHANGED
@@ -1,509 +1,25 @@
1
- var Ae = Object.defineProperty;
2
- var ke = (e, t, r) => t in e ? Ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Q = (e, t, r) => ke(e, typeof t != "symbol" ? t + "" : t, r);
4
- import Me, { useRef as Ie, useMemo as z, useEffect as L, useState as G, useCallback as $e, Fragment as xe } from "react";
5
- var Z = { exports: {} }, be;
6
- function De() {
7
- if (be) return Z.exports;
8
- be = 1;
9
- var e = typeof Reflect == "object" ? Reflect : null, t = e && typeof e.apply == "function" ? e.apply : function(a, o, l) {
10
- return Function.prototype.apply.call(a, o, l);
11
- }, r;
12
- e && typeof e.ownKeys == "function" ? r = e.ownKeys : Object.getOwnPropertySymbols ? r = function(a) {
13
- return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a));
14
- } : r = function(a) {
15
- return Object.getOwnPropertyNames(a);
1
+ import { useRef as R, useMemo as d, useEffect as m, useState as S, useCallback as D, Fragment as O } from "react";
2
+ import { jsx as g, Fragment as T } from "react/jsx-runtime";
3
+ function w(e, t) {
4
+ let r = null, s = function(...o) {
5
+ r && clearTimeout(r), r = setTimeout(() => {
6
+ e(...o);
7
+ }, t);
16
8
  };
17
- function u(i) {
18
- console && console.warn && console.warn(i);
19
- }
20
- var f = Number.isNaN || function(a) {
21
- return a !== a;
22
- };
23
- function n() {
24
- n.init.call(this);
25
- }
26
- Z.exports = n, Z.exports.once = N, n.EventEmitter = n, n.prototype._events = void 0, n.prototype._eventsCount = 0, n.prototype._maxListeners = void 0;
27
- var c = 10;
28
- function d(i) {
29
- if (typeof i != "function")
30
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof i);
31
- }
32
- Object.defineProperty(n, "defaultMaxListeners", {
33
- enumerable: !0,
34
- get: function() {
35
- return c;
36
- },
37
- set: function(i) {
38
- if (typeof i != "number" || i < 0 || f(i))
39
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + i + ".");
40
- c = i;
41
- }
42
- }), n.init = function() {
43
- (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
44
- }, n.prototype.setMaxListeners = function(a) {
45
- if (typeof a != "number" || a < 0 || f(a))
46
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + a + ".");
47
- return this._maxListeners = a, this;
48
- };
49
- function p(i) {
50
- return i._maxListeners === void 0 ? n.defaultMaxListeners : i._maxListeners;
51
- }
52
- n.prototype.getMaxListeners = function() {
53
- return p(this);
54
- }, n.prototype.emit = function(a) {
55
- for (var o = [], l = 1; l < arguments.length; l++) o.push(arguments[l]);
56
- var h = a === "error", g = this._events;
57
- if (g !== void 0)
58
- h = h && g.error === void 0;
59
- else if (!h)
60
- return !1;
61
- if (h) {
62
- var b;
63
- if (o.length > 0 && (b = o[0]), b instanceof Error)
64
- throw b;
65
- var j = new Error("Unhandled error." + (b ? " (" + b.message + ")" : ""));
66
- throw j.context = b, j;
67
- }
68
- var A = g[a];
69
- if (A === void 0)
70
- return !1;
71
- if (typeof A == "function")
72
- t(A, this, o);
73
- else
74
- for (var B = A.length, U = M(A, B), l = 0; l < B; ++l)
75
- t(U[l], this, o);
76
- return !0;
77
- };
78
- function v(i, a, o, l) {
79
- var h, g, b;
80
- if (d(o), g = i._events, g === void 0 ? (g = i._events = /* @__PURE__ */ Object.create(null), i._eventsCount = 0) : (g.newListener !== void 0 && (i.emit(
81
- "newListener",
82
- a,
83
- o.listener ? o.listener : o
84
- ), g = i._events), b = g[a]), b === void 0)
85
- b = g[a] = o, ++i._eventsCount;
86
- else if (typeof b == "function" ? b = g[a] = l ? [o, b] : [b, o] : l ? b.unshift(o) : b.push(o), h = p(i), h > 0 && b.length > h && !b.warned) {
87
- b.warned = !0;
88
- var j = new Error("Possible EventEmitter memory leak detected. " + b.length + " " + String(a) + " listeners added. Use emitter.setMaxListeners() to increase limit");
89
- j.name = "MaxListenersExceededWarning", j.emitter = i, j.type = a, j.count = b.length, u(j);
90
- }
91
- return i;
92
- }
93
- n.prototype.addListener = function(a, o) {
94
- return v(this, a, o, !1);
95
- }, n.prototype.on = n.prototype.addListener, n.prototype.prependListener = function(a, o) {
96
- return v(this, a, o, !0);
97
- };
98
- function _() {
99
- if (!this.fired)
100
- return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
101
- }
102
- function E(i, a, o) {
103
- var l = { fired: !1, wrapFn: void 0, target: i, type: a, listener: o }, h = _.bind(l);
104
- return h.listener = o, l.wrapFn = h, h;
105
- }
106
- n.prototype.once = function(a, o) {
107
- return d(o), this.on(a, E(this, a, o)), this;
108
- }, n.prototype.prependOnceListener = function(a, o) {
109
- return d(o), this.prependListener(a, E(this, a, o)), this;
110
- }, n.prototype.removeListener = function(a, o) {
111
- var l, h, g, b, j;
112
- if (d(o), h = this._events, h === void 0)
113
- return this;
114
- if (l = h[a], l === void 0)
115
- return this;
116
- if (l === o || l.listener === o)
117
- --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete h[a], h.removeListener && this.emit("removeListener", a, l.listener || o));
118
- else if (typeof l != "function") {
119
- for (g = -1, b = l.length - 1; b >= 0; b--)
120
- if (l[b] === o || l[b].listener === o) {
121
- j = l[b].listener, g = b;
122
- break;
123
- }
124
- if (g < 0)
125
- return this;
126
- g === 0 ? l.shift() : y(l, g), l.length === 1 && (h[a] = l[0]), h.removeListener !== void 0 && this.emit("removeListener", a, j || o);
127
- }
128
- return this;
129
- }, n.prototype.off = n.prototype.removeListener, n.prototype.removeAllListeners = function(a) {
130
- var o, l, h;
131
- if (l = this._events, l === void 0)
132
- return this;
133
- if (l.removeListener === void 0)
134
- return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : l[a] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete l[a]), this;
135
- if (arguments.length === 0) {
136
- var g = Object.keys(l), b;
137
- for (h = 0; h < g.length; ++h)
138
- b = g[h], b !== "removeListener" && this.removeAllListeners(b);
139
- return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
140
- }
141
- if (o = l[a], typeof o == "function")
142
- this.removeListener(a, o);
143
- else if (o !== void 0)
144
- for (h = o.length - 1; h >= 0; h--)
145
- this.removeListener(a, o[h]);
146
- return this;
147
- };
148
- function T(i, a, o) {
149
- var l = i._events;
150
- if (l === void 0)
151
- return [];
152
- var h = l[a];
153
- return h === void 0 ? [] : typeof h == "function" ? o ? [h.listener || h] : [h] : o ? O(h) : M(h, h.length);
154
- }
155
- n.prototype.listeners = function(a) {
156
- return T(this, a, !0);
157
- }, n.prototype.rawListeners = function(a) {
158
- return T(this, a, !1);
159
- }, n.listenerCount = function(i, a) {
160
- return typeof i.listenerCount == "function" ? i.listenerCount(a) : C.call(i, a);
161
- }, n.prototype.listenerCount = C;
162
- function C(i) {
163
- var a = this._events;
164
- if (a !== void 0) {
165
- var o = a[i];
166
- if (typeof o == "function")
167
- return 1;
168
- if (o !== void 0)
169
- return o.length;
170
- }
171
- return 0;
172
- }
173
- n.prototype.eventNames = function() {
174
- return this._eventsCount > 0 ? r(this._events) : [];
175
- };
176
- function M(i, a) {
177
- for (var o = new Array(a), l = 0; l < a; ++l)
178
- o[l] = i[l];
179
- return o;
180
- }
181
- function y(i, a) {
182
- for (; a + 1 < i.length; a++)
183
- i[a] = i[a + 1];
184
- i.pop();
185
- }
186
- function O(i) {
187
- for (var a = new Array(i.length), o = 0; o < a.length; ++o)
188
- a[o] = i[o].listener || i[o];
189
- return a;
190
- }
191
- function N(i, a) {
192
- return new Promise(function(o, l) {
193
- function h(b) {
194
- i.removeListener(a, g), l(b);
195
- }
196
- function g() {
197
- typeof i.removeListener == "function" && i.removeListener("error", h), o([].slice.call(arguments));
198
- }
199
- D(i, a, g, { once: !0 }), a !== "error" && x(i, h, { once: !0 });
200
- });
201
- }
202
- function x(i, a, o) {
203
- typeof i.on == "function" && D(i, "error", a, o);
204
- }
205
- function D(i, a, o, l) {
206
- if (typeof i.on == "function")
207
- l.once ? i.once(a, o) : i.on(a, o);
208
- else if (typeof i.addEventListener == "function")
209
- i.addEventListener(a, function h(g) {
210
- l.once && i.removeEventListener(a, h), o(g);
211
- });
212
- else
213
- throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof i);
214
- }
215
- return Z.exports;
216
- }
217
- var Fe = De(), We = typeof global == "object" && global && global.Object === Object && global, ze = typeof self == "object" && self && self.Object === Object && self, re = We || ze || Function("return this")(), te = re.Symbol, Se = Object.prototype, Ye = Se.hasOwnProperty, Ge = Se.toString, V = te ? te.toStringTag : void 0;
218
- function He(e) {
219
- var t = Ye.call(e, V), r = e[V];
220
- try {
221
- e[V] = void 0;
222
- var u = !0;
223
- } catch {
224
- }
225
- var f = Ge.call(e);
226
- return u && (t ? e[V] = r : delete e[V]), f;
227
- }
228
- var Ue = Object.prototype, Ve = Ue.toString;
229
- function qe(e) {
230
- return Ve.call(e);
231
- }
232
- var Je = "[object Null]", Xe = "[object Undefined]", _e = te ? te.toStringTag : void 0;
233
- function je(e) {
234
- return e == null ? e === void 0 ? Xe : Je : _e && _e in Object(e) ? He(e) : qe(e);
235
- }
236
- function Ke(e) {
237
- return e != null && typeof e == "object";
238
- }
239
- var Be = "[object Symbol]";
240
- function Qe(e) {
241
- return typeof e == "symbol" || Ke(e) && je(e) == Be;
242
- }
243
- var Ze = /\s/;
244
- function et(e) {
245
- for (var t = e.length; t-- && Ze.test(e.charAt(t)); )
246
- ;
247
- return t;
248
- }
249
- var tt = /^\s+/;
250
- function rt(e) {
251
- return e && e.slice(0, et(e) + 1).replace(tt, "");
252
- }
253
- function X(e) {
254
- var t = typeof e;
255
- return e != null && (t == "object" || t == "function");
256
- }
257
- var ge = NaN, nt = /^[-+]0x[0-9a-f]+$/i, ot = /^0b[01]+$/i, at = /^0o[0-7]+$/i, st = parseInt;
258
- function ye(e) {
259
- if (typeof e == "number")
260
- return e;
261
- if (Qe(e))
262
- return ge;
263
- if (X(e)) {
264
- var t = typeof e.valueOf == "function" ? e.valueOf() : e;
265
- e = X(t) ? t + "" : t;
266
- }
267
- if (typeof e != "string")
268
- return e === 0 ? e : +e;
269
- e = rt(e);
270
- var r = ot.test(e);
271
- return r || at.test(e) ? st(e.slice(2), r ? 2 : 8) : nt.test(e) ? ge : +e;
272
- }
273
- var it = "[object AsyncFunction]", ut = "[object Function]", ct = "[object GeneratorFunction]", ft = "[object Proxy]";
274
- function lt(e) {
275
- if (!X(e))
276
- return !1;
277
- var t = je(e);
278
- return t == ut || t == ct || t == it || t == ft;
279
- }
280
- var ce = re["__core-js_shared__"], Ee = function() {
281
- var e = /[^.]+$/.exec(ce && ce.keys && ce.keys.IE_PROTO || "");
282
- return e ? "Symbol(src)_1." + e : "";
283
- }();
284
- function dt(e) {
285
- return !!Ee && Ee in e;
286
- }
287
- var ht = Function.prototype, pt = ht.toString;
288
- function vt(e) {
289
- if (e != null) {
290
- try {
291
- return pt.call(e);
292
- } catch {
293
- }
294
- try {
295
- return e + "";
296
- } catch {
297
- }
298
- }
299
- return "";
300
- }
301
- var mt = /[\\^$.*+?()[\]{}|]/g, bt = /^\[object .+?Constructor\]$/, _t = Function.prototype, gt = Object.prototype, yt = _t.toString, Et = gt.hasOwnProperty, wt = RegExp(
302
- "^" + yt.call(Et).replace(mt, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
303
- );
304
- function Tt(e) {
305
- if (!X(e) || dt(e))
306
- return !1;
307
- var t = lt(e) ? wt : bt;
308
- return t.test(vt(e));
309
- }
310
- function Ot(e, t) {
311
- return e == null ? void 0 : e[t];
312
- }
313
- function Ce(e, t) {
314
- var r = Ot(e, t);
315
- return Tt(r) ? r : void 0;
316
- }
317
- function Rt(e, t) {
318
- return e === t || e !== e && t !== t;
319
- }
320
- var K = Ce(Object, "create");
321
- function St() {
322
- this.__data__ = K ? K(null) : {}, this.size = 0;
323
- }
324
- function jt(e) {
325
- var t = this.has(e) && delete this.__data__[e];
326
- return this.size -= t ? 1 : 0, t;
327
- }
328
- var Ct = "__lodash_hash_undefined__", Lt = Object.prototype, Pt = Lt.hasOwnProperty;
329
- function Nt(e) {
330
- var t = this.__data__;
331
- if (K) {
332
- var r = t[e];
333
- return r === Ct ? void 0 : r;
334
- }
335
- return Pt.call(t, e) ? t[e] : void 0;
336
- }
337
- var At = Object.prototype, kt = At.hasOwnProperty;
338
- function Mt(e) {
339
- var t = this.__data__;
340
- return K ? t[e] !== void 0 : kt.call(t, e);
341
- }
342
- var It = "__lodash_hash_undefined__";
343
- function $t(e, t) {
344
- var r = this.__data__;
345
- return this.size += this.has(e) ? 0 : 1, r[e] = K && t === void 0 ? It : t, this;
346
- }
347
- function I(e) {
348
- var t = -1, r = e == null ? 0 : e.length;
349
- for (this.clear(); ++t < r; ) {
350
- var u = e[t];
351
- this.set(u[0], u[1]);
352
- }
353
- }
354
- I.prototype.clear = St;
355
- I.prototype.delete = jt;
356
- I.prototype.get = Nt;
357
- I.prototype.has = Mt;
358
- I.prototype.set = $t;
359
- function xt() {
360
- this.__data__ = [], this.size = 0;
361
- }
362
- function ne(e, t) {
363
- for (var r = e.length; r--; )
364
- if (Rt(e[r][0], t))
365
- return r;
366
- return -1;
367
- }
368
- var Dt = Array.prototype, Ft = Dt.splice;
369
- function Wt(e) {
370
- var t = this.__data__, r = ne(t, e);
371
- if (r < 0)
372
- return !1;
373
- var u = t.length - 1;
374
- return r == u ? t.pop() : Ft.call(t, r, 1), --this.size, !0;
375
- }
376
- function zt(e) {
377
- var t = this.__data__, r = ne(t, e);
378
- return r < 0 ? void 0 : t[r][1];
379
- }
380
- function Yt(e) {
381
- return ne(this.__data__, e) > -1;
382
- }
383
- function Gt(e, t) {
384
- var r = this.__data__, u = ne(r, e);
385
- return u < 0 ? (++this.size, r.push([e, t])) : r[u][1] = t, this;
386
- }
387
- function H(e) {
388
- var t = -1, r = e == null ? 0 : e.length;
389
- for (this.clear(); ++t < r; ) {
390
- var u = e[t];
391
- this.set(u[0], u[1]);
392
- }
393
- }
394
- H.prototype.clear = xt;
395
- H.prototype.delete = Wt;
396
- H.prototype.get = zt;
397
- H.prototype.has = Yt;
398
- H.prototype.set = Gt;
399
- var Ht = Ce(re, "Map");
400
- function Ut() {
401
- this.size = 0, this.__data__ = {
402
- hash: new I(),
403
- map: new (Ht || H)(),
404
- string: new I()
405
- };
406
- }
407
- function Vt(e) {
408
- var t = typeof e;
409
- return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
410
- }
411
- function oe(e, t) {
412
- var r = e.__data__;
413
- return Vt(t) ? r[typeof t == "string" ? "string" : "hash"] : r.map;
414
- }
415
- function qt(e) {
416
- var t = oe(this, e).delete(e);
417
- return this.size -= t ? 1 : 0, t;
418
- }
419
- function Jt(e) {
420
- return oe(this, e).get(e);
421
- }
422
- function Xt(e) {
423
- return oe(this, e).has(e);
424
- }
425
- function Kt(e, t) {
426
- var r = oe(this, e), u = r.size;
427
- return r.set(e, t), this.size += r.size == u ? 0 : 1, this;
428
- }
429
- function $(e) {
430
- var t = -1, r = e == null ? 0 : e.length;
431
- for (this.clear(); ++t < r; ) {
432
- var u = e[t];
433
- this.set(u[0], u[1]);
434
- }
435
- }
436
- $.prototype.clear = Ut;
437
- $.prototype.delete = qt;
438
- $.prototype.get = Jt;
439
- $.prototype.has = Xt;
440
- $.prototype.set = Kt;
441
- var Bt = "Expected a function";
442
- function le(e, t) {
443
- if (typeof e != "function" || t != null && typeof t != "function")
444
- throw new TypeError(Bt);
445
- var r = function() {
446
- var u = arguments, f = t ? t.apply(this, u) : u[0], n = r.cache;
447
- if (n.has(f))
448
- return n.get(f);
449
- var c = e.apply(this, u);
450
- return r.cache = n.set(f, c) || n, c;
9
+ return s.cancel = () => clearTimeout(r), s;
10
+ }
11
+ function V(e) {
12
+ const t = /* @__PURE__ */ new Map();
13
+ return function(...r) {
14
+ const s = JSON.stringify(r);
15
+ if (t.has(s))
16
+ return t.get(s);
17
+ const o = e(...r);
18
+ return t.set(s, o), o;
451
19
  };
452
- return r.cache = new (le.Cache || $)(), r;
453
20
  }
454
- le.Cache = $;
455
- var fe = function() {
456
- return re.Date.now();
457
- }, Qt = "Expected a function", Zt = Math.max, er = Math.min;
458
- function ae(e, t, r) {
459
- var u, f, n, c, d, p, v = 0, _ = !1, E = !1, T = !0;
460
- if (typeof e != "function")
461
- throw new TypeError(Qt);
462
- t = ye(t) || 0, X(r) && (_ = !!r.leading, E = "maxWait" in r, n = E ? Zt(ye(r.maxWait) || 0, t) : n, T = "trailing" in r ? !!r.trailing : T);
463
- function C(o) {
464
- var l = u, h = f;
465
- return u = f = void 0, v = o, c = e.apply(h, l), c;
466
- }
467
- function M(o) {
468
- return v = o, d = setTimeout(N, t), _ ? C(o) : c;
469
- }
470
- function y(o) {
471
- var l = o - p, h = o - v, g = t - l;
472
- return E ? er(g, n - h) : g;
473
- }
474
- function O(o) {
475
- var l = o - p, h = o - v;
476
- return p === void 0 || l >= t || l < 0 || E && h >= n;
477
- }
478
- function N() {
479
- var o = fe();
480
- if (O(o))
481
- return x(o);
482
- d = setTimeout(N, y(o));
483
- }
484
- function x(o) {
485
- return d = void 0, T && u ? C(o) : (u = f = void 0, c);
486
- }
487
- function D() {
488
- d !== void 0 && clearTimeout(d), v = 0, u = p = f = d = void 0;
489
- }
490
- function i() {
491
- return d === void 0 ? c : x(fe());
492
- }
493
- function a() {
494
- var o = fe(), l = O(o);
495
- if (u = arguments, f = this, p = o, l) {
496
- if (d === void 0)
497
- return M(p);
498
- if (E)
499
- return clearTimeout(d), d = setTimeout(N, t), C(p);
500
- }
501
- return d === void 0 && (d = setTimeout(N, t)), c;
502
- }
503
- return a.cancel = D, a.flush = i, a;
504
- }
505
- const we = () => Math.random().toString().slice(2), tr = (e) => {
506
- const { current: { computedHash: t } } = Ie({
21
+ const v = () => Math.random().toString().slice(2), j = (e) => {
22
+ const { current: { computedHash: t } } = R({
507
23
  /**
508
24
  * Getter for the computed hash function.
509
25
  *
@@ -512,529 +28,238 @@ const we = () => Math.random().toString().slice(2), tr = (e) => {
512
28
  * - Updates the hash if any difference is detected.
513
29
  */
514
30
  get computedHash() {
515
- let r = [], u = we();
516
- return (f) => {
31
+ let r = [], s = v();
32
+ return (o) => {
517
33
  let n = !1;
518
- return n = n || !f != !r, n = n || (f == null ? void 0 : f.length) != (r == null ? void 0 : r.length), n = n || f.some((c, d) => c != r[d]), r = f, n && (u = we()), u;
34
+ return n = n || !o != !r, n = n || o?.length != r?.length, n = n || o.some((a, c) => a != r[c]), r = o, n && (s = v()), s;
519
35
  };
520
36
  }
521
37
  });
522
38
  return t(e);
523
39
  };
524
- class rr {
40
+ class G extends Event {
41
+ constructor(t, r) {
42
+ super(t), this.event = t, this.value = r;
43
+ }
44
+ }
45
+ class H extends EventTarget {
525
46
  /**
526
47
  * Create a new Context instance.
527
48
  * @param name - The name of the context (for debugging).
528
49
  */
529
50
  constructor(t) {
530
- Q(this, "event", new Fe.EventEmitter());
531
- /**
532
- * The current data held by the context.
533
- */
534
- Q(this, "data", {});
535
- /**
536
- * Registry for tracking active keys (for duplicate detection).
537
- */
538
- Q(this, "registry", /* @__PURE__ */ new Set());
539
- this.name = t, console.log("[CONTEXT] %s", t), this.event.setMaxListeners(100);
51
+ console.log("[CONTEXT] %s", t), super(), this.name = t;
540
52
  }
53
+ // private event = new EventEmitter()
54
+ /**
55
+ * The current data held by the context.
56
+ */
57
+ data = {};
58
+ /**
59
+ * Registry for tracking active keys (for duplicate detection).
60
+ */
61
+ registry = /* @__PURE__ */ new Set();
541
62
  /**
542
63
  * Publish a value to the context and notify subscribers if it changed.
543
64
  * @param key - The key to update.
544
65
  * @param value - The new value.
545
66
  */
546
67
  publish(t, r) {
547
- r != this.data[t] && (this.data[t] = r, this.event.emit(String(t), { value: r }));
68
+ r != this.data[t] && (this.data[t] = r, this.dispatchEvent(new G(String(t), r)));
548
69
  }
549
70
  /**
550
71
  * Subscribe to changes for a specific key in the context.
551
72
  * @param key - The key to subscribe to.
552
- * @param listender - Callback invoked with the new value.
73
+ * @param _listener - Callback invoked with the new value.
553
74
  * @returns Unsubscribe function.
554
75
  */
555
76
  subscribe(t, r) {
556
- const u = ({ value: f }) => {
557
- r(f);
77
+ const s = ({ event: o, value: n }) => {
78
+ r(n);
558
79
  };
559
- return this.event.addListener(String(t), u), t in this.data && r(this.data[t]), () => (this.event.removeListener(String(t), u), void 0);
80
+ return this.addEventListener(String(t), s), t in this.data && r(this.data[t]), () => (this.removeEventListener(String(t), s), void 0);
560
81
  }
561
82
  }
562
- const nr = le((e) => new rr(e)), Y = (e = "noname") => z(() => nr(e), [e]), Le = (e, ...t) => {
563
- const r = new Error("[ctx] useRegistryChecker failed " + JSON.stringify({ names: t, ctx: (e == null ? void 0 : e.name) ?? "undefined" }));
564
- L(
83
+ const A = V((e) => new H(e)), p = (e = "noname") => d(() => A(e), [e]), N = (e, ...t) => {
84
+ const r = new Error("[ctx] useRegistryChecker failed " + JSON.stringify({ names: t, ctx: e?.name ?? "undefined" }));
85
+ m(
565
86
  () => {
566
87
  if (e)
567
- return t.some((u) => e.registry.has(u)) && console.error(r), t.forEach((u) => e.registry.add(u)), () => {
568
- t.forEach((u) => e.registry.delete(u));
88
+ return t.some((s) => e.registry.has(s)) && console.error(r), t.forEach((s) => e.registry.add(s)), () => {
89
+ t.forEach((s) => e.registry.delete(s));
569
90
  };
570
91
  },
571
92
  [e, t.length]
572
93
  );
573
- }, dr = (e, t, r) => {
574
- L(() => {
94
+ }, x = (e, t, r) => {
95
+ m(() => {
575
96
  e && e.data[t] != r && e.publish(t, r);
576
- }, [t, r, e]), Le(e, t);
577
- }, or = (e, t, r = 0) => {
578
- const [{ value: u }, f] = G(() => {
579
- var n;
580
- return { value: (n = e == null ? void 0 : e.data) == null ? void 0 : n[t] };
581
- });
582
- return L(() => {
97
+ }, [t, r, e]), N(e, t);
98
+ }, W = (e, t, r = 0) => {
99
+ const [{ value: s }, o] = S(() => ({ value: e?.data?.[t] }));
100
+ return m(() => {
583
101
  if (e) {
584
- let n = r == 0 ? (d) => f({ value: d }) : ae((d) => f({ value: d }), r), c = e.subscribe(t, n);
585
- return u != e.data[t] && f({ value: e.data[t] }), () => {
586
- c();
102
+ let n = r == 0 ? (c) => o({ value: c }) : w((c) => o({ value: c }), r), a = e.subscribe(t, n);
103
+ return s != e.data[t] && o({ value: e.data[t] }), () => {
104
+ a();
587
105
  };
588
106
  }
589
- }, [t, e]), e == null ? void 0 : e.data[t];
590
- }, hr = (e, t, r) => {
591
- const [, u] = G(0), f = z(
592
- () => r(e == null ? void 0 : e.data[t]),
593
- [r, e == null ? void 0 : e.data[t]]
107
+ }, [t, e]), e?.data[t];
108
+ }, z = (e, t, r) => {
109
+ const [, s] = S(0), o = d(
110
+ () => r(e?.data[t]),
111
+ [r, e?.data[t]]
594
112
  );
595
- return L(() => {
113
+ return m(() => {
596
114
  if (e) {
597
- let n = f, c = () => {
598
- let p = r(e.data[t]);
599
- p != n && (n = p, u((v) => v + 1));
600
- }, d = e.subscribe(t, c);
601
- return c(), () => d();
115
+ let n = o, a = () => {
116
+ let u = r(e.data[t]);
117
+ u != n && (n = u, s((l) => l + 1));
118
+ }, c = e.subscribe(t, a);
119
+ return a(), () => c();
602
120
  }
603
- }, [t, e]), f;
604
- }, Pe = (e, ...t) => {
605
- L(() => {
121
+ }, [t, e]), o;
122
+ }, M = (e, ...t) => {
123
+ m(() => {
606
124
  if (e)
607
- for (let [r, u] of t)
608
- e.data[r] != u && e.publish(r, u);
609
- }, [e, tr(t.flat())]), Le(e, ...t.map((r) => r[0]));
610
- }, pr = (e, ...t) => {
611
- const [, r] = G(0), u = t.map((f) => {
612
- var n;
613
- return (n = e == null ? void 0 : e.data) == null ? void 0 : n[f];
614
- });
615
- return L(() => {
125
+ for (let [r, s] of t)
126
+ e.data[r] != s && e.publish(r, s);
127
+ }, [e, j(t.flat())]), N(e, ...t.map((r) => r[0]));
128
+ }, K = (e, ...t) => {
129
+ const [, r] = S(0), s = t.map((o) => e?.data?.[o]);
130
+ return m(() => {
616
131
  if (e) {
617
- let f = u;
618
- const n = ae(() => {
619
- let p = t.map((v) => {
620
- var _;
621
- return (_ = e == null ? void 0 : e.data) == null ? void 0 : _[v];
622
- });
623
- t.some((v, _) => f[_] != p[_]) && (f = p, r((v) => v + 1));
132
+ let o = s;
133
+ const n = w(() => {
134
+ let u = t.map((l) => e?.data?.[l]);
135
+ t.some((l, i) => o[i] != u[i]) && (o = u, r((l) => l + 1));
624
136
  }, 1);
625
- let c = t.map((p) => e.subscribe(p, n)), d = setTimeout(n, 1);
137
+ let a = t.map((u) => e.subscribe(u, n)), c = setTimeout(n, 1);
626
138
  return () => {
627
- clearTimeout(d), n.cancel(), c.forEach((p) => p());
139
+ clearTimeout(c), n.cancel(), a.forEach((u) => u());
628
140
  };
629
141
  }
630
- }, [e, ...t]), Object.fromEntries(t.map((f, n) => [f, u[n]]));
631
- }, vr = (e, t = 50, ...r) => {
632
- const [, u] = G(0), f = r.map((n) => {
633
- var c;
634
- return (c = e == null ? void 0 : e.data) == null ? void 0 : c[n];
635
- });
636
- return L(() => {
142
+ }, [e, ...t]), Object.fromEntries(t.map((o, n) => [o, s[n]]));
143
+ }, P = (e, t = 50, ...r) => {
144
+ const [, s] = S(0), o = r.map((n) => e?.data?.[n]);
145
+ return m(() => {
637
146
  if (e) {
638
- let n = f;
639
- const c = ae(() => {
640
- let v = r.map((_) => {
641
- var E;
642
- return (E = e == null ? void 0 : e.data) == null ? void 0 : E[_];
643
- });
644
- r.some((_, E) => n[E] != v[E]) && (n = v, u((_) => _ + 1));
147
+ let n = o;
148
+ const a = w(() => {
149
+ let l = r.map((i) => e?.data?.[i]);
150
+ r.some((i, b) => n[b] != l[b]) && (n = l, s((i) => i + 1));
645
151
  }, t);
646
- let d = r.map((v) => e.subscribe(v, c)), p = setTimeout(c, 1);
152
+ let c = r.map((l) => e.subscribe(l, a)), u = setTimeout(a, 1);
647
153
  return () => {
648
- clearTimeout(p), c.cancel(), d.forEach((v) => v());
154
+ clearTimeout(u), a.cancel(), c.forEach((l) => l());
649
155
  };
650
156
  }
651
- }, [e, ...r]), f;
652
- };
653
- var ee = { exports: {} }, q = {};
654
- /**
655
- * @license React
656
- * react-jsx-runtime.production.js
657
- *
658
- * Copyright (c) Meta Platforms, Inc. and affiliates.
659
- *
660
- * This source code is licensed under the MIT license found in the
661
- * LICENSE file in the root directory of this source tree.
662
- */
663
- var Te;
664
- function ar() {
665
- if (Te) return q;
666
- Te = 1;
667
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
668
- function r(u, f, n) {
669
- var c = null;
670
- if (n !== void 0 && (c = "" + n), f.key !== void 0 && (c = "" + f.key), "key" in f) {
671
- n = {};
672
- for (var d in f)
673
- d !== "key" && (n[d] = f[d]);
674
- } else n = f;
675
- return f = n.ref, {
676
- $$typeof: e,
677
- type: u,
678
- key: c,
679
- ref: f !== void 0 ? f : null,
680
- props: n
681
- };
682
- }
683
- return q.Fragment = t, q.jsx = r, q.jsxs = r, q;
684
- }
685
- var J = {};
686
- /**
687
- * @license React
688
- * react-jsx-runtime.development.js
689
- *
690
- * Copyright (c) Meta Platforms, Inc. and affiliates.
691
- *
692
- * This source code is licensed under the MIT license found in the
693
- * LICENSE file in the root directory of this source tree.
694
- */
695
- var Oe;
696
- function sr() {
697
- return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && function() {
698
- function e(s) {
699
- if (s == null) return null;
700
- if (typeof s == "function")
701
- return s.$$typeof === b ? null : s.displayName || s.name || null;
702
- if (typeof s == "string") return s;
703
- switch (s) {
704
- case y:
705
- return "Fragment";
706
- case N:
707
- return "Profiler";
708
- case O:
709
- return "StrictMode";
710
- case a:
711
- return "Suspense";
712
- case o:
713
- return "SuspenseList";
714
- case g:
715
- return "Activity";
716
- }
717
- if (typeof s == "object")
718
- switch (typeof s.tag == "number" && console.error(
719
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
720
- ), s.$$typeof) {
721
- case M:
722
- return "Portal";
723
- case D:
724
- return (s.displayName || "Context") + ".Provider";
725
- case x:
726
- return (s._context.displayName || "Context") + ".Consumer";
727
- case i:
728
- var m = s.render;
729
- return s = s.displayName, s || (s = m.displayName || m.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
730
- case l:
731
- return m = s.displayName || null, m !== null ? m : e(s.type) || "Memo";
732
- case h:
733
- m = s._payload, s = s._init;
734
- try {
735
- return e(s(m));
736
- } catch {
737
- }
738
- }
739
- return null;
740
- }
741
- function t(s) {
742
- return "" + s;
743
- }
744
- function r(s) {
745
- try {
746
- t(s);
747
- var m = !1;
748
- } catch {
749
- m = !0;
750
- }
751
- if (m) {
752
- m = console;
753
- var w = m.error, R = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
754
- return w.call(
755
- m,
756
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
757
- R
758
- ), t(s);
759
- }
760
- }
761
- function u(s) {
762
- if (s === y) return "<>";
763
- if (typeof s == "object" && s !== null && s.$$typeof === h)
764
- return "<...>";
765
- try {
766
- var m = e(s);
767
- return m ? "<" + m + ">" : "<...>";
768
- } catch {
769
- return "<...>";
770
- }
771
- }
772
- function f() {
773
- var s = j.A;
774
- return s === null ? null : s.getOwner();
775
- }
776
- function n() {
777
- return Error("react-stack-top-frame");
778
- }
779
- function c(s) {
780
- if (A.call(s, "key")) {
781
- var m = Object.getOwnPropertyDescriptor(s, "key").get;
782
- if (m && m.isReactWarning) return !1;
783
- }
784
- return s.key !== void 0;
785
- }
786
- function d(s, m) {
787
- function w() {
788
- de || (de = !0, console.error(
789
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
790
- m
791
- ));
792
- }
793
- w.isReactWarning = !0, Object.defineProperty(s, "key", {
794
- get: w,
795
- configurable: !0
796
- });
797
- }
798
- function p() {
799
- var s = e(this.type);
800
- return he[s] || (he[s] = !0, console.error(
801
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
802
- )), s = this.props.ref, s !== void 0 ? s : null;
803
- }
804
- function v(s, m, w, R, k, P, se, ie) {
805
- return w = P.ref, s = {
806
- $$typeof: C,
807
- type: s,
808
- key: m,
809
- props: P,
810
- _owner: k
811
- }, (w !== void 0 ? w : null) !== null ? Object.defineProperty(s, "ref", {
812
- enumerable: !1,
813
- get: p
814
- }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
815
- configurable: !1,
816
- enumerable: !1,
817
- writable: !0,
818
- value: 0
819
- }), Object.defineProperty(s, "_debugInfo", {
820
- configurable: !1,
821
- enumerable: !1,
822
- writable: !0,
823
- value: null
824
- }), Object.defineProperty(s, "_debugStack", {
825
- configurable: !1,
826
- enumerable: !1,
827
- writable: !0,
828
- value: se
829
- }), Object.defineProperty(s, "_debugTask", {
830
- configurable: !1,
831
- enumerable: !1,
832
- writable: !0,
833
- value: ie
834
- }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
835
- }
836
- function _(s, m, w, R, k, P, se, ie) {
837
- var S = m.children;
838
- if (S !== void 0)
839
- if (R)
840
- if (B(S)) {
841
- for (R = 0; R < S.length; R++)
842
- E(S[R]);
843
- Object.freeze && Object.freeze(S);
844
- } else
845
- console.error(
846
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
847
- );
848
- else E(S);
849
- if (A.call(m, "key")) {
850
- S = e(s);
851
- var F = Object.keys(m).filter(function(Ne) {
852
- return Ne !== "key";
853
- });
854
- R = 0 < F.length ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}", me[S + R] || (F = 0 < F.length ? "{" + F.join(": ..., ") + ": ...}" : "{}", console.error(
855
- `A props object containing a "key" prop is being spread into JSX:
856
- let props = %s;
857
- <%s {...props} />
858
- React keys must be passed directly to JSX without using spread:
859
- let props = %s;
860
- <%s key={someKey} {...props} />`,
861
- R,
862
- S,
863
- F,
864
- S
865
- ), me[S + R] = !0);
866
- }
867
- if (S = null, w !== void 0 && (r(w), S = "" + w), c(m) && (r(m.key), S = "" + m.key), "key" in m) {
868
- w = {};
869
- for (var ue in m)
870
- ue !== "key" && (w[ue] = m[ue]);
871
- } else w = m;
872
- return S && d(
873
- w,
874
- typeof s == "function" ? s.displayName || s.name || "Unknown" : s
875
- ), v(
876
- s,
877
- S,
878
- P,
879
- k,
880
- f(),
881
- w,
882
- se,
883
- ie
884
- );
885
- }
886
- function E(s) {
887
- typeof s == "object" && s !== null && s.$$typeof === C && s._store && (s._store.validated = 1);
888
- }
889
- var T = Me, C = Symbol.for("react.transitional.element"), M = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), N = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), D = Symbol.for("react.context"), i = Symbol.for("react.forward_ref"), a = Symbol.for("react.suspense"), o = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), h = Symbol.for("react.lazy"), g = Symbol.for("react.activity"), b = Symbol.for("react.client.reference"), j = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, B = Array.isArray, U = console.createTask ? console.createTask : function() {
890
- return null;
891
- };
892
- T = {
893
- "react-stack-bottom-frame": function(s) {
894
- return s();
895
- }
896
- };
897
- var de, he = {}, pe = T["react-stack-bottom-frame"].bind(
898
- T,
899
- n
900
- )(), ve = U(u(n)), me = {};
901
- J.Fragment = y, J.jsx = function(s, m, w, R, k) {
902
- var P = 1e4 > j.recentlyCreatedOwnerStacks++;
903
- return _(
904
- s,
905
- m,
906
- w,
907
- !1,
908
- R,
909
- k,
910
- P ? Error("react-stack-top-frame") : pe,
911
- P ? U(u(s)) : ve
912
- );
913
- }, J.jsxs = function(s, m, w, R, k) {
914
- var P = 1e4 > j.recentlyCreatedOwnerStacks++;
915
- return _(
916
- s,
917
- m,
918
- w,
919
- !0,
920
- R,
921
- k,
922
- P ? Error("react-stack-top-frame") : pe,
923
- P ? U(u(s)) : ve
924
- );
925
- };
926
- }()), J;
927
- }
928
- var Re;
929
- function ir() {
930
- return Re || (Re = 1, process.env.NODE_ENV === "production" ? ee.exports = ar() : ee.exports = sr()), ee.exports;
931
- }
932
- var W = ir();
933
- const mr = (e, t) => {
157
+ }, [e, ...r]), o;
158
+ }, Q = (e, t) => {
934
159
  const r = (n) => [
935
160
  e,
936
- ...Object.entries(n ?? {}).sort((c, d) => c[0].localeCompare(d[0])).flat()
161
+ ...Object.entries(n ?? {}).sort((a, c) => a[0].localeCompare(c[0])).flat()
937
162
  ].join("-");
938
- let u = /* @__PURE__ */ new Set();
939
- const f = (n) => {
940
- const c = t(n), d = r(n), p = Y(d), v = z(() => new Error().stack, []);
941
- return Pe(
942
- p,
943
- ...Object.entries(c)
944
- ), L(() => {
945
- if (u.has(d)) {
946
- const _ = new Error("RootContext " + d + " are mounted more than once");
947
- throw _.stack = v, _;
163
+ let s = /* @__PURE__ */ new Set();
164
+ const o = (n) => {
165
+ const a = t(n), c = r(n), u = p(c), l = d(() => new Error().stack, []);
166
+ return M(
167
+ u,
168
+ ...Object.entries(a)
169
+ ), m(() => {
170
+ if (s.has(c)) {
171
+ const i = new Error("RootContext " + c + " are mounted more than once");
172
+ throw i.stack = l, i;
948
173
  }
949
- return u.add(d), () => {
950
- u.delete(d);
174
+ return s.add(c), () => {
175
+ s.delete(c);
951
176
  };
952
- }), /* @__PURE__ */ W.jsx(W.Fragment, {});
177
+ }), /* @__PURE__ */ g(T, {});
953
178
  };
954
- return f.displayName = `State[${(t == null ? void 0 : t.name) ?? "??"}]`, {
179
+ return o.displayName = `State[${t?.name ?? "??"}]`, {
955
180
  resolveCtxName: r,
956
- Root: f,
181
+ Root: o,
957
182
  /**
958
183
  * Strict consumer: throws if the corresponding Root for these props isn't mounted.
959
184
  * Use in development/tests to fail fast when wiring is incorrect.
960
185
  */
961
186
  useCtxStateStrict: (n) => {
962
- const c = r(n), d = z(() => new Error().stack, []);
963
- return L(() => {
964
- if (!u.has(c)) {
965
- const p = new Error("RootContext [" + c + "] is not mounted");
966
- throw p.stack = d, p;
187
+ const a = r(n), c = d(() => new Error().stack, []);
188
+ return m(() => {
189
+ if (!s.has(a)) {
190
+ const u = new Error("RootContext [" + a + "] is not mounted");
191
+ throw u.stack = c, u;
967
192
  }
968
- }, [c]), Y(c);
193
+ }, [a]), p(a);
969
194
  },
970
195
  /**
971
196
  * Lenient consumer: schedules a console.error if the Root isn't mounted instead of throwing.
972
197
  * Useful in production to avoid hard crashes while still surfacing misconfiguration.
973
198
  */
974
199
  useCtxState: (n) => {
975
- const c = r(n), d = z(() => new Error().stack, []);
976
- return L(() => {
977
- if (!u.has(c)) {
978
- const p = new Error("RootContext [" + c + "] is not mounted");
979
- p.stack = d;
980
- let v = setTimeout(() => console.error(p), 1e3);
981
- return () => clearTimeout(v);
200
+ const a = r(n), c = d(() => new Error().stack, []);
201
+ return m(() => {
202
+ if (!s.has(a)) {
203
+ const u = new Error("RootContext [" + a + "] is not mounted");
204
+ u.stack = c;
205
+ let l = setTimeout(() => console.error(u), 1e3);
206
+ return () => clearTimeout(l);
982
207
  }
983
- }, [u.has(c)]), Y(c);
208
+ }, [s.has(a)]), p(a);
984
209
  }
985
210
  };
986
- }, ur = /* @__PURE__ */ function() {
211
+ }, F = /* @__PURE__ */ function() {
987
212
  const e = /* @__PURE__ */ new WeakMap();
988
213
  return (t) => {
989
214
  let r = e.get(t);
990
- return r || e.set(t, r = ((t == null ? void 0 : t.name) ?? "") + Math.random().toString()), r;
215
+ return r || e.set(t, r = (t?.name ?? "") + Math.random().toString()), r;
991
216
  };
992
- }(), cr = (e) => [
217
+ }(), J = (e) => [
993
218
  ...Object.entries(e ?? {}).sort((t, r) => t[0].localeCompare(r[0])).flat()
994
- ].join("-"), br = ({ Wrapper: e = xe }) => {
995
- const t = Y("auto-ctx"), [r, u] = G({}), f = $e(
996
- (n, c) => {
997
- const d = ur(n), p = cr(c);
998
- return u(({
999
- [d]: {
1000
- Component: v = n,
219
+ ].join("-"), U = ({ Wrapper: e = O }) => {
220
+ const t = p("auto-ctx"), [r, s] = S({}), o = D(
221
+ (n, a) => {
222
+ const c = F(n), u = J(a);
223
+ return s(({
224
+ [c]: {
225
+ Component: l = n,
1001
226
  subState: {
1002
- [p]: _ = { params: c, counter: 0 },
1003
- ...E
227
+ [u]: i = { params: a, counter: 0 },
228
+ ...b
1004
229
  } = {}
1005
230
  } = {},
1006
- ...T
231
+ ...h
1007
232
  }) => ({
1008
- ...T,
1009
- [d]: {
1010
- Component: v,
233
+ ...h,
234
+ [c]: {
235
+ Component: l,
1011
236
  subState: {
1012
- ...E,
1013
- [p]: {
1014
- ..._,
1015
- counter: _.counter + 1
237
+ ...b,
238
+ [u]: {
239
+ ...i,
240
+ counter: i.counter + 1
1016
241
  }
1017
242
  }
1018
243
  }
1019
- })), () => u(({
1020
- [d]: {
1021
- Component: v = n,
244
+ })), () => s(({
245
+ [c]: {
246
+ Component: l = n,
1022
247
  subState: {
1023
- [p]: _ = { params: c, counter: 0 },
1024
- ...E
248
+ [u]: i = { params: a, counter: 0 },
249
+ ...b
1025
250
  } = {}
1026
251
  } = {},
1027
- ...T
252
+ ...h
1028
253
  }) => ({
1029
- ...T,
1030
- [d]: {
1031
- Component: v,
254
+ ...h,
255
+ [c]: {
256
+ Component: l,
1032
257
  subState: {
1033
- ...E,
1034
- ..._.counter > 1 ? {
1035
- [p]: {
1036
- ..._,
1037
- counter: _.counter - 1
258
+ ...b,
259
+ ...i.counter > 1 ? {
260
+ [u]: {
261
+ ...i,
262
+ counter: i.counter - 1
1038
263
  }
1039
264
  } : {}
1040
265
  }
@@ -1043,71 +268,67 @@ const mr = (e, t) => {
1043
268
  },
1044
269
  []
1045
270
  );
1046
- return Pe(
271
+ return M(
1047
272
  t,
1048
- ["subscribe", f],
273
+ ["subscribe", o],
1049
274
  ["state", r]
1050
- ), /* @__PURE__ */ W.jsx(W.Fragment, { children: Object.entries(r).flatMap(
1051
- ([n, { Component: c, subState: d }]) => Object.entries(d).map(([p, { counter: v, params: _ }]) => ({ key: n + p, Component: c, params: _, counter: v })).filter((p) => p.counter > 0).map(({ key: p, params: v, Component: _ }) => /* @__PURE__ */ W.jsx(e, { children: /* @__PURE__ */ W.jsx(_, { ...v }) }, p))
275
+ ), /* @__PURE__ */ g(T, { children: Object.entries(r).flatMap(
276
+ ([n, { Component: a, subState: c }]) => Object.entries(c).map(([u, { counter: l, params: i }]) => ({ key: n + u, Component: a, params: i, counter: l })).filter((u) => u.counter > 0).map(({ key: u, params: l, Component: i }) => /* @__PURE__ */ g(e, { children: /* @__PURE__ */ g(i, { ...l }) }, u))
1052
277
  ) });
1053
- }, _r = ({ Root: e, useCtxState: t, useCtxStateStrict: r, resolveCtxName: u }) => ({
1054
- useCtxState: (f) => {
1055
- const n = u(f), c = or(Y("auto-ctx"), "subscribe");
1056
- return L(() => c == null ? void 0 : c(e, f), [c, n]), Y(n);
278
+ }, X = ({ Root: e, useCtxState: t, useCtxStateStrict: r, resolveCtxName: s }) => ({
279
+ useCtxState: (o) => {
280
+ const n = s(o), a = W(p("auto-ctx"), "subscribe");
281
+ return m(() => a?.(e, o), [a, n]), p(n);
1057
282
  }
1058
- }), gr = (e) => {
1059
- const [, t] = G(0), { proxy: r, finalGetter: u, openGetter: f, clean: n } = z(
283
+ }), q = (e) => {
284
+ const [, t] = S(0), { proxy: r, finalGetter: s, openGetter: o, clean: n } = d(
1060
285
  () => {
1061
- const c = /* @__PURE__ */ new Set(), d = {}, p = /* @__PURE__ */ new Map(), v = new Proxy(
1062
- e == null ? void 0 : e.data,
286
+ const a = /* @__PURE__ */ new Set(), c = {}, u = /* @__PURE__ */ new Map(), l = new Proxy(
287
+ e?.data,
1063
288
  {
1064
- get(y, O) {
1065
- if (_)
1066
- return c.add(O), d[O] = y[O];
289
+ get(f, C) {
290
+ if (i)
291
+ return a.add(C), c[C] = f[C];
1067
292
  throw new Error("now allow here");
1068
293
  }
1069
294
  }
1070
295
  );
1071
- let _ = !0, E = ae(() => {
1072
- [...c.values()].some((y) => {
1073
- var O;
1074
- return d[y] != ((O = e == null ? void 0 : e.data) == null ? void 0 : O[y]);
1075
- }) && t((y) => y + 1);
1076
- }, 0), T = () => {
1077
- _ = !0, c.clear();
1078
- }, C = () => {
1079
- _ = !1, [...c.values()].filter((y) => !p.has(y)).forEach((y) => {
1080
- p.set(y, e == null ? void 0 : e.subscribe(y, E));
1081
- }), [...p.keys()].filter((y) => !c.has(y)).forEach((y) => {
1082
- let O = p.get(y);
1083
- O == null || O(), p.delete(y);
296
+ let i = !0, b = w(() => {
297
+ [...a.values()].some((f) => c[f] != e?.data?.[f]) && t((f) => f + 1);
298
+ }, 0), h = () => {
299
+ i = !0, a.clear();
300
+ }, E = () => {
301
+ i = !1, [...a.values()].filter((f) => !u.has(f)).forEach((f) => {
302
+ u.set(f, e?.subscribe(f, b));
303
+ }), [...u.keys()].filter((f) => !a.has(f)).forEach((f) => {
304
+ u.get(f)?.(), u.delete(f);
1084
305
  });
1085
306
  };
1086
- return { proxy: v, finalGetter: C, openGetter: T, clean: () => {
1087
- T(), C(), t((y) => y + 1);
307
+ return { proxy: l, finalGetter: E, openGetter: h, clean: () => {
308
+ h(), E(), t((f) => f + 1);
1088
309
  } };
1089
310
  },
1090
311
  [e]
1091
312
  );
1092
- return f(), setTimeout(u, 0), L(
313
+ return o(), setTimeout(s, 0), m(
1093
314
  () => () => n(),
1094
315
  [n]
1095
316
  ), r;
1096
317
  };
1097
318
  export {
1098
- br as AutoRootCtx,
1099
- rr as Context,
1100
- _r as createAutoCtx,
1101
- mr as createRootCtx,
1102
- nr as getContext,
1103
- tr as useArrayHash,
1104
- Y as useDataContext,
1105
- dr as useDataSource,
1106
- Pe as useDataSourceMultiple,
1107
- or as useDataSubscribe,
1108
- pr as useDataSubscribeMultiple,
1109
- vr as useDataSubscribeMultipleWithDebounce,
1110
- hr as useDataSubscribeWithTransform,
1111
- gr as useQuickSubscribe
319
+ U as AutoRootCtx,
320
+ H as Context,
321
+ X as createAutoCtx,
322
+ Q as createRootCtx,
323
+ A as getContext,
324
+ j as useArrayHash,
325
+ p as useDataContext,
326
+ x as useDataSource,
327
+ M as useDataSourceMultiple,
328
+ W as useDataSubscribe,
329
+ K as useDataSubscribeMultiple,
330
+ P as useDataSubscribeMultipleWithDebounce,
331
+ z as useDataSubscribeWithTransform,
332
+ q as useQuickSubscribe
1112
333
  };
1113
334
  //# sourceMappingURL=index.es.js.map