merchi_cart 0.0.4-c → 0.0.4-e

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.
Files changed (196) hide show
  1. package/lib/Cart.js +20 -25
  2. package/lib/CartAlert.js +14 -12
  3. package/lib/CartHeader.js +9 -9
  4. package/lib/CartProvider.js +157 -226
  5. package/lib/CartTotals.js +44 -44
  6. package/lib/MerchiSDK/constants/auto_assign_production_on_actions.js +1 -1
  7. package/lib/MerchiSDK/constants/call_to_actions.js +1 -1
  8. package/lib/MerchiSDK/constants/discount_types.js +1 -1
  9. package/lib/MerchiSDK/constants/domain_types.js +1 -1
  10. package/lib/MerchiSDK/constants/errors.js +1 -1
  11. package/lib/MerchiSDK/constants/event_types.js +1 -1
  12. package/lib/MerchiSDK/constants/field_types.js +1 -1
  13. package/lib/MerchiSDK/constants/input_types.js +1 -1
  14. package/lib/MerchiSDK/constants/inventory_statuses.js +1 -1
  15. package/lib/MerchiSDK/constants/invoice_types.js +1 -1
  16. package/lib/MerchiSDK/constants/item_types.js +1 -1
  17. package/lib/MerchiSDK/constants/job/drafting_status.js +1 -1
  18. package/lib/MerchiSDK/constants/job/payment_status.js +1 -1
  19. package/lib/MerchiSDK/constants/job/production_status.js +1 -1
  20. package/lib/MerchiSDK/constants/job/shipment_status.js +1 -1
  21. package/lib/MerchiSDK/constants/job/supply_chain_request_status.js +1 -1
  22. package/lib/MerchiSDK/constants/job_priorities.js +1 -1
  23. package/lib/MerchiSDK/constants/job_status.js +5 -5
  24. package/lib/MerchiSDK/constants/job_types.js +1 -1
  25. package/lib/MerchiSDK/constants/notification_sections.js +1 -1
  26. package/lib/MerchiSDK/constants/notification_types.js +1 -1
  27. package/lib/MerchiSDK/constants/notification_urgencies.js +1 -1
  28. package/lib/MerchiSDK/constants/payment_types.js +1 -1
  29. package/lib/MerchiSDK/constants/platform.js +5 -5
  30. package/lib/MerchiSDK/constants/product_types.js +1 -1
  31. package/lib/MerchiSDK/constants/rights.js +1 -1
  32. package/lib/MerchiSDK/constants/robots_meta_directives.js +1 -1
  33. package/lib/MerchiSDK/constants/roles.js +8 -14
  34. package/lib/MerchiSDK/constants/shipment_companies.js +1 -1
  35. package/lib/MerchiSDK/constants/shipment_services.js +1 -1
  36. package/lib/MerchiSDK/constants/system_roles.js +1 -1
  37. package/lib/MerchiSDK/constants/theme_foundations.js +1 -1
  38. package/lib/MerchiSDK/constants/theme_status.js +1 -1
  39. package/lib/MerchiSDK/constants/user_types.js +1 -1
  40. package/lib/MerchiSDK/constants/white_label_accessibilities.js +1 -1
  41. package/lib/MerchiSDK/cookie.js +3 -3
  42. package/lib/MerchiSDK/entities/address.js +22 -43
  43. package/lib/MerchiSDK/entities/assignment.js +28 -49
  44. package/lib/MerchiSDK/entities/automatic_payment_relationship.js +11 -32
  45. package/lib/MerchiSDK/entities/backup.js +6 -27
  46. package/lib/MerchiSDK/entities/bank.js +17 -38
  47. package/lib/MerchiSDK/entities/cart.js +31 -64
  48. package/lib/MerchiSDK/entities/cart_item.js +30 -51
  49. package/lib/MerchiSDK/entities/cart_shipment_group.js +9 -30
  50. package/lib/MerchiSDK/entities/cart_shipment_quote.js +13 -34
  51. package/lib/MerchiSDK/entities/category.js +14 -35
  52. package/lib/MerchiSDK/entities/company.js +88 -109
  53. package/lib/MerchiSDK/entities/company_invitation.js +13 -34
  54. package/lib/MerchiSDK/entities/component.js +33 -54
  55. package/lib/MerchiSDK/entities/component_tag.js +7 -28
  56. package/lib/MerchiSDK/entities/component_version.js +12 -33
  57. package/lib/MerchiSDK/entities/country_tax.js +21 -45
  58. package/lib/MerchiSDK/entities/discount.js +13 -34
  59. package/lib/MerchiSDK/entities/discount_group.js +11 -32
  60. package/lib/MerchiSDK/entities/domain.js +80 -101
  61. package/lib/MerchiSDK/entities/domain_invitation.js +14 -35
  62. package/lib/MerchiSDK/entities/domain_tag.js +15 -36
  63. package/lib/MerchiSDK/entities/draft.js +32 -65
  64. package/lib/MerchiSDK/entities/draft_comment.js +19 -40
  65. package/lib/MerchiSDK/entities/draft_template.js +15 -36
  66. package/lib/MerchiSDK/entities/email_address.js +10 -31
  67. package/lib/MerchiSDK/entities/email_counter.js +8 -29
  68. package/lib/MerchiSDK/entities/enrolled_domain.js +20 -44
  69. package/lib/MerchiSDK/entities/exchange_rate.js +9 -30
  70. package/lib/MerchiSDK/entities/file.js +59 -80
  71. package/lib/MerchiSDK/entities/internal_tag.js +17 -38
  72. package/lib/MerchiSDK/entities/inventory.js +19 -42
  73. package/lib/MerchiSDK/entities/inventory_unit_variation.js +12 -33
  74. package/lib/MerchiSDK/entities/invoice.js +57 -78
  75. package/lib/MerchiSDK/entities/item.js +18 -39
  76. package/lib/MerchiSDK/entities/job.js +117 -140
  77. package/lib/MerchiSDK/entities/job_comment.js +18 -39
  78. package/lib/MerchiSDK/entities/matching_inventory.js +11 -32
  79. package/lib/MerchiSDK/entities/menu.js +12 -33
  80. package/lib/MerchiSDK/entities/menu_item.js +12 -33
  81. package/lib/MerchiSDK/entities/notification.js +32 -53
  82. package/lib/MerchiSDK/entities/page.js +13 -34
  83. package/lib/MerchiSDK/entities/payment.js +25 -46
  84. package/lib/MerchiSDK/entities/payment_device.js +12 -33
  85. package/lib/MerchiSDK/entities/phone_number.js +14 -35
  86. package/lib/MerchiSDK/entities/product.js +153 -188
  87. package/lib/MerchiSDK/entities/production_comment.js +18 -39
  88. package/lib/MerchiSDK/entities/quote.js +70 -106
  89. package/lib/MerchiSDK/entities/quote_item.js +28 -49
  90. package/lib/MerchiSDK/entities/seo_domain_page.js +13 -34
  91. package/lib/MerchiSDK/entities/session.js +11 -32
  92. package/lib/MerchiSDK/entities/shipment.js +62 -83
  93. package/lib/MerchiSDK/entities/shipment_item.js +7 -28
  94. package/lib/MerchiSDK/entities/shipment_item_fulfillment.js +7 -28
  95. package/lib/MerchiSDK/entities/shipment_method.js +21 -42
  96. package/lib/MerchiSDK/entities/shipment_method_variation.js +15 -36
  97. package/lib/MerchiSDK/entities/short_url.js +14 -35
  98. package/lib/MerchiSDK/entities/subscription_plan.js +26 -47
  99. package/lib/MerchiSDK/entities/supply_domain.js +11 -32
  100. package/lib/MerchiSDK/entities/system_role.js +7 -28
  101. package/lib/MerchiSDK/entities/theme.js +89 -110
  102. package/lib/MerchiSDK/entities/theme_css_setting.js +10 -31
  103. package/lib/MerchiSDK/entities/user.js +151 -213
  104. package/lib/MerchiSDK/entities/user_company.js +11 -32
  105. package/lib/MerchiSDK/entities/variation.js +21 -42
  106. package/lib/MerchiSDK/entities/variation_field.js +61 -94
  107. package/lib/MerchiSDK/entities/variation_fields_option.js +40 -61
  108. package/lib/MerchiSDK/entities/variation_option.js +20 -41
  109. package/lib/MerchiSDK/entities/variations_group.js +15 -36
  110. package/lib/MerchiSDK/entity.js +534 -624
  111. package/lib/MerchiSDK/merchi.js +42 -53
  112. package/lib/MerchiSDK/request.js +47 -75
  113. package/lib/MerchiSDK/test_util.js +6 -10
  114. package/lib/MerchiSDK/toasts.js +12 -13
  115. package/lib/MerchiSDK/util/float.js +7 -19
  116. package/lib/MerchiSDK/util/query_string.js +4 -4
  117. package/lib/MerchiSDK/util/validation.js +2 -3
  118. package/lib/MerchiSDK/uuid.js +2 -2
  119. package/lib/buttons/Button.js +15 -15
  120. package/lib/buttons/ButtonBack.js +22 -25
  121. package/lib/buttons/ButtonClearCart.js +8 -9
  122. package/lib/buttons/ButtonInvoiceDownload.js +26 -61
  123. package/lib/buttons/ButtonNext.js +20 -25
  124. package/lib/buttons/ButtonNextDynamic.js +16 -18
  125. package/lib/buttons/ButtonPay.js +17 -13
  126. package/lib/buttons/ButtonShipmentTabNext.js +12 -13
  127. package/lib/buttons/index.js +13 -13
  128. package/lib/components/Alert.js +14 -12
  129. package/lib/components/CartBody.js +10 -8
  130. package/lib/components/CartClient.js +22 -17
  131. package/lib/components/CartFooter.js +9 -7
  132. package/lib/components/CartItemRow.js +58 -48
  133. package/lib/components/CartPaymentSettingsInvalid.js +3 -4
  134. package/lib/components/CartShipment.js +18 -13
  135. package/lib/components/CartTabContent.js +9 -7
  136. package/lib/components/CartTabPanel.js +15 -13
  137. package/lib/components/CartTableContainer.js +9 -7
  138. package/lib/components/Collapse.js +14 -22
  139. package/lib/components/LoadingTemplate.js +10 -7
  140. package/lib/components/NoCartItems.js +9 -9
  141. package/lib/components/ShipmentGroupCard.js +69 -52
  142. package/lib/components/Table.js +7 -4
  143. package/lib/components/Title.js +11 -9
  144. package/lib/components/containers.js +12 -11
  145. package/lib/components/index.js +30 -31
  146. package/lib/forms/FormNewCustomer.js +48 -76
  147. package/lib/forms/FormReturningCustomer.js +38 -58
  148. package/lib/forms/FormShipmentAddressAndNotes.js +42 -47
  149. package/lib/forms/FormSquarePayment.js +8 -9
  150. package/lib/forms/FormStripePayment.js +8 -9
  151. package/lib/forms/InputAcceptUserTermsAndConditions.js +12 -11
  152. package/lib/forms/InputError.js +11 -9
  153. package/lib/forms/InputSelect.js +34 -36
  154. package/lib/forms/InputText.js +38 -42
  155. package/lib/forms/InputsAddress.js +59 -69
  156. package/lib/index.js +6 -6
  157. package/lib/panels/PanelCartItems.js +14 -17
  158. package/lib/panels/PanelCartShipment.js +10 -13
  159. package/lib/panels/PanelClearCart.js +8 -7
  160. package/lib/panels/PanelClientCheckout.js +18 -17
  161. package/lib/panels/PanelEditCartItem.js +17 -22
  162. package/lib/panels/PanelPaymentSuccess.js +18 -16
  163. package/lib/panels/index.js +13 -13
  164. package/lib/slices/sliceCart.js +53 -56
  165. package/lib/slices/sliceCartAlert.js +11 -15
  166. package/lib/slices/sliceCartItem.js +11 -10
  167. package/lib/slices/sliceCartPayment.js +15 -16
  168. package/lib/slices/sliceCartShipment.js +23 -26
  169. package/lib/slices/sliceFormReturningCustomer.js +7 -7
  170. package/lib/slices/sliceNewCustomerForm.js +6 -6
  171. package/lib/square/SquareCard.js +16 -18
  172. package/lib/square/actions.js +24 -46
  173. package/lib/square/slices/reducersSquare.js +6 -6
  174. package/lib/square/slices/sliceSquareAlerts.js +10 -16
  175. package/lib/square/slices/sliceSquareForm.js +10 -9
  176. package/lib/store.js +359 -565
  177. package/lib/stripe/StripeCardFields.js +43 -44
  178. package/lib/stripe/StripeCardForm.js +51 -109
  179. package/lib/stripe/StripePaymentButtons.js +35 -46
  180. package/lib/stripe/actions.js +75 -196
  181. package/lib/stripe/slices/sliceStripeAlerts.js +10 -16
  182. package/lib/stripe/slices/sliceStripeCardForm.js +6 -6
  183. package/lib/stripe/slices/sliceStripeForm.js +18 -17
  184. package/lib/stripe/utils.js +1 -1
  185. package/lib/tabs/CartNav.js +15 -24
  186. package/lib/tabs/NavTab.js +20 -19
  187. package/lib/utilities/address.js +32 -30
  188. package/lib/utilities/cart.js +33 -50
  189. package/lib/utilities/cookie.js +46 -129
  190. package/lib/utilities/currency.js +29 -25
  191. package/lib/utilities/helpers.js +41 -60
  192. package/lib/utilities/invoice.js +45 -114
  193. package/lib/utilities/product.js +5 -3
  194. package/lib/utilities/user.js +24 -62
  195. package/lib/utilities/variations.js +16 -14
  196. package/package.json +1 -1
@@ -8,14 +8,14 @@ exports.addressInOneLine = addressInOneLine;
8
8
  exports.geoSuggestResultAsNewAddress = geoSuggestResultAsNewAddress;
9
9
  exports.makeAddress = makeAddress;
10
10
  var _merchi = require("../MerchiSDK/merchi");
11
- var merchi = new _merchi.Merchi();
11
+ const merchi = new _merchi.Merchi();
12
12
  function makeAddress(addressJson, makeDirty) {
13
- var address = new merchi.Address();
13
+ const address = new merchi.Address();
14
14
  return address.fromJson(addressJson, {
15
- makeDirty: makeDirty
15
+ makeDirty
16
16
  });
17
17
  }
18
- var isoCountries = {
18
+ const isoCountries = {
19
19
  AF: "Afghanistan",
20
20
  AX: "Aland Islands",
21
21
  AL: "Albania",
@@ -263,22 +263,24 @@ var isoCountries = {
263
263
  ZW: "Zimbabwe"
264
264
  };
265
265
  function addressInOneLine(address) {
266
- var a = address ? address : {};
267
- var city = a.city,
268
- country = a.country,
269
- lineOne = a.lineOne,
270
- lineTwo = a.lineTwo,
271
- postcode = a.postcode,
272
- state = a.state;
273
- var l1 = lineOne ? "".concat(lineOne, " ") : '';
274
- var l2 = lineTwo ? "".concat(lineTwo, " ") : '';
275
- var c = city ? "".concat(city, " ") : '';
276
- var s = state ? "".concat(state, " ") : '';
277
- var p = postcode ? "".concat(postcode, " ") : '';
278
- var countryFull = country ? isoCountries[country] : '';
266
+ const a = address ? address : {};
267
+ const {
268
+ city,
269
+ country,
270
+ lineOne,
271
+ lineTwo,
272
+ postcode,
273
+ state
274
+ } = a;
275
+ const l1 = lineOne ? `${lineOne} ` : '';
276
+ const l2 = lineTwo ? `${lineTwo} ` : '';
277
+ const c = city ? `${city} ` : '';
278
+ const s = state ? `${state} ` : '';
279
+ const p = postcode ? `${postcode} ` : '';
280
+ const countryFull = country ? isoCountries[country] : '';
279
281
  return l1 + l2 + c + s + p + countryFull;
280
282
  }
281
- var addressComponentsSettings = exports.addressComponentsSettings = {
283
+ const addressComponentsSettings = exports.addressComponentsSettings = {
282
284
  administrative_area_level_1: 'short_name',
283
285
  administrative_area_level_2: 'short_name',
284
286
  country: 'short_name',
@@ -294,9 +296,9 @@ var addressComponentsSettings = exports.addressComponentsSettings = {
294
296
  subpremise: 'short_name'
295
297
  };
296
298
  function geoSuggestResultAsNewAddress(resp) {
297
- var addressComponents = resp && resp.gmaps ? resp.gmaps.address_components : null;
298
- var name = resp && resp.gmaps && resp.gmaps.name;
299
- var address = {
299
+ const addressComponents = resp && resp.gmaps ? resp.gmaps.address_components : null;
300
+ const name = resp && resp.gmaps && resp.gmaps.name;
301
+ const address = {
300
302
  city: '',
301
303
  country: '',
302
304
  lineOne: name ? name : '',
@@ -304,15 +306,15 @@ function geoSuggestResultAsNewAddress(resp) {
304
306
  postcode: '',
305
307
  state: ''
306
308
  };
307
- var i;
309
+ let i;
308
310
  if (addressComponents) {
309
311
  for (i = 0; i < addressComponents.length; i++) {
310
- var addrComponent = addressComponents[i];
311
- var addrTypes = addrComponent.types;
312
- var addrType = addrTypes.length > 0 ? addrTypes[0] : null;
313
- var componentSetting = addrType ? addressComponentsSettings[addrType] : null;
312
+ const addrComponent = addressComponents[i];
313
+ const addrTypes = addrComponent.types;
314
+ const addrType = addrTypes.length > 0 ? addrTypes[0] : null;
315
+ const componentSetting = addrType ? addressComponentsSettings[addrType] : null;
314
316
  if (componentSetting) {
315
- var addressVal = addrComponent[componentSetting];
317
+ const addressVal = addrComponent[componentSetting];
316
318
  switch (addrType) {
317
319
  case 'establishment':
318
320
  case 'room':
@@ -321,12 +323,12 @@ function geoSuggestResultAsNewAddress(resp) {
321
323
  case 'premise':
322
324
  case 'subpremise':
323
325
  case 'route':
324
- var oldLineOne = address.lineOne;
325
- address.lineOne = oldLineOne.includes(addressVal) ? oldLineOne : "".concat(oldLineOne, " ").concat(addressVal);
326
+ const oldLineOne = address.lineOne;
327
+ address.lineOne = oldLineOne.includes(addressVal) ? oldLineOne : `${oldLineOne} ${addressVal}`;
326
328
  break;
327
329
  case 'locality':
328
330
  case 'sublocality':
329
- var oldCity = address.city ? "".concat(address.city, " ") : '';
331
+ const oldCity = address.city ? `${address.city} ` : '';
330
332
  address.city = oldCity + addressVal;
331
333
  break;
332
334
  case 'administrative_area_level_1':
@@ -12,88 +12,71 @@ exports.makeCartShipmentQuote = makeCartShipmentQuote;
12
12
  exports.stripeIsValidAndActive = stripeIsValidAndActive;
13
13
  var _merchi = require("../MerchiSDK/merchi");
14
14
  var _company = require("./company");
15
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; 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; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; 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); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { 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); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; 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; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
17
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
18
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
19
- var merchi = new _merchi.Merchi();
20
- var makeCart = exports.makeCart = function makeCart(json, makeDirty, cartToken) {
21
- var merchi = new _merchi.Merchi();
15
+ const merchi = new _merchi.Merchi();
16
+ const makeCart = (json, makeDirty, cartToken) => {
17
+ const merchi = new _merchi.Merchi();
22
18
  if (cartToken) merchi.cartToken = cartToken;
23
- var cart = new merchi.Cart();
19
+ const cart = new merchi.Cart();
24
20
  return cart.fromJson(json, {
25
- makeDirty: makeDirty
21
+ makeDirty
26
22
  });
27
23
  };
28
- var makeCartItem = exports.makeCartItem = function makeCartItem(json, makeDirty, cartToken) {
29
- var merchi = new _merchi.Merchi();
24
+ exports.makeCart = makeCart;
25
+ const makeCartItem = (json, makeDirty, cartToken) => {
26
+ const merchi = new _merchi.Merchi();
30
27
  if (cartToken) merchi.cartToken = cartToken;
31
- var cartItem = new merchi.CartItem();
28
+ const cartItem = new merchi.CartItem();
32
29
  return cartItem.fromJson(json, {
33
- makeDirty: makeDirty
30
+ makeDirty
34
31
  });
35
32
  };
33
+ exports.makeCartItem = makeCartItem;
36
34
  function makeCartShipmentQuote(json, makeDirty) {
37
- var cartShipmentQuote = new merchi.CartShipmentQuote();
35
+ const cartShipmentQuote = new merchi.CartShipmentQuote();
38
36
  return cartShipmentQuote.fromJson(json, {
39
- makeDirty: makeDirty
37
+ makeDirty
40
38
  });
41
39
  }
42
40
  function cartHasSelectedQuotes(cart) {
43
- var _cart$shipmentGroups = cart.shipmentGroups,
44
- shipmentGroups = _cart$shipmentGroups === void 0 ? [] : _cart$shipmentGroups;
41
+ const {
42
+ shipmentGroups = []
43
+ } = cart;
45
44
  if (shipmentGroups.length) {
46
- var selected = shipmentGroups.filter(function (g) {
47
- return !!g.selectedQuote;
48
- });
45
+ const selected = shipmentGroups.filter(g => !!g.selectedQuote);
49
46
  return selected.length === shipmentGroups.length;
50
47
  }
51
48
  return false;
52
49
  }
53
- function getCartShipmentGroupsAndQuotes(_x) {
54
- return _getCartShipmentGroupsAndQuotes.apply(this, arguments);
55
- }
56
- function _getCartShipmentGroupsAndQuotes() {
57
- _getCartShipmentGroupsAndQuotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cart) {
58
- var query;
59
- return _regeneratorRuntime().wrap(function _callee$(_context) {
60
- while (1) switch (_context.prev = _context.next) {
61
- case 0:
62
- query = [];
63
- query.push(['cart_token', cart.token]);
64
- return _context.abrupt("return", merchi.authenticatedFetch("/generate-cart-shipment-quotes/".concat(cart.id, "/"), {
65
- method: 'GET',
66
- query: query
67
- }));
68
- case 3:
69
- case "end":
70
- return _context.stop();
71
- }
72
- }, _callee);
73
- }));
74
- return _getCartShipmentGroupsAndQuotes.apply(this, arguments);
50
+ async function getCartShipmentGroupsAndQuotes(cart) {
51
+ const query = [];
52
+ query.push(['cart_token', cart.token]);
53
+ return merchi.authenticatedFetch(`/generate-cart-shipment-quotes/${cart.id}/`, {
54
+ method: 'GET',
55
+ query
56
+ });
75
57
  }
76
58
  function cartCompany(cart) {
77
59
  return cart && cart.domain && cart.domain.company ? cart.domain.company : null;
78
60
  }
79
61
  function hasStripeLegacyAccount(cart) {
80
- var company = cartCompany(cart);
62
+ const company = cartCompany(cart);
81
63
  return Boolean(company && (0, _company.companyStripePubKeyOrTestPubKey)(company));
82
64
  }
83
65
  function hasStripeConnectAccount(cart) {
84
- var company = cartCompany(cart);
66
+ const company = cartCompany(cart);
85
67
  return Boolean(company && company.isStripeAccountEnabled);
86
68
  }
87
69
  function stripeIsValidAndActive(cart) {
88
- var company = cartCompany(cart);
89
- var hasStripe = hasStripeLegacyAccount(cart) || hasStripeConnectAccount(cart);
70
+ const company = cartCompany(cart);
71
+ const hasStripe = hasStripeLegacyAccount(cart) || hasStripeConnectAccount(cart);
90
72
  return Boolean(hasStripe && company && company.acceptStripe);
91
73
  }
92
74
  function cartRequiresShipment(cart) {
93
- var _cart$cartItems = cart.cartItems,
94
- cartItems = _cart$cartItems === void 0 ? [] : _cart$cartItems;
95
- for (var i = 0; i < cartItems.length; i++) {
96
- var item = cartItems[i];
75
+ const {
76
+ cartItems = []
77
+ } = cart;
78
+ for (let i = 0; i < cartItems.length; i++) {
79
+ const item = cartItems[i];
97
80
  if (item && item.product && item.product.needsShipping) {
98
81
  return true;
99
82
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -9,134 +8,52 @@ exports.getCookie = getCookie;
9
8
  exports.setCartCookie = void 0;
10
9
  var _lodash = require("lodash");
11
10
  var _browserOrNode = require("browser-or-node");
12
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; 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; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; 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); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { 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); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; 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; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
13
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
- function getCookie(_x, _x2) {
16
- return _getCookie.apply(this, arguments);
11
+ async function getCookie(name, defaultValue) {
12
+ if (!_browserOrNode.isBrowser) {
13
+ return '';
14
+ }
15
+ const searchPrefix = name + '=';
16
+ const cookies = document.cookie.split(';');
17
+ let i;
18
+ let cookie;
19
+ for (i = 0; i < cookies.length; ++i) {
20
+ cookie = cookies[i];
21
+ cookie = cookie.replace(/^\s*/, '');
22
+ if (cookie.indexOf(searchPrefix) === 0) {
23
+ return cookie.substring(searchPrefix.length, cookie.length);
24
+ }
25
+ }
26
+ if ((0, _lodash.isUndefined)(defaultValue)) {
27
+ throw 'no such cookie present';
28
+ } else {
29
+ return defaultValue;
30
+ }
17
31
  }
18
- function _getCookie() {
19
- _getCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name, defaultValue) {
20
- var searchPrefix, cookies, i, cookie;
21
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
22
- while (1) switch (_context2.prev = _context2.next) {
23
- case 0:
24
- if (_browserOrNode.isBrowser) {
25
- _context2.next = 2;
26
- break;
27
- }
28
- return _context2.abrupt("return", '');
29
- case 2:
30
- searchPrefix = name + '=';
31
- cookies = document.cookie.split(';');
32
- i = 0;
33
- case 5:
34
- if (!(i < cookies.length)) {
35
- _context2.next = 13;
36
- break;
37
- }
38
- cookie = cookies[i];
39
- cookie = cookie.replace(/^\s*/, '');
40
- if (!(cookie.indexOf(searchPrefix) === 0)) {
41
- _context2.next = 10;
42
- break;
43
- }
44
- return _context2.abrupt("return", cookie.substring(searchPrefix.length, cookie.length));
45
- case 10:
46
- ++i;
47
- _context2.next = 5;
48
- break;
49
- case 13:
50
- if (!(0, _lodash.isUndefined)(defaultValue)) {
51
- _context2.next = 17;
52
- break;
53
- }
54
- throw 'no such cookie present';
55
- case 17:
56
- return _context2.abrupt("return", defaultValue);
57
- case 18:
58
- case "end":
59
- return _context2.stop();
60
- }
61
- }, _callee2);
62
- }));
63
- return _getCookie.apply(this, arguments);
32
+ async function getCartCookie(domainId) {
33
+ const idAndToken = await getCookie(`cart-${domainId}`, null);
34
+ return idAndToken ? idAndToken.split(',') : null;
64
35
  }
65
- function getCartCookie(_x3) {
66
- return _getCartCookie.apply(this, arguments);
36
+ async function setSessionCookie(name, value, domain) {
37
+ if (!_browserOrNode.isBrowser) {
38
+ return;
39
+ }
40
+ let cookie = name + '=' + value;
41
+ if (!!domain) {
42
+ // remove port, if it exists
43
+ let n = domain.indexOf(':');
44
+ domain = domain.substring(0, n != -1 ? n : domain.length);
45
+ // remove trailing slash and path, if they exists
46
+ n = domain.indexOf('/');
47
+ domain = domain.substring(0, n != -1 ? n : domain.length);
48
+ cookie += '; Domain=' + domain;
49
+ } else {
50
+ cookie += '; Domain=' + '.' + location.hostname;
51
+ }
52
+ cookie += '; path=/';
53
+ document.cookie = cookie;
67
54
  }
68
- function _getCartCookie() {
69
- _getCartCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(domainId) {
70
- var idAndToken;
71
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72
- while (1) switch (_context3.prev = _context3.next) {
73
- case 0:
74
- _context3.next = 2;
75
- return getCookie("cart-".concat(domainId), null);
76
- case 2:
77
- idAndToken = _context3.sent;
78
- return _context3.abrupt("return", idAndToken ? idAndToken.split(',') : null);
79
- case 4:
80
- case "end":
81
- return _context3.stop();
82
- }
83
- }, _callee3);
84
- }));
85
- return _getCartCookie.apply(this, arguments);
86
- }
87
- function setSessionCookie(_x4, _x5, _x6) {
88
- return _setSessionCookie.apply(this, arguments);
89
- }
90
- function _setSessionCookie() {
91
- _setSessionCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(name, value, domain) {
92
- var cookie, n;
93
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
94
- while (1) switch (_context4.prev = _context4.next) {
95
- case 0:
96
- if (_browserOrNode.isBrowser) {
97
- _context4.next = 2;
98
- break;
99
- }
100
- return _context4.abrupt("return");
101
- case 2:
102
- cookie = name + '=' + value;
103
- if (!!domain) {
104
- // remove port, if it exists
105
- n = domain.indexOf(':');
106
- domain = domain.substring(0, n != -1 ? n : domain.length);
107
- // remove trailing slash and path, if they exists
108
- n = domain.indexOf('/');
109
- domain = domain.substring(0, n != -1 ? n : domain.length);
110
- cookie += '; Domain=' + domain;
111
- } else {
112
- cookie += '; Domain=' + '.' + location.hostname;
113
- }
114
- cookie += '; path=/';
115
- document.cookie = cookie;
116
- case 6:
117
- case "end":
118
- return _context4.stop();
119
- }
120
- }, _callee4);
121
- }));
122
- return _setSessionCookie.apply(this, arguments);
123
- }
124
- var setCartCookie = exports.setCartCookie = /*#__PURE__*/function () {
125
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(storeId, cart, domain) {
126
- var cookieValue;
127
- return _regeneratorRuntime().wrap(function _callee$(_context) {
128
- while (1) switch (_context.prev = _context.next) {
129
- case 0:
130
- cookieValue = cart ? cart.id + ',' + cart.token : '';
131
- _context.next = 3;
132
- return setSessionCookie('cart-' + String(storeId), cookieValue, domain);
133
- case 3:
134
- case "end":
135
- return _context.stop();
136
- }
137
- }, _callee);
138
- }));
139
- return function setCartCookie(_x7, _x8, _x9) {
140
- return _ref.apply(this, arguments);
141
- };
142
- }();
55
+ const setCartCookie = async (storeId, cart, domain) => {
56
+ const cookieValue = cart ? cart.id + ',' + cart.token : '';
57
+ await setSessionCookie('cart-' + String(storeId), cookieValue, domain);
58
+ };
59
+ exports.setCartCookie = setCartCookie;
@@ -8,7 +8,7 @@ exports.cartItemCurrencyAndCost = cartItemCurrencyAndCost;
8
8
  exports.currencyMap = void 0;
9
9
  exports.currencyTaxAndCost = currencyTaxAndCost;
10
10
  exports.formatCurrency = formatCurrency;
11
- var currencyMap = exports.currencyMap = {
11
+ const currencyMap = exports.currencyMap = {
12
12
  ALL: 'L',
13
13
  AFN: '؋',
14
14
  ARS: '$',
@@ -137,9 +137,9 @@ function formatCurrency(amount, options) {
137
137
  --> '(£222.123)'
138
138
  */
139
139
 
140
- var symbol;
141
- var negative = false;
142
- var result;
140
+ let symbol;
141
+ let negative = false;
142
+ let result;
143
143
  options = options || {};
144
144
  options.currency = options.currency || 'AUD';
145
145
  options.showCodeIfNoSymbol = options.showCodeIfNoSymbol || true;
@@ -161,7 +161,7 @@ function formatCurrency(amount, options) {
161
161
  symbol += '(' + options.currency + ') ';
162
162
  }
163
163
  if (options.codeBeforeSymbol) {
164
- symbol = "(".concat(options.currency, ") ").concat(symbol);
164
+ symbol = `(${options.currency}) ${symbol}`;
165
165
  }
166
166
  } else if (options.showCodeIfNoSymbol) {
167
167
  symbol = options.currency;
@@ -185,45 +185,49 @@ function formatCurrency(amount, options) {
185
185
  }
186
186
  if (negative) {
187
187
  if (options.financialNegative) {
188
- result = "(".concat(result, ")");
188
+ result = `(${result})`;
189
189
  } else {
190
- result = "-".concat(result);
190
+ result = `-${result}`;
191
191
  }
192
192
  }
193
193
  if (options.codeAfterAmount === true) {
194
- result += " (".concat(options.currency, ")");
194
+ result += ` (${options.currency})`;
195
195
  }
196
196
  return result;
197
197
  }
198
198
  function formatCountryTax(countryTax) {
199
- var taxName = countryTax.taxName,
200
- taxPercent = countryTax.taxPercent;
201
- return taxPercent > 0 ? " inc ".concat(taxName, " (").concat(taxPercent, "%)") : '';
199
+ const {
200
+ taxName,
201
+ taxPercent
202
+ } = countryTax;
203
+ return taxPercent > 0 ? ` inc ${taxName} (${taxPercent}%)` : '';
202
204
  }
203
205
  function calculateTotalWithTax(total, tax) {
204
- var taxMultiplier = 1.0;
206
+ let taxMultiplier = 1.0;
205
207
  if (tax && tax.taxPercent() > 0) {
206
208
  taxMultiplier += tax.taxPercent() / 100;
207
209
  taxMultiplier = parseFloat(taxMultiplier.toFixed(2));
208
210
  }
209
- var grandTotal = total * taxMultiplier;
211
+ let grandTotal = total * taxMultiplier;
210
212
  return parseFloat(grandTotal.toFixed(2));
211
213
  }
212
214
  function cartItemCurrencyAndCost(cartItem) {
213
- var currency = cartItem.currency,
214
- subtotalCost = cartItem.subtotalCost,
215
- taxType = cartItem.taxType;
216
- var tax = taxType ? formatCountryTax(taxType) : '';
217
- return "".concat(currency, " ").concat(formatCurrency(subtotalCost, {
218
- currency: currency,
215
+ const {
216
+ currency,
217
+ subtotalCost,
218
+ taxType
219
+ } = cartItem;
220
+ const tax = taxType ? formatCountryTax(taxType) : '';
221
+ return `${currency} ${formatCurrency(subtotalCost, {
222
+ currency,
219
223
  showCodeIfNoSymbol: false
220
- }), " ").concat(tax);
224
+ })} ${tax}`;
221
225
  }
222
226
  function currencyTaxAndCost(currency, tax, theCost) {
223
- var totalCost = calculateTotalWithTax(theCost, tax);
224
- var _tax = tax ? formatCountryTax(tax) : '';
225
- return "".concat(currency, " ").concat(formatCurrency(totalCost, {
226
- currency: currency,
227
+ const totalCost = calculateTotalWithTax(theCost, tax);
228
+ const _tax = tax ? formatCountryTax(tax) : '';
229
+ return `${currency} ${formatCurrency(totalCost, {
230
+ currency,
227
231
  showCodeIfNoSymbol: false
228
- }), " ").concat(_tax);
232
+ })} ${_tax}`;
229
233
  }