@plasmicpkgs/commerce-swell 0.0.166 → 0.0.167

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.
@@ -8,7 +8,8 @@ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGl
8
8
  var React = require('react');
9
9
  var React__default = _interopDefault(React);
10
10
  var commerce = require('@plasmicpkgs/commerce');
11
- var swell = _interopDefault(require('swell-js'));
11
+ var swell = require('swell-js');
12
+ var swell__default = _interopDefault(swell);
12
13
  var Cookies = _interopDefault(require('js-cookie'));
13
14
  var debounce = _interopDefault(require('debounce'));
14
15
 
@@ -20,6 +21,307 @@ var SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId';
20
21
  var SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl';
21
22
  var SWELL_COOKIE_EXPIRE = 30;
22
23
 
24
+ function _regeneratorRuntime() {
25
+ _regeneratorRuntime = function () {
26
+ return e;
27
+ };
28
+ var t,
29
+ e = {},
30
+ r = Object.prototype,
31
+ n = r.hasOwnProperty,
32
+ o = Object.defineProperty || function (t, e, r) {
33
+ t[e] = r.value;
34
+ },
35
+ i = "function" == typeof Symbol ? Symbol : {},
36
+ a = i.iterator || "@@iterator",
37
+ c = i.asyncIterator || "@@asyncIterator",
38
+ u = i.toStringTag || "@@toStringTag";
39
+ function define(t, e, r) {
40
+ return Object.defineProperty(t, e, {
41
+ value: r,
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0
45
+ }), t[e];
46
+ }
47
+ try {
48
+ define({}, "");
49
+ } catch (t) {
50
+ define = function (t, e, r) {
51
+ return t[e] = r;
52
+ };
53
+ }
54
+ function wrap(t, e, r, n) {
55
+ var i = e && e.prototype instanceof Generator ? e : Generator,
56
+ a = Object.create(i.prototype),
57
+ c = new Context(n || []);
58
+ return o(a, "_invoke", {
59
+ value: makeInvokeMethod(t, r, c)
60
+ }), a;
61
+ }
62
+ function tryCatch(t, e, r) {
63
+ try {
64
+ return {
65
+ type: "normal",
66
+ arg: t.call(e, r)
67
+ };
68
+ } catch (t) {
69
+ return {
70
+ type: "throw",
71
+ arg: t
72
+ };
73
+ }
74
+ }
75
+ e.wrap = wrap;
76
+ var h = "suspendedStart",
77
+ l = "suspendedYield",
78
+ f = "executing",
79
+ s = "completed",
80
+ y = {};
81
+ function Generator() {}
82
+ function GeneratorFunction() {}
83
+ function GeneratorFunctionPrototype() {}
84
+ var p = {};
85
+ define(p, a, function () {
86
+ return this;
87
+ });
88
+ var d = Object.getPrototypeOf,
89
+ v = d && d(d(values([])));
90
+ v && v !== r && n.call(v, a) && (p = v);
91
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
92
+ function defineIteratorMethods(t) {
93
+ ["next", "throw", "return"].forEach(function (e) {
94
+ define(t, e, function (t) {
95
+ return this._invoke(e, t);
96
+ });
97
+ });
98
+ }
99
+ function AsyncIterator(t, e) {
100
+ function invoke(r, o, i, a) {
101
+ var c = tryCatch(t[r], t, o);
102
+ if ("throw" !== c.type) {
103
+ var u = c.arg,
104
+ h = u.value;
105
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
106
+ invoke("next", t, i, a);
107
+ }, function (t) {
108
+ invoke("throw", t, i, a);
109
+ }) : e.resolve(h).then(function (t) {
110
+ u.value = t, i(u);
111
+ }, function (t) {
112
+ return invoke("throw", t, i, a);
113
+ });
114
+ }
115
+ a(c.arg);
116
+ }
117
+ var r;
118
+ o(this, "_invoke", {
119
+ value: function (t, n) {
120
+ function callInvokeWithMethodAndArg() {
121
+ return new e(function (e, r) {
122
+ invoke(t, n, e, r);
123
+ });
124
+ }
125
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
126
+ }
127
+ });
128
+ }
129
+ function makeInvokeMethod(e, r, n) {
130
+ var o = h;
131
+ return function (i, a) {
132
+ if (o === f) throw new Error("Generator is already running");
133
+ if (o === s) {
134
+ if ("throw" === i) throw a;
135
+ return {
136
+ value: t,
137
+ done: !0
138
+ };
139
+ }
140
+ for (n.method = i, n.arg = a;;) {
141
+ var c = n.delegate;
142
+ if (c) {
143
+ var u = maybeInvokeDelegate(c, n);
144
+ if (u) {
145
+ if (u === y) continue;
146
+ return u;
147
+ }
148
+ }
149
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
150
+ if (o === h) throw o = s, n.arg;
151
+ n.dispatchException(n.arg);
152
+ } else "return" === n.method && n.abrupt("return", n.arg);
153
+ o = f;
154
+ var p = tryCatch(e, r, n);
155
+ if ("normal" === p.type) {
156
+ if (o = n.done ? s : l, p.arg === y) continue;
157
+ return {
158
+ value: p.arg,
159
+ done: n.done
160
+ };
161
+ }
162
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
163
+ }
164
+ };
165
+ }
166
+ function maybeInvokeDelegate(e, r) {
167
+ var n = r.method,
168
+ o = e.iterator[n];
169
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
170
+ var i = tryCatch(o, e.iterator, r.arg);
171
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
172
+ var a = i.arg;
173
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
174
+ }
175
+ function pushTryEntry(t) {
176
+ var e = {
177
+ tryLoc: t[0]
178
+ };
179
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
180
+ }
181
+ function resetTryEntry(t) {
182
+ var e = t.completion || {};
183
+ e.type = "normal", delete e.arg, t.completion = e;
184
+ }
185
+ function Context(t) {
186
+ this.tryEntries = [{
187
+ tryLoc: "root"
188
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
189
+ }
190
+ function values(e) {
191
+ if (e || "" === e) {
192
+ var r = e[a];
193
+ if (r) return r.call(e);
194
+ if ("function" == typeof e.next) return e;
195
+ if (!isNaN(e.length)) {
196
+ var o = -1,
197
+ i = function next() {
198
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
199
+ return next.value = t, next.done = !0, next;
200
+ };
201
+ return i.next = i;
202
+ }
203
+ }
204
+ throw new TypeError(typeof e + " is not iterable");
205
+ }
206
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
207
+ value: GeneratorFunctionPrototype,
208
+ configurable: !0
209
+ }), o(GeneratorFunctionPrototype, "constructor", {
210
+ value: GeneratorFunction,
211
+ configurable: !0
212
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
213
+ var e = "function" == typeof t && t.constructor;
214
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
215
+ }, e.mark = function (t) {
216
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
217
+ }, e.awrap = function (t) {
218
+ return {
219
+ __await: t
220
+ };
221
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
222
+ return this;
223
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
224
+ void 0 === i && (i = Promise);
225
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
226
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
227
+ return t.done ? t.value : a.next();
228
+ });
229
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
230
+ return this;
231
+ }), define(g, "toString", function () {
232
+ return "[object Generator]";
233
+ }), e.keys = function (t) {
234
+ var e = Object(t),
235
+ r = [];
236
+ for (var n in e) r.push(n);
237
+ return r.reverse(), function next() {
238
+ for (; r.length;) {
239
+ var t = r.pop();
240
+ if (t in e) return next.value = t, next.done = !1, next;
241
+ }
242
+ return next.done = !0, next;
243
+ };
244
+ }, e.values = values, Context.prototype = {
245
+ constructor: Context,
246
+ reset: function (e) {
247
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
248
+ },
249
+ stop: function () {
250
+ this.done = !0;
251
+ var t = this.tryEntries[0].completion;
252
+ if ("throw" === t.type) throw t.arg;
253
+ return this.rval;
254
+ },
255
+ dispatchException: function (e) {
256
+ if (this.done) throw e;
257
+ var r = this;
258
+ function handle(n, o) {
259
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
260
+ }
261
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
262
+ var i = this.tryEntries[o],
263
+ a = i.completion;
264
+ if ("root" === i.tryLoc) return handle("end");
265
+ if (i.tryLoc <= this.prev) {
266
+ var c = n.call(i, "catchLoc"),
267
+ u = n.call(i, "finallyLoc");
268
+ if (c && u) {
269
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
270
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
271
+ } else if (c) {
272
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
273
+ } else {
274
+ if (!u) throw new Error("try statement without catch or finally");
275
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
276
+ }
277
+ }
278
+ }
279
+ },
280
+ abrupt: function (t, e) {
281
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
282
+ var o = this.tryEntries[r];
283
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
284
+ var i = o;
285
+ break;
286
+ }
287
+ }
288
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
289
+ var a = i ? i.completion : {};
290
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
291
+ },
292
+ complete: function (t, e) {
293
+ if ("throw" === t.type) throw t.arg;
294
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
295
+ },
296
+ finish: function (t) {
297
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
298
+ var r = this.tryEntries[e];
299
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
300
+ }
301
+ },
302
+ catch: function (t) {
303
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
304
+ var r = this.tryEntries[e];
305
+ if (r.tryLoc === t) {
306
+ var n = r.completion;
307
+ if ("throw" === n.type) {
308
+ var o = n.arg;
309
+ resetTryEntry(r);
310
+ }
311
+ return o;
312
+ }
313
+ }
314
+ throw new Error("illegal catch attempt");
315
+ },
316
+ delegateYield: function (e, r, n) {
317
+ return this.delegate = {
318
+ iterator: values(e),
319
+ resultName: r,
320
+ nextLoc: n
321
+ }, "next" === this.method && (this.arg = t), y;
322
+ }
323
+ }, e;
324
+ }
23
325
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
24
326
  try {
25
327
  var info = gen[key](arg);
@@ -108,664 +410,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
108
410
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
109
411
  }
110
412
 
111
- function createCommonjsModule(fn, module) {
112
- return module = { exports: {} }, fn(module, module.exports), module.exports;
113
- }
114
-
115
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
116
- /**
117
- * Copyright (c) 2014-present, Facebook, Inc.
118
- *
119
- * This source code is licensed under the MIT license found in the
120
- * LICENSE file in the root directory of this source tree.
121
- */
122
-
123
- var runtime = function (exports) {
124
-
125
- var Op = Object.prototype;
126
- var hasOwn = Op.hasOwnProperty;
127
- var undefined$1; // More compressible than void 0.
128
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
129
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
130
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
131
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
132
- function define(obj, key, value) {
133
- Object.defineProperty(obj, key, {
134
- value: value,
135
- enumerable: true,
136
- configurable: true,
137
- writable: true
138
- });
139
- return obj[key];
140
- }
141
- try {
142
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
143
- define({}, "");
144
- } catch (err) {
145
- define = function define(obj, key, value) {
146
- return obj[key] = value;
147
- };
148
- }
149
- function wrap(innerFn, outerFn, self, tryLocsList) {
150
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
151
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
152
- var generator = Object.create(protoGenerator.prototype);
153
- var context = new Context(tryLocsList || []);
154
-
155
- // The ._invoke method unifies the implementations of the .next,
156
- // .throw, and .return methods.
157
- generator._invoke = makeInvokeMethod(innerFn, self, context);
158
- return generator;
159
- }
160
- exports.wrap = wrap;
161
-
162
- // Try/catch helper to minimize deoptimizations. Returns a completion
163
- // record like context.tryEntries[i].completion. This interface could
164
- // have been (and was previously) designed to take a closure to be
165
- // invoked without arguments, but in all the cases we care about we
166
- // already have an existing method we want to call, so there's no need
167
- // to create a new function object. We can even get away with assuming
168
- // the method takes exactly one argument, since that happens to be true
169
- // in every case, so we don't have to touch the arguments object. The
170
- // only additional allocation required is the completion record, which
171
- // has a stable shape and so hopefully should be cheap to allocate.
172
- function tryCatch(fn, obj, arg) {
173
- try {
174
- return {
175
- type: "normal",
176
- arg: fn.call(obj, arg)
177
- };
178
- } catch (err) {
179
- return {
180
- type: "throw",
181
- arg: err
182
- };
183
- }
184
- }
185
- var GenStateSuspendedStart = "suspendedStart";
186
- var GenStateSuspendedYield = "suspendedYield";
187
- var GenStateExecuting = "executing";
188
- var GenStateCompleted = "completed";
189
-
190
- // Returning this object from the innerFn has the same effect as
191
- // breaking out of the dispatch switch statement.
192
- var ContinueSentinel = {};
193
-
194
- // Dummy constructor functions that we use as the .constructor and
195
- // .constructor.prototype properties for functions that return Generator
196
- // objects. For full spec compliance, you may wish to configure your
197
- // minifier not to mangle the names of these two functions.
198
- function Generator() {}
199
- function GeneratorFunction() {}
200
- function GeneratorFunctionPrototype() {}
201
-
202
- // This is a polyfill for %IteratorPrototype% for environments that
203
- // don't natively support it.
204
- var IteratorPrototype = {};
205
- define(IteratorPrototype, iteratorSymbol, function () {
206
- return this;
207
- });
208
- var getProto = Object.getPrototypeOf;
209
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
210
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
211
- // This environment has a native %IteratorPrototype%; use it instead
212
- // of the polyfill.
213
- IteratorPrototype = NativeIteratorPrototype;
214
- }
215
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
216
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
217
- define(Gp, "constructor", GeneratorFunctionPrototype);
218
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
219
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
220
-
221
- // Helper for defining the .next, .throw, and .return methods of the
222
- // Iterator interface in terms of a single ._invoke method.
223
- function defineIteratorMethods(prototype) {
224
- ["next", "throw", "return"].forEach(function (method) {
225
- define(prototype, method, function (arg) {
226
- return this._invoke(method, arg);
227
- });
228
- });
229
- }
230
- exports.isGeneratorFunction = function (genFun) {
231
- var ctor = typeof genFun === "function" && genFun.constructor;
232
- return ctor ? ctor === GeneratorFunction ||
233
- // For the native GeneratorFunction constructor, the best we can
234
- // do is to check its .name property.
235
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
236
- };
237
- exports.mark = function (genFun) {
238
- if (Object.setPrototypeOf) {
239
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
240
- } else {
241
- genFun.__proto__ = GeneratorFunctionPrototype;
242
- define(genFun, toStringTagSymbol, "GeneratorFunction");
243
- }
244
- genFun.prototype = Object.create(Gp);
245
- return genFun;
246
- };
247
-
248
- // Within the body of any async function, `await x` is transformed to
249
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
250
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
251
- // meant to be awaited.
252
- exports.awrap = function (arg) {
253
- return {
254
- __await: arg
255
- };
256
- };
257
- function AsyncIterator(generator, PromiseImpl) {
258
- function invoke(method, arg, resolve, reject) {
259
- var record = tryCatch(generator[method], generator, arg);
260
- if (record.type === "throw") {
261
- reject(record.arg);
262
- } else {
263
- var result = record.arg;
264
- var value = result.value;
265
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
266
- return PromiseImpl.resolve(value.__await).then(function (value) {
267
- invoke("next", value, resolve, reject);
268
- }, function (err) {
269
- invoke("throw", err, resolve, reject);
270
- });
271
- }
272
- return PromiseImpl.resolve(value).then(function (unwrapped) {
273
- // When a yielded Promise is resolved, its final value becomes
274
- // the .value of the Promise<{value,done}> result for the
275
- // current iteration.
276
- result.value = unwrapped;
277
- resolve(result);
278
- }, function (error) {
279
- // If a rejected Promise was yielded, throw the rejection back
280
- // into the async generator function so it can be handled there.
281
- return invoke("throw", error, resolve, reject);
282
- });
283
- }
284
- }
285
- var previousPromise;
286
- function enqueue(method, arg) {
287
- function callInvokeWithMethodAndArg() {
288
- return new PromiseImpl(function (resolve, reject) {
289
- invoke(method, arg, resolve, reject);
290
- });
291
- }
292
- return previousPromise =
293
- // If enqueue has been called before, then we want to wait until
294
- // all previous Promises have been resolved before calling invoke,
295
- // so that results are always delivered in the correct order. If
296
- // enqueue has not been called before, then it is important to
297
- // call invoke immediately, without waiting on a callback to fire,
298
- // so that the async generator function has the opportunity to do
299
- // any necessary setup in a predictable way. This predictability
300
- // is why the Promise constructor synchronously invokes its
301
- // executor callback, and why async functions synchronously
302
- // execute code before the first await. Since we implement simple
303
- // async functions in terms of async generators, it is especially
304
- // important to get this right, even though it requires care.
305
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
306
- // Avoid propagating failures to Promises returned by later
307
- // invocations of the iterator.
308
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
309
- }
310
-
311
- // Define the unified helper method that is used to implement .next,
312
- // .throw, and .return (see defineIteratorMethods).
313
- this._invoke = enqueue;
314
- }
315
- defineIteratorMethods(AsyncIterator.prototype);
316
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
317
- return this;
318
- });
319
- exports.AsyncIterator = AsyncIterator;
320
-
321
- // Note that simple async functions are implemented on top of
322
- // AsyncIterator objects; they just return a Promise for the value of
323
- // the final result produced by the iterator.
324
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
325
- if (PromiseImpl === void 0) PromiseImpl = Promise;
326
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
327
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
328
- : iter.next().then(function (result) {
329
- return result.done ? result.value : iter.next();
330
- });
331
- };
332
- function makeInvokeMethod(innerFn, self, context) {
333
- var state = GenStateSuspendedStart;
334
- return function invoke(method, arg) {
335
- if (state === GenStateExecuting) {
336
- throw new Error("Generator is already running");
337
- }
338
- if (state === GenStateCompleted) {
339
- if (method === "throw") {
340
- throw arg;
341
- }
342
-
343
- // Be forgiving, per 25.3.3.3.3 of the spec:
344
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
345
- return doneResult();
346
- }
347
- context.method = method;
348
- context.arg = arg;
349
- while (true) {
350
- var delegate = context.delegate;
351
- if (delegate) {
352
- var delegateResult = maybeInvokeDelegate(delegate, context);
353
- if (delegateResult) {
354
- if (delegateResult === ContinueSentinel) continue;
355
- return delegateResult;
356
- }
357
- }
358
- if (context.method === "next") {
359
- // Setting context._sent for legacy support of Babel's
360
- // function.sent implementation.
361
- context.sent = context._sent = context.arg;
362
- } else if (context.method === "throw") {
363
- if (state === GenStateSuspendedStart) {
364
- state = GenStateCompleted;
365
- throw context.arg;
366
- }
367
- context.dispatchException(context.arg);
368
- } else if (context.method === "return") {
369
- context.abrupt("return", context.arg);
370
- }
371
- state = GenStateExecuting;
372
- var record = tryCatch(innerFn, self, context);
373
- if (record.type === "normal") {
374
- // If an exception is thrown from innerFn, we leave state ===
375
- // GenStateExecuting and loop back for another invocation.
376
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
377
- if (record.arg === ContinueSentinel) {
378
- continue;
379
- }
380
- return {
381
- value: record.arg,
382
- done: context.done
383
- };
384
- } else if (record.type === "throw") {
385
- state = GenStateCompleted;
386
- // Dispatch the exception by looping back around to the
387
- // context.dispatchException(context.arg) call above.
388
- context.method = "throw";
389
- context.arg = record.arg;
390
- }
391
- }
392
- };
393
- }
394
-
395
- // Call delegate.iterator[context.method](context.arg) and handle the
396
- // result, either by returning a { value, done } result from the
397
- // delegate iterator, or by modifying context.method and context.arg,
398
- // setting context.delegate to null, and returning the ContinueSentinel.
399
- function maybeInvokeDelegate(delegate, context) {
400
- var method = delegate.iterator[context.method];
401
- if (method === undefined$1) {
402
- // A .throw or .return when the delegate iterator has no .throw
403
- // method always terminates the yield* loop.
404
- context.delegate = null;
405
- if (context.method === "throw") {
406
- // Note: ["return"] must be used for ES3 parsing compatibility.
407
- if (delegate.iterator["return"]) {
408
- // If the delegate iterator has a return method, give it a
409
- // chance to clean up.
410
- context.method = "return";
411
- context.arg = undefined$1;
412
- maybeInvokeDelegate(delegate, context);
413
- if (context.method === "throw") {
414
- // If maybeInvokeDelegate(context) changed context.method from
415
- // "return" to "throw", let that override the TypeError below.
416
- return ContinueSentinel;
417
- }
418
- }
419
- context.method = "throw";
420
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
421
- }
422
- return ContinueSentinel;
423
- }
424
- var record = tryCatch(method, delegate.iterator, context.arg);
425
- if (record.type === "throw") {
426
- context.method = "throw";
427
- context.arg = record.arg;
428
- context.delegate = null;
429
- return ContinueSentinel;
430
- }
431
- var info = record.arg;
432
- if (!info) {
433
- context.method = "throw";
434
- context.arg = new TypeError("iterator result is not an object");
435
- context.delegate = null;
436
- return ContinueSentinel;
437
- }
438
- if (info.done) {
439
- // Assign the result of the finished delegate to the temporary
440
- // variable specified by delegate.resultName (see delegateYield).
441
- context[delegate.resultName] = info.value;
442
-
443
- // Resume execution at the desired location (see delegateYield).
444
- context.next = delegate.nextLoc;
445
-
446
- // If context.method was "throw" but the delegate handled the
447
- // exception, let the outer generator proceed normally. If
448
- // context.method was "next", forget context.arg since it has been
449
- // "consumed" by the delegate iterator. If context.method was
450
- // "return", allow the original .return call to continue in the
451
- // outer generator.
452
- if (context.method !== "return") {
453
- context.method = "next";
454
- context.arg = undefined$1;
455
- }
456
- } else {
457
- // Re-yield the result returned by the delegate method.
458
- return info;
459
- }
460
-
461
- // The delegate iterator is finished, so forget it and continue with
462
- // the outer generator.
463
- context.delegate = null;
464
- return ContinueSentinel;
465
- }
466
-
467
- // Define Generator.prototype.{next,throw,return} in terms of the
468
- // unified ._invoke helper method.
469
- defineIteratorMethods(Gp);
470
- define(Gp, toStringTagSymbol, "Generator");
471
-
472
- // A Generator should always return itself as the iterator object when the
473
- // @@iterator function is called on it. Some browsers' implementations of the
474
- // iterator prototype chain incorrectly implement this, causing the Generator
475
- // object to not be returned from this call. This ensures that doesn't happen.
476
- // See https://github.com/facebook/regenerator/issues/274 for more details.
477
- define(Gp, iteratorSymbol, function () {
478
- return this;
479
- });
480
- define(Gp, "toString", function () {
481
- return "[object Generator]";
482
- });
483
- function pushTryEntry(locs) {
484
- var entry = {
485
- tryLoc: locs[0]
486
- };
487
- if (1 in locs) {
488
- entry.catchLoc = locs[1];
489
- }
490
- if (2 in locs) {
491
- entry.finallyLoc = locs[2];
492
- entry.afterLoc = locs[3];
493
- }
494
- this.tryEntries.push(entry);
495
- }
496
- function resetTryEntry(entry) {
497
- var record = entry.completion || {};
498
- record.type = "normal";
499
- delete record.arg;
500
- entry.completion = record;
501
- }
502
- function Context(tryLocsList) {
503
- // The root entry object (effectively a try statement without a catch
504
- // or a finally block) gives us a place to store values thrown from
505
- // locations where there is no enclosing try statement.
506
- this.tryEntries = [{
507
- tryLoc: "root"
508
- }];
509
- tryLocsList.forEach(pushTryEntry, this);
510
- this.reset(true);
511
- }
512
- exports.keys = function (object) {
513
- var keys = [];
514
- for (var key in object) {
515
- keys.push(key);
516
- }
517
- keys.reverse();
518
-
519
- // Rather than returning an object with a next method, we keep
520
- // things simple and return the next function itself.
521
- return function next() {
522
- while (keys.length) {
523
- var key = keys.pop();
524
- if (key in object) {
525
- next.value = key;
526
- next.done = false;
527
- return next;
528
- }
529
- }
530
-
531
- // To avoid creating an additional object, we just hang the .value
532
- // and .done properties off the next function object itself. This
533
- // also ensures that the minifier will not anonymize the function.
534
- next.done = true;
535
- return next;
536
- };
537
- };
538
- function values(iterable) {
539
- if (iterable) {
540
- var iteratorMethod = iterable[iteratorSymbol];
541
- if (iteratorMethod) {
542
- return iteratorMethod.call(iterable);
543
- }
544
- if (typeof iterable.next === "function") {
545
- return iterable;
546
- }
547
- if (!isNaN(iterable.length)) {
548
- var i = -1,
549
- next = function next() {
550
- while (++i < iterable.length) {
551
- if (hasOwn.call(iterable, i)) {
552
- next.value = iterable[i];
553
- next.done = false;
554
- return next;
555
- }
556
- }
557
- next.value = undefined$1;
558
- next.done = true;
559
- return next;
560
- };
561
- return next.next = next;
562
- }
563
- }
564
-
565
- // Return an iterator with no values.
566
- return {
567
- next: doneResult
568
- };
569
- }
570
- exports.values = values;
571
- function doneResult() {
572
- return {
573
- value: undefined$1,
574
- done: true
575
- };
576
- }
577
- Context.prototype = {
578
- constructor: Context,
579
- reset: function reset(skipTempReset) {
580
- this.prev = 0;
581
- this.next = 0;
582
- // Resetting context._sent for legacy support of Babel's
583
- // function.sent implementation.
584
- this.sent = this._sent = undefined$1;
585
- this.done = false;
586
- this.delegate = null;
587
- this.method = "next";
588
- this.arg = undefined$1;
589
- this.tryEntries.forEach(resetTryEntry);
590
- if (!skipTempReset) {
591
- for (var name in this) {
592
- // Not sure about the optimal order of these conditions:
593
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
594
- this[name] = undefined$1;
595
- }
596
- }
597
- }
598
- },
599
- stop: function stop() {
600
- this.done = true;
601
- var rootEntry = this.tryEntries[0];
602
- var rootRecord = rootEntry.completion;
603
- if (rootRecord.type === "throw") {
604
- throw rootRecord.arg;
605
- }
606
- return this.rval;
607
- },
608
- dispatchException: function dispatchException(exception) {
609
- if (this.done) {
610
- throw exception;
611
- }
612
- var context = this;
613
- function handle(loc, caught) {
614
- record.type = "throw";
615
- record.arg = exception;
616
- context.next = loc;
617
- if (caught) {
618
- // If the dispatched exception was caught by a catch block,
619
- // then let that catch block handle the exception normally.
620
- context.method = "next";
621
- context.arg = undefined$1;
622
- }
623
- return !!caught;
624
- }
625
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
626
- var entry = this.tryEntries[i];
627
- var record = entry.completion;
628
- if (entry.tryLoc === "root") {
629
- // Exception thrown outside of any try block that could handle
630
- // it, so set the completion value of the entire function to
631
- // throw the exception.
632
- return handle("end");
633
- }
634
- if (entry.tryLoc <= this.prev) {
635
- var hasCatch = hasOwn.call(entry, "catchLoc");
636
- var hasFinally = hasOwn.call(entry, "finallyLoc");
637
- if (hasCatch && hasFinally) {
638
- if (this.prev < entry.catchLoc) {
639
- return handle(entry.catchLoc, true);
640
- } else if (this.prev < entry.finallyLoc) {
641
- return handle(entry.finallyLoc);
642
- }
643
- } else if (hasCatch) {
644
- if (this.prev < entry.catchLoc) {
645
- return handle(entry.catchLoc, true);
646
- }
647
- } else if (hasFinally) {
648
- if (this.prev < entry.finallyLoc) {
649
- return handle(entry.finallyLoc);
650
- }
651
- } else {
652
- throw new Error("try statement without catch or finally");
653
- }
654
- }
655
- }
656
- },
657
- abrupt: function abrupt(type, arg) {
658
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
659
- var entry = this.tryEntries[i];
660
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
661
- var finallyEntry = entry;
662
- break;
663
- }
664
- }
665
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
666
- // Ignore the finally entry if control is not jumping to a
667
- // location outside the try/catch block.
668
- finallyEntry = null;
669
- }
670
- var record = finallyEntry ? finallyEntry.completion : {};
671
- record.type = type;
672
- record.arg = arg;
673
- if (finallyEntry) {
674
- this.method = "next";
675
- this.next = finallyEntry.finallyLoc;
676
- return ContinueSentinel;
677
- }
678
- return this.complete(record);
679
- },
680
- complete: function complete(record, afterLoc) {
681
- if (record.type === "throw") {
682
- throw record.arg;
683
- }
684
- if (record.type === "break" || record.type === "continue") {
685
- this.next = record.arg;
686
- } else if (record.type === "return") {
687
- this.rval = this.arg = record.arg;
688
- this.method = "return";
689
- this.next = "end";
690
- } else if (record.type === "normal" && afterLoc) {
691
- this.next = afterLoc;
692
- }
693
- return ContinueSentinel;
694
- },
695
- finish: function finish(finallyLoc) {
696
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
697
- var entry = this.tryEntries[i];
698
- if (entry.finallyLoc === finallyLoc) {
699
- this.complete(entry.completion, entry.afterLoc);
700
- resetTryEntry(entry);
701
- return ContinueSentinel;
702
- }
703
- }
704
- },
705
- "catch": function _catch(tryLoc) {
706
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
707
- var entry = this.tryEntries[i];
708
- if (entry.tryLoc === tryLoc) {
709
- var record = entry.completion;
710
- if (record.type === "throw") {
711
- var thrown = record.arg;
712
- resetTryEntry(entry);
713
- }
714
- return thrown;
715
- }
716
- }
717
-
718
- // The context.catch method must only be called with a location
719
- // argument that corresponds to a known catch block.
720
- throw new Error("illegal catch attempt");
721
- },
722
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
723
- this.delegate = {
724
- iterator: values(iterable),
725
- resultName: resultName,
726
- nextLoc: nextLoc
727
- };
728
- if (this.method === "next") {
729
- // Deliberately forget the last sent value so that we don't
730
- // accidentally pass it on to the delegate.
731
- this.arg = undefined$1;
732
- }
733
- return ContinueSentinel;
734
- }
735
- };
736
-
737
- // Regardless of whether this script is executing as a CommonJS module
738
- // or not, return the runtime object so that we can declare the variable
739
- // regeneratorRuntime in the outer scope, which allows this module to be
740
- // injected easily by `bin/regenerator --include-runtime script.js`.
741
- return exports;
742
- }(
743
- // If this script is executing as a CommonJS module, use module.exports
744
- // as the regeneratorRuntime namespace. Otherwise create a new empty
745
- // object. Either way, the resulting object will be used to initialize
746
- // the regeneratorRuntime variable at the top of this file.
747
- module.exports );
748
- try {
749
- regeneratorRuntime = runtime;
750
- } catch (accidentalStrictMode) {
751
- // This module should not be running in strict mode, so the above
752
- // assignment should always work unless something is misconfigured. Just
753
- // in case runtime.js accidentally runs in strict mode, in modern engines
754
- // we can explicitly access globalThis. In older engines we can escape
755
- // strict mode using a global Function call. This could conceivably fail
756
- // if a Content Security Policy forbids using Function, but in that case
757
- // the proper solution is to fix the accidental strict mode problem. If
758
- // you've misconfigured your bundler to force strict mode and applied a
759
- // CSP to forbid Function, and you're not willing to fix either of those
760
- // problems, please detail your unique predicament in a GitHub issue.
761
- if (typeof globalThis === "object") {
762
- globalThis.regeneratorRuntime = runtime;
763
- } else {
764
- Function("r", "regeneratorRuntime = r")(runtime);
765
- }
766
- }
767
- });
768
-
769
413
  var _excluded = ["file"];
770
414
  var normalizeProductOption = function normalizeProductOption(_ref2) {
771
415
  var id = _ref2.id,
@@ -984,36 +628,32 @@ function normalizeCategory(_ref7) {
984
628
  };
985
629
  }
986
630
 
987
- var handleFetchResponse = /*#__PURE__*/function () {
988
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(res) {
989
- return runtime_1.wrap(function _callee$(_context) {
990
- while (1) {
991
- switch (_context.prev = _context.next) {
992
- case 0:
993
- if (!res) {
994
- _context.next = 4;
995
- break;
996
- }
997
- if (!res.error) {
998
- _context.next = 3;
999
- break;
1000
- }
1001
- throw new commerce.CommerceError(res.error);
1002
- case 3:
1003
- return _context.abrupt("return", res);
1004
- case 4:
1005
- return _context.abrupt("return", null);
1006
- case 5:
1007
- case "end":
1008
- return _context.stop();
1009
- }
631
+ var _ref;
632
+ var handleFetchResponse = function handleFetchResponse(_x) {
633
+ return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
634
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
635
+ while (1) switch (_context.prev = _context.next) {
636
+ case 0:
637
+ if (!res) {
638
+ _context.next = 4;
639
+ break;
640
+ }
641
+ if (!res.error) {
642
+ _context.next = 3;
643
+ break;
644
+ }
645
+ throw new commerce.CommerceError(res.error);
646
+ case 3:
647
+ return _context.abrupt("return", res);
648
+ case 4:
649
+ return _context.abrupt("return", null);
650
+ case 5:
651
+ case "end":
652
+ return _context.stop();
1010
653
  }
1011
654
  }, _callee);
1012
- }));
1013
- return function handleFetchResponse(_x) {
1014
- return _ref.apply(this, arguments);
1015
- };
1016
- }();
655
+ }))).apply(this, arguments);
656
+ };
1017
657
 
1018
658
  /*
1019
659
  Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
@@ -1036,52 +676,48 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
1036
676
  return normalizeCart(checkoutPayload);
1037
677
  };
1038
678
 
1039
- var checkoutCreate = /*#__PURE__*/function () {
1040
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(fetch) {
679
+ var _ref$1;
680
+ var checkoutCreate = function checkoutCreate(_x) {
681
+ return (_ref$1 = _ref$1 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetch) {
1041
682
  var cart, checkoutUrl, options;
1042
- return runtime_1.wrap(function _callee$(_context) {
1043
- while (1) {
1044
- switch (_context.prev = _context.next) {
1045
- case 0:
1046
- _context.next = 2;
1047
- return fetch({
1048
- query: 'cart',
1049
- method: 'get'
1050
- });
1051
- case 2:
1052
- cart = _context.sent;
1053
- if (cart) {
1054
- _context.next = 6;
1055
- break;
1056
- }
683
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
684
+ while (1) switch (_context.prev = _context.next) {
685
+ case 0:
686
+ _context.next = 2;
687
+ return fetch({
688
+ query: 'cart',
689
+ method: 'get'
690
+ });
691
+ case 2:
692
+ cart = _context.sent;
693
+ if (cart) {
1057
694
  _context.next = 6;
1058
- return fetch({
1059
- query: 'cart',
1060
- method: 'setItems',
1061
- variables: [[]]
1062
- });
1063
- case 6:
1064
- checkoutUrl = cart == null ? void 0 : cart.checkout_url;
1065
- options = {
1066
- expires: SWELL_COOKIE_EXPIRE,
1067
- sameSite: "none",
1068
- secure: true
1069
- };
1070
- if (checkoutUrl) {
1071
- Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options);
1072
- }
1073
- return _context.abrupt("return", cart);
1074
- case 10:
1075
- case "end":
1076
- return _context.stop();
1077
- }
695
+ break;
696
+ }
697
+ _context.next = 6;
698
+ return fetch({
699
+ query: 'cart',
700
+ method: 'setItems',
701
+ variables: [[]]
702
+ });
703
+ case 6:
704
+ checkoutUrl = cart == null ? void 0 : cart.checkout_url;
705
+ options = {
706
+ expires: SWELL_COOKIE_EXPIRE,
707
+ sameSite: "none",
708
+ secure: true
709
+ };
710
+ if (checkoutUrl) {
711
+ Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl, options);
712
+ }
713
+ return _context.abrupt("return", cart);
714
+ case 10:
715
+ case "end":
716
+ return _context.stop();
1078
717
  }
1079
718
  }, _callee);
1080
- }));
1081
- return function checkoutCreate(_x) {
1082
- return _ref.apply(this, arguments);
1083
- };
1084
- }();
719
+ }))).apply(this, arguments);
720
+ };
1085
721
 
1086
722
  var handler = {
1087
723
  fetchOptions: {
@@ -1089,22 +725,20 @@ var handler = {
1089
725
  method: 'get'
1090
726
  },
1091
727
  fetcher: function fetcher(_ref) {
1092
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
728
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1093
729
  var fetch, cart;
1094
- return runtime_1.wrap(function _callee$(_context) {
1095
- while (1) {
1096
- switch (_context.prev = _context.next) {
1097
- case 0:
1098
- fetch = _ref.fetch;
1099
- _context.next = 3;
1100
- return checkoutCreate(fetch);
1101
- case 3:
1102
- cart = _context.sent;
1103
- return _context.abrupt("return", cart ? normalizeCart(cart) : null);
1104
- case 5:
1105
- case "end":
1106
- return _context.stop();
1107
- }
730
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
731
+ while (1) switch (_context.prev = _context.next) {
732
+ case 0:
733
+ fetch = _ref.fetch;
734
+ _context.next = 3;
735
+ return checkoutCreate(fetch);
736
+ case 3:
737
+ cart = _context.sent;
738
+ return _context.abrupt("return", cart ? normalizeCart(cart) : null);
739
+ case 5:
740
+ case "end":
741
+ return _context.stop();
1108
742
  }
1109
743
  }, _callee);
1110
744
  }))();
@@ -1138,40 +772,38 @@ var handler$1 = {
1138
772
  method: 'addItem'
1139
773
  },
1140
774
  fetcher: function fetcher(_ref) {
1141
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
775
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1142
776
  var item, options, fetch, variables, response;
1143
- return runtime_1.wrap(function _callee$(_context) {
1144
- while (1) {
1145
- switch (_context.prev = _context.next) {
1146
- case 0:
1147
- item = _ref.input, options = _ref.options, fetch = _ref.fetch;
1148
- if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
1149
- _context.next = 3;
1150
- break;
1151
- }
1152
- throw new commerce.CommerceError({
1153
- message: 'The item quantity has to be a valid integer greater than 0'
1154
- });
1155
- case 3:
1156
- variables = {
1157
- checkoutId: getCheckoutId(),
1158
- product_id: item.productId,
1159
- quantity: item.quantity
1160
- };
1161
- if (item.productId !== item.variantId) {
1162
- variables.variant_id = item.variantId;
1163
- }
1164
- _context.next = 7;
1165
- return fetch(_extends({}, options, {
1166
- variables: variables
1167
- }));
1168
- case 7:
1169
- response = _context.sent;
1170
- return _context.abrupt("return", checkoutToCart(response));
1171
- case 9:
1172
- case "end":
1173
- return _context.stop();
1174
- }
777
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
778
+ while (1) switch (_context.prev = _context.next) {
779
+ case 0:
780
+ item = _ref.input, options = _ref.options, fetch = _ref.fetch;
781
+ if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
782
+ _context.next = 3;
783
+ break;
784
+ }
785
+ throw new commerce.CommerceError({
786
+ message: 'The item quantity has to be a valid integer greater than 0'
787
+ });
788
+ case 3:
789
+ variables = {
790
+ checkoutId: getCheckoutId(),
791
+ product_id: item.productId,
792
+ quantity: item.quantity
793
+ };
794
+ if (item.productId !== item.variantId) {
795
+ variables.variant_id = item.variantId;
796
+ }
797
+ _context.next = 7;
798
+ return fetch(_extends({}, options, {
799
+ variables: variables
800
+ }));
801
+ case 7:
802
+ response = _context.sent;
803
+ return _context.abrupt("return", checkoutToCart(response));
804
+ case 9:
805
+ case "end":
806
+ return _context.stop();
1175
807
  }
1176
808
  }, _callee);
1177
809
  }))();
@@ -1179,37 +811,32 @@ var handler$1 = {
1179
811
  useHook: function useHook(_ref2) {
1180
812
  var fetch = _ref2.fetch;
1181
813
  return function () {
814
+ var _addItem;
1182
815
  var _useCart = commerce.useCart(),
1183
816
  mutate = _useCart.mutate;
1184
- return React.useCallback( /*#__PURE__*/function () {
1185
- var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
817
+ return React.useCallback(function addItem(_x) {
818
+ return (_addItem = _addItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
1186
819
  var data;
1187
- return runtime_1.wrap(function _callee2$(_context2) {
1188
- while (1) {
1189
- switch (_context2.prev = _context2.next) {
1190
- case 0:
1191
- _context2.next = 2;
1192
- return fetch({
1193
- input: input
1194
- });
1195
- case 2:
1196
- data = _context2.sent;
1197
- _context2.next = 5;
1198
- return mutate(data, false);
1199
- case 5:
1200
- return _context2.abrupt("return", data);
1201
- case 6:
1202
- case "end":
1203
- return _context2.stop();
1204
- }
820
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
821
+ while (1) switch (_context2.prev = _context2.next) {
822
+ case 0:
823
+ _context2.next = 2;
824
+ return fetch({
825
+ input: input
826
+ });
827
+ case 2:
828
+ data = _context2.sent;
829
+ _context2.next = 5;
830
+ return mutate(data, false);
831
+ case 5:
832
+ return _context2.abrupt("return", data);
833
+ case 6:
834
+ case "end":
835
+ return _context2.stop();
1205
836
  }
1206
837
  }, _callee2);
1207
- }));
1208
- function addItem(_x) {
1209
- return _addItem.apply(this, arguments);
1210
- }
1211
- return addItem;
1212
- }(), [fetch, mutate]);
838
+ }))).apply(this, arguments);
839
+ }, [fetch, mutate]);
1213
840
  };
1214
841
  }
1215
842
  };
@@ -1220,24 +847,22 @@ var handler$2 = {
1220
847
  method: "removeItem"
1221
848
  },
1222
849
  fetcher: function fetcher(_ref) {
1223
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
850
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1224
851
  var itemId, options, fetch, response;
1225
- return runtime_1.wrap(function _callee$(_context) {
1226
- while (1) {
1227
- switch (_context.prev = _context.next) {
1228
- case 0:
1229
- itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
1230
- _context.next = 3;
1231
- return fetch(_extends({}, options, {
1232
- variables: [itemId]
1233
- }));
1234
- case 3:
1235
- response = _context.sent;
1236
- return _context.abrupt("return", checkoutToCart(response));
1237
- case 5:
1238
- case "end":
1239
- return _context.stop();
1240
- }
852
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
853
+ while (1) switch (_context.prev = _context.next) {
854
+ case 0:
855
+ itemId = _ref.input.itemId, options = _ref.options, fetch = _ref.fetch;
856
+ _context.next = 3;
857
+ return fetch(_extends({}, options, {
858
+ variables: [itemId]
859
+ }));
860
+ case 3:
861
+ response = _context.sent;
862
+ return _context.abrupt("return", checkoutToCart(response));
863
+ case 5:
864
+ case "end":
865
+ return _context.stop();
1241
866
  }
1242
867
  }, _callee);
1243
868
  }))();
@@ -1245,39 +870,34 @@ var handler$2 = {
1245
870
  useHook: function useHook(_ref2) {
1246
871
  var fetch = _ref2.fetch;
1247
872
  return function () {
873
+ var _removeItem;
1248
874
  var _useCart = commerce.useCart(),
1249
875
  mutate = _useCart.mutate;
1250
- return React.useCallback( /*#__PURE__*/function () {
1251
- var _removeItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
876
+ return React.useCallback(function removeItem(_x) {
877
+ return (_removeItem = _removeItem || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
1252
878
  var data;
1253
- return runtime_1.wrap(function _callee2$(_context2) {
1254
- while (1) {
1255
- switch (_context2.prev = _context2.next) {
1256
- case 0:
1257
- _context2.next = 2;
1258
- return fetch({
1259
- input: {
1260
- itemId: input.id
1261
- }
1262
- });
1263
- case 2:
1264
- data = _context2.sent;
1265
- _context2.next = 5;
1266
- return mutate(data, false);
1267
- case 5:
1268
- return _context2.abrupt("return", data);
1269
- case 6:
1270
- case "end":
1271
- return _context2.stop();
1272
- }
879
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
880
+ while (1) switch (_context2.prev = _context2.next) {
881
+ case 0:
882
+ _context2.next = 2;
883
+ return fetch({
884
+ input: {
885
+ itemId: input.id
886
+ }
887
+ });
888
+ case 2:
889
+ data = _context2.sent;
890
+ _context2.next = 5;
891
+ return mutate(data, false);
892
+ case 5:
893
+ return _context2.abrupt("return", data);
894
+ case 6:
895
+ case "end":
896
+ return _context2.stop();
1273
897
  }
1274
898
  }, _callee2);
1275
- }));
1276
- function removeItem(_x) {
1277
- return _removeItem.apply(this, arguments);
1278
- }
1279
- return removeItem;
1280
- }(), [fetch, mutate]);
899
+ }))).apply(this, arguments);
900
+ }, [fetch, mutate]);
1281
901
  };
1282
902
  }
1283
903
  };
@@ -1288,53 +908,51 @@ var handler$3 = {
1288
908
  method: "updateItem"
1289
909
  },
1290
910
  fetcher: function fetcher(_ref) {
1291
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
911
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1292
912
  var _ref$input, itemId, item, options, fetch, response;
1293
- return runtime_1.wrap(function _callee$(_context) {
1294
- while (1) {
1295
- switch (_context.prev = _context.next) {
1296
- case 0:
1297
- _ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
1298
- if (!Number.isInteger(item.quantity)) {
1299
- _context.next = 6;
1300
- break;
1301
- }
1302
- if (!(item.quantity < 1)) {
1303
- _context.next = 4;
1304
- break;
1305
- }
1306
- return _context.abrupt("return", handler$2.fetcher({
1307
- options: handler$2.fetchOptions,
1308
- input: {
1309
- itemId: itemId
1310
- },
1311
- fetch: fetch
1312
- }));
1313
- case 4:
913
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
914
+ while (1) switch (_context.prev = _context.next) {
915
+ case 0:
916
+ _ref$input = _ref.input, itemId = _ref$input.itemId, item = _ref$input.item, options = _ref.options, fetch = _ref.fetch;
917
+ if (!Number.isInteger(item.quantity)) {
918
+ _context.next = 6;
919
+ break;
920
+ }
921
+ if (!(item.quantity < 1)) {
922
+ _context.next = 4;
923
+ break;
924
+ }
925
+ return _context.abrupt("return", handler$2.fetcher({
926
+ options: handler$2.fetchOptions,
927
+ input: {
928
+ itemId: itemId
929
+ },
930
+ fetch: fetch
931
+ }));
932
+ case 4:
933
+ _context.next = 8;
934
+ break;
935
+ case 6:
936
+ if (!item.quantity) {
1314
937
  _context.next = 8;
1315
938
  break;
1316
- case 6:
1317
- if (!item.quantity) {
1318
- _context.next = 8;
1319
- break;
1320
- }
1321
- throw new commerce.ValidationError({
1322
- message: "The item quantity has to be a valid integer"
1323
- });
1324
- case 8:
1325
- _context.next = 10;
1326
- return fetch(_extends({}, options, {
1327
- variables: [itemId, {
1328
- quantity: item.quantity
1329
- }]
1330
- }));
1331
- case 10:
1332
- response = _context.sent;
1333
- return _context.abrupt("return", checkoutToCart(response));
1334
- case 12:
1335
- case "end":
1336
- return _context.stop();
1337
- }
939
+ }
940
+ throw new commerce.ValidationError({
941
+ message: "The item quantity has to be a valid integer"
942
+ });
943
+ case 8:
944
+ _context.next = 10;
945
+ return fetch(_extends({}, options, {
946
+ variables: [itemId, {
947
+ quantity: item.quantity
948
+ }]
949
+ }));
950
+ case 10:
951
+ response = _context.sent;
952
+ return _context.abrupt("return", checkoutToCart(response));
953
+ case 12:
954
+ case "end":
955
+ return _context.stop();
1338
956
  }
1339
957
  }, _callee);
1340
958
  }))();
@@ -1342,7 +960,7 @@ var handler$3 = {
1342
960
  useHook: function useHook(_ref2) {
1343
961
  var fetch = _ref2.fetch;
1344
962
  return function (ctx) {
1345
- var _ctx$wait;
963
+ var _ref3, _ctx$wait;
1346
964
  if (ctx === void 0) {
1347
965
  ctx = {};
1348
966
  }
@@ -1350,49 +968,44 @@ var handler$3 = {
1350
968
  item = _ctx.item;
1351
969
  var _useCart = commerce.useCart(),
1352
970
  mutate = _useCart.mutate;
1353
- return React.useCallback(debounce( /*#__PURE__*/function () {
1354
- var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
971
+ return React.useCallback(debounce(function (_x) {
972
+ return (_ref3 = _ref3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
1355
973
  var _input$id;
1356
974
  var itemId, data;
1357
- return runtime_1.wrap(function _callee2$(_context2) {
1358
- while (1) {
1359
- switch (_context2.prev = _context2.next) {
1360
- case 0:
1361
- itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
1362
- if (itemId) {
1363
- _context2.next = 3;
1364
- break;
975
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
976
+ while (1) switch (_context2.prev = _context2.next) {
977
+ case 0:
978
+ itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
979
+ if (itemId) {
980
+ _context2.next = 3;
981
+ break;
982
+ }
983
+ throw new commerce.ValidationError({
984
+ message: "Invalid input used for this operation"
985
+ });
986
+ case 3:
987
+ _context2.next = 5;
988
+ return fetch({
989
+ input: {
990
+ item: {
991
+ quantity: input.quantity
992
+ },
993
+ itemId: itemId
1365
994
  }
1366
- throw new commerce.ValidationError({
1367
- message: "Invalid input used for this operation"
1368
- });
1369
- case 3:
1370
- _context2.next = 5;
1371
- return fetch({
1372
- input: {
1373
- item: {
1374
- quantity: input.quantity
1375
- },
1376
- itemId: itemId
1377
- }
1378
- });
1379
- case 5:
1380
- data = _context2.sent;
1381
- _context2.next = 8;
1382
- return mutate(data, false);
1383
- case 8:
1384
- return _context2.abrupt("return", data);
1385
- case 9:
1386
- case "end":
1387
- return _context2.stop();
1388
- }
995
+ });
996
+ case 5:
997
+ data = _context2.sent;
998
+ _context2.next = 8;
999
+ return mutate(data, false);
1000
+ case 8:
1001
+ return _context2.abrupt("return", data);
1002
+ case 9:
1003
+ case "end":
1004
+ return _context2.stop();
1389
1005
  }
1390
1006
  }, _callee2);
1391
- }));
1392
- return function (_x) {
1393
- return _ref3.apply(this, arguments);
1394
- };
1395
- }(), (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
1007
+ }))).apply(this, arguments);
1008
+ }, (_ctx$wait = ctx.wait) != null ? _ctx$wait : 500), [fetch, mutate]);
1396
1009
  };
1397
1010
  }
1398
1011
  };
@@ -1447,50 +1060,48 @@ var handler$4 = {
1447
1060
  method: "list"
1448
1061
  },
1449
1062
  fetcher: function fetcher(_ref) {
1450
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1063
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1451
1064
  var input, options, fetch, sortMap, categoryId, includeSubCategories, categories, brandId, search, _input$sort, sort, count, mappedSort, includedCategories, _yield$fetch, products;
1452
- return runtime_1.wrap(function _callee$(_context) {
1453
- while (1) {
1454
- switch (_context.prev = _context.next) {
1455
- case 0:
1456
- input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1457
- sortMap = new Map([["latest-desc", ""], ["price-asc", "price asc"], ["price-desc", "price desc"], ["trending-desc", "popularity"]]);
1458
- categoryId = input.categoryId, includeSubCategories = input.includeSubCategories, categories = input.categories, brandId = input.brandId, search = input.search, _input$sort = input.sort, sort = _input$sort === void 0 ? "latest-desc" : _input$sort, count = input.count;
1459
- mappedSort = sortMap.get(sort);
1460
- includedCategories = includeSubCategories ? walkCategoryTree(categories == null ? void 0 : categories.find(function (category) {
1461
- return category.id === categoryId;
1462
- }), categories) : undefined;
1463
- _context.next = 7;
1464
- return fetch({
1465
- query: options.query,
1466
- method: options.method,
1467
- variables: ensureNoNilFields({
1468
- category: !includeSubCategories ? categoryId : undefined,
1469
- brand: brandId,
1470
- search: search,
1471
- sort: mappedSort,
1472
- expand: ["variants"],
1473
- limit: count,
1474
- $filters: _extends({}, includeSubCategories ? {
1475
- category: includedCategories == null ? void 0 : includedCategories.map(function (c) {
1476
- return c.id;
1477
- })
1478
- } : {})
1479
- })
1480
- });
1481
- case 7:
1482
- _yield$fetch = _context.sent;
1483
- products = _yield$fetch.results;
1484
- return _context.abrupt("return", {
1485
- products: products.map(function (product) {
1486
- return normalizeProduct(product);
1487
- }),
1488
- found: products.length > 0
1489
- });
1490
- case 10:
1491
- case "end":
1492
- return _context.stop();
1493
- }
1065
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1066
+ while (1) switch (_context.prev = _context.next) {
1067
+ case 0:
1068
+ input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1069
+ sortMap = new Map([["latest-desc", ""], ["price-asc", "price asc"], ["price-desc", "price desc"], ["trending-desc", "popularity"]]);
1070
+ categoryId = input.categoryId, includeSubCategories = input.includeSubCategories, categories = input.categories, brandId = input.brandId, search = input.search, _input$sort = input.sort, sort = _input$sort === void 0 ? "latest-desc" : _input$sort, count = input.count;
1071
+ mappedSort = sortMap.get(sort);
1072
+ includedCategories = includeSubCategories ? walkCategoryTree(categories == null ? void 0 : categories.find(function (category) {
1073
+ return category.id === categoryId;
1074
+ }), categories) : undefined;
1075
+ _context.next = 7;
1076
+ return fetch({
1077
+ query: options.query,
1078
+ method: options.method,
1079
+ variables: ensureNoNilFields({
1080
+ category: !includeSubCategories ? categoryId : undefined,
1081
+ brand: brandId,
1082
+ search: search,
1083
+ sort: mappedSort,
1084
+ expand: ["variants"],
1085
+ limit: count,
1086
+ $filters: _extends({}, includeSubCategories ? {
1087
+ category: includedCategories == null ? void 0 : includedCategories.map(function (c) {
1088
+ return c.id;
1089
+ })
1090
+ } : {})
1091
+ })
1092
+ });
1093
+ case 7:
1094
+ _yield$fetch = _context.sent;
1095
+ products = _yield$fetch.results;
1096
+ return _context.abrupt("return", {
1097
+ products: products.map(function (product) {
1098
+ return normalizeProduct(product);
1099
+ }),
1100
+ found: products.length > 0
1101
+ });
1102
+ case 10:
1103
+ case "end":
1104
+ return _context.stop();
1494
1105
  }
1495
1106
  }, _callee);
1496
1107
  }))();
@@ -1517,33 +1128,31 @@ var handler$5 = {
1517
1128
  method: 'get'
1518
1129
  },
1519
1130
  fetcher: function fetcher(_ref) {
1520
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1131
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1521
1132
  var input, options, fetch, id, product;
1522
- return runtime_1.wrap(function _callee$(_context) {
1523
- while (1) {
1524
- switch (_context.prev = _context.next) {
1525
- case 0:
1526
- input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1527
- id = input.id;
1528
- _context.next = 4;
1529
- return fetch({
1530
- query: options.query,
1531
- method: options.method,
1532
- variables: [id]
1533
- });
1534
- case 4:
1535
- product = _context.sent;
1536
- if (product) {
1537
- _context.next = 7;
1538
- break;
1539
- }
1540
- return _context.abrupt("return", null);
1541
- case 7:
1542
- return _context.abrupt("return", normalizeProduct(product));
1543
- case 8:
1544
- case "end":
1545
- return _context.stop();
1546
- }
1133
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1134
+ while (1) switch (_context.prev = _context.next) {
1135
+ case 0:
1136
+ input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1137
+ id = input.id;
1138
+ _context.next = 4;
1139
+ return fetch({
1140
+ query: options.query,
1141
+ method: options.method,
1142
+ variables: [id]
1143
+ });
1144
+ case 4:
1145
+ product = _context.sent;
1146
+ if (product) {
1147
+ _context.next = 7;
1148
+ break;
1149
+ }
1150
+ return _context.abrupt("return", null);
1151
+ case 7:
1152
+ return _context.abrupt("return", normalizeProduct(product));
1153
+ case 8:
1154
+ case "end":
1155
+ return _context.stop();
1547
1156
  }
1548
1157
  }, _callee);
1549
1158
  }))();
@@ -1570,86 +1179,96 @@ var handler$6 = {
1570
1179
  method: "get"
1571
1180
  },
1572
1181
  fetcher: function fetcher(_ref) {
1573
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1182
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1574
1183
  var _data$results;
1575
- var input, options, fetch, addIsEmptyField, categoryId, data, categories, normalizedCategories, _loop, _iterator, _step;
1576
- return runtime_1.wrap(function _callee2$(_context2) {
1577
- while (1) {
1578
- switch (_context2.prev = _context2.next) {
1579
- case 0:
1580
- input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1581
- addIsEmptyField = input.addIsEmptyField, categoryId = input.categoryId;
1582
- _context2.next = 4;
1583
- return fetch({
1584
- query: options.query,
1585
- method: options.method,
1586
- variables: ensureNoNilFields({
1587
- expand: ["children", "parent_id"],
1588
- id: categoryId
1589
- })
1590
- });
1591
- case 4:
1592
- data = _context2.sent;
1593
- categories = (_data$results = data == null ? void 0 : data.results) != null ? _data$results : [];
1594
- if (!addIsEmptyField) {
1595
- _context2.next = 10;
1596
- break;
1597
- }
1598
- _context2.next = 9;
1599
- return Promise.all(categories.map( /*#__PURE__*/function () {
1600
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(category) {
1601
- return runtime_1.wrap(function _callee$(_context) {
1602
- while (1) {
1603
- switch (_context.prev = _context.next) {
1604
- case 0:
1605
- _context.t0 = _extends;
1606
- _context.t1 = {};
1607
- _context.t2 = category;
1608
- _context.next = 5;
1609
- return fetch({
1610
- query: "products",
1611
- method: "list",
1612
- variables: ensureNoNilFields({
1613
- limit: 1,
1614
- category: category.id
1615
- })
1616
- });
1617
- case 5:
1618
- _context.t3 = _context.sent.results;
1619
- _context.t4 = {
1620
- products: _context.t3
1621
- };
1622
- return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
1623
- case 8:
1624
- case "end":
1625
- return _context.stop();
1626
- }
1627
- }
1628
- }, _callee);
1629
- }));
1630
- return function (_x) {
1631
- return _ref2.apply(this, arguments);
1632
- };
1633
- }()));
1634
- case 9:
1635
- categories = _context2.sent;
1636
- case 10:
1637
- normalizedCategories = !categoryId ? topologicalSortForCategoryTree(categories.map(normalizeCategory)) : categories.map(normalizeCategory);
1638
- _loop = function _loop() {
1639
- var _normalizedCategories, _normalizedCategories2;
1640
- var category = _step.value;
1641
- category.depth = ((_normalizedCategories = (_normalizedCategories2 = normalizedCategories.find(function (c) {
1642
- return c.id === category.parentId;
1643
- })) == null ? void 0 : _normalizedCategories2.depth) != null ? _normalizedCategories : -1) + 1;
1644
- };
1645
- for (_iterator = _createForOfIteratorHelperLoose(normalizedCategories); !(_step = _iterator()).done;) {
1646
- _loop();
1647
- }
1648
- return _context2.abrupt("return", normalizedCategories);
1649
- case 14:
1650
- case "end":
1651
- return _context2.stop();
1652
- }
1184
+ var input, options, fetch, addIsEmptyField, categoryId, data, categories, _ref2, normalizedCategories, _loop, _iterator, _step;
1185
+ return _regeneratorRuntime().wrap(function _callee2$(_context3) {
1186
+ while (1) switch (_context3.prev = _context3.next) {
1187
+ case 0:
1188
+ input = _ref.input, options = _ref.options, fetch = _ref.fetch;
1189
+ addIsEmptyField = input.addIsEmptyField, categoryId = input.categoryId;
1190
+ _context3.next = 4;
1191
+ return fetch({
1192
+ query: options.query,
1193
+ method: options.method,
1194
+ variables: ensureNoNilFields({
1195
+ expand: ["children", "parent_id"],
1196
+ id: categoryId
1197
+ })
1198
+ });
1199
+ case 4:
1200
+ data = _context3.sent;
1201
+ categories = (_data$results = data == null ? void 0 : data.results) != null ? _data$results : [];
1202
+ if (!addIsEmptyField) {
1203
+ _context3.next = 10;
1204
+ break;
1205
+ }
1206
+ _context3.next = 9;
1207
+ return Promise.all(categories.map(function (_x) {
1208
+ return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(category) {
1209
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1210
+ while (1) switch (_context.prev = _context.next) {
1211
+ case 0:
1212
+ _context.t0 = _extends;
1213
+ _context.t1 = {};
1214
+ _context.t2 = category;
1215
+ _context.next = 5;
1216
+ return fetch({
1217
+ query: "products",
1218
+ method: "list",
1219
+ variables: ensureNoNilFields({
1220
+ limit: 1,
1221
+ category: category.id
1222
+ })
1223
+ });
1224
+ case 5:
1225
+ _context.t3 = _context.sent.results;
1226
+ _context.t4 = {
1227
+ products: _context.t3
1228
+ };
1229
+ return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
1230
+ case 8:
1231
+ case "end":
1232
+ return _context.stop();
1233
+ }
1234
+ }, _callee);
1235
+ }))).apply(this, arguments);
1236
+ }));
1237
+ case 9:
1238
+ categories = _context3.sent;
1239
+ case 10:
1240
+ normalizedCategories = !categoryId ? topologicalSortForCategoryTree(categories.map(normalizeCategory)) : categories.map(normalizeCategory);
1241
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
1242
+ var _normalizedCategories, _normalizedCategories2;
1243
+ var category;
1244
+ return _regeneratorRuntime().wrap(function _loop$(_context2) {
1245
+ while (1) switch (_context2.prev = _context2.next) {
1246
+ case 0:
1247
+ category = _step.value;
1248
+ category.depth = ((_normalizedCategories = (_normalizedCategories2 = normalizedCategories.find(function (c) {
1249
+ return c.id === category.parentId;
1250
+ })) == null ? void 0 : _normalizedCategories2.depth) != null ? _normalizedCategories : -1) + 1;
1251
+ case 2:
1252
+ case "end":
1253
+ return _context2.stop();
1254
+ }
1255
+ }, _loop);
1256
+ });
1257
+ _iterator = _createForOfIteratorHelperLoose(normalizedCategories);
1258
+ case 13:
1259
+ if ((_step = _iterator()).done) {
1260
+ _context3.next = 17;
1261
+ break;
1262
+ }
1263
+ return _context3.delegateYield(_loop(), "t0", 15);
1264
+ case 15:
1265
+ _context3.next = 13;
1266
+ break;
1267
+ case 17:
1268
+ return _context3.abrupt("return", normalizedCategories);
1269
+ case 18:
1270
+ case "end":
1271
+ return _context3.stop();
1653
1272
  }
1654
1273
  }, _callee2);
1655
1274
  }))();
@@ -1684,55 +1303,53 @@ var handler$7 = {
1684
1303
  method: "get"
1685
1304
  },
1686
1305
  fetcher: function fetcher(_ref) {
1687
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1306
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1688
1307
  var _yield$fetch$values, _yield$fetch;
1689
1308
  var fetch, vendors;
1690
- return runtime_1.wrap(function _callee$(_context) {
1691
- while (1) {
1692
- switch (_context.prev = _context.next) {
1693
- case 0:
1694
- fetch = _ref.fetch;
1695
- _context.next = 3;
1696
- return fetch({
1697
- query: "attributes",
1698
- method: "get",
1699
- variables: "brand"
1700
- });
1701
- case 3:
1702
- _context.t0 = _yield$fetch = _context.sent;
1703
- if (!(_context.t0 == null)) {
1704
- _context.next = 8;
1705
- break;
1706
- }
1707
- _context.t1 = void 0;
1708
- _context.next = 9;
1309
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1310
+ while (1) switch (_context.prev = _context.next) {
1311
+ case 0:
1312
+ fetch = _ref.fetch;
1313
+ _context.next = 3;
1314
+ return fetch({
1315
+ query: "attributes",
1316
+ method: "get",
1317
+ variables: "brand"
1318
+ });
1319
+ case 3:
1320
+ _context.t0 = _yield$fetch = _context.sent;
1321
+ if (!(_context.t0 == null)) {
1322
+ _context.next = 8;
1709
1323
  break;
1710
- case 8:
1711
- _context.t1 = _yield$fetch.values;
1712
- case 9:
1713
- _context.t2 = _yield$fetch$values = _context.t1;
1714
- if (!(_context.t2 != null)) {
1715
- _context.next = 14;
1716
- break;
1717
- }
1718
- _context.t3 = _yield$fetch$values;
1719
- _context.next = 15;
1324
+ }
1325
+ _context.t1 = void 0;
1326
+ _context.next = 9;
1327
+ break;
1328
+ case 8:
1329
+ _context.t1 = _yield$fetch.values;
1330
+ case 9:
1331
+ _context.t2 = _yield$fetch$values = _context.t1;
1332
+ if (!(_context.t2 != null)) {
1333
+ _context.next = 14;
1720
1334
  break;
1721
- case 14:
1722
- _context.t3 = [];
1723
- case 15:
1724
- vendors = _context.t3;
1725
- return _context.abrupt("return", Array.from(new Set(vendors).values()).map(function (v) {
1726
- return {
1727
- entityId: v,
1728
- name: v,
1729
- path: "brands/" + v
1730
- };
1731
- }));
1732
- case 17:
1733
- case "end":
1734
- return _context.stop();
1735
- }
1335
+ }
1336
+ _context.t3 = _yield$fetch$values;
1337
+ _context.next = 15;
1338
+ break;
1339
+ case 14:
1340
+ _context.t3 = [];
1341
+ case 15:
1342
+ vendors = _context.t3;
1343
+ return _context.abrupt("return", Array.from(new Set(vendors).values()).map(function (v) {
1344
+ return {
1345
+ entityId: v,
1346
+ name: v,
1347
+ path: "brands/" + v
1348
+ };
1349
+ }));
1350
+ case 17:
1351
+ case "end":
1352
+ return _context.stop();
1736
1353
  }
1737
1354
  }, _callee);
1738
1355
  }))();
@@ -1760,73 +1377,64 @@ var handler$7 = {
1760
1377
  }
1761
1378
  };
1762
1379
 
1763
- var fetcher = /*#__PURE__*/function () {
1764
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref) {
1765
- var _ref$method, method, variables, query, callSwell, _callSwell;
1766
- return runtime_1.wrap(function _callee2$(_context2) {
1767
- while (1) {
1768
- switch (_context2.prev = _context2.next) {
1769
- case 0:
1770
- _callSwell = function _callSwell3() {
1771
- _callSwell = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1772
- var arg1, arg2, response, _response;
1773
- return runtime_1.wrap(function _callee$(_context) {
1774
- while (1) {
1775
- switch (_context.prev = _context.next) {
1776
- case 0:
1777
- if (!Array.isArray(variables)) {
1778
- _context.next = 9;
1779
- break;
1780
- }
1781
- arg1 = variables[0];
1782
- arg2 = variables[1];
1783
- _context.next = 5;
1784
- return swell[query][method](arg1, arg2);
1785
- case 5:
1786
- response = _context.sent;
1787
- return _context.abrupt("return", handleFetchResponse(response));
1788
- case 9:
1789
- _context.next = 11;
1790
- return swell[query][method](variables);
1791
- case 11:
1792
- _response = _context.sent;
1793
- return _context.abrupt("return", handleFetchResponse(_response));
1794
- case 13:
1795
- case "end":
1796
- return _context.stop();
1380
+ var _ref2;
1381
+ var fetcher = function fetcher(_x) {
1382
+ return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
1383
+ var _callSwell;
1384
+ var _ref$method, method, variables, query, callSwell;
1385
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1386
+ while (1) switch (_context2.prev = _context2.next) {
1387
+ case 0:
1388
+ callSwell = function _callSwell2() {
1389
+ return (_callSwell = _callSwell || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1390
+ var arg1, arg2, response, _response;
1391
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1392
+ while (1) switch (_context.prev = _context.next) {
1393
+ case 0:
1394
+ if (!Array.isArray(variables)) {
1395
+ _context.next = 9;
1396
+ break;
1797
1397
  }
1798
- }
1799
- }, _callee);
1800
- }));
1801
- return _callSwell.apply(this, arguments);
1802
- };
1803
- callSwell = function _callSwell2() {
1804
- return _callSwell.apply(this, arguments);
1805
- };
1806
- _ref$method = _ref.method, method = _ref$method === void 0 ? 'get' : _ref$method, variables = _ref.variables, query = _ref.query;
1807
- if (!(query && query in swell)) {
1808
- _context2.next = 9;
1809
- break;
1810
- }
1811
- _context2.next = 6;
1812
- return callSwell();
1813
- case 6:
1814
- return _context2.abrupt("return", _context2.sent);
1815
- case 9:
1816
- throw new commerce.CommerceError({
1817
- message: 'Invalid query argument!'
1818
- });
1819
- case 10:
1820
- case "end":
1821
- return _context2.stop();
1822
- }
1398
+ arg1 = variables[0];
1399
+ arg2 = variables[1];
1400
+ _context.next = 5;
1401
+ return swell__default[query][method](arg1, arg2);
1402
+ case 5:
1403
+ response = _context.sent;
1404
+ return _context.abrupt("return", handleFetchResponse(response));
1405
+ case 9:
1406
+ _context.next = 11;
1407
+ return swell__default[query][method](variables);
1408
+ case 11:
1409
+ _response = _context.sent;
1410
+ return _context.abrupt("return", handleFetchResponse(_response));
1411
+ case 13:
1412
+ case "end":
1413
+ return _context.stop();
1414
+ }
1415
+ }, _callee);
1416
+ }))).apply(this, arguments);
1417
+ };
1418
+ _ref$method = _ref.method, method = _ref$method === void 0 ? 'get' : _ref$method, variables = _ref.variables, query = _ref.query;
1419
+ if (!(query && query in swell__default)) {
1420
+ _context2.next = 8;
1421
+ break;
1422
+ }
1423
+ _context2.next = 5;
1424
+ return callSwell();
1425
+ case 5:
1426
+ return _context2.abrupt("return", _context2.sent);
1427
+ case 8:
1428
+ throw new commerce.CommerceError({
1429
+ message: 'Invalid query argument!'
1430
+ });
1431
+ case 9:
1432
+ case "end":
1433
+ return _context2.stop();
1823
1434
  }
1824
1435
  }, _callee2);
1825
- }));
1826
- return function fetcher(_x) {
1827
- return _ref2.apply(this, arguments);
1828
- };
1829
- }();
1436
+ }))).apply(this, arguments);
1437
+ };
1830
1438
 
1831
1439
  /*
1832
1440
  Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
@@ -1835,9 +1443,9 @@ var fetcher = /*#__PURE__*/function () {
1835
1443
  var getSwellProvider = function getSwellProvider(storeId, publicKey) {
1836
1444
  swell.init(storeId, publicKey);
1837
1445
  return {
1838
- locale: 'en-us',
1446
+ locale: "en-us",
1839
1447
  cartCookie: SWELL_CHECKOUT_ID_COOKIE,
1840
- swell: swell,
1448
+ swell: swell__default,
1841
1449
  fetcher: fetcher,
1842
1450
  cart: {
1843
1451
  useCart: handler,