@plasmicpkgs/commerce-local 0.0.1

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.
@@ -0,0 +1,1506 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
+ var React = require('react');
9
+ var React__default = _interopDefault(React);
10
+ var commerce = require('@plasmicpkgs/commerce');
11
+
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
+ try {
14
+ var info = gen[key](arg);
15
+ var value = info.value;
16
+ } catch (error) {
17
+ reject(error);
18
+ return;
19
+ }
20
+
21
+ if (info.done) {
22
+ resolve(value);
23
+ } else {
24
+ Promise.resolve(value).then(_next, _throw);
25
+ }
26
+ }
27
+
28
+ function _asyncToGenerator(fn) {
29
+ return function () {
30
+ var self = this,
31
+ args = arguments;
32
+ return new Promise(function (resolve, reject) {
33
+ var gen = fn.apply(self, args);
34
+
35
+ function _next(value) {
36
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
37
+ }
38
+
39
+ function _throw(err) {
40
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
41
+ }
42
+
43
+ _next(undefined);
44
+ });
45
+ };
46
+ }
47
+
48
+ function _extends() {
49
+ _extends = Object.assign || function (target) {
50
+ for (var i = 1; i < arguments.length; i++) {
51
+ var source = arguments[i];
52
+
53
+ for (var key in source) {
54
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
55
+ target[key] = source[key];
56
+ }
57
+ }
58
+ }
59
+
60
+ return target;
61
+ };
62
+
63
+ return _extends.apply(this, arguments);
64
+ }
65
+
66
+ function _unsupportedIterableToArray(o, minLen) {
67
+ if (!o) return;
68
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
69
+ var n = Object.prototype.toString.call(o).slice(8, -1);
70
+ if (n === "Object" && o.constructor) n = o.constructor.name;
71
+ if (n === "Map" || n === "Set") return Array.from(o);
72
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
73
+ }
74
+
75
+ function _arrayLikeToArray(arr, len) {
76
+ if (len == null || len > arr.length) len = arr.length;
77
+
78
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
79
+
80
+ return arr2;
81
+ }
82
+
83
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
84
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
85
+ if (it) return (it = it.call(o)).next.bind(it);
86
+
87
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
88
+ if (it) o = it;
89
+ var i = 0;
90
+ return function () {
91
+ if (i >= o.length) return {
92
+ done: true
93
+ };
94
+ return {
95
+ done: false,
96
+ value: o[i++]
97
+ };
98
+ };
99
+ }
100
+
101
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
102
+ }
103
+
104
+ function createCommonjsModule(fn, module) {
105
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
106
+ }
107
+
108
+ var runtime_1 = createCommonjsModule(function (module) {
109
+ /**
110
+ * Copyright (c) 2014-present, Facebook, Inc.
111
+ *
112
+ * This source code is licensed under the MIT license found in the
113
+ * LICENSE file in the root directory of this source tree.
114
+ */
115
+
116
+ var runtime = (function (exports) {
117
+
118
+ var Op = Object.prototype;
119
+ var hasOwn = Op.hasOwnProperty;
120
+ var undefined$1; // More compressible than void 0.
121
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
122
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
123
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
124
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
125
+
126
+ function define(obj, key, value) {
127
+ Object.defineProperty(obj, key, {
128
+ value: value,
129
+ enumerable: true,
130
+ configurable: true,
131
+ writable: true
132
+ });
133
+ return obj[key];
134
+ }
135
+ try {
136
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
137
+ define({}, "");
138
+ } catch (err) {
139
+ define = function(obj, key, value) {
140
+ return obj[key] = value;
141
+ };
142
+ }
143
+
144
+ function wrap(innerFn, outerFn, self, tryLocsList) {
145
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
146
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
147
+ var generator = Object.create(protoGenerator.prototype);
148
+ var context = new Context(tryLocsList || []);
149
+
150
+ // The ._invoke method unifies the implementations of the .next,
151
+ // .throw, and .return methods.
152
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
153
+
154
+ return generator;
155
+ }
156
+ exports.wrap = wrap;
157
+
158
+ // Try/catch helper to minimize deoptimizations. Returns a completion
159
+ // record like context.tryEntries[i].completion. This interface could
160
+ // have been (and was previously) designed to take a closure to be
161
+ // invoked without arguments, but in all the cases we care about we
162
+ // already have an existing method we want to call, so there's no need
163
+ // to create a new function object. We can even get away with assuming
164
+ // the method takes exactly one argument, since that happens to be true
165
+ // in every case, so we don't have to touch the arguments object. The
166
+ // only additional allocation required is the completion record, which
167
+ // has a stable shape and so hopefully should be cheap to allocate.
168
+ function tryCatch(fn, obj, arg) {
169
+ try {
170
+ return { type: "normal", arg: fn.call(obj, arg) };
171
+ } catch (err) {
172
+ return { type: "throw", arg: err };
173
+ }
174
+ }
175
+
176
+ var GenStateSuspendedStart = "suspendedStart";
177
+ var GenStateSuspendedYield = "suspendedYield";
178
+ var GenStateExecuting = "executing";
179
+ var GenStateCompleted = "completed";
180
+
181
+ // Returning this object from the innerFn has the same effect as
182
+ // breaking out of the dispatch switch statement.
183
+ var ContinueSentinel = {};
184
+
185
+ // Dummy constructor functions that we use as the .constructor and
186
+ // .constructor.prototype properties for functions that return Generator
187
+ // objects. For full spec compliance, you may wish to configure your
188
+ // minifier not to mangle the names of these two functions.
189
+ function Generator() {}
190
+ function GeneratorFunction() {}
191
+ function GeneratorFunctionPrototype() {}
192
+
193
+ // This is a polyfill for %IteratorPrototype% for environments that
194
+ // don't natively support it.
195
+ var IteratorPrototype = {};
196
+ IteratorPrototype[iteratorSymbol] = function () {
197
+ return this;
198
+ };
199
+
200
+ var getProto = Object.getPrototypeOf;
201
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
202
+ if (NativeIteratorPrototype &&
203
+ NativeIteratorPrototype !== Op &&
204
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
205
+ // This environment has a native %IteratorPrototype%; use it instead
206
+ // of the polyfill.
207
+ IteratorPrototype = NativeIteratorPrototype;
208
+ }
209
+
210
+ var Gp = GeneratorFunctionPrototype.prototype =
211
+ Generator.prototype = Object.create(IteratorPrototype);
212
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
213
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
214
+ GeneratorFunction.displayName = define(
215
+ GeneratorFunctionPrototype,
216
+ toStringTagSymbol,
217
+ "GeneratorFunction"
218
+ );
219
+
220
+ // Helper for defining the .next, .throw, and .return methods of the
221
+ // Iterator interface in terms of a single ._invoke method.
222
+ function defineIteratorMethods(prototype) {
223
+ ["next", "throw", "return"].forEach(function(method) {
224
+ define(prototype, method, function(arg) {
225
+ return this._invoke(method, arg);
226
+ });
227
+ });
228
+ }
229
+
230
+ exports.isGeneratorFunction = function(genFun) {
231
+ var ctor = typeof genFun === "function" && genFun.constructor;
232
+ return ctor
233
+ ? ctor === GeneratorFunction ||
234
+ // For the native GeneratorFunction constructor, the best we can
235
+ // do is to check its .name property.
236
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
237
+ : false;
238
+ };
239
+
240
+ exports.mark = function(genFun) {
241
+ if (Object.setPrototypeOf) {
242
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
243
+ } else {
244
+ genFun.__proto__ = GeneratorFunctionPrototype;
245
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
246
+ }
247
+ genFun.prototype = Object.create(Gp);
248
+ return genFun;
249
+ };
250
+
251
+ // Within the body of any async function, `await x` is transformed to
252
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
253
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
254
+ // meant to be awaited.
255
+ exports.awrap = function(arg) {
256
+ return { __await: arg };
257
+ };
258
+
259
+ function AsyncIterator(generator, PromiseImpl) {
260
+ function invoke(method, arg, resolve, reject) {
261
+ var record = tryCatch(generator[method], generator, arg);
262
+ if (record.type === "throw") {
263
+ reject(record.arg);
264
+ } else {
265
+ var result = record.arg;
266
+ var value = result.value;
267
+ if (value &&
268
+ typeof value === "object" &&
269
+ hasOwn.call(value, "__await")) {
270
+ return PromiseImpl.resolve(value.__await).then(function(value) {
271
+ invoke("next", value, resolve, reject);
272
+ }, function(err) {
273
+ invoke("throw", err, resolve, reject);
274
+ });
275
+ }
276
+
277
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
278
+ // When a yielded Promise is resolved, its final value becomes
279
+ // the .value of the Promise<{value,done}> result for the
280
+ // current iteration.
281
+ result.value = unwrapped;
282
+ resolve(result);
283
+ }, function(error) {
284
+ // If a rejected Promise was yielded, throw the rejection back
285
+ // into the async generator function so it can be handled there.
286
+ return invoke("throw", error, resolve, reject);
287
+ });
288
+ }
289
+ }
290
+
291
+ var previousPromise;
292
+
293
+ function enqueue(method, arg) {
294
+ function callInvokeWithMethodAndArg() {
295
+ return new PromiseImpl(function(resolve, reject) {
296
+ invoke(method, arg, resolve, reject);
297
+ });
298
+ }
299
+
300
+ return previousPromise =
301
+ // If enqueue has been called before, then we want to wait until
302
+ // all previous Promises have been resolved before calling invoke,
303
+ // so that results are always delivered in the correct order. If
304
+ // enqueue has not been called before, then it is important to
305
+ // call invoke immediately, without waiting on a callback to fire,
306
+ // so that the async generator function has the opportunity to do
307
+ // any necessary setup in a predictable way. This predictability
308
+ // is why the Promise constructor synchronously invokes its
309
+ // executor callback, and why async functions synchronously
310
+ // execute code before the first await. Since we implement simple
311
+ // async functions in terms of async generators, it is especially
312
+ // important to get this right, even though it requires care.
313
+ previousPromise ? previousPromise.then(
314
+ callInvokeWithMethodAndArg,
315
+ // Avoid propagating failures to Promises returned by later
316
+ // invocations of the iterator.
317
+ callInvokeWithMethodAndArg
318
+ ) : callInvokeWithMethodAndArg();
319
+ }
320
+
321
+ // Define the unified helper method that is used to implement .next,
322
+ // .throw, and .return (see defineIteratorMethods).
323
+ this._invoke = enqueue;
324
+ }
325
+
326
+ defineIteratorMethods(AsyncIterator.prototype);
327
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
328
+ return this;
329
+ };
330
+ exports.AsyncIterator = AsyncIterator;
331
+
332
+ // Note that simple async functions are implemented on top of
333
+ // AsyncIterator objects; they just return a Promise for the value of
334
+ // the final result produced by the iterator.
335
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
336
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
337
+
338
+ var iter = new AsyncIterator(
339
+ wrap(innerFn, outerFn, self, tryLocsList),
340
+ PromiseImpl
341
+ );
342
+
343
+ return exports.isGeneratorFunction(outerFn)
344
+ ? iter // If outerFn is a generator, return the full iterator.
345
+ : iter.next().then(function(result) {
346
+ return result.done ? result.value : iter.next();
347
+ });
348
+ };
349
+
350
+ function makeInvokeMethod(innerFn, self, context) {
351
+ var state = GenStateSuspendedStart;
352
+
353
+ return function invoke(method, arg) {
354
+ if (state === GenStateExecuting) {
355
+ throw new Error("Generator is already running");
356
+ }
357
+
358
+ if (state === GenStateCompleted) {
359
+ if (method === "throw") {
360
+ throw arg;
361
+ }
362
+
363
+ // Be forgiving, per 25.3.3.3.3 of the spec:
364
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
365
+ return doneResult();
366
+ }
367
+
368
+ context.method = method;
369
+ context.arg = arg;
370
+
371
+ while (true) {
372
+ var delegate = context.delegate;
373
+ if (delegate) {
374
+ var delegateResult = maybeInvokeDelegate(delegate, context);
375
+ if (delegateResult) {
376
+ if (delegateResult === ContinueSentinel) continue;
377
+ return delegateResult;
378
+ }
379
+ }
380
+
381
+ if (context.method === "next") {
382
+ // Setting context._sent for legacy support of Babel's
383
+ // function.sent implementation.
384
+ context.sent = context._sent = context.arg;
385
+
386
+ } else if (context.method === "throw") {
387
+ if (state === GenStateSuspendedStart) {
388
+ state = GenStateCompleted;
389
+ throw context.arg;
390
+ }
391
+
392
+ context.dispatchException(context.arg);
393
+
394
+ } else if (context.method === "return") {
395
+ context.abrupt("return", context.arg);
396
+ }
397
+
398
+ state = GenStateExecuting;
399
+
400
+ var record = tryCatch(innerFn, self, context);
401
+ if (record.type === "normal") {
402
+ // If an exception is thrown from innerFn, we leave state ===
403
+ // GenStateExecuting and loop back for another invocation.
404
+ state = context.done
405
+ ? GenStateCompleted
406
+ : GenStateSuspendedYield;
407
+
408
+ if (record.arg === ContinueSentinel) {
409
+ continue;
410
+ }
411
+
412
+ return {
413
+ value: record.arg,
414
+ done: context.done
415
+ };
416
+
417
+ } else if (record.type === "throw") {
418
+ state = GenStateCompleted;
419
+ // Dispatch the exception by looping back around to the
420
+ // context.dispatchException(context.arg) call above.
421
+ context.method = "throw";
422
+ context.arg = record.arg;
423
+ }
424
+ }
425
+ };
426
+ }
427
+
428
+ // Call delegate.iterator[context.method](context.arg) and handle the
429
+ // result, either by returning a { value, done } result from the
430
+ // delegate iterator, or by modifying context.method and context.arg,
431
+ // setting context.delegate to null, and returning the ContinueSentinel.
432
+ function maybeInvokeDelegate(delegate, context) {
433
+ var method = delegate.iterator[context.method];
434
+ if (method === undefined$1) {
435
+ // A .throw or .return when the delegate iterator has no .throw
436
+ // method always terminates the yield* loop.
437
+ context.delegate = null;
438
+
439
+ if (context.method === "throw") {
440
+ // Note: ["return"] must be used for ES3 parsing compatibility.
441
+ if (delegate.iterator["return"]) {
442
+ // If the delegate iterator has a return method, give it a
443
+ // chance to clean up.
444
+ context.method = "return";
445
+ context.arg = undefined$1;
446
+ maybeInvokeDelegate(delegate, context);
447
+
448
+ if (context.method === "throw") {
449
+ // If maybeInvokeDelegate(context) changed context.method from
450
+ // "return" to "throw", let that override the TypeError below.
451
+ return ContinueSentinel;
452
+ }
453
+ }
454
+
455
+ context.method = "throw";
456
+ context.arg = new TypeError(
457
+ "The iterator does not provide a 'throw' method");
458
+ }
459
+
460
+ return ContinueSentinel;
461
+ }
462
+
463
+ var record = tryCatch(method, delegate.iterator, context.arg);
464
+
465
+ if (record.type === "throw") {
466
+ context.method = "throw";
467
+ context.arg = record.arg;
468
+ context.delegate = null;
469
+ return ContinueSentinel;
470
+ }
471
+
472
+ var info = record.arg;
473
+
474
+ if (! info) {
475
+ context.method = "throw";
476
+ context.arg = new TypeError("iterator result is not an object");
477
+ context.delegate = null;
478
+ return ContinueSentinel;
479
+ }
480
+
481
+ if (info.done) {
482
+ // Assign the result of the finished delegate to the temporary
483
+ // variable specified by delegate.resultName (see delegateYield).
484
+ context[delegate.resultName] = info.value;
485
+
486
+ // Resume execution at the desired location (see delegateYield).
487
+ context.next = delegate.nextLoc;
488
+
489
+ // If context.method was "throw" but the delegate handled the
490
+ // exception, let the outer generator proceed normally. If
491
+ // context.method was "next", forget context.arg since it has been
492
+ // "consumed" by the delegate iterator. If context.method was
493
+ // "return", allow the original .return call to continue in the
494
+ // outer generator.
495
+ if (context.method !== "return") {
496
+ context.method = "next";
497
+ context.arg = undefined$1;
498
+ }
499
+
500
+ } else {
501
+ // Re-yield the result returned by the delegate method.
502
+ return info;
503
+ }
504
+
505
+ // The delegate iterator is finished, so forget it and continue with
506
+ // the outer generator.
507
+ context.delegate = null;
508
+ return ContinueSentinel;
509
+ }
510
+
511
+ // Define Generator.prototype.{next,throw,return} in terms of the
512
+ // unified ._invoke helper method.
513
+ defineIteratorMethods(Gp);
514
+
515
+ define(Gp, toStringTagSymbol, "Generator");
516
+
517
+ // A Generator should always return itself as the iterator object when the
518
+ // @@iterator function is called on it. Some browsers' implementations of the
519
+ // iterator prototype chain incorrectly implement this, causing the Generator
520
+ // object to not be returned from this call. This ensures that doesn't happen.
521
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
522
+ Gp[iteratorSymbol] = function() {
523
+ return this;
524
+ };
525
+
526
+ Gp.toString = function() {
527
+ return "[object Generator]";
528
+ };
529
+
530
+ function pushTryEntry(locs) {
531
+ var entry = { tryLoc: locs[0] };
532
+
533
+ if (1 in locs) {
534
+ entry.catchLoc = locs[1];
535
+ }
536
+
537
+ if (2 in locs) {
538
+ entry.finallyLoc = locs[2];
539
+ entry.afterLoc = locs[3];
540
+ }
541
+
542
+ this.tryEntries.push(entry);
543
+ }
544
+
545
+ function resetTryEntry(entry) {
546
+ var record = entry.completion || {};
547
+ record.type = "normal";
548
+ delete record.arg;
549
+ entry.completion = record;
550
+ }
551
+
552
+ function Context(tryLocsList) {
553
+ // The root entry object (effectively a try statement without a catch
554
+ // or a finally block) gives us a place to store values thrown from
555
+ // locations where there is no enclosing try statement.
556
+ this.tryEntries = [{ tryLoc: "root" }];
557
+ tryLocsList.forEach(pushTryEntry, this);
558
+ this.reset(true);
559
+ }
560
+
561
+ exports.keys = function(object) {
562
+ var keys = [];
563
+ for (var key in object) {
564
+ keys.push(key);
565
+ }
566
+ keys.reverse();
567
+
568
+ // Rather than returning an object with a next method, we keep
569
+ // things simple and return the next function itself.
570
+ return function next() {
571
+ while (keys.length) {
572
+ var key = keys.pop();
573
+ if (key in object) {
574
+ next.value = key;
575
+ next.done = false;
576
+ return next;
577
+ }
578
+ }
579
+
580
+ // To avoid creating an additional object, we just hang the .value
581
+ // and .done properties off the next function object itself. This
582
+ // also ensures that the minifier will not anonymize the function.
583
+ next.done = true;
584
+ return next;
585
+ };
586
+ };
587
+
588
+ function values(iterable) {
589
+ if (iterable) {
590
+ var iteratorMethod = iterable[iteratorSymbol];
591
+ if (iteratorMethod) {
592
+ return iteratorMethod.call(iterable);
593
+ }
594
+
595
+ if (typeof iterable.next === "function") {
596
+ return iterable;
597
+ }
598
+
599
+ if (!isNaN(iterable.length)) {
600
+ var i = -1, next = function next() {
601
+ while (++i < iterable.length) {
602
+ if (hasOwn.call(iterable, i)) {
603
+ next.value = iterable[i];
604
+ next.done = false;
605
+ return next;
606
+ }
607
+ }
608
+
609
+ next.value = undefined$1;
610
+ next.done = true;
611
+
612
+ return next;
613
+ };
614
+
615
+ return next.next = next;
616
+ }
617
+ }
618
+
619
+ // Return an iterator with no values.
620
+ return { next: doneResult };
621
+ }
622
+ exports.values = values;
623
+
624
+ function doneResult() {
625
+ return { value: undefined$1, done: true };
626
+ }
627
+
628
+ Context.prototype = {
629
+ constructor: Context,
630
+
631
+ reset: function(skipTempReset) {
632
+ this.prev = 0;
633
+ this.next = 0;
634
+ // Resetting context._sent for legacy support of Babel's
635
+ // function.sent implementation.
636
+ this.sent = this._sent = undefined$1;
637
+ this.done = false;
638
+ this.delegate = null;
639
+
640
+ this.method = "next";
641
+ this.arg = undefined$1;
642
+
643
+ this.tryEntries.forEach(resetTryEntry);
644
+
645
+ if (!skipTempReset) {
646
+ for (var name in this) {
647
+ // Not sure about the optimal order of these conditions:
648
+ if (name.charAt(0) === "t" &&
649
+ hasOwn.call(this, name) &&
650
+ !isNaN(+name.slice(1))) {
651
+ this[name] = undefined$1;
652
+ }
653
+ }
654
+ }
655
+ },
656
+
657
+ stop: function() {
658
+ this.done = true;
659
+
660
+ var rootEntry = this.tryEntries[0];
661
+ var rootRecord = rootEntry.completion;
662
+ if (rootRecord.type === "throw") {
663
+ throw rootRecord.arg;
664
+ }
665
+
666
+ return this.rval;
667
+ },
668
+
669
+ dispatchException: function(exception) {
670
+ if (this.done) {
671
+ throw exception;
672
+ }
673
+
674
+ var context = this;
675
+ function handle(loc, caught) {
676
+ record.type = "throw";
677
+ record.arg = exception;
678
+ context.next = loc;
679
+
680
+ if (caught) {
681
+ // If the dispatched exception was caught by a catch block,
682
+ // then let that catch block handle the exception normally.
683
+ context.method = "next";
684
+ context.arg = undefined$1;
685
+ }
686
+
687
+ return !! caught;
688
+ }
689
+
690
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
691
+ var entry = this.tryEntries[i];
692
+ var record = entry.completion;
693
+
694
+ if (entry.tryLoc === "root") {
695
+ // Exception thrown outside of any try block that could handle
696
+ // it, so set the completion value of the entire function to
697
+ // throw the exception.
698
+ return handle("end");
699
+ }
700
+
701
+ if (entry.tryLoc <= this.prev) {
702
+ var hasCatch = hasOwn.call(entry, "catchLoc");
703
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
704
+
705
+ if (hasCatch && hasFinally) {
706
+ if (this.prev < entry.catchLoc) {
707
+ return handle(entry.catchLoc, true);
708
+ } else if (this.prev < entry.finallyLoc) {
709
+ return handle(entry.finallyLoc);
710
+ }
711
+
712
+ } else if (hasCatch) {
713
+ if (this.prev < entry.catchLoc) {
714
+ return handle(entry.catchLoc, true);
715
+ }
716
+
717
+ } else if (hasFinally) {
718
+ if (this.prev < entry.finallyLoc) {
719
+ return handle(entry.finallyLoc);
720
+ }
721
+
722
+ } else {
723
+ throw new Error("try statement without catch or finally");
724
+ }
725
+ }
726
+ }
727
+ },
728
+
729
+ abrupt: function(type, arg) {
730
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
731
+ var entry = this.tryEntries[i];
732
+ if (entry.tryLoc <= this.prev &&
733
+ hasOwn.call(entry, "finallyLoc") &&
734
+ this.prev < entry.finallyLoc) {
735
+ var finallyEntry = entry;
736
+ break;
737
+ }
738
+ }
739
+
740
+ if (finallyEntry &&
741
+ (type === "break" ||
742
+ type === "continue") &&
743
+ finallyEntry.tryLoc <= arg &&
744
+ arg <= finallyEntry.finallyLoc) {
745
+ // Ignore the finally entry if control is not jumping to a
746
+ // location outside the try/catch block.
747
+ finallyEntry = null;
748
+ }
749
+
750
+ var record = finallyEntry ? finallyEntry.completion : {};
751
+ record.type = type;
752
+ record.arg = arg;
753
+
754
+ if (finallyEntry) {
755
+ this.method = "next";
756
+ this.next = finallyEntry.finallyLoc;
757
+ return ContinueSentinel;
758
+ }
759
+
760
+ return this.complete(record);
761
+ },
762
+
763
+ complete: function(record, afterLoc) {
764
+ if (record.type === "throw") {
765
+ throw record.arg;
766
+ }
767
+
768
+ if (record.type === "break" ||
769
+ record.type === "continue") {
770
+ this.next = record.arg;
771
+ } else if (record.type === "return") {
772
+ this.rval = this.arg = record.arg;
773
+ this.method = "return";
774
+ this.next = "end";
775
+ } else if (record.type === "normal" && afterLoc) {
776
+ this.next = afterLoc;
777
+ }
778
+
779
+ return ContinueSentinel;
780
+ },
781
+
782
+ finish: function(finallyLoc) {
783
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
784
+ var entry = this.tryEntries[i];
785
+ if (entry.finallyLoc === finallyLoc) {
786
+ this.complete(entry.completion, entry.afterLoc);
787
+ resetTryEntry(entry);
788
+ return ContinueSentinel;
789
+ }
790
+ }
791
+ },
792
+
793
+ "catch": function(tryLoc) {
794
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
795
+ var entry = this.tryEntries[i];
796
+ if (entry.tryLoc === tryLoc) {
797
+ var record = entry.completion;
798
+ if (record.type === "throw") {
799
+ var thrown = record.arg;
800
+ resetTryEntry(entry);
801
+ }
802
+ return thrown;
803
+ }
804
+ }
805
+
806
+ // The context.catch method must only be called with a location
807
+ // argument that corresponds to a known catch block.
808
+ throw new Error("illegal catch attempt");
809
+ },
810
+
811
+ delegateYield: function(iterable, resultName, nextLoc) {
812
+ this.delegate = {
813
+ iterator: values(iterable),
814
+ resultName: resultName,
815
+ nextLoc: nextLoc
816
+ };
817
+
818
+ if (this.method === "next") {
819
+ // Deliberately forget the last sent value so that we don't
820
+ // accidentally pass it on to the delegate.
821
+ this.arg = undefined$1;
822
+ }
823
+
824
+ return ContinueSentinel;
825
+ }
826
+ };
827
+
828
+ // Regardless of whether this script is executing as a CommonJS module
829
+ // or not, return the runtime object so that we can declare the variable
830
+ // regeneratorRuntime in the outer scope, which allows this module to be
831
+ // injected easily by `bin/regenerator --include-runtime script.js`.
832
+ return exports;
833
+
834
+ }(
835
+ // If this script is executing as a CommonJS module, use module.exports
836
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
837
+ // object. Either way, the resulting object will be used to initialize
838
+ // the regeneratorRuntime variable at the top of this file.
839
+ module.exports
840
+ ));
841
+
842
+ try {
843
+ regeneratorRuntime = runtime;
844
+ } catch (accidentalStrictMode) {
845
+ // This module should not be running in strict mode, so the above
846
+ // assignment should always work unless something is misconfigured. Just
847
+ // in case runtime.js accidentally runs in strict mode, we can escape
848
+ // strict mode using a global Function call. This could conceivably fail
849
+ // if a Content Security Policy forbids using Function, but in that case
850
+ // the proper solution is to fix the accidental strict mode problem. If
851
+ // you've misconfigured your bundler to force strict mode and applied a
852
+ // CSP to forbid Function, and you're not willing to fix either of those
853
+ // problems, please detail your unique predicament in a GitHub issue.
854
+ Function("r", "regeneratorRuntime = r")(runtime);
855
+ }
856
+ });
857
+
858
+ var fetcher = /*#__PURE__*/function () {
859
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
860
+ var res, _yield$res$json, data;
861
+
862
+ return runtime_1.wrap(function _callee$(_context) {
863
+ while (1) {
864
+ switch (_context.prev = _context.next) {
865
+ case 0:
866
+ console.log('FETCHER');
867
+ _context.next = 3;
868
+ return fetch('./data.json');
869
+
870
+ case 3:
871
+ res = _context.sent;
872
+
873
+ if (!res.ok) {
874
+ _context.next = 10;
875
+ break;
876
+ }
877
+
878
+ _context.next = 7;
879
+ return res.json();
880
+
881
+ case 7:
882
+ _yield$res$json = _context.sent;
883
+ data = _yield$res$json.data;
884
+ return _context.abrupt("return", data);
885
+
886
+ case 10:
887
+ throw res;
888
+
889
+ case 11:
890
+ case "end":
891
+ return _context.stop();
892
+ }
893
+ }
894
+ }, _callee);
895
+ }));
896
+
897
+ return function fetcher() {
898
+ return _ref.apply(this, arguments);
899
+ };
900
+ }();
901
+
902
+ var LOCAL_CART_URL = 'localCartUrl';
903
+
904
+ var handler = {
905
+ fetchOptions: {
906
+ query: ''
907
+ },
908
+ fetcher: function fetcher(_ref) {
909
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
910
+ var _localStorage$getItem;
911
+
912
+ var cartId, fetch;
913
+ return runtime_1.wrap(function _callee$(_context) {
914
+ while (1) {
915
+ switch (_context.prev = _context.next) {
916
+ case 0:
917
+ cartId = _ref.input.cartId, fetch = _ref.fetch;
918
+
919
+ if (!cartId) {
920
+ cartId = LOCAL_CART_URL;
921
+ }
922
+
923
+ return _context.abrupt("return", JSON.parse((_localStorage$getItem = localStorage.getItem(cartId)) != null ? _localStorage$getItem : "null"));
924
+
925
+ case 3:
926
+ case "end":
927
+ return _context.stop();
928
+ }
929
+ }
930
+ }, _callee);
931
+ }))();
932
+ },
933
+ useHook: function useHook(_ref2) {
934
+ var useData = _ref2.useData;
935
+ return function (input) {
936
+ return useData({
937
+ swrOptions: _extends({
938
+ revalidateOnFocus: false
939
+ }, input == null ? void 0 : input.swrOptions)
940
+ });
941
+ };
942
+ }
943
+ };
944
+
945
+ var products = [
946
+ {
947
+ id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
948
+ name: "New Short Sleeve T-Shirt",
949
+ vendor: "Next.js",
950
+ path: "/new-short-sleeve-t-shirt",
951
+ slug: "new-short-sleeve-t-shirt",
952
+ price: {
953
+ value: 25,
954
+ currencyCode: "USD"
955
+ },
956
+ descriptionHtml: "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
957
+ images: [
958
+ {
959
+ url: "https://static1.plasmic.app/commerce/drop-shirt-0.png",
960
+ altText: "Shirt",
961
+ width: 1000,
962
+ height: 1000
963
+ },
964
+ {
965
+ url: "https://static1.plasmic.app/commerce/drop-shirt-1.png",
966
+ altText: "Shirt",
967
+ width: 1000,
968
+ height: 1000
969
+ },
970
+ {
971
+ url: "https://static1.plasmic.app/commerce/drop-shirt-2.png",
972
+ altText: "Shirt",
973
+ width: 1000,
974
+ height: 1000
975
+ }
976
+ ],
977
+ variants: [
978
+ {
979
+ id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
980
+ options: [
981
+ {
982
+ __typename: "MultipleChoiceOption",
983
+ id: "asd",
984
+ displayName: "Size",
985
+ values: [
986
+ {
987
+ label: "XL"
988
+ }
989
+ ]
990
+ }
991
+ ]
992
+ }
993
+ ],
994
+ options: [
995
+ {
996
+ id: "option-color",
997
+ displayName: "Color",
998
+ values: [
999
+ {
1000
+ label: "color",
1001
+ hexColors: [
1002
+ "#222"
1003
+ ]
1004
+ }
1005
+ ]
1006
+ },
1007
+ {
1008
+ id: "option-size",
1009
+ displayName: "Size",
1010
+ values: [
1011
+ {
1012
+ label: "S"
1013
+ },
1014
+ {
1015
+ label: "M"
1016
+ },
1017
+ {
1018
+ label: "L"
1019
+ }
1020
+ ]
1021
+ }
1022
+ ]
1023
+ },
1024
+ {
1025
+ id: "Z2lkOi8vc2hvcGlmeS9Qcm9ksdWN0LzU0NDczMjUwMjQ0MjA=",
1026
+ name: "Lightweight Jacket",
1027
+ vendor: "Next.js",
1028
+ path: "/lightweight-jacket",
1029
+ slug: "lightweight-jacket",
1030
+ price: {
1031
+ value: 249.99,
1032
+ currencyCode: "USD"
1033
+ },
1034
+ descriptionHtml: "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
1035
+ images: [
1036
+ {
1037
+ url: "https://static1.plasmic.app/commerce/lightweight-jacket-0.png",
1038
+ altText: "Lightweight Jacket",
1039
+ width: 1000,
1040
+ height: 1000
1041
+ },
1042
+ {
1043
+ url: "https://static1.plasmic.app/commerce/lightweight-jacket-1.png",
1044
+ altText: "Lightweight Jacket",
1045
+ width: 1000,
1046
+ height: 1000
1047
+ },
1048
+ {
1049
+ url: "https://static1.plasmic.app/commerce/lightweight-jacket-2.png",
1050
+ altText: "Lightweight Jacket",
1051
+ width: 1000,
1052
+ height: 1000
1053
+ }
1054
+ ],
1055
+ variants: [
1056
+ {
1057
+ id: "Z2lkOid8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
1058
+ options: [
1059
+ {
1060
+ __typename: "MultipleChoiceOption",
1061
+ id: "asd",
1062
+ displayName: "Size",
1063
+ values: [
1064
+ {
1065
+ label: "XL"
1066
+ }
1067
+ ]
1068
+ }
1069
+ ]
1070
+ }
1071
+ ],
1072
+ options: [
1073
+ {
1074
+ id: "option-color",
1075
+ displayName: "Color",
1076
+ values: [
1077
+ {
1078
+ label: "color",
1079
+ hexColors: [
1080
+ "#222"
1081
+ ]
1082
+ }
1083
+ ]
1084
+ },
1085
+ {
1086
+ id: "option-size",
1087
+ displayName: "Size",
1088
+ values: [
1089
+ {
1090
+ label: "S"
1091
+ },
1092
+ {
1093
+ label: "M"
1094
+ },
1095
+ {
1096
+ label: "L"
1097
+ }
1098
+ ]
1099
+ }
1100
+ ]
1101
+ },
1102
+ {
1103
+ id: "Z2lkOis8vc2hvcGlmsddeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
1104
+ name: "Shirt",
1105
+ vendor: "Next.js",
1106
+ path: "/shirt",
1107
+ slug: "shirt",
1108
+ price: {
1109
+ value: 25,
1110
+ currencyCode: "USD"
1111
+ },
1112
+ descriptionHtml: "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
1113
+ images: [
1114
+ {
1115
+ url: "https://static1.plasmic.app/commerce/t-shirt-0.png",
1116
+ altText: "Shirt",
1117
+ width: 1000,
1118
+ height: 1000
1119
+ },
1120
+ {
1121
+ url: "https://static1.plasmic.app/commerce/t-shirt-1.png",
1122
+ altText: "Shirt",
1123
+ width: 1000,
1124
+ height: 1000
1125
+ },
1126
+ {
1127
+ url: "https://static1.plasmic.app/commerce/t-shirt-2.png",
1128
+ altText: "Shirt",
1129
+ width: 1000,
1130
+ height: 1000
1131
+ },
1132
+ {
1133
+ url: "https://static1.plasmic.app/commerce/t-shirt-3.png",
1134
+ altText: "Shirt",
1135
+ width: 1000,
1136
+ height: 1000
1137
+ },
1138
+ {
1139
+ url: "https://static1.plasmic.app/commerce/t-shirt-4.png",
1140
+ altText: "Shirt",
1141
+ width: 1000,
1142
+ height: 1000
1143
+ }
1144
+ ],
1145
+ variants: [
1146
+ {
1147
+ id: "Z2lkOi8vc2hvcGlmeS9Qcms9kdWN0LzU0NDczMjUwMjQ0MjAss=",
1148
+ options: [
1149
+ {
1150
+ __typename: "MultipleChoiceOption",
1151
+ id: "asd",
1152
+ displayName: "Size",
1153
+ values: [
1154
+ {
1155
+ label: "XL"
1156
+ }
1157
+ ]
1158
+ }
1159
+ ]
1160
+ }
1161
+ ],
1162
+ options: [
1163
+ {
1164
+ id: "option-color",
1165
+ displayName: "Color",
1166
+ values: [
1167
+ {
1168
+ label: "color",
1169
+ hexColors: [
1170
+ "#222"
1171
+ ]
1172
+ }
1173
+ ]
1174
+ },
1175
+ {
1176
+ id: "option-size",
1177
+ displayName: "Size",
1178
+ values: [
1179
+ {
1180
+ label: "S"
1181
+ },
1182
+ {
1183
+ label: "M"
1184
+ },
1185
+ {
1186
+ label: "L"
1187
+ }
1188
+ ]
1189
+ }
1190
+ ]
1191
+ }
1192
+ ];
1193
+ var data = {
1194
+ products: products
1195
+ };
1196
+
1197
+ var createCart = function createCart() {
1198
+ return {
1199
+ id: '',
1200
+ createdAt: '',
1201
+ currency: {
1202
+ code: ''
1203
+ },
1204
+ taxesIncluded: false,
1205
+ lineItems: [],
1206
+ lineItemsSubtotalPrice: 0,
1207
+ subtotalPrice: 0,
1208
+ totalPrice: 0
1209
+ };
1210
+ };
1211
+
1212
+ var handler$1 = {
1213
+ fetchOptions: {
1214
+ query: ''
1215
+ },
1216
+ fetcher: function fetcher(_ref) {
1217
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1218
+ var _item$quantity;
1219
+
1220
+ var item, fetch, lineItem, cart, _iterator, _step, product, _item$quantity2;
1221
+
1222
+ return runtime_1.wrap(function _callee$(_context) {
1223
+ while (1) {
1224
+ switch (_context.prev = _context.next) {
1225
+ case 0:
1226
+ item = _ref.input, fetch = _ref.fetch;
1227
+
1228
+ if (!(item.quantity && (!Number.isInteger(item.quantity) || item.quantity < 1))) {
1229
+ _context.next = 3;
1230
+ break;
1231
+ }
1232
+
1233
+ throw new commerce.CommerceError({
1234
+ message: 'The item quantity has to be a valid integer greater than 0'
1235
+ });
1236
+
1237
+ case 3:
1238
+ lineItem = {
1239
+ variantId: item.variantId,
1240
+ quantity: (_item$quantity = item.quantity) != null ? _item$quantity : 1
1241
+ };
1242
+
1243
+ if (!localStorage.getItem(LOCAL_CART_URL)) {
1244
+ cart = createCart();
1245
+ } else {
1246
+ cart = JSON.parse(localStorage.getItem(LOCAL_CART_URL));
1247
+ }
1248
+
1249
+ for (_iterator = _createForOfIteratorHelperLoose(data.products); !(_step = _iterator()).done;) {
1250
+ product = _step.value;
1251
+
1252
+ if (product.id === item.variantId || product.variants.some(function (productVariant) {
1253
+ return productVariant.id === item.variantId;
1254
+ })) {
1255
+ cart.lineItems.push(lineItem);
1256
+ cart.totalPrice += product.price.value * ((_item$quantity2 = item.quantity) != null ? _item$quantity2 : 1);
1257
+ cart.currency.code = product.price.currencyCode;
1258
+ }
1259
+ }
1260
+
1261
+ localStorage.setItem(LOCAL_CART_URL, JSON.stringify(cart));
1262
+ return _context.abrupt("return", cart);
1263
+
1264
+ case 8:
1265
+ case "end":
1266
+ return _context.stop();
1267
+ }
1268
+ }
1269
+ }, _callee);
1270
+ }))();
1271
+ },
1272
+ useHook: function useHook(_ref2) {
1273
+ var fetch = _ref2.fetch;
1274
+ return function () {
1275
+ var _useCart = commerce.useCart(),
1276
+ mutate = _useCart.mutate;
1277
+
1278
+ return React.useCallback( /*#__PURE__*/function () {
1279
+ var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1280
+ var data;
1281
+ return runtime_1.wrap(function _callee2$(_context2) {
1282
+ while (1) {
1283
+ switch (_context2.prev = _context2.next) {
1284
+ case 0:
1285
+ _context2.next = 2;
1286
+ return fetch({
1287
+ input: input
1288
+ });
1289
+
1290
+ case 2:
1291
+ data = _context2.sent;
1292
+ _context2.next = 5;
1293
+ return mutate(data, false);
1294
+
1295
+ case 5:
1296
+ return _context2.abrupt("return", data);
1297
+
1298
+ case 6:
1299
+ case "end":
1300
+ return _context2.stop();
1301
+ }
1302
+ }
1303
+ }, _callee2);
1304
+ }));
1305
+
1306
+ function addItem(_x) {
1307
+ return _addItem.apply(this, arguments);
1308
+ }
1309
+
1310
+ return addItem;
1311
+ }(), [fetch, mutate]);
1312
+ };
1313
+ }
1314
+ };
1315
+
1316
+ var handler$2 = {
1317
+ fetchOptions: {
1318
+ query: ''
1319
+ },
1320
+ fetcher: function fetcher(_ref) {
1321
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1322
+ return runtime_1.wrap(function _callee$(_context) {
1323
+ while (1) {
1324
+ switch (_context.prev = _context.next) {
1325
+ case 0:
1326
+
1327
+ case 1:
1328
+ case "end":
1329
+ return _context.stop();
1330
+ }
1331
+ }
1332
+ }, _callee);
1333
+ }))();
1334
+ },
1335
+ useHook: function useHook(_ref2) {
1336
+ return function () {
1337
+ return /*#__PURE__*/function () {
1338
+ var _addItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1339
+ return runtime_1.wrap(function _callee2$(_context2) {
1340
+ while (1) {
1341
+ switch (_context2.prev = _context2.next) {
1342
+ case 0:
1343
+ return _context2.abrupt("return", {});
1344
+
1345
+ case 1:
1346
+ case "end":
1347
+ return _context2.stop();
1348
+ }
1349
+ }
1350
+ }, _callee2);
1351
+ }));
1352
+
1353
+ function addItem() {
1354
+ return _addItem.apply(this, arguments);
1355
+ }
1356
+
1357
+ return addItem;
1358
+ }();
1359
+ };
1360
+ }
1361
+ };
1362
+
1363
+ var handler$3 = {
1364
+ fetchOptions: {
1365
+ query: ''
1366
+ },
1367
+ fetcher: function fetcher(_ref) {
1368
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1369
+ return runtime_1.wrap(function _callee$(_context) {
1370
+ while (1) {
1371
+ switch (_context.prev = _context.next) {
1372
+ case 0:
1373
+
1374
+ case 1:
1375
+ case "end":
1376
+ return _context.stop();
1377
+ }
1378
+ }
1379
+ }, _callee);
1380
+ }))();
1381
+ },
1382
+ useHook: function useHook(_ref2) {
1383
+ return function () {
1384
+ return /*#__PURE__*/function () {
1385
+ var _removeItem = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
1386
+ return runtime_1.wrap(function _callee2$(_context2) {
1387
+ while (1) {
1388
+ switch (_context2.prev = _context2.next) {
1389
+ case 0:
1390
+ return _context2.abrupt("return", {});
1391
+
1392
+ case 1:
1393
+ case "end":
1394
+ return _context2.stop();
1395
+ }
1396
+ }
1397
+ }, _callee2);
1398
+ }));
1399
+
1400
+ function removeItem(_x) {
1401
+ return _removeItem.apply(this, arguments);
1402
+ }
1403
+
1404
+ return removeItem;
1405
+ }();
1406
+ };
1407
+ }
1408
+ };
1409
+
1410
+ var handler$4 = {
1411
+ fetchOptions: {
1412
+ query: ''
1413
+ },
1414
+ fetcher: function fetcher(_ref) {
1415
+ return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1416
+ return runtime_1.wrap(function _callee$(_context) {
1417
+ while (1) {
1418
+ switch (_context.prev = _context.next) {
1419
+ case 0:
1420
+ return _context.abrupt("return", {
1421
+ data: {
1422
+ products: data.products
1423
+ }
1424
+ });
1425
+
1426
+ case 2:
1427
+ case "end":
1428
+ return _context.stop();
1429
+ }
1430
+ }
1431
+ }, _callee);
1432
+ }))();
1433
+ },
1434
+ useHook: function useHook() {
1435
+ return function () {
1436
+ return {
1437
+ data: {
1438
+ products: data.products
1439
+ }
1440
+ };
1441
+ };
1442
+ }
1443
+ };
1444
+
1445
+ /*
1446
+ Forked from https://github.com/vercel/commerce/tree/main/packages/local/src
1447
+ Changes: Removed authentication, customer and wishlist hooks
1448
+ */
1449
+ var localProvider = {
1450
+ locale: 'en-us',
1451
+ cartCookie: 'LOCAL_CART',
1452
+ fetcher: fetcher,
1453
+ cart: {
1454
+ useCart: handler,
1455
+ useAddItem: handler$1,
1456
+ useUpdateItem: handler$2,
1457
+ useRemoveItem: handler$3
1458
+ },
1459
+ products: {
1460
+ useSearch: handler$4
1461
+ }
1462
+ };
1463
+
1464
+ /*
1465
+ Forked from https://github.com/vercel/commerce/tree/main/packages/local/src
1466
+ Changes: None
1467
+ */
1468
+ var CommerceProvider = /*#__PURE__*/commerce.getCommerceProvider(localProvider);
1469
+ var useCommerce = function useCommerce() {
1470
+ return commerce.useCommerce();
1471
+ };
1472
+
1473
+ var commerceProviderMeta = {
1474
+ name: "Local Provider",
1475
+ displayName: "Local Provider",
1476
+ props: {
1477
+ children: {
1478
+ type: "slot"
1479
+ }
1480
+ },
1481
+ importPath: "commerce-providers/local",
1482
+ importName: "LocalProvider"
1483
+ };
1484
+
1485
+ function CommerceProviderComponent(props) {
1486
+ return React__default.createElement(CommerceProvider, null, props.children);
1487
+ }
1488
+
1489
+ function registerCommerceProvider(loader, customCommerceProviderMeta) {
1490
+ var doRegisterComponent = function doRegisterComponent() {
1491
+ return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
1492
+ };
1493
+
1494
+ doRegisterComponent(CommerceProviderComponent, customCommerceProviderMeta != null ? customCommerceProviderMeta : commerceProviderMeta);
1495
+ }
1496
+
1497
+ function registerAll(loader) {
1498
+ registerCommerceProvider(loader);
1499
+ }
1500
+
1501
+ exports.CommerceProvider = CommerceProvider;
1502
+ exports.localProvider = localProvider;
1503
+ exports.registerAll = registerAll;
1504
+ exports.registerCommerceProvider = registerCommerceProvider;
1505
+ exports.useCommerce = useCommerce;
1506
+ //# sourceMappingURL=commerce-local.cjs.development.js.map