@solidjs/signals 0.4.4 → 0.4.6

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/node.cjs CHANGED
@@ -41,7 +41,7 @@ function incrementClock() {
41
41
  clock++;
42
42
  }
43
43
  var ActiveTransition = null;
44
- var unobserved = [];
44
+ var Unobserved = [];
45
45
  var scheduled = false;
46
46
  function schedule() {
47
47
  if (scheduled)
@@ -52,12 +52,12 @@ function schedule() {
52
52
  }
53
53
  function notifyUnobserved() {
54
54
  var _a, _b;
55
- for (let i = 0; i < unobserved.length; i++) {
56
- const source = unobserved[i];
57
- if (!source.d || !source.d.length)
58
- (_b = (_a = unobserved[i]).da) == null ? void 0 : _b.call(_a);
55
+ for (let i = 0; i < Unobserved.length; i++) {
56
+ const source = Unobserved[i];
57
+ if (!source.b || !source.b.length)
58
+ (_b = (_a = Unobserved[i]).da) == null ? void 0 : _b.call(_a);
59
59
  }
60
- unobserved = [];
60
+ Unobserved = [];
61
61
  }
62
62
  var pureQueue = [];
63
63
  var Queue = class {
@@ -67,8 +67,8 @@ var Queue = class {
67
67
  e = [];
68
68
  created = clock;
69
69
  enqueue(type, fn) {
70
- if (ActiveTransition && ActiveTransition.w.has(this))
71
- return ActiveTransition.w.get(this).enqueue(type, fn);
70
+ if (ActiveTransition && ActiveTransition.u.has(this))
71
+ return ActiveTransition.u.get(this).enqueue(type, fn);
72
72
  pureQueue.push(fn);
73
73
  if (type)
74
74
  this.f[type - 1].push(fn);
@@ -100,7 +100,7 @@ var Queue = class {
100
100
  this.run(EFFECT_USER);
101
101
  } finally {
102
102
  this.z = false;
103
- unobserved.length && notifyUnobserved();
103
+ Unobserved.length && notifyUnobserved();
104
104
  }
105
105
  }
106
106
  addChild(child) {
@@ -113,8 +113,8 @@ var Queue = class {
113
113
  this.e.splice(index, 1);
114
114
  }
115
115
  notify(...args) {
116
- if (ActiveTransition && ActiveTransition.w.has(this))
117
- return ActiveTransition.w.get(this).notify(...args);
116
+ if (ActiveTransition && ActiveTransition.u.has(this))
117
+ return ActiveTransition.u.get(this).notify(...args);
118
118
  if (this.m)
119
119
  return this.m.notify(...args);
120
120
  return false;
@@ -123,7 +123,7 @@ var Queue = class {
123
123
  this.f[0].push.apply(this.f[0], queue.f[0]);
124
124
  this.f[1].push.apply(this.f[1], queue.f[1]);
125
125
  for (let i = 0; i < queue.e.length; i++) {
126
- const og = this.e.find((c) => c.j === queue.e[i].j);
126
+ const og = this.e.find((c) => c.g === queue.e[i].g);
127
127
  if (og)
128
128
  og.merge(queue.e[i]);
129
129
  else
@@ -143,12 +143,12 @@ function runQueue(queue, type) {
143
143
  }
144
144
  var Transition = class _Transition {
145
145
  a = /* @__PURE__ */ new Map();
146
- t = /* @__PURE__ */ new Set();
147
- Q = /* @__PURE__ */ new Set();
146
+ s = /* @__PURE__ */ new Set();
147
+ R = /* @__PURE__ */ new Set();
148
148
  W = /* @__PURE__ */ new Set();
149
149
  I = false;
150
150
  f = [[], []];
151
- w = /* @__PURE__ */ new Map();
151
+ u = /* @__PURE__ */ new Map();
152
152
  E = [];
153
153
  e = [];
154
154
  m = null;
@@ -156,9 +156,9 @@ var Transition = class _Transition {
156
156
  X = false;
157
157
  created = clock;
158
158
  constructor() {
159
- this.w.set(globalQueue, this);
159
+ this.u.set(globalQueue, this);
160
160
  for (const child of globalQueue.e) {
161
- cloneQueue(child, this, this.w);
161
+ cloneQueue(child, this, this.u);
162
162
  }
163
163
  }
164
164
  enqueue(type, fn) {
@@ -211,9 +211,9 @@ var Transition = class _Transition {
211
211
  if (!(type & LOADING_BIT))
212
212
  return false;
213
213
  if (flags & LOADING_BIT) {
214
- this.t.add(node);
214
+ this.s.add(node);
215
215
  } else {
216
- this.t.delete(node);
216
+ this.s.delete(node);
217
217
  }
218
218
  return true;
219
219
  }
@@ -222,7 +222,7 @@ var Transition = class _Transition {
222
222
  this.f[1].push.apply(this.f[1], queue.f[1]);
223
223
  this.E.push.apply(this.E, queue.E);
224
224
  for (let i = 0; i < queue.e.length; i++) {
225
- const og = this.e.find((c) => c.j === queue.e[i].j);
225
+ const og = this.e.find((c) => c.g === queue.e[i].g);
226
226
  if (og)
227
227
  og.merge(queue.e[i]);
228
228
  else
@@ -250,9 +250,9 @@ var Transition = class _Transition {
250
250
  const result = fn();
251
251
  const transition2 = ActiveTransition;
252
252
  if (result instanceof Promise) {
253
- transition2.Q.add(result);
253
+ transition2.R.add(result);
254
254
  result.finally(() => {
255
- transition2.Q.delete(result);
255
+ transition2.R.delete(result);
256
256
  finishTransition(transition2);
257
257
  });
258
258
  }
@@ -263,12 +263,12 @@ var Transition = class _Transition {
263
263
  }
264
264
  }
265
265
  addOptimistic(fn) {
266
- if (fn.k && fn.k !== this) {
267
- mergeTransitions(fn.k, this);
268
- ActiveTransition = fn.k;
266
+ if (fn.l && fn.l !== this) {
267
+ mergeTransitions(fn.l, this);
268
+ ActiveTransition = fn.l;
269
269
  return;
270
270
  }
271
- fn.k = this;
271
+ fn.l = this;
272
272
  this.W.add(fn);
273
273
  }
274
274
  };
@@ -277,51 +277,59 @@ function transition(fn) {
277
277
  queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
278
278
  }
279
279
  function cloneGraph(node) {
280
- if (node.k) {
281
- if (node.k !== ActiveTransition) {
282
- mergeTransitions(node.k, ActiveTransition);
283
- ActiveTransition = node.k;
280
+ if (node.l) {
281
+ if (node.l !== ActiveTransition) {
282
+ mergeTransitions(node.l, ActiveTransition);
283
+ ActiveTransition = node.l;
284
284
  }
285
- return node.k.a.get(node);
285
+ return node.l.a.get(node);
286
286
  }
287
287
  const clone = Object.create(Object.getPrototypeOf(node));
288
- Object.assign(clone, node, { n: null, s: null, j: node });
288
+ Object.assign(clone, node, {
289
+ n: null,
290
+ r: null,
291
+ b: null,
292
+ a: node.a ? [...node.a] : null,
293
+ g: node
294
+ });
289
295
  ActiveTransition.a.set(node, clone);
290
- node.k = ActiveTransition;
291
- if (node.d) {
292
- for (let i = 0, length = node.d.length; i < length; i++) {
293
- const o = node.d[i];
294
- node.d.push(cloneGraph(o));
296
+ node.l = ActiveTransition;
297
+ if (node.a) {
298
+ for (let i = 0; i < node.a.length; i++)
299
+ node.a[i].b.push(clone);
300
+ }
301
+ if (node.b) {
302
+ clone.b = [];
303
+ for (let i = 0, length = node.b.length; i < length; i++) {
304
+ !node.b[i].g && clone.b.push(cloneGraph(node.b[i]));
295
305
  }
296
306
  }
297
307
  return clone;
298
308
  }
299
- function removeSourceObservers(node, index) {
309
+ function replaceSourceObservers(node, transition2) {
300
310
  let source;
311
+ let transitionSource;
301
312
  let swap;
302
- for (let i = index; i < node.a.length; i++) {
303
- source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
304
- if (source.d) {
305
- if ((swap = source.d.indexOf(node)) !== -1) {
306
- source.d[swap] = source.d[source.d.length - 1];
307
- source.d.pop();
308
- }
309
- if (!source.d.length)
310
- unobserved.push(source);
313
+ for (let i = 0; i < node.a.length; i++) {
314
+ transitionSource = transition2.a.get(node.a[i]);
315
+ source = transitionSource || node.a[i];
316
+ if (source.b && (swap = source.b.indexOf(node)) !== -1) {
317
+ source.b[swap] = transitionSource ? node.g : source.b[source.b.length - 1];
318
+ !transitionSource && source.b.pop();
311
319
  }
312
320
  }
313
321
  }
314
322
  function cloneQueue(queue, parent, clonedQueues) {
315
323
  const clone = Object.create(Object.getPrototypeOf(queue));
316
324
  Object.assign(clone, queue, {
317
- j: queue,
325
+ g: queue,
318
326
  m: parent,
319
327
  e: [],
320
328
  enqueue(type, fn) {
321
329
  ActiveTransition == null ? void 0 : ActiveTransition.enqueue(type, fn);
322
330
  },
323
331
  notify(node, type, flags) {
324
- node = node.j || node;
332
+ node = node.g || node;
325
333
  if (!clone.F || type & LOADING_BIT) {
326
334
  type &= ~LOADING_BIT;
327
335
  ActiveTransition == null ? void 0 : ActiveTransition.notify(node, LOADING_BIT, flags);
@@ -339,7 +347,7 @@ function cloneQueue(queue, parent, clonedQueues) {
339
347
  }
340
348
  function resolveQueues(children) {
341
349
  for (const child of children) {
342
- const og = child.j;
350
+ const og = child.g;
343
351
  if (og) {
344
352
  const clonedChildren = child.e;
345
353
  delete child.enqueue;
@@ -347,50 +355,50 @@ function resolveQueues(children) {
347
355
  delete child.m;
348
356
  delete child.e;
349
357
  Object.assign(og, child);
350
- delete og.j;
358
+ delete og.g;
351
359
  resolveQueues(clonedChildren);
352
- } else if (child.m.j) {
353
- child.m.j.addChild(child);
360
+ } else if (child.m.g) {
361
+ child.m.g.addChild(child);
354
362
  }
355
363
  }
356
364
  }
357
365
  function mergeTransitions(t1, t2) {
358
366
  t2.a.forEach((value, key) => {
359
- key.k = t1;
367
+ key.l = t1;
360
368
  t1.a.set(key, value);
361
369
  });
362
370
  t2.W.forEach((c) => {
363
- c.k = t1;
371
+ c.l = t1;
364
372
  t1.W.add(c);
365
373
  });
366
- t2.Q.forEach((p) => t1.Q.add(p));
367
- t2.t.forEach((n) => t1.t.add(n));
374
+ t2.R.forEach((p) => t1.R.add(p));
375
+ t2.s.forEach((n) => t1.s.add(n));
368
376
  t1.merge(t2);
369
377
  t2.I = t1;
370
378
  }
371
379
  function finishTransition(transition2) {
372
- if (transition2.I || transition2.X || transition2.Q.size || transition2.t.size)
380
+ if (transition2.I || transition2.X || transition2.R.size || transition2.s.size)
373
381
  return;
374
382
  for (const [source, clone] of transition2.a) {
375
- if (source === clone || source.k !== transition2)
383
+ if (source === clone || source.l !== transition2)
376
384
  continue;
377
385
  if (clone.a)
378
- removeSourceObservers(clone, 0);
386
+ replaceSourceObservers(clone, transition2);
379
387
  source.dispose(false);
380
388
  source.emptyDisposal();
381
389
  Object.assign(source, clone);
382
- delete source.j;
383
- delete source.k;
390
+ delete source.g;
391
+ delete source.l;
384
392
  }
385
393
  globalQueue.f[0].push.apply(globalQueue.f[0], transition2.f[0]);
386
394
  globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
387
395
  resolveQueues(transition2.e);
388
396
  transition2.I = true;
389
- globalQueue.flush();
390
397
  for (const reset of transition2.W) {
391
- delete reset.k;
398
+ delete reset.l;
392
399
  reset();
393
400
  }
401
+ globalQueue.flush();
394
402
  }
395
403
 
396
404
  // src/core/owner.ts
@@ -409,12 +417,12 @@ var Owner = class {
409
417
  // However, the children are actually added in reverse creation order
410
418
  // See comment at the top of the file for an example of the _nextSibling traversal
411
419
  m = null;
412
- s = null;
420
+ r = null;
413
421
  B = null;
414
- b = STATE_CLEAN;
422
+ c = STATE_CLEAN;
415
423
  n = null;
416
- x = defaultContext;
417
- l = globalQueue;
424
+ w = defaultContext;
425
+ k = globalQueue;
418
426
  ea = 0;
419
427
  id = null;
420
428
  constructor(id = null, skipAppend = false) {
@@ -426,27 +434,27 @@ var Owner = class {
426
434
  append(child) {
427
435
  child.m = this;
428
436
  child.B = this;
429
- if (this.s)
430
- this.s.B = child;
431
- child.s = this.s;
432
- this.s = child;
437
+ if (this.r)
438
+ this.r.B = child;
439
+ child.r = this.r;
440
+ this.r = child;
433
441
  if (this.id != null && child.id == null)
434
442
  child.id = this.getNextChildId();
435
- if (child.x !== this.x) {
436
- child.x = { ...this.x, ...child.x };
443
+ if (child.w !== this.w) {
444
+ child.w = { ...this.w, ...child.w };
437
445
  }
438
- if (this.l)
439
- child.l = this.l;
446
+ if (this.k)
447
+ child.k = this.k;
440
448
  }
441
449
  dispose(self = true) {
442
- if (this.b === STATE_DISPOSED)
450
+ if (this.c === STATE_DISPOSED)
443
451
  return;
444
- let head = self ? this.B || this.m : this, current = this.s, next = null;
452
+ let head = self ? this.B || this.m : this, current = this.r, next = null;
445
453
  while (current && current.m === this) {
446
454
  current.dispose(true);
447
455
  current.J();
448
- next = current.s;
449
- current.s = null;
456
+ next = current.r;
457
+ current.r = null;
450
458
  current = next;
451
459
  }
452
460
  this.ea = 0;
@@ -455,15 +463,15 @@ var Owner = class {
455
463
  if (current)
456
464
  current.B = !self ? this : this.B;
457
465
  if (head)
458
- head.s = current;
466
+ head.r = current;
459
467
  }
460
468
  J() {
461
469
  if (this.B)
462
- this.B.s = null;
470
+ this.B.r = null;
463
471
  this.m = null;
464
472
  this.B = null;
465
- this.x = defaultContext;
466
- this.b = STATE_DISPOSED;
473
+ this.w = defaultContext;
474
+ this.c = STATE_DISPOSED;
467
475
  this.emptyDisposal();
468
476
  }
469
477
  emptyDisposal() {
@@ -492,7 +500,7 @@ function getContext(context, owner = currentOwner) {
492
500
  if (!owner) {
493
501
  throw new NoOwnerError();
494
502
  }
495
- const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue;
503
+ const value = hasContext(context, owner) ? owner.w[context.id] : context.defaultValue;
496
504
  if (isUndefined(value)) {
497
505
  throw new ContextNotFoundError();
498
506
  }
@@ -502,13 +510,13 @@ function setContext(context, value, owner = currentOwner) {
502
510
  if (!owner) {
503
511
  throw new NoOwnerError();
504
512
  }
505
- owner.x = {
506
- ...owner.x,
513
+ owner.w = {
514
+ ...owner.w,
507
515
  [context.id]: isUndefined(value) ? context.defaultValue : value
508
516
  };
509
517
  }
510
518
  function hasContext(context, owner = currentOwner) {
511
- return !isUndefined(owner == null ? void 0 : owner.x[context.id]);
519
+ return !isUndefined(owner == null ? void 0 : owner.w[context.id]);
512
520
  }
513
521
  function onCleanup(fn) {
514
522
  if (!currentOwner)
@@ -546,10 +554,10 @@ function getObserver() {
546
554
  var UNCHANGED = Symbol(0);
547
555
  var Computation = class extends Owner {
548
556
  a = null;
549
- d = null;
550
- i;
551
- R;
557
+ b = null;
558
+ j;
552
559
  K;
560
+ L;
553
561
  // Used in __DEV__ mode, hopefully removed in production
554
562
  ka;
555
563
  // Using false is an optimization as an alternative to _equals: () => false
@@ -561,16 +569,16 @@ var Computation = class extends Owner {
561
569
  h = 0;
562
570
  /** Which flags raised by sources are handled, vs. being passed through. */
563
571
  aa = DEFAULT_FLAGS;
564
- L = -1;
572
+ M = -1;
565
573
  G = false;
566
- k;
567
- j;
574
+ l;
575
+ g;
568
576
  constructor(initialValue, compute2, options) {
569
577
  super(options == null ? void 0 : options.id, compute2 === null);
570
- this.K = compute2;
571
- this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
578
+ this.L = compute2;
579
+ this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
572
580
  this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
573
- this.i = initialValue;
581
+ this.j = initialValue;
574
582
  if ((options == null ? void 0 : options.equals) !== void 0)
575
583
  this.$ = options.equals;
576
584
  if (options == null ? void 0 : options.pureWrite)
@@ -578,7 +586,7 @@ var Computation = class extends Owner {
578
586
  if (options == null ? void 0 : options.unobserved)
579
587
  this.da = options == null ? void 0 : options.unobserved;
580
588
  if (ActiveTransition) {
581
- this.k = ActiveTransition;
589
+ this.l = ActiveTransition;
582
590
  ActiveTransition.a.set(this, this);
583
591
  }
584
592
  }
@@ -586,9 +594,9 @@ var Computation = class extends Owner {
586
594
  track(this);
587
595
  newFlags |= this.h & ~currentMask;
588
596
  if (this.h & ERROR_BIT) {
589
- throw this.R;
597
+ throw this.K;
590
598
  } else {
591
- return this.i;
599
+ return this.j;
592
600
  }
593
601
  }
594
602
  /**
@@ -596,13 +604,13 @@ var Computation = class extends Owner {
596
604
  * Automatically re-executes the surrounding computation when the value changes
597
605
  */
598
606
  read() {
599
- if (ActiveTransition && ActiveTransition.a.has(this)) {
600
- const clone = ActiveTransition.a.get(this);
607
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
608
+ const clone = ActiveTransition.a.get(this) || cloneGraph(this);
601
609
  if (clone !== this)
602
610
  return clone.read();
603
611
  }
604
- if (this.K) {
605
- if (this.h & ERROR_BIT && this.L <= clock)
612
+ if (this.L) {
613
+ if (this.h & ERROR_BIT && this.M <= clock)
606
614
  update(this);
607
615
  else
608
616
  this.H();
@@ -617,13 +625,13 @@ var Computation = class extends Owner {
617
625
  * before continuing
618
626
  */
619
627
  wait() {
620
- if (ActiveTransition && ActiveTransition.a.has(this)) {
621
- const clone = ActiveTransition.a.get(this);
628
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
629
+ const clone = ActiveTransition.a.get(this) || cloneGraph(this);
622
630
  if (clone !== this)
623
631
  return clone.wait();
624
632
  }
625
- if (this.K) {
626
- if (this.h & ERROR_BIT && this.L <= clock)
633
+ if (this.L) {
634
+ if (this.h & ERROR_BIT && this.M <= clock)
627
635
  update(this);
628
636
  else
629
637
  this.H();
@@ -633,54 +641,49 @@ var Computation = class extends Owner {
633
641
  throw new NotReadyError();
634
642
  }
635
643
  if (staleCheck && this.h & LOADING_BIT) {
636
- staleCheck.i = true;
644
+ staleCheck.j = true;
637
645
  }
638
646
  return this.fa();
639
647
  }
640
648
  /** Update the computation with a new value. */
641
649
  write(value, flags = 0, raw = false) {
642
- if (ActiveTransition && !this.j) {
650
+ if (ActiveTransition && !this.g) {
643
651
  const clone = cloneGraph(this);
644
652
  if (clone !== this)
645
653
  return clone.write(value, flags, raw);
646
654
  }
647
- const newValue = !raw && typeof value === "function" ? value(this.i) : value;
655
+ const newValue = !raw && typeof value === "function" ? value(this.j) : value;
648
656
  const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
649
- this.$ === false || !this.$(this.i, newValue));
657
+ this.$ === false || !this.$(this.j, newValue));
650
658
  if (valueChanged) {
651
- this.i = newValue;
652
- this.R = void 0;
659
+ this.j = newValue;
660
+ this.K = void 0;
653
661
  }
654
662
  const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
655
663
  this.h = flags;
656
- this.L = clock + 1;
657
- if (this.d) {
658
- for (let i = 0; i < this.d.length; i++) {
664
+ this.M = clock + 1;
665
+ if (this.b) {
666
+ for (let i = 0; i < this.b.length; i++) {
659
667
  if (valueChanged) {
660
- this.d[i].o(STATE_DIRTY);
668
+ this.b[i].x(STATE_DIRTY);
661
669
  } else if (changedFlagsMask) {
662
- this.d[i].Y(changedFlagsMask, changedFlags);
670
+ this.b[i].Y(changedFlagsMask, changedFlags);
663
671
  }
664
672
  }
665
673
  }
666
- return this.i;
674
+ return this.j;
667
675
  }
668
676
  /**
669
677
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
670
678
  */
671
- o(state, skipQueue) {
672
- if (ActiveTransition && ActiveTransition.a.has(this)) {
673
- const clone = ActiveTransition.a.get(this);
674
- if (clone !== this)
675
- return clone.o(state, skipQueue);
676
- }
677
- if (this.b >= state && !this.G)
679
+ x(state, skipQueue) {
680
+ if (this.c >= state && !this.G)
678
681
  return;
679
682
  this.G = !!skipQueue;
680
- this.b = state;
681
- if (this.d) {
682
- for (let i = 0; i < this.d.length; i++) {
683
- this.d[i].o(STATE_CHECK, skipQueue);
683
+ this.c = state;
684
+ if (this.b) {
685
+ for (let i = 0; i < this.b.length; i++) {
686
+ this.b[i].x(STATE_CHECK, skipQueue);
684
687
  }
685
688
  }
686
689
  }
@@ -691,34 +694,34 @@ var Computation = class extends Owner {
691
694
  * @param newFlags The source's new flags, masked to just the changed ones.
692
695
  */
693
696
  Y(mask, newFlags2) {
694
- if (this.b >= STATE_DIRTY)
697
+ if (this.c >= STATE_DIRTY)
695
698
  return;
696
699
  if (mask & this.aa) {
697
- this.o(STATE_DIRTY);
700
+ this.x(STATE_DIRTY);
698
701
  return;
699
702
  }
700
- if (this.b >= STATE_CHECK)
703
+ if (this.c >= STATE_CHECK)
701
704
  return;
702
705
  const prevFlags = this.h & mask;
703
706
  const deltaFlags = prevFlags ^ newFlags2;
704
707
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
705
- this.o(STATE_CHECK);
708
+ this.x(STATE_CHECK);
706
709
  } else {
707
710
  this.h ^= deltaFlags;
708
- if (this.d) {
709
- for (let i = 0; i < this.d.length; i++) {
710
- this.d[i].Y(mask, newFlags2);
711
+ if (this.b) {
712
+ for (let i = 0; i < this.b.length; i++) {
713
+ this.b[i].Y(mask, newFlags2);
711
714
  }
712
715
  }
713
716
  }
714
717
  }
715
- M(error) {
716
- if (ActiveTransition && !this.j) {
718
+ N(error) {
719
+ if (ActiveTransition && !this.g) {
717
720
  const clone = cloneGraph(this);
718
721
  if (clone !== this)
719
- return clone.M(error);
722
+ return clone.N(error);
720
723
  }
721
- this.R = error;
724
+ this.K = error;
722
725
  this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
723
726
  }
724
727
  /**
@@ -729,38 +732,38 @@ var Computation = class extends Owner {
729
732
  * This function will ensure that the value and states we read from the computation are up to date
730
733
  */
731
734
  H() {
732
- if (!this.K) {
735
+ if (!this.L) {
733
736
  return;
734
737
  }
735
- if (this.b === STATE_DISPOSED) {
738
+ if (this.c === STATE_DISPOSED) {
736
739
  return;
737
740
  }
738
- if (this.b === STATE_CLEAN) {
741
+ if (this.c === STATE_CLEAN) {
739
742
  return;
740
743
  }
741
744
  let observerFlags = 0;
742
- if (this.b === STATE_CHECK) {
745
+ if (this.c === STATE_CHECK) {
743
746
  for (let i = 0; i < this.a.length; i++) {
744
747
  const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
745
748
  source.H();
746
- observerFlags |= source.h;
747
- if (this.b === STATE_DIRTY) {
749
+ observerFlags |= source.h & ~UNINITIALIZED_BIT;
750
+ if (this.c === STATE_DIRTY) {
748
751
  break;
749
752
  }
750
753
  }
751
754
  }
752
- if (this.b === STATE_DIRTY) {
755
+ if (this.c === STATE_DIRTY) {
753
756
  update(this);
754
757
  } else {
755
758
  this.write(UNCHANGED, observerFlags);
756
- this.b = STATE_CLEAN;
759
+ this.c = STATE_CLEAN;
757
760
  }
758
761
  }
759
762
  /**
760
763
  * Remove ourselves from the owner graph and the computation graph
761
764
  */
762
765
  J() {
763
- if (this.b === STATE_DISPOSED)
766
+ if (this.c === STATE_DISPOSED)
764
767
  return;
765
768
  if (this.a)
766
769
  removeSourceObservers(this, 0);
@@ -768,8 +771,8 @@ var Computation = class extends Owner {
768
771
  }
769
772
  };
770
773
  function track(computation) {
771
- if (ActiveTransition && computation.j)
772
- computation = computation.j;
774
+ if (ActiveTransition && computation.g)
775
+ computation = computation.g;
773
776
  if (currentObserver) {
774
777
  if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
775
778
  newSourcesIndex++;
@@ -779,7 +782,7 @@ function track(computation) {
779
782
  newSources.push(computation);
780
783
  }
781
784
  if (updateCheck) {
782
- updateCheck.i = computation.L > currentObserver.L;
785
+ updateCheck.j = computation.M > currentObserver.M;
783
786
  }
784
787
  }
785
788
  }
@@ -791,13 +794,13 @@ function update(node) {
791
794
  try {
792
795
  node.dispose(false);
793
796
  node.emptyDisposal();
794
- const result = compute(node, node.K, node);
797
+ const result = compute(node, node.L, node);
795
798
  node.write(result, newFlags, true);
796
799
  } catch (error) {
797
800
  if (error instanceof NotReadyError) {
798
801
  node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
799
802
  } else {
800
- node.M(error);
803
+ node.N(error);
801
804
  }
802
805
  } finally {
803
806
  if (newSources) {
@@ -813,11 +816,11 @@ function update(node) {
813
816
  }
814
817
  let source;
815
818
  for (let i = newSourcesIndex; i < node.a.length; i++) {
816
- source = node.a[i];
817
- if (!source.d)
818
- source.d = [node];
819
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
820
+ if (!source.b)
821
+ source.b = [node];
819
822
  else
820
- source.d.push(node);
823
+ source.b.push(node);
821
824
  }
822
825
  } else if (node.a && newSourcesIndex < node.a.length) {
823
826
  removeSourceObservers(node, newSourcesIndex);
@@ -826,8 +829,23 @@ function update(node) {
826
829
  newSources = prevSources;
827
830
  newSourcesIndex = prevSourcesIndex;
828
831
  newFlags = prevFlags;
829
- node.L = clock + 1;
830
- node.b = STATE_CLEAN;
832
+ node.M = clock + 1;
833
+ node.c = STATE_CLEAN;
834
+ }
835
+ }
836
+ function removeSourceObservers(node, index) {
837
+ let source;
838
+ let swap;
839
+ for (let i = index; i < node.a.length; i++) {
840
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
841
+ if (source.b) {
842
+ if ((swap = source.b.indexOf(node)) !== -1) {
843
+ source.b[swap] = source.b[source.b.length - 1];
844
+ source.b.pop();
845
+ }
846
+ if (!source.b.length)
847
+ Unobserved.push(source);
848
+ }
831
849
  }
832
850
  }
833
851
  function isEqual(a, b) {
@@ -840,20 +858,20 @@ function untrack(fn) {
840
858
  }
841
859
  function hasUpdated(fn) {
842
860
  const current = updateCheck;
843
- updateCheck = { i: false };
861
+ updateCheck = { j: false };
844
862
  try {
845
863
  fn();
846
- return updateCheck.i;
864
+ return updateCheck.j;
847
865
  } finally {
848
866
  updateCheck = current;
849
867
  }
850
868
  }
851
869
  function pendingCheck(fn, loadingValue) {
852
870
  const current = staleCheck;
853
- staleCheck = { i: false };
871
+ staleCheck = { j: false };
854
872
  try {
855
873
  latest(fn);
856
- return staleCheck.i;
874
+ return staleCheck.j;
857
875
  } catch (err) {
858
876
  if (!(err instanceof NotReadyError))
859
877
  return false;
@@ -901,7 +919,7 @@ function runWithObserver(observer, run) {
901
919
  newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
902
920
  );
903
921
  } else {
904
- observer.M(error);
922
+ observer.N(error);
905
923
  }
906
924
  } finally {
907
925
  if (newSources) {
@@ -916,10 +934,10 @@ function runWithObserver(observer, run) {
916
934
  let source;
917
935
  for (let i = newSourcesIndex; i < observer.a.length; i++) {
918
936
  source = observer.a[i];
919
- if (!source.d)
920
- source.d = [observer];
937
+ if (!source.b)
938
+ source.b = [observer];
921
939
  else
922
- source.d.push(observer);
940
+ source.b.push(observer);
923
941
  }
924
942
  }
925
943
  newSources = prevSources;
@@ -933,7 +951,7 @@ function compute(owner, fn, observer) {
933
951
  currentMask = (observer == null ? void 0 : observer.aa) ?? DEFAULT_FLAGS;
934
952
  notStale = true;
935
953
  try {
936
- return fn(observer ? observer.i : void 0);
954
+ return fn.call(observer, observer ? observer.j : void 0);
937
955
  } finally {
938
956
  setOwner(prevOwner);
939
957
  currentObserver = prevObserver;
@@ -946,7 +964,7 @@ function compute(owner, fn, observer) {
946
964
  var Effect = class extends Computation {
947
965
  ba;
948
966
  Z;
949
- N;
967
+ O;
950
968
  ca = false;
951
969
  _;
952
970
  A;
@@ -957,92 +975,93 @@ var Effect = class extends Computation {
957
975
  this._ = initialValue;
958
976
  this.A = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
959
977
  if (this.A === EFFECT_RENDER) {
960
- this.K = (p) => !ActiveTransition && clock > this.l.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
978
+ this.L = function(p) {
979
+ return !this.g && clock > this.k.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
980
+ };
961
981
  }
962
982
  this.H();
963
- !(options == null ? void 0 : options.defer) && (this.A === EFFECT_USER ? this.l.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
983
+ !(options == null ? void 0 : options.defer) && (this.A === EFFECT_USER ? this.k.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
964
984
  }
965
985
  write(value, flags = 0) {
966
- if (this.b == STATE_DIRTY) {
986
+ if (this.c == STATE_DIRTY) {
967
987
  this.h = flags;
968
988
  if (this.A === EFFECT_RENDER) {
969
- this.l.notify(this, LOADING_BIT | ERROR_BIT, flags);
989
+ this.k.notify(this, LOADING_BIT | ERROR_BIT, this.h);
970
990
  }
971
991
  }
972
992
  if (value === UNCHANGED)
973
- return this.i;
974
- this.i = value;
993
+ return this.j;
994
+ this.j = value;
975
995
  this.ca = true;
996
+ this.K = void 0;
976
997
  return value;
977
998
  }
978
- o(state, skipQueue) {
979
- if (ActiveTransition && ActiveTransition.a.has(this)) {
980
- return ActiveTransition.a.get(this).o(state, skipQueue);
981
- }
982
- if (this.b >= state || skipQueue)
999
+ x(state, skipQueue) {
1000
+ if (this.c >= state || skipQueue)
983
1001
  return;
984
- if (this.b === STATE_CLEAN)
985
- this.l.enqueue(this.A, this.C.bind(this));
986
- this.b = state;
1002
+ if (this.c === STATE_CLEAN)
1003
+ this.k.enqueue(this.A, this.C.bind(this));
1004
+ this.c = state;
987
1005
  }
988
1006
  Y(mask, newFlags2) {
989
- if (ActiveTransition && ActiveTransition.a.has(this)) {
990
- if (this.b >= STATE_CHECK)
1007
+ if (this.g) {
1008
+ if (this.c >= STATE_DIRTY)
991
1009
  return;
992
1010
  if (mask & 3) {
993
- this.o(STATE_DIRTY);
1011
+ this.x(STATE_DIRTY);
994
1012
  return;
995
1013
  }
996
1014
  }
997
1015
  super.Y(mask, newFlags2);
998
1016
  }
999
- M(error) {
1000
- this.R = error;
1001
- this.l.notify(this, LOADING_BIT, 0);
1017
+ N(error) {
1018
+ this.K = error;
1019
+ this.k.notify(this, LOADING_BIT, 0);
1002
1020
  this.h = ERROR_BIT;
1003
1021
  if (this.A === EFFECT_USER) {
1004
1022
  try {
1005
1023
  return this.Z ? this.Z(error, () => {
1006
1024
  var _a;
1007
- (_a = this.N) == null ? void 0 : _a.call(this);
1008
- this.N = void 0;
1025
+ (_a = this.O) == null ? void 0 : _a.call(this);
1026
+ this.O = void 0;
1009
1027
  }) : console.error(error);
1010
1028
  } catch (e) {
1011
1029
  error = e;
1012
1030
  }
1013
1031
  }
1014
- if (!this.l.notify(this, ERROR_BIT, ERROR_BIT))
1032
+ if (!this.k.notify(this, ERROR_BIT, ERROR_BIT))
1015
1033
  throw error;
1016
1034
  }
1017
1035
  J() {
1018
1036
  var _a;
1019
- if (this.b === STATE_DISPOSED)
1037
+ if (this.c === STATE_DISPOSED)
1020
1038
  return;
1021
1039
  this.ba = void 0;
1022
1040
  this._ = void 0;
1023
1041
  this.Z = void 0;
1024
- (_a = this.N) == null ? void 0 : _a.call(this);
1025
- this.N = void 0;
1042
+ (_a = this.O) == null ? void 0 : _a.call(this);
1043
+ this.O = void 0;
1044
+ this.k.notify(this, ERROR_BIT | LOADING_BIT, 0);
1026
1045
  super.J();
1027
1046
  }
1028
1047
  C(type) {
1029
1048
  var _a;
1030
1049
  if (type) {
1031
- const effect = this.j || this;
1032
- if (effect.ca && effect.b !== STATE_DISPOSED) {
1033
- (_a = effect.N) == null ? void 0 : _a.call(effect);
1050
+ const effect = this.g || this;
1051
+ if (effect.ca && effect.c !== STATE_DISPOSED) {
1052
+ (_a = effect.O) == null ? void 0 : _a.call(effect);
1034
1053
  try {
1035
- effect.N = effect.ba(effect.i, effect._);
1054
+ effect.O = effect.ba(effect.j, effect._);
1036
1055
  } catch (e) {
1037
- if (!effect.l.notify(effect, ERROR_BIT, ERROR_BIT))
1056
+ if (!effect.k.notify(effect, ERROR_BIT, ERROR_BIT))
1038
1057
  throw e;
1039
1058
  } finally {
1040
- effect._ = effect.i;
1059
+ effect._ = effect.j;
1041
1060
  effect.ca = false;
1042
1061
  }
1043
1062
  }
1044
1063
  } else
1045
- this.b !== STATE_CLEAN && runTop(this);
1064
+ this.c !== STATE_CLEAN && runTop(this);
1046
1065
  }
1047
1066
  };
1048
1067
  var EagerComputation = class extends Computation {
@@ -1050,18 +1069,15 @@ var EagerComputation = class extends Computation {
1050
1069
  super(initialValue, compute2, options);
1051
1070
  !(options == null ? void 0 : options.defer) && this.H();
1052
1071
  }
1053
- o(state, skipQueue) {
1054
- if (ActiveTransition && ActiveTransition.a.has(this)) {
1055
- return ActiveTransition.a.get(this).o(state, skipQueue);
1056
- }
1057
- if (this.b >= state && !this.G)
1072
+ x(state, skipQueue) {
1073
+ if (this.c >= state && !this.G)
1058
1074
  return;
1059
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.G))
1060
- this.l.enqueue(EFFECT_PURE, this.C.bind(this));
1061
- super.o(state, skipQueue);
1075
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1076
+ this.k.enqueue(EFFECT_PURE, this.C.bind(this));
1077
+ super.x(state, skipQueue);
1062
1078
  }
1063
1079
  C() {
1064
- this.b !== STATE_CLEAN && runTop(this);
1080
+ this.c !== STATE_CLEAN && runTop(this);
1065
1081
  }
1066
1082
  };
1067
1083
  var FirewallComputation = class extends Computation {
@@ -1069,30 +1085,27 @@ var FirewallComputation = class extends Computation {
1069
1085
  constructor(compute2) {
1070
1086
  super(void 0, compute2);
1071
1087
  }
1072
- o(state, skipQueue) {
1073
- if (ActiveTransition && ActiveTransition.a.has(this)) {
1074
- return ActiveTransition.a.get(this).o(state, skipQueue);
1075
- }
1076
- if (this.b >= state && !this.G)
1088
+ x(state, skipQueue) {
1089
+ if (this.c >= state && !this.G)
1077
1090
  return;
1078
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.G))
1079
- this.l.enqueue(EFFECT_PURE, this.C.bind(this));
1080
- super.o(state, true);
1091
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1092
+ this.k.enqueue(EFFECT_PURE, this.C.bind(this));
1093
+ super.x(state, true);
1081
1094
  this.G = !!skipQueue;
1082
1095
  }
1083
1096
  C() {
1084
- this.b !== STATE_CLEAN && runTop(this);
1097
+ this.c !== STATE_CLEAN && runTop(this);
1085
1098
  }
1086
1099
  };
1087
1100
  function runTop(node) {
1088
1101
  const ancestors = [];
1089
1102
  for (let current = node; current !== null; current = current.m) {
1090
- if (current.b !== STATE_CLEAN) {
1103
+ if (current.c !== STATE_CLEAN) {
1091
1104
  ancestors.push(current);
1092
1105
  }
1093
1106
  }
1094
1107
  for (let i = ancestors.length - 1; i >= 0; i--) {
1095
- if (ancestors[i].b !== STATE_DISPOSED)
1108
+ if (ancestors[i].c !== STATE_DISPOSED)
1096
1109
  ancestors[i].H();
1097
1110
  }
1098
1111
  }
@@ -1228,7 +1241,7 @@ var storeTraps = {
1228
1241
  return desc.get.call(receiver);
1229
1242
  }
1230
1243
  if (Writing == null ? void 0 : Writing.has(receiver)) {
1231
- let value2 = tracked && (overridden || !proxySource) ? tracked.i : storeValue[property];
1244
+ let value2 = tracked && (overridden || !proxySource) ? tracked.j : storeValue[property];
1232
1245
  value2 === $DELETED && (value2 = void 0);
1233
1246
  if (!isWrappable(value2))
1234
1247
  return value2;
@@ -1525,6 +1538,8 @@ function applyState(next, state, keyFn, all) {
1525
1538
  }
1526
1539
  function reconcile(value, key, all = false) {
1527
1540
  return (state) => {
1541
+ if (state == null)
1542
+ throw new Error("Cannot reconcile null or undefined state");
1528
1543
  const keyFn = typeof key === "string" ? (item) => item[key] : key;
1529
1544
  const eq = keyFn(state);
1530
1545
  if (eq !== void 0 && keyFn(value) !== keyFn(state))
@@ -1766,12 +1781,12 @@ function createMemo(compute2, value, options) {
1766
1781
  return () => {
1767
1782
  var _a, _b;
1768
1783
  if (node) {
1769
- if (node.b === STATE_DISPOSED) {
1784
+ if (node.c === STATE_DISPOSED) {
1770
1785
  node = void 0;
1771
1786
  return resolvedValue;
1772
1787
  }
1773
1788
  resolvedValue = node.wait();
1774
- if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.s) == null ? void 0 : _b.m) !== node) {
1789
+ if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.r) == null ? void 0 : _b.m) !== node && !(node.h & UNINITIALIZED_BIT)) {
1775
1790
  node.dispose();
1776
1791
  node = void 0;
1777
1792
  }
@@ -1807,8 +1822,8 @@ function createAsync(compute2, value, options) {
1807
1822
  if (abort)
1808
1823
  return;
1809
1824
  if (transition2)
1810
- return transition2.runTransition(() => node.M(error), true);
1811
- node.M(error);
1825
+ return transition2.runTransition(() => node.N(error), true);
1826
+ node.N(error);
1812
1827
  }
1813
1828
  );
1814
1829
  } else {
@@ -1832,9 +1847,13 @@ function createAsync(compute2, value, options) {
1832
1847
  );
1833
1848
  const read = node.wait.bind(node);
1834
1849
  read.refresh = () => {
1835
- node.b = STATE_DIRTY;
1850
+ let n = node;
1851
+ if (ActiveTransition && !node.g) {
1852
+ n = cloneGraph(node);
1853
+ }
1854
+ n.c = STATE_DIRTY;
1836
1855
  refreshing = true;
1837
- node.H();
1856
+ n.H();
1838
1857
  };
1839
1858
  return read;
1840
1859
  }
@@ -1915,7 +1934,7 @@ function createOptimistic(initial, compute2, key) {
1915
1934
  (s) => {
1916
1935
  const value = initial();
1917
1936
  if (!ActiveTransition)
1918
- s.value = value;
1937
+ reconcile({ value }, key)(s);
1919
1938
  },
1920
1939
  { value: void 0 }
1921
1940
  );
@@ -1923,9 +1942,9 @@ function createOptimistic(initial, compute2, key) {
1923
1942
  [store, setStore] = createStore({ value: initial });
1924
1943
  const reset = () => setStore(
1925
1944
  (s) => reconcile(
1926
- typeof initial === "function" ? initial() : initial,
1945
+ { value: typeof initial === "function" ? initial() : initial },
1927
1946
  key
1928
- )(s.value)
1947
+ )(s)
1929
1948
  );
1930
1949
  let lastChange = void 0;
1931
1950
  function write(v) {
@@ -1947,15 +1966,15 @@ function mapArray(list, map, options) {
1947
1966
  const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
1948
1967
  return updateKeyedMap.bind({
1949
1968
  S: new Owner(),
1950
- p: 0,
1969
+ o: 0,
1951
1970
  ha: list,
1952
1971
  D: [],
1953
- O: map,
1954
- g: [],
1955
- c: [],
1956
- P: keyFn,
1957
- q: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
1958
- r: map.length > 1 ? [] : void 0,
1972
+ P: map,
1973
+ i: [],
1974
+ d: [],
1975
+ Q: keyFn,
1976
+ p: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
1977
+ q: map.length > 1 ? [] : void 0,
1959
1978
  T: options == null ? void 0 : options.fallback
1960
1979
  });
1961
1980
  }
@@ -1964,113 +1983,113 @@ function updateKeyedMap() {
1964
1983
  const newItems = this.ha() || [], newLen = newItems.length;
1965
1984
  newItems[$TRACK];
1966
1985
  runWithOwner(this.S, () => {
1967
- let i, j, mapper = this.q ? () => {
1968
- this.q[j] = new Computation(newItems[j], null, pureOptions);
1969
- this.r && (this.r[j] = new Computation(j, null, pureOptions));
1970
- return this.O(
1971
- Computation.prototype.read.bind(this.q[j]),
1972
- this.r ? Computation.prototype.read.bind(this.r[j]) : void 0
1986
+ let i, j, mapper = this.p ? () => {
1987
+ this.p[j] = new Computation(newItems[j], null, pureOptions);
1988
+ this.q && (this.q[j] = new Computation(j, null, pureOptions));
1989
+ return this.P(
1990
+ Computation.prototype.read.bind(this.p[j]),
1991
+ this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
1973
1992
  );
1974
- } : this.r ? () => {
1993
+ } : this.q ? () => {
1975
1994
  const item = newItems[j];
1976
- this.r[j] = new Computation(j, null, pureOptions);
1977
- return this.O(() => item, Computation.prototype.read.bind(this.r[j]));
1995
+ this.q[j] = new Computation(j, null, pureOptions);
1996
+ return this.P(() => item, Computation.prototype.read.bind(this.q[j]));
1978
1997
  } : () => {
1979
1998
  const item = newItems[j];
1980
- return this.O(() => item);
1999
+ return this.P(() => item);
1981
2000
  };
1982
2001
  if (newLen === 0) {
1983
- if (this.p !== 0) {
2002
+ if (this.o !== 0) {
1984
2003
  this.S.dispose(false);
1985
- this.c = [];
2004
+ this.d = [];
1986
2005
  this.D = [];
1987
- this.g = [];
1988
- this.p = 0;
2006
+ this.i = [];
2007
+ this.o = 0;
2008
+ this.p && (this.p = []);
1989
2009
  this.q && (this.q = []);
1990
- this.r && (this.r = []);
1991
2010
  }
1992
- if (this.T && !this.g[0]) {
1993
- this.g[0] = compute(
1994
- this.c[0] = new Owner(),
2011
+ if (this.T && !this.i[0]) {
2012
+ this.i[0] = compute(
2013
+ this.d[0] = new Owner(),
1995
2014
  this.T,
1996
2015
  null
1997
2016
  );
1998
2017
  }
1999
- } else if (this.p === 0) {
2000
- if (this.c[0])
2001
- this.c[0].dispose();
2002
- this.g = new Array(newLen);
2018
+ } else if (this.o === 0) {
2019
+ if (this.d[0])
2020
+ this.d[0].dispose();
2021
+ this.i = new Array(newLen);
2003
2022
  for (j = 0; j < newLen; j++) {
2004
2023
  this.D[j] = newItems[j];
2005
- this.g[j] = compute(this.c[j] = new Owner(), mapper, null);
2024
+ this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2006
2025
  }
2007
- this.p = newLen;
2026
+ this.o = newLen;
2008
2027
  } else {
2009
- let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.q ? new Array(newLen) : void 0, tempIndexes = this.r ? new Array(newLen) : void 0;
2010
- for (start = 0, end = Math.min(this.p, newLen); start < end && (this.D[start] === newItems[start] || this.q && compare(this.P, this.D[start], newItems[start])); start++) {
2011
- if (this.q)
2012
- this.q[start].write(newItems[start]);
2028
+ let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
2029
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.D[start] === newItems[start] || this.p && compare(this.Q, this.D[start], newItems[start])); start++) {
2030
+ if (this.p)
2031
+ this.p[start].write(newItems[start]);
2013
2032
  }
2014
- for (end = this.p - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.q && compare(this.P, this.D[end], newItems[newEnd])); end--, newEnd--) {
2015
- temp[newEnd] = this.g[end];
2016
- tempNodes[newEnd] = this.c[end];
2017
- tempRows && (tempRows[newEnd] = this.q[end]);
2018
- tempIndexes && (tempIndexes[newEnd] = this.r[end]);
2033
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.p && compare(this.Q, this.D[end], newItems[newEnd])); end--, newEnd--) {
2034
+ temp[newEnd] = this.i[end];
2035
+ tempNodes[newEnd] = this.d[end];
2036
+ tempRows && (tempRows[newEnd] = this.p[end]);
2037
+ tempIndexes && (tempIndexes[newEnd] = this.q[end]);
2019
2038
  }
2020
2039
  newIndices = /* @__PURE__ */ new Map();
2021
2040
  newIndicesNext = new Array(newEnd + 1);
2022
2041
  for (j = newEnd; j >= start; j--) {
2023
2042
  item = newItems[j];
2024
- key = this.P ? this.P(item) : item;
2043
+ key = this.Q ? this.Q(item) : item;
2025
2044
  i = newIndices.get(key);
2026
2045
  newIndicesNext[j] = i === void 0 ? -1 : i;
2027
2046
  newIndices.set(key, j);
2028
2047
  }
2029
2048
  for (i = start; i <= end; i++) {
2030
2049
  item = this.D[i];
2031
- key = this.P ? this.P(item) : item;
2050
+ key = this.Q ? this.Q(item) : item;
2032
2051
  j = newIndices.get(key);
2033
2052
  if (j !== void 0 && j !== -1) {
2034
- temp[j] = this.g[i];
2035
- tempNodes[j] = this.c[i];
2036
- tempRows && (tempRows[j] = this.q[i]);
2037
- tempIndexes && (tempIndexes[j] = this.r[i]);
2053
+ temp[j] = this.i[i];
2054
+ tempNodes[j] = this.d[i];
2055
+ tempRows && (tempRows[j] = this.p[i]);
2056
+ tempIndexes && (tempIndexes[j] = this.q[i]);
2038
2057
  j = newIndicesNext[j];
2039
2058
  newIndices.set(key, j);
2040
2059
  } else
2041
- this.c[i].dispose();
2060
+ this.d[i].dispose();
2042
2061
  }
2043
2062
  for (j = start; j < newLen; j++) {
2044
2063
  if (j in temp) {
2045
- this.g[j] = temp[j];
2046
- this.c[j] = tempNodes[j];
2064
+ this.i[j] = temp[j];
2065
+ this.d[j] = tempNodes[j];
2047
2066
  if (tempRows) {
2048
- this.q[j] = tempRows[j];
2049
- this.q[j].write(newItems[j]);
2067
+ this.p[j] = tempRows[j];
2068
+ this.p[j].write(newItems[j]);
2050
2069
  }
2051
2070
  if (tempIndexes) {
2052
- this.r[j] = tempIndexes[j];
2053
- this.r[j].write(j);
2071
+ this.q[j] = tempIndexes[j];
2072
+ this.q[j].write(j);
2054
2073
  }
2055
2074
  } else {
2056
- this.g[j] = compute(this.c[j] = new Owner(), mapper, null);
2075
+ this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2057
2076
  }
2058
2077
  }
2059
- this.g = this.g.slice(0, this.p = newLen);
2078
+ this.i = this.i.slice(0, this.o = newLen);
2060
2079
  this.D = newItems.slice(0);
2061
2080
  }
2062
2081
  });
2063
- return this.g;
2082
+ return this.i;
2064
2083
  }
2065
2084
  function repeat(count, map, options) {
2066
2085
  return updateRepeat.bind({
2067
2086
  S: new Owner(),
2068
- p: 0,
2087
+ o: 0,
2069
2088
  y: 0,
2070
2089
  ia: count,
2071
- O: map,
2072
- c: [],
2073
- g: [],
2090
+ P: map,
2091
+ d: [],
2092
+ i: [],
2074
2093
  ja: options == null ? void 0 : options.from,
2075
2094
  T: options == null ? void 0 : options.fallback
2076
2095
  });
@@ -2081,15 +2100,15 @@ function updateRepeat() {
2081
2100
  const from = ((_a = this.ja) == null ? void 0 : _a.call(this)) || 0;
2082
2101
  runWithOwner(this.S, () => {
2083
2102
  if (newLen === 0) {
2084
- if (this.p !== 0) {
2103
+ if (this.o !== 0) {
2085
2104
  this.S.dispose(false);
2086
- this.c = [];
2087
- this.g = [];
2088
- this.p = 0;
2105
+ this.d = [];
2106
+ this.i = [];
2107
+ this.o = 0;
2089
2108
  }
2090
- if (this.T && !this.g[0]) {
2091
- this.g[0] = compute(
2092
- this.c[0] = new Owner(),
2109
+ if (this.T && !this.i[0]) {
2110
+ this.i[0] = compute(
2111
+ this.d[0] = new Owner(),
2093
2112
  this.T,
2094
2113
  null
2095
2114
  );
@@ -2097,46 +2116,46 @@ function updateRepeat() {
2097
2116
  return;
2098
2117
  }
2099
2118
  const to = from + newLen;
2100
- const prevTo = this.y + this.p;
2101
- if (this.p === 0 && this.c[0])
2102
- this.c[0].dispose();
2119
+ const prevTo = this.y + this.o;
2120
+ if (this.o === 0 && this.d[0])
2121
+ this.d[0].dispose();
2103
2122
  for (let i = to; i < prevTo; i++)
2104
- this.c[i - this.y].dispose();
2123
+ this.d[i - this.y].dispose();
2105
2124
  if (this.y < from) {
2106
2125
  let i = this.y;
2107
- while (i < from && i < this.p)
2108
- this.c[i++].dispose();
2109
- this.c.splice(0, from - this.y);
2110
- this.g.splice(0, from - this.y);
2126
+ while (i < from && i < this.o)
2127
+ this.d[i++].dispose();
2128
+ this.d.splice(0, from - this.y);
2129
+ this.i.splice(0, from - this.y);
2111
2130
  } else if (this.y > from) {
2112
2131
  let i = prevTo - this.y - 1;
2113
2132
  let difference = this.y - from;
2114
- this.c.length = this.g.length = newLen;
2133
+ this.d.length = this.i.length = newLen;
2115
2134
  while (i >= difference) {
2116
- this.c[i] = this.c[i - difference];
2117
- this.g[i] = this.g[i - difference];
2135
+ this.d[i] = this.d[i - difference];
2136
+ this.i[i] = this.i[i - difference];
2118
2137
  i--;
2119
2138
  }
2120
2139
  for (let i2 = 0; i2 < difference; i2++) {
2121
- this.g[i2] = compute(
2122
- this.c[i2] = new Owner(),
2123
- () => this.O(i2 + from),
2140
+ this.i[i2] = compute(
2141
+ this.d[i2] = new Owner(),
2142
+ () => this.P(i2 + from),
2124
2143
  null
2125
2144
  );
2126
2145
  }
2127
2146
  }
2128
2147
  for (let i = prevTo; i < to; i++) {
2129
- this.g[i - from] = compute(
2130
- this.c[i - from] = new Owner(),
2131
- () => this.O(i),
2148
+ this.i[i - from] = compute(
2149
+ this.d[i - from] = new Owner(),
2150
+ () => this.P(i),
2132
2151
  null
2133
2152
  );
2134
2153
  }
2135
- this.g = this.g.slice(0, newLen);
2154
+ this.i = this.i.slice(0, newLen);
2136
2155
  this.y = from;
2137
- this.p = newLen;
2156
+ this.o = newLen;
2138
2157
  });
2139
- return this.g;
2158
+ return this.i;
2140
2159
  }
2141
2160
  function compare(key, a, b) {
2142
2161
  return key ? key(a) === key(b) : true;
@@ -2154,14 +2173,14 @@ var BoundaryComputation = class extends EagerComputation {
2154
2173
  if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT)) {
2155
2174
  flags &= ~LOADING_BIT;
2156
2175
  }
2157
- this.l.notify(this, this.U, flags);
2158
- return this.i;
2176
+ this.k.notify(this, this.U, flags);
2177
+ return this.j;
2159
2178
  }
2160
2179
  };
2161
2180
  function createBoundChildren(owner, fn, queue, mask) {
2162
- const parentQueue = owner.l;
2163
- parentQueue.addChild(owner.l = queue);
2164
- onCleanup(() => parentQueue.removeChild(owner.l));
2181
+ const parentQueue = owner.k;
2182
+ parentQueue.addChild(owner.k = queue);
2183
+ onCleanup(() => parentQueue.removeChild(owner.k));
2165
2184
  return compute(
2166
2185
  owner,
2167
2186
  () => {
@@ -2172,27 +2191,27 @@ function createBoundChildren(owner, fn, queue, mask) {
2172
2191
  );
2173
2192
  }
2174
2193
  var ConditionalQueue = class extends Queue {
2175
- u;
2194
+ t;
2176
2195
  V = /* @__PURE__ */ new Set();
2177
- t = /* @__PURE__ */ new Set();
2196
+ s = /* @__PURE__ */ new Set();
2178
2197
  constructor(disabled) {
2179
2198
  super();
2180
- this.u = disabled;
2199
+ this.t = disabled;
2181
2200
  }
2182
2201
  run(type) {
2183
- if (!type || this.u.read())
2202
+ if (!type || this.t.read())
2184
2203
  return;
2185
2204
  return super.run(type);
2186
2205
  }
2187
2206
  notify(node, type, flags) {
2188
- if (ActiveTransition && ActiveTransition.w.has(this))
2189
- return ActiveTransition.w.get(this).notify(node, type, flags);
2190
- if (this.u.read()) {
2207
+ if (ActiveTransition && ActiveTransition.u.has(this))
2208
+ return ActiveTransition.u.get(this).notify(node, type, flags);
2209
+ if (this.t.read()) {
2191
2210
  if (type & LOADING_BIT) {
2192
2211
  if (flags & LOADING_BIT) {
2193
- this.t.add(node);
2212
+ this.s.add(node);
2194
2213
  type &= ~LOADING_BIT;
2195
- } else if (this.t.delete(node))
2214
+ } else if (this.s.delete(node))
2196
2215
  type &= ~LOADING_BIT;
2197
2216
  }
2198
2217
  if (type & ERROR_BIT) {
@@ -2206,43 +2225,43 @@ var ConditionalQueue = class extends Queue {
2206
2225
  return type ? super.notify(node, type, flags) : true;
2207
2226
  }
2208
2227
  merge(queue) {
2209
- queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2228
+ queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2210
2229
  queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2211
2230
  super.merge(queue);
2212
2231
  }
2213
2232
  };
2214
2233
  var CollectionQueue = class extends Queue {
2215
2234
  F;
2216
- c = /* @__PURE__ */ new Set();
2217
- u = new Computation(false, null, { pureWrite: true });
2235
+ d = /* @__PURE__ */ new Set();
2236
+ t = new Computation(false, null, { pureWrite: true });
2218
2237
  constructor(type) {
2219
2238
  super();
2220
2239
  this.F = type;
2221
2240
  }
2222
2241
  run(type) {
2223
- if (!type || this.u.read())
2242
+ if (!type || this.t.read())
2224
2243
  return;
2225
2244
  return super.run(type);
2226
2245
  }
2227
2246
  notify(node, type, flags) {
2228
- if (ActiveTransition && ActiveTransition.w.has(this))
2229
- return ActiveTransition.w.get(this).notify(node, type, flags);
2247
+ if (ActiveTransition && ActiveTransition.u.has(this))
2248
+ return ActiveTransition.u.get(this).notify(node, type, flags);
2230
2249
  if (!(type & this.F))
2231
2250
  return super.notify(node, type, flags);
2232
2251
  if (flags & this.F) {
2233
- this.c.add(node);
2234
- if (this.c.size === 1)
2235
- this.u.write(true);
2252
+ this.d.add(node);
2253
+ if (this.d.size === 1)
2254
+ this.t.write(true);
2236
2255
  } else {
2237
- this.c.delete(node);
2238
- if (this.c.size === 0)
2239
- this.u.write(false);
2256
+ this.d.delete(node);
2257
+ if (this.d.size === 0)
2258
+ this.t.write(false);
2240
2259
  }
2241
2260
  type &= ~this.F;
2242
2261
  return type ? super.notify(node, type, flags) : true;
2243
2262
  }
2244
2263
  merge(queue) {
2245
- queue.c.forEach((n) => this.notify(n, this.F, this.F));
2264
+ queue.d.forEach((n) => this.notify(n, this.F, this.F));
2246
2265
  super.merge(queue);
2247
2266
  }
2248
2267
  };
@@ -2253,25 +2272,25 @@ function createBoundary(fn, condition) {
2253
2272
  );
2254
2273
  const tree = createBoundChildren(owner, fn, queue, 0);
2255
2274
  new EagerComputation(void 0, () => {
2256
- const disabled = queue.u.read();
2275
+ const disabled = queue.t.read();
2257
2276
  tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
2258
2277
  if (!disabled) {
2259
- queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2278
+ queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2260
2279
  queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2261
- queue.t.clear();
2280
+ queue.s.clear();
2262
2281
  queue.V.clear();
2263
2282
  }
2264
2283
  });
2265
- return () => queue.u.read() ? void 0 : tree.read();
2284
+ return () => queue.t.read() ? void 0 : tree.read();
2266
2285
  }
2267
2286
  function createCollectionBoundary(type, fn, fallback) {
2268
2287
  const owner = new Owner();
2269
2288
  const queue = new CollectionQueue(type);
2270
2289
  const tree = createBoundChildren(owner, fn, queue, type);
2271
2290
  const decision = new Computation(void 0, () => {
2272
- if (!queue.u.read()) {
2291
+ if (!queue.t.read()) {
2273
2292
  const resolved = tree.read();
2274
- if (!queue.u.read())
2293
+ if (!queue.t.read())
2275
2294
  return resolved;
2276
2295
  }
2277
2296
  return fallback(queue);
@@ -2283,14 +2302,16 @@ function createSuspense(fn, fallback) {
2283
2302
  }
2284
2303
  function createErrorBoundary(fn, fallback) {
2285
2304
  return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2286
- let node = queue.c.values().next().value;
2305
+ let node = queue.d.values().next().value;
2287
2306
  ActiveTransition && ActiveTransition.a.has(node) && (node = ActiveTransition.a.get(node));
2288
- return fallback(node.R, () => {
2307
+ return fallback(node.K, () => {
2289
2308
  var _a;
2290
2309
  incrementClock();
2291
- for (let node2 of queue.c) {
2292
- node2.b = STATE_DIRTY;
2293
- (_a = node2.l) == null ? void 0 : _a.enqueue(node2.A, node2.C.bind(node2));
2310
+ for (let node2 of queue.d) {
2311
+ if (ActiveTransition && !node2.g)
2312
+ node2 = cloneGraph(node2);
2313
+ node2.c = STATE_DIRTY;
2314
+ (_a = node2.k) == null ? void 0 : _a.enqueue(node2.A, node2.C.bind(node2));
2294
2315
  }
2295
2316
  });
2296
2317
  });