@but212/atom-effect-jquery 0.21.0 → 0.21.1

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,17 +1,17 @@
1
- var we = Object.defineProperty;
2
- var ke = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var ct = (e, t, n) => ke(e, typeof t != "symbol" ? t + "" : t, n);
4
- import h from "jquery";
5
- import { default as mn } from "jquery";
6
- const _t = {
1
+ var Le = Object.defineProperty;
2
+ var ve = (e, t, n) => t in e ? Le(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var ut = (e, t, n) => ve(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import l from "jquery";
5
+ import { default as Sn } from "jquery";
6
+ const pt = {
7
7
  IDLE: "idle",
8
8
  PENDING: "pending",
9
9
  RESOLVED: "resolved",
10
10
  REJECTED: "rejected"
11
- }, F = {
11
+ }, P = {
12
12
  DISPOSED: 1,
13
13
  EXECUTING: 8
14
- }, ne = {
14
+ }, re = {
15
15
  DISPOSED: 1,
16
16
  /** Marker bit: identifies this node as a computed. */
17
17
  IS_COMPUTED: 2,
@@ -22,11 +22,11 @@ const _t = {
22
22
  REJECTED: 128,
23
23
  RECOMPUTING: 256,
24
24
  HAS_ERROR: 512
25
- }, z = {
25
+ }, j = {
26
26
  DISPOSED: 1,
27
27
  SYNC: 8,
28
28
  NOTIFICATION_SCHEDULED: 16
29
- }, K = {
29
+ }, Y = {
30
30
  // Infinite loop protection
31
31
  MAX_EXECUTIONS_PER_SECOND: 1e3,
32
32
  MAX_EXECUTIONS_PER_EFFECT: 100,
@@ -34,67 +34,72 @@ const _t = {
34
34
  MAX_EXECUTIONS_PER_FLUSH: 1e4,
35
35
  MAX_FLUSH_ITERATIONS: 1e3,
36
36
  MIN_FLUSH_ITERATIONS: 10,
37
+ // Memory management
37
38
  BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
38
- }, De = {
39
- WARN_INFINITE_LOOP: !0
40
- }, Ut = 1073741823, R = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, Te = Object.freeze([]);
41
- class it extends Error {
39
+ }, ce = {
40
+ WARN_INFINITE_LOOP: !0,
41
+ EFFECT_FREQUENCY_WINDOW: 1e3
42
+ }, Vt = {
43
+ MAX_ASYNC_RETRIES: 3,
44
+ MAX_PROMISE_ID: Number.MAX_SAFE_INTEGER - 1
45
+ }, Mt = 1073741823, x = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, ke = Object.freeze([]);
46
+ class ot extends Error {
42
47
  constructor(t, n = null, s = !0) {
43
48
  super(t), this.cause = n, this.recoverable = s, this.name = "AtomError";
44
49
  }
45
50
  }
46
- class H extends it {
51
+ class V extends ot {
47
52
  constructor(t, n = null) {
48
53
  super(t, n, !0), this.name = "ComputedError";
49
54
  }
50
55
  }
51
- class W extends it {
56
+ class K extends ot {
52
57
  constructor(t, n = null) {
53
58
  super(t, n, !1), this.name = "EffectError";
54
59
  }
55
60
  }
56
- class pt extends it {
61
+ class gt extends ot {
57
62
  constructor(t, n = null) {
58
63
  super(t, n, !1), this.name = "SchedulerError";
59
64
  }
60
65
  }
61
- const Bt = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Oe = /* @__PURE__ */ Symbol("AtomEffect.Id"), jt = /* @__PURE__ */ Symbol("AtomEffect.Type"), Tt = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Ae = (e) => "dependencies" in e && Array.isArray(e.dependencies);
62
- function se(e, t, n) {
66
+ const zt = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Re = /* @__PURE__ */ Symbol("AtomEffect.Id"), qt = /* @__PURE__ */ Symbol("AtomEffect.Type"), Lt = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Ue = (e) => "dependencies" in e && Array.isArray(e.dependencies);
67
+ function ae(e, t, n) {
63
68
  if (e === t)
64
- throw new H(
69
+ throw new V(
65
70
  "Circular dependency detected: The computation refers to itself explicitly or implicitly."
66
71
  );
67
- if (!n.has(e.id) && (n.add(e.id), Ae(e))) {
72
+ if (!n.has(e.id) && (n.add(e.id), Ue(e))) {
68
73
  const s = e.dependencies;
69
74
  for (let i = 0; i < s.length; i++) {
70
75
  const o = s[i];
71
- o && se(o, t, n);
76
+ o && ae(o, t, n);
72
77
  }
73
78
  }
74
79
  }
75
80
  const J = {
76
81
  // Dev mode flag
77
- enabled: R,
78
- warnInfiniteLoop: De.WARN_INFINITE_LOOP,
82
+ enabled: x,
83
+ warnInfiniteLoop: ce.WARN_INFINITE_LOOP,
79
84
  warn(e, t) {
80
- R && this.enabled && e && console.warn(`[Atom Effect] ${t}`);
85
+ x && this.enabled && e && console.warn(`[Atom Effect] ${t}`);
81
86
  },
82
87
  checkCircular(e, t) {
83
88
  if (e === t)
84
- throw new H("Direct circular dependency detected");
85
- R && this.enabled && se(e, t, /* @__PURE__ */ new Set());
89
+ throw new V("Direct circular dependency detected");
90
+ x && this.enabled && ae(e, t, /* @__PURE__ */ new Set());
86
91
  },
87
92
  attachDebugInfo(e, t, n) {
88
- if (!R || !this.enabled) return;
93
+ if (!x || !this.enabled) return;
89
94
  const s = e;
90
- s[Bt] = `${t}_${n}`, s[Oe] = n, s[jt] = t;
95
+ s[zt] = `${t}_${n}`, s[Re] = n, s[qt] = t;
91
96
  },
92
- getDebugName: (e) => e?.[Bt],
93
- getDebugType: (e) => e?.[jt]
97
+ getDebugName: (e) => e?.[zt],
98
+ getDebugType: (e) => e?.[qt]
94
99
  };
95
- let Le = 1;
96
- const xe = () => Le++;
97
- function ie(e, t, n) {
100
+ let xe = 1;
101
+ const Fe = () => xe++;
102
+ function ue(e, t, n) {
98
103
  if (typeof t == "function") {
99
104
  const i = t;
100
105
  for (let o = 0, r = n.length; o < r; o++) {
@@ -115,7 +120,7 @@ function ie(e, t, n) {
115
120
  }
116
121
  n.push(new xt(void 0, s));
117
122
  }
118
- function zt(e, t, n) {
123
+ function Xt(e, t, n) {
119
124
  const s = /* @__PURE__ */ new Map();
120
125
  for (let i = 0, o = t.length; i < o; i++) {
121
126
  const r = t[i];
@@ -130,7 +135,7 @@ function zt(e, t, n) {
130
135
  for (const i of s.values())
131
136
  i();
132
137
  }
133
- class bt {
138
+ class Ut {
134
139
  constructor(t, n, s = void 0) {
135
140
  this.node = t, this.version = n, this.unsub = s;
136
141
  }
@@ -140,7 +145,7 @@ class xt {
140
145
  this.fn = t, this.sub = n;
141
146
  }
142
147
  }
143
- const S = {
148
+ const b = {
144
149
  // Computed Errors
145
150
  COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
146
151
  COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
@@ -161,36 +166,38 @@ const S = {
161
166
  // System / Debug
162
167
  CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler",
163
168
  // Effect frequency
164
- EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop."
169
+ EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop.",
170
+ SCHEDULER_CALLBACK_MUST_BE_FUNCTION: "Scheduler callback must be a function",
171
+ SCHEDULER_END_BATCH_WITHOUT_START: "endBatch() called without matching startBatch(). Ignoring."
165
172
  };
166
- function st(e, t, n) {
167
- if (e instanceof it)
173
+ function it(e, t, n) {
174
+ if (e instanceof ot)
168
175
  return e;
169
176
  const s = e instanceof Error, i = s ? e.message : String(e), o = s ? e : void 0, r = `${s ? e.constructor.name : "Unexpected error"} (${n}): ${i}`;
170
177
  return new t(r, o);
171
178
  }
172
- class oe {
179
+ class le {
173
180
  constructor() {
174
- this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = xe() & Ut;
181
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = Fe() & Mt;
175
182
  }
176
183
  }
177
- class re extends oe {
184
+ class he extends le {
178
185
  /**
179
186
  * Adds subscriber.
180
187
  */
181
188
  subscribe(t) {
182
189
  const n = typeof t == "function";
183
190
  if (!n && (!t || typeof t.execute != "function"))
184
- throw st(
191
+ throw it(
185
192
  new TypeError("Invalid subscriber"),
186
- it,
187
- S.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
193
+ ot,
194
+ b.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
188
195
  );
189
196
  const s = this._subscribers;
190
197
  for (let o = 0, r = s.length; o < r; o++) {
191
198
  const c = s[o];
192
199
  if (c && (n ? c.fn === t : c.sub === t))
193
- return R && console.warn("Duplicate subscription ignored."), () => {
200
+ return x && console.warn("Duplicate subscription ignored."), () => {
194
201
  };
195
202
  }
196
203
  const i = new xt(
@@ -222,22 +229,22 @@ class re extends oe {
222
229
  }
223
230
  }
224
231
  _handleNotifyError(t) {
225
- console.error(st(t, it, S.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
232
+ console.error(it(t, ot, b.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
226
233
  }
227
234
  }
228
- let Ot = 0;
229
- const Ft = () => (Ot = Ot + 1 & Ut || 1, Ot), Nt = (e) => e + 1 & Ut;
230
- let Pt = 0, vt = !1, ce = 0;
231
- const Ne = () => ce;
232
- function Ht() {
233
- return vt ? (R && console.warn("startFlush() called during flush - ignored"), !1) : (vt = !0, ce = Ft(), Pt = 0, !0);
235
+ let vt = 0;
236
+ const $t = () => (vt = vt + 1 & Mt || 1, vt), Ft = (e) => e + 1 & Mt;
237
+ let Bt = 0, Ot = !1, fe = 0;
238
+ const Pe = () => fe;
239
+ function Gt() {
240
+ return Ot ? (x && console.warn("startFlush() called during flush - ignored"), !1) : (Ot = !0, fe = $t(), Bt = 0, !0);
234
241
  }
235
- const Vt = () => {
236
- vt = !1;
237
- }, Re = () => vt ? ++Pt : 0;
238
- class Ue {
242
+ const Qt = () => {
243
+ Ot = !1;
244
+ }, Me = () => Ot ? ++Bt : 0;
245
+ class $e {
239
246
  constructor() {
240
- 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 = K.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
247
+ 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 = Y.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
241
248
  }
242
249
  get phase() {
243
250
  return this._isProcessing || this._isFlushingSync ? 2 : this._isBatching ? 1 : 0;
@@ -252,8 +259,8 @@ class Ue {
252
259
  * Schedules job.
253
260
  */
254
261
  schedule(t) {
255
- if (R && typeof t != "function")
256
- throw new pt("Scheduler callback must be a function");
262
+ if (x && typeof t != "function")
263
+ throw new gt(b.SCHEDULER_CALLBACK_MUST_BE_FUNCTION);
257
264
  if (t._nextEpoch !== this._epoch) {
258
265
  if (t._nextEpoch = this._epoch, this._isBatching || this._isFlushingSync) {
259
266
  this._batchQueue[this._batchQueueSize++] = t;
@@ -274,19 +281,19 @@ class Ue {
274
281
  _runLoop() {
275
282
  try {
276
283
  if (this._size === 0) return;
277
- const t = Ht();
278
- this._drainQueue(), t && Vt();
284
+ const t = Gt();
285
+ this._drainQueue(), t && Qt();
279
286
  } finally {
280
287
  this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
281
288
  }
282
289
  }
283
290
  _flushSync() {
284
291
  this._isFlushingSync = !0;
285
- const t = Ht();
292
+ const t = Gt();
286
293
  try {
287
294
  this._mergeBatchQueue(), this._drainQueue();
288
295
  } finally {
289
- this._isFlushingSync = !1, t && Vt();
296
+ this._isFlushingSync = !1, t && Qt();
290
297
  }
291
298
  }
292
299
  _mergeBatchQueue() {
@@ -297,7 +304,7 @@ class Ue {
297
304
  const r = n[o];
298
305
  r._nextEpoch !== t && (r._nextEpoch = t, s[i++] = r);
299
306
  }
300
- this._size = i, this._batchQueueSize = 0, n.length > K.BATCH_QUEUE_SHRINK_THRESHOLD && (n.length = 0);
307
+ this._size = i, this._batchQueueSize = 0, n.length > Y.BATCH_QUEUE_SHRINK_THRESHOLD && (n.length = 0);
301
308
  }
302
309
  _drainQueue() {
303
310
  let t = 0;
@@ -316,15 +323,15 @@ class Ue {
316
323
  try {
317
324
  n[i]();
318
325
  } catch (o) {
319
- console.error(new pt("Error occurred during scheduler execution", o));
326
+ console.error(new gt("Error occurred during scheduler execution", o));
320
327
  }
321
328
  n.length = 0;
322
329
  }
323
330
  _handleFlushOverflow() {
324
331
  const t = this._size + this._batchQueueSize;
325
332
  if (console.error(
326
- new pt(
327
- S.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t)
333
+ new gt(
334
+ b.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t)
328
335
  )
329
336
  ), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
330
337
  try {
@@ -337,20 +344,20 @@ class Ue {
337
344
  }
338
345
  endBatch() {
339
346
  if (this._batchDepth === 0) {
340
- R && console.warn("endBatch() called without matching startBatch(). Ignoring.");
347
+ x && console.warn(b.SCHEDULER_END_BATCH_WITHOUT_START);
341
348
  return;
342
349
  }
343
350
  --this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
344
351
  }
345
352
  setMaxFlushIterations(t) {
346
- if (t < K.MIN_FLUSH_ITERATIONS)
347
- throw new pt(
348
- `Max flush iterations must be at least ${K.MIN_FLUSH_ITERATIONS}`
353
+ if (t < Y.MIN_FLUSH_ITERATIONS)
354
+ throw new gt(
355
+ `Max flush iterations must be at least ${Y.MIN_FLUSH_ITERATIONS}`
349
356
  );
350
357
  this._maxFlushIterations = t;
351
358
  }
352
359
  }
353
- const ht = new Ue(), Mt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ae = /* @__PURE__ */ Symbol.for("atom-effect/computed"), Fe = /* @__PURE__ */ Symbol.for("atom-effect/effect"), M = {
360
+ const dt = new $e(), Ht = /* @__PURE__ */ Symbol.for("atom-effect/atom"), de = /* @__PURE__ */ Symbol.for("atom-effect/computed"), Be = /* @__PURE__ */ Symbol.for("atom-effect/effect"), M = {
354
361
  /** Active listener. */
355
362
  current: null,
356
363
  /**
@@ -370,7 +377,7 @@ const ht = new Ue(), Mt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ae = /
370
377
  }
371
378
  }
372
379
  };
373
- function Pe(e) {
380
+ function He(e) {
374
381
  const t = M.current;
375
382
  if (t === null) return e();
376
383
  M.current = null;
@@ -380,26 +387,26 @@ function Pe(e) {
380
387
  M.current = t;
381
388
  }
382
389
  }
383
- var qt, Xt;
384
- class Me extends (Xt = re, qt = Mt, Xt) {
390
+ var Kt, Wt;
391
+ class je extends (Wt = he, Kt = Ht, Wt) {
385
392
  constructor(t, n) {
386
- super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this[qt] = !0, this._value = t, n && (this.flags |= z.SYNC), J.attachDebugInfo(this, "atom", this.id);
393
+ super(), this._pendingOldValue = void 0, this._notifyTask = () => this._flushNotifications(), this._subscribers = [], this[Kt] = !0, this._value = t, n && (this.flags |= j.SYNC), J.attachDebugInfo(this, "atom", this.id);
387
394
  }
388
395
  get value() {
389
396
  const t = M.current;
390
- return t && ie(this, t, this._subscribers), this._value;
397
+ return t && ue(this, t, this._subscribers), this._value;
391
398
  }
392
399
  set value(t) {
393
400
  const n = this._value;
394
401
  if (Object.is(n, t)) return;
395
- this._value = t, this.version = Nt(this.version);
402
+ this._value = t, this.version = Ft(this.version);
396
403
  const s = this.flags;
397
- if (!(this._subscribers.length === 0 || s & z.NOTIFICATION_SCHEDULED)) {
398
- if (this._pendingOldValue = n, this.flags = s | z.NOTIFICATION_SCHEDULED, s & z.SYNC && !ht.isBatching) {
404
+ if (!(this._subscribers.length === 0 || s & j.NOTIFICATION_SCHEDULED)) {
405
+ if (this._pendingOldValue = n, this.flags = s | j.NOTIFICATION_SCHEDULED, s & j.SYNC && !dt.isBatching) {
399
406
  this._flushNotifications();
400
407
  return;
401
408
  }
402
- this._notifyTask || (this._notifyTask = () => this._flushNotifications()), ht.schedule(this._notifyTask);
409
+ dt.schedule(this._notifyTask);
403
410
  }
404
411
  }
405
412
  /**
@@ -407,7 +414,7 @@ class Me extends (Xt = re, qt = Mt, Xt) {
407
414
  */
408
415
  _flushNotifications() {
409
416
  const t = this.flags;
410
- if (!(t & z.NOTIFICATION_SCHEDULED) || t & z.DISPOSED)
417
+ if (!(t & j.NOTIFICATION_SCHEDULED) || t & j.DISPOSED)
411
418
  return;
412
419
  const n = this._pendingOldValue;
413
420
  this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value, n);
@@ -416,20 +423,20 @@ class Me extends (Xt = re, qt = Mt, Xt) {
416
423
  return this._value;
417
424
  }
418
425
  dispose() {
419
- this.flags & z.DISPOSED || (this._subscribers.length = 0, this.flags |= z.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
426
+ this.flags & j.DISPOSED || (this._subscribers.length = 0, this.flags |= j.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
420
427
  }
421
428
  }
422
- function ue(e, t = {}) {
423
- return new Me(e, t.sync ?? !1);
429
+ function _e(e, t = {}) {
430
+ return new je(e, t.sync ?? !1);
424
431
  }
425
- class $e {
432
+ class Ve {
426
433
  /**
427
434
  * @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
428
435
  * @param capacity - Max length of an array to accept (default: 256).
429
436
  * @param enableStats - Force-enable stats even in production (default: false).
430
437
  */
431
438
  constructor(t = 50, n = 256, s = !1) {
432
- this.limit = t, this.capacity = n, this.pool = [], this.stats = null, this.stats = R || s ? {
439
+ this.limit = t, this.capacity = n, this.pool = [], this.stats = null, this.stats = x || s ? {
433
440
  acquired: 0,
434
441
  released: 0,
435
442
  rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
@@ -489,29 +496,29 @@ class $e {
489
496
  });
490
497
  }
491
498
  }
492
- const P = Object.freeze(
499
+ const k = Object.freeze(
493
500
  []
494
- ), V = new $e();
495
- function le(e) {
496
- return e !== null && typeof e == "object" && Mt in e;
501
+ ), z = new Ve();
502
+ function Ee(e) {
503
+ return e !== null && typeof e == "object" && Ht in e;
497
504
  }
498
- function he(e) {
499
- return e !== null && typeof e == "object" && ae in e;
505
+ function pe(e) {
506
+ return e !== null && typeof e == "object" && de in e;
500
507
  }
501
- function fe(e) {
508
+ function ge(e) {
502
509
  return e !== null && typeof e == "object" && typeof e.then == "function";
503
510
  }
504
- var Qt, Gt, Wt;
505
- const Be = 3, je = Number.MAX_SAFE_INTEGER - 1, { IDLE: Et, DIRTY: nt, PENDING: Ct, RESOLVED: Y, REJECTED: ut, HAS_ERROR: gt, RECOMPUTING: at, DISPOSED: At, IS_COMPUTED: ze } = ne;
506
- function He(e) {
507
- return e & Y ? _t.RESOLVED : e & Ct ? _t.PENDING : e & ut ? _t.REJECTED : _t.IDLE;
511
+ var Yt, Jt, Zt;
512
+ const { IDLE: mt, DIRTY: st, PENDING: It, RESOLVED: W, REJECTED: ht, HAS_ERROR: yt, RECOMPUTING: lt, DISPOSED: kt, IS_COMPUTED: ze } = re;
513
+ function qe(e) {
514
+ return e & W ? pt.RESOLVED : e & It ? pt.PENDING : e & ht ? pt.REJECTED : pt.IDLE;
508
515
  }
509
- class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
516
+ class Xe extends (Zt = he, Jt = Ht, Yt = de, Zt) {
510
517
  constructor(t, n = {}) {
511
- if (typeof t != "function") throw new H(S.COMPUTED_MUST_BE_FUNCTION);
512
- super(), this[Gt] = !0, this[Qt] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = P, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = P, this._trackCount = 0, this._value = void 0, this.flags = ze | nt | Et, this._equal = n.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in n ? n.defaultValue : Tt, this._onError = n.onError ?? null;
518
+ if (typeof t != "function") throw new V(b.COMPUTED_MUST_BE_FUNCTION);
519
+ super(), this[Jt] = !0, this[Yt] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = k, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = k, this._trackCount = 0, this._value = void 0, this.flags = ze | st | mt, this._equal = n.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in n ? n.defaultValue : Lt, this._onError = n.onError ?? null;
513
520
  const s = n.maxAsyncRetries;
514
- if (this._maxAsyncRetries = s != null && s >= 0 ? s : Be, J.attachDebugInfo(this, "computed", this.id), n.lazy === !1)
521
+ if (this._maxAsyncRetries = s != null && s >= 0 ? s : Vt.MAX_ASYNC_RETRIES, J.attachDebugInfo(this, "computed", this.id), n.lazy === !1)
515
522
  try {
516
523
  this._recompute();
517
524
  } catch {
@@ -519,28 +526,28 @@ class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
519
526
  }
520
527
  _track() {
521
528
  const t = M.current;
522
- t && ie(this, t, this._subscribers);
529
+ t && ue(this, t, this._subscribers);
523
530
  }
524
531
  get value() {
525
532
  this._track();
526
533
  const t = this.flags;
527
- if ((t & (Y | nt | Et)) === Y)
534
+ if ((t & (W | st | mt)) === W)
528
535
  return this._value;
529
- if (t & At)
530
- throw new H(S.COMPUTED_DISPOSED);
531
- if (t & at) {
532
- if (this._defaultValue !== Tt) return this._defaultValue;
533
- throw new H(S.COMPUTED_CIRCULAR_DEPENDENCY);
536
+ if (t & kt)
537
+ throw new V(b.COMPUTED_DISPOSED);
538
+ if (t & lt) {
539
+ if (this._defaultValue !== Lt) return this._defaultValue;
540
+ throw new V(b.COMPUTED_CIRCULAR_DEPENDENCY);
534
541
  }
535
- if (t & (nt | Et) && (this._recompute(), this.flags & Y))
542
+ if (t & (st | mt) && (this._recompute(), this.flags & W))
536
543
  return this._value;
537
- const n = this._defaultValue, s = n !== Tt;
538
- if (this.flags & Ct) {
544
+ const n = this._defaultValue, s = n !== Lt;
545
+ if (this.flags & It) {
539
546
  if (s) return n;
540
- throw new H(S.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
547
+ throw new V(b.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
541
548
  }
542
- if (this.flags & ut) {
543
- if (this._error?.recoverable && s) return n;
549
+ if (this.flags & ht) {
550
+ if (s) return n;
544
551
  throw this._error;
545
552
  }
546
553
  return this._value;
@@ -549,14 +556,14 @@ class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
549
556
  return this._value;
550
557
  }
551
558
  get state() {
552
- return this._track(), He(this.flags);
559
+ return this._track(), qe(this.flags);
553
560
  }
554
561
  get hasError() {
555
- if (this._track(), this.flags & (ut | gt)) return !0;
562
+ if (this._track(), this.flags & (ht | yt)) return !0;
556
563
  const t = this._links;
557
564
  for (let n = 0, s = t.length; n < s; n++) {
558
565
  const i = t[n]?.node;
559
- if (i && i.flags & gt) return !0;
566
+ if (i && i.flags & yt) return !0;
560
567
  }
561
568
  return !1;
562
569
  }
@@ -564,21 +571,19 @@ class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
564
571
  return !this.hasError;
565
572
  }
566
573
  get errors() {
567
- if (this._track(), !this.hasError) return Te;
574
+ if (this._track(), !this.hasError) return ke;
568
575
  const t = [];
569
576
  this._error && t.push(this._error);
570
577
  const n = this._links;
571
578
  for (let s = 0, i = n.length; s < i; s++) {
572
579
  const o = n[s].node;
573
- if (o.flags & gt) {
574
- const r = o;
575
- if (r.errors) {
576
- const c = r.errors;
577
- for (let a = 0; a < c.length; a++) {
578
- const l = c[a];
579
- l && t.indexOf(l) === -1 && t.push(l);
580
+ if (o.flags & yt) {
581
+ const r = o.errors;
582
+ if (r.length > 0)
583
+ for (let c = 0; c < r.length; c++) {
584
+ const a = r[c];
585
+ a && t.indexOf(a) === -1 && t.push(a);
580
586
  }
581
- }
582
587
  }
583
588
  }
584
589
  return Object.freeze(t);
@@ -587,23 +592,23 @@ class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
587
592
  return this._track(), this._error;
588
593
  }
589
594
  get isPending() {
590
- return this._track(), (this.flags & Ct) !== 0;
595
+ return this._track(), (this.flags & It) !== 0;
591
596
  }
592
597
  get isResolved() {
593
- return this._track(), (this.flags & Y) !== 0;
598
+ return this._track(), (this.flags & W) !== 0;
594
599
  }
595
600
  invalidate() {
596
601
  this._markDirty();
597
602
  }
598
603
  dispose() {
599
- if (this.flags & At) return;
604
+ if (this.flags & kt) return;
600
605
  const t = this._links;
601
- if (t !== P) {
606
+ if (t !== k) {
602
607
  for (let n = 0, s = t.length; n < s; n++)
603
608
  t[n].unsub?.();
604
- V.release(t), this._links = P;
609
+ z.release(t), this._links = k;
605
610
  }
606
- this._subscribers.length = 0, this.flags = At | nt | Et, this._error = null, this._value = void 0;
611
+ this._subscribers.length = 0, this.flags = kt | st | mt, this._error = null, this._value = void 0;
607
612
  }
608
613
  addDependency(t) {
609
614
  if (t._lastSeenEpoch !== this._trackEpoch) {
@@ -611,48 +616,48 @@ class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
611
616
  const n = this._trackLinks[this._trackCount];
612
617
  n.node = t, n.version = t.version;
613
618
  } else
614
- this._trackLinks.push(new bt(t, t.version));
619
+ this._trackLinks.push(new Ut(t, t.version));
615
620
  this._trackCount++;
616
621
  }
617
622
  }
618
623
  _recompute() {
619
- if (this.flags & at) return;
620
- this.flags |= at;
624
+ if (this.flags & lt) return;
625
+ this.flags |= lt;
621
626
  const t = this._links;
622
- this._trackEpoch = Ft(), this._trackLinks = V.acquire(), this._trackCount = 0;
627
+ this._trackEpoch = $t(), this._trackLinks = z.acquire(), this._trackCount = 0;
623
628
  let n = !1;
624
629
  try {
625
630
  const s = M.run(this, this._fn);
626
- this._trackLinks.length = this._trackCount, zt(this._trackLinks, t, this), this._links = this._trackLinks, n = !0, fe(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
631
+ this._trackLinks.length = this._trackCount, Xt(this._trackLinks, t, this), this._links = this._trackLinks, n = !0, ge(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
627
632
  } catch (s) {
628
633
  if (!n)
629
634
  try {
630
- this._trackLinks.length = this._trackCount, zt(this._trackLinks, t, this), this._links = this._trackLinks, n = !0;
635
+ this._trackLinks.length = this._trackCount, Xt(this._trackLinks, t, this), this._links = this._trackLinks, n = !0;
631
636
  } catch (i) {
632
- R && console.warn("[atom-effect] _commitDeps failed during error recovery:", i);
637
+ x && console.warn("[atom-effect] _commitDeps failed during error recovery:", i);
633
638
  }
634
- this._handleError(s, S.COMPUTED_COMPUTATION_FAILED, !0);
639
+ this._handleError(s, b.COMPUTED_COMPUTATION_FAILED, !0);
635
640
  } finally {
636
- n && t !== P ? V.release(t) : n || V.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = P, this._trackCount = 0, this.flags &= ~at;
641
+ n && t !== k ? z.release(t) : n || z.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = k, this._trackCount = 0, this.flags &= ~lt;
637
642
  }
638
643
  }
639
644
  _handleAsyncComputation(t) {
640
- this.flags = (this.flags | Ct) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % je;
645
+ this.flags = (this.flags | It) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Vt.MAX_PROMISE_ID;
641
646
  const n = this._promiseId;
642
647
  t.then(
643
648
  (s) => {
644
649
  if (n === this._promiseId) {
645
650
  if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
646
651
  return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
647
- new H(
652
+ new V(
648
653
  `Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
649
654
  ),
650
- S.COMPUTED_ASYNC_COMPUTATION_FAILED
655
+ b.COMPUTED_ASYNC_COMPUTATION_FAILED
651
656
  );
652
657
  this._finalizeResolution(s), this._notifySubscribers(s, void 0);
653
658
  }
654
659
  },
655
- (s) => n === this._promiseId && this._handleError(s, S.COMPUTED_ASYNC_COMPUTATION_FAILED)
660
+ (s) => n === this._promiseId && this._handleError(s, b.COMPUTED_ASYNC_COMPUTATION_FAILED)
656
661
  );
657
662
  }
658
663
  _captureVersionSnapshot() {
@@ -663,111 +668,109 @@ class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
663
668
  return t;
664
669
  }
665
670
  _handleError(t, n, s = !1) {
666
- const i = st(t, H, n);
667
- if (!s && !(this.flags & ut) && (this.version = Nt(this.version)), this._error = i, this.flags = this.flags & -121 | ut | gt, this._onError)
671
+ const i = it(t, V, n);
672
+ if (!s && !(this.flags & ht) && (this.version = Ft(this.version)), this._error = i, this.flags = this.flags & -121 | ht | yt, this._onError)
668
673
  try {
669
674
  this._onError(i);
670
675
  } catch (o) {
671
- console.error(S.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
676
+ console.error(b.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
672
677
  }
673
678
  if (s) throw i;
674
679
  this._notifySubscribers(void 0, void 0);
675
680
  }
676
681
  _finalizeResolution(t) {
677
- (!(this.flags & Y) || !this._equal(this._value, t)) && (this.version = Nt(this.version)), this._value = t, this._error = null, this.flags = (this.flags | Y) & -697;
682
+ (!(this.flags & W) || !this._equal(this._value, t)) && (this.version = Ft(this.version)), this._value = t, this._error = null, this.flags = (this.flags | W) & -697;
678
683
  }
679
684
  execute() {
680
685
  this._markDirty();
681
686
  }
682
687
  /** @internal */
683
688
  _markDirty() {
684
- this.flags & (at | nt) || (this.flags |= nt, this._notifySubscribers(void 0, void 0));
689
+ this.flags & (lt | st) || (this.flags |= st, this._notifySubscribers(void 0, void 0));
685
690
  }
686
691
  }
687
- function de(e, t = {}) {
688
- return new Ve(e, t);
692
+ function me(e, t = {}) {
693
+ return new Xe(e, t);
689
694
  }
690
- var Yt, Kt;
691
- class qe extends (Kt = oe, Yt = Fe, Kt) {
695
+ var te, ee;
696
+ class Ge extends (ee = le, te = Be, ee) {
692
697
  constructor(t, n = {}) {
693
- super(), this[Yt] = !0, this._cleanup = null, this._links = P, this._nextLinks = null, this._prevLinks = null, 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 = n.onError ?? null, this._sync = n.sync ?? !1, this._maxExecutions = n.maxExecutionsPerSecond ?? K.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = n.maxExecutionsPerFlush ?? K.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = n.trackModifications ?? !1, J.attachDebugInfo(this, "effect", this.id);
698
+ super(), this[te] = !0, this._cleanup = null, this._links = k, this._nextLinks = null, this._prevLinks = k, 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 = n.onError ?? null, this._sync = n.sync ?? !1, this._maxExecutions = n.maxExecutionsPerSecond ?? Y.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = n.maxExecutionsPerFlush ?? Y.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = n.trackModifications ?? !1, this._sync ? (this._executeTask = void 0, this._notifyCallback = () => this.execute()) : (this._executeTask = () => this.execute(), this._notifyCallback = () => dt.schedule(this._executeTask)), J.attachDebugInfo(this, "effect", this.id);
694
699
  }
695
700
  run() {
696
- if (this.flags & F.DISPOSED)
697
- throw new W(S.EFFECT_DISPOSED);
701
+ if (this.flags & P.DISPOSED)
702
+ throw new K(b.EFFECT_DISPOSED);
698
703
  this.execute(!0);
699
704
  }
700
705
  dispose() {
701
- this.flags & F.DISPOSED || (this.flags |= F.DISPOSED, this._execCleanup(), this._unsubLinks(this._links), this._links !== P && V.release(this._links), this._links = P, this._executeTask = void 0);
706
+ this.flags & P.DISPOSED || (this.flags |= P.DISPOSED, this._execCleanup(), this._unsubLinks(this._links), this._links !== k && z.release(this._links), this._links = k, this._prevLinks = k);
702
707
  }
703
708
  addDependency(t) {
704
- if (!(this.flags & F.EXECUTING) || t._lastSeenEpoch === this._currentEpoch) return;
705
- t._lastSeenEpoch = this._currentEpoch;
706
- const n = this._nextLinks, s = this._prevLinks;
707
- if (s)
708
- for (let i = 0, o = s.length; i < o; i++) {
709
- const r = s[i];
710
- if (r && r.node === t && r.unsub) {
711
- n.push(new bt(t, t.version, r.unsub)), r.unsub = void 0;
712
- return;
713
- }
709
+ if (!(this.flags & P.EXECUTING)) return;
710
+ const n = this._currentEpoch;
711
+ if (t._lastSeenEpoch === n) return;
712
+ t._lastSeenEpoch = n;
713
+ const s = this._nextLinks, i = this._prevLinks;
714
+ for (let o = 0, r = i.length; o < r; o++) {
715
+ const c = i[o];
716
+ if (c && c.node === t && c.unsub) {
717
+ c.version = t.version, s.push(c), i[o] = null;
718
+ return;
714
719
  }
720
+ }
715
721
  try {
716
- const i = t.subscribe(() => {
717
- if (this._trackModifications && this.flags & F.EXECUTING && (t._modifiedAtEpoch = this._currentEpoch), this._sync) return this.execute();
718
- this._executeTask ??= () => this.execute(), ht.schedule(this._executeTask);
719
- });
720
- n.push(new bt(t, t.version, i));
721
- } catch (i) {
722
- const o = st(i, W, S.EFFECT_EXECUTION_FAILED);
723
- if (console.error(o), this._onError)
722
+ let o;
723
+ this._trackModifications ? o = t.subscribe(() => {
724
+ this.flags & P.EXECUTING && (t._modifiedAtEpoch = this._currentEpoch), this._notifyCallback();
725
+ }) : o = t.subscribe(this._notifyCallback), s.push(new Ut(t, t.version, o));
726
+ } catch (o) {
727
+ const r = it(o, K, b.EFFECT_EXECUTION_FAILED);
728
+ if (console.error(r), this._onError)
724
729
  try {
725
- this._onError(o);
730
+ this._onError(r);
726
731
  } catch {
727
732
  }
728
- n.push(new bt(t, t.version, void 0));
733
+ s.push(new Ut(t, t.version, void 0));
729
734
  }
730
735
  }
731
736
  /**
732
737
  * Executes effect with tracking.
733
738
  */
734
739
  execute(t = !1) {
735
- if (this.flags & (F.DISPOSED | F.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
736
- this._checkInfiniteLoops(), this.flags |= F.EXECUTING, this._execCleanup();
737
- const n = this._links;
738
- this._prevLinks = n !== P ? n : null;
739
- const s = V.acquire();
740
- this._nextLinks = s, this._currentEpoch = Ft();
741
- let i = !1;
740
+ if (this.flags & (P.DISPOSED | P.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
741
+ this._checkInfiniteLoops(), this.flags |= P.EXECUTING, this._execCleanup(), this._prevLinks = this._links;
742
+ const n = z.acquire();
743
+ this._nextLinks = n, this._currentEpoch = $t();
744
+ let s = !1;
742
745
  try {
743
- const o = M.run(this, this._fn);
744
- if (this._links = s, i = !0, this._trackModifications && J.enabled) {
745
- const r = this._currentEpoch;
746
- for (let c = 0, a = s.length; c < a; c++) {
747
- const l = s[c].node;
748
- l._modifiedAtEpoch === r && J.warn(
746
+ const i = M.run(this, this._fn);
747
+ if (this._links = n, s = !0, this._trackModifications && J.enabled) {
748
+ const o = this._currentEpoch;
749
+ for (let r = 0, c = n.length; r < c; r++) {
750
+ const a = n[r].node;
751
+ a._modifiedAtEpoch === o && J.warn(
749
752
  !0,
750
- `Effect is reading a dependency (${J.getDebugName(l) || "unknown"}) that it just modified. Infinite loop may occur`
753
+ `Effect is reading a dependency (${J.getDebugName(a) || "unknown"}) that it just modified. Infinite loop may occur`
751
754
  );
752
755
  }
753
756
  }
754
- fe(o) ? this._handleAsyncResult(o) : this._cleanup = typeof o == "function" ? o : null;
755
- } catch (o) {
756
- i = !0, this._handleExecutionError(o), this._cleanup = null;
757
+ ge(i) ? this._handleAsyncResult(i) : this._cleanup = typeof i == "function" ? i : null;
758
+ } catch (i) {
759
+ this._links = n, s = !0, this._handleExecutionError(i), this._cleanup = null;
757
760
  } finally {
758
- this._finalizeDependencies(i, n, s), this.flags &= -9;
761
+ this._finalizeDependencies(s, this._prevLinks, n), this.flags &= -9;
759
762
  }
760
763
  }
761
764
  _handleAsyncResult(t) {
762
765
  const n = ++this._execId;
763
766
  t.then(
764
767
  (s) => {
765
- if (n !== this._execId || this.flags & F.DISPOSED) {
768
+ if (n !== this._execId || this.flags & P.DISPOSED) {
766
769
  if (typeof s == "function")
767
770
  try {
768
771
  s();
769
772
  } catch (i) {
770
- this._handleExecutionError(i, S.EFFECT_CLEANUP_FAILED);
773
+ this._handleExecutionError(i, b.EFFECT_CLEANUP_FAILED);
771
774
  }
772
775
  return;
773
776
  }
@@ -777,15 +780,14 @@ class qe extends (Kt = oe, Yt = Fe, Kt) {
777
780
  );
778
781
  }
779
782
  _finalizeDependencies(t, n, s) {
780
- if (this._nextLinks = null, t) {
781
- const i = this._prevLinks;
782
- if (i)
783
- for (let o = 0, r = i.length; o < r; o++)
784
- i[o]?.unsub?.();
785
- n !== P && V.release(n);
783
+ if (this._nextLinks = null, this._prevLinks = k, t) {
784
+ for (let i = 0, o = n.length; i < o; i++) {
785
+ const r = n[i];
786
+ r && r.unsub?.();
787
+ }
788
+ n !== k && z.release(n);
786
789
  } else
787
- this._unsubLinks(s), V.release(s);
788
- this._prevLinks = null;
790
+ this._unsubLinks(s), z.release(s);
789
791
  }
790
792
  _unsubLinks(t) {
791
793
  for (let n = 0, s = t.length; n < s; n++)
@@ -797,11 +799,11 @@ class qe extends (Kt = oe, Yt = Fe, Kt) {
797
799
  try {
798
800
  for (let s = 0, i = t.length; s < i; s++) {
799
801
  const o = t[s], r = o.node;
800
- if (r.flags & ne.IS_COMPUTED)
802
+ if (r.flags & re.IS_COMPUTED)
801
803
  try {
802
804
  r.value;
803
805
  } catch {
804
- return R && console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`), !0;
806
+ return x && console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`), !0;
805
807
  }
806
808
  if (r.version !== o.version) return !0;
807
809
  }
@@ -815,68 +817,68 @@ class qe extends (Kt = oe, Yt = Fe, Kt) {
815
817
  try {
816
818
  this._cleanup();
817
819
  } catch (t) {
818
- this._handleExecutionError(t, S.EFFECT_CLEANUP_FAILED);
820
+ this._handleExecutionError(t, b.EFFECT_CLEANUP_FAILED);
819
821
  }
820
822
  this._cleanup = null;
821
823
  }
822
824
  }
823
825
  _checkInfiniteLoops() {
824
- const t = Ne();
825
- if (this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Re() > K.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, R && Number.isFinite(this._maxExecutions)) {
826
+ const t = Pe();
827
+ if (this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Me() > Y.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, x && Number.isFinite(this._maxExecutions)) {
826
828
  const n = Date.now();
827
- if (n - this._windowStart >= 1e3)
829
+ if (n - this._windowStart >= ce.EFFECT_FREQUENCY_WINDOW)
828
830
  this._windowStart = n, this._windowCount = 1;
829
831
  else if (++this._windowCount > this._maxExecutions) {
830
- const s = new W(S.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
832
+ const s = new K(b.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
831
833
  throw this.dispose(), this._handleExecutionError(s), s;
832
834
  }
833
835
  }
834
836
  }
835
837
  get isDisposed() {
836
- return (this.flags & F.DISPOSED) !== 0;
838
+ return (this.flags & P.DISPOSED) !== 0;
837
839
  }
838
840
  get executionCount() {
839
841
  return this._executionCount;
840
842
  }
841
843
  get isExecuting() {
842
- return (this.flags & F.EXECUTING) !== 0;
844
+ return (this.flags & P.EXECUTING) !== 0;
843
845
  }
844
846
  _throwInfiniteLoopError(t) {
845
- const n = new W(
846
- `Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Pt}`
847
+ const n = new K(
848
+ `Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Bt}`
847
849
  );
848
850
  throw this.dispose(), console.error(n), n;
849
851
  }
850
- _handleExecutionError(t, n = S.EFFECT_EXECUTION_FAILED) {
851
- const s = st(t, W, n);
852
+ _handleExecutionError(t, n = b.EFFECT_EXECUTION_FAILED) {
853
+ const s = it(t, K, n);
852
854
  if (console.error(s), this._onError)
853
855
  try {
854
856
  this._onError(s);
855
857
  } catch (i) {
856
- console.error(st(i, W, S.CALLBACK_ERROR_IN_ERROR_HANDLER));
858
+ console.error(it(i, K, b.CALLBACK_ERROR_IN_ERROR_HANDLER));
857
859
  }
858
860
  }
859
861
  }
860
862
  function Z(e, t = {}) {
861
863
  if (typeof e != "function")
862
- throw new W(S.EFFECT_MUST_BE_FUNCTION);
863
- const n = new qe(e, t);
864
+ throw new K(b.EFFECT_MUST_BE_FUNCTION);
865
+ const n = new Ge(e, t);
864
866
  return n.execute(), n;
865
867
  }
866
- function $t(e) {
868
+ function jt(e) {
867
869
  if (typeof e != "function")
868
870
  throw new TypeError("Batch callback must be a function");
869
- ht.startBatch();
871
+ dt.startBatch();
870
872
  try {
871
873
  return e();
872
874
  } finally {
873
- ht.endBatch();
875
+ dt.endBatch();
874
876
  }
875
877
  }
876
- function _e(e) {
877
- return le(e) || he(e);
878
+ function ye(e) {
879
+ return Ee(e) || pe(e);
878
880
  }
879
- function Dt(e) {
881
+ function wt(e) {
880
882
  if (!e) return "unknown";
881
883
  const t = "jquery" in e ? e[0] : e;
882
884
  if (!t) return "unknown";
@@ -893,7 +895,7 @@ function Dt(e) {
893
895
  }
894
896
  return s;
895
897
  }
896
- function It(e) {
898
+ function Tt(e) {
897
899
  let t = String(e ?? "");
898
900
  t = t.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""), t = t.replace(/<\?[\s\S]*?\?>/g, "");
899
901
  const n = /(<(script|iframe|object|embed|base|meta|applet|noscript)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript)\b[^>]*\/?>)/gim;
@@ -906,7 +908,7 @@ function It(e) {
906
908
  const o = /data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript|text\/xml|application\/xhtml\+xml)/gim;
907
909
  return t = t.replace(o, "data-unsafe-protocol:"), t = t.replace(/\bon\w+\s*=/gim, "data-unsafe-attr="), t = t.replace(/expression\s*\(/gim, "data-unsafe-css(").replace(/behavior\s*:/gim, "data-unsafe-css:"), t;
908
910
  }
909
- const Xe = /* @__PURE__ */ new Set([
911
+ const Qe = /* @__PURE__ */ new Set([
910
912
  "href",
911
913
  "src",
912
914
  "action",
@@ -922,14 +924,14 @@ const Xe = /* @__PURE__ */ new Set([
922
924
  "usemap",
923
925
  "classid",
924
926
  "codebase"
925
- ]), Qe = /^\s*(?:javascript|vbscript)\s*:/i;
926
- function Ge(e, t) {
927
- return Xe.has(e.toLowerCase()) ? Qe.test(t) : !1;
927
+ ]), Ke = /^\s*(?:javascript|vbscript)\s*:/i;
928
+ function We(e, t) {
929
+ return Qe.has(e.toLowerCase()) ? Ke.test(t) : !1;
928
930
  }
929
- function We(e) {
931
+ function Ye(e) {
930
932
  return e.toLowerCase().includes("url(") ? /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i.test(e) : !1;
931
933
  }
932
- function Ye(e, t) {
934
+ function Je(e, t) {
933
935
  if (e === t) return !0;
934
936
  if (typeof e != "object" || e === null || typeof t != "object" || t === null) return !1;
935
937
  const n = Object.keys(e), s = Object.keys(t);
@@ -941,7 +943,7 @@ function Ye(e, t) {
941
943
  }
942
944
  return !0;
943
945
  }
944
- function Ke(e) {
946
+ function Ze(e) {
945
947
  const t = e.length;
946
948
  if (t === 0) return new Int32Array(0);
947
949
  const n = new Int32Array(t), s = new Int32Array(t);
@@ -954,13 +956,13 @@ function Ke(e) {
954
956
  n[r] = a ?? -1, s[i++] = r;
955
957
  continue;
956
958
  }
957
- let l = 0, p = i - 1;
958
- for (; l < p; ) {
959
- const b = l + p >>> 1, T = s[b];
960
- T !== void 0 && (e[T] ?? -1) < c ? l = b + 1 : p = b;
959
+ let h = 0, E = i - 1;
960
+ for (; h < E; ) {
961
+ const C = h + E >>> 1, N = s[C];
962
+ N !== void 0 && (e[N] ?? -1) < c ? h = C + 1 : E = C;
961
963
  }
962
- const C = s[l];
963
- C !== void 0 && c < (e[C] ?? Number.MAX_SAFE_INTEGER) && (l > 0 && (n[r] = s[l - 1] ?? -1), s[l] = r);
964
+ const S = s[h];
965
+ S !== void 0 && c < (e[S] ?? Number.MAX_SAFE_INTEGER) && (h > 0 && (n[r] = s[h - 1] ?? -1), s[h] = r);
964
966
  }
965
967
  const o = new Int32Array(i);
966
968
  if (i > 0) {
@@ -970,26 +972,26 @@ function Ke(e) {
970
972
  }
971
973
  return o;
972
974
  }
973
- function Je() {
975
+ function tn() {
974
976
  if (typeof window < "u") {
975
977
  const e = window.__ATOM_DEBUG__;
976
978
  if (typeof e == "boolean") return e;
977
979
  }
978
980
  return !1;
979
981
  }
980
- let G = Je();
982
+ let Q = tn();
981
983
  const m = {
982
984
  get enabled() {
983
- return G;
985
+ return Q;
984
986
  },
985
987
  set enabled(e) {
986
- G = e;
988
+ Q = e;
987
989
  },
988
990
  log(e, ...t) {
989
- G && console.log(`[atom-effect-jquery] ${e}:`, ...t);
991
+ Q && console.log(`[atom-effect-jquery] ${e}:`, ...t);
990
992
  },
991
993
  atomChanged(e, t, n) {
992
- G && console.log(
994
+ Q && console.log(
993
995
  `[atom-effect-jquery] Atom "${e ?? "anonymous"}" changed:`,
994
996
  t,
995
997
  "→",
@@ -1000,39 +1002,39 @@ const m = {
1000
1002
  * Logs DOM updates and triggers visual highlight.
1001
1003
  */
1002
1004
  domUpdated(e, t, n) {
1003
- G && (console.log(`[atom-effect-jquery] DOM updated: ${Dt(e)}.${t} =`, n), tn(e));
1005
+ Q && (console.log(`[atom-effect-jquery] DOM updated: ${wt(e)}.${t} =`, n), nn(e));
1004
1006
  },
1005
1007
  cleanup(e) {
1006
- G && console.log(`[atom-effect-jquery] Cleanup: ${e}`);
1008
+ Q && console.log(`[atom-effect-jquery] Cleanup: ${e}`);
1007
1009
  },
1008
1010
  warn(...e) {
1009
- G && console.warn("[atom-effect-jquery]", ...e);
1011
+ Q && console.warn("[atom-effect-jquery]", ...e);
1010
1012
  }
1011
- }, Rt = "atom-debug-highlight";
1012
- let Jt = !1;
1013
- function Ze() {
1014
- if (Jt) return;
1015
- Jt = !0;
1013
+ }, Pt = "atom-debug-highlight";
1014
+ let ne = !1;
1015
+ function en() {
1016
+ if (ne) return;
1017
+ ne = !0;
1016
1018
  const e = document.createElement("style");
1017
- e.textContent = `.${Rt}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline 0.5s ease-out}`, document.head.appendChild(e);
1019
+ e.textContent = `.${Pt}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline 0.5s ease-out}`, document.head.appendChild(e);
1018
1020
  }
1019
- const Lt = /* @__PURE__ */ new WeakMap();
1020
- function tn(e) {
1021
+ const Rt = /* @__PURE__ */ new WeakMap();
1022
+ function nn(e) {
1021
1023
  const t = "jquery" in e ? e[0] : e;
1022
1024
  if (!t || !t.isConnected) return;
1023
- Ze();
1024
- const n = Lt.get(t);
1025
- n && clearTimeout(n), t.classList.add(Rt), Lt.set(
1025
+ en();
1026
+ const n = Rt.get(t);
1027
+ n && clearTimeout(n), t.classList.add(Pt), Rt.set(
1026
1028
  t,
1027
1029
  setTimeout(() => {
1028
- t.classList.remove(Rt), Lt.delete(t);
1030
+ t.classList.remove(Pt), Rt.delete(t);
1029
1031
  }, 600)
1030
1032
  );
1031
1033
  }
1032
- function pe(e, t = {}) {
1033
- return ue(e, t);
1034
+ function be(e, t = {}) {
1035
+ return _e(e, t);
1034
1036
  }
1035
- Object.defineProperty(pe, "debug", {
1037
+ Object.defineProperty(be, "debug", {
1036
1038
  get() {
1037
1039
  return m.enabled;
1038
1040
  },
@@ -1040,27 +1042,50 @@ Object.defineProperty(pe, "debug", {
1040
1042
  m.enabled = e;
1041
1043
  }
1042
1044
  });
1043
- function en() {
1045
+ function sn() {
1044
1046
  return new Promise((e) => setTimeout(e, 0));
1045
1047
  }
1046
- h.extend({
1047
- atom: pe,
1048
- computed: de,
1048
+ l.extend({
1049
+ atom: be,
1050
+ computed: me,
1049
1051
  effect: Z,
1050
- batch: $t,
1051
- untracked: Pe,
1052
- isAtom: le,
1053
- isComputed: he,
1054
- isReactive: _e,
1055
- nextTick: en
1052
+ batch: jt,
1053
+ untracked: He,
1054
+ isAtom: Ee,
1055
+ isComputed: pe,
1056
+ isReactive: ye,
1057
+ nextTick: sn
1056
1058
  });
1057
- const mt = "_aes-bound";
1058
- class nn {
1059
+ const on = "_aes-bound", tt = {
1060
+ ROUTE: "[$.route]",
1061
+ BIND: "[atomBind]",
1062
+ LIST: "[atomList]"
1063
+ }, bt = {
1064
+ MODE: "hash",
1065
+ ACTIVE_CLASS: "active",
1066
+ BASE_PATH: "",
1067
+ AUTO_BIND_LINKS: !1
1068
+ }, rn = {
1069
+ EVENT: "input"
1070
+ }, cn = ["innerHTML", "outerHTML"], rt = {
1071
+ ROUTE_NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
1072
+ TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
1073
+ TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
1074
+ MALFORMED_URI: (e) => `Malformed URI component: ${e}`,
1075
+ UNSAFE_CONTENT: "Unsafe content neutralized during sanitization.",
1076
+ BLOCKED_DANGEROUS_VALUE: (e) => `Blocked dangerous value in "${e}" property.`,
1077
+ BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute "${e}".`,
1078
+ BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}" attribute.`,
1079
+ BLOCKED_DANGEROUS_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`,
1080
+ INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
1081
+ DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.`
1082
+ }, Ct = on;
1083
+ class an {
1059
1084
  constructor() {
1060
- ct(this, "records", /* @__PURE__ */ new WeakMap());
1061
- ct(this, "boundElements", /* @__PURE__ */ new WeakSet());
1062
- ct(this, "preservedNodes", /* @__PURE__ */ new WeakSet());
1063
- ct(this, "ignoredNodes", /* @__PURE__ */ new WeakSet());
1085
+ ut(this, "records", /* @__PURE__ */ new WeakMap());
1086
+ ut(this, "boundElements", /* @__PURE__ */ new WeakSet());
1087
+ ut(this, "preservedNodes", /* @__PURE__ */ new WeakSet());
1088
+ ut(this, "ignoredNodes", /* @__PURE__ */ new WeakSet());
1064
1089
  }
1065
1090
  // Prevent redundant cleanup
1066
1091
  keep(t) {
@@ -1077,7 +1102,7 @@ class nn {
1077
1102
  }
1078
1103
  _getOrCreateRecord(t) {
1079
1104
  let n = this.records.get(t);
1080
- return n || (n = {}, this.records.set(t, n), this.boundElements.has(t) || (this.boundElements.add(t), t.classList.add(mt))), n;
1105
+ return n || (n = {}, this.records.set(t, n), this.boundElements.has(t) || (this.boundElements.add(t), t.classList.add(Ct))), n;
1081
1106
  }
1082
1107
  trackEffect(t, n) {
1083
1108
  const s = this._getOrCreateRecord(t);
@@ -1094,7 +1119,7 @@ class nn {
1094
1119
  if (!this.boundElements.delete(t)) return;
1095
1120
  const n = this.records.get(t);
1096
1121
  if (!n) return;
1097
- this.records.delete(t), this.preservedNodes.delete(t), this.ignoredNodes.delete(t), t.classList.remove(mt), m.enabled && m.cleanup(Dt(t));
1122
+ this.records.delete(t), this.preservedNodes.delete(t), this.ignoredNodes.delete(t), t.classList.remove(Ct), m.enabled && m.cleanup(wt(t));
1098
1123
  const s = n.effects;
1099
1124
  if (s)
1100
1125
  for (let o = 0, r = s.length; o < r; o++)
@@ -1113,20 +1138,20 @@ class nn {
1113
1138
  }
1114
1139
  }
1115
1140
  cleanupDescendants(t) {
1116
- const n = t.querySelectorAll(`.${mt}`);
1141
+ const n = t.querySelectorAll(`.${Ct}`);
1117
1142
  for (let s = 0, i = n.length; s < i; s++) {
1118
1143
  const o = n[s];
1119
- o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(mt);
1144
+ o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(Ct);
1120
1145
  }
1121
1146
  }
1122
1147
  cleanupTree(t) {
1123
1148
  this.cleanupDescendants(t), this.cleanup(t);
1124
1149
  }
1125
1150
  }
1126
- const y = new nn();
1127
- let lt = null;
1128
- function sn(e = document.body) {
1129
- lt || (lt = new MutationObserver((t) => {
1151
+ const y = new an();
1152
+ let ft = null;
1153
+ function un(e = document.body) {
1154
+ ft || (ft = new MutationObserver((t) => {
1130
1155
  for (let n = 0, s = t.length; n < s; n++) {
1131
1156
  const i = t[n]?.removedNodes;
1132
1157
  if (!i) continue;
@@ -1137,102 +1162,102 @@ function sn(e = document.body) {
1137
1162
  c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
1138
1163
  }
1139
1164
  }
1140
- }), lt.observe(e, { childList: !0, subtree: !0 }));
1165
+ }), ft.observe(e, { childList: !0, subtree: !0 }));
1141
1166
  }
1142
- function pn() {
1143
- lt?.disconnect(), lt = null;
1167
+ function yn() {
1168
+ ft?.disconnect(), ft = null;
1144
1169
  }
1145
1170
  function q(e, t, n, s) {
1146
- _e(t) ? y.trackEffect(
1171
+ ye(t) ? y.trackEffect(
1147
1172
  e,
1148
1173
  Z(() => {
1149
1174
  const i = t.value;
1150
- n(i), m.domUpdated(h(e), s, i);
1175
+ n(i), m.domUpdated(l(e), s, i);
1151
1176
  })
1152
- ) : (n(t), m.enabled && m.domUpdated(h(e), s, t));
1177
+ ) : (n(t), m.enabled && m.domUpdated(l(e), s, t));
1153
1178
  }
1154
- var k = /* @__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))(k || {});
1155
- function Ee() {
1179
+ var O = /* @__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))(O || {});
1180
+ function Ce() {
1156
1181
  return {
1157
1182
  timeoutId: null,
1158
1183
  flags: 0
1159
1184
  /* None */
1160
1185
  };
1161
1186
  }
1162
- function on(e, t, n = {}) {
1187
+ function ln(e, t, n = {}) {
1163
1188
  const {
1164
1189
  debounce: s,
1165
- event: i = "input",
1190
+ event: i = rn.EVENT,
1166
1191
  parse: o = (I) => I,
1167
1192
  format: r = (I) => String(I ?? ""),
1168
1193
  equal: c = Object.is
1169
- } = n, a = Ee(), l = e[0], p = () => {
1170
- if (!(a.flags & k.Busy)) {
1171
- a.flags |= k.SyncingToAtom;
1194
+ } = n, a = Ce(), h = e[0], E = () => {
1195
+ if (!(a.flags & O.Busy)) {
1196
+ a.flags |= O.SyncingToAtom;
1172
1197
  try {
1173
- const I = l.value, v = o(I);
1174
- c(t.value, v) || (t.value = v);
1198
+ const I = h.value, T = o(I);
1199
+ c(t.value, T) || (t.value = T);
1175
1200
  } finally {
1176
- a.flags &= ~k.SyncingToAtom;
1201
+ a.flags &= ~O.SyncingToAtom;
1177
1202
  }
1178
1203
  }
1179
- }, C = () => {
1180
- a.timeoutId && (clearTimeout(a.timeoutId), a.timeoutId = null, p()), a.flags &= ~k.Focused;
1204
+ }, S = () => {
1205
+ a.timeoutId && (clearTimeout(a.timeoutId), a.timeoutId = null, E()), a.flags &= ~O.Focused;
1181
1206
  const I = r(t.value);
1182
- l.value !== I && (l.value = I);
1183
- }, b = () => {
1184
- a.flags & k.Busy || (s ? (a.timeoutId && clearTimeout(a.timeoutId), a.timeoutId = setTimeout(p, s)) : p());
1185
- }, T = {
1207
+ h.value !== I && (h.value = I);
1208
+ }, C = () => {
1209
+ a.flags & O.Busy || (s ? (a.timeoutId && clearTimeout(a.timeoutId), a.timeoutId = setTimeout(E, s)) : E());
1210
+ }, N = {
1186
1211
  compositionstart: () => {
1187
- a.flags |= k.Composing;
1212
+ a.flags |= O.Composing;
1188
1213
  },
1189
1214
  compositionend: () => {
1190
- a.flags &= ~k.Composing, p();
1215
+ a.flags &= ~O.Composing, E();
1191
1216
  },
1192
1217
  focus: () => {
1193
- a.flags |= k.Focused;
1218
+ a.flags |= O.Focused;
1194
1219
  },
1195
- blur: C,
1196
- [i]: b,
1197
- change: b
1220
+ blur: S,
1221
+ [i]: C,
1222
+ change: C
1198
1223
  };
1199
- return e.on(T), { effect: () => {
1200
- const I = t.value, v = r(I), L = l.value;
1201
- if (L !== v && !(a.flags & k.Focused && c(o(L), I))) {
1202
- a.flags |= k.SyncingToDom;
1224
+ return e.on(N), { effect: () => {
1225
+ const I = t.value, T = r(I), v = h.value;
1226
+ if (v !== T && !(a.flags & O.Focused && c(o(v), I))) {
1227
+ a.flags |= O.SyncingToDom;
1203
1228
  try {
1204
- if (a.flags & k.Focused) {
1205
- const { selectionStart: tt, selectionEnd: ot } = l;
1206
- l.value = v;
1207
- const j = v.length;
1208
- l.setSelectionRange(Math.min(tt ?? 0, j), Math.min(ot ?? 0, j));
1229
+ if (a.flags & O.Focused) {
1230
+ const { selectionStart: et, selectionEnd: ct } = h;
1231
+ h.value = T;
1232
+ const H = T.length;
1233
+ h.setSelectionRange(Math.min(et ?? 0, H), Math.min(ct ?? 0, H));
1209
1234
  } else
1210
- l.value = v;
1211
- m.domUpdated(e, "val", v);
1235
+ h.value = T;
1236
+ m.domUpdated(e, "val", T);
1212
1237
  } finally {
1213
- a.flags &= ~k.SyncingToDom;
1238
+ a.flags &= ~O.SyncingToDom;
1214
1239
  }
1215
1240
  }
1216
1241
  }, cleanup: () => {
1217
- e.off(T), a.timeoutId && clearTimeout(a.timeoutId);
1242
+ e.off(N), a.timeoutId && clearTimeout(a.timeoutId);
1218
1243
  } };
1219
1244
  }
1220
- const Zt = /* @__PURE__ */ Object.create(null);
1221
- function rn(e) {
1222
- let t = Zt[e];
1223
- return t || (t = e.includes("-") ? e.replace(/-./g, (n) => n[1].toUpperCase()) : e, Zt[e] = t, t);
1245
+ const se = /* @__PURE__ */ Object.create(null);
1246
+ function hn(e) {
1247
+ let t = se[e];
1248
+ return t || (t = e.includes("-") ? e.replace(/-./g, (n) => n[1].toUpperCase()) : e, se[e] = t, t);
1224
1249
  }
1225
1250
  function $(e) {
1226
1251
  let t = null;
1227
1252
  return {
1228
1253
  get $el() {
1229
- return t || (t = h(e)), t;
1254
+ return t || (t = l(e)), t;
1230
1255
  },
1231
1256
  el: e,
1232
1257
  trackCleanup: (n) => y.trackCleanup(e, n)
1233
1258
  };
1234
1259
  }
1235
- function cn(e, t) {
1260
+ function fn(e, t) {
1236
1261
  const n = e.el;
1237
1262
  q(
1238
1263
  n,
@@ -1244,19 +1269,19 @@ function cn(e, t) {
1244
1269
  "text"
1245
1270
  );
1246
1271
  }
1247
- function ge(e, t) {
1272
+ function Se(e, t) {
1248
1273
  const n = e.el;
1249
1274
  q(
1250
1275
  n,
1251
1276
  t,
1252
1277
  (s) => {
1253
- const i = String(s ?? ""), o = It(i);
1254
- o !== i && console.warn("[atomBind] Unsafe content neutralized during sanitization."), n.innerHTML !== o && (n.innerHTML = o);
1278
+ const i = String(s ?? ""), o = Tt(i);
1279
+ o !== i && console.warn(`${tt.BIND} ${rt.UNSAFE_CONTENT}`), n.innerHTML !== o && (n.innerHTML = o);
1255
1280
  },
1256
1281
  "html"
1257
1282
  );
1258
1283
  }
1259
- function me(e, t) {
1284
+ function Ie(e, t) {
1260
1285
  for (const n in t)
1261
1286
  q(
1262
1287
  e.el,
@@ -1267,33 +1292,33 @@ function me(e, t) {
1267
1292
  `class.${n}`
1268
1293
  );
1269
1294
  }
1270
- function ye(e, t) {
1295
+ function Te(e, t) {
1271
1296
  const n = e.el, s = n.style;
1272
1297
  for (const i in t) {
1273
1298
  const o = t[i];
1274
1299
  if (o === void 0) continue;
1275
- const r = rn(i), c = Array.isArray(o), a = c ? o[0] : o, l = c ? o[1] : "";
1300
+ const r = hn(i), c = Array.isArray(o), a = c ? o[0] : o, h = c ? o[1] : "";
1276
1301
  q(
1277
1302
  n,
1278
1303
  a,
1279
- (p) => {
1280
- const C = l ? `${p}${l}` : String(p);
1281
- if (We(C)) {
1282
- console.warn(`[atomBind] Blocked dangerous value in "${i}" property.`);
1304
+ (E) => {
1305
+ const S = h ? `${E}${h}` : String(E);
1306
+ if (Ye(S)) {
1307
+ console.warn(`${tt.BIND} ${rt.BLOCKED_DANGEROUS_VALUE(i)}`);
1283
1308
  return;
1284
1309
  }
1285
- s[r] = C;
1310
+ s[r] = S;
1286
1311
  },
1287
1312
  `css.${i}`
1288
1313
  );
1289
1314
  }
1290
1315
  }
1291
- function be(e, t) {
1316
+ function De(e, t) {
1292
1317
  const n = e.el;
1293
1318
  for (const s in t) {
1294
1319
  const i = s.charCodeAt(0);
1295
1320
  if ((i === 111 || i === 79) && (s.charCodeAt(1) === 110 || s.charCodeAt(1) === 78)) {
1296
- console.warn(`[atomBind] Blocked setting dangerous event handler attribute "${s}".`);
1321
+ console.warn(`${tt.BIND} ${rt.BLOCKED_EVENT_HANDLER(s)}`);
1297
1322
  continue;
1298
1323
  }
1299
1324
  q(
@@ -1305,8 +1330,8 @@ function be(e, t) {
1305
1330
  return;
1306
1331
  }
1307
1332
  const r = o === !0 ? s : String(o);
1308
- if (Ge(s, r)) {
1309
- console.warn(`[atomBind] Blocked dangerous protocol in "${s}" attribute.`);
1333
+ if (We(s, r)) {
1334
+ console.warn(`${tt.BIND} ${rt.BLOCKED_PROTOCOL(s)}`);
1310
1335
  return;
1311
1336
  }
1312
1337
  n.getAttribute(s) !== r && n.setAttribute(s, r);
@@ -1315,14 +1340,11 @@ function be(e, t) {
1315
1340
  );
1316
1341
  }
1317
1342
  }
1318
- const an = ["innerHTML", "outerHTML"];
1319
- function Ce(e, t) {
1343
+ function Oe(e, t) {
1320
1344
  const n = e.el;
1321
1345
  for (const s in t) {
1322
- if (an.includes(s)) {
1323
- console.warn(
1324
- `[atomBind] Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`
1325
- );
1346
+ if (cn.includes(s)) {
1347
+ console.warn(`${tt.BIND} ${rt.BLOCKED_DANGEROUS_PROP(s)}`);
1326
1348
  continue;
1327
1349
  }
1328
1350
  q(
@@ -1335,7 +1357,7 @@ function Ce(e, t) {
1335
1357
  );
1336
1358
  }
1337
1359
  }
1338
- function wt(e, t, n, s) {
1360
+ function At(e, t, n, s) {
1339
1361
  const i = e.el;
1340
1362
  q(
1341
1363
  i,
@@ -1347,209 +1369,209 @@ function wt(e, t, n, s) {
1347
1369
  s
1348
1370
  );
1349
1371
  }
1350
- function Ie(e, t) {
1372
+ function Ae(e, t) {
1351
1373
  const n = e.el.tagName.toLowerCase();
1352
1374
  if (n !== "input" && n !== "select" && n !== "textarea") {
1353
1375
  console.warn(`[atomBind] Val binding used on non-input element <${n}>.`);
1354
1376
  return;
1355
1377
  }
1356
- const s = Array.isArray(t), { effect: i, cleanup: o } = on(
1378
+ const s = Array.isArray(t), { effect: i, cleanup: o } = ln(
1357
1379
  e.$el,
1358
1380
  s ? t[0] : t,
1359
1381
  s ? t[1] : {}
1360
1382
  );
1361
1383
  y.trackEffect(e.el, Z(i)), e.trackCleanup(o);
1362
1384
  }
1363
- function Se(e, t) {
1364
- const n = e.el, s = e.$el, i = Ee(), o = () => {
1365
- if (i.flags & k.Busy) return;
1385
+ function Ne(e, t) {
1386
+ const n = e.el, s = e.$el, i = Ce(), o = () => {
1387
+ if (i.flags & O.Busy) return;
1366
1388
  const c = n.checked;
1367
1389
  t.value !== c && (t.value = c);
1368
1390
  };
1369
1391
  s.on("change", o), e.trackCleanup(() => s.off("change", o));
1370
1392
  const r = Z(() => {
1371
- i.flags |= k.SyncingToDom;
1393
+ i.flags |= O.SyncingToDom;
1372
1394
  const c = !!t.value;
1373
- n.checked !== c && (n.checked = c, m.enabled && m.domUpdated(s, "checked", c)), i.flags &= ~k.SyncingToDom;
1395
+ n.checked !== c && (n.checked = c, m.enabled && m.domUpdated(s, "checked", c)), i.flags &= ~O.SyncingToDom;
1374
1396
  });
1375
1397
  y.trackEffect(n, r);
1376
1398
  }
1377
- function un(e, t) {
1399
+ function dn(e, t) {
1378
1400
  for (const n in t) {
1379
1401
  const s = t[n];
1380
1402
  if (typeof s != "function") continue;
1381
1403
  const i = (o) => {
1382
- $t(
1404
+ jt(
1383
1405
  () => s.call(
1384
1406
  e.el,
1385
- h.Event(o.type, { originalEvent: o })
1407
+ l.Event(o.type, { originalEvent: o })
1386
1408
  )
1387
1409
  );
1388
1410
  };
1389
1411
  e.el.addEventListener(n, i), e.trackCleanup(() => e.el.removeEventListener(n, i));
1390
1412
  }
1391
1413
  }
1392
- h.fn.atomBind = function(e) {
1414
+ l.fn.atomBind = function(e) {
1393
1415
  return this.each(function() {
1394
1416
  const t = $(this);
1395
- e.text !== void 0 && cn(t, e.text), e.html !== void 0 && ge(t, e.html), e.class && me(t, e.class), e.css && ye(t, e.css), e.attr && be(t, e.attr), e.prop && Ce(t, e.prop), e.show !== void 0 && wt(t, e.show, !1, "show"), e.hide !== void 0 && wt(t, e.hide, !0, "hide"), e.val !== void 0 && Ie(t, e.val), e.checked !== void 0 && Se(t, e.checked), e.on && un(t, e.on);
1417
+ e.text !== void 0 && fn(t, e.text), e.html !== void 0 && Se(t, e.html), e.class && Ie(t, e.class), e.css && Te(t, e.css), e.attr && De(t, e.attr), e.prop && Oe(t, e.prop), e.show !== void 0 && At(t, e.show, !1, "show"), e.hide !== void 0 && At(t, e.hide, !0, "hide"), e.val !== void 0 && Ae(t, e.val), e.checked !== void 0 && Ne(t, e.checked), e.on && dn(t, e.on);
1396
1418
  });
1397
1419
  };
1398
- h.fn.atomText = function(e, t) {
1420
+ l.fn.atomText = function(e, t) {
1399
1421
  return this.each(function() {
1400
- const n = h(this);
1422
+ const n = l(this);
1401
1423
  q(this, e, t ? (i) => n.text(t(i)) : (i) => n.text(String(i ?? "")), "text");
1402
1424
  });
1403
1425
  };
1404
- h.fn.atomHtml = function(e) {
1426
+ l.fn.atomHtml = function(e) {
1405
1427
  return this.each(function() {
1406
- ge($(this), e);
1428
+ Se($(this), e);
1407
1429
  });
1408
1430
  };
1409
- h.fn.atomClass = function(e, t) {
1431
+ l.fn.atomClass = function(e, t) {
1410
1432
  return this.each(function() {
1411
- me($(this), { [e]: t });
1433
+ Ie($(this), { [e]: t });
1412
1434
  });
1413
1435
  };
1414
- h.fn.atomCss = function(e, t, n) {
1436
+ l.fn.atomCss = function(e, t, n) {
1415
1437
  return this.each(function() {
1416
- ye($(this), { [e]: n ? [t, n] : t });
1438
+ Te($(this), { [e]: n ? [t, n] : t });
1417
1439
  });
1418
1440
  };
1419
- h.fn.atomAttr = function(e, t) {
1441
+ l.fn.atomAttr = function(e, t) {
1420
1442
  return this.each(function() {
1421
- be($(this), { [e]: t });
1443
+ De($(this), { [e]: t });
1422
1444
  });
1423
1445
  };
1424
- h.fn.atomProp = function(e, t) {
1446
+ l.fn.atomProp = function(e, t) {
1425
1447
  return this.each(function() {
1426
- Ce($(this), { [e]: t });
1448
+ Oe($(this), { [e]: t });
1427
1449
  });
1428
1450
  };
1429
- h.fn.atomShow = function(e) {
1451
+ l.fn.atomShow = function(e) {
1430
1452
  return this.each(function() {
1431
- wt($(this), e, !1, "show");
1453
+ At($(this), e, !1, "show");
1432
1454
  });
1433
1455
  };
1434
- h.fn.atomHide = function(e) {
1456
+ l.fn.atomHide = function(e) {
1435
1457
  return this.each(function() {
1436
- wt($(this), e, !0, "hide");
1458
+ At($(this), e, !0, "hide");
1437
1459
  });
1438
1460
  };
1439
- h.fn.atomVal = function(e, t = {}) {
1461
+ l.fn.atomVal = function(e, t = {}) {
1440
1462
  return this.each(function() {
1441
- Ie(
1463
+ Ae(
1442
1464
  $(this),
1443
1465
  t && Object.keys(t).length > 0 ? [e, t] : e
1444
1466
  );
1445
1467
  });
1446
1468
  };
1447
- h.fn.atomChecked = function(e) {
1469
+ l.fn.atomChecked = function(e) {
1448
1470
  return this.each(function() {
1449
- Se($(this), e);
1471
+ Ne($(this), e);
1450
1472
  });
1451
1473
  };
1452
- h.fn.atomOn = function(e, t) {
1474
+ l.fn.atomOn = function(e, t) {
1453
1475
  return this.each(function() {
1454
- const n = h(this);
1476
+ const n = l(this);
1455
1477
  n.on(e, t), y.trackCleanup(this, () => n.off(e, t));
1456
1478
  });
1457
1479
  };
1458
- h.fn.atomUnbind = function() {
1480
+ l.fn.atomUnbind = function() {
1459
1481
  return this.each(function() {
1460
1482
  y.cleanupTree(this);
1461
1483
  });
1462
1484
  };
1463
- h.fn.atomList = function(e, t) {
1464
- const { key: n, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: a } = t, l = typeof n == "function" ? n : (p, C) => p[n];
1485
+ l.fn.atomList = function(e, t) {
1486
+ const { key: n, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: a } = t, h = typeof n == "function" ? n : (E, S) => E[n];
1465
1487
  return this.each(function() {
1466
- const p = h(this), C = Dt(this), b = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Set();
1467
- let O = [], A = null;
1488
+ const E = l(this), S = wt(this), C = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Set();
1489
+ let w = [], L = null;
1468
1490
  const I = Z(() => {
1469
- const v = e.value, L = v.length;
1470
- if (L === 0) {
1471
- if (a && !A) {
1472
- const d = typeof a == "string" ? It(a) : a;
1473
- A = h(d).appendTo(p);
1491
+ const T = e.value, v = T.length;
1492
+ if (v === 0) {
1493
+ if (a && !L) {
1494
+ const d = typeof a == "string" ? Tt(a) : a;
1495
+ L = l(d).appendTo(E);
1474
1496
  }
1475
- } else A && (A.remove(), A = null);
1476
- if (L === 0 && b.size === 0) {
1477
- O = [];
1497
+ } else L && (L.remove(), L = null);
1498
+ if (v === 0 && C.size === 0) {
1499
+ w = [];
1478
1500
  return;
1479
1501
  }
1480
- m.log("list", `${C} updating with ${L} items`);
1481
- const tt = /* @__PURE__ */ new Map(), ot = O.length;
1482
- for (let d = 0; d < ot; d++)
1483
- tt.set(O[d], d);
1484
- const j = new Array(L), rt = /* @__PURE__ */ new Set(), ft = new Int32Array(L);
1485
- for (let d = 0; d < L; d++) {
1486
- const N = v[d], g = l(N, d);
1487
- rt.has(g) && console.warn(`[atomList] Duplicate key "${g}" at index ${d}.`), j[d] = g, rt.add(g), ft[d] = tt.get(g) ?? -1;
1502
+ m.log("list", `${S} updating with ${v} items`);
1503
+ const et = /* @__PURE__ */ new Map(), ct = w.length;
1504
+ for (let d = 0; d < ct; d++)
1505
+ et.set(w[d], d);
1506
+ const H = new Array(v), at = /* @__PURE__ */ new Set(), _t = new Int32Array(v);
1507
+ for (let d = 0; d < v; d++) {
1508
+ const U = T[d], g = h(U, d);
1509
+ at.has(g) && console.warn(`${tt.LIST} ${rt.DUPLICATE_KEY(g, d)}`), H[d] = g, at.add(g), _t[d] = et.get(g) ?? -1;
1488
1510
  }
1489
- if (b.size > 0)
1490
- for (const [d, N] of b) {
1491
- if (rt.has(d) || T.has(d)) continue;
1511
+ if (C.size > 0)
1512
+ for (const [d, U] of C) {
1513
+ if (at.has(d) || N.has(d)) continue;
1492
1514
  const g = () => {
1493
- N.$el.remove(), N.$el[0] && y.cleanup(N.$el[0]), T.delete(d), m.log("list", `${C} removed item:`, d);
1515
+ U.$el.remove(), U.$el[0] && y.cleanup(U.$el[0]), N.delete(d), m.log("list", `${S} removed item:`, d);
1494
1516
  };
1495
- if (b.delete(d), T.add(d), c) {
1496
- const w = c(N.$el);
1497
- w instanceof Promise ? w.then(g) : g();
1517
+ if (C.delete(d), N.add(d), c) {
1518
+ const D = c(U.$el);
1519
+ D instanceof Promise ? D.then(g) : g();
1498
1520
  } else
1499
1521
  g();
1500
1522
  }
1501
- if (L === 0) {
1502
- O = [];
1523
+ if (v === 0) {
1524
+ w = [];
1503
1525
  return;
1504
1526
  }
1505
- const dt = Ke(ft);
1506
- let U = dt.length - 1, x = null;
1507
- for (let d = L - 1; d >= 0; d--) {
1508
- const N = j[d], g = v[d], w = b.get(N);
1509
- if (w) {
1510
- const B = w.item;
1511
- w.item = g;
1512
- const et = w.$el[0];
1513
- if (!et) continue;
1527
+ const Et = Ze(_t);
1528
+ let F = Et.length - 1, R = null;
1529
+ for (let d = v - 1; d >= 0; d--) {
1530
+ const U = H[d], g = T[d], D = C.get(U);
1531
+ if (D) {
1532
+ const B = D.item;
1533
+ D.item = g;
1534
+ const nt = D.$el[0];
1535
+ if (!nt) continue;
1514
1536
  if (o)
1515
- o(w.$el, g, d), m.domUpdated(w.$el, "list.update", g);
1516
- else if (B !== g && !Ye(B, g)) {
1517
- const u = s(g, d), _ = typeof u == "string" ? It(u) : u, E = h(_), f = x === et;
1518
- w.$el.replaceWith(E), w.$el = E, i && i(E, g, d), m.domUpdated(E, "list.render", g), f && (x = E[0] || null);
1537
+ o(D.$el, g, d), m.domUpdated(D.$el, "list.update", g);
1538
+ else if (B !== g && !Je(B, g)) {
1539
+ const u = s(g, d), _ = typeof u == "string" ? Tt(u) : u, p = l(_), f = R === nt;
1540
+ D.$el.replaceWith(p), D.$el = p, i && i(p, g, d), m.domUpdated(p, "list.render", g), f && (R = p[0] || null);
1519
1541
  }
1520
- if (U >= 0 && dt[U] === d)
1521
- U--;
1542
+ if (F >= 0 && Et[F] === d)
1543
+ F--;
1522
1544
  else {
1523
- const u = w.$el[0];
1524
- x?.isConnected ? x !== u && w.$el.insertBefore(x) : w.$el.appendTo(p);
1545
+ const u = D.$el[0];
1546
+ R?.isConnected ? R !== u && D.$el.insertBefore(R) : D.$el.appendTo(E);
1525
1547
  }
1526
- x = w.$el[0] || null;
1548
+ R = D.$el[0] || null;
1527
1549
  } else {
1528
- const B = s(g, d), et = typeof B == "string" ? It(B) : B, u = h(et);
1529
- b.set(N, { $el: u, item: g }), x?.isConnected ? u.insertBefore(x) : u.appendTo(p), i && i(u, g, d), r && r(u), m.domUpdated(u, "list.add", g), x = u[0] || null;
1550
+ const B = s(g, d), nt = typeof B == "string" ? Tt(B) : B, u = l(nt);
1551
+ C.set(U, { $el: u, item: g }), R?.isConnected ? u.insertBefore(R) : u.appendTo(E), i && i(u, g, d), r && r(u), m.domUpdated(u, "list.add", g), R = u[0] || null;
1530
1552
  }
1531
1553
  }
1532
- O = j;
1554
+ w = H;
1533
1555
  });
1534
1556
  y.trackEffect(this, I), y.trackCleanup(this, () => {
1535
- b.clear(), T.clear(), O = [], A?.remove();
1557
+ C.clear(), N.clear(), w = [], L?.remove();
1536
1558
  });
1537
1559
  });
1538
1560
  };
1539
- const St = /* @__PURE__ */ new WeakMap();
1540
- h.fn.atomMount = function(e, t = {}) {
1561
+ const Dt = /* @__PURE__ */ new WeakMap();
1562
+ l.fn.atomMount = function(e, t = {}) {
1541
1563
  return this.each(function() {
1542
- const n = Dt(this), s = St.get(this);
1564
+ const n = wt(this), s = Dt.get(this);
1543
1565
  s && (m.log("mount", `${n} unmounting existing component`), s()), m.log("mount", `${n} mounting component`);
1544
1566
  let i;
1545
1567
  try {
1546
- i = e(h(this), t);
1568
+ i = e(l(this), t);
1547
1569
  } catch (r) {
1548
1570
  console.error("[atom-effect-jquery] Mount error:", r);
1549
1571
  return;
1550
1572
  }
1551
1573
  const o = () => {
1552
- if (St.delete(this)) {
1574
+ if (Dt.delete(this)) {
1553
1575
  if (m.log("mount", `${n} full cleanup`), typeof i == "function")
1554
1576
  try {
1555
1577
  i();
@@ -1559,129 +1581,129 @@ h.fn.atomMount = function(e, t = {}) {
1559
1581
  y.cleanupTree(this);
1560
1582
  }
1561
1583
  };
1562
- St.set(this, o), y.trackCleanup(this, o);
1584
+ Dt.set(this, o), y.trackCleanup(this, o);
1563
1585
  });
1564
1586
  };
1565
- h.fn.atomUnmount = function() {
1587
+ l.fn.atomUnmount = function() {
1566
1588
  return this.each(function() {
1567
- const e = St.get(this);
1589
+ const e = Dt.get(this);
1568
1590
  e && e();
1569
1591
  });
1570
1592
  };
1571
- const yt = "[$.route]";
1572
- function ln(e) {
1593
+ const St = tt.ROUTE;
1594
+ function _n(e) {
1573
1595
  const {
1574
1596
  target: t,
1575
1597
  default: n,
1576
1598
  routes: s,
1577
1599
  notFound: i,
1578
- mode: o = "hash",
1579
- basePath: r = "",
1580
- autoBindLinks: c = !1,
1581
- activeClass: a = "active",
1582
- beforeTransition: l,
1583
- afterTransition: p
1584
- } = e, C = o === "history";
1585
- let b = !1, T = null, O = C ? window.location.pathname + window.location.search : window.location.hash;
1586
- const A = [], I = /* @__PURE__ */ new Set(), v = h(t), L = () => {
1587
- if (C) {
1600
+ mode: o = bt.MODE,
1601
+ basePath: r = bt.BASE_PATH,
1602
+ autoBindLinks: c = bt.AUTO_BIND_LINKS,
1603
+ activeClass: a = bt.ACTIVE_CLASS,
1604
+ beforeTransition: h,
1605
+ afterTransition: E
1606
+ } = e, S = o === "history";
1607
+ let C = !1, N = null, w = S ? window.location.pathname + window.location.search : window.location.hash;
1608
+ const L = [], I = /* @__PURE__ */ new Set(), T = l(t), v = () => {
1609
+ if (S) {
1588
1610
  let f = window.location.pathname;
1589
1611
  return r && f.startsWith(r) && (f = f.substring(r.length)), f.replace(/^\//, "") || n;
1590
1612
  }
1591
1613
  const u = window.location.hash, _ = u.indexOf("?");
1592
1614
  return (_ === -1 ? u.substring(1) : u.substring(1, _)) || n;
1593
- }, tt = () => {
1615
+ }, et = () => {
1594
1616
  let u;
1595
- if (C) {
1617
+ if (S) {
1596
1618
  if (u = window.location.search.substring(1), !u) return {};
1597
1619
  } else {
1598
- const f = window.location.hash, D = f.indexOf("?");
1599
- if (D === -1) return {};
1600
- u = f.substring(D + 1);
1620
+ const f = window.location.hash, A = f.indexOf("?");
1621
+ if (A === -1) return {};
1622
+ u = f.substring(A + 1);
1601
1623
  }
1602
- const _ = new URLSearchParams(u), E = Object.fromEntries(_);
1624
+ const _ = new URLSearchParams(u), p = Object.fromEntries(_);
1603
1625
  if (u.includes("%"))
1604
1626
  try {
1605
1627
  decodeURIComponent(u);
1606
1628
  } catch {
1607
- console.warn(`${yt} Malformed URI component: ${u}`);
1629
+ console.warn(`${St} Malformed URI component: ${u}`);
1608
1630
  }
1609
- return E;
1610
- }, ot = (u) => {
1611
- if (C) {
1631
+ return p;
1632
+ }, ct = (u) => {
1633
+ if (S) {
1612
1634
  const _ = `${r.replace(/\/$/, "")}/${u}`;
1613
- history.pushState(null, "", _), O = _;
1635
+ history.pushState(null, "", _), w = _;
1614
1636
  } else {
1615
1637
  const _ = `#${u}`;
1616
- O = _, window.location.hash = _;
1638
+ w = _, window.location.hash = _;
1617
1639
  }
1618
- }, j = () => {
1619
- C ? history.replaceState(null, "", O) : window.location.hash = O;
1620
- }, rt = () => C ? window.location.pathname + window.location.search : window.location.hash, ft = (u) => {
1640
+ }, H = () => {
1641
+ S ? history.replaceState(null, "", w) : window.location.hash = w;
1642
+ }, at = () => S ? window.location.pathname + window.location.search : window.location.hash, _t = (u) => {
1621
1643
  let _ = s[u];
1622
- return !_ && i && (_ = s[i]), _ || (console.warn(`${yt} Route "${u}" not found and no notFound route configured`), null);
1623
- }, dt = (u) => {
1644
+ return !_ && i && (_ = s[i]), _ || (console.warn(`${St} Route "${u}" not found and no notFound route configured`), null);
1645
+ }, Et = (u) => {
1624
1646
  const _ = document.querySelector(u);
1625
1647
  if (!_?.content)
1626
- return console.warn(`${yt} Template "${u}" not found`), !1;
1627
- const E = _.content.cloneNode(!0);
1628
- return v.append(E), !0;
1629
- }, U = ue(L()), x = (u) => {
1630
- if (b) return;
1631
- const _ = v[0];
1648
+ return console.warn(`${St} Template "${u}" not found`), !1;
1649
+ const p = _.content.cloneNode(!0);
1650
+ return T.append(p), !0;
1651
+ }, F = _e(v()), R = (u) => {
1652
+ if (C) return;
1653
+ const _ = T[0];
1632
1654
  if (!_) {
1633
- console.warn(`${yt} Target element "${t}" not found`);
1655
+ console.warn(`${St} Target element "${t}" not found`);
1634
1656
  return;
1635
1657
  }
1636
- const E = ft(u);
1637
- if (!E) return;
1638
- const f = tt();
1639
- l && l(T || u, u), v.empty();
1640
- let D = f;
1641
- if (E.onEnter) {
1642
- const X = E.onEnter(f);
1643
- X !== void 0 && (D = { ...f, ...X });
1658
+ const p = _t(u);
1659
+ if (!p) return;
1660
+ const f = et();
1661
+ h && h(N || u, u), T.empty();
1662
+ let A = f;
1663
+ if (p.onEnter) {
1664
+ const X = p.onEnter(f);
1665
+ X !== void 0 && (A = { ...f, ...X });
1644
1666
  }
1645
- E.render ? E.render(_, u, D) : E.template && dt(E.template), p && p(T || u, u), T = u;
1667
+ p.render ? p.render(_, u, A) : p.template && Et(p.template), E && E(N || u, u), N = u;
1646
1668
  }, d = (u) => {
1647
- if (b) return;
1648
- const _ = U.value, E = s[_];
1649
- if (E?.onLeave && E.onLeave() === !1)
1669
+ if (C) return;
1670
+ const _ = F.value, p = s[_];
1671
+ if (p?.onLeave && p.onLeave() === !1)
1650
1672
  return;
1651
1673
  const f = u || n;
1652
- ot(f), U.value = f;
1653
- }, N = () => {
1654
- if (b) return;
1655
- const u = rt();
1656
- if (u === O) return;
1657
- const _ = L(), E = U.value;
1658
- if (E !== _) {
1659
- const f = s[E];
1674
+ ct(f), F.value = f;
1675
+ }, U = () => {
1676
+ if (C) return;
1677
+ const u = at();
1678
+ if (u === w) return;
1679
+ const _ = v(), p = F.value;
1680
+ if (p !== _) {
1681
+ const f = s[p];
1660
1682
  if (f?.onLeave && f.onLeave() === !1) {
1661
- j();
1683
+ H();
1662
1684
  return;
1663
1685
  }
1664
- U.value = _;
1686
+ F.value = _;
1665
1687
  } else
1666
- x(_);
1667
- O = u;
1688
+ R(_);
1689
+ w = u;
1668
1690
  }, g = () => {
1669
1691
  if (!c) return;
1670
1692
  const u = (f) => {
1671
1693
  f.preventDefault();
1672
- const D = f.currentTarget.dataset.route;
1673
- D != null && d(D);
1694
+ const A = f.currentTarget.dataset.route;
1695
+ A != null && d(A);
1674
1696
  };
1675
- h(document).on("click", "[data-route]", u), A.push(() => {
1676
- h(document).off("click", "[data-route]", u);
1697
+ l(document).on("click", "[data-route]", u), L.push(() => {
1698
+ l(document).off("click", "[data-route]", u);
1677
1699
  });
1678
1700
  const _ = (f) => {
1679
1701
  if (I.has(f)) return;
1680
- const D = f.dataset.route;
1702
+ const A = f.dataset.route;
1681
1703
  I.add(f);
1682
1704
  const X = Z(() => {
1683
- const Q = U.value === D;
1684
- f.classList.toggle(a, Q), Q ? f.setAttribute("aria-current", "page") : f.removeAttribute("aria-current");
1705
+ const G = F.value === A;
1706
+ f.classList.toggle(a, G), G ? f.setAttribute("aria-current", "page") : f.removeAttribute("aria-current");
1685
1707
  });
1686
1708
  y.trackEffect(f, X), y.trackCleanup(f, () => {
1687
1709
  I.delete(f);
@@ -1689,124 +1711,124 @@ function ln(e) {
1689
1711
  };
1690
1712
  for (const f of document.querySelectorAll("[data-route]"))
1691
1713
  _(f);
1692
- const E = new MutationObserver((f) => {
1693
- for (const D of f)
1694
- D.type === "childList" && D.addedNodes.forEach((X) => {
1714
+ const p = new MutationObserver((f) => {
1715
+ for (const A of f)
1716
+ A.type === "childList" && A.addedNodes.forEach((X) => {
1695
1717
  if (X.nodeType === 1) {
1696
- const Q = X;
1697
- Q.matches?.("[data-route]") && _(Q), Q.querySelectorAll && Q.querySelectorAll("[data-route]").forEach(
1698
- (ve) => _(ve)
1718
+ const G = X;
1719
+ G.matches?.("[data-route]") && _(G), G.querySelectorAll && G.querySelectorAll("[data-route]").forEach(
1720
+ (we) => _(we)
1699
1721
  );
1700
1722
  }
1701
1723
  });
1702
1724
  });
1703
- E.observe(document.body, { childList: !0, subtree: !0 }), A.push(() => E.disconnect());
1704
- }, w = () => {
1705
- b || (b = !0, A.forEach((u) => u()), A.length = 0, I.forEach((u) => y.cleanup(u)), I.clear());
1706
- }, B = C ? "popstate" : "hashchange";
1707
- window.addEventListener(B, N), A.push(() => window.removeEventListener(B, N));
1708
- const et = Z(() => {
1709
- x(U.value);
1725
+ p.observe(document.body, { childList: !0, subtree: !0 }), L.push(() => p.disconnect());
1726
+ }, D = () => {
1727
+ C || (C = !0, L.forEach((u) => u()), L.length = 0, I.forEach((u) => y.cleanup(u)), I.clear());
1728
+ }, B = S ? "popstate" : "hashchange";
1729
+ window.addEventListener(B, U), L.push(() => window.removeEventListener(B, U));
1730
+ const nt = Z(() => {
1731
+ R(F.value);
1710
1732
  });
1711
- return A.push(() => et.dispose()), g(), v[0] && y.trackCleanup(v[0], w), {
1712
- currentRoute: U,
1733
+ return L.push(() => nt.dispose()), g(), T[0] && y.trackCleanup(T[0], D), {
1734
+ currentRoute: F,
1713
1735
  navigate: d,
1714
- destroy: w
1736
+ destroy: D
1715
1737
  };
1716
1738
  }
1717
- h.extend({
1718
- route: ln
1739
+ l.extend({
1740
+ route: _n
1719
1741
  });
1720
- function hn(e, t) {
1742
+ function En(e, t) {
1721
1743
  const { defaultValue: n, transform: s, method: i, headers: o, ajaxOptions: r } = t, c = typeof e == "function" ? e : () => e;
1722
- return de(
1744
+ return me(
1723
1745
  async () => {
1724
- const a = c(), l = await h.ajax({ ...r, url: a, method: i, headers: o });
1725
- return s ? s(l) : l;
1746
+ const a = c(), h = await l.ajax({ ...r, url: a, method: i, headers: o });
1747
+ return s ? s(h) : h;
1726
1748
  },
1727
1749
  { defaultValue: n, lazy: !1 }
1728
1750
  );
1729
1751
  }
1730
- h.extend({ atomFetch: hn });
1731
- const kt = /* @__PURE__ */ new WeakMap();
1732
- let te = !1;
1733
- const ee = (e) => {
1734
- let t = kt.get(e);
1752
+ l.extend({ atomFetch: En });
1753
+ const Nt = /* @__PURE__ */ new WeakMap();
1754
+ let ie = !1;
1755
+ const oe = (e) => {
1756
+ let t = Nt.get(e);
1735
1757
  return t || (t = function(...n) {
1736
- return $t(() => e.apply(this, n));
1737
- }, kt.set(e, t)), t;
1758
+ return jt(() => e.apply(this, n));
1759
+ }, Nt.set(e, t)), t;
1738
1760
  };
1739
- function fn() {
1740
- if (te) return;
1741
- te = !0;
1742
- const e = h.fn.on, t = h.fn.off, n = h.fn.remove, s = h.fn.empty, i = h.fn.detach;
1743
- h.fn.remove = function(o) {
1761
+ function pn() {
1762
+ if (ie) return;
1763
+ ie = !0;
1764
+ const e = l.fn.on, t = l.fn.off, n = l.fn.remove, s = l.fn.empty, i = l.fn.detach;
1765
+ l.fn.remove = function(o) {
1744
1766
  const r = o ? this.filter(o) : this;
1745
1767
  for (let c = 0, a = r.length; c < a; c++) {
1746
- const l = r[c];
1747
- l && (y.cleanupTree(l), y.markIgnored(l));
1768
+ const h = r[c];
1769
+ h && (y.cleanupTree(h), y.markIgnored(h));
1748
1770
  }
1749
1771
  return n.call(this, o);
1750
- }, h.fn.empty = function() {
1772
+ }, l.fn.empty = function() {
1751
1773
  for (let o = 0, r = this.length; o < r; o++) {
1752
1774
  const c = this[o];
1753
1775
  c && y.cleanupDescendants(c);
1754
1776
  }
1755
1777
  return s.call(this);
1756
- }, h.fn.detach = function(o) {
1778
+ }, l.fn.detach = function(o) {
1757
1779
  const r = o ? this.filter(o) : this;
1758
1780
  for (let c = 0, a = r.length; c < a; c++) {
1759
- const l = r[c];
1760
- l && y.keep(l);
1781
+ const h = r[c];
1782
+ h && y.keep(h);
1761
1783
  }
1762
1784
  return i.call(this, o);
1763
- }, h.fn.on = function(...o) {
1785
+ }, l.fn.on = function(...o) {
1764
1786
  const r = o[0];
1765
1787
  if (r && typeof r == "object") {
1766
1788
  const c = r, a = {};
1767
- for (const l in c) {
1768
- const p = c[l];
1769
- p && (a[l] = ee(p));
1789
+ for (const h in c) {
1790
+ const E = c[h];
1791
+ E && (a[h] = oe(E));
1770
1792
  }
1771
1793
  o[0] = a;
1772
1794
  } else
1773
1795
  for (let c = o.length - 1; c >= 0; c--)
1774
1796
  if (typeof o[c] == "function") {
1775
- o[c] = ee(o[c]);
1797
+ o[c] = oe(o[c]);
1776
1798
  break;
1777
1799
  }
1778
1800
  return e.apply(this, o);
1779
- }, h.fn.off = function(...o) {
1801
+ }, l.fn.off = function(...o) {
1780
1802
  const r = o[0];
1781
1803
  if (r && typeof r == "object") {
1782
1804
  const c = r, a = {};
1783
- for (const l in c) {
1784
- const p = c[l];
1785
- p && (a[l] = kt.get(p) || p);
1805
+ for (const h in c) {
1806
+ const E = c[h];
1807
+ E && (a[h] = Nt.get(E) || E);
1786
1808
  }
1787
1809
  o[0] = a;
1788
1810
  } else
1789
1811
  for (let c = o.length - 1; c >= 0; c--)
1790
1812
  if (typeof o[c] == "function") {
1791
- o[c] = kt.get(o[c]) || o[c];
1813
+ o[c] = Nt.get(o[c]) || o[c];
1792
1814
  break;
1793
1815
  }
1794
1816
  return t.apply(this, o);
1795
1817
  };
1796
1818
  }
1797
- h(() => {
1798
- fn(), sn(document.body);
1819
+ l(() => {
1820
+ pn(), un(document.body);
1799
1821
  });
1800
1822
  export {
1801
- ue as atom,
1802
- $t as batch,
1803
- de as computed,
1804
- mn as default,
1805
- pn as disableAutoCleanup,
1823
+ _e as atom,
1824
+ jt as batch,
1825
+ me as computed,
1826
+ Sn as default,
1827
+ yn as disableAutoCleanup,
1806
1828
  Z as effect,
1807
- sn as enableAutoCleanup,
1808
- fn as enablejQueryOverrides,
1829
+ un as enableAutoCleanup,
1830
+ pn as enablejQueryOverrides,
1809
1831
  y as registry,
1810
- Pe as untracked
1832
+ He as untracked
1811
1833
  };
1812
1834
  //# sourceMappingURL=index.mjs.map