@plasmicpkgs/commerce-saleor 0.0.122 → 0.0.124

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