@clicktap/state 0.14.1 → 0.14.2

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 we } from "react/jsx-runtime";
2
- import { createContext as be, useContext as Ne, useState as Ke, useEffect as Ze, cloneElement as An } from "react";
2
+ import { createContext as be, useContext as Ne, useState as Oe, useEffect as Ce, cloneElement as An } from "react";
3
3
  function xn(e, t) {
4
4
  for (var n = 0; n < t.length; n++) {
5
5
  const s = t[n];
@@ -72,7 +72,7 @@ function Rn(e, t) {
72
72
  type: `xstate.after.${e}.${t}`
73
73
  };
74
74
  }
75
- function Ve(e, t) {
75
+ function ze(e, t) {
76
76
  return {
77
77
  type: `xstate.done.state.${e}`,
78
78
  output: t
@@ -106,7 +106,7 @@ function pt(e, t) {
106
106
  return `${e.sessionId}.${t}`;
107
107
  }
108
108
  let Ln = 0;
109
- function Pn(e, t) {
109
+ function Un(e, t) {
110
110
  const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), o = {}, {
111
111
  clock: a,
112
112
  logger: c
@@ -229,9 +229,9 @@ function yt(e) {
229
229
  if (typeof e != "string")
230
230
  return e;
231
231
  const t = et(e);
232
- return Un(t);
232
+ return Pn(t);
233
233
  }
234
- function Un(e) {
234
+ function Pn(e) {
235
235
  if (e.length === 1)
236
236
  return e[0];
237
237
  const t = {};
@@ -259,7 +259,7 @@ function zt(e) {
259
259
  function j(e) {
260
260
  return e === void 0 ? [] : zt(e);
261
261
  }
262
- function He(e, t, n, s) {
262
+ function Ge(e, t, n, s) {
263
263
  return typeof e == "function" ? e({
264
264
  context: t,
265
265
  event: n,
@@ -333,7 +333,7 @@ class jn {
333
333
  systemId: u,
334
334
  inspect: h
335
335
  } = s;
336
- this.system = o ? o.system : Pn(this, {
336
+ this.system = o ? o.system : Un(this, {
337
337
  clock: r,
338
338
  logger: i
339
339
  }), h && !o && this.system.inspect(gt(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 = {
@@ -682,7 +682,7 @@ class jn {
682
682
  return this._snapshot;
683
683
  }
684
684
  }
685
- function U(e, ...[t]) {
685
+ function P(e, ...[t]) {
686
686
  return new jn(e, t);
687
687
  }
688
688
  function $n(e, t, n, s, {
@@ -710,7 +710,7 @@ function zn(e, t, n, s, {
710
710
  }) {
711
711
  const u = typeof o == "string" ? tt(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 = P(u, {
714
714
  id: h,
715
715
  src: o,
716
716
  parent: e.self,
@@ -861,7 +861,7 @@ function Wt(e, t) {
861
861
  function it(e, t) {
862
862
  return t.type === "compound" ? te(t).some((n) => n.type === "final" && e.has(n)) : t.type === "parallel" ? te(t).every((n) => it(e, n)) : t.type === "final";
863
863
  }
864
- const Oe = (e) => e[0] === Cn;
864
+ const ke = (e) => e[0] === Cn;
865
865
  function Qn(e, t) {
866
866
  return e.transitions.get(t) || [...e.transitions.keys()].filter((s) => {
867
867
  if (s === kn)
@@ -982,7 +982,7 @@ function es(e, t) {
982
982
  return t.map((n) => {
983
983
  if (typeof n != "string")
984
984
  return n;
985
- if (Oe(n))
985
+ if (ke(n))
986
986
  return e.machine.getStateNodeById(n);
987
987
  const s = n[0] === Ft;
988
988
  if (s && !e.parent)
@@ -1029,7 +1029,7 @@ function Zt(e) {
1029
1029
  return n(e), t;
1030
1030
  }
1031
1031
  function ne(e, t) {
1032
- if (Oe(t))
1032
+ if (ke(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.`);
@@ -1039,7 +1039,7 @@ function ne(e, t) {
1039
1039
  return n;
1040
1040
  }
1041
1041
  function Ie(e, t) {
1042
- if (typeof t == "string" && Oe(t))
1042
+ if (typeof t == "string" && ke(t))
1043
1043
  try {
1044
1044
  return e.machine.getStateNodeById(t);
1045
1045
  } catch {
@@ -1117,7 +1117,7 @@ function en(e, t, n) {
1117
1117
  let i = !1;
1118
1118
  const o = /* @__PURE__ */ new Set();
1119
1119
  for (const a of s)
1120
- if (is(ze([r], t, n), ze([a], t, n)))
1120
+ if (is(Je([r], t, n), Je([a], t, n)))
1121
1121
  if ($(r.source, a.source))
1122
1122
  o.add(a);
1123
1123
  else {
@@ -1166,7 +1166,7 @@ function tn(e, t) {
1166
1166
  if (!e.reenter)
1167
1167
  return e.source.machine.root;
1168
1168
  }
1169
- function ze(e, t, n) {
1169
+ function Je(e, t, n) {
1170
1170
  var r;
1171
1171
  const s = /* @__PURE__ */ new Set();
1172
1172
  for (const i of e)
@@ -1186,7 +1186,7 @@ function as(e, t) {
1186
1186
  return !1;
1187
1187
  return !0;
1188
1188
  }
1189
- function Ge(e, t, n, s, r, i) {
1189
+ function Ye(e, t, n, s, r, i) {
1190
1190
  if (!e.length)
1191
1191
  return t;
1192
1192
  const o = new Set(t._nodes);
@@ -1208,8 +1208,8 @@ function Ge(e, t, n, s, r, i) {
1208
1208
  function cs(e, t, n, s, r) {
1209
1209
  if (s.output === void 0)
1210
1210
  return;
1211
- const i = Ve(r.id, r.output !== void 0 && r.parent ? He(r.output, e.context, t, n.self) : void 0);
1212
- return He(s.output, e.context, i, n.self);
1211
+ const i = ze(r.id, r.output !== void 0 && r.parent ? Ge(r.output, e.context, t, n.self) : void 0);
1212
+ return Ge(s.output, e.context, i, n.self);
1213
1213
  }
1214
1214
  function us(e, t, n, s, r, i, o, a) {
1215
1215
  let c = e;
@@ -1232,8 +1232,8 @@ function us(e, t, n, s, r, i, o, a) {
1232
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, I = v || f;
1235
- for ((y == null ? void 0 : y.type) === "compound" && i.push(Ve(y.id, f.output !== void 0 ? He(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && it(r, v); )
1236
- d.add(v), i.push(Ve(v.id)), I = v, v = v.parent;
1235
+ for ((y == null ? void 0 : y.type) === "compound" && i.push(ze(y.id, f.output !== void 0 ? Ge(f.output, c.context, t, n.self) : void 0)); (v == null ? void 0 : v.type) === "parallel" && !d.has(v) && it(r, v); )
1236
+ d.add(v), i.push(ze(v.id)), I = v, v = v.parent;
1237
1237
  if (v)
1238
1238
  continue;
1239
1239
  c = Y(c, {
@@ -1268,17 +1268,17 @@ function Z(e, t, n, s) {
1268
1268
  for (const o of i)
1269
1269
  s.add(o), Z(o, t, n, s);
1270
1270
  for (const o of i)
1271
- Me(o, e.parent, s, t, n);
1271
+ Ue(o, e.parent, s, t, n);
1272
1272
  } else {
1273
1273
  const i = Kt(e);
1274
1274
  for (const o of i.target)
1275
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
- Me(o, e.parent, s, t, n);
1277
+ Ue(o, e.parent, s, t, n);
1278
1278
  }
1279
1279
  else if (e.type === "compound") {
1280
1280
  const [i] = e.initial.target;
1281
- J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Me(i, e, s, t, n);
1281
+ J(i) || (s.add(i), n.add(i)), Z(i, t, n, s), Ue(i, e, s, t, n);
1282
1282
  } else if (e.type === "parallel")
1283
1283
  for (const i of te(e).filter((o) => !J(o)))
1284
1284
  [...s].some((o) => $(o, i)) || (J(i) || (s.add(i), n.add(i)), Z(i, t, n, s));
@@ -1289,12 +1289,12 @@ function nn(e, t, n, s, r) {
1289
1289
  for (const o of te(i).filter((a) => !J(a)))
1290
1290
  [...e].some((a) => $(a, o)) || (e.add(o), Z(o, t, n, e));
1291
1291
  }
1292
- function Me(e, t, n, s, r) {
1292
+ function Ue(e, t, n, s, r) {
1293
1293
  nn(n, s, r, le(e, t));
1294
1294
  }
1295
1295
  function ls(e, t, n, s, r, i, o) {
1296
1296
  let a = e;
1297
- const c = ze(s, r, i);
1297
+ const c = Je(s, r, i);
1298
1298
  c.sort((h, d) => d.order - h.order);
1299
1299
  let u;
1300
1300
  for (const h of c)
@@ -1375,7 +1375,7 @@ function se(e, t, n, s, r, i) {
1375
1375
  c.retryResolve(n, a, u);
1376
1376
  }), a;
1377
1377
  }
1378
- function Le(e, t, n, s = []) {
1378
+ function Pe(e, t, n, s = []) {
1379
1379
  let r = e;
1380
1380
  const i = [];
1381
1381
  function o(u, h, d) {
@@ -1405,7 +1405,7 @@ function Le(e, t, n, s = []) {
1405
1405
  snapshot: r,
1406
1406
  microstates: i
1407
1407
  };
1408
- r = Ge(
1408
+ r = Ye(
1409
1409
  d,
1410
1410
  e,
1411
1411
  n,
@@ -1424,7 +1424,7 @@ function Le(e, t, n, s = []) {
1424
1424
  break;
1425
1425
  a = s.shift(), u = St(a, r);
1426
1426
  }
1427
- r = Ge(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1427
+ r = Ye(u, r, n, a, !1, s), c = r !== h, o(r, a, u);
1428
1428
  }
1429
1429
  return r.status !== "active" && _t(r, a, n), {
1430
1430
  snapshot: r,
@@ -1727,7 +1727,7 @@ function xs(e, {
1727
1727
  const h = tt(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 = P(h, {
1731
1731
  id: a.id,
1732
1732
  parent: e.self,
1733
1733
  syncSnapshot: a.syncSnapshot,
@@ -1741,7 +1741,7 @@ function xs(e, {
1741
1741
  });
1742
1742
  return r[d.id] = d, d;
1743
1743
  } else
1744
- return U(o, {
1744
+ return P(o, {
1745
1745
  id: a.id,
1746
1746
  parent: e.self,
1747
1747
  syncSnapshot: a.syncSnapshot,
@@ -1804,7 +1804,7 @@ function Ns(e, {
1804
1804
  }) {
1805
1805
  e.defer(() => e.emit(t));
1806
1806
  }
1807
- function Pe(e) {
1807
+ function Fe(e) {
1808
1808
  function t(n, s) {
1809
1809
  }
1810
1810
  return t.type = "xstate.emit", t.event = e, t.resolve = bs, t.execute = Ns, t;
@@ -2107,7 +2107,7 @@ class ut {
2107
2107
  * @param event The received event
2108
2108
  */
2109
2109
  transition(t, n, s) {
2110
- return Le(t, n, s).snapshot;
2110
+ return Pe(t, n, s).snapshot;
2111
2111
  }
2112
2112
  /**
2113
2113
  * Determines the next state given the current `state` and `event`.
@@ -2117,7 +2117,7 @@ class ut {
2117
2117
  * @param event The received event
2118
2118
  */
2119
2119
  microstep(t, n, s) {
2120
- return Le(t, n, s).microstates;
2120
+ return Pe(t, n, s).microstates;
2121
2121
  }
2122
2122
  getTransitionData(t, n) {
2123
2123
  return ot(this.root, t.value, t, n) || [];
@@ -2149,7 +2149,7 @@ class ut {
2149
2149
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
2150
2150
  */
2151
2151
  getInitialSnapshot(t, n) {
2152
- const s = Vt(n), r = [], i = this.getPreInitialState(t, s, r), o = Ge([{
2152
+ const s = Vt(n), r = [], i = this.getPreInitialState(t, s, r), o = Ye([{
2153
2153
  target: [...Zt(this.root)],
2154
2154
  source: this.root,
2155
2155
  reenter: !0,
@@ -2159,7 +2159,7 @@ class ut {
2159
2159
  // TODO: fix
2160
2160
  }], i, t, s, !0, r), {
2161
2161
  snapshot: a
2162
- } = Le(o, s, t, r);
2162
+ } = Pe(o, s, t, r);
2163
2163
  return a;
2164
2164
  }
2165
2165
  start(t) {
@@ -2168,7 +2168,7 @@ class ut {
2168
2168
  });
2169
2169
  }
2170
2170
  getStateNodeById(t) {
2171
- const n = et(t), s = n.slice(1), r = Oe(n[0]) ? n[0].slice(Rs.length) : n[0], i = this.idMap.get(r);
2171
+ const n = et(t), s = n.slice(1), r = ke(n[0]) ? n[0].slice(Rs.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
2174
  return Ie(i, s);
@@ -2188,7 +2188,7 @@ class ut {
2188
2188
  const u = r[c], h = u.snapshot, d = u.src, f = typeof d == "string" ? tt(this, d) : d;
2189
2189
  if (!f)
2190
2190
  return;
2191
- const m = U(f, {
2191
+ const m = P(f, {
2192
2192
  id: c,
2193
2193
  parent: n.self,
2194
2194
  syncSnapshot: u.syncSnapshot,
@@ -2267,7 +2267,7 @@ function Ls() {
2267
2267
  errors: []
2268
2268
  };
2269
2269
  }
2270
- function Ps({
2270
+ function Us({
2271
2271
  context: e,
2272
2272
  event: t
2273
2273
  }) {
@@ -2279,7 +2279,7 @@ function Ps({
2279
2279
  ignoreRefreshToken: !1
2280
2280
  };
2281
2281
  }
2282
- function Us() {
2282
+ function Ps() {
2283
2283
  return {
2284
2284
  ignoreRefreshToken: !0
2285
2285
  };
@@ -2309,7 +2309,7 @@ function js() {
2309
2309
  ignoreRefreshToken: !1
2310
2310
  };
2311
2311
  }
2312
- async function Je(e, t) {
2312
+ async function Xe(e, t) {
2313
2313
  const n = await fetch(e, t);
2314
2314
  return n.status === 200 ? n.json() : Promise.resolve({
2315
2315
  message: n.statusText,
@@ -2318,7 +2318,7 @@ async function Je(e, t) {
2318
2318
  }
2319
2319
  const $s = V(async ({ input: e }) => {
2320
2320
  var n;
2321
- const t = await Je(e.endpoint.client, {
2321
+ const t = await Xe(e.endpoint.client, {
2322
2322
  method: "POST",
2323
2323
  mode: "cors",
2324
2324
  credentials: "include",
@@ -2351,7 +2351,7 @@ const $s = V(async ({ input: e }) => {
2351
2351
  if (e.refreshToken === "")
2352
2352
  throw new Error("Unauthorized.");
2353
2353
  try {
2354
- if (t = await Je(e.endpoint.server, {
2354
+ if (t = await Xe(e.endpoint.server, {
2355
2355
  method: "POST",
2356
2356
  mode: "cors",
2357
2357
  credentials: "include",
@@ -2371,7 +2371,7 @@ const $s = V(async ({ input: e }) => {
2371
2371
  throw console.log(n), new Error("Could not complete refresh request (server)");
2372
2372
  }
2373
2373
  } else {
2374
- if (t = await Je(e.endpoint.client, {
2374
+ if (t = await Xe(e.endpoint.client, {
2375
2375
  method: "POST",
2376
2376
  mode: "cors",
2377
2377
  credentials: "include",
@@ -2415,8 +2415,8 @@ const $s = V(async ({ input: e }) => {
2415
2415
  actions: {
2416
2416
  addError: C(Ms),
2417
2417
  clearErrors: C(Ls),
2418
- setAccessToken: C(Ps),
2419
- setIgnoreRefreshToken: C(Us),
2418
+ setAccessToken: C(Us),
2419
+ setIgnoreRefreshToken: C(Ps),
2420
2420
  setUserContext: C(Fs),
2421
2421
  unsetRefreshToken: C(Bs),
2422
2422
  unsetUserContext: C(js)
@@ -2565,11 +2565,11 @@ const $s = V(async ({ input: e }) => {
2565
2565
  }
2566
2566
  }), an = be(
2567
2567
  {}
2568
- ), di = () => {
2569
- const e = Ne(an), [t, n] = Ke(
2568
+ ), li = () => {
2569
+ const e = Ne(an), [t, n] = Oe(
2570
2570
  typeof window < "u" && e.getSnapshot().value === "loggedIn"
2571
2571
  );
2572
- return Ze(() => {
2572
+ return Ce(() => {
2573
2573
  if (typeof window > "u")
2574
2574
  return;
2575
2575
  const s = e.subscribe((r) => {
@@ -2579,19 +2579,19 @@ const $s = V(async ({ input: e }) => {
2579
2579
  s.unsubscribe();
2580
2580
  };
2581
2581
  }, [e]), { authActor: e, isLoggedIn: t };
2582
- }, li = async (e = "", t = {
2582
+ }, hi = async (e = "", t = {
2583
2583
  inspect: void 0,
2584
2584
  endpoints: { login: "", logout: "", refresh: "", ssrRefresh: "" }
2585
2585
  }) => typeof window < "u" ? (console.warn(
2586
2586
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
2587
- ), U(Ot, {
2587
+ ), P(Ot, {
2588
2588
  inspect: t.inspect,
2589
2589
  input: {
2590
2590
  initialContext: {
2591
2591
  endpoints: t.endpoints
2592
2592
  }
2593
2593
  }
2594
- }).start()) : U(Ot, {
2594
+ }).start()) : P(Ot, {
2595
2595
  input: {
2596
2596
  initialContext: {
2597
2597
  endpoints: t.endpoints,
@@ -2600,7 +2600,7 @@ const $s = V(async ({ input: e }) => {
2600
2600
  },
2601
2601
  inspect: t.inspect
2602
2602
  }).start();
2603
- function hi({ actor: e, children: t }) {
2603
+ function fi({ actor: e, children: t }) {
2604
2604
  return /* @__PURE__ */ we(an.Provider, { value: e, children: t });
2605
2605
  }
2606
2606
  function zs({
@@ -2660,7 +2660,7 @@ function Zs(e, t) {
2660
2660
  );
2661
2661
  }
2662
2662
  const er = /\r\n|[\n\r]/g;
2663
- function Ye(e, t) {
2663
+ function Qe(e, t) {
2664
2664
  let n = 0, s = 1;
2665
2665
  for (const r of e.body.matchAll(er)) {
2666
2666
  if (typeof r.index == "number" || Zs(!1), r.index >= t)
@@ -2675,7 +2675,7 @@ function Ye(e, t) {
2675
2675
  function tr(e) {
2676
2676
  return cn(
2677
2677
  e.source,
2678
- Ye(e.source, e.start)
2678
+ Qe(e.source, e.start)
2679
2679
  );
2680
2680
  }
2681
2681
  function cn(e, t) {
@@ -2764,7 +2764,7 @@ class lt extends Error {
2764
2764
  const f = kt(
2765
2765
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((y) => y.loc).filter((y) => y != null)
2766
2766
  );
2767
- 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) => Ye(a, y)) : f == null ? void 0 : f.map((y) => Ye(y.source, y.start));
2767
+ 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) => Qe(a, y)) : f == null ? void 0 : f.map((y) => Qe(y.source, y.start));
2768
2768
  const m = Ks(
2769
2769
  h == null ? void 0 : h.extensions
2770
2770
  ) ? h == null ? void 0 : h.extensions : void 0;
@@ -2985,15 +2985,15 @@ var ee;
2985
2985
  (function(e) {
2986
2986
  e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
2987
2987
  })(ee || (ee = {}));
2988
- var Xe;
2988
+ var We;
2989
2989
  (function(e) {
2990
2990
  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";
2991
- })(Xe || (Xe = {}));
2991
+ })(We || (We = {}));
2992
2992
  var T;
2993
2993
  (function(e) {
2994
2994
  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";
2995
2995
  })(T || (T = {}));
2996
- function Qe(e) {
2996
+ function Ke(e) {
2997
2997
  return e === 9 || e === 32;
2998
2998
  }
2999
2999
  function de(e) {
@@ -3024,15 +3024,15 @@ function or(e) {
3024
3024
  }
3025
3025
  function ar(e) {
3026
3026
  let t = 0;
3027
- for (; t < e.length && Qe(e.charCodeAt(t)); )
3027
+ for (; t < e.length && Ke(e.charCodeAt(t)); )
3028
3028
  ++t;
3029
3029
  return t;
3030
3030
  }
3031
3031
  function cr(e, t) {
3032
- 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 || Qe(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
3032
+ 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 || Ke(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
3033
3033
  (!r || e.length > 70 || u || i || o);
3034
3034
  let d = "";
3035
- const f = r && Qe(e.charCodeAt(0));
3035
+ const f = r && Ke(e.charCodeAt(0));
3036
3036
  return (h && !f || i) && (d += `
3037
3037
  `), d += n, (h || u) && (d += `
3038
3038
  `), '"""' + d + '"""';
@@ -3091,7 +3091,7 @@ function dr(e) {
3091
3091
  function re(e) {
3092
3092
  return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
3093
3093
  }
3094
- function Ce(e, t) {
3094
+ function De(e, t) {
3095
3095
  return fn(e.charCodeAt(t)) && pn(e.charCodeAt(t + 1));
3096
3096
  }
3097
3097
  function fn(e) {
@@ -3174,7 +3174,7 @@ function lr(e, t) {
3174
3174
  throw b(
3175
3175
  e.source,
3176
3176
  r,
3177
- i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || Ce(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3177
+ i === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : re(i) || De(n, r) ? `Unexpected character: ${X(e, r)}.` : `Invalid character: ${X(e, r)}.`
3178
3178
  );
3179
3179
  }
3180
3180
  return w(e, p.EOF, s, s);
@@ -3188,7 +3188,7 @@ function hr(e, t) {
3188
3188
  break;
3189
3189
  if (re(i))
3190
3190
  ++r;
3191
- else if (Ce(n, r))
3191
+ else if (De(n, r))
3192
3192
  r += 2;
3193
3193
  else
3194
3194
  break;
@@ -3215,8 +3215,8 @@ function fr(e, t, n) {
3215
3215
  )}.`
3216
3216
  );
3217
3217
  } else
3218
- r = Ue(e, r, i), i = s.charCodeAt(r);
3219
- if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Ue(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 = Ue(e, r, i), i = s.charCodeAt(r)), i === 46 || hn(i))
3218
+ r = Be(e, r, i), i = s.charCodeAt(r);
3219
+ if (i === 46 && (o = !0, i = s.charCodeAt(++r), r = Be(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 = Be(e, r, i), i = s.charCodeAt(r)), i === 46 || hn(i))
3220
3220
  throw b(
3221
3221
  e.source,
3222
3222
  r,
@@ -3233,7 +3233,7 @@ function fr(e, t, n) {
3233
3233
  s.slice(t, r)
3234
3234
  );
3235
3235
  }
3236
- function Ue(e, t, n) {
3236
+ function Be(e, t, n) {
3237
3237
  if (!de(n))
3238
3238
  throw b(
3239
3239
  e.source,
@@ -3266,7 +3266,7 @@ function pr(e, t) {
3266
3266
  break;
3267
3267
  if (re(a))
3268
3268
  ++r;
3269
- else if (Ce(n, r))
3269
+ else if (De(n, r))
3270
3270
  r += 2;
3271
3271
  else
3272
3272
  throw b(
@@ -3415,7 +3415,7 @@ function Er(e, t) {
3415
3415
  }
3416
3416
  if (re(u))
3417
3417
  ++i;
3418
- else if (Ce(n, i))
3418
+ else if (De(n, i))
3419
3419
  i += 2;
3420
3420
  else
3421
3421
  throw b(
@@ -3449,9 +3449,9 @@ function vr(e, t) {
3449
3449
  }
3450
3450
  const Tr = 10, yn = 2;
3451
3451
  function ht(e) {
3452
- return ke(e, []);
3452
+ return Re(e, []);
3453
3453
  }
3454
- function ke(e, t) {
3454
+ function Re(e, t) {
3455
3455
  switch (typeof e) {
3456
3456
  case "string":
3457
3457
  return JSON.stringify(e);
@@ -3472,7 +3472,7 @@ function _r(e, t) {
3472
3472
  if (Sr(e)) {
3473
3473
  const s = e.toJSON();
3474
3474
  if (s !== e)
3475
- return typeof s == "string" ? s : ke(s, n);
3475
+ return typeof s == "string" ? s : Re(s, n);
3476
3476
  } else if (Array.isArray(e))
3477
3477
  return Ar(e, n);
3478
3478
  return Ir(e, n);
@@ -3483,7 +3483,7 @@ function Sr(e) {
3483
3483
  function Ir(e, t) {
3484
3484
  const n = Object.entries(e);
3485
3485
  return n.length === 0 ? "{}" : t.length > yn ? "[" + xr(e) + "]" : "{ " + n.map(
3486
- ([r, i]) => r + ": " + ke(i, t)
3486
+ ([r, i]) => r + ": " + Re(i, t)
3487
3487
  ).join(", ") + " }";
3488
3488
  }
3489
3489
  function Ar(e, t) {
@@ -3493,7 +3493,7 @@ function Ar(e, t) {
3493
3493
  return "[Array]";
3494
3494
  const n = Math.min(Tr, e.length), s = e.length - n, r = [];
3495
3495
  for (let i = 0; i < n; ++i)
3496
- r.push(ke(e[i], t));
3496
+ r.push(Re(e[i], t));
3497
3497
  return s === 1 ? r.push("... 1 more item") : s > 1 && r.push(`... ${s} more items`), "[" + r.join(", ") + "]";
3498
3498
  }
3499
3499
  function xr(e) {
@@ -4520,7 +4520,7 @@ class Or {
4520
4520
  */
4521
4521
  parseDirectiveLocation() {
4522
4522
  const t = this._lexer.token, n = this.parseName();
4523
- if (Object.prototype.hasOwnProperty.call(Xe, n.value))
4523
+ if (Object.prototype.hasOwnProperty.call(We, n.value))
4524
4524
  return n;
4525
4525
  throw this.unexpected(t);
4526
4526
  }
@@ -4921,9 +4921,9 @@ function Lr(e, t) {
4921
4921
  };
4922
4922
  }
4923
4923
  function En(e) {
4924
- return Mr(e, Ur);
4924
+ return Mr(e, Pr);
4925
4925
  }
4926
- const Pr = 80, Ur = {
4926
+ const Ur = 80, Pr = {
4927
4927
  Name: {
4928
4928
  leave: (e) => e.value
4929
4929
  },
@@ -4959,7 +4959,7 @@ const Pr = 80, Ur = {
4959
4959
  leave({ alias: e, name: t, arguments: n, directives: s, selectionSet: r }) {
4960
4960
  const i = S("", e, ": ") + t;
4961
4961
  let o = i + S("(", E(n, ", "), ")");
4962
- return o.length > Pr && (o = i + S(`(
4962
+ return o.length > Ur && (o = i + S(`(
4963
4963
  `, Te(E(n, `
4964
4964
  `)), `
4965
4965
  )`)), E([o, E(s, " "), r], " ");
@@ -5187,7 +5187,7 @@ const Mt = (e) => {
5187
5187
  let t;
5188
5188
  const n = e.definitions.filter((i) => i.kind === "OperationDefinition");
5189
5189
  return n.length === 1 && (t = (r = (s = n[0]) == null ? void 0 : s.name) == null ? void 0 : r.value), t;
5190
- }, Fe = (e) => {
5190
+ }, je = (e) => {
5191
5191
  if (typeof e == "string") {
5192
5192
  let n;
5193
5193
  try {
@@ -5217,7 +5217,7 @@ var Fr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
5217
5217
  function Br(e) {
5218
5218
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5219
5219
  }
5220
- var We = { exports: {} };
5220
+ var Ze = { exports: {} };
5221
5221
  (function(e, t) {
5222
5222
  var n = typeof self < "u" ? self : Fr, s = function() {
5223
5223
  function i() {
@@ -5423,25 +5423,25 @@ var We = { exports: {} };
5423
5423
  }), g;
5424
5424
  }
5425
5425
  F.call(L.prototype);
5426
- function P(l, g) {
5426
+ function U(l, g) {
5427
5427
  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);
5428
5428
  }
5429
- F.call(P.prototype), P.prototype.clone = function() {
5430
- return new P(this._bodyInit, {
5429
+ F.call(U.prototype), U.prototype.clone = function() {
5430
+ return new U(this._bodyInit, {
5431
5431
  status: this.status,
5432
5432
  statusText: this.statusText,
5433
5433
  headers: new y(this.headers),
5434
5434
  url: this.url
5435
5435
  });
5436
- }, P.error = function() {
5437
- var l = new P(null, { status: 0, statusText: "" });
5436
+ }, U.error = function() {
5437
+ var l = new U(null, { status: 0, statusText: "" });
5438
5438
  return l.type = "error", l;
5439
5439
  };
5440
5440
  var In = [301, 302, 303, 307, 308];
5441
- P.redirect = function(l, g) {
5441
+ U.redirect = function(l, g) {
5442
5442
  if (In.indexOf(g) === -1)
5443
5443
  throw new RangeError("Invalid status code");
5444
- return new P(null, { status: g, headers: { location: l } });
5444
+ return new U(null, { status: g, headers: { location: l } });
5445
5445
  }, o.DOMException = i.DOMException;
5446
5446
  try {
5447
5447
  new o.DOMException();
@@ -5452,7 +5452,7 @@ var We = { exports: {} };
5452
5452
  this.stack = O.stack;
5453
5453
  }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
5454
5454
  }
5455
- function Re(l, g) {
5455
+ function Me(l, g) {
5456
5456
  return new Promise(function(_, O) {
5457
5457
  var N = new L(l, g);
5458
5458
  if (N.signal && N.signal.aborted)
@@ -5468,28 +5468,28 @@ var We = { exports: {} };
5468
5468
  headers: pe(A.getAllResponseHeaders() || "")
5469
5469
  };
5470
5470
  ie.url = "responseURL" in A ? A.responseURL : ie.headers.get("X-Request-URL");
5471
- var qe = "response" in A ? A.response : A.responseText;
5472
- _(new P(qe, ie));
5471
+ var Le = "response" in A ? A.response : A.responseText;
5472
+ _(new U(Le, ie));
5473
5473
  }, A.onerror = function() {
5474
5474
  O(new TypeError("Network request failed"));
5475
5475
  }, A.ontimeout = function() {
5476
5476
  O(new TypeError("Network request failed"));
5477
5477
  }, A.onabort = function() {
5478
5478
  O(new o.DOMException("Aborted", "AbortError"));
5479
- }, A.open(N.method, N.url, !0), N.credentials === "include" ? A.withCredentials = !0 : N.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), N.headers.forEach(function(ie, qe) {
5480
- A.setRequestHeader(qe, ie);
5479
+ }, A.open(N.method, N.url, !0), N.credentials === "include" ? A.withCredentials = !0 : N.credentials === "omit" && (A.withCredentials = !1), "responseType" in A && a.blob && (A.responseType = "blob"), N.headers.forEach(function(ie, Le) {
5480
+ A.setRequestHeader(Le, ie);
5481
5481
  }), N.signal && (N.signal.addEventListener("abort", ye), A.onreadystatechange = function() {
5482
5482
  A.readyState === 4 && N.signal.removeEventListener("abort", ye);
5483
5483
  }), A.send(typeof N._bodyInit > "u" ? null : N._bodyInit);
5484
5484
  });
5485
5485
  }
5486
- return Re.polyfill = !0, i.fetch || (i.fetch = Re, i.Headers = y, i.Request = L, i.Response = P), o.Headers = y, o.Request = L, o.Response = P, o.fetch = Re, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5486
+ return Me.polyfill = !0, i.fetch || (i.fetch = Me, i.Headers = y, i.Request = L, i.Response = U), o.Headers = y, o.Request = L, o.Response = U, o.fetch = Me, Object.defineProperty(o, "__esModule", { value: !0 }), o;
5487
5487
  })({});
5488
5488
  })(s), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
5489
5489
  var r = s;
5490
5490
  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;
5491
- })(We, We.exports);
5492
- var xe = We.exports;
5491
+ })(Ze, Ze.exports);
5492
+ var xe = Ze.exports;
5493
5493
  const _e = /* @__PURE__ */ Br(xe), jr = /* @__PURE__ */ xn({
5494
5494
  __proto__: null,
5495
5495
  default: _e
@@ -5537,13 +5537,13 @@ class vn {
5537
5537
  this.url = t, this.requestConfig = n, this.rawRequest = async (...s) => {
5538
5538
  const [r, i, o] = s, a = Xs(r, i, o), { headers: c, fetch: u = _e, method: h = "POST", requestMiddleware: d, responseMiddleware: f, ...m } = this.requestConfig, { url: y } = this;
5539
5539
  a.signal !== void 0 && (m.signal = a.signal);
5540
- const { operationName: v } = Fe(a.query);
5541
- return Be({
5540
+ const { operationName: v } = je(a.query);
5541
+ return $e({
5542
5542
  url: y,
5543
5543
  query: a.query,
5544
5544
  variables: a.variables,
5545
5545
  headers: {
5546
- ...W(je(c)),
5546
+ ...W(Ve(c)),
5547
5547
  ...W(a.requestHeaders)
5548
5548
  },
5549
5549
  operationName: v,
@@ -5559,13 +5559,13 @@ class vn {
5559
5559
  async request(t, ...n) {
5560
5560
  const [s, r] = n, i = Ys(t, s, r), { headers: o, fetch: a = _e, method: c = "POST", requestMiddleware: u, responseMiddleware: h, ...d } = this.requestConfig, { url: f } = this;
5561
5561
  i.signal !== void 0 && (d.signal = i.signal);
5562
- const { query: m, operationName: y } = Fe(i.document);
5563
- return Be({
5562
+ const { query: m, operationName: y } = je(i.document);
5563
+ return $e({
5564
5564
  url: f,
5565
5565
  query: m,
5566
5566
  variables: i.variables,
5567
5567
  headers: {
5568
- ...W(je(o)),
5568
+ ...W(Ve(o)),
5569
5569
  ...W(i.requestHeaders)
5570
5570
  },
5571
5571
  operationName: y,
@@ -5581,14 +5581,14 @@ class vn {
5581
5581
  batchRequests(t, n) {
5582
5582
  const s = Qs(t, n), { headers: r, ...i } = this.requestConfig;
5583
5583
  s.signal !== void 0 && (i.signal = s.signal);
5584
- const o = s.documents.map(({ document: c }) => Fe(c).query), a = s.documents.map(({ variables: c }) => c);
5585
- return Be({
5584
+ const o = s.documents.map(({ document: c }) => je(c).query), a = s.documents.map(({ variables: c }) => c);
5585
+ return $e({
5586
5586
  url: this.url,
5587
5587
  query: o,
5588
5588
  // @ts-expect-error TODO reconcile batch variables into system.
5589
5589
  variables: a,
5590
5590
  headers: {
5591
- ...W(je(r)),
5591
+ ...W(Ve(r)),
5592
5592
  ...W(s.requestHeaders)
5593
5593
  },
5594
5594
  operationName: void 0,
@@ -5617,7 +5617,7 @@ class vn {
5617
5617
  return this.url = t, this;
5618
5618
  }
5619
5619
  }
5620
- const Be = async (e) => {
5620
+ const $e = async (e) => {
5621
5621
  const { query: t, variables: n, fetchOptions: s } = e, r = Vr(Gs(e.method ?? "post")), i = Array.isArray(e.query), o = await r(e), a = await zr(o, s.jsonSerializer ?? dt), 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";
5622
5622
  if (o.ok && u && c) {
5623
5623
  const { errors: h, ...d } = (Array.isArray(a), a), f = s.errorPolicy === "ignore" ? d : a;
@@ -5637,7 +5637,7 @@ const Be = async (e) => {
5637
5637
  );
5638
5638
  }
5639
5639
  };
5640
- async function De(e, t, ...n) {
5640
+ async function qe(e, t, ...n) {
5641
5641
  const s = Ws(e, t, ...n);
5642
5642
  return new vn(s.url).request({
5643
5643
  ...s
@@ -5656,7 +5656,7 @@ const Hr = (e, t, n, s) => {
5656
5656
  return e.headers.forEach((s, r) => {
5657
5657
  r.toLowerCase() === "content-type" && (n = s);
5658
5658
  }), 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();
5659
- }, je = (e) => typeof e == "function" ? e() : e, Gr = V(async ({ input: e }) => {
5659
+ }, Ve = (e) => typeof e == "function" ? e() : e, Gr = V(async ({ input: e }) => {
5660
5660
  var t;
5661
5661
  if (!e.endpoint || e.endpoint === "")
5662
5662
  throw new Error("No endpoint provided.");
@@ -5667,7 +5667,7 @@ const Hr = (e, t, n, s) => {
5667
5667
  if (!e.requestHeaders)
5668
5668
  throw new Error("No request headers provided.");
5669
5669
  try {
5670
- const n = await De(
5670
+ const n = await qe(
5671
5671
  e.endpoint,
5672
5672
  e.document,
5673
5673
  {
@@ -5688,7 +5688,7 @@ const Hr = (e, t, n, s) => {
5688
5688
  } catch {
5689
5689
  throw console.log("Request to add submit step data failed."), new Error("Request to add submit step data failed.");
5690
5690
  }
5691
- }), Jr = ({ context: e }) => Object.keys(e.quote).length > 0, Pt = he({
5691
+ }), Jr = ({ context: e }) => Object.keys(e.quote).length > 0, Ut = he({
5692
5692
  types: {
5693
5693
  context: {},
5694
5694
  events: {},
@@ -5832,12 +5832,12 @@ const Hr = (e, t, n, s) => {
5832
5832
  // SYNC_IS_LOGGED_IN: '.syncIsLoggedIn',
5833
5833
  // SYNC_QUOTE: '.syncQuote',
5834
5834
  // },
5835
- }), Tn = be({}), fi = () => {
5835
+ }), Tn = be({}), pi = () => {
5836
5836
  const e = Ne(Tn);
5837
5837
  if (!e || !e.getSnapshot)
5838
5838
  throw new Error("checkoutActor is not properly initialized");
5839
- const [t, n] = Ke(() => e.getSnapshot());
5840
- Ze(() => {
5839
+ const [t, n] = Oe(() => e.getSnapshot());
5840
+ Ce(() => {
5841
5841
  if (!e || !e.getSnapshot) {
5842
5842
  console.error("checkoutActor is not properly initialized");
5843
5843
  return;
@@ -5857,7 +5857,7 @@ const Hr = (e, t, n, s) => {
5857
5857
  checkoutActor: e,
5858
5858
  currentStep: s
5859
5859
  };
5860
- }, pi = async (e = {
5860
+ }, yi = async (e = {
5861
5861
  inspect: void 0,
5862
5862
  currentStep: "",
5863
5863
  steps: [],
@@ -5866,14 +5866,14 @@ const Hr = (e, t, n, s) => {
5866
5866
  graphql: {}
5867
5867
  }) => typeof window < "u" ? (console.warn(
5868
5868
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
5869
- ), U(Pt, {
5869
+ ), P(Ut, {
5870
5870
  inspect: e.inspect,
5871
5871
  input: {
5872
5872
  initialContext: {
5873
5873
  endpoints: e.endpoints
5874
5874
  }
5875
5875
  }
5876
- }).start()) : U(Pt, {
5876
+ }).start()) : P(Ut, {
5877
5877
  input: {
5878
5878
  initialContext: {
5879
5879
  currentStep: e.currentStep,
@@ -5887,10 +5887,11 @@ const Hr = (e, t, n, s) => {
5887
5887
  },
5888
5888
  inspect: e.inspect
5889
5889
  }).start();
5890
- function yi({ actor: e, children: t }) {
5890
+ function mi({ actor: e, children: t }) {
5891
5891
  return /* @__PURE__ */ we(Tn.Provider, { value: e, children: t });
5892
5892
  }
5893
- const Yr = he({
5893
+ let Yr = (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), "");
5894
+ const Xr = he({
5894
5895
  actors: {
5895
5896
  tick: As(
5896
5897
  ({ sendBack: e, input: t }) => {
@@ -5968,9 +5969,9 @@ const Yr = he({
5968
5969
  type: "final"
5969
5970
  }
5970
5971
  }
5971
- }), mi = he({
5972
+ }), gi = he({
5972
5973
  actors: {
5973
- timer: Yr
5974
+ timer: Xr
5974
5975
  },
5975
5976
  types: {
5976
5977
  context: {},
@@ -5981,7 +5982,7 @@ const Yr = he({
5981
5982
  addItem: C(({ context: e, event: t }) => {
5982
5983
  if (t.type !== "ADD_ITEM")
5983
5984
  return e;
5984
- const n = `notification-${Math.random().toString(36).slice(2, 11)}-${Date.now().toString(36)}`, s = t.duration ?? e.duration, r = An(t.item, {
5985
+ const n = `notification-${Yr()}`, s = t.duration ?? e.duration, r = An(t.item, {
5985
5986
  duration: s,
5986
5987
  id: n,
5987
5988
  key: t.item.key ?? n,
@@ -6017,7 +6018,15 @@ const Yr = he({
6017
6018
  }
6018
6019
  }).createMachine({
6019
6020
  id: "toast",
6020
- context: { items: [], order: "desc", duration: 0, activeItem: null },
6021
+ context: ({ input: e }) => {
6022
+ var t, n, s, r;
6023
+ return {
6024
+ items: ((t = e == null ? void 0 : e.initialContext) == null ? void 0 : t.items) ?? [],
6025
+ order: ((n = e == null ? void 0 : e.initialContext) == null ? void 0 : n.order) ?? "desc",
6026
+ duration: ((s = e == null ? void 0 : e.initialContext) == null ? void 0 : s.duration) ?? 0,
6027
+ activeItem: ((r = e == null ? void 0 : e.initialContext) == null ? void 0 : r.activeItem) ?? null
6028
+ };
6029
+ },
6021
6030
  initial: "idle",
6022
6031
  states: {
6023
6032
  idle: {
@@ -6041,16 +6050,9 @@ const Yr = he({
6041
6050
  target: "removing",
6042
6051
  guard: "itemHasTimeout"
6043
6052
  }
6044
- // data: Object.assign(timerMachine.context, {
6045
- // duration: (context: ToastMachineContext) =>
6046
- // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
6047
- // context.items[context.items.length - 1].duration ??
6048
- // context.duration,
6049
- // }),
6050
6053
  },
6051
6054
  on: {
6052
6055
  ADD_ITEM: {
6053
- // actions: sendTo('timer', 'PAUSE_TIMER'),
6054
6056
  target: "adding"
6055
6057
  },
6056
6058
  REMOVE_ITEM: {
@@ -6061,19 +6063,11 @@ const Yr = he({
6061
6063
  },
6062
6064
  RESUME_TIMER: {
6063
6065
  actions: bt("timer", { type: "RESUME_TIMER" })
6064
- // cond: (context) => context.duration > 0,
6065
6066
  },
6066
6067
  PAUSE_TIMER: {
6067
6068
  actions: bt("timer", { type: "PAUSE_TIMER" })
6068
- // cond: (context) => context.duration > 0,
6069
6069
  }
6070
6070
  }
6071
- // after: {
6072
- // ITEM_TIMEOUT: {
6073
- // target: 'removing',
6074
- // cond: 'itemHasTimeout',
6075
- // },
6076
- // },
6077
6071
  },
6078
6072
  adding: {
6079
6073
  entry: ["addItem"],
@@ -6100,11 +6094,31 @@ const Yr = he({
6100
6094
  }
6101
6095
  }), _n = be(
6102
6096
  {}
6103
- ), gi = () => ({ toastActor: Ne(_n) });
6104
- function Ei({ children: e, actor: t }) {
6097
+ ), Ei = () => {
6098
+ const e = Ne(_n);
6099
+ if (!e || !e.getSnapshot)
6100
+ throw new Error("toastActor is not properly initialized");
6101
+ const [t, n] = Oe(() => e.getSnapshot());
6102
+ return Ce(() => {
6103
+ if (!e || !e.getSnapshot) {
6104
+ console.error("toastActor is not properly initialized");
6105
+ return;
6106
+ }
6107
+ (() => {
6108
+ n(e.getSnapshot());
6109
+ })();
6110
+ const r = e.subscribe((i) => {
6111
+ n(i);
6112
+ });
6113
+ return () => {
6114
+ r.unsubscribe();
6115
+ };
6116
+ }, [e]), { toastActor: e };
6117
+ };
6118
+ function vi({ children: e, actor: t }) {
6105
6119
  return /* @__PURE__ */ we(_n.Provider, { value: t, children: e });
6106
6120
  }
6107
- function Xr({
6121
+ function Qr({
6108
6122
  context: e,
6109
6123
  event: t
6110
6124
  }) {
@@ -6116,7 +6130,7 @@ function Xr({
6116
6130
  itemsAdded: n.output.itemsAdded
6117
6131
  };
6118
6132
  }
6119
- function Qr({
6133
+ function Wr({
6120
6134
  event: e
6121
6135
  }) {
6122
6136
  if (!e.type.includes("xstate.done.actor"))
@@ -6127,7 +6141,7 @@ function Qr({
6127
6141
  itemsAdded: t.output.itemsAdded
6128
6142
  };
6129
6143
  }
6130
- function Wr({
6144
+ function Kr({
6131
6145
  event: e
6132
6146
  }) {
6133
6147
  if (!e.type.includes("xstate.done.actor"))
@@ -6138,7 +6152,7 @@ function Wr({
6138
6152
  itemsRemoved: t.output.itemsRemoved
6139
6153
  };
6140
6154
  }
6141
- function Kr({
6155
+ function Zr({
6142
6156
  event: e
6143
6157
  }) {
6144
6158
  if (!e.type.includes("xstate.done.actor"))
@@ -6155,7 +6169,7 @@ function Kr({
6155
6169
  itemsUpdated: t.output.itemsUpdated
6156
6170
  };
6157
6171
  }
6158
- function Zr({
6172
+ function ei({
6159
6173
  context: e,
6160
6174
  event: t
6161
6175
  }) {
@@ -6167,7 +6181,7 @@ function Zr({
6167
6181
  itemsRemoved: n.output.itemsRemoved
6168
6182
  };
6169
6183
  }
6170
- function ei({
6184
+ function ti({
6171
6185
  context: e,
6172
6186
  event: t
6173
6187
  }) {
@@ -6178,7 +6192,7 @@ function ei({
6178
6192
  quote: { ...e.quote, ...n.output.quote }
6179
6193
  };
6180
6194
  }
6181
- function ti({
6195
+ function ni({
6182
6196
  context: e,
6183
6197
  event: t
6184
6198
  }) {
@@ -6190,7 +6204,7 @@ function ti({
6190
6204
  itemsUpdated: n.output.itemsUpdated
6191
6205
  };
6192
6206
  }
6193
- const ni = V(
6207
+ const si = V(
6194
6208
  async ({ input: e }) => {
6195
6209
  var t;
6196
6210
  if (!e.endpoint || e.endpoint === "")
@@ -6202,7 +6216,7 @@ const ni = V(
6202
6216
  if (!e.requestHeaders)
6203
6217
  throw new Error("No request headers provided.");
6204
6218
  try {
6205
- const n = await De(
6219
+ const n = await qe(
6206
6220
  e.endpoint,
6207
6221
  e.document,
6208
6222
  { items: e.items },
@@ -6219,14 +6233,14 @@ const ni = V(
6219
6233
  throw new Error("Request to add item(s) failed.");
6220
6234
  }
6221
6235
  }
6222
- ), si = V(async ({ input: e }) => {
6236
+ ), ri = V(async ({ input: e }) => {
6223
6237
  var t;
6224
6238
  if (!e.endpoint || e.endpoint === "")
6225
6239
  throw new Error("No endpoint provided.");
6226
6240
  if (e.items.length < 1)
6227
6241
  throw new Error("No items provided.");
6228
6242
  try {
6229
- const n = await De(
6243
+ const n = await qe(
6230
6244
  e.endpoint,
6231
6245
  ""
6232
6246
  // input.document,
@@ -6243,7 +6257,7 @@ const ni = V(
6243
6257
  } catch {
6244
6258
  throw new Error("Request to remove item(s) failed.");
6245
6259
  }
6246
- }), $e = typeof window > "u", ri = V(
6260
+ }), He = typeof window > "u", ii = V(
6247
6261
  async ({ input: e }) => {
6248
6262
  var n, s, r, i;
6249
6263
  if (!e.endpoint)
@@ -6257,8 +6271,8 @@ const ni = V(
6257
6271
  if (!e.requestHeaders)
6258
6272
  throw console.log("no headers"), new Error("No request headers provided.");
6259
6273
  const t = new vn(
6260
- $e ? e.endpointSsr : e.endpoint,
6261
- $e ? { fetch, method: "POST" } : {
6274
+ He ? e.endpointSsr : e.endpoint,
6275
+ He ? { fetch, method: "POST" } : {
6262
6276
  credentials: "include",
6263
6277
  method: "POST",
6264
6278
  mode: "cors"
@@ -6268,7 +6282,7 @@ const ni = V(
6268
6282
  const { data: o, headers: a, status: c, errors: u, extensions: h } = await t.rawRequest(
6269
6283
  En(e.document),
6270
6284
  {},
6271
- $e ? {
6285
+ He ? {
6272
6286
  ...e.requestHeaders,
6273
6287
  Cookie: `quote_${e.locale}=${e.quoteId ?? ""}`
6274
6288
  } : e.requestHeaders
@@ -6285,7 +6299,7 @@ const ni = V(
6285
6299
  throw console.log("refresh error", o), new Error("Request to add item(s) failed.");
6286
6300
  }
6287
6301
  }
6288
- ), ii = V(async ({ input: e }) => {
6302
+ ), oi = V(async ({ input: e }) => {
6289
6303
  var t;
6290
6304
  if (!e.endpoint || e.endpoint === "")
6291
6305
  throw new Error("No endpoint provided.");
@@ -6296,7 +6310,7 @@ const ni = V(
6296
6310
  if (!e.requestHeaders)
6297
6311
  throw new Error("No request headers provided.");
6298
6312
  try {
6299
- const n = await De(
6313
+ const n = await qe(
6300
6314
  e.endpoint,
6301
6315
  e.document,
6302
6316
  { items: e.items },
@@ -6312,7 +6326,7 @@ const ni = V(
6312
6326
  } catch {
6313
6327
  throw new Error("Request to add item(s) failed.");
6314
6328
  }
6315
- }), oi = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", ai = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Ut = he({
6329
+ }), ai = ({ context: e }) => typeof window > "u" && e.quote.id !== "" || typeof window < "u", ci = ({ context: e }) => !!e.quote.items && e.quote.items.length > 0, Pt = he({
6316
6330
  types: {
6317
6331
  context: {},
6318
6332
  emitted: {},
@@ -6320,23 +6334,23 @@ const ni = V(
6320
6334
  input: {}
6321
6335
  },
6322
6336
  actions: {
6323
- addItems: C(Xr),
6324
- notifyAddItems: Pe(Qr),
6325
- notifyRemoveItems: Pe(Wr),
6326
- notifyUpdateItems: Pe(Kr),
6327
- removeItems: C(Zr),
6328
- refresh: C(ei),
6329
- updateItems: C(ti)
6337
+ addItems: C(Qr),
6338
+ notifyAddItems: Fe(Wr),
6339
+ notifyRemoveItems: Fe(Kr),
6340
+ notifyUpdateItems: Fe(Zr),
6341
+ removeItems: C(ei),
6342
+ refresh: C(ti),
6343
+ updateItems: C(ni)
6330
6344
  },
6331
6345
  actors: {
6332
- addItems: ni,
6333
- removeItems: si,
6334
- refresh: ri,
6335
- updateItems: ii
6346
+ addItems: si,
6347
+ removeItems: ri,
6348
+ refresh: ii,
6349
+ updateItems: oi
6336
6350
  },
6337
6351
  guards: {
6338
- canRefresh: oi,
6339
- hasItems: ai
6352
+ canRefresh: ai,
6353
+ hasItems: ci
6340
6354
  }
6341
6355
  }).createMachine({
6342
6356
  /** @todo do we need to add the view to the id? (e.g. quote_en-us) */
@@ -6691,13 +6705,13 @@ const ni = V(
6691
6705
  }
6692
6706
  }), Sn = be(
6693
6707
  {}
6694
- ), vi = () => {
6708
+ ), Ti = () => {
6695
6709
  var c;
6696
6710
  const e = Ne(Sn);
6697
6711
  if (!e || !e.getSnapshot)
6698
6712
  throw new Error("quoteActor is not properly initialized");
6699
- const [t, n] = Ke(() => e.getSnapshot());
6700
- Ze(() => {
6713
+ const [t, n] = Oe(() => e.getSnapshot());
6714
+ Ce(() => {
6701
6715
  if (!e || !e.getSnapshot) {
6702
6716
  console.error("quoteActor is not properly initialized");
6703
6717
  return;
@@ -6721,21 +6735,21 @@ const ni = V(
6721
6735
  isRemovingItems: o,
6722
6736
  isUpdatingItems: a
6723
6737
  };
6724
- }, Ti = async (e = {
6738
+ }, _i = async (e = {
6725
6739
  inspect: void 0,
6726
6740
  quote: { id: "", locale: "" },
6727
6741
  endpoints: { client: "", server: "" },
6728
6742
  graphql: {}
6729
6743
  }) => typeof window < "u" ? (console.warn(
6730
6744
  "App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."
6731
- ), U(Ut, {
6745
+ ), P(Pt, {
6732
6746
  inspect: e.inspect,
6733
6747
  input: {
6734
6748
  initialContext: {
6735
6749
  endpoints: e.endpoints
6736
6750
  }
6737
6751
  }
6738
- }).start()) : U(Ut, {
6752
+ }).start()) : P(Pt, {
6739
6753
  input: {
6740
6754
  initialContext: {
6741
6755
  endpoints: e.endpoints,
@@ -6748,28 +6762,28 @@ const ni = V(
6748
6762
  },
6749
6763
  inspect: e.inspect
6750
6764
  }).start();
6751
- function _i({ actor: e, children: t }) {
6765
+ function Si({ actor: e, children: t }) {
6752
6766
  return /* @__PURE__ */ we(Sn.Provider, { value: e, children: t });
6753
6767
  }
6754
6768
  export {
6755
6769
  an as AuthContext,
6756
- hi as AuthProvider,
6770
+ fi as AuthProvider,
6757
6771
  Tn as CheckoutContext,
6758
- yi as CheckoutProvider,
6772
+ mi as CheckoutProvider,
6759
6773
  Sn as QuoteContext,
6760
- _i as QuoteProvider,
6774
+ Si as QuoteProvider,
6761
6775
  _n as ToastContext,
6762
- Ei as ToastProvider,
6776
+ vi as ToastProvider,
6763
6777
  Ot as authMachine,
6764
- Pt as checkoutMachine,
6765
- li as getAuth,
6766
- pi as getCheckout,
6767
- Ti as getQuote,
6768
- Ut as quoteMachine,
6769
- Yr as timerMachine,
6770
- mi as toastMachine,
6771
- di as useAuth,
6772
- fi as useCheckout,
6773
- vi as useQuote,
6774
- gi as useToast
6778
+ Ut as checkoutMachine,
6779
+ hi as getAuth,
6780
+ yi as getCheckout,
6781
+ _i as getQuote,
6782
+ Pt as quoteMachine,
6783
+ Xr as timerMachine,
6784
+ gi as toastMachine,
6785
+ li as useAuth,
6786
+ pi as useCheckout,
6787
+ Ti as useQuote,
6788
+ Ei as useToast
6775
6789
  };