@but212/atom-effect-jquery 0.22.1 → 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
- }, we = {
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, ke = typeof process < "u" && process.env && !1 || !1, xe = 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 Pe = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Me = /* @__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: ke,
65
- warnInfiniteLoop: we.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?.[Pe],
75
- getDebugType: (e) => e?.[Me]
74
+ getDebugName: (s) => s?.[$e],
75
+ getDebugType: (s) => s?.[Me]
76
76
  };
77
- let $e = 1;
78
- const Fe = () => $e++;
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 = Fe() & 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 me = () => 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"), ge = /* @__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"), ge = /
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" && ge in e;
460
- }
461
- function Ie(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._lastDriftEpoch = -1, 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 xe;
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 = ge, 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,63 +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, Ie(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) {
585
+ if (e === this._promiseId) {
586
586
  if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion) {
587
- const i = me();
587
+ const i = pe();
588
588
  return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
589
- new z(
589
+ new j(
590
590
  `Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
591
591
  ),
592
- y.COMPUTED_ASYNC_COMPUTATION_FAILED
592
+ b.COMPUTED_ASYNC_COMPUTATION_FAILED
593
593
  );
594
594
  }
595
595
  this._finalizeResolution(n), this._notifySubscribers(n, void 0);
596
596
  }
597
597
  },
598
- (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)
599
599
  );
600
600
  }
601
601
  _captureVersionSnapshot() {
602
602
  let t = 0;
603
- const s = this._links;
604
- for (let n = 0, i = s.length; n < i; n++)
605
- 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;
606
606
  return t;
607
607
  }
608
- _handleError(t, s, n = !1) {
609
- const i = Z(t, z, s);
610
- 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)
611
611
  try {
612
612
  this._onError(i);
613
- } catch (r) {
614
- console.error(y.CALLBACK_ERROR_IN_ERROR_HANDLER, r);
613
+ } catch (o) {
614
+ console.error(b.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
615
615
  }
616
616
  if (n) throw i;
617
617
  this._notifySubscribers(void 0, void 0);
618
618
  }
619
619
  _finalizeResolution(t) {
620
- (!(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;
621
621
  }
622
622
  execute() {
623
623
  this._markDirty();
@@ -627,98 +627,98 @@ class Qe extends Ee {
627
627
  this.flags & (st | K) || (this.flags |= K, this._notifySubscribers(void 0, void 0));
628
628
  }
629
629
  }
630
- function Ct(e, t = {}) {
631
- return new Qe(e, t);
630
+ function St(s, t = {}) {
631
+ return new Ye(s, t);
632
632
  }
633
- var ce;
634
- class Ke extends _e {
635
- constructor(t, s = {}) {
636
- 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);
637
637
  }
638
638
  run() {
639
- if (this.flags & L.DISPOSED)
640
- throw new J(y.EFFECT_DISPOSED);
639
+ if (this.flags & k.DISPOSED)
640
+ throw new Z(b.EFFECT_DISPOSED);
641
641
  this.execute(!0);
642
642
  }
643
643
  dispose() {
644
- 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);
645
645
  }
646
- [(ce = Ge, Symbol.dispose)]() {
646
+ [(re = ze, Symbol.dispose)]() {
647
647
  this.dispose();
648
648
  }
649
649
  addDependency(t) {
650
- if (!(this.flags & L.EXECUTING)) return;
651
- const s = this._currentEpoch;
652
- if (t._lastSeenEpoch === s) return;
653
- t._lastSeenEpoch = s;
654
- const n = this._nextLinks, i = this._prevLinks, r = i.findIndex((o) => o && o.node === t && o.unsub);
655
- if (r !== -1) {
656
- const o = i[r];
657
- 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;
658
658
  return;
659
659
  }
660
660
  try {
661
- const o = t.subscribe(this._notifyCallback);
662
- n.push(new Pt(t, t.version, o));
663
- } catch (o) {
664
- const l = Z(o, J, y.EFFECT_EXECUTION_FAILED);
665
- 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)
666
666
  try {
667
- this._onError(l);
667
+ this._onError(c);
668
668
  } catch {
669
669
  }
670
- n.push(new Pt(t, t.version, void 0));
670
+ n.push(new $t(t, t.version, void 0));
671
671
  }
672
672
  }
673
673
  /**
674
674
  * Executes effect with tracking.
675
675
  */
676
676
  execute(t = !1) {
677
- if (this.flags & (L.DISPOSED | L.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
678
- this._checkInfiniteLoops(), this.flags |= L.EXECUTING, this._execCleanup(), this._prevLinks = this._links;
679
- const s = B.acquire();
680
- 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();
681
681
  let n = !1;
682
682
  try {
683
- const i = k.run(this, this._fn);
684
- this._links = s, n = !0, Ie(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;
685
685
  } catch (i) {
686
- this._links = s, n = !0, this._handleExecutionError(i), this._cleanup = null;
686
+ this._links = e, n = !0, this._handleExecutionError(i), this._cleanup = null;
687
687
  } finally {
688
- this._finalizeDependencies(n, this._prevLinks, s), this.flags &= -9;
688
+ this._finalizeDependencies(n, this._prevLinks, e), this.flags &= -9;
689
689
  }
690
690
  }
691
691
  _handleAsyncResult(t) {
692
- const s = ++this._execId;
692
+ const e = ++this._execId;
693
693
  t.then(
694
694
  (n) => {
695
- if (s !== this._execId || this.flags & L.DISPOSED) {
695
+ if (e !== this._execId || this.flags & k.DISPOSED) {
696
696
  if (typeof n == "function")
697
697
  try {
698
698
  n();
699
699
  } catch (i) {
700
- this._handleExecutionError(i, y.EFFECT_CLEANUP_FAILED);
700
+ this._handleExecutionError(i, b.EFFECT_CLEANUP_FAILED);
701
701
  }
702
702
  return;
703
703
  }
704
704
  typeof n == "function" && (this._cleanup = n);
705
705
  },
706
- (n) => s === this._execId && this._handleExecutionError(n)
706
+ (n) => e === this._execId && this._handleExecutionError(n)
707
707
  );
708
708
  }
709
- _finalizeDependencies(t, s, n) {
710
- 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));
711
711
  }
712
712
  _unsubLinks(t) {
713
- t.forEach((s) => s?.unsub?.());
713
+ t.forEach((e) => e?.unsub?.());
714
714
  }
715
715
  _isDirty() {
716
- const t = this._links, s = k.current;
717
- k.current = null;
716
+ const t = this._links, e = P.current;
717
+ P.current = null;
718
718
  try {
719
719
  return t.some((n) => {
720
720
  const i = n.node;
721
- if (i.flags & fe.IS_COMPUTED)
721
+ if (i.flags & ue.IS_COMPUTED)
722
722
  try {
723
723
  i.value;
724
724
  } catch {
@@ -727,7 +727,7 @@ class Ke extends _e {
727
727
  return i.version !== n.version;
728
728
  });
729
729
  } finally {
730
- k.current = s;
730
+ P.current = e;
731
731
  }
732
732
  }
733
733
  _execCleanup() {
@@ -735,57 +735,57 @@ class Ke extends _e {
735
735
  try {
736
736
  this._cleanup();
737
737
  } catch (t) {
738
- this._handleExecutionError(t, y.EFFECT_CLEANUP_FAILED);
738
+ this._handleExecutionError(t, b.EFFECT_CLEANUP_FAILED);
739
739
  }
740
740
  this._cleanup = null;
741
741
  }
742
742
  }
743
743
  _checkInfiniteLoops() {
744
- const t = me();
745
- 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++;
746
746
  }
747
747
  get isDisposed() {
748
- return (this.flags & L.DISPOSED) !== 0;
748
+ return (this.flags & k.DISPOSED) !== 0;
749
749
  }
750
750
  get executionCount() {
751
751
  return this._executionCount;
752
752
  }
753
753
  get isExecuting() {
754
- return (this.flags & L.EXECUTING) !== 0;
754
+ return (this.flags & k.EXECUTING) !== 0;
755
755
  }
756
756
  _throwInfiniteLoopError(t) {
757
- const s = new J(
758
- `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}`
759
759
  );
760
- throw this.dispose(), console.error(s), s;
760
+ throw this.dispose(), console.error(e), e;
761
761
  }
762
- _handleExecutionError(t, s = y.EFFECT_EXECUTION_FAILED) {
763
- const n = Z(t, J, s);
762
+ _handleExecutionError(t, e = b.EFFECT_EXECUTION_FAILED) {
763
+ const n = tt(t, Z, e);
764
764
  if (console.error(n), this._onError)
765
765
  try {
766
766
  this._onError(n);
767
767
  } catch (i) {
768
- console.error(Z(i, J, y.CALLBACK_ERROR_IN_ERROR_HANDLER));
768
+ console.error(tt(i, Z, b.CALLBACK_ERROR_IN_ERROR_HANDLER));
769
769
  }
770
770
  }
771
771
  }
772
- function X(e, t = {}) {
773
- if (typeof e != "function")
774
- throw new J(y.EFFECT_MUST_BE_FUNCTION);
775
- const s = new Ke(e, t);
776
- 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;
777
777
  }
778
- function ye(e) {
779
- if (typeof e != "function")
778
+ function Ie(s) {
779
+ if (typeof s != "function")
780
780
  throw new TypeError("Batch callback must be a function");
781
- rt.startBatch();
781
+ ot.startBatch();
782
782
  try {
783
- return e();
783
+ return s();
784
784
  } finally {
785
- rt.endBatch();
785
+ ot.endBatch();
786
786
  }
787
787
  }
788
- const d = {
788
+ const g = {
789
789
  /** Used by the SPA router ($.route). */
790
790
  ROUTE: "[atom-route]",
791
791
  /** Used by all reactive binding helpers (bindText, bindCss, bindAttr, …). */
@@ -794,57 +794,57 @@ const d = {
794
794
  LIST: "[atom-list]",
795
795
  /** Used by mount/unmount lifecycle helpers. */
796
796
  MOUNT: "[atom-mount]"
797
- }, dt = Object.freeze({
797
+ }, _t = Object.freeze({
798
798
  mode: "hash",
799
799
  basePath: "",
800
800
  autoBindLinks: !1,
801
801
  activeClass: "active"
802
- }), Ye = {
802
+ }), We = {
803
803
  EVENT: "input"
804
- }, We = /* @__PURE__ */ new Set(["input", "select", "textarea"]), Je = /* @__PURE__ */ new Set([
804
+ }, Je = /* @__PURE__ */ new Set(["input", "select", "textarea"]), Ze = /* @__PURE__ */ new Set([
805
805
  "innerHTML",
806
806
  "outerHTML",
807
807
  "srcdoc",
808
808
  "__proto__",
809
809
  "constructor",
810
810
  "prototype"
811
- ]), S = {
812
- ROUTE_NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
813
- TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
814
- TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
815
- 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}`,
816
816
  /** Emitted when sanitizeHtml modifies the input. Prefixed at call site with LOG_PREFIXES.BINDING or LIST to identify the originating subsystem. */
817
817
  UNSAFE_CONTENT: () => "Unsafe content neutralized during sanitization.",
818
818
  /** Emitted by bindCss when a CSS style property value contains a dangerous protocol. */
819
- BLOCKED_DANGEROUS_CSS_VALUE: (e) => `Blocked dangerous value in CSS style property "${e}".`,
820
- BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute "${e}".`,
821
- BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}" attribute.`,
822
- BLOCKED_DANGEROUS_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`,
823
- INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
824
- MISSING_SOURCE: (e) => `[${e}] source is required when prop/name is a string.`,
825
- MISSING_CONDITION: (e) => `[${e}] condition is required when className is a string.`,
826
- DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.`,
827
- 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}"`,
828
828
  EFFECT_DISPOSE_ERROR: () => "Effect dispose error",
829
829
  BINDING_CLEANUP_ERROR: () => "Binding cleanup error",
830
830
  PARSE_ERROR: () => "parse() threw during DOM→Atom sync",
831
831
  MOUNT_ERROR: () => "Mount error",
832
832
  MOUNT_CLEANUP_ERROR: () => "Cleanup error"
833
833
  };
834
- function Ce(e) {
835
- return qt(e);
834
+ function ye(s) {
835
+ return qt(s);
836
836
  }
837
- function Xt(e) {
838
- const t = e.tagName.toLowerCase();
839
- if (e.id) return `${t}#${e.id}`;
840
- 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;
841
841
  if (n === 0) return t;
842
842
  let i = t;
843
- for (let r = 0; r < n; r++)
844
- i += `.${s[r]}`;
843
+ for (let o = 0; o < n; o++)
844
+ i += `.${e[o]}`;
845
845
  return i;
846
846
  }
847
- const Ze = /* @__PURE__ */ new Set([
847
+ const ts = /* @__PURE__ */ new Set([
848
848
  "href",
849
849
  "src",
850
850
  "action",
@@ -860,98 +860,106 @@ const Ze = /* @__PURE__ */ new Set([
860
860
  "usemap",
861
861
  "classid",
862
862
  "codebase"
863
- ]), ts = Object.prototype.hasOwnProperty, es = /^\s*(?:javascript|vbscript)\s*:/i, ss = (
863
+ ]), rt = Object.prototype.hasOwnProperty, es = /^\s*(?:javascript|vbscript)\s*:/i, ss = (
864
864
  // biome-ignore lint/suspicious/noControlCharactersInRegex: Intentionally matching control characters for XSS sanitization
865
- /(?: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
866
- ), 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");
867
- function Bt(e) {
868
- let t = String(e ?? "");
869
- t = t.replace(is, ""), t = t.replace(rs, "");
870
- 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;
871
879
  do
872
- s = t, t = t.replace(os, "");
873
- while (t !== s);
874
- 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;
875
- }
876
- function ls(e, t) {
877
- return Ze.has(e.toLowerCase()) ? es.test(t) : !1;
878
- }
879
- function fs(e) {
880
- return e.toLowerCase().includes("url(") ? ns.test(e) : !1;
881
- }
882
- function ds(e, t) {
883
- if (e === t) return !0;
884
- if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
885
- const s = Object.keys(e), n = Object.keys(t);
886
- if (s.length !== n.length) return !1;
887
- const i = e, r = t;
888
- for (let o = 0; o < s.length; o++) {
889
- const l = s[o];
890
- 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])
891
899
  return !1;
892
900
  }
893
901
  return !0;
894
902
  }
895
- function _s(e) {
896
- const t = e.length;
903
+ function gs(s) {
904
+ const t = s.length;
897
905
  if (t === 0) return new Int32Array(0);
898
- const s = new Int32Array(t).fill(-1), n = new Int32Array(t);
906
+ const e = new Int32Array(t).fill(-1), n = new Int32Array(t);
899
907
  let i = 0;
900
- for (let o = 0; o < t; o++) {
901
- const l = e[o];
902
- if (l === void 0 || l === -1) continue;
903
- const p = i > 0 ? n[i - 1] : void 0;
904
- if (i === 0 || p !== void 0 && (e[p] ?? -1) < l) {
905
- 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;
906
914
  continue;
907
915
  }
908
- let C = 0, b = i - 1;
909
- for (; C < b; ) {
910
- const E = C + b >>> 1, m = n[E];
911
- 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;
912
920
  }
913
- const N = n[C];
914
- 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);
915
923
  }
916
- const r = new Int32Array(i);
924
+ const o = new Int32Array(i);
917
925
  if (i > 0) {
918
- let o = n[i - 1];
919
- for (let l = i - 1; l >= 0 && o !== void 0 && o !== -1; l--)
920
- 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];
921
929
  }
922
- return r;
930
+ return o;
923
931
  }
924
- const Es = {}, be = 600, ps = `${be / 1e3}s`;
925
- function ms() {
932
+ const ms = {}, Ce = 600, Is = `${Ce / 1e3}s`;
933
+ function ys() {
926
934
  if (typeof window < "u") {
927
- const e = window.__ATOM_DEBUG__;
928
- if (typeof e == "boolean") return e;
935
+ const s = window.__ATOM_DEBUG__;
936
+ if (typeof s == "boolean") return s;
929
937
  }
930
- return Es?.VITE_ATOM_DEBUG === "true";
938
+ return ms?.VITE_ATOM_DEBUG === "true";
931
939
  }
932
- let Y = ms();
940
+ let W = ys();
933
941
  const f = {
934
942
  get enabled() {
935
- return Y;
943
+ return W;
936
944
  },
937
- set enabled(e) {
938
- Y = e;
945
+ set enabled(s) {
946
+ W = s;
939
947
  },
940
948
  /**
941
949
  * Logs a message only when debug mode is active.
942
950
  */
943
- log(e, ...t) {
944
- Y && console.log(`${d.MOUNT} ${e}:`, ...t);
951
+ log(s, ...t) {
952
+ W && console.log(`${g.MOUNT} ${s}:`, ...t);
945
953
  },
946
954
  /**
947
955
  * Logs an atom value change only when debug mode is active.
948
956
  */
949
- atomChanged(e, t, s) {
950
- Y && console.log(
951
- `${d.MOUNT} Atom "${e ?? "anonymous"}" changed:`,
957
+ atomChanged(s, t, e) {
958
+ W && console.log(
959
+ `${g.MOUNT} Atom "${s ?? "anonymous"}" changed:`,
952
960
  t,
953
961
  "→",
954
- s
962
+ e
955
963
  );
956
964
  },
957
965
  /**
@@ -962,16 +970,16 @@ const f = {
962
970
  * @param type - The binding type (e.g. 'text', 'checked', 'attr.href').
963
971
  * @param value - The new value that was applied.
964
972
  */
965
- domUpdated(e, t, s) {
966
- if (!Y) return;
967
- const n = e instanceof Element ? e : e[0];
968
- 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));
969
977
  },
970
978
  /**
971
979
  * Logs a cleanup event only when debug mode is active.
972
980
  */
973
- cleanup(e) {
974
- Y && console.log(`${d.MOUNT} Cleanup: ${e}`);
981
+ cleanup(s) {
982
+ W && console.log(`${g.MOUNT} Cleanup: ${s}`);
975
983
  },
976
984
  /**
977
985
  * Unconditional warning for runtime errors and unexpected states.
@@ -983,44 +991,44 @@ const f = {
983
991
  * originating subsystem appears in the log rather than the generic MOUNT tag.
984
992
  * Pass an empty string to emit a prefix-free message.
985
993
  */
986
- warn(e, t, ...s) {
987
- console.warn(`${e} ${t}`, ...s);
994
+ warn(s, t, ...e) {
995
+ console.warn(`${s} ${t}`, ...e);
988
996
  },
989
997
  /**
990
998
  * Unconditional error for binding failures.
991
999
  * Not gated by debugEnabled — binding errors are always surfaced because
992
1000
  * they indicate a broken updater that silently stopped applying values.
993
1001
  */
994
- error(e, t, s) {
995
- console.error(`${e} ${t}`, s);
996
- }
997
- }, Ht = "atom-debug-highlight", gs = "data-atom-debug";
998
- let ae;
999
- function Is() {
1000
- if (ae?.deref()?.isConnected) return;
1001
- const e = document.createElement("style");
1002
- 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);
1003
- }
1004
- const kt = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
1005
- function ys(e) {
1006
- if (!e.isConnected) return;
1007
- Is();
1008
- 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);
1009
1017
  t !== void 0 && cancelAnimationFrame(t);
1010
- const s = kt.get(e);
1011
- s !== void 0 && clearTimeout(s);
1018
+ const e = xt.get(s);
1019
+ e !== void 0 && clearTimeout(e);
1012
1020
  const n = requestAnimationFrame(() => {
1013
- xt.delete(e), e.classList.add(Ht), kt.set(
1014
- e,
1021
+ Pt.delete(s), s.classList.add(Gt), xt.set(
1022
+ s,
1015
1023
  setTimeout(() => {
1016
- e.classList.remove(Ht), kt.delete(e);
1017
- }, be)
1024
+ s.classList.remove(Gt), xt.delete(s);
1025
+ }, Ce)
1018
1026
  );
1019
1027
  });
1020
- xt.set(e, n);
1028
+ Pt.set(s, n);
1021
1029
  }
1022
- function Se(e, t) {
1023
- return Ft(e, t);
1030
+ function Se(s, t) {
1031
+ return Bt(s, t);
1024
1032
  }
1025
1033
  Object.defineProperty(Se, "debug", {
1026
1034
  enumerable: !0,
@@ -1031,31 +1039,31 @@ Object.defineProperty(Se, "debug", {
1031
1039
  get() {
1032
1040
  return f.enabled;
1033
1041
  },
1034
- set(e) {
1035
- f.enabled = e;
1042
+ set(s) {
1043
+ f.enabled = s;
1036
1044
  }
1037
1045
  });
1038
- function Cs() {
1039
- return new Promise((e) => setTimeout(e, 0));
1046
+ function Ts() {
1047
+ return new Promise((s) => setTimeout(s, 0));
1040
1048
  }
1041
- const bs = {
1049
+ const Rs = {
1042
1050
  // `atom` carries a runtime `debug` accessor added via Object.defineProperty.
1043
1051
  // TypeScript cannot see it through the declared function type, so the double
1044
1052
  // cast is unavoidable. The NamespaceExtensions annotation still verifies all
1045
1053
  // other fields; only `atom`'s shape escapes static checking here.
1046
1054
  atom: Se,
1047
- computed: Ct,
1055
+ computed: St,
1048
1056
  effect: X,
1049
- batch: ye,
1057
+ batch: Ie,
1050
1058
  untracked: H,
1051
1059
  isAtom: qt,
1052
- isComputed: Ve,
1053
- isReactive: Ce,
1054
- nextTick: Cs
1060
+ isComputed: qe,
1061
+ isReactive: ye,
1062
+ nextTick: Ts
1055
1063
  };
1056
- c.extend(bs);
1057
- const W = "_aes-bound";
1058
- class Ss {
1064
+ l.extend(Rs);
1065
+ const J = "_aes-bound";
1066
+ class Ns {
1059
1067
  constructor() {
1060
1068
  this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
1061
1069
  }
@@ -1078,20 +1086,20 @@ class Ss {
1078
1086
  // Tracking
1079
1087
  // --------------------------------------------------------------------------
1080
1088
  getOrCreateRecord(t) {
1081
- let s = this.records.get(t);
1082
- 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;
1083
1091
  }
1084
- trackEffect(t, s) {
1092
+ trackEffect(t, e) {
1085
1093
  const n = this.getOrCreateRecord(t);
1086
- n.effects ??= [], n.effects.push(s);
1094
+ n.effects ??= [], n.effects.push(e);
1087
1095
  }
1088
- trackCleanup(t, s) {
1096
+ trackCleanup(t, e) {
1089
1097
  const n = this.getOrCreateRecord(t);
1090
- n.cleanups ??= [], n.cleanups.push(s);
1098
+ n.cleanups ??= [], n.cleanups.push(e);
1091
1099
  }
1092
- setComponentCleanup(t, s) {
1100
+ setComponentCleanup(t, e) {
1093
1101
  const n = this.getOrCreateRecord(t);
1094
- n.componentCleanup = s;
1102
+ n.componentCleanup = e;
1095
1103
  }
1096
1104
  hasBind(t) {
1097
1105
  return this.records.has(t);
@@ -1100,160 +1108,171 @@ class Ss {
1100
1108
  // Cleanup
1101
1109
  // --------------------------------------------------------------------------
1102
1110
  cleanup(t) {
1103
- const s = this.records.get(t);
1104
- if (!s) {
1105
- 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);
1106
1114
  return;
1107
1115
  }
1108
- 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)
1109
1117
  try {
1110
- s.componentCleanup();
1118
+ e.componentCleanup();
1111
1119
  } catch (n) {
1112
- f.error(d.MOUNT, S.MOUNT_CLEANUP_ERROR(), n);
1113
- }
1114
- s.effects?.forEach((n) => {
1115
- try {
1116
- n.dispose();
1117
- } catch (i) {
1118
- f.error(d.BINDING, S.EFFECT_DISPOSE_ERROR(), i);
1120
+ f.error(g.MOUNT, T.MOUNT_CLEANUP_ERROR(), n);
1119
1121
  }
1120
- }), s.cleanups?.forEach((n) => {
1121
- try {
1122
- n();
1123
- } catch (i) {
1124
- f.error(d.BINDING, S.BINDING_CLEANUP_ERROR(), i);
1125
- }
1126
- });
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
+ }
1127
1140
  }
1128
1141
  cleanupDescendants(t) {
1129
- const s = t.querySelectorAll(`.${W}`);
1130
- for (const n of s)
1131
- this.records.has(n) ? this.cleanup(n) : (n.classList.remove(W), f.warn(
1132
- d.BINDING,
1133
- `${W} class found on unregistered element:`,
1134
- n
1135
- ));
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
+ }
1136
1151
  }
1137
1152
  cleanupTree(t) {
1138
1153
  this.cleanupDescendants(t), this.cleanup(t);
1139
1154
  }
1140
1155
  }
1141
- const g = new Ss();
1142
- let it = null, Et = null;
1143
- function Rs(e) {
1156
+ const y = new Ns();
1157
+ let it = null, pt = null;
1158
+ function Os(s) {
1144
1159
  if (it !== null) {
1145
- Et !== e && f.warn(
1146
- d.BINDING,
1160
+ pt !== s && f.warn(
1161
+ g.BINDING,
1147
1162
  "enableAutoCleanup() called with a different root while already active. Observation was NOT switched — call disableAutoCleanup() first.",
1148
- { current: Et, requested: e }
1163
+ { current: pt, requested: s }
1149
1164
  );
1150
1165
  return;
1151
1166
  }
1152
- Et = e, it = new MutationObserver((t) => {
1153
- for (const s of t)
1154
- for (const n of s.removedNodes)
1155
- n.nodeType === 1 && (n.isConnected || g.isKept(n) || g.isIgnored(n) || g.cleanupTree(n));
1156
- }), 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 });
1157
1176
  }
1158
- function Gs() {
1159
- it?.disconnect(), it = null, Et = null;
1177
+ function Vs() {
1178
+ it?.disconnect(), it = null, pt = null;
1160
1179
  }
1161
- function Q(e, t, s, n) {
1162
- if (Ce(t)) {
1180
+ function Q(s, t, e, n) {
1181
+ if (ye(t)) {
1163
1182
  const i = t;
1164
- g.trackEffect(
1165
- e,
1183
+ y.trackEffect(
1184
+ s,
1166
1185
  X(() => {
1167
- const r = i.value;
1186
+ const o = i.value;
1168
1187
  H(() => {
1169
1188
  try {
1170
- s(r);
1171
- } catch (o) {
1172
- 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);
1173
1192
  return;
1174
1193
  }
1175
- f.enabled && f.domUpdated(e, n, r);
1194
+ f.enabled && f.domUpdated(s, n, o);
1176
1195
  });
1177
1196
  })
1178
1197
  );
1179
1198
  } else {
1180
1199
  try {
1181
- s(t);
1200
+ e(t);
1182
1201
  } catch (i) {
1183
- f.error(d.BINDING, `${S.UPDATER_ERROR(n)} (static):`, i);
1202
+ f.error(g.BINDING, `${T.UPDATER_ERROR(n)} (static):`, i);
1184
1203
  return;
1185
1204
  }
1186
- f.enabled && f.domUpdated(e, n, t);
1205
+ f.enabled && f.domUpdated(s, n, t);
1187
1206
  }
1188
1207
  }
1189
1208
  const F = /* @__PURE__ */ Symbol("atom-effect-internal"), mt = /* @__PURE__ */ new WeakMap();
1190
- let w = null;
1191
- const Re = (e) => {
1192
- if (e[F]) return e;
1193
- let t = mt.get(e);
1194
- return t || (t = function(...s) {
1195
- return ye(() => e.apply(this, s));
1196
- }, 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;
1197
1216
  };
1198
- function Ts(e) {
1217
+ function Ds(s) {
1199
1218
  const t = {};
1200
- return Object.keys(e).forEach((s) => {
1201
- const n = e[s];
1202
- n && (t[s] = Re(n));
1219
+ return Object.keys(s).forEach((e) => {
1220
+ const n = s[e];
1221
+ n && (t[e] = be(n));
1203
1222
  }), t;
1204
1223
  }
1205
- function Os(e) {
1224
+ function vs(s) {
1206
1225
  const t = {};
1207
- return Object.keys(e).forEach((s) => {
1208
- const n = e[s];
1209
- 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;
1210
1229
  }), t;
1211
1230
  }
1212
- function Ns() {
1213
- if (w !== null) return;
1214
- w = {
1215
- on: c.fn.on,
1216
- off: c.fn.off,
1217
- remove: c.fn.remove,
1218
- empty: c.fn.empty,
1219
- 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
1220
1239
  };
1221
- const e = w;
1222
- c.fn.remove = function(t) {
1223
- const s = t ? this.filter(t) : this;
1224
- for (let n = 0, i = s.length; n < i; n++) {
1225
- const r = s[n];
1226
- 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));
1227
1246
  }
1228
- return e.remove.call(this, t);
1229
- }, c.fn.empty = function() {
1230
- 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++) {
1231
1250
  const n = this[t];
1232
- n && g.cleanupDescendants(n);
1251
+ n && y.cleanupDescendants(n);
1233
1252
  }
1234
- return e.empty.call(this);
1235
- }, c.fn.detach = function(t) {
1236
- const s = t ? this.filter(t) : this;
1237
- for (let n = 0, i = s.length; n < i; n++) {
1238
- const r = s[n];
1239
- 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);
1240
1259
  }
1241
- return e.detach.call(this, t);
1242
- }, c.fn.on = function(...t) {
1243
- const s = t[0];
1244
- if (s && typeof s == "object")
1245
- t[0] = Ts(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);
1246
1265
  else
1247
1266
  for (let n = t.length - 1; n >= 0; n--)
1248
1267
  if (typeof t[n] == "function") {
1249
- t[n] = Re(t[n]);
1268
+ t[n] = be(t[n]);
1250
1269
  break;
1251
1270
  }
1252
- return e.on.apply(this, t);
1253
- }, c.fn.off = function(...t) {
1254
- const s = t[0];
1255
- if (s && typeof s == "object")
1256
- 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);
1257
1276
  else
1258
1277
  for (let n = t.length - 1; n >= 0; n--)
1259
1278
  if (typeof t[n] == "function") {
@@ -1261,483 +1280,497 @@ function Ns() {
1261
1280
  t[n] = mt.get(i) ?? i;
1262
1281
  break;
1263
1282
  }
1264
- return e.off.apply(this, t);
1283
+ return s.off.apply(this, t);
1265
1284
  };
1266
1285
  }
1267
- function js() {
1268
- 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);
1269
1288
  }
1270
- var T = /* @__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))(T || {});
1271
- let vs = 0;
1272
- class Ds {
1273
- constructor(t, s, n) {
1274
- this.flags = 0, this.timeoutId = void 0, this.ns = `.atomBind-${++vs}`, this.handleCompositionStart = () => {
1275
- this.flags |= T.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;
1276
1295
  }, this.handleCompositionEnd = () => {
1277
- this.flags &= ~T.Composing, this.handleInput();
1296
+ this.flags &= ~v.Composing, this.handleInput();
1278
1297
  }, this.handleFocus = () => {
1279
- this.flags |= T.Focused;
1298
+ this.flags |= v.Focused;
1280
1299
  }, this.handleBlur = () => {
1281
- this.flags &= ~T.Focused, this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
1282
- 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());
1283
1302
  this.el.value !== r && (this.el.value = r);
1284
1303
  }, this.syncDomFromAtom = () => {
1285
1304
  const r = this.atom.value;
1286
1305
  H(() => {
1287
- const o = this.options.format(r), l = this.el.value;
1288
- if (l === o) return;
1289
- const p = !!(this.flags & T.Focused);
1290
- 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)
1291
1310
  try {
1292
- if (this.options.equal(this.options.parse(l), r)) return;
1311
+ if (this.equal(this.parse(E), r)) return;
1293
1312
  } catch {
1294
1313
  }
1295
- this.flags |= T.SyncingToDom;
1314
+ this.flags |= v.SyncingToDom;
1296
1315
  try {
1297
- if (p && (this.el instanceof HTMLInputElement || this.el instanceof HTMLTextAreaElement)) {
1298
- const C = this.el.selectionStart, b = this.el.selectionEnd;
1299
- this.el.value = o;
1300
- const N = o.length;
1301
- 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);
1302
1321
  } else
1303
- this.el.value = o;
1304
- f.domUpdated(this.$el, "val", o);
1322
+ this.el.value = c;
1323
+ f.domUpdated(this.$el, "val", c);
1305
1324
  } finally {
1306
- this.flags &= ~T.SyncingToDom;
1325
+ this.flags &= ~v.SyncingToDom;
1307
1326
  }
1308
1327
  });
1309
1328
  }, this.cleanup = () => {
1310
1329
  this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
1311
- }, this.$el = t, this.el = t[0], this.atom = s;
1312
- const i = n.debounce ?? 0;
1313
- this.options = {
1314
- debounce: i,
1315
- event: n.event ?? Ye.EVENT,
1316
- parse: n.parse ?? ((r) => r),
1317
- format: n.format ?? ((r) => String(r ?? "")),
1318
- equal: n.equal ?? Object.is
1319
- }, i > 0 ? this.handleInput = () => {
1320
- this.flags & T.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));
1321
1334
  } : this.handleInput = () => {
1322
- this.flags & T.Composing || this.syncAtomFromDom();
1323
- }, 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);
1324
1337
  }
1325
1338
  // --- Sync Logic ---
1326
1339
  syncAtomFromDom() {
1327
- if (!(this.flags & T.Busy)) {
1328
- this.flags |= T.SyncingToAtom;
1340
+ if (!(this.flags & v.Busy)) {
1341
+ this.flags |= v.SyncingToAtom;
1329
1342
  try {
1330
- const t = this.options.parse(this.el.value);
1331
- 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);
1332
1345
  } catch (t) {
1333
- f.warn(d.BINDING, `${S.PARSE_ERROR()}:`, t);
1346
+ f.warn(g.BINDING, `${T.PARSE_ERROR()}:`, t);
1334
1347
  } finally {
1335
- this.flags &= ~T.SyncingToAtom;
1348
+ this.flags &= ~v.SyncingToAtom;
1336
1349
  }
1337
1350
  }
1338
1351
  }
1339
- bindEvents() {
1340
- 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);
1341
1355
  }
1342
1356
  }
1343
- function As(e, t, s) {
1344
- const n = new Ds(e, t, s);
1357
+ function ws(s, t, e) {
1358
+ const n = new Us(s, t, e);
1345
1359
  return { fx: X(n.syncDomFromAtom), cleanup: n.cleanup };
1346
1360
  }
1347
- const he = /* @__PURE__ */ new Map();
1348
- function Us(e) {
1349
- let t = he.get(e);
1350
- 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;
1351
1365
  }
1352
- const ue = /* @__PURE__ */ new WeakMap();
1353
- function Ls(e) {
1354
- let t = ue.get(e);
1355
- 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;
1356
1370
  }
1357
- function D(e) {
1371
+ function U(s) {
1358
1372
  return {
1359
- $el: c(e),
1360
- el: e,
1361
- trackCleanup: (t) => g.trackCleanup(e, t)
1373
+ $el: l(s),
1374
+ el: s,
1375
+ trackCleanup: (t) => y.trackCleanup(s, t)
1362
1376
  };
1363
1377
  }
1364
- function Te(e, t, s) {
1365
- const n = e.el;
1378
+ function Te(s, t, e) {
1379
+ const n = s.el;
1366
1380
  Q(
1367
1381
  n,
1368
1382
  t,
1369
1383
  (i) => {
1370
- const r = s ? s(i) : typeof i == "string" ? i : String(i ?? "");
1371
- 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);
1372
1386
  },
1373
1387
  "text"
1374
1388
  );
1375
1389
  }
1376
- function Oe(e, t) {
1377
- 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;
1378
1392
  Q(
1379
- s,
1393
+ e,
1380
1394
  n,
1381
1395
  (i) => {
1382
- s.innerHTML !== i && (g.cleanupDescendants(s), s.innerHTML = i);
1396
+ e.innerHTML !== i && (y.cleanupDescendants(e), e.innerHTML = i);
1383
1397
  },
1384
1398
  "html"
1385
1399
  );
1386
1400
  }
1387
- function Ne(e, t) {
1388
- Object.entries(t).forEach(([s, n]) => {
1389
- Q(
1390
- e.el,
1391
- n,
1392
- (i) => {
1393
- e.el.classList.toggle(s, !!i);
1394
- },
1395
- `class.${s}`
1396
- );
1397
- });
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
+ }
1398
1414
  }
1399
- function ve(e, t) {
1400
- const s = e.el, n = s.style;
1401
- Object.entries(t).forEach(([i, r]) => {
1402
- const o = Us(i), [l, p] = Array.isArray(r) ? r : [r, ""];
1403
- Q(
1404
- s,
1405
- l,
1406
- (C) => {
1407
- const b = p ? `${C}${p}` : String(C);
1408
- fs(b) || (n[o] = b);
1409
- },
1410
- `css.${i}`
1411
- );
1412
- });
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
+ }
1413
1430
  }
1414
- function De(e, t) {
1415
- const s = e.el;
1416
- Object.keys(t).forEach((n) => {
1417
- n.toLowerCase().startsWith("on") || Q(
1418
- s,
1419
- t[n],
1420
- (i) => {
1421
- if (i == null || i === !1) {
1422
- s.removeAttribute(n);
1423
- return;
1424
- }
1425
- const r = i === !0 ? n : String(i);
1426
- ls(n, r) || s.getAttribute(n) !== r && s.setAttribute(n, r);
1427
- },
1428
- `attr.${n}`
1429
- );
1430
- });
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
+ }
1431
1450
  }
1432
- function Ae(e, t) {
1433
- const s = e.el;
1434
- Object.keys(t).forEach((n) => {
1435
- Je.has(n) || Q(
1436
- e.el,
1437
- t[n],
1438
- (i) => {
1439
- s[n] !== i && (s[n] = i);
1440
- },
1441
- `prop.${n}`
1442
- );
1443
- });
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
+ }
1444
1465
  }
1445
- function gt(e, t, s) {
1446
- const n = e.el;
1466
+ function It(s, t, e) {
1467
+ const n = s.el;
1447
1468
  Q(
1448
1469
  n,
1449
1470
  t,
1450
- (r) => {
1451
- const o = s !== !!r;
1452
- n.style.display = o ? "" : "none";
1471
+ (o) => {
1472
+ const r = e !== !!o;
1473
+ n.style.display = r ? "" : "none";
1453
1474
  },
1454
- s ? "hide" : "show"
1475
+ e ? "hide" : "show"
1455
1476
  );
1456
1477
  }
1457
- function Gt(e, t, s = {}) {
1458
- const n = e.el.tagName.toLowerCase();
1459
- if (!We.has(n)) {
1460
- 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)}`);
1461
1482
  return;
1462
1483
  }
1463
- const { fx: i, cleanup: r } = As(e.$el, t, s);
1464
- 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);
1465
1486
  }
1466
- function Ue(e, t) {
1467
- const s = e.el, n = e.$el, i = () => {
1468
- const o = s.checked;
1469
- 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);
1470
1491
  };
1471
- i[F] = !0, n.on("change", i), e.trackCleanup(() => n.off("change", i));
1472
- const r = X(() => {
1473
- 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;
1474
1495
  H(() => {
1475
- s.checked !== o && (s.checked = o, f.domUpdated(n, "checked", o));
1496
+ e.checked !== r && (e.checked = r, f.domUpdated(n, "checked", r));
1476
1497
  });
1477
1498
  });
1478
- g.trackEffect(s, r);
1499
+ y.trackEffect(e, o);
1479
1500
  }
1480
- function ws(e, t) {
1481
- const s = e.$el;
1482
- 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));
1483
1504
  }
1484
- function ks(e, t, s) {
1485
- const n = e.$el;
1486
- 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));
1487
1508
  }
1488
- function Le(e) {
1489
- g.cleanupTree(e);
1509
+ function Ue(s) {
1510
+ y.cleanupTree(s);
1490
1511
  }
1491
- c.fn.atomText = function(e, t) {
1492
- return this.each(function() {
1493
- Te(D(this), e, t);
1494
- });
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;
1495
1516
  };
1496
- c.fn.atomHtml = function(e) {
1497
- return this.each(function() {
1498
- Oe(D(this), e);
1499
- });
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;
1500
1521
  };
1501
- c.fn.atomClass = function(e, t) {
1502
- if (typeof e == "string" && t === void 0)
1503
- return console.warn(`${d.BINDING} ${S.MISSING_CONDITION("atomClass")}`), this;
1504
- const s = typeof e == "string" ? { [e]: t } : e;
1505
- return this.each(function() {
1506
- Ne(D(this), s);
1507
- });
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;
1508
1529
  };
1509
- c.fn.atomCss = function(e, t, s) {
1510
- if (typeof e == "string" && t === void 0)
1511
- return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomCss")}`), this;
1512
- const n = typeof e == "string" ? { [e]: s ? [t, s] : t } : e;
1513
- return this.each(function() {
1514
- ve(D(this), n);
1515
- });
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;
1516
1537
  };
1517
- c.fn.atomAttr = function(e, t) {
1518
- if (typeof e == "string" && t === void 0)
1519
- return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomAttr")}`), this;
1520
- const s = typeof e == "string" ? { [e]: t } : e;
1521
- return this.each(function() {
1522
- De(D(this), s);
1523
- });
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;
1524
1545
  };
1525
- c.fn.atomProp = function(e, t) {
1526
- if (typeof e == "string" && t === void 0)
1527
- return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomProp")}`), this;
1528
- const s = typeof e == "string" ? { [e]: t } : e;
1529
- return this.each(function() {
1530
- Ae(D(this), s);
1531
- });
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;
1532
1553
  };
1533
- c.fn.atomShow = function(e) {
1534
- return this.each(function() {
1535
- gt(D(this), e, !1);
1536
- });
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;
1537
1558
  };
1538
- c.fn.atomHide = function(e) {
1539
- return this.each(function() {
1540
- gt(D(this), e, !0);
1541
- });
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;
1542
1563
  };
1543
- c.fn.atomVal = function(e, t = {}) {
1544
- return this.each(function() {
1545
- Gt(D(this), e, t);
1546
- });
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;
1547
1568
  };
1548
- c.fn.atomChecked = function(e) {
1549
- return this.each(function() {
1550
- Ue(D(this), e);
1551
- });
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;
1552
1573
  };
1553
- c.fn.atomOn = function(e, t) {
1554
- return this.each(function() {
1555
- ks(D(this), e, t);
1556
- });
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;
1557
1578
  };
1558
- c.fn.atomBind = function(e) {
1559
- return this.each(function() {
1560
- const t = D(this);
1561
- if (e.text !== void 0 && Te(t, e.text), e.html !== void 0 && Oe(t, e.html), e.class !== void 0 && Ne(t, e.class), e.css !== void 0 && ve(t, e.css), e.attr !== void 0 && De(t, e.attr), e.prop !== void 0 && Ae(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)
1562
- if (Array.isArray(e.val)) {
1563
- const [s, n] = e.val;
1564
- Gt(t, s, n);
1565
- } else
1566
- Gt(t, e.val);
1567
- e.checked !== void 0 && Ue(t, e.checked), e.on !== void 0 && ws(t, e.on);
1568
- });
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;
1569
1588
  };
1570
- c.fn.atomUnbind = function() {
1571
- return this.each(function() {
1572
- Le(this);
1573
- });
1589
+ l.fn.atomUnbind = function() {
1590
+ for (let s = 0, t = this.length; s < t; s++)
1591
+ Ue(this[s]);
1592
+ return this;
1574
1593
  };
1575
- function xs(e, t, s) {
1576
- t?.isConnected ? e.insertBefore(t) : e.appendTo(s);
1577
- }
1578
- c.fn.atomList = function(e, t) {
1579
- 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];
1580
- return this.each(function() {
1581
- const b = c(this), N = Xt(this), E = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
1582
- let P = [], U = null;
1583
- const G = (v, R) => {
1584
- const j = () => {
1585
- bt?.isDisposed || (R.$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));
1586
1605
  };
1587
- if (l) {
1588
- const M = l(R.$el);
1589
- M instanceof Promise ? M.then(j, j) : j();
1590
- } else
1591
- j();
1592
- }, Qt = (v, R) => {
1593
- E.delete(v), m.add(v), G(v, R);
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);
1594
1614
  };
1595
1615
  let bt;
1596
1616
  bt = X(() => {
1597
- const v = e.value, R = v.length;
1617
+ const L = s.value, D = L.length;
1598
1618
  H(() => {
1599
- if (U && R > 0 && (U.remove(), U = null), R === 0) {
1600
- if (p && !U) {
1601
- const a = typeof p == "string" ? Bt(p) : p;
1602
- 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, _);
1603
1627
  }
1604
- E.forEach((a, h) => {
1605
- m.has(h) || Qt(h, a);
1606
- }), P = [];
1628
+ R.length = 0;
1607
1629
  return;
1608
1630
  }
1609
- f.log("list", `${N} updating with ${R} items`);
1610
- const j = /* @__PURE__ */ new Map();
1611
- for (let a = 0; a < P.length; a++)
1612
- j.set(P[a], a);
1613
- const M = new Array(R), St = /* @__PURE__ */ new Set(), ot = new Int32Array(R), ct = [], Rt = [], Tt = [];
1614
- for (let a = 0; a < R; a++) {
1615
- const h = v[a], _ = C(h, a);
1616
- if (M[a] = _, St.has(_)) {
1617
- 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;
1618
1640
  continue;
1619
1641
  }
1620
- St.add(_);
1621
- const I = E.get(_);
1622
- if (I) {
1623
- const u = I.item;
1624
- !r && u !== h && !ds(u, h) && (ct.push(_), Rt.push(h), Tt.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;
1625
1647
  } else
1626
- ct.push(_), Rt.push(h), Tt.push(a), ot[a] = -1;
1648
+ at.push(_), Rt.push(h), Nt.push(a), ct[a] = -1;
1627
1649
  }
1628
- const Kt = "<!--sep-->", at = ct.length, Yt = new Array(
1629
- at
1650
+ const lt = at.length, Yt = new Array(
1651
+ lt
1630
1652
  ), Ot = [];
1631
- for (let a = 0; a < at; a++) {
1632
- const h = n(Rt[a], Tt[a]);
1653
+ for (let a = 0; a < lt; a++) {
1654
+ const h = n(Rt[a], Nt[a]);
1633
1655
  Yt[a] = h, typeof h == "string" && Ot.push(h);
1634
1656
  }
1635
1657
  let ht = null;
1636
1658
  if (Ot.length > 0) {
1637
- const a = Ot.join(Kt);
1638
- 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);
1639
1661
  }
1640
- let Wt = 0;
1641
- for (let a = 0; a < at; a++) {
1642
- 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);
1643
1665
  if (u) {
1644
- const A = u.$el[0];
1645
- 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";
1646
1668
  } else
1647
- E.set(I, { $el: _, item: null, state: "new" });
1669
+ C.set(S, { $el: _, item: null, state: "new" });
1648
1670
  }
1649
- for (const [a, h] of E)
1650
- !St.has(a) && !m.has(a) && Qt(a, h);
1651
- const Jt = _s(ot);
1652
- let Nt = Jt.length - 1, Zt = null;
1653
- const vt = P.length === 0;
1654
- if (vt && ht !== null && Wt === at && !i && !o && !l && m.size === 0) {
1655
- 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("");
1656
1683
  let a = 0;
1657
- for (let h = 0; h < R; h++) {
1658
- 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(_);
1659
1686
  if (!u) continue;
1660
- const A = this.children[a++];
1661
- 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));
1662
1689
  }
1663
1690
  } else {
1664
1691
  const a = vt ? document.createDocumentFragment() : null;
1665
1692
  if (vt && a) {
1666
- for (let h = R - 1; h >= 0; h--) {
1667
- 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(_);
1668
1695
  if (!u) continue;
1669
- const A = u.state, x = A === "new", et = A === "replaced";
1670
- 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));
1671
- for (let Dt = u.$el.length - 1; Dt >= 0; Dt--)
1672
- a.insertBefore(u.$el[Dt], a.firstChild);
1673
- 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));
1674
1701
  }
1675
- this.appendChild(a);
1702
+ p.appendChild(a);
1676
1703
  } else
1677
- for (let h = R - 1; h >= 0; h--) {
1678
- 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(_);
1679
1706
  if (!u) continue;
1680
- const A = u.state, x = A === "new", et = A === "replaced";
1681
- 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));
1682
1709
  }
1683
1710
  }
1684
- P = M;
1711
+ R = $;
1685
1712
  });
1686
- }), g.trackEffect(this, bt), g.trackCleanup(this, () => {
1687
- 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();
1688
1715
  });
1689
- });
1716
+ }
1717
+ return this;
1690
1718
  };
1691
- const Ps = Object.freeze({});
1692
- c.fn.atomMount = function(e, t) {
1693
- const s = t ?? Ps;
1694
- return this.each(function() {
1695
- g.cleanupTree(this);
1696
- const n = c(this);
1697
- 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;
1698
1728
  try {
1699
- i = H(() => e(n, s));
1700
- } catch (r) {
1701
- f.error(d.MOUNT, S.MOUNT_ERROR(), r);
1702
- return;
1729
+ c = H(() => s(r, e));
1730
+ } catch (E) {
1731
+ f.error(g.MOUNT, T.MOUNT_ERROR(), E);
1732
+ continue;
1703
1733
  }
1704
- typeof i == "function" && g.setComponentCleanup(this, i);
1705
- });
1734
+ typeof c == "function" && y.setComponentCleanup(o, c);
1735
+ }
1736
+ return this;
1706
1737
  };
1707
- c.fn.atomUnmount = function() {
1708
- return this.each(function() {
1709
- Le(this);
1710
- });
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;
1711
1744
  };
1712
- function le(e, t) {
1745
+ function he(s, t) {
1713
1746
  try {
1714
- return history.pushState(e, "", t), !0;
1715
- } catch (s) {
1747
+ return history.pushState(s, "", t), !0;
1748
+ } catch (e) {
1716
1749
  return f.warn(
1717
- d.ROUTE,
1750
+ g.ROUTE,
1718
1751
  "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.",
1719
- s
1752
+ e
1720
1753
  ), !1;
1721
1754
  }
1722
1755
  }
1723
- class Ms {
1756
+ class Bs {
1724
1757
  constructor(t) {
1725
1758
  this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.config = {
1726
1759
  ...t,
1727
- mode: t.mode ?? dt.mode,
1728
- basePath: t.basePath ?? dt.basePath,
1729
- autoBindLinks: t.autoBindLinks ?? dt.autoBindLinks,
1730
- activeClass: t.activeClass ?? dt.activeClass
1731
- }, 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();
1732
1765
  }
1733
1766
  init() {
1734
1767
  const t = this.isHistoryMode ? "popstate" : "hashchange";
1735
1768
  window.addEventListener(t, this.handleUrlChange), this.cleanups.push(() => window.removeEventListener(t, this.handleUrlChange));
1736
- const s = X(() => {
1769
+ const e = X(() => {
1737
1770
  const n = this.currentRouteAtom.value;
1738
1771
  H(() => this.renderRoute(n));
1739
1772
  });
1740
- 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);
1741
1774
  }
1742
1775
  // --- Mode-abstracted internal methods ---
1743
1776
  /**
@@ -1747,11 +1780,11 @@ class Ms {
1747
1780
  getRouteName() {
1748
1781
  const { default: t } = this.config;
1749
1782
  if (this.isHistoryMode) {
1750
- let r = window.location.pathname;
1751
- 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;
1752
1785
  }
1753
- const s = window.location.hash, n = s.indexOf("?");
1754
- 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;
1755
1788
  }
1756
1789
  /**
1757
1790
  * Parses query parameters from the current URL.
@@ -1766,16 +1799,16 @@ class Ms {
1766
1799
  if (this.isHistoryMode) {
1767
1800
  if (t = window.location.search.substring(1), !t) return {};
1768
1801
  } else {
1769
- const i = window.location.hash, r = i.indexOf("?");
1770
- if (r === -1) return {};
1771
- 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);
1772
1805
  }
1773
- const s = new URLSearchParams(t), n = Object.fromEntries(s);
1806
+ const e = new URLSearchParams(t), n = Object.fromEntries(e);
1774
1807
  if (t.includes("%"))
1775
1808
  try {
1776
1809
  decodeURIComponent(t);
1777
1810
  } catch {
1778
- f.warn(d.ROUTE, S.MALFORMED_URI(t));
1811
+ f.warn(g.ROUTE, T.MALFORMED_URI(t));
1779
1812
  }
1780
1813
  return n;
1781
1814
  }
@@ -1785,11 +1818,11 @@ class Ms {
1785
1818
  */
1786
1819
  setUrl(t) {
1787
1820
  if (this.isHistoryMode) {
1788
- const s = `${this.normalizedBasePath}/${t}`;
1789
- le(null, s), this.previousUrl = s;
1821
+ const e = `${this.normalizedBasePath}/${t}`;
1822
+ he(null, e), this.previousUrl = e;
1790
1823
  } else {
1791
- const s = `#${t}`;
1792
- window.location.hash = s, this.previousUrl = s;
1824
+ const e = `#${t}`;
1825
+ window.location.hash = e, this.previousUrl = e;
1793
1826
  }
1794
1827
  }
1795
1828
  /**
@@ -1798,7 +1831,7 @@ class Ms {
1798
1831
  * that occur with replaceState during popstate events.
1799
1832
  */
1800
1833
  restoreUrl() {
1801
- this.isHistoryMode ? le(null, this.previousUrl) : window.location.hash = this.previousUrl;
1834
+ this.isHistoryMode ? he(null, this.previousUrl) : window.location.hash = this.previousUrl;
1802
1835
  }
1803
1836
  /**
1804
1837
  * Returns the current full URL string for comparison purposes.
@@ -1811,9 +1844,9 @@ class Ms {
1811
1844
  * Resolves route configuration, falling back to notFound route if needed.
1812
1845
  */
1813
1846
  getRouteConfig(t) {
1814
- const { routes: s, notFound: n } = this.config;
1815
- let i = s[t];
1816
- 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);
1817
1850
  }
1818
1851
  /**
1819
1852
  * Appends cloned template content into the target container.
@@ -1821,14 +1854,14 @@ class Ms {
1821
1854
  * before invoking this method if a clean slate is needed.
1822
1855
  */
1823
1856
  renderTemplate(t) {
1824
- let s = this.templateCache.get(t);
1825
- if (!s) {
1857
+ let e = this.templateCache.get(t);
1858
+ if (!e) {
1826
1859
  const i = document.querySelector(t);
1827
1860
  if (!i || !(i instanceof HTMLTemplateElement))
1828
- return f.warn(d.ROUTE, S.TEMPLATE_NOT_FOUND(t)), !1;
1829
- 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);
1830
1863
  }
1831
- const n = s.content.cloneNode(!0);
1864
+ const n = e.content.cloneNode(!0);
1832
1865
  return this.$target.append(n), !0;
1833
1866
  }
1834
1867
  /**
@@ -1846,21 +1879,21 @@ class Ms {
1846
1879
  */
1847
1880
  renderRoute(t) {
1848
1881
  if (this.isDestroyed) return;
1849
- const s = this.$target[0];
1850
- if (!s) {
1851
- 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));
1852
1885
  return;
1853
1886
  }
1854
1887
  const n = this.getRouteConfig(t);
1855
1888
  if (!n) return;
1856
- const i = this.getQueryParams(), r = this.previousRoute;
1857
- this.config.beforeTransition && this.config.beforeTransition(r, t), this.$target.empty();
1858
- 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;
1859
1892
  if (n.onEnter) {
1860
- const l = n.onEnter(i);
1861
- l !== void 0 && (o = { ...i, ...l });
1893
+ const c = n.onEnter(i);
1894
+ c !== void 0 && (r = { ...i, ...c });
1862
1895
  }
1863
- 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;
1864
1897
  }
1865
1898
  /**
1866
1899
  * Handles browser URL change events (hashchange or popstate).
@@ -1869,18 +1902,18 @@ class Ms {
1869
1902
  if (this.isDestroyed) return;
1870
1903
  const t = this.getCurrentUrl();
1871
1904
  if (t === this.previousUrl) return;
1872
- const s = this.getRouteName(), n = this.currentRouteAtom.peek(), i = this.getQueryParams();
1873
- if (n !== s) {
1874
- const r = this.config.routes[n];
1875
- 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) {
1876
1909
  this.restoreUrl();
1877
1910
  return;
1878
1911
  }
1879
- this.currentRouteAtom.value = s, this.queryParamsAtom.value = i;
1912
+ this.currentRouteAtom.value = e, this.queryParamsAtom.value = i;
1880
1913
  } else {
1881
1914
  this.queryParamsAtom.value = i;
1882
- const r = this.config.routes[n];
1883
- r?.onParamsChange ? r.onParamsChange(i) : this.renderRoute(s);
1915
+ const o = this.config.routes[n];
1916
+ o?.onParamsChange ? o.onParamsChange(i) : this.renderRoute(e);
1884
1917
  }
1885
1918
  this.previousUrl = t;
1886
1919
  }
@@ -1899,19 +1932,19 @@ class Ms {
1899
1932
  if (!this.config.autoBindLinks) return;
1900
1933
  const t = (i) => {
1901
1934
  i.preventDefault();
1902
- const r = i.currentTarget.dataset.route;
1903
- r != null && this.navigate(r);
1935
+ const o = i.currentTarget.dataset.route;
1936
+ o != null && this.navigate(o);
1904
1937
  };
1905
- c(document).on("click", "[data-route]", t), this.cleanups.push(() => {
1906
- 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);
1907
1940
  });
1908
- const { activeClass: s } = this.config, n = X(() => {
1941
+ const { activeClass: e } = this.config, n = X(() => {
1909
1942
  const i = this.currentRouteAtom.value;
1910
1943
  H(() => {
1911
- const r = document.querySelectorAll("[data-route]");
1912
- for (const o of r) {
1913
- const l = o.dataset.route, p = i === l;
1914
- 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");
1915
1948
  }
1916
1949
  });
1917
1950
  });
@@ -1927,13 +1960,13 @@ class Ms {
1927
1960
  */
1928
1961
  navigate(t) {
1929
1962
  if (this.isDestroyed) return;
1930
- const s = this.currentRouteAtom.peek(), n = this.config.routes[s];
1963
+ const e = this.currentRouteAtom.peek(), n = this.config.routes[e];
1931
1964
  if (n?.onLeave && n.onLeave() === !1)
1932
1965
  return;
1933
1966
  const i = t || this.config.default;
1934
1967
  if (!i) {
1935
1968
  f.warn(
1936
- d.ROUTE,
1969
+ g.ROUTE,
1937
1970
  "navigate() called with empty routeName and no default configured."
1938
1971
  );
1939
1972
  return;
@@ -1946,73 +1979,75 @@ class Ms {
1946
1979
  * cleanup does not prevent the remaining ones from running.
1947
1980
  */
1948
1981
  destroy() {
1949
- 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++)
1950
1986
  try {
1951
- t();
1952
- } catch (s) {
1953
- 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);
1954
1990
  }
1955
- }), this.cleanups.length = 0, this.templateCache.clear());
1991
+ this.cleanups.length = 0, this.templateCache.clear();
1956
1992
  }
1957
1993
  }
1958
- function $s(e) {
1959
- return new Ms(e);
1994
+ function Hs(s) {
1995
+ return new Bs(s);
1960
1996
  }
1961
- c.extend({
1962
- route: $s
1997
+ l.extend({
1998
+ route: Hs
1963
1999
  });
1964
- const Fs = new Promise(() => {
2000
+ const Gs = new Promise(() => {
1965
2001
  });
1966
- c.extend({
1967
- atomFetch(e, t) {
1968
- 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 = {
1969
- ...o,
1970
- ...i !== void 0 && { method: i },
1971
- ...r !== void 0 && { headers: r }
1972
- };
1973
- let E = null;
1974
- 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(
1975
2008
  async () => {
1976
- E?.abort(), E = new AbortController();
1977
- const m = E.signal, P = b ? { ...N, url: b } : { ...N, url: C() }, U = c.ajax(P);
1978
- 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();
1979
2014
  try {
1980
- const G = await U;
1981
- return n ? n(G) : G;
1982
- } catch (G) {
1983
- if (m.aborted)
1984
- return Fs;
2015
+ const R = await I;
2016
+ return n ? n(R) : R;
2017
+ } catch (R) {
2018
+ if (C.aborted)
2019
+ return Gs;
1985
2020
  try {
1986
- l?.(G);
2021
+ c?.(R);
1987
2022
  } catch {
1988
2023
  }
1989
- throw G;
2024
+ throw R;
1990
2025
  } finally {
1991
- m.onabort = null, E.signal === m && (E = null);
2026
+ C.onabort = null, O.signal === C && (O = null);
1992
2027
  }
1993
2028
  },
1994
- { defaultValue: s, lazy: !(p ?? !0) }
2029
+ { defaultValue: e, lazy: !(E ?? !0) }
1995
2030
  );
1996
2031
  }
1997
2032
  });
1998
- c(() => {
1999
- Ns(), Rs(document.body);
2033
+ l(() => {
2034
+ As(), Os(document.body);
2000
2035
  });
2001
2036
  export {
2002
- Ft as atom,
2003
- ye as batch,
2004
- Ct as computed,
2005
- qs as default,
2006
- Gs as disableAutoCleanup,
2007
- js as disablejQueryOverrides,
2037
+ Bt as atom,
2038
+ Ie as batch,
2039
+ St as computed,
2040
+ Ys as default,
2041
+ Vs as disableAutoCleanup,
2042
+ qs as disablejQueryOverrides,
2008
2043
  X as effect,
2009
- Rs as enableAutoCleanup,
2010
- Ns as enablejQueryOverrides,
2044
+ Os as enableAutoCleanup,
2045
+ As as enablejQueryOverrides,
2011
2046
  qt as isAtom,
2012
- Ve as isComputed,
2013
- Ce as isReactive,
2014
- Cs as nextTick,
2015
- g as registry,
2047
+ qe as isComputed,
2048
+ ye as isReactive,
2049
+ Ts as nextTick,
2050
+ y as registry,
2016
2051
  H as untracked
2017
2052
  };
2018
2053
  //# sourceMappingURL=index.mjs.map