@clicktap/state 0.13.5 → 0.13.7

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
1
  import { jsx as Ge } from "react/jsx-runtime";
2
- import { createContext as ze, useContext as Je, useState as Pe, useEffect as Rt, cloneElement as Tn } from "react";
2
+ import { createContext as ze, useContext as Je, useState as Dt, useEffect as Rt, cloneElement as Tn } from "react";
3
3
  function _n(e, t) {
4
4
  for (var n = 0; n < t.length; n++) {
5
5
  const s = t[n];
@@ -120,19 +120,19 @@ function Rn(e, t) {
120
120
  id: S,
121
121
  startedAt: Date.now()
122
122
  }, R = ct(h, S);
123
- d._snapshot._scheduledEvents[R] = A;
123
+ l._snapshot._scheduledEvents[R] = A;
124
124
  const D = a.setTimeout(() => {
125
- delete o[R], delete d._snapshot._scheduledEvents[R], d._relay(h, m, y);
125
+ delete o[R], delete l._snapshot._scheduledEvents[R], l._relay(h, m, y);
126
126
  }, v);
127
127
  o[R] = D;
128
128
  },
129
129
  cancel: (h, m) => {
130
130
  const y = ct(h, m), v = o[y];
131
- delete o[y], delete d._snapshot._scheduledEvents[y], a.clearTimeout(v);
131
+ delete o[y], delete l._snapshot._scheduledEvents[y], a.clearTimeout(v);
132
132
  },
133
133
  cancelAll: (h) => {
134
- for (const m in d._snapshot._scheduledEvents) {
135
- const y = d._snapshot._scheduledEvents[m];
134
+ for (const m in l._snapshot._scheduledEvents) {
135
+ const y = l._snapshot._scheduledEvents[m];
136
136
  y.source === h && u.cancel(h, y.id);
137
137
  }
138
138
  }
@@ -147,7 +147,7 @@ function Rn(e, t) {
147
147
  var v;
148
148
  return (v = y.next) == null ? void 0 : v.call(y, m);
149
149
  });
150
- }, d = {
150
+ }, l = {
151
151
  _snapshot: {
152
152
  _scheduledEvents: ((t == null ? void 0 : t.snapshot) && t.snapshot.scheduler) ?? {}
153
153
  },
@@ -170,7 +170,7 @@ function Rn(e, t) {
170
170
  },
171
171
  _sendInspectionEvent: f,
172
172
  _relay: (h, m, y) => {
173
- d._sendInspectionEvent({
173
+ l._sendInspectionEvent({
174
174
  type: "@xstate.event",
175
175
  sourceRef: h,
176
176
  actorRef: m,
@@ -180,12 +180,12 @@ function Rn(e, t) {
180
180
  scheduler: u,
181
181
  getSnapshot: () => ({
182
182
  _scheduledEvents: {
183
- ...d._snapshot._scheduledEvents
183
+ ...l._snapshot._scheduledEvents
184
184
  }
185
185
  }),
186
186
  start: () => {
187
- const h = d._snapshot._scheduledEvents;
188
- d._snapshot._scheduledEvents = {};
187
+ const h = l._snapshot._scheduledEvents;
188
+ l._snapshot._scheduledEvents = {};
189
189
  for (const m in h) {
190
190
  const {
191
191
  source: y,
@@ -200,7 +200,7 @@ function Rn(e, t) {
200
200
  _clock: a,
201
201
  _logger: c
202
202
  };
203
- return d;
203
+ return l;
204
204
  }
205
205
  function Ut(e, t) {
206
206
  const n = ut(e), s = ut(t);
@@ -224,7 +224,7 @@ function Ye(e) {
224
224
  return t.push(n), t;
225
225
  }
226
226
  function ut(e) {
227
- if (ls(e))
227
+ if (ds(e))
228
228
  return e.value;
229
229
  if (typeof e != "string")
230
230
  return e;
@@ -245,7 +245,7 @@ function Ln(e) {
245
245
  }
246
246
  return t;
247
247
  }
248
- function lt(e, t) {
248
+ function dt(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];
@@ -281,7 +281,7 @@ function $t(e) {
281
281
  if (!(e === void 0 || e === An))
282
282
  return F(e);
283
283
  }
284
- function dt(e, t, n) {
284
+ function lt(e, t, n) {
285
285
  var i, o, a;
286
286
  const s = typeof e == "object", r = s ? e : void 0;
287
287
  return {
@@ -336,25 +336,25 @@ class qn {
336
336
  this.system = o ? o.system : Rn(this, {
337
337
  clock: r,
338
338
  logger: i
339
- }), f && !o && this.system.inspect(dt(f)), 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
+ }), f && !o && this.system.inspect(lt(f)), 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,
343
343
  logger: this.logger,
344
- defer: (d) => {
345
- this._deferred.push(d);
344
+ defer: (l) => {
345
+ this._deferred.push(l);
346
346
  },
347
347
  system: this.system,
348
- stopChild: (d) => {
349
- if (d._parent !== this)
350
- throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);
351
- d._stop();
348
+ stopChild: (l) => {
349
+ if (l._parent !== this)
350
+ throw new Error(`Cannot stop child actor ${l.id} of ${this.id} because it is not a child`);
351
+ l._stop();
352
352
  },
353
- emit: (d) => {
354
- const h = this.eventListeners.get(d.type);
353
+ emit: (l) => {
354
+ const h = this.eventListeners.get(l.type);
355
355
  if (h)
356
356
  for (const m of Array.from(h))
357
- m(d);
357
+ m(l);
358
358
  }
359
359
  }, this.send = this.send.bind(this), this.system._sendInspectionEvent({
360
360
  type: "@xstate.actor",
@@ -466,7 +466,7 @@ class qn {
466
466
  */
467
467
  subscribe(t, n, s) {
468
468
  var i;
469
- const r = dt(t, n, s);
469
+ const r = lt(t, n, s);
470
470
  if (this._processingStatus !== k.Stopped)
471
471
  this.observers.add(r);
472
472
  else
@@ -709,8 +709,8 @@ function jn(e, t, n, s, {
709
709
  syncSnapshot: c
710
710
  }) {
711
711
  const u = typeof o == "string" ? Xe(t.machine, o) : o, f = typeof r == "function" ? r(n) : r;
712
- let d;
713
- return u && (d = U(u, {
712
+ let l;
713
+ return u && (l = U(u, {
714
714
  id: f,
715
715
  src: o,
716
716
  parent: e.self,
@@ -724,11 +724,11 @@ function jn(e, t, n, s, {
724
724
  })), [H(t, {
725
725
  children: {
726
726
  ...t.children,
727
- [f]: d
727
+ [f]: l
728
728
  }
729
729
  }), {
730
730
  id: r,
731
- actorRef: d
731
+ actorRef: l
732
732
  }];
733
733
  }
734
734
  function $n(e, {
@@ -1193,16 +1193,16 @@ function Be(e, t, n, s, r, i) {
1193
1193
  let a = t.historyValue;
1194
1194
  const c = Xt(e, o, a);
1195
1195
  let u = t;
1196
- r || ([u, a] = as(u, s, n, c, o, a, i)), u = te(u, s, n, c.flatMap((d) => d.actions), i), u = is(u, s, n, c, o, i, a, r);
1196
+ r || ([u, a] = as(u, s, n, c, o, a, i)), u = te(u, s, n, c.flatMap((l) => l.actions), i), u = is(u, s, n, c, o, i, a, r);
1197
1197
  const f = [...o];
1198
- u.status === "done" && (u = te(u, s, n, f.sort((d, h) => h.order - d.order).flatMap((d) => d.exit), i));
1198
+ u.status === "done" && (u = te(u, s, n, f.sort((l, h) => h.order - l.order).flatMap((l) => l.exit), i));
1199
1199
  try {
1200
1200
  return a === t.historyValue && ss(t._nodes, o) ? u : H(u, {
1201
1201
  _nodes: f,
1202
1202
  historyValue: a
1203
1203
  });
1204
- } catch (d) {
1205
- throw d;
1204
+ } catch (l) {
1205
+ throw l;
1206
1206
  }
1207
1207
  }
1208
1208
  function rs(e, t, n, s, r) {
@@ -1215,7 +1215,7 @@ function is(e, t, n, s, r, i, o, a) {
1215
1215
  let c = e;
1216
1216
  const u = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
1217
1217
  os(s, o, f, u), a && f.add(e.machine.root);
1218
- const d = /* @__PURE__ */ new Set();
1218
+ const l = /* @__PURE__ */ new Set();
1219
1219
  for (const h of [...u].sort((m, y) => m.order - y.order)) {
1220
1220
  r.add(h);
1221
1221
  const m = [];
@@ -1232,8 +1232,8 @@ function is(e, t, n, s, r, i, o, a) {
1232
1232
  if (c = te(c, t, n, m, i, h.invoke.map((y) => y.id)), h.type === "final") {
1233
1233
  const y = h.parent;
1234
1234
  let v = (y == null ? void 0 : y.type) === "parallel" ? y : y == null ? void 0 : y.parent, S = v || h;
1235
- for ((y == null ? void 0 : y.type) === "compound" && i.push(qe(y.id, h.output !== void 0 ? Fe(h.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(qe(v.id)), S = v, v = v.parent;
1235
+ for ((y == null ? void 0 : y.type) === "compound" && i.push(qe(y.id, h.output !== void 0 ? Fe(h.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !l.has(v) && Ze(r, v); )
1236
+ l.add(v), i.push(qe(v.id)), S = v, v = v.parent;
1237
1237
  if (v)
1238
1238
  continue;
1239
1239
  c = H(c, {
@@ -1295,17 +1295,17 @@ function Ne(e, t, n, s, r) {
1295
1295
  function as(e, t, n, s, r, i, o) {
1296
1296
  let a = e;
1297
1297
  const c = Ue(s, r, i);
1298
- c.sort((f, d) => d.order - f.order);
1298
+ c.sort((f, l) => l.order - f.order);
1299
1299
  let u;
1300
1300
  for (const f of c)
1301
- for (const d of es(f)) {
1301
+ for (const l of es(f)) {
1302
1302
  let h;
1303
- d.history === "deep" ? h = (m) => Ke(m) && B(m, f) : h = (m) => m.parent === f, u ?? (u = {
1303
+ l.history === "deep" ? h = (m) => Ke(m) && B(m, f) : h = (m) => m.parent === f, u ?? (u = {
1304
1304
  ...i
1305
- }), u[d.id] = Array.from(r).filter(h);
1305
+ }), u[l.id] = Array.from(r).filter(h);
1306
1306
  }
1307
1307
  for (const f of c)
1308
- a = te(a, t, n, [...f.exit, ...f.invoke.map((d) => Vt(d.id))], o), r.delete(f);
1308
+ a = te(a, t, n, [...f.exit, ...f.invoke.map((l) => Vt(l.id))], o), r.delete(f);
1309
1309
  return [a, u || i];
1310
1310
  }
1311
1311
  let pt = !1;
@@ -1325,7 +1325,7 @@ function Kt(e, t, n, s, r, i) {
1325
1325
  }
1326
1326
  });
1327
1327
  try {
1328
- pt = f, f(d, h);
1328
+ pt = f, f(l, h);
1329
1329
  } finally {
1330
1330
  pt = !1;
1331
1331
  }
@@ -1338,7 +1338,7 @@ function Kt(e, t, n, s, r, i) {
1338
1338
  );
1339
1339
  if (!f)
1340
1340
  continue;
1341
- const d = {
1341
+ const l = {
1342
1342
  context: a.context,
1343
1343
  event: t,
1344
1344
  self: n.self,
@@ -1356,7 +1356,7 @@ function Kt(e, t, n, s, r, i) {
1356
1356
  const y = f, [v, S, A] = y.resolve(
1357
1357
  n,
1358
1358
  a,
1359
- d,
1359
+ l,
1360
1360
  h,
1361
1361
  f,
1362
1362
  // this holds all params
@@ -1378,13 +1378,13 @@ function te(e, t, n, s, r, i) {
1378
1378
  function ke(e, t, n, s = []) {
1379
1379
  let r = e;
1380
1380
  const i = [];
1381
- function o(u, f, d) {
1381
+ function o(u, f, l) {
1382
1382
  n.system._sendInspectionEvent({
1383
1383
  type: "@xstate.microstep",
1384
1384
  actorRef: n.self,
1385
1385
  event: f,
1386
1386
  snapshot: u,
1387
- _transitions: d
1387
+ _transitions: l
1388
1388
  }), i.push(u);
1389
1389
  }
1390
1390
  if (t.type === ae)
@@ -1396,8 +1396,8 @@ function ke(e, t, n, s = []) {
1396
1396
  };
1397
1397
  let a = t;
1398
1398
  if (a.type !== Pt) {
1399
- const u = a, f = Mn(u), d = mt(u, r);
1400
- if (f && !d.length)
1399
+ const u = a, f = Mn(u), l = mt(u, r);
1400
+ if (f && !l.length)
1401
1401
  return r = H(e, {
1402
1402
  status: "error",
1403
1403
  error: u.error
@@ -1406,14 +1406,14 @@ function ke(e, t, n, s = []) {
1406
1406
  microstates: i
1407
1407
  };
1408
1408
  r = Be(
1409
- d,
1409
+ l,
1410
1410
  e,
1411
1411
  n,
1412
1412
  a,
1413
1413
  !1,
1414
1414
  // isInitial
1415
1415
  s
1416
- ), o(r, u, d);
1416
+ ), o(r, u, l);
1417
1417
  }
1418
1418
  let c = !0;
1419
1419
  for (; r.status === "active"; ) {
@@ -1455,10 +1455,10 @@ function us(e, t) {
1455
1455
  const n = ve(_e(e, t));
1456
1456
  return zt(e, [...n]);
1457
1457
  }
1458
- function ls(e) {
1458
+ function ds(e) {
1459
1459
  return !!e && typeof e == "object" && "machine" in e && "value" in e;
1460
1460
  }
1461
- const ds = function(t) {
1461
+ const ls = function(t) {
1462
1462
  return Ut(t, this.value);
1463
1463
  }, hs = function(t) {
1464
1464
  return this.tags.has(t);
@@ -1497,7 +1497,7 @@ function ye(e, t) {
1497
1497
  tags: new Set(e._nodes.flatMap((n) => n.tags)),
1498
1498
  children: e.children,
1499
1499
  historyValue: e.historyValue || {},
1500
- matches: ds,
1500
+ matches: ls,
1501
1501
  hasTag: hs,
1502
1502
  can: fs,
1503
1503
  getMeta: ys,
@@ -1521,7 +1521,7 @@ function ms(e, t) {
1521
1521
  hasTag: c,
1522
1522
  matches: u,
1523
1523
  getMeta: f,
1524
- toJSON: d,
1524
+ toJSON: l,
1525
1525
  ...h
1526
1526
  } = e, m = {};
1527
1527
  for (const v in i) {
@@ -1573,8 +1573,8 @@ function gs(e, t, n, s, {
1573
1573
  const u = typeof r == "function" ? r(n, s) : r;
1574
1574
  let f;
1575
1575
  if (typeof o == "string") {
1576
- const d = c && c[o];
1577
- f = typeof d == "function" ? d(n, s) : d;
1576
+ const l = c && c[o];
1577
+ f = typeof l == "function" ? l(n, s) : l;
1578
1578
  } else
1579
1579
  f = typeof o == "function" ? o(n, s) : o;
1580
1580
  return typeof f != "number" && a.push(u), [t, {
@@ -1727,7 +1727,7 @@ function _s(e, {
1727
1727
  const f = Xe(t, o);
1728
1728
  if (!f)
1729
1729
  throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
1730
- const d = U(f, {
1730
+ const l = U(f, {
1731
1731
  id: a.id,
1732
1732
  parent: e.self,
1733
1733
  syncSnapshot: a.syncSnapshot,
@@ -1739,7 +1739,7 @@ function _s(e, {
1739
1739
  src: o,
1740
1740
  systemId: c
1741
1741
  });
1742
- return r[d.id] = d, d;
1742
+ return r[l.id] = l, l;
1743
1743
  } else
1744
1744
  return U(o, {
1745
1745
  id: a.id,
@@ -1805,12 +1805,12 @@ function Ss(e, t, n, s, {
1805
1805
  if (typeof i == "string")
1806
1806
  throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);
1807
1807
  const f = typeof i == "function" ? i(n, s) : i;
1808
- let d;
1808
+ let l;
1809
1809
  if (typeof a == "string") {
1810
1810
  const v = u && u[a];
1811
- d = typeof v == "function" ? v(n, s) : v;
1811
+ l = typeof v == "function" ? v(n, s) : v;
1812
1812
  } else
1813
- d = typeof a == "function" ? a(n, s) : a;
1813
+ l = typeof a == "function" ? a(n, s) : a;
1814
1814
  const h = typeof r == "function" ? r(n, s) : r;
1815
1815
  let m;
1816
1816
  if (typeof h == "string") {
@@ -1822,7 +1822,7 @@ function Ss(e, t, n, s, {
1822
1822
  to: m,
1823
1823
  event: f,
1824
1824
  id: o,
1825
- delay: d
1825
+ delay: l
1826
1826
  }];
1827
1827
  }
1828
1828
  function xs(e, t, n) {
@@ -1870,7 +1870,7 @@ const ws = {}, re = (e) => typeof e == "string" ? {
1870
1870
  } : e;
1871
1871
  class nt {
1872
1872
  constructor(t, n) {
1873
- 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 ? lt(this.config.states, (s, r) => new nt(s, {
1873
+ 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, {
1874
1874
  _parent: this,
1875
1875
  _key: r,
1876
1876
  _machine: this.machine
@@ -1907,7 +1907,7 @@ class nt {
1907
1907
  })
1908
1908
  } : void 0,
1909
1909
  history: this.history,
1910
- states: lt(this.states, (t) => t.definition),
1910
+ states: dt(this.states, (t) => t.definition),
1911
1911
  on: this.on,
1912
1912
  transitions: [...this.transitions.values()].flat().map((t) => ({
1913
1913
  ...t,
@@ -1981,10 +1981,10 @@ class nt {
1981
1981
  let f = !1;
1982
1982
  try {
1983
1983
  f = !c || We(c, u, n, t);
1984
- } catch (d) {
1984
+ } catch (l) {
1985
1985
  const h = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
1986
1986
  throw new Error(`Unable to evaluate guard ${h ? `'${h}' ` : ""}in transition for event '${s}' in state node '${this.id}':
1987
- ${d.message}`);
1987
+ ${l.message}`);
1988
1988
  }
1989
1989
  if (f) {
1990
1990
  r.push(...a.actions), i = a;
@@ -2167,7 +2167,7 @@ class st {
2167
2167
  restoreSnapshot(t, n) {
2168
2168
  const s = {}, r = t.children;
2169
2169
  Object.keys(r).forEach((c) => {
2170
- const u = r[c], f = u.snapshot, d = u.src, h = typeof d == "string" ? Xe(this, d) : d;
2170
+ const u = r[c], f = u.snapshot, l = u.src, h = typeof l == "string" ? Xe(this, l) : l;
2171
2171
  if (!h)
2172
2172
  return;
2173
2173
  const m = U(h, {
@@ -2175,7 +2175,7 @@ class st {
2175
2175
  parent: n.self,
2176
2176
  syncSnapshot: u.syncSnapshot,
2177
2177
  snapshot: f,
2178
- src: d,
2178
+ src: l,
2179
2179
  systemId: u.systemId
2180
2180
  });
2181
2181
  s[c] = m;
@@ -2190,13 +2190,13 @@ class st {
2190
2190
  if (!o.has(c)) {
2191
2191
  o.add(c);
2192
2192
  for (let f in c) {
2193
- const d = c[f];
2194
- if (d && typeof d == "object") {
2195
- if ("xstate$$type" in d && d.xstate$$type === Qe) {
2196
- c[f] = u[d.id];
2193
+ const l = c[f];
2194
+ if (l && typeof l == "object") {
2195
+ if ("xstate$$type" in l && l.xstate$$type === Qe) {
2196
+ c[f] = u[l.id];
2197
2197
  continue;
2198
2198
  }
2199
- a(d, u);
2199
+ a(l, u);
2200
2200
  }
2201
2201
  }
2202
2202
  }
@@ -2533,7 +2533,7 @@ const St = xe({
2533
2533
  }), en = ze(
2534
2534
  {}
2535
2535
  ), jr = () => {
2536
- const e = Je(en), [t, n] = Pe(
2536
+ const e = Je(en), [t, n] = Dt(
2537
2537
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2538
2538
  );
2539
2539
  return Rt(() => {
@@ -2884,11 +2884,11 @@ function Vs(e) {
2884
2884
  }
2885
2885
  function nn(e, t) {
2886
2886
  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}
2887
- `, f = s.split(/\r\n|[\n\r]/g), d = f[r];
2888
- if (d.length > 120) {
2887
+ `, f = s.split(/\r\n|[\n\r]/g), l = f[r];
2888
+ if (l.length > 120) {
2889
2889
  const h = Math.floor(c / 80), m = c % 80, y = [];
2890
- for (let v = 0; v < d.length; v += 80)
2891
- y.push(d.slice(v, v + 80));
2890
+ for (let v = 0; v < l.length; v += 80)
2891
+ y.push(l.slice(v, v + 80));
2892
2892
  return u + xt([
2893
2893
  [`${o} |`, y[0]],
2894
2894
  ...y.slice(1, h + 1).map((v) => ["|", v]),
@@ -2899,7 +2899,7 @@ function nn(e, t) {
2899
2899
  return u + xt([
2900
2900
  // Lines specified like this: ["prefix", "string"],
2901
2901
  [`${o - 1} |`, f[r - 1]],
2902
- [`${o} |`, d],
2902
+ [`${o} |`, l],
2903
2903
  ["|", "^".padStart(c)],
2904
2904
  [`${o + 1} |`, f[r + 1]]
2905
2905
  ]);
@@ -2961,7 +2961,7 @@ class it extends Error {
2961
2961
  */
2962
2962
  constructor(t, ...n) {
2963
2963
  var s, r, i;
2964
- const { nodes: o, source: a, positions: c, path: u, originalError: f, extensions: d } = Hs(n);
2964
+ const { nodes: o, source: a, positions: c, path: u, originalError: f, extensions: l } = Hs(n);
2965
2965
  super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = f ?? void 0, this.nodes = At(
2966
2966
  Array.isArray(o) ? o : o ? [o] : void 0
2967
2967
  );
@@ -2972,7 +2972,7 @@ class it extends Error {
2972
2972
  const m = Bs(
2973
2973
  f == null ? void 0 : f.extensions
2974
2974
  ) ? f == null ? void 0 : f.extensions : void 0;
2975
- this.extensions = (i = d ?? m) !== null && i !== void 0 ? i : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
2975
+ this.extensions = (i = l ?? m) !== null && i !== void 0 ? i : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
2976
2976
  message: {
2977
2977
  writable: !0,
2978
2978
  enumerable: !0
@@ -3235,11 +3235,11 @@ function Xs(e) {
3235
3235
  function Qs(e, t) {
3236
3236
  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, f = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
3237
3237
  (!r || e.length > 70 || u || i || o);
3238
- let d = "";
3238
+ let l = "";
3239
3239
  const h = r && Ve(e.charCodeAt(0));
3240
- return (f && !h || i) && (d += `
3241
- `), d += n, (f || u) && (d += `
3242
- `), '"""' + d + '"""';
3240
+ return (f && !h || i) && (l += `
3241
+ `), l += n, (f || u) && (l += `
3242
+ `), '"""' + l + '"""';
3243
3243
  }
3244
3244
  var p;
3245
3245
  (function(e) {
@@ -3651,7 +3651,7 @@ function ar(e, t) {
3651
3651
  n.slice(t, r)
3652
3652
  );
3653
3653
  }
3654
- const cr = 10, ln = 2;
3654
+ const cr = 10, dn = 2;
3655
3655
  function ot(e) {
3656
3656
  return we(e, []);
3657
3657
  }
@@ -3673,27 +3673,27 @@ function ur(e, t) {
3673
3673
  if (t.includes(e))
3674
3674
  return "[Circular]";
3675
3675
  const n = [...t, e];
3676
- if (lr(e)) {
3676
+ if (dr(e)) {
3677
3677
  const s = e.toJSON();
3678
3678
  if (s !== e)
3679
3679
  return typeof s == "string" ? s : we(s, n);
3680
3680
  } else if (Array.isArray(e))
3681
3681
  return hr(e, n);
3682
- return dr(e, n);
3682
+ return lr(e, n);
3683
3683
  }
3684
- function lr(e) {
3684
+ function dr(e) {
3685
3685
  return typeof e.toJSON == "function";
3686
3686
  }
3687
- function dr(e, t) {
3687
+ function lr(e, t) {
3688
3688
  const n = Object.entries(e);
3689
- return n.length === 0 ? "{}" : t.length > ln ? "[" + fr(e) + "]" : "{ " + n.map(
3689
+ return n.length === 0 ? "{}" : t.length > dn ? "[" + fr(e) + "]" : "{ " + n.map(
3690
3690
  ([r, i]) => r + ": " + we(i, t)
3691
3691
  ).join(", ") + " }";
3692
3692
  }
3693
3693
  function hr(e, t) {
3694
3694
  if (e.length === 0)
3695
3695
  return "[]";
3696
- if (t.length > ln)
3696
+ if (t.length > dn)
3697
3697
  return "[Array]";
3698
3698
  const n = Math.min(cr, e.length), s = e.length - n, r = [];
3699
3699
  for (let i = 0; i < n; ++i)
@@ -3742,7 +3742,7 @@ spurious results.`);
3742
3742
  return !1;
3743
3743
  }
3744
3744
  );
3745
- class dn {
3745
+ class ln {
3746
3746
  constructor(t, n = "GraphQL request", s = {
3747
3747
  line: 1,
3748
3748
  column: 1
@@ -3760,14 +3760,14 @@ class dn {
3760
3760
  }
3761
3761
  }
3762
3762
  function yr(e) {
3763
- return pr(e, dn);
3763
+ return pr(e, ln);
3764
3764
  }
3765
3765
  function mr(e, t) {
3766
3766
  return new gr(e, t).parseDocument();
3767
3767
  }
3768
3768
  class gr {
3769
3769
  constructor(t, n = {}) {
3770
- const s = yr(t) ? t : new dn(t);
3770
+ const s = yr(t) ? t : new ln(t);
3771
3771
  this._lexer = new Ws(s), this._options = n, this._tokenCounter = 0;
3772
3772
  }
3773
3773
  /**
@@ -5051,19 +5051,19 @@ function Sr(e, t, n = rn) {
5051
5051
  const s = /* @__PURE__ */ new Map();
5052
5052
  for (const A of Object.values(T))
5053
5053
  s.set(A, xr(t, A));
5054
- let r, i = Array.isArray(e), o = [e], a = -1, c = [], u = e, f, d;
5054
+ let r, i = Array.isArray(e), o = [e], a = -1, c = [], u = e, f, l;
5055
5055
  const h = [], m = [];
5056
5056
  do {
5057
5057
  a++;
5058
5058
  const A = a === o.length, R = A && c.length !== 0;
5059
5059
  if (A) {
5060
- if (f = m.length === 0 ? void 0 : h[h.length - 1], u = d, d = m.pop(), R)
5060
+ if (f = m.length === 0 ? void 0 : h[h.length - 1], u = l, l = m.pop(), R)
5061
5061
  if (i) {
5062
5062
  u = u.slice();
5063
5063
  let L = 0;
5064
- for (const [z, le] of c) {
5065
- const de = z - L;
5066
- le === null ? (u.splice(de, 1), L++) : u[de] = le;
5064
+ for (const [z, de] of c) {
5065
+ const le = z - L;
5066
+ de === null ? (u.splice(le, 1), L++) : u[le] = de;
5067
5067
  }
5068
5068
  } else {
5069
5069
  u = Object.defineProperties(
@@ -5074,8 +5074,8 @@ function Sr(e, t, n = rn) {
5074
5074
  u[L] = z;
5075
5075
  }
5076
5076
  a = r.index, o = r.keys, c = r.edits, i = r.inArray, r = r.prev;
5077
- } else if (d) {
5078
- if (f = i ? a : o[a], u = d[f], u == null)
5077
+ } else if (l) {
5078
+ if (f = i ? a : o[a], u = l[f], u == null)
5079
5079
  continue;
5080
5080
  h.push(f);
5081
5081
  }
@@ -5084,7 +5084,7 @@ function Sr(e, t, n = rn) {
5084
5084
  var y, v;
5085
5085
  wt(u) || me(!1, `Invalid AST Node: ${ot(u)}.`);
5086
5086
  const L = A ? (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;
5087
- if (D = L == null ? void 0 : L.call(t, u, f, d, h, m), D === Ir)
5087
+ if (D = L == null ? void 0 : L.call(t, u, f, l, h, m), D === Ir)
5088
5088
  break;
5089
5089
  if (D === !1) {
5090
5090
  if (!A) {
@@ -5109,7 +5109,7 @@ function Sr(e, t, n = rn) {
5109
5109
  keys: o,
5110
5110
  edits: c,
5111
5111
  prev: r
5112
- }, i = Array.isArray(u), o = i ? u : (S = n[u.kind]) !== null && S !== void 0 ? S : [], a = -1, c = [], d && m.push(d), d = u;
5112
+ }, i = Array.isArray(u), o = i ? u : (S = n[u.kind]) !== null && S !== void 0 ? S : [], a = -1, c = [], l && m.push(l), l = u;
5113
5113
  }
5114
5114
  } while (r !== void 0);
5115
5115
  return c.length !== 0 ? c[c.length - 1][1] : e;
@@ -5444,8 +5444,8 @@ var He = { exports: {} };
5444
5444
  formData: "FormData" in i,
5445
5445
  arrayBuffer: "ArrayBuffer" in i
5446
5446
  };
5447
- function c(l) {
5448
- return l && DataView.prototype.isPrototypeOf(l);
5447
+ function c(d) {
5448
+ return d && DataView.prototype.isPrototypeOf(d);
5449
5449
  }
5450
5450
  if (a.arrayBuffer)
5451
5451
  var u = [
@@ -5458,21 +5458,21 @@ var He = { exports: {} };
5458
5458
  "[object Uint32Array]",
5459
5459
  "[object Float32Array]",
5460
5460
  "[object Float64Array]"
5461
- ], f = ArrayBuffer.isView || function(l) {
5462
- return l && u.indexOf(Object.prototype.toString.call(l)) > -1;
5461
+ ], f = ArrayBuffer.isView || function(d) {
5462
+ return d && u.indexOf(Object.prototype.toString.call(d)) > -1;
5463
5463
  };
5464
- function d(l) {
5465
- if (typeof l != "string" && (l = String(l)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l))
5464
+ function l(d) {
5465
+ if (typeof d != "string" && (d = String(d)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(d))
5466
5466
  throw new TypeError("Invalid character in header field name");
5467
- return l.toLowerCase();
5467
+ return d.toLowerCase();
5468
5468
  }
5469
- function h(l) {
5470
- return typeof l != "string" && (l = String(l)), l;
5469
+ function h(d) {
5470
+ return typeof d != "string" && (d = String(d)), d;
5471
5471
  }
5472
- function m(l) {
5472
+ function m(d) {
5473
5473
  var g = {
5474
5474
  next: function() {
5475
- var _ = l.shift();
5475
+ var _ = d.shift();
5476
5476
  return { done: _ === void 0, value: _ };
5477
5477
  }
5478
5478
  };
@@ -5480,86 +5480,86 @@ var He = { exports: {} };
5480
5480
  return g;
5481
5481
  }), g;
5482
5482
  }
5483
- function y(l) {
5484
- this.map = {}, l instanceof y ? l.forEach(function(g, _) {
5483
+ function y(d) {
5484
+ this.map = {}, d instanceof y ? d.forEach(function(g, _) {
5485
5485
  this.append(_, g);
5486
- }, this) : Array.isArray(l) ? l.forEach(function(g) {
5486
+ }, this) : Array.isArray(d) ? d.forEach(function(g) {
5487
5487
  this.append(g[0], g[1]);
5488
- }, this) : l && Object.getOwnPropertyNames(l).forEach(function(g) {
5489
- this.append(g, l[g]);
5488
+ }, this) : d && Object.getOwnPropertyNames(d).forEach(function(g) {
5489
+ this.append(g, d[g]);
5490
5490
  }, this);
5491
5491
  }
5492
- y.prototype.append = function(l, g) {
5493
- l = d(l), g = h(g);
5494
- var _ = this.map[l];
5495
- this.map[l] = _ ? _ + ", " + g : g;
5496
- }, y.prototype.delete = function(l) {
5497
- delete this.map[d(l)];
5498
- }, y.prototype.get = function(l) {
5499
- return l = d(l), this.has(l) ? this.map[l] : null;
5500
- }, y.prototype.has = function(l) {
5501
- return this.map.hasOwnProperty(d(l));
5502
- }, y.prototype.set = function(l, g) {
5503
- this.map[d(l)] = h(g);
5504
- }, y.prototype.forEach = function(l, g) {
5492
+ y.prototype.append = function(d, g) {
5493
+ d = l(d), g = h(g);
5494
+ var _ = this.map[d];
5495
+ this.map[d] = _ ? _ + ", " + g : g;
5496
+ }, y.prototype.delete = function(d) {
5497
+ delete this.map[l(d)];
5498
+ }, y.prototype.get = function(d) {
5499
+ return d = l(d), this.has(d) ? this.map[d] : null;
5500
+ }, y.prototype.has = function(d) {
5501
+ return this.map.hasOwnProperty(l(d));
5502
+ }, y.prototype.set = function(d, g) {
5503
+ this.map[l(d)] = h(g);
5504
+ }, y.prototype.forEach = function(d, g) {
5505
5505
  for (var _ in this.map)
5506
- this.map.hasOwnProperty(_) && l.call(g, this.map[_], _, this);
5506
+ this.map.hasOwnProperty(_) && d.call(g, this.map[_], _, this);
5507
5507
  }, y.prototype.keys = function() {
5508
- var l = [];
5508
+ var d = [];
5509
5509
  return this.forEach(function(g, _) {
5510
- l.push(_);
5511
- }), m(l);
5510
+ d.push(_);
5511
+ }), m(d);
5512
5512
  }, y.prototype.values = function() {
5513
- var l = [];
5513
+ var d = [];
5514
5514
  return this.forEach(function(g) {
5515
- l.push(g);
5516
- }), m(l);
5515
+ d.push(g);
5516
+ }), m(d);
5517
5517
  }, y.prototype.entries = function() {
5518
- var l = [];
5518
+ var d = [];
5519
5519
  return this.forEach(function(g, _) {
5520
- l.push([_, g]);
5521
- }), m(l);
5520
+ d.push([_, g]);
5521
+ }), m(d);
5522
5522
  }, a.iterable && (y.prototype[Symbol.iterator] = y.prototype.entries);
5523
- function v(l) {
5524
- if (l.bodyUsed)
5523
+ function v(d) {
5524
+ if (d.bodyUsed)
5525
5525
  return Promise.reject(new TypeError("Already read"));
5526
- l.bodyUsed = !0;
5526
+ d.bodyUsed = !0;
5527
5527
  }
5528
- function S(l) {
5528
+ function S(d) {
5529
5529
  return new Promise(function(g, _) {
5530
- l.onload = function() {
5531
- g(l.result);
5532
- }, l.onerror = function() {
5533
- _(l.error);
5530
+ d.onload = function() {
5531
+ g(d.result);
5532
+ }, d.onerror = function() {
5533
+ _(d.error);
5534
5534
  };
5535
5535
  });
5536
5536
  }
5537
- function A(l) {
5537
+ function A(d) {
5538
5538
  var g = new FileReader(), _ = S(g);
5539
- return g.readAsArrayBuffer(l), _;
5539
+ return g.readAsArrayBuffer(d), _;
5540
5540
  }
5541
- function R(l) {
5541
+ function R(d) {
5542
5542
  var g = new FileReader(), _ = S(g);
5543
- return g.readAsText(l), _;
5543
+ return g.readAsText(d), _;
5544
5544
  }
5545
- function D(l) {
5546
- for (var g = new Uint8Array(l), _ = new Array(g.length), N = 0; N < g.length; N++)
5545
+ function D(d) {
5546
+ for (var g = new Uint8Array(d), _ = new Array(g.length), N = 0; N < g.length; N++)
5547
5547
  _[N] = String.fromCharCode(g[N]);
5548
5548
  return _.join("");
5549
5549
  }
5550
- function L(l) {
5551
- if (l.slice)
5552
- return l.slice(0);
5553
- var g = new Uint8Array(l.byteLength);
5554
- return g.set(new Uint8Array(l)), g.buffer;
5550
+ function L(d) {
5551
+ if (d.slice)
5552
+ return d.slice(0);
5553
+ var g = new Uint8Array(d.byteLength);
5554
+ return g.set(new Uint8Array(d)), g.buffer;
5555
5555
  }
5556
5556
  function z() {
5557
- return this.bodyUsed = !1, this._initBody = function(l) {
5558
- 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 = L(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || f(l)) ? this._bodyArrayBuffer = L(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"));
5557
+ return this.bodyUsed = !1, this._initBody = function(d) {
5558
+ this._bodyInit = d, d ? typeof d == "string" ? this._bodyText = d : a.blob && Blob.prototype.isPrototypeOf(d) ? this._bodyBlob = d : a.formData && FormData.prototype.isPrototypeOf(d) ? this._bodyFormData = d : a.searchParams && URLSearchParams.prototype.isPrototypeOf(d) ? this._bodyText = d.toString() : a.arrayBuffer && a.blob && c(d) ? (this._bodyArrayBuffer = L(d.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(d) || f(d)) ? this._bodyArrayBuffer = L(d) : this._bodyText = d = Object.prototype.toString.call(d) : this._bodyText = "", this.headers.get("content-type") || (typeof d == "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(d) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
5559
5559
  }, a.blob && (this.blob = function() {
5560
- var l = v(this);
5561
- if (l)
5562
- return l;
5560
+ var d = v(this);
5561
+ if (d)
5562
+ return d;
5563
5563
  if (this._bodyBlob)
5564
5564
  return Promise.resolve(this._bodyBlob);
5565
5565
  if (this._bodyArrayBuffer)
@@ -5570,9 +5570,9 @@ var He = { exports: {} };
5570
5570
  }, this.arrayBuffer = function() {
5571
5571
  return this._bodyArrayBuffer ? v(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(A);
5572
5572
  }), this.text = function() {
5573
- var l = v(this);
5574
- if (l)
5575
- return l;
5573
+ var d = v(this);
5574
+ if (d)
5575
+ return d;
5576
5576
  if (this._bodyBlob)
5577
5577
  return R(this._bodyBlob);
5578
5578
  if (this._bodyArrayBuffer)
@@ -5586,38 +5586,38 @@ var He = { exports: {} };
5586
5586
  return this.text().then(JSON.parse);
5587
5587
  }, this;
5588
5588
  }
5589
- var le = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5590
- function de(l) {
5591
- var g = l.toUpperCase();
5592
- return le.indexOf(g) > -1 ? g : l;
5589
+ var de = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5590
+ function le(d) {
5591
+ var g = d.toUpperCase();
5592
+ return de.indexOf(g) > -1 ? g : d;
5593
5593
  }
5594
- function j(l, g) {
5594
+ function j(d, g) {
5595
5595
  g = g || {};
5596
5596
  var _ = g.body;
5597
- if (l instanceof j) {
5598
- if (l.bodyUsed)
5597
+ if (d instanceof j) {
5598
+ if (d.bodyUsed)
5599
5599
  throw new TypeError("Already read");
5600
- 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);
5600
+ this.url = d.url, this.credentials = d.credentials, g.headers || (this.headers = new y(d.headers)), this.method = d.method, this.mode = d.mode, this.signal = d.signal, !_ && d._bodyInit != null && (_ = d._bodyInit, d.bodyUsed = !0);
5601
5601
  } else
5602
- this.url = String(l);
5603
- if (this.credentials = g.credentials || this.credentials || "same-origin", (g.headers || !this.headers) && (this.headers = new y(g.headers)), this.method = de(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") && _)
5602
+ this.url = String(d);
5603
+ 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") && _)
5604
5604
  throw new TypeError("Body not allowed for GET or HEAD requests");
5605
5605
  this._initBody(_);
5606
5606
  }
5607
5607
  j.prototype.clone = function() {
5608
5608
  return new j(this, { body: this._bodyInit });
5609
5609
  };
5610
- function gn(l) {
5610
+ function gn(d) {
5611
5611
  var g = new FormData();
5612
- return l.trim().split("&").forEach(function(_) {
5612
+ return d.trim().split("&").forEach(function(_) {
5613
5613
  if (_) {
5614
5614
  var N = _.split("="), O = N.shift().replace(/\+/g, " "), x = N.join("=").replace(/\+/g, " ");
5615
5615
  g.append(decodeURIComponent(O), decodeURIComponent(x));
5616
5616
  }
5617
5617
  }), g;
5618
5618
  }
5619
- function En(l) {
5620
- var g = new y(), _ = l.replace(/\r?\n[\t ]+/g, " ");
5619
+ function En(d) {
5620
+ var g = new y(), _ = d.replace(/\r?\n[\t ]+/g, " ");
5621
5621
  return _.split(/\r?\n/).forEach(function(N) {
5622
5622
  var O = N.split(":"), x = O.shift().trim();
5623
5623
  if (x) {
@@ -5627,8 +5627,8 @@ var He = { exports: {} };
5627
5627
  }), g;
5628
5628
  }
5629
5629
  z.call(j.prototype);
5630
- function P(l, g) {
5631
- 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);
5630
+ function P(d, g) {
5631
+ 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(d);
5632
5632
  }
5633
5633
  z.call(P.prototype), P.prototype.clone = function() {
5634
5634
  return new P(this._bodyInit, {
@@ -5638,14 +5638,14 @@ var He = { exports: {} };
5638
5638
  url: this.url
5639
5639
  });
5640
5640
  }, P.error = function() {
5641
- var l = new P(null, { status: 0, statusText: "" });
5642
- return l.type = "error", l;
5641
+ var d = new P(null, { status: 0, statusText: "" });
5642
+ return d.type = "error", d;
5643
5643
  };
5644
5644
  var vn = [301, 302, 303, 307, 308];
5645
- P.redirect = function(l, g) {
5645
+ P.redirect = function(d, g) {
5646
5646
  if (vn.indexOf(g) === -1)
5647
5647
  throw new RangeError("Invalid status code");
5648
- return new P(null, { status: g, headers: { location: l } });
5648
+ return new P(null, { status: g, headers: { location: d } });
5649
5649
  }, o.DOMException = i.DOMException;
5650
5650
  try {
5651
5651
  new o.DOMException();
@@ -5656,9 +5656,9 @@ var He = { exports: {} };
5656
5656
  this.stack = N.stack;
5657
5657
  }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
5658
5658
  }
5659
- function be(l, g) {
5659
+ function be(d, g) {
5660
5660
  return new Promise(function(_, N) {
5661
- var O = new j(l, g);
5661
+ var O = new j(d, g);
5662
5662
  if (O.signal && O.signal.aborted)
5663
5663
  return N(new o.DOMException("Aborted", "AbortError"));
5664
5664
  var x = new XMLHttpRequest();
@@ -5716,8 +5716,8 @@ const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5716
5716
  return `query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`;
5717
5717
  }, Cr = (e) => async (t) => {
5718
5718
  const { url: n, query: s, variables: r, operationName: i, fetch: o, fetchOptions: a, middleware: c } = t, u = { ...t.headers };
5719
- let f = "", d;
5720
- e === "POST" ? (d = Dr(s, r, i, a.jsonSerializer), typeof d == "string" && (u["Content-Type"] = "application/json")) : f = kr({
5719
+ let f = "", l;
5720
+ e === "POST" ? (l = Dr(s, r, i, a.jsonSerializer), typeof l == "string" && (u["Content-Type"] = "application/json")) : f = kr({
5721
5721
  query: s,
5722
5722
  variables: r,
5723
5723
  operationName: i,
@@ -5726,7 +5726,7 @@ const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5726
5726
  const h = {
5727
5727
  method: e,
5728
5728
  headers: u,
5729
- body: d,
5729
+ body: l,
5730
5730
  ...a
5731
5731
  };
5732
5732
  let m = n, y = h;
@@ -5739,7 +5739,7 @@ const Ee = /* @__PURE__ */ Or(Ie), Nr = /* @__PURE__ */ _n({
5739
5739
  class pn {
5740
5740
  constructor(t, n = {}) {
5741
5741
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5742
- const [r, i, o] = s, a = qs(r, i, o), { headers: c, fetch: u = Ee, method: f = "POST", requestMiddleware: d, responseMiddleware: h, ...m } = this.requestConfig, { url: y } = this;
5742
+ const [r, i, o] = s, a = qs(r, i, o), { headers: c, fetch: u = Ee, method: f = "POST", requestMiddleware: l, responseMiddleware: h, ...m } = this.requestConfig, { url: y } = this;
5743
5743
  a.signal !== void 0 && (m.signal = a.signal);
5744
5744
  const { operationName: v } = Re(a.query);
5745
5745
  return Le({
@@ -5754,15 +5754,15 @@ class pn {
5754
5754
  fetch: u,
5755
5755
  method: f,
5756
5756
  fetchOptions: m,
5757
- middleware: d
5757
+ middleware: l
5758
5758
  }).then((S) => (h && h(S), S)).catch((S) => {
5759
5759
  throw h && h(S), S;
5760
5760
  });
5761
5761
  };
5762
5762
  }
5763
5763
  async request(t, ...n) {
5764
- const [s, r] = n, i = Ps(t, s, r), { headers: o, fetch: a = Ee, method: c = "POST", requestMiddleware: u, responseMiddleware: f, ...d } = this.requestConfig, { url: h } = this;
5765
- i.signal !== void 0 && (d.signal = i.signal);
5764
+ const [s, r] = n, i = Ps(t, s, r), { headers: o, fetch: a = Ee, method: c = "POST", requestMiddleware: u, responseMiddleware: f, ...l } = this.requestConfig, { url: h } = this;
5765
+ i.signal !== void 0 && (l.signal = i.signal);
5766
5766
  const { query: m, operationName: y } = Re(i.document);
5767
5767
  return Le({
5768
5768
  url: h,
@@ -5775,7 +5775,7 @@ class pn {
5775
5775
  operationName: y,
5776
5776
  fetch: a,
5777
5777
  method: c,
5778
- fetchOptions: d,
5778
+ fetchOptions: l,
5779
5779
  middleware: u
5780
5780
  }).then((v) => (f && f(v), v.data)).catch((v) => {
5781
5781
  throw f && f(v), v;
@@ -5824,7 +5824,7 @@ class pn {
5824
5824
  const Le = async (e) => {
5825
5825
  const { query: t, variables: n, fetchOptions: s } = e, r = Cr(Ls(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await Rr(o, s.jsonSerializer ?? rt), c = Array.isArray(a) ? !a.some(({ data: f }) => !f) : !!a.data, u = Array.isArray(a) || !a.errors || Array.isArray(a.errors) && !a.errors.length || s.errorPolicy === "all" || s.errorPolicy === "ignore";
5826
5826
  if (o.ok && u && c) {
5827
- const { errors: f, ...d } = (Array.isArray(a), a), h = s.errorPolicy === "ignore" ? d : a;
5827
+ const { errors: f, ...l } = (Array.isArray(a), a), h = s.errorPolicy === "ignore" ? l : a;
5828
5828
  return {
5829
5829
  ...i ? { data: h } : h,
5830
5830
  headers: o.headers,
@@ -5908,7 +5908,7 @@ const Dr = (e, t, n, s) => {
5908
5908
  } catch {
5909
5909
  throw new Error("Request to remove item(s) failed.");
5910
5910
  }
5911
- }), Ct = typeof window > "u", Pr = K(
5911
+ }), Pe = typeof window > "u", Pr = K(
5912
5912
  async ({ input: e }) => {
5913
5913
  var n, s, r, i;
5914
5914
  if (!e.endpoint)
@@ -5922,39 +5922,35 @@ const Dr = (e, t, n, s) => {
5922
5922
  if (!e.requestHeaders)
5923
5923
  throw console.log("no headers"), new Error("No request headers provided.");
5924
5924
  const t = new pn(
5925
- Ct ? e.endpointSsr : e.endpoint,
5926
- Ct ? { fetch, method: "POST" } : {
5925
+ Pe ? e.endpointSsr : e.endpoint,
5926
+ Pe ? { fetch, method: "POST" } : {
5927
5927
  credentials: "include",
5928
5928
  method: "POST",
5929
5929
  mode: "cors"
5930
5930
  }
5931
5931
  );
5932
- console.log("input", e), console.log(
5933
- "input cookie name",
5934
- `quote_${e.locale}=${e.quoteId ?? ""}`
5935
- );
5936
5932
  try {
5937
5933
  const { data: o, headers: a, status: c, errors: u, extensions: f } = await t.rawRequest(
5938
5934
  fn(e.document),
5939
5935
  {},
5940
- typeof window > "u" ? {
5936
+ Pe ? {
5941
5937
  ...e.requestHeaders,
5942
5938
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
5943
5939
  } : e.requestHeaders
5944
- ), d = o;
5945
- if (!((n = d.refreshQuote) != null && n.quote))
5940
+ ), l = o;
5941
+ if (!((n = l.refreshQuote) != null && n.quote))
5946
5942
  throw console.log(
5947
5943
  "userError: ",
5948
- (s = d.refreshQuote) == null ? void 0 : s.userErrors[0].code,
5949
- (r = d.refreshQuote) == null ? void 0 : r.userErrors[0].field,
5950
- (i = d.refreshQuote) == null ? void 0 : i.userErrors[0].message
5944
+ (s = l.refreshQuote) == null ? void 0 : s.userErrors[0].code,
5945
+ (r = l.refreshQuote) == null ? void 0 : r.userErrors[0].field,
5946
+ (i = l.refreshQuote) == null ? void 0 : i.userErrors[0].message
5951
5947
  ), new Error("Could not add items to quote.");
5952
- return console.log("refreshQuote response: ", d.refreshQuote.quote), { type: "REFRESH_SUCCESS", quote: d.refreshQuote.quote };
5948
+ return { type: "REFRESH_SUCCESS", quote: l.refreshQuote.quote };
5953
5949
  } catch (o) {
5954
5950
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
5955
5951
  }
5956
5952
  }
5957
- ), qr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Fr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Dt = xe({
5953
+ ), qr = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", Fr = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ct = xe({
5958
5954
  types: {
5959
5955
  context: {},
5960
5956
  events: {},
@@ -5979,7 +5975,7 @@ const Dr = (e, t, n, s) => {
5979
5975
  id: "quote",
5980
5976
  initial: "initializing",
5981
5977
  context: ({ input: e }) => {
5982
- var t, n, s, r, i, o, a, c, u, f, d, h, m, y;
5978
+ var t, n, s, r, i, o, a, c, u, f, l, h, m, y;
5983
5979
  return {
5984
5980
  quote: {
5985
5981
  id: "",
@@ -6040,7 +6036,7 @@ const Dr = (e, t, n, s) => {
6040
6036
  requestHeaders: ((c = (a = (o = e == null ? void 0 : e.initialContext) == null ? void 0 : o.graphql) == null ? void 0 : a.refresh) == null ? void 0 : c.requestHeaders) ?? void 0
6041
6037
  },
6042
6038
  addItems: {
6043
- document: ((d = (f = (u = e == null ? void 0 : e.initialContext) == null ? void 0 : u.graphql) == null ? void 0 : f.addItems) == null ? void 0 : d.document) ?? "",
6039
+ document: ((l = (f = (u = e == null ? void 0 : e.initialContext) == null ? void 0 : u.graphql) == null ? void 0 : f.addItems) == null ? void 0 : l.document) ?? "",
6044
6040
  requestHeaders: ((y = (m = (h = e == null ? void 0 : e.initialContext) == null ? void 0 : h.graphql) == null ? void 0 : m.addItems) == null ? void 0 : y.requestHeaders) ?? void 0
6045
6041
  }
6046
6042
  // removeItems: {
@@ -6238,16 +6234,39 @@ const Dr = (e, t, n, s) => {
6238
6234
  }), mn = ze(
6239
6235
  {}
6240
6236
  ), Jr = () => {
6241
- var i;
6242
- const e = Je(mn), [t, n] = Pe(
6243
- e.getSnapshot().context.quote.items ?? []
6244
- ), [s, r] = Pe(
6245
- ((i = e.getSnapshot().context.quote.items) == null ? void 0 : i.length) ?? 0
6246
- );
6237
+ const e = Je(mn), [t, n] = Dt(() => {
6238
+ var r;
6239
+ const s = e.getSnapshot();
6240
+ return {
6241
+ items: s.context.quote.items ?? [],
6242
+ itemsCount: ((r = s.context.quote.items) == null ? void 0 : r.length) ?? 0,
6243
+ isAddingItems: s.value === "addingItems",
6244
+ isRemovingItems: s.value === "removingItems",
6245
+ isUpdatingItems: s.value === "addingItems" || s.value === "removingItems"
6246
+ };
6247
+ });
6247
6248
  return Rt(() => {
6248
- const o = e.getSnapshot().context.quote.items ?? [];
6249
- n(o), r(o.length);
6250
- }, [e]), { quoteActor: e, items: t, itemsCount: s };
6249
+ const s = e.subscribe((r) => {
6250
+ const i = r.context.quote.items ?? [];
6251
+ n({
6252
+ items: i,
6253
+ itemsCount: i.length,
6254
+ isAddingItems: r.matches("addingItems"),
6255
+ isRemovingItems: r.matches("removingItems"),
6256
+ isUpdatingItems: r.matches("addingItems") || r.matches("removingItems")
6257
+ });
6258
+ });
6259
+ return () => {
6260
+ s.unsubscribe();
6261
+ };
6262
+ }, [e]), {
6263
+ quoteActor: e,
6264
+ isAddingItems: t.isAddingItems,
6265
+ isRemovingItems: t.isRemovingItems,
6266
+ isUpdatingItems: t.isUpdatingItems,
6267
+ items: t.items,
6268
+ itemsCount: t.itemsCount
6269
+ };
6251
6270
  }, Yr = async (e = {
6252
6271
  inspect: void 0,
6253
6272
  quote: { id: "", locale: "" },
@@ -6255,14 +6274,14 @@ const Dr = (e, t, n, s) => {
6255
6274
  graphql: {}
6256
6275
  }) => typeof window < "u" ? (console.warn(
6257
6276
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6258
- ), U(Dt, {
6277
+ ), U(Ct, {
6259
6278
  inspect: e.inspect,
6260
6279
  input: {
6261
6280
  initialContext: {
6262
6281
  endpoints: e.endpoints
6263
6282
  }
6264
6283
  }
6265
- }).start()) : U(Dt, {
6284
+ }).start()) : U(Ct, {
6266
6285
  input: {
6267
6286
  initialContext: {
6268
6287
  endpoints: e.endpoints,
@@ -6288,7 +6307,7 @@ export {
6288
6307
  St as authMachine,
6289
6308
  $r as getAuth,
6290
6309
  Yr as getQuote,
6291
- Dt as quoteMachine,
6310
+ Ct as quoteMachine,
6292
6311
  ks as timerMachine,
6293
6312
  Hr as toastMachine,
6294
6313
  jr as useAuth,