@but212/atom-effect-jquery 0.22.0 → 0.22.2

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
@@ -1,14 +1,14 @@
1
- import c from "jquery";
2
- import { default as qs } from "jquery";
1
+ import l from "jquery";
2
+ import { default as Ys } from "jquery";
3
3
  const ut = {
4
4
  IDLE: "idle",
5
5
  PENDING: "pending",
6
6
  RESOLVED: "resolved",
7
7
  REJECTED: "rejected"
8
- }, L = {
8
+ }, k = {
9
9
  DISPOSED: 1,
10
10
  EXECUTING: 8
11
- }, fe = {
11
+ }, ue = {
12
12
  DISPOSED: 1,
13
13
  /** Marker bit: identifies this node as a computed. */
14
14
  IS_COMPUTED: 2,
@@ -19,7 +19,7 @@ const ut = {
19
19
  REJECTED: 128,
20
20
  RECOMPUTING: 256,
21
21
  HAS_ERROR: 512
22
- }, $ = {
22
+ }, M = {
23
23
  DISPOSED: 1,
24
24
  SYNC: 8,
25
25
  NOTIFICATION_SCHEDULED: 16
@@ -33,84 +33,84 @@ const ut = {
33
33
  MIN_FLUSH_ITERATIONS: 10,
34
34
  // Memory management
35
35
  BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
36
- }, Le = {
36
+ }, ke = {
37
37
  WARN_INFINITE_LOOP: !0
38
- }, te = {
38
+ }, Zt = {
39
39
  MAX_ASYNC_RETRIES: 3,
40
40
  MAX_PROMISE_ID: Number.MAX_SAFE_INTEGER - 1
41
- }, It = 1073741823, we = typeof process < "u" && process.env && !1 || !1, ke = Object.freeze([]);
42
- class tt extends Error {
43
- constructor(t, s = null, n = !0) {
44
- super(t), this.cause = s, this.recoverable = n, this.name = "AtomError";
41
+ }, yt = 1073741823, xe = typeof process < "u" && process.env && !1 || !1, Pe = Object.freeze([]);
42
+ class et extends Error {
43
+ constructor(t, e = null, n = !0) {
44
+ super(t), this.cause = e, this.recoverable = n, this.name = "AtomError";
45
45
  }
46
46
  }
47
- class z extends tt {
48
- constructor(t, s = null) {
49
- super(t, s, !0), this.name = "ComputedError";
47
+ class j extends et {
48
+ constructor(t, e = null) {
49
+ super(t, e, !0), this.name = "ComputedError";
50
50
  }
51
51
  }
52
- class J extends tt {
53
- constructor(t, s = null) {
54
- super(t, s, !1), this.name = "EffectError";
52
+ class Z extends et {
53
+ constructor(t, e = null) {
54
+ super(t, e, !1), this.name = "EffectError";
55
55
  }
56
56
  }
57
- class At extends tt {
58
- constructor(t, s = null) {
59
- super(t, s, !1), this.name = "SchedulerError";
57
+ class Lt extends et {
58
+ constructor(t, e = null) {
59
+ super(t, e, !1), this.name = "SchedulerError";
60
60
  }
61
61
  }
62
- const xe = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Pe = /* @__PURE__ */ Symbol("AtomEffect.Type"), Ut = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), yt = {
62
+ const $e = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Me = /* @__PURE__ */ Symbol("AtomEffect.Type"), Ut = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Ct = {
63
63
  // Dev mode flag
64
- enabled: we,
65
- warnInfiniteLoop: Le.WARN_INFINITE_LOOP,
66
- warn(e, t) {
64
+ enabled: xe,
65
+ warnInfiniteLoop: ke.WARN_INFINITE_LOOP,
66
+ warn(s, t) {
67
67
  },
68
- checkCircular(e, t) {
69
- if (e === t)
70
- throw new z("Direct circular dependency detected");
68
+ checkCircular(s, t) {
69
+ if (s === t)
70
+ throw new j("Direct circular dependency detected");
71
71
  },
72
- attachDebugInfo(e, t, s) {
72
+ attachDebugInfo(s, t, e) {
73
73
  },
74
- getDebugName: (e) => e?.[xe],
75
- getDebugType: (e) => e?.[Pe]
74
+ getDebugName: (s) => s?.[$e],
75
+ getDebugType: (s) => s?.[Me]
76
76
  };
77
- let Me = 1;
78
- const $e = () => Me++;
79
- function de(e, t, s) {
77
+ let Fe = 1;
78
+ const Be = () => Fe++;
79
+ function fe(s, t, e) {
80
80
  if (typeof t == "function") {
81
81
  const i = t;
82
- if (s.some((r) => r && r.fn === i)) return;
83
- s.push(new Mt(i, void 0));
82
+ if (e.some((o) => o && o.fn === i)) return;
83
+ e.push(new Mt(i, void 0));
84
84
  return;
85
85
  }
86
86
  if ("addDependency" in t) {
87
- t.addDependency(e);
87
+ t.addDependency(s);
88
88
  return;
89
89
  }
90
90
  const n = t;
91
- s.some((i) => i && i.sub === n) || s.push(new Mt(void 0, n));
91
+ e.some((i) => i && i.sub === n) || e.push(new Mt(void 0, n));
92
92
  }
93
- function ee(e, t, s) {
93
+ function te(s, t, e) {
94
94
  const n = /* @__PURE__ */ new Map();
95
95
  t.forEach((i) => {
96
96
  i?.unsub && n.set(i.node, i.unsub);
97
- }), e.forEach((i) => {
97
+ }), s.forEach((i) => {
98
98
  if (!i) return;
99
- const r = i.node, o = n.get(r);
100
- o !== void 0 ? (i.unsub = o, n.delete(r)) : (yt.checkCircular(r, s), i.unsub = r.subscribe(s));
99
+ const o = i.node, r = n.get(o);
100
+ r !== void 0 ? (i.unsub = r, n.delete(o)) : (Ct.checkCircular(o, e), i.unsub = o.subscribe(e));
101
101
  }), n.forEach((i) => i());
102
102
  }
103
- class Pt {
104
- constructor(t, s, n = void 0) {
105
- this.node = t, this.version = s, this.unsub = n;
103
+ class $t {
104
+ constructor(t, e, n = void 0) {
105
+ this.node = t, this.version = e, this.unsub = n;
106
106
  }
107
107
  }
108
108
  class Mt {
109
- constructor(t, s) {
110
- this.fn = t, this.sub = s;
109
+ constructor(t, e) {
110
+ this.fn = t, this.sub = e;
111
111
  }
112
112
  }
113
- const y = {
113
+ const b = {
114
114
  // Computed Errors
115
115
  COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
116
116
  COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
@@ -127,7 +127,7 @@ const y = {
127
127
  EFFECT_CLEANUP_FAILED: "Effect cleanup failed",
128
128
  EFFECT_DISPOSED: "Attempted to run disposed effect",
129
129
  // Scheduler Errors
130
- SCHEDULER_FLUSH_OVERFLOW: (e, t) => `Maximum flush iterations (${e}) exceeded. ${t} jobs dropped. Possible infinite loop.`,
130
+ SCHEDULER_FLUSH_OVERFLOW: (s, t) => `Maximum flush iterations (${s}) exceeded. ${t} jobs dropped. Possible infinite loop.`,
131
131
  // System / Debug
132
132
  CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler",
133
133
  // Effect frequency
@@ -135,72 +135,72 @@ const y = {
135
135
  SCHEDULER_CALLBACK_MUST_BE_FUNCTION: "Scheduler callback must be a function",
136
136
  SCHEDULER_END_BATCH_WITHOUT_START: "endBatch() called without matching startBatch(). Ignoring."
137
137
  };
138
- function Z(e, t, s) {
139
- if (e instanceof tt)
140
- return e;
141
- const n = e instanceof Error, i = n ? e.message : String(e), r = n ? e : void 0, o = `${n ? e.constructor.name : "Unexpected error"} (${s}): ${i}`;
142
- return new t(o, r);
138
+ function tt(s, t, e) {
139
+ if (s instanceof et)
140
+ return s;
141
+ const n = s instanceof Error, i = n ? s.message : String(s), o = n ? s : void 0, r = `${n ? s.constructor.name : "Unexpected error"} (${e}): ${i}`;
142
+ return new t(r, o);
143
143
  }
144
- class _e {
144
+ class de {
145
145
  constructor() {
146
- this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = $e() & It;
146
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = Be() & yt;
147
147
  }
148
148
  }
149
- class Ee extends _e {
149
+ class _e extends de {
150
150
  /**
151
151
  * Adds subscriber.
152
152
  */
153
153
  subscribe(t) {
154
- const s = typeof t == "function";
155
- if (!s && (!t || typeof t.execute != "function"))
156
- throw Z(
154
+ const e = typeof t == "function";
155
+ if (!e && (!t || typeof t.execute != "function"))
156
+ throw tt(
157
157
  new TypeError("Invalid subscriber"),
158
- tt,
159
- y.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
158
+ et,
159
+ b.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
160
160
  );
161
- if (this._subscribers.some((i) => i ? s ? i.fn === t : i.sub === t : !1))
161
+ if (this._subscribers.some((i) => i ? e ? i.fn === t : i.sub === t : !1))
162
162
  return () => {
163
163
  };
164
164
  const n = new Mt(
165
- s ? t : void 0,
166
- s ? void 0 : t
165
+ e ? t : void 0,
166
+ e ? void 0 : t
167
167
  );
168
168
  return this._subscribers.push(n), () => this._unsubscribe(n);
169
169
  }
170
170
  _unsubscribe(t) {
171
- const s = this._subscribers, n = s.indexOf(t);
171
+ const e = this._subscribers, n = e.indexOf(t);
172
172
  if (n === -1) return;
173
- const i = s.pop();
174
- n < s.length && i && (s[n] = i);
173
+ const i = e.pop();
174
+ n < e.length && i && (e[n] = i);
175
175
  }
176
176
  subscriberCount() {
177
177
  return this._subscribers.length;
178
178
  }
179
- _notifySubscribers(t, s) {
179
+ _notifySubscribers(t, e) {
180
180
  this._subscribers.length !== 0 && this._subscribers.slice(0).forEach((n) => {
181
181
  if (n)
182
182
  try {
183
- n.fn ? n.fn(t, s) : n.sub && n.sub.execute();
183
+ n.fn ? n.fn(t, e) : n.sub && n.sub.execute();
184
184
  } catch (i) {
185
185
  this._handleNotifyError(i);
186
186
  }
187
187
  });
188
188
  }
189
189
  _handleNotifyError(t) {
190
- console.error(Z(t, tt, y.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
190
+ console.error(tt(t, et, b.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
191
191
  }
192
192
  }
193
- let Lt = 0;
194
- const jt = () => (Lt = Lt + 1 & It || 1, Lt), $t = (e) => e + 1 & It;
195
- let zt = 0, pt = !1, pe = 0;
196
- const Fe = () => pe;
197
- function se() {
198
- return pt ? !1 : (pt = !0, pe = jt(), zt = 0, !0);
193
+ let wt = 0;
194
+ const zt = () => (wt = wt + 1 & yt || 1, wt), Ft = (s) => s + 1 & yt;
195
+ let jt = 0, gt = !1, Ee = 0;
196
+ const pe = () => Ee;
197
+ function ee() {
198
+ return gt ? !1 : (gt = !0, Ee = zt(), jt = 0, !0);
199
199
  }
200
- const ne = () => {
201
- pt = !1;
202
- }, Be = () => pt ? ++zt : 0;
203
- class He {
200
+ const se = () => {
201
+ gt = !1;
202
+ }, He = () => gt ? ++jt : 0;
203
+ class Ge {
204
204
  constructor() {
205
205
  this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = q.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
206
206
  }
@@ -237,28 +237,28 @@ class He {
237
237
  _runLoop() {
238
238
  try {
239
239
  if (this._size === 0) return;
240
- const t = se();
241
- this._drainQueue(), t && ne();
240
+ const t = ee();
241
+ this._drainQueue(), t && se();
242
242
  } finally {
243
243
  this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
244
244
  }
245
245
  }
246
246
  _flushSync() {
247
247
  this._isFlushingSync = !0;
248
- const t = se();
248
+ const t = ee();
249
249
  try {
250
250
  this._mergeBatchQueue(), this._drainQueue();
251
251
  } finally {
252
- this._isFlushingSync = !1, t && ne();
252
+ this._isFlushingSync = !1, t && se();
253
253
  }
254
254
  }
255
255
  _mergeBatchQueue() {
256
256
  if (this._batchQueueSize === 0) return;
257
- const t = ++this._epoch, s = this._batchQueue, n = this._queueBuffer[this._bufferIndex];
257
+ const t = ++this._epoch, e = this._batchQueue, n = this._queueBuffer[this._bufferIndex];
258
258
  let i = this._size;
259
- s.slice(0, this._batchQueueSize).forEach((r) => {
260
- r._nextEpoch !== t && (r._nextEpoch = t, n[i++] = r);
261
- }), this._size = i, this._batchQueueSize = 0, s.length > q.BATCH_QUEUE_SHRINK_THRESHOLD && (s.length = 0);
259
+ e.slice(0, this._batchQueueSize).forEach((o) => {
260
+ o._nextEpoch !== t && (o._nextEpoch = t, n[i++] = o);
261
+ }), this._size = i, this._batchQueueSize = 0, e.length > q.BATCH_QUEUE_SHRINK_THRESHOLD && (e.length = 0);
262
262
  }
263
263
  _drainQueue() {
264
264
  let t = 0;
@@ -271,21 +271,21 @@ class He {
271
271
  }
272
272
  }
273
273
  _processQueue() {
274
- const t = this._bufferIndex, s = this._queueBuffer[t], n = this._size;
274
+ const t = this._bufferIndex, e = this._queueBuffer[t], n = this._size;
275
275
  this._bufferIndex = t ^ 1, this._size = 0, this._epoch++;
276
276
  for (let i = 0; i < n; i++)
277
277
  try {
278
- s[i]();
279
- } catch (r) {
280
- console.error(new At("Error occurred during scheduler execution", r));
278
+ e[i]();
279
+ } catch (o) {
280
+ console.error(new Lt("Error occurred during scheduler execution", o));
281
281
  }
282
- s.length = 0;
282
+ e.length = 0;
283
283
  }
284
284
  _handleFlushOverflow() {
285
285
  const t = this._size + this._batchQueueSize;
286
286
  if (console.error(
287
- new At(
288
- y.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t)
287
+ new Lt(
288
+ b.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t)
289
289
  )
290
290
  ), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
291
291
  try {
@@ -301,13 +301,13 @@ class He {
301
301
  }
302
302
  setMaxFlushIterations(t) {
303
303
  if (t < q.MIN_FLUSH_ITERATIONS)
304
- throw new At(
304
+ throw new Lt(
305
305
  `Max flush iterations must be at least ${q.MIN_FLUSH_ITERATIONS}`
306
306
  );
307
307
  this._maxFlushIterations = t;
308
308
  }
309
309
  }
310
- const rt = new He(), Vt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), me = /* @__PURE__ */ Symbol.for("atom-effect/computed"), Ge = /* @__PURE__ */ Symbol.for("atom-effect/effect"), k = {
310
+ const ot = new Ge(), Vt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ge = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ze = /* @__PURE__ */ Symbol.for("atom-effect/effect"), P = {
311
311
  /** Active listener. */
312
312
  current: null,
313
313
  /**
@@ -317,46 +317,46 @@ const rt = new He(), Vt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), me = /
317
317
  * @param fn - The logic to execute.
318
318
  * @returns The result of `fn`.
319
319
  */
320
- run(e, t) {
321
- const s = this.current;
322
- this.current = e;
320
+ run(s, t) {
321
+ const e = this.current;
322
+ this.current = s;
323
323
  try {
324
324
  return t();
325
325
  } finally {
326
- this.current = s;
326
+ this.current = e;
327
327
  }
328
328
  }
329
329
  };
330
- function H(e) {
331
- const t = k.current;
332
- if (t === null) return e();
333
- k.current = null;
330
+ function H(s) {
331
+ const t = P.current;
332
+ if (t === null) return s();
333
+ P.current = null;
334
334
  try {
335
- return e();
335
+ return s();
336
336
  } finally {
337
- k.current = t;
337
+ P.current = t;
338
338
  }
339
339
  }
340
- var ie;
341
- class je extends Ee {
342
- constructor(t, s) {
343
- super(), this._pendingOldValue = void 0, this._notifyTask = () => this._flushNotifications(), this._subscribers = [], this[ie] = !0, this._value = t, s && (this.flags |= $.SYNC), yt.attachDebugInfo(this, "atom", this.id);
340
+ var ne;
341
+ class je extends _e {
342
+ constructor(t, e) {
343
+ super(), this._pendingOldValue = void 0, this._notifyTask = () => this._flushNotifications(), this._subscribers = [], this[ne] = !0, this._value = t, e && (this.flags |= M.SYNC), Ct.attachDebugInfo(this, "atom", this.id);
344
344
  }
345
345
  get value() {
346
- const t = k.current;
347
- return t && de(this, t, this._subscribers), this._value;
346
+ const t = P.current;
347
+ return t && fe(this, t, this._subscribers), this._value;
348
348
  }
349
349
  set value(t) {
350
- const s = this._value;
351
- if (Object.is(s, t)) return;
352
- this._value = t, this.version = $t(this.version);
350
+ const e = this._value;
351
+ if (Object.is(e, t)) return;
352
+ this._value = t, this.version = Ft(this.version);
353
353
  const n = this.flags;
354
- if (!(this._subscribers.length === 0 || n & $.NOTIFICATION_SCHEDULED)) {
355
- if (this._pendingOldValue = s, this.flags = n | $.NOTIFICATION_SCHEDULED, n & $.SYNC && !rt.isBatching) {
354
+ if (!(this._subscribers.length === 0 || n & M.NOTIFICATION_SCHEDULED)) {
355
+ if (this._pendingOldValue = e, this.flags = n | M.NOTIFICATION_SCHEDULED, n & M.SYNC && !ot.isBatching) {
356
356
  this._flushNotifications();
357
357
  return;
358
358
  }
359
- rt.schedule(this._notifyTask);
359
+ ot.schedule(this._notifyTask);
360
360
  }
361
361
  }
362
362
  /**
@@ -364,32 +364,32 @@ class je extends Ee {
364
364
  */
365
365
  _flushNotifications() {
366
366
  const t = this.flags;
367
- if (!(t & $.NOTIFICATION_SCHEDULED) || t & $.DISPOSED)
367
+ if (!(t & M.NOTIFICATION_SCHEDULED) || t & M.DISPOSED)
368
368
  return;
369
- const s = this._pendingOldValue;
370
- this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value, s);
369
+ const e = this._pendingOldValue;
370
+ this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value, e);
371
371
  }
372
372
  peek() {
373
373
  return this._value;
374
374
  }
375
375
  dispose() {
376
- this.flags & $.DISPOSED || (this._subscribers.length = 0, this.flags |= $.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
376
+ this.flags & M.DISPOSED || (this._subscribers.length = 0, this.flags |= M.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
377
377
  }
378
- [(ie = Vt, Symbol.dispose)]() {
378
+ [(ne = Vt, Symbol.dispose)]() {
379
379
  this.dispose();
380
380
  }
381
381
  }
382
- function Ft(e, t = {}) {
383
- return new je(e, t.sync ?? !1);
382
+ function Bt(s, t = {}) {
383
+ return new je(s, t.sync ?? !1);
384
384
  }
385
- class ze {
385
+ class Ve {
386
386
  /**
387
387
  * @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
388
388
  * @param capacity - Max length of an array to accept (default: 256).
389
389
  * @param enableStats - Force-enable stats even in production (default: false).
390
390
  */
391
- constructor(t = 50, s = 256, n = !1) {
392
- this.limit = t, this.capacity = s, this.pool = [], this.stats = null, this.stats = n ? {
391
+ constructor(t = 50, e = 256, n = !1) {
392
+ this.limit = t, this.capacity = e, this.pool = [], this.stats = null, this.stats = n ? {
393
393
  acquired: 0,
394
394
  released: 0,
395
395
  rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
@@ -407,8 +407,8 @@ class ze {
407
407
  * @param arr - Array to release.
408
408
  * @param emptyConst - Optional empty constant.
409
409
  */
410
- release(t, s) {
411
- if (!(s && t === s)) {
410
+ release(t, e) {
411
+ if (!(e && t === e)) {
412
412
  if (t.length > this.capacity) {
413
413
  this.stats && this.stats.rejected.tooLarge++;
414
414
  return;
@@ -429,10 +429,10 @@ class ze {
429
429
  */
430
430
  getStats() {
431
431
  if (!this.stats) return null;
432
- const { acquired: t, released: s, rejected: n } = this.stats, i = t - s - (n.frozen + n.tooLarge + n.poolFull);
432
+ const { acquired: t, released: e, rejected: n } = this.stats, i = t - e - (n.frozen + n.tooLarge + n.poolFull);
433
433
  return {
434
434
  acquired: t,
435
- released: s,
435
+ released: e,
436
436
  rejected: { ...n },
437
437
  leaked: i,
438
438
  poolSize: this.pool.length
@@ -449,58 +449,58 @@ class ze {
449
449
  });
450
450
  }
451
451
  }
452
- const O = Object.freeze(
452
+ const A = Object.freeze(
453
453
  []
454
- ), B = new ze();
455
- function qt(e) {
456
- return e !== null && typeof e == "object" && Vt in e;
457
- }
458
- function Ve(e) {
459
- return e !== null && typeof e == "object" && me in e;
460
- }
461
- function ge(e) {
462
- return e !== null && typeof e == "object" && typeof e.then == "function";
463
- }
464
- var re, oe;
465
- const { IDLE: lt, DIRTY: K, PENDING: _t, RESOLVED: V, REJECTED: nt, HAS_ERROR: ft, RECOMPUTING: st, DISPOSED: wt, IS_COMPUTED: qe } = fe;
466
- function Xe(e) {
467
- return e & V ? ut.RESOLVED : e & _t ? ut.PENDING : e & nt ? ut.REJECTED : ut.IDLE;
468
- }
469
- class Qe extends Ee {
470
- constructor(t, s = {}) {
471
- if (typeof t != "function") throw new z(y.COMPUTED_MUST_BE_FUNCTION);
472
- super(), this[oe] = !0, this[re] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = O, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = O, this._trackCount = 0, this._value = void 0, this.flags = qe | K | lt, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : Ut, this._onError = s.onError ?? null;
473
- const n = s.maxAsyncRetries;
474
- if (this._maxAsyncRetries = (n ?? te.MAX_ASYNC_RETRIES) & It, yt.attachDebugInfo(this, "computed", this.id), s.lazy === !1)
454
+ ), B = new Ve();
455
+ function qt(s) {
456
+ return s !== null && typeof s == "object" && Vt in s;
457
+ }
458
+ function qe(s) {
459
+ return s !== null && typeof s == "object" && ge in s;
460
+ }
461
+ function me(s) {
462
+ return s !== null && typeof s == "object" && typeof s.then == "function";
463
+ }
464
+ var ie, oe;
465
+ const { IDLE: ft, DIRTY: K, PENDING: Et, RESOLVED: V, REJECTED: nt, HAS_ERROR: dt, RECOMPUTING: st, DISPOSED: kt, IS_COMPUTED: Xe } = ue;
466
+ function Qe(s) {
467
+ return s & V ? ut.RESOLVED : s & Et ? ut.PENDING : s & nt ? ut.REJECTED : ut.IDLE;
468
+ }
469
+ class Ye extends _e {
470
+ constructor(t, e = {}) {
471
+ if (typeof t != "function") throw new j(b.COMPUTED_MUST_BE_FUNCTION);
472
+ super(), this[oe] = !0, this[ie] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = A, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._lastDriftEpoch = -1, this._trackEpoch = -1, this._trackLinks = A, this._trackCount = 0, this._value = void 0, this.flags = Xe | K | ft, this._equal = e.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in e ? e.defaultValue : Ut, this._onError = e.onError ?? null;
473
+ const n = e.maxAsyncRetries;
474
+ if (this._maxAsyncRetries = (n ?? Zt.MAX_ASYNC_RETRIES) & yt, Ct.attachDebugInfo(this, "computed", this.id), e.lazy === !1)
475
475
  try {
476
476
  this._recompute();
477
477
  } catch {
478
478
  }
479
479
  }
480
480
  _track() {
481
- const t = k.current;
482
- t && de(this, t, this._subscribers);
481
+ const t = P.current;
482
+ t && fe(this, t, this._subscribers);
483
483
  }
484
484
  get value() {
485
485
  this._track();
486
486
  const t = this.flags;
487
- if ((t & (V | K | lt)) === V)
487
+ if ((t & (V | K | ft)) === V)
488
488
  return this._value;
489
- if (t & wt)
490
- throw new z(y.COMPUTED_DISPOSED);
489
+ if (t & kt)
490
+ throw new j(b.COMPUTED_DISPOSED);
491
491
  if (t & st) {
492
492
  if (this._defaultValue !== Ut) return this._defaultValue;
493
- throw new z(y.COMPUTED_CIRCULAR_DEPENDENCY);
493
+ throw new j(b.COMPUTED_CIRCULAR_DEPENDENCY);
494
494
  }
495
- if (t & (K | lt) && (this._recompute(), this.flags & V))
495
+ if (t & (K | ft) && (this._recompute(), this.flags & V))
496
496
  return this._value;
497
- const s = this._defaultValue, n = s !== Ut;
498
- if (this.flags & _t) {
499
- if (n) return s;
500
- throw new z(y.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
497
+ const e = this._defaultValue, n = e !== Ut;
498
+ if (this.flags & Et) {
499
+ if (n) return e;
500
+ throw new j(b.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
501
501
  }
502
502
  if (this.flags & nt) {
503
- if (n) return s;
503
+ if (n) return e;
504
504
  throw this._error;
505
505
  }
506
506
  return this._value;
@@ -509,20 +509,20 @@ class Qe extends Ee {
509
509
  return this._value;
510
510
  }
511
511
  get state() {
512
- return this._track(), Xe(this.flags);
512
+ return this._track(), Qe(this.flags);
513
513
  }
514
514
  get hasError() {
515
- return this._track(), this.flags & (nt | ft) ? !0 : this._links.some((t) => t?.node?.flags & ft);
515
+ return this._track(), this.flags & (nt | dt) ? !0 : this._links.some((t) => t?.node?.flags & dt);
516
516
  }
517
517
  get isValid() {
518
518
  return !this.hasError;
519
519
  }
520
520
  get errors() {
521
- if (this._track(), !this.hasError) return ke;
521
+ if (this._track(), !this.hasError) return Pe;
522
522
  const t = [];
523
- return this._error && t.push(this._error), this._links.forEach((s) => {
524
- const n = s.node;
525
- n.flags & ft && n.errors.forEach((i) => {
523
+ return this._error && t.push(this._error), this._links.forEach((e) => {
524
+ const n = e.node;
525
+ n.flags & dt && n.errors.forEach((i) => {
526
526
  i && !t.includes(i) && t.push(i);
527
527
  });
528
528
  }), Object.freeze(t);
@@ -531,7 +531,7 @@ class Qe extends Ee {
531
531
  return this._track(), this._error;
532
532
  }
533
533
  get isPending() {
534
- return this._track(), (this.flags & _t) !== 0;
534
+ return this._track(), (this.flags & Et) !== 0;
535
535
  }
536
536
  get isResolved() {
537
537
  return this._track(), (this.flags & V) !== 0;
@@ -540,20 +540,20 @@ class Qe extends Ee {
540
540
  this._markDirty();
541
541
  }
542
542
  dispose() {
543
- if (this.flags & wt) return;
543
+ if (this.flags & kt) return;
544
544
  const t = this._links;
545
- t !== O && (t.forEach((s) => s.unsub?.()), B.release(t), this._links = O), this._subscribers.length = 0, this.flags = wt | K | lt, this._error = null, this._value = void 0;
545
+ t !== A && (t.forEach((e) => e.unsub?.()), B.release(t), this._links = A), this._subscribers.length = 0, this.flags = kt | K | ft, this._error = null, this._value = void 0;
546
546
  }
547
- [(oe = Vt, re = me, Symbol.dispose)]() {
547
+ [(oe = Vt, ie = ge, Symbol.dispose)]() {
548
548
  this.dispose();
549
549
  }
550
550
  addDependency(t) {
551
551
  if (t._lastSeenEpoch !== this._trackEpoch) {
552
552
  if (t._lastSeenEpoch = this._trackEpoch, this._trackCount < this._trackLinks.length) {
553
- const s = this._trackLinks[this._trackCount];
554
- s.node = t, s.version = t.version;
553
+ const e = this._trackLinks[this._trackCount];
554
+ e.node = t, e.version = t.version;
555
555
  } else
556
- this._trackLinks.push(new Pt(t, t.version));
556
+ this._trackLinks.push(new $t(t, t.version));
557
557
  this._trackCount++;
558
558
  }
559
559
  }
@@ -561,61 +561,63 @@ class Qe extends Ee {
561
561
  if (this.flags & st) return;
562
562
  this.flags |= st;
563
563
  const t = this._links;
564
- this._trackEpoch = jt(), this._trackLinks = B.acquire(), this._trackCount = 0;
565
- let s = !1;
564
+ this._trackEpoch = zt(), this._trackLinks = B.acquire(), this._trackCount = 0;
565
+ let e = !1;
566
566
  try {
567
- const n = k.run(this, this._fn);
568
- this._trackLinks.length = this._trackCount, ee(this._trackLinks, t, this), this._links = this._trackLinks, s = !0, ge(n) ? this._handleAsyncComputation(n) : this._finalizeResolution(n);
567
+ const n = P.run(this, this._fn);
568
+ this._trackLinks.length = this._trackCount, te(this._trackLinks, t, this), this._links = this._trackLinks, e = !0, me(n) ? this._handleAsyncComputation(n) : this._finalizeResolution(n);
569
569
  } catch (n) {
570
- if (!s)
570
+ if (!e)
571
571
  try {
572
- this._trackLinks.length = this._trackCount, ee(this._trackLinks, t, this), this._links = this._trackLinks, s = !0;
572
+ this._trackLinks.length = this._trackCount, te(this._trackLinks, t, this), this._links = this._trackLinks, e = !0;
573
573
  } catch {
574
574
  }
575
- this._handleError(n, y.COMPUTED_COMPUTATION_FAILED, !0);
575
+ this._handleError(n, b.COMPUTED_COMPUTATION_FAILED, !0);
576
576
  } finally {
577
- s && t !== O ? B.release(t) : s || B.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = O, this._trackCount = 0, this.flags &= ~st;
577
+ e && t !== A ? B.release(t) : e || B.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = A, this._trackCount = 0, this.flags &= ~st;
578
578
  }
579
579
  }
580
580
  _handleAsyncComputation(t) {
581
- this.flags = (this.flags | _t) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % te.MAX_PROMISE_ID;
582
- const s = this._promiseId;
581
+ this.flags = (this.flags | Et) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Zt.MAX_PROMISE_ID;
582
+ const e = this._promiseId;
583
583
  t.then(
584
584
  (n) => {
585
- if (s === this._promiseId) {
586
- if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
587
- return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
588
- new z(
585
+ if (e === this._promiseId) {
586
+ if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion) {
587
+ const i = pe();
588
+ return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
589
+ new j(
589
590
  `Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
590
591
  ),
591
- y.COMPUTED_ASYNC_COMPUTATION_FAILED
592
+ b.COMPUTED_ASYNC_COMPUTATION_FAILED
592
593
  );
594
+ }
593
595
  this._finalizeResolution(n), this._notifySubscribers(n, void 0);
594
596
  }
595
597
  },
596
- (n) => s === this._promiseId && this._handleError(n, y.COMPUTED_ASYNC_COMPUTATION_FAILED)
598
+ (n) => e === this._promiseId && this._handleError(n, b.COMPUTED_ASYNC_COMPUTATION_FAILED)
597
599
  );
598
600
  }
599
601
  _captureVersionSnapshot() {
600
602
  let t = 0;
601
- const s = this._links;
602
- for (let n = 0, i = s.length; n < i; n++)
603
- t = (t << 5) - t + s[n].node.version | 0;
603
+ const e = this._links;
604
+ for (let n = 0, i = e.length; n < i; n++)
605
+ t = (t << 5) - t + e[n].node.version | 0;
604
606
  return t;
605
607
  }
606
- _handleError(t, s, n = !1) {
607
- const i = Z(t, z, s);
608
- if (!n && !(this.flags & nt) && (this.version = $t(this.version)), this._error = i, this.flags = this.flags & -121 | nt | ft, this._onError)
608
+ _handleError(t, e, n = !1) {
609
+ const i = tt(t, j, e);
610
+ if (!n && !(this.flags & nt) && (this.version = Ft(this.version)), this._error = i, this.flags = this.flags & -121 | nt | dt, this._onError)
609
611
  try {
610
612
  this._onError(i);
611
- } catch (r) {
612
- console.error(y.CALLBACK_ERROR_IN_ERROR_HANDLER, r);
613
+ } catch (o) {
614
+ console.error(b.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
613
615
  }
614
616
  if (n) throw i;
615
617
  this._notifySubscribers(void 0, void 0);
616
618
  }
617
619
  _finalizeResolution(t) {
618
- (!(this.flags & V) || !this._equal(this._value, t)) && (this.version = $t(this.version)), this._value = t, this._error = null, this.flags = (this.flags | V) & -697;
620
+ (!(this.flags & V) || !this._equal(this._value, t)) && (this.version = Ft(this.version)), this._value = t, this._error = null, this.flags = (this.flags | V) & -697;
619
621
  }
620
622
  execute() {
621
623
  this._markDirty();
@@ -625,98 +627,98 @@ class Qe extends Ee {
625
627
  this.flags & (st | K) || (this.flags |= K, this._notifySubscribers(void 0, void 0));
626
628
  }
627
629
  }
628
- function Ct(e, t = {}) {
629
- return new Qe(e, t);
630
+ function St(s, t = {}) {
631
+ return new Ye(s, t);
630
632
  }
631
- var ce;
632
- class Ke extends _e {
633
- constructor(t, s = {}) {
634
- super(), this[ce] = !0, this._cleanup = null, this._links = O, this._nextLinks = null, this._prevLinks = O, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._sync ? (this._executeTask = void 0, this._notifyCallback = () => this.execute()) : (this._executeTask = () => this.execute(), this._notifyCallback = () => rt.schedule(this._executeTask)), yt.attachDebugInfo(this, "effect", this.id);
633
+ var re;
634
+ class Ke extends de {
635
+ constructor(t, e = {}) {
636
+ super(), this[re] = !0, this._cleanup = null, this._links = A, this._nextLinks = null, this._prevLinks = A, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = e.onError ?? null, this._sync = e.sync ?? !1, this._maxExecutions = e.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = e.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._sync ? (this._executeTask = void 0, this._notifyCallback = () => this.execute()) : (this._executeTask = () => this.execute(), this._notifyCallback = () => ot.schedule(this._executeTask)), Ct.attachDebugInfo(this, "effect", this.id);
635
637
  }
636
638
  run() {
637
- if (this.flags & L.DISPOSED)
638
- throw new J(y.EFFECT_DISPOSED);
639
+ if (this.flags & k.DISPOSED)
640
+ throw new Z(b.EFFECT_DISPOSED);
639
641
  this.execute(!0);
640
642
  }
641
643
  dispose() {
642
- this.flags & L.DISPOSED || (this.flags |= L.DISPOSED, this._execCleanup(), this._unsubLinks(this._links), this._links !== O && B.release(this._links), this._links = O, this._prevLinks = O);
644
+ this.flags & k.DISPOSED || (this.flags |= k.DISPOSED, this._execCleanup(), this._unsubLinks(this._links), this._links !== A && B.release(this._links), this._links = A, this._prevLinks = A);
643
645
  }
644
- [(ce = Ge, Symbol.dispose)]() {
646
+ [(re = ze, Symbol.dispose)]() {
645
647
  this.dispose();
646
648
  }
647
649
  addDependency(t) {
648
- if (!(this.flags & L.EXECUTING)) return;
649
- const s = this._currentEpoch;
650
- if (t._lastSeenEpoch === s) return;
651
- t._lastSeenEpoch = s;
652
- const n = this._nextLinks, i = this._prevLinks, r = i.findIndex((o) => o && o.node === t && o.unsub);
653
- if (r !== -1) {
654
- const o = i[r];
655
- o.version = t.version, n.push(o), i[r] = null;
650
+ if (!(this.flags & k.EXECUTING)) return;
651
+ const e = this._currentEpoch;
652
+ if (t._lastSeenEpoch === e) return;
653
+ t._lastSeenEpoch = e;
654
+ const n = this._nextLinks, i = this._prevLinks, o = i.findIndex((r) => r && r.node === t && r.unsub);
655
+ if (o !== -1) {
656
+ const r = i[o];
657
+ r.version = t.version, n.push(r), i[o] = null;
656
658
  return;
657
659
  }
658
660
  try {
659
- const o = t.subscribe(this._notifyCallback);
660
- n.push(new Pt(t, t.version, o));
661
- } catch (o) {
662
- const l = Z(o, J, y.EFFECT_EXECUTION_FAILED);
663
- if (console.error(l), this._onError)
661
+ const r = t.subscribe(this._notifyCallback);
662
+ n.push(new $t(t, t.version, r));
663
+ } catch (r) {
664
+ const c = tt(r, Z, b.EFFECT_EXECUTION_FAILED);
665
+ if (console.error(c), this._onError)
664
666
  try {
665
- this._onError(l);
667
+ this._onError(c);
666
668
  } catch {
667
669
  }
668
- n.push(new Pt(t, t.version, void 0));
670
+ n.push(new $t(t, t.version, void 0));
669
671
  }
670
672
  }
671
673
  /**
672
674
  * Executes effect with tracking.
673
675
  */
674
676
  execute(t = !1) {
675
- if (this.flags & (L.DISPOSED | L.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
676
- this._checkInfiniteLoops(), this.flags |= L.EXECUTING, this._execCleanup(), this._prevLinks = this._links;
677
- const s = B.acquire();
678
- this._nextLinks = s, this._currentEpoch = jt();
677
+ if (this.flags & (k.DISPOSED | k.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
678
+ this._checkInfiniteLoops(), this.flags |= k.EXECUTING, this._execCleanup(), this._prevLinks = this._links;
679
+ const e = B.acquire();
680
+ this._nextLinks = e, this._currentEpoch = zt();
679
681
  let n = !1;
680
682
  try {
681
- const i = k.run(this, this._fn);
682
- this._links = s, n = !0, ge(i) ? this._handleAsyncResult(i) : this._cleanup = typeof i == "function" ? i : null;
683
+ const i = P.run(this, this._fn);
684
+ this._links = e, n = !0, me(i) ? this._handleAsyncResult(i) : this._cleanup = typeof i == "function" ? i : null;
683
685
  } catch (i) {
684
- this._links = s, n = !0, this._handleExecutionError(i), this._cleanup = null;
686
+ this._links = e, n = !0, this._handleExecutionError(i), this._cleanup = null;
685
687
  } finally {
686
- this._finalizeDependencies(n, this._prevLinks, s), this.flags &= -9;
688
+ this._finalizeDependencies(n, this._prevLinks, e), this.flags &= -9;
687
689
  }
688
690
  }
689
691
  _handleAsyncResult(t) {
690
- const s = ++this._execId;
692
+ const e = ++this._execId;
691
693
  t.then(
692
694
  (n) => {
693
- if (s !== this._execId || this.flags & L.DISPOSED) {
695
+ if (e !== this._execId || this.flags & k.DISPOSED) {
694
696
  if (typeof n == "function")
695
697
  try {
696
698
  n();
697
699
  } catch (i) {
698
- this._handleExecutionError(i, y.EFFECT_CLEANUP_FAILED);
700
+ this._handleExecutionError(i, b.EFFECT_CLEANUP_FAILED);
699
701
  }
700
702
  return;
701
703
  }
702
704
  typeof n == "function" && (this._cleanup = n);
703
705
  },
704
- (n) => s === this._execId && this._handleExecutionError(n)
706
+ (n) => e === this._execId && this._handleExecutionError(n)
705
707
  );
706
708
  }
707
- _finalizeDependencies(t, s, n) {
708
- this._nextLinks = null, this._prevLinks = O, t ? (s.forEach((i) => i?.unsub?.()), s !== O && B.release(s)) : (this._unsubLinks(n), B.release(n));
709
+ _finalizeDependencies(t, e, n) {
710
+ this._nextLinks = null, this._prevLinks = A, t ? (e.forEach((i) => i?.unsub?.()), e !== A && B.release(e)) : (this._unsubLinks(n), B.release(n));
709
711
  }
710
712
  _unsubLinks(t) {
711
- t.forEach((s) => s?.unsub?.());
713
+ t.forEach((e) => e?.unsub?.());
712
714
  }
713
715
  _isDirty() {
714
- const t = this._links, s = k.current;
715
- k.current = null;
716
+ const t = this._links, e = P.current;
717
+ P.current = null;
716
718
  try {
717
719
  return t.some((n) => {
718
720
  const i = n.node;
719
- if (i.flags & fe.IS_COMPUTED)
721
+ if (i.flags & ue.IS_COMPUTED)
720
722
  try {
721
723
  i.value;
722
724
  } catch {
@@ -725,7 +727,7 @@ class Ke extends _e {
725
727
  return i.version !== n.version;
726
728
  });
727
729
  } finally {
728
- k.current = s;
730
+ P.current = e;
729
731
  }
730
732
  }
731
733
  _execCleanup() {
@@ -733,57 +735,57 @@ class Ke extends _e {
733
735
  try {
734
736
  this._cleanup();
735
737
  } catch (t) {
736
- this._handleExecutionError(t, y.EFFECT_CLEANUP_FAILED);
738
+ this._handleExecutionError(t, b.EFFECT_CLEANUP_FAILED);
737
739
  }
738
740
  this._cleanup = null;
739
741
  }
740
742
  }
741
743
  _checkInfiniteLoops() {
742
- const t = Fe();
743
- this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Be() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
744
+ const t = pe();
745
+ this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), He() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
744
746
  }
745
747
  get isDisposed() {
746
- return (this.flags & L.DISPOSED) !== 0;
748
+ return (this.flags & k.DISPOSED) !== 0;
747
749
  }
748
750
  get executionCount() {
749
751
  return this._executionCount;
750
752
  }
751
753
  get isExecuting() {
752
- return (this.flags & L.EXECUTING) !== 0;
754
+ return (this.flags & k.EXECUTING) !== 0;
753
755
  }
754
756
  _throwInfiniteLoopError(t) {
755
- const s = new J(
756
- `Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${zt}`
757
+ const e = new Z(
758
+ `Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${jt}`
757
759
  );
758
- throw this.dispose(), console.error(s), s;
760
+ throw this.dispose(), console.error(e), e;
759
761
  }
760
- _handleExecutionError(t, s = y.EFFECT_EXECUTION_FAILED) {
761
- const n = Z(t, J, s);
762
+ _handleExecutionError(t, e = b.EFFECT_EXECUTION_FAILED) {
763
+ const n = tt(t, Z, e);
762
764
  if (console.error(n), this._onError)
763
765
  try {
764
766
  this._onError(n);
765
767
  } catch (i) {
766
- console.error(Z(i, J, y.CALLBACK_ERROR_IN_ERROR_HANDLER));
768
+ console.error(tt(i, Z, b.CALLBACK_ERROR_IN_ERROR_HANDLER));
767
769
  }
768
770
  }
769
771
  }
770
- function X(e, t = {}) {
771
- if (typeof e != "function")
772
- throw new J(y.EFFECT_MUST_BE_FUNCTION);
773
- const s = new Ke(e, t);
774
- return s.execute(), s;
772
+ function X(s, t = {}) {
773
+ if (typeof s != "function")
774
+ throw new Z(b.EFFECT_MUST_BE_FUNCTION);
775
+ const e = new Ke(s, t);
776
+ return e.execute(), e;
775
777
  }
776
- function Ie(e) {
777
- if (typeof e != "function")
778
+ function Ie(s) {
779
+ if (typeof s != "function")
778
780
  throw new TypeError("Batch callback must be a function");
779
- rt.startBatch();
781
+ ot.startBatch();
780
782
  try {
781
- return e();
783
+ return s();
782
784
  } finally {
783
- rt.endBatch();
785
+ ot.endBatch();
784
786
  }
785
787
  }
786
- const d = {
788
+ const g = {
787
789
  /** Used by the SPA router ($.route). */
788
790
  ROUTE: "[atom-route]",
789
791
  /** Used by all reactive binding helpers (bindText, bindCss, bindAttr, …). */
@@ -792,57 +794,57 @@ const d = {
792
794
  LIST: "[atom-list]",
793
795
  /** Used by mount/unmount lifecycle helpers. */
794
796
  MOUNT: "[atom-mount]"
795
- }, dt = Object.freeze({
797
+ }, _t = Object.freeze({
796
798
  mode: "hash",
797
799
  basePath: "",
798
800
  autoBindLinks: !1,
799
801
  activeClass: "active"
800
- }), Ye = {
802
+ }), We = {
801
803
  EVENT: "input"
802
- }, We = /* @__PURE__ */ new Set(["input", "select", "textarea"]), Je = /* @__PURE__ */ new Set([
804
+ }, Je = /* @__PURE__ */ new Set(["input", "select", "textarea"]), Ze = /* @__PURE__ */ new Set([
803
805
  "innerHTML",
804
806
  "outerHTML",
805
807
  "srcdoc",
806
808
  "__proto__",
807
809
  "constructor",
808
810
  "prototype"
809
- ]), S = {
810
- ROUTE_NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
811
- TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
812
- TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
813
- MALFORMED_URI: (e) => `Malformed URI component: ${e}`,
811
+ ]), T = {
812
+ ROUTE_NOT_FOUND: (s) => `Route "${s}" not found and no notFound route configured`,
813
+ TEMPLATE_NOT_FOUND: (s) => `Template "${s}" not found`,
814
+ TARGET_NOT_FOUND: (s) => `Target element "${s}" not found`,
815
+ MALFORMED_URI: (s) => `Malformed URI component: ${s}`,
814
816
  /** Emitted when sanitizeHtml modifies the input. Prefixed at call site with LOG_PREFIXES.BINDING or LIST to identify the originating subsystem. */
815
817
  UNSAFE_CONTENT: () => "Unsafe content neutralized during sanitization.",
816
818
  /** Emitted by bindCss when a CSS style property value contains a dangerous protocol. */
817
- BLOCKED_DANGEROUS_CSS_VALUE: (e) => `Blocked dangerous value in CSS style property "${e}".`,
818
- BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute "${e}".`,
819
- BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}" attribute.`,
820
- BLOCKED_DANGEROUS_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`,
821
- INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
822
- MISSING_SOURCE: (e) => `[${e}] source is required when prop/name is a string.`,
823
- MISSING_CONDITION: (e) => `[${e}] condition is required when className is a string.`,
824
- DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.`,
825
- UPDATER_ERROR: (e) => `Updater threw in binding "${e}"`,
819
+ BLOCKED_DANGEROUS_CSS_VALUE: (s) => `Blocked dangerous value in CSS style property "${s}".`,
820
+ BLOCKED_EVENT_HANDLER: (s) => `Blocked setting dangerous event handler attribute "${s}".`,
821
+ BLOCKED_PROTOCOL: (s) => `Blocked dangerous protocol in "${s}" attribute.`,
822
+ BLOCKED_DANGEROUS_PROP: (s) => `Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`,
823
+ INVALID_INPUT_ELEMENT: (s) => `Val binding used on non-input element <${s}>.`,
824
+ MISSING_SOURCE: (s) => `[${s}] source is required when prop/name is a string.`,
825
+ MISSING_CONDITION: (s) => `[${s}] condition is required when className is a string.`,
826
+ DUPLICATE_KEY: (s, t) => `Duplicate key "${s}" at index ${t}.`,
827
+ UPDATER_ERROR: (s) => `Updater threw in binding "${s}"`,
826
828
  EFFECT_DISPOSE_ERROR: () => "Effect dispose error",
827
829
  BINDING_CLEANUP_ERROR: () => "Binding cleanup error",
828
830
  PARSE_ERROR: () => "parse() threw during DOM→Atom sync",
829
831
  MOUNT_ERROR: () => "Mount error",
830
832
  MOUNT_CLEANUP_ERROR: () => "Cleanup error"
831
833
  };
832
- function ye(e) {
833
- return qt(e);
834
+ function ye(s) {
835
+ return qt(s);
834
836
  }
835
- function Xt(e) {
836
- const t = e.tagName.toLowerCase();
837
- if (e.id) return `${t}#${e.id}`;
838
- const s = e.classList, n = s.length;
837
+ function Xt(s) {
838
+ const t = s.tagName.toLowerCase();
839
+ if (s.id) return `${t}#${s.id}`;
840
+ const e = s.classList, n = e.length;
839
841
  if (n === 0) return t;
840
842
  let i = t;
841
- for (let r = 0; r < n; r++)
842
- i += `.${s[r]}`;
843
+ for (let o = 0; o < n; o++)
844
+ i += `.${e[o]}`;
843
845
  return i;
844
846
  }
845
- const Ze = /* @__PURE__ */ new Set([
847
+ const ts = /* @__PURE__ */ new Set([
846
848
  "href",
847
849
  "src",
848
850
  "action",
@@ -858,98 +860,106 @@ const Ze = /* @__PURE__ */ new Set([
858
860
  "usemap",
859
861
  "classid",
860
862
  "codebase"
861
- ]), ts = Object.prototype.hasOwnProperty, es = /^\s*(?:javascript|vbscript)\s*:/i, ss = (
863
+ ]), rt = Object.prototype.hasOwnProperty, es = /^\s*(?:javascript|vbscript)\s*:/i, ss = (
862
864
  // biome-ignore lint/suspicious/noControlCharactersInRegex: Intentionally matching control characters for XSS sanitization
863
- /(?:expression\s*\(|behavior\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
864
- ), ns = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, is = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, rs = /<\?[\s\S]*?\?>/g, os = /(<(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, cs = /(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, as = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, hs = /\bon\w+\s*=/gim, us = new RegExp(ss.source, "gim");
865
- function Bt(e) {
866
- let t = String(e ?? "");
867
- t = t.replace(is, ""), t = t.replace(rs, "");
868
- let s;
865
+ /(?: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
866
+ ), ns = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, is = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, os = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, rs = {
867
+ colon: ":",
868
+ Tab: " ",
869
+ NewLine: `
870
+ `
871
+ }, cs = /&(colon|Tab|NewLine);/g, as = /<\?[\s\S]*?\?>/g, ls = /(<(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, hs = /(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, us = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, fs = /\bon\w+\s*=/gim, ds = new RegExp(ss.source, "gim");
872
+ function Ht(s) {
873
+ let t = String(s ?? "");
874
+ t = t.replace(is, ""), t = t.replace(
875
+ os,
876
+ (n, i, o) => String.fromCodePoint(i ? parseInt(i, 16) : parseInt(o, 10))
877
+ ), t = t.replace(cs, (n, i) => rs[i] ?? ""), t = t.replace(as, "");
878
+ let e;
869
879
  do
870
- s = t, t = t.replace(os, "");
871
- while (t !== s);
872
- return t = t.replace(cs, "data-unsafe-protocol:"), t = t.replace(as, "data-unsafe-protocol:"), t = t.replace(hs, "data-unsafe-attr="), t = t.replace(us, "data-unsafe-css:"), t;
873
- }
874
- function ls(e, t) {
875
- return Ze.has(e.toLowerCase()) ? es.test(t) : !1;
876
- }
877
- function fs(e) {
878
- return e.toLowerCase().includes("url(") ? ns.test(e) : !1;
879
- }
880
- function ds(e, t) {
881
- if (e === t) return !0;
882
- if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
883
- const s = Object.keys(e), n = Object.keys(t);
884
- if (s.length !== n.length) return !1;
885
- const i = e, r = t;
886
- for (let o = 0; o < s.length; o++) {
887
- const l = s[o];
888
- if (!ts.call(r, l) || i[l] !== r[l])
880
+ e = t, t = t.replace(ls, "");
881
+ while (t !== e);
882
+ return t = t.replace(hs, "data-unsafe-protocol:"), t = t.replace(us, "data-unsafe-protocol:"), t = t.replace(fs, "data-unsafe-attr="), t = t.replace(ds, "data-unsafe-css:"), t;
883
+ }
884
+ function _s(s, t) {
885
+ return ts.has(s.toLowerCase()) ? es.test(t) : !1;
886
+ }
887
+ function Es(s) {
888
+ return s.toLowerCase().includes("url(") ? ns.test(s) : !1;
889
+ }
890
+ function ps(s, t) {
891
+ if (s === t) return !0;
892
+ if (s === null || t === null || typeof s != "object" || typeof t != "object") return !1;
893
+ const e = Object.keys(s), n = Object.keys(t);
894
+ if (e.length !== n.length) return !1;
895
+ const i = s, o = t;
896
+ for (let r = 0; r < e.length; r++) {
897
+ const c = e[r];
898
+ if (!rt.call(o, c) || i[c] !== o[c])
889
899
  return !1;
890
900
  }
891
901
  return !0;
892
902
  }
893
- function _s(e) {
894
- const t = e.length;
903
+ function gs(s) {
904
+ const t = s.length;
895
905
  if (t === 0) return new Int32Array(0);
896
- const s = new Int32Array(t).fill(-1), n = new Int32Array(t);
906
+ const e = new Int32Array(t).fill(-1), n = new Int32Array(t);
897
907
  let i = 0;
898
- for (let o = 0; o < t; o++) {
899
- const l = e[o];
900
- if (l === void 0 || l === -1) continue;
901
- const p = i > 0 ? n[i - 1] : void 0;
902
- if (i === 0 || p !== void 0 && (e[p] ?? -1) < l) {
903
- s[o] = p ?? -1, n[i++] = o;
908
+ for (let r = 0; r < t; r++) {
909
+ const c = s[r];
910
+ if (c === void 0 || c === -1) continue;
911
+ const E = i > 0 ? n[i - 1] : void 0;
912
+ if (i === 0 || E !== void 0 && (s[E] ?? -1) < c) {
913
+ e[r] = E ?? -1, n[i++] = r;
904
914
  continue;
905
915
  }
906
- let C = 0, b = i - 1;
907
- for (; C < b; ) {
908
- const E = C + b >>> 1, m = n[E];
909
- m !== void 0 && (e[m] ?? -1) < l ? C = E + 1 : b = E;
916
+ let d = 0, m = i - 1;
917
+ for (; d < m; ) {
918
+ const p = d + m >>> 1, O = n[p];
919
+ O !== void 0 && (s[O] ?? -1) < c ? d = p + 1 : m = p;
910
920
  }
911
- const N = n[C];
912
- N !== void 0 && l < (e[N] ?? Number.MAX_SAFE_INTEGER) && (C > 0 && (s[o] = n[C - 1] ?? -1), n[C] = o);
921
+ const N = n[d];
922
+ N !== void 0 && c < (s[N] ?? Number.MAX_SAFE_INTEGER) && (d > 0 && (e[r] = n[d - 1] ?? -1), n[d] = r);
913
923
  }
914
- const r = new Int32Array(i);
924
+ const o = new Int32Array(i);
915
925
  if (i > 0) {
916
- let o = n[i - 1];
917
- for (let l = i - 1; l >= 0 && o !== void 0 && o !== -1; l--)
918
- r[l] = o, o = s[o];
926
+ let r = n[i - 1];
927
+ for (let c = i - 1; c >= 0 && r !== void 0 && r !== -1; c--)
928
+ o[c] = r, r = e[r];
919
929
  }
920
- return r;
930
+ return o;
921
931
  }
922
- const Es = {}, Ce = 600, ps = `${Ce / 1e3}s`;
923
- function ms() {
932
+ const ms = {}, Ce = 600, Is = `${Ce / 1e3}s`;
933
+ function ys() {
924
934
  if (typeof window < "u") {
925
- const e = window.__ATOM_DEBUG__;
926
- if (typeof e == "boolean") return e;
935
+ const s = window.__ATOM_DEBUG__;
936
+ if (typeof s == "boolean") return s;
927
937
  }
928
- return Es?.VITE_ATOM_DEBUG === "true";
938
+ return ms?.VITE_ATOM_DEBUG === "true";
929
939
  }
930
- let Y = ms();
940
+ let W = ys();
931
941
  const f = {
932
942
  get enabled() {
933
- return Y;
943
+ return W;
934
944
  },
935
- set enabled(e) {
936
- Y = e;
945
+ set enabled(s) {
946
+ W = s;
937
947
  },
938
948
  /**
939
949
  * Logs a message only when debug mode is active.
940
950
  */
941
- log(e, ...t) {
942
- Y && console.log(`${d.MOUNT} ${e}:`, ...t);
951
+ log(s, ...t) {
952
+ W && console.log(`${g.MOUNT} ${s}:`, ...t);
943
953
  },
944
954
  /**
945
955
  * Logs an atom value change only when debug mode is active.
946
956
  */
947
- atomChanged(e, t, s) {
948
- Y && console.log(
949
- `${d.MOUNT} Atom "${e ?? "anonymous"}" changed:`,
957
+ atomChanged(s, t, e) {
958
+ W && console.log(
959
+ `${g.MOUNT} Atom "${s ?? "anonymous"}" changed:`,
950
960
  t,
951
961
  "→",
952
- s
962
+ e
953
963
  );
954
964
  },
955
965
  /**
@@ -960,16 +970,16 @@ const f = {
960
970
  * @param type - The binding type (e.g. 'text', 'checked', 'attr.href').
961
971
  * @param value - The new value that was applied.
962
972
  */
963
- domUpdated(e, t, s) {
964
- if (!Y) return;
965
- const n = e instanceof Element ? e : e[0];
966
- n instanceof HTMLElement && (console.log(`${d.MOUNT} DOM updated: ${Xt(n)}.${t} =`, s), ys(n));
973
+ domUpdated(s, t, e) {
974
+ if (!W) return;
975
+ const n = s instanceof Element ? s : s[0];
976
+ n instanceof HTMLElement && (console.log(`${g.MOUNT} DOM updated: ${Xt(n)}.${t} =`, e), bs(n));
967
977
  },
968
978
  /**
969
979
  * Logs a cleanup event only when debug mode is active.
970
980
  */
971
- cleanup(e) {
972
- Y && console.log(`${d.MOUNT} Cleanup: ${e}`);
981
+ cleanup(s) {
982
+ W && console.log(`${g.MOUNT} Cleanup: ${s}`);
973
983
  },
974
984
  /**
975
985
  * Unconditional warning for runtime errors and unexpected states.
@@ -981,46 +991,46 @@ const f = {
981
991
  * originating subsystem appears in the log rather than the generic MOUNT tag.
982
992
  * Pass an empty string to emit a prefix-free message.
983
993
  */
984
- warn(e, t, ...s) {
985
- console.warn(`${e} ${t}`, ...s);
994
+ warn(s, t, ...e) {
995
+ console.warn(`${s} ${t}`, ...e);
986
996
  },
987
997
  /**
988
998
  * Unconditional error for binding failures.
989
999
  * Not gated by debugEnabled — binding errors are always surfaced because
990
1000
  * they indicate a broken updater that silently stopped applying values.
991
1001
  */
992
- error(e, t, s) {
993
- console.error(`${e} ${t}`, s);
994
- }
995
- }, Ht = "atom-debug-highlight", gs = "data-atom-debug";
996
- let ae;
997
- function Is() {
998
- if (ae?.deref()?.isConnected) return;
999
- const e = document.createElement("style");
1000
- e.setAttribute(gs, ""), e.textContent = `.${Ht}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${ps} ease-out}`, document.head.appendChild(e), ae = new WeakRef(e);
1001
- }
1002
- const kt = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
1003
- function ys(e) {
1004
- if (!e.isConnected) return;
1005
- Is();
1006
- const t = xt.get(e);
1002
+ error(s, t, e) {
1003
+ console.error(`${s} ${t}`, e);
1004
+ }
1005
+ }, Gt = "atom-debug-highlight", Cs = "data-atom-debug";
1006
+ let ce;
1007
+ function Ss() {
1008
+ if (ce?.deref()?.isConnected) return;
1009
+ const s = document.createElement("style");
1010
+ s.setAttribute(Cs, ""), s.textContent = `.${Gt}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Is} ease-out}`, document.head.appendChild(s), ce = new WeakRef(s);
1011
+ }
1012
+ const xt = /* @__PURE__ */ new WeakMap(), Pt = /* @__PURE__ */ new WeakMap();
1013
+ function bs(s) {
1014
+ if (!s.isConnected) return;
1015
+ Ss();
1016
+ const t = Pt.get(s);
1007
1017
  t !== void 0 && cancelAnimationFrame(t);
1008
- const s = kt.get(e);
1009
- s !== void 0 && clearTimeout(s);
1018
+ const e = xt.get(s);
1019
+ e !== void 0 && clearTimeout(e);
1010
1020
  const n = requestAnimationFrame(() => {
1011
- xt.delete(e), e.classList.add(Ht), kt.set(
1012
- e,
1021
+ Pt.delete(s), s.classList.add(Gt), xt.set(
1022
+ s,
1013
1023
  setTimeout(() => {
1014
- e.classList.remove(Ht), kt.delete(e);
1024
+ s.classList.remove(Gt), xt.delete(s);
1015
1025
  }, Ce)
1016
1026
  );
1017
1027
  });
1018
- xt.set(e, n);
1028
+ Pt.set(s, n);
1019
1029
  }
1020
- function be(e, t) {
1021
- return Ft(e, t);
1030
+ function Se(s, t) {
1031
+ return Bt(s, t);
1022
1032
  }
1023
- Object.defineProperty(be, "debug", {
1033
+ Object.defineProperty(Se, "debug", {
1024
1034
  enumerable: !0,
1025
1035
  // configurable: true allows tests and advanced consumers to redefine or
1026
1036
  // delete the accessor if needed. The default (false) would permanently lock
@@ -1029,31 +1039,31 @@ Object.defineProperty(be, "debug", {
1029
1039
  get() {
1030
1040
  return f.enabled;
1031
1041
  },
1032
- set(e) {
1033
- f.enabled = e;
1042
+ set(s) {
1043
+ f.enabled = s;
1034
1044
  }
1035
1045
  });
1036
- function Cs() {
1037
- return new Promise((e) => setTimeout(e, 0));
1046
+ function Ts() {
1047
+ return new Promise((s) => setTimeout(s, 0));
1038
1048
  }
1039
- const bs = {
1049
+ const Rs = {
1040
1050
  // `atom` carries a runtime `debug` accessor added via Object.defineProperty.
1041
1051
  // TypeScript cannot see it through the declared function type, so the double
1042
1052
  // cast is unavoidable. The NamespaceExtensions annotation still verifies all
1043
1053
  // other fields; only `atom`'s shape escapes static checking here.
1044
- atom: be,
1045
- computed: Ct,
1054
+ atom: Se,
1055
+ computed: St,
1046
1056
  effect: X,
1047
1057
  batch: Ie,
1048
1058
  untracked: H,
1049
1059
  isAtom: qt,
1050
- isComputed: Ve,
1060
+ isComputed: qe,
1051
1061
  isReactive: ye,
1052
- nextTick: Cs
1062
+ nextTick: Ts
1053
1063
  };
1054
- c.extend(bs);
1055
- const W = "_aes-bound";
1056
- class Ss {
1064
+ l.extend(Rs);
1065
+ const J = "_aes-bound";
1066
+ class Ns {
1057
1067
  constructor() {
1058
1068
  this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
1059
1069
  }
@@ -1076,20 +1086,20 @@ class Ss {
1076
1086
  // Tracking
1077
1087
  // --------------------------------------------------------------------------
1078
1088
  getOrCreateRecord(t) {
1079
- let s = this.records.get(t);
1080
- return s || (s = {}, this.records.set(t, s), t.classList.add(W)), s;
1089
+ let e = this.records.get(t);
1090
+ return e || (e = {}, this.records.set(t, e), t.classList.add(J)), e;
1081
1091
  }
1082
- trackEffect(t, s) {
1092
+ trackEffect(t, e) {
1083
1093
  const n = this.getOrCreateRecord(t);
1084
- n.effects ??= [], n.effects.push(s);
1094
+ n.effects ??= [], n.effects.push(e);
1085
1095
  }
1086
- trackCleanup(t, s) {
1096
+ trackCleanup(t, e) {
1087
1097
  const n = this.getOrCreateRecord(t);
1088
- n.cleanups ??= [], n.cleanups.push(s);
1098
+ n.cleanups ??= [], n.cleanups.push(e);
1089
1099
  }
1090
- setComponentCleanup(t, s) {
1100
+ setComponentCleanup(t, e) {
1091
1101
  const n = this.getOrCreateRecord(t);
1092
- n.componentCleanup = s;
1102
+ n.componentCleanup = e;
1093
1103
  }
1094
1104
  hasBind(t) {
1095
1105
  return this.records.has(t);
@@ -1098,160 +1108,171 @@ class Ss {
1098
1108
  // Cleanup
1099
1109
  // --------------------------------------------------------------------------
1100
1110
  cleanup(t) {
1101
- const s = this.records.get(t);
1102
- if (!s) {
1103
- t.isConnected && t.classList.remove(W), this.preservedNodes.delete(t), this.ignoredNodes.delete(t);
1111
+ const e = this.records.get(t);
1112
+ if (!e) {
1113
+ t.isConnected && t.classList.remove(J), this.preservedNodes.delete(t), this.ignoredNodes.delete(t);
1104
1114
  return;
1105
1115
  }
1106
- if (this.records.delete(t), this.preservedNodes.delete(t), this.ignoredNodes.delete(t), t.isConnected && t.classList.remove(W), f.enabled && f.cleanup(Xt(t)), s.componentCleanup)
1116
+ if (this.records.delete(t), this.preservedNodes.delete(t), this.ignoredNodes.delete(t), t.isConnected && t.classList.remove(J), f.enabled && f.cleanup(Xt(t)), e.componentCleanup)
1107
1117
  try {
1108
- s.componentCleanup();
1118
+ e.componentCleanup();
1109
1119
  } catch (n) {
1110
- f.error(d.MOUNT, S.MOUNT_CLEANUP_ERROR(), n);
1111
- }
1112
- s.effects?.forEach((n) => {
1113
- try {
1114
- n.dispose();
1115
- } catch (i) {
1116
- f.error(d.BINDING, S.EFFECT_DISPOSE_ERROR(), i);
1120
+ f.error(g.MOUNT, T.MOUNT_CLEANUP_ERROR(), n);
1117
1121
  }
1118
- }), s.cleanups?.forEach((n) => {
1119
- try {
1120
- n();
1121
- } catch (i) {
1122
- f.error(d.BINDING, S.BINDING_CLEANUP_ERROR(), i);
1123
- }
1124
- });
1122
+ if (e.effects) {
1123
+ const n = e.effects;
1124
+ for (let i = 0, o = n.length; i < o; i++)
1125
+ try {
1126
+ n[i].dispose();
1127
+ } catch (r) {
1128
+ f.error(g.BINDING, T.EFFECT_DISPOSE_ERROR(), r);
1129
+ }
1130
+ }
1131
+ if (e.cleanups) {
1132
+ const n = e.cleanups;
1133
+ for (let i = 0, o = n.length; i < o; i++)
1134
+ try {
1135
+ n[i]();
1136
+ } catch (r) {
1137
+ f.error(g.BINDING, T.BINDING_CLEANUP_ERROR(), r);
1138
+ }
1139
+ }
1125
1140
  }
1126
1141
  cleanupDescendants(t) {
1127
- const s = t.querySelectorAll(`.${W}`);
1128
- for (const n of s)
1129
- this.records.has(n) ? this.cleanup(n) : (n.classList.remove(W), f.warn(
1130
- d.BINDING,
1131
- `${W} class found on unregistered element:`,
1132
- n
1133
- ));
1142
+ const e = t.getElementsByClassName(J);
1143
+ for (let n = e.length - 1; n >= 0; n--) {
1144
+ const i = e[n];
1145
+ i && (this.records.has(i) ? this.cleanup(i) : (i.classList.remove(J), f.enabled && f.warn(
1146
+ g.BINDING,
1147
+ `${J} class found on unregistered element:`,
1148
+ i
1149
+ )));
1150
+ }
1134
1151
  }
1135
1152
  cleanupTree(t) {
1136
1153
  this.cleanupDescendants(t), this.cleanup(t);
1137
1154
  }
1138
1155
  }
1139
- const g = new Ss();
1140
- let it = null, Et = null;
1141
- function Ts(e) {
1156
+ const y = new Ns();
1157
+ let it = null, pt = null;
1158
+ function Os(s) {
1142
1159
  if (it !== null) {
1143
- Et !== e && f.warn(
1144
- d.BINDING,
1160
+ pt !== s && f.warn(
1161
+ g.BINDING,
1145
1162
  "enableAutoCleanup() called with a different root while already active. Observation was NOT switched — call disableAutoCleanup() first.",
1146
- { current: Et, requested: e }
1163
+ { current: pt, requested: s }
1147
1164
  );
1148
1165
  return;
1149
1166
  }
1150
- Et = e, it = new MutationObserver((t) => {
1151
- for (const s of t)
1152
- for (const n of s.removedNodes)
1153
- n.nodeType === 1 && (n.isConnected || g.isKept(n) || g.isIgnored(n) || g.cleanupTree(n));
1154
- }), it.observe(e, { childList: !0, subtree: !0 });
1167
+ pt = s, it = new MutationObserver((t) => {
1168
+ for (let e = 0, n = t.length; e < n; e++) {
1169
+ const i = t[e].removedNodes;
1170
+ for (let o = 0, r = i.length; o < r; o++) {
1171
+ const c = i[o];
1172
+ c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
1173
+ }
1174
+ }
1175
+ }), it.observe(s, { childList: !0, subtree: !0 });
1155
1176
  }
1156
- function Gs() {
1157
- it?.disconnect(), it = null, Et = null;
1177
+ function Vs() {
1178
+ it?.disconnect(), it = null, pt = null;
1158
1179
  }
1159
- function Q(e, t, s, n) {
1180
+ function Q(s, t, e, n) {
1160
1181
  if (ye(t)) {
1161
1182
  const i = t;
1162
- g.trackEffect(
1163
- e,
1183
+ y.trackEffect(
1184
+ s,
1164
1185
  X(() => {
1165
- const r = i.value;
1186
+ const o = i.value;
1166
1187
  H(() => {
1167
1188
  try {
1168
- s(r);
1169
- } catch (o) {
1170
- f.error(d.BINDING, `${S.UPDATER_ERROR(n)}:`, o);
1189
+ e(o);
1190
+ } catch (r) {
1191
+ f.error(g.BINDING, `${T.UPDATER_ERROR(n)}:`, r);
1171
1192
  return;
1172
1193
  }
1173
- f.enabled && f.domUpdated(e, n, r);
1194
+ f.enabled && f.domUpdated(s, n, o);
1174
1195
  });
1175
1196
  })
1176
1197
  );
1177
1198
  } else {
1178
1199
  try {
1179
- s(t);
1200
+ e(t);
1180
1201
  } catch (i) {
1181
- f.error(d.BINDING, `${S.UPDATER_ERROR(n)} (static):`, i);
1202
+ f.error(g.BINDING, `${T.UPDATER_ERROR(n)} (static):`, i);
1182
1203
  return;
1183
1204
  }
1184
- f.enabled && f.domUpdated(e, n, t);
1205
+ f.enabled && f.domUpdated(s, n, t);
1185
1206
  }
1186
1207
  }
1187
1208
  const F = /* @__PURE__ */ Symbol("atom-effect-internal"), mt = /* @__PURE__ */ new WeakMap();
1188
- let w = null;
1189
- const Se = (e) => {
1190
- if (e[F]) return e;
1191
- let t = mt.get(e);
1192
- return t || (t = function(...s) {
1193
- return Ie(() => e.apply(this, s));
1194
- }, t[F] = !0, mt.set(e, t)), t;
1209
+ let x = null;
1210
+ const be = (s) => {
1211
+ if (s[F]) return s;
1212
+ let t = mt.get(s);
1213
+ return t || (t = function(...e) {
1214
+ return Ie(() => s.apply(this, e));
1215
+ }, t[F] = !0, mt.set(s, t)), t;
1195
1216
  };
1196
- function Rs(e) {
1217
+ function Ds(s) {
1197
1218
  const t = {};
1198
- return Object.keys(e).forEach((s) => {
1199
- const n = e[s];
1200
- n && (t[s] = Se(n));
1219
+ return Object.keys(s).forEach((e) => {
1220
+ const n = s[e];
1221
+ n && (t[e] = be(n));
1201
1222
  }), t;
1202
1223
  }
1203
- function Os(e) {
1224
+ function vs(s) {
1204
1225
  const t = {};
1205
- return Object.keys(e).forEach((s) => {
1206
- const n = e[s];
1207
- t[s] = n ? mt.get(n) ?? n : void 0;
1226
+ return Object.keys(s).forEach((e) => {
1227
+ const n = s[e];
1228
+ t[e] = n ? mt.get(n) ?? n : void 0;
1208
1229
  }), t;
1209
1230
  }
1210
- function Ns() {
1211
- if (w !== null) return;
1212
- w = {
1213
- on: c.fn.on,
1214
- off: c.fn.off,
1215
- remove: c.fn.remove,
1216
- empty: c.fn.empty,
1217
- detach: c.fn.detach
1231
+ function As() {
1232
+ if (x !== null) return;
1233
+ x = {
1234
+ on: l.fn.on,
1235
+ off: l.fn.off,
1236
+ remove: l.fn.remove,
1237
+ empty: l.fn.empty,
1238
+ detach: l.fn.detach
1218
1239
  };
1219
- const e = w;
1220
- c.fn.remove = function(t) {
1221
- const s = t ? this.filter(t) : this;
1222
- for (let n = 0, i = s.length; n < i; n++) {
1223
- const r = s[n];
1224
- r && (g.markIgnored(r), g.cleanupTree(r));
1240
+ const s = x;
1241
+ l.fn.remove = function(t) {
1242
+ const e = t ? this.filter(t) : this;
1243
+ for (let n = 0, i = e.length; n < i; n++) {
1244
+ const o = e[n];
1245
+ o && (y.markIgnored(o), y.cleanupTree(o));
1225
1246
  }
1226
- return e.remove.call(this, t);
1227
- }, c.fn.empty = function() {
1228
- for (let t = 0, s = this.length; t < s; t++) {
1247
+ return s.remove.call(this, t);
1248
+ }, l.fn.empty = function() {
1249
+ for (let t = 0, e = this.length; t < e; t++) {
1229
1250
  const n = this[t];
1230
- n && g.cleanupDescendants(n);
1251
+ n && y.cleanupDescendants(n);
1231
1252
  }
1232
- return e.empty.call(this);
1233
- }, c.fn.detach = function(t) {
1234
- const s = t ? this.filter(t) : this;
1235
- for (let n = 0, i = s.length; n < i; n++) {
1236
- const r = s[n];
1237
- r && g.keep(r);
1253
+ return s.empty.call(this);
1254
+ }, l.fn.detach = function(t) {
1255
+ const e = t ? this.filter(t) : this;
1256
+ for (let n = 0, i = e.length; n < i; n++) {
1257
+ const o = e[n];
1258
+ o && y.keep(o);
1238
1259
  }
1239
- return e.detach.call(this, t);
1240
- }, c.fn.on = function(...t) {
1241
- const s = t[0];
1242
- if (s && typeof s == "object")
1243
- t[0] = Rs(s);
1260
+ return s.detach.call(this, t);
1261
+ }, l.fn.on = function(...t) {
1262
+ const e = t[0];
1263
+ if (e && typeof e == "object")
1264
+ t[0] = Ds(e);
1244
1265
  else
1245
1266
  for (let n = t.length - 1; n >= 0; n--)
1246
1267
  if (typeof t[n] == "function") {
1247
- t[n] = Se(t[n]);
1268
+ t[n] = be(t[n]);
1248
1269
  break;
1249
1270
  }
1250
- return e.on.apply(this, t);
1251
- }, c.fn.off = function(...t) {
1252
- const s = t[0];
1253
- if (s && typeof s == "object")
1254
- t[0] = Os(s);
1271
+ return s.on.apply(this, t);
1272
+ }, l.fn.off = function(...t) {
1273
+ const e = t[0];
1274
+ if (e && typeof e == "object")
1275
+ t[0] = vs(e);
1255
1276
  else
1256
1277
  for (let n = t.length - 1; n >= 0; n--)
1257
1278
  if (typeof t[n] == "function") {
@@ -1259,483 +1280,497 @@ function Ns() {
1259
1280
  t[n] = mt.get(i) ?? i;
1260
1281
  break;
1261
1282
  }
1262
- return e.off.apply(this, t);
1283
+ return s.off.apply(this, t);
1263
1284
  };
1264
1285
  }
1265
- function js() {
1266
- w !== null && (c.fn.on = w.on, c.fn.off = w.off, c.fn.remove = w.remove, c.fn.empty = w.empty, c.fn.detach = w.detach, w = null);
1286
+ function qs() {
1287
+ x !== null && (l.fn.on = x.on, l.fn.off = x.off, l.fn.remove = x.remove, l.fn.empty = x.empty, l.fn.detach = x.detach, x = null);
1267
1288
  }
1268
- var R = /* @__PURE__ */ ((e) => (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))(R || {});
1269
- let vs = 0;
1270
- class Ds {
1271
- constructor(t, s, n) {
1272
- this.flags = 0, this.timeoutId = void 0, this.ns = `.atomBind-${++vs}`, this.handleCompositionStart = () => {
1273
- this.flags |= R.Composing;
1289
+ var v = /* @__PURE__ */ ((s) => (s[s.None = 0] = "None", s[s.Focused = 1] = "Focused", s[s.Composing = 2] = "Composing", s[s.SyncingToAtom = 4] = "SyncingToAtom", s[s.SyncingToDom = 8] = "SyncingToDom", s[s.Busy = 14] = "Busy", s))(v || {});
1290
+ let Ls = 0;
1291
+ class Us {
1292
+ constructor(t, e, n) {
1293
+ this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
1294
+ this.flags |= v.Composing;
1274
1295
  }, this.handleCompositionEnd = () => {
1275
- this.flags &= ~R.Composing, this.handleInput();
1296
+ this.flags &= ~v.Composing, this.handleInput();
1276
1297
  }, this.handleFocus = () => {
1277
- this.flags |= R.Focused;
1298
+ this.flags |= v.Focused;
1278
1299
  }, this.handleBlur = () => {
1279
- this.flags &= ~R.Focused, this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
1280
- const r = this.options.format(this.atom.peek());
1300
+ this.flags &= ~v.Focused, this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
1301
+ const r = this.format(this.atom.peek());
1281
1302
  this.el.value !== r && (this.el.value = r);
1282
1303
  }, this.syncDomFromAtom = () => {
1283
1304
  const r = this.atom.value;
1284
1305
  H(() => {
1285
- const o = this.options.format(r), l = this.el.value;
1286
- if (l === o) return;
1287
- const p = !!(this.flags & R.Focused);
1288
- if (p)
1306
+ const c = this.format(r), E = this.el.value;
1307
+ if (E === c) return;
1308
+ const d = !!(this.flags & v.Focused);
1309
+ if (d)
1289
1310
  try {
1290
- if (this.options.equal(this.options.parse(l), r)) return;
1311
+ if (this.equal(this.parse(E), r)) return;
1291
1312
  } catch {
1292
1313
  }
1293
- this.flags |= R.SyncingToDom;
1314
+ this.flags |= v.SyncingToDom;
1294
1315
  try {
1295
- if (p && (this.el instanceof HTMLInputElement || this.el instanceof HTMLTextAreaElement)) {
1296
- const C = this.el.selectionStart, b = this.el.selectionEnd;
1297
- this.el.value = o;
1298
- const N = o.length;
1299
- C !== null && b !== null && this.el.setSelectionRange(Math.min(C, N), Math.min(b, N));
1316
+ if (d && (this.el instanceof HTMLInputElement || this.el instanceof HTMLTextAreaElement)) {
1317
+ const m = this.el.selectionStart, N = this.el.selectionEnd;
1318
+ this.el.value = c;
1319
+ const p = c.length;
1320
+ m !== null && N !== null && this.el.setSelectionRange(m < p ? m : p, N < p ? N : p);
1300
1321
  } else
1301
- this.el.value = o;
1302
- f.domUpdated(this.$el, "val", o);
1322
+ this.el.value = c;
1323
+ f.domUpdated(this.$el, "val", c);
1303
1324
  } finally {
1304
- this.flags &= ~R.SyncingToDom;
1325
+ this.flags &= ~v.SyncingToDom;
1305
1326
  }
1306
1327
  });
1307
1328
  }, this.cleanup = () => {
1308
1329
  this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
1309
- }, this.$el = t, this.el = t[0], this.atom = s;
1310
- const i = n.debounce ?? 0;
1311
- this.options = {
1312
- debounce: i,
1313
- event: n.event ?? Ye.EVENT,
1314
- parse: n.parse ?? ((r) => r),
1315
- format: n.format ?? ((r) => String(r ?? "")),
1316
- equal: n.equal ?? Object.is
1317
- }, i > 0 ? this.handleInput = () => {
1318
- this.flags & R.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), i));
1330
+ }, this.$el = t, this.el = t[0], this.atom = e, this.ns = `.atomBind-${++Ls}`;
1331
+ const i = n.debounce ?? 0, o = n.event ?? We.EVENT;
1332
+ this.parse = n.parse ?? ((r) => r), this.format = n.format ?? ((r) => String(r ?? "")), this.equal = n.equal ?? Object.is, i > 0 ? this.handleInput = () => {
1333
+ this.flags & v.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), i));
1319
1334
  } : this.handleInput = () => {
1320
- this.flags & R.Composing || this.syncAtomFromDom();
1321
- }, this.handleFocus[F] = !0, this.handleBlur[F] = !0, this.handleCompositionStart[F] = !0, this.handleCompositionEnd[F] = !0, this.handleInput[F] = !0, this.bindEvents();
1335
+ this.flags & v.Composing || this.syncAtomFromDom();
1336
+ }, this.handleFocus[F] = !0, this.handleBlur[F] = !0, this.handleCompositionStart[F] = !0, this.handleCompositionEnd[F] = !0, this.handleInput[F] = !0, this.bindEvents(o);
1322
1337
  }
1323
1338
  // --- Sync Logic ---
1324
1339
  syncAtomFromDom() {
1325
- if (!(this.flags & R.Busy)) {
1326
- this.flags |= R.SyncingToAtom;
1340
+ if (!(this.flags & v.Busy)) {
1341
+ this.flags |= v.SyncingToAtom;
1327
1342
  try {
1328
- const t = this.options.parse(this.el.value);
1329
- this.options.equal(this.atom.peek(), t) || (this.atom.value = t);
1343
+ const t = this.parse(this.el.value);
1344
+ this.equal(this.atom.peek(), t) || (this.atom.value = t);
1330
1345
  } catch (t) {
1331
- f.warn(d.BINDING, `${S.PARSE_ERROR()}:`, t);
1346
+ f.warn(g.BINDING, `${T.PARSE_ERROR()}:`, t);
1332
1347
  } finally {
1333
- this.flags &= ~R.SyncingToAtom;
1348
+ this.flags &= ~v.SyncingToAtom;
1334
1349
  }
1335
1350
  }
1336
1351
  }
1337
- bindEvents() {
1338
- this.$el.on(`focus${this.ns}`, this.handleFocus).on(`blur${this.ns}`, this.handleBlur).on(`compositionstart${this.ns}`, this.handleCompositionStart).on(`compositionend${this.ns}`, this.handleCompositionEnd).on(`${this.options.event}${this.ns}`, this.handleInput);
1352
+ bindEvents(t) {
1353
+ const e = this.ns;
1354
+ this.$el.on(`focus${e}`, this.handleFocus).on(`blur${e}`, this.handleBlur).on(`compositionstart${e}`, this.handleCompositionStart).on(`compositionend${e}`, this.handleCompositionEnd).on(`${t}${e}`, this.handleInput);
1339
1355
  }
1340
1356
  }
1341
- function As(e, t, s) {
1342
- const n = new Ds(e, t, s);
1357
+ function ws(s, t, e) {
1358
+ const n = new Us(s, t, e);
1343
1359
  return { fx: X(n.syncDomFromAtom), cleanup: n.cleanup };
1344
1360
  }
1345
- const he = /* @__PURE__ */ new Map();
1346
- function Us(e) {
1347
- let t = he.get(e);
1348
- return t !== void 0 || (t = e.includes("-") ? e.replace(/-./g, (s) => s[1].toUpperCase()) : e, he.set(e, t)), t;
1361
+ const ae = /* @__PURE__ */ new Map();
1362
+ function ks(s) {
1363
+ let t = ae.get(s);
1364
+ return t !== void 0 || (t = s.includes("-") ? s.replace(/-./g, (e) => e[1].toUpperCase()) : s, ae.set(s, t)), t;
1349
1365
  }
1350
- const ue = /* @__PURE__ */ new WeakMap();
1351
- function Ls(e) {
1352
- let t = ue.get(e);
1353
- return t || (t = Ct(() => Bt(e.value)), ue.set(e, t)), t;
1366
+ const le = /* @__PURE__ */ new WeakMap();
1367
+ function xs(s) {
1368
+ let t = le.get(s);
1369
+ return t || (t = St(() => Ht(s.value)), le.set(s, t)), t;
1354
1370
  }
1355
- function D(e) {
1371
+ function U(s) {
1356
1372
  return {
1357
- $el: c(e),
1358
- el: e,
1359
- trackCleanup: (t) => g.trackCleanup(e, t)
1373
+ $el: l(s),
1374
+ el: s,
1375
+ trackCleanup: (t) => y.trackCleanup(s, t)
1360
1376
  };
1361
1377
  }
1362
- function Te(e, t, s) {
1363
- const n = e.el;
1378
+ function Te(s, t, e) {
1379
+ const n = s.el;
1364
1380
  Q(
1365
1381
  n,
1366
1382
  t,
1367
1383
  (i) => {
1368
- const r = s ? s(i) : typeof i == "string" ? i : String(i ?? "");
1369
- n.textContent !== r && (n.textContent = r);
1384
+ const o = e ? e(i) : typeof i == "string" ? i : String(i ?? "");
1385
+ n.textContent !== o && (n.textContent = o);
1370
1386
  },
1371
1387
  "text"
1372
1388
  );
1373
1389
  }
1374
- function Re(e, t) {
1375
- const s = e.el, n = qt(t) ? Ls(t) : t;
1390
+ function Re(s, t) {
1391
+ const e = s.el, n = qt(t) ? xs(t) : t;
1376
1392
  Q(
1377
- s,
1393
+ e,
1378
1394
  n,
1379
1395
  (i) => {
1380
- s.innerHTML !== i && (g.cleanupDescendants(s), s.innerHTML = i);
1396
+ e.innerHTML !== i && (y.cleanupDescendants(e), e.innerHTML = i);
1381
1397
  },
1382
1398
  "html"
1383
1399
  );
1384
1400
  }
1385
- function Oe(e, t) {
1386
- Object.entries(t).forEach(([s, n]) => {
1387
- Q(
1388
- e.el,
1389
- n,
1390
- (i) => {
1391
- e.el.classList.toggle(s, !!i);
1392
- },
1393
- `class.${s}`
1394
- );
1395
- });
1401
+ function Ne(s, t) {
1402
+ for (const e in t)
1403
+ if (rt.call(t, e)) {
1404
+ const n = t[e];
1405
+ Q(
1406
+ s.el,
1407
+ n,
1408
+ (i) => {
1409
+ s.el.classList.toggle(e, !!i);
1410
+ },
1411
+ `class.${e}`
1412
+ );
1413
+ }
1396
1414
  }
1397
- function Ne(e, t) {
1398
- const s = e.el, n = s.style;
1399
- Object.entries(t).forEach(([i, r]) => {
1400
- const o = Us(i), [l, p] = Array.isArray(r) ? r : [r, ""];
1401
- Q(
1402
- s,
1403
- l,
1404
- (C) => {
1405
- const b = p ? `${C}${p}` : String(C);
1406
- fs(b) || (n[o] = b);
1407
- },
1408
- `css.${i}`
1409
- );
1410
- });
1415
+ function Oe(s, t) {
1416
+ const e = s.el, n = e.style;
1417
+ for (const i in t)
1418
+ if (rt.call(t, i)) {
1419
+ const o = t[i], r = ks(i), [c, E] = Array.isArray(o) ? o : [o, ""];
1420
+ Q(
1421
+ e,
1422
+ c,
1423
+ (d) => {
1424
+ const m = E ? `${d}${E}` : String(d);
1425
+ Es(m) || (n[r] = m);
1426
+ },
1427
+ `css.${i}`
1428
+ );
1429
+ }
1411
1430
  }
1412
- function ve(e, t) {
1413
- const s = e.el;
1414
- Object.keys(t).forEach((n) => {
1415
- n.toLowerCase().startsWith("on") || Q(
1416
- s,
1417
- t[n],
1418
- (i) => {
1419
- if (i == null || i === !1) {
1420
- s.removeAttribute(n);
1421
- return;
1422
- }
1423
- const r = i === !0 ? n : String(i);
1424
- ls(n, r) || s.getAttribute(n) !== r && s.setAttribute(n, r);
1425
- },
1426
- `attr.${n}`
1427
- );
1428
- });
1431
+ function De(s, t) {
1432
+ const e = s.el;
1433
+ for (const n in t)
1434
+ if (rt.call(t, n)) {
1435
+ if (n.toLowerCase().startsWith("on")) continue;
1436
+ Q(
1437
+ e,
1438
+ t[n],
1439
+ (i) => {
1440
+ if (i == null || i === !1) {
1441
+ e.removeAttribute(n);
1442
+ return;
1443
+ }
1444
+ const o = i === !0 ? n : String(i);
1445
+ _s(n, o) || e.getAttribute(n) !== o && e.setAttribute(n, o);
1446
+ },
1447
+ `attr.${n}`
1448
+ );
1449
+ }
1429
1450
  }
1430
- function De(e, t) {
1431
- const s = e.el;
1432
- Object.keys(t).forEach((n) => {
1433
- Je.has(n) || Q(
1434
- e.el,
1435
- t[n],
1436
- (i) => {
1437
- s[n] !== i && (s[n] = i);
1438
- },
1439
- `prop.${n}`
1440
- );
1441
- });
1451
+ function ve(s, t) {
1452
+ const e = s.el;
1453
+ for (const n in t)
1454
+ if (rt.call(t, n)) {
1455
+ if (Ze.has(n)) continue;
1456
+ Q(
1457
+ s.el,
1458
+ t[n],
1459
+ (i) => {
1460
+ e[n] !== i && (e[n] = i);
1461
+ },
1462
+ `prop.${n}`
1463
+ );
1464
+ }
1442
1465
  }
1443
- function gt(e, t, s) {
1444
- const n = e.el;
1466
+ function It(s, t, e) {
1467
+ const n = s.el;
1445
1468
  Q(
1446
1469
  n,
1447
1470
  t,
1448
- (r) => {
1449
- const o = s !== !!r;
1450
- n.style.display = o ? "" : "none";
1471
+ (o) => {
1472
+ const r = e !== !!o;
1473
+ n.style.display = r ? "" : "none";
1451
1474
  },
1452
- s ? "hide" : "show"
1475
+ e ? "hide" : "show"
1453
1476
  );
1454
1477
  }
1455
- function Gt(e, t, s = {}) {
1456
- const n = e.el.tagName.toLowerCase();
1457
- if (!We.has(n)) {
1458
- console.warn(`${d.BINDING} ${S.INVALID_INPUT_ELEMENT(n)}`);
1478
+ function Ae(s, t, e = {}) {
1479
+ const n = s.el.tagName.toLowerCase();
1480
+ if (!Je.has(n)) {
1481
+ console.warn(`${g.BINDING} ${T.INVALID_INPUT_ELEMENT(n)}`);
1459
1482
  return;
1460
1483
  }
1461
- const { fx: i, cleanup: r } = As(e.$el, t, s);
1462
- g.trackEffect(e.el, i), e.trackCleanup(r);
1484
+ const { fx: i, cleanup: o } = ws(s.$el, t, e);
1485
+ y.trackEffect(s.el, i), s.trackCleanup(o);
1463
1486
  }
1464
- function Ae(e, t) {
1465
- const s = e.el, n = e.$el, i = () => {
1466
- const o = s.checked;
1467
- t.value !== o && (t.value = o);
1487
+ function Le(s, t) {
1488
+ const e = s.el, n = s.$el, i = () => {
1489
+ const r = e.checked;
1490
+ t.value !== r && (t.value = r);
1468
1491
  };
1469
- i[F] = !0, n.on("change", i), e.trackCleanup(() => n.off("change", i));
1470
- const r = X(() => {
1471
- const o = !!t.value;
1492
+ i[F] = !0, n.on("change", i), s.trackCleanup(() => n.off("change", i));
1493
+ const o = X(() => {
1494
+ const r = !!t.value;
1472
1495
  H(() => {
1473
- s.checked !== o && (s.checked = o, f.domUpdated(n, "checked", o));
1496
+ e.checked !== r && (e.checked = r, f.domUpdated(n, "checked", r));
1474
1497
  });
1475
1498
  });
1476
- g.trackEffect(s, r);
1499
+ y.trackEffect(e, o);
1477
1500
  }
1478
- function ws(e, t) {
1479
- const s = e.$el;
1480
- s.on(t), e.trackCleanup(() => s.off(t));
1501
+ function Ps(s, t) {
1502
+ const e = s.$el;
1503
+ e.on(t), s.trackCleanup(() => e.off(t));
1481
1504
  }
1482
- function ks(e, t, s) {
1483
- const n = e.$el;
1484
- n.on(t, s), e.trackCleanup(() => n.off(t, s));
1505
+ function $s(s, t, e) {
1506
+ const n = s.$el;
1507
+ n.on(t, e), s.trackCleanup(() => n.off(t, e));
1485
1508
  }
1486
- function Ue(e) {
1487
- g.cleanupTree(e);
1509
+ function Ue(s) {
1510
+ y.cleanupTree(s);
1488
1511
  }
1489
- c.fn.atomText = function(e, t) {
1490
- return this.each(function() {
1491
- Te(D(this), e, t);
1492
- });
1512
+ l.fn.atomText = function(s, t) {
1513
+ for (let e = 0, n = this.length; e < n; e++)
1514
+ Te(U(this[e]), s, t);
1515
+ return this;
1493
1516
  };
1494
- c.fn.atomHtml = function(e) {
1495
- return this.each(function() {
1496
- Re(D(this), e);
1497
- });
1517
+ l.fn.atomHtml = function(s) {
1518
+ for (let t = 0, e = this.length; t < e; t++)
1519
+ Re(U(this[t]), s);
1520
+ return this;
1498
1521
  };
1499
- c.fn.atomClass = function(e, t) {
1500
- if (typeof e == "string" && t === void 0)
1501
- return console.warn(`${d.BINDING} ${S.MISSING_CONDITION("atomClass")}`), this;
1502
- const s = typeof e == "string" ? { [e]: t } : e;
1503
- return this.each(function() {
1504
- Oe(D(this), s);
1505
- });
1522
+ l.fn.atomClass = function(s, t) {
1523
+ if (typeof s == "string" && t === void 0)
1524
+ return console.warn(`${g.BINDING} ${T.MISSING_CONDITION("atomClass")}`), this;
1525
+ const e = typeof s == "string" ? { [s]: t } : s;
1526
+ for (let n = 0, i = this.length; n < i; n++)
1527
+ Ne(U(this[n]), e);
1528
+ return this;
1506
1529
  };
1507
- c.fn.atomCss = function(e, t, s) {
1508
- if (typeof e == "string" && t === void 0)
1509
- return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomCss")}`), this;
1510
- const n = typeof e == "string" ? { [e]: s ? [t, s] : t } : e;
1511
- return this.each(function() {
1512
- Ne(D(this), n);
1513
- });
1530
+ l.fn.atomCss = function(s, t, e) {
1531
+ if (typeof s == "string" && t === void 0)
1532
+ return console.warn(`${g.BINDING} ${T.MISSING_SOURCE("atomCss")}`), this;
1533
+ const n = typeof s == "string" ? { [s]: e ? [t, e] : t } : s;
1534
+ for (let i = 0, o = this.length; i < o; i++)
1535
+ Oe(U(this[i]), n);
1536
+ return this;
1514
1537
  };
1515
- c.fn.atomAttr = function(e, t) {
1516
- if (typeof e == "string" && t === void 0)
1517
- return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomAttr")}`), this;
1518
- const s = typeof e == "string" ? { [e]: t } : e;
1519
- return this.each(function() {
1520
- ve(D(this), s);
1521
- });
1538
+ l.fn.atomAttr = function(s, t) {
1539
+ if (typeof s == "string" && t === void 0)
1540
+ return console.warn(`${g.BINDING} ${T.MISSING_SOURCE("atomAttr")}`), this;
1541
+ const e = typeof s == "string" ? { [s]: t } : s;
1542
+ for (let n = 0, i = this.length; n < i; n++)
1543
+ De(U(this[n]), e);
1544
+ return this;
1522
1545
  };
1523
- c.fn.atomProp = function(e, t) {
1524
- if (typeof e == "string" && t === void 0)
1525
- return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomProp")}`), this;
1526
- const s = typeof e == "string" ? { [e]: t } : e;
1527
- return this.each(function() {
1528
- De(D(this), s);
1529
- });
1546
+ l.fn.atomProp = function(s, t) {
1547
+ if (typeof s == "string" && t === void 0)
1548
+ return console.warn(`${g.BINDING} ${T.MISSING_SOURCE("atomProp")}`), this;
1549
+ const e = typeof s == "string" ? { [s]: t } : s;
1550
+ for (let n = 0, i = this.length; n < i; n++)
1551
+ ve(U(this[n]), e);
1552
+ return this;
1530
1553
  };
1531
- c.fn.atomShow = function(e) {
1532
- return this.each(function() {
1533
- gt(D(this), e, !1);
1534
- });
1554
+ l.fn.atomShow = function(s) {
1555
+ for (let t = 0, e = this.length; t < e; t++)
1556
+ It(U(this[t]), s, !1);
1557
+ return this;
1535
1558
  };
1536
- c.fn.atomHide = function(e) {
1537
- return this.each(function() {
1538
- gt(D(this), e, !0);
1539
- });
1559
+ l.fn.atomHide = function(s) {
1560
+ for (let t = 0, e = this.length; t < e; t++)
1561
+ It(U(this[t]), s, !0);
1562
+ return this;
1540
1563
  };
1541
- c.fn.atomVal = function(e, t = {}) {
1542
- return this.each(function() {
1543
- Gt(D(this), e, t);
1544
- });
1564
+ l.fn.atomVal = function(s, t = {}) {
1565
+ for (let e = 0, n = this.length; e < n; e++)
1566
+ Ae(U(this[e]), s, t);
1567
+ return this;
1545
1568
  };
1546
- c.fn.atomChecked = function(e) {
1547
- return this.each(function() {
1548
- Ae(D(this), e);
1549
- });
1569
+ l.fn.atomChecked = function(s) {
1570
+ for (let t = 0, e = this.length; t < e; t++)
1571
+ Le(U(this[t]), s);
1572
+ return this;
1550
1573
  };
1551
- c.fn.atomOn = function(e, t) {
1552
- return this.each(function() {
1553
- ks(D(this), e, t);
1554
- });
1574
+ l.fn.atomOn = function(s, t) {
1575
+ for (let e = 0, n = this.length; e < n; e++)
1576
+ $s(U(this[e]), s, t);
1577
+ return this;
1555
1578
  };
1556
- c.fn.atomBind = function(e) {
1557
- return this.each(function() {
1558
- const t = D(this);
1559
- if (e.text !== void 0 && Te(t, e.text), e.html !== void 0 && Re(t, e.html), e.class !== void 0 && Oe(t, e.class), e.css !== void 0 && Ne(t, e.css), e.attr !== void 0 && ve(t, e.attr), e.prop !== void 0 && De(t, e.prop), e.show !== void 0 && gt(t, e.show, !1), e.hide !== void 0 && gt(t, e.hide, !0), e.val !== void 0)
1560
- if (Array.isArray(e.val)) {
1561
- const [s, n] = e.val;
1562
- Gt(t, s, n);
1563
- } else
1564
- Gt(t, e.val);
1565
- e.checked !== void 0 && Ae(t, e.checked), e.on !== void 0 && ws(t, e.on);
1566
- });
1579
+ l.fn.atomBind = function(s) {
1580
+ const { text: t, html: e, class: n, css: i, attr: o, prop: r, show: c, hide: E, val: d, checked: m, on: N } = s;
1581
+ let p, O;
1582
+ d !== void 0 && (Array.isArray(d) ? (p = d[0], O = d[1]) : p = d);
1583
+ for (let G = 0, C = this.length; G < C; G++) {
1584
+ const I = U(this[G]);
1585
+ t !== void 0 && Te(I, t), e !== void 0 && Re(I, e), n !== void 0 && Ne(I, n), i !== void 0 && Oe(I, i), o !== void 0 && De(I, o), r !== void 0 && ve(I, r), c !== void 0 && It(I, c, !1), E !== void 0 && It(I, E, !0), d !== void 0 && Ae(I, p, O), m !== void 0 && Le(I, m), N !== void 0 && Ps(I, N);
1586
+ }
1587
+ return this;
1567
1588
  };
1568
- c.fn.atomUnbind = function() {
1569
- return this.each(function() {
1570
- Ue(this);
1571
- });
1589
+ l.fn.atomUnbind = function() {
1590
+ for (let s = 0, t = this.length; s < t; s++)
1591
+ Ue(this[s]);
1592
+ return this;
1572
1593
  };
1573
- function xs(e, t, s) {
1574
- t?.isConnected ? e.insertBefore(t) : e.appendTo(s);
1575
- }
1576
- c.fn.atomList = function(e, t) {
1577
- const { key: s, render: n, bind: i, update: r, onAdd: o, onRemove: l, empty: p } = t, C = typeof s == "function" ? s : (b, N) => b[s];
1578
- return this.each(function() {
1579
- const b = c(this), N = Xt(this), E = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
1580
- let P = [], U = null;
1581
- const G = (v, T) => {
1582
- const j = () => {
1583
- bt?.isDisposed || (T.$el.remove(), m.delete(v), f.log("list", `${N} removed item:`, v));
1594
+ function Ms(s, t, e) {
1595
+ t?.isConnected ? s.insertBefore(t) : s.appendTo(e);
1596
+ }
1597
+ l.fn.atomList = function(s, t) {
1598
+ const { key: e, render: n, bind: i, update: o, onAdd: r, onRemove: c, empty: E } = t, d = typeof e == "function" ? e : (m, N) => m[e];
1599
+ for (let m = 0, N = this.length; m < N; m++) {
1600
+ const p = this[m], O = l(p), G = Xt(p), C = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Set();
1601
+ let R = [], Y = null;
1602
+ const we = (L, D) => {
1603
+ const z = () => {
1604
+ bt?.isDisposed || (D.$el.remove(), I.delete(L), f.log("list", `${G} removed item:`, L));
1584
1605
  };
1585
- if (l) {
1586
- const M = l(T.$el);
1587
- M instanceof Promise ? M.then(j, j) : j();
1588
- } else
1589
- j();
1590
- }, Qt = (v, T) => {
1591
- E.delete(v), m.add(v), G(v, T);
1606
+ if (!c) {
1607
+ z();
1608
+ return;
1609
+ }
1610
+ const $ = c(D.$el);
1611
+ $ instanceof Promise ? $.then(z, z) : z();
1612
+ }, Qt = (L, D) => {
1613
+ C.delete(L), I.add(L), we(L, D);
1592
1614
  };
1593
1615
  let bt;
1594
1616
  bt = X(() => {
1595
- const v = e.value, T = v.length;
1617
+ const L = s.value, D = L.length;
1596
1618
  H(() => {
1597
- if (U && T > 0 && (U.remove(), U = null), T === 0) {
1598
- if (p && !U) {
1599
- const a = typeof p == "string" ? Bt(p) : p;
1600
- U = c(a).appendTo(b);
1619
+ if (Y && D > 0 && (Y.remove(), Y = null), D === 0) {
1620
+ if (E && !Y) {
1621
+ const a = typeof E == "string" ? Ht(E) : E;
1622
+ Y = l(a).appendTo(O);
1623
+ }
1624
+ for (let a = 0; a < R.length; a++) {
1625
+ const h = R[a], _ = C.get(h);
1626
+ _ && Qt(h, _);
1601
1627
  }
1602
- E.forEach((a, h) => {
1603
- m.has(h) || Qt(h, a);
1604
- }), P = [];
1628
+ R.length = 0;
1605
1629
  return;
1606
1630
  }
1607
- f.log("list", `${N} updating with ${T} items`);
1608
- const j = /* @__PURE__ */ new Map();
1609
- for (let a = 0; a < P.length; a++)
1610
- j.set(P[a], a);
1611
- const M = new Array(T), St = /* @__PURE__ */ new Set(), ot = new Int32Array(T), ct = [], Tt = [], Rt = [];
1612
- for (let a = 0; a < T; a++) {
1613
- const h = v[a], _ = C(h, a);
1614
- if (M[a] = _, St.has(_)) {
1615
- f.warn(d.LIST, S.DUPLICATE_KEY(_, a)), ot[a] = -1;
1631
+ f.log("list", `${G} updating with ${D} items`);
1632
+ const z = /* @__PURE__ */ new Map();
1633
+ for (let a = 0; a < R.length; a++)
1634
+ z.set(R[a], a);
1635
+ const $ = new Array(D), Tt = /* @__PURE__ */ new Set(), ct = new Int32Array(D), at = [], Rt = [], Nt = [];
1636
+ for (let a = 0; a < D; a++) {
1637
+ const h = L[a], _ = d(h, a);
1638
+ if ($[a] = _, Tt.has(_)) {
1639
+ f.warn(g.LIST, T.DUPLICATE_KEY(_, a)), ct[a] = -1;
1616
1640
  continue;
1617
1641
  }
1618
- St.add(_);
1619
- const I = E.get(_);
1620
- if (I) {
1621
- const u = I.item;
1622
- !r && u !== h && !ds(u, h) && (ct.push(_), Tt.push(h), Rt.push(a)), ot[a] = m.has(_) ? -1 : j.get(_) ?? -1;
1642
+ Tt.add(_);
1643
+ const S = C.get(_);
1644
+ if (S) {
1645
+ const u = S.item;
1646
+ !o && u !== h && !ps(u, h) && (at.push(_), Rt.push(h), Nt.push(a)), ct[a] = I.has(_) ? -1 : z.get(_) ?? -1;
1623
1647
  } else
1624
- ct.push(_), Tt.push(h), Rt.push(a), ot[a] = -1;
1648
+ at.push(_), Rt.push(h), Nt.push(a), ct[a] = -1;
1625
1649
  }
1626
- const Kt = "<!--sep-->", at = ct.length, Yt = new Array(
1627
- at
1650
+ const lt = at.length, Yt = new Array(
1651
+ lt
1628
1652
  ), Ot = [];
1629
- for (let a = 0; a < at; a++) {
1630
- const h = n(Tt[a], Rt[a]);
1653
+ for (let a = 0; a < lt; a++) {
1654
+ const h = n(Rt[a], Nt[a]);
1631
1655
  Yt[a] = h, typeof h == "string" && Ot.push(h);
1632
1656
  }
1633
1657
  let ht = null;
1634
1658
  if (Ot.length > 0) {
1635
- const a = Ot.join(Kt);
1636
- ht = Bt(a).split(Kt);
1659
+ const a = `<!--sep-${Math.random().toString(36).substring(2)}-${Date.now().toString(36)}-->`;
1660
+ ht = Ht(Ot.join(a)).split(a);
1637
1661
  }
1638
- let Wt = 0;
1639
- for (let a = 0; a < at; a++) {
1640
- const h = Yt[a], _ = typeof h == "string" ? c(ht[Wt++]) : c(h), I = ct[a], u = E.get(I);
1662
+ let Kt = 0;
1663
+ for (let a = 0; a < lt; a++) {
1664
+ const h = Yt[a], _ = typeof h == "string" ? l(ht[Kt++]) : l(h), S = at[a], u = C.get(S);
1641
1665
  if (u) {
1642
- const A = u.$el[0];
1643
- A && g.cleanupTree(A), u.$el.replaceWith(_), u.$el = _, u.state = "replaced";
1666
+ const w = u.$el[0];
1667
+ w && y.cleanupTree(w), u.$el.replaceWith(_), u.$el = _, u.state = "replaced";
1644
1668
  } else
1645
- E.set(I, { $el: _, item: null, state: "new" });
1669
+ C.set(S, { $el: _, item: null, state: "new" });
1646
1670
  }
1647
- for (const [a, h] of E)
1648
- !St.has(a) && !m.has(a) && Qt(a, h);
1649
- const Jt = _s(ot);
1650
- let Nt = Jt.length - 1, Zt = null;
1651
- const vt = P.length === 0;
1652
- if (vt && ht !== null && Wt === at && !i && !o && !l && m.size === 0) {
1653
- this.innerHTML = ht.join("");
1671
+ for (let a = 0; a < R.length; a++) {
1672
+ const h = R[a];
1673
+ if (!Tt.has(h)) {
1674
+ const _ = C.get(h);
1675
+ _ && Qt(h, _);
1676
+ }
1677
+ }
1678
+ const Wt = gs(ct);
1679
+ let Dt = Wt.length - 1, Jt = null;
1680
+ const vt = R.length === 0;
1681
+ if (vt && ht !== null && Kt === lt && !i && !r && !c && I.size === 0) {
1682
+ p.innerHTML = ht.join("");
1654
1683
  let a = 0;
1655
- for (let h = 0; h < T; h++) {
1656
- const _ = M[h], I = v[h], u = E.get(_);
1684
+ for (let h = 0; h < D; h++) {
1685
+ const _ = $[h], S = L[h], u = C.get(_);
1657
1686
  if (!u) continue;
1658
- const A = this.children[a++];
1659
- A && (u.$el = c(A), u.item = I, u.state = void 0, m.delete(_), f.domUpdated(u.$el, "list.add", I));
1687
+ const w = p.children[a++];
1688
+ w && (u.$el = l(w), u.item = S, u.state = void 0, I.delete(_), f.domUpdated(u.$el, "list.add", S));
1660
1689
  }
1661
1690
  } else {
1662
1691
  const a = vt ? document.createDocumentFragment() : null;
1663
1692
  if (vt && a) {
1664
- for (let h = T - 1; h >= 0; h--) {
1665
- const _ = M[h], I = v[h], u = E.get(_);
1693
+ for (let h = D - 1; h >= 0; h--) {
1694
+ const _ = $[h], S = L[h], u = C.get(_);
1666
1695
  if (!u) continue;
1667
- const A = u.state, x = A === "new", et = A === "replaced";
1668
- u.item = I, u.state = void 0, u.$el[0] && (!x && !et && r ? r(u.$el, I, h) : (x || et) && i && i(u.$el, I, h));
1669
- for (let Dt = u.$el.length - 1; Dt >= 0; Dt--)
1670
- a.insertBefore(u.$el[Dt], a.firstChild);
1671
- o && x && o(u.$el), x && (m.delete(_), f.domUpdated(u.$el, "list.add", I));
1696
+ const w = u.state;
1697
+ u.item = S, u.state = void 0, u.$el[0] && (w === void 0 ? o && o(u.$el, S, h) : i && i(u.$el, S, h));
1698
+ for (let At = u.$el.length - 1; At >= 0; At--)
1699
+ a.insertBefore(u.$el[At], a.firstChild);
1700
+ w === "new" && (r && r(u.$el), I.delete(_), f.domUpdated(u.$el, "list.add", S));
1672
1701
  }
1673
- this.appendChild(a);
1702
+ p.appendChild(a);
1674
1703
  } else
1675
- for (let h = T - 1; h >= 0; h--) {
1676
- const _ = M[h], I = v[h], u = E.get(_);
1704
+ for (let h = D - 1; h >= 0; h--) {
1705
+ const _ = $[h], S = L[h], u = C.get(_);
1677
1706
  if (!u) continue;
1678
- const A = u.state, x = A === "new", et = A === "replaced";
1679
- u.item = I, u.state = void 0, u.$el[0] && (!x && !et && r ? r(u.$el, I, h) : (x || et) && i && i(u.$el, I, h)), Nt >= 0 && Jt[Nt] === h ? Nt-- : xs(u.$el, Zt, b), o && x && o(u.$el), Zt = u.$el[0] ?? null, x && (m.delete(_), f.domUpdated(u.$el, "list.add", I));
1707
+ const w = u.state;
1708
+ u.item = S, u.state = void 0, u.$el[0] && (w === void 0 ? o && o(u.$el, S, h) : i && i(u.$el, S, h)), Dt >= 0 && Wt[Dt] === h ? Dt-- : Ms(u.$el, Jt, O), Jt = u.$el[0] ?? null, w === "new" && (r && r(u.$el), I.delete(_), f.domUpdated(u.$el, "list.add", S));
1680
1709
  }
1681
1710
  }
1682
- P = M;
1711
+ R = $;
1683
1712
  });
1684
- }), g.trackEffect(this, bt), g.trackCleanup(this, () => {
1685
- E.clear(), m.clear(), P = [], U?.remove();
1713
+ }), y.trackEffect(p, bt), y.trackCleanup(p, () => {
1714
+ C.clear(), I.clear(), R.length = 0, Y?.remove();
1686
1715
  });
1687
- });
1716
+ }
1717
+ return this;
1688
1718
  };
1689
- const Ps = Object.freeze({});
1690
- c.fn.atomMount = function(e, t) {
1691
- const s = t ?? Ps;
1692
- return this.each(function() {
1693
- g.cleanupTree(this);
1694
- const n = c(this);
1695
- let i;
1719
+ const Fs = Object.freeze({});
1720
+ l.fn.atomMount = function(s, t) {
1721
+ const e = t ?? Fs;
1722
+ for (let n = 0, i = this.length; n < i; n++) {
1723
+ const o = this[n];
1724
+ if (!o) continue;
1725
+ y.cleanupTree(o);
1726
+ const r = l(o);
1727
+ let c;
1696
1728
  try {
1697
- i = H(() => e(n, s));
1698
- } catch (r) {
1699
- f.error(d.MOUNT, S.MOUNT_ERROR(), r);
1700
- return;
1729
+ c = H(() => s(r, e));
1730
+ } catch (E) {
1731
+ f.error(g.MOUNT, T.MOUNT_ERROR(), E);
1732
+ continue;
1701
1733
  }
1702
- typeof i == "function" && g.setComponentCleanup(this, i);
1703
- });
1734
+ typeof c == "function" && y.setComponentCleanup(o, c);
1735
+ }
1736
+ return this;
1704
1737
  };
1705
- c.fn.atomUnmount = function() {
1706
- return this.each(function() {
1707
- Ue(this);
1708
- });
1738
+ l.fn.atomUnmount = function() {
1739
+ for (let s = 0, t = this.length; s < t; s++) {
1740
+ const e = this[s];
1741
+ e && Ue(e);
1742
+ }
1743
+ return this;
1709
1744
  };
1710
- function le(e, t) {
1745
+ function he(s, t) {
1711
1746
  try {
1712
- return history.pushState(e, "", t), !0;
1713
- } catch (s) {
1747
+ return history.pushState(s, "", t), !0;
1748
+ } catch (e) {
1714
1749
  return f.warn(
1715
- d.ROUTE,
1750
+ g.ROUTE,
1716
1751
  "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.",
1717
- s
1752
+ e
1718
1753
  ), !1;
1719
1754
  }
1720
1755
  }
1721
- class Ms {
1756
+ class Bs {
1722
1757
  constructor(t) {
1723
1758
  this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.config = {
1724
1759
  ...t,
1725
- mode: t.mode ?? dt.mode,
1726
- basePath: t.basePath ?? dt.basePath,
1727
- autoBindLinks: t.autoBindLinks ?? dt.autoBindLinks,
1728
- activeClass: t.activeClass ?? dt.activeClass
1729
- }, this.isHistoryMode = this.config.mode === "history", this.$target = c(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.previousUrl = this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash, this.currentRouteAtom = Ft(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = Ft(this.getQueryParams()), this.queryParams = Ct(() => this.queryParamsAtom.value), this.handleUrlChange = this.handleUrlChange.bind(this), this.destroy = this.destroy.bind(this), this.init();
1760
+ mode: t.mode ?? _t.mode,
1761
+ basePath: t.basePath ?? _t.basePath,
1762
+ autoBindLinks: t.autoBindLinks ?? _t.autoBindLinks,
1763
+ activeClass: t.activeClass ?? _t.activeClass
1764
+ }, this.isHistoryMode = this.config.mode === "history", this.$target = l(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.previousUrl = this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash, this.currentRouteAtom = Bt(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = Bt(this.getQueryParams()), this.queryParams = St(() => this.queryParamsAtom.value), this.handleUrlChange = this.handleUrlChange.bind(this), this.destroy = this.destroy.bind(this), this.init();
1730
1765
  }
1731
1766
  init() {
1732
1767
  const t = this.isHistoryMode ? "popstate" : "hashchange";
1733
1768
  window.addEventListener(t, this.handleUrlChange), this.cleanups.push(() => window.removeEventListener(t, this.handleUrlChange));
1734
- const s = X(() => {
1769
+ const e = X(() => {
1735
1770
  const n = this.currentRouteAtom.value;
1736
1771
  H(() => this.renderRoute(n));
1737
1772
  });
1738
- this.cleanups.push(() => s.dispose()), this.setupAutoBindLinks(), this.$target[0] && g.trackCleanup(this.$target[0], this.destroy);
1773
+ this.cleanups.push(() => e.dispose()), this.setupAutoBindLinks(), this.$target[0] && y.trackCleanup(this.$target[0], this.destroy);
1739
1774
  }
1740
1775
  // --- Mode-abstracted internal methods ---
1741
1776
  /**
@@ -1745,11 +1780,11 @@ class Ms {
1745
1780
  getRouteName() {
1746
1781
  const { default: t } = this.config;
1747
1782
  if (this.isHistoryMode) {
1748
- let r = window.location.pathname;
1749
- return this.normalizedBasePath && r.startsWith(this.normalizedBasePath) && (r = r.substring(this.normalizedBasePath.length)), r.charCodeAt(0) === 47 && (r = r.slice(1)), r || t;
1783
+ let o = window.location.pathname;
1784
+ return this.normalizedBasePath && o.startsWith(this.normalizedBasePath) && (o = o.substring(this.normalizedBasePath.length)), o.charCodeAt(0) === 47 && (o = o.slice(1)), o || t;
1750
1785
  }
1751
- const s = window.location.hash, n = s.indexOf("?");
1752
- return (n === -1 ? s.substring(1) : s.substring(1, n)) || t;
1786
+ const e = window.location.hash, n = e.indexOf("?");
1787
+ return (n === -1 ? e.substring(1) : e.substring(1, n)) || t;
1753
1788
  }
1754
1789
  /**
1755
1790
  * Parses query parameters from the current URL.
@@ -1764,16 +1799,16 @@ class Ms {
1764
1799
  if (this.isHistoryMode) {
1765
1800
  if (t = window.location.search.substring(1), !t) return {};
1766
1801
  } else {
1767
- const i = window.location.hash, r = i.indexOf("?");
1768
- if (r === -1) return {};
1769
- t = i.substring(r + 1);
1802
+ const i = window.location.hash, o = i.indexOf("?");
1803
+ if (o === -1) return {};
1804
+ t = i.substring(o + 1);
1770
1805
  }
1771
- const s = new URLSearchParams(t), n = Object.fromEntries(s);
1806
+ const e = new URLSearchParams(t), n = Object.fromEntries(e);
1772
1807
  if (t.includes("%"))
1773
1808
  try {
1774
1809
  decodeURIComponent(t);
1775
1810
  } catch {
1776
- f.warn(d.ROUTE, S.MALFORMED_URI(t));
1811
+ f.warn(g.ROUTE, T.MALFORMED_URI(t));
1777
1812
  }
1778
1813
  return n;
1779
1814
  }
@@ -1783,11 +1818,11 @@ class Ms {
1783
1818
  */
1784
1819
  setUrl(t) {
1785
1820
  if (this.isHistoryMode) {
1786
- const s = `${this.normalizedBasePath}/${t}`;
1787
- le(null, s), this.previousUrl = s;
1821
+ const e = `${this.normalizedBasePath}/${t}`;
1822
+ he(null, e), this.previousUrl = e;
1788
1823
  } else {
1789
- const s = `#${t}`;
1790
- window.location.hash = s, this.previousUrl = s;
1824
+ const e = `#${t}`;
1825
+ window.location.hash = e, this.previousUrl = e;
1791
1826
  }
1792
1827
  }
1793
1828
  /**
@@ -1796,7 +1831,7 @@ class Ms {
1796
1831
  * that occur with replaceState during popstate events.
1797
1832
  */
1798
1833
  restoreUrl() {
1799
- this.isHistoryMode ? le(null, this.previousUrl) : window.location.hash = this.previousUrl;
1834
+ this.isHistoryMode ? he(null, this.previousUrl) : window.location.hash = this.previousUrl;
1800
1835
  }
1801
1836
  /**
1802
1837
  * Returns the current full URL string for comparison purposes.
@@ -1809,9 +1844,9 @@ class Ms {
1809
1844
  * Resolves route configuration, falling back to notFound route if needed.
1810
1845
  */
1811
1846
  getRouteConfig(t) {
1812
- const { routes: s, notFound: n } = this.config;
1813
- let i = s[t];
1814
- return !i && n && (i = s[n]), i || (f.warn(d.ROUTE, S.ROUTE_NOT_FOUND(t)), null);
1847
+ const { routes: e, notFound: n } = this.config;
1848
+ let i = e[t];
1849
+ return !i && n && (i = e[n]), i || (f.warn(g.ROUTE, T.ROUTE_NOT_FOUND(t)), null);
1815
1850
  }
1816
1851
  /**
1817
1852
  * Appends cloned template content into the target container.
@@ -1819,14 +1854,14 @@ class Ms {
1819
1854
  * before invoking this method if a clean slate is needed.
1820
1855
  */
1821
1856
  renderTemplate(t) {
1822
- let s = this.templateCache.get(t);
1823
- if (!s) {
1857
+ let e = this.templateCache.get(t);
1858
+ if (!e) {
1824
1859
  const i = document.querySelector(t);
1825
1860
  if (!i || !(i instanceof HTMLTemplateElement))
1826
- return f.warn(d.ROUTE, S.TEMPLATE_NOT_FOUND(t)), !1;
1827
- s = i, this.templateCache.set(t, s);
1861
+ return f.warn(g.ROUTE, T.TEMPLATE_NOT_FOUND(t)), !1;
1862
+ e = i, this.templateCache.set(t, e);
1828
1863
  }
1829
- const n = s.content.cloneNode(!0);
1864
+ const n = e.content.cloneNode(!0);
1830
1865
  return this.$target.append(n), !0;
1831
1866
  }
1832
1867
  /**
@@ -1844,21 +1879,21 @@ class Ms {
1844
1879
  */
1845
1880
  renderRoute(t) {
1846
1881
  if (this.isDestroyed) return;
1847
- const s = this.$target[0];
1848
- if (!s) {
1849
- f.warn(d.ROUTE, S.TARGET_NOT_FOUND(this.config.target));
1882
+ const e = this.$target[0];
1883
+ if (!e) {
1884
+ f.warn(g.ROUTE, T.TARGET_NOT_FOUND(this.config.target));
1850
1885
  return;
1851
1886
  }
1852
1887
  const n = this.getRouteConfig(t);
1853
1888
  if (!n) return;
1854
- const i = this.getQueryParams(), r = this.previousRoute;
1855
- this.config.beforeTransition && this.config.beforeTransition(r, t), this.$target.empty();
1856
- let o = i;
1889
+ const i = this.getQueryParams(), o = this.previousRoute;
1890
+ this.config.beforeTransition && this.config.beforeTransition(o, t), this.$target.empty();
1891
+ let r = i;
1857
1892
  if (n.onEnter) {
1858
- const l = n.onEnter(i);
1859
- l !== void 0 && (o = { ...i, ...l });
1893
+ const c = n.onEnter(i);
1894
+ c !== void 0 && (r = { ...i, ...c });
1860
1895
  }
1861
- n.render ? n.render(s, t, o) : n.template && this.renderTemplate(n.template) && n.onMount && n.onMount(this.$target.children()), this.config.afterTransition && this.config.afterTransition(r, t), this.previousRoute = t;
1896
+ n.render ? n.render(e, t, r) : n.template && this.renderTemplate(n.template) && n.onMount && n.onMount(this.$target.children()), this.config.afterTransition && this.config.afterTransition(o, t), this.previousRoute = t;
1862
1897
  }
1863
1898
  /**
1864
1899
  * Handles browser URL change events (hashchange or popstate).
@@ -1867,18 +1902,18 @@ class Ms {
1867
1902
  if (this.isDestroyed) return;
1868
1903
  const t = this.getCurrentUrl();
1869
1904
  if (t === this.previousUrl) return;
1870
- const s = this.getRouteName(), n = this.currentRouteAtom.peek(), i = this.getQueryParams();
1871
- if (n !== s) {
1872
- const r = this.config.routes[n];
1873
- if (r?.onLeave && r.onLeave() === !1) {
1905
+ const e = this.getRouteName(), n = this.currentRouteAtom.peek(), i = this.getQueryParams();
1906
+ if (n !== e) {
1907
+ const o = this.config.routes[n];
1908
+ if (o?.onLeave && o.onLeave() === !1) {
1874
1909
  this.restoreUrl();
1875
1910
  return;
1876
1911
  }
1877
- this.currentRouteAtom.value = s, this.queryParamsAtom.value = i;
1912
+ this.currentRouteAtom.value = e, this.queryParamsAtom.value = i;
1878
1913
  } else {
1879
1914
  this.queryParamsAtom.value = i;
1880
- const r = this.config.routes[n];
1881
- r?.onParamsChange ? r.onParamsChange(i) : this.renderRoute(s);
1915
+ const o = this.config.routes[n];
1916
+ o?.onParamsChange ? o.onParamsChange(i) : this.renderRoute(e);
1882
1917
  }
1883
1918
  this.previousUrl = t;
1884
1919
  }
@@ -1897,19 +1932,19 @@ class Ms {
1897
1932
  if (!this.config.autoBindLinks) return;
1898
1933
  const t = (i) => {
1899
1934
  i.preventDefault();
1900
- const r = i.currentTarget.dataset.route;
1901
- r != null && this.navigate(r);
1935
+ const o = i.currentTarget.dataset.route;
1936
+ o != null && this.navigate(o);
1902
1937
  };
1903
- c(document).on("click", "[data-route]", t), this.cleanups.push(() => {
1904
- c(document).off("click", "[data-route]", t);
1938
+ l(document).on("click", "[data-route]", t), this.cleanups.push(() => {
1939
+ l(document).off("click", "[data-route]", t);
1905
1940
  });
1906
- const { activeClass: s } = this.config, n = X(() => {
1941
+ const { activeClass: e } = this.config, n = X(() => {
1907
1942
  const i = this.currentRouteAtom.value;
1908
1943
  H(() => {
1909
- const r = document.querySelectorAll("[data-route]");
1910
- for (const o of r) {
1911
- const l = o.dataset.route, p = i === l;
1912
- o.classList.toggle(s, p), p ? o.setAttribute("aria-current", "page") : o.removeAttribute("aria-current");
1944
+ const o = document.querySelectorAll("[data-route]");
1945
+ for (let r = 0, c = o.length; r < c; r++) {
1946
+ const E = o[r], d = E.dataset.route, m = i === d;
1947
+ E.classList.toggle(e, m), m ? E.setAttribute("aria-current", "page") : E.removeAttribute("aria-current");
1913
1948
  }
1914
1949
  });
1915
1950
  });
@@ -1925,13 +1960,13 @@ class Ms {
1925
1960
  */
1926
1961
  navigate(t) {
1927
1962
  if (this.isDestroyed) return;
1928
- const s = this.currentRouteAtom.peek(), n = this.config.routes[s];
1963
+ const e = this.currentRouteAtom.peek(), n = this.config.routes[e];
1929
1964
  if (n?.onLeave && n.onLeave() === !1)
1930
1965
  return;
1931
1966
  const i = t || this.config.default;
1932
1967
  if (!i) {
1933
1968
  f.warn(
1934
- d.ROUTE,
1969
+ g.ROUTE,
1935
1970
  "navigate() called with empty routeName and no default configured."
1936
1971
  );
1937
1972
  return;
@@ -1944,73 +1979,75 @@ class Ms {
1944
1979
  * cleanup does not prevent the remaining ones from running.
1945
1980
  */
1946
1981
  destroy() {
1947
- this.isDestroyed || (this.isDestroyed = !0, this.cleanups.forEach((t) => {
1982
+ if (this.isDestroyed) return;
1983
+ this.isDestroyed = !0;
1984
+ const t = this.cleanups;
1985
+ for (let e = 0, n = t.length; e < n; e++)
1948
1986
  try {
1949
- t();
1950
- } catch (s) {
1951
- f.warn(d.ROUTE, "Cleanup error during destroy:", s);
1987
+ t[e]();
1988
+ } catch (i) {
1989
+ f.warn(g.ROUTE, "Cleanup error during destroy:", i);
1952
1990
  }
1953
- }), this.cleanups.length = 0, this.templateCache.clear());
1991
+ this.cleanups.length = 0, this.templateCache.clear();
1954
1992
  }
1955
1993
  }
1956
- function $s(e) {
1957
- return new Ms(e);
1994
+ function Hs(s) {
1995
+ return new Bs(s);
1958
1996
  }
1959
- c.extend({
1960
- route: $s
1997
+ l.extend({
1998
+ route: Hs
1961
1999
  });
1962
- const Fs = new Promise(() => {
2000
+ const Gs = new Promise(() => {
1963
2001
  });
1964
- c.extend({
1965
- atomFetch(e, t) {
1966
- const { defaultValue: s, transform: n, method: i, headers: r, ajaxOptions: o, onError: l, eager: p } = t, C = typeof e == "function" ? e : null, b = typeof e == "string" ? e : void 0, N = {
1967
- ...o,
1968
- ...i !== void 0 && { method: i },
1969
- ...r !== void 0 && { headers: r }
1970
- };
1971
- let E = null;
1972
- return Ct(
2002
+ l.extend({
2003
+ atomFetch(s, t) {
2004
+ const { defaultValue: e, transform: n, method: i, headers: o, ajaxOptions: r, onError: c, eager: E } = t, d = typeof s == "string", m = d ? s : void 0, N = d ? null : s, p = Object.assign({}, r);
2005
+ i !== void 0 && (p.method = i), o !== void 0 && (p.headers = o), d && (p.url = m);
2006
+ let O = null;
2007
+ return St(
1973
2008
  async () => {
1974
- E?.abort(), E = new AbortController();
1975
- const m = E.signal, P = b ? { ...N, url: b } : { ...N, url: C() }, U = c.ajax(P);
1976
- m.onabort = () => U.abort(), m.aborted && U.abort();
2009
+ O?.abort(), O = new AbortController();
2010
+ const C = O.signal;
2011
+ d || (p.url = N());
2012
+ const I = l.ajax(p);
2013
+ C.onabort = () => I.abort(), C.aborted && I.abort();
1977
2014
  try {
1978
- const G = await U;
1979
- return n ? n(G) : G;
1980
- } catch (G) {
1981
- if (m.aborted)
1982
- return Fs;
2015
+ const R = await I;
2016
+ return n ? n(R) : R;
2017
+ } catch (R) {
2018
+ if (C.aborted)
2019
+ return Gs;
1983
2020
  try {
1984
- l?.(G);
2021
+ c?.(R);
1985
2022
  } catch {
1986
2023
  }
1987
- throw G;
2024
+ throw R;
1988
2025
  } finally {
1989
- m.onabort = null, E.signal === m && (E = null);
2026
+ C.onabort = null, O.signal === C && (O = null);
1990
2027
  }
1991
2028
  },
1992
- { defaultValue: s, lazy: !(p ?? !0) }
2029
+ { defaultValue: e, lazy: !(E ?? !0) }
1993
2030
  );
1994
2031
  }
1995
2032
  });
1996
- c(() => {
1997
- Ns(), Ts(document.body);
2033
+ l(() => {
2034
+ As(), Os(document.body);
1998
2035
  });
1999
2036
  export {
2000
- Ft as atom,
2037
+ Bt as atom,
2001
2038
  Ie as batch,
2002
- Ct as computed,
2003
- qs as default,
2004
- Gs as disableAutoCleanup,
2005
- js as disablejQueryOverrides,
2039
+ St as computed,
2040
+ Ys as default,
2041
+ Vs as disableAutoCleanup,
2042
+ qs as disablejQueryOverrides,
2006
2043
  X as effect,
2007
- Ts as enableAutoCleanup,
2008
- Ns as enablejQueryOverrides,
2044
+ Os as enableAutoCleanup,
2045
+ As as enablejQueryOverrides,
2009
2046
  qt as isAtom,
2010
- Ve as isComputed,
2047
+ qe as isComputed,
2011
2048
  ye as isReactive,
2012
- Cs as nextTick,
2013
- g as registry,
2049
+ Ts as nextTick,
2050
+ y as registry,
2014
2051
  H as untracked
2015
2052
  };
2016
2053
  //# sourceMappingURL=index.mjs.map