@zonos/elements 1.3.20-alpha.1 → 1.3.21

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.
@@ -236,8 +236,8 @@ const zonosLoadUrl = (() => {
236
236
  }
237
237
  return null;
238
238
  })();
239
- const ZONOS_URL = zonosLoadUrl || "https://v1.3.20-alpha.1.js.zonos.com";
240
- const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1";
239
+ const ZONOS_URL = zonosLoadUrl || "https://v1.3.21.js.zonos.com";
240
+ const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21";
241
241
  const INTER_FONT_URL = 'https://rsms.me';
242
242
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
243
243
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -257,7 +257,7 @@ Zonos.isBigCommerce = false;
257
257
  Zonos.isNpm = true;
258
258
  Zonos.internationalHideSelector = '';
259
259
  Zonos.zonosQaUrl = null;
260
- Zonos.version = `v${"1.3.20-alpha.1"}`;
260
+ Zonos.version = `v${"1.3.21"}`;
261
261
  Zonos.modeAlerted = false;
262
262
  Zonos.tempCartData = null;
263
263
  Zonos.getCurrentTimestamp = () => new Date().getTime();
@@ -1,6 +1,7 @@
1
1
  // eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
2
2
  import "./global.d";
3
3
  export * from '../components.d';
4
+ export * from './checkout/api/CalculateLandedCostRequest';
4
5
  export * from './checkout/CheckoutConfig';
5
6
  export * from './hello/HelloConfig';
6
7
  export * from './JsonError';
package/dist/esm/index.js CHANGED
@@ -232,8 +232,8 @@ const zonosLoadUrl = (() => {
232
232
  }
233
233
  return null;
234
234
  })();
235
- const ZONOS_URL = zonosLoadUrl || "https://v1.3.20-alpha.1.js.zonos.com";
236
- const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1";
235
+ const ZONOS_URL = zonosLoadUrl || "https://v1.3.21.js.zonos.com";
236
+ const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21";
237
237
  const INTER_FONT_URL = 'https://rsms.me';
238
238
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
239
239
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -253,7 +253,7 @@ Zonos.isBigCommerce = false;
253
253
  Zonos.isNpm = true;
254
254
  Zonos.internationalHideSelector = '';
255
255
  Zonos.zonosQaUrl = null;
256
- Zonos.version = `v${"1.3.20-alpha.1"}`;
256
+ Zonos.version = `v${"1.3.21"}`;
257
257
  Zonos.modeAlerted = false;
258
258
  Zonos.tempCartData = null;
259
259
  Zonos.getCurrentTimestamp = () => new Date().getTime();
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,o,e,r){function t(n){return n instanceof e?n:new e((function(o){o(n)}))}return new(e||(e=Promise))((function(e,i){function s(n){try{u(r.next(n))}catch(n){i(n)}}function a(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?e(n.value):t(n.value).then(s,a)}u((r=r.apply(n,o||[])).next())}))};var __generator=this&&this.__generator||function(n,o){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(o){return u([n,o])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(e=0)),e)try{if(r=1,t&&(i=a[0]&2?t["return"]:a[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,a[1])).done)return i;if(t=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;t=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){e.label=a[1];break}if(a[0]===6&&e.label<i[1]){e.label=i[1];i=a;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(a);break}if(i[2])e.ops.pop();e.trys.pop();continue}a=o.call(n,e)}catch(n){a=[6,n];t=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{l as log,a as logError}from"./logError-c456c092.js";var checkIfLoadVersionDomain=function(n){var o=n.loadScriptSrc;if(!o){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var e=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(o).origin;var i=e.some((function(n){return t.includes(n)}));var s=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:s,isWhiteListed:i}};var extractZonosQaUrl=function(n){if(!n){return null}var o=new URL(n).searchParams;var e=o.get("zonosQaUrl");if(!e){return null}var r=/[^a-zA-Z0-9-_]+/.test(e);if(!!r){return null}return e};var getZonosQaUrl=function(){if(typeof window==="undefined"){return null}var n=extractZonosQaUrl(window.location.href);if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var o="preview.js.zonos.com";var e="https://".concat(n,".").concat(o);log("[ZONOS-WARNING] using '".concat(e,"' for loading script"),"warn");void fetch(e).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(e,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var o=window.location.pathname;var r="".concat(o,"?").concat(n.toString());window.history.replaceState(window.history.state,"",r);window.location.reload();return null}));return e};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 o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(!V3_URL_REGEX.test(e.src)){continue}return e}return null};var stripePromise$1=null;var injectScript=function(n){var o=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var e=document.createElement("script");e.src="".concat(V3_URL).concat(o);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(e);return e};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(o,e){if(typeof window==="undefined"||typeof document==="undefined"){o(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){o(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){o(window.Stripe)}else{e(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){e(new Error("Failed to load Stripe.js"))}))}catch(n){e(n);return}}));return stripePromise$1};var registerWrapper=function(n,o){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:o})};var initStripe=function(n,o,e){if(n===null){return null}var r=n.apply(undefined,o);registerWrapper(r,e);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 o=0;o<arguments.length;o++){n[o]=arguments[o]}return __awaiter(void 0,void 0,void 0,(function(){var o;return __generator(this,(function(e){loadCalled=true;o=Date.now();return[2,stripePromise.then((function(e){return initStripe(e,n,o)}))]}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var o=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),e=o.currentLoadScriptUrl,r=o.isWhiteListed;if(r){return e}return null}();var ZONOS_URL=zonosLoadUrl||"https://v1.3.20-alpha.1.js.zonos.com";var JS_DELIVR_ZONOS_URL="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1";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.isBigCommerce=false;Zonos.isNpm=true;Zonos.internationalHideSelector="";Zonos.zonosQaUrl=null;Zonos.version="v".concat("1.3.20-alpha.1");Zonos.modeAlerted=false;Zonos.tempCartData=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,[n],void 0,(function(n){var o=n.appearance,e=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,s=n.storeId,a=n.zonosApiKey;return __generator(this,(function(n){if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));if(!a){logError("Missing Zonos API key");return[2]}_a.zonosApiKey=a;_a.storeId=s;log("init zonos");_a.injectSentryScript();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:o,checkoutSettings:e,currencyConverter:r,helloSettings:t,onCountryChange:i},zonosApiKey: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 o=document.querySelector("zonos-hello");if(o){void o.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.showNotification(n))};Zonos.updateOrganizationName=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var o=n.autoEnable,e=o===void 0?true:o,r=n.disable,t=n.placeOrderButtonSelector;if(t){var i=document.querySelectorAll(t);var s=function(n){var o=n.target;if(o.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};i.forEach((function(n){var o=n.getAttribute("data-zonos-checkout-attached");if(o){return}if(r){n.setAttribute("disabled","true");n.addEventListener("click",s)}else{n.removeAttribute("disabled");n.removeEventListener("click",s)}}));if(e&&r){setTimeout((function(){i.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",s)}))}),5e3)}}};Zonos.injectController=function(n){var o=n.config,e=n.zonosApiKey;var r;if(document.querySelector("zonos-controller")){return}if((r=o.checkoutSettings)===null||r===void 0?void 0:r.placeOrderButtonSelector){var t=o.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=o;s.zonosApiKey=e;s.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var o,e;return __generator(this,(function(r){switch(r.label){case 0:o=n.detail;log("loading Stripe");return[4,zonosLoadStripe(o.publishableKey)];case 1:e=r.sent();if(!e){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=e;void s.initCheckoutElement(e);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectSentryScript=function(){var n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";var o=function(){var o=document.querySelector('script[src="'.concat(n,'"]'));return!!o};if(o()){log("Sentry script already exists in the document","warn");return}var e=document.head||document.body;var r=document.createElement("script");r.crossOrigin="anonymous";r.src=n;r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l";r.setAttribute("data-lazy","no");r.onerror=function(){logError("Failed to load ".concat(r.src))};r.onload=function(){var n;(n=window.Sentry)===null||n===void 0?void 0:n.init({beforeSend:function(n){var o,e,r,t,i,s;var a=(s=(i=(t=(r=(e=(o=n.exception)===null||o===void 0?void 0:o.values)===null||e===void 0?void 0:e[0])===null||r===void 0?void 0:r.stacktrace)===null||t===void 0?void 0:t.frames)===null||i===void 0?void 0:i[0])===null||s===void 0?void 0:s.filename;var u=(a===null||a===void 0?void 0:a.includes("js.zonos.com"))||(a===null||a===void 0?void 0:a.includes("@zonos/elements"));var l=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");if(u&&!l){return n}return null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:"zonos-elements@".concat(_a.version),tracesSampler:function(){return.01}})};e.appendChild(r)};Zonos.injectScript=function(n){var o=n.fallBackDomain,e=n.isModule,r=n.scriptDomain,t=n.theRestUrl;var i="".concat(r,"/").concat(t);var s=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(s()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var a=document.head||document.body;var u=document.createElement("script");if(!!e){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){var n=/\/\/v\d+\./g.test(r);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o){_a.injectScript({isModule:e,scriptDomain:o,theRestUrl:t})}logError("Failed to load ".concat(u.src))};a.appendChild(u)};Zonos.getZonosUrl=function(){if(_a.isNpm){var n=getZonosQaUrl();return n||ZONOS_URL}return ZONOS_URL};Zonos.injectZonosCdn=function(){var n=_a.getZonosUrl();_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:true,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:false,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var o=n.fallBackDomain,e=n.stylesheetDomain,r=n.theRestUrl;var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(e,"/").concat(r);s.onerror=function(){var n=/\/\/v\d+\./g.test(e);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o&&n){_a.injectStylesheet({stylesheetDomain:o,theRestUrl:r})}logError("Failed to load ".concat(s.href))};t.appendChild(s)};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({fallBackDomain:JS_DELIVR_ZONOS_URL,stylesheetDomain:ZONOS_URL,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 o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(INTER_FONT_REGEX.test(e.href)){continue}return e}return null};if(n()){log("Inter font already injected","warn");return}var o=document.head||document.body;var e=document.createElement("link");e.rel="preconnect";e.href=INTER_FONT_URL;o.appendChild(e);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");o.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var o;log("[FONT] injecting ".concat(n));var e=(o=n.match(/family=(.*?):/))===null||o===void 0?void 0:o[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(e," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(e," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(n,o,e,r){function t(n){return n instanceof e?n:new e((function(o){o(n)}))}return new(e||(e=Promise))((function(e,i){function s(n){try{u(r.next(n))}catch(n){i(n)}}function a(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?e(n.value):t(n.value).then(s,a)}u((r=r.apply(n,o||[])).next())}))};var __generator=this&&this.__generator||function(n,o){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(o){return u([n,o])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(e=0)),e)try{if(r=1,t&&(i=a[0]&2?t["return"]:a[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,a[1])).done)return i;if(t=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;t=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){e.label=a[1];break}if(a[0]===6&&e.label<i[1]){e.label=i[1];i=a;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(a);break}if(i[2])e.ops.pop();e.trys.pop();continue}a=o.call(n,e)}catch(n){a=[6,n];t=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{l as log,a as logError}from"./logError-c456c092.js";var checkIfLoadVersionDomain=function(n){var o=n.loadScriptSrc;if(!o){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var e=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(o).origin;var i=e.some((function(n){return t.includes(n)}));var s=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:s,isWhiteListed:i}};var extractZonosQaUrl=function(n){if(!n){return null}var o=new URL(n).searchParams;var e=o.get("zonosQaUrl");if(!e){return null}var r=/[^a-zA-Z0-9-_]+/.test(e);if(!!r){return null}return e};var getZonosQaUrl=function(){if(typeof window==="undefined"){return null}var n=extractZonosQaUrl(window.location.href);if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var o="preview.js.zonos.com";var e="https://".concat(n,".").concat(o);log("[ZONOS-WARNING] using '".concat(e,"' for loading script"),"warn");void fetch(e).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(e,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var o=window.location.pathname;var r="".concat(o,"?").concat(n.toString());window.history.replaceState(window.history.state,"",r);window.location.reload();return null}));return e};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 o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(!V3_URL_REGEX.test(e.src)){continue}return e}return null};var stripePromise$1=null;var injectScript=function(n){var o=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var e=document.createElement("script");e.src="".concat(V3_URL).concat(o);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(e);return e};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(o,e){if(typeof window==="undefined"||typeof document==="undefined"){o(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){o(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){o(window.Stripe)}else{e(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){e(new Error("Failed to load Stripe.js"))}))}catch(n){e(n);return}}));return stripePromise$1};var registerWrapper=function(n,o){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:o})};var initStripe=function(n,o,e){if(n===null){return null}var r=n.apply(undefined,o);registerWrapper(r,e);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 o=0;o<arguments.length;o++){n[o]=arguments[o]}return __awaiter(void 0,void 0,void 0,(function(){var o;return __generator(this,(function(e){loadCalled=true;o=Date.now();return[2,stripePromise.then((function(e){return initStripe(e,n,o)}))]}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var o=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),e=o.currentLoadScriptUrl,r=o.isWhiteListed;if(r){return e}return null}();var ZONOS_URL=zonosLoadUrl||"https://v1.3.21.js.zonos.com";var JS_DELIVR_ZONOS_URL="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21";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.isBigCommerce=false;Zonos.isNpm=true;Zonos.internationalHideSelector="";Zonos.zonosQaUrl=null;Zonos.version="v".concat("1.3.21");Zonos.modeAlerted=false;Zonos.tempCartData=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,[n],void 0,(function(n){var o=n.appearance,e=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,s=n.storeId,a=n.zonosApiKey;return __generator(this,(function(n){if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));if(!a){logError("Missing Zonos API key");return[2]}_a.zonosApiKey=a;_a.storeId=s;log("init zonos");_a.injectSentryScript();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:o,checkoutSettings:e,currencyConverter:r,helloSettings:t,onCountryChange:i},zonosApiKey: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 o=document.querySelector("zonos-hello");if(o){void o.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.showNotification(n))};Zonos.updateOrganizationName=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var o=n.autoEnable,e=o===void 0?true:o,r=n.disable,t=n.placeOrderButtonSelector;if(t){var i=document.querySelectorAll(t);var s=function(n){var o=n.target;if(o.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};i.forEach((function(n){var o=n.getAttribute("data-zonos-checkout-attached");if(o){return}if(r){n.setAttribute("disabled","true");n.addEventListener("click",s)}else{n.removeAttribute("disabled");n.removeEventListener("click",s)}}));if(e&&r){setTimeout((function(){i.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",s)}))}),5e3)}}};Zonos.injectController=function(n){var o=n.config,e=n.zonosApiKey;var r;if(document.querySelector("zonos-controller")){return}if((r=o.checkoutSettings)===null||r===void 0?void 0:r.placeOrderButtonSelector){var t=o.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=o;s.zonosApiKey=e;s.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var o,e;return __generator(this,(function(r){switch(r.label){case 0:o=n.detail;log("loading Stripe");return[4,zonosLoadStripe(o.publishableKey)];case 1:e=r.sent();if(!e){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=e;void s.initCheckoutElement(e);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectSentryScript=function(){var n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";var o=function(){var o=document.querySelector('script[src="'.concat(n,'"]'));return!!o};if(o()){log("Sentry script already exists in the document","warn");return}var e=document.head||document.body;var r=document.createElement("script");r.crossOrigin="anonymous";r.src=n;r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l";r.setAttribute("data-lazy","no");r.onerror=function(){logError("Failed to load ".concat(r.src))};r.onload=function(){var n;(n=window.Sentry)===null||n===void 0?void 0:n.init({beforeSend:function(n){var o,e,r,t,i,s;var a=(s=(i=(t=(r=(e=(o=n.exception)===null||o===void 0?void 0:o.values)===null||e===void 0?void 0:e[0])===null||r===void 0?void 0:r.stacktrace)===null||t===void 0?void 0:t.frames)===null||i===void 0?void 0:i[0])===null||s===void 0?void 0:s.filename;var u=(a===null||a===void 0?void 0:a.includes("js.zonos.com"))||(a===null||a===void 0?void 0:a.includes("@zonos/elements"));var l=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");if(u&&!l){return n}return null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:"zonos-elements@".concat(_a.version),tracesSampler:function(){return.01}})};e.appendChild(r)};Zonos.injectScript=function(n){var o=n.fallBackDomain,e=n.isModule,r=n.scriptDomain,t=n.theRestUrl;var i="".concat(r,"/").concat(t);var s=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(s()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var a=document.head||document.body;var u=document.createElement("script");if(!!e){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){var n=/\/\/v\d+\./g.test(r);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o){_a.injectScript({isModule:e,scriptDomain:o,theRestUrl:t})}logError("Failed to load ".concat(u.src))};a.appendChild(u)};Zonos.getZonosUrl=function(){if(_a.isNpm){var n=getZonosQaUrl();return n||ZONOS_URL}return ZONOS_URL};Zonos.injectZonosCdn=function(){var n=_a.getZonosUrl();_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:true,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:false,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var o=n.fallBackDomain,e=n.stylesheetDomain,r=n.theRestUrl;var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(e,"/").concat(r);s.onerror=function(){var n=/\/\/v\d+\./g.test(e);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o&&n){_a.injectStylesheet({stylesheetDomain:o,theRestUrl:r})}logError("Failed to load ".concat(s.href))};t.appendChild(s)};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({fallBackDomain:JS_DELIVR_ZONOS_URL,stylesheetDomain:ZONOS_URL,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 o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(INTER_FONT_REGEX.test(e.href)){continue}return e}return null};if(n()){log("Inter font already injected","warn");return}var o=document.head||document.body;var e=document.createElement("link");e.rel="preconnect";e.href=INTER_FONT_URL;o.appendChild(e);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");o.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var o;log("[FONT] injecting ".concat(n));var e=(o=n.match(/family=(.*?):/))===null||o===void 0?void 0:o[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(e," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(e," font injected!"))};export{Zonos};
@@ -3474,6 +3474,46 @@ declare module "@stencil/core" {
3474
3474
  }
3475
3475
  }
3476
3476
 
3477
+ type CalculateLandedCostRequest = {
3478
+ billingAddress: {
3479
+ addressLine1: string;
3480
+ addressLine2?: string | undefined;
3481
+ city: string;
3482
+ country: string;
3483
+ postalCode: string;
3484
+ state: string;
3485
+ };
3486
+ billingContact: {
3487
+ firstName: string;
3488
+ lastName: string;
3489
+ phone: string;
3490
+ };
3491
+ checkoutSessionId: string;
3492
+ contact: {
3493
+ email?: string;
3494
+ firstName: string;
3495
+ lastName: string;
3496
+ phone: string;
3497
+ };
3498
+ items: CartItem[];
3499
+ landedCostAdjustments?: {
3500
+ amount: number;
3501
+ type: LandedCostAdjustmentType;
3502
+ }[];
3503
+ metadata?: {
3504
+ key: string;
3505
+ value: string;
3506
+ }[];
3507
+ shippingAddress: {
3508
+ addressLine1: string;
3509
+ addressLine2?: string | undefined;
3510
+ city: string;
3511
+ country: string;
3512
+ postalCode: string;
3513
+ state: string;
3514
+ };
3515
+ };
3516
+
3477
3517
  type HelloConfig = {
3478
3518
  anchorElementSelector: string;
3479
3519
  cartUrlPattern: string | null;
@@ -3553,46 +3593,6 @@ type CartItem = {
3553
3593
  sku?: string;
3554
3594
  };
3555
3595
 
3556
- type CalculateLandedCostRequest = {
3557
- billingAddress: {
3558
- addressLine1: string;
3559
- addressLine2?: string | undefined;
3560
- city: string;
3561
- country: string;
3562
- postalCode: string;
3563
- state: string;
3564
- };
3565
- billingContact: {
3566
- firstName: string;
3567
- lastName: string;
3568
- phone: string;
3569
- };
3570
- checkoutSessionId: string;
3571
- contact: {
3572
- email?: string;
3573
- firstName: string;
3574
- lastName: string;
3575
- phone: string;
3576
- };
3577
- items: CartItem[];
3578
- landedCostAdjustments?: {
3579
- amount: number;
3580
- type: LandedCostAdjustmentType;
3581
- }[];
3582
- metadata?: {
3583
- key: string;
3584
- value: string;
3585
- }[];
3586
- shippingAddress: {
3587
- addressLine1: string;
3588
- addressLine2?: string | undefined;
3589
- city: string;
3590
- country: string;
3591
- postalCode: string;
3592
- state: string;
3593
- };
3594
- };
3595
-
3596
3596
  type BuildLandedCostParams = {
3597
3597
  billingAddress: CalculateLandedCostRequest['billingAddress'];
3598
3598
  billingContact: CalculateLandedCostRequest['billingContact'];
@@ -3601,13 +3601,14 @@ type BuildLandedCostParams = {
3601
3601
  shippingAddress: CalculateLandedCostRequest['shippingAddress'];
3602
3602
  zonosApiRoute: string;
3603
3603
  };
3604
- type BuildLandedCostResponse = Promise<(CalculateLandedCostMutation & {
3604
+ type BuildLandedCostResponse = (CalculateLandedCostMutation & {
3605
3605
  errors?: {
3606
3606
  message: string;
3607
3607
  }[];
3608
- }) | null>;
3608
+ }) | null;
3609
3609
 
3610
3610
  type ZonosOrder = GetOrderQuery['order'];
3611
+
3611
3612
  type CheckoutConfig = {
3612
3613
  /**
3613
3614
  * Validate address to allow specific character sets
@@ -3676,7 +3677,7 @@ type CheckoutConfig = {
3676
3677
  * Calculate landed cost callback for checkout (optional)
3677
3678
  * @note will use temp cart data if available
3678
3679
  */
3679
- buildLandedCost?: (params: BuildLandedCostParams) => BuildLandedCostResponse;
3680
+ buildLandedCost?: (params: BuildLandedCostParams) => Promise<BuildLandedCostResponse>;
3680
3681
  /**
3681
3682
  * Callback trigger when the checkout is closed
3682
3683
  */
@@ -1 +1 @@
1
- (function(){"use strict";const e=(e,t,...n)=>{var o,r;if(!(!!(null===(o=window.Zonos)||void 0===o?void 0:o.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...n));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(r=s.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(t){case"warn":i.warn(e,...n);break;case"info":i.info(e,...n);break;case"error":i.error(e,...n);break;default:i.groupCollapsed(e,...n),i.trace(),i.groupEnd()}},t=(t,...n)=>{e(t,"error",...n)},n=()=>{if("undefined"==typeof window)return null;const t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href);if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${n}' for loading script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},o="https://js.stripe.com/v3",r=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let i=null;const l=e=>(null!==i||(i=new Promise(((n,i)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)n(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&r.test(n.src))return n}return null})();l&&e?console.warn(s):l||(l=(e=>{const n=document.createElement("script");n.src=`${o}`;const r=document.head||document.body;return r?(r.appendChild(n),n):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==l||l.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):i(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{i(new Error("Failed to load Stripe.js"))}))}catch(e){return void i(e)}else n(null)}))),i),c=Promise.resolve().then((()=>l(null)));let d=!1;c.catch((e=>{d||console.warn(e)}));var a;const u=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,n=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),o=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:o,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?t:null})()||"https://v1.3.20-alpha.1.js.zonos.com",m="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1",p="https://rsms.me",h="https://fonts.googleapis.com",y=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class w{}a=w,w.doneInit=!1,w.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),w.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),w.isBigCommerce=!1,w.isNpm=!0,w.internationalHideSelector="",w.zonosQaUrl=null,w.version="v1.3.20-alpha.1",w.modeAlerted=!1,w.tempCartData=null,w.getCurrentTimestamp=()=>(new Date).getTime(),w.zonosController=null,w.init=async({appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,storeId:l,zonosApiKey:c})=>{a.doneInit||(e(`====== ZONOS DEBUG MODE: on (${a.version}) ======`),c?(a.zonosApiKey=c,a.storeId=l,e("init zonos"),a.injectSentryScript(),a.injectZonosCdn(),a.injectZonosCss(),a.injectFonts(),a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i},zonosApiKey:c}),a.doneInit=!0):t("Missing Zonos API key"))},w.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},w.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},w.showNotification=e=>{var t;null===(t=a.zonosController)||void 0===t||t.showNotification(e)},w.updateOrganizationName=e=>{var t;null===(t=a.zonosController)||void 0===t||t.updateOrganizationName(e)},w.disablePlaceOrderButtons=({autoEnable:e=!0,disable:t,placeOrderButtonSelector:n})=>{if(n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},w.injectController=({config:n,zonosApiKey:o})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=n.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=o,s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{d=!0;const t=Date.now();return c.then((n=>((e,t,n)=>{if(null===e)return null;const o=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(o,n),o})(n,e,t)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),a.zonosController=s,e("Zonos controller injected!")},w.injectSentryScript=()=>{const n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${n}"]`))return void e("Sentry script already exists in the document","warn");const o=document.head||document.body,r=document.createElement("script");r.crossOrigin="anonymous",r.src=n,r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",r.setAttribute("data-lazy","no"),r.onerror=()=>{t(`Failed to load ${r.src}`)},r.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({beforeSend(e){var t,n,o,r,s,i;const l=null===(i=null===(s=null===(r=null===(o=null===(n=null===(t=e.exception)||void 0===t?void 0:t.values)||void 0===n?void 0:n[0])||void 0===o?void 0:o.stacktrace)||void 0===r?void 0:r.frames)||void 0===s?void 0:s[0])||void 0===i?void 0:i.filename,c=(null==l?void 0:l.includes("js.zonos.com"))||(null==l?void 0:l.includes("@zonos/elements")),d=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");return c&&!d?e:null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${a.version}`,tracesSampler:()=>.01})},o.appendChild(r)},w.injectScript=({fallBackDomain:n,isModule:o,scriptDomain:r,theRestUrl:s})=>{const i=`${r}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{/\/\/v\d+\./g.test(r)?(n&&a.injectScript({isModule:o,scriptDomain:n,theRestUrl:s}),t(`Failed to load ${c.src}`)):e("No need to fallback since this is not a versioned domain","warn")},l.appendChild(c)},w.getZonosUrl=()=>{if(a.isNpm){return n()||u}return u},w.injectZonosCdn=()=>{const t=a.getZonosUrl();a.injectScript({fallBackDomain:m,isModule:!0,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),a.injectScript({fallBackDomain:m,isModule:!1,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},w.injectStylesheet=({fallBackDomain:n,stylesheetDomain:o,theRestUrl:r})=>{const s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${u}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${o}/${r}`,l.onerror=()=>{const s=/\/\/v\d+\./g.test(o);s?(n&&s&&a.injectStylesheet({stylesheetDomain:n,theRestUrl:r}),t(`Failed to load ${l.href}`)):e("No need to fallback since this is not a versioned domain","warn")},s.appendChild(l)},w.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(a.injectStylesheet({fallBackDomain:m,stylesheetDomain:u,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},w.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${p}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&!y.test(n.href))return n}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=p,t.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${p}/inter/inter.css`,t.appendChild(o),e("Zonos font injected!")},w.setupGoogleFont=e=>{var t;null===(t=a.zonosController)||void 0===t||t.setupGoogleFont(e)},w.injectSupportGoogleFont=t=>{var n;e(`[FONT] injecting ${t}`);const o=null===(n=t.match(/family=(.*?):/))||void 0===n?void 0:n[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${h}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=h,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${o} font injected!`)},exports.Zonos=w})();
1
+ (function(){"use strict";const e=(e,t,...n)=>{var o,r;if(!(!!(null===(o=window.Zonos)||void 0===o?void 0:o.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...n));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(r=s.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(t){case"warn":i.warn(e,...n);break;case"info":i.info(e,...n);break;case"error":i.error(e,...n);break;default:i.groupCollapsed(e,...n),i.trace(),i.groupEnd()}},t=(t,...n)=>{e(t,"error",...n)},n=()=>{if("undefined"==typeof window)return null;const t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href);if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${n}' for loading script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},o="https://js.stripe.com/v3",r=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let i=null;const l=e=>(null!==i||(i=new Promise(((n,i)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)n(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&r.test(n.src))return n}return null})();l&&e?console.warn(s):l||(l=(e=>{const n=document.createElement("script");n.src=`${o}`;const r=document.head||document.body;return r?(r.appendChild(n),n):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==l||l.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):i(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{i(new Error("Failed to load Stripe.js"))}))}catch(e){return void i(e)}else n(null)}))),i),c=Promise.resolve().then((()=>l(null)));let d=!1;c.catch((e=>{d||console.warn(e)}));var a;const u=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,n=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),o=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:o,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?t:null})()||"https://v1.3.21.js.zonos.com",m="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21",p="https://rsms.me",h="https://fonts.googleapis.com",y=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class w{}a=w,w.doneInit=!1,w.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),w.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),w.isBigCommerce=!1,w.isNpm=!0,w.internationalHideSelector="",w.zonosQaUrl=null,w.version="v1.3.21",w.modeAlerted=!1,w.tempCartData=null,w.getCurrentTimestamp=()=>(new Date).getTime(),w.zonosController=null,w.init=async({appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,storeId:l,zonosApiKey:c})=>{a.doneInit||(e(`====== ZONOS DEBUG MODE: on (${a.version}) ======`),c?(a.zonosApiKey=c,a.storeId=l,e("init zonos"),a.injectSentryScript(),a.injectZonosCdn(),a.injectZonosCss(),a.injectFonts(),a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i},zonosApiKey:c}),a.doneInit=!0):t("Missing Zonos API key"))},w.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},w.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},w.showNotification=e=>{var t;null===(t=a.zonosController)||void 0===t||t.showNotification(e)},w.updateOrganizationName=e=>{var t;null===(t=a.zonosController)||void 0===t||t.updateOrganizationName(e)},w.disablePlaceOrderButtons=({autoEnable:e=!0,disable:t,placeOrderButtonSelector:n})=>{if(n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},w.injectController=({config:n,zonosApiKey:o})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=n.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=o,s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{d=!0;const t=Date.now();return c.then((n=>((e,t,n)=>{if(null===e)return null;const o=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(o,n),o})(n,e,t)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),a.zonosController=s,e("Zonos controller injected!")},w.injectSentryScript=()=>{const n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${n}"]`))return void e("Sentry script already exists in the document","warn");const o=document.head||document.body,r=document.createElement("script");r.crossOrigin="anonymous",r.src=n,r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",r.setAttribute("data-lazy","no"),r.onerror=()=>{t(`Failed to load ${r.src}`)},r.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({beforeSend(e){var t,n,o,r,s,i;const l=null===(i=null===(s=null===(r=null===(o=null===(n=null===(t=e.exception)||void 0===t?void 0:t.values)||void 0===n?void 0:n[0])||void 0===o?void 0:o.stacktrace)||void 0===r?void 0:r.frames)||void 0===s?void 0:s[0])||void 0===i?void 0:i.filename,c=(null==l?void 0:l.includes("js.zonos.com"))||(null==l?void 0:l.includes("@zonos/elements")),d=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");return c&&!d?e:null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${a.version}`,tracesSampler:()=>.01})},o.appendChild(r)},w.injectScript=({fallBackDomain:n,isModule:o,scriptDomain:r,theRestUrl:s})=>{const i=`${r}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{/\/\/v\d+\./g.test(r)?(n&&a.injectScript({isModule:o,scriptDomain:n,theRestUrl:s}),t(`Failed to load ${c.src}`)):e("No need to fallback since this is not a versioned domain","warn")},l.appendChild(c)},w.getZonosUrl=()=>{if(a.isNpm){return n()||u}return u},w.injectZonosCdn=()=>{const t=a.getZonosUrl();a.injectScript({fallBackDomain:m,isModule:!0,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),a.injectScript({fallBackDomain:m,isModule:!1,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},w.injectStylesheet=({fallBackDomain:n,stylesheetDomain:o,theRestUrl:r})=>{const s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${u}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${o}/${r}`,l.onerror=()=>{const s=/\/\/v\d+\./g.test(o);s?(n&&s&&a.injectStylesheet({stylesheetDomain:n,theRestUrl:r}),t(`Failed to load ${l.href}`)):e("No need to fallback since this is not a versioned domain","warn")},s.appendChild(l)},w.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(a.injectStylesheet({fallBackDomain:m,stylesheetDomain:u,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},w.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${p}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&!y.test(n.href))return n}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=p,t.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${p}/inter/inter.css`,t.appendChild(o),e("Zonos font injected!")},w.setupGoogleFont=e=>{var t;null===(t=a.zonosController)||void 0===t||t.setupGoogleFont(e)},w.injectSupportGoogleFont=t=>{var n;e(`[FONT] injecting ${t}`);const o=null===(n=t.match(/family=(.*?):/))||void 0===n?void 0:n[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${h}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=h,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${o} font injected!`)},exports.Zonos=w})();
@@ -1 +1 @@
1
- (function(){"use strict";"function"==typeof SuppressedError&&SuppressedError;const e=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{return await e.json()}catch(e){if(t)throw e;return o&&console.error(e),null}};const o=async(o,t)=>{const r=(function(e,o){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)o.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(t[r[n]]=e[r[n]])}return t})(t||{},[]),n=r.body?JSON.stringify(r.body):void 0,s=r.method||"GET",i=new URL(o);i.searchParams.set("zToken",(function(e){try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));const a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===s?void 0:n,headers:a,method:s});return(async(o,t)=>{let r;try{r=await fetch(o,t)}catch(e){return e instanceof Error?{errors:[{message:e.message,type:"unknown"}],json:null,response:null}:{errors:[{message:"Fail to fetch",type:"unknown"}],json:null,response:null}}const n=r.headers.get("Zonos-Mode"),s=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&n&&s&&("production"===n&&alert("Please be aware that you are currently operating in the production environment. Any interactions with the customer store, including payments, will be processed as real transactions!"),"test"===n&&alert("For testing payments, you can utilize the test payment information provided at this link: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-test-the-integration"),window.Zonos.modeAlerted=!0),r.ok)return{errors:[],json:await e({response:r}),response:r};const i=r.status.toString();try{const o=await e({response:r,shouldThrow:!0});return{errors:[{message:`${i}: ${JSON.stringify(o)}`,type:i}],json:null,response:r}}catch(e){return{errors:[{message:`${i}: Unknown error`,type:i}],json:null,response:null}}})(i.toString(),c)},t=(e,o,...t)=>{var r,n;if(!(!!(null===(r=window.Zonos)||void 0===r?void 0:r.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===o&&console.error(e,...t));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(n=s.contentWindow)||void 0===n?void 0:n.window.console)||window.console;switch(o){case"warn":i.warn(e,...t);break;case"info":i.info(e,...t);break;case"error":i.error(e,...t);break;default:i.groupCollapsed(e,...t),i.trace(),i.groupEnd()}},r=(e,...o)=>{t(e,"error",...o)},n=async({endpoint:e,errors:t,metadata:r})=>{const n="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:t,metadata:Object.assign({href:window.location.href,userAgent:n&&n.brands.length>0?n:window.navigator.userAgent},r)};o("https://v1.route.js.zonos.com/api/zonos-elements/log-error",{body:s,method:"POST"})};var s;const i=(()=>{if("undefined"==typeof window)return null;const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href);if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const o=`https://${e}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${o}' for loading script`,"warn"),fetch(o).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${o}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,r=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",r),window.location.reload(),null})),o})();class a{static get isNpm(){return!1}}s=a,a.isBigCommerce=!1,a.requested=!1,a.internationalHideSelector="",a.zonosQaUrl=null,a.tempCartData=null,a.zonosApiKey=null,a.isLegacyCheckout=!1,a.legacyStoreLogo=null,a.legacyStoreFavicon=null,a.parallelLoadTimes=[],a.paralellLoadState="off",a.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:t,metadata:r,scriptLoadUrl:n,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(n)&&"script"===o.initiatorType}));null==e||e.transferSize;(async e=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!t},r)))}catch(e){}},a.loadScriptLogParallelHandler=async e=>{try{if(s.parallelLoadTimes.push(e),2===s.parallelLoadTimes.length){const e=s.parallelLoadTimes.find((e=>"vercel"===e.type)),o=s.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void n({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});s.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},a.legacyCheckoutErrorHandler=({message:e,tempCartUUID:o})=>{r(`[ZONOS - loadZonos] ${e}`),n({endpoint:"LegacyCheckoutInit",errors:[e],metadata:{tempCartUUID:o}}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},a.injectZonos=({initConfig:e,isGithubCdn:o=!1,parallelLoaded:r,url:a,version:c})=>{var l;const d=()=>{const e="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1";return c?e.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${c}`):e},p=i||a,m=p.replace("https://","").replace("http://",""),u=document.createElement("script"),g=c&&c<"1.2.5"?"loadZonos.js":"zonos.js";u.src=`https://${m}/dist/scripts/${g}`,t(`[ZONOS - loadZonos] Injecting "${g}" from "${m}"`,"info");const w="4g"===(null===(l=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})())||void 0===l?void 0:l.effectiveType),y=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),h="on"===s.paralellLoadState&&w&&!o&&!y;if(h){const o=d();s.injectZonos({initConfig:e,isGithubCdn:!0,parallelLoaded:!0,url:o,version:c})}const f=performance.now();u.addEventListener("load",(()=>{if(h||r?s.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-f,scriptLoadUrl:u.src,storeId:s.storeId,type:o?"jsdelivr":"vercel"}):s.loadScriptLogHandler({fallbackLoadTime:performance.now()-f,scriptLoadUrl:u.src,storeId:s.storeId,type:o?"jsdelivr":"vercel"}),s.isBigCommerce||(s.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=i,window.Zonos.internationalHideSelector=s.internationalHideSelector,window.Zonos.isBigCommerce=s.isBigCommerce,s.isLegacyCheckout){if(!s.zonosApiKey)throw s.legacyCheckoutErrorHandler({message:"zonosApiKey is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(!s.tempCartData)throw s.legacyCheckoutErrorHandler({message:"tempCartData is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(s.legacyStoreFavicon){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=s.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.tempCartData=s.tempCartData;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:s.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:"ZONOS_SUCCESS_PAGE",successRedirectUrl:s.tempCartData.contShoppingURL}),zonosApiKey:s.zonosApiKey});e=o}window.Zonos.version&&(t(`[ZONOS - loadZonos] Execute "Zonos.init" from "${g}" from "${m}"`,"info"),window.Zonos.init(e))})),u.addEventListener("error",(async()=>{if(!h&&!r){const o=d();s.injectZonos({initConfig:e,isGithubCdn:!0,url:o,version:c})}["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||i||(h||r?s.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-f,isError:!0,scriptLoadUrl:u.src,storeId:s.storeId,type:o?"jsdelivr":"vercel"}):n(o?{endpoint:u.src,errors:["zonos.js - Failed to fetch github CDN."],metadata:{cdnLoadTime:performance.now()-f,cdnType:"jsdelivr",loadUrl:p,version:c}}:{endpoint:u.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{vercelLoadTime:performance.now()-f}}))})),document.head.appendChild(u)},a.setupCartData=async e=>{const n=await(async e=>{const{errors:t,json:r}=await o("https://v1.route.js.zonos.com/api/bigcommerce/legacy-migration/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!r||t.length?null:r})(e);if(t("[ZONOS - loadZonos] getting temp cart data","info",n),!n)throw r("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),s.legacyCheckoutErrorHandler({message:"Error getting temp cart data",tempCartUUID:e}),new Error("Error getting temp cart data");return s.tempCartData=n.tempCart,s.legacyStoreLogo=n.storeLogoUrl,s.legacyStoreFavicon=n.storeFaviconUrl,{storeId:n.tempCart.storeId,zonosApiKey:n.zonosApiKey}},a.init=async e=>{var n;const i="https://v1.3.20-alpha.1.js.zonos.com",a=document.querySelector('script[src*="/zonos.js"]'),c=null===(n=document.querySelector("script[src*='/loadZonos.js']"))||void 0===n?void 0:n.src,l=null==c?void 0:c.includes("timestamp=");if(!(s.isNpm||c&&l))return void r("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(a||!c||s.requested)return void t("[ZONOS - loadZonos] script is already loaded or requested","info");s.requested=!0;let d=e.storeId;if(e.tempCartUUID){const o=await s.setupCartData(e.tempCartUUID);d=o.storeId,s.zonosApiKey=o.zonosApiKey,s.isLegacyCheckout=!0}if(!d)return t("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void s.injectZonos({initConfig:e,url:i,version:null});s.storeId=d;const p=new URL("https://v1.route.js.zonos.com/api/get-store-version");p.searchParams.set("storeId",e.storeId.toString());const{errors:m,json:u}=await o(p.toString());if(m.length||!u)return t("[ZONOS - loadZonos] Error getting store version, loadding the latest version.","error"),void s.injectZonos({initConfig:e,url:i,version:null});const{version:g}=u;if(!a){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),r=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:t}})({loadScriptSrc:c}),i=n&&!r?o:`${"alpha"===g?"alpha":`v${g}`}.js.zonos.com`,a=n&&!r?null:g;t("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:n,loadUrl:i,loadVersion:a,version:g}),s.injectZonos({initConfig:e,url:i,version:a})}},void 0===window.Zonos&&(window.Zonos=a)})();
1
+ (function(){"use strict";"function"==typeof SuppressedError&&SuppressedError;const e=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{return await e.json()}catch(e){if(t)throw e;return o&&console.error(e),null}};const o=async(o,t)=>{const r=(function(e,o){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)o.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(t[r[n]]=e[r[n]])}return t})(t||{},[]),n=r.body?JSON.stringify(r.body):void 0,s=r.method||"GET",i=new URL(o);i.searchParams.set("zToken",(function(e){try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));const a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===s?void 0:n,headers:a,method:s});return(async(o,t)=>{let r;try{r=await fetch(o,t)}catch(e){return e instanceof Error?{errors:[{message:e.message,type:"unknown"}],json:null,response:null}:{errors:[{message:"Fail to fetch",type:"unknown"}],json:null,response:null}}const n=r.headers.get("Zonos-Mode"),s=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&n&&s&&("production"===n&&alert("Please be aware that you are currently operating in the production environment. Any interactions with the customer store, including payments, will be processed as real transactions!"),"test"===n&&alert("For testing payments, you can utilize the test payment information provided at this link: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-test-the-integration"),window.Zonos.modeAlerted=!0),r.ok)return{errors:[],json:await e({response:r}),response:r};const i=r.status.toString();try{const o=await e({response:r,shouldThrow:!0});return{errors:[{message:`${i}: ${JSON.stringify(o)}`,type:i}],json:null,response:r}}catch(e){return{errors:[{message:`${i}: Unknown error`,type:i}],json:null,response:null}}})(i.toString(),c)},t=(e,o,...t)=>{var r,n;if(!(!!(null===(r=window.Zonos)||void 0===r?void 0:r.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===o&&console.error(e,...t));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(n=s.contentWindow)||void 0===n?void 0:n.window.console)||window.console;switch(o){case"warn":i.warn(e,...t);break;case"info":i.info(e,...t);break;case"error":i.error(e,...t);break;default:i.groupCollapsed(e,...t),i.trace(),i.groupEnd()}},r=(e,...o)=>{t(e,"error",...o)},n=async({endpoint:e,errors:t,metadata:r})=>{const n="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:t,metadata:Object.assign({href:window.location.href,userAgent:n&&n.brands.length>0?n:window.navigator.userAgent},r)};o("https://v1.route.js.zonos.com/api/zonos-elements/log-error",{body:s,method:"POST"})};var s;const i=(()=>{if("undefined"==typeof window)return null;const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href);if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const o=`https://${e}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${o}' for loading script`,"warn"),fetch(o).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${o}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,r=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",r),window.location.reload(),null})),o})();class a{static get isNpm(){return!1}}s=a,a.isBigCommerce=!1,a.requested=!1,a.internationalHideSelector="",a.zonosQaUrl=null,a.tempCartData=null,a.zonosApiKey=null,a.isLegacyCheckout=!1,a.legacyStoreLogo=null,a.legacyStoreFavicon=null,a.parallelLoadTimes=[],a.paralellLoadState="off",a.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:t,metadata:r,scriptLoadUrl:n,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(n)&&"script"===o.initiatorType}));null==e||e.transferSize;(async e=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!t},r)))}catch(e){}},a.loadScriptLogParallelHandler=async e=>{try{if(s.parallelLoadTimes.push(e),2===s.parallelLoadTimes.length){const e=s.parallelLoadTimes.find((e=>"vercel"===e.type)),o=s.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void n({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});s.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},a.legacyCheckoutErrorHandler=({message:e,tempCartUUID:o})=>{r(`[ZONOS - loadZonos] ${e}`),n({endpoint:"LegacyCheckoutInit",errors:[e],metadata:{tempCartUUID:o}}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},a.injectZonos=({initConfig:e,isGithubCdn:o=!1,parallelLoaded:r,url:a,version:c})=>{var l;const d=()=>{const e="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21";return c?e.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${c}`):e},p=i||a,m=p.replace("https://","").replace("http://",""),u=document.createElement("script"),g=c&&c<"1.2.5"?"loadZonos.js":"zonos.js";u.src=`https://${m}/dist/scripts/${g}`,t(`[ZONOS - loadZonos] Injecting "${g}" from "${m}"`,"info");const w="4g"===(null===(l=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})())||void 0===l?void 0:l.effectiveType),y=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),h="on"===s.paralellLoadState&&w&&!o&&!y;if(h){const o=d();s.injectZonos({initConfig:e,isGithubCdn:!0,parallelLoaded:!0,url:o,version:c})}const f=performance.now();u.addEventListener("load",(()=>{if(h||r?s.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-f,scriptLoadUrl:u.src,storeId:s.storeId,type:o?"jsdelivr":"vercel"}):s.loadScriptLogHandler({fallbackLoadTime:performance.now()-f,scriptLoadUrl:u.src,storeId:s.storeId,type:o?"jsdelivr":"vercel"}),s.isBigCommerce||(s.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=i,window.Zonos.internationalHideSelector=s.internationalHideSelector,window.Zonos.isBigCommerce=s.isBigCommerce,s.isLegacyCheckout){if(!s.zonosApiKey)throw s.legacyCheckoutErrorHandler({message:"zonosApiKey is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(!s.tempCartData)throw s.legacyCheckoutErrorHandler({message:"tempCartData is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(s.legacyStoreFavicon){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=s.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.tempCartData=s.tempCartData;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:s.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:"ZONOS_SUCCESS_PAGE",successRedirectUrl:s.tempCartData.contShoppingURL}),zonosApiKey:s.zonosApiKey});e=o}window.Zonos.version&&(t(`[ZONOS - loadZonos] Execute "Zonos.init" from "${g}" from "${m}"`,"info"),window.Zonos.init(e))})),u.addEventListener("error",(async()=>{if(!h&&!r){const o=d();s.injectZonos({initConfig:e,isGithubCdn:!0,url:o,version:c})}["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||i||(h||r?s.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-f,isError:!0,scriptLoadUrl:u.src,storeId:s.storeId,type:o?"jsdelivr":"vercel"}):n(o?{endpoint:u.src,errors:["zonos.js - Failed to fetch github CDN."],metadata:{cdnLoadTime:performance.now()-f,cdnType:"jsdelivr",loadUrl:p,version:c}}:{endpoint:u.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{vercelLoadTime:performance.now()-f}}))})),document.head.appendChild(u)},a.setupCartData=async e=>{const n=await(async e=>{const{errors:t,json:r}=await o("https://v1.route.js.zonos.com/api/bigcommerce/legacy-migration/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!r||t.length?null:r})(e);if(t("[ZONOS - loadZonos] getting temp cart data","info",n),!n)throw r("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),s.legacyCheckoutErrorHandler({message:"Error getting temp cart data",tempCartUUID:e}),new Error("Error getting temp cart data");return s.tempCartData=n.tempCart,s.legacyStoreLogo=n.storeLogoUrl,s.legacyStoreFavicon=n.storeFaviconUrl,{storeId:n.tempCart.storeId,zonosApiKey:n.zonosApiKey}},a.init=async e=>{var n;const i="https://v1.3.21.js.zonos.com",a=document.querySelector('script[src*="/zonos.js"]'),c=null===(n=document.querySelector("script[src*='/loadZonos.js']"))||void 0===n?void 0:n.src,l=null==c?void 0:c.includes("timestamp=");if(!(s.isNpm||c&&l))return void r("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(a||!c||s.requested)return void t("[ZONOS - loadZonos] script is already loaded or requested","info");s.requested=!0;let d=e.storeId;if(e.tempCartUUID){const o=await s.setupCartData(e.tempCartUUID);d=o.storeId,s.zonosApiKey=o.zonosApiKey,s.isLegacyCheckout=!0}if(!d)return t("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void s.injectZonos({initConfig:e,url:i,version:null});s.storeId=d;const p=new URL("https://v1.route.js.zonos.com/api/get-store-version");p.searchParams.set("storeId",e.storeId.toString());const{errors:m,json:u}=await o(p.toString());if(m.length||!u)return t("[ZONOS - loadZonos] Error getting store version, loadding the latest version.","error"),void s.injectZonos({initConfig:e,url:i,version:null});const{version:g}=u;if(!a){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),r=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:t}})({loadScriptSrc:c}),i=n&&!r?o:`${"alpha"===g?"alpha":`v${g}`}.js.zonos.com`,a=n&&!r?null:g;t("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:n,loadUrl:i,loadVersion:a,version:g}),s.injectZonos({initConfig:e,url:i,version:a})}},void 0===window.Zonos&&(window.Zonos=a)})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=(e,t,...n)=>{var o,r;if(!(!!(null===(o=window.Zonos)||void 0===o?void 0:o.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...n));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(r=s.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(t){case"warn":i.warn(e,...n);break;case"info":i.info(e,...n);break;case"error":i.error(e,...n);break;default:i.groupCollapsed(e,...n),i.trace(),i.groupEnd()}},t=(t,...n)=>{e(t,"error",...n)},n=()=>{if("undefined"==typeof window)return null;const t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href);if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${n}' for loading script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},o="https://js.stripe.com/v3",r=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let i=null;const l=e=>(null!==i||(i=new Promise(((n,i)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)n(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&r.test(n.src))return n}return null})();l&&e?console.warn(s):l||(l=(e=>{const n=document.createElement("script");n.src=`${o}`;const r=document.head||document.body;return r?(r.appendChild(n),n):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==l||l.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):i(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{i(new Error("Failed to load Stripe.js"))}))}catch(e){return void i(e)}else n(null)}))),i),c=Promise.resolve().then((()=>l(null)));let d=!1;c.catch((e=>{d||console.warn(e)}));var a;const u=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,n=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),o=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:o,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?t:null})()||"https://v1.3.20-alpha.1.js.zonos.com",m="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1",p="https://rsms.me",h="https://fonts.googleapis.com",y=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class w{}a=w,w.doneInit=!1,w.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),w.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),w.isBigCommerce=!1,w.isNpm=!0,w.internationalHideSelector="",w.zonosQaUrl=null,w.version="v1.3.20-alpha.1",w.modeAlerted=!1,w.tempCartData=null,w.getCurrentTimestamp=()=>(new Date).getTime(),w.zonosController=null,w.init=async({appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,storeId:l,zonosApiKey:c})=>{a.doneInit||(e(`====== ZONOS DEBUG MODE: on (${a.version}) ======`),c?(a.zonosApiKey=c,a.storeId=l,e("init zonos"),a.injectSentryScript(),a.injectZonosCdn(),a.injectZonosCss(),a.injectFonts(),a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i},zonosApiKey:c}),a.doneInit=!0):t("Missing Zonos API key"))},w.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},w.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},w.showNotification=e=>{var t;null===(t=a.zonosController)||void 0===t||t.showNotification(e)},w.updateOrganizationName=e=>{var t;null===(t=a.zonosController)||void 0===t||t.updateOrganizationName(e)},w.disablePlaceOrderButtons=({autoEnable:e=!0,disable:t,placeOrderButtonSelector:n})=>{if(n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},w.injectController=({config:n,zonosApiKey:o})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=n.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=o,s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{d=!0;const t=Date.now();return c.then((n=>((e,t,n)=>{if(null===e)return null;const o=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(o,n),o})(n,e,t)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),a.zonosController=s,e("Zonos controller injected!")},w.injectSentryScript=()=>{const n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${n}"]`))return void e("Sentry script already exists in the document","warn");const o=document.head||document.body,r=document.createElement("script");r.crossOrigin="anonymous",r.src=n,r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",r.setAttribute("data-lazy","no"),r.onerror=()=>{t(`Failed to load ${r.src}`)},r.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({beforeSend(e){var t,n,o,r,s,i;const l=null===(i=null===(s=null===(r=null===(o=null===(n=null===(t=e.exception)||void 0===t?void 0:t.values)||void 0===n?void 0:n[0])||void 0===o?void 0:o.stacktrace)||void 0===r?void 0:r.frames)||void 0===s?void 0:s[0])||void 0===i?void 0:i.filename,c=(null==l?void 0:l.includes("js.zonos.com"))||(null==l?void 0:l.includes("@zonos/elements")),d=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");return c&&!d?e:null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${a.version}`,tracesSampler:()=>.01})},o.appendChild(r)},w.injectScript=({fallBackDomain:n,isModule:o,scriptDomain:r,theRestUrl:s})=>{const i=`${r}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{/\/\/v\d+\./g.test(r)?(n&&a.injectScript({isModule:o,scriptDomain:n,theRestUrl:s}),t(`Failed to load ${c.src}`)):e("No need to fallback since this is not a versioned domain","warn")},l.appendChild(c)},w.getZonosUrl=()=>{if(a.isNpm){return n()||u}return u},w.injectZonosCdn=()=>{const t=a.getZonosUrl();a.injectScript({fallBackDomain:m,isModule:!0,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),a.injectScript({fallBackDomain:m,isModule:!1,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},w.injectStylesheet=({fallBackDomain:n,stylesheetDomain:o,theRestUrl:r})=>{const s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${u}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${o}/${r}`,l.onerror=()=>{const s=/\/\/v\d+\./g.test(o);s?(n&&s&&a.injectStylesheet({stylesheetDomain:n,theRestUrl:r}),t(`Failed to load ${l.href}`)):e("No need to fallback since this is not a versioned domain","warn")},s.appendChild(l)},w.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(a.injectStylesheet({fallBackDomain:m,stylesheetDomain:u,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},w.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${p}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&!y.test(n.href))return n}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=p,t.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${p}/inter/inter.css`,t.appendChild(o),e("Zonos font injected!")},w.setupGoogleFont=e=>{var t;null===(t=a.zonosController)||void 0===t||t.setupGoogleFont(e)},w.injectSupportGoogleFont=t=>{var n;e(`[FONT] injecting ${t}`);const o=null===(n=t.match(/family=(.*?):/))||void 0===n?void 0:n[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${h}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=h,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${o} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=w)})();
1
+ (function(){"use strict";const e=(e,t,...n)=>{var o,r;if(!(!!(null===(o=window.Zonos)||void 0===o?void 0:o.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...n));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(r=s.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(t){case"warn":i.warn(e,...n);break;case"info":i.info(e,...n);break;case"error":i.error(e,...n);break;default:i.groupCollapsed(e,...n),i.trace(),i.groupEnd()}},t=(t,...n)=>{e(t,"error",...n)},n=()=>{if("undefined"==typeof window)return null;const t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href);if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${n}' for loading script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},o="https://js.stripe.com/v3",r=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let i=null;const l=e=>(null!==i||(i=new Promise(((n,i)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)n(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&r.test(n.src))return n}return null})();l&&e?console.warn(s):l||(l=(e=>{const n=document.createElement("script");n.src=`${o}`;const r=document.head||document.body;return r?(r.appendChild(n),n):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==l||l.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):i(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{i(new Error("Failed to load Stripe.js"))}))}catch(e){return void i(e)}else n(null)}))),i),c=Promise.resolve().then((()=>l(null)));let d=!1;c.catch((e=>{d||console.warn(e)}));var a;const u=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,n=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),o=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:o,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?t:null})()||"https://v1.3.21.js.zonos.com",m="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21",p="https://rsms.me",h="https://fonts.googleapis.com",y=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class w{}a=w,w.doneInit=!1,w.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),w.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),w.isBigCommerce=!1,w.isNpm=!0,w.internationalHideSelector="",w.zonosQaUrl=null,w.version="v1.3.21",w.modeAlerted=!1,w.tempCartData=null,w.getCurrentTimestamp=()=>(new Date).getTime(),w.zonosController=null,w.init=async({appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,storeId:l,zonosApiKey:c})=>{a.doneInit||(e(`====== ZONOS DEBUG MODE: on (${a.version}) ======`),c?(a.zonosApiKey=c,a.storeId=l,e("init zonos"),a.injectSentryScript(),a.injectZonosCdn(),a.injectZonosCss(),a.injectFonts(),a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i},zonosApiKey:c}),a.doneInit=!0):t("Missing Zonos API key"))},w.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},w.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},w.showNotification=e=>{var t;null===(t=a.zonosController)||void 0===t||t.showNotification(e)},w.updateOrganizationName=e=>{var t;null===(t=a.zonosController)||void 0===t||t.updateOrganizationName(e)},w.disablePlaceOrderButtons=({autoEnable:e=!0,disable:t,placeOrderButtonSelector:n})=>{if(n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},w.injectController=({config:n,zonosApiKey:o})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=n.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=o,s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{d=!0;const t=Date.now();return c.then((n=>((e,t,n)=>{if(null===e)return null;const o=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(o,n),o})(n,e,t)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),a.zonosController=s,e("Zonos controller injected!")},w.injectSentryScript=()=>{const n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${n}"]`))return void e("Sentry script already exists in the document","warn");const o=document.head||document.body,r=document.createElement("script");r.crossOrigin="anonymous",r.src=n,r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",r.setAttribute("data-lazy","no"),r.onerror=()=>{t(`Failed to load ${r.src}`)},r.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({beforeSend(e){var t,n,o,r,s,i;const l=null===(i=null===(s=null===(r=null===(o=null===(n=null===(t=e.exception)||void 0===t?void 0:t.values)||void 0===n?void 0:n[0])||void 0===o?void 0:o.stacktrace)||void 0===r?void 0:r.frames)||void 0===s?void 0:s[0])||void 0===i?void 0:i.filename,c=(null==l?void 0:l.includes("js.zonos.com"))||(null==l?void 0:l.includes("@zonos/elements")),d=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");return c&&!d?e:null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${a.version}`,tracesSampler:()=>.01})},o.appendChild(r)},w.injectScript=({fallBackDomain:n,isModule:o,scriptDomain:r,theRestUrl:s})=>{const i=`${r}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{/\/\/v\d+\./g.test(r)?(n&&a.injectScript({isModule:o,scriptDomain:n,theRestUrl:s}),t(`Failed to load ${c.src}`)):e("No need to fallback since this is not a versioned domain","warn")},l.appendChild(c)},w.getZonosUrl=()=>{if(a.isNpm){return n()||u}return u},w.injectZonosCdn=()=>{const t=a.getZonosUrl();a.injectScript({fallBackDomain:m,isModule:!0,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),a.injectScript({fallBackDomain:m,isModule:!1,scriptDomain:t,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},w.injectStylesheet=({fallBackDomain:n,stylesheetDomain:o,theRestUrl:r})=>{const s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${u}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${o}/${r}`,l.onerror=()=>{const s=/\/\/v\d+\./g.test(o);s?(n&&s&&a.injectStylesheet({stylesheetDomain:n,theRestUrl:r}),t(`Failed to load ${l.href}`)):e("No need to fallback since this is not a versioned domain","warn")},s.appendChild(l)},w.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(a.injectStylesheet({fallBackDomain:m,stylesheetDomain:u,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},w.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${p}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&!y.test(n.href))return n}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=p,t.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${p}/inter/inter.css`,t.appendChild(o),e("Zonos font injected!")},w.setupGoogleFont=e=>{var t;null===(t=a.zonosController)||void 0===t||t.setupGoogleFont(e)},w.injectSupportGoogleFont=t=>{var n;e(`[FONT] injecting ${t}`);const o=null===(n=t.match(/family=(.*?):/))||void 0===n?void 0:n[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${h}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=h,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${o} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=w)})();
@@ -8,12 +8,12 @@ export type BuildLandedCostParams = {
8
8
  shippingAddress: CalculateLandedCostRequest['shippingAddress'];
9
9
  zonosApiRoute: string;
10
10
  };
11
- export type BuildLandedCostResponse = Promise<(CalculateLandedCostMutation & {
11
+ export type BuildLandedCostResponse = (CalculateLandedCostMutation & {
12
12
  errors?: {
13
13
  message: string;
14
14
  }[];
15
- }) | null>;
16
- type BuildLandedCost = (props: BuildLandedCostParams) => BuildLandedCostResponse;
15
+ }) | null;
16
+ type BuildLandedCost = (props: BuildLandedCostParams) => Promise<BuildLandedCostResponse>;
17
17
  export declare const triggerBuildLandedCost: (buildLandedCost: BuildLandedCost) => Promise<CalculateLandedCostMutation & {
18
18
  errors?: {
19
19
  message: string;
@@ -2,6 +2,7 @@ import type { CartItem } from "../../components/store/checkout/cart";
2
2
  import type { BuildLandedCostParams, BuildLandedCostResponse } from "../../components/utils/api/triggerBuildLandedCost";
3
3
  import type { AnalyticsProviderStatus, AnalyticsProviderType, CheckoutSubscriptionStatus, CheckoutSuccessBehavior, CheckoutVisibilityStatus, GetOrderQuery, NotificationActiveStatus } from "../generated/graphql.customer.types";
4
4
  export type ZonosOrder = GetOrderQuery['order'];
5
+ export type { BuildLandedCostParams, BuildLandedCostResponse };
5
6
  export type CheckoutConfig = {
6
7
  /**
7
8
  * Validate address to allow specific character sets
@@ -70,7 +71,7 @@ export type CheckoutConfig = {
70
71
  * Calculate landed cost callback for checkout (optional)
71
72
  * @note will use temp cart data if available
72
73
  */
73
- buildLandedCost?: (params: BuildLandedCostParams) => BuildLandedCostResponse;
74
+ buildLandedCost?: (params: BuildLandedCostParams) => Promise<BuildLandedCostResponse>;
74
75
  /**
75
76
  * Callback trigger when the checkout is closed
76
77
  */
@@ -1,6 +1,7 @@
1
1
  import './global.d';
2
2
  export * from '../components.d';
3
3
  export type { CartItem, ItemMeasurement, } from '../components/store/checkout/cart';
4
+ export * from './checkout/api/CalculateLandedCostRequest';
4
5
  export * from './checkout/CheckoutConfig';
5
6
  export * from './hello/HelloConfig';
6
7
  export * from './JsonError';
@@ -1 +1 @@
1
- import{l as e,a as n}from"./p-eaa335e1.js";const o="https://js.stripe.com/v3",t=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let i=null;const l=Promise.resolve().then((()=>{return e=null,null!==i||(i=new Promise(((i,l)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)i(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&t.test(o.src))return o}return null})();r&&e?console.warn(s):r||(r=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",s=document.createElement("script");s.src=`${o}${t}`;const i=document.head||document.body;return i?(i.appendChild(s),s):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==r||r.addEventListener("load",(()=>{window.Stripe?i(window.Stripe):l(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{l(new Error("Failed to load Stripe.js"))}))}catch(e){return void l(e)}else i(null)}))),i;var e}));let r=!1;var c;l.catch((e=>{r||console.warn(e)}));const d=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})()||"https://v1.3.20-alpha.1.js.zonos.com",a="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1",u="https://rsms.me",m="https://fonts.googleapis.com",p=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class w{}c=w,w.doneInit=!1,w.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),w.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),w.isBigCommerce=!1,w.isNpm=!0,w.internationalHideSelector="",w.zonosQaUrl=null,w.version="v1.3.20-alpha.1",w.modeAlerted=!1,w.tempCartData=null,w.getCurrentTimestamp=()=>(new Date).getTime(),w.zonosController=null,w.init=async({appearance:o,checkoutSettings:t,currencyConverter:s,helloSettings:i,onCountryChange:l,storeId:r,zonosApiKey:d})=>{c.doneInit||(e(`====== ZONOS DEBUG MODE: on (${c.version}) ======`),d?(c.zonosApiKey=d,c.storeId=r,e("init zonos"),c.injectSentryScript(),c.injectZonosCdn(),c.injectZonosCss(),c.injectFonts(),c.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:s,helloSettings:i,onCountryChange:l},zonosApiKey:d}),c.doneInit=!0):n("Missing Zonos API key"))},w.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},w.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},w.showNotification=e=>{var n;null===(n=c.zonosController)||void 0===n||n.showNotification(e)},w.updateOrganizationName=e=>{var n;null===(n=c.zonosController)||void 0===n||n.updateOrganizationName(e)},w.disablePlaceOrderButtons=({autoEnable:e=!0,disable:n,placeOrderButtonSelector:o})=>{if(o){const t=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(n?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&n&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},w.injectController=({config:o,zonosApiKey:t})=>{var s;if(document.querySelector("zonos-controller"))return;if(null===(s=o.checkoutSettings)||void 0===s?void 0:s.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;c.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{c.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const i=document.createElement("zonos-controller");i.config=o,i.zonosApiKey=t,i.addEventListener("stripeInitEvent",(async o=>{const{detail:t}=o;e("loading Stripe");const s=await(async(...e)=>{r=!0;const n=Date.now();return l.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);s?(window.Zonos.stripe=s,i.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(i),c.zonosController=i,e("Zonos controller injected!")},w.injectSentryScript=()=>{const o="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${o}"]`))return void e("Sentry script already exists in the document","warn");const t=document.head||document.body,s=document.createElement("script");s.crossOrigin="anonymous",s.src=o,s.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",s.setAttribute("data-lazy","no"),s.onerror=()=>{n(`Failed to load ${s.src}`)},s.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({beforeSend(e){var n,o,t,s,i,l;const r=null===(l=null===(i=null===(s=null===(t=null===(o=null===(n=e.exception)||void 0===n?void 0:n.values)||void 0===o?void 0:o[0])||void 0===t?void 0:t.stacktrace)||void 0===s?void 0:s.frames)||void 0===i?void 0:i[0])||void 0===l?void 0:l.filename,c=(null==r?void 0:r.includes("js.zonos.com"))||(null==r?void 0:r.includes("@zonos/elements")),d=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");return c&&!d?e:null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${c.version}`,tracesSampler:()=>.01})},t.appendChild(s)},w.injectScript=({fallBackDomain:o,isModule:t,scriptDomain:s,theRestUrl:i})=>{const l=`${s}/${i}`;if(document.querySelector(`script[src="${l}"]`))return void e(`Zonos script "${l}" already exists in the document`,"warn");const r=document.head||document.body,d=document.createElement("script");t?d.type="module":d.noModule=!0,d.src=l,d.crossOrigin="anonymous",d.onerror=()=>{/\/\/v\d+\./g.test(s)?(o&&c.injectScript({isModule:t,scriptDomain:o,theRestUrl:i}),n(`Failed to load ${d.src}`)):e("No need to fallback since this is not a versioned domain","warn")},r.appendChild(d)},w.getZonosUrl=()=>c.isNpm&&(()=>{if("undefined"==typeof window)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href);if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const o=`https://${n}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${o}' for loading script`,"warn"),fetch(o).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${o}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),o})()||d,w.injectZonosCdn=()=>{const n=c.getZonosUrl();c.injectScript({fallBackDomain:a,isModule:!0,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),c.injectScript({fallBackDomain:a,isModule:!1,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},w.injectStylesheet=({fallBackDomain:o,stylesheetDomain:t,theRestUrl:s})=>{const i=document.head||document.body,l=document.createElement("link");l.rel="preconnect",l.href=`${d}/`,i.appendChild(l);const r=document.createElement("link");r.rel="stylesheet",r.href=`${t}/${s}`,r.onerror=()=>{const i=/\/\/v\d+\./g.test(t);i?(o&&i&&c.injectStylesheet({stylesheetDomain:o,theRestUrl:s}),n(`Failed to load ${r.href}`)):e("No need to fallback since this is not a versioned domain","warn")},i.appendChild(r)},w.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(c.injectStylesheet({fallBackDomain:a,stylesheetDomain:d,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},w.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!p.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=u,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${u}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},w.setupGoogleFont=e=>{var n;null===(n=c.zonosController)||void 0===n||n.setupGoogleFont(e)},w.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${m}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=m,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const i=document.createElement("link");i.rel="stylesheet",i.href=n,s.appendChild(i),e(`[FONT] ${t} font injected!`)};export{w as Zonos}
1
+ import{l as e,a as n}from"./p-eaa335e1.js";const o="https://js.stripe.com/v3",t=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let i=null;const l=Promise.resolve().then((()=>{return e=null,null!==i||(i=new Promise(((i,l)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)i(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&t.test(o.src))return o}return null})();r&&e?console.warn(s):r||(r=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",s=document.createElement("script");s.src=`${o}${t}`;const i=document.head||document.body;return i?(i.appendChild(s),s):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==r||r.addEventListener("load",(()=>{window.Stripe?i(window.Stripe):l(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{l(new Error("Failed to load Stripe.js"))}))}catch(e){return void l(e)}else i(null)}))),i;var e}));let r=!1;var c;l.catch((e=>{r||console.warn(e)}));const d=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})()||"https://v1.3.21.js.zonos.com",a="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21",u="https://rsms.me",m="https://fonts.googleapis.com",p=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class w{}c=w,w.doneInit=!1,w.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),w.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),w.isBigCommerce=!1,w.isNpm=!0,w.internationalHideSelector="",w.zonosQaUrl=null,w.version="v1.3.21",w.modeAlerted=!1,w.tempCartData=null,w.getCurrentTimestamp=()=>(new Date).getTime(),w.zonosController=null,w.init=async({appearance:o,checkoutSettings:t,currencyConverter:s,helloSettings:i,onCountryChange:l,storeId:r,zonosApiKey:d})=>{c.doneInit||(e(`====== ZONOS DEBUG MODE: on (${c.version}) ======`),d?(c.zonosApiKey=d,c.storeId=r,e("init zonos"),c.injectSentryScript(),c.injectZonosCdn(),c.injectZonosCss(),c.injectFonts(),c.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:s,helloSettings:i,onCountryChange:l},zonosApiKey:d}),c.doneInit=!0):n("Missing Zonos API key"))},w.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},w.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},w.showNotification=e=>{var n;null===(n=c.zonosController)||void 0===n||n.showNotification(e)},w.updateOrganizationName=e=>{var n;null===(n=c.zonosController)||void 0===n||n.updateOrganizationName(e)},w.disablePlaceOrderButtons=({autoEnable:e=!0,disable:n,placeOrderButtonSelector:o})=>{if(o){const t=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(n?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&n&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},w.injectController=({config:o,zonosApiKey:t})=>{var s;if(document.querySelector("zonos-controller"))return;if(null===(s=o.checkoutSettings)||void 0===s?void 0:s.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;c.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{c.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const i=document.createElement("zonos-controller");i.config=o,i.zonosApiKey=t,i.addEventListener("stripeInitEvent",(async o=>{const{detail:t}=o;e("loading Stripe");const s=await(async(...e)=>{r=!0;const n=Date.now();return l.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);s?(window.Zonos.stripe=s,i.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(i),c.zonosController=i,e("Zonos controller injected!")},w.injectSentryScript=()=>{const o="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${o}"]`))return void e("Sentry script already exists in the document","warn");const t=document.head||document.body,s=document.createElement("script");s.crossOrigin="anonymous",s.src=o,s.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",s.setAttribute("data-lazy","no"),s.onerror=()=>{n(`Failed to load ${s.src}`)},s.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({beforeSend(e){var n,o,t,s,i,l;const r=null===(l=null===(i=null===(s=null===(t=null===(o=null===(n=e.exception)||void 0===n?void 0:n.values)||void 0===o?void 0:o[0])||void 0===t?void 0:t.stacktrace)||void 0===s?void 0:s.frames)||void 0===i?void 0:i[0])||void 0===l?void 0:l.filename,c=(null==r?void 0:r.includes("js.zonos.com"))||(null==r?void 0:r.includes("@zonos/elements")),d=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");return c&&!d?e:null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${c.version}`,tracesSampler:()=>.01})},t.appendChild(s)},w.injectScript=({fallBackDomain:o,isModule:t,scriptDomain:s,theRestUrl:i})=>{const l=`${s}/${i}`;if(document.querySelector(`script[src="${l}"]`))return void e(`Zonos script "${l}" already exists in the document`,"warn");const r=document.head||document.body,d=document.createElement("script");t?d.type="module":d.noModule=!0,d.src=l,d.crossOrigin="anonymous",d.onerror=()=>{/\/\/v\d+\./g.test(s)?(o&&c.injectScript({isModule:t,scriptDomain:o,theRestUrl:i}),n(`Failed to load ${d.src}`)):e("No need to fallback since this is not a versioned domain","warn")},r.appendChild(d)},w.getZonosUrl=()=>c.isNpm&&(()=>{if("undefined"==typeof window)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href);if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const o=`https://${n}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${o}' for loading script`,"warn"),fetch(o).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${o}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),o})()||d,w.injectZonosCdn=()=>{const n=c.getZonosUrl();c.injectScript({fallBackDomain:a,isModule:!0,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),c.injectScript({fallBackDomain:a,isModule:!1,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},w.injectStylesheet=({fallBackDomain:o,stylesheetDomain:t,theRestUrl:s})=>{const i=document.head||document.body,l=document.createElement("link");l.rel="preconnect",l.href=`${d}/`,i.appendChild(l);const r=document.createElement("link");r.rel="stylesheet",r.href=`${t}/${s}`,r.onerror=()=>{const i=/\/\/v\d+\./g.test(t);i?(o&&i&&c.injectStylesheet({stylesheetDomain:o,theRestUrl:s}),n(`Failed to load ${r.href}`)):e("No need to fallback since this is not a versioned domain","warn")},i.appendChild(r)},w.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(c.injectStylesheet({fallBackDomain:a,stylesheetDomain:d,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},w.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!p.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=u,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${u}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},w.setupGoogleFont=e=>{var n;null===(n=c.zonosController)||void 0===n||n.setupGoogleFont(e)},w.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${m}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=m,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const i=document.createElement("link");i.rel="stylesheet",i.href=n,s.appendChild(i),e(`[FONT] ${t} font injected!`)};export{w as Zonos}
@@ -0,0 +1 @@
1
+ var __awaiter=this&&this.__awaiter||function(n,e,t,r){function o(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,i){function u(n){try{a(r.next(n))}catch(n){i(n)}}function s(n){try{a(r["throw"](n))}catch(n){i(n)}}function a(n){n.done?t(n.value):o(n.value).then(u,s)}a((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(n){return function(e){return a([n,e])}}function a(s){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=e.call(n,t)}catch(n){s=[6,n];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-63db40b9.system.js"],(function(n){"use strict";var e,t;return{setters:[function(n){e=n.l;t=n.a}],execute:function(){var r=this;var o=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(e).origin;var i=t.some((function(n){return o.includes(n)}));var u=r.some((function(n){return o.includes(n)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var i=function(n){if(!n){return null}var e=new URL(n).searchParams;var t=e.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var u=function(){if(typeof window==="undefined"){return null}var n=i(window.location.href);if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);e("[ZONOS-WARNING] using '".concat(r,"' for loading script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' 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 t="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return r};var s="https://js.stripe.com/v3";var a=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var c="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var l=function(){var n=document.querySelectorAll('script[src^="'.concat(s,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(!a.test(t.src)){continue}return t}return null};var d=null;var f=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var r=document.createElement("script");r.src="".concat(s).concat(e);var o=document.head||document.body;if(!o){t("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}o.appendChild(r);return r};var v=function(n){if(d!==null){return d}d=new Promise((function(e,t){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(c)}if(window.Stripe){e(window.Stripe);return}try{var r=l();if(r&&n){console.warn(c)}else if(!r){r=f(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(n){t(n);return}}));return d};var m=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var w=function(n,e,t){if(n===null){return null}var r=n.apply(undefined,e);m(r,t);return r};var h=Promise.resolve().then((function(){return v(null)}));var p=false;h.catch((function(n){if(!p){console.warn(n)}}));var y=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(t){p=true;e=Date.now();return[2,h.then((function(t){return w(t,n,e)}))]}))}))};var z;var b=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=o({loadScriptSrc:n===null||n===void 0?void 0:n.src}),t=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return t}return null}();var g=b||"https://v1.3.21.js.zonos.com";var j="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.21";var S="https://rsms.me";var k="https://fonts.googleapis.com";var D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var N=function(){function n(){}return n}();n("Zonos",N);z=N;N.doneInit=false;N.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);N.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);N.isBigCommerce=false;N.isNpm=true;N.internationalHideSelector="";N.zonosQaUrl=null;N.version="v".concat("1.3.21");N.modeAlerted=false;N.tempCartData=null;N.getCurrentTimestamp=function(){return(new Date).getTime()};N.zonosController=null;N.init=function(n){return __awaiter(r,[n],void 0,(function(n){var r=n.appearance,o=n.checkoutSettings,i=n.currencyConverter,u=n.helloSettings,s=n.onCountryChange,a=n.storeId,c=n.zonosApiKey;return __generator(this,(function(n){if(z.doneInit){return[2]}e("====== ZONOS DEBUG MODE: on (".concat(z.version,") ======"));if(!c){t("Missing Zonos API key");return[2]}z.zonosApiKey=c;z.storeId=a;e("init zonos");z.injectSentryScript();z.injectZonosCdn();z.injectZonosCss();z.injectFonts();z.injectController({config:{appearance:r,checkoutSettings:o,currencyConverter:i,helloSettings:u,onCountryChange:s},zonosApiKey:c});z.doneInit=true;return[2]}))}))};N.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};N.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};N.showNotification=function(n){var e;void((e=z.zonosController)===null||e===void 0?void 0:e.showNotification(n))};N.updateOrganizationName=function(n){var e;void((e=z.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};N.disablePlaceOrderButtons=function(n){var e=n.autoEnable,t=e===void 0?true:e,r=n.disable,o=n.placeOrderButtonSelector;if(o){var i=document.querySelectorAll(o);var u=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};i.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(r){n.setAttribute("disabled","true");n.addEventListener("click",u)}else{n.removeAttribute("disabled");n.removeEventListener("click",u)}}));if(t&&r){setTimeout((function(){i.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",u)}))}),5e3)}}};N.injectController=function(n){var o=n.config,i=n.zonosApiKey;var u;if(document.querySelector("zonos-controller")){return}if((u=o.checkoutSettings)===null||u===void 0?void 0:u.placeOrderButtonSelector){var s=o.checkoutSettings.placeOrderButtonSelector;z.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:s});var a=new MutationObserver((function(){z.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:s})}));a.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=o;c.zonosApiKey=i;c.addEventListener("stripeInitEvent",(function(n){return __awaiter(r,void 0,void 0,(function(){var r,o;return __generator(this,(function(i){switch(i.label){case 0:r=n.detail;e("loading Stripe");return[4,y(r.publishableKey)];case 1:o=i.sent();if(!o){t("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void c.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(c);z.zonosController=c;e("Zonos controller injected!")};N.injectSentryScript=function(){var n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";var r=function(){var e=document.querySelector('script[src="'.concat(n,'"]'));return!!e};if(r()){e("Sentry script already exists in the document","warn");return}var o=document.head||document.body;var i=document.createElement("script");i.crossOrigin="anonymous";i.src=n;i.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l";i.setAttribute("data-lazy","no");i.onerror=function(){t("Failed to load ".concat(i.src))};i.onload=function(){var n;(n=window.Sentry)===null||n===void 0?void 0:n.init({beforeSend:function(n){var e,t,r,o,i,u;var s=(u=(i=(o=(r=(t=(e=n.exception)===null||e===void 0?void 0:e.values)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.stacktrace)===null||o===void 0?void 0:o.frames)===null||i===void 0?void 0:i[0])===null||u===void 0?void 0:u.filename;var a=(s===null||s===void 0?void 0:s.includes("js.zonos.com"))||(s===null||s===void 0?void 0:s.includes("@zonos/elements"));var c=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");if(a&&!c){return n}return null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:"zonos-elements@".concat(z.version),tracesSampler:function(){return.01}})};o.appendChild(i)};N.injectScript=function(n){var r=n.fallBackDomain,o=n.isModule,i=n.scriptDomain,u=n.theRestUrl;var s="".concat(i,"/").concat(u);var a=function(){var n=document.querySelector('script[src="'.concat(s,'"]'));return!!n};if(a()){e('Zonos script "'.concat(s,'" already exists in the document'),"warn");return}var c=document.head||document.body;var l=document.createElement("script");if(!!o){l.type="module"}else{l.noModule=true}l.src=s;l.crossOrigin="anonymous";l.onerror=function(){var n=/\/\/v\d+\./g.test(i);if(!n){e("No need to fallback since this is not a versioned domain","warn");return}if(r){z.injectScript({isModule:o,scriptDomain:r,theRestUrl:u})}t("Failed to load ".concat(l.src))};c.appendChild(l)};N.getZonosUrl=function(){if(z.isNpm){var n=u();return n||g}return g};N.injectZonosCdn=function(){var n=z.getZonosUrl();z.injectScript({fallBackDomain:j,isModule:true,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});z.injectScript({fallBackDomain:j,isModule:false,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"});e("Zonos cdn script injected!")};N.injectStylesheet=function(n){var r=n.fallBackDomain,o=n.stylesheetDomain,i=n.theRestUrl;var u=document.head||document.body;var s=document.createElement("link");s.rel="preconnect";s.href="".concat(g,"/");u.appendChild(s);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(o,"/").concat(i);a.onerror=function(){var n=/\/\/v\d+\./g.test(o);if(!n){e("No need to fallback since this is not a versioned domain","warn");return}if(r&&n){z.injectStylesheet({stylesheetDomain:r,theRestUrl:i})}t("Failed to load ".concat(a.href))};u.appendChild(a)};N.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){e("Zonos style links already injected","warn");return}z.injectStylesheet({fallBackDomain:j,stylesheetDomain:g,theRestUrl:"dist/zonos-elements/zonos-elements.css"});e("Zonos style css injected!")};N.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(S,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(D.test(t.href)){continue}return t}return null};if(n()){e("Inter font already injected","warn");return}var t=document.head||document.body;var r=document.createElement("link");r.rel="preconnect";r.href=S;t.appendChild(r);var o=document.createElement("link");o.rel="stylesheet";o.href="".concat(S,"/inter/inter.css");t.appendChild(o);e("Zonos font injected!")};N.setupGoogleFont=function(n){var e;void((e=z.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};N.injectSupportGoogleFont=function(n){var t;e("[FONT] injecting ".concat(n));var r=(t=n.match(/family=(.*?):/))===null||t===void 0?void 0:t[1];var o=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(k,'"]'))){var i=document.createElement("link");i.rel="preconnect";i.href=k;o.appendChild(i)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){e("[FONT] ".concat(r," font already injected"),"warn");return}var u=document.createElement("link");u.rel="stylesheet";u.href=n;o.appendChild(u);e("[FONT] ".concat(r," font injected!"))}}}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/elements",
3
- "version": "1.3.20-alpha.1",
3
+ "version": "1.3.21",
4
4
  "description": "Zonos component UI for Stripe elements",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs.js",
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,t,r){function o(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,i){function u(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r["throw"](n))}catch(n){i(n)}}function s(n){n.done?t(n.value):o(n.value).then(u,a)}s((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(n){return function(e){return s([n,e])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=e.call(n,t)}catch(n){a=[6,n];o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-63db40b9.system.js"],(function(n){"use strict";var e,t;return{setters:[function(n){e=n.l;t=n.a}],execute:function(){var r=this;var o=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(e).origin;var i=t.some((function(n){return o.includes(n)}));var u=r.some((function(n){return o.includes(n)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var i=function(n){if(!n){return null}var e=new URL(n).searchParams;var t=e.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var u=function(){if(typeof window==="undefined"){return null}var n=i(window.location.href);if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);e("[ZONOS-WARNING] using '".concat(r,"' for loading script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' 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 t="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return r};var a="https://js.stripe.com/v3";var s=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var c="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var l=function(){var n=document.querySelectorAll('script[src^="'.concat(a,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(!s.test(t.src)){continue}return t}return null};var d=null;var f=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var r=document.createElement("script");r.src="".concat(a).concat(e);var o=document.head||document.body;if(!o){t("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}o.appendChild(r);return r};var v=function(n){if(d!==null){return d}d=new Promise((function(e,t){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(c)}if(window.Stripe){e(window.Stripe);return}try{var r=l();if(r&&n){console.warn(c)}else if(!r){r=f(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(n){t(n);return}}));return d};var m=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var w=function(n,e,t){if(n===null){return null}var r=n.apply(undefined,e);m(r,t);return r};var h=Promise.resolve().then((function(){return v(null)}));var p=false;h.catch((function(n){if(!p){console.warn(n)}}));var y=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(t){p=true;e=Date.now();return[2,h.then((function(t){return w(t,n,e)}))]}))}))};var z;var b=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=o({loadScriptSrc:n===null||n===void 0?void 0:n.src}),t=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return t}return null}();var g=b||"https://v1.3.20-alpha.1.js.zonos.com";var j="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.1";var S="https://rsms.me";var k="https://fonts.googleapis.com";var D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var N=function(){function n(){}return n}();n("Zonos",N);z=N;N.doneInit=false;N.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);N.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);N.isBigCommerce=false;N.isNpm=true;N.internationalHideSelector="";N.zonosQaUrl=null;N.version="v".concat("1.3.20-alpha.1");N.modeAlerted=false;N.tempCartData=null;N.getCurrentTimestamp=function(){return(new Date).getTime()};N.zonosController=null;N.init=function(n){return __awaiter(r,[n],void 0,(function(n){var r=n.appearance,o=n.checkoutSettings,i=n.currencyConverter,u=n.helloSettings,a=n.onCountryChange,s=n.storeId,c=n.zonosApiKey;return __generator(this,(function(n){if(z.doneInit){return[2]}e("====== ZONOS DEBUG MODE: on (".concat(z.version,") ======"));if(!c){t("Missing Zonos API key");return[2]}z.zonosApiKey=c;z.storeId=s;e("init zonos");z.injectSentryScript();z.injectZonosCdn();z.injectZonosCss();z.injectFonts();z.injectController({config:{appearance:r,checkoutSettings:o,currencyConverter:i,helloSettings:u,onCountryChange:a},zonosApiKey:c});z.doneInit=true;return[2]}))}))};N.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};N.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};N.showNotification=function(n){var e;void((e=z.zonosController)===null||e===void 0?void 0:e.showNotification(n))};N.updateOrganizationName=function(n){var e;void((e=z.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};N.disablePlaceOrderButtons=function(n){var e=n.autoEnable,t=e===void 0?true:e,r=n.disable,o=n.placeOrderButtonSelector;if(o){var i=document.querySelectorAll(o);var u=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};i.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(r){n.setAttribute("disabled","true");n.addEventListener("click",u)}else{n.removeAttribute("disabled");n.removeEventListener("click",u)}}));if(t&&r){setTimeout((function(){i.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",u)}))}),5e3)}}};N.injectController=function(n){var o=n.config,i=n.zonosApiKey;var u;if(document.querySelector("zonos-controller")){return}if((u=o.checkoutSettings)===null||u===void 0?void 0:u.placeOrderButtonSelector){var a=o.checkoutSettings.placeOrderButtonSelector;z.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:a});var s=new MutationObserver((function(){z.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:a})}));s.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=o;c.zonosApiKey=i;c.addEventListener("stripeInitEvent",(function(n){return __awaiter(r,void 0,void 0,(function(){var r,o;return __generator(this,(function(i){switch(i.label){case 0:r=n.detail;e("loading Stripe");return[4,y(r.publishableKey)];case 1:o=i.sent();if(!o){t("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void c.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(c);z.zonosController=c;e("Zonos controller injected!")};N.injectSentryScript=function(){var n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";var r=function(){var e=document.querySelector('script[src="'.concat(n,'"]'));return!!e};if(r()){e("Sentry script already exists in the document","warn");return}var o=document.head||document.body;var i=document.createElement("script");i.crossOrigin="anonymous";i.src=n;i.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l";i.setAttribute("data-lazy","no");i.onerror=function(){t("Failed to load ".concat(i.src))};i.onload=function(){var n;(n=window.Sentry)===null||n===void 0?void 0:n.init({beforeSend:function(n){var e,t,r,o,i,u;var a=(u=(i=(o=(r=(t=(e=n.exception)===null||e===void 0?void 0:e.values)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.stacktrace)===null||o===void 0?void 0:o.frames)===null||i===void 0?void 0:i[0])===null||u===void 0?void 0:u.filename;var s=(a===null||a===void 0?void 0:a.includes("js.zonos.com"))||(a===null||a===void 0?void 0:a.includes("@zonos/elements"));var c=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");if(s&&!c){return n}return null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:"zonos-elements@".concat(z.version),tracesSampler:function(){return.01}})};o.appendChild(i)};N.injectScript=function(n){var r=n.fallBackDomain,o=n.isModule,i=n.scriptDomain,u=n.theRestUrl;var a="".concat(i,"/").concat(u);var s=function(){var n=document.querySelector('script[src="'.concat(a,'"]'));return!!n};if(s()){e('Zonos script "'.concat(a,'" already exists in the document'),"warn");return}var c=document.head||document.body;var l=document.createElement("script");if(!!o){l.type="module"}else{l.noModule=true}l.src=a;l.crossOrigin="anonymous";l.onerror=function(){var n=/\/\/v\d+\./g.test(i);if(!n){e("No need to fallback since this is not a versioned domain","warn");return}if(r){z.injectScript({isModule:o,scriptDomain:r,theRestUrl:u})}t("Failed to load ".concat(l.src))};c.appendChild(l)};N.getZonosUrl=function(){if(z.isNpm){var n=u();return n||g}return g};N.injectZonosCdn=function(){var n=z.getZonosUrl();z.injectScript({fallBackDomain:j,isModule:true,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});z.injectScript({fallBackDomain:j,isModule:false,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"});e("Zonos cdn script injected!")};N.injectStylesheet=function(n){var r=n.fallBackDomain,o=n.stylesheetDomain,i=n.theRestUrl;var u=document.head||document.body;var a=document.createElement("link");a.rel="preconnect";a.href="".concat(g,"/");u.appendChild(a);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(o,"/").concat(i);s.onerror=function(){var n=/\/\/v\d+\./g.test(o);if(!n){e("No need to fallback since this is not a versioned domain","warn");return}if(r&&n){z.injectStylesheet({stylesheetDomain:r,theRestUrl:i})}t("Failed to load ".concat(s.href))};u.appendChild(s)};N.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){e("Zonos style links already injected","warn");return}z.injectStylesheet({fallBackDomain:j,stylesheetDomain:g,theRestUrl:"dist/zonos-elements/zonos-elements.css"});e("Zonos style css injected!")};N.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(S,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(D.test(t.href)){continue}return t}return null};if(n()){e("Inter font already injected","warn");return}var t=document.head||document.body;var r=document.createElement("link");r.rel="preconnect";r.href=S;t.appendChild(r);var o=document.createElement("link");o.rel="stylesheet";o.href="".concat(S,"/inter/inter.css");t.appendChild(o);e("Zonos font injected!")};N.setupGoogleFont=function(n){var e;void((e=z.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};N.injectSupportGoogleFont=function(n){var t;e("[FONT] injecting ".concat(n));var r=(t=n.match(/family=(.*?):/))===null||t===void 0?void 0:t[1];var o=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(k,'"]'))){var i=document.createElement("link");i.rel="preconnect";i.href=k;o.appendChild(i)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){e("[FONT] ".concat(r," font already injected"),"warn");return}var u=document.createElement("link");u.rel="stylesheet";u.href=n;o.appendChild(u);e("[FONT] ".concat(r," font injected!"))}}}}));