@zonos/elements 1.3.175 → 1.3.176

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 (105) hide show
  1. package/dist/cjs/CheckoutConfig-f1442a60.js +35 -0
  2. package/dist/cjs/{cart-93ed3002.js → cart-e648a65f.js} +11 -5
  3. package/dist/cjs/index.cjs.js +67 -12
  4. package/dist/cjs/{paypal-8b49ef07.js → paypal-2390cfb2.js} +1 -1
  5. package/dist/cjs/zonos-address_7.cjs.entry.js +1 -1
  6. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +2 -2
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +57 -4
  8. package/dist/cjs/zonos-controller.cjs.entry.js +8 -1
  9. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +2 -2
  12. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  15. package/dist/collection/components/utils/api/getShippingZones.js +8 -3
  16. package/dist/collection/components/utils/api/getZonosSettings.js +7 -0
  17. package/dist/collection/components/utils/api/trackConversionEvent.js +5 -2
  18. package/dist/collection/scripts/_getCartInfoById.js +29 -0
  19. package/dist/collection/scripts/_zonosBase.js +8 -5
  20. package/dist/collection/scripts/cart/_setupCartDataWithSettings.js +28 -0
  21. package/dist/collection/types/generated/graphql.internal.types.js +3 -0
  22. package/dist/esm/CheckoutConfig-5479d192.js +31 -0
  23. package/dist/esm/{cart-54d84646.js → cart-dc171e7f.js} +12 -6
  24. package/dist/esm/index.js +68 -13
  25. package/dist/esm/{paypal-17a320c8.js → paypal-1beec534.js} +1 -1
  26. package/dist/esm/zonos-address_7.entry.js +1 -1
  27. package/dist/esm/zonos-cart-items_13.entry.js +2 -2
  28. package/dist/esm/zonos-checkout.entry.js +56 -3
  29. package/dist/esm/zonos-controller.entry.js +8 -1
  30. package/dist/esm/zonos-country-flag.entry.js +1 -1
  31. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  32. package/dist/esm/zonos-empty-state-payment_4.entry.js +2 -2
  33. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  34. package/dist/esm/zonos-hello.entry.js +1 -1
  35. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  36. package/dist/esm-es5/CheckoutConfig-5479d192.js +1 -0
  37. package/dist/esm-es5/cart-dc171e7f.js +1 -0
  38. package/dist/esm-es5/index.js +1 -1
  39. package/dist/esm-es5/{paypal-17a320c8.js → paypal-1beec534.js} +1 -1
  40. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  41. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  42. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  43. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  44. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  45. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  46. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  47. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  48. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  49. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  50. package/dist/scripts/index.d.ts +199 -0
  51. package/dist/scripts/index.js +1 -1
  52. package/dist/scripts/loadZonos.js +1 -1
  53. package/dist/scripts/zonos.js +1 -1
  54. package/dist/types/scripts/_getCartInfoById.d.ts +7 -0
  55. package/dist/types/scripts/_zonosBase.d.ts +11 -1
  56. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +166 -0
  57. package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +20 -1
  58. package/dist/types/types/generated/graphql.internal.types.d.ts +155 -0
  59. package/dist/types/types/generated/graphql.internal.types.ts +159 -0
  60. package/dist/types/types/utils/ZonosSettings.d.ts +1 -1
  61. package/dist/zonos-elements/index.esm.js +1 -1
  62. package/dist/zonos-elements/p-007a4d24.entry.js +1 -0
  63. package/dist/zonos-elements/{p-9f8b820e.system.entry.js → p-08fa3875.system.entry.js} +1 -1
  64. package/dist/zonos-elements/{p-3d169241.system.entry.js → p-0a6aa4cf.system.entry.js} +1 -1
  65. package/dist/zonos-elements/{p-d9779ea7.entry.js → p-0ef83bec.entry.js} +1 -1
  66. package/dist/zonos-elements/{p-ed8a8a44.entry.js → p-117eb67d.entry.js} +1 -1
  67. package/dist/zonos-elements/{p-28dcd7bb.entry.js → p-24d4f2ec.entry.js} +1 -1
  68. package/dist/zonos-elements/{p-d22c15be.entry.js → p-30ff0a71.entry.js} +1 -1
  69. package/dist/zonos-elements/p-35bfc9d1.system.entry.js +1 -0
  70. package/dist/zonos-elements/p-40e5359c.system.js +1 -0
  71. package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
  72. package/dist/zonos-elements/p-5372fed8.system.js +1 -0
  73. package/dist/zonos-elements/{p-c67f6666.system.entry.js → p-60ab9c4c.system.entry.js} +1 -1
  74. package/dist/zonos-elements/p-655bc743.system.entry.js +1 -0
  75. package/dist/zonos-elements/{p-6612e6f9.system.entry.js → p-6ef7451f.system.entry.js} +1 -1
  76. package/dist/zonos-elements/{p-e11eecbf.system.entry.js → p-7dd0d6b4.system.entry.js} +1 -1
  77. package/dist/zonos-elements/p-80dd3fb6.entry.js +1 -0
  78. package/dist/zonos-elements/p-8ee34712.system.js +1 -0
  79. package/dist/zonos-elements/{p-d98fa14c.system.entry.js → p-a334b6d8.system.entry.js} +1 -1
  80. package/dist/zonos-elements/{p-c444f997.system.entry.js → p-a7d2a768.system.entry.js} +1 -1
  81. package/dist/zonos-elements/{p-78a95cee.entry.js → p-aa651c8f.entry.js} +1 -1
  82. package/dist/zonos-elements/{p-8e436df2.system.entry.js → p-bdf93de1.system.entry.js} +1 -1
  83. package/dist/zonos-elements/{p-f80f24a0.js → p-d53968eb.js} +2 -2
  84. package/dist/zonos-elements/p-e3f9a12b.js +1 -0
  85. package/dist/zonos-elements/{p-0ee9b22a.entry.js → p-e9f8edbb.entry.js} +1 -1
  86. package/dist/zonos-elements/{p-8964d8f8.system.js → p-ef7d14a3.system.js} +1 -1
  87. package/dist/zonos-elements/p-f4d9f007.entry.js +1 -0
  88. package/dist/zonos-elements/{p-a450910c.entry.js → p-f4eaf289.entry.js} +1 -1
  89. package/dist/zonos-elements/p-fe253cc1.js +1 -0
  90. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  91. package/package.json +1 -1
  92. package/dist/cjs/CheckoutConfig-fb59baa3.js +0 -90
  93. package/dist/esm/CheckoutConfig-63b3ed06.js +0 -86
  94. package/dist/esm-es5/CheckoutConfig-63b3ed06.js +0 -1
  95. package/dist/esm-es5/cart-54d84646.js +0 -1
  96. package/dist/zonos-elements/p-19ac0f84.system.entry.js +0 -1
  97. package/dist/zonos-elements/p-416ac901.entry.js +0 -1
  98. package/dist/zonos-elements/p-4a87a92c.entry.js +0 -1
  99. package/dist/zonos-elements/p-75b771cf.js +0 -1
  100. package/dist/zonos-elements/p-84dd312c.system.js +0 -1
  101. package/dist/zonos-elements/p-869bbedc.js +0 -1
  102. package/dist/zonos-elements/p-b86b82eb.entry.js +0 -1
  103. package/dist/zonos-elements/p-c10f4e56.system.js +0 -1
  104. package/dist/zonos-elements/p-d74ab632.system.entry.js +0 -1
  105. package/dist/zonos-elements/p-e0d3aeae.system.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { c as createStore, z as zonosStore } from './zonosStore-d3c5a0a5.js';
2
- import { h as handleFetch, b as logError, l as log, f as fallbackApiList, s as sendErrorLog, d as allLogs, j as jsonParse, a as getIsStagingMode } from './handleFetch-621e45bc.js';
2
+ import { h as handleFetch, b as logError, l as log, f as fallbackApiList, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, d as allLogs, j as jsonParse } from './handleFetch-621e45bc.js';
3
3
  import { i as isDarkColor } from './isDarkColor-446fccb7.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-ada3ccad.js';
5
5
 
@@ -9896,13 +9896,18 @@ const getLocalization = async () => {
9896
9896
  };
9897
9897
 
9898
9898
  const getShippingZones = async () => {
9899
- var _a, _b;
9899
+ var _a, _b, _c;
9900
+ if ((_a = window.Zonos.cartSettings) === null || _a === void 0 ? void 0 : _a.shippingZones) {
9901
+ return window.Zonos.cartSettings.shippingZones
9902
+ .flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes)
9903
+ .filter(Boolean);
9904
+ }
9900
9905
  const { errors, json } = await handleFetch('/api/zonos-elements/shipping-zones');
9901
9906
  if (errors.length || !json) {
9902
- logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
9907
+ logError(`Error fetching shipping zones: ${(_b = errors.find(Boolean)) === null || _b === void 0 ? void 0 : _b.message}`);
9903
9908
  return null;
9904
9909
  }
9905
- const shippingZones = (_b = json === null || json === void 0 ? void 0 : json.shippingZones) === null || _b === void 0 ? void 0 : _b.flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes).filter(Boolean);
9910
+ const shippingZones = (_c = json === null || json === void 0 ? void 0 : json.shippingZones) === null || _c === void 0 ? void 0 : _c.flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes).filter(Boolean);
9906
9911
  return shippingZones || null;
9907
9912
  };
9908
9913
 
@@ -10692,8 +10697,9 @@ const trackConversionEvent = async (eventName, metadata) => {
10692
10697
  const isDevelopment = window.location.href.includes('zonos.com') ||
10693
10698
  !!((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.zonosQaUrl) ||
10694
10699
  !!((_b = window.Zonos) === null || _b === void 0 ? void 0 : _b.debug);
10695
- if (isDevelopment &&
10696
- // if found, it means we want to test the conversion event in development site
10700
+ const isTest = getIsTestMode() || getIsStagingMode();
10701
+ if ((isTest || isDevelopment) &&
10702
+ // if found, it means we want to test the conversion event in development site, or test mode and staging mode
10697
10703
  !window.Zonos.zonosConversionTest) {
10698
10704
  return;
10699
10705
  }
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { g as getIsTestMode, a as getIsStagingMode, l as log, h as handleFetch, b as logError } from './handleFetch-621e45bc.js';
2
- import { s as setupCartData, c as checkoutHiddenBtnSelector } from './CheckoutConfig-63b3ed06.js';
3
- export { c as checkoutHiddenBtnSelector, d as domesticRedirectedBtnSelector } from './CheckoutConfig-63b3ed06.js';
2
+ import { _ as _getIsValidCartId, c as checkoutHiddenBtnSelector } from './CheckoutConfig-5479d192.js';
3
+ export { c as checkoutHiddenBtnSelector, d as domesticRedirectedBtnSelector } from './CheckoutConfig-5479d192.js';
4
4
  export { c as countryRequireTaxId, s as shipToTaxIdLabels } from './TaxId-915ef042.js';
5
5
 
6
6
  /**
@@ -126,7 +126,7 @@ const getZonosQaUrl = () => {
126
126
  return null;
127
127
  }
128
128
  const qaUrl = extractZonosQaUrl(window.location.href);
129
- const cdnUrl = "https://v1.3.175.js.zonos.com";
129
+ const cdnUrl = "https://v1.3.176.js.zonos.com";
130
130
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
131
131
  if (!qaUrl &&
132
132
  (cdnUrl.includes('test.') ||
@@ -293,6 +293,58 @@ const getCartIdFromQueryParam = () => {
293
293
  return cartId;
294
294
  };
295
295
 
296
+ const getCartInfoById = async ({ cartId, retries, }) => {
297
+ const isTestMode = getIsTestMode();
298
+ const { errors, json, zonosMode } = await handleFetch('/api/zonos-elements/get-cart', {
299
+ body: {
300
+ isTestMode,
301
+ tempCartUUID: cartId,
302
+ },
303
+ headers: {
304
+ 'Content-Type': 'application/json',
305
+ },
306
+ method: 'POST',
307
+ });
308
+ const failedResponse = !json || errors.length;
309
+ if (failedResponse && retries) {
310
+ log('[ZONOS - loadZonos] temp cart not ready, retrying in 1 second', 'info', {
311
+ retries,
312
+ });
313
+ // wait 1 second before retrying
314
+ await new Promise(resolve => setTimeout(resolve, 500));
315
+ return getCartInfoById({ cartId, retries: retries - 1 });
316
+ }
317
+ if (failedResponse) {
318
+ return null;
319
+ }
320
+ return Object.assign(Object.assign({}, json), { zonosMode });
321
+ };
322
+
323
+ const setupCartDataWithSettings = async (cartId) => {
324
+ const { isDgsCartId, isLegacyCartId } = _getIsValidCartId(cartId);
325
+ if (!isLegacyCartId && !isDgsCartId) {
326
+ logError('[ZONOS - loadZonos] invalid cart id');
327
+ return null;
328
+ }
329
+ const tempCartResult = await getCartInfoById({ cartId, retries: 5 });
330
+ log('[ZONOS - loadZonos] getting temp cart data', 'info', tempCartResult);
331
+ if (!tempCartResult) {
332
+ logError('[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.');
333
+ return null;
334
+ }
335
+ window.Zonos.storeId = tempCartResult.cartData.storeId;
336
+ window.Zonos.zonosApiKey = tempCartResult.cartData.credentialToken;
337
+ window.Zonos.zonosMode = tempCartResult.zonosMode;
338
+ return {
339
+ cartData: tempCartResult.cartData,
340
+ settings: tempCartResult.settings,
341
+ storeFavicon: tempCartResult.storeFaviconUrl,
342
+ storeId: tempCartResult.cartData.storeId,
343
+ storeLogo: tempCartResult.storeLogoUrl,
344
+ zonosApiKey: tempCartResult.cartData.credentialToken,
345
+ };
346
+ };
347
+
296
348
  var _a;
297
349
  /**
298
350
  * Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
@@ -310,16 +362,17 @@ const zonosLoadUrl = (() => {
310
362
  }
311
363
  return null;
312
364
  })();
313
- const ZONOS_URL = "https://v1.3.175.js.zonos.com";
314
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.175";
315
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.175";
316
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.175";
365
+ const ZONOS_URL = "https://v1.3.176.js.zonos.com";
366
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.176";
367
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.176";
368
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.176";
317
369
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
318
370
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
319
371
  class Zonos {
320
372
  }
321
373
  _a = Zonos;
322
374
  Zonos.doneInit = false;
375
+ Zonos.cartSettings = null;
323
376
  // if query 'zonosDebug=1' param from url, debug mode is on
324
377
  Zonos.debug = typeof window !== 'undefined' &&
325
378
  !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
@@ -327,7 +380,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
327
380
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
328
381
  Zonos._paypalMockResponse = null;
329
382
  Zonos.isBigCommerce = false;
330
- Zonos.releaseDate = "1742933949936";
383
+ Zonos.releaseDate = "1743432435915";
331
384
  Zonos.isLegacyCheckout = false;
332
385
  Zonos.domain = typeof window !== 'undefined'
333
386
  ? // domain that embeds the iframe
@@ -343,10 +396,11 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
343
396
  Zonos.isNpm = true;
344
397
  Zonos.zonosQaUrl = null;
345
398
  Zonos.zonosQaUrlApi = null;
346
- Zonos.version = `v${"1.3.175"}`;
399
+ Zonos.version = `v${"1.3.176"}`;
347
400
  Zonos.modeAlerted = false;
348
401
  Zonos.cartData = null;
349
402
  Zonos.paypal = null;
403
+ Zonos.zonosMode = null;
350
404
  Zonos.getCurrentTimestamp = () => new Date().getTime();
351
405
  Zonos.zonosController = null;
352
406
  Zonos.loadTimeApiInfoList = [];
@@ -396,13 +450,14 @@ Zonos.init = async (params) => {
396
450
  */
397
451
  if (!_a.cartData && _a.cartId) {
398
452
  log('Initialize cart data');
399
- const cartinfo = await setupCartData(_a.cartId);
400
- if (!cartinfo) {
453
+ const cartInfo = await setupCartDataWithSettings(_a.cartId);
454
+ if (!cartInfo) {
401
455
  logError('Failed to get cart data');
402
456
  return;
403
457
  }
404
- _a.cartData = cartinfo.cartData;
405
- _a.zonosApiKey = cartinfo.zonosApiKey;
458
+ _a.cartData = cartInfo.cartData;
459
+ _a.zonosApiKey = cartInfo.zonosApiKey;
460
+ _a.cartSettings = cartInfo.settings;
406
461
  }
407
462
  // Try to request for test API key if the API key is production but query param isTestMode is provided
408
463
  const testPublicCredential = await getWithTestPublicCredential();
@@ -1,5 +1,5 @@
1
1
  import { z as zonosStore, c as createStore } from './zonosStore-d3c5a0a5.js';
2
- import { t as trackConversionEvent, F as validateCheckoutSession, f as stripeStore, e as cartStore, z as stripeStoreHandleInventoryCheck, r as translate, x as cartStoreNextStep, k as cartStoreClearCheckoutInterval } from './cart-54d84646.js';
2
+ import { t as trackConversionEvent, F as validateCheckoutSession, f as stripeStore, e as cartStore, z as stripeStoreHandleInventoryCheck, r as translate, x as cartStoreNextStep, k as cartStoreClearCheckoutInterval } from './cart-dc171e7f.js';
3
3
  import { h as handleFetch, l as log, b as logError, j as jsonParse } from './handleFetch-621e45bc.js';
4
4
  import { t as tinycolor } from './isDarkColor-446fccb7.js';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, d as getElement } from './index-d82f06f2.js';
2
- import { f as stripeStore, t as trackConversionEvent, V as getFallbackDefaultCountryCode, r as translate, l as localizationStore, e as cartStore } from './cart-54d84646.js';
2
+ import { f as stripeStore, t as trackConversionEvent, V as getFallbackDefaultCountryCode, r as translate, l as localizationStore, e as cartStore } from './cart-dc171e7f.js';
3
3
  import { z as zonosStore, d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
4
4
  import { b as logError, l as log, i as isCheckoutMobile } from './handleFetch-621e45bc.js';
5
5
  import { i as isTextContainsNonLatinChars, c as containsNonLatinChars } from './containsNonLatinChars-2d8810c3.js';
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, a as getAssetPath, h, H as Host, F as Fragment, c as createEvent, d as getElement } from './index-d82f06f2.js';
2
- import { e as cartStore, E as currencyFormat, r as translate, M as cartStoreHasOneEligibleItem, N as stripeStoreApplyPromoCode, O as stripeStoreRemovePromoCode, f as stripeStore, C as stripeStoreReset, d as stripeStoreRetrievePayment, t as trackConversionEvent, P as stripeStoreResetPromoCode, Q as stripeStoreMessageBasedOnStatus, l as localizationStore, x as cartStoreNextStep, R as stripeStoreTranslateAddressToLatin, S as cartStoreUpdateSelectedShippingOption, T as cartStoreGetShippingTransitInfo, U as sortServiceLevelOptionsByAmount } from './cart-54d84646.js';
2
+ import { e as cartStore, E as currencyFormat, r as translate, M as cartStoreHasOneEligibleItem, N as stripeStoreApplyPromoCode, O as stripeStoreRemovePromoCode, f as stripeStore, C as stripeStoreReset, d as stripeStoreRetrievePayment, t as trackConversionEvent, P as stripeStoreResetPromoCode, Q as stripeStoreMessageBasedOnStatus, l as localizationStore, x as cartStoreNextStep, R as stripeStoreTranslateAddressToLatin, S as cartStoreUpdateSelectedShippingOption, T as cartStoreGetShippingTransitInfo, U as sortServiceLevelOptionsByAmount } from './cart-dc171e7f.js';
3
3
  import { c as classes } from './classes-0d95c529.js';
4
- import { s as submitGtag, c as paypalStoreReset, b as paypalStore, i as isContrastColor } from './paypal-17a320c8.js';
4
+ import { s as submitGtag, c as paypalStoreReset, b as paypalStore, i as isContrastColor } from './paypal-1beec534.js';
5
5
  import { z as zonosStore, g as getZonosStoreTheme, d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
6
6
  import { h as handleFetch, l as log, s as sendErrorLog, j as jsonParse, g as getIsTestMode, d as allLogs, i as isCheckoutMobile, b as logError, a as getIsStagingMode } from './handleFetch-621e45bc.js';
7
7
  import { c as createCustomEvent } from './createCustomEvent-58159025.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host, F as Fragment } from './index-d82f06f2.js';
2
- import { l as localizationStore, s as stripeStoreGetDomesticShippingSession, a as localizationStoreUpdateSelectedCountryCode, b as stripeStoreCleanupDomesticShippingSession, c as stripeStoreSaveDomesticShippingSession, i as initStripeElements, d as stripeStoreRetrievePayment, e as cartStore, f as stripeStore, g as cartStoreUpdateItems, h as cartStoreReset, j as cartStoreResetTabItems, k as cartStoreClearCheckoutInterval, m as stripeStoreInitCheckoutSession, n as stripeStoreGetPaymentIntent, o as cartStoreStartCheckoutInterval, t as trackConversionEvent, p as getCheckoutSessionBody, q as cartStoreUpdateToErrorState, r as translate, u as getZCountryUrlParam, v as cartStoreSetCheckoutSession, w as stripeStorePrefetchLandedCost, x as cartStoreNextStep, y as stripeStoreUpdateCheckoutSessionBaseCurrency, z as stripeStoreHandleInventoryCheck, A as stripeStoreConfirmPayment, B as stripeStoreHandleInventoryRefund, C as stripeStoreReset, D as localizationStoreOnUpdate, E as currencyFormat } from './cart-54d84646.js';
3
- import { p as paypalStoreHasPaypalEnabled, s as submitGtag, a as paypalInitScript, b as paypalStore } from './paypal-17a320c8.js';
2
+ import { l as localizationStore, s as stripeStoreGetDomesticShippingSession, a as localizationStoreUpdateSelectedCountryCode, b as stripeStoreCleanupDomesticShippingSession, c as stripeStoreSaveDomesticShippingSession, i as initStripeElements, d as stripeStoreRetrievePayment, e as cartStore, f as stripeStore, g as cartStoreUpdateItems, h as cartStoreReset, j as cartStoreResetTabItems, k as cartStoreClearCheckoutInterval, m as stripeStoreInitCheckoutSession, n as stripeStoreGetPaymentIntent, o as cartStoreStartCheckoutInterval, t as trackConversionEvent, p as getCheckoutSessionBody, q as cartStoreUpdateToErrorState, r as translate, u as getZCountryUrlParam, v as cartStoreSetCheckoutSession, w as stripeStorePrefetchLandedCost, x as cartStoreNextStep, y as stripeStoreUpdateCheckoutSessionBaseCurrency, z as stripeStoreHandleInventoryCheck, A as stripeStoreConfirmPayment, B as stripeStoreHandleInventoryRefund, C as stripeStoreReset, D as localizationStoreOnUpdate, E as currencyFormat } from './cart-dc171e7f.js';
3
+ import { p as paypalStoreHasPaypalEnabled, s as submitGtag, a as paypalInitScript, b as paypalStore } from './paypal-1beec534.js';
4
4
  import { z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-d3c5a0a5.js';
5
5
  import { h as handleFetch, l as log, b as logError, s as sendErrorLog, c as getElapsedTime, d as allLogs, e as getAdditionalLogMetadata, g as getIsTestMode, j as jsonParse, a as getIsStagingMode, i as isCheckoutMobile } from './handleFetch-621e45bc.js';
6
6
  import { c as classes } from './classes-0d95c529.js';
@@ -8,7 +8,7 @@ import { c as createCustomEvent } from './createCustomEvent-58159025.js';
8
8
  import { g as getBorderRadius } from './getBorderRadius-ada3ccad.js';
9
9
  import { i as isDarkColor } from './isDarkColor-446fccb7.js';
10
10
  import { s as styles } from './styles-6fc2fad9.js';
11
- import { c as checkoutHiddenBtnSelector, s as setupCartData, d as domesticRedirectedBtnSelector } from './CheckoutConfig-63b3ed06.js';
11
+ import { _ as _getIsValidCartId, c as checkoutHiddenBtnSelector, d as domesticRedirectedBtnSelector } from './CheckoutConfig-5479d192.js';
12
12
  import { R as RemoveIcon } from './RemoveIcon-9dc5dd1a.js';
13
13
 
14
14
  /**
@@ -246,6 +246,59 @@ const sendLoadNativeCheckoutLog = async ({ loadTime, }) => {
246
246
  });
247
247
  };
248
248
 
249
+ const getTempCartById = async ({ cartId, retries, }) => {
250
+ const isTestMode = getIsTestMode();
251
+ const { errors, json } = await handleFetch('/api/zonos-elements/get-temp-cart', {
252
+ body: {
253
+ isTestMode,
254
+ options: {
255
+ noOnlineStoreSettings: true,
256
+ },
257
+ tempCartUUID: cartId,
258
+ },
259
+ headers: {
260
+ 'Content-Type': 'application/json',
261
+ },
262
+ method: 'POST',
263
+ });
264
+ const failedResponse = !json || errors.length;
265
+ if (failedResponse && retries) {
266
+ log('[ZONOS - loadZonos] temp cart not ready, retrying in 1 second', 'info', {
267
+ retries,
268
+ });
269
+ // wait 1 second before retrying
270
+ await new Promise(resolve => setTimeout(resolve, 500));
271
+ return getTempCartById({ cartId, retries: retries - 1 });
272
+ }
273
+ if (failedResponse) {
274
+ return null;
275
+ }
276
+ return json;
277
+ };
278
+
279
+ const setupCartData = async (cartId) => {
280
+ const { isDgsCartId, isLegacyCartId } = _getIsValidCartId(cartId);
281
+ if (!isLegacyCartId && !isDgsCartId) {
282
+ logError('[ZONOS - loadZonos] invalid cart id');
283
+ return null;
284
+ }
285
+ const tempCartResult = await getTempCartById({ cartId, retries: 5 });
286
+ log('[ZONOS - loadZonos] getting temp cart data', 'info', tempCartResult);
287
+ if (!tempCartResult) {
288
+ logError('[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.');
289
+ return null;
290
+ }
291
+ window.Zonos.storeId = tempCartResult.cartData.storeId;
292
+ window.Zonos.zonosApiKey = tempCartResult.cartData.credentialToken;
293
+ return {
294
+ cartData: tempCartResult.cartData,
295
+ storeFavicon: tempCartResult.storeFaviconUrl,
296
+ storeId: tempCartResult.cartData.storeId,
297
+ storeLogo: tempCartResult.storeLogoUrl,
298
+ zonosApiKey: tempCartResult.cartData.credentialToken,
299
+ };
300
+ };
301
+
249
302
  const MessageIcon = `<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">
250
303
  <path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>
251
304
  </svg>
@@ -1,11 +1,18 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-d82f06f2.js';
2
- import { G as isValidSelector, f as stripeStore, H as initLocalizationStore, e as cartStore, a as localizationStoreUpdateSelectedCountryCode } from './cart-54d84646.js';
2
+ import { G as isValidSelector, f as stripeStore, H as initLocalizationStore, e as cartStore, a as localizationStoreUpdateSelectedCountryCode } from './cart-dc171e7f.js';
3
3
  import { z as zonosStore, b as zonosStoreInitSetting, d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
4
4
  import { h as handleFetch, b as logError, l as log } from './handleFetch-621e45bc.js';
5
5
  import './isDarkColor-446fccb7.js';
6
6
  import './getBorderRadius-ada3ccad.js';
7
7
 
8
8
  const getZonosSettings = async () => {
9
+ if (window.Zonos.cartSettings) {
10
+ return {
11
+ errors: [],
12
+ json: window.Zonos.cartSettings,
13
+ zonosMode: window.Zonos.zonosMode,
14
+ };
15
+ }
9
16
  const { errors, json, zonosMode } = await handleFetch('/api/zonos-elements/zonos-settings');
10
17
  if (errors.length) {
11
18
  logError(`Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings`);
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-d82f06f2.js';
2
- import { l as localizationStore } from './cart-54d84646.js';
2
+ import { l as localizationStore } from './cart-dc171e7f.js';
3
3
  import { d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import './handleFetch-621e45bc.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-d82f06f2.js';
2
- import { a as localizationStoreUpdateSelectedCountryCode, r as translate, l as localizationStore } from './cart-54d84646.js';
2
+ import { a as localizationStoreUpdateSelectedCountryCode, r as translate, l as localizationStore } from './cart-dc171e7f.js';
3
3
  import { d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
4
4
  import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
5
5
  import { i as isDarkColor } from './isDarkColor-446fccb7.js';
@@ -2,9 +2,9 @@ import { r as registerInstance, h, H as Host, d as getElement, c as createEvent
2
2
  import { d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
3
3
  import { c as classes } from './classes-0d95c529.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-ada3ccad.js';
5
- import { f as stripeStore, t as trackConversionEvent } from './cart-54d84646.js';
5
+ import { f as stripeStore, t as trackConversionEvent } from './cart-dc171e7f.js';
6
6
  import { b as logError, l as log } from './handleFetch-621e45bc.js';
7
- import { d as paypalStoreInitButtons } from './paypal-17a320c8.js';
7
+ import { d as paypalStoreInitButtons } from './paypal-1beec534.js';
8
8
  import './isDarkColor-446fccb7.js';
9
9
 
10
10
  const PaymentEmptyStateDarkIcon = `<svg width="536" height="200" viewBox="0 0 536 200" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host } from './index-d82f06f2.js';
2
- import { r as translate, l as localizationStore, E as currencyFormat } from './cart-54d84646.js';
2
+ import { r as translate, l as localizationStore, E as currencyFormat } from './cart-dc171e7f.js';
3
3
  import { z as zonosStore } from './zonosStore-d3c5a0a5.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-d82f06f2.js';
2
2
  import { _ as _root, e as _baseGetTag, i as isObjectLike_1, f as isObject_1, z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-d3c5a0a5.js';
3
- import { l as localizationStore, G as isValidSelector, r as translate, u as getZCountryUrlParam, I as setZCountryUrlParam, J as currencyDisplay, K as currencyConvertAndFormat, L as currencyConvert, E as currencyFormat } from './cart-54d84646.js';
3
+ import { l as localizationStore, G as isValidSelector, r as translate, u as getZCountryUrlParam, I as setZCountryUrlParam, J as currencyDisplay, K as currencyConvertAndFormat, L as currencyConvert, E as currencyFormat } from './cart-dc171e7f.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { h as handleFetch, b as logError, l as log } from './handleFetch-621e45bc.js';
6
6
  import { g as getHasMoreSpaceOnRight } from './getHasMoreSpaceOnRight-70eb913a.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-d82f06f2.js';
2
- import { W as localizationStoreUpdateSelectedLocale, r as translate, l as localizationStore } from './cart-54d84646.js';
2
+ import { W as localizationStoreUpdateSelectedLocale, r as translate, l as localizationStore } from './cart-dc171e7f.js';
3
3
  import { d as zonosStoreFontFamily } from './zonosStore-d3c5a0a5.js';
4
4
  import { l as languages } from './ILanguage-cd6acb72.js';
5
5
  import './handleFetch-621e45bc.js';
@@ -0,0 +1 @@
1
+ var baseRe=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;var uuidRe=new RegExp("^".concat(baseRe.source,"$"));var cartUuidRe=new RegExp("^cart_".concat(baseRe.source,"$"));var tsidRe=/^[a-zA-Z0-9]{2,}$/;var cartTsidRe=/^cart_[a-zA-Z0-9]{2,}$/;var _getIsValidCartId=function(e){if(!e){return{isDgsCartId:false,isLegacyCartId:false}}if(e.includes("undefined")){return{isDgsCartId:false,isLegacyCartId:false}}if(cartTsidRe.test(e)){return{isDgsCartId:true,isLegacyCartId:false}}if(tsidRe.test(e)){return{isDgsCartId:false,isLegacyCartId:true}}if(cartUuidRe.test(e)){return{isDgsCartId:true,isLegacyCartId:false}}if(uuidRe.test(e)){return{isDgsCartId:false,isLegacyCartId:true}}return{isDgsCartId:false,isLegacyCartId:false}};var checkoutHiddenBtnSelector="zonos--checkout-hidden-button";var domesticRedirectedBtnSelector="zonos--domestic-redirected-checkout-button";export{_getIsValidCartId as _,checkoutHiddenBtnSelector as c,domesticRedirectedBtnSelector as d};