@but212/atom-effect-jquery 0.17.0 → 0.19.0

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