@but212/atom-effect-jquery 0.25.0 → 0.26.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/index.mjs CHANGED
@@ -89,7 +89,7 @@ var d = Object.freeze([]), f = class {
89
89
  BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
90
90
  }, y = class {
91
91
  constructor() {
92
- this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null;
92
+ this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null, this._freeIndices = null;
93
93
  }
94
94
  get size() {
95
95
  return this._count;
@@ -162,7 +162,7 @@ var d = Object.freeze([]), f = class {
162
162
  }
163
163
  e <= 4 ? (n.length = 0, this._overflow = null) : n.length = e - 4;
164
164
  }
165
- this._count = e;
165
+ this._freeIndices !== null && (this._freeIndices = null), this._count = e;
166
166
  }
167
167
  _onItemRemoved(e) {}
168
168
  add(e) {
@@ -182,14 +182,13 @@ var d = Object.freeze([]), f = class {
182
182
  this._s3 = e, this._count++;
183
183
  return;
184
184
  }
185
+ this._addToOverflow(e);
186
+ }
187
+ _addToOverflow(e) {
185
188
  if (this._overflow === null) this._overflow = [e];
186
189
  else {
187
- let t = this._overflow;
188
- for (let n = 0, r = t.length; n < r; n++) if (t[n] === null) {
189
- t[n] = e, this._count++;
190
- return;
191
- }
192
- t.push(e);
190
+ let t = this._freeIndices;
191
+ t !== null && t.length > 0 ? this._overflow[t.pop()] = e : this._overflow.push(e);
193
192
  }
194
193
  this._count++;
195
194
  }
@@ -200,47 +199,32 @@ var d = Object.freeze([]), f = class {
200
199
  if (this._s3 === e) return this._s3 = null, this._count--, !0;
201
200
  let t = this._overflow;
202
201
  if (t == null) return !1;
203
- for (let n = 0, r = t.length; n < r; n++) if (t[n] === e) return t[n] = null, this._count--, !0;
202
+ for (let n = 0, r = t.length; n < r; n++) if (t[n] === e) return t[n] = null, this._count--, this._freeIndices === null && (this._freeIndices = []), this._freeIndices.push(n), !0;
204
203
  return !1;
205
204
  }
206
205
  has(e) {
207
- let t = this._count;
208
- if (t === 0) return !1;
206
+ if (this._count === 0) return !1;
209
207
  if (this._s0 === e || this._s1 === e || this._s2 === e || this._s3 === e) return !0;
210
- if (t <= 4) return !1;
211
- let n = this._overflow;
212
- if (n != null) {
213
- let r = 0;
214
- this._s0 != null && r++, this._s1 != null && r++, this._s2 != null && r++, this._s3 != null && r++;
215
- for (let i = 0, a = n.length; i < a; i++) {
216
- let a = n[i];
217
- if (a != null) {
218
- if (a === e) return !0;
219
- if (++r === t) break;
220
- }
221
- }
208
+ let t = this._overflow;
209
+ if (t != null) {
210
+ for (let n = 0, r = t.length; n < r; n++) if (t[n] === e) return !0;
222
211
  }
223
212
  return !1;
224
213
  }
225
214
  forEach(e) {
226
- let t = this._count;
227
- if (t === 0) return;
228
- let n = this._s0;
215
+ if (this._count === 0) return;
216
+ let t = this._s0;
217
+ t != null && e(t);
218
+ let n = this._s1;
229
219
  n != null && e(n);
230
- let r = this._s1;
220
+ let r = this._s2;
231
221
  r != null && e(r);
232
- let i = this._s2;
222
+ let i = this._s3;
233
223
  i != null && e(i);
234
- let a = this._s3;
235
- if (a != null && e(a), t <= 4) return;
236
- let o = this._overflow;
237
- if (o != null) {
238
- let s = 0;
239
- n != null && s++, r != null && s++, i != null && s++, a != null && s++;
240
- for (let n = 0, r = o.length; n < r; n++) {
241
- let r = o[n];
242
- if (r != null && (e(r), ++s === t)) return;
243
- }
224
+ let a = this._overflow;
225
+ if (a != null) for (let t = 0, n = a.length; t < n; t++) {
226
+ let n = a[t];
227
+ n != null && e(n);
244
228
  }
245
229
  }
246
230
  forEachIndexed(e) {
@@ -253,11 +237,11 @@ var d = Object.freeze([]), f = class {
253
237
  let a = this._s2;
254
238
  a != null && (e(a), n++);
255
239
  let o = this._s3;
256
- if (o != null && (e(o), n++), t <= 4 || n === t) return n;
240
+ if (o != null && (e(o), n++), n === t) return n;
257
241
  let s = this._overflow;
258
- if (s != null) for (let r = 0, i = s.length; r < i; r++) {
259
- let i = s[r];
260
- if (i != null && (e(i), ++n === t)) break;
242
+ if (s != null) for (let t = 0, r = s.length; t < r; t++) {
243
+ let r = s[t];
244
+ r != null && (e(r), n++);
261
245
  }
262
246
  return n;
263
247
  }
@@ -266,13 +250,13 @@ var d = Object.freeze([]), f = class {
266
250
  if (e === null || e.length === 0) return;
267
251
  let t = 0;
268
252
  for (; t < e.length;) if (e[t] === null) {
269
- let n = e.pop();
270
- t < e.length && n != null && (e[t] = n);
253
+ for (; e.length > t && e[e.length - 1] === null;) e.pop();
254
+ e.length > t && (e[t] = e.pop(), t++);
271
255
  } else t++;
272
- e.length === 0 && (this._overflow = null);
256
+ this._freeIndices = null, e.length === 0 && (this._overflow = null);
273
257
  }
274
258
  clear() {
275
- this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null);
259
+ this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null), this._freeIndices = null;
276
260
  }
277
261
  dispose() {
278
262
  this.clear();
@@ -344,13 +328,18 @@ var ne = class {
344
328
  }
345
329
  return !e.hasComputeds && !e.isDirtyFast() ? !1 : this._deepDirtyCheck();
346
330
  }
347
- }, re = 0, ie = () => (re = re + 1 & 1073741823 || 1, re), ae = (e) => e + 1 & l, oe = 0, se = !1, ce = 0, le = () => ce;
331
+ }, re = 0, ie = () => (re = re + 1 & 1073741823 || 1, re), ae = (e) => e + 1 & 1073741823 || 1, oe = 0, se = !1, ce = 0, le = () => ce;
348
332
  function ue() {
349
333
  return se ? !1 : (se = !0, ce = ie(), oe = 0, !0);
350
334
  }
351
335
  var de = () => {
352
336
  se = !1;
353
- }, fe = () => se ? ++oe : 0, pe = /* @__PURE__ */ (function(e) {
337
+ }, fe = () => {
338
+ if (!se) return 0;
339
+ let e = ++oe;
340
+ if (e > a.MAX_EXECUTIONS_PER_FLUSH) throw Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${a.MAX_EXECUTIONS_PER_FLUSH}`);
341
+ return e;
342
+ }, pe = /* @__PURE__ */ (function(e) {
354
343
  return e[e.IDLE = 0] = "IDLE", e[e.BATCHING = 1] = "BATCHING", e[e.FLUSHING = 2] = "FLUSHING", e;
355
344
  })({}), T = new class {
356
345
  constructor() {
@@ -506,10 +495,10 @@ var ve = class extends ne {
506
495
  this.dispose();
507
496
  }
508
497
  };
509
- function ye(e, t = {}) {
498
+ function O(e, t = {}) {
510
499
  return new ve(e, t.sync ?? !1);
511
500
  }
512
- var be = class extends y {
501
+ var ye = class extends y {
513
502
  constructor() {
514
503
  super(), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0, this._map = null, this.hasComputeds = !1, this._depsHash = 0;
515
504
  }
@@ -586,10 +575,6 @@ var be = class extends y {
586
575
  }
587
576
  return !0;
588
577
  }
589
- _swapInline(e, t, n) {
590
- let r = this.getAt(t);
591
- this.setAt(t, n), this.setAt(e, r);
592
- }
593
578
  _swapGeneral(e, t, n) {
594
579
  if (e === t) return;
595
580
  let r = this.getAt(t);
@@ -606,7 +591,7 @@ var be = class extends y {
606
591
  let n = this._count;
607
592
  if (e < n) {
608
593
  let t = this.getAt(e);
609
- t != null && (this.add(t), this._map !== null && t.unsub && this._map.set(t.node, this._count - 1));
594
+ t != null && (this._addToOverflow(t), this._map !== null && t.unsub && this._map.set(t.node, this._count - 1));
610
595
  }
611
596
  if (e === 0) this._s0 = t;
612
597
  else if (e === 1) this._s1 = t;
@@ -622,67 +607,62 @@ var be = class extends y {
622
607
  e >= this._count || (super.truncateFrom(e), this._map !== null && (this._map.clear(), this._map = null));
623
608
  }
624
609
  seal() {
625
- let e = this._count, t = u.VERSION_BITS, n = 0;
626
- switch (e) {
627
- case 0:
628
- this._depsHash = 0;
629
- return;
630
- case 1: {
631
- let e = this._s0;
632
- n = n + (e.version << t) + e.node.id | 0;
633
- break;
634
- }
635
- case 2: {
636
- let e = this._s0, r = this._s1;
637
- n = n + (e.version << t) + e.node.id | 0, n = n + (r.version << t) + r.node.id | 0;
638
- break;
639
- }
640
- case 3: {
641
- let e = this._s0, r = this._s1, i = this._s2;
642
- n = n + (e.version << t) + e.node.id | 0, n = n + (r.version << t) + r.node.id | 0, n = n + (i.version << t) + i.node.id | 0;
643
- break;
644
- }
645
- default: {
646
- let r = this._s0, i = this._s1, a = this._s2, o = this._s3;
647
- if (n = n + (r.version << t) + r.node.id | 0, n = n + (i.version << t) + i.node.id | 0, n = n + (a.version << t) + a.node.id | 0, n = n + (o.version << t) + o.node.id | 0, e > 4) {
648
- let e = this._overflow;
649
- for (let r = 0, i = e.length; r < i; r++) {
650
- let i = e[r];
651
- n = n + (i.version << t) + i.node.id | 0;
652
- }
653
- }
610
+ let e = this._count;
611
+ if (e === 0) {
612
+ this._depsHash = 0;
613
+ return;
614
+ }
615
+ let t = u.VERSION_BITS, n = 0;
616
+ if (e >= 1) {
617
+ let e = this._s0;
618
+ n = n + (e.version << t) + e.node.id | 0;
619
+ }
620
+ if (e >= 2) {
621
+ let e = this._s1;
622
+ n = n + (e.version << t) + e.node.id | 0;
623
+ }
624
+ if (e >= 3) {
625
+ let e = this._s2;
626
+ n = n + (e.version << t) + e.node.id | 0;
627
+ }
628
+ if (e >= 4) {
629
+ let e = this._s3;
630
+ n = n + (e.version << t) + e.node.id | 0;
631
+ }
632
+ if (e > 4) {
633
+ let e = this._overflow;
634
+ for (let r = 0, i = e.length; r < i; r++) {
635
+ let i = e[r];
636
+ n = n + (i.version << t) + i.node.id | 0;
654
637
  }
655
638
  }
656
639
  this._depsHash = n;
657
640
  }
658
641
  isDirtyFast() {
659
- let e = this._count, t = u.VERSION_BITS, n = 0;
660
- switch (e) {
661
- case 0: return !1;
662
- case 1: {
663
- let e = this._s0.node;
664
- n = n + (e.version << t) + e.id | 0;
665
- break;
666
- }
667
- case 2: {
668
- let e = this._s0.node, r = this._s1.node;
669
- n = n + (e.version << t) + e.id | 0, n = n + (r.version << t) + r.id | 0;
670
- break;
671
- }
672
- case 3: {
673
- let e = this._s0.node, r = this._s1.node, i = this._s2.node;
674
- n = n + (e.version << t) + e.id | 0, n = n + (r.version << t) + r.id | 0, n = n + (i.version << t) + i.id | 0;
675
- break;
676
- }
677
- default: {
678
- let r = this._s0.node, i = this._s1.node, a = this._s2.node, o = this._s3.node;
679
- if (n = n + (r.version << t) + r.id | 0, n = n + (i.version << t) + i.id | 0, n = n + (a.version << t) + a.id | 0, n = n + (o.version << t) + o.id | 0, e > 4) {
680
- let e = this._overflow;
681
- for (let r = 0, i = e.length; r < i; r++) {
682
- let i = e[r].node;
683
- n = n + (i.version << t) + i.id | 0;
684
- }
685
- }
642
+ let e = this._count;
643
+ if (e === 0) return !1;
644
+ let t = u.VERSION_BITS, n = 0;
645
+ if (e >= 1) {
646
+ let e = this._s0.node;
647
+ n = n + (e.version << t) + e.id | 0;
648
+ }
649
+ if (e >= 2) {
650
+ let e = this._s1.node;
651
+ n = n + (e.version << t) + e.id | 0;
652
+ }
653
+ if (e >= 3) {
654
+ let e = this._s2.node;
655
+ n = n + (e.version << t) + e.id | 0;
656
+ }
657
+ if (e >= 4) {
658
+ let e = this._s3.node;
659
+ n = n + (e.version << t) + e.id | 0;
660
+ }
661
+ if (e > 4) {
662
+ let e = this._overflow;
663
+ for (let r = 0, i = e.length; r < i; r++) {
664
+ let i = e[r].node;
665
+ n = n + (i.version << t) + i.id | 0;
686
666
  }
687
667
  }
688
668
  return n !== this._depsHash;
@@ -695,19 +675,19 @@ var be = class extends y {
695
675
  }
696
676
  compact() {}
697
677
  };
698
- function xe(e) {
678
+ function be(e) {
699
679
  return typeof e == "object" && !!e && me in e;
700
680
  }
701
- function Se(e) {
681
+ function xe(e) {
702
682
  return typeof e == "object" && !!e && he in e;
703
683
  }
704
- function Ce(e) {
684
+ function Se(e) {
705
685
  return typeof e == "object" && !!e && typeof e.then == "function";
706
686
  }
707
- var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, RECOMPUTING: P, DISPOSED: we, IS_COMPUTED: Te, FORCE_COMPUTE: Ee } = r, De = class extends ne {
687
+ var { IDLE: k, DIRTY: A, PENDING: j, RESOLVED: M, REJECTED: N, HAS_ERROR: P, RECOMPUTING: Ce, DISPOSED: we, IS_COMPUTED: Te, FORCE_COMPUTE: Ee } = r, De = class extends ne {
708
688
  constructor(e, t = {}) {
709
689
  if (typeof e != "function") throw new h(v.COMPUTED_MUST_BE_FUNCTION);
710
- if (super(), this[me] = !0, this[he] = !0, this._error = null, this._promiseId = 0, this._deps = new be(), this._asyncRetryCount = 0, this._lastDriftEpoch = c.UNINITIALIZED, this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = Te | k | O, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : S, this._onError = t.onError ?? null, this._maxAsyncRetries = (t.maxAsyncRetries ?? s.MAX_ASYNC_RETRIES) & l, C.attachDebugInfo(this, "computed", this.id), t.lazy === !1) try {
690
+ if (super(), this[me] = !0, this[he] = !0, this._error = null, this._promiseId = 0, this._deps = new ye(), this._asyncRetryCount = 0, this._lastDriftEpoch = c.UNINITIALIZED, this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = Te | A | k, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : S, this._onError = t.onError ?? null, this._maxAsyncRetries = (t.maxAsyncRetries ?? s.MAX_ASYNC_RETRIES) & l, C.attachDebugInfo(this, "computed", this.id), t.lazy === !1) try {
711
691
  this._recompute();
712
692
  } catch {}
713
693
  }
@@ -717,19 +697,19 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
717
697
  get value() {
718
698
  this._track();
719
699
  let e = this.flags;
720
- if ((e & (j | k | O)) === j) return this._value;
700
+ if ((e & (M | A | k)) === M) return this._value;
721
701
  if (e & we) throw new h(v.COMPUTED_DISPOSED);
722
- if (e & P) {
702
+ if (e & Ce) {
723
703
  if (this._defaultValue !== S) return this._defaultValue;
724
704
  throw new h(v.COMPUTED_CIRCULAR_DEPENDENCY);
725
705
  }
726
- if (e & (k | O) && ((e & O) === 0 && (e & Ee) === 0 && this._deps.size > 0 && !this._isDirty() ? this.flags &= ~k : this._recompute(), this.flags & j)) return this._value;
706
+ if (e & (A | k) && ((e & k) === 0 && (e & Ee) === 0 && this._deps.size > 0 && !this._isDirty() ? this.flags &= ~A : this._recompute(), this.flags & M)) return this._value;
727
707
  let t = this._defaultValue, n = t !== S;
728
- if (this.flags & A) {
708
+ if (this.flags & j) {
729
709
  if (n) return t;
730
710
  throw new h(v.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
731
711
  }
732
- if (this.flags & M) {
712
+ if (this.flags & N) {
733
713
  if (n) return t;
734
714
  throw this._error;
735
715
  }
@@ -741,16 +721,16 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
741
721
  get state() {
742
722
  this._track();
743
723
  let e = this.flags;
744
- return e & j ? t.RESOLVED : e & A ? t.PENDING : e & M ? t.REJECTED : t.IDLE;
724
+ return e & M ? t.RESOLVED : e & j ? t.PENDING : e & N ? t.REJECTED : t.IDLE;
745
725
  }
746
726
  get hasError() {
747
- if (this._track(), this.flags & (M | N)) return !0;
727
+ if (this._track(), this.flags & (N | P)) return !0;
748
728
  let e = this._deps;
749
729
  if (!e.hasComputeds) return !1;
750
730
  let t = e.size;
751
731
  for (let n = 0; n < t; n++) {
752
732
  let t = e.getAt(n);
753
- if (t != null && t.node.flags & N) return !0;
733
+ if (t != null && t.node.flags & P) return !0;
754
734
  }
755
735
  return !1;
756
736
  }
@@ -768,7 +748,7 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
768
748
  let n = t.getAt(r);
769
749
  if (n == null) continue;
770
750
  let i = n.node;
771
- i.flags & N && this._collectErrorsFromDep(i, e);
751
+ i.flags & P && this._collectErrorsFromDep(i, e);
772
752
  }
773
753
  return e.length === 0 ? d : Object.freeze(e);
774
754
  }
@@ -783,16 +763,16 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
783
763
  return this._track(), this._error;
784
764
  }
785
765
  get isPending() {
786
- return this._track(), (this.flags & A) !== 0;
766
+ return this._track(), (this.flags & j) !== 0;
787
767
  }
788
768
  get isResolved() {
789
- return this._track(), (this.flags & j) !== 0;
769
+ return this._track(), (this.flags & M) !== 0;
790
770
  }
791
771
  invalidate() {
792
772
  this.flags |= Ee, this._markDirty();
793
773
  }
794
774
  dispose() {
795
- this.flags & we || (this._deps.disposeAll(), this._slots?.clear(), this.flags = we | k | O, this._error = null, this._value = void 0, this._hotIndex = -1);
775
+ this.flags & we || (this._deps.disposeAll(), this._slots?.clear(), this.flags = we | A | k, this._error = null, this._value = void 0, this._hotIndex = -1);
796
776
  }
797
777
  [Symbol.dispose]() {
798
778
  this.dispose();
@@ -809,23 +789,23 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
809
789
  e.flags & Te && (this._deps.hasComputeds = !0), this._trackCount = t + 1;
810
790
  }
811
791
  _recompute() {
812
- if (this.flags & P) return;
813
- this.flags = (this.flags | P) & ~Ee, this._trackEpoch = ie(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
792
+ if (this.flags & Ce) return;
793
+ this.flags = (this.flags | Ce) & ~Ee, this._trackEpoch = ie(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
814
794
  let e = !1;
815
795
  try {
816
796
  let t = E.run(this, this._fn);
817
- this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0, Ce(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
797
+ this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0, Se(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
818
798
  } catch (t) {
819
799
  if (!e) try {
820
800
  this._deps.truncateFrom(this._trackCount);
821
801
  } catch {}
822
802
  this._handleError(t, v.COMPUTED_COMPUTATION_FAILED, !0);
823
803
  } finally {
824
- this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~P;
804
+ this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~Ce;
825
805
  }
826
806
  }
827
807
  _handleAsyncComputation(e) {
828
- this.flags = (this.flags | A) & ~(O | k | j | M), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % s.MAX_PROMISE_ID;
808
+ this.flags = (this.flags | j) & ~(k | A | M | N), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % s.MAX_PROMISE_ID;
829
809
  let t = this._promiseId;
830
810
  e.then((e) => {
831
811
  if (t === this._promiseId) {
@@ -839,7 +819,7 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
839
819
  }
840
820
  _handleError(e, t, n = !1) {
841
821
  let r = w(e, h, t);
842
- if (!n && !(this.flags & M) && (this.version = ae(this.version)), this._error = r, this.flags = this.flags & ~(O | k | A | j) | M | N, this._onError) try {
822
+ if (!n && !(this.flags & N) && (this.version = ae(this.version)), this._error = r, this.flags = this.flags & ~(k | A | j | M) | N | P, this._onError) try {
843
823
  this._onError(r);
844
824
  } catch (e) {
845
825
  console.error(v.CALLBACK_ERROR_IN_ERROR_HANDLER, e);
@@ -848,13 +828,13 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
848
828
  this._notifySubscribers(void 0, void 0);
849
829
  }
850
830
  _finalizeResolution(e) {
851
- (!(this.flags & j) || !this._equal(this._value, e)) && (this.version = ae(this.version)), this._value = e, this._error = null, this.flags = (this.flags | j) & ~(O | k | A | M | N);
831
+ (!(this.flags & M) || !this._equal(this._value, e)) && (this.version = ae(this.version)), this._value = e, this._error = null, this.flags = (this.flags | M) & ~(k | A | j | N | P);
852
832
  }
853
833
  execute() {
854
834
  this._markDirty();
855
835
  }
856
836
  _markDirty() {
857
- this.flags & (P | k) || (this.flags |= k, this._notifySubscribers(void 0, void 0));
837
+ this.flags & (Ce | A) || (this.flags |= A, this._notifySubscribers(void 0, void 0));
858
838
  }
859
839
  _isDirty() {
860
840
  let e = this._deps;
@@ -885,7 +865,7 @@ function F(e, t = {}) {
885
865
  }
886
866
  var Oe = class extends ne {
887
867
  constructor(e, t = {}) {
888
- super(), this[ge] = !0, this._cleanup = null, this._deps = new be(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? a.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? a.MAX_EXECUTIONS_PER_EFFECT, this._cleanup = null, this._deps = new be(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => T.schedule(this), C.attachDebugInfo(this, "effect", this.id);
868
+ super(), this[ge] = !0, this._cleanup = null, this._deps = new ye(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? a.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? a.MAX_EXECUTIONS_PER_EFFECT, this._cleanup = null, this._deps = new ye(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => T.schedule(this), C.attachDebugInfo(this, "effect", this.id);
889
869
  }
890
870
  run() {
891
871
  if (this.flags & n.DISPOSED) throw new g(v.EFFECT_DISPOSED);
@@ -927,7 +907,7 @@ var Oe = class extends ne {
927
907
  let r = !1;
928
908
  try {
929
909
  let e = E.run(this, this._fn);
930
- t.truncateFrom(this._trackCount), t.seal(), r = !0, Ce(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
910
+ t.truncateFrom(this._trackCount), t.seal(), r = !0, Se(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
931
911
  } catch (e) {
932
912
  if (!r) try {
933
913
  t.truncateFrom(this._trackCount);
@@ -1042,7 +1022,7 @@ function ke(e) {
1042
1022
  //#endregion
1043
1023
  //#region src/utils/index.ts
1044
1024
  function L(e) {
1045
- return xe(e);
1025
+ return be(e);
1046
1026
  }
1047
1027
  function Ae(e) {
1048
1028
  return !!e && typeof e.then == "function";
@@ -1154,7 +1134,7 @@ var Re = Le(), U = {
1154
1134
  domUpdated(e, t, n, r) {
1155
1135
  if (!this.enabled) return;
1156
1136
  let i = t instanceof Element ? t : t[0];
1157
- i && (console.log(`${e} DOM updated: ${R(i)}.${n} =`, r), We(i));
1137
+ i && (console.log(`${e} DOM updated: ${R(i)}.${n} =`, r), Ge(i));
1158
1138
  },
1159
1139
  cleanup(e, t) {
1160
1140
  this.enabled && console.log(`${e} Cleanup: ${t}`);
@@ -1165,33 +1145,94 @@ var Re = Le(), U = {
1165
1145
  error(e, t, n) {
1166
1146
  console.error(`${e} ${t}`, n);
1167
1147
  }
1168
- }, ze = "atom-debug-highlight", Be = "data-atom-debug", W;
1169
- function Ve() {
1170
- if ((W instanceof HTMLStyleElement ? W : W?.deref())?.isConnected || document.querySelector(`style[${Be}]`)) return;
1148
+ }, ze = "atom-debug-highlight", Be = "data-atom-debug", Ve;
1149
+ function He() {
1150
+ if ((Ve instanceof HTMLStyleElement ? Ve : Ve?.deref())?.isConnected || document.querySelector(`style[${Be}]`)) return;
1171
1151
  let e = document.createElement("style");
1172
- e.setAttribute(Be, ""), e.textContent = `.${ze}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Ie} ease-out}`, document.head.appendChild(e), W = typeof WeakRef < "u" ? new WeakRef(e) : e;
1152
+ e.setAttribute(Be, ""), e.textContent = `.${ze}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Ie} ease-out}`, document.head.appendChild(e), Ve = typeof WeakRef < "u" ? new WeakRef(e) : e;
1173
1153
  }
1174
- var He = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap();
1175
- function We(e) {
1154
+ var Ue = /* @__PURE__ */ new WeakMap(), We = /* @__PURE__ */ new WeakMap();
1155
+ function Ge(e) {
1176
1156
  if (!U.enabled || !e.isConnected) return;
1177
- Ve();
1178
- let t = Ue.get(e);
1157
+ He();
1158
+ let t = We.get(e);
1179
1159
  t !== void 0 && cancelAnimationFrame(t);
1180
- let n = He.get(e);
1160
+ let n = Ue.get(e);
1181
1161
  n !== void 0 && clearTimeout(n);
1182
1162
  let r = requestAnimationFrame(() => {
1183
- Ue.delete(e), e.isConnected && (e.classList.add(ze), He.set(e, setTimeout(() => {
1184
- e.isConnected && e.classList.remove(ze), He.delete(e);
1163
+ We.delete(e), e.isConnected && (e.classList.add(ze), Ue.set(e, setTimeout(() => {
1164
+ e.isConnected && e.classList.remove(ze), Ue.delete(e);
1185
1165
  }, Ne.HIGHLIGHT_DURATION_MS)));
1186
1166
  });
1187
- Ue.set(e, r);
1167
+ We.set(e, r);
1168
+ }
1169
+ //#endregion
1170
+ //#region src/core/lens.ts
1171
+ var Ke = Symbol.for("atom-effect/atom"), qe = Symbol.for("atom-effect/writable");
1172
+ function Je(e, t, n, r) {
1173
+ if (n === t.length) return r;
1174
+ let i = t[n], a = e && typeof e == "object" ? e : {}, o = a[i], s = Je(o, t, n + 1, r);
1175
+ if (Object.is(o, s)) return e;
1176
+ if (Array.isArray(a)) {
1177
+ let e = [...a], t = Number.parseInt(i, 10);
1178
+ return Number.isNaN(t) ? e[i] = s : e[t] = s, e;
1179
+ }
1180
+ return {
1181
+ ...a,
1182
+ [i]: s
1183
+ };
1184
+ }
1185
+ function W(e, t) {
1186
+ let n = e;
1187
+ for (let e = 0, r = t.length; e < r && n != null; e++) n = n[t[e]];
1188
+ return n;
1189
+ }
1190
+ function Ye(e, t) {
1191
+ let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set(), i = () => {
1192
+ for (let e of r) e();
1193
+ r.clear();
1194
+ };
1195
+ return {
1196
+ get value() {
1197
+ return W(e.value, n);
1198
+ },
1199
+ set value(t) {
1200
+ let r = e.peek(), i = Je(r, n, 0, t);
1201
+ i !== r && (e.value = i);
1202
+ },
1203
+ peek() {
1204
+ return W(e.peek(), n);
1205
+ },
1206
+ subscribe(t) {
1207
+ let i = e.subscribe((e, r) => {
1208
+ let i = W(e, n), a = W(r, n);
1209
+ Object.is(i, a) || t(i, a);
1210
+ });
1211
+ return r.add(i), () => {
1212
+ i(), r.delete(i);
1213
+ };
1214
+ },
1215
+ subscriberCount() {
1216
+ return r.size;
1217
+ },
1218
+ dispose: i,
1219
+ [Symbol.dispose]: i,
1220
+ [Ke]: !0,
1221
+ [qe]: !0
1222
+ };
1223
+ }
1224
+ function Xe(e, t) {
1225
+ return Ye(e, t);
1226
+ }
1227
+ function Ze(e) {
1228
+ return (t) => Ye(e, t);
1188
1229
  }
1189
1230
  //#endregion
1190
1231
  //#region src/core/namespace.ts
1191
- function Ge(e, t) {
1192
- return ye(e, t);
1232
+ function Qe(e, t) {
1233
+ return O(e, t);
1193
1234
  }
1194
- Object.defineProperty(Ge, "debug", {
1235
+ Object.defineProperty(Qe, "debug", {
1195
1236
  enumerable: !0,
1196
1237
  configurable: !0,
1197
1238
  get() {
@@ -1201,24 +1242,27 @@ Object.defineProperty(Ge, "debug", {
1201
1242
  U.enabled = e;
1202
1243
  }
1203
1244
  });
1204
- function Ke() {
1245
+ function $e() {
1205
1246
  return new Promise((e) => setTimeout(e, 0));
1206
1247
  }
1207
- var qe = {
1208
- atom: Ge,
1248
+ var et = {
1249
+ atom: Qe,
1209
1250
  computed: F,
1210
1251
  effect: I,
1211
1252
  batch: ke,
1212
1253
  untracked: D,
1213
- isAtom: xe,
1214
- isComputed: Se,
1254
+ isAtom: be,
1255
+ isComputed: xe,
1215
1256
  isReactive: L,
1216
- nextTick: Ke
1257
+ nextTick: $e,
1258
+ atomLens: Ye,
1259
+ composeLens: Xe,
1260
+ lensFor: Ze
1217
1261
  };
1218
- e.extend(qe);
1262
+ e.extend(et);
1219
1263
  //#endregion
1220
1264
  //#region src/utils/array-pool.ts
1221
- var Je = class {
1265
+ var tt = class {
1222
1266
  constructor(e = 50, t = 256) {
1223
1267
  this.limit = e, this.capacity = t, this.pool = [];
1224
1268
  }
@@ -1231,7 +1275,7 @@ var Je = class {
1231
1275
  reset() {
1232
1276
  this.pool.length = 0;
1233
1277
  }
1234
- }, Ye = class {
1278
+ }, nt = class {
1235
1279
  constructor(e, t, n = 64) {
1236
1280
  this.factory = e, this.reset = t, this.limit = n, this.pool = [];
1237
1281
  }
@@ -1247,7 +1291,7 @@ var Je = class {
1247
1291
  get size() {
1248
1292
  return this.pool.length;
1249
1293
  }
1250
- }, Xe = new Je(), Ze = new Je(), Qe = new Ye(() => ({
1294
+ }, rt = new tt(), it = new tt(), at = new nt(() => ({
1251
1295
  effects: void 0,
1252
1296
  cleanups: void 0,
1253
1297
  componentCleanup: void 0
@@ -1271,15 +1315,15 @@ var Je = class {
1271
1315
  }
1272
1316
  getOrCreateRecord(e) {
1273
1317
  let t = this.records.get(e);
1274
- return t || (t = Qe.acquire(), this.records.set(e, t), e.classList.add(G)), t;
1318
+ return t || (t = at.acquire(), this.records.set(e, t), e.classList.add(G)), t;
1275
1319
  }
1276
1320
  trackEffect(e, t) {
1277
1321
  let n = this.getOrCreateRecord(e);
1278
- n.effects ??= Xe.acquire(), n.effects.push(t);
1322
+ n.effects ??= rt.acquire(), n.effects.push(t);
1279
1323
  }
1280
1324
  trackCleanup(e, t) {
1281
1325
  let n = this.getOrCreateRecord(e);
1282
- n.cleanups ??= Ze.acquire(), n.cleanups.push(t);
1326
+ n.cleanups ??= it.acquire(), n.cleanups.push(t);
1283
1327
  }
1284
1328
  setComponentCleanup(e, t) {
1285
1329
  let n = this.getOrCreateRecord(e);
@@ -1312,7 +1356,7 @@ var Je = class {
1312
1356
  let n = e.nodeType === 1 ? R(e) : "Node";
1313
1357
  U.error(B.BINDING, H.CORE.EFFECT_DISPOSE_ERROR(n), t);
1314
1358
  }
1315
- Xe.release(n), t.effects = void 0;
1359
+ rt.release(n), t.effects = void 0;
1316
1360
  }
1317
1361
  if (t.cleanups) {
1318
1362
  let n = t.cleanups;
@@ -1322,9 +1366,9 @@ var Je = class {
1322
1366
  let n = e.nodeType === 1 ? R(e) : "Node";
1323
1367
  U.error(B.BINDING, H.BINDING.CLEANUP_ERROR(n), t);
1324
1368
  }
1325
- Ze.release(n), t.cleanups = void 0;
1369
+ it.release(n), t.cleanups = void 0;
1326
1370
  }
1327
- Qe.release(t);
1371
+ at.release(t);
1328
1372
  }
1329
1373
  cleanupDescendants(e) {
1330
1374
  let t = "getElementsByClassName" in e && typeof e.getElementsByClassName == "function" ? e.getElementsByClassName(G) : e.querySelectorAll(`.${G}`);
@@ -1336,9 +1380,9 @@ var Je = class {
1336
1380
  cleanupTree(e) {
1337
1381
  (e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
1338
1382
  }
1339
- }(), $e = /* @__PURE__ */ new Map();
1340
- function et(e) {
1341
- if ($e.has(e)) return;
1383
+ }(), ot = /* @__PURE__ */ new Map();
1384
+ function st(e) {
1385
+ if (ot.has(e)) return;
1342
1386
  let t = new MutationObserver((e) => {
1343
1387
  for (let t = 0, n = e.length; t < n; t++) {
1344
1388
  let n = e[t].removedNodes;
@@ -1351,37 +1395,37 @@ function et(e) {
1351
1395
  t.observe(e, {
1352
1396
  childList: !0,
1353
1397
  subtree: !0
1354
- }), $e.set(e, t);
1398
+ }), ot.set(e, t);
1355
1399
  }
1356
- function tt() {
1357
- $e.forEach((e) => e.disconnect()), $e.clear();
1400
+ function ct() {
1401
+ ot.forEach((e) => e.disconnect()), ot.clear();
1358
1402
  }
1359
1403
  //#endregion
1360
1404
  //#region src/core/jquery-patch.ts
1361
- var nt = Symbol("atom-effect-internal"), rt = /* @__PURE__ */ new WeakMap(), q = null, it = (e) => {
1362
- if (e[nt]) return e;
1363
- let t = rt.get(e);
1405
+ var lt = Symbol("atom-effect-internal"), ut = /* @__PURE__ */ new WeakMap(), q = null, dt = (e) => {
1406
+ if (e[lt]) return e;
1407
+ let t = ut.get(e);
1364
1408
  return t || (t = function(...t) {
1365
1409
  return ke(() => e.apply(this, t));
1366
- }, t[nt] = !0, rt.set(e, t)), t;
1410
+ }, t[lt] = !0, ut.set(e, t)), t;
1367
1411
  };
1368
- function at(e) {
1412
+ function ft(e) {
1369
1413
  let t = {}, n = Object.entries(e);
1370
1414
  for (let e = 0, r = n.length; e < r; e++) {
1371
1415
  let r = n[e], i = r[0], a = r[1];
1372
- a && (t[i] = it(a));
1416
+ a && (t[i] = dt(a));
1373
1417
  }
1374
1418
  return t;
1375
1419
  }
1376
- function ot(e) {
1420
+ function pt(e) {
1377
1421
  let t = {}, n = Object.entries(e);
1378
1422
  for (let e = 0, r = n.length; e < r; e++) {
1379
1423
  let r = n[e], i = r[0], a = r[1];
1380
- t[i] = a ? rt.get(a) ?? a : void 0;
1424
+ t[i] = a ? ut.get(a) ?? a : void 0;
1381
1425
  }
1382
1426
  return t;
1383
1427
  }
1384
- function st() {
1428
+ function mt() {
1385
1429
  if (q !== null) return;
1386
1430
  q = {
1387
1431
  on: e.fn.on,
@@ -1416,39 +1460,39 @@ function st() {
1416
1460
  return r === void 0 ? this : r;
1417
1461
  }, e.fn.on = function(...e) {
1418
1462
  let n = e[0];
1419
- if (n && typeof n == "object") e[0] = at(n);
1463
+ if (n && typeof n == "object") e[0] = ft(n);
1420
1464
  else {
1421
1465
  let t = e.length - 1;
1422
- t >= 0 && typeof e[t] == "function" && (e[t] = it(e[t]));
1466
+ t >= 0 && typeof e[t] == "function" && (e[t] = dt(e[t]));
1423
1467
  }
1424
1468
  let r = t.on.apply(this, e);
1425
1469
  return r === void 0 ? this : r;
1426
1470
  }, e.fn.off = function(...e) {
1427
1471
  let n = e[0];
1428
- if (n && typeof n == "object") e[0] = ot(n);
1472
+ if (n && typeof n == "object") e[0] = pt(n);
1429
1473
  else {
1430
1474
  let t = e.length - 1;
1431
1475
  if (t >= 0 && typeof e[t] == "function") {
1432
1476
  let n = e[t];
1433
- e[t] = rt.get(n) ?? n;
1477
+ e[t] = ut.get(n) ?? n;
1434
1478
  }
1435
1479
  }
1436
1480
  let r = t.off.apply(this, e);
1437
1481
  return r === void 0 ? this : r;
1438
1482
  };
1439
1483
  }
1440
- function ct() {
1484
+ function ht() {
1441
1485
  q !== null && (e.fn.on = q.on, e.fn.off = q.off, e.fn.remove = q.remove, e.fn.empty = q.empty, e.fn.detach = q.detach, q = null);
1442
1486
  }
1443
1487
  //#endregion
1444
1488
  //#region src/types.ts
1445
1489
  var J = /* @__PURE__ */ function(e) {
1446
1490
  return e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e;
1447
- }({}), lt = 0;
1491
+ }({}), gt = 0;
1448
1492
  function Y(e) {
1449
- e[nt] = !0;
1493
+ e[lt] = !0;
1450
1494
  }
1451
- var ut = class {
1495
+ var _t = class {
1452
1496
  constructor(e, t, n) {
1453
1497
  this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
1454
1498
  this.flags |= J.Composing;
@@ -1489,7 +1533,7 @@ var ut = class {
1489
1533
  });
1490
1534
  }, this.cleanup = () => {
1491
1535
  this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
1492
- }, this.$el = e, this.el = e[0], this.atom = t, this.isMultipleSelect = this.el.tagName === "SELECT" && this.el.multiple, this.ns = `.atomBind-${++lt}`;
1536
+ }, this.$el = e, this.el = e[0], this.atom = t, this.isMultipleSelect = this.el.tagName === "SELECT" && this.el.multiple, this.ns = `.atomBind-${++gt}`;
1493
1537
  let r = n.debounce ?? 0, i = n.event ?? Me.EVENT;
1494
1538
  this.parse = n.parse ?? ((e) => e), this.format = n.format ?? ((e) => this.isMultipleSelect ? (Array.isArray(e) ? e : e ? [String(e)] : []).join(",") : String(e ?? ""));
1495
1539
  let a = n.equal ?? Object.is;
@@ -1529,8 +1573,8 @@ var ut = class {
1529
1573
  this.$el.on(`focus${t}`, this.handleFocus).on(`blur${t}`, this.handleBlur).on(`compositionstart${t}`, this.handleCompositionStart).on(`compositionend${t}`, this.handleCompositionEnd).on(n, this.handleInput);
1530
1574
  }
1531
1575
  };
1532
- function dt(e, t, n) {
1533
- let r = new ut(e, t, n);
1576
+ function vt(e, t, n) {
1577
+ let r = new _t(e, t, n);
1534
1578
  return {
1535
1579
  fx: I(r.syncDomFromAtom),
1536
1580
  cleanup: r.cleanup
@@ -1538,7 +1582,7 @@ function dt(e, t, n) {
1538
1582
  }
1539
1583
  //#endregion
1540
1584
  //#region src/core/effect-factory.ts
1541
- function ft(e, t, n, r) {
1585
+ function yt(e, t, n, r) {
1542
1586
  let i = null, a = (t) => {
1543
1587
  if (Ae(t)) {
1544
1588
  let a = t;
@@ -1570,7 +1614,7 @@ function ft(e, t, n, r) {
1570
1614
  D(() => a(e));
1571
1615
  }, { name: r })) : D(() => a(t));
1572
1616
  }
1573
- function pt(e, t, n, r) {
1617
+ function bt(e, t, n, r) {
1574
1618
  let i = Object.keys(t), a = [], o = {};
1575
1619
  for (let e = 0; e < i.length; e++) {
1576
1620
  let n = i[e], r = t[n];
@@ -1622,7 +1666,7 @@ function pt(e, t, n, r) {
1622
1666
  }
1623
1667
  //#endregion
1624
1668
  //#region src/utils/sanitize.ts
1625
- var mt = new Set([
1669
+ var xt = new Set([
1626
1670
  "href",
1627
1671
  "src",
1628
1672
  "action",
@@ -1637,85 +1681,85 @@ var mt = new Set([
1637
1681
  "usemap",
1638
1682
  "classid",
1639
1683
  "codebase"
1640
- ]), ht = /^\s*(?:javascript|vbscript)\s*:/i, gt = /(?:expression\s*\(|behavior\s*:|-moz-binding\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t|d\s*a\s*t\s*a)\s*:(?!image\/))/i, _t = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, vt = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, yt = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, bt = {
1684
+ ]), St = /^\s*(?:javascript|vbscript)\s*:/i, Ct = /(?:expression\s*\(|behavior\s*:|-moz-binding\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t|d\s*a\s*t\s*a)\s*:(?!image\/))/i, wt = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, Tt = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, Et = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, Dt = {
1641
1685
  colon: ":",
1642
1686
  Tab: " ",
1643
1687
  NewLine: "\n"
1644
- }, xt = /&(colon|Tab|NewLine);/g, St = /<\?[\s\S]*?\?>/g, Ct = /(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi, wt = /(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi, Tt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Et = /\bon\w+\s*=/gim, Dt = new RegExp(gt.source, "gim");
1688
+ }, Ot = /&(colon|Tab|NewLine);/g, kt = /<\?[\s\S]*?\?>/g, At = /(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi, jt = /(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi, Mt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Nt = /\bon\w+\s*=/gim, Pt = new RegExp(Ct.source, "gim");
1645
1689
  function X(e) {
1646
1690
  let t = String(e ?? "");
1647
- t = t.replace(vt, ""), t = t.replace(yt, (e, t, n) => String.fromCodePoint(t ? parseInt(t, 16) : parseInt(n, 10))), t = t.replace(xt, (e, t) => bt[t] ?? ""), t = t.replace(St, "");
1691
+ t = t.replace(Tt, ""), t = t.replace(Et, (e, t, n) => String.fromCodePoint(t ? parseInt(t, 16) : parseInt(n, 10))), t = t.replace(Ot, (e, t) => Dt[t] ?? ""), t = t.replace(kt, "");
1648
1692
  let n;
1649
1693
  do
1650
- n = t, t = t.replace(Ct, "");
1694
+ n = t, t = t.replace(At, "");
1651
1695
  while (t !== n);
1652
- return t = t.replace(wt, "data-unsafe-protocol:"), t = t.replace(Tt, "data-unsafe-protocol:"), t = t.replace(Et, "data-unsafe-attr="), t = t.replace(Dt, "data-unsafe-css:"), t;
1696
+ return t = t.replace(jt, "data-unsafe-protocol:"), t = t.replace(Mt, "data-unsafe-protocol:"), t = t.replace(Nt, "data-unsafe-attr="), t = t.replace(Pt, "data-unsafe-css:"), t;
1653
1697
  }
1654
- function Ot(e) {
1655
- return e.toLowerCase().includes("url(") ? _t.test(e) : !1;
1698
+ function Ft(e) {
1699
+ return e.toLowerCase().includes("url(") ? wt.test(e) : !1;
1656
1700
  }
1657
1701
  //#endregion
1658
1702
  //#region src/bindings/unified.ts
1659
- var kt = /* @__PURE__ */ new Map();
1660
- function At(e) {
1661
- let t = kt.get(e);
1662
- return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, kt.set(e, t), t) : t;
1703
+ var It = /* @__PURE__ */ new Map();
1704
+ function Lt(e) {
1705
+ let t = It.get(e);
1706
+ return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, It.set(e, t), t) : t;
1663
1707
  }
1664
- var jt = /* @__PURE__ */ new WeakMap();
1665
- function Mt(e) {
1666
- let t = jt.get(e);
1708
+ var Rt = /* @__PURE__ */ new WeakMap();
1709
+ function zt(e) {
1710
+ let t = Rt.get(e);
1667
1711
  return t || (t = F(() => {
1668
1712
  let t = e.value;
1669
1713
  return Ae(t) ? t.then((e) => X(e)) : X(t);
1670
- }), jt.set(e, t)), t;
1714
+ }), Rt.set(e, t)), t;
1671
1715
  }
1672
- function Nt(e) {
1716
+ function Bt(e) {
1673
1717
  return {
1674
1718
  el: e,
1675
1719
  trackCleanup: (t) => K.trackCleanup(e, t)
1676
1720
  };
1677
1721
  }
1678
- function Pt(e, t, n) {
1722
+ function Vt(e, t, n) {
1679
1723
  let r = e.el;
1680
- ft(r, t, (e) => {
1724
+ yt(r, t, (e) => {
1681
1725
  let t = n ? n(e) : typeof e == "string" ? e : String(e ?? "");
1682
1726
  r.textContent !== t && (r.textContent = t);
1683
1727
  }, "text");
1684
1728
  }
1685
- function Ft(e, t) {
1686
- let n = e.el, r = xe(t) ? Mt(t) : t;
1687
- ft(n, r, (e) => {
1729
+ function Ht(e, t) {
1730
+ let n = e.el, r = be(t) ? zt(t) : t;
1731
+ yt(n, r, (e) => {
1688
1732
  let i = r === t ? X(e) : e;
1689
1733
  n.innerHTML !== i && (K.cleanupDescendants(n), n.innerHTML = i);
1690
1734
  }, "html");
1691
1735
  }
1692
- function It(e, t) {
1736
+ function Ut(e, t) {
1693
1737
  let n = e.el, r = {};
1694
1738
  for (let e in t) z.call(t, e) && (r[e] = e.trim().split(/\s+/).filter(Boolean));
1695
- pt(n, t, (e) => {
1739
+ bt(n, t, (e) => {
1696
1740
  for (let t in e) {
1697
1741
  let i = e[t], a = r[t];
1698
1742
  i ? n.classList.add(...a) : n.classList.remove(...a);
1699
1743
  }
1700
1744
  }, "class");
1701
1745
  }
1702
- function Lt(e, t) {
1746
+ function Wt(e, t) {
1703
1747
  let n = e.el, r = n.style, i = {}, a = {};
1704
1748
  for (let e in t) if (z.call(t, e)) {
1705
1749
  let n = t[e], [r, o] = Array.isArray(n) ? n : [n, ""];
1706
1750
  i[e] = r, a[e] = {
1707
- camel: At(e),
1751
+ camel: Lt(e),
1708
1752
  unit: o
1709
1753
  };
1710
1754
  }
1711
- pt(n, i, (e) => {
1755
+ bt(n, i, (e) => {
1712
1756
  for (let t in e) {
1713
1757
  let n = e[t], { camel: i, unit: o } = a[t], s = o ? String(n) + o : String(n);
1714
- Ot(s) || r[i] !== s && (r[i] = s);
1758
+ Ft(s) || r[i] !== s && (r[i] = s);
1715
1759
  }
1716
1760
  }, "css");
1717
1761
  }
1718
- function Rt(e, t) {
1762
+ function Gt(e, t) {
1719
1763
  let n = e.el, r = {}, i = {};
1720
1764
  for (let e in t) if (z.call(t, e)) {
1721
1765
  let n = e.toLowerCase();
@@ -1725,12 +1769,12 @@ function Rt(e, t) {
1725
1769
  }
1726
1770
  r[e] = t[e], i[e] = {
1727
1771
  isAria: n.startsWith("aria-"),
1728
- isUrl: mt.has(n)
1772
+ isUrl: xt.has(n)
1729
1773
  };
1730
1774
  }
1731
1775
  let a = {};
1732
1776
  for (let e in r) a[e] = n.getAttribute(e);
1733
- pt(n, r, (e) => {
1777
+ bt(n, r, (e) => {
1734
1778
  for (let t in e) {
1735
1779
  let r = e[t], o = i[t], s = o.isAria;
1736
1780
  if (r == null || r === !1 && !s) {
@@ -1738,7 +1782,7 @@ function Rt(e, t) {
1738
1782
  continue;
1739
1783
  }
1740
1784
  let c = r === !0 ? s ? "true" : t : String(r);
1741
- if (o.isUrl && ht.test(c)) {
1785
+ if (o.isUrl && St.test(c)) {
1742
1786
  console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);
1743
1787
  continue;
1744
1788
  }
@@ -1746,7 +1790,7 @@ function Rt(e, t) {
1746
1790
  }
1747
1791
  }, "attr");
1748
1792
  }
1749
- function zt(e, t) {
1793
+ function Kt(e, t) {
1750
1794
  let n = e.el, r = {}, i = {};
1751
1795
  for (let e in t) if (z.call(t, e)) {
1752
1796
  let n = e.toLowerCase();
@@ -1758,12 +1802,12 @@ function zt(e, t) {
1758
1802
  console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROP(e)}`);
1759
1803
  continue;
1760
1804
  }
1761
- r[e] = t[e], i[e] = { isUrl: mt.has(n) };
1805
+ r[e] = t[e], i[e] = { isUrl: xt.has(n) };
1762
1806
  }
1763
- pt(e.el, r, (e) => {
1807
+ bt(e.el, r, (e) => {
1764
1808
  for (let t in e) {
1765
1809
  let r = e[t];
1766
- if (i[t].isUrl && typeof r == "string" && ht.test(r)) {
1810
+ if (i[t].isUrl && typeof r == "string" && St.test(r)) {
1767
1811
  console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);
1768
1812
  continue;
1769
1813
  }
@@ -1771,23 +1815,23 @@ function zt(e, t) {
1771
1815
  }
1772
1816
  }, "prop");
1773
1817
  }
1774
- function Bt(e, t, n) {
1818
+ function qt(e, t, n) {
1775
1819
  let r = e.el, i = n ? "hide" : "show", a = r.style.display, o = a === "none" ? "" : a;
1776
- ft(r, t, (e) => {
1820
+ yt(r, t, (e) => {
1777
1821
  let t = n === !!e ? "none" : o;
1778
1822
  r.style.display !== t && (r.style.display = t);
1779
1823
  }, i);
1780
1824
  }
1781
- function Vt(t, n, r = {}) {
1825
+ function Jt(t, n, r = {}) {
1782
1826
  let i = t.el.tagName.toLowerCase();
1783
1827
  if (!Pe.has(i)) {
1784
1828
  console.warn(`${B.BINDING} ${H.BINDING.INVALID_INPUT_ELEMENT(i)}`);
1785
1829
  return;
1786
1830
  }
1787
- let { fx: a, cleanup: o } = dt(e(t.el), n, r);
1831
+ let { fx: a, cleanup: o } = vt(e(t.el), n, r);
1788
1832
  K.trackEffect(t.el, a), t.trackCleanup(o);
1789
1833
  }
1790
- function Ht(t, n) {
1834
+ function Yt(t, n) {
1791
1835
  let r = t.el, i = e(r), a = r.type === "radio", o = () => {
1792
1836
  let t = r.checked;
1793
1837
  if (n.peek() !== t && (n.value = t, a && t && r.name)) {
@@ -1795,7 +1839,7 @@ function Ht(t, n) {
1795
1839
  (r.form ? e(r.form) : e(document)).find(`input[type="radio"][name="${t}"]`).not(r).trigger("change.atomRadioSync");
1796
1840
  }
1797
1841
  };
1798
- o[nt] = !0, i.on("change change.atomRadioSync", o), t.trackCleanup(() => i.off("change change.atomRadioSync", o));
1842
+ o[lt] = !0, i.on("change change.atomRadioSync", o), t.trackCleanup(() => i.off("change change.atomRadioSync", o));
1799
1843
  let s = I(() => {
1800
1844
  let e = !!n.value;
1801
1845
  D(() => {
@@ -1804,132 +1848,114 @@ function Ht(t, n) {
1804
1848
  });
1805
1849
  K.trackEffect(r, s);
1806
1850
  }
1807
- function Ut(t, n) {
1851
+ function Xt(t, n) {
1808
1852
  let r = e(t.el);
1809
1853
  r.on(n), t.trackCleanup(() => r.off(n));
1810
1854
  }
1811
- function Wt(t, n, r) {
1855
+ function Zt(t, n, r) {
1812
1856
  let i = e(t.el);
1813
1857
  i.on(n, r), t.trackCleanup(() => i.off(n, r));
1814
1858
  }
1815
- function Gt(e) {
1859
+ function Qt(e) {
1816
1860
  K.cleanupTree(e);
1817
1861
  }
1818
1862
  //#endregion
1819
1863
  //#region src/bindings/form.ts
1820
- function Kt(e, t, n, r) {
1821
- if (n === t.length) return r;
1822
- let i = t[n], a = e && typeof e == "object" ? e : {}, o = a[i], s = Kt(o, t, n + 1, r);
1823
- return Object.is(o, s) ? e : {
1824
- ...a,
1825
- [i]: s
1826
- };
1827
- }
1828
- function qt(e, t) {
1829
- let n = Symbol.for("atom-effect/atom"), r = Symbol.for("atom-effect/writable"), i = t.includes(".") ? t.split(".") : [t], a = (e) => {
1830
- let t = e;
1831
- for (let e = 0, n = i.length; e < n && t != null; e++) t = t[i[e]];
1832
- return t;
1833
- };
1834
- return {
1835
- get value() {
1836
- return a(e.value);
1837
- },
1838
- set value(t) {
1839
- let n = e.peek(), r = Kt(n, i, 0, t);
1840
- r !== n && (e.value = r);
1841
- },
1842
- peek() {
1843
- return a(e.peek());
1844
- },
1845
- subscribe(t) {
1846
- return e.subscribe(t);
1847
- },
1848
- subscriberCount() {
1849
- return e.subscriberCount();
1850
- },
1851
- dispose() {},
1852
- [Symbol.dispose]() {},
1853
- [n]: !0,
1854
- [r]: !0
1855
- };
1856
- }
1857
- function Jt(e, t, n = {}) {
1858
- let r = e.elements, i = (e) => {
1864
+ function $t(e, t, n = {}) {
1865
+ let r = e.elements, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = I(() => {
1866
+ let e = t.value;
1867
+ D(() => {
1868
+ for (let [t, n] of i) {
1869
+ let r = W(e, a.get(t));
1870
+ Object.is(n.peek(), r) || (n.value = r);
1871
+ }
1872
+ });
1873
+ });
1874
+ K.trackEffect(e, o);
1875
+ let s = (n) => {
1876
+ let r = i.get(n);
1877
+ if (!r) {
1878
+ let o = n.includes(".") ? n.split(".") : [n];
1879
+ a.set(n, o), r = O(W(t.peek(), o));
1880
+ let s = I(() => {
1881
+ let e = r.value, n = t.peek(), i = Je(n, o, 0, e);
1882
+ i !== n && (t.value = i);
1883
+ });
1884
+ K.trackEffect(e, s), i.set(n, r);
1885
+ }
1886
+ return r;
1887
+ }, c = (e) => {
1859
1888
  if (!(e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)) return;
1860
- let r = e.name;
1861
- if (!r || K.hasBind(e)) return;
1862
- let i = qt(t, r), a = Nt(e);
1863
- e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? Ht(a, i) : Vt(a, i, n);
1889
+ let t = e.name;
1890
+ if (!t || K.hasBind(e)) return;
1891
+ let r = s(t), i = Bt(e);
1892
+ e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? Yt(i, r) : Jt(i, r, n);
1864
1893
  };
1865
- for (let e = 0, t = r.length; e < t; e++) i(r[e]);
1866
- let a = new MutationObserver((e) => {
1894
+ for (let e = 0, t = r.length; e < t; e++) c(r[e]);
1895
+ let l = new MutationObserver((e) => {
1867
1896
  for (let t = 0, n = e.length; t < n; t++) {
1868
1897
  let n = e[t];
1869
1898
  if (n.type === "childList") {
1870
1899
  let e = n.addedNodes;
1871
- for (let t = 0, n = e.length; t < n; t++) {
1900
+ for (let t = 0, n = e.length; t < n; t++) if (e[t].nodeType === 1) {
1872
1901
  let n = e[t];
1873
- if (n.nodeType === 1) {
1874
- let e = n;
1875
- i(e);
1876
- let t = e.querySelectorAll("input, select, textarea");
1877
- for (let e = 0, n = t.length; e < n; e++) i(t[e]);
1878
- }
1902
+ c(n);
1903
+ let r = n.querySelectorAll("input, select, textarea");
1904
+ for (let e = 0, t = r.length; e < t; e++) c(r[e]);
1879
1905
  }
1880
- } else n.type === "attributes" && n.attributeName === "name" && i(n.target);
1906
+ } else n.type === "attributes" && n.attributeName === "name" && c(n.target);
1881
1907
  }
1882
1908
  });
1883
- a.observe(e, {
1909
+ l.observe(e, {
1884
1910
  childList: !0,
1885
1911
  subtree: !0,
1886
1912
  attributes: !0,
1887
1913
  attributeFilter: ["name"]
1888
- }), K.trackCleanup(e, () => a.disconnect());
1914
+ }), K.trackCleanup(e, () => l.disconnect());
1889
1915
  }
1890
1916
  //#endregion
1891
1917
  //#region src/bindings/chainable.ts
1892
1918
  function Z(e, t) {
1893
1919
  for (let n = 0, r = e.length; n < r; n++) {
1894
1920
  let r = e[n];
1895
- r.nodeType === 1 ? t(Nt(r), r) : U.enabled && U.log(B.BINDING, `Skipping non-Element node (nodeType=${r.nodeType})`);
1921
+ r.nodeType === 1 ? t(Bt(r), r) : U.enabled && U.log(B.BINDING, `Skipping non-Element node (nodeType=${r.nodeType})`);
1896
1922
  }
1897
1923
  return e;
1898
1924
  }
1899
1925
  e.fn.atomText = function(e, t) {
1900
- return Z(this, (n) => Pt(n, e, t));
1926
+ return Z(this, (n) => Vt(n, e, t));
1901
1927
  }, e.fn.atomHtml = function(e) {
1902
- return Z(this, (t) => Ft(t, e));
1928
+ return Z(this, (t) => Ht(t, e));
1903
1929
  }, e.fn.atomClass = function(e, t) {
1904
1930
  if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_CONDITION("atomClass")}`), this;
1905
1931
  let n = typeof e == "string" ? { [e]: t } : e;
1906
- return Z(this, (e) => It(e, n));
1932
+ return Z(this, (e) => Ut(e, n));
1907
1933
  }, e.fn.atomCss = function(e, t, n) {
1908
1934
  if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_SOURCE("atomCss")}`), this;
1909
1935
  let r = typeof e == "string" ? { [e]: n ? [t, n] : t } : e;
1910
- return Z(this, (e) => Lt(e, r));
1936
+ return Z(this, (e) => Wt(e, r));
1911
1937
  }, e.fn.atomAttr = function(e, t) {
1912
1938
  if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_SOURCE("atomAttr")}`), this;
1913
1939
  let n = typeof e == "string" ? { [e]: t } : e;
1914
- return Z(this, (e) => Rt(e, n));
1940
+ return Z(this, (e) => Gt(e, n));
1915
1941
  }, e.fn.atomProp = function(e, t) {
1916
1942
  if (typeof e == "string" && t === void 0) return console.warn(`${B.BINDING} ${H.BINDING.MISSING_SOURCE("atomProp")}`), this;
1917
1943
  let n = typeof e == "string" ? { [e]: t } : e;
1918
- return Z(this, (e) => zt(e, n));
1944
+ return Z(this, (e) => Kt(e, n));
1919
1945
  }, e.fn.atomShow = function(e) {
1920
- return Z(this, (t) => Bt(t, e, !1));
1946
+ return Z(this, (t) => qt(t, e, !1));
1921
1947
  }, e.fn.atomHide = function(e) {
1922
- return Z(this, (t) => Bt(t, e, !0));
1948
+ return Z(this, (t) => qt(t, e, !0));
1923
1949
  }, e.fn.atomVal = function(e, t = {}) {
1924
- return Z(this, (n) => Vt(n, e, t));
1950
+ return Z(this, (n) => Jt(n, e, t));
1925
1951
  }, e.fn.atomChecked = function(e) {
1926
- return Z(this, (t) => Ht(t, e));
1952
+ return Z(this, (t) => Yt(t, e));
1927
1953
  }, e.fn.atomForm = function(e, t = {}) {
1928
1954
  return Z(this, (n, r) => {
1929
- r instanceof HTMLFormElement && Jt(r, e, t);
1955
+ r instanceof HTMLFormElement && $t(r, e, t);
1930
1956
  });
1931
1957
  }, e.fn.atomOn = function(e, t) {
1932
- return Z(this, (n) => Wt(n, e, t));
1958
+ return Z(this, (n) => Zt(n, e, t));
1933
1959
  }, e.fn.atomBind = function(e) {
1934
1960
  let { text: t, html: n, class: r, css: i, attr: a, prop: o, show: s, hide: c, val: l, checked: u, form: d, on: f } = e, p = l === void 0 ? null : Array.isArray(l) ? {
1935
1961
  atom: l[0],
@@ -1939,25 +1965,25 @@ e.fn.atomText = function(e, t) {
1939
1965
  opts: void 0
1940
1966
  };
1941
1967
  return Z(this, (e) => {
1942
- t !== void 0 && Pt(e, t), n !== void 0 && Ft(e, n), r !== void 0 && It(e, r), i !== void 0 && Lt(e, i), a !== void 0 && Rt(e, a), o !== void 0 && zt(e, o), s !== void 0 && Bt(e, s, !1), c !== void 0 && Bt(e, c, !0), p !== null && Vt(e, p.atom, p.opts), u !== void 0 && Ht(e, u), d !== void 0 && e.el instanceof HTMLFormElement && Jt(e.el, d), f !== void 0 && Ut(e, f);
1968
+ t !== void 0 && Vt(e, t), n !== void 0 && Ht(e, n), r !== void 0 && Ut(e, r), i !== void 0 && Wt(e, i), a !== void 0 && Gt(e, a), o !== void 0 && Kt(e, o), s !== void 0 && qt(e, s, !1), c !== void 0 && qt(e, c, !0), p !== null && Jt(e, p.atom, p.opts), u !== void 0 && Yt(e, u), d !== void 0 && e.el instanceof HTMLFormElement && $t(e.el, d), f !== void 0 && Xt(e, f);
1943
1969
  });
1944
1970
  }, e.fn.atomUnbind = function() {
1945
1971
  for (let e = 0, t = this.length; e < t; e++) {
1946
1972
  let t = this[e];
1947
- t.nodeType === 1 && Gt(t);
1973
+ t.nodeType === 1 && Qt(t);
1948
1974
  }
1949
1975
  return this;
1950
1976
  };
1951
1977
  //#endregion
1952
1978
  //#region src/bindings/list.ts
1953
- var Yt = /* @__PURE__ */ new WeakMap(), Xt = 0, Zt = new Ye(() => /* @__PURE__ */ new Map(), (e) => e.clear()), Qt = new Ye(() => /* @__PURE__ */ new Set(), (e) => e.clear()), Q = new Je(100, 1024);
1954
- function $t(e, t, n) {
1979
+ var en = /* @__PURE__ */ new WeakMap(), tn = 0, nn = new nt(() => /* @__PURE__ */ new Map(), (e) => e.clear()), rn = new nt(() => /* @__PURE__ */ new Set(), (e) => e.clear()), Q = new tt(100, 1024);
1980
+ function an(e, t, n) {
1955
1981
  t?.isConnected ? e.insertBefore(t) : e.appendTo(n);
1956
1982
  }
1957
1983
  function $(t) {
1958
1984
  return t instanceof Element ? e(t) : t;
1959
1985
  }
1960
- var en = class {
1986
+ var on = class {
1961
1987
  constructor(e, t, n) {
1962
1988
  this.$container = e, this.containerSelector = t, this.onRemove = n, this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.removingKeys = /* @__PURE__ */ new Set(), this.$emptyEl = null, this.keyToIndex = /* @__PURE__ */ new Map(), this.statesBuffer = new Uint8Array(256), this.indicesBuffer = new Int32Array(256);
1963
1989
  }
@@ -1988,7 +2014,7 @@ var en = class {
1988
2014
  this.statesBuffer.length < e && (this.statesBuffer = new Uint8Array(Math.max(e, this.statesBuffer.length * 2))), this.indicesBuffer.length < e && (this.indicesBuffer = new Int32Array(Math.max(e, this.indicesBuffer.length * 2)));
1989
2015
  }
1990
2016
  };
1991
- function tn(t, n, r, i) {
2017
+ function sn(t, n, r, i) {
1992
2018
  if (t.$emptyEl && n > 0 && (t.$emptyEl.remove(), t.$emptyEl = null), n !== 0) return;
1993
2019
  let { oldKeys: a, oldNodes: o, onRemove: s } = t;
1994
2020
  if (s) for (let e = 0, n = a.length; e < n; e++) {
@@ -2001,7 +2027,7 @@ function tn(t, n, r, i) {
2001
2027
  }
2002
2028
  i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? X(i) : i).appendTo(r)), Q.release(t.oldKeys), Q.release(t.oldItems), Q.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
2003
2029
  }
2004
- function nn(e, t, n, r, i, a) {
2030
+ function cn(e, t, n, r, i, a) {
2005
2031
  let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1;
2006
2032
  for (; f <= p && f <= m;) {
2007
2033
  let e = t[f], n = r(e, f);
@@ -2017,11 +2043,11 @@ function nn(e, t, n, r, i, a) {
2017
2043
  if (!(a ? a(i, e) : je(i, e))) break;
2018
2044
  u.set(n, m), p--, m--;
2019
2045
  }
2020
- let h = Zt.acquire();
2046
+ let h = nn.acquire();
2021
2047
  for (let e = f; e <= p; e++) h.set(o[e], e);
2022
2048
  let g = Q.acquire();
2023
2049
  g.length = n;
2024
- let _ = Qt.acquire();
2050
+ let _ = rn.acquire();
2025
2051
  e.ensureBuffers(n);
2026
2052
  let v = Q.acquire();
2027
2053
  v.length = n;
@@ -2047,7 +2073,7 @@ function nn(e, t, n, r, i, a) {
2047
2073
  let m = a ? a(p, o) : je(p, o);
2048
2074
  !i && p !== o && !m ? (S.push(d), C.push(o), ee.push(n), b[n] = 2) : b[n] = 0, x[n] = l.has(d) ? -1 : f;
2049
2075
  }
2050
- return Zt.release(h), {
2076
+ return nn.release(h), {
2051
2077
  newKeys: g,
2052
2078
  newKeySet: _,
2053
2079
  newItems: v,
@@ -2062,7 +2088,7 @@ function nn(e, t, n, r, i, a) {
2062
2088
  newEndIndex: m
2063
2089
  };
2064
2090
  }
2065
- function rn(t, n, r) {
2091
+ function ln(t, n, r) {
2066
2092
  let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u = n.render, d = Array(l), f = [], p = 0;
2067
2093
  for (let e = 0; e < l; e++) {
2068
2094
  let t = u(a[e], o[e]);
@@ -2071,7 +2097,7 @@ function rn(t, n, r) {
2071
2097
  let m = null, h = f.length;
2072
2098
  if (h > 0) if (h === 1) m = [X(f[0])];
2073
2099
  else {
2074
- let e = `<template data-atom-sep="${(Xt++).toString(36)}"></template>`;
2100
+ let e = `<template data-atom-sep="${(tn++).toString(36)}"></template>`;
2075
2101
  m = X(f.join(e)).split(e);
2076
2102
  }
2077
2103
  if (r && m && p === l && !n.bind && !n.onAdd && !n.onRemove && !n.events) return m;
@@ -2097,7 +2123,7 @@ function rn(t, n, r) {
2097
2123
  }
2098
2124
  return null;
2099
2125
  }
2100
- function an(e, t) {
2126
+ function un(e, t) {
2101
2127
  let { startIndex: n, oldEndIndex: r, newKeySet: i } = t, { oldKeys: a, oldNodes: o } = e;
2102
2128
  for (let t = n; t <= r; t++) {
2103
2129
  let n = a[t];
@@ -2106,7 +2132,7 @@ function an(e, t) {
2106
2132
  r && e.removeItem(n, $(r));
2107
2133
  }
2108
2134
  }
2109
- function on(t, n, r, i, a, o) {
2135
+ function dn(t, n, r, i, a, o) {
2110
2136
  let { bind: s, update: c, onAdd: l } = a, { newKeys: u, newItems: d, newNodes: f, newStates: p, newIndices: m } = n, h = u.length, g = t.oldKeys.length === 0;
2111
2137
  if (o !== null) {
2112
2138
  r.innerHTML = o.join("");
@@ -2129,7 +2155,7 @@ function on(t, n, r, i, a, o) {
2129
2155
  let e = null, t = 2147483647;
2130
2156
  for (let n = h - 1; n >= 0; n--) {
2131
2157
  let r = m[n], a = f[n];
2132
- r !== -1 && r < t ? t = r : $t($(a), e, i), e = a instanceof Element ? a : a[0] ?? null;
2158
+ r !== -1 && r < t ? t = r : an($(a), e, i), e = a instanceof Element ? a : a[0] ?? null;
2133
2159
  }
2134
2160
  }
2135
2161
  for (let e = 0; e < h; e++) {
@@ -2155,22 +2181,22 @@ e.fn.atomList = function(t, n) {
2155
2181
  for (let r = 0, i = this.length; r < i; r++) {
2156
2182
  let i = this[r], o = e(i);
2157
2183
  o.off(".atomList");
2158
- let p = Yt.get(i);
2184
+ let p = en.get(i);
2159
2185
  p && (p.fx.dispose(), p.ctx.dispose());
2160
- let m = R(i), h = new en(o, m, s), g = I(() => {
2186
+ let m = R(i), h = new on(o, m, s), g = I(() => {
2161
2187
  let e = t.value, r = e.length;
2162
2188
  D(() => {
2163
- if (tn(h, r, o, c), r === 0) return;
2189
+ if (sn(h, r, o, c), r === 0) return;
2164
2190
  U.log(B.LIST, `${m} updating with ${r} items`);
2165
- let t = nn(h, e, r, d, a, u), s = rn(t, n, h.oldKeys.length === 0);
2166
- if (an(h, t), on(h, t, i, o, f, s), l) {
2191
+ let t = cn(h, e, r, d, a, u), s = ln(t, n, h.oldKeys.length === 0);
2192
+ if (un(h, t), dn(h, t, i, o, f, s), l) {
2167
2193
  let { startIndex: e, oldEndIndex: n, newKeySet: r } = t;
2168
2194
  for (let t = e; t <= n; t++) {
2169
2195
  let e = h.oldKeys[t];
2170
2196
  r.has(e) || h.keyToIndex.delete(e);
2171
2197
  }
2172
2198
  }
2173
- Q.release(h.oldKeys), Q.release(h.oldItems), Q.release(h.oldNodes), h.oldKeys = t.newKeys, h.oldItems = t.newItems, h.oldNodes = t.newNodes, Qt.release(t.newKeySet), Q.release(t.trKeys), Q.release(t.trItems), Q.release(t.trIdxs);
2199
+ Q.release(h.oldKeys), Q.release(h.oldItems), Q.release(h.oldNodes), h.oldKeys = t.newKeys, h.oldItems = t.newItems, h.oldNodes = t.newNodes, rn.release(t.newKeySet), Q.release(t.trKeys), Q.release(t.trItems), Q.release(t.trIdxs);
2174
2200
  });
2175
2201
  });
2176
2202
  if (h.fx = g, l) for (let e in l) {
@@ -2190,20 +2216,20 @@ e.fn.atomList = function(t, n) {
2190
2216
  a !== void 0 && t.call(n, h.oldItems[a], a, e);
2191
2217
  });
2192
2218
  }
2193
- K.trackEffect(i, g), Yt.set(i, {
2219
+ K.trackEffect(i, g), en.set(i, {
2194
2220
  fx: g,
2195
2221
  ctx: h
2196
2222
  }), K.trackCleanup(i, () => {
2197
- h.dispose(), Yt.delete(i);
2223
+ h.dispose(), en.delete(i);
2198
2224
  });
2199
2225
  }
2200
2226
  return this;
2201
2227
  };
2202
2228
  //#endregion
2203
2229
  //#region src/bindings/mount.ts
2204
- var sn = Object.freeze({});
2230
+ var fn = Object.freeze({});
2205
2231
  e.fn.atomMount = function(t, n) {
2206
- let r = n ?? sn;
2232
+ let r = n ?? fn;
2207
2233
  for (let n = 0, i = this.length; n < i; n++) {
2208
2234
  let i = this[n];
2209
2235
  if (!i) continue;
@@ -2221,20 +2247,20 @@ e.fn.atomMount = function(t, n) {
2221
2247
  }, e.fn.atomUnmount = function() {
2222
2248
  for (let e = 0, t = this.length; e < t; e++) {
2223
2249
  let t = this[e];
2224
- t && Gt(t);
2250
+ t && Qt(t);
2225
2251
  }
2226
2252
  return this;
2227
2253
  };
2228
2254
  //#endregion
2229
2255
  //#region src/features/route.ts
2230
- function cn(e, t) {
2256
+ function pn(e, t) {
2231
2257
  try {
2232
2258
  return history.pushState(e, "", t), !0;
2233
2259
  } catch (e) {
2234
2260
  return U.warn(B.ROUTE, "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.", e), !1;
2235
2261
  }
2236
2262
  }
2237
- var ln = class {
2263
+ var mn = class {
2238
2264
  constructor(t) {
2239
2265
  this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.routeCleanups = [], this.lastRawQuery = "", this.cachedParams = {}, this.config = {
2240
2266
  ...t,
@@ -2242,7 +2268,7 @@ var ln = class {
2242
2268
  basePath: t.basePath ?? V.basePath,
2243
2269
  autoBindLinks: t.autoBindLinks ?? V.autoBindLinks,
2244
2270
  activeClass: t.activeClass ?? V.activeClass
2245
- }, this.isHistoryMode = this.config.mode === "history", this.$target = e(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.activeClass = this.config.activeClass ?? V.activeClass, this.previousUrl = this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash, this.currentRouteAtom = ye(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = ye(this.getQueryParams()), this.queryParams = F(() => this.queryParamsAtom.value), this.handleUrlChange = this.handleUrlChange.bind(this), this.destroy = this.destroy.bind(this), this.init();
2271
+ }, this.isHistoryMode = this.config.mode === "history", this.$target = e(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.activeClass = this.config.activeClass ?? V.activeClass, this.previousUrl = this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash, this.currentRouteAtom = O(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = O(this.getQueryParams()), this.queryParams = F(() => this.queryParamsAtom.value), this.handleUrlChange = this.handleUrlChange.bind(this), this.destroy = this.destroy.bind(this), this.init();
2246
2272
  }
2247
2273
  init() {
2248
2274
  let e = this.isHistoryMode ? "popstate" : "hashchange";
@@ -2298,14 +2324,14 @@ var ln = class {
2298
2324
  setUrl(e) {
2299
2325
  if (this.isHistoryMode) {
2300
2326
  let t = `${this.normalizedBasePath}/${e}`;
2301
- cn(null, t), this.previousUrl = t;
2327
+ pn(null, t), this.previousUrl = t;
2302
2328
  } else {
2303
2329
  let t = `#${e}`;
2304
2330
  window.location.hash = t, this.previousUrl = t;
2305
2331
  }
2306
2332
  }
2307
2333
  restoreUrl() {
2308
- this.isHistoryMode ? cn(null, this.previousUrl) : window.location.hash = this.previousUrl;
2334
+ this.isHistoryMode ? pn(null, this.previousUrl) : window.location.hash = this.previousUrl;
2309
2335
  }
2310
2336
  getCurrentUrl() {
2311
2337
  return this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash;
@@ -2418,13 +2444,13 @@ var ln = class {
2418
2444
  this.templateCache.clear();
2419
2445
  }
2420
2446
  };
2421
- function un(e) {
2422
- return new ln(e);
2447
+ function hn(e) {
2448
+ return new mn(e);
2423
2449
  }
2424
- e.extend({ route: un });
2450
+ e.extend({ route: hn });
2425
2451
  //#endregion
2426
2452
  //#region src/features/fetch.ts
2427
- var dn = class {
2453
+ var gn = class {
2428
2454
  constructor(e, t) {
2429
2455
  this.abortController = null, this.isStaticUrl = typeof e == "string", this.isStaticUrl ? this.staticUrl = e : this.getUrl = e, typeof t.ajaxOptions == "function" ? (this.ajaxOptionsFn = t.ajaxOptions, this.staticOptions = {}) : this.staticOptions = { ...t.ajaxOptions }, t.method !== void 0 && (this.staticOptions.method = t.method), t.headers !== void 0 && (this.staticOptions.headers = {
2430
2456
  ...this.staticOptions.headers,
@@ -2477,16 +2503,16 @@ var dn = class {
2477
2503
  //#endregion
2478
2504
  //#region src/index.ts
2479
2505
  e.extend({ atomFetch(e, t) {
2480
- let n = new dn(e, t), r = !(t.eager ?? !0), i = F(n.execute, {
2506
+ let n = new gn(e, t), r = !(t.eager ?? !0), i = F(n.execute, {
2481
2507
  defaultValue: t.defaultValue,
2482
2508
  lazy: r
2483
2509
  });
2484
2510
  return Object.assign(i, { abort: () => n.abort() });
2485
2511
  } }), e(() => {
2486
- st(), et(document.body);
2512
+ mt(), st(document.body);
2487
2513
  });
2488
- var fn = e;
2514
+ var _n = e;
2489
2515
  //#endregion
2490
- export { ye as atom, ke as batch, F as computed, fn as default, tt as disableAutoCleanup, ct as disablejQueryOverrides, I as effect, et as enableAutoCleanup, st as enablejQueryOverrides, xe as isAtom, Se as isComputed, L as isReactive, Ke as nextTick, K as registry, D as untracked };
2516
+ export { O as atom, Ye as atomLens, ke as batch, Xe as composeLens, F as computed, _n as default, ct as disableAutoCleanup, ht as disablejQueryOverrides, I as effect, st as enableAutoCleanup, mt as enablejQueryOverrides, be as isAtom, xe as isComputed, L as isReactive, Ze as lensFor, $e as nextTick, K as registry, D as untracked };
2491
2517
 
2492
2518
  //# sourceMappingURL=index.mjs.map