@but212/atom-effect-jquery 0.19.0 → 0.19.1

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