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