@but212/atom-effect 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- var b = {
1
+ var y = {
2
2
  IDLE: "idle",
3
3
  PENDING: "pending",
4
4
  RESOLVED: "resolved",
5
5
  REJECTED: "rejected"
6
- }, f = {
6
+ }, c = {
7
7
  DISPOSED: 1,
8
8
  EXECUTING: 8
9
- }, x = {
9
+ }, B = {
10
10
  DISPOSED: 1,
11
11
  IS_COMPUTED: 2,
12
12
  DIRTY: 8,
@@ -17,27 +17,27 @@ var b = {
17
17
  RECOMPUTING: 256,
18
18
  HAS_ERROR: 512,
19
19
  FORCE_COMPUTE: 1024
20
- }, d = {
20
+ }, a = {
21
21
  DISPOSED: 1,
22
22
  SYNC: 8,
23
23
  NOTIFICATION_SCHEDULED: 16
24
- }, m = {
24
+ }, I = {
25
25
  MAX_EXECUTIONS_PER_SECOND: 1e3,
26
26
  MAX_EXECUTIONS_PER_EFFECT: 100,
27
27
  MAX_EXECUTIONS_PER_FLUSH: 1e4,
28
28
  MAX_FLUSH_ITERATIONS: 1e3,
29
29
  MIN_FLUSH_ITERATIONS: 10,
30
30
  BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
31
- }, st = {
31
+ }, tt = {
32
32
  WARN_INFINITE_LOOP: !0,
33
33
  EFFECT_FREQUENCY_WINDOW: 1e3
34
- }, j = {
34
+ }, $ = {
35
35
  MAX_ASYNC_RETRIES: 3,
36
36
  MAX_PROMISE_ID: Number.MAX_SAFE_INTEGER - 1
37
- }, C = {
37
+ }, p = {
38
38
  UNINITIALIZED: -1,
39
39
  MIN: 1
40
- }, G = 1073741823, q = { VERSION_BITS: 16 }, Ct = (typeof process < "u" && process.env, !1), W = Object.freeze([]), H = class {
40
+ }, st = 1073741823, j = { VERSION_BITS: 16 }, Ct = (typeof process < "u" && process.env, !1), q = Object.freeze([]), x = class {
41
41
  constructor(t, s, e = void 0) {
42
42
  this.node = t, this.version = s, this.unsub = e;
43
43
  }
@@ -48,23 +48,23 @@ var b = {
48
48
  notify(t, s) {
49
49
  this.fn ? this.fn(t, s) : this.sub && this.sub.execute();
50
50
  }
51
- }, A = class extends Error {
51
+ }, T = class extends Error {
52
52
  constructor(t, s = null, e = !0) {
53
53
  super(t), this.cause = s, this.recoverable = e, this.name = "AtomError";
54
54
  }
55
- }, S = class extends A {
55
+ }, v = class extends T {
56
56
  constructor(t, s = null) {
57
57
  super(t, s, !0), this.name = "ComputedError";
58
58
  }
59
- }, D = class extends A {
59
+ }, D = class extends T {
60
60
  constructor(t, s = null) {
61
61
  super(t, s, !1), this.name = "EffectError";
62
62
  }
63
- }, R = class extends A {
63
+ }, R = class extends T {
64
64
  constructor(t, s = null) {
65
65
  super(t, s, !1), this.name = "SchedulerError";
66
66
  }
67
- }, l = {
67
+ }, h = {
68
68
  COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
69
69
  COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
70
70
  COMPUTED_COMPUTATION_FAILED: "Computation execution failed",
@@ -85,7 +85,7 @@ var b = {
85
85
  BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
86
86
  }, et = class {
87
87
  constructor() {
88
- this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null;
88
+ this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null, this._freeIndices = null;
89
89
  }
90
90
  get size() {
91
91
  return this._count;
@@ -156,13 +156,13 @@ var b = {
156
156
  const e = this._overflow;
157
157
  if (e !== null && s > 4) {
158
158
  const i = t > 4 ? t - 4 : 0, n = e.length;
159
- for (let r = i; r < n; r++) {
160
- const o = e[r];
161
- o != null && (this._onItemRemoved(o), e[r] = null);
159
+ for (let o = i; o < n; o++) {
160
+ const r = e[o];
161
+ r != null && (this._onItemRemoved(r), e[o] = null);
162
162
  }
163
163
  t <= 4 ? (e.length = 0, this._overflow = null) : e.length = t - 4;
164
164
  }
165
- this._count = t;
165
+ this._freeIndices !== null && (this._freeIndices = null), this._count = t;
166
166
  }
167
167
  _onItemRemoved(t) {
168
168
  }
@@ -183,14 +183,13 @@ var b = {
183
183
  this._s3 = t, this._count++;
184
184
  return;
185
185
  }
186
+ this._addToOverflow(t);
187
+ }
188
+ _addToOverflow(t) {
186
189
  if (this._overflow === null) this._overflow = [t];
187
190
  else {
188
- const s = this._overflow;
189
- for (let e = 0, i = s.length; e < i; e++) if (s[e] === null) {
190
- s[e] = t, this._count++;
191
- return;
192
- }
193
- s.push(t);
191
+ const s = this._freeIndices;
192
+ s !== null && s.length > 0 ? this._overflow[s.pop()] = t : this._overflow.push(t);
194
193
  }
195
194
  this._count++;
196
195
  }
@@ -206,48 +205,32 @@ var b = {
206
205
  const s = this._overflow;
207
206
  if (s == null) return !1;
208
207
  for (let e = 0, i = s.length; e < i; e++) if (s[e] === t)
209
- return s[e] = null, this._count--, !0;
208
+ return s[e] = null, this._count--, this._freeIndices === null && (this._freeIndices = []), this._freeIndices.push(e), !0;
210
209
  return !1;
211
210
  }
212
211
  has(t) {
213
- const s = this._count;
214
- if (s === 0) return !1;
212
+ if (this._count === 0) return !1;
215
213
  if (this._s0 === t || this._s1 === t || this._s2 === t || this._s3 === t) return !0;
216
- if (s <= 4) return !1;
217
- const e = this._overflow;
218
- if (e != null) {
219
- let i = 0;
220
- this._s0 != null && i++, this._s1 != null && i++, this._s2 != null && i++, this._s3 != null && i++;
221
- for (let n = 0, r = e.length; n < r; n++) {
222
- const o = e[n];
223
- if (o != null) {
224
- if (o === t) return !0;
225
- if (++i === s) break;
226
- }
227
- }
214
+ const s = this._overflow;
215
+ if (s != null) {
216
+ for (let e = 0, i = s.length; e < i; e++) if (s[e] === t) return !0;
228
217
  }
229
218
  return !1;
230
219
  }
231
220
  forEach(t) {
232
- const s = this._count;
233
- if (s === 0) return;
234
- const e = this._s0;
221
+ if (this._count === 0) return;
222
+ const s = this._s0;
223
+ s != null && t(s);
224
+ const e = this._s1;
235
225
  e != null && t(e);
236
- const i = this._s1;
226
+ const i = this._s2;
237
227
  i != null && t(i);
238
- const n = this._s2;
228
+ const n = this._s3;
239
229
  n != null && t(n);
240
- const r = this._s3;
241
- if (r != null && t(r), s <= 4) return;
242
230
  const o = this._overflow;
243
- if (o != null) {
244
- let h = 0;
245
- e != null && h++, i != null && h++, n != null && h++, r != null && h++;
246
- for (let u = 0, a = o.length; u < a; u++) {
247
- const c = o[u];
248
- if (c != null && (t(c), ++h === s))
249
- return;
250
- }
231
+ if (o != null) for (let r = 0, u = o.length; r < u; r++) {
232
+ const l = o[r];
233
+ l != null && t(l);
251
234
  }
252
235
  }
253
236
  forEachIndexed(t) {
@@ -258,15 +241,14 @@ var b = {
258
241
  i != null && (t(i), e++);
259
242
  const n = this._s1;
260
243
  n != null && (t(n), e++);
261
- const r = this._s2;
262
- r != null && (t(r), e++);
263
- const o = this._s3;
264
- if (o != null && (t(o), e++), s <= 4 || e === s) return e;
265
- const h = this._overflow;
266
- if (h != null) for (let u = 0, a = h.length; u < a; u++) {
267
- const c = h[u];
268
- if (c != null && (t(c), ++e === s))
269
- break;
244
+ const o = this._s2;
245
+ o != null && (t(o), e++);
246
+ const r = this._s3;
247
+ if (r != null && (t(r), e++), e === s) return e;
248
+ const u = this._overflow;
249
+ if (u != null) for (let l = 0, O = u.length; l < O; l++) {
250
+ const Y = u[l];
251
+ Y != null && (t(Y), e++);
270
252
  }
271
253
  return e;
272
254
  }
@@ -275,44 +257,44 @@ var b = {
275
257
  if (t === null || t.length === 0) return;
276
258
  let s = 0;
277
259
  for (; s < t.length; ) if (t[s] === null) {
278
- const e = t.pop();
279
- s < t.length && e != null && (t[s] = e);
260
+ for (; t.length > s && t[t.length - 1] === null; ) t.pop();
261
+ t.length > s && (t[s] = t.pop(), s++);
280
262
  } else s++;
281
- t.length === 0 && (this._overflow = null);
263
+ this._freeIndices = null, t.length === 0 && (this._overflow = null);
282
264
  }
283
265
  clear() {
284
- this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null);
266
+ this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null), this._freeIndices = null;
285
267
  }
286
268
  dispose() {
287
269
  this.clear();
288
270
  }
289
- }, K = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), lt = /* @__PURE__ */ Symbol("AtomEffect.Id"), Z = /* @__PURE__ */ Symbol("AtomEffect.Type"), U = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), X = {
271
+ }, W = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), lt = /* @__PURE__ */ Symbol("AtomEffect.Id"), K = /* @__PURE__ */ Symbol("AtomEffect.Type"), b = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), G = {
290
272
  enabled: !1,
291
- warnInfiniteLoop: st.WARN_INFINITE_LOOP,
273
+ warnInfiniteLoop: tt.WARN_INFINITE_LOOP,
292
274
  warn(t, s) {
293
275
  },
294
276
  attachDebugInfo(t, s, e) {
295
277
  },
296
- getDebugName: (t) => t?.[K],
297
- getDebugType: (t) => t?.[Z]
278
+ getDebugName: (t) => t?.[W],
279
+ getDebugType: (t) => t?.[K]
298
280
  }, _t = 1, ct = () => _t++;
299
- function T(t, s, e) {
300
- if (t instanceof A) return t;
301
- const i = t instanceof Error, n = i ? t.message : String(t), r = i ? t : void 0;
302
- return new s(`${i ? t.constructor.name : "Unexpected error"} (${e}): ${n}`, r);
281
+ function g(t, s, e) {
282
+ if (t instanceof T) return t;
283
+ const i = t instanceof Error, n = i ? t.message : String(t), o = i ? t : void 0;
284
+ return new s(`${i ? t.constructor.name : "Unexpected error"} (${e}): ${n}`, o);
303
285
  }
304
- var V = class {
286
+ var X = class {
305
287
  constructor() {
306
- this.flags = 0, this.version = 0, this._lastSeenEpoch = C.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = ct() & G;
288
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = p.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = ct() & st;
307
289
  }
308
290
  subscribe(t) {
309
291
  const s = typeof t == "function";
310
- if (!s && (!t || typeof t.execute != "function")) throw T(/* @__PURE__ */ new TypeError("Invalid subscriber"), A, l.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
292
+ if (!s && (!t || typeof t.execute != "function")) throw g(/* @__PURE__ */ new TypeError("Invalid subscriber"), T, h.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
311
293
  let e = this._slots;
312
294
  e || (e = new et(), this._slots = e);
313
295
  let i = !1;
314
- if (e.forEach((r) => {
315
- (s ? r.fn === t : r.sub === t) && (i = !0);
296
+ if (e.forEach((o) => {
297
+ (s ? o.fn === t : o.sub === t) && (i = !0);
316
298
  }), i)
317
299
  return () => {
318
300
  };
@@ -340,7 +322,7 @@ var V = class {
340
322
  try {
341
323
  i.notify(t, s);
342
324
  } catch (n) {
343
- console.error(T(n, A, l.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
325
+ console.error(g(n, T, h.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
344
326
  }
345
327
  });
346
328
  } finally {
@@ -357,20 +339,25 @@ var V = class {
357
339
  }
358
340
  return !t.hasComputeds && !t.isDirtyFast() ? !1 : this._deepDirtyCheck();
359
341
  }
360
- }, w = 0, Q = () => (w = w + 1 & 1073741823 || 1, w), z = (t) => t + 1 & G, Y = 0, F = !1, it = 0, nt = () => it;
361
- function J() {
362
- return F ? !1 : (F = !0, it = Q(), Y = 0, !0);
342
+ }, U = 0, k = () => (U = U + 1 & 1073741823 || 1, U), H = (t) => t + 1 & 1073741823 || 1, V = 0, F = !1, it = 0, nt = () => it;
343
+ function Z() {
344
+ return F ? !1 : (F = !0, it = k(), V = 0, !0);
363
345
  }
364
- var tt = () => {
346
+ var J = () => {
365
347
  F = !1;
366
- }, ft = () => F ? ++Y : 0, L = /* @__PURE__ */ (function(t) {
348
+ }, ft = () => {
349
+ if (!F) return 0;
350
+ const t = ++V;
351
+ if (t > I.MAX_EXECUTIONS_PER_FLUSH) throw new Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${I.MAX_EXECUTIONS_PER_FLUSH}`);
352
+ return t;
353
+ }, w = /* @__PURE__ */ (function(t) {
367
354
  return t[t.IDLE = 0] = "IDLE", t[t.BATCHING = 1] = "BATCHING", t[t.FLUSHING = 2] = "FLUSHING", t;
368
355
  })({}), at = class {
369
356
  constructor() {
370
- 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 = m.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
357
+ 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 = I.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
371
358
  }
372
359
  get phase() {
373
- return this._isProcessing || this._isFlushingSync ? L.FLUSHING : this._isBatching ? L.BATCHING : L.IDLE;
360
+ return this._isProcessing || this._isFlushingSync ? w.FLUSHING : this._isBatching ? w.BATCHING : w.IDLE;
374
361
  }
375
362
  get queueSize() {
376
363
  return this._size;
@@ -393,19 +380,19 @@ var tt = () => {
393
380
  _runLoop() {
394
381
  try {
395
382
  if (this._size === 0) return;
396
- const t = J();
397
- this._drainQueue(), t && tt();
383
+ const t = Z();
384
+ this._drainQueue(), t && J();
398
385
  } finally {
399
386
  this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
400
387
  }
401
388
  }
402
389
  _flushSync() {
403
390
  this._isFlushingSync = !0;
404
- const t = J();
391
+ const t = Z();
405
392
  try {
406
393
  this._mergeBatchQueue(), this._drainQueue();
407
394
  } finally {
408
- this._isFlushingSync = !1, t && tt();
395
+ this._isFlushingSync = !1, t && J();
409
396
  }
410
397
  }
411
398
  _mergeBatchQueue() {
@@ -413,8 +400,8 @@ var tt = () => {
413
400
  const t = ++this._epoch, s = this._batchQueue, e = this._queueBuffer[this._bufferIndex];
414
401
  let i = this._size;
415
402
  for (let n = 0; n < this._batchQueueSize; n++) {
416
- const r = s[n];
417
- r._nextEpoch !== t && (r._nextEpoch = t, e[i++] = r);
403
+ const o = s[n];
404
+ o._nextEpoch !== t && (o._nextEpoch = t, e[i++] = o);
418
405
  }
419
406
  this._size = i, this._batchQueueSize = 0, s.length = 0;
420
407
  }
@@ -441,7 +428,7 @@ var tt = () => {
441
428
  }
442
429
  _handleFlushOverflow() {
443
430
  const t = this._size + this._batchQueueSize;
444
- if (console.error(new R(l.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t))), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow) try {
431
+ if (console.error(new R(h.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t))), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow) try {
445
432
  this.onOverflow(t);
446
433
  } catch {
447
434
  }
@@ -453,10 +440,10 @@ var tt = () => {
453
440
  this._batchDepth !== 0 && --this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
454
441
  }
455
442
  setMaxFlushIterations(t) {
456
- if (t < m.MIN_FLUSH_ITERATIONS) throw new R(`Max flush iterations must be at least ${m.MIN_FLUSH_ITERATIONS}`);
443
+ if (t < I.MIN_FLUSH_ITERATIONS) throw new R(`Max flush iterations must be at least ${I.MIN_FLUSH_ITERATIONS}`);
457
444
  this._maxFlushIterations = t;
458
445
  }
459
- }, y = new at(), $ = /* @__PURE__ */ Symbol.for("atom-effect/atom"), rt = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ot = /* @__PURE__ */ Symbol.for("atom-effect/effect"), Et = /* @__PURE__ */ Symbol.for("atom-effect/writable"), _ = {
446
+ }, A = new at(), Q = /* @__PURE__ */ Symbol.for("atom-effect/atom"), rt = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ot = /* @__PURE__ */ Symbol.for("atom-effect/effect"), Et = /* @__PURE__ */ Symbol.for("atom-effect/writable"), _ = {
460
447
  current: null,
461
448
  run(t, s) {
462
449
  const e = this.current;
@@ -468,7 +455,7 @@ var tt = () => {
468
455
  }
469
456
  }
470
457
  };
471
- function vt(t) {
458
+ function Dt(t) {
472
459
  const s = _.current;
473
460
  if (s === null) return t();
474
461
  _.current = null;
@@ -478,9 +465,9 @@ function vt(t) {
478
465
  _.current = s;
479
466
  }
480
467
  }
481
- var dt = class extends V {
468
+ var dt = class extends X {
482
469
  constructor(t, s) {
483
- super(), this[$] = !0, this[Et] = !0, this._value = t, this._pendingOldValue = void 0, s && (this.flags |= d.SYNC), X.attachDebugInfo(this, "atom", this.id);
470
+ super(), this[Q] = !0, this[Et] = !0, this._value = t, this._pendingOldValue = void 0, s && (this.flags |= a.SYNC), G.attachDebugInfo(this, "atom", this.id);
484
471
  }
485
472
  get value() {
486
473
  const t = _.current;
@@ -489,31 +476,31 @@ var dt = class extends V {
489
476
  set value(t) {
490
477
  const s = this._value;
491
478
  if (Object.is(s, t)) return;
492
- this._value = t, this.version = z(this.version);
479
+ this._value = t, this.version = H(this.version);
493
480
  const e = this._slots, i = this.flags;
494
- if (e == null || e.size === 0 || i & d.NOTIFICATION_SCHEDULED) return;
481
+ if (e == null || e.size === 0 || i & a.NOTIFICATION_SCHEDULED) return;
495
482
  this._pendingOldValue = s;
496
- const n = i | d.NOTIFICATION_SCHEDULED;
497
- if (this.flags = n, (n & d.SYNC) !== 0 && !y.isBatching) {
483
+ const n = i | a.NOTIFICATION_SCHEDULED;
484
+ if (this.flags = n, (n & a.SYNC) !== 0 && !A.isBatching) {
498
485
  this._flushNotifications();
499
486
  return;
500
487
  }
501
- y.schedule(this);
488
+ A.schedule(this);
502
489
  }
503
490
  execute() {
504
491
  this._flushNotifications();
505
492
  }
506
493
  _flushNotifications() {
507
494
  const t = this.flags;
508
- if (!(t & d.NOTIFICATION_SCHEDULED) || t & d.DISPOSED) return;
495
+ if (!(t & a.NOTIFICATION_SCHEDULED) || t & a.DISPOSED) return;
509
496
  const s = this._pendingOldValue;
510
- this._pendingOldValue = void 0, this.flags &= ~d.NOTIFICATION_SCHEDULED, this._notifySubscribers(this._value, s);
497
+ this._pendingOldValue = void 0, this.flags &= ~a.NOTIFICATION_SCHEDULED, this._notifySubscribers(this._value, s);
511
498
  }
512
499
  peek() {
513
500
  return this._value;
514
501
  }
515
502
  dispose() {
516
- this.flags & d.DISPOSED || (this._slots?.clear(), this.flags |= d.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
503
+ this.flags & a.DISPOSED || (this._slots?.clear(), this.flags |= a.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
517
504
  }
518
505
  _deepDirtyCheck() {
519
506
  return !1;
@@ -522,10 +509,10 @@ var dt = class extends V {
522
509
  this.dispose();
523
510
  }
524
511
  };
525
- function Dt(t, s = {}) {
512
+ function vt(t, s = {}) {
526
513
  return new dt(t, s.sync ?? !1);
527
514
  }
528
- var k = class extends et {
515
+ var z = class extends et {
529
516
  constructor() {
530
517
  super(), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0, this._map = null, this.hasComputeds = !1, this._depsHash = 0;
531
518
  }
@@ -543,44 +530,44 @@ var k = class extends et {
543
530
  if (this._map !== null || i > this._SCAN_THRESHOLD) return this._claimViaMap(t, s);
544
531
  if (s < 4) switch (s) {
545
532
  case 0: {
546
- const o = this._s0;
547
- if (o && o.node === t && o.unsub)
548
- return o.version = t.version, !0;
533
+ const r = this._s0;
534
+ if (r && r.node === t && r.unsub)
535
+ return r.version = t.version, !0;
549
536
  }
550
537
  case 1:
551
538
  if (e > 1) {
552
- const o = this._s1;
553
- if (o && o.node === t && o.unsub)
554
- return o.version = t.version, s !== 1 && (this._s1 = this._s0, this._s0 = o), !0;
539
+ const r = this._s1;
540
+ if (r && r.node === t && r.unsub)
541
+ return r.version = t.version, s !== 1 && (this._s1 = this._s0, this._s0 = r), !0;
555
542
  }
556
543
  case 2:
557
544
  if (e > 2) {
558
- const o = this._s2;
559
- if (o && o.node === t && o.unsub) {
560
- if (o.version = t.version, s !== 2) {
561
- const h = s === 0 ? this._s0 : this._s1;
562
- s === 0 ? this._s0 = o : this._s1 = o, this._s2 = h;
545
+ const r = this._s2;
546
+ if (r && r.node === t && r.unsub) {
547
+ if (r.version = t.version, s !== 2) {
548
+ const u = s === 0 ? this._s0 : this._s1;
549
+ s === 0 ? this._s0 = r : this._s1 = r, this._s2 = u;
563
550
  }
564
551
  return !0;
565
552
  }
566
553
  }
567
554
  case 3:
568
555
  if (e > 3) {
569
- const o = this._s3;
570
- if (o && o.node === t && o.unsub) {
571
- if (o.version = t.version, s !== 3) {
572
- let h;
573
- s === 0 ? (h = this._s0, this._s0 = o) : s === 1 ? (h = this._s1, this._s1 = o) : (h = this._s2, this._s2 = o), this._s3 = h;
556
+ const r = this._s3;
557
+ if (r && r.node === t && r.unsub) {
558
+ if (r.version = t.version, s !== 3) {
559
+ let u;
560
+ s === 0 ? (u = this._s0, this._s0 = r) : s === 1 ? (u = this._s1, this._s1 = r) : (u = this._s2, this._s2 = r), this._s3 = u;
574
561
  }
575
562
  return !0;
576
563
  }
577
564
  }
578
565
  }
579
- const n = s > 4 ? s : 4, r = this._overflow;
580
- if (r) for (let o = n - 4, h = r.length; o < h; o++) {
581
- const u = r[o];
582
- if (u && u.node === t && u.unsub)
583
- return u.version = t.version, this._swapGeneral(o + 4, s, u), !0;
566
+ const n = s > 4 ? s : 4, o = this._overflow;
567
+ if (o) for (let r = n - 4, u = o.length; r < u; r++) {
568
+ const l = o[r];
569
+ if (l && l.node === t && l.unsub)
570
+ return l.version = t.version, this._swapGeneral(r + 4, s, l), !0;
584
571
  }
585
572
  return !1;
586
573
  }
@@ -589,12 +576,12 @@ var k = class extends et {
589
576
  this._map = /* @__PURE__ */ new Map();
590
577
  const n = this._count;
591
578
  s < 4 && (s <= 0 && this._s0?.unsub && this._map.set(this._s0.node, 0), s <= 1 && this._s1?.unsub && this._map.set(this._s1.node, 1), s <= 2 && this._s2?.unsub && this._map.set(this._s2.node, 2), s <= 3 && this._s3?.unsub && this._map.set(this._s3.node, 3));
592
- const r = this._overflow;
593
- if (r && n > 4) {
594
- const o = s > 4 ? s : 4;
595
- for (let h = o - 4, u = r.length; h < u; h++) {
596
- const a = r[h];
597
- a?.unsub && this._map.set(a.node, h + 4);
579
+ const o = this._overflow;
580
+ if (o && n > 4) {
581
+ const r = s > 4 ? s : 4;
582
+ for (let u = r - 4, l = o.length; u < l; u++) {
583
+ const O = o[u];
584
+ O?.unsub && this._map.set(O.node, u + 4);
598
585
  }
599
586
  }
600
587
  }
@@ -608,10 +595,6 @@ var k = class extends et {
608
595
  }
609
596
  return !0;
610
597
  }
611
- _swapInline(t, s, e) {
612
- const i = this.getAt(s);
613
- this.setAt(s, e), this.setAt(t, i);
614
- }
615
598
  _swapGeneral(t, s, e) {
616
599
  if (t === s) return;
617
600
  const i = this.getAt(s);
@@ -628,7 +611,7 @@ var k = class extends et {
628
611
  const e = this._count;
629
612
  if (t < e) {
630
613
  const i = this.getAt(t);
631
- i != null && (this.add(i), this._map !== null && i.unsub && this._map.set(i.node, this._count - 1));
614
+ i != null && (this._addToOverflow(i), this._map !== null && i.unsub && this._map.set(i.node, this._count - 1));
632
615
  }
633
616
  if (t === 0) this._s0 = s;
634
617
  else if (t === 1) this._s1 = s;
@@ -644,70 +627,64 @@ var k = class extends et {
644
627
  t >= this._count || (super.truncateFrom(t), this._map !== null && (this._map.clear(), this._map = null));
645
628
  }
646
629
  seal() {
647
- const t = this._count, s = q.VERSION_BITS;
630
+ const t = this._count;
631
+ if (t === 0) {
632
+ this._depsHash = 0;
633
+ return;
634
+ }
635
+ const s = j.VERSION_BITS;
648
636
  let e = 0;
649
- switch (t) {
650
- case 0:
651
- this._depsHash = 0;
652
- return;
653
- case 1: {
654
- const i = this._s0;
655
- e = e + (i.version << s) + i.node.id | 0;
656
- break;
657
- }
658
- case 2: {
659
- const i = this._s0, n = this._s1;
660
- e = e + (i.version << s) + i.node.id | 0, e = e + (n.version << s) + n.node.id | 0;
661
- break;
662
- }
663
- case 3: {
664
- const i = this._s0, n = this._s1, r = this._s2;
665
- e = e + (i.version << s) + i.node.id | 0, e = e + (n.version << s) + n.node.id | 0, e = e + (r.version << s) + r.node.id | 0;
666
- break;
667
- }
668
- default: {
669
- const i = this._s0, n = this._s1, r = this._s2, o = this._s3;
670
- if (e = e + (i.version << s) + i.node.id | 0, e = e + (n.version << s) + n.node.id | 0, e = e + (r.version << s) + r.node.id | 0, e = e + (o.version << s) + o.node.id | 0, t > 4) {
671
- const h = this._overflow;
672
- for (let u = 0, a = h.length; u < a; u++) {
673
- const c = h[u];
674
- e = e + (c.version << s) + c.node.id | 0;
675
- }
676
- }
637
+ if (t >= 1) {
638
+ const i = this._s0;
639
+ e = e + (i.version << s) + i.node.id | 0;
640
+ }
641
+ if (t >= 2) {
642
+ const i = this._s1;
643
+ e = e + (i.version << s) + i.node.id | 0;
644
+ }
645
+ if (t >= 3) {
646
+ const i = this._s2;
647
+ e = e + (i.version << s) + i.node.id | 0;
648
+ }
649
+ if (t >= 4) {
650
+ const i = this._s3;
651
+ e = e + (i.version << s) + i.node.id | 0;
652
+ }
653
+ if (t > 4) {
654
+ const i = this._overflow;
655
+ for (let n = 0, o = i.length; n < o; n++) {
656
+ const r = i[n];
657
+ e = e + (r.version << s) + r.node.id | 0;
677
658
  }
678
659
  }
679
660
  this._depsHash = e;
680
661
  }
681
662
  isDirtyFast() {
682
- const t = this._count, s = q.VERSION_BITS;
663
+ const t = this._count;
664
+ if (t === 0) return !1;
665
+ const s = j.VERSION_BITS;
683
666
  let e = 0;
684
- switch (t) {
685
- case 0:
686
- return !1;
687
- case 1: {
688
- const i = this._s0.node;
689
- e = e + (i.version << s) + i.id | 0;
690
- break;
691
- }
692
- case 2: {
693
- const i = this._s0.node, n = this._s1.node;
694
- e = e + (i.version << s) + i.id | 0, e = e + (n.version << s) + n.id | 0;
695
- break;
696
- }
697
- case 3: {
698
- const i = this._s0.node, n = this._s1.node, r = this._s2.node;
699
- e = e + (i.version << s) + i.id | 0, e = e + (n.version << s) + n.id | 0, e = e + (r.version << s) + r.id | 0;
700
- break;
701
- }
702
- default: {
703
- const i = this._s0.node, n = this._s1.node, r = this._s2.node, o = this._s3.node;
704
- if (e = e + (i.version << s) + i.id | 0, e = e + (n.version << s) + n.id | 0, e = e + (r.version << s) + r.id | 0, e = e + (o.version << s) + o.id | 0, t > 4) {
705
- const h = this._overflow;
706
- for (let u = 0, a = h.length; u < a; u++) {
707
- const c = h[u].node;
708
- e = e + (c.version << s) + c.id | 0;
709
- }
710
- }
667
+ if (t >= 1) {
668
+ const i = this._s0.node;
669
+ e = e + (i.version << s) + i.id | 0;
670
+ }
671
+ if (t >= 2) {
672
+ const i = this._s1.node;
673
+ e = e + (i.version << s) + i.id | 0;
674
+ }
675
+ if (t >= 3) {
676
+ const i = this._s2.node;
677
+ e = e + (i.version << s) + i.id | 0;
678
+ }
679
+ if (t >= 4) {
680
+ const i = this._s3.node;
681
+ e = e + (i.version << s) + i.id | 0;
682
+ }
683
+ if (t > 4) {
684
+ const i = this._overflow;
685
+ for (let n = 0, o = i.length; n < o; n++) {
686
+ const r = i[n].node;
687
+ e = e + (r.version << s) + r.id | 0;
711
688
  }
712
689
  }
713
690
  return e !== this._depsHash;
@@ -722,21 +699,21 @@ var k = class extends et {
722
699
  }
723
700
  };
724
701
  function St(t) {
725
- return t !== null && typeof t == "object" && $ in t;
702
+ return t !== null && typeof t == "object" && Q in t;
726
703
  }
727
704
  function gt(t) {
728
705
  return t !== null && typeof t == "object" && rt in t;
729
706
  }
730
- function mt(t) {
707
+ function Tt(t) {
731
708
  return t !== null && typeof t == "object" && ot in t;
732
709
  }
733
710
  function ht(t) {
734
711
  return t !== null && typeof t == "object" && typeof t.then == "function";
735
712
  }
736
- var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, RECOMPUTING: O, DISPOSED: M, IS_COMPUTED: P, FORCE_COMPUTE: B } = x, pt = class extends V {
713
+ var { IDLE: d, DIRTY: f, PENDING: S, RESOLVED: E, REJECTED: C, HAS_ERROR: m, RECOMPUTING: N, DISPOSED: L, IS_COMPUTED: M, FORCE_COMPUTE: P } = B, pt = class extends X {
737
714
  constructor(t, s = {}) {
738
- if (typeof t != "function") throw new S(l.COMPUTED_MUST_BE_FUNCTION);
739
- if (super(), this[$] = !0, this[rt] = !0, this._error = null, this._promiseId = 0, this._deps = new k(), this._asyncRetryCount = 0, this._lastDriftEpoch = C.UNINITIALIZED, this._trackEpoch = C.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = P | E | I, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : U, this._onError = s.onError ?? null, this._maxAsyncRetries = (s.maxAsyncRetries ?? j.MAX_ASYNC_RETRIES) & G, X.attachDebugInfo(this, "computed", this.id), s.lazy === !1) try {
715
+ if (typeof t != "function") throw new v(h.COMPUTED_MUST_BE_FUNCTION);
716
+ if (super(), this[Q] = !0, this[rt] = !0, this._error = null, this._promiseId = 0, this._deps = new z(), this._asyncRetryCount = 0, this._lastDriftEpoch = p.UNINITIALIZED, this._trackEpoch = p.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = M | f | d, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : b, this._onError = s.onError ?? null, this._maxAsyncRetries = (s.maxAsyncRetries ?? $.MAX_ASYNC_RETRIES) & st, G.attachDebugInfo(this, "computed", this.id), s.lazy === !1) try {
740
717
  this._recompute();
741
718
  } catch {
742
719
  }
@@ -747,20 +724,20 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
747
724
  get value() {
748
725
  this._track();
749
726
  const t = this.flags;
750
- if ((t & (p | E | I)) === p) return this._value;
751
- if (t & M) throw new S(l.COMPUTED_DISPOSED);
752
- if (t & O) {
753
- if (this._defaultValue !== U) return this._defaultValue;
754
- throw new S(l.COMPUTED_CIRCULAR_DEPENDENCY);
727
+ if ((t & (E | f | d)) === E) return this._value;
728
+ if (t & L) throw new v(h.COMPUTED_DISPOSED);
729
+ if (t & N) {
730
+ if (this._defaultValue !== b) return this._defaultValue;
731
+ throw new v(h.COMPUTED_CIRCULAR_DEPENDENCY);
755
732
  }
756
- if (t & (E | I) && ((t & I) === 0 && (t & B) === 0 && this._deps.size > 0 && !this._isDirty() ? this.flags &= ~E : this._recompute(), this.flags & p))
733
+ if (t & (f | d) && ((t & d) === 0 && (t & P) === 0 && this._deps.size > 0 && !this._isDirty() ? this.flags &= ~f : this._recompute(), this.flags & E))
757
734
  return this._value;
758
- const s = this._defaultValue, e = s !== U;
759
- if (this.flags & g) {
735
+ const s = this._defaultValue, e = s !== b;
736
+ if (this.flags & S) {
760
737
  if (e) return s;
761
- throw new S(l.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
738
+ throw new v(h.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
762
739
  }
763
- if (this.flags & v) {
740
+ if (this.flags & C) {
764
741
  if (e) return s;
765
742
  throw this._error;
766
743
  }
@@ -772,16 +749,16 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
772
749
  get state() {
773
750
  this._track();
774
751
  const t = this.flags;
775
- return t & p ? b.RESOLVED : t & g ? b.PENDING : t & v ? b.REJECTED : b.IDLE;
752
+ return t & E ? y.RESOLVED : t & S ? y.PENDING : t & C ? y.REJECTED : y.IDLE;
776
753
  }
777
754
  get hasError() {
778
- if (this._track(), this.flags & (v | N)) return !0;
755
+ if (this._track(), this.flags & (C | m)) return !0;
779
756
  const t = this._deps;
780
757
  if (!t.hasComputeds) return !1;
781
758
  const s = t.size;
782
759
  for (let e = 0; e < s; e++) {
783
760
  const i = t.getAt(e);
784
- if (i != null && i.node.flags & N) return !0;
761
+ if (i != null && i.node.flags & m) return !0;
785
762
  }
786
763
  return !1;
787
764
  }
@@ -793,37 +770,37 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
793
770
  const t = [];
794
771
  this._error && t.push(this._error);
795
772
  const s = this._deps;
796
- if (!s.hasComputeds) return t.length === 0 ? W : Object.freeze(t);
773
+ if (!s.hasComputeds) return t.length === 0 ? q : Object.freeze(t);
797
774
  const e = s.size;
798
775
  for (let i = 0; i < e; i++) {
799
776
  const n = s.getAt(i);
800
777
  if (n == null) continue;
801
- const r = n.node;
802
- r.flags & N && this._collectErrorsFromDep(r, t);
778
+ const o = n.node;
779
+ o.flags & m && this._collectErrorsFromDep(o, t);
803
780
  }
804
- return t.length === 0 ? W : Object.freeze(t);
781
+ return t.length === 0 ? q : Object.freeze(t);
805
782
  }
806
783
  _collectErrorsFromDep(t, s) {
807
784
  const e = t.errors, i = e.length;
808
785
  for (let n = 0; n < i; n++) {
809
- const r = e[n];
810
- r != null && !s.includes(r) && s.push(r);
786
+ const o = e[n];
787
+ o != null && !s.includes(o) && s.push(o);
811
788
  }
812
789
  }
813
790
  get lastError() {
814
791
  return this._track(), this._error;
815
792
  }
816
793
  get isPending() {
817
- return this._track(), (this.flags & g) !== 0;
794
+ return this._track(), (this.flags & S) !== 0;
818
795
  }
819
796
  get isResolved() {
820
- return this._track(), (this.flags & p) !== 0;
797
+ return this._track(), (this.flags & E) !== 0;
821
798
  }
822
799
  invalidate() {
823
- this.flags |= B, this._markDirty();
800
+ this.flags |= P, this._markDirty();
824
801
  }
825
802
  dispose() {
826
- this.flags & M || (this._deps.disposeAll(), this._slots?.clear(), this.flags = M | E | I, this._error = null, this._value = void 0, this._hotIndex = -1);
803
+ this.flags & L || (this._deps.disposeAll(), this._slots?.clear(), this.flags = L | f | d, this._error = null, this._value = void 0, this._hotIndex = -1);
827
804
  }
828
805
  [Symbol.dispose]() {
829
806
  this.dispose();
@@ -834,14 +811,14 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
834
811
  const s = this._trackCount, e = this._deps.getAt(s);
835
812
  if (e != null && e.node === t) e.version = t.version;
836
813
  else if (!this._deps.claimExisting(t, s)) {
837
- const i = new H(t, t.version, t.subscribe(this));
814
+ const i = new x(t, t.version, t.subscribe(this));
838
815
  this._deps.insertNew(s, i);
839
816
  }
840
- t.flags & P && (this._deps.hasComputeds = !0), this._trackCount = s + 1;
817
+ t.flags & M && (this._deps.hasComputeds = !0), this._trackCount = s + 1;
841
818
  }
842
819
  _recompute() {
843
- if (this.flags & O) return;
844
- this.flags = (this.flags | O) & ~B, this._trackEpoch = Q(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
820
+ if (this.flags & N) return;
821
+ this.flags = (this.flags | N) & ~P, this._trackEpoch = k(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
845
822
  let t = !1;
846
823
  try {
847
824
  const s = _.run(this, this._fn);
@@ -851,42 +828,42 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
851
828
  this._deps.truncateFrom(this._trackCount);
852
829
  } catch {
853
830
  }
854
- this._handleError(s, l.COMPUTED_COMPUTATION_FAILED, !0);
831
+ this._handleError(s, h.COMPUTED_COMPUTATION_FAILED, !0);
855
832
  } finally {
856
- this._trackEpoch = C.UNINITIALIZED, this._trackCount = 0, this.flags &= ~O;
833
+ this._trackEpoch = p.UNINITIALIZED, this._trackCount = 0, this.flags &= ~N;
857
834
  }
858
835
  }
859
836
  _handleAsyncComputation(t) {
860
- this.flags = (this.flags | g) & ~(I | E | p | v), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % j.MAX_PROMISE_ID;
837
+ this.flags = (this.flags | S) & ~(d | f | E | C), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % $.MAX_PROMISE_ID;
861
838
  const s = this._promiseId;
862
839
  t.then((e) => {
863
840
  if (s === this._promiseId) {
864
841
  if (this._isDirty()) {
865
842
  const i = nt();
866
- return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new S(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), l.COMPUTED_ASYNC_COMPUTATION_FAILED);
843
+ return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new v(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), h.COMPUTED_ASYNC_COMPUTATION_FAILED);
867
844
  }
868
845
  this._finalizeResolution(e), this._notifySubscribers(e, void 0);
869
846
  }
870
- }, (e) => s === this._promiseId && this._handleError(e, l.COMPUTED_ASYNC_COMPUTATION_FAILED));
847
+ }, (e) => s === this._promiseId && this._handleError(e, h.COMPUTED_ASYNC_COMPUTATION_FAILED));
871
848
  }
872
849
  _handleError(t, s, e = !1) {
873
- const i = T(t, S, s);
874
- if (!e && !(this.flags & v) && (this.version = z(this.version)), this._error = i, this.flags = this.flags & ~(I | E | g | p) | v | N, this._onError) try {
850
+ const i = g(t, v, s);
851
+ if (!e && !(this.flags & C) && (this.version = H(this.version)), this._error = i, this.flags = this.flags & ~(d | f | S | E) | C | m, this._onError) try {
875
852
  this._onError(i);
876
853
  } catch (n) {
877
- console.error(l.CALLBACK_ERROR_IN_ERROR_HANDLER, n);
854
+ console.error(h.CALLBACK_ERROR_IN_ERROR_HANDLER, n);
878
855
  }
879
856
  if (e) throw i;
880
857
  this._notifySubscribers(void 0, void 0);
881
858
  }
882
859
  _finalizeResolution(t) {
883
- (!(this.flags & p) || !this._equal(this._value, t)) && (this.version = z(this.version)), this._value = t, this._error = null, this.flags = (this.flags | p) & ~(I | E | g | v | N);
860
+ (!(this.flags & E) || !this._equal(this._value, t)) && (this.version = H(this.version)), this._value = t, this._error = null, this.flags = (this.flags | E) & ~(d | f | S | C | m);
884
861
  }
885
862
  execute() {
886
863
  this._markDirty();
887
864
  }
888
865
  _markDirty() {
889
- this.flags & (O | E) || (this.flags |= E, this._notifySubscribers(void 0, void 0));
866
+ this.flags & (N | f) || (this.flags |= f, this._notifySubscribers(void 0, void 0));
890
867
  }
891
868
  _isDirty() {
892
869
  const t = this._deps;
@@ -900,12 +877,12 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
900
877
  for (let i = 0; i < e; i++) {
901
878
  const n = t.getAt(i);
902
879
  if (n == null) continue;
903
- const r = n.node;
904
- if (r.flags & P) try {
905
- r.value;
880
+ const o = n.node;
881
+ if (o.flags & M) try {
882
+ o.value;
906
883
  } catch {
907
884
  }
908
- if (r.version !== n.version)
885
+ if (o.version !== n.version)
909
886
  return this._hotIndex = i, !0;
910
887
  }
911
888
  return this._hotIndex = -1, !1;
@@ -914,52 +891,52 @@ var { IDLE: I, DIRTY: E, PENDING: g, RESOLVED: p, REJECTED: v, HAS_ERROR: N, REC
914
891
  }
915
892
  }
916
893
  };
917
- function Tt(t, s = {}) {
894
+ function mt(t, s = {}) {
918
895
  return new pt(t, s);
919
896
  }
920
- var It = class extends V {
897
+ var It = class extends X {
921
898
  constructor(t, s = {}) {
922
- super(), this[ot] = !0, this._cleanup = null, this._deps = new k(), this._currentEpoch = C.UNINITIALIZED, this._lastFlushEpoch = C.UNINITIALIZED, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? m.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? m.MAX_EXECUTIONS_PER_EFFECT, this._cleanup = null, this._deps = new k(), this._currentEpoch = C.UNINITIALIZED, this._lastFlushEpoch = C.UNINITIALIZED, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => y.schedule(this), X.attachDebugInfo(this, "effect", this.id);
899
+ super(), this[ot] = !0, this._cleanup = null, this._deps = new z(), this._currentEpoch = p.UNINITIALIZED, this._lastFlushEpoch = p.UNINITIALIZED, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? I.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? I.MAX_EXECUTIONS_PER_EFFECT, this._cleanup = null, this._deps = new z(), this._currentEpoch = p.UNINITIALIZED, this._lastFlushEpoch = p.UNINITIALIZED, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => A.schedule(this), G.attachDebugInfo(this, "effect", this.id);
923
900
  }
924
901
  run() {
925
- if (this.flags & f.DISPOSED) throw new D(l.EFFECT_DISPOSED);
902
+ if (this.flags & c.DISPOSED) throw new D(h.EFFECT_DISPOSED);
926
903
  this.execute(!0);
927
904
  }
928
905
  dispose() {
929
- this.flags & f.DISPOSED || (this.flags |= f.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
906
+ this.flags & c.DISPOSED || (this.flags |= c.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
930
907
  }
931
908
  [Symbol.dispose]() {
932
909
  this.dispose();
933
910
  }
934
911
  addDependency(t) {
935
- if (!(this.flags & f.EXECUTING)) return;
912
+ if (!(this.flags & c.EXECUTING)) return;
936
913
  const s = this._currentEpoch;
937
914
  if (t._lastSeenEpoch === s) return;
938
915
  t._lastSeenEpoch = s;
939
916
  const e = this._trackCount, i = this._deps;
940
917
  let n;
941
- e === 0 ? n = i._s0 : e === 1 ? n = i._s1 : e === 2 ? n = i._s2 : e === 3 ? n = i._s3 : n = i.getAt(e), n != null && n.node === t ? n.version = t.version : i.claimExisting(t, e) || this._insertNewDependency(t, e), t.flags & x.IS_COMPUTED && (i.hasComputeds = !0), this._trackCount = e + 1;
918
+ e === 0 ? n = i._s0 : e === 1 ? n = i._s1 : e === 2 ? n = i._s2 : e === 3 ? n = i._s3 : n = i.getAt(e), n != null && n.node === t ? n.version = t.version : i.claimExisting(t, e) || this._insertNewDependency(t, e), t.flags & B.IS_COMPUTED && (i.hasComputeds = !0), this._trackCount = e + 1;
942
919
  }
943
920
  _insertNewDependency(t, s) {
944
921
  let e;
945
922
  try {
946
923
  const i = t.subscribe(this._notifyCallback);
947
- e = new H(t, t.version, i);
924
+ e = new x(t, t.version, i);
948
925
  } catch (i) {
949
- const n = T(i, D, l.EFFECT_EXECUTION_FAILED);
926
+ const n = g(i, D, h.EFFECT_EXECUTION_FAILED);
950
927
  if (console.error(n), this._onError) try {
951
928
  this._onError(n);
952
929
  } catch {
953
930
  }
954
- e = new H(t, t.version, void 0);
931
+ e = new x(t, t.version, void 0);
955
932
  }
956
933
  this._deps.insertNew(s, e);
957
934
  }
958
935
  execute(t = !1) {
959
- if (this.flags & (f.DISPOSED | f.EXECUTING)) return;
936
+ if (this.flags & (c.DISPOSED | c.EXECUTING)) return;
960
937
  const s = this._deps;
961
938
  if (!t && s.size > 0 && !this._isDirty()) return;
962
- this._checkInfiniteLoops(), this.flags |= f.EXECUTING, this._execCleanup(), this._currentEpoch = Q(), this._trackCount = 0, s.prepareTracking(), this._hotIndex = -1;
939
+ this._checkInfiniteLoops(), this.flags |= c.EXECUTING, this._execCleanup(), this._currentEpoch = k(), this._trackCount = 0, s.prepareTracking(), this._hotIndex = -1;
963
940
  let e = !1;
964
941
  try {
965
942
  const i = _.run(this, this._fn);
@@ -971,7 +948,7 @@ var It = class extends V {
971
948
  }
972
949
  this._handleExecutionError(i), this._cleanup = null;
973
950
  } finally {
974
- this.flags &= ~f.EXECUTING;
951
+ this.flags &= ~c.EXECUTING;
975
952
  }
976
953
  }
977
954
  _isDirty() {
@@ -981,11 +958,11 @@ var It = class extends V {
981
958
  _handleAsyncResult(t) {
982
959
  const s = ++this._execId;
983
960
  t.then((e) => {
984
- if (s !== this._execId || this.flags & f.DISPOSED) {
961
+ if (s !== this._execId || this.flags & c.DISPOSED) {
985
962
  if (typeof e == "function") try {
986
963
  e();
987
964
  } catch (i) {
988
- this._handleExecutionError(i, l.EFFECT_CLEANUP_FAILED);
965
+ this._handleExecutionError(i, h.EFFECT_CLEANUP_FAILED);
989
966
  }
990
967
  return;
991
968
  }
@@ -1001,8 +978,8 @@ var It = class extends V {
1001
978
  for (let i = 0; i < e; i++) {
1002
979
  const n = s.getAt(i);
1003
980
  if (n == null) continue;
1004
- const r = n.node;
1005
- if (r.flags & x.IS_COMPUTED && this._tryPullComputed(r), r.version !== n.version)
981
+ const o = n.node;
982
+ if (o.flags & B.IS_COMPUTED && this._tryPullComputed(o), o.version !== n.version)
1006
983
  return this._hotIndex = i, !0;
1007
984
  }
1008
985
  return !1;
@@ -1021,81 +998,81 @@ var It = class extends V {
1021
998
  try {
1022
999
  this._cleanup();
1023
1000
  } catch (t) {
1024
- this._handleExecutionError(t, l.EFFECT_CLEANUP_FAILED);
1001
+ this._handleExecutionError(t, h.EFFECT_CLEANUP_FAILED);
1025
1002
  }
1026
1003
  this._cleanup = null;
1027
1004
  }
1028
1005
  }
1029
1006
  _checkInfiniteLoops() {
1030
1007
  const t = nt();
1031
- this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ft() > m.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
1008
+ this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ft() > I.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
1032
1009
  }
1033
1010
  _checkFrequencyLimit() {
1034
1011
  if (!Number.isFinite(this._maxExecutions)) return;
1035
1012
  const t = Date.now();
1036
- if (t - this._windowStart >= st.EFFECT_FREQUENCY_WINDOW) {
1013
+ if (t - this._windowStart >= tt.EFFECT_FREQUENCY_WINDOW) {
1037
1014
  this._windowStart = t, this._windowCount = 1;
1038
1015
  return;
1039
1016
  }
1040
1017
  if (++this._windowCount > this._maxExecutions) {
1041
- const s = new D(l.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
1018
+ const s = new D(h.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
1042
1019
  throw this.dispose(), this._handleExecutionError(s), s;
1043
1020
  }
1044
1021
  }
1045
1022
  get isDisposed() {
1046
- return (this.flags & f.DISPOSED) !== 0;
1023
+ return (this.flags & c.DISPOSED) !== 0;
1047
1024
  }
1048
1025
  get executionCount() {
1049
1026
  return this._executionCount;
1050
1027
  }
1051
1028
  get isExecuting() {
1052
- return (this.flags & f.EXECUTING) !== 0;
1029
+ return (this.flags & c.EXECUTING) !== 0;
1053
1030
  }
1054
1031
  _throwInfiniteLoopError(t) {
1055
- const s = new D(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Y}`);
1032
+ const s = new D(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${V}`);
1056
1033
  throw this.dispose(), console.error(s), s;
1057
1034
  }
1058
- _handleExecutionError(t, s = l.EFFECT_EXECUTION_FAILED) {
1059
- const e = T(t, D, s);
1035
+ _handleExecutionError(t, s = h.EFFECT_EXECUTION_FAILED) {
1036
+ const e = g(t, D, s);
1060
1037
  if (console.error(e), this._onError) try {
1061
1038
  this._onError(e);
1062
1039
  } catch (i) {
1063
- console.error(T(i, D, l.CALLBACK_ERROR_IN_ERROR_HANDLER));
1040
+ console.error(g(i, D, h.CALLBACK_ERROR_IN_ERROR_HANDLER));
1064
1041
  }
1065
1042
  }
1066
1043
  };
1067
- function At(t, s = {}) {
1068
- if (typeof t != "function") throw new D(l.EFFECT_MUST_BE_FUNCTION);
1044
+ function Nt(t, s = {}) {
1045
+ if (typeof t != "function") throw new D(h.EFFECT_MUST_BE_FUNCTION);
1069
1046
  const e = new It(t, s);
1070
1047
  return e.execute(), e;
1071
1048
  }
1072
- function Nt(t) {
1073
- if (typeof t != "function") throw new TypeError(l.BATCH_CALLBACK_MUST_BE_FUNCTION);
1074
- y.startBatch();
1049
+ function At(t) {
1050
+ if (typeof t != "function") throw new TypeError(h.BATCH_CALLBACK_MUST_BE_FUNCTION);
1051
+ A.startBatch();
1075
1052
  try {
1076
1053
  return t();
1077
1054
  } finally {
1078
- y.endBatch();
1055
+ A.endBatch();
1079
1056
  }
1080
1057
  }
1081
1058
  export {
1082
- b as AsyncState,
1083
- A as AtomError,
1084
- S as ComputedError,
1085
- st as DEBUG_CONFIG,
1086
- X as DEBUG_RUNTIME,
1059
+ y as AsyncState,
1060
+ T as AtomError,
1061
+ v as ComputedError,
1062
+ tt as DEBUG_CONFIG,
1063
+ G as DEBUG_RUNTIME,
1087
1064
  D as EffectError,
1088
- m as SCHEDULER_CONFIG,
1065
+ I as SCHEDULER_CONFIG,
1089
1066
  R as SchedulerError,
1090
- Dt as atom,
1091
- Nt as batch,
1092
- Tt as computed,
1093
- At as effect,
1067
+ vt as atom,
1068
+ At as batch,
1069
+ mt as computed,
1070
+ Nt as effect,
1094
1071
  St as isAtom,
1095
1072
  gt as isComputed,
1096
- mt as isEffect,
1097
- y as scheduler,
1098
- vt as untracked
1073
+ Tt as isEffect,
1074
+ A as scheduler,
1075
+ Dt as untracked
1099
1076
  };
1100
1077
 
1101
1078
  //# sourceMappingURL=index.mjs.map