@clicktap/state 0.13.16 → 0.13.18

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { jsx as Ge } from "react/jsx-runtime";
2
- import { createContext as ze, useContext as Je, useState as Rt, useEffect as Mt, cloneElement as _n } from "react";
1
+ import { jsx as Ye } from "react/jsx-runtime";
2
+ import { createContext as Xe, useContext as Qe, useState as Lt, useEffect as Ut, cloneElement as _n } from "react";
3
3
  function In(e, t) {
4
4
  for (var n = 0; n < t.length; n++) {
5
5
  const s = t[n];
@@ -37,7 +37,7 @@ const xn = (e) => {
37
37
  const t = An();
38
38
  t && t.register(e);
39
39
  };
40
- class at {
40
+ class lt {
41
41
  constructor(t) {
42
42
  this._process = t, this._active = !1, this._current = null, this._last = null;
43
43
  }
@@ -66,13 +66,13 @@ class at {
66
66
  this._last = null;
67
67
  }
68
68
  }
69
- const Lt = ".", wn = "", qt = "", bn = "#", On = "*", Pt = "xstate.init", Nn = "xstate.error", ae = "xstate.stop";
69
+ const Pt = ".", wn = "", Ft = "", bn = "#", On = "*", Bt = "xstate.init", Nn = "xstate.error", ue = "xstate.stop";
70
70
  function kn(e, t) {
71
71
  return {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
74
74
  }
75
- function Pe(e, t) {
75
+ function Be(e, t) {
76
76
  return {
77
77
  type: `xstate.done.state.${e}`,
78
78
  output: t
@@ -84,25 +84,25 @@ function Cn(e, t) {
84
84
  output: t
85
85
  };
86
86
  }
87
- function Ft(e, t) {
87
+ function jt(e, t) {
88
88
  return {
89
89
  type: `xstate.error.actor.${e}`,
90
90
  error: t
91
91
  };
92
92
  }
93
- function Ut(e) {
93
+ function $t(e) {
94
94
  return {
95
- type: Pt,
95
+ type: Bt,
96
96
  input: e
97
97
  };
98
98
  }
99
- function P(e) {
99
+ function F(e) {
100
100
  setTimeout(() => {
101
101
  throw e;
102
102
  });
103
103
  }
104
104
  const Dn = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")();
105
- function ct(e, t) {
105
+ function ht(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
108
  let Rn = 0;
@@ -119,15 +119,15 @@ function Mn(e, t) {
119
119
  delay: v,
120
120
  id: S,
121
121
  startedAt: Date.now()
122
- }, C = ct(f, S);
123
- d._snapshot._scheduledEvents[C] = x;
124
- const R = a.setTimeout(() => {
125
- delete o[C], delete d._snapshot._scheduledEvents[C], d._relay(f, m, y);
122
+ }, R = ht(f, S);
123
+ d._snapshot._scheduledEvents[R] = x;
124
+ const k = a.setTimeout(() => {
125
+ delete o[R], delete d._snapshot._scheduledEvents[R], d._relay(f, m, y);
126
126
  }, v);
127
- o[C] = R;
127
+ o[R] = k;
128
128
  },
129
129
  cancel: (f, m) => {
130
- const y = ct(f, m), v = o[y];
130
+ const y = ht(f, m), v = o[y];
131
131
  delete o[y], delete d._snapshot._scheduledEvents[y], a.clearTimeout(v);
132
132
  },
133
133
  cancelAll: (f) => {
@@ -192,9 +192,9 @@ function Mn(e, t) {
192
192
  target: v,
193
193
  event: S,
194
194
  delay: x,
195
- id: C
195
+ id: R
196
196
  } = f[m];
197
- u.schedule(y, v, S, x, C);
197
+ u.schedule(y, v, S, x, R);
198
198
  }
199
199
  },
200
200
  _clock: a,
@@ -202,12 +202,12 @@ function Mn(e, t) {
202
202
  };
203
203
  return d;
204
204
  }
205
- function Bt(e, t) {
206
- const n = ut(e), s = ut(t);
207
- return typeof s == "string" ? typeof n == "string" ? s === n : !1 : typeof n == "string" ? n in s : Object.keys(n).every((r) => r in s ? Bt(n[r], s[r]) : !1);
205
+ function Vt(e, t) {
206
+ const n = ft(e), s = ft(t);
207
+ return typeof s == "string" ? typeof n == "string" ? s === n : !1 : typeof n == "string" ? n in s : Object.keys(n).every((r) => r in s ? Vt(n[r], s[r]) : !1);
208
208
  }
209
- function Ye(e) {
210
- if ($t(e))
209
+ function We(e) {
210
+ if (Gt(e))
211
211
  return e;
212
212
  let t = [], n = "";
213
213
  for (let s = 0; s < e.length; s++) {
@@ -223,15 +223,15 @@ function Ye(e) {
223
223
  }
224
224
  return t.push(n), t;
225
225
  }
226
- function ut(e) {
226
+ function ft(e) {
227
227
  if (ls(e))
228
228
  return e.value;
229
229
  if (typeof e != "string")
230
230
  return e;
231
- const t = Ye(e);
232
- return Ln(t);
231
+ const t = We(e);
232
+ return qn(t);
233
233
  }
234
- function Ln(e) {
234
+ function qn(e) {
235
235
  if (e.length === 1)
236
236
  return e[0];
237
237
  const t = {};
@@ -245,7 +245,7 @@ function Ln(e) {
245
245
  }
246
246
  return t;
247
247
  }
248
- function dt(e, t) {
248
+ function pt(e, t) {
249
249
  const n = {}, s = Object.keys(e);
250
250
  for (let r = 0; r < s.length; r++) {
251
251
  const i = s[r];
@@ -253,35 +253,35 @@ function dt(e, t) {
253
253
  }
254
254
  return n;
255
255
  }
256
- function jt(e) {
257
- return $t(e) ? e : [e];
256
+ function Ht(e) {
257
+ return Gt(e) ? e : [e];
258
258
  }
259
- function F(e) {
260
- return e === void 0 ? [] : jt(e);
259
+ function B(e) {
260
+ return e === void 0 ? [] : Ht(e);
261
261
  }
262
- function Fe(e, t, n, s) {
262
+ function je(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
264
264
  context: t,
265
265
  event: n,
266
266
  self: s
267
267
  }) : e;
268
268
  }
269
- function $t(e) {
269
+ function Gt(e) {
270
270
  return Array.isArray(e);
271
271
  }
272
- function qn(e) {
272
+ function Ln(e) {
273
273
  return e.type.startsWith("xstate.error.actor");
274
274
  }
275
- function X(e) {
276
- return jt(e).map((t) => typeof t > "u" || typeof t == "string" ? {
275
+ function K(e) {
276
+ return Ht(e).map((t) => typeof t > "u" || typeof t == "string" ? {
277
277
  target: t
278
278
  } : t);
279
279
  }
280
- function Vt(e) {
280
+ function zt(e) {
281
281
  if (!(e === void 0 || e === wn))
282
- return F(e);
282
+ return B(e);
283
283
  }
284
- function lt(e, t, n) {
284
+ function yt(e, t, n) {
285
285
  var i, o, a;
286
286
  const s = typeof e == "object", r = s ? e : void 0;
287
287
  return {
@@ -290,21 +290,21 @@ function lt(e, t, n) {
290
290
  complete: (a = s ? e.complete : n) == null ? void 0 : a.bind(r)
291
291
  };
292
292
  }
293
- function ht(e, t) {
293
+ function mt(e, t) {
294
294
  return `${t}.${e}`;
295
295
  }
296
- function Xe(e, t) {
296
+ function Ke(e, t) {
297
297
  const n = t.match(/^xstate\.invoke\.(\d+)\.(.*)/);
298
298
  if (!n)
299
299
  return e.implementations.actors[t];
300
300
  const [, s, r] = n, o = e.getStateNodeById(r).config.invoke;
301
301
  return (Array.isArray(o) ? o[s] : o).src;
302
302
  }
303
- const Qe = 1;
304
- let k = /* @__PURE__ */ function(e) {
303
+ const Ze = 1;
304
+ let C = /* @__PURE__ */ function(e) {
305
305
  return e[e.NotStarted = 0] = "NotStarted", e[e.Running = 1] = "Running", e[e.Stopped = 2] = "Stopped", e;
306
306
  }({});
307
- const Pn = {
307
+ const Un = {
308
308
  clock: {
309
309
  setTimeout: (e, t) => setTimeout(e, t),
310
310
  clearTimeout: (e) => clearTimeout(e)
@@ -312,7 +312,7 @@ const Pn = {
312
312
  logger: console.log.bind(console),
313
313
  devTools: !1
314
314
  };
315
- class Fn {
315
+ class Pn {
316
316
  /**
317
317
  * Creates a new actor instance for the given logic with the provided options, if any.
318
318
  *
@@ -320,9 +320,9 @@ class Fn {
320
320
  * @param options Actor options
321
321
  */
322
322
  constructor(t, n) {
323
- this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new at(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = k.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
323
+ this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new lt(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = C.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
324
324
  const s = {
325
- ...Pn,
325
+ ...Un,
326
326
  ...n
327
327
  }, {
328
328
  clock: r,
@@ -336,7 +336,7 @@ class Fn {
336
336
  this.system = o ? o.system : Mn(this, {
337
337
  clock: r,
338
338
  logger: i
339
- }), h && !o && this.system.inspect(lt(h)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
339
+ }), h && !o && this.system.inspect(yt(h)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = (n == null ? void 0 : n.logger) ?? this.system._logger, this.clock = (n == null ? void 0 : n.clock) ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = s, this.src = s.src ?? t, this.ref = this, this._actorScope = {
340
340
  self: this,
341
341
  id: this.id,
342
342
  sessionId: this.sessionId,
@@ -393,7 +393,7 @@ class Fn {
393
393
  try {
394
394
  (r = o.next) == null || r.call(o, t);
395
395
  } catch (a) {
396
- P(a);
396
+ F(a);
397
397
  }
398
398
  break;
399
399
  case "done":
@@ -401,7 +401,7 @@ class Fn {
401
401
  try {
402
402
  (i = o.next) == null || i.call(o, t);
403
403
  } catch (a) {
404
- P(a);
404
+ F(a);
405
405
  }
406
406
  this._stopProcedure(), this._complete(), this._doneEvent = Cn(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
407
407
  break;
@@ -466,8 +466,8 @@ class Fn {
466
466
  */
467
467
  subscribe(t, n, s) {
468
468
  var i;
469
- const r = lt(t, n, s);
470
- if (this._processingStatus !== k.Stopped)
469
+ const r = yt(t, n, s);
470
+ if (this._processingStatus !== C.Stopped)
471
471
  this.observers.add(r);
472
472
  else
473
473
  switch (this._snapshot.status) {
@@ -475,18 +475,18 @@ class Fn {
475
475
  try {
476
476
  (i = r.complete) == null || i.call(r);
477
477
  } catch (o) {
478
- P(o);
478
+ F(o);
479
479
  }
480
480
  break;
481
481
  case "error": {
482
482
  const o = this._snapshot.error;
483
483
  if (!r.error)
484
- P(o);
484
+ F(o);
485
485
  else
486
486
  try {
487
487
  r.error(o);
488
488
  } catch (a) {
489
- P(a);
489
+ F(a);
490
490
  }
491
491
  break;
492
492
  }
@@ -511,7 +511,7 @@ class Fn {
511
511
  * Starts the Actor from the initial state
512
512
  */
513
513
  start() {
514
- if (this._processingStatus === k.Running)
514
+ if (this._processingStatus === C.Running)
515
515
  return this;
516
516
  this._syncSnapshot && this.subscribe({
517
517
  next: (s) => {
@@ -522,8 +522,8 @@ class Fn {
522
522
  },
523
523
  error: () => {
524
524
  }
525
- }), this.system._register(this.sessionId, this), this._systemId && this.system._set(this._systemId, this), this._processingStatus = k.Running;
526
- const t = Ut(this.options.input);
525
+ }), this.system._register(this.sessionId, this), this._systemId && this.system._set(this._systemId, this), this._processingStatus = C.Running;
526
+ const t = $t(this.options.input);
527
527
  switch (this.system._sendInspectionEvent({
528
528
  type: "@xstate.event",
529
529
  sourceRef: this._parent,
@@ -567,11 +567,11 @@ class Fn {
567
567
  }, this._error(r);
568
568
  return;
569
569
  }
570
- this.update(n, t), t.type === ae && (this._stopProcedure(), this._complete());
570
+ this.update(n, t), t.type === ue && (this._stopProcedure(), this._complete());
571
571
  }
572
572
  _stop() {
573
- return this._processingStatus === k.Stopped ? this : (this.mailbox.clear(), this._processingStatus === k.NotStarted ? (this._processingStatus = k.Stopped, this) : (this.mailbox.enqueue({
574
- type: ae
573
+ return this._processingStatus === C.Stopped ? this : (this.mailbox.clear(), this._processingStatus === C.NotStarted ? (this._processingStatus = C.Stopped, this) : (this.mailbox.enqueue({
574
+ type: ue
575
575
  }), this));
576
576
  }
577
577
  /**
@@ -588,13 +588,13 @@ class Fn {
588
588
  try {
589
589
  (t = n.complete) == null || t.call(n);
590
590
  } catch (s) {
591
- P(s);
591
+ F(s);
592
592
  }
593
593
  this.observers.clear();
594
594
  }
595
595
  _reportError(t) {
596
596
  if (!this.observers.size) {
597
- this._parent || P(t);
597
+ this._parent || F(t);
598
598
  return;
599
599
  }
600
600
  let n = !1;
@@ -604,13 +604,13 @@ class Fn {
604
604
  try {
605
605
  r == null || r(t);
606
606
  } catch (i) {
607
- P(i);
607
+ F(i);
608
608
  }
609
609
  }
610
- this.observers.clear(), n && P(t);
610
+ this.observers.clear(), n && F(t);
611
611
  }
612
612
  _error(t) {
613
- this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, Ft(this.id, t));
613
+ this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, jt(this.id, t));
614
614
  }
615
615
  // TODO: atm children don't belong entirely to the actor so
616
616
  // in a way - it's not even super aware of them
@@ -618,13 +618,13 @@ class Fn {
618
618
  // right now, they are being stopped within the machine's transition
619
619
  // but that could throw and leave us with "orphaned" active actors
620
620
  _stopProcedure() {
621
- return this._processingStatus !== k.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new at(this._process.bind(this)), this._processingStatus = k.Stopped, this.system._unregister(this), this);
621
+ return this._processingStatus !== C.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new lt(this._process.bind(this)), this._processingStatus = C.Stopped, this.system._unregister(this), this);
622
622
  }
623
623
  /**
624
624
  * @internal
625
625
  */
626
626
  _send(t) {
627
- this._processingStatus !== k.Stopped && this.mailbox.enqueue(t);
627
+ this._processingStatus !== C.Stopped && this.mailbox.enqueue(t);
628
628
  }
629
629
  /**
630
630
  * Sends an event to the running Actor to trigger a transition.
@@ -642,7 +642,7 @@ class Fn {
642
642
  }
643
643
  toJSON() {
644
644
  return {
645
- xstate$$type: Qe,
645
+ xstate$$type: Ze,
646
646
  id: this.id
647
647
  };
648
648
  }
@@ -682,10 +682,10 @@ class Fn {
682
682
  return this._snapshot;
683
683
  }
684
684
  }
685
- function U(e, ...[t]) {
686
- return new Fn(e, t);
685
+ function j(e, ...[t]) {
686
+ return new Pn(e, t);
687
687
  }
688
- function Un(e, t, n, s, {
688
+ function Fn(e, t, n, s, {
689
689
  sendId: r
690
690
  }) {
691
691
  const i = typeof r == "function" ? r(n, s) : r;
@@ -699,7 +699,7 @@ function Bn(e, t) {
699
699
  function jn(e) {
700
700
  function t(n, s) {
701
701
  }
702
- return t.type = "xstate.cancel", t.sendId = e, t.resolve = Un, t.execute = Bn, t;
702
+ return t.type = "xstate.cancel", t.sendId = e, t.resolve = Fn, t.execute = Bn, t;
703
703
  }
704
704
  function $n(e, t, n, s, {
705
705
  id: r,
@@ -708,9 +708,9 @@ function $n(e, t, n, s, {
708
708
  input: a,
709
709
  syncSnapshot: c
710
710
  }) {
711
- const u = typeof o == "string" ? Xe(t.machine, o) : o, h = typeof r == "function" ? r(n) : r;
711
+ const u = typeof o == "string" ? Ke(t.machine, o) : o, h = typeof r == "function" ? r(n) : r;
712
712
  let d;
713
- return u && (d = U(u, {
713
+ return u && (d = j(u, {
714
714
  id: h,
715
715
  src: o,
716
716
  parent: e.self,
@@ -721,7 +721,7 @@ function $n(e, t, n, s, {
721
721
  event: n.event,
722
722
  self: e.self
723
723
  }) : a
724
- })), [H(t, {
724
+ })), [Y(t, {
725
725
  children: {
726
726
  ...t.children,
727
727
  [h]: d
@@ -736,7 +736,7 @@ function Vn(e, {
736
736
  actorRef: n
737
737
  }) {
738
738
  n && e.defer(() => {
739
- n._processingStatus !== k.Stopped && n.start();
739
+ n._processingStatus !== C.Stopped && n.start();
740
740
  });
741
741
  }
742
742
  function Hn(...[e, {
@@ -756,13 +756,13 @@ function Gn(e, t, n, s, {
756
756
  let a = t.children;
757
757
  return o && (a = {
758
758
  ...a
759
- }, delete a[o.id]), [H(t, {
759
+ }, delete a[o.id]), [Y(t, {
760
760
  children: a
761
761
  }), o];
762
762
  }
763
763
  function zn(e, t) {
764
764
  if (t) {
765
- if (e.system._unregister(t), t._processingStatus !== k.Running) {
765
+ if (e.system._unregister(t), t._processingStatus !== C.Running) {
766
766
  e.stopChild(t);
767
767
  return;
768
768
  }
@@ -771,19 +771,19 @@ function zn(e, t) {
771
771
  });
772
772
  }
773
773
  }
774
- function Ht(e) {
774
+ function Jt(e) {
775
775
  function t(n, s) {
776
776
  }
777
777
  return t.type = "xstate.stopChild", t.actorRef = e, t.resolve = Gn, t.execute = zn, t;
778
778
  }
779
- function We(e, t, n, s) {
779
+ function et(e, t, n, s) {
780
780
  const {
781
781
  machine: r
782
782
  } = s, i = typeof e == "function", o = i ? e : r.implementations.guards[typeof e == "string" ? e : e.type];
783
783
  if (!i && !o)
784
784
  throw new Error(`Guard '${typeof e == "string" ? e : e.type}' is not implemented.'.`);
785
785
  if (typeof o != "function")
786
- return We(o, t, n, s);
786
+ return et(o, t, n, s);
787
787
  const a = {
788
788
  context: t,
789
789
  event: n
@@ -798,11 +798,11 @@ function We(e, t, n, s) {
798
798
  // this holds all params
799
799
  ) : o(a, c);
800
800
  }
801
- const Ke = (e) => e.type === "atomic" || e.type === "final";
802
- function Z(e) {
801
+ const tt = (e) => e.type === "atomic" || e.type === "final";
802
+ function te(e) {
803
803
  return Object.values(e.states).filter((t) => t.type !== "history");
804
804
  }
805
- function ue(e, t) {
805
+ function le(e, t) {
806
806
  const n = [];
807
807
  if (t === e)
808
808
  return n;
@@ -811,15 +811,15 @@ function ue(e, t) {
811
811
  n.push(s), s = s.parent;
812
812
  return n;
813
813
  }
814
- function ve(e) {
815
- const t = new Set(e), n = zt(t);
814
+ function _e(e) {
815
+ const t = new Set(e), n = Xt(t);
816
816
  for (const s of t)
817
817
  if (s.type === "compound" && (!n.get(s) || !n.get(s).length))
818
- ft(s).forEach((r) => t.add(r));
818
+ gt(s).forEach((r) => t.add(r));
819
819
  else if (s.type === "parallel") {
820
- for (const r of Z(s))
820
+ for (const r of te(s))
821
821
  if (r.type !== "history" && !t.has(r)) {
822
- const i = ft(r);
822
+ const i = gt(r);
823
823
  for (const o of i)
824
824
  t.add(o);
825
825
  }
@@ -831,37 +831,37 @@ function ve(e) {
831
831
  }
832
832
  return t;
833
833
  }
834
- function Gt(e, t) {
834
+ function Yt(e, t) {
835
835
  const n = t.get(e);
836
836
  if (!n)
837
837
  return {};
838
838
  if (e.type === "compound") {
839
839
  const r = n[0];
840
840
  if (r) {
841
- if (Ke(r))
841
+ if (tt(r))
842
842
  return r.key;
843
843
  } else
844
844
  return {};
845
845
  }
846
846
  const s = {};
847
847
  for (const r of n)
848
- s[r.key] = Gt(r, t);
848
+ s[r.key] = Yt(r, t);
849
849
  return s;
850
850
  }
851
- function zt(e) {
851
+ function Xt(e) {
852
852
  const t = /* @__PURE__ */ new Map();
853
853
  for (const n of e)
854
854
  t.has(n) || t.set(n, []), n.parent && (t.has(n.parent) || t.set(n.parent, []), t.get(n.parent).push(n));
855
855
  return t;
856
856
  }
857
- function Jt(e, t) {
858
- const n = ve(t);
859
- return Gt(e, zt(n));
857
+ function Qt(e, t) {
858
+ const n = _e(t);
859
+ return Yt(e, Xt(n));
860
860
  }
861
- function Ze(e, t) {
862
- return t.type === "compound" ? Z(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? Z(t).every((n) => Ze(e, n)) : t.type === "final";
861
+ function nt(e, t) {
862
+ return t.type === "compound" ? te(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? te(t).every((n) => nt(e, n)) : t.type === "final";
863
863
  }
864
- const Se = (e) => e[0] === bn;
864
+ const xe = (e) => e[0] === bn;
865
865
  function Jn(e, t) {
866
866
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
867
867
  if (s === On)
@@ -894,7 +894,7 @@ function Yn(e) {
894
894
  const o = t[r], a = typeof o == "string" ? {
895
895
  target: o
896
896
  } : o, c = Number.isNaN(+r) ? r : +r, u = n(c);
897
- return F(a).map((h) => ({
897
+ return B(a).map((h) => ({
898
898
  ...h,
899
899
  event: u,
900
900
  delay: c
@@ -904,15 +904,15 @@ function Yn(e) {
904
904
  delay: i
905
905
  } = r;
906
906
  return {
907
- ...$(e, r.event, r),
907
+ ...G(e, r.event, r),
908
908
  delay: i
909
909
  };
910
910
  });
911
911
  }
912
- function $(e, t, n) {
913
- const s = Vt(n.target), r = n.reenter ?? !1, i = Wn(e, s), o = {
912
+ function G(e, t, n) {
913
+ const s = zt(n.target), r = n.reenter ?? !1, i = Wn(e, s), o = {
914
914
  ...n,
915
- actions: F(n.actions),
915
+ actions: B(n.actions),
916
916
  guard: n.guard,
917
917
  target: i,
918
918
  source: e,
@@ -930,27 +930,27 @@ function Xn(e) {
930
930
  const t = /* @__PURE__ */ new Map();
931
931
  if (e.config.on)
932
932
  for (const n of Object.keys(e.config.on)) {
933
- if (n === qt)
933
+ if (n === Ft)
934
934
  throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
935
935
  const s = e.config.on[n];
936
- t.set(n, X(s).map((r) => $(e, n, r)));
936
+ t.set(n, K(s).map((r) => G(e, n, r)));
937
937
  }
938
938
  if (e.config.onDone) {
939
939
  const n = `xstate.done.state.${e.id}`;
940
- t.set(n, X(e.config.onDone).map((s) => $(e, n, s)));
940
+ t.set(n, K(e.config.onDone).map((s) => G(e, n, s)));
941
941
  }
942
942
  for (const n of e.invoke) {
943
943
  if (n.onDone) {
944
944
  const s = `xstate.done.actor.${n.id}`;
945
- t.set(s, X(n.onDone).map((r) => $(e, s, r)));
945
+ t.set(s, K(n.onDone).map((r) => G(e, s, r)));
946
946
  }
947
947
  if (n.onError) {
948
948
  const s = `xstate.error.actor.${n.id}`;
949
- t.set(s, X(n.onError).map((r) => $(e, s, r)));
949
+ t.set(s, K(n.onError).map((r) => G(e, s, r)));
950
950
  }
951
951
  if (n.onSnapshot) {
952
952
  const s = `xstate.snapshot.${n.id}`;
953
- t.set(s, X(n.onSnapshot).map((r) => $(e, s, r)));
953
+ t.set(s, K(n.onSnapshot).map((r) => G(e, s, r)));
954
954
  }
955
955
  }
956
956
  for (const n of e.after) {
@@ -965,7 +965,7 @@ function Qn(e, t) {
965
965
  throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);
966
966
  const s = {
967
967
  source: e,
968
- actions: !t || typeof t == "string" ? [] : F(t.actions),
968
+ actions: !t || typeof t == "string" ? [] : B(t.actions),
969
969
  eventType: null,
970
970
  reenter: !1,
971
971
  target: n ? [n] : [],
@@ -982,15 +982,15 @@ function Wn(e, t) {
982
982
  return t.map((n) => {
983
983
  if (typeof n != "string")
984
984
  return n;
985
- if (Se(n))
985
+ if (xe(n))
986
986
  return e.machine.getStateNodeById(n);
987
- const s = n[0] === Lt;
987
+ const s = n[0] === Pt;
988
988
  if (s && !e.parent)
989
- return Te(e, n.slice(1));
989
+ return Ie(e, n.slice(1));
990
990
  const r = s ? e.key + n : n;
991
991
  if (e.parent)
992
992
  try {
993
- return Te(e.parent, r);
993
+ return Ie(e.parent, r);
994
994
  } catch (i) {
995
995
  throw new Error(`Invalid transition definition for state node '${e.id}':
996
996
  ${i.message}`);
@@ -999,37 +999,37 @@ ${i.message}`);
999
999
  throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`);
1000
1000
  });
1001
1001
  }
1002
- function Yt(e) {
1003
- const t = Vt(e.config.target);
1002
+ function Wt(e) {
1003
+ const t = zt(e.config.target);
1004
1004
  return t ? {
1005
- target: t.map((n) => typeof n == "string" ? Te(e.parent, n) : n)
1005
+ target: t.map((n) => typeof n == "string" ? Ie(e.parent, n) : n)
1006
1006
  } : e.parent.initial;
1007
1007
  }
1008
- function V(e) {
1008
+ function z(e) {
1009
1009
  return e.type === "history";
1010
1010
  }
1011
- function ft(e) {
1012
- const t = Xt(e);
1011
+ function gt(e) {
1012
+ const t = Kt(e);
1013
1013
  for (const n of t)
1014
- for (const s of ue(n, e))
1014
+ for (const s of le(n, e))
1015
1015
  t.add(s);
1016
1016
  return t;
1017
1017
  }
1018
- function Xt(e) {
1018
+ function Kt(e) {
1019
1019
  const t = /* @__PURE__ */ new Set();
1020
1020
  function n(s) {
1021
1021
  if (!t.has(s)) {
1022
1022
  if (t.add(s), s.type === "compound")
1023
1023
  n(s.initial.target[0]);
1024
1024
  else if (s.type === "parallel")
1025
- for (const r of Z(s))
1025
+ for (const r of te(s))
1026
1026
  n(r);
1027
1027
  }
1028
1028
  }
1029
1029
  return n(e), t;
1030
1030
  }
1031
- function ee(e, t) {
1032
- if (Se(t))
1031
+ function ne(e, t) {
1032
+ if (xe(t))
1033
1033
  return e.machine.getStateNodeById(t);
1034
1034
  if (!e.states)
1035
1035
  throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);
@@ -1038,44 +1038,44 @@ function ee(e, t) {
1038
1038
  throw new Error(`Child state '${t}' does not exist on '${e.id}'`);
1039
1039
  return n;
1040
1040
  }
1041
- function Te(e, t) {
1042
- if (typeof t == "string" && Se(t))
1041
+ function Ie(e, t) {
1042
+ if (typeof t == "string" && xe(t))
1043
1043
  try {
1044
1044
  return e.machine.getStateNodeById(t);
1045
1045
  } catch {
1046
1046
  }
1047
- const n = Ye(t).slice();
1047
+ const n = We(t).slice();
1048
1048
  let s = e;
1049
1049
  for (; n.length; ) {
1050
1050
  const r = n.shift();
1051
1051
  if (!r.length)
1052
1052
  break;
1053
- s = ee(s, r);
1053
+ s = ne(s, r);
1054
1054
  }
1055
1055
  return s;
1056
1056
  }
1057
- function _e(e, t) {
1057
+ function Se(e, t) {
1058
1058
  if (typeof t == "string") {
1059
1059
  const r = e.states[t];
1060
1060
  if (!r)
1061
1061
  throw new Error(`State '${t}' does not exist on '${e.id}'`);
1062
1062
  return [e, r];
1063
1063
  }
1064
- const n = Object.keys(t), s = n.map((r) => ee(e, r)).filter(Boolean);
1064
+ const n = Object.keys(t), s = n.map((r) => ne(e, r)).filter(Boolean);
1065
1065
  return [e.machine.root, e].concat(s, n.reduce((r, i) => {
1066
- const o = ee(e, i);
1066
+ const o = ne(e, i);
1067
1067
  if (!o)
1068
1068
  return r;
1069
- const a = _e(o, t[i]);
1069
+ const a = Se(o, t[i]);
1070
1070
  return r.concat(a);
1071
1071
  }, []));
1072
1072
  }
1073
1073
  function Kn(e, t, n, s) {
1074
- const i = ee(e, t).next(n, s);
1074
+ const i = ne(e, t).next(n, s);
1075
1075
  return !i || !i.length ? e.next(n, s) : i;
1076
1076
  }
1077
1077
  function Zn(e, t, n, s) {
1078
- const r = Object.keys(t), i = ee(e, r[0]), o = et(i, t[r[0]], n, s);
1078
+ const r = Object.keys(t), i = ne(e, r[0]), o = st(i, t[r[0]], n, s);
1079
1079
  return !o || !o.length ? e.next(n, s) : o;
1080
1080
  }
1081
1081
  function es(e, t, n, s) {
@@ -1084,18 +1084,18 @@ function es(e, t, n, s) {
1084
1084
  const o = t[i];
1085
1085
  if (!o)
1086
1086
  continue;
1087
- const a = ee(e, i), c = et(a, o, n, s);
1087
+ const a = ne(e, i), c = st(a, o, n, s);
1088
1088
  c && r.push(...c);
1089
1089
  }
1090
1090
  return r.length ? r : e.next(n, s);
1091
1091
  }
1092
- function et(e, t, n, s) {
1092
+ function st(e, t, n, s) {
1093
1093
  return typeof t == "string" ? Kn(e, t, n, s) : Object.keys(t).length === 1 ? Zn(e, t, n, s) : es(e, t, n, s);
1094
1094
  }
1095
1095
  function ts(e) {
1096
1096
  return Object.keys(e.states).map((t) => e.states[t]).filter((t) => t.type === "history");
1097
1097
  }
1098
- function B(e, t) {
1098
+ function $(e, t) {
1099
1099
  let n = e;
1100
1100
  for (; n.parent && n.parent !== t; )
1101
1101
  n = n.parent;
@@ -1111,14 +1111,14 @@ function ns(e, t) {
1111
1111
  return !0;
1112
1112
  return !1;
1113
1113
  }
1114
- function Qt(e, t, n) {
1114
+ function Zt(e, t, n) {
1115
1115
  const s = /* @__PURE__ */ new Set();
1116
1116
  for (const r of e) {
1117
1117
  let i = !1;
1118
1118
  const o = /* @__PURE__ */ new Set();
1119
1119
  for (const a of s)
1120
- if (ns(Ue([r], t, n), Ue([a], t, n)))
1121
- if (B(r.source, a.source))
1120
+ if (ns($e([r], t, n), $e([a], t, n)))
1121
+ if ($(r.source, a.source))
1122
1122
  o.add(a);
1123
1123
  else {
1124
1124
  i = !0;
@@ -1134,31 +1134,31 @@ function Qt(e, t, n) {
1134
1134
  }
1135
1135
  function ss(e) {
1136
1136
  const [t, ...n] = e;
1137
- for (const s of ue(t, void 0))
1138
- if (n.every((r) => B(r, s)))
1137
+ for (const s of le(t, void 0))
1138
+ if (n.every((r) => $(r, s)))
1139
1139
  return s;
1140
1140
  }
1141
- function tt(e, t) {
1141
+ function rt(e, t) {
1142
1142
  if (!e.target)
1143
1143
  return [];
1144
1144
  const n = /* @__PURE__ */ new Set();
1145
1145
  for (const s of e.target)
1146
- if (V(s))
1146
+ if (z(s))
1147
1147
  if (t[s.id])
1148
1148
  for (const r of t[s.id])
1149
1149
  n.add(r);
1150
1150
  else
1151
- for (const r of tt(Yt(s), t))
1151
+ for (const r of rt(Wt(s), t))
1152
1152
  n.add(r);
1153
1153
  else
1154
1154
  n.add(s);
1155
1155
  return [...n];
1156
1156
  }
1157
- function Wt(e, t) {
1158
- const n = tt(e, t);
1157
+ function en(e, t) {
1158
+ const n = rt(e, t);
1159
1159
  if (!n)
1160
1160
  return;
1161
- if (!e.reenter && n.every((r) => r === e.source || B(r, e.source)))
1161
+ if (!e.reenter && n.every((r) => r === e.source || $(r, e.source)))
1162
1162
  return e.source;
1163
1163
  const s = ss(n.concat(e.source));
1164
1164
  if (s)
@@ -1166,15 +1166,15 @@ function Wt(e, t) {
1166
1166
  if (!e.reenter)
1167
1167
  return e.source.machine.root;
1168
1168
  }
1169
- function Ue(e, t, n) {
1169
+ function $e(e, t, n) {
1170
1170
  var r;
1171
1171
  const s = /* @__PURE__ */ new Set();
1172
1172
  for (const i of e)
1173
1173
  if ((r = i.target) != null && r.length) {
1174
- const o = Wt(i, n);
1174
+ const o = en(i, n);
1175
1175
  i.reenter && i.source === o && s.add(o);
1176
1176
  for (const a of t)
1177
- B(a, o) && s.add(a);
1177
+ $(a, o) && s.add(a);
1178
1178
  }
1179
1179
  return [...s];
1180
1180
  }
@@ -1186,18 +1186,18 @@ function rs(e, t) {
1186
1186
  return !1;
1187
1187
  return !0;
1188
1188
  }
1189
- function Be(e, t, n, s, r, i) {
1189
+ function Ve(e, t, n, s, r, i) {
1190
1190
  if (!e.length)
1191
1191
  return t;
1192
1192
  const o = new Set(t._nodes);
1193
1193
  let a = t.historyValue;
1194
- const c = Qt(e, o, a);
1194
+ const c = Zt(e, o, a);
1195
1195
  let u = t;
1196
- r || ([u, a] = cs(u, s, n, c, o, a, i)), u = te(u, s, n, c.flatMap((d) => d.actions), i), u = os(u, s, n, c, o, i, a, r);
1196
+ r || ([u, a] = cs(u, s, n, c, o, a, i)), u = se(u, s, n, c.flatMap((d) => d.actions), i), u = os(u, s, n, c, o, i, a, r);
1197
1197
  const h = [...o];
1198
- u.status === "done" && (u = te(u, s, n, h.sort((d, f) => f.order - d.order).flatMap((d) => d.exit), i));
1198
+ u.status === "done" && (u = se(u, s, n, h.sort((d, f) => f.order - d.order).flatMap((d) => d.exit), i));
1199
1199
  try {
1200
- return a === t.historyValue && rs(t._nodes, o) ? u : H(u, {
1200
+ return a === t.historyValue && rs(t._nodes, o) ? u : Y(u, {
1201
1201
  _nodes: h,
1202
1202
  historyValue: a
1203
1203
  });
@@ -1208,8 +1208,8 @@ function Be(e, t, n, s, r, i) {
1208
1208
  function is(e, t, n, s, r) {
1209
1209
  if (s.output === void 0)
1210
1210
  return;
1211
- const i = Pe(r.id, r.output !== void 0 && r.parent ? Fe(r.output, e.context, t, n.self) : void 0);
1212
- return Fe(s.output, e.context, i, n.self);
1211
+ const i = Be(r.id, r.output !== void 0 && r.parent ? je(r.output, e.context, t, n.self) : void 0);
1212
+ return je(s.output, e.context, i, n.self);
1213
1213
  }
1214
1214
  function os(e, t, n, s, r, i, o, a) {
1215
1215
  let c = e;
@@ -1229,14 +1229,14 @@ function os(e, t, n, s, r, i, o, a) {
1229
1229
  const y = f.initial.actions;
1230
1230
  m.push(...y);
1231
1231
  }
1232
- if (c = te(c, t, n, m, i, f.invoke.map((y) => y.id)), f.type === "final") {
1232
+ if (c = se(c, t, n, m, i, f.invoke.map((y) => y.id)), f.type === "final") {
1233
1233
  const y = f.parent;
1234
1234
  let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, S = v || f;
1235
- for ((y == null ? void 0 : y.type) === "compound" && i.push(Pe(y.id, f.output !== void 0 ? Fe(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && Ze(r, v); )
1236
- d.add(v), i.push(Pe(v.id)), S = v, v = v.parent;
1235
+ for ((y == null ? void 0 : y.type) === "compound" && i.push(Be(y.id, f.output !== void 0 ? je(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && nt(r, v); )
1236
+ d.add(v), i.push(Be(v.id)), S = v, v = v.parent;
1237
1237
  if (v)
1238
1238
  continue;
1239
- c = H(c, {
1239
+ c = Y(c, {
1240
1240
  status: "done",
1241
1241
  output: is(c, t, n, c.machine.root, S)
1242
1242
  });
@@ -1246,70 +1246,70 @@ function os(e, t, n, s, r, i, o, a) {
1246
1246
  }
1247
1247
  function as(e, t, n, s) {
1248
1248
  for (const r of e) {
1249
- const i = Wt(r, t);
1249
+ const i = en(r, t);
1250
1250
  for (const a of r.target || [])
1251
- !V(a) && // if the target is different than the source then it will *definitely* be entered
1251
+ !z(a) && // if the target is different than the source then it will *definitely* be entered
1252
1252
  (r.source !== a || // we know that the domain can't lie within the source
1253
1253
  // if it's different than the source then it's outside of it and it means that the target has to be entered as well
1254
1254
  r.source !== i || // reentering transitions always enter the target, even if it's the source itself
1255
- r.reenter) && (s.add(a), n.add(a)), Q(a, t, n, s);
1256
- const o = tt(r, t);
1255
+ r.reenter) && (s.add(a), n.add(a)), Z(a, t, n, s);
1256
+ const o = rt(r, t);
1257
1257
  for (const a of o) {
1258
- const c = ue(a, i);
1259
- (i == null ? void 0 : i.type) === "parallel" && c.push(i), Kt(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1258
+ const c = le(a, i);
1259
+ (i == null ? void 0 : i.type) === "parallel" && c.push(i), tn(s, t, n, c, !r.source.parent && r.reenter ? void 0 : i);
1260
1260
  }
1261
1261
  }
1262
1262
  }
1263
- function Q(e, t, n, s) {
1263
+ function Z(e, t, n, s) {
1264
1264
  var r;
1265
- if (V(e))
1265
+ if (z(e))
1266
1266
  if (t[e.id]) {
1267
1267
  const i = t[e.id];
1268
1268
  for (const o of i)
1269
- s.add(o), Q(o, t, n, s);
1269
+ s.add(o), Z(o, t, n, s);
1270
1270
  for (const o of i)
1271
- Ne(o, e.parent, s, t, n);
1271
+ Ce(o, e.parent, s, t, n);
1272
1272
  } else {
1273
- const i = Yt(e);
1273
+ const i = Wt(e);
1274
1274
  for (const o of i.target)
1275
- s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), Q(o, t, n, s);
1275
+ s.add(o), i === ((r = e.parent) == null ? void 0 : r.initial) && n.add(e.parent), Z(o, t, n, s);
1276
1276
  for (const o of i.target)
1277
- Ne(o, e.parent, s, t, n);
1277
+ Ce(o, e.parent, s, t, n);
1278
1278
  }
1279
1279
  else if (e.type === "compound") {
1280
1280
  const [i] = e.initial.target;
1281
- V(i) || (s.add(i), n.add(i)), Q(i, t, n, s), Ne(i, e, s, t, n);
1281
+ z(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Ce(i, e, s, t, n);
1282
1282
  } else if (e.type === "parallel")
1283
- for (const i of Z(e).filter((o) => !V(o)))
1284
- [...s].some((o) => B(o, i)) || (V(i) || (s.add(i), n.add(i)), Q(i, t, n, s));
1283
+ for (const i of te(e).filter((o) => !z(o)))
1284
+ [...s].some((o) => $(o, i)) || (z(i) || (s.add(i), n.add(i)), Z(i, t, n, s));
1285
1285
  }
1286
- function Kt(e, t, n, s, r) {
1286
+ function tn(e, t, n, s, r) {
1287
1287
  for (const i of s)
1288
- if ((!r || B(i, r)) && e.add(i), i.type === "parallel")
1289
- for (const o of Z(i).filter((a) => !V(a)))
1290
- [...e].some((a) => B(a, o)) || (e.add(o), Q(o, t, n, e));
1288
+ if ((!r || $(i, r)) && e.add(i), i.type === "parallel")
1289
+ for (const o of te(i).filter((a) => !z(a)))
1290
+ [...e].some((a) => $(a, o)) || (e.add(o), Z(o, t, n, e));
1291
1291
  }
1292
- function Ne(e, t, n, s, r) {
1293
- Kt(n, s, r, ue(e, t));
1292
+ function Ce(e, t, n, s, r) {
1293
+ tn(n, s, r, le(e, t));
1294
1294
  }
1295
1295
  function cs(e, t, n, s, r, i, o) {
1296
1296
  let a = e;
1297
- const c = Ue(s, r, i);
1297
+ const c = $e(s, r, i);
1298
1298
  c.sort((h, d) => d.order - h.order);
1299
1299
  let u;
1300
1300
  for (const h of c)
1301
1301
  for (const d of ts(h)) {
1302
1302
  let f;
1303
- d.history === "deep" ? f = (m) => Ke(m) && B(m, h) : f = (m) => m.parent === h, u ?? (u = {
1303
+ d.history === "deep" ? f = (m) => tt(m) && $(m, h) : f = (m) => m.parent === h, u ?? (u = {
1304
1304
  ...i
1305
1305
  }), u[d.id] = Array.from(r).filter(f);
1306
1306
  }
1307
1307
  for (const h of c)
1308
- a = te(a, t, n, [...h.exit, ...h.invoke.map((d) => Ht(d.id))], o), r.delete(h);
1308
+ a = se(a, t, n, [...h.exit, ...h.invoke.map((d) => Jt(d.id))], o), r.delete(h);
1309
1309
  return [a, u || i];
1310
1310
  }
1311
- let pt = !1;
1312
- function Zt(e, t, n, s, r, i) {
1311
+ let Et = !1;
1312
+ function nn(e, t, n, s, r, i) {
1313
1313
  const {
1314
1314
  machine: o
1315
1315
  } = e;
@@ -1325,9 +1325,9 @@ function Zt(e, t, n, s, r, i) {
1325
1325
  }
1326
1326
  });
1327
1327
  try {
1328
- pt = h, h(d, f);
1328
+ Et = h, h(d, f);
1329
1329
  } finally {
1330
- pt = !1;
1330
+ Et = !1;
1331
1331
  }
1332
1332
  };
1333
1333
  const u = typeof c == "function", h = u ? c : (
@@ -1348,7 +1348,7 @@ function Zt(e, t, n, s, r, i) {
1348
1348
  event: t
1349
1349
  }) : c.params : void 0;
1350
1350
  if (!("resolve" in h)) {
1351
- n.self._processingStatus === k.Running ? m() : n.defer(() => {
1351
+ n.self._processingStatus === C.Running ? m() : n.defer(() => {
1352
1352
  m();
1353
1353
  });
1354
1354
  continue;
@@ -1362,12 +1362,12 @@ function Zt(e, t, n, s, r, i) {
1362
1362
  // this holds all params
1363
1363
  r
1364
1364
  );
1365
- a = v, "retryResolve" in y && (i == null || i.push([y, S])), "execute" in y && (n.self._processingStatus === k.Running ? y.execute(n, S) : n.defer(y.execute.bind(null, n, S))), x && (a = Zt(a, t, n, x, r, i));
1365
+ a = v, "retryResolve" in y && (i == null || i.push([y, S])), "execute" in y && (n.self._processingStatus === C.Running ? y.execute(n, S) : n.defer(y.execute.bind(null, n, S))), x && (a = nn(a, t, n, x, r, i));
1366
1366
  }
1367
1367
  return a;
1368
1368
  }
1369
- function te(e, t, n, s, r, i) {
1370
- const o = i ? [] : void 0, a = Zt(e, t, n, s, {
1369
+ function se(e, t, n, s, r, i) {
1370
+ const o = i ? [] : void 0, a = nn(e, t, n, s, {
1371
1371
  internalQueue: r,
1372
1372
  deferredActorIds: i
1373
1373
  }, o);
@@ -1375,7 +1375,7 @@ function te(e, t, n, s, r, i) {
1375
1375
  c.retryResolve(n, a, u);
1376
1376
  }), a;
1377
1377
  }
1378
- function ke(e, t, n, s = []) {
1378
+ function De(e, t, n, s = []) {
1379
1379
  let r = e;
1380
1380
  const i = [];
1381
1381
  function o(u, h, d) {
@@ -1387,25 +1387,25 @@ function ke(e, t, n, s = []) {
1387
1387
  _transitions: d
1388
1388
  }), i.push(u);
1389
1389
  }
1390
- if (t.type === ae)
1391
- return r = H(yt(r, t, n), {
1390
+ if (t.type === ue)
1391
+ return r = Y(vt(r, t, n), {
1392
1392
  status: "stopped"
1393
1393
  }), o(r, t, []), {
1394
1394
  snapshot: r,
1395
1395
  microstates: i
1396
1396
  };
1397
1397
  let a = t;
1398
- if (a.type !== Pt) {
1399
- const u = a, h = qn(u), d = mt(u, r);
1398
+ if (a.type !== Bt) {
1399
+ const u = a, h = Ln(u), d = Tt(u, r);
1400
1400
  if (h && !d.length)
1401
- return r = H(e, {
1401
+ return r = Y(e, {
1402
1402
  status: "error",
1403
1403
  error: u.error
1404
1404
  }), o(r, u, []), {
1405
1405
  snapshot: r,
1406
1406
  microstates: i
1407
1407
  };
1408
- r = Be(
1408
+ r = Ve(
1409
1409
  d,
1410
1410
  e,
1411
1411
  n,
@@ -1422,44 +1422,44 @@ function ke(e, t, n, s = []) {
1422
1422
  if (!u.length) {
1423
1423
  if (!s.length)
1424
1424
  break;
1425
- a = s.shift(), u = mt(a, r);
1425
+ a = s.shift(), u = Tt(a, r);
1426
1426
  }
1427
- r = Be(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1427
+ r = Ve(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1428
1428
  }
1429
- return r.status !== "active" && yt(r, a, n), {
1429
+ return r.status !== "active" && vt(r, a, n), {
1430
1430
  snapshot: r,
1431
1431
  microstates: i
1432
1432
  };
1433
1433
  }
1434
- function yt(e, t, n) {
1435
- return te(e, t, n, Object.values(e.children).map((s) => Ht(s)), []);
1434
+ function vt(e, t, n) {
1435
+ return se(e, t, n, Object.values(e.children).map((s) => Jt(s)), []);
1436
1436
  }
1437
- function mt(e, t) {
1437
+ function Tt(e, t) {
1438
1438
  return t.machine.getTransitionData(t, e);
1439
1439
  }
1440
1440
  function us(e, t) {
1441
- const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(Ke);
1441
+ const n = /* @__PURE__ */ new Set(), s = e._nodes.filter(tt);
1442
1442
  for (const r of s)
1443
1443
  e:
1444
- for (const i of [r].concat(ue(r, void 0)))
1444
+ for (const i of [r].concat(le(r, void 0)))
1445
1445
  if (i.always) {
1446
1446
  for (const o of i.always)
1447
- if (o.guard === void 0 || We(o.guard, e.context, t, e)) {
1447
+ if (o.guard === void 0 || et(o.guard, e.context, t, e)) {
1448
1448
  n.add(o);
1449
1449
  break e;
1450
1450
  }
1451
1451
  }
1452
- return Qt(Array.from(n), new Set(e._nodes), e.historyValue);
1452
+ return Zt(Array.from(n), new Set(e._nodes), e.historyValue);
1453
1453
  }
1454
1454
  function ds(e, t) {
1455
- const n = ve(_e(e, t));
1456
- return Jt(e, [...n]);
1455
+ const n = _e(Se(e, t));
1456
+ return Qt(e, [...n]);
1457
1457
  }
1458
1458
  function ls(e) {
1459
1459
  return !!e && typeof e == "object" && "machine" in e && "value" in e;
1460
1460
  }
1461
1461
  const hs = function(t) {
1462
- return Bt(t, this.value);
1462
+ return Vt(t, this.value);
1463
1463
  }, fs = function(t) {
1464
1464
  return this.tags.has(t);
1465
1465
  }, ps = function(t) {
@@ -1485,7 +1485,7 @@ const hs = function(t) {
1485
1485
  }, ms = function() {
1486
1486
  return this._nodes.reduce((t, n) => (n.meta !== void 0 && (t[n.id] = n.meta), t), {});
1487
1487
  };
1488
- function ye(e, t) {
1488
+ function ge(e, t) {
1489
1489
  return {
1490
1490
  status: e.status,
1491
1491
  output: e.output,
@@ -1493,7 +1493,7 @@ function ye(e, t) {
1493
1493
  machine: t,
1494
1494
  context: e.context,
1495
1495
  _nodes: e._nodes,
1496
- value: Jt(t.root, e._nodes),
1496
+ value: Qt(t.root, e._nodes),
1497
1497
  tags: new Set(e._nodes.flatMap((n) => n.tags)),
1498
1498
  children: e.children,
1499
1499
  historyValue: e.historyValue || {},
@@ -1504,8 +1504,8 @@ function ye(e, t) {
1504
1504
  toJSON: ys
1505
1505
  };
1506
1506
  }
1507
- function H(e, t = {}) {
1508
- return ye({
1507
+ function Y(e, t = {}) {
1508
+ return ge({
1509
1509
  ...e,
1510
1510
  ...t
1511
1511
  }, e.machine);
@@ -1535,11 +1535,11 @@ function gs(e, t) {
1535
1535
  }
1536
1536
  return {
1537
1537
  ...f,
1538
- context: en(o),
1538
+ context: sn(o),
1539
1539
  children: m
1540
1540
  };
1541
1541
  }
1542
- function en(e) {
1542
+ function sn(e) {
1543
1543
  let t;
1544
1544
  for (const n in e) {
1545
1545
  const s = e[n];
@@ -1548,11 +1548,11 @@ function en(e) {
1548
1548
  t ?? (t = Array.isArray(e) ? e.slice() : {
1549
1549
  ...e
1550
1550
  }), t[n] = {
1551
- xstate$$type: Qe,
1551
+ xstate$$type: Ze,
1552
1552
  id: s.id
1553
1553
  };
1554
1554
  else {
1555
- const r = en(s);
1555
+ const r = sn(s);
1556
1556
  r !== s && (t ?? (t = Array.isArray(e) ? e.slice() : {
1557
1557
  ...e
1558
1558
  }), t[n] = r);
@@ -1602,7 +1602,7 @@ function Ts(e, t) {
1602
1602
  }
1603
1603
  return n.type = "xstate.raise", n.event = e, n.id = t == null ? void 0 : t.id, n.delay = t == null ? void 0 : t.delay, n.resolve = Es, n.execute = vs, n;
1604
1604
  }
1605
- const gt = /* @__PURE__ */ new WeakMap();
1605
+ const _t = /* @__PURE__ */ new WeakMap();
1606
1606
  function _s(e) {
1607
1607
  return {
1608
1608
  config: e,
@@ -1614,7 +1614,7 @@ function _s(e) {
1614
1614
  receivers: void 0,
1615
1615
  dispose: void 0
1616
1616
  };
1617
- gt.set(r, o), o.dispose = e({
1617
+ _t.set(r, o), o.dispose = e({
1618
1618
  input: n.input,
1619
1619
  system: i,
1620
1620
  self: r,
@@ -1628,8 +1628,8 @@ function _s(e) {
1628
1628
  },
1629
1629
  transition: (n, s, r) => {
1630
1630
  var o, a;
1631
- const i = gt.get(r.self);
1632
- return s.type === ae ? (n = {
1631
+ const i = _t.get(r.self);
1632
+ return s.type === ue ? (n = {
1633
1633
  ...n,
1634
1634
  status: "stopped",
1635
1635
  error: void 0
@@ -1645,8 +1645,8 @@ function _s(e) {
1645
1645
  restoreSnapshot: (n) => n
1646
1646
  };
1647
1647
  }
1648
- const Et = "xstate.promise.resolve", vt = "xstate.promise.reject", fe = /* @__PURE__ */ new WeakMap();
1649
- function K(e) {
1648
+ const It = "xstate.promise.resolve", St = "xstate.promise.reject", ye = /* @__PURE__ */ new WeakMap();
1649
+ function J(e) {
1650
1650
  return {
1651
1651
  config: e,
1652
1652
  transition: (n, s, r) => {
@@ -1654,7 +1654,7 @@ function K(e) {
1654
1654
  if (n.status !== "active")
1655
1655
  return n;
1656
1656
  switch (s.type) {
1657
- case Et: {
1657
+ case It: {
1658
1658
  const o = s.data;
1659
1659
  return {
1660
1660
  ...n,
@@ -1663,15 +1663,15 @@ function K(e) {
1663
1663
  input: void 0
1664
1664
  };
1665
1665
  }
1666
- case vt:
1666
+ case St:
1667
1667
  return {
1668
1668
  ...n,
1669
1669
  status: "error",
1670
1670
  error: s.data,
1671
1671
  input: void 0
1672
1672
  };
1673
- case ae:
1674
- return (i = fe.get(r.self)) == null || i.abort(), {
1673
+ case ue:
1674
+ return (i = ye.get(r.self)) == null || i.abort(), {
1675
1675
  ...n,
1676
1676
  status: "stopped",
1677
1677
  input: void 0
@@ -1687,19 +1687,19 @@ function K(e) {
1687
1687
  if (n.status !== "active")
1688
1688
  return;
1689
1689
  const i = new AbortController();
1690
- fe.set(s, i), Promise.resolve(e({
1690
+ ye.set(s, i), Promise.resolve(e({
1691
1691
  input: n.input,
1692
1692
  system: r,
1693
1693
  self: s,
1694
1694
  signal: i.signal
1695
1695
  })).then((a) => {
1696
- s.getSnapshot().status === "active" && (fe.delete(s), r._relay(s, s, {
1697
- type: Et,
1696
+ s.getSnapshot().status === "active" && (ye.delete(s), r._relay(s, s, {
1697
+ type: It,
1698
1698
  data: a
1699
1699
  }));
1700
1700
  }, (a) => {
1701
- s.getSnapshot().status === "active" && (fe.delete(s), r._relay(s, s, {
1702
- type: vt,
1701
+ s.getSnapshot().status === "active" && (ye.delete(s), r._relay(s, s, {
1702
+ type: St,
1703
1703
  data: a
1704
1704
  }));
1705
1705
  });
@@ -1724,10 +1724,10 @@ function Is(e, {
1724
1724
  input: u
1725
1725
  } = a;
1726
1726
  if (typeof o == "string") {
1727
- const h = Xe(t, o);
1727
+ const h = Ke(t, o);
1728
1728
  if (!h)
1729
1729
  throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
1730
- const d = U(h, {
1730
+ const d = j(h, {
1731
1731
  id: a.id,
1732
1732
  parent: e.self,
1733
1733
  syncSnapshot: a.syncSnapshot,
@@ -1741,7 +1741,7 @@ function Is(e, {
1741
1741
  });
1742
1742
  return r[d.id] = d, d;
1743
1743
  } else
1744
- return U(o, {
1744
+ return j(o, {
1745
1745
  id: a.id,
1746
1746
  parent: e.self,
1747
1747
  syncSnapshot: a.syncSnapshot,
@@ -1753,7 +1753,7 @@ function Is(e, {
1753
1753
  return (o, a) => {
1754
1754
  const c = i(o, a);
1755
1755
  return r[c.id] = c, e.defer(() => {
1756
- c._processingStatus !== k.Stopped && c.start();
1756
+ c._processingStatus !== C.Stopped && c.start();
1757
1757
  }), c;
1758
1758
  };
1759
1759
  }
@@ -1778,7 +1778,7 @@ function Ss(e, t, n, s, {
1778
1778
  a[u] = typeof h == "function" ? h(o, s) : h;
1779
1779
  }
1780
1780
  const c = Object.assign({}, t.context, a);
1781
- return [H(t, {
1781
+ return [Y(t, {
1782
1782
  context: c,
1783
1783
  children: Object.keys(i).length ? {
1784
1784
  ...t.children,
@@ -1804,12 +1804,12 @@ function xs(e, {
1804
1804
  }) {
1805
1805
  e.defer(() => e.emit(t));
1806
1806
  }
1807
- function Tt(e) {
1807
+ function Re(e) {
1808
1808
  function t(n, s) {
1809
1809
  }
1810
1810
  return t.type = "xstate.emit", t.event = e, t.resolve = As, t.execute = xs, t;
1811
1811
  }
1812
- let _t = /* @__PURE__ */ function(e) {
1812
+ let At = /* @__PURE__ */ function(e) {
1813
1813
  return e.Parent = "#_parent", e.Internal = "#_internal", e;
1814
1814
  }({});
1815
1815
  function ws(e, t, n, s, {
@@ -1832,7 +1832,7 @@ function ws(e, t, n, s, {
1832
1832
  const f = typeof r == "function" ? r(n, s) : r;
1833
1833
  let m;
1834
1834
  if (typeof f == "string") {
1835
- if (f === _t.Parent ? m = e.self._parent : f === _t.Internal ? m = e.self : f.startsWith("#_") ? m = t.children[f.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(f) ? f : t.children[f], !m)
1835
+ if (f === At.Parent ? m = e.self._parent : f === At.Internal ? m = e.self : f.startsWith("#_") ? m = t.children[f.slice(2)] : m = (y = c.deferredActorIds) != null && y.includes(f) ? f : t.children[f], !m)
1836
1836
  throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`);
1837
1837
  } else
1838
1838
  m = f || e.self;
@@ -1863,42 +1863,42 @@ function Os(e, t) {
1863
1863
  // at this point, in a deferred task, it should already be mutated by retryResolveSendTo
1864
1864
  // if it initially started as a string
1865
1865
  n,
1866
- s.type === Nn ? Ft(e.self.id, s.data) : s
1866
+ s.type === Nn ? jt(e.self.id, s.data) : s
1867
1867
  );
1868
1868
  });
1869
1869
  }
1870
- function It(e, t, n) {
1870
+ function xt(e, t, n) {
1871
1871
  function s(r, i) {
1872
1872
  }
1873
1873
  return s.type = "xsnapshot.sendTo", s.to = e, s.event = t, s.id = n == null ? void 0 : n.id, s.delay = n == null ? void 0 : n.delay, s.resolve = ws, s.retryResolve = bs, s.execute = Os, s;
1874
1874
  }
1875
- const St = /* @__PURE__ */ new WeakMap();
1876
- function J(e, t, n) {
1877
- let s = St.get(e);
1875
+ const wt = /* @__PURE__ */ new WeakMap();
1876
+ function Q(e, t, n) {
1877
+ let s = wt.get(e);
1878
1878
  return s ? t in s || (s[t] = n()) : (s = {
1879
1879
  [t]: n()
1880
- }, St.set(e, s)), s[t];
1880
+ }, wt.set(e, s)), s[t];
1881
1881
  }
1882
- const Ns = {}, re = (e) => typeof e == "string" ? {
1882
+ const Ns = {}, oe = (e) => typeof e == "string" ? {
1883
1883
  type: e
1884
1884
  } : typeof e == "function" ? "resolve" in e ? {
1885
1885
  type: e.type
1886
1886
  } : {
1887
1887
  type: e.name
1888
1888
  } : e;
1889
- class nt {
1889
+ class it {
1890
1890
  constructor(t, n) {
1891
- if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = n._parent, this.key = n._key, this.machine = n._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Lt), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? dt(this.config.states, (s, r) => new nt(s, {
1891
+ if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = n._parent, this.key = n._key, this.machine = n._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Pt), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? pt(this.config.states, (s, r) => new it(s, {
1892
1892
  _parent: this,
1893
1893
  _key: r,
1894
1894
  _machine: this.machine
1895
1895
  })) : Ns, this.type === "compound" && !this.config.initial)
1896
1896
  throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);
1897
- this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = F(this.config.entry).slice(), this.exit = F(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = F(t.tags).slice();
1897
+ this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = B(this.config.entry).slice(), this.exit = B(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = B(t.tags).slice();
1898
1898
  }
1899
1899
  /** @internal */
1900
1900
  _initialize() {
1901
- this.transitions = Xn(this), this.config.always && (this.always = X(this.config.always).map((t) => $(this, qt, t))), Object.keys(this.states).forEach((t) => {
1901
+ this.transitions = Xn(this), this.config.always && (this.always = K(this.config.always).map((t) => G(this, Ft, t))), Object.keys(this.states).forEach((t) => {
1902
1902
  this.states[t]._initialize();
1903
1903
  });
1904
1904
  }
@@ -1914,25 +1914,25 @@ class nt {
1914
1914
  initial: this.initial ? {
1915
1915
  target: this.initial.target,
1916
1916
  source: this,
1917
- actions: this.initial.actions.map(re),
1917
+ actions: this.initial.actions.map(oe),
1918
1918
  eventType: null,
1919
1919
  reenter: !1,
1920
1920
  toJSON: () => ({
1921
1921
  target: this.initial.target.map((t) => `#${t.id}`),
1922
1922
  source: `#${this.id}`,
1923
- actions: this.initial.actions.map(re),
1923
+ actions: this.initial.actions.map(oe),
1924
1924
  eventType: null
1925
1925
  })
1926
1926
  } : void 0,
1927
1927
  history: this.history,
1928
- states: dt(this.states, (t) => t.definition),
1928
+ states: pt(this.states, (t) => t.definition),
1929
1929
  on: this.on,
1930
1930
  transitions: [...this.transitions.values()].flat().map((t) => ({
1931
1931
  ...t,
1932
- actions: t.actions.map(re)
1932
+ actions: t.actions.map(oe)
1933
1933
  })),
1934
- entry: this.entry.map(re),
1935
- exit: this.exit.map(re),
1934
+ entry: this.entry.map(oe),
1935
+ exit: this.exit.map(oe),
1936
1936
  meta: this.meta,
1937
1937
  order: this.order || -1,
1938
1938
  output: this.output,
@@ -1949,11 +1949,11 @@ class nt {
1949
1949
  * The logic invoked as actors by this state node.
1950
1950
  */
1951
1951
  get invoke() {
1952
- return J(this, "invoke", () => F(this.config.invoke).map((t, n) => {
1952
+ return Q(this, "invoke", () => B(this.config.invoke).map((t, n) => {
1953
1953
  const {
1954
1954
  src: s,
1955
1955
  systemId: r
1956
- } = t, i = t.id ?? ht(this.id, n), o = typeof s == "string" ? s : `xstate.invoke.${ht(this.id, n)}`;
1956
+ } = t, i = t.id ?? mt(this.id, n), o = typeof s == "string" ? s : `xstate.invoke.${mt(this.id, n)}`;
1957
1957
  return {
1958
1958
  ...t,
1959
1959
  src: o,
@@ -1979,26 +1979,26 @@ class nt {
1979
1979
  * The mapping of events to transitions.
1980
1980
  */
1981
1981
  get on() {
1982
- return J(this, "on", () => [...this.transitions].flatMap(([n, s]) => s.map((r) => [n, r])).reduce((n, [s, r]) => (n[s] = n[s] || [], n[s].push(r), n), {}));
1982
+ return Q(this, "on", () => [...this.transitions].flatMap(([n, s]) => s.map((r) => [n, r])).reduce((n, [s, r]) => (n[s] = n[s] || [], n[s].push(r), n), {}));
1983
1983
  }
1984
1984
  get after() {
1985
- return J(this, "delayedTransitions", () => Yn(this));
1985
+ return Q(this, "delayedTransitions", () => Yn(this));
1986
1986
  }
1987
1987
  get initial() {
1988
- return J(this, "initial", () => Qn(this, this.config.initial));
1988
+ return Q(this, "initial", () => Qn(this, this.config.initial));
1989
1989
  }
1990
1990
  /** @internal */
1991
1991
  next(t, n) {
1992
1992
  const s = n.type, r = [];
1993
1993
  let i;
1994
- const o = J(this, `candidates-${s}`, () => Jn(this, s));
1994
+ const o = Q(this, `candidates-${s}`, () => Jn(this, s));
1995
1995
  for (const a of o) {
1996
1996
  const {
1997
1997
  guard: c
1998
1998
  } = a, u = t.context;
1999
1999
  let h = !1;
2000
2000
  try {
2001
- h = !c || We(c, u, n, t);
2001
+ h = !c || et(c, u, n, t);
2002
2002
  } catch (d) {
2003
2003
  const f = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
2004
2004
  throw new Error(`Unable to evaluate guard ${f ? `'${f}' ` : ""}in transition for event '${s}' in state node '${this.id}':
@@ -2015,7 +2015,7 @@ ${d.message}`);
2015
2015
  * All the event types accepted by this state node and its descendants.
2016
2016
  */
2017
2017
  get events() {
2018
- return J(this, "events", () => {
2018
+ return Q(this, "events", () => {
2019
2019
  const {
2020
2020
  states: t
2021
2021
  } = this, n = new Set(this.ownEvents);
@@ -2040,14 +2040,14 @@ ${d.message}`);
2040
2040
  }
2041
2041
  }
2042
2042
  const ks = "#";
2043
- class st {
2043
+ class ot {
2044
2044
  constructor(t, n) {
2045
2045
  this.config = t, this.version = void 0, this.schemas = void 0, this.implementations = void 0, this.__xstatenode = !0, this.idMap = /* @__PURE__ */ new Map(), this.root = void 0, this.id = void 0, this.states = void 0, this.events = void 0, this.__TResolvedTypesMeta = void 0, this.id = t.id || "(machine)", this.implementations = {
2046
2046
  actors: (n == null ? void 0 : n.actors) ?? {},
2047
2047
  actions: (n == null ? void 0 : n.actions) ?? {},
2048
2048
  delays: (n == null ? void 0 : n.delays) ?? {},
2049
2049
  guards: (n == null ? void 0 : n.guards) ?? {}
2050
- }, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new nt(t, {
2050
+ }, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new it(t, {
2051
2051
  _key: this.id,
2052
2052
  _machine: this
2053
2053
  }), this.root._initialize(), this.states = this.root.states, this.events = this.root.events;
@@ -2068,7 +2068,7 @@ class st {
2068
2068
  actors: r,
2069
2069
  delays: i
2070
2070
  } = this.implementations;
2071
- return new st(this.config, {
2071
+ return new ot(this.config, {
2072
2072
  actions: {
2073
2073
  ...n,
2074
2074
  ...t.actions
@@ -2088,12 +2088,12 @@ class st {
2088
2088
  });
2089
2089
  }
2090
2090
  resolveState(t) {
2091
- const n = ds(this.root, t.value), s = ve(_e(this.root, n));
2092
- return ye({
2091
+ const n = ds(this.root, t.value), s = _e(Se(this.root, n));
2092
+ return ge({
2093
2093
  _nodes: [...s],
2094
2094
  context: t.context || {},
2095
2095
  children: {},
2096
- status: Ze(s, this.root) ? "done" : t.status || "active",
2096
+ status: nt(s, this.root) ? "done" : t.status || "active",
2097
2097
  output: t.output,
2098
2098
  error: t.error,
2099
2099
  historyValue: t.historyValue
@@ -2107,7 +2107,7 @@ class st {
2107
2107
  * @param event The received event
2108
2108
  */
2109
2109
  transition(t, n, s) {
2110
- return ke(t, n, s).snapshot;
2110
+ return De(t, n, s).snapshot;
2111
2111
  }
2112
2112
  /**
2113
2113
  * Determines the next state given the current `state` and `event`.
@@ -2117,10 +2117,10 @@ class st {
2117
2117
  * @param event The received event
2118
2118
  */
2119
2119
  microstep(t, n, s) {
2120
- return ke(t, n, s).microstates;
2120
+ return De(t, n, s).microstates;
2121
2121
  }
2122
2122
  getTransitionData(t, n) {
2123
- return et(this.root, t.value, t, n) || [];
2123
+ return st(this.root, t.value, t, n) || [];
2124
2124
  }
2125
2125
  /**
2126
2126
  * The initial state _before_ evaluating any microsteps.
@@ -2129,13 +2129,13 @@ class st {
2129
2129
  getPreInitialState(t, n, s) {
2130
2130
  const {
2131
2131
  context: r
2132
- } = this.config, i = ye({
2132
+ } = this.config, i = ge({
2133
2133
  context: typeof r != "function" && r ? r : {},
2134
2134
  _nodes: [this.root],
2135
2135
  children: {},
2136
2136
  status: "active"
2137
2137
  }, this);
2138
- return typeof r == "function" ? te(i, n, t, [D(({
2138
+ return typeof r == "function" ? se(i, n, t, [D(({
2139
2139
  spawn: a,
2140
2140
  event: c,
2141
2141
  self: u
@@ -2149,8 +2149,8 @@ class st {
2149
2149
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2150
2150
  */
2151
2151
  getInitialSnapshot(t, n) {
2152
- const s = Ut(n), r = [], i = this.getPreInitialState(t, s, r), o = Be([{
2153
- target: [...Xt(this.root)],
2152
+ const s = $t(n), r = [], i = this.getPreInitialState(t, s, r), o = Ve([{
2153
+ target: [...Kt(this.root)],
2154
2154
  source: this.root,
2155
2155
  reenter: !0,
2156
2156
  actions: [],
@@ -2159,7 +2159,7 @@ class st {
2159
2159
  // TODO: fix
2160
2160
  }], i, t, s, !0, r), {
2161
2161
  snapshot: a
2162
- } = ke(o, s, t, r);
2162
+ } = De(o, s, t, r);
2163
2163
  return a;
2164
2164
  }
2165
2165
  start(t) {
@@ -2168,10 +2168,10 @@ class st {
2168
2168
  });
2169
2169
  }
2170
2170
  getStateNodeById(t) {
2171
- const n = Ye(t), s = n.slice(1), r = Se(n[0]) ? n[0].slice(ks.length) : n[0], i = this.idMap.get(r);
2171
+ const n = We(t), s = n.slice(1), r = xe(n[0]) ? n[0].slice(ks.length) : n[0], i = this.idMap.get(r);
2172
2172
  if (!i)
2173
2173
  throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
2174
- return Te(i, s);
2174
+ return Ie(i, s);
2175
2175
  }
2176
2176
  get definition() {
2177
2177
  return this.root.definition;
@@ -2185,10 +2185,10 @@ class st {
2185
2185
  restoreSnapshot(t, n) {
2186
2186
  const s = {}, r = t.children;
2187
2187
  Object.keys(r).forEach((c) => {
2188
- const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? Xe(this, d) : d;
2188
+ const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? Ke(this, d) : d;
2189
2189
  if (!f)
2190
2190
  return;
2191
- const m = U(f, {
2191
+ const m = j(f, {
2192
2192
  id: c,
2193
2193
  parent: n.self,
2194
2194
  syncSnapshot: u.syncSnapshot,
@@ -2198,10 +2198,10 @@ class st {
2198
2198
  });
2199
2199
  s[c] = m;
2200
2200
  });
2201
- const i = ye({
2201
+ const i = ge({
2202
2202
  ...t,
2203
2203
  children: s,
2204
- _nodes: Array.from(ve(_e(this.root, t.value)))
2204
+ _nodes: Array.from(_e(Se(this.root, t.value)))
2205
2205
  }, this);
2206
2206
  let o = /* @__PURE__ */ new Set();
2207
2207
  function a(c, u) {
@@ -2210,7 +2210,7 @@ class st {
2210
2210
  for (let h in c) {
2211
2211
  const d = c[h];
2212
2212
  if (d && typeof d == "object") {
2213
- if ("xstate$$type" in d && d.xstate$$type === Qe) {
2213
+ if ("xstate$$type" in d && d.xstate$$type === Ze) {
2214
2214
  c[h] = u[d.id];
2215
2215
  continue;
2216
2216
  }
@@ -2223,9 +2223,9 @@ class st {
2223
2223
  }
2224
2224
  }
2225
2225
  function Cs(e, t) {
2226
- return new st(e, t);
2226
+ return new ot(e, t);
2227
2227
  }
2228
- function Ae({
2228
+ function we({
2229
2229
  schemas: e,
2230
2230
  actors: t,
2231
2231
  actions: n,
@@ -2244,14 +2244,14 @@ function Ae({
2244
2244
  })
2245
2245
  };
2246
2246
  }
2247
- async function Ce(e, t) {
2247
+ async function Me(e, t) {
2248
2248
  const n = await fetch(e, t);
2249
2249
  return n.status === 200 ? n.json() : Promise.resolve({
2250
2250
  message: n.statusText,
2251
2251
  success: !1
2252
2252
  });
2253
2253
  }
2254
- const At = Ae({
2254
+ const bt = we({
2255
2255
  types: {
2256
2256
  context: {},
2257
2257
  events: {},
@@ -2319,13 +2319,13 @@ const At = Ae({
2319
2319
  // },
2320
2320
  },
2321
2321
  actors: {
2322
- refreshAccessToken: K(async ({ input: e }) => {
2322
+ refreshAccessToken: J(async ({ input: e }) => {
2323
2323
  let t;
2324
2324
  if (typeof window > "u") {
2325
2325
  if (e.context.refreshToken === "")
2326
2326
  throw new Error("Unauthorized.");
2327
2327
  try {
2328
- const s = await Ce(
2328
+ const s = await Me(
2329
2329
  e.context.endpoints.ssrRefresh,
2330
2330
  {
2331
2331
  method: "POST",
@@ -2349,7 +2349,7 @@ const At = Ae({
2349
2349
  throw console.log(n), new Error("Could not complete refresh request (server)");
2350
2350
  }
2351
2351
  } else {
2352
- t = await Ce(
2352
+ t = await Me(
2353
2353
  e.context.endpoints.refresh,
2354
2354
  {
2355
2355
  method: "POST",
@@ -2377,9 +2377,9 @@ const At = Ae({
2377
2377
  };
2378
2378
  }
2379
2379
  }),
2380
- authenticate: K(async ({ input: e }) => {
2380
+ authenticate: J(async ({ input: e }) => {
2381
2381
  var s;
2382
- const n = await Ce(
2382
+ const n = await Me(
2383
2383
  e.context.endpoints.login,
2384
2384
  {
2385
2385
  method: "POST",
@@ -2406,7 +2406,7 @@ const At = Ae({
2406
2406
  accessToken: n.accessToken
2407
2407
  };
2408
2408
  }),
2409
- unauthenticate: K(async ({ input: e }) => (await fetch(e.context.endpoints.logout, {
2409
+ unauthenticate: J(async ({ input: e }) => (await fetch(e.context.endpoints.logout, {
2410
2410
  method: "POST",
2411
2411
  mode: "cors",
2412
2412
  credentials: "include",
@@ -2548,13 +2548,13 @@ const At = Ae({
2548
2548
  // },
2549
2549
  // },
2550
2550
  }
2551
- }), tn = ze(
2551
+ }), rn = Xe(
2552
2552
  {}
2553
- ), zr = () => {
2554
- const e = Je(tn), [t, n] = Rt(
2553
+ ), Xr = () => {
2554
+ const e = Qe(rn), [t, n] = Lt(
2555
2555
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2556
2556
  );
2557
- return Mt(() => {
2557
+ return Ut(() => {
2558
2558
  if (typeof window > "u")
2559
2559
  return;
2560
2560
  const s = e.subscribe((r) => {
@@ -2564,19 +2564,19 @@ const At = Ae({
2564
2564
  s.unsubscribe();
2565
2565
  };
2566
2566
  }, [e]), { authActor: e, isLoggedIn: t };
2567
- }, Jr = async (e = "", t = {
2567
+ }, Qr = async (e = "", t = {
2568
2568
  inspect: void 0,
2569
2569
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2570
2570
  }) => typeof window < "u" ? (console.warn(
2571
2571
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2572
- ), U(At, {
2572
+ ), j(bt, {
2573
2573
  inspect: t.inspect,
2574
2574
  input: {
2575
2575
  initialContext: {
2576
2576
  endpoints: t.endpoints
2577
2577
  }
2578
2578
  }
2579
- }).start()) : U(At, {
2579
+ }).start()) : j(bt, {
2580
2580
  input: {
2581
2581
  initialContext: {
2582
2582
  endpoints: t.endpoints,
@@ -2585,11 +2585,11 @@ const At = Ae({
2585
2585
  },
2586
2586
  inspect: t.inspect
2587
2587
  }).start();
2588
- function Yr({ actor: e, children: t }) {
2589
- return /* @__PURE__ */ Ge(tn.Provider, { value: e, children: t });
2588
+ function Wr({ actor: e, children: t }) {
2589
+ return /* @__PURE__ */ Ye(rn.Provider, { value: e, children: t });
2590
2590
  }
2591
2591
  let Ds = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, n) => (n &= 63, n < 36 ? t += n.toString(36) : n < 62 ? t += (n - 26).toString(36).toUpperCase() : n > 62 ? t += "-" : t += "_", t), "");
2592
- const Rs = Ae({
2592
+ const Rs = we({
2593
2593
  actors: {
2594
2594
  tick: _s(
2595
2595
  ({ sendBack: e, input: t }) => {
@@ -2667,7 +2667,7 @@ const Rs = Ae({
2667
2667
  type: "final"
2668
2668
  }
2669
2669
  }
2670
- }), Xr = Ae({
2670
+ }), Kr = we({
2671
2671
  actors: {
2672
2672
  timer: Rs
2673
2673
  },
@@ -2759,11 +2759,11 @@ const Rs = Ae({
2759
2759
  target: "idle"
2760
2760
  },
2761
2761
  RESUME_TIMER: {
2762
- actions: It("timer", { type: "RESUME_TIMER" })
2762
+ actions: xt("timer", { type: "RESUME_TIMER" })
2763
2763
  // cond: (context) => context.duration > 0,
2764
2764
  },
2765
2765
  PAUSE_TIMER: {
2766
- actions: It("timer", { type: "PAUSE_TIMER" })
2766
+ actions: xt("timer", { type: "PAUSE_TIMER" })
2767
2767
  // cond: (context) => context.duration > 0,
2768
2768
  }
2769
2769
  }
@@ -2797,12 +2797,12 @@ const Rs = Ae({
2797
2797
  }
2798
2798
  }
2799
2799
  }
2800
- }), nn = ze({}), Qr = () => Je(nn);
2801
- function Wr({
2800
+ }), on = Xe({}), Zr = () => Qe(on);
2801
+ function ei({
2802
2802
  children: e,
2803
2803
  actor: t
2804
2804
  }) {
2805
- return /* @__PURE__ */ Ge(nn.Provider, { value: t, children: e });
2805
+ return /* @__PURE__ */ Ye(on.Provider, { value: t, children: e });
2806
2806
  }
2807
2807
  function Ms({
2808
2808
  context: e,
@@ -2816,7 +2816,7 @@ function Ms({
2816
2816
  itemsAdded: n.output.itemsAdded
2817
2817
  };
2818
2818
  }
2819
- function Ls({
2819
+ function qs({
2820
2820
  event: e
2821
2821
  }) {
2822
2822
  if (!e.type.includes("xstate.done.actor"))
@@ -2827,7 +2827,7 @@ function Ls({
2827
2827
  itemsAdded: t.output.itemsAdded
2828
2828
  };
2829
2829
  }
2830
- function qs({
2830
+ function Ls({
2831
2831
  event: e
2832
2832
  }) {
2833
2833
  if (!e.type.includes("xstate.done.actor"))
@@ -2838,6 +2838,23 @@ function qs({
2838
2838
  itemsRemoved: t.output.itemsRemoved
2839
2839
  };
2840
2840
  }
2841
+ function Us({
2842
+ event: e
2843
+ }) {
2844
+ if (!e.type.includes("xstate.done.actor"))
2845
+ return {
2846
+ type: "EMIT_UPDATE_ITEMS",
2847
+ itemsUpdated: []
2848
+ };
2849
+ const t = e;
2850
+ return t.output.type !== "UPDATE_ITEMS_SUCCESS" ? {
2851
+ type: "EMIT_UPDATE_ITEMS",
2852
+ itemsUpdated: []
2853
+ } : {
2854
+ type: "EMIT_UPDATE_ITEMS",
2855
+ itemsUpdated: t.output.itemsUpdated
2856
+ };
2857
+ }
2841
2858
  function Ps({
2842
2859
  context: e,
2843
2860
  event: t
@@ -2861,26 +2878,38 @@ function Fs({
2861
2878
  quote: { ...e.quote, ...n.output.quote }
2862
2879
  };
2863
2880
  }
2864
- const rt = JSON, Us = (e) => e.toUpperCase(), Bs = (e) => {
2881
+ function Bs({
2882
+ context: e,
2883
+ event: t
2884
+ }) {
2885
+ if (!t.type.includes("xstate.done.actor"))
2886
+ return e;
2887
+ const n = t;
2888
+ return n.output.type !== "UPDATE_ITEMS_SUCCESS" ? e : {
2889
+ quote: { ...e.quote, ...n.output.quote },
2890
+ itemsUpdated: n.output.itemsUpdated
2891
+ };
2892
+ }
2893
+ const at = JSON, js = (e) => e.toUpperCase(), $s = (e) => {
2865
2894
  const t = {};
2866
2895
  return e.forEach((n, s) => {
2867
2896
  t[s] = n;
2868
2897
  }), t;
2869
- }, js = (e, t, n) => e.document ? e : {
2898
+ }, Vs = (e, t, n) => e.document ? e : {
2870
2899
  document: e,
2871
2900
  variables: t,
2872
2901
  requestHeaders: n,
2873
2902
  signal: void 0
2874
- }, $s = (e, t, n) => e.query ? e : {
2903
+ }, Hs = (e, t, n) => e.query ? e : {
2875
2904
  query: e,
2876
2905
  variables: t,
2877
2906
  requestHeaders: n,
2878
2907
  signal: void 0
2879
- }, Vs = (e, t) => e.documents ? e : {
2908
+ }, Gs = (e, t) => e.documents ? e : {
2880
2909
  documents: e,
2881
2910
  requestHeaders: t,
2882
2911
  signal: void 0
2883
- }, Hs = (e, t, ...n) => {
2912
+ }, zs = (e, t, ...n) => {
2884
2913
  const [s, r] = n;
2885
2914
  return e.document ? e : {
2886
2915
  url: e,
@@ -2890,24 +2919,24 @@ const rt = JSON, Us = (e) => e.toUpperCase(), Bs = (e) => {
2890
2919
  signal: void 0
2891
2920
  };
2892
2921
  };
2893
- function me(e, t) {
2922
+ function Ee(e, t) {
2894
2923
  if (!!!e)
2895
2924
  throw new Error(t);
2896
2925
  }
2897
- function Gs(e) {
2926
+ function Js(e) {
2898
2927
  return typeof e == "object" && e !== null;
2899
2928
  }
2900
- function zs(e, t) {
2929
+ function Ys(e, t) {
2901
2930
  if (!!!e)
2902
2931
  throw new Error(
2903
2932
  t ?? "Unexpected invariant triggered."
2904
2933
  );
2905
2934
  }
2906
- const Js = /\r\n|[\n\r]/g;
2907
- function je(e, t) {
2935
+ const Xs = /\r\n|[\n\r]/g;
2936
+ function He(e, t) {
2908
2937
  let n = 0, s = 1;
2909
- for (const r of e.body.matchAll(Js)) {
2910
- if (typeof r.index == "number" || zs(!1), r.index >= t)
2938
+ for (const r of e.body.matchAll(Xs)) {
2939
+ if (typeof r.index == "number" || Ys(!1), r.index >= t)
2911
2940
  break;
2912
2941
  n = r.index + r[0].length, s += 1;
2913
2942
  }
@@ -2916,27 +2945,27 @@ function je(e, t) {
2916
2945
  column: t + 1 - n
2917
2946
  };
2918
2947
  }
2919
- function Ys(e) {
2920
- return sn(
2948
+ function Qs(e) {
2949
+ return an(
2921
2950
  e.source,
2922
- je(e.source, e.start)
2951
+ He(e.source, e.start)
2923
2952
  );
2924
2953
  }
2925
- function sn(e, t) {
2954
+ function an(e, t) {
2926
2955
  const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, r = t.line - 1, i = e.locationOffset.line - 1, o = t.line + i, a = t.line === 1 ? n : 0, c = t.column + a, u = `${e.name}:${o}:${c}
2927
2956
  `, h = s.split(/\r\n|[\n\r]/g), d = h[r];
2928
2957
  if (d.length > 120) {
2929
2958
  const f = Math.floor(c / 80), m = c % 80, y = [];
2930
2959
  for (let v = 0; v < d.length; v += 80)
2931
2960
  y.push(d.slice(v, v + 80));
2932
- return u + xt([
2961
+ return u + Ot([
2933
2962
  [`${o} |`, y[0]],
2934
2963
  ...y.slice(1, f + 1).map((v) => ["|", v]),
2935
2964
  ["|", "^".padStart(m)],
2936
2965
  ["|", y[f + 1]]
2937
2966
  ]);
2938
2967
  }
2939
- return u + xt([
2968
+ return u + Ot([
2940
2969
  // Lines specified like this: ["prefix", "string"],
2941
2970
  [`${o - 1} |`, h[r - 1]],
2942
2971
  [`${o} |`, d],
@@ -2944,12 +2973,12 @@ function sn(e, t) {
2944
2973
  [`${o + 1} |`, h[r + 1]]
2945
2974
  ]);
2946
2975
  }
2947
- function xt(e) {
2976
+ function Ot(e) {
2948
2977
  const t = e.filter(([s, r]) => r !== void 0), n = Math.max(...t.map(([s]) => s.length));
2949
2978
  return t.map(([s, r]) => s.padStart(n) + (r ? " " + r : "")).join(`
2950
2979
  `);
2951
2980
  }
2952
- function Xs(e) {
2981
+ function Ws(e) {
2953
2982
  const t = e[0];
2954
2983
  return t == null || "kind" in t || "length" in t ? {
2955
2984
  nodes: t,
@@ -2960,7 +2989,7 @@ function Xs(e) {
2960
2989
  extensions: e[5]
2961
2990
  } : t;
2962
2991
  }
2963
- class it extends Error {
2992
+ class ct extends Error {
2964
2993
  /**
2965
2994
  * An array of `{ line, column }` locations within the source GraphQL document
2966
2995
  * which correspond to this error.
@@ -3001,15 +3030,15 @@ class it extends Error {
3001
3030
  */
3002
3031
  constructor(t, ...n) {
3003
3032
  var s, r, i;
3004
- const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = Xs(n);
3005
- super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = wt(
3033
+ const { nodes: o, source: a, positions: c, path: u, originalError: h, extensions: d } = Ws(n);
3034
+ super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = Nt(
3006
3035
  Array.isArray(o) ? o : o ? [o] : void 0
3007
3036
  );
3008
- const f = wt(
3037
+ const f = Nt(
3009
3038
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
3010
3039
  );
3011
- this.source = a ?? (f == null || (r = f[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (f == null ? void 0 : f.map((y) => y.start)), this.locations = c && a ? c.map((y) => je(a, y)) : f == null ? void 0 : f.map((y) => je(y.source, y.start));
3012
- const m = Gs(
3040
+ this.source = a ?? (f == null || (r = f[0]) === null || r === void 0 ? void 0 : r.source), this.positions = c ?? (f == null ? void 0 : f.map((y) => y.start)), this.locations = c && a ? c.map((y) => He(a, y)) : f == null ? void 0 : f.map((y) => He(y.source, y.start));
3041
+ const m = Js(
3013
3042
  h == null ? void 0 : h.extensions
3014
3043
  ) ? h == null ? void 0 : h.extensions : void 0;
3015
3044
  this.extensions = (i = d ?? m) !== null && i !== void 0 ? i : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
@@ -3036,7 +3065,7 @@ class it extends Error {
3036
3065
  value: h.stack,
3037
3066
  writable: !0,
3038
3067
  configurable: !0
3039
- }) : Error.captureStackTrace ? Error.captureStackTrace(this, it) : Object.defineProperty(this, "stack", {
3068
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, ct) : Object.defineProperty(this, "stack", {
3040
3069
  value: Error().stack,
3041
3070
  writable: !0,
3042
3071
  configurable: !0
@@ -3051,12 +3080,12 @@ class it extends Error {
3051
3080
  for (const n of this.nodes)
3052
3081
  n.loc && (t += `
3053
3082
 
3054
- ` + Ys(n.loc));
3083
+ ` + Qs(n.loc));
3055
3084
  else if (this.source && this.locations)
3056
3085
  for (const n of this.locations)
3057
3086
  t += `
3058
3087
 
3059
- ` + sn(this.source, n);
3088
+ ` + an(this.source, n);
3060
3089
  return t;
3061
3090
  }
3062
3091
  toJSON() {
@@ -3066,16 +3095,16 @@ class it extends Error {
3066
3095
  return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t;
3067
3096
  }
3068
3097
  }
3069
- function wt(e) {
3098
+ function Nt(e) {
3070
3099
  return e === void 0 || e.length === 0 ? void 0 : e;
3071
3100
  }
3072
3101
  function b(e, t, n) {
3073
- return new it(`Syntax Error: ${n}`, {
3102
+ return new ct(`Syntax Error: ${n}`, {
3074
3103
  source: e,
3075
3104
  positions: [t]
3076
3105
  });
3077
3106
  }
3078
- class Qs {
3107
+ class Ks {
3079
3108
  /**
3080
3109
  * The character offset at which this Node begins.
3081
3110
  */
@@ -3104,7 +3133,7 @@ class Qs {
3104
3133
  };
3105
3134
  }
3106
3135
  }
3107
- class rn {
3136
+ class cn {
3108
3137
  /**
3109
3138
  * The kind of Token.
3110
3139
  */
@@ -3146,7 +3175,7 @@ class rn {
3146
3175
  };
3147
3176
  }
3148
3177
  }
3149
- const on = {
3178
+ const un = {
3150
3179
  Name: [],
3151
3180
  Document: ["definitions"],
3152
3181
  OperationDefinition: [
@@ -3220,45 +3249,45 @@ const on = {
3220
3249
  UnionTypeExtension: ["name", "directives", "types"],
3221
3250
  EnumTypeExtension: ["name", "directives", "values"],
3222
3251
  InputObjectTypeExtension: ["name", "directives", "fields"]
3223
- }, Ws = new Set(Object.keys(on));
3224
- function bt(e) {
3252
+ }, Zs = new Set(Object.keys(un));
3253
+ function kt(e) {
3225
3254
  const t = e == null ? void 0 : e.kind;
3226
- return typeof t == "string" && Ws.has(t);
3255
+ return typeof t == "string" && Zs.has(t);
3227
3256
  }
3228
- var W;
3257
+ var ee;
3229
3258
  (function(e) {
3230
3259
  e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
3231
- })(W || (W = {}));
3232
- var $e;
3260
+ })(ee || (ee = {}));
3261
+ var Ge;
3233
3262
  (function(e) {
3234
3263
  e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
3235
- })($e || ($e = {}));
3264
+ })(Ge || (Ge = {}));
3236
3265
  var T;
3237
3266
  (function(e) {
3238
3267
  e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
3239
3268
  })(T || (T = {}));
3240
- function Ve(e) {
3269
+ function ze(e) {
3241
3270
  return e === 9 || e === 32;
3242
3271
  }
3243
- function ce(e) {
3272
+ function de(e) {
3244
3273
  return e >= 48 && e <= 57;
3245
3274
  }
3246
- function an(e) {
3275
+ function dn(e) {
3247
3276
  return e >= 97 && e <= 122 || // A-Z
3248
3277
  e >= 65 && e <= 90;
3249
3278
  }
3250
- function cn(e) {
3251
- return an(e) || e === 95;
3279
+ function ln(e) {
3280
+ return dn(e) || e === 95;
3252
3281
  }
3253
- function Ks(e) {
3254
- return an(e) || ce(e) || e === 95;
3282
+ function er(e) {
3283
+ return dn(e) || de(e) || e === 95;
3255
3284
  }
3256
- function Zs(e) {
3285
+ function tr(e) {
3257
3286
  var t;
3258
3287
  let n = Number.MAX_SAFE_INTEGER, s = null, r = -1;
3259
3288
  for (let o = 0; o < e.length; ++o) {
3260
3289
  var i;
3261
- const a = e[o], c = er(a);
3290
+ const a = e[o], c = nr(a);
3262
3291
  c !== a.length && (s = (i = s) !== null && i !== void 0 ? i : o, r = o, o !== 0 && c < n && (n = c));
3263
3292
  }
3264
3293
  return e.map((o, a) => a === 0 ? o : o.slice(n)).slice(
@@ -3266,17 +3295,17 @@ function Zs(e) {
3266
3295
  r + 1
3267
3296
  );
3268
3297
  }
3269
- function er(e) {
3298
+ function nr(e) {
3270
3299
  let t = 0;
3271
- for (; t < e.length && Ve(e.charCodeAt(t)); )
3300
+ for (; t < e.length && ze(e.charCodeAt(t)); )
3272
3301
  ++t;
3273
3302
  return t;
3274
3303
  }
3275
- function tr(e, t) {
3276
- const n = e.replace(/"""/g, '\\"""'), s = n.split(/\r\n|[\n\r]/g), r = s.length === 1, i = s.length > 1 && s.slice(1).every((m) => m.length === 0 || Ve(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, h = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3304
+ function sr(e, t) {
3305
+ const n = e.replace(/"""/g, '\\"""'), s = n.split(/\r\n|[\n\r]/g), r = s.length === 1, i = s.length > 1 && s.slice(1).every((m) => m.length === 0 || ze(m.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), u = a || c, h = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3277
3306
  (!r || e.length > 70 || u || i || o);
3278
3307
  let d = "";
3279
- const f = r && Ve(e.charCodeAt(0));
3308
+ const f = r && ze(e.charCodeAt(0));
3280
3309
  return (h && !f || i) && (d += `
3281
3310
  `), d += n, (h || u) && (d += `
3282
3311
  `), '"""' + d + '"""';
@@ -3285,7 +3314,7 @@ var p;
3285
3314
  (function(e) {
3286
3315
  e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
3287
3316
  })(p || (p = {}));
3288
- class nr {
3317
+ class rr {
3289
3318
  /**
3290
3319
  * The previously focused non-ignored token.
3291
3320
  */
@@ -3299,7 +3328,7 @@ class nr {
3299
3328
  * The character offset at which the current line begins.
3300
3329
  */
3301
3330
  constructor(t) {
3302
- const n = new rn(p.SOF, 0, 0, 0, 0);
3331
+ const n = new cn(p.SOF, 0, 0, 0, 0);
3303
3332
  this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
3304
3333
  }
3305
3334
  get [Symbol.toStringTag]() {
@@ -3322,29 +3351,29 @@ class nr {
3322
3351
  if (t.next)
3323
3352
  t = t.next;
3324
3353
  else {
3325
- const n = rr(this, t.end);
3354
+ const n = or(this, t.end);
3326
3355
  t.next = n, n.prev = t, t = n;
3327
3356
  }
3328
3357
  while (t.kind === p.COMMENT);
3329
3358
  return t;
3330
3359
  }
3331
3360
  }
3332
- function sr(e) {
3361
+ function ir(e) {
3333
3362
  return e === p.BANG || e === p.DOLLAR || e === p.AMP || e === p.PAREN_L || e === p.PAREN_R || e === p.SPREAD || e === p.COLON || e === p.EQUALS || e === p.AT || e === p.BRACKET_L || e === p.BRACKET_R || e === p.BRACE_L || e === p.PIPE || e === p.BRACE_R;
3334
3363
  }
3335
- function ne(e) {
3364
+ function re(e) {
3336
3365
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3337
3366
  }
3338
- function xe(e, t) {
3339
- return un(e.charCodeAt(t)) && dn(e.charCodeAt(t + 1));
3367
+ function be(e, t) {
3368
+ return hn(e.charCodeAt(t)) && fn(e.charCodeAt(t + 1));
3340
3369
  }
3341
- function un(e) {
3370
+ function hn(e) {
3342
3371
  return e >= 55296 && e <= 56319;
3343
3372
  }
3344
- function dn(e) {
3373
+ function fn(e) {
3345
3374
  return e >= 56320 && e <= 57343;
3346
3375
  }
3347
- function G(e, t) {
3376
+ function X(e, t) {
3348
3377
  const n = e.source.body.codePointAt(t);
3349
3378
  if (n === void 0)
3350
3379
  return p.EOF;
@@ -3356,9 +3385,9 @@ function G(e, t) {
3356
3385
  }
3357
3386
  function w(e, t, n, s, r) {
3358
3387
  const i = e.line, o = 1 + n - e.lineStart;
3359
- return new rn(t, n, s, i, o, r);
3388
+ return new cn(t, n, s, i, o, r);
3360
3389
  }
3361
- function rr(e, t) {
3390
+ function or(e, t) {
3362
3391
  const n = e.source.body, s = n.length;
3363
3392
  let r = t;
3364
3393
  for (; r < s; ) {
@@ -3377,7 +3406,7 @@ function rr(e, t) {
3377
3406
  n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, ++e.line, e.lineStart = r;
3378
3407
  continue;
3379
3408
  case 35:
3380
- return ir(e, r);
3409
+ return ar(e, r);
3381
3410
  case 33:
3382
3411
  return w(e, p.BANG, r, r + 1);
3383
3412
  case 36:
@@ -3409,30 +3438,30 @@ function rr(e, t) {
3409
3438
  case 125:
3410
3439
  return w(e, p.BRACE_R, r, r + 1);
3411
3440
  case 34:
3412
- return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? lr(e, r) : ar(e, r);
3441
+ return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? fr(e, r) : ur(e, r);
3413
3442
  }
3414
- if (ce(i) || i === 45)
3415
- return or(e, r, i);
3416
- if (cn(i))
3417
- return hr(e, r);
3443
+ if (de(i) || i === 45)
3444
+ return cr(e, r, i);
3445
+ if (ln(i))
3446
+ return pr(e, r);
3418
3447
  throw b(
3419
3448
  e.source,
3420
3449
  r,
3421
- i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : ne(i) || xe(n, r) ? `Unexpected character: ${G(e, r)}.` : `Invalid character: ${G(e, r)}.`
3450
+ i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || be(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3422
3451
  );
3423
3452
  }
3424
3453
  return w(e, p.EOF, s, s);
3425
3454
  }
3426
- function ir(e, t) {
3455
+ function ar(e, t) {
3427
3456
  const n = e.source.body, s = n.length;
3428
3457
  let r = t + 1;
3429
3458
  for (; r < s; ) {
3430
3459
  const i = n.charCodeAt(r);
3431
3460
  if (i === 10 || i === 13)
3432
3461
  break;
3433
- if (ne(i))
3462
+ if (re(i))
3434
3463
  ++r;
3435
- else if (xe(n, r))
3464
+ else if (be(n, r))
3436
3465
  r += 2;
3437
3466
  else
3438
3467
  break;
@@ -3445,26 +3474,26 @@ function ir(e, t) {
3445
3474
  n.slice(t + 1, r)
3446
3475
  );
3447
3476
  }
3448
- function or(e, t, n) {
3477
+ function cr(e, t, n) {
3449
3478
  const s = e.source.body;
3450
3479
  let r = t, i = n, o = !1;
3451
3480
  if (i === 45 && (i = s.charCodeAt(++r)), i === 48) {
3452
- if (i = s.charCodeAt(++r), ce(i))
3481
+ if (i = s.charCodeAt(++r), de(i))
3453
3482
  throw b(
3454
3483
  e.source,
3455
3484
  r,
3456
- `Invalid number, unexpected digit after 0: ${G(
3485
+ `Invalid number, unexpected digit after 0: ${X(
3457
3486
  e,
3458
3487
  r
3459
3488
  )}.`
3460
3489
  );
3461
3490
  } else
3462
- r = De(e, r, i), i = s.charCodeAt(r);
3463
- if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = De(e, r, i), i = s.charCodeAt(r)), (i === 69 || i === 101) && (o = !0, i = s.charCodeAt(++r), (i === 43 || i === 45) && (i = s.charCodeAt(++r)), r = De(e, r, i), i = s.charCodeAt(r)), i === 46 || cn(i))
3491
+ r = qe(e, r, i), i = s.charCodeAt(r);
3492
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = qe(e, r, i), i = s.charCodeAt(r)), (i === 69 || i === 101) && (o = !0, i = s.charCodeAt(++r), (i === 43 || i === 45) && (i = s.charCodeAt(++r)), r = qe(e, r, i), i = s.charCodeAt(r)), i === 46 || ln(i))
3464
3493
  throw b(
3465
3494
  e.source,
3466
3495
  r,
3467
- `Invalid number, expected digit but got: ${G(
3496
+ `Invalid number, expected digit but got: ${X(
3468
3497
  e,
3469
3498
  r
3470
3499
  )}.`
@@ -3477,23 +3506,23 @@ function or(e, t, n) {
3477
3506
  s.slice(t, r)
3478
3507
  );
3479
3508
  }
3480
- function De(e, t, n) {
3481
- if (!ce(n))
3509
+ function qe(e, t, n) {
3510
+ if (!de(n))
3482
3511
  throw b(
3483
3512
  e.source,
3484
3513
  t,
3485
- `Invalid number, expected digit but got: ${G(
3514
+ `Invalid number, expected digit but got: ${X(
3486
3515
  e,
3487
3516
  t
3488
3517
  )}.`
3489
3518
  );
3490
3519
  const s = e.source.body;
3491
3520
  let r = t + 1;
3492
- for (; ce(s.charCodeAt(r)); )
3521
+ for (; de(s.charCodeAt(r)); )
3493
3522
  ++r;
3494
3523
  return r;
3495
3524
  }
3496
- function ar(e, t) {
3525
+ function ur(e, t) {
3497
3526
  const n = e.source.body, s = n.length;
3498
3527
  let r = t + 1, i = r, o = "";
3499
3528
  for (; r < s; ) {
@@ -3502,21 +3531,21 @@ function ar(e, t) {
3502
3531
  return o += n.slice(i, r), w(e, p.STRING, t, r + 1, o);
3503
3532
  if (a === 92) {
3504
3533
  o += n.slice(i, r);
3505
- const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? cr(e, r) : ur(e, r) : dr(e, r);
3534
+ const c = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? dr(e, r) : lr(e, r) : hr(e, r);
3506
3535
  o += c.value, r += c.size, i = r;
3507
3536
  continue;
3508
3537
  }
3509
3538
  if (a === 10 || a === 13)
3510
3539
  break;
3511
- if (ne(a))
3540
+ if (re(a))
3512
3541
  ++r;
3513
- else if (xe(n, r))
3542
+ else if (be(n, r))
3514
3543
  r += 2;
3515
3544
  else
3516
3545
  throw b(
3517
3546
  e.source,
3518
3547
  r,
3519
- `Invalid character within String: ${G(
3548
+ `Invalid character within String: ${X(
3520
3549
  e,
3521
3550
  r
3522
3551
  )}.`
@@ -3524,20 +3553,20 @@ function ar(e, t) {
3524
3553
  }
3525
3554
  throw b(e.source, r, "Unterminated string.");
3526
3555
  }
3527
- function cr(e, t) {
3556
+ function dr(e, t) {
3528
3557
  const n = e.source.body;
3529
3558
  let s = 0, r = 3;
3530
3559
  for (; r < 12; ) {
3531
3560
  const i = n.charCodeAt(t + r++);
3532
3561
  if (i === 125) {
3533
- if (r < 5 || !ne(s))
3562
+ if (r < 5 || !re(s))
3534
3563
  break;
3535
3564
  return {
3536
3565
  value: String.fromCodePoint(s),
3537
3566
  size: r
3538
3567
  };
3539
3568
  }
3540
- if (s = s << 4 | ie(i), s < 0)
3569
+ if (s = s << 4 | ae(i), s < 0)
3541
3570
  break;
3542
3571
  }
3543
3572
  throw b(
@@ -3549,16 +3578,16 @@ function cr(e, t) {
3549
3578
  )}".`
3550
3579
  );
3551
3580
  }
3552
- function ur(e, t) {
3553
- const n = e.source.body, s = Ot(n, t + 2);
3554
- if (ne(s))
3581
+ function lr(e, t) {
3582
+ const n = e.source.body, s = Ct(n, t + 2);
3583
+ if (re(s))
3555
3584
  return {
3556
3585
  value: String.fromCodePoint(s),
3557
3586
  size: 6
3558
3587
  };
3559
- if (un(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3560
- const r = Ot(n, t + 8);
3561
- if (dn(r))
3588
+ if (hn(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
3589
+ const r = Ct(n, t + 8);
3590
+ if (fn(r))
3562
3591
  return {
3563
3592
  value: String.fromCodePoint(s, r),
3564
3593
  size: 12
@@ -3570,13 +3599,13 @@ function ur(e, t) {
3570
3599
  `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
3571
3600
  );
3572
3601
  }
3573
- function Ot(e, t) {
3574
- return ie(e.charCodeAt(t)) << 12 | ie(e.charCodeAt(t + 1)) << 8 | ie(e.charCodeAt(t + 2)) << 4 | ie(e.charCodeAt(t + 3));
3602
+ function Ct(e, t) {
3603
+ return ae(e.charCodeAt(t)) << 12 | ae(e.charCodeAt(t + 1)) << 8 | ae(e.charCodeAt(t + 2)) << 4 | ae(e.charCodeAt(t + 3));
3575
3604
  }
3576
- function ie(e) {
3605
+ function ae(e) {
3577
3606
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
3578
3607
  }
3579
- function dr(e, t) {
3608
+ function hr(e, t) {
3580
3609
  const n = e.source.body;
3581
3610
  switch (n.charCodeAt(t + 1)) {
3582
3611
  case 34:
@@ -3630,7 +3659,7 @@ function dr(e, t) {
3630
3659
  )}".`
3631
3660
  );
3632
3661
  }
3633
- function lr(e, t) {
3662
+ function fr(e, t) {
3634
3663
  const n = e.source.body, s = n.length;
3635
3664
  let r = e.lineStart, i = t + 3, o = i, a = "";
3636
3665
  const c = [];
@@ -3644,7 +3673,7 @@ function lr(e, t) {
3644
3673
  t,
3645
3674
  i + 3,
3646
3675
  // Return a string of the lines joined with U+000A.
3647
- Zs(c).join(`
3676
+ tr(c).join(`
3648
3677
  `)
3649
3678
  );
3650
3679
  return e.line += c.length - 1, e.lineStart = r, h;
@@ -3657,15 +3686,15 @@ function lr(e, t) {
3657
3686
  a += n.slice(o, i), c.push(a), u === 13 && n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, a = "", o = i, r = i;
3658
3687
  continue;
3659
3688
  }
3660
- if (ne(u))
3689
+ if (re(u))
3661
3690
  ++i;
3662
- else if (xe(n, i))
3691
+ else if (be(n, i))
3663
3692
  i += 2;
3664
3693
  else
3665
3694
  throw b(
3666
3695
  e.source,
3667
3696
  i,
3668
- `Invalid character within String: ${G(
3697
+ `Invalid character within String: ${X(
3669
3698
  e,
3670
3699
  i
3671
3700
  )}.`
@@ -3673,12 +3702,12 @@ function lr(e, t) {
3673
3702
  }
3674
3703
  throw b(e.source, i, "Unterminated string.");
3675
3704
  }
3676
- function hr(e, t) {
3705
+ function pr(e, t) {
3677
3706
  const n = e.source.body, s = n.length;
3678
3707
  let r = t + 1;
3679
3708
  for (; r < s; ) {
3680
3709
  const i = n.charCodeAt(r);
3681
- if (Ks(i))
3710
+ if (er(i))
3682
3711
  ++r;
3683
3712
  else
3684
3713
  break;
@@ -3691,56 +3720,56 @@ function hr(e, t) {
3691
3720
  n.slice(t, r)
3692
3721
  );
3693
3722
  }
3694
- const fr = 10, ln = 2;
3695
- function ot(e) {
3696
- return we(e, []);
3723
+ const yr = 10, pn = 2;
3724
+ function ut(e) {
3725
+ return Oe(e, []);
3697
3726
  }
3698
- function we(e, t) {
3727
+ function Oe(e, t) {
3699
3728
  switch (typeof e) {
3700
3729
  case "string":
3701
3730
  return JSON.stringify(e);
3702
3731
  case "function":
3703
3732
  return e.name ? `[function ${e.name}]` : "[function]";
3704
3733
  case "object":
3705
- return pr(e, t);
3734
+ return mr(e, t);
3706
3735
  default:
3707
3736
  return String(e);
3708
3737
  }
3709
3738
  }
3710
- function pr(e, t) {
3739
+ function mr(e, t) {
3711
3740
  if (e === null)
3712
3741
  return "null";
3713
3742
  if (t.includes(e))
3714
3743
  return "[Circular]";
3715
3744
  const n = [...t, e];
3716
- if (yr(e)) {
3745
+ if (gr(e)) {
3717
3746
  const s = e.toJSON();
3718
3747
  if (s !== e)
3719
- return typeof s == "string" ? s : we(s, n);
3748
+ return typeof s == "string" ? s : Oe(s, n);
3720
3749
  } else if (Array.isArray(e))
3721
- return gr(e, n);
3722
- return mr(e, n);
3750
+ return vr(e, n);
3751
+ return Er(e, n);
3723
3752
  }
3724
- function yr(e) {
3753
+ function gr(e) {
3725
3754
  return typeof e.toJSON == "function";
3726
3755
  }
3727
- function mr(e, t) {
3756
+ function Er(e, t) {
3728
3757
  const n = Object.entries(e);
3729
- return n.length === 0 ? "{}" : t.length > ln ? "[" + Er(e) + "]" : "{ " + n.map(
3730
- ([r, i]) => r + ": " + we(i, t)
3758
+ return n.length === 0 ? "{}" : t.length > pn ? "[" + Tr(e) + "]" : "{ " + n.map(
3759
+ ([r, i]) => r + ": " + Oe(i, t)
3731
3760
  ).join(", ") + " }";
3732
3761
  }
3733
- function gr(e, t) {
3762
+ function vr(e, t) {
3734
3763
  if (e.length === 0)
3735
3764
  return "[]";
3736
- if (t.length > ln)
3765
+ if (t.length > pn)
3737
3766
  return "[Array]";
3738
- const n = Math.min(fr, e.length), s = e.length - n, r = [];
3767
+ const n = Math.min(yr, e.length), s = e.length - n, r = [];
3739
3768
  for (let i = 0; i < n; ++i)
3740
- r.push(we(e[i], t));
3769
+ r.push(Oe(e[i], t));
3741
3770
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3742
3771
  }
3743
- function Er(e) {
3772
+ function Tr(e) {
3744
3773
  const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
3745
3774
  if (t === "Object" && typeof e.constructor == "function") {
3746
3775
  const n = e.constructor.name;
@@ -3749,7 +3778,7 @@ function Er(e) {
3749
3778
  }
3750
3779
  return t;
3751
3780
  }
3752
- const vr = (
3781
+ const _r = (
3753
3782
  /* c8 ignore next 6 */
3754
3783
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3755
3784
  globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function(t, n) {
@@ -3764,7 +3793,7 @@ const vr = (
3764
3793
  Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
3765
3794
  );
3766
3795
  if (r === i) {
3767
- const o = ot(t);
3796
+ const o = ut(t);
3768
3797
  throw new Error(`Cannot use ${r} "${o}" from another module or realm.
3769
3798
 
3770
3799
  Ensure that there is only one instance of "graphql" in the node_modules
@@ -3782,15 +3811,15 @@ spurious results.`);
3782
3811
  return !1;
3783
3812
  }
3784
3813
  );
3785
- class hn {
3814
+ class yn {
3786
3815
  constructor(t, n = "GraphQL request", s = {
3787
3816
  line: 1,
3788
3817
  column: 1
3789
3818
  }) {
3790
- typeof t == "string" || me(!1, `Body must be a string. Received: ${ot(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || me(
3819
+ typeof t == "string" || Ee(!1, `Body must be a string. Received: ${ut(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || Ee(
3791
3820
  !1,
3792
3821
  "line in locationOffset is 1-indexed and must be positive."
3793
- ), this.locationOffset.column > 0 || me(
3822
+ ), this.locationOffset.column > 0 || Ee(
3794
3823
  !1,
3795
3824
  "column in locationOffset is 1-indexed and must be positive."
3796
3825
  );
@@ -3799,16 +3828,16 @@ class hn {
3799
3828
  return "Source";
3800
3829
  }
3801
3830
  }
3802
- function Tr(e) {
3803
- return vr(e, hn);
3831
+ function Ir(e) {
3832
+ return _r(e, yn);
3804
3833
  }
3805
- function _r(e, t) {
3806
- return new Ir(e, t).parseDocument();
3834
+ function Sr(e, t) {
3835
+ return new Ar(e, t).parseDocument();
3807
3836
  }
3808
- class Ir {
3837
+ class Ar {
3809
3838
  constructor(t, n = {}) {
3810
- const s = Tr(t) ? t : new hn(t);
3811
- this._lexer = new nr(s), this._options = n, this._tokenCounter = 0;
3839
+ const s = Ir(t) ? t : new yn(t);
3840
+ this._lexer = new rr(s), this._options = n, this._tokenCounter = 0;
3812
3841
  }
3813
3842
  /**
3814
3843
  * Converts a name lex token into a name parse node.
@@ -3910,7 +3939,7 @@ class Ir {
3910
3939
  if (this.peek(p.BRACE_L))
3911
3940
  return this.node(t, {
3912
3941
  kind: T.OPERATION_DEFINITION,
3913
- operation: W.QUERY,
3942
+ operation: ee.QUERY,
3914
3943
  name: void 0,
3915
3944
  variableDefinitions: [],
3916
3945
  directives: [],
@@ -3934,11 +3963,11 @@ class Ir {
3934
3963
  const t = this.expectToken(p.NAME);
3935
3964
  switch (t.value) {
3936
3965
  case "query":
3937
- return W.QUERY;
3966
+ return ee.QUERY;
3938
3967
  case "mutation":
3939
- return W.MUTATION;
3968
+ return ee.MUTATION;
3940
3969
  case "subscription":
3941
- return W.SUBSCRIPTION;
3970
+ return ee.SUBSCRIPTION;
3942
3971
  }
3943
3972
  throw this.unexpected(t);
3944
3973
  }
@@ -4505,7 +4534,7 @@ class Ir {
4505
4534
  throw b(
4506
4535
  this._lexer.source,
4507
4536
  this._lexer.token.start,
4508
- `${pe(
4537
+ `${me(
4509
4538
  this._lexer.token
4510
4539
  )} is reserved and cannot be used for an enum value.`
4511
4540
  );
@@ -4764,7 +4793,7 @@ class Ir {
4764
4793
  */
4765
4794
  parseDirectiveLocation() {
4766
4795
  const t = this._lexer.token, n = this.parseName();
4767
- if (Object.prototype.hasOwnProperty.call($e, n.value))
4796
+ if (Object.prototype.hasOwnProperty.call(Ge, n.value))
4768
4797
  return n;
4769
4798
  throw this.unexpected(t);
4770
4799
  }
@@ -4775,7 +4804,7 @@ class Ir {
4775
4804
  * given parsed object.
4776
4805
  */
4777
4806
  node(t, n) {
4778
- return this._options.noLocation !== !0 && (n.loc = new Qs(
4807
+ return this._options.noLocation !== !0 && (n.loc = new Ks(
4779
4808
  t,
4780
4809
  this._lexer.lastToken,
4781
4810
  this._lexer.source
@@ -4798,7 +4827,7 @@ class Ir {
4798
4827
  throw b(
4799
4828
  this._lexer.source,
4800
4829
  n.start,
4801
- `Expected ${fn(t)}, found ${pe(n)}.`
4830
+ `Expected ${mn(t)}, found ${me(n)}.`
4802
4831
  );
4803
4832
  }
4804
4833
  /**
@@ -4820,7 +4849,7 @@ class Ir {
4820
4849
  throw b(
4821
4850
  this._lexer.source,
4822
4851
  n.start,
4823
- `Expected "${t}", found ${pe(n)}.`
4852
+ `Expected "${t}", found ${me(n)}.`
4824
4853
  );
4825
4854
  }
4826
4855
  /**
@@ -4839,7 +4868,7 @@ class Ir {
4839
4868
  return b(
4840
4869
  this._lexer.source,
4841
4870
  n.start,
4842
- `Unexpected ${pe(n)}.`
4871
+ `Unexpected ${me(n)}.`
4843
4872
  );
4844
4873
  }
4845
4874
  /**
@@ -4906,21 +4935,21 @@ class Ir {
4906
4935
  );
4907
4936
  }
4908
4937
  }
4909
- function pe(e) {
4938
+ function me(e) {
4910
4939
  const t = e.value;
4911
- return fn(e.kind) + (t != null ? ` "${t}"` : "");
4940
+ return mn(e.kind) + (t != null ? ` "${t}"` : "");
4912
4941
  }
4913
- function fn(e) {
4914
- return sr(e) ? `"${e}"` : e;
4942
+ function mn(e) {
4943
+ return ir(e) ? `"${e}"` : e;
4915
4944
  }
4916
- function Sr(e) {
4917
- return `"${e.replace(Ar, xr)}"`;
4918
- }
4919
- const Ar = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4920
4945
  function xr(e) {
4921
- return wr[e.charCodeAt(0)];
4946
+ return `"${e.replace(wr, br)}"`;
4947
+ }
4948
+ const wr = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
4949
+ function br(e) {
4950
+ return Or[e.charCodeAt(0)];
4922
4951
  }
4923
- const wr = [
4952
+ const Or = [
4924
4953
  "\\u0000",
4925
4954
  "\\u0001",
4926
4955
  "\\u0002",
@@ -5086,32 +5115,32 @@ const wr = [
5086
5115
  "\\u009D",
5087
5116
  "\\u009E",
5088
5117
  "\\u009F"
5089
- ], br = Object.freeze({});
5090
- function Or(e, t, n = on) {
5118
+ ], Nr = Object.freeze({});
5119
+ function kr(e, t, n = un) {
5091
5120
  const s = /* @__PURE__ */ new Map();
5092
5121
  for (const x of Object.values(T))
5093
- s.set(x, Nr(t, x));
5122
+ s.set(x, Cr(t, x));
5094
5123
  let r, i = Array.isArray(e), o = [e], a = -1, c = [], u = e, h, d;
5095
5124
  const f = [], m = [];
5096
5125
  do {
5097
5126
  a++;
5098
- const x = a === o.length, C = x && c.length !== 0;
5127
+ const x = a === o.length, R = x && c.length !== 0;
5099
5128
  if (x) {
5100
- if (h = m.length === 0 ? void 0 : f[f.length - 1], u = d, d = m.pop(), C)
5129
+ if (h = m.length === 0 ? void 0 : f[f.length - 1], u = d, d = m.pop(), R)
5101
5130
  if (i) {
5102
5131
  u = u.slice();
5103
5132
  let M = 0;
5104
- for (const [z, de] of c) {
5105
- const le = z - M;
5106
- de === null ? (u.splice(le, 1), M++) : u[le] = de;
5133
+ for (const [P, V] of c) {
5134
+ const H = P - M;
5135
+ V === null ? (u.splice(H, 1), M++) : u[H] = V;
5107
5136
  }
5108
5137
  } else {
5109
5138
  u = Object.defineProperties(
5110
5139
  {},
5111
5140
  Object.getOwnPropertyDescriptors(u)
5112
5141
  );
5113
- for (const [M, z] of c)
5114
- u[M] = z;
5142
+ for (const [M, P] of c)
5143
+ u[M] = P;
5115
5144
  }
5116
5145
  a = r.index, o = r.keys, c = r.edits, i = r.inArray, r = r.prev;
5117
5146
  } else if (d) {
@@ -5119,27 +5148,27 @@ function Or(e, t, n = on) {
5119
5148
  continue;
5120
5149
  f.push(h);
5121
5150
  }
5122
- let R;
5151
+ let k;
5123
5152
  if (!Array.isArray(u)) {
5124
5153
  var y, v;
5125
- bt(u) || me(!1, `Invalid AST Node: ${ot(u)}.`);
5154
+ kt(u) || Ee(!1, `Invalid AST Node: ${ut(u)}.`);
5126
5155
  const M = x ? (y = s.get(u.kind)) === null || y === void 0 ? void 0 : y.leave : (v = s.get(u.kind)) === null || v === void 0 ? void 0 : v.enter;
5127
- if (R = M == null ? void 0 : M.call(t, u, h, d, f, m), R === br)
5156
+ if (k = M == null ? void 0 : M.call(t, u, h, d, f, m), k === Nr)
5128
5157
  break;
5129
- if (R === !1) {
5158
+ if (k === !1) {
5130
5159
  if (!x) {
5131
5160
  f.pop();
5132
5161
  continue;
5133
5162
  }
5134
- } else if (R !== void 0 && (c.push([h, R]), !x))
5135
- if (bt(R))
5136
- u = R;
5163
+ } else if (k !== void 0 && (c.push([h, k]), !x))
5164
+ if (kt(k))
5165
+ u = k;
5137
5166
  else {
5138
5167
  f.pop();
5139
5168
  continue;
5140
5169
  }
5141
5170
  }
5142
- if (R === void 0 && C && c.push([h, u]), x)
5171
+ if (k === void 0 && R && c.push([h, u]), x)
5143
5172
  f.pop();
5144
5173
  else {
5145
5174
  var S;
@@ -5154,7 +5183,7 @@ function Or(e, t, n = on) {
5154
5183
  } while (r !== void 0);
5155
5184
  return c.length !== 0 ? c[c.length - 1][1] : e;
5156
5185
  }
5157
- function Nr(e, t) {
5186
+ function Cr(e, t) {
5158
5187
  const n = e[t];
5159
5188
  return typeof n == "object" ? n : typeof n == "function" ? {
5160
5189
  enter: n,
@@ -5164,10 +5193,10 @@ function Nr(e, t) {
5164
5193
  leave: e.leave
5165
5194
  };
5166
5195
  }
5167
- function pn(e) {
5168
- return Or(e, Cr);
5196
+ function gn(e) {
5197
+ return kr(e, Rr);
5169
5198
  }
5170
- const kr = 80, Cr = {
5199
+ const Dr = 80, Rr = {
5171
5200
  Name: {
5172
5201
  leave: (e) => e.value
5173
5202
  },
@@ -5197,14 +5226,14 @@ const kr = 80, Cr = {
5197
5226
  leave: ({ variable: e, type: t, defaultValue: n, directives: s }) => e + ": " + t + I(" = ", n) + I(" ", E(s, " "))
5198
5227
  },
5199
5228
  SelectionSet: {
5200
- leave: ({ selections: e }) => L(e)
5229
+ leave: ({ selections: e }) => q(e)
5201
5230
  },
5202
5231
  Field: {
5203
5232
  leave({ alias: e, name: t, arguments: n, directives: s, selectionSet: r }) {
5204
5233
  const i = I("", e, ": ") + t;
5205
5234
  let o = i + I("(", E(n, ", "), ")");
5206
- return o.length > kr && (o = i + I(`(
5207
- `, ge(E(n, `
5235
+ return o.length > Dr && (o = i + I(`(
5236
+ `, ve(E(n, `
5208
5237
  `)), `
5209
5238
  )`)), E([o, E(s, " "), r], " ");
5210
5239
  }
@@ -5241,7 +5270,7 @@ const kr = 80, Cr = {
5241
5270
  leave: ({ value: e }) => e
5242
5271
  },
5243
5272
  StringValue: {
5244
- leave: ({ value: e, block: t }) => t ? tr(e) : Sr(e)
5273
+ leave: ({ value: e, block: t }) => t ? sr(e) : xr(e)
5245
5274
  },
5246
5275
  BooleanValue: {
5247
5276
  leave: ({ value: e }) => e ? "true" : "false"
@@ -5278,7 +5307,7 @@ const kr = 80, Cr = {
5278
5307
  // Type System Definitions
5279
5308
  SchemaDefinition: {
5280
5309
  leave: ({ description: e, directives: t, operationTypes: n }) => I("", e, `
5281
- `) + E(["schema", E(t, " "), L(n)], " ")
5310
+ `) + E(["schema", E(t, " "), q(n)], " ")
5282
5311
  },
5283
5312
  OperationTypeDefinition: {
5284
5313
  leave: ({ operation: e, type: t }) => e + ": " + t
@@ -5295,15 +5324,15 @@ const kr = 80, Cr = {
5295
5324
  t,
5296
5325
  I("implements ", E(n, " & ")),
5297
5326
  E(s, " "),
5298
- L(r)
5327
+ q(r)
5299
5328
  ],
5300
5329
  " "
5301
5330
  )
5302
5331
  },
5303
5332
  FieldDefinition: {
5304
5333
  leave: ({ description: e, name: t, arguments: n, type: s, directives: r }) => I("", e, `
5305
- `) + t + (Nt(n) ? I(`(
5306
- `, ge(E(n, `
5334
+ `) + t + (Dt(n) ? I(`(
5335
+ `, ve(E(n, `
5307
5336
  `)), `
5308
5337
  )`) : I("(", E(n, ", "), ")")) + ": " + s + I(" ", E(r, " "))
5309
5338
  },
@@ -5322,7 +5351,7 @@ const kr = 80, Cr = {
5322
5351
  t,
5323
5352
  I("implements ", E(n, " & ")),
5324
5353
  E(s, " "),
5325
- L(r)
5354
+ q(r)
5326
5355
  ],
5327
5356
  " "
5328
5357
  )
@@ -5336,7 +5365,7 @@ const kr = 80, Cr = {
5336
5365
  },
5337
5366
  EnumTypeDefinition: {
5338
5367
  leave: ({ description: e, name: t, directives: n, values: s }) => I("", e, `
5339
- `) + E(["enum", t, E(n, " "), L(s)], " ")
5368
+ `) + E(["enum", t, E(n, " "), q(s)], " ")
5340
5369
  },
5341
5370
  EnumValueDefinition: {
5342
5371
  leave: ({ description: e, name: t, directives: n }) => I("", e, `
@@ -5344,18 +5373,18 @@ const kr = 80, Cr = {
5344
5373
  },
5345
5374
  InputObjectTypeDefinition: {
5346
5375
  leave: ({ description: e, name: t, directives: n, fields: s }) => I("", e, `
5347
- `) + E(["input", t, E(n, " "), L(s)], " ")
5376
+ `) + E(["input", t, E(n, " "), q(s)], " ")
5348
5377
  },
5349
5378
  DirectiveDefinition: {
5350
5379
  leave: ({ description: e, name: t, arguments: n, repeatable: s, locations: r }) => I("", e, `
5351
- `) + "directive @" + t + (Nt(n) ? I(`(
5352
- `, ge(E(n, `
5380
+ `) + "directive @" + t + (Dt(n) ? I(`(
5381
+ `, ve(E(n, `
5353
5382
  `)), `
5354
5383
  )`) : I("(", E(n, ", "), ")")) + (s ? " repeatable" : "") + " on " + E(r, " | ")
5355
5384
  },
5356
5385
  SchemaExtension: {
5357
5386
  leave: ({ directives: e, operationTypes: t }) => E(
5358
- ["extend schema", E(e, " "), L(t)],
5387
+ ["extend schema", E(e, " "), q(t)],
5359
5388
  " "
5360
5389
  )
5361
5390
  },
@@ -5369,7 +5398,7 @@ const kr = 80, Cr = {
5369
5398
  e,
5370
5399
  I("implements ", E(t, " & ")),
5371
5400
  E(n, " "),
5372
- L(s)
5401
+ q(s)
5373
5402
  ],
5374
5403
  " "
5375
5404
  )
@@ -5381,7 +5410,7 @@ const kr = 80, Cr = {
5381
5410
  e,
5382
5411
  I("implements ", E(t, " & ")),
5383
5412
  E(n, " "),
5384
- L(s)
5413
+ q(s)
5385
5414
  ],
5386
5415
  " "
5387
5416
  )
@@ -5398,72 +5427,72 @@ const kr = 80, Cr = {
5398
5427
  )
5399
5428
  },
5400
5429
  EnumTypeExtension: {
5401
- leave: ({ name: e, directives: t, values: n }) => E(["extend enum", e, E(t, " "), L(n)], " ")
5430
+ leave: ({ name: e, directives: t, values: n }) => E(["extend enum", e, E(t, " "), q(n)], " ")
5402
5431
  },
5403
5432
  InputObjectTypeExtension: {
5404
- leave: ({ name: e, directives: t, fields: n }) => E(["extend input", e, E(t, " "), L(n)], " ")
5433
+ leave: ({ name: e, directives: t, fields: n }) => E(["extend input", e, E(t, " "), q(n)], " ")
5405
5434
  }
5406
5435
  };
5407
5436
  function E(e, t = "") {
5408
5437
  var n;
5409
5438
  return (n = e == null ? void 0 : e.filter((s) => s).join(t)) !== null && n !== void 0 ? n : "";
5410
5439
  }
5411
- function L(e) {
5440
+ function q(e) {
5412
5441
  return I(`{
5413
- `, ge(E(e, `
5442
+ `, ve(E(e, `
5414
5443
  `)), `
5415
5444
  }`);
5416
5445
  }
5417
5446
  function I(e, t, n = "") {
5418
5447
  return t != null && t !== "" ? e + t + n : "";
5419
5448
  }
5420
- function ge(e) {
5449
+ function ve(e) {
5421
5450
  return I(" ", e.replace(/\n/g, `
5422
5451
  `));
5423
5452
  }
5424
- function Nt(e) {
5453
+ function Dt(e) {
5425
5454
  var t;
5426
5455
  return (t = e == null ? void 0 : e.some((n) => n.includes(`
5427
5456
  `))) !== null && t !== void 0 ? t : !1;
5428
5457
  }
5429
- const kt = (e) => {
5458
+ const Rt = (e) => {
5430
5459
  var s, r;
5431
5460
  let t;
5432
5461
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
5433
5462
  return n.length === 1 && (t = (r = (s = n[0]) == null ? void 0 : s.name) == null ? void 0 : r.value), t;
5434
- }, Re = (e) => {
5463
+ }, Le = (e) => {
5435
5464
  if (typeof e == "string") {
5436
5465
  let n;
5437
5466
  try {
5438
- const s = _r(e);
5439
- n = kt(s);
5467
+ const s = Sr(e);
5468
+ n = Rt(s);
5440
5469
  } catch {
5441
5470
  }
5442
5471
  return { query: e, operationName: n };
5443
5472
  }
5444
- const t = kt(e);
5445
- return { query: pn(e), operationName: t };
5473
+ const t = Rt(e);
5474
+ return { query: gn(e), operationName: t };
5446
5475
  };
5447
- class oe extends Error {
5476
+ class ce extends Error {
5448
5477
  constructor(t, n) {
5449
- const s = `${oe.extractMessage(t)}: ${JSON.stringify({
5478
+ const s = `${ce.extractMessage(t)}: ${JSON.stringify({
5450
5479
  response: t,
5451
5480
  request: n
5452
5481
  })}`;
5453
- super(s), Object.setPrototypeOf(this, oe.prototype), this.response = t, this.request = n, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, oe);
5482
+ super(s), Object.setPrototypeOf(this, ce.prototype), this.response = t, this.request = n, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, ce);
5454
5483
  }
5455
5484
  static extractMessage(t) {
5456
5485
  var n, s;
5457
5486
  return ((s = (n = t.errors) == null ? void 0 : n[0]) == null ? void 0 : s.message) ?? `GraphQL Error (Code: ${t.status})`;
5458
5487
  }
5459
5488
  }
5460
- var Dr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5461
- function Rr(e) {
5489
+ var Mr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5490
+ function qr(e) {
5462
5491
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5463
5492
  }
5464
- var He = { exports: {} };
5493
+ var Je = { exports: {} };
5465
5494
  (function(e, t) {
5466
- var n = typeof self < "u" ? self : Dr, s = function() {
5495
+ var n = typeof self < "u" ? self : Mr, s = function() {
5467
5496
  function i() {
5468
5497
  this.fetch = !1, this.DOMException = n.DOMException;
5469
5498
  }
@@ -5578,11 +5607,11 @@ var He = { exports: {} };
5578
5607
  var g = new FileReader(), _ = S(g);
5579
5608
  return g.readAsArrayBuffer(l), _;
5580
5609
  }
5581
- function C(l) {
5610
+ function R(l) {
5582
5611
  var g = new FileReader(), _ = S(g);
5583
5612
  return g.readAsText(l), _;
5584
5613
  }
5585
- function R(l) {
5614
+ function k(l) {
5586
5615
  for (var g = new Uint8Array(l), _ = new Array(g.length), N = 0; N < g.length; N++)
5587
5616
  _[N] = String.fromCharCode(g[N]);
5588
5617
  return _.join("");
@@ -5593,7 +5622,7 @@ var He = { exports: {} };
5593
5622
  var g = new Uint8Array(l.byteLength);
5594
5623
  return g.set(new Uint8Array(l)), g.buffer;
5595
5624
  }
5596
- function z() {
5625
+ function P() {
5597
5626
  return this.bodyUsed = !1, this._initBody = function(l) {
5598
5627
  this._bodyInit = l, l ? typeof l == "string" ? this._bodyText = l : a.blob && Blob.prototype.isPrototypeOf(l) ? this._bodyBlob = l : a.formData && FormData.prototype.isPrototypeOf(l) ? this._bodyFormData = l : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) ? this._bodyText = l.toString() : a.arrayBuffer && a.blob && c(l) ? (this._bodyArrayBuffer = M(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || h(l)) ? this._bodyArrayBuffer = M(l) : this._bodyText = l = Object.prototype.toString.call(l) : this._bodyText = "", this.headers.get("content-type") || (typeof l == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
5599
5628
  }, a.blob && (this.blob = function() {
@@ -5614,40 +5643,40 @@ var He = { exports: {} };
5614
5643
  if (l)
5615
5644
  return l;
5616
5645
  if (this._bodyBlob)
5617
- return C(this._bodyBlob);
5646
+ return R(this._bodyBlob);
5618
5647
  if (this._bodyArrayBuffer)
5619
- return Promise.resolve(R(this._bodyArrayBuffer));
5648
+ return Promise.resolve(k(this._bodyArrayBuffer));
5620
5649
  if (this._bodyFormData)
5621
5650
  throw new Error("could not read FormData body as text");
5622
5651
  return Promise.resolve(this._bodyText);
5623
5652
  }, a.formData && (this.formData = function() {
5624
- return this.text().then(En);
5653
+ return this.text().then(he);
5625
5654
  }), this.json = function() {
5626
5655
  return this.text().then(JSON.parse);
5627
5656
  }, this;
5628
5657
  }
5629
- var de = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5630
- function le(l) {
5658
+ var V = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5659
+ function H(l) {
5631
5660
  var g = l.toUpperCase();
5632
- return de.indexOf(g) > -1 ? g : l;
5661
+ return V.indexOf(g) > -1 ? g : l;
5633
5662
  }
5634
- function j(l, g) {
5663
+ function L(l, g) {
5635
5664
  g = g || {};
5636
5665
  var _ = g.body;
5637
- if (l instanceof j) {
5666
+ if (l instanceof L) {
5638
5667
  if (l.bodyUsed)
5639
5668
  throw new TypeError("Already read");
5640
5669
  this.url = l.url, this.credentials = l.credentials, g.headers || (this.headers = new y(l.headers)), this.method = l.method, this.mode = l.mode, this.signal = l.signal, !_ && l._bodyInit != null && (_ = l._bodyInit, l.bodyUsed = !0);
5641
5670
  } else
5642
5671
  this.url = String(l);
5643
- if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = le(g.method || this.method || "GET"), this.mode = g.mode || this.mode || null, this.signal = g.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && _)
5672
+ if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = H(g.method || this.method || "GET"), this.mode = g.mode || this.mode || null, this.signal = g.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && _)
5644
5673
  throw new TypeError("Body not allowed for GET or HEAD requests");
5645
5674
  this._initBody(_);
5646
5675
  }
5647
- j.prototype.clone = function() {
5648
- return new j(this, { body: this._bodyInit });
5676
+ L.prototype.clone = function() {
5677
+ return new L(this, { body: this._bodyInit });
5649
5678
  };
5650
- function En(l) {
5679
+ function he(l) {
5651
5680
  var g = new FormData();
5652
5681
  return l.trim().split("&").forEach(function(_) {
5653
5682
  if (_) {
@@ -5656,36 +5685,36 @@ var He = { exports: {} };
5656
5685
  }
5657
5686
  }), g;
5658
5687
  }
5659
- function vn(l) {
5688
+ function fe(l) {
5660
5689
  var g = new y(), _ = l.replace(/\r?\n[\t ]+/g, " ");
5661
5690
  return _.split(/\r?\n/).forEach(function(N) {
5662
5691
  var O = N.split(":"), A = O.shift().trim();
5663
5692
  if (A) {
5664
- var he = O.join(":").trim();
5665
- g.append(A, he);
5693
+ var pe = O.join(":").trim();
5694
+ g.append(A, pe);
5666
5695
  }
5667
5696
  }), g;
5668
5697
  }
5669
- z.call(j.prototype);
5670
- function q(l, g) {
5698
+ P.call(L.prototype);
5699
+ function U(l, g) {
5671
5700
  g || (g = {}), this.type = "default", this.status = g.status === void 0 ? 200 : g.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in g ? g.statusText : "OK", this.headers = new y(g.headers), this.url = g.url || "", this._initBody(l);
5672
5701
  }
5673
- z.call(q.prototype), q.prototype.clone = function() {
5674
- return new q(this._bodyInit, {
5702
+ P.call(U.prototype), U.prototype.clone = function() {
5703
+ return new U(this._bodyInit, {
5675
5704
  status: this.status,
5676
5705
  statusText: this.statusText,
5677
5706
  headers: new y(this.headers),
5678
5707
  url: this.url
5679
5708
  });
5680
- }, q.error = function() {
5681
- var l = new q(null, { status: 0, statusText: "" });
5709
+ }, U.error = function() {
5710
+ var l = new U(null, { status: 0, statusText: "" });
5682
5711
  return l.type = "error", l;
5683
5712
  };
5684
5713
  var Tn = [301, 302, 303, 307, 308];
5685
- q.redirect = function(l, g) {
5714
+ U.redirect = function(l, g) {
5686
5715
  if (Tn.indexOf(g) === -1)
5687
5716
  throw new RangeError("Invalid status code");
5688
- return new q(null, { status: g, headers: { location: l } });
5717
+ return new U(null, { status: g, headers: { location: l } });
5689
5718
  }, o.DOMException = i.DOMException;
5690
5719
  try {
5691
5720
  new o.DOMException();
@@ -5696,72 +5725,72 @@ var He = { exports: {} };
5696
5725
  this.stack = N.stack;
5697
5726
  }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
5698
5727
  }
5699
- function be(l, g) {
5728
+ function Ne(l, g) {
5700
5729
  return new Promise(function(_, N) {
5701
- var O = new j(l, g);
5730
+ var O = new L(l, g);
5702
5731
  if (O.signal && O.signal.aborted)
5703
5732
  return N(new o.DOMException("Aborted", "AbortError"));
5704
5733
  var A = new XMLHttpRequest();
5705
- function he() {
5734
+ function pe() {
5706
5735
  A.abort();
5707
5736
  }
5708
5737
  A.onload = function() {
5709
- var se = {
5738
+ var ie = {
5710
5739
  status: A.status,
5711
5740
  statusText: A.statusText,
5712
- headers: vn(A.getAllResponseHeaders() || "")
5741
+ headers: fe(A.getAllResponseHeaders() || "")
5713
5742
  };
5714
- se.url = "responseURL" in A ? A.responseURL : se.headers.get("X-Request-URL");
5715
- var Oe = "response" in A ? A.response : A.responseText;
5716
- _(new q(Oe, se));
5743
+ ie.url = "responseURL" in A ? A.responseURL : ie.headers.get("X-Request-URL");
5744
+ var ke = "response" in A ? A.response : A.responseText;
5745
+ _(new U(ke, ie));
5717
5746
  }, A.onerror = function() {
5718
5747
  N(new TypeError("Network request failed"));
5719
5748
  }, A.ontimeout = function() {
5720
5749
  N(new TypeError("Network request failed"));
5721
5750
  }, A.onabort = function() {
5722
5751
  N(new o.DOMException("Aborted", "AbortError"));
5723
- }, A.open(O.method, O.url, !0), O.credentials === "include" ? A.withCredentials = !0 : O.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), O.headers.forEach(function(se, Oe) {
5724
- A.setRequestHeader(Oe, se);
5725
- }), O.signal && (O.signal.addEventListener("abort", he), A.onreadystatechange = function() {
5726
- A.readyState === 4 && O.signal.removeEventListener("abort", he);
5752
+ }, A.open(O.method, O.url, !0), O.credentials === "include" ? A.withCredentials = !0 : O.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), O.headers.forEach(function(ie, ke) {
5753
+ A.setRequestHeader(ke, ie);
5754
+ }), O.signal && (O.signal.addEventListener("abort", pe), A.onreadystatechange = function() {
5755
+ A.readyState === 4 && O.signal.removeEventListener("abort", pe);
5727
5756
  }), A.send(typeof O._bodyInit > "u" ? null : O._bodyInit);
5728
5757
  });
5729
5758
  }
5730
- return be.polyfill = !0, i.fetch || (i.fetch = be, i.Headers = y, i.Request = j, i.Response = q), o.Headers = y, o.Request = j, o.Response = q, o.fetch = be, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5759
+ return Ne.polyfill = !0, i.fetch || (i.fetch = Ne, i.Headers = y, i.Request = L, i.Response = U), o.Headers = y, o.Request = L, o.Response = U, o.fetch = Ne, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5731
5760
  })({});
5732
5761
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5733
5762
  var r = s;
5734
5763
  t = r.fetch, t.default = r.fetch, t.fetch = r.fetch, t.Headers = r.Headers, t.Request = r.Request, t.Response = r.Response, e.exports = t;
5735
- })(He, He.exports);
5736
- var Ie = He.exports;
5737
- const Ee = /* @__PURE__ */ Rr(Ie), Mr = /* @__PURE__ */ In({
5764
+ })(Je, Je.exports);
5765
+ var Ae = Je.exports;
5766
+ const Te = /* @__PURE__ */ qr(Ae), Lr = /* @__PURE__ */ In({
5738
5767
  __proto__: null,
5739
- default: Ee
5740
- }, [Ie]), Y = (e) => {
5768
+ default: Te
5769
+ }, [Ae]), W = (e) => {
5741
5770
  let t = {};
5742
- return e && (typeof Headers < "u" && e instanceof Headers || Mr && Ie.Headers && e instanceof Ie.Headers ? t = Bs(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5771
+ return e && (typeof Headers < "u" && e instanceof Headers || Lr && Ae.Headers && e instanceof Ae.Headers ? t = $s(e) : Array.isArray(e) ? e.forEach(([n, s]) => {
5743
5772
  n && s !== void 0 && (t[n] = s);
5744
5773
  }) : t = e), t;
5745
- }, Ct = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), Lr = (e) => {
5774
+ }, Mt = (e) => e.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim(), Ur = (e) => {
5746
5775
  if (!Array.isArray(e.query)) {
5747
- const s = e, r = [`query=${encodeURIComponent(Ct(s.query))}`];
5776
+ const s = e, r = [`query=${encodeURIComponent(Mt(s.query))}`];
5748
5777
  return e.variables && r.push(`variables=${encodeURIComponent(s.jsonSerializer.stringify(s.variables))}`), s.operationName && r.push(`operationName=${encodeURIComponent(s.operationName)}`), r.join("&");
5749
5778
  }
5750
5779
  if (typeof e.variables < "u" && !Array.isArray(e.variables))
5751
5780
  throw new Error("Cannot create query with given variable type, array expected");
5752
5781
  const t = e, n = e.query.reduce((s, r, i) => (s.push({
5753
- query: Ct(r),
5782
+ query: Mt(r),
5754
5783
  variables: t.variables ? t.jsonSerializer.stringify(t.variables[i]) : void 0
5755
5784
  }), s), []);
5756
5785
  return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
5757
- }, qr = (e) => async (t) => {
5786
+ }, Pr = (e) => async (t) => {
5758
5787
  const { url: n, query: s, variables: r, operationName: i, fetch: o, fetchOptions: a, middleware: c } = t, u = { ...t.headers };
5759
5788
  let h = "", d;
5760
- e === "POST" ? (d = Pr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = Lr({
5789
+ e === "POST" ? (d = Fr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : h = Ur({
5761
5790
  query: s,
5762
5791
  variables: r,
5763
5792
  operationName: i,
5764
- jsonSerializer: a.jsonSerializer ?? rt
5793
+ jsonSerializer: a.jsonSerializer ?? at
5765
5794
  });
5766
5795
  const f = {
5767
5796
  method: e,
@@ -5776,19 +5805,19 @@ const Ee = /* @__PURE__ */ Rr(Ie), Mr = /* @__PURE__ */ In({
5776
5805
  }
5777
5806
  return h && (m = `${m}?${h}`), await o(m, y);
5778
5807
  };
5779
- class yn {
5808
+ class En {
5780
5809
  constructor(t, n = {}) {
5781
5810
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5782
- const [r, i, o] = s, a = $s(r, i, o), { headers: c, fetch: u = Ee, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5811
+ const [r, i, o] = s, a = Hs(r, i, o), { headers: c, fetch: u = Te, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5783
5812
  a.signal !== void 0 && (m.signal = a.signal);
5784
- const { operationName: v } = Re(a.query);
5785
- return Me({
5813
+ const { operationName: v } = Le(a.query);
5814
+ return Ue({
5786
5815
  url: y,
5787
5816
  query: a.query,
5788
5817
  variables: a.variables,
5789
5818
  headers: {
5790
- ...Y(Le(c)),
5791
- ...Y(a.requestHeaders)
5819
+ ...W(Pe(c)),
5820
+ ...W(a.requestHeaders)
5792
5821
  },
5793
5822
  operationName: v,
5794
5823
  fetch: u,
@@ -5801,16 +5830,16 @@ class yn {
5801
5830
  };
5802
5831
  }
5803
5832
  async request(t, ...n) {
5804
- const [s, r] = n, i = js(t, s, r), { headers: o, fetch: a = Ee, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5833
+ const [s, r] = n, i = Vs(t, s, r), { headers: o, fetch: a = Te, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5805
5834
  i.signal !== void 0 && (d.signal = i.signal);
5806
- const { query: m, operationName: y } = Re(i.document);
5807
- return Me({
5835
+ const { query: m, operationName: y } = Le(i.document);
5836
+ return Ue({
5808
5837
  url: f,
5809
5838
  query: m,
5810
5839
  variables: i.variables,
5811
5840
  headers: {
5812
- ...Y(Le(o)),
5813
- ...Y(i.requestHeaders)
5841
+ ...W(Pe(o)),
5842
+ ...W(i.requestHeaders)
5814
5843
  },
5815
5844
  operationName: y,
5816
5845
  fetch: a,
@@ -5823,20 +5852,20 @@ class yn {
5823
5852
  }
5824
5853
  // prettier-ignore
5825
5854
  batchRequests(t, n) {
5826
- const s = Vs(t, n), { headers: r, ...i } = this.requestConfig;
5855
+ const s = Gs(t, n), { headers: r, ...i } = this.requestConfig;
5827
5856
  s.signal !== void 0 && (i.signal = s.signal);
5828
- const o = s.documents.map(({ document: c }) => Re(c).query), a = s.documents.map(({ variables: c }) => c);
5829
- return Me({
5857
+ const o = s.documents.map(({ document: c }) => Le(c).query), a = s.documents.map(({ variables: c }) => c);
5858
+ return Ue({
5830
5859
  url: this.url,
5831
5860
  query: o,
5832
5861
  // @ts-expect-error TODO reconcile batch variables into system.
5833
5862
  variables: a,
5834
5863
  headers: {
5835
- ...Y(Le(r)),
5836
- ...Y(s.requestHeaders)
5864
+ ...W(Pe(r)),
5865
+ ...W(s.requestHeaders)
5837
5866
  },
5838
5867
  operationName: void 0,
5839
- fetch: this.requestConfig.fetch ?? Ee,
5868
+ fetch: this.requestConfig.fetch ?? Te,
5840
5869
  method: this.requestConfig.method || "POST",
5841
5870
  fetchOptions: i,
5842
5871
  middleware: this.requestConfig.requestMiddleware
@@ -5861,8 +5890,8 @@ class yn {
5861
5890
  return this.url = t, this;
5862
5891
  }
5863
5892
  }
5864
- const Me = async (e) => {
5865
- const { query: t, variables: n, fetchOptions: s } = e, r = qr(Us(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Fr(o, s.jsonSerializer ?? rt), c = Array.isArray(a) ? !a.some(({ data: h }) => !h) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5893
+ const Ue = async (e) => {
5894
+ const { query: t, variables: n, fetchOptions: s } = e, r = Pr(js(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Br(o, s.jsonSerializer ?? at), c = Array.isArray(a) ? !a.some(({ data: h }) => !h) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5866
5895
  if (o.ok && u && c) {
5867
5896
  const { errors: h, ...d } = (Array.isArray(a), a), f = s.errorPolicy === "ignore" ? d : a;
5868
5897
  return {
@@ -5874,33 +5903,33 @@ const Me = async (e) => {
5874
5903
  const h = typeof a == "string" ? {
5875
5904
  error: a
5876
5905
  } : a;
5877
- throw new oe(
5906
+ throw new ce(
5878
5907
  // @ts-expect-error TODO
5879
5908
  { ...h, status: o.status, headers: o.headers },
5880
5909
  { query: t, variables: n }
5881
5910
  );
5882
5911
  }
5883
5912
  };
5884
- async function mn(e, t, ...n) {
5885
- const s = Hs(e, t, ...n);
5886
- return new yn(s.url).request({
5913
+ async function dt(e, t, ...n) {
5914
+ const s = zs(e, t, ...n);
5915
+ return new En(s.url).request({
5887
5916
  ...s
5888
5917
  });
5889
5918
  }
5890
- const Pr = (e, t, n, s) => {
5891
- const r = s ?? rt;
5919
+ const Fr = (e, t, n, s) => {
5920
+ const r = s ?? at;
5892
5921
  if (!Array.isArray(e))
5893
5922
  return r.stringify({ query: e, variables: t, operationName: n });
5894
5923
  if (typeof t < "u" && !Array.isArray(t))
5895
5924
  throw new Error("Cannot create request body with given variable type, array expected");
5896
5925
  const i = e.reduce((o, a, c) => (o.push({ query: a, variables: t ? t[c] : void 0 }), o), []);
5897
5926
  return r.stringify(i);
5898
- }, Fr = async (e, t) => {
5927
+ }, Br = async (e, t) => {
5899
5928
  let n;
5900
5929
  return e.headers.forEach((s, r) => {
5901
5930
  r.toLowerCase() === "content-type" && (n = s);
5902
5931
  }), n && (n.toLowerCase().startsWith("application/json") || n.toLowerCase().startsWith("application/graphql+json") || n.toLowerCase().startsWith("application/graphql-response+json")) ? t.parse(await e.text()) : e.text();
5903
- }, Le = (e) => typeof e == "function" ? e() : e, Ur = K(
5932
+ }, Pe = (e) => typeof e == "function" ? e() : e, jr = J(
5904
5933
  async ({ input: e }) => {
5905
5934
  var t;
5906
5935
  if (!e.endpoint || e.endpoint === "")
@@ -5912,7 +5941,7 @@ const Pr = (e, t, n, s) => {
5912
5941
  if (!e.requestHeaders)
5913
5942
  throw new Error("No request headers provided.");
5914
5943
  try {
5915
- const n = await mn(
5944
+ const n = await dt(
5916
5945
  e.endpoint,
5917
5946
  e.document,
5918
5947
  { items: e.items },
@@ -5929,14 +5958,14 @@ const Pr = (e, t, n, s) => {
5929
5958
  throw new Error("Request to add item(s) failed.");
5930
5959
  }
5931
5960
  }
5932
- ), Br = K(async ({ input: e }) => {
5961
+ ), $r = J(async ({ input: e }) => {
5933
5962
  var t;
5934
5963
  if (!e.endpoint || e.endpoint === "")
5935
5964
  throw new Error("No endpoint provided.");
5936
5965
  if (e.items.length < 1)
5937
5966
  throw new Error("No items provided.");
5938
5967
  try {
5939
- const n = await mn(
5968
+ const n = await dt(
5940
5969
  e.endpoint,
5941
5970
  ""
5942
5971
  // input.document,
@@ -5953,7 +5982,7 @@ const Pr = (e, t, n, s) => {
5953
5982
  } catch {
5954
5983
  throw new Error("Request to remove item(s) failed.");
5955
5984
  }
5956
- }), qe = typeof window > "u", jr = K(
5985
+ }), Fe = typeof window > "u", Vr = J(
5957
5986
  async ({ input: e }) => {
5958
5987
  var n, s, r, i;
5959
5988
  if (!e.endpoint)
@@ -5966,9 +5995,9 @@ const Pr = (e, t, n, s) => {
5966
5995
  throw console.log("no request document"), new Error("No request document provided.");
5967
5996
  if (!e.requestHeaders)
5968
5997
  throw console.log("no headers"), new Error("No request headers provided.");
5969
- const t = new yn(
5970
- qe ? e.endpointSsr : e.endpoint,
5971
- qe ? { fetch, method: "POST" } : {
5998
+ const t = new En(
5999
+ Fe ? e.endpointSsr : e.endpoint,
6000
+ Fe ? { fetch, method: "POST" } : {
5972
6001
  credentials: "include",
5973
6002
  method: "POST",
5974
6003
  mode: "cors"
@@ -5976,9 +6005,9 @@ const Pr = (e, t, n, s) => {
5976
6005
  );
5977
6006
  try {
5978
6007
  const { data: o, headers: a, status: c, errors: u, extensions: h } = await t.rawRequest(
5979
- pn(e.document),
6008
+ gn(e.document),
5980
6009
  {},
5981
- qe ? {
6010
+ Fe ? {
5982
6011
  ...e.requestHeaders,
5983
6012
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
5984
6013
  } : e.requestHeaders
@@ -5995,7 +6024,34 @@ const Pr = (e, t, n, s) => {
5995
6024
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
5996
6025
  }
5997
6026
  }
5998
- ), $r = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Vr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Dt = Ae({
6027
+ ), Hr = J(async ({ input: e }) => {
6028
+ var t;
6029
+ if (!e.endpoint || e.endpoint === "")
6030
+ throw new Error("No endpoint provided.");
6031
+ if (e.items.length < 1)
6032
+ throw new Error("No items provided.");
6033
+ if (!e.document)
6034
+ throw new Error("No request document provided.");
6035
+ if (!e.requestHeaders)
6036
+ throw new Error("No request headers provided.");
6037
+ try {
6038
+ const n = await dt(
6039
+ e.endpoint,
6040
+ e.document,
6041
+ { items: e.items },
6042
+ e.requestHeaders
6043
+ );
6044
+ if (!((t = n.quoteUpdateItem) != null && t.quote))
6045
+ throw new Error("Could not add items to quote.");
6046
+ return {
6047
+ type: "UPDATE_ITEMS_SUCCESS",
6048
+ quote: n.quoteUpdateItem.quote,
6049
+ itemsUpdated: n.quoteUpdateItem.itemsUpdated
6050
+ };
6051
+ } catch {
6052
+ throw new Error("Request to add item(s) failed.");
6053
+ }
6054
+ }), Gr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", zr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, qt = we({
5999
6055
  types: {
6000
6056
  context: {},
6001
6057
  emitted: {},
@@ -6004,26 +6060,29 @@ const Pr = (e, t, n, s) => {
6004
6060
  },
6005
6061
  actions: {
6006
6062
  addItems: D(Ms),
6007
- notifyAddItems: Tt(Ls),
6008
- notifyRemoveItems: Tt(qs),
6063
+ notifyAddItems: Re(qs),
6064
+ notifyRemoveItems: Re(Ls),
6065
+ notifyUpdateItems: Re(Us),
6009
6066
  removeItems: D(Ps),
6010
- refresh: D(Fs)
6067
+ refresh: D(Fs),
6068
+ updateItems: D(Bs)
6011
6069
  },
6012
6070
  actors: {
6013
- addItems: Ur,
6014
- removeItems: Br,
6015
- refresh: jr
6071
+ addItems: jr,
6072
+ removeItems: $r,
6073
+ refresh: Vr,
6074
+ updateItems: Hr
6016
6075
  },
6017
6076
  guards: {
6018
- canRefresh: $r,
6019
- hasItems: Vr
6077
+ canRefresh: Gr,
6078
+ hasItems: zr
6020
6079
  }
6021
6080
  }).createMachine({
6022
6081
  /** @todo do we need to add the view to the id? (e.g. quote_en-us) */
6023
6082
  id: "quote",
6024
6083
  initial: "initializing",
6025
6084
  context: ({ input: e }) => {
6026
- var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, S, x, C;
6085
+ var t, n, s, r, i, o, a, c, u, h, d, f, m, y, v, S, x, R, k, M, P, V, H, L, he, fe;
6027
6086
  return {
6028
6087
  quote: {
6029
6088
  id: "",
@@ -6091,8 +6150,12 @@ const Pr = (e, t, n, s) => {
6091
6150
  requestHeaders: ((y = (m = (f = e == null ? void 0 : e.initialContext) == null ? void 0 : f.graphql) == null ? void 0 : m.addItems) == null ? void 0 : y.requestHeaders) ?? void 0
6092
6151
  },
6093
6152
  removeItems: {
6094
- document: ((S = (v = e.initialContext.graphql) == null ? void 0 : v.removeItems) == null ? void 0 : S.document) ?? "",
6095
- requestHeaders: ((C = (x = e.initialContext.graphql) == null ? void 0 : x.removeItems) == null ? void 0 : C.requestHeaders) ?? void 0
6153
+ document: ((x = (S = (v = e == null ? void 0 : e.initialContext) == null ? void 0 : v.graphql) == null ? void 0 : S.removeItems) == null ? void 0 : x.document) ?? "",
6154
+ requestHeaders: ((M = (k = (R = e == null ? void 0 : e.initialContext) == null ? void 0 : R.graphql) == null ? void 0 : k.removeItems) == null ? void 0 : M.requestHeaders) ?? void 0
6155
+ },
6156
+ updateItems: {
6157
+ document: ((H = (V = (P = e == null ? void 0 : e.initialContext) == null ? void 0 : P.graphql) == null ? void 0 : V.updateItems) == null ? void 0 : H.document) ?? "",
6158
+ requestHeaders: ((fe = (he = (L = e == null ? void 0 : e.initialContext) == null ? void 0 : L.graphql) == null ? void 0 : he.updateItems) == null ? void 0 : fe.requestHeaders) ?? void 0
6096
6159
  }
6097
6160
  }
6098
6161
  };
@@ -6111,7 +6174,8 @@ const Pr = (e, t, n, s) => {
6111
6174
  */
6112
6175
  empty: {
6113
6176
  on: {
6114
- ADD_ITEMS: "addingItems"
6177
+ ADD_ITEMS: "addingItems",
6178
+ UPDATE_ITEMS: "updatingItems"
6115
6179
  }
6116
6180
  },
6117
6181
  /**
@@ -6121,7 +6185,8 @@ const Pr = (e, t, n, s) => {
6121
6185
  on: {
6122
6186
  ADD_ITEMS: "addingItems",
6123
6187
  REMOVE_ITEMS: "removingItems",
6124
- REFRESH: "refreshing"
6188
+ REFRESH: "refreshing",
6189
+ UPDATE_ITEMS: "updatingItems"
6125
6190
  // CLEAR_ITEMS: 'clearing',
6126
6191
  // APPLY_PROMOTION: 'applyingPromotion',
6127
6192
  // REMOVE_PROMOTION: 'removingPromotion',
@@ -6258,36 +6323,78 @@ const Pr = (e, t, n, s) => {
6258
6323
  }
6259
6324
  ]
6260
6325
  }
6261
- // invoke: {
6262
- // /** @todo is there any way to limit the event to be a known event? */
6263
- // input: ({ context, event }) => ({
6264
- // endpoint: context.endpoints.client,
6265
- // items: event.type === 'REMOVE_ITEMS' ? event.items : [],
6266
- // document: context.graphql.removeItems?.document,
6267
- // requestHeaders: context.graphql.removeItems?.requestHeaders,
6268
- // }),
6269
- // src: 'removeItems',
6270
- // onDone: [
6271
- // {
6272
- // actions: ['removeItems'],
6273
- // guard: 'hasItems',
6274
- // target: 'active',
6275
- // },
6276
- // { target: 'empty' },
6277
- // ],
6278
- // onError: [
6279
- // {
6280
- // /** @todo log error? */
6281
- // // actions: ['addItems'],
6282
- // guard: 'hasItems',
6283
- // target: 'active',
6284
- // },
6285
- // {
6286
- // target: 'empty',
6287
- // },
6288
- // ],
6289
- // },
6326
+ },
6327
+ /**
6328
+ * Updating quote item(s):
6329
+ * Used for stateful updates to quote like number input on cart
6330
+ * or B2B grids where we are passing actual quantity instead of
6331
+ * incrementing or decrementing by N
6332
+ *
6333
+ * For example: { sku: "ABC", quantity: 5 } we want to update the
6334
+ * quantity from N -> 5 instead of incrementing/decrementing by 5
6335
+ */
6336
+ updatingItems: {
6337
+ invoke: {
6338
+ /** @todo is there any way to limit the event to be a known event? */
6339
+ input: ({ context: e, event: t }) => {
6340
+ var n, s;
6341
+ return {
6342
+ endpoint: e.endpoints.client,
6343
+ items: t.type === "UPDATE_ITEMS" ? t.items : [],
6344
+ document: (n = e.graphql.updateItems) == null ? void 0 : n.document,
6345
+ requestHeaders: (s = e.graphql.updateItems) == null ? void 0 : s.requestHeaders
6346
+ };
6347
+ },
6348
+ src: "updateItems",
6349
+ onDone: [
6350
+ {
6351
+ actions: ["updateItems", "notifyUpdateItems"],
6352
+ target: "checkingItems"
6353
+ }
6354
+ ],
6355
+ onError: [
6356
+ {
6357
+ /** @todo log error? */
6358
+ // actions: ['addItems'],
6359
+ guard: "hasItems",
6360
+ target: "active"
6361
+ },
6362
+ {
6363
+ target: "empty"
6364
+ }
6365
+ ]
6366
+ }
6290
6367
  }
6368
+ // invoke: {
6369
+ // /** @todo is there any way to limit the event to be a known event? */
6370
+ // input: ({ context, event }) => ({
6371
+ // endpoint: context.endpoints.client,
6372
+ // items: event.type === 'REMOVE_ITEMS' ? event.items : [],
6373
+ // document: context.graphql.removeItems?.document,
6374
+ // requestHeaders: context.graphql.removeItems?.requestHeaders,
6375
+ // }),
6376
+ // src: 'removeItems',
6377
+ // onDone: [
6378
+ // {
6379
+ // actions: ['removeItems'],
6380
+ // guard: 'hasItems',
6381
+ // target: 'active',
6382
+ // },
6383
+ // { target: 'empty' },
6384
+ // ],
6385
+ // onError: [
6386
+ // {
6387
+ // /** @todo log error? */
6388
+ // // actions: ['addItems'],
6389
+ // guard: 'hasItems',
6390
+ // target: 'active',
6391
+ // },
6392
+ // {
6393
+ // target: 'empty',
6394
+ // },
6395
+ // ],
6396
+ // },
6397
+ // },
6291
6398
  /**
6292
6399
  * Clear all items from quote and reset to empty, generate a new quoteId
6293
6400
  */
@@ -6318,15 +6425,15 @@ const Pr = (e, t, n, s) => {
6318
6425
  // removingGiftCard: {},
6319
6426
  // applyingSettings: {},
6320
6427
  }
6321
- }), gn = ze(
6428
+ }), vn = Xe(
6322
6429
  {}
6323
- ), Kr = () => {
6430
+ ), ti = () => {
6324
6431
  var c;
6325
- const e = Je(gn);
6432
+ const e = Qe(vn);
6326
6433
  if (!e || !e.getSnapshot)
6327
6434
  throw new Error("quoteActor is not properly initialized");
6328
- const [t, n] = Rt(() => e.getSnapshot());
6329
- Mt(() => {
6435
+ const [t, n] = Lt(() => e.getSnapshot());
6436
+ Ut(() => {
6330
6437
  if (!e || !e.getSnapshot) {
6331
6438
  console.error("quoteActor is not properly initialized");
6332
6439
  return;
@@ -6350,21 +6457,21 @@ const Pr = (e, t, n, s) => {
6350
6457
  isRemovingItems: o,
6351
6458
  isUpdatingItems: a
6352
6459
  };
6353
- }, Zr = async (e = {
6460
+ }, ni = async (e = {
6354
6461
  inspect: void 0,
6355
6462
  quote: { id: "", locale: "" },
6356
6463
  endpoints: { client: "", server: "" },
6357
6464
  graphql: {}
6358
6465
  }) => typeof window < "u" ? (console.warn(
6359
6466
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6360
- ), U(Dt, {
6467
+ ), j(qt, {
6361
6468
  inspect: e.inspect,
6362
6469
  input: {
6363
6470
  initialContext: {
6364
6471
  endpoints: e.endpoints
6365
6472
  }
6366
6473
  }
6367
- }).start()) : U(Dt, {
6474
+ }).start()) : j(qt, {
6368
6475
  input: {
6369
6476
  initialContext: {
6370
6477
  endpoints: e.endpoints,
@@ -6377,23 +6484,23 @@ const Pr = (e, t, n, s) => {
6377
6484
  },
6378
6485
  inspect: e.inspect
6379
6486
  }).start();
6380
- function ei({ actor: e, children: t }) {
6381
- return /* @__PURE__ */ Ge(gn.Provider, { value: e, children: t });
6487
+ function si({ actor: e, children: t }) {
6488
+ return /* @__PURE__ */ Ye(vn.Provider, { value: e, children: t });
6382
6489
  }
6383
6490
  export {
6384
- tn as AuthContext,
6385
- Yr as AuthProvider,
6386
- gn as QuoteContext,
6387
- ei as QuoteProvider,
6388
- nn as ToastContext,
6389
- Wr as ToastProvider,
6390
- At as authMachine,
6391
- Jr as getAuth,
6392
- Zr as getQuote,
6393
- Dt as quoteMachine,
6491
+ rn as AuthContext,
6492
+ Wr as AuthProvider,
6493
+ vn as QuoteContext,
6494
+ si as QuoteProvider,
6495
+ on as ToastContext,
6496
+ ei as ToastProvider,
6497
+ bt as authMachine,
6498
+ Qr as getAuth,
6499
+ ni as getQuote,
6500
+ qt as quoteMachine,
6394
6501
  Rs as timerMachine,
6395
- Xr as toastMachine,
6396
- zr as useAuth,
6397
- Kr as useQuote,
6398
- Qr as useToast
6502
+ Kr as toastMachine,
6503
+ Xr as useAuth,
6504
+ ti as useQuote,
6505
+ Zr as useToast
6399
6506
  };