@zonos/elements 1.3.135 → 1.3.136

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 (36) hide show
  1. package/dist/cjs/index.cjs.js +7 -7
  2. package/dist/cjs/{paypal-045033fb.js → paypal-fd50c7d5.js} +0 -1
  3. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +1 -1
  4. package/dist/cjs/zonos-checkout.cjs.entry.js +33 -3
  5. package/dist/cjs/zonos-notification_3.cjs.entry.js +1 -1
  6. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +32 -2
  7. package/dist/collection/components/store/checkout/paypal.js +0 -1
  8. package/dist/esm/index.js +7 -7
  9. package/dist/esm/{paypal-7f41ff20.js → paypal-b4af6cc0.js} +0 -1
  10. package/dist/esm/zonos-cart-items_13.entry.js +1 -1
  11. package/dist/esm/zonos-checkout.entry.js +33 -3
  12. package/dist/esm/zonos-notification_3.entry.js +1 -1
  13. package/dist/esm-es5/index.js +1 -1
  14. package/dist/esm-es5/{paypal-7f41ff20.js → paypal-b4af6cc0.js} +1 -1
  15. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  16. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  17. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  18. package/dist/scripts/index.js +1 -1
  19. package/dist/scripts/loadZonos.js +1 -1
  20. package/dist/scripts/zonos.js +1 -1
  21. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  22. package/dist/zonos-elements/index.esm.js +1 -1
  23. package/dist/zonos-elements/{p-1856c3fa.system.js → p-18cb1aee.system.js} +1 -1
  24. package/dist/zonos-elements/{p-b1bb00a8.entry.js → p-37991f24.entry.js} +1 -1
  25. package/dist/zonos-elements/{p-a0de6e0f.system.entry.js → p-af3ecd9d.system.entry.js} +1 -1
  26. package/dist/zonos-elements/{p-fa41d3e4.system.js → p-b776e39e.system.js} +1 -1
  27. package/dist/zonos-elements/{p-aaa3addd.system.entry.js → p-c52a8369.system.entry.js} +1 -1
  28. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  29. package/dist/zonos-elements/{p-acb45eb6.system.entry.js → p-c8927b27.system.entry.js} +1 -1
  30. package/dist/zonos-elements/p-caddd067.entry.js +1 -0
  31. package/dist/zonos-elements/p-e1ac8cd8.js +17 -0
  32. package/dist/zonos-elements/{p-fb7d8b52.entry.js → p-e9862f66.entry.js} +1 -1
  33. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  34. package/package.json +1 -1
  35. package/dist/zonos-elements/p-8759f66b.js +0 -17
  36. package/dist/zonos-elements/p-99d47e1c.entry.js +0 -1
@@ -127,7 +127,7 @@ const getZonosQaUrl = () => {
127
127
  return null;
128
128
  }
129
129
  const qaUrl = extractZonosQaUrl(window.location.href);
130
- const cdnUrl = "https://v1.3.135.js.zonos.com";
130
+ const cdnUrl = "https://v1.3.136.js.zonos.com";
131
131
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
132
132
  if (!qaUrl &&
133
133
  (cdnUrl.includes('test.') ||
@@ -311,10 +311,10 @@ const zonosLoadUrl = (() => {
311
311
  }
312
312
  return null;
313
313
  })();
314
- const ZONOS_URL = "https://v1.3.135.js.zonos.com";
315
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";
316
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.135";
317
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";
314
+ const ZONOS_URL = "https://v1.3.136.js.zonos.com";
315
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.136";
316
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.136";
317
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.136";
318
318
  const INTER_FONT_URL = 'https://rsms.me';
319
319
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
320
320
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -329,7 +329,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
329
329
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
330
330
  Zonos._paypalMockResponse = null;
331
331
  Zonos.isBigCommerce = false;
332
- Zonos.releaseDate = "1732640550316";
332
+ Zonos.releaseDate = "1733241504089";
333
333
  Zonos.isLegacyCheckout = false;
334
334
  Zonos.domain = typeof window !== 'undefined'
335
335
  ? // domain that embeds the iframe
@@ -345,7 +345,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
345
345
  Zonos.isNpm = true;
346
346
  Zonos.zonosQaUrl = null;
347
347
  Zonos.zonosQaUrlApi = null;
348
- Zonos.version = `v${"1.3.135"}`;
348
+ Zonos.version = `v${"1.3.136"}`;
349
349
  Zonos.modeAlerted = false;
350
350
  Zonos.cartData = null;
351
351
  Zonos.paypal = null;
@@ -266,7 +266,6 @@ const paypalStoreCreaterOrder = async ({ checkoutSessionId, }) => {
266
266
  };
267
267
  const paypalStoreCaptureOrder = async ({ checkoutSessionId, paypalMockResponse, }) => {
268
268
  var _a, _b;
269
- new URL(window.location.href);
270
269
  const { errors, json } = await paypalCaptureOrder({
271
270
  checkoutSessionId,
272
271
  paypalMockResponse,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-d56e0a8b.js');
6
6
  const cart = require('./cart-0f32f556.js');
7
7
  const classes = require('./classes-b7918f56.js');
8
- const paypal = require('./paypal-045033fb.js');
8
+ const paypal = require('./paypal-fd50c7d5.js');
9
9
  const zonosStore = require('./zonosStore-293bb3ba.js');
10
10
  const createCustomEvent = require('./createCustomEvent-3e982e57.js');
11
11
  const getBorderRadius = require('./getBorderRadius-f72d8edf.js');
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
6
  const cart = require('./cart-0f32f556.js');
7
- const paypal = require('./paypal-045033fb.js');
7
+ const paypal = require('./paypal-fd50c7d5.js');
8
8
  const zonosStore = require('./zonosStore-293bb3ba.js');
9
9
  const handleFetch = require('./handleFetch-4a90f091.js');
10
10
  const createCustomEvent = require('./createCustomEvent-3e982e57.js');
@@ -934,12 +934,42 @@ const ZonosCheckout = class {
934
934
  cart.stripeStoreReset();
935
935
  }
936
936
  handleOpenChange() {
937
+ const overflowAttrKey = 'data-zonos-overflow-origin';
938
+ const body = document.body;
939
+ const html = document.documentElement;
937
940
  // disable scroll on the body when dialog is open
938
941
  if (this.open) {
939
- document.body.style.overflow = 'hidden';
942
+ // record overflow state to data-zonos-overflow-origin in body/html element so we can reset it later
943
+ if (body.style.overflow) {
944
+ body.setAttribute(overflowAttrKey, body.style.overflow);
945
+ }
946
+ body.style.overflow = 'hidden';
947
+ if (html.style.overflow) {
948
+ html.setAttribute(overflowAttrKey, html.style.overflow);
949
+ }
950
+ html.style.overflow = 'hidden';
940
951
  }
941
952
  else {
942
- document.body.style.overflow = 'auto';
953
+ const bodyOverflow = body.getAttribute(overflowAttrKey);
954
+ const htmlOverflow = html.getAttribute(overflowAttrKey);
955
+ // reset overflow state to original state
956
+ if (bodyOverflow) {
957
+ body.removeAttribute(overflowAttrKey);
958
+ body.style.overflow = bodyOverflow;
959
+ }
960
+ else {
961
+ // just remove the overflow style if it's not set
962
+ body.style.removeProperty('overflow');
963
+ }
964
+ // reset overflow state to original state
965
+ if (htmlOverflow) {
966
+ html.removeAttribute(overflowAttrKey);
967
+ html.style.overflow = htmlOverflow;
968
+ }
969
+ else {
970
+ // just remove the overflow style if it's not set
971
+ html.style.removeProperty('overflow');
972
+ }
943
973
  }
944
974
  }
945
975
  componentWillLoad() {
@@ -8,7 +8,7 @@ const classes = require('./classes-b7918f56.js');
8
8
  const getBorderRadius = require('./getBorderRadius-f72d8edf.js');
9
9
  const cart = require('./cart-0f32f556.js');
10
10
  const handleFetch = require('./handleFetch-4a90f091.js');
11
- const paypal = require('./paypal-045033fb.js');
11
+ const paypal = require('./paypal-fd50c7d5.js');
12
12
  require('./isDarkColor-dd6d723b.js');
13
13
 
14
14
  const zonosNotificationCss = ":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--notification-items{position:fixed;z-index:9999999999;bottom:24px;gap:8px;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}:host .zonos--notification-item{cursor:pointer;-webkit-transition:all 0.3s ease;transition:all 0.3s ease;padding:8px;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));opacity:0;-ms-flex-negative:0.0001;flex-shrink:0.0001;-webkit-transform:translateY(100%);transform:translateY(100%)}:host .zonos--notification-item+:host .zonos--notification-item{margin-top:8px}:host .zonos--notification-item.show{opacity:1;-webkit-transform:translateY(0);transform:translateY(0);-ms-flex-positive:1000;flex-grow:1000}:host .zonos--notification-item.success{background-color:var(--zonos-elements-green-700)}:host .zonos--notification-item.error{background-color:var(--zonos-elements-red-700)}:host .zonos--notification-item.warning{background-color:var(--zonos-elements-orange-700)}";
@@ -723,12 +723,42 @@ export class ZonosCheckout {
723
723
  stripeStoreReset();
724
724
  }
725
725
  handleOpenChange() {
726
+ const overflowAttrKey = 'data-zonos-overflow-origin';
727
+ const body = document.body;
728
+ const html = document.documentElement;
726
729
  // disable scroll on the body when dialog is open
727
730
  if (this.open) {
728
- document.body.style.overflow = 'hidden';
731
+ // record overflow state to data-zonos-overflow-origin in body/html element so we can reset it later
732
+ if (body.style.overflow) {
733
+ body.setAttribute(overflowAttrKey, body.style.overflow);
734
+ }
735
+ body.style.overflow = 'hidden';
736
+ if (html.style.overflow) {
737
+ html.setAttribute(overflowAttrKey, html.style.overflow);
738
+ }
739
+ html.style.overflow = 'hidden';
729
740
  }
730
741
  else {
731
- document.body.style.overflow = 'auto';
742
+ const bodyOverflow = body.getAttribute(overflowAttrKey);
743
+ const htmlOverflow = html.getAttribute(overflowAttrKey);
744
+ // reset overflow state to original state
745
+ if (bodyOverflow) {
746
+ body.removeAttribute(overflowAttrKey);
747
+ body.style.overflow = bodyOverflow;
748
+ }
749
+ else {
750
+ // just remove the overflow style if it's not set
751
+ body.style.removeProperty('overflow');
752
+ }
753
+ // reset overflow state to original state
754
+ if (htmlOverflow) {
755
+ html.removeAttribute(overflowAttrKey);
756
+ html.style.overflow = htmlOverflow;
757
+ }
758
+ else {
759
+ // just remove the overflow style if it's not set
760
+ html.style.removeProperty('overflow');
761
+ }
732
762
  }
733
763
  }
734
764
  componentWillLoad() {
@@ -31,7 +31,6 @@ const paypalStoreCreaterOrder = async ({ checkoutSessionId, }) => {
31
31
  };
32
32
  const paypalStoreCaptureOrder = async ({ checkoutSessionId, paypalMockResponse, }) => {
33
33
  var _a, _b;
34
- const {} = new URL(window.location.href);
35
34
  const { errors, json } = await paypalCaptureOrder({
36
35
  checkoutSessionId,
37
36
  paypalMockResponse,
package/dist/esm/index.js CHANGED
@@ -124,7 +124,7 @@ const getZonosQaUrl = () => {
124
124
  return null;
125
125
  }
126
126
  const qaUrl = extractZonosQaUrl(window.location.href);
127
- const cdnUrl = "https://v1.3.135.js.zonos.com";
127
+ const cdnUrl = "https://v1.3.136.js.zonos.com";
128
128
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
129
129
  if (!qaUrl &&
130
130
  (cdnUrl.includes('test.') ||
@@ -308,10 +308,10 @@ const zonosLoadUrl = (() => {
308
308
  }
309
309
  return null;
310
310
  })();
311
- const ZONOS_URL = "https://v1.3.135.js.zonos.com";
312
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";
313
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.135";
314
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";
311
+ const ZONOS_URL = "https://v1.3.136.js.zonos.com";
312
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.136";
313
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.136";
314
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.136";
315
315
  const INTER_FONT_URL = 'https://rsms.me';
316
316
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
317
317
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -326,7 +326,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
326
326
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
327
327
  Zonos._paypalMockResponse = null;
328
328
  Zonos.isBigCommerce = false;
329
- Zonos.releaseDate = "1732640550316";
329
+ Zonos.releaseDate = "1733241504089";
330
330
  Zonos.isLegacyCheckout = false;
331
331
  Zonos.domain = typeof window !== 'undefined'
332
332
  ? // domain that embeds the iframe
@@ -342,7 +342,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
342
342
  Zonos.isNpm = true;
343
343
  Zonos.zonosQaUrl = null;
344
344
  Zonos.zonosQaUrlApi = null;
345
- Zonos.version = `v${"1.3.135"}`;
345
+ Zonos.version = `v${"1.3.136"}`;
346
346
  Zonos.modeAlerted = false;
347
347
  Zonos.cartData = null;
348
348
  Zonos.paypal = null;
@@ -264,7 +264,6 @@ const paypalStoreCreaterOrder = async ({ checkoutSessionId, }) => {
264
264
  };
265
265
  const paypalStoreCaptureOrder = async ({ checkoutSessionId, paypalMockResponse, }) => {
266
266
  var _a, _b;
267
- new URL(window.location.href);
268
267
  const { errors, json } = await paypalCaptureOrder({
269
268
  checkoutSessionId,
270
269
  paypalMockResponse,
@@ -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-86b8247e.js';
2
2
  import { d as cartStore, H as currencyFormat, p as translate, I as cartStoreHasOneEligibleItem, J as stripeStoreApplyPromoCode, K as stripeStoreRemovePromoCode, z as stripeStoreReset, j as stripeStore, L as stripeStoreRetrievePayment, t as trackConversionEvent, M as stripeStoreResetPromoCode, N as stripeStoreMessageBasedOnStatus, l as localizationStore, O as stripeStoreTranslateAddressToLatin, P as cartStoreUpdateSelectedShippingOption, Q as cartStoreGetShippingTransitInfo, R as sortServiceLevelOptionsByAmount } from './cart-3e0e4d5c.js';
3
3
  import { c as classes } from './classes-0d95c529.js';
4
- import { s as submitGtag, b as paypalStore, c as paypalStoreReset, i as isContrastColor } from './paypal-7f41ff20.js';
4
+ import { s as submitGtag, b as paypalStore, c as paypalStoreReset, i as isContrastColor } from './paypal-b4af6cc0.js';
5
5
  import { z as zonosStore, g as getZonosStoreTheme, d as zonosStoreFontFamily } from './zonosStore-c493c4fe.js';
6
6
  import { c as createCustomEvent, g as getIsTestMode } from './createCustomEvent-31a792d3.js';
7
7
  import { g as getBorderRadius } from './getBorderRadius-bdd709e7.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host, F as Fragment } from './index-86b8247e.js';
2
2
  import { l as localizationStore, s as stripeStoreGetDomesticShippingSession, a as localizationStoreUpdateSelectedCountryCode, b as stripeStoreCleanupDomesticShippingSession, c as stripeStoreSaveDomesticShippingSession, i as initStripeElements, d as cartStore, e as cartStoreUpdateItems, f as cartStoreReset, g as cartStoreResetTabItems, h as cartStoreClearCheckoutInterval, j as stripeStore, k as stripeStoreInitCheckoutSession, m as cartStoreStartCheckoutInterval, t as trackConversionEvent, n as getCheckoutSessionBody, o as cartStoreUpdateToErrorState, p as translate, q as getZCountryUrlParam, r as cartStoreSetCheckoutSession, u as stripeStorePrefetchLandedCost, v as cartStoreNextStep, w as stripeStoreHandleInventoryCheck, x as stripeStoreConfirmPayment, y as stripeStoreHandleInventoryRefund, z as stripeStoreReset, A as localizationStoreOnUpdate } from './cart-3e0e4d5c.js';
3
- import { p as paypalStoreHasPaypalEnabled, s as submitGtag, a as paypalInitScript } from './paypal-7f41ff20.js';
3
+ import { p as paypalStoreHasPaypalEnabled, s as submitGtag, a as paypalInitScript } from './paypal-b4af6cc0.js';
4
4
  import { z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-c493c4fe.js';
5
5
  import { h as handleFetch, l as log, a as logError, s as sendErrorLog, g as getElapsedTime, b as allLogs, j as jsonParse } from './handleFetch-22cb914b.js';
6
6
  import { g as getIsTestMode, c as createCustomEvent } from './createCustomEvent-31a792d3.js';
@@ -930,12 +930,42 @@ const ZonosCheckout = class {
930
930
  stripeStoreReset();
931
931
  }
932
932
  handleOpenChange() {
933
+ const overflowAttrKey = 'data-zonos-overflow-origin';
934
+ const body = document.body;
935
+ const html = document.documentElement;
933
936
  // disable scroll on the body when dialog is open
934
937
  if (this.open) {
935
- document.body.style.overflow = 'hidden';
938
+ // record overflow state to data-zonos-overflow-origin in body/html element so we can reset it later
939
+ if (body.style.overflow) {
940
+ body.setAttribute(overflowAttrKey, body.style.overflow);
941
+ }
942
+ body.style.overflow = 'hidden';
943
+ if (html.style.overflow) {
944
+ html.setAttribute(overflowAttrKey, html.style.overflow);
945
+ }
946
+ html.style.overflow = 'hidden';
936
947
  }
937
948
  else {
938
- document.body.style.overflow = 'auto';
949
+ const bodyOverflow = body.getAttribute(overflowAttrKey);
950
+ const htmlOverflow = html.getAttribute(overflowAttrKey);
951
+ // reset overflow state to original state
952
+ if (bodyOverflow) {
953
+ body.removeAttribute(overflowAttrKey);
954
+ body.style.overflow = bodyOverflow;
955
+ }
956
+ else {
957
+ // just remove the overflow style if it's not set
958
+ body.style.removeProperty('overflow');
959
+ }
960
+ // reset overflow state to original state
961
+ if (htmlOverflow) {
962
+ html.removeAttribute(overflowAttrKey);
963
+ html.style.overflow = htmlOverflow;
964
+ }
965
+ else {
966
+ // just remove the overflow style if it's not set
967
+ html.style.removeProperty('overflow');
968
+ }
939
969
  }
940
970
  }
941
971
  componentWillLoad() {
@@ -4,7 +4,7 @@ import { c as classes } from './classes-0d95c529.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-bdd709e7.js';
5
5
  import { j as stripeStore } from './cart-3e0e4d5c.js';
6
6
  import { a as logError, l as log } from './handleFetch-22cb914b.js';
7
- import { d as paypalStoreInitButtons } from './paypal-7f41ff20.js';
7
+ import { d as paypalStoreInitButtons } from './paypal-b4af6cc0.js';
8
8
  import './isDarkColor-c6924924.js';
9
9
 
10
10
  const zonosNotificationCss = ":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--notification-items{position:fixed;z-index:9999999999;bottom:24px;gap:8px;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column}:host .zonos--notification-item{cursor:pointer;-webkit-transition:all 0.3s ease;transition:all 0.3s ease;padding:8px;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-6));opacity:0;-ms-flex-negative:0.0001;flex-shrink:0.0001;-webkit-transform:translateY(100%);transform:translateY(100%)}:host .zonos--notification-item+:host .zonos--notification-item{margin-top:8px}:host .zonos--notification-item.show{opacity:1;-webkit-transform:translateY(0);transform:translateY(0);-ms-flex-positive:1000;flex-grow:1000}:host .zonos--notification-item.success{background-color:var(--zonos-elements-green-700)}:host .zonos--notification-item.error{background-color:var(--zonos-elements-red-700)}:host .zonos--notification-item.warning{background-color:var(--zonos-elements-orange-700)}";
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,o,r){function t(n){return n instanceof o?n:new o((function(e){e(n)}))}return new(o||(o=Promise))((function(o,i){function a(n){try{u(r.next(n))}catch(n){i(n)}}function s(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?o(n.value):t(n.value).then(a,s)}u((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(n){return function(e){return u([n,e])}}function u(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(r=1,t&&(i=s[0]&2?t["return"]:s[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,s[1])).done)return i;if(t=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;t=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=e.call(n,o)}catch(n){s=[6,n];t=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{l as log,h as handleFetch,a as logError}from"./handleFetch-22cb914b.js";import{s as setupCartData,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-930107d4.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-930107d4.js";var checkIfLoadVersionDomain=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(e).origin;var i=o.some((function(n){return t.includes(n)}));var a=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(n){var e=fallbackList.indexOf(n);var o=fallbackList[e+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var n,e,o,r,t;return __generator(this,(function(i){switch(i.label){case 0:n=window.location.search.includes("zonosTestMode=1");if(!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:e=i.sent(),o=e.errors,r=e.json;if(o.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);return[2,null]}t=r.publicCredential;if(!t){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(t),"info");return[2,t]}}))}))};var extractZonosQaUrl=function(n){if(!n){return null}var e=new URL(n).searchParams;var o=e.get("zonosQaUrl");if(!o){return null}var r=/[^a-zA-Z0-9-_]+/.test(o);if(!!r){return null}return o};var getZonosQaUrl=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var e=extractZonosQaUrl(window.location.href);var o="https://v1.3.135.js.zonos.com";if(!e&&(o.includes("test.")||o.includes("test-"))){return o}if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!e){return null}if(e==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var t="https://".concat(e,".").concat(r);log("[ZONOS-WARNING] using '".concat(t,"' for loading elements script"),"warn");void fetch(t).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(t,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var o="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return t};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var n=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(e);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(o);return o};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(e,o){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){e(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(n){o(n);return}}));return stripePromise$1};var registerWrapper=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var initStripe=function(n,e,o){if(n===null){return null}var r=n.apply(undefined,e);registerWrapper(r,o);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(n){if(!loadCalled){console.warn(n)}}));var zonosLoadStripe=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(o){loadCalled=true;e=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,n,e)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var n=new URLSearchParams(window.location.search);var e=n.get(TEMP_CART_ID_QUERY_PARAM);return e};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),o=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return o}return null}();var ZONOS_URL="https://v1.3.135.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.135";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";var INTER_FONT_URL="https://rsms.me";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var INTER_FONT_REGEX=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var Zonos=function(){function n(){}return n}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1732640550316";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.version="v".concat("1.3.135");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o,r,t,i,a,s,u,c,l,d,f,v;return __generator(this,(function(m){switch(m.label){case 0:e=n.appearance,o=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,a=n.overrideCurrencyFormat,s=n.storeId,u=n.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");l=document.createElement("script");l.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(n)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));window.isZonosPreview=true;return[2]}if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartData(_a.cartId)];case 1:d=m.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;m.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=m.sent();if(f){_a.zonosApiKey=f}m.label=4;case 4:if(_a.cartId&&_a.cartData){log("Cart data is available, inject hidden button and trigger checkout");v=document.createElement("button");v.style.display="none";v.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(v)}log("init zonos");_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:e,checkoutSettings:o,currencyConverter:r,helloSettings:t,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};Zonos.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.showNotification(n))};Zonos.updateOrganizationName=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var e=n.autoEnable,o=e===void 0?true:e,r=n.config,t=n.disable,i=n.placeOrderButtonSelector;var a;if((a=r.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var u=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};s.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(t){n.setAttribute("disabled","true");n.addEventListener("click",u)}else{n.removeAttribute("disabled");n.removeEventListener("click",u)}}));if(o&&t){setTimeout((function(){s.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",u)}))}),5e3)}}};Zonos.injectController=function(n){var e=n.config;var o;if(document.querySelector("zonos-controller")){return}if((o=e.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=e.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r});var t=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r})}));t.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=e;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o;return __generator(this,(function(r){switch(r.label){case 0:e=n.detail;log("loading Stripe");return[4,zonosLoadStripe(e.publishableKey)];case 1:o=r.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(n){var e=n.cdnType,o=n.isModule,r=n.theRestUrl;var t=_a.getZonosUrl(e);var i="".concat(t,"/").concat(r);var a=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var u=document.createElement("script");if(!!o){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var n=getNextFallbackUrl(e);if(!n){return}_a.injectScript({cdnType:n,isModule:o,theRestUrl:r})};s.appendChild(u)};Zonos.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||e()}return e()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var e=n.cdnType,o=n.theRestUrl;var r=_a.getZonosUrl(e);var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(r,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var n=getNextFallbackUrl(e);if(!n){return}_a.injectStylesheet({cdnType:n,theRestUrl:o})};t.appendChild(a)};Zonos.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(INTER_FONT_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(INTER_FONT_REGEX.test(o.href)){continue}return o}return null};if(n()){log("Inter font already injected","warn");return}var e=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=INTER_FONT_URL;e.appendChild(o);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");e.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var e;log("[FONT] injecting ".concat(n));var o=(e=n.match(/family=(.*?):/))===null||e===void 0?void 0:e[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(n,e,o,r){function t(n){return n instanceof o?n:new o((function(e){e(n)}))}return new(o||(o=Promise))((function(o,i){function a(n){try{u(r.next(n))}catch(n){i(n)}}function s(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?o(n.value):t(n.value).then(a,s)}u((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(n){return function(e){return u([n,e])}}function u(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(r=1,t&&(i=s[0]&2?t["return"]:s[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,s[1])).done)return i;if(t=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;t=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=e.call(n,o)}catch(n){s=[6,n];t=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{l as log,h as handleFetch,a as logError}from"./handleFetch-22cb914b.js";import{s as setupCartData,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-930107d4.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-930107d4.js";var checkIfLoadVersionDomain=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(e).origin;var i=o.some((function(n){return t.includes(n)}));var a=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(n){var e=fallbackList.indexOf(n);var o=fallbackList[e+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var n,e,o,r,t;return __generator(this,(function(i){switch(i.label){case 0:n=window.location.search.includes("zonosTestMode=1");if(!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:e=i.sent(),o=e.errors,r=e.json;if(o.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);return[2,null]}t=r.publicCredential;if(!t){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(t),"info");return[2,t]}}))}))};var extractZonosQaUrl=function(n){if(!n){return null}var e=new URL(n).searchParams;var o=e.get("zonosQaUrl");if(!o){return null}var r=/[^a-zA-Z0-9-_]+/.test(o);if(!!r){return null}return o};var getZonosQaUrl=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var e=extractZonosQaUrl(window.location.href);var o="https://v1.3.136.js.zonos.com";if(!e&&(o.includes("test.")||o.includes("test-"))){return o}if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!e){return null}if(e==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var t="https://".concat(e,".").concat(r);log("[ZONOS-WARNING] using '".concat(t,"' for loading elements script"),"warn");void fetch(t).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(t,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var o="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return t};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var n=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(e);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(o);return o};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(e,o){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){e(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(n){o(n);return}}));return stripePromise$1};var registerWrapper=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var initStripe=function(n,e,o){if(n===null){return null}var r=n.apply(undefined,e);registerWrapper(r,o);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(n){if(!loadCalled){console.warn(n)}}));var zonosLoadStripe=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(o){loadCalled=true;e=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,n,e)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var n=new URLSearchParams(window.location.search);var e=n.get(TEMP_CART_ID_QUERY_PARAM);return e};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),o=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return o}return null}();var ZONOS_URL="https://v1.3.136.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.136";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.136";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.136";var INTER_FONT_URL="https://rsms.me";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var INTER_FONT_REGEX=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var Zonos=function(){function n(){}return n}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1733241504089";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.version="v".concat("1.3.136");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o,r,t,i,a,s,u,c,l,d,f,v;return __generator(this,(function(m){switch(m.label){case 0:e=n.appearance,o=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,a=n.overrideCurrencyFormat,s=n.storeId,u=n.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");l=document.createElement("script");l.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(n)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));window.isZonosPreview=true;return[2]}if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartData(_a.cartId)];case 1:d=m.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;m.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=m.sent();if(f){_a.zonosApiKey=f}m.label=4;case 4:if(_a.cartId&&_a.cartData){log("Cart data is available, inject hidden button and trigger checkout");v=document.createElement("button");v.style.display="none";v.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(v)}log("init zonos");_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:e,checkoutSettings:o,currencyConverter:r,helloSettings:t,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};Zonos.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.showNotification(n))};Zonos.updateOrganizationName=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var e=n.autoEnable,o=e===void 0?true:e,r=n.config,t=n.disable,i=n.placeOrderButtonSelector;var a;if((a=r.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var u=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};s.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(t){n.setAttribute("disabled","true");n.addEventListener("click",u)}else{n.removeAttribute("disabled");n.removeEventListener("click",u)}}));if(o&&t){setTimeout((function(){s.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",u)}))}),5e3)}}};Zonos.injectController=function(n){var e=n.config;var o;if(document.querySelector("zonos-controller")){return}if((o=e.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=e.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r});var t=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r})}));t.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=e;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o;return __generator(this,(function(r){switch(r.label){case 0:e=n.detail;log("loading Stripe");return[4,zonosLoadStripe(e.publishableKey)];case 1:o=r.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(n){var e=n.cdnType,o=n.isModule,r=n.theRestUrl;var t=_a.getZonosUrl(e);var i="".concat(t,"/").concat(r);var a=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var u=document.createElement("script");if(!!o){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var n=getNextFallbackUrl(e);if(!n){return}_a.injectScript({cdnType:n,isModule:o,theRestUrl:r})};s.appendChild(u)};Zonos.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||e()}return e()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var e=n.cdnType,o=n.theRestUrl;var r=_a.getZonosUrl(e);var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(r,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var n=getNextFallbackUrl(e);if(!n){return}_a.injectStylesheet({cdnType:n,theRestUrl:o})};t.appendChild(a)};Zonos.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(INTER_FONT_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(INTER_FONT_REGEX.test(o.href)){continue}return o}return null};if(n()){log("Inter font already injected","warn");return}var e=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=INTER_FONT_URL;e.appendChild(o);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");e.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var e;log("[FONT] injecting ".concat(n));var o=(e=n.match(/family=(.*?):/))===null||e===void 0?void 0:e[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
@@ -14,4 +14,4 @@ var __awaiter=this&&this.__awaiter||function(r,e,t,n){function o(r){return r ins
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */function findScript(r,e){var t=document.querySelector('script[src="'.concat(r,'"]'));if(t===null)return null;var n=createScriptElement(r,e);var o=t.cloneNode();delete o.dataset.uidAuto;if(Object.keys(o.dataset).length!==Object.keys(n.dataset).length){return null}var a=true;Object.keys(o.dataset).forEach((function(r){if(o.dataset[r]!==n.dataset[r]){a=false}}));return a?t:null}function insertScriptElement(r){var e=r.url,t=r.attributes,n=r.onSuccess,o=r.onError;var a=createScriptElement(e,t);a.onerror=o;a.onload=n;document.head.insertBefore(a,document.head.firstElementChild)}function processOptions(r){var e=r.environment;var t=e==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js";delete r.environment;if(r.sdkBaseUrl){t=r.sdkBaseUrl;delete r.sdkBaseUrl}var n=r;var o=Object.keys(n).filter((function(r){return typeof n[r]!=="undefined"&&n[r]!==null&&n[r]!==""})).reduce((function(r,e){var t=n[e].toString();e=camelCaseToKebabCase(e);if(e.substring(0,4)==="data"||e==="crossorigin"){r.attributes[e]=t}else{r.queryParams[e]=t}return r}),{queryParams:{},attributes:{}}),a=o.queryParams,i=o.attributes;if(a["merchant-id"]&&a["merchant-id"].indexOf(",")!==-1){i["data-merchant-id"]=a["merchant-id"];a["merchant-id"]="*"}return{url:"".concat(t,"?").concat(objectToQueryString(a)),attributes:i}}function camelCaseToKebabCase(r){var e=function(r,e){return(e?"-":"")+r.toLowerCase()};return r.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function objectToQueryString(r){var e="";Object.keys(r).forEach((function(t){if(e.length!==0)e+="&";e+=t+"="+r[t]}));return e}function createScriptElement(r,e){if(e===void 0){e={}}var t=document.createElement("script");t.src=r;Object.keys(e).forEach((function(r){t.setAttribute(r,e[r]);if(r==="data-csp-nonce"){t.setAttribute("nonce",e["data-csp-nonce"])}}));return t}function loadScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);if(typeof document==="undefined")return e.resolve(null);var t=processOptions(r),n=t.url,o=t.attributes;var a=o["data-namespace"]||"paypal";var i=getPayPalWindowNamespace(a);if(!o["data-js-sdk-library"]){o["data-js-sdk-library"]="paypal-js"}if(findScript(n,o)&&i){return e.resolve(i)}return loadCustomScript({url:n,attributes:o},e).then((function(){var r=getPayPalWindowNamespace(a);if(r){return r}throw new Error("The window.".concat(a," global variable is not available."))}))}function loadCustomScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);var t=r.url,n=r.attributes;if(typeof t!=="string"||t.length===0){throw new Error("Invalid url.")}if(typeof n!=="undefined"&&typeof n!=="object"){throw new Error("Expected attributes to be an object.")}return new e((function(r,e){if(typeof document==="undefined")return r();insertScriptElement({url:t,attributes:n,onSuccess:function(){return r()},onError:function(){var r=new Error('The script "'.concat(t,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(r)}})}))}function getPayPalWindowNamespace(r){return window[r]}function validateArguments(r,e){if(typeof r!=="object"||r===null){throw new Error("Expected an options object.")}var t=r.environment;if(t&&t!=="production"&&t!=="sandbox"){throw new Error('The `environment` option must be either "production" or "sandbox".')}if(typeof e!=="undefined"&&typeof e!=="function"){throw new Error("Expected PromisePonyfill to be a function.")}}var paypalCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n;var o=r.checkoutSessionId,a=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:o,paypalMockResponse:a},method:"POST"})];case 1:e=r.sent(),t=e.errors,n=e.json;return[2,{errors:t,json:n}]}}))}))};var paypalCreateOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n;var o=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:o},method:"POST"})];case 1:e=r.sent(),t=e.errors,n=e.json;return[2,{errors:t,json:n}]}}))}))};var isContrastColor=function(r){var e=r.backgroundColor1,t=r.backgroundColor2;var n=tinycolor.readability(e,t);return n>2.5};var submitGtag=function(r){var e=zonosStore.checkoutSettings.analyticsProviders.find((function(r){return r.type==="GOOGLE_ANALYTICS"}));if(!e||(e===null||e===void 0?void 0:e.status)==="DISABLED"){return}if(typeof window.gtag==="function"){log("Zonos submits gtag event","log",r);window.gtag("event",r,{})}};var _c=createStore((function(){return{orderIdCreated:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}})),paypalStoreReset=_c.reset,paypalStore=_c.state;var paypalStoreCreaterOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n,o,a,i;var u=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:return[4,paypalCreateOrder({checkoutSessionId:u})];case 1:n=r.sent(),o=n.errors,a=n.json;i=(e=a===null||a===void 0?void 0:a.paypalOrderCreate)===null||e===void 0?void 0:e.paypalOrderId;if(o.length||!i){throw new Error(((t=o.find(Boolean))===null||t===void 0?void 0:t.message)||"An unexpected error occurred when creating paypal order.")}return[2,i]}}))}))};var paypalStoreCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n,o,a,i;var u=r.checkoutSessionId,c=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:new URL(window.location.href);return[4,paypalCaptureOrder({checkoutSessionId:u,paypalMockResponse:c})];case 1:n=r.sent(),o=n.errors,a=n.json;i=(e=a===null||a===void 0?void 0:a.paypalOrderCapture.order)===null||e===void 0?void 0:e.id;if(o.length||!i){throw new Error(((t=o.find(Boolean))===null||t===void 0?void 0:t.message)||translate("An unexpected error occurred when processing PayPal order."))}return[2,i]}}))}))};var paypalErrorHandler=function(r){var e=r.error;var t;var n=jsonParse(e.message);var o=(t=n===null||n===void 0?void 0:n.errors.find(Boolean))===null||t===void 0?void 0:t.message;var a=(o===null||o===void 0?void 0:o.match(/\[(.*?)\] (.*)/i))||[];if(!a){paypalStore.paypalErrorMessage=translate("An unexpected error occurred when processing PayPal order.")}var i=a[2]||translate("An unexpected error occurred when processing PayPal order.");paypalStore.paypalErrorMessage=i};var paypalButtonOptions=function(r){var e=r.checkoutSessionId,t=r.onPaypalFail,n=r.onPaypalSessionDone,o=r.overrideBorderRaidus,a=r.overridePrimaryColor;var i=a||zonosStore.appearance.colorPrimary;var u="#ffc33a";var c=isContrastColor({backgroundColor1:u,backgroundColor2:i||""});return{createOrder:function(){return __awaiter(void 0,void 0,void 0,(function(){var r,n,o,a;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,6,,7]);paypalStore.paypalErrorMessage=null;cartStore.inventoryCheckErrorMessage=null;i.label=1;case 1:i.trys.push([1,3,,4]);r=cartStore;return[4,stripeStoreHandleInventoryCheck()];case 2:r.inventoryCheckErrorMessage=i.sent();return[3,4];case 3:n=i.sent();cartStore.inventoryCheckErrorMessage=translate("Unable to check inventory. Please try again.");return[3,4];case 4:if(cartStore.inventoryCheckErrorMessage){return[2,""]}return[4,paypalStoreCreaterOrder({checkoutSessionId:e})];case 5:o=i.sent();return[2,o];case 6:a=i.sent();logError("Failed to create paypal order",a);paypalStore.paypalErrorMessage=translate("Failed to create PayPal order. Please try again, or consider using an alternative method.");t===null||t===void 0?void 0:t();return[2,""];case 7:return[2]}}))}))},onApprove:function(r,o){return __awaiter(void 0,void 0,void 0,(function(){var r,o;return __generator(this,(function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);paypalStore.paypalErrorMessage=null;submitGtag("zonos-checkout-payment-info");return[4,paypalStoreCaptureOrder({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse})];case 1:r=a.sent();paypalStore.orderIdCreated=r;n===null||n===void 0?void 0:n({orderId:r});cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,3];case 2:o=a.sent();logError("==== Failed to capture paypal order",o);if(o instanceof Error){return[2,paypalErrorHandler({error:o})]}t===null||t===void 0?void 0:t();return[3,3];case 3:return[2]}}))}))},style:{borderRadius:o==="SHARP"?0:10,color:c?"gold":"blue",shape:"rect"}}};var paypalStoreResetButtons=function(){if(!paypalStore.paypalButtons.length){return}paypalStore.paypalButtons.forEach((function(r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,r.close()];case 1:e.sent();return[2]}}))}))}));paypalStore.paypalButtons=[]};var paypalInitScript=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n,o,a;var i=r.currency;return __generator(this,(function(r){switch(r.label){case 0:t=!!((e=zonosStore.checkoutSettings.externalPaymentMethods)===null||e===void 0?void 0:e.find((function(r){return r.type==="PAYPAL"&&r.status==="ENABLED"})));if(!t){log("=== Paypal is disabled for this store","warn");return[2]}n=zonosStore.checkoutSettings.externalServiceTokens.find((function(r){return r.type==="PAYPAL_CLIENT_ID"}));if(!n){log("Failed to load paypal -- missing paypal publishable key","warn");return[2]}o=zonosStore.zonosMode==="production"&&zonosStore.checkoutSettings.mode==="LIVE"?"production":"sandbox";a=window.Zonos;return[4,loadScript({clientId:n.token,currency:i,environment:o})];case 1:a.paypal=r.sent();log("==== Paypal script loaded");return[2]}}))}))};var paypalStoreInitButtons=function(r){var e;var t=window.Zonos.paypal;if(!t){log("Paypal is not available");return null}var n=cartStore.checkoutSessionId;if(!n){log("Paypal is not available due to checkoutSessionId is not available");return null}log("==== Loading Paypal buttons");paypalStoreResetButtons();var o=[(e=t.FUNDING)===null||e===void 0?void 0:e.PAYPAL].filter(Boolean);paypalStore.paypalButtons=o.map((function(e){var o;var a=null;try{a=((o=t.Buttons)===null||o===void 0?void 0:o.call(t,Object.assign(Object.assign({},paypalButtonOptions(Object.assign({checkoutSessionId:n,fundingSource:e},r))),{fundingSource:e})))||null}catch(r){log("===== Failed to load paypal's \"".concat(e,'" button'),"warn",r)}if(a===null||a===void 0?void 0:a.isEligible()){log("==== Paypal button ".concat(e," loaded"));return a}return null})).filter(Boolean);return paypalStore.paypalButtons};var paypalStoreHasPaypalEnabled=function(){var r,e;var t=((e=(r=zonosStore.checkoutSettings.externalPaymentMethods)===null||r===void 0?void 0:r.find((function(r){return r.type==="PAYPAL"})))===null||e===void 0?void 0:e.status)==="ENABLED";return t||!!paypalStore.paypalButtons.length};export{paypalInitScript as a,paypalStore as b,paypalStoreReset as c,paypalStoreInitButtons as d,isContrastColor as i,paypalStoreHasPaypalEnabled as p,submitGtag as s};
17
+ */function findScript(r,e){var t=document.querySelector('script[src="'.concat(r,'"]'));if(t===null)return null;var n=createScriptElement(r,e);var o=t.cloneNode();delete o.dataset.uidAuto;if(Object.keys(o.dataset).length!==Object.keys(n.dataset).length){return null}var a=true;Object.keys(o.dataset).forEach((function(r){if(o.dataset[r]!==n.dataset[r]){a=false}}));return a?t:null}function insertScriptElement(r){var e=r.url,t=r.attributes,n=r.onSuccess,o=r.onError;var a=createScriptElement(e,t);a.onerror=o;a.onload=n;document.head.insertBefore(a,document.head.firstElementChild)}function processOptions(r){var e=r.environment;var t=e==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js";delete r.environment;if(r.sdkBaseUrl){t=r.sdkBaseUrl;delete r.sdkBaseUrl}var n=r;var o=Object.keys(n).filter((function(r){return typeof n[r]!=="undefined"&&n[r]!==null&&n[r]!==""})).reduce((function(r,e){var t=n[e].toString();e=camelCaseToKebabCase(e);if(e.substring(0,4)==="data"||e==="crossorigin"){r.attributes[e]=t}else{r.queryParams[e]=t}return r}),{queryParams:{},attributes:{}}),a=o.queryParams,i=o.attributes;if(a["merchant-id"]&&a["merchant-id"].indexOf(",")!==-1){i["data-merchant-id"]=a["merchant-id"];a["merchant-id"]="*"}return{url:"".concat(t,"?").concat(objectToQueryString(a)),attributes:i}}function camelCaseToKebabCase(r){var e=function(r,e){return(e?"-":"")+r.toLowerCase()};return r.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function objectToQueryString(r){var e="";Object.keys(r).forEach((function(t){if(e.length!==0)e+="&";e+=t+"="+r[t]}));return e}function createScriptElement(r,e){if(e===void 0){e={}}var t=document.createElement("script");t.src=r;Object.keys(e).forEach((function(r){t.setAttribute(r,e[r]);if(r==="data-csp-nonce"){t.setAttribute("nonce",e["data-csp-nonce"])}}));return t}function loadScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);if(typeof document==="undefined")return e.resolve(null);var t=processOptions(r),n=t.url,o=t.attributes;var a=o["data-namespace"]||"paypal";var i=getPayPalWindowNamespace(a);if(!o["data-js-sdk-library"]){o["data-js-sdk-library"]="paypal-js"}if(findScript(n,o)&&i){return e.resolve(i)}return loadCustomScript({url:n,attributes:o},e).then((function(){var r=getPayPalWindowNamespace(a);if(r){return r}throw new Error("The window.".concat(a," global variable is not available."))}))}function loadCustomScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);var t=r.url,n=r.attributes;if(typeof t!=="string"||t.length===0){throw new Error("Invalid url.")}if(typeof n!=="undefined"&&typeof n!=="object"){throw new Error("Expected attributes to be an object.")}return new e((function(r,e){if(typeof document==="undefined")return r();insertScriptElement({url:t,attributes:n,onSuccess:function(){return r()},onError:function(){var r=new Error('The script "'.concat(t,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(r)}})}))}function getPayPalWindowNamespace(r){return window[r]}function validateArguments(r,e){if(typeof r!=="object"||r===null){throw new Error("Expected an options object.")}var t=r.environment;if(t&&t!=="production"&&t!=="sandbox"){throw new Error('The `environment` option must be either "production" or "sandbox".')}if(typeof e!=="undefined"&&typeof e!=="function"){throw new Error("Expected PromisePonyfill to be a function.")}}var paypalCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n;var o=r.checkoutSessionId,a=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:o,paypalMockResponse:a},method:"POST"})];case 1:e=r.sent(),t=e.errors,n=e.json;return[2,{errors:t,json:n}]}}))}))};var paypalCreateOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n;var o=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:o},method:"POST"})];case 1:e=r.sent(),t=e.errors,n=e.json;return[2,{errors:t,json:n}]}}))}))};var isContrastColor=function(r){var e=r.backgroundColor1,t=r.backgroundColor2;var n=tinycolor.readability(e,t);return n>2.5};var submitGtag=function(r){var e=zonosStore.checkoutSettings.analyticsProviders.find((function(r){return r.type==="GOOGLE_ANALYTICS"}));if(!e||(e===null||e===void 0?void 0:e.status)==="DISABLED"){return}if(typeof window.gtag==="function"){log("Zonos submits gtag event","log",r);window.gtag("event",r,{})}};var _c=createStore((function(){return{orderIdCreated:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}})),paypalStoreReset=_c.reset,paypalStore=_c.state;var paypalStoreCreaterOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n,o,a,i;var u=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:return[4,paypalCreateOrder({checkoutSessionId:u})];case 1:n=r.sent(),o=n.errors,a=n.json;i=(e=a===null||a===void 0?void 0:a.paypalOrderCreate)===null||e===void 0?void 0:e.paypalOrderId;if(o.length||!i){throw new Error(((t=o.find(Boolean))===null||t===void 0?void 0:t.message)||"An unexpected error occurred when creating paypal order.")}return[2,i]}}))}))};var paypalStoreCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n,o,a,i;var u=r.checkoutSessionId,c=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,paypalCaptureOrder({checkoutSessionId:u,paypalMockResponse:c})];case 1:n=r.sent(),o=n.errors,a=n.json;i=(e=a===null||a===void 0?void 0:a.paypalOrderCapture.order)===null||e===void 0?void 0:e.id;if(o.length||!i){throw new Error(((t=o.find(Boolean))===null||t===void 0?void 0:t.message)||translate("An unexpected error occurred when processing PayPal order."))}return[2,i]}}))}))};var paypalErrorHandler=function(r){var e=r.error;var t;var n=jsonParse(e.message);var o=(t=n===null||n===void 0?void 0:n.errors.find(Boolean))===null||t===void 0?void 0:t.message;var a=(o===null||o===void 0?void 0:o.match(/\[(.*?)\] (.*)/i))||[];if(!a){paypalStore.paypalErrorMessage=translate("An unexpected error occurred when processing PayPal order.")}var i=a[2]||translate("An unexpected error occurred when processing PayPal order.");paypalStore.paypalErrorMessage=i};var paypalButtonOptions=function(r){var e=r.checkoutSessionId,t=r.onPaypalFail,n=r.onPaypalSessionDone,o=r.overrideBorderRaidus,a=r.overridePrimaryColor;var i=a||zonosStore.appearance.colorPrimary;var u="#ffc33a";var c=isContrastColor({backgroundColor1:u,backgroundColor2:i||""});return{createOrder:function(){return __awaiter(void 0,void 0,void 0,(function(){var r,n,o,a;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,6,,7]);paypalStore.paypalErrorMessage=null;cartStore.inventoryCheckErrorMessage=null;i.label=1;case 1:i.trys.push([1,3,,4]);r=cartStore;return[4,stripeStoreHandleInventoryCheck()];case 2:r.inventoryCheckErrorMessage=i.sent();return[3,4];case 3:n=i.sent();cartStore.inventoryCheckErrorMessage=translate("Unable to check inventory. Please try again.");return[3,4];case 4:if(cartStore.inventoryCheckErrorMessage){return[2,""]}return[4,paypalStoreCreaterOrder({checkoutSessionId:e})];case 5:o=i.sent();return[2,o];case 6:a=i.sent();logError("Failed to create paypal order",a);paypalStore.paypalErrorMessage=translate("Failed to create PayPal order. Please try again, or consider using an alternative method.");t===null||t===void 0?void 0:t();return[2,""];case 7:return[2]}}))}))},onApprove:function(r,o){return __awaiter(void 0,void 0,void 0,(function(){var r,o;return __generator(this,(function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);paypalStore.paypalErrorMessage=null;submitGtag("zonos-checkout-payment-info");return[4,paypalStoreCaptureOrder({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse})];case 1:r=a.sent();paypalStore.orderIdCreated=r;n===null||n===void 0?void 0:n({orderId:r});cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,3];case 2:o=a.sent();logError("==== Failed to capture paypal order",o);if(o instanceof Error){return[2,paypalErrorHandler({error:o})]}t===null||t===void 0?void 0:t();return[3,3];case 3:return[2]}}))}))},style:{borderRadius:o==="SHARP"?0:10,color:c?"gold":"blue",shape:"rect"}}};var paypalStoreResetButtons=function(){if(!paypalStore.paypalButtons.length){return}paypalStore.paypalButtons.forEach((function(r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,r.close()];case 1:e.sent();return[2]}}))}))}));paypalStore.paypalButtons=[]};var paypalInitScript=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,n,o,a;var i=r.currency;return __generator(this,(function(r){switch(r.label){case 0:t=!!((e=zonosStore.checkoutSettings.externalPaymentMethods)===null||e===void 0?void 0:e.find((function(r){return r.type==="PAYPAL"&&r.status==="ENABLED"})));if(!t){log("=== Paypal is disabled for this store","warn");return[2]}n=zonosStore.checkoutSettings.externalServiceTokens.find((function(r){return r.type==="PAYPAL_CLIENT_ID"}));if(!n){log("Failed to load paypal -- missing paypal publishable key","warn");return[2]}o=zonosStore.zonosMode==="production"&&zonosStore.checkoutSettings.mode==="LIVE"?"production":"sandbox";a=window.Zonos;return[4,loadScript({clientId:n.token,currency:i,environment:o})];case 1:a.paypal=r.sent();log("==== Paypal script loaded");return[2]}}))}))};var paypalStoreInitButtons=function(r){var e;var t=window.Zonos.paypal;if(!t){log("Paypal is not available");return null}var n=cartStore.checkoutSessionId;if(!n){log("Paypal is not available due to checkoutSessionId is not available");return null}log("==== Loading Paypal buttons");paypalStoreResetButtons();var o=[(e=t.FUNDING)===null||e===void 0?void 0:e.PAYPAL].filter(Boolean);paypalStore.paypalButtons=o.map((function(e){var o;var a=null;try{a=((o=t.Buttons)===null||o===void 0?void 0:o.call(t,Object.assign(Object.assign({},paypalButtonOptions(Object.assign({checkoutSessionId:n,fundingSource:e},r))),{fundingSource:e})))||null}catch(r){log("===== Failed to load paypal's \"".concat(e,'" button'),"warn",r)}if(a===null||a===void 0?void 0:a.isEligible()){log("==== Paypal button ".concat(e," loaded"));return a}return null})).filter(Boolean);return paypalStore.paypalButtons};var paypalStoreHasPaypalEnabled=function(){var r,e;var t=((e=(r=zonosStore.checkoutSettings.externalPaymentMethods)===null||r===void 0?void 0:r.find((function(r){return r.type==="PAYPAL"})))===null||e===void 0?void 0:e.status)==="ENABLED";return t||!!paypalStore.paypalButtons.length};export{paypalInitScript as a,paypalStore as b,paypalStoreReset as c,paypalStoreInitButtons as d,isContrastColor as i,paypalStoreHasPaypalEnabled as p,submitGtag as s};