@zonos/elements 1.3.251 → 1.3.252

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.
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,o){if(o||arguments.length===2)for(var t=0,r=n.length,i;t<r;t++){if(i||!(t in n)){if(!i)i=Array.prototype.slice.call(n,0,t);i[t]=n[t]}}return e.concat(i||Array.prototype.slice.call(n))};import{c as createCustomEvent}from"./createCustomEvent-58159025.js";import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-0bc3e118.js";import{l as log}from"./VarianceTest-572cecf5.js";export{a as availableTestKeys}from"./VarianceTest-572cecf5.js";import{g as getIsTestMode,a as getIsStagingMode,h as handleFetch,l as logError}from"./handleFetch-a844cac1.js";import{g as getAbandonedCartRenewTokenValue,_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as countryRequireShortAddressCode}from"./ShortAddressCode-7620e622.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./TaxId-50d72254.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.251.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}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);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements 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 e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};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 e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,c,u;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:n,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,c=i.zonosMode;u=!s||a.length;if(!(u&&l))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:d,retries:l-1})];case 3:if(u){return[2,null]}return[2,Object.assign(Object.assign({},s),{zonosMode:c})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.3.251.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.251";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.251";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.251";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1775502731069";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.251");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,d,l,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true}if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");d=document.createElement("script");d.src="".concat(u,"/dist/scripts/zonos.js");document.head.appendChild(d);d.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;window.Zonos.zonosMode=_a.zonosMode;void window.Zonos.init(e)}));d.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartDataWithSettings(_a.cartId)];case 1:l=p.sent();if(!l){logError("Failed to get cart data");return[2]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;p.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=p.sent();if(f){_a.zonosApiKey=f}p.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");_=document.createElement("button");_.style.display="none";_.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(_)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectCheckoutInternationalButton();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector))){var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.triggerCheckoutInternational=function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(n){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));setTimeout((function(){if(e){e.dispatchEvent(createCustomEvent("click"))}}),10);return[2]}))}))};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;if(window.Zonos.isCollect){void s.initCollectElement(o)}else if(window.Zonos.isInvoice){void s.initInvoiceElement(o)}else{void s.initCheckoutElement(o)}return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};var checkoutSessionMutableAttributeKeys=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"];var checkoutSessionImmutableAttributeKeys=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"];var checkoutSessionAttributeKeys=__spreadArray(__spreadArray([],checkoutSessionMutableAttributeKeys,true),checkoutSessionImmutableAttributeKeys,true);export{Zonos,checkoutSessionAttributeKeys,checkoutSessionImmutableAttributeKeys,checkoutSessionMutableAttributeKeys};
1
+ var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,o){if(o||arguments.length===2)for(var t=0,r=n.length,i;t<r;t++){if(i||!(t in n)){if(!i)i=Array.prototype.slice.call(n,0,t);i[t]=n[t]}}return e.concat(i||Array.prototype.slice.call(n))};import{c as createCustomEvent}from"./createCustomEvent-58159025.js";import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-0bc3e118.js";import{l as log}from"./VarianceTest-572cecf5.js";export{a as availableTestKeys}from"./VarianceTest-572cecf5.js";import{g as getIsTestMode,a as getIsStagingMode,h as handleFetch,l as logError}from"./handleFetch-a844cac1.js";import{g as getAbandonedCartRenewTokenValue,_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-724d7bae.js";export{c as countryRequireShortAddressCode}from"./ShortAddressCode-7620e622.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./TaxId-50d72254.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.252.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}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);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements 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 e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};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 e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,c,u;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:n,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,c=i.zonosMode;u=!s||a.length;if(!(u&&l))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:d,retries:l-1})];case 3:if(u){return[2,null]}return[2,Object.assign(Object.assign({},s),{zonosMode:c})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.3.252.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.252";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.252";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.252";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1775682510484";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.252");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,d,l,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true}if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");d=document.createElement("script");d.src="".concat(u,"/dist/scripts/zonos.js");document.head.appendChild(d);d.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;window.Zonos.zonosMode=_a.zonosMode;void window.Zonos.init(e)}));d.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartDataWithSettings(_a.cartId)];case 1:l=p.sent();if(!l){logError("Failed to get cart data");return[2]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;p.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=p.sent();if(f){_a.zonosApiKey=f}p.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");_=document.createElement("button");_.style.display="none";_.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(_)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectCheckoutInternationalButton();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector))){var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.triggerCheckoutInternational=function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(n){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));setTimeout((function(){if(e){e.dispatchEvent(createCustomEvent("click"))}}),10);return[2]}))}))};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;if(window.Zonos.isCollect){void s.initCollectElement(o)}else if(window.Zonos.isInvoice){void s.initInvoiceElement(o)}else{void s.initCheckoutElement(o)}return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};var checkoutSessionMutableAttributeKeys=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"];var checkoutSessionImmutableAttributeKeys=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"];var checkoutSessionAttributeKeys=__spreadArray(__spreadArray([],checkoutSessionMutableAttributeKeys,true),checkoutSessionImmutableAttributeKeys,true);export{Zonos,checkoutSessionAttributeKeys,checkoutSessionImmutableAttributeKeys,checkoutSessionMutableAttributeKeys};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,o,r){function n(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r["throw"](e))}catch(e){s(e)}}function c(e){e.done?o(e.value):n(e.value).then(i,a)}c((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,n,s,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(a){if(r)throw new TypeError("Generator is already executing.");while(i&&(i=0,a[0]&&(o=0)),o)try{if(r=1,n&&(s=a[0]&2?n["return"]:a[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;if(n=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:o.label++;return{value:a[1],done:false};case 5:o.label++;n=a[1];a=[0];continue;case 7:a=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){o=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(a[0]===6&&o.label<s[1]){o.label=s[1];s=a;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(a);break}if(s[2])o.ops.pop();o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e];n=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,o){if(o||arguments.length===2)for(var r=0,n=t.length,s;r<n;r++){if(s||!(r in t)){if(!s)s=Array.prototype.slice.call(t,0,r);s[r]=t[r]}}return e.concat(s||Array.prototype.slice.call(t))};import{r as registerInstance,h,F as Fragment,a as Host}from"./index-cfd394c8.js";import{s as stripeStoreGetDomesticShippingSession,a as stripeStoreSaveDomesticShippingSession,b as stripeStore,i as initStripeElements,c as stripeStoreRetrievePayment,d as cartStore,e as cartStoreUpdateItems,f as cartStoreReset,g as cartStoreResetTabItems,h as cartStoreClearCheckoutInterval,j as stripeStoreInitCheckoutSession,k as stripeStoreGetPaymentIntent,l as cartStoreStartCheckoutInterval,t as trackConversionEvent,m as getCheckoutSessionBody,n as cartStoreUpdateToErrorState,o as stripeStoreCleanupDomesticShippingSession,p as cartStoreSetCheckoutSession,q as stripeStorePrefetchLandedCost,r as cartStoreNextStep,u as stripeStoreUpdateCheckoutSessionBaseCurrency,v as stripeStoreHandleInventoryCheck,w as storeCreditStoreApplyCredit,x as storeCreditStoreCoversFullAmount,y as validateCheckoutSession,z as storeCreditStoreCreateOrder,A as stripeStoreConfirmPayment,B as stripeStoreHandleInventoryRefund,C as stripeStoreReset,D as cartStoreOnChange,E as stripeStoreOnChange,F as storeCreditStoreGetEffectiveAmount}from"./cart-394c9ddb.js";import{p as paypalStoreHasPaypalEnabled,a as paypalStore,b as paypalInitScript}from"./paypal-b6fa3ec3.js";import{f as filterValidTests,l as localizationStore,a as localizationStoreUpdateSelectedCountryCode,g as getZCountryUrlParam,s as storageStore,V as VARIANT_TEST_KEY_EXPIRATION,b as storageStoreSetEnabledVariantTestKeys,t as translate,c as localizationStoreOnChange,d as currencyFormat}from"./localization-0ebc8356.js";import{z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-5242a58d.js";import{b as buildCartItemsByTempCart}from"./buildCartItemsByTempCart-a117f75d.js";import{h as handleFetch,b as getAdditionalLogMetadata,g as getIsTestMode,l as logError,j as jsonParse,s as sendErrorLog,a as getIsStagingMode,i as isCheckoutMobile}from"./handleFetch-a844cac1.js";import{u as updateCheckoutSessionAttributes}from"./updateCheckoutSessionAttributes-b9f7e982.js";import{_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector,g as getAbandonedCartRenewTokenValue}from"./CheckoutConfig-724d7bae.js";import{l as log,g as getElapsedTime,b as allLogs}from"./VarianceTest-572cecf5.js";import{c as classes}from"./classes-0d95c529.js";import{c as createCustomEvent}from"./createCustomEvent-58159025.js";import{g as getBorderRadius}from"./getBorderRadius-c21a42e5.js";import{i as isDarkColor}from"./isDarkColor-3537021b.js";import{s as styles}from"./styles-6fc2fad9.js";import{s as submitGtag}from"./submitGtag-13de9f1f.js";import{R as RemoveIcon}from"./RemoveIcon-9dc5dd1a.js";import"./isContrastColor-c17e83c9.js";import"./debounce-efc0e473.js";var isStoreDiscountEnabled=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/get-store-discount-enabled-status")];case 1:e=r.sent(),t=e.errors,o=e.json;if(t.length||!(o===null||o===void 0?void 0:o.enabled)){return[2,{enabled:false}]}return[2,{enabled:true}]}}))}))};var selectVarianceTest=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,o,r,n;var s=e.testKeys;return __generator(this,(function(e){switch(e.label){case 0:if(s.length===0){return[2,null]}return[4,handleFetch("/api/zonos-elements/select-variance-test",{body:{testKeys:s},method:"POST"})];case 1:t=e.sent(),o=t.errors,r=t.json;if(o.length||!r){return[2,null]}n=filterValidTests(r);return[2,n]}}))}))};var buildCartUrl=function(e){var t=e.cartId,o=e.checkoutSessionId,r=e.customerAddress1,n=e.customerAddress2,s=e.customerCity,i=e.customerCountry,a=e.customerEmail,c=e.customerFirstName,u=e.customerLastName,l=e.customerPhone,d=e.customerState,h=e.customerZip,f=e.hostedCheckoutUrl,m=e.isTestMode,v=e.isVariantTest;var g=new URLSearchParams;g.set("tempCartUUID",t);if(c){g.set("customerFirstName",c)}if(u){g.set("customerLastName",u)}if(a){g.set("customerEmail",a)}if(l){g.set("customerPhone",l)}if(h){g.set("customerZip",h)}if(s){g.set("customerCity",s)}if(d){g.set("customerState",d)}if(i){g.set("zCountry",i)}if(r){g.set("customerAddress1",r)}if(n){g.set("customerAddress2",n)}if(m){g.set("zonosTestMode","1")}if(o){g.set("zonosCheckoutSessionId",o)}if(v){g.set("zonosVariantTest","1")}return"".concat(f,"?").concat(g.toString())};var isDisabledCountry=function(e){if(e===void 0){e=true}if(!localizationStore.localizationLoaded){return true}if(localizationStore.isDisabledCountry){if(e){log("Checkout: disabled country")}return true}return false};var isShippableCountry=function(e,t){if(e===void 0){e=true}var o;if(!localizationStore.localizationLoaded){return false}if(t){var r=!!((o=localizationStore.shippingZoneCountries)===null||o===void 0?void 0:o[t])&&!zonosStore.disabledCountries.includes(t);if(e&&!r){log("Checkout: ".concat(t," is not a shippable country: ").concat(r))}return r}if(!localizationStore.isShippableCountry){if(e){log("Checkout: not shippable country")}return false}return true};var FALLBACK_SHIP_TO_COUNTRY_SELECTOR='select[name="shippingAddress.countryCode"]';var watchImmediateBigcommerceDomesticCheckoutRedirect=function(e){var t=e.domesticRedirectedBtnSelector,o=e.onInternationalCheckoutSelected,r=e.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}var n=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,n,s;return __generator(this,(function(i){switch(i.label){case 0:r=document.querySelector(((t=zonosStore.genericSettings)===null||t===void 0?void 0:t.bigcommerceDomesticCheckoutCountrySelector)||FALLBACK_SHIP_TO_COUNTRY_SELECTOR);n=(r===null||r===void 0?void 0:r.value)||e;if(!n){return[2,false]}if(!isShippableCountry(false,n)){return[2,false]}if(!o)return[3,2];return[4,o()];case 1:i.sent();i.label=2;case 2:localizationStoreUpdateSelectedCountryCode({isInitializing:false,newSelectedCountryCode:n});s={address1:"",address2:"",city:"",countryCode:n,firstName:"",lastName:"",phone:"",postalCode:"",stateOrProvince:""};stripeStoreSaveDomesticShippingSession({address1:s.address1,address2:s.address2,city:s.city,countryCode:s.countryCode,firstName:s.firstName,lastName:s.lastName,phone:s.phone,postalCode:s.postalCode,state:s.stateOrProvince});window.location.href="/";return[2,true]}}))}))};var s=false;var i=false;var a=new MutationObserver((function(){var e;var o=document.querySelector(t);var c=stripeStoreGetDomesticShippingSession();if(!o&&c){var u=document.createElement("button");u.style.display="none";u.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(u);r===null||r===void 0?void 0:r(c);a.disconnect();return}var l=window.location.pathname.includes("/checkout")&&window.Zonos.isBigCommerce;var d=document.querySelector(((e=zonosStore.genericSettings)===null||e===void 0?void 0:e.bigcommerceDomesticCheckoutCountrySelector)||FALLBACK_SHIP_TO_COUNTRY_SELECTOR);if(!l){a.disconnect();return}if(!d){return}log("Domestic checkout found - Listening for shipping country change","info",{value:d.value});if(i){return}i=true;a.disconnect();var h=setInterval((function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;return __generator(this,(function(o){switch(o.label){case 0:if(s){return[2]}s=true;o.label=1;case 1:o.trys.push([1,3,,4]);return[4,n()];case 2:e=o.sent();if(e){clearInterval(h);return[2]}s=false;return[3,4];case 3:t=o.sent();s=false;return[3,4];case 4:return[2]}}))}))}),1e3);var f=setInterval((function(){var e;if(!window.bcStripeElements){clearInterval(f);return}var t=(e=window.bcStripeElements)===null||e===void 0?void 0:e.getElement("address");if(!t){return}clearInterval(f);t.on("change",(function(e){var t=e.value.address.country;if(t){void n(t)}}))}),500)}));a.observe(document.body,{childList:true,subtree:true})};var getLegacyQueryParams=function(){var e=new URLSearchParams(window.location.search);log("legacy urlParams","info",Object.fromEntries(e.entries()));var t=function(t){var o=e.get(t);if(!o||o==="undefined"){return""}return o};var o=getZCountryUrlParam(e)||localizationStore.selectedCountryCode||"US";var r=t("customerCity");var n=t("customerEmail");var s=t("customerAddress1");var i=t("customerAddress2");var a=t("customerName");var c=t("customerPhone");var u=t("customerZip");var l=t("customerState");var d=t("customerFirstName");var h=t("customerLastName");return{customerAddress1:s,customerAddress2:i,customerCity:r,customerCountry:o,customerEmail:n,customerFirstName:d,customerLastName:h,customerName:a,customerPhone:c,customerState:l,customerZip:u}};var numberOfFailures=0;var sendBulkLoadTimeApiLog=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;var o;return __generator(this,(function(r){switch(r.label){case 0:if(window.Zonos.loadTimeApiInfoList.length===0){return[2]}log("Sending bulk load time api log","info",{loadTimeApiInfoList:window.Zonos.loadTimeApiInfoList});e={data:__spreadArray([],window.Zonos.loadTimeApiInfoList,true),storeId:window.Zonos.storeId||0};window.Zonos.loadTimeApiInfoList.length=0;return[4,handleFetch("/api/zonos-elements/log-bulk-load-data",{body:e,method:"POST"})];case 1:t=r.sent().errors;if(t.length){(o=window.Zonos.loadTimeApiInfoList).push.apply(o,e.data);numberOfFailures++;if(numberOfFailures>5&&window.Zonos.logIntervalId){clearInterval(window.Zonos.logIntervalId)}}return[2]}}))}))};var sendLoadCheckoutFacadeLog=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;return __generator(this,(function(o){e=getElapsedTime().elapsedTime;t={cache:"miss",eventName:"jsdelivr",flag:"LOG_CHECKOUT_FACADE_LOAD",href:window.location.href,loadTime:e,metadata:Object.assign({allLogs:allLogs},getAdditionalLogMetadata()),scriptLoadUrl:"checkoutFacade",storeId:window.Zonos.storeId||0};void handleFetch("/api/zonos-elements/log-script-load",{body:t,method:"POST"});return[2]}))}))};var sendLoadNativeCheckoutLog=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t;var o=e.loadTime;return __generator(this,(function(e){t={cache:"miss",eventName:"jsdelivr",flag:"LOG_NATIVE_CHECKOUT_LOAD",href:window.location.href,loadTime:o,metadata:Object.assign({allLogs:allLogs},getAdditionalLogMetadata()),scriptLoadUrl:"nativeCheckout",storeId:window.Zonos.storeId||0};void handleFetch("/api/zonos-elements/log-script-load",{body:t,method:"POST"});return[2]}))}))};var filterExpiredTests=function(e){return(e===null||e===void 0?void 0:e.filter((function(e){if(e.expiresAt&&e.expiresAt<Date.now()||!e.expiresAt){return false}return true})))||[]};var getSelectedTestVariant=function(e){var t;var o=(t=storageStore.enabledVariantTestKeys)===null||t===void 0?void 0:t.find((function(t){return t.testKey===e}));return(o===null||o===void 0?void 0:o.selectedVariantKey)||null};var isTestEnabled=function(e){return zonosStore.enabledVariantTestKeys.includes(e)};var mergeTest=function(e){var t=e.baseTestObj,o=e.mergeTestObj;return t.map((function(e){var t=e.testKey;var r=o.find((function(e){var o=e.testKey;return o===t}));return{expiresAt:(r===null||r===void 0?void 0:r.expiresAt)||Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:(r===null||r===void 0?void 0:r.selectedVariantKey)||null,testKey:t}}))};var getTempCartById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,o,r,n,s;var i=e.cartId,a=e.retries;return __generator(this,(function(e){switch(e.label){case 0:t=getIsTestMode();return[4,handleFetch("/api/zonos-elements/get-temp-cart",{body:{isTestMode:t,options:{noOnlineStoreSettings:true},tempCartUUID:i},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:o=e.sent(),r=o.errors,n=o.json;s=!n||r.length;if(!(s&&a))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:a});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getTempCartById({cartId:i,retries:a-1})];case 3:if(s){return[2,null]}return[2,n]}}))}))};var setupCartData=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,o,r,n;return __generator(this,(function(s){switch(s.label){case 0:t=_getIsValidCartId(e),o=t.isDgsCartId,r=t.isLegacyCartId;if(!r&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getTempCartById({cartId:e,retries:5})];case 1:n=s.sent();log("[ZONOS - loadZonos] getting temp cart data","info",n);if(!n){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=n.cartData.storeId;window.Zonos.zonosApiKey=n.cartData.credentialToken;return[2,{cartData:n.cartData,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}]}}))}))};var MessageIcon='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var zonosCheckoutCss=".sc-zonos-checkout-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h{z-index:2147483647;position:fixed}.sc-zonos-checkout-h *.sc-zonos-checkout{-ms-scroll-chaining:none;overscroll-behavior:contain}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:32px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--zonos--primary-color, var(--zonos-elements-gray-0));border-right:1px solid var(--zonos-elements-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--zonos-elements-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--zonos-elements-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:relative}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 8px 8px}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:24px}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--right-actions.sc-zonos-checkout{position:absolute;right:24px;top:24px;z-index:2;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo-wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;gap:16px;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--logo-wrapper.sc-zonos-checkout>*.sc-zonos-checkout{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout img.sc-zonos-checkout{max-height:72px}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:76px;margin-bottom:8px}.zonos--close-button.sc-zonos-checkout{-ms-flex-item-align:start;align-self:flex-start}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto;position:relative}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--zonos-elements-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:32px}.hidden-mode.sc-zonos-checkout-h{height:0;opacity:0;pointer-events:none;position:absolute;visibility:hidden;width:0;z-index:-1}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:12px;padding-bottom:76px}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:0}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:16px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10));background-color:var(--zonos-elements-gray-50);padding:12px;margin-top:32px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:8px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.iframed.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{-ms-scroll-chaining:chained;overscroll-behavior:auto}.zonos--processing-payment.sc-zonos-checkout-h{z-index:2147483646}";var ZonosCheckoutStyle0=zonosCheckoutCss;var CHECKOUT_SESSION_TIMEOUT=90*60*1e3;var ORDER_DUPLICATION_NOTIFICATION_EXPIRATION=6*60*60*1e3;var ZonosCheckout=function(){function e(e){var t=this;registerInstance(this,e);this.storeUnsubscribeList=[];this.isRedirectAfterOrder=false;this.preview=false;this.hiddenMode=false;this.mobile=false;this.defaultAddress=[];this.forceDialogOpen=false;this.defaultAddressParams=[];this.defaultCustomerProfileAddress=[];this.customerProfile=null;this.open=this.forceDialogOpen;this.isOverlayLoading=false;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.collapseReviewMobile=true;this.isAttachError=false;this.isMobile=false;this.isIframed=false;this.isLegacyCheckout=window.Zonos.isLegacyCheckout;this.confirmDialogOpen=false;this.isCartExpired=false;this.payInUsdConfirmDialogOpen=false;this.inventoryCheckErrorMessage=null;this.placedOrderInfo=null;this.shouldShowFedexShippingConsentDialog=false;this.detectedDomesticCheckoutDialogOpen=false;this.redirectToDomesticCheckoutDialogOpen=false;this.clientSecret=stripeStore.clientSecret;this.stripeCustomerSessionClientSecret=stripeStore.stripeCustomerSessionClientSecret;this.applyStripeTheme=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,o,r,n;return __generator(this,(function(s){switch(s.label){case 0:n=((e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRadius:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.style,overridePrimaryColor:(o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.colorPrimary,overrideSecondaryColor:(r=this.appearanceSettingsOverride)===null||r===void 0?void 0:r.colorSecondary,overrideTheme:this.isMobile?n:undefined,paypalEnabled:paypalStoreHasPaypalEnabled()})];case 1:s.sent();return[2]}}))}))};this.checkStripePaymentIntentStatus=function(e){return __awaiter(t,[e],void 0,(function(e){var t,o,r,n,s,i,a,c,u;var l=e.triggeredButton;return __generator(this,(function(e){switch(e.label){case 0:t=l===null||l===void 0?void 0:l.matches("#".concat(checkoutHiddenBtnSelector));o=!!window.Zonos.cartData;r=new URL(window.location.href).searchParams;n=r.get("payment_intent_client_secret");s=r.get("zonosCheckoutSessionId");if(!t){log("Checkout is triggered by user, no need to check stripe payment intent status");return[2,{shouldAllowOrder:true}]}log("Payment intent exist, checking stripe payment intent status");if(!n){log("No stripe client secret found in the URL, proceed to order if cart data is available");return[2,{shouldAllowOrder:o}]}return[4,stripeStoreRetrievePayment({clientSecret:n})];case 1:i=e.sent(),a=i.error,c=i.status;u=new URLSearchParams(window.location.search).get("redirect_status");if(u){if(!a){log("Payment intent is succeeded or in a good state to move forward, show success screen")}else{log("Payment intent failed, show status from error")}this.open=true;storageStore.checkoutSessionId=s;stripeStore.clientSecret=n;void this.setToFinishStep(c);return[2,{shouldAllowOrder:false}]}if(!o){log("Cart data is not available, only check payment intent status, skip order.");return[2,{shouldAllowOrder:false}]}log("Payment intent is not succeeded, proceed to order");return[2,{shouldAllowOrder:true}]}}))}))};this.initializeTestKeys=function(){storageStore.enabledVariantTestKeys=filterExpiredTests(storageStore.enabledVariantTestKeys||[]);var e=zonosStore.enabledVariantTestKeys.map((function(e){var t;var o=(t=storageStore.enabledVariantTestKeys)===null||t===void 0?void 0:t.find((function(t){var o=t.testKey;return o===e}));return{expiresAt:(o===null||o===void 0?void 0:o.expiresAt)||Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:(o===null||o===void 0?void 0:o.selectedVariantKey)||null,testKey:e}}));storageStoreSetEnabledVariantTestKeys(e);return{allSelected:false}};this.shouldAllowHostedVsNativeTest=function(){if(typeof zonosStore.checkoutSettings.createCartId!=="function"){return false}var e=zonosStore.enabledVariantTestKeys.includes("hosted_vs_native");if(!e){return false}return true};this.registerTestHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,o,r;return __generator(this,(function(n){switch(n.label){case 0:e=this.shouldAllowHostedVsNativeTest();if(!e){return[2]}log("[TEST] - Registering hosted vs native test");t=getSelectedTestVariant("hosted_vs_native");if(t){log("[TEST] - Hosted vs native test already has variant selected: ".concat(t));return[2]}return[4,selectVarianceTest({testKeys:["hosted_vs_native"]})];case 1:o=n.sent();if(!o){log("[TEST] - Failed to get selection for hosted vs native test");return[2]}r=mergeTest({baseTestObj:storageStore.enabledVariantTestKeys||[],mergeTestObj:o});storageStoreSetEnabledVariantTestKeys(r);return[2]}}))}))};this.handleHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,o,r,n,s,i,a;return __generator(this,(function(c){switch(c.label){case 0:t=this.shouldAllowHostedVsNativeTest();if(!t){return[2,{redirected:false}]}o=getSelectedTestVariant("hosted_vs_native");log("[TEST] - hosted_vs_native: ".concat(o));if(typeof zonosStore.checkoutSettings.createCartId!=="function"){log("[TEST] - createCartId is not provided, skipping hosted vs native test");return[2,{redirected:false}]}if(o!=="hosted"){log("[TEST] - Hosted vs native test is enabled for native, skipping");return[2,{redirected:false}]}if(!((e=zonosStore.genericSettings)===null||e===void 0?void 0:e.hostedCheckoutUrl)){log("[TEST] - Hosted checkout URL is not provided");return[2,{redirected:false}]}log('"createCartId" is provided, start building cart');return[4,zonosStore.checkoutSettings.createCartId()];case 1:r=c.sent();s=null;if(typeof r==="object"){n=r.cartId;s=r.shippingData||null}else{n=r}i=getLegacyQueryParams();a=buildCartUrl(Object.assign(Object.assign({cartId:n,checkoutSessionId:storageStore.checkoutSessionId||undefined,hostedCheckoutUrl:zonosStore.genericSettings.hostedCheckoutUrl,isTestMode:getIsTestMode(),isVariantTest:true},i),s));log("[TEST] - Redirecting to: ".concat(a));window.open(a,"_blank");return[2,{redirected:true}]}}))}))};this.formatDate=function(e){if(!e){return""}var t=new Date(e);return t.toLocaleDateString()};this.formatTime=function(e){if(!e){return""}var t=new Date(e);return t.toLocaleTimeString()};this.getCurrentLocalePageEnum=function(){switch(cartStore.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.getBaseCurrencySettlementInfo=function(){var e=cartStore.selectedLandedCost;if(!e){return null}var t=e.landedCost.amountSubtotals;if(!t){return null}var o=(t.discounts||0)+t.items+t.landedCostTotal+t.shipping;return{settlementAmount:o}};this.getDefaultAddress=function(){if(t.defaultCustomerProfileAddress.length){return t.defaultCustomerProfileAddress}if(Array.isArray(t.defaultAddress)&&t.defaultAddress.length){return t.defaultAddress}if(!Array.isArray(t.defaultAddress)&&typeof t.defaultAddress==="object"){return[t.defaultAddress]}return t.defaultAddressParams};this.handleHostedOpenWindowCallback=function(e){var t;var o=(t=zonosStore.genericSettings)===null||t===void 0?void 0:t.hostedCheckoutUrl;if(!origin){return}var r=["dev.checkout.elements.zonos.com"].some((function(t){return e.origin.includes(t)}));if(e.origin!==o&&!r){return}switch(e.data.type){case"zonos-checkout-session-update":storageStore.checkoutSessionId=e.data.checkoutSessionId;break}};this.captureParamsRedirectedForVariantTest=function(){var e=new URL(window.location.href);var t=e.searchParams.get("zonosVariantTest")==="1";if(!t){return}var o=e.searchParams.get("zonosCheckoutSessionId");if(o){storageStore.checkoutSessionId=o}var r=storageStore.enabledVariantTestKeys||[];if(window.Zonos.isLegacyCheckout){var n=getSelectedTestVariant("hosted_vs_native");if(!n){r.push({expiresAt:Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:"hosted",testKey:"hosted_vs_native"});storageStoreSetEnabledVariantTestKeys(r)}else{storageStoreSetEnabledVariantTestKeys(r.map((function(e){if(e.testKey==="hosted_vs_native"){return Object.assign(Object.assign({},e),{selectedVariantKey:"hosted"})}return e})))}}e.searchParams.delete("zonosCheckoutSessionId");e.searchParams.delete("zonosVariantTest");window.history.replaceState({},"",e.toString())}}e.prototype.initCartInfoHandler=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(o){t=e.detail;void cartStoreUpdateItems({adjustments:cartStore.adjustments,cartItems:t});return[2]}))}))};e.prototype.handleKeyPress=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(e.key==="Escape"){void this.closeDialogHandler()}return[2]}))}))};e.prototype.closeDialogHandler=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o;return __generator(this,(function(r){if(!this.open){return[2]}if(!(e===null||e===void 0?void 0:e.confirmed)){this.confirmDialogOpen=true;return[2]}this.confirmDialogOpen=false;submitGtag({event:"zonos-checkout-close",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";cartStoreResetTabItems();cartStoreClearCheckoutInterval();(o=(t=zonosStore.checkoutSettings).onClose)===null||o===void 0?void 0:o.call(t);return[2]}))}))};e.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r,n,s,i,a,s,i,i,c,u,s,l;return __generator(this,(function(d){switch(d.label){case 0:if(!(typeof zonosStore.checkoutSettings.createCartId==="function"))return[3,4];log('"createCartId" is provided, start building cart');return[4,zonosStore.checkoutSettings.createCartId()];case 1:e=d.sent();t=void 0;if(typeof e==="object"){log("object detected, use cartId and prefill address from createCartId","info",e);t=e.cartId;this.useShippingDataFromCreateCartId(e.shippingData);cartStore.customerAuthenticationToken=e.customerAuthenticationToken||null}else{t=e}window.Zonos.cartId=t;return[4,setupCartData(t)];case 2:o=d.sent();r=o===null||o===void 0?void 0:o.cartData;if(!r){logError("Failed to build cart, please try again.");return[2,false]}window.Zonos.cartData=r;n=buildCartItemsByTempCart(r),s=n.adjustments,i=n.cartItems;return[4,cartStoreUpdateItems({adjustments:s,cartItems:i})];case 3:d.sent();return[3,9];case 4:if(!window.Zonos.cartData)return[3,6];log("tempCartUUID is provided, start building cart");a=buildCartItemsByTempCart(window.Zonos.cartData),s=a.adjustments,i=a.cartItems;return[4,cartStoreUpdateItems({adjustments:s,cartItems:i})];case 5:d.sent();return[3,9];case 6:if(!(zonosStore.checkoutSettings.buildCartDetail&&localizationStore.selectedCountryCode))return[3,9];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail({countryCode:localizationStore.selectedCountryCode,currencyCode:localizationStore.targetCurrency})];case 7:i=d.sent();c=i.filter((function(e){return e.amount>=0}));u=i.filter((function(e){return e.amount<0}));log("cartItems","info",{cartItems:i});s=u.map((function(e){return{amount:e.amount,currencyCode:e.currencyCode,description:e.name||e.description||"",productId:e.productId||null,sku:e.sku||null,type:"CART_TOTAL"}}));return[4,cartStoreUpdateItems({adjustments:s,cartItems:c})];case 8:d.sent();d.label=9;case 9:if(!!storageStore.checkoutSessionId)return[3,11];return[4,stripeStoreInitCheckoutSession()];case 10:l=d.sent();log("stripeStoreInitCheckoutSession: ".concat(l));if(!l){return[2,false]}d.label=11;case 11:if(!cartStore.isStagingMode){void stripeStoreGetPaymentIntent()}return[4,this.applyStripeTheme()];case 12:d.sent();this.isRedirectAfterOrder=zonosStore.checkoutSettings.successBehavior==="REDIRECT_TO_SUCCESS_PAGE"||!!cartStore.externalConfirmationPageURL;return[2,true]}}))}))};e.prototype.reloadCheckoutSession=function(){window.location.reload()};e.prototype.handleOrderDuplication=function(){var e=jsonParse(localStorage.getItem("zonos--placed-order-info"));if(!e){localStorage.removeItem("zonos--placed-order-info");return}var t=Date.now()-e.time;log("=== Existing placed order info: ".concat(e.orderId," - ").concat(this.formatDate(e.time)," - elapsed in hh:ss format: ").concat(new Date(t).toISOString().substring(11,8)),"warn");var o=parseFloat(new URLSearchParams(window.location.search).get("zonosOverrideExpiredDuplication")||"0")||ORDER_DUPLICATION_NOTIFICATION_EXPIRATION;if(t>o){log("=== Existing placed order info is older than ".concat(o,"ms, cleaning localStorage"),"warn");localStorage.removeItem("zonos--placed-order-info");return}this.placedOrderInfo=e;log("=== Showing order duplication confirmation","warn")};e.prototype.recordCheckoutInfo=function(){if(!storageStore.checkoutSessionId){return}void updateCheckoutSessionAttributes({attributes:[{key:"APP_VERSION",value:window.Zonos.version},{key:"APP_VERSION_NPM_INTEGRATION",value:window.Zonos.isNpm?"1":"0"},{key:"LEGACY_CHECKOUT_FACADE",value:window.Zonos.isLegacyCheckout?"1":"0"}],checkoutSessionId:storageStore.checkoutSessionId})};e.prototype.confirmProceedWithOrderDuplication=function(){this.placedOrderInfo=null;if(!storageStore.checkoutSessionId){return}void updateCheckoutSessionAttributes({attributes:[{key:"ORDER_DUPLICATION_CONSENT",value:"1"}],checkoutSessionId:storageStore.checkoutSessionId})};e.prototype.markTheSessionAsAbandonedCart=function(){if(!storageStore.checkoutSessionId){return}void updateCheckoutSessionAttributes({attributes:[{key:"WITH_ABANDONED_CART_TOKEN",value:"1"}],checkoutSessionId:storageStore.checkoutSessionId})};e.prototype.handleCancelOrderDuplication=function(){var e;this.placedOrderInfo=null;if(this.isLegacyCheckout){var t=((e=window.Zonos.cartData)===null||e===void 0?void 0:e.storeBaseUrl)||zonosStore.onlineStoreSettings.url;if(!t){return}if(window.parent){window.parent.location.href=t}window.location.href=t;return}void this.closeDialogHandler({confirmed:true})};e.prototype.attachCheckout=function(){var e=this;var t=zonosStore.checkoutSettings.placeOrderButtonSelector;var o=zonosStore.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;log("attach checkout ".concat(t));log("attach checkout to always trigger international checkout selector: ".concat(o));if(!t&&!o&&!window.Zonos.cartData){return}var r=[t,o,"#".concat(domesticRedirectedBtnSelector),"#".concat(checkoutHiddenBtnSelector),"#".concat(checkoutHiddenInternationalBtnSelector)].filter(Boolean);var n=document.querySelectorAll(r.join(","));n.forEach((function(r){var n=r.getAttribute("data-zonos-checkout-attached");if(n){return}log("attached event to button ".concat(t),"info",{button:r});r.addEventListener("click",(function(t){return __awaiter(e,void 0,void 0,(function(){var e,n,s,i,a,c,u,l,d,h,f,m,v,g,p,S;return __generator(this,(function(z){switch(z.label){case 0:s=performance.now();i=o&&r.matches(o);a=r.matches("#".concat(checkoutHiddenInternationalBtnSelector));c=r.matches("#".concat(domesticRedirectedBtnSelector))||r.matches("#".concat(checkoutHiddenBtnSelector));if(!window.Zonos.isLegacyCheckout&&(!isShippableCountry()||isDisabledCountry())&&!i&&!a&&!c){return[2]}t.preventDefault();t.stopPropagation();log("zonos checkout button clicked");return[4,this.checkStripePaymentIntentStatus({triggeredButton:t.target})];case 1:u=z.sent().shouldAllowOrder;if(!u){return[2]}if(!window.Zonos.logIntervalId){window.Zonos.logIntervalId=setInterval((function(){void sendBulkLoadTimeApiLog()}),2e3)}if(!isTestEnabled("hosted_vs_native"))return[3,4];this.isOverlayLoading=true;return[4,this.registerTestHostedVsNative()];case 2:z.sent();return[4,this.handleHostedVsNative()];case 3:l=z.sent().redirected;this.isOverlayLoading=false;if(l){return[2]}z.label=4;case 4:stripeStore.isFetchingSession=true;this.open=true;z.label=5;case 5:z.trys.push([5,8,,9]);return[4,this.buildCartAndInit()];case 6:d=z.sent();if(!d){throw new Error("Error building cart")}(e=window.opener)===null||e===void 0?void 0:e.postMessage({checkoutSessionId:storageStore.checkoutSessionId,type:"zonos-checkout-session-update"},"*");cartStoreStartCheckoutInterval({isPreview:this.preview,sessionTimeout:CHECKOUT_SESSION_TIMEOUT});submitGtag({event:"zonos-checkout-start",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});h=storageStore.checkoutSessionId;void trackConversionEvent({checkoutSessionId:h,eventName:"checkout_open"});return[4,isStoreDiscountEnabled()];case 7:f=z.sent().enabled;cartStore.shouldHideDiscountInput=!f;this.handleOrderDuplication();if(window.Zonos.isLegacyCheckout){void sendLoadCheckoutFacadeLog()}else{m=performance.now();v=m-s;void sendLoadNativeCheckoutLog({loadTime:v})}this.recordCheckoutInfo();g=!!getAbandonedCartRenewTokenValue();if(g){this.markTheSessionAsAbandonedCart()}return[3,9];case 8:p=z.sent();if(p instanceof Error){S=p.message;if(S==="Cart is expired."){this.isCartExpired=true}}stripeStore.isFetchingSession=false;logError(p);if(this.isCartExpired){stripeStore.isFetchingSession=true;return[2]}void sendErrorLog({endpoint:"Error creating Checkout",errors:[p instanceof Error?p.toString():"Unknown error"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionBody:getCheckoutSessionBody(),href:window.location.href,storeBaseUrl:((n=window.Zonos.cartData)===null||n===void 0?void 0:n.storeBaseUrl)||zonosStore.onlineStoreSettings.url}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,9];case 9:return[2]}}))}))}),{capture:true,passive:false});if(!zonosStore.checkoutSettings.disablePlaceOrderButtonActivation){r.removeAttribute("disabled")}r.setAttribute("data-zonos-checkout-attached","true");if(r.matches("#".concat(domesticRedirectedBtnSelector))){r.dispatchEvent(createCustomEvent("click"));stripeStoreCleanupDomesticShippingSession();r.remove()}if(r.matches("#".concat(checkoutHiddenBtnSelector))){r.dispatchEvent(createCustomEvent("click"));r.remove()}}))};e.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};e.prototype.useShippingDataFromCreateCartId=function(e){if(!e){return}log("shipping data from createCartId result","info",Object.entries(e));var t=e.customerAddress1,o=e.customerAddress2,r=e.customerCity,n=e.customerCountry,s=e.customerEmail,i=e.customerFirstName,a=e.customerLastName,c=e.customerName,u=e.customerPhone,l=e.customerState,d=e.customerZip;var h=new URLSearchParams(window.location.search);var f=n||getZCountryUrlParam(h)||localizationStore.selectedCountryCode;this.applyPrefillAddress({customerAddress1:t,customerAddress2:o,customerCity:r,customerCountry:f,customerEmail:s,customerFirstName:i,customerLastName:a,customerName:c,customerPhone:u,customerState:l,customerZip:d})};e.prototype.useLegacyQueryParams=function(){var e=new URLSearchParams(window.location.search);log("legacy urlParams","info",Object.fromEntries(e.entries()));var t=function(t){var o=e.get(t);if(!o||o==="undefined"){return null}return o};var o=getZCountryUrlParam(e)||localizationStore.selectedCountryCode;var r=t("customerCity");var n=t("customerEmail");var s=t("customerAddress1");var i=t("customerAddress2");var a=t("customerName");var c=t("customerFirstName");var u=t("customerLastName");var l=t("customerPhone");var d=t("customerZip");var h=t("customerState");this.applyPrefillAddress({customerAddress1:s,customerAddress2:i,customerCity:r,customerCountry:o,customerEmail:n,customerFirstName:c,customerLastName:u,customerName:a,customerPhone:l,customerState:h,customerZip:d})};e.prototype.applyPrefillAddress=function(e){var t=e.customerAddress1||"";var o=e.customerCountry||"";var r=e.customerAddress2||"";var n=e.customerCity||"";var s=e.customerEmail||"";var i=e.customerFirstName&&e.customerLastName?"".concat(e.customerFirstName," ").concat(e.customerLastName):e.customerName||"";var a=e.customerPhone||"";var c=e.customerZip||"";var u=e.customerState||"";if(!t||!i||!a||!o){log("Missing required query params so it can not be prefilled","info",[!t&&"line1",!i&&"name",!a&&"phone",!o&&"country"].filter(Boolean).join(", "));return}if(o&&localizationStore.shippingZoneCountries&&!(o in localizationStore.shippingZoneCountries)){log('Country "'.concat(o,'" is not in the shipping zone, so it can not be prefilled'),"warn");return}this.defaultAddressParams=[{address:{city:n||"",country:o,line1:t,line2:r,postal_code:c,state:u},email:s,name:i,phone:a}];log("Prefill address applied","info",{prefillAddress:this.defaultAddressParams,providedAddress:e})};e.prototype.overrideStagingModeChanged=function(){cartStore.isStagingMode=!!this.overrideStagingMode};e.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var e;var t=this;return __generator(this,(function(o){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;cartStore.isStagingMode=getIsStagingMode();if(typeof this.overrideStagingMode!=="undefined"){cartStore.isStagingMode=this.overrideStagingMode}watchImmediateBigcommerceDomesticCheckoutRedirect({domesticRedirectedBtnSelector:domesticRedirectedBtnSelector,onInternationalCheckoutSelected:function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:this.detectedDomesticCheckoutDialogOpen=true;return[4,new Promise((function(e){return setTimeout(e,2e3)}))];case 1:e.sent();return[2]}}))}))},onShippingAddressSessionFound:function(e){t.defaultAddress=[{address:{city:e.city,country:e.countryCode,line1:e.address1,line2:e.address2,postal_code:e.postalCode,state:e.state},email:"",name:"".concat(e.firstName," ").concat(e.lastName),phone:e.phone}]}});if(window.Zonos){this.useLegacyQueryParams()}e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else if(window.Zonos.isLegacyCheckout){t.attachCheckout()}else if(window){t.attachCheckout();var o=new MutationObserver((function(){t.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};e.prototype.setToFinishStep=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){cartStore.step="finish";this.storybookPaymentStatusOverride=e;return[2]}))}))};e.prototype.mockCheckoutSession=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){cartStoreSetCheckoutSession(e);return[2]}))}))};e.prototype.triggerCheckoutInternational=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));if(e){e.dispatchEvent(createCustomEvent("click"))}return[2]}))}))};e.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r,n,s,i,a;var c=this;return __generator(this,(function(u){switch(u.label){case 0:submitGtag({event:"zonos-checkout-customer-info",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});n=storageStore.checkoutSessionId;void trackConversionEvent({checkoutSessionId:n,eventName:"checkout_customerInfoCompleted"});this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:s=u.sent().isRequestNotReady;if(s&&cartStore.addressFormRenderType==="stripe"){void sendErrorLog({endpoint:"ADDRESS_NOT_READY_AT_CUSTOMER_INFO_CONTINUE",errors:["Address not ready at customer info continue"],metadata:{address:(t=(e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.value)===null||t===void 0?void 0:t.address,billingAddress:(r=(o=stripeStore.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value)===null||r===void 0?void 0:r.address,cartId:window.Zonos.cartId}})}i=function(e){if(cartStore.step!=="customer-info"){clearInterval(e);return}if(!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){void paypalInitScript({currency:cartStore.currency});cartStoreNextStep()}c.submitLoading=false;if(e){clearInterval(e)}}};i();a=setInterval((function(){i(a)}),20);setTimeout((function(){clearInterval(a)}),1e4);return[2]}}))}))};e.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStoreNextStep();return[2]}))}))};e.prototype.handleInventoryCheckDialogConfirm=function(){cartStore.inventoryCheckErrorMessage=null;if(!this.isLegacyCheckout){void this.closeDialogHandler({confirmed:true})}};e.prototype.handleCartExpiredDialogConfirm=function(){var e;this.isCartExpired=false;if(this.isLegacyCheckout){var t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.storeBaseUrl;if(!t){return}if(window.parent){window.parent.location.href=t}window.location.href=t;return}if(window.parent){window.parent.location.href=window.location.href}window.location.reload()};e.prototype.handleStripePaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r,n,s,i,a,c,u;return __generator(this,(function(l){switch(l.label){case 0:e=stripeStore.checkoutSettlementCurrency==="USD";if(e&&stripeStore.shouldRenderPayInUsdButton&&!this.payInUsdConfirmDialogOpen){this.payInUsdConfirmDialogOpen=true;return[2]}this.payInUsdConfirmDialogOpen=false;paypalStore.paypalErrorMessage=null;stripeStore.hasPaymentError=false;this.submitLoading=true;cartStore.inventoryCheckErrorMessage=null;return[4,stripeStoreUpdateCheckoutSessionBaseCurrency()];case 1:t=l.sent();if(!t){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=translate("Unable to complete payment in [currency]. Please try again or select a different currency. If the issue persists, contact our support team for assistance.",{currency:stripeStore.checkoutSettlementCurrency});this.submitLoading=false;return[2]}l.label=2;case 2:l.trys.push([2,4,,5]);o=cartStore;return[4,stripeStoreHandleInventoryCheck()];case 3:o.inventoryCheckErrorMessage=l.sent();return[3,5];case 4:r=l.sent();cartStore.inventoryCheckErrorMessage=translate("Unable to check inventory. Please try again.");return[3,5];case 5:if(cartStore.inventoryCheckErrorMessage){this.submitLoading=false;return[2]}n=storeCreditStoreGetEffectiveAmount();if(!(n>0))return[3,7];return[4,storeCreditStoreApplyCredit()];case 6:s=l.sent();if(!s.success){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=s.error||translate("Unable to apply store credit. Please try again.");this.submitLoading=false;return[2]}l.label=7;case 7:if(!storeCreditStoreCoversFullAmount())return[3,13];l.label=8;case 8:l.trys.push([8,11,,12]);return[4,validateCheckoutSession()];case 9:i=l.sent();if(!i.valid){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=i.errorMessage;this.submitLoading=false;return[2]}return[4,storeCreditStoreCreateOrder()];case 10:a=l.sent();if(!a.success){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=a.error||translate("Unable to place order with store credit. Please try again.");this.submitLoading=false;return[2]}cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,12];case 11:c=l.sent();logError(c);submitGtag({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});stripeStore.hasPaymentError=true;return[3,12];case 12:this.submitLoading=false;return[2];case 13:l.trys.push([13,15,,16]);return[4,stripeStoreConfirmPayment()];case 14:l.sent();cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,16];case 15:u=l.sent();logError(u);submitGtag({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});stripeStore.hasPaymentError=true;if(stripeStore.shouldInventoryRefund){void stripeStoreHandleInventoryRefund();stripeStore.shouldInventoryRefund=false}return[3,16];case 16:this.submitLoading=false;return[2]}}))}))};e.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r;return __generator(this,(function(n){switch(n.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:n.sent();return[2];case 2:cartStoreReset();if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData){e=window.Zonos.cartData.storeBaseUrl||zonosStore.onlineStoreSettings.url;if(window.parent){window.parent.location.href=e}window.location.href=e;return[2]}t=window.location.href;o=t.split("?")[0];this.open=false;r=window.location.hostname.includes("dashboard.zonos.com");if(!r){window.history.replaceState(window.history.state,document.title,o);window.location.reload()}return[2]}}))}))};e.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};e.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};e.prototype.handleAppearanceSettingsOverrideChange=function(){var e;if((e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};e.prototype.handleAddressChange=function(){stripeStoreReset()};e.prototype.handleCustomerProfileChange=function(){var e,t;if(!this.customerProfile){log("No customer profile","info");this.defaultCustomerProfileAddress=[];return}log("Customer profile found","info",{customerProfile:this.customerProfile});this.defaultCustomerProfileAddress=((t=(e=stripeStore.customerProfile)===null||e===void 0?void 0:e.locations)===null||t===void 0?void 0:t.map((function(e){var t;return{address:{city:e.locality,country:e.countryCode,line1:e.line1,line2:e.line2||"",postal_code:e.postalCode,state:e.administrativeArea},email:e.email||((t=stripeStore.customerProfile)===null||t===void 0?void 0:t.email)||"",name:e.name||"",phone:e.phone||""}})))||[]};e.prototype.handleClientSecretChange=function(){log("==== Client secret changed","info",{clientSecret:this.clientSecret,stripeCustomerSessionClientSecret:this.stripeCustomerSessionClientSecret});void this.applyStripeTheme()};e.prototype.handleOpenChange=function(){var e="data-zonos-overflow-origin";var t=document.body;var o=document.documentElement;if(this.open){window.Zonos.openHelloDialog(false);if(t.style.overflow){t.setAttribute(e,t.style.overflow)}t.style.overflow="hidden";if(o.style.overflow){o.setAttribute(e,o.style.overflow)}o.style.overflow="hidden"}else{this.stripeCustomerSessionClientSecret=null;var r=t.getAttribute(e);var n=o.getAttribute(e);if(r){t.removeAttribute(e);t.style.overflow=r}else{t.style.removeProperty("overflow")}if(n){o.removeAttribute(e);o.style.overflow=n}else{o.style.removeProperty("overflow")}}};e.prototype.componentWillLoad=function(){var e=this;void this.init();this.isMobile=isCheckoutMobile(this.mobile);this.isIframed=window.self!==window.top;log("iframed: ".concat(this.isIframed));if(window.Zonos.isLegacyCheckout){this.captureParamsRedirectedForVariantTest()}this.handleAppearanceSettingsOverrideChange();this.storeUnsubscribeList=[localizationStoreOnChange("selectedLocale",(function(){void e.applyStripeTheme()})),cartStoreOnChange("selectedShippingOption",(function(){var t,o,r,n;var s=cartStore.selectedShippingOption;if(((t=zonosStore.genericSettings)===null||t===void 0?void 0:t.shouldFedExShippingConsentForCanadianShopper)&&((r=(o=s===null||s===void 0?void 0:s.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.code)===null||r===void 0?void 0:r.toLowerCase().startsWith("fedex."))&&((n=stripeStore.stripeAddressEventData)===null||n===void 0?void 0:n.value.address.country)==="CA"){e.shouldShowFedexShippingConsentDialog=true}})),stripeStoreOnChange("stripeAddressEventData",(function(t){var o;if(!window.Zonos.isBigCommerce||!t||e.redirectToDomesticCheckoutDialogOpen||!((o=zonosStore.genericSettings)===null||o===void 0?void 0:o.isBigcommerceDomesticCheckoutRedirectEnabled)||zonosStore.sourceCurrency!=="USD"){return}var r=t.value.address.country;if(r&&zonosStore.disabledCountries.includes(r)){e.redirectToDomesticCheckoutDialogOpen=true;log("Domestic country ".concat(r," selected in international checkout, redirecting to BigCommerce domestic checkout"),"info");setTimeout((function(){window.location.href="/checkout"}),2e3)}}))];this.initializeTestKeys();window.addEventListener("message",this.handleHostedOpenWindowCallback);log("mobile: ".concat(this.isMobile))};e.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset();this.storeUnsubscribeList.forEach((function(e){return e()}));window.removeEventListener("message",this.handleHostedOpenWindowCallback)};e.prototype.render=function(){var e=this;var t,o,r,n;this.customerProfile=stripeStore.customerProfile;this.clientSecret=stripeStore.clientSecret;if(stripeStore.stripeCustomerSessionClientSecret){this.stripeCustomerSessionClientSecret=stripeStore.stripeCustomerSessionClientSecret}var s=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var i=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride||null),a=i.colorPrimary,c=i.colorSecondary,u=i.logoUrl,l=i.style;var d=zonosStore.appearance.zonosAttribution==="ENABLED";var f=zonosStore.appearance.theme;var m=a&&isDarkColor(a)?"DARK":"LIGHT";var v=this.isMobile?f:m;var g=!this.isMobile?c:undefined;var p=localizationStore.customMessages;var S=(t=p.find((function(e){return e.pageName==="checkout_default"})))===null||t===void 0?void 0:t.message;var z=this.getCurrentLocalePageEnum();var k=p.filter((function(e){return e.pageName===z}));var w=this.getBaseCurrencySettlementInfo();var C=function(){var t=e.preview?"".concat(u,"?timestamp=").concat(Date.now()):u;return h("div",{class:"zonos--logo"},t&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:t}))};var y=getIsTestMode();var b=function(){var t=new URLSearchParams(window.location.search);var o=t.get("zonosQaUrl");var r=t.get("zonosDebug");var n=t.get("zonosE2ETest");var s=e.overrideStagingMode||getIsStagingMode();return h("zonos-v-stack",null,h("div",{class:"zonos--logo-wrapper"},C(),y&&h("zonos-badge",{badgeColor:"orange",size:"small"},translate("Test mode")),s&&h("zonos-badge",{badgeColor:"red",size:"small"},translate("Staging mode")),r==="1"&&h("zonos-badge",{badgeColor:"cyan",size:"small"},"debug"),o&&h("zonos-badge",{badgeColor:"purple",size:"small"},o),n&&h("zonos-badge",{badgeColor:"gray",size:"small"},"E2E Test")),h("zonos-checkout-progress-tabs",{backgroundColor:e.isMobile?"--zonos-elements-gray-0":null}),k.map((function(e){return h("zonos-custom-message",{icon:MessageIcon,message:e.message})})))};var _=function(){if(cartStore.checkoutSessionTimeoutShow){return h("zonos-rest-state",{class:"zonos--session-timeout",restStateSubtitle:translate("Your checkout session has expired. Please reload the page to continue."),restStateTitle:translate("Session timed out"),restStateType:"Warning"},h("zonos-button",{onClick:function(){return e.reloadCheckoutSession()},variant:"primary"},translate("Reload")))}return h("div",{class:"zonos--content",style:{"--zonos--border-radius":getBorderRadius({overrideBorderStyle:l})}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":v,style:styles({"--zonos--primary-color":!e.isMobile?a:undefined})},!e.isMobile&&b(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:e.submitLoading,defaultAddress:e.getDefaultAddress(),isMobile:e.isMobile,onContinueClicked:function(){return e.handleCustomerInfoContinue()},submitBtnColor:g}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return e.handleShippingContinue()},submitBtnColor:g}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.handleStripePaymentContinue()];case 1:e.sent();return[2]}}))}))},submitBtnColor:g})),h("div",{class:"zonos--right","data-theme":f},e.isMobile&&b(),h("div",{class:"zonos--right-actions"},window.Zonos.showBaseForeign&&h("zonos-currency-toggle",null),!e.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return e.closeDialogHandler()}})),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:e.collapseReviewMobile,mobile:e.isMobile,onClick:function(){if(!e.isMobile){return}e.collapseReviewMobile=!e.collapseReviewMobile}}),h("zonos-collapse",{collapsed:e.collapseReviewMobile&&e.isMobile},h("zonos-cart-items",null),e.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",{submitBtnColor:g}),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:S})))),h("zonos-cart-restricted-items",null),!e.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:S}))))),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":f},h("div",{class:"zonos--header"},C(),!e.isRedirectAfterOrder&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return e.handleFinishClick()},theme:f})),h("zonos-checkout-finish",{borderRadius:l,onCloseClick:function(){return e.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:e.storybookPaymentStatusOverride})),h("zonos-checkout-footer",{"data-theme":f,mobile:e.isMobile,slot:!e.isMobile?"dialog-footer":undefined}))};return h(Host,{class:classes(["zonos--checkout zonos--elements",cartStore.step==="payment"&&"zonos--processing-payment",d&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile",this.isIframed&&"iframed",this.hiddenMode&&"hidden-mode"])},this.preview?_():h("zonos-dialog",{borderStyle:l,class:"zonos--checkout-dialog","data-theme":f,height:"980px",isLoading:s,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return e.closeDialogHandler()},open:this.open,width:"1200px"},_()),h("zonos-dialog",{isLoading:true,loadingText:translate("You will be redirected to international checkout shortly."),loadingTitle:translate("We detected that you are shipping to an international address."),noClickOutside:true,noCloseButton:true,open:this.detectedDomesticCheckoutDialogOpen,width:"450px"}),h("zonos-dialog",{isLoading:true,loadingText:translate("You will be redirected to domestic checkout shortly."),loadingTitle:translate("We detected that you are shipping to a domestic address."),noClickOutside:true,noCloseButton:true,open:this.redirectToDomesticCheckoutDialogOpen,width:"450px"}),h("zonos-confirm-dialog",{class:"zonos--close-confirm-dialog",dialogCancelBtnText:translate("Don't close"),dialogConfirmBtnText:translate("Close"),dialogIntent:"warn",dialogOpen:this.confirmDialogOpen,dialogSubtitle:translate("Would you like to close checkout and return to the site?"),dialogTitle:translate("Are you sure?"),onCancelClicked:function(){e.confirmDialogOpen=false},onConfirmClicked:function(){return e.closeDialogHandler({confirmed:true})}}),h("zonos-confirm-dialog",{class:"zonos--order-duplication-dialog",dialogCancelBtnText:translate("Return to merchant site"),dialogConfirmBtnText:translate("Proceed with order"),dialogIntent:"warn",dialogOpen:!!this.placedOrderInfo,dialogSubtitle:((o=this.placedOrderInfo)===null||o===void 0?void 0:o.zonosOrderNumber)?translate("It looks like you placed an order recently ([date] at [time]) under order number #[orderNumber]. Check your email for the order confirmation. Are you sure you want to place another order?",{date:this.formatDate(this.placedOrderInfo.time),orderNumber:this.placedOrderInfo.zonosOrderNumber,time:this.formatTime(this.placedOrderInfo.time)}):translate("It looks like you placed an order recently ([date] at [time]). Check your email for the order confirmation. Are you sure you want to place another one?",{date:this.formatDate(((r=this.placedOrderInfo)===null||r===void 0?void 0:r.time)||null),time:this.formatTime(((n=this.placedOrderInfo)===null||n===void 0?void 0:n.time)||null)}),dialogTitle:translate("Are you sure?"),dialogWidth:530,onCancelClicked:function(){e.handleCancelOrderDuplication()},onConfirmClicked:function(){e.confirmProceedWithOrderDuplication()}}),h("zonos-confirm-dialog",{class:"zonos--fedex-shipping-dialog",dialogConfirmBtnText:translate("Confirm"),dialogIntent:"info",dialogOpen:!!this.shouldShowFedexShippingConsentDialog,dialogSubtitle:h(Fragment,null,translate("If you select FedEx Ground as your shipping option, you'll need to complete a General Agency Agreement (GAA) after placing your order. This form allows FedEx to clear your package through Canadian customs on your behalf. FedEx will contact you directly—usually by email or phone—with instructions on how to complete the GAA. To avoid delays or the return of your package, please respond promptly to their request."),h("zonos-link",{href:"https://ftn.fedex.com/us/assets/docs/One-Time_GAA.pdf",target:"_blank"},translate("View GAA Form."))),dialogTitle:translate("Fedex Shipping Procedure"),dialogType:"alert",dialogWidth:500,onConfirmClicked:function(){return e.shouldShowFedexShippingConsentDialog=false}}),h("zonos-confirm-dialog",{class:"zonos--inventory-check-failure-dialog",dialogConfirmBtnText:translate("Return to cart"),dialogIntent:"danger",dialogOpen:!!cartStore.inventoryCheckErrorMessage,dialogSubtitle:cartStore.inventoryCheckErrorMessage,dialogTitle:translate("Couldn't place order"),dialogType:"alert",onConfirmClicked:function(){return e.handleInventoryCheckDialogConfirm()}}),w&&h("zonos-confirm-dialog",{class:"zonos--pay-in-usd-dialog",dialogCancelBtnText:translate("Cancel"),dialogConfirmBtnText:translate("Pay [orderTotal]",{orderTotal:currencyFormat({amount:w.settlementAmount,currency:"USD"})}),dialogIntent:"warn",dialogOpen:this.payInUsdConfirmDialogOpen,dialogSubtitle:translate("By paying in USD, your card will be charged directly with no currency conversion. However, using a non-USD based card may result in additional currency conversion fees at the bank level."),dialogTitle:translate("Pay in USD (United States Dollar)?"),dialogType:"confirm",dialogWidth:480,onCancelClicked:function(){e.payInUsdConfirmDialogOpen=false},onConfirmClicked:function(){return e.handleStripePaymentContinue()}}),h("zonos-confirm-dialog",{class:"zonos--shopping-cart-expired-dialog",dialogConfirmBtnText:translate("OK"),dialogIntent:"danger",dialogOpen:this.isCartExpired,dialogSubtitle:translate("You are being sent back to the shop to re-add items to your cart."),dialogTitle:translate("Shopping cart expired"),dialogType:"alert",onConfirmClicked:function(){return e.handleCartExpiredDialogConfirm()}}),h("zonos-loading-overlay",{open:this.isOverlayLoading}))};Object.defineProperty(e,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],overrideStagingMode:["overrideStagingModeChanged"],mobile:["handleMobileChange"],defaultAddress:["handleAddressChange"],customerProfile:["handleCustomerProfileChange"],clientSecret:["handleClientSecretChange"],stripeCustomerSessionClientSecret:["handleClientSecretChange"],open:["handleOpenChange"]}},enumerable:false,configurable:true});return e}();ZonosCheckout.style=ZonosCheckoutStyle0;export{ZonosCheckout as zonos_checkout};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,o,r){function n(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r["throw"](e))}catch(e){s(e)}}function c(e){e.done?o(e.value):n(e.value).then(i,a)}c((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,n,s,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(a){if(r)throw new TypeError("Generator is already executing.");while(i&&(i=0,a[0]&&(o=0)),o)try{if(r=1,n&&(s=a[0]&2?n["return"]:a[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;if(n=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:o.label++;return{value:a[1],done:false};case 5:o.label++;n=a[1];a=[0];continue;case 7:a=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){o=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(a[0]===6&&o.label<s[1]){o.label=s[1];s=a;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(a);break}if(s[2])o.ops.pop();o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e];n=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,o){if(o||arguments.length===2)for(var r=0,n=t.length,s;r<n;r++){if(s||!(r in t)){if(!s)s=Array.prototype.slice.call(t,0,r);s[r]=t[r]}}return e.concat(s||Array.prototype.slice.call(t))};import{r as registerInstance,h,F as Fragment,a as Host}from"./index-cfd394c8.js";import{s as stripeStoreGetDomesticShippingSession,a as stripeStoreSaveDomesticShippingSession,b as stripeStore,i as initStripeElements,c as stripeStoreRetrievePayment,d as cartStore,e as cartStoreUpdateItems,f as cartStoreReset,g as cartStoreResetTabItems,h as cartStoreClearCheckoutInterval,j as stripeStoreInitCheckoutSession,k as stripeStoreGetPaymentIntent,l as cartStoreStartCheckoutInterval,t as trackConversionEvent,m as getCheckoutSessionBody,n as cartStoreUpdateToErrorState,o as stripeStoreCleanupDomesticShippingSession,p as cartStoreSetCheckoutSession,q as stripeStorePrefetchLandedCost,r as cartStoreNextStep,u as stripeStoreUpdateCheckoutSessionBaseCurrency,v as stripeStoreHandleInventoryCheck,w as storeCreditStoreApplyCredit,x as storeCreditStoreCoversFullAmount,y as validateCheckoutSession,z as storeCreditStoreCreateOrder,A as stripeStoreConfirmPayment,B as stripeStoreHandleInventoryRefund,C as stripeStoreReset,D as cartStoreOnChange,E as stripeStoreOnChange,F as storeCreditStoreGetEffectiveAmount}from"./cart-394c9ddb.js";import{p as paypalStoreHasPaypalEnabled,a as paypalStore,b as paypalInitScript}from"./paypal-b6fa3ec3.js";import{f as filterValidTests,l as localizationStore,a as localizationStoreUpdateSelectedCountryCode,g as getZCountryUrlParam,s as storageStore,V as VARIANT_TEST_KEY_EXPIRATION,b as storageStoreSetEnabledVariantTestKeys,t as translate,c as localizationStoreOnChange,d as currencyFormat}from"./localization-0ebc8356.js";import{z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-5242a58d.js";import{b as buildCartItemsByTempCart}from"./buildCartItemsByTempCart-a117f75d.js";import{h as handleFetch,l as logError,b as getAdditionalLogMetadata,g as getIsTestMode,j as jsonParse,s as sendErrorLog,a as getIsStagingMode,i as isCheckoutMobile}from"./handleFetch-a844cac1.js";import{u as updateCheckoutSessionAttributes}from"./updateCheckoutSessionAttributes-b9f7e982.js";import{_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector,g as getAbandonedCartRenewTokenValue}from"./CheckoutConfig-724d7bae.js";import{l as log,g as getElapsedTime,b as allLogs}from"./VarianceTest-572cecf5.js";import{c as classes}from"./classes-0d95c529.js";import{c as createCustomEvent}from"./createCustomEvent-58159025.js";import{g as getBorderRadius}from"./getBorderRadius-c21a42e5.js";import{i as isDarkColor}from"./isDarkColor-3537021b.js";import{s as styles}from"./styles-6fc2fad9.js";import{s as submitGtag}from"./submitGtag-13de9f1f.js";import{R as RemoveIcon}from"./RemoveIcon-9dc5dd1a.js";import"./isContrastColor-c17e83c9.js";import"./debounce-efc0e473.js";var isStoreDiscountEnabled=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/get-store-discount-enabled-status")];case 1:e=r.sent(),t=e.errors,o=e.json;if(t.length||!(o===null||o===void 0?void 0:o.enabled)){return[2,{enabled:false}]}return[2,{enabled:true}]}}))}))};var selectVarianceTest=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,o,r,n;var s=e.testKeys;return __generator(this,(function(e){switch(e.label){case 0:if(s.length===0){return[2,null]}return[4,handleFetch("/api/zonos-elements/select-variance-test",{body:{testKeys:s},method:"POST"})];case 1:t=e.sent(),o=t.errors,r=t.json;if(o.length||!r){return[2,null]}n=filterValidTests(r);return[2,n]}}))}))};var buildCartUrl=function(e){var t=e.cartId,o=e.checkoutSessionId,r=e.customerAddress1,n=e.customerAddress2,s=e.customerCity,i=e.customerCountry,a=e.customerEmail,c=e.customerFirstName,u=e.customerLastName,l=e.customerPhone,d=e.customerState,h=e.customerZip,f=e.hostedCheckoutUrl,v=e.isTestMode,m=e.isVariantTest;var g=new URLSearchParams;g.set("tempCartUUID",t);if(c){g.set("customerFirstName",c)}if(u){g.set("customerLastName",u)}if(a){g.set("customerEmail",a)}if(l){g.set("customerPhone",l)}if(h){g.set("customerZip",h)}if(s){g.set("customerCity",s)}if(d){g.set("customerState",d)}if(i){g.set("zCountry",i)}if(r){g.set("customerAddress1",r)}if(n){g.set("customerAddress2",n)}if(v){g.set("zonosTestMode","1")}if(o){g.set("zonosCheckoutSessionId",o)}if(m){g.set("zonosVariantTest","1")}return"".concat(f,"?").concat(g.toString())};var isDisabledCountry=function(e){if(e===void 0){e=true}if(!localizationStore.localizationLoaded){return true}if(localizationStore.isDisabledCountry){if(e){log("Checkout: disabled country")}return true}return false};var isShippableCountry=function(e,t){if(e===void 0){e=true}var o;if(!localizationStore.localizationLoaded){return false}if(t){var r=!!((o=localizationStore.shippingZoneCountries)===null||o===void 0?void 0:o[t])&&!zonosStore.disabledCountries.includes(t);if(e&&!r){log("Checkout: ".concat(t," is not a shippable country: ").concat(r))}return r}if(!localizationStore.isShippableCountry){if(e){log("Checkout: not shippable country")}return false}return true};var FALLBACK_SHIP_TO_COUNTRY_SELECTOR='select[name="shippingAddress.countryCode"]';var fetchCheckoutId=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,o,r,n;return __generator(this,(function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,fetch("/api/storefront/cart",{credentials:"same-origin",headers:{Accept:"application/json"}})];case 1:o=s.sent();if(!o.ok){log("Failed to fetch BigCommerce cart: ".concat(String(o.status)),"error");return[2,null]}return[4,o.json()];case 2:r=s.sent();return[2,(t=(e=r===null||r===void 0?void 0:r[0])===null||e===void 0?void 0:e.id)!==null&&t!==void 0?t:null];case 3:n=s.sent();logError("Error fetching BigCommerce cart data",n);return[2,null];case 4:return[2]}}))}))};var fetchBigCommerceCheckout=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,o;return __generator(this,(function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,fetch("/api/storefront/checkouts/".concat(e),{credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}})];case 1:t=r.sent();if(!t.ok){log("Failed to fetch BigCommerce checkout: ".concat(String(t.status)),"error");return[2,null]}return[4,t.json()];case 2:return[2,r.sent()];case 3:o=r.sent();logError("Error fetching BigCommerce checkout data",o);return[2,null];case 4:return[2]}}))}))};var checkLoggedInUserShippingAddress=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,o,r,n,s,i,a,c,u,l,d,h,f,v;var m=e.onInternationalCheckoutSelected;return __generator(this,(function(e){switch(e.label){case 0:return[4,fetchCheckoutId()];case 1:d=e.sent();if(!d){return[2,false]}return[4,fetchBigCommerceCheckout(d)];case 2:h=e.sent();f=(o=(t=h===null||h===void 0?void 0:h.consignments)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.shippingAddress;if(!(f===null||f===void 0?void 0:f.countryCode)){return[2,false]}v=f.countryCode;if(!isShippableCountry(false,v)){return[2,false]}log("Logged-in user has international shipping address: ".concat(v,", redirecting"),"info");if(!m)return[3,4];return[4,m()];case 3:e.sent();e.label=4;case 4:localizationStoreUpdateSelectedCountryCode({isInitializing:false,newSelectedCountryCode:v});stripeStoreSaveDomesticShippingSession({address1:(r=f.address1)!==null&&r!==void 0?r:"",address2:(n=f.address2)!==null&&n!==void 0?n:"",city:(s=f.city)!==null&&s!==void 0?s:"",countryCode:v,firstName:(i=f.firstName)!==null&&i!==void 0?i:"",lastName:(a=f.lastName)!==null&&a!==void 0?a:"",phone:(c=f.phone)!==null&&c!==void 0?c:"",postalCode:(u=f.postalCode)!==null&&u!==void 0?u:"",state:(l=f.stateOrProvince)!==null&&l!==void 0?l:""});window.location.href="/";return[2,true]}}))}))};var watchImmediateBigcommerceDomesticCheckoutRedirect=function(e){var t=e.domesticRedirectedBtnSelector,o=e.onInternationalCheckoutSelected,r=e.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}var n=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,n,s;return __generator(this,(function(i){switch(i.label){case 0:r=document.querySelector(((t=zonosStore.genericSettings)===null||t===void 0?void 0:t.bigcommerceDomesticCheckoutCountrySelector)||FALLBACK_SHIP_TO_COUNTRY_SELECTOR);n=(r===null||r===void 0?void 0:r.value)||e;if(!n){return[2,false]}if(!isShippableCountry(false,n)){return[2,false]}if(!o)return[3,2];return[4,o()];case 1:i.sent();i.label=2;case 2:localizationStoreUpdateSelectedCountryCode({isInitializing:false,newSelectedCountryCode:n});s={address1:"",address2:"",city:"",countryCode:n,firstName:"",lastName:"",phone:"",postalCode:"",stateOrProvince:""};stripeStoreSaveDomesticShippingSession({address1:s.address1,address2:s.address2,city:s.city,countryCode:s.countryCode,firstName:s.firstName,lastName:s.lastName,phone:s.phone,postalCode:s.postalCode,state:s.stateOrProvince});window.location.href="/";return[2,true]}}))}))};var s=false;var i=false;var a=false;var c=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var e,u,l,d,h,f,v,m,g,p;return __generator(this,(function(S){switch(S.label){case 0:u=document.querySelector(t);l=stripeStoreGetDomesticShippingSession();if(!u&&l){d=document.createElement("button");d.style.display="none";d.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(d);r===null||r===void 0?void 0:r(l);c.disconnect();return[2]}h=window.location.pathname.includes("/checkout")&&window.Zonos.isBigCommerce;if(!h){c.disconnect();return[2]}if(a){return[2]}a=true;S.label=1;case 1:S.trys.push([1,3,4,5]);return[4,checkLoggedInUserShippingAddress({onInternationalCheckoutSelected:o})];case 2:f=S.sent();if(f){c.disconnect();return[2]}return[3,5];case 3:v=S.sent();logError("Error checking logged-in user shipping address",v);return[3,5];case 4:a=false;return[7];case 5:m=document.querySelector(((e=zonosStore.genericSettings)===null||e===void 0?void 0:e.bigcommerceDomesticCheckoutCountrySelector)||FALLBACK_SHIP_TO_COUNTRY_SELECTOR);if(!m){return[2]}log("Domestic checkout found - Listening for shipping country change","info",{value:m.value});if(i){return[2]}i=true;c.disconnect();g=setInterval((function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;return __generator(this,(function(o){switch(o.label){case 0:if(s){return[2]}s=true;o.label=1;case 1:o.trys.push([1,3,,4]);return[4,n()];case 2:e=o.sent();if(e){clearInterval(g);return[2]}s=false;return[3,4];case 3:t=o.sent();s=false;return[3,4];case 4:return[2]}}))}))}),1e3);p=setInterval((function(){var e;if(!window.bcStripeElements){clearInterval(p);return}var t=(e=window.bcStripeElements)===null||e===void 0?void 0:e.getElement("address");if(!t){return}clearInterval(p);t.on("change",(function(e){var t=e.value.address.country;if(t){void n(t)}}))}),500);return[2]}}))}))}));c.observe(document.body,{childList:true,subtree:true})};var getLegacyQueryParams=function(){var e=new URLSearchParams(window.location.search);log("legacy urlParams","info",Object.fromEntries(e.entries()));var t=function(t){var o=e.get(t);if(!o||o==="undefined"){return""}return o};var o=getZCountryUrlParam(e)||localizationStore.selectedCountryCode||"US";var r=t("customerCity");var n=t("customerEmail");var s=t("customerAddress1");var i=t("customerAddress2");var a=t("customerName");var c=t("customerPhone");var u=t("customerZip");var l=t("customerState");var d=t("customerFirstName");var h=t("customerLastName");return{customerAddress1:s,customerAddress2:i,customerCity:r,customerCountry:o,customerEmail:n,customerFirstName:d,customerLastName:h,customerName:a,customerPhone:c,customerState:l,customerZip:u}};var numberOfFailures=0;var sendBulkLoadTimeApiLog=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;var o;return __generator(this,(function(r){switch(r.label){case 0:if(window.Zonos.loadTimeApiInfoList.length===0){return[2]}log("Sending bulk load time api log","info",{loadTimeApiInfoList:window.Zonos.loadTimeApiInfoList});e={data:__spreadArray([],window.Zonos.loadTimeApiInfoList,true),storeId:window.Zonos.storeId||0};window.Zonos.loadTimeApiInfoList.length=0;return[4,handleFetch("/api/zonos-elements/log-bulk-load-data",{body:e,method:"POST"})];case 1:t=r.sent().errors;if(t.length){(o=window.Zonos.loadTimeApiInfoList).push.apply(o,e.data);numberOfFailures++;if(numberOfFailures>5&&window.Zonos.logIntervalId){clearInterval(window.Zonos.logIntervalId)}}return[2]}}))}))};var sendLoadCheckoutFacadeLog=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;return __generator(this,(function(o){e=getElapsedTime().elapsedTime;t={cache:"miss",eventName:"jsdelivr",flag:"LOG_CHECKOUT_FACADE_LOAD",href:window.location.href,loadTime:e,metadata:Object.assign({allLogs:allLogs},getAdditionalLogMetadata()),scriptLoadUrl:"checkoutFacade",storeId:window.Zonos.storeId||0};void handleFetch("/api/zonos-elements/log-script-load",{body:t,method:"POST"});return[2]}))}))};var sendLoadNativeCheckoutLog=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t;var o=e.loadTime;return __generator(this,(function(e){t={cache:"miss",eventName:"jsdelivr",flag:"LOG_NATIVE_CHECKOUT_LOAD",href:window.location.href,loadTime:o,metadata:Object.assign({allLogs:allLogs},getAdditionalLogMetadata()),scriptLoadUrl:"nativeCheckout",storeId:window.Zonos.storeId||0};void handleFetch("/api/zonos-elements/log-script-load",{body:t,method:"POST"});return[2]}))}))};var filterExpiredTests=function(e){return(e===null||e===void 0?void 0:e.filter((function(e){if(e.expiresAt&&e.expiresAt<Date.now()||!e.expiresAt){return false}return true})))||[]};var getSelectedTestVariant=function(e){var t;var o=(t=storageStore.enabledVariantTestKeys)===null||t===void 0?void 0:t.find((function(t){return t.testKey===e}));return(o===null||o===void 0?void 0:o.selectedVariantKey)||null};var isTestEnabled=function(e){return zonosStore.enabledVariantTestKeys.includes(e)};var mergeTest=function(e){var t=e.baseTestObj,o=e.mergeTestObj;return t.map((function(e){var t=e.testKey;var r=o.find((function(e){var o=e.testKey;return o===t}));return{expiresAt:(r===null||r===void 0?void 0:r.expiresAt)||Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:(r===null||r===void 0?void 0:r.selectedVariantKey)||null,testKey:t}}))};var getTempCartById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,o,r,n,s;var i=e.cartId,a=e.retries;return __generator(this,(function(e){switch(e.label){case 0:t=getIsTestMode();return[4,handleFetch("/api/zonos-elements/get-temp-cart",{body:{isTestMode:t,options:{noOnlineStoreSettings:true},tempCartUUID:i},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:o=e.sent(),r=o.errors,n=o.json;s=!n||r.length;if(!(s&&a))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:a});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getTempCartById({cartId:i,retries:a-1})];case 3:if(s){return[2,null]}return[2,n]}}))}))};var setupCartData=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,o,r,n;return __generator(this,(function(s){switch(s.label){case 0:t=_getIsValidCartId(e),o=t.isDgsCartId,r=t.isLegacyCartId;if(!r&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getTempCartById({cartId:e,retries:5})];case 1:n=s.sent();log("[ZONOS - loadZonos] getting temp cart data","info",n);if(!n){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=n.cartData.storeId;window.Zonos.zonosApiKey=n.cartData.credentialToken;return[2,{cartData:n.cartData,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}]}}))}))};var MessageIcon='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var zonosCheckoutCss=".sc-zonos-checkout-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h{z-index:2147483647;position:fixed}.sc-zonos-checkout-h *.sc-zonos-checkout{-ms-scroll-chaining:none;overscroll-behavior:contain}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:32px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--zonos--primary-color, var(--zonos-elements-gray-0));border-right:1px solid var(--zonos-elements-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--zonos-elements-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--zonos-elements-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:relative}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 8px 8px}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:24px}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--right-actions.sc-zonos-checkout{position:absolute;right:24px;top:24px;z-index:2;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo-wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;gap:16px;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--logo-wrapper.sc-zonos-checkout>*.sc-zonos-checkout{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout img.sc-zonos-checkout{max-height:72px}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:76px;margin-bottom:8px}.zonos--close-button.sc-zonos-checkout{-ms-flex-item-align:start;align-self:flex-start}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto;position:relative}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--zonos-elements-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:32px}.hidden-mode.sc-zonos-checkout-h{height:0;opacity:0;pointer-events:none;position:absolute;visibility:hidden;width:0;z-index:-1}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:12px;padding-bottom:76px}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:0}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:16px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10));background-color:var(--zonos-elements-gray-50);padding:12px;margin-top:32px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:8px}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.iframed.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{-ms-scroll-chaining:chained;overscroll-behavior:auto}.zonos--processing-payment.sc-zonos-checkout-h{z-index:2147483646}";var ZonosCheckoutStyle0=zonosCheckoutCss;var CHECKOUT_SESSION_TIMEOUT=90*60*1e3;var ORDER_DUPLICATION_NOTIFICATION_EXPIRATION=6*60*60*1e3;var ZonosCheckout=function(){function e(e){var t=this;registerInstance(this,e);this.storeUnsubscribeList=[];this.isRedirectAfterOrder=false;this.preview=false;this.hiddenMode=false;this.mobile=false;this.defaultAddress=[];this.forceDialogOpen=false;this.defaultAddressParams=[];this.defaultCustomerProfileAddress=[];this.customerProfile=null;this.open=this.forceDialogOpen;this.isOverlayLoading=false;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.collapseReviewMobile=true;this.isAttachError=false;this.isMobile=false;this.isIframed=false;this.isLegacyCheckout=window.Zonos.isLegacyCheckout;this.confirmDialogOpen=false;this.isCartExpired=false;this.payInUsdConfirmDialogOpen=false;this.inventoryCheckErrorMessage=null;this.placedOrderInfo=null;this.shouldShowFedexShippingConsentDialog=false;this.detectedDomesticCheckoutDialogOpen=false;this.redirectToDomesticCheckoutDialogOpen=false;this.clientSecret=stripeStore.clientSecret;this.stripeCustomerSessionClientSecret=stripeStore.stripeCustomerSessionClientSecret;this.applyStripeTheme=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,o,r,n;return __generator(this,(function(s){switch(s.label){case 0:n=((e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRadius:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.style,overridePrimaryColor:(o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.colorPrimary,overrideSecondaryColor:(r=this.appearanceSettingsOverride)===null||r===void 0?void 0:r.colorSecondary,overrideTheme:this.isMobile?n:undefined,paypalEnabled:paypalStoreHasPaypalEnabled()})];case 1:s.sent();return[2]}}))}))};this.checkStripePaymentIntentStatus=function(e){return __awaiter(t,[e],void 0,(function(e){var t,o,r,n,s,i,a,c,u;var l=e.triggeredButton;return __generator(this,(function(e){switch(e.label){case 0:t=l===null||l===void 0?void 0:l.matches("#".concat(checkoutHiddenBtnSelector));o=!!window.Zonos.cartData;r=new URL(window.location.href).searchParams;n=r.get("payment_intent_client_secret");s=r.get("zonosCheckoutSessionId");if(!t){log("Checkout is triggered by user, no need to check stripe payment intent status");return[2,{shouldAllowOrder:true}]}log("Payment intent exist, checking stripe payment intent status");if(!n){log("No stripe client secret found in the URL, proceed to order if cart data is available");return[2,{shouldAllowOrder:o}]}return[4,stripeStoreRetrievePayment({clientSecret:n})];case 1:i=e.sent(),a=i.error,c=i.status;u=new URLSearchParams(window.location.search).get("redirect_status");if(u){if(!a){log("Payment intent is succeeded or in a good state to move forward, show success screen")}else{log("Payment intent failed, show status from error")}this.open=true;storageStore.checkoutSessionId=s;stripeStore.clientSecret=n;void this.setToFinishStep(c);return[2,{shouldAllowOrder:false}]}if(!o){log("Cart data is not available, only check payment intent status, skip order.");return[2,{shouldAllowOrder:false}]}log("Payment intent is not succeeded, proceed to order");return[2,{shouldAllowOrder:true}]}}))}))};this.initializeTestKeys=function(){storageStore.enabledVariantTestKeys=filterExpiredTests(storageStore.enabledVariantTestKeys||[]);var e=zonosStore.enabledVariantTestKeys.map((function(e){var t;var o=(t=storageStore.enabledVariantTestKeys)===null||t===void 0?void 0:t.find((function(t){var o=t.testKey;return o===e}));return{expiresAt:(o===null||o===void 0?void 0:o.expiresAt)||Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:(o===null||o===void 0?void 0:o.selectedVariantKey)||null,testKey:e}}));storageStoreSetEnabledVariantTestKeys(e);return{allSelected:false}};this.shouldAllowHostedVsNativeTest=function(){if(typeof zonosStore.checkoutSettings.createCartId!=="function"){return false}var e=zonosStore.enabledVariantTestKeys.includes("hosted_vs_native");if(!e){return false}return true};this.registerTestHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,o,r;return __generator(this,(function(n){switch(n.label){case 0:e=this.shouldAllowHostedVsNativeTest();if(!e){return[2]}log("[TEST] - Registering hosted vs native test");t=getSelectedTestVariant("hosted_vs_native");if(t){log("[TEST] - Hosted vs native test already has variant selected: ".concat(t));return[2]}return[4,selectVarianceTest({testKeys:["hosted_vs_native"]})];case 1:o=n.sent();if(!o){log("[TEST] - Failed to get selection for hosted vs native test");return[2]}r=mergeTest({baseTestObj:storageStore.enabledVariantTestKeys||[],mergeTestObj:o});storageStoreSetEnabledVariantTestKeys(r);return[2]}}))}))};this.handleHostedVsNative=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,o,r,n,s,i,a;return __generator(this,(function(c){switch(c.label){case 0:t=this.shouldAllowHostedVsNativeTest();if(!t){return[2,{redirected:false}]}o=getSelectedTestVariant("hosted_vs_native");log("[TEST] - hosted_vs_native: ".concat(o));if(typeof zonosStore.checkoutSettings.createCartId!=="function"){log("[TEST] - createCartId is not provided, skipping hosted vs native test");return[2,{redirected:false}]}if(o!=="hosted"){log("[TEST] - Hosted vs native test is enabled for native, skipping");return[2,{redirected:false}]}if(!((e=zonosStore.genericSettings)===null||e===void 0?void 0:e.hostedCheckoutUrl)){log("[TEST] - Hosted checkout URL is not provided");return[2,{redirected:false}]}log('"createCartId" is provided, start building cart');return[4,zonosStore.checkoutSettings.createCartId()];case 1:r=c.sent();s=null;if(typeof r==="object"){n=r.cartId;s=r.shippingData||null}else{n=r}i=getLegacyQueryParams();a=buildCartUrl(Object.assign(Object.assign({cartId:n,checkoutSessionId:storageStore.checkoutSessionId||undefined,hostedCheckoutUrl:zonosStore.genericSettings.hostedCheckoutUrl,isTestMode:getIsTestMode(),isVariantTest:true},i),s));log("[TEST] - Redirecting to: ".concat(a));window.open(a,"_blank");return[2,{redirected:true}]}}))}))};this.formatDate=function(e){if(!e){return""}var t=new Date(e);return t.toLocaleDateString()};this.formatTime=function(e){if(!e){return""}var t=new Date(e);return t.toLocaleTimeString()};this.getCurrentLocalePageEnum=function(){switch(cartStore.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.getBaseCurrencySettlementInfo=function(){var e=cartStore.selectedLandedCost;if(!e){return null}var t=e.landedCost.amountSubtotals;if(!t){return null}var o=(t.discounts||0)+t.items+t.landedCostTotal+t.shipping;return{settlementAmount:o}};this.getDefaultAddress=function(){if(t.defaultCustomerProfileAddress.length){return t.defaultCustomerProfileAddress}if(Array.isArray(t.defaultAddress)&&t.defaultAddress.length){return t.defaultAddress}if(!Array.isArray(t.defaultAddress)&&typeof t.defaultAddress==="object"){return[t.defaultAddress]}return t.defaultAddressParams};this.handleHostedOpenWindowCallback=function(e){var t;var o=(t=zonosStore.genericSettings)===null||t===void 0?void 0:t.hostedCheckoutUrl;if(!origin){return}var r=["dev.checkout.elements.zonos.com"].some((function(t){return e.origin.includes(t)}));if(e.origin!==o&&!r){return}switch(e.data.type){case"zonos-checkout-session-update":storageStore.checkoutSessionId=e.data.checkoutSessionId;break}};this.captureParamsRedirectedForVariantTest=function(){var e=new URL(window.location.href);var t=e.searchParams.get("zonosVariantTest")==="1";if(!t){return}var o=e.searchParams.get("zonosCheckoutSessionId");if(o){storageStore.checkoutSessionId=o}var r=storageStore.enabledVariantTestKeys||[];if(window.Zonos.isLegacyCheckout){var n=getSelectedTestVariant("hosted_vs_native");if(!n){r.push({expiresAt:Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:"hosted",testKey:"hosted_vs_native"});storageStoreSetEnabledVariantTestKeys(r)}else{storageStoreSetEnabledVariantTestKeys(r.map((function(e){if(e.testKey==="hosted_vs_native"){return Object.assign(Object.assign({},e),{selectedVariantKey:"hosted"})}return e})))}}e.searchParams.delete("zonosCheckoutSessionId");e.searchParams.delete("zonosVariantTest");window.history.replaceState({},"",e.toString())}}e.prototype.initCartInfoHandler=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(o){t=e.detail;void cartStoreUpdateItems({adjustments:cartStore.adjustments,cartItems:t});return[2]}))}))};e.prototype.handleKeyPress=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(e.key==="Escape"){void this.closeDialogHandler()}return[2]}))}))};e.prototype.closeDialogHandler=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o;return __generator(this,(function(r){if(!this.open){return[2]}if(!(e===null||e===void 0?void 0:e.confirmed)){this.confirmDialogOpen=true;return[2]}this.confirmDialogOpen=false;submitGtag({event:"zonos-checkout-close",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";cartStoreResetTabItems();cartStoreClearCheckoutInterval();(o=(t=zonosStore.checkoutSettings).onClose)===null||o===void 0?void 0:o.call(t);return[2]}))}))};e.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r,n,s,i,a,s,i,i,c,u,s,l;return __generator(this,(function(d){switch(d.label){case 0:if(!(typeof zonosStore.checkoutSettings.createCartId==="function"))return[3,4];log('"createCartId" is provided, start building cart');return[4,zonosStore.checkoutSettings.createCartId()];case 1:e=d.sent();t=void 0;if(typeof e==="object"){log("object detected, use cartId and prefill address from createCartId","info",e);t=e.cartId;this.useShippingDataFromCreateCartId(e.shippingData);cartStore.customerAuthenticationToken=e.customerAuthenticationToken||null}else{t=e}window.Zonos.cartId=t;return[4,setupCartData(t)];case 2:o=d.sent();r=o===null||o===void 0?void 0:o.cartData;if(!r){logError("Failed to build cart, please try again.");return[2,false]}window.Zonos.cartData=r;n=buildCartItemsByTempCart(r),s=n.adjustments,i=n.cartItems;return[4,cartStoreUpdateItems({adjustments:s,cartItems:i})];case 3:d.sent();return[3,9];case 4:if(!window.Zonos.cartData)return[3,6];log("tempCartUUID is provided, start building cart");a=buildCartItemsByTempCart(window.Zonos.cartData),s=a.adjustments,i=a.cartItems;return[4,cartStoreUpdateItems({adjustments:s,cartItems:i})];case 5:d.sent();return[3,9];case 6:if(!(zonosStore.checkoutSettings.buildCartDetail&&localizationStore.selectedCountryCode))return[3,9];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail({countryCode:localizationStore.selectedCountryCode,currencyCode:localizationStore.targetCurrency})];case 7:i=d.sent();c=i.filter((function(e){return e.amount>=0}));u=i.filter((function(e){return e.amount<0}));log("cartItems","info",{cartItems:i});s=u.map((function(e){return{amount:e.amount,currencyCode:e.currencyCode,description:e.name||e.description||"",productId:e.productId||null,sku:e.sku||null,type:"CART_TOTAL"}}));return[4,cartStoreUpdateItems({adjustments:s,cartItems:c})];case 8:d.sent();d.label=9;case 9:if(!!storageStore.checkoutSessionId)return[3,11];return[4,stripeStoreInitCheckoutSession()];case 10:l=d.sent();log("stripeStoreInitCheckoutSession: ".concat(l));if(!l){return[2,false]}d.label=11;case 11:if(!cartStore.isStagingMode){void stripeStoreGetPaymentIntent()}return[4,this.applyStripeTheme()];case 12:d.sent();this.isRedirectAfterOrder=zonosStore.checkoutSettings.successBehavior==="REDIRECT_TO_SUCCESS_PAGE"||!!cartStore.externalConfirmationPageURL;return[2,true]}}))}))};e.prototype.reloadCheckoutSession=function(){window.location.reload()};e.prototype.handleOrderDuplication=function(){var e=jsonParse(localStorage.getItem("zonos--placed-order-info"));if(!e){localStorage.removeItem("zonos--placed-order-info");return}var t=Date.now()-e.time;log("=== Existing placed order info: ".concat(e.orderId," - ").concat(this.formatDate(e.time)," - elapsed in hh:ss format: ").concat(new Date(t).toISOString().substring(11,8)),"warn");var o=parseFloat(new URLSearchParams(window.location.search).get("zonosOverrideExpiredDuplication")||"0")||ORDER_DUPLICATION_NOTIFICATION_EXPIRATION;if(t>o){log("=== Existing placed order info is older than ".concat(o,"ms, cleaning localStorage"),"warn");localStorage.removeItem("zonos--placed-order-info");return}this.placedOrderInfo=e;log("=== Showing order duplication confirmation","warn")};e.prototype.recordCheckoutInfo=function(){if(!storageStore.checkoutSessionId){return}void updateCheckoutSessionAttributes({attributes:[{key:"APP_VERSION",value:window.Zonos.version},{key:"APP_VERSION_NPM_INTEGRATION",value:window.Zonos.isNpm?"1":"0"},{key:"LEGACY_CHECKOUT_FACADE",value:window.Zonos.isLegacyCheckout?"1":"0"}],checkoutSessionId:storageStore.checkoutSessionId})};e.prototype.confirmProceedWithOrderDuplication=function(){this.placedOrderInfo=null;if(!storageStore.checkoutSessionId){return}void updateCheckoutSessionAttributes({attributes:[{key:"ORDER_DUPLICATION_CONSENT",value:"1"}],checkoutSessionId:storageStore.checkoutSessionId})};e.prototype.markTheSessionAsAbandonedCart=function(){if(!storageStore.checkoutSessionId){return}void updateCheckoutSessionAttributes({attributes:[{key:"WITH_ABANDONED_CART_TOKEN",value:"1"}],checkoutSessionId:storageStore.checkoutSessionId})};e.prototype.handleCancelOrderDuplication=function(){var e;this.placedOrderInfo=null;if(this.isLegacyCheckout){var t=((e=window.Zonos.cartData)===null||e===void 0?void 0:e.storeBaseUrl)||zonosStore.onlineStoreSettings.url;if(!t){return}if(window.parent){window.parent.location.href=t}window.location.href=t;return}void this.closeDialogHandler({confirmed:true})};e.prototype.attachCheckout=function(){var e=this;var t=zonosStore.checkoutSettings.placeOrderButtonSelector;var o=zonosStore.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;log("attach checkout ".concat(t));log("attach checkout to always trigger international checkout selector: ".concat(o));if(!t&&!o&&!window.Zonos.cartData){return}var r=[t,o,"#".concat(domesticRedirectedBtnSelector),"#".concat(checkoutHiddenBtnSelector),"#".concat(checkoutHiddenInternationalBtnSelector)].filter(Boolean);var n=document.querySelectorAll(r.join(","));n.forEach((function(r){var n=r.getAttribute("data-zonos-checkout-attached");if(n){return}log("attached event to button ".concat(t),"info",{button:r});r.addEventListener("click",(function(t){return __awaiter(e,void 0,void 0,(function(){var e,n,s,i,a,c,u,l,d,h,f,v,m,g,p,S;return __generator(this,(function(z){switch(z.label){case 0:s=performance.now();i=o&&r.matches(o);a=r.matches("#".concat(checkoutHiddenInternationalBtnSelector));c=r.matches("#".concat(domesticRedirectedBtnSelector))||r.matches("#".concat(checkoutHiddenBtnSelector));if(!window.Zonos.isLegacyCheckout&&(!isShippableCountry()||isDisabledCountry())&&!i&&!a&&!c){return[2]}t.preventDefault();t.stopPropagation();log("zonos checkout button clicked");return[4,this.checkStripePaymentIntentStatus({triggeredButton:t.target})];case 1:u=z.sent().shouldAllowOrder;if(!u){return[2]}if(!window.Zonos.logIntervalId){window.Zonos.logIntervalId=setInterval((function(){void sendBulkLoadTimeApiLog()}),2e3)}if(!isTestEnabled("hosted_vs_native"))return[3,4];this.isOverlayLoading=true;return[4,this.registerTestHostedVsNative()];case 2:z.sent();return[4,this.handleHostedVsNative()];case 3:l=z.sent().redirected;this.isOverlayLoading=false;if(l){return[2]}z.label=4;case 4:stripeStore.isFetchingSession=true;this.open=true;z.label=5;case 5:z.trys.push([5,8,,9]);return[4,this.buildCartAndInit()];case 6:d=z.sent();if(!d){throw new Error("Error building cart")}(e=window.opener)===null||e===void 0?void 0:e.postMessage({checkoutSessionId:storageStore.checkoutSessionId,type:"zonos-checkout-session-update"},"*");cartStoreStartCheckoutInterval({isPreview:this.preview,sessionTimeout:CHECKOUT_SESSION_TIMEOUT});submitGtag({event:"zonos-checkout-start",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});h=storageStore.checkoutSessionId;void trackConversionEvent({checkoutSessionId:h,eventName:"checkout_open"});return[4,isStoreDiscountEnabled()];case 7:f=z.sent().enabled;cartStore.shouldHideDiscountInput=!f;this.handleOrderDuplication();if(window.Zonos.isLegacyCheckout){void sendLoadCheckoutFacadeLog()}else{v=performance.now();m=v-s;void sendLoadNativeCheckoutLog({loadTime:m})}this.recordCheckoutInfo();g=!!getAbandonedCartRenewTokenValue();if(g){this.markTheSessionAsAbandonedCart()}return[3,9];case 8:p=z.sent();if(p instanceof Error){S=p.message;if(S==="Cart is expired."){this.isCartExpired=true}}stripeStore.isFetchingSession=false;logError(p);if(this.isCartExpired){stripeStore.isFetchingSession=true;return[2]}void sendErrorLog({endpoint:"Error creating Checkout",errors:[p instanceof Error?p.toString():"Unknown error"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionBody:getCheckoutSessionBody(),href:window.location.href,storeBaseUrl:((n=window.Zonos.cartData)===null||n===void 0?void 0:n.storeBaseUrl)||zonosStore.onlineStoreSettings.url}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,9];case 9:return[2]}}))}))}),{capture:true,passive:false});if(!zonosStore.checkoutSettings.disablePlaceOrderButtonActivation){r.removeAttribute("disabled")}r.setAttribute("data-zonos-checkout-attached","true");if(r.matches("#".concat(domesticRedirectedBtnSelector))){r.dispatchEvent(createCustomEvent("click"));stripeStoreCleanupDomesticShippingSession();r.remove()}if(r.matches("#".concat(checkoutHiddenBtnSelector))){r.dispatchEvent(createCustomEvent("click"));r.remove()}}))};e.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};e.prototype.useShippingDataFromCreateCartId=function(e){if(!e){return}log("shipping data from createCartId result","info",Object.entries(e));var t=e.customerAddress1,o=e.customerAddress2,r=e.customerCity,n=e.customerCountry,s=e.customerEmail,i=e.customerFirstName,a=e.customerLastName,c=e.customerName,u=e.customerPhone,l=e.customerState,d=e.customerZip;var h=new URLSearchParams(window.location.search);var f=n||getZCountryUrlParam(h)||localizationStore.selectedCountryCode;this.applyPrefillAddress({customerAddress1:t,customerAddress2:o,customerCity:r,customerCountry:f,customerEmail:s,customerFirstName:i,customerLastName:a,customerName:c,customerPhone:u,customerState:l,customerZip:d})};e.prototype.useLegacyQueryParams=function(){var e=new URLSearchParams(window.location.search);log("legacy urlParams","info",Object.fromEntries(e.entries()));var t=function(t){var o=e.get(t);if(!o||o==="undefined"){return null}return o};var o=getZCountryUrlParam(e)||localizationStore.selectedCountryCode;var r=t("customerCity");var n=t("customerEmail");var s=t("customerAddress1");var i=t("customerAddress2");var a=t("customerName");var c=t("customerFirstName");var u=t("customerLastName");var l=t("customerPhone");var d=t("customerZip");var h=t("customerState");this.applyPrefillAddress({customerAddress1:s,customerAddress2:i,customerCity:r,customerCountry:o,customerEmail:n,customerFirstName:c,customerLastName:u,customerName:a,customerPhone:l,customerState:h,customerZip:d})};e.prototype.applyPrefillAddress=function(e){var t=e.customerAddress1||"";var o=e.customerCountry||"";var r=e.customerAddress2||"";var n=e.customerCity||"";var s=e.customerEmail||"";var i=e.customerFirstName&&e.customerLastName?"".concat(e.customerFirstName," ").concat(e.customerLastName):e.customerName||"";var a=e.customerPhone||"";var c=e.customerZip||"";var u=e.customerState||"";if(!t||!i||!a||!o){log("Missing required query params so it can not be prefilled","info",[!t&&"line1",!i&&"name",!a&&"phone",!o&&"country"].filter(Boolean).join(", "));return}if(o&&localizationStore.shippingZoneCountries&&!(o in localizationStore.shippingZoneCountries)){log('Country "'.concat(o,'" is not in the shipping zone, so it can not be prefilled'),"warn");return}this.defaultAddressParams=[{address:{city:n||"",country:o,line1:t,line2:r,postal_code:c,state:u},email:s,name:i,phone:a}];log("Prefill address applied","info",{prefillAddress:this.defaultAddressParams,providedAddress:e})};e.prototype.overrideStagingModeChanged=function(){cartStore.isStagingMode=!!this.overrideStagingMode};e.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var e;var t=this;return __generator(this,(function(o){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;cartStore.isStagingMode=getIsStagingMode();if(typeof this.overrideStagingMode!=="undefined"){cartStore.isStagingMode=this.overrideStagingMode}watchImmediateBigcommerceDomesticCheckoutRedirect({domesticRedirectedBtnSelector:domesticRedirectedBtnSelector,onInternationalCheckoutSelected:function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:this.detectedDomesticCheckoutDialogOpen=true;return[4,new Promise((function(e){return setTimeout(e,2e3)}))];case 1:e.sent();return[2]}}))}))},onShippingAddressSessionFound:function(e){t.defaultAddress=[{address:{city:e.city,country:e.countryCode,line1:e.address1,line2:e.address2,postal_code:e.postalCode,state:e.state},email:"",name:"".concat(e.firstName," ").concat(e.lastName),phone:e.phone}]}});if(window.Zonos){this.useLegacyQueryParams()}e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else if(window.Zonos.isLegacyCheckout){t.attachCheckout()}else if(window){t.attachCheckout();var o=new MutationObserver((function(){t.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};e.prototype.setToFinishStep=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){cartStore.step="finish";this.storybookPaymentStatusOverride=e;return[2]}))}))};e.prototype.mockCheckoutSession=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){cartStoreSetCheckoutSession(e);return[2]}))}))};e.prototype.triggerCheckoutInternational=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));if(e){e.dispatchEvent(createCustomEvent("click"))}return[2]}))}))};e.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r,n,s,i,a;var c=this;return __generator(this,(function(u){switch(u.label){case 0:submitGtag({event:"zonos-checkout-customer-info",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});n=storageStore.checkoutSessionId;void trackConversionEvent({checkoutSessionId:n,eventName:"checkout_customerInfoCompleted"});this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:s=u.sent().isRequestNotReady;if(s&&cartStore.addressFormRenderType==="stripe"){void sendErrorLog({endpoint:"ADDRESS_NOT_READY_AT_CUSTOMER_INFO_CONTINUE",errors:["Address not ready at customer info continue"],metadata:{address:(t=(e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.value)===null||t===void 0?void 0:t.address,billingAddress:(r=(o=stripeStore.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value)===null||r===void 0?void 0:r.address,cartId:window.Zonos.cartId}})}i=function(e){if(cartStore.step!=="customer-info"){clearInterval(e);return}if(!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){void paypalInitScript({currency:cartStore.currency});cartStoreNextStep()}c.submitLoading=false;if(e){clearInterval(e)}}};i();a=setInterval((function(){i(a)}),20);setTimeout((function(){clearInterval(a)}),1e4);return[2]}}))}))};e.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStoreNextStep();return[2]}))}))};e.prototype.handleInventoryCheckDialogConfirm=function(){cartStore.inventoryCheckErrorMessage=null;if(!this.isLegacyCheckout){void this.closeDialogHandler({confirmed:true})}};e.prototype.handleCartExpiredDialogConfirm=function(){var e;this.isCartExpired=false;if(this.isLegacyCheckout){var t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.storeBaseUrl;if(!t){return}if(window.parent){window.parent.location.href=t}window.location.href=t;return}if(window.parent){window.parent.location.href=window.location.href}window.location.reload()};e.prototype.handleStripePaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r,n,s,i,a,c,u;return __generator(this,(function(l){switch(l.label){case 0:e=stripeStore.checkoutSettlementCurrency==="USD";if(e&&stripeStore.shouldRenderPayInUsdButton&&!this.payInUsdConfirmDialogOpen){this.payInUsdConfirmDialogOpen=true;return[2]}this.payInUsdConfirmDialogOpen=false;paypalStore.paypalErrorMessage=null;stripeStore.hasPaymentError=false;this.submitLoading=true;cartStore.inventoryCheckErrorMessage=null;return[4,stripeStoreUpdateCheckoutSessionBaseCurrency()];case 1:t=l.sent();if(!t){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=translate("Unable to complete payment in [currency]. Please try again or select a different currency. If the issue persists, contact our support team for assistance.",{currency:stripeStore.checkoutSettlementCurrency});this.submitLoading=false;return[2]}l.label=2;case 2:l.trys.push([2,4,,5]);o=cartStore;return[4,stripeStoreHandleInventoryCheck()];case 3:o.inventoryCheckErrorMessage=l.sent();return[3,5];case 4:r=l.sent();cartStore.inventoryCheckErrorMessage=translate("Unable to check inventory. Please try again.");return[3,5];case 5:if(cartStore.inventoryCheckErrorMessage){this.submitLoading=false;return[2]}n=storeCreditStoreGetEffectiveAmount();if(!(n>0))return[3,7];return[4,storeCreditStoreApplyCredit()];case 6:s=l.sent();if(!s.success){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=s.error||translate("Unable to apply store credit. Please try again.");this.submitLoading=false;return[2]}l.label=7;case 7:if(!storeCreditStoreCoversFullAmount())return[3,13];l.label=8;case 8:l.trys.push([8,11,,12]);return[4,validateCheckoutSession()];case 9:i=l.sent();if(!i.valid){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=i.errorMessage;this.submitLoading=false;return[2]}return[4,storeCreditStoreCreateOrder()];case 10:a=l.sent();if(!a.success){stripeStore.hasPaymentError=true;stripeStore.customErrorMessage=a.error||translate("Unable to place order with store credit. Please try again.");this.submitLoading=false;return[2]}cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,12];case 11:c=l.sent();logError(c);submitGtag({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});stripeStore.hasPaymentError=true;return[3,12];case 12:this.submitLoading=false;return[2];case 13:l.trys.push([13,15,,16]);return[4,stripeStoreConfirmPayment()];case 14:l.sent();cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,16];case 15:u=l.sent();logError(u);submitGtag({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});stripeStore.hasPaymentError=true;if(stripeStore.shouldInventoryRefund){void stripeStoreHandleInventoryRefund();stripeStore.shouldInventoryRefund=false}return[3,16];case 16:this.submitLoading=false;return[2]}}))}))};e.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,r;return __generator(this,(function(n){switch(n.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:n.sent();return[2];case 2:cartStoreReset();if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData){e=window.Zonos.cartData.storeBaseUrl||zonosStore.onlineStoreSettings.url;if(window.parent){window.parent.location.href=e}window.location.href=e;return[2]}t=window.location.href;o=t.split("?")[0];this.open=false;r=window.location.hostname.includes("dashboard.zonos.com");if(!r){window.history.replaceState(window.history.state,document.title,o);window.location.reload()}return[2]}}))}))};e.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};e.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};e.prototype.handleAppearanceSettingsOverrideChange=function(){var e;if((e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};e.prototype.handleAddressChange=function(){stripeStoreReset()};e.prototype.handleCustomerProfileChange=function(){var e,t;if(!this.customerProfile){log("No customer profile","info");this.defaultCustomerProfileAddress=[];return}log("Customer profile found","info",{customerProfile:this.customerProfile});this.defaultCustomerProfileAddress=((t=(e=stripeStore.customerProfile)===null||e===void 0?void 0:e.locations)===null||t===void 0?void 0:t.map((function(e){var t;return{address:{city:e.locality,country:e.countryCode,line1:e.line1,line2:e.line2||"",postal_code:e.postalCode,state:e.administrativeArea},email:e.email||((t=stripeStore.customerProfile)===null||t===void 0?void 0:t.email)||"",name:e.name||"",phone:e.phone||""}})))||[]};e.prototype.handleClientSecretChange=function(){log("==== Client secret changed","info",{clientSecret:this.clientSecret,stripeCustomerSessionClientSecret:this.stripeCustomerSessionClientSecret});void this.applyStripeTheme()};e.prototype.handleOpenChange=function(){var e="data-zonos-overflow-origin";var t=document.body;var o=document.documentElement;if(this.open){window.Zonos.openHelloDialog(false);if(t.style.overflow){t.setAttribute(e,t.style.overflow)}t.style.overflow="hidden";if(o.style.overflow){o.setAttribute(e,o.style.overflow)}o.style.overflow="hidden"}else{this.stripeCustomerSessionClientSecret=null;var r=t.getAttribute(e);var n=o.getAttribute(e);if(r){t.removeAttribute(e);t.style.overflow=r}else{t.style.removeProperty("overflow")}if(n){o.removeAttribute(e);o.style.overflow=n}else{o.style.removeProperty("overflow")}}};e.prototype.componentWillLoad=function(){var e=this;void this.init();this.isMobile=isCheckoutMobile(this.mobile);this.isIframed=window.self!==window.top;log("iframed: ".concat(this.isIframed));if(window.Zonos.isLegacyCheckout){this.captureParamsRedirectedForVariantTest()}this.handleAppearanceSettingsOverrideChange();this.storeUnsubscribeList=[localizationStoreOnChange("selectedLocale",(function(){void e.applyStripeTheme()})),cartStoreOnChange("selectedShippingOption",(function(){var t,o,r,n;var s=cartStore.selectedShippingOption;if(((t=zonosStore.genericSettings)===null||t===void 0?void 0:t.shouldFedExShippingConsentForCanadianShopper)&&((r=(o=s===null||s===void 0?void 0:s.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.code)===null||r===void 0?void 0:r.toLowerCase().startsWith("fedex."))&&((n=stripeStore.stripeAddressEventData)===null||n===void 0?void 0:n.value.address.country)==="CA"){e.shouldShowFedexShippingConsentDialog=true}})),stripeStoreOnChange("stripeAddressEventData",(function(t){var o;if(!window.Zonos.isBigCommerce||!t||e.redirectToDomesticCheckoutDialogOpen||!((o=zonosStore.genericSettings)===null||o===void 0?void 0:o.isBigcommerceDomesticCheckoutRedirectEnabled)||zonosStore.sourceCurrency!=="USD"){return}var r=t.value.address.country;if(r&&zonosStore.disabledCountries.includes(r)){e.redirectToDomesticCheckoutDialogOpen=true;log("Domestic country ".concat(r," selected in international checkout, redirecting to BigCommerce domestic checkout"),"info");setTimeout((function(){window.location.href="/checkout"}),2e3)}}))];this.initializeTestKeys();window.addEventListener("message",this.handleHostedOpenWindowCallback);log("mobile: ".concat(this.isMobile))};e.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset();this.storeUnsubscribeList.forEach((function(e){return e()}));window.removeEventListener("message",this.handleHostedOpenWindowCallback)};e.prototype.render=function(){var e=this;var t,o,r,n;this.customerProfile=stripeStore.customerProfile;this.clientSecret=stripeStore.clientSecret;if(stripeStore.stripeCustomerSessionClientSecret){this.stripeCustomerSessionClientSecret=stripeStore.stripeCustomerSessionClientSecret}var s=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var i=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride||null),a=i.colorPrimary,c=i.colorSecondary,u=i.logoUrl,l=i.style;var d=zonosStore.appearance.zonosAttribution==="ENABLED";var f=zonosStore.appearance.theme;var v=a&&isDarkColor(a)?"DARK":"LIGHT";var m=this.isMobile?f:v;var g=!this.isMobile?c:undefined;var p=localizationStore.customMessages;var S=(t=p.find((function(e){return e.pageName==="checkout_default"})))===null||t===void 0?void 0:t.message;var z=this.getCurrentLocalePageEnum();var k=p.filter((function(e){return e.pageName===z}));var w=this.getBaseCurrencySettlementInfo();var C=function(){var t=e.preview?"".concat(u,"?timestamp=").concat(Date.now()):u;return h("div",{class:"zonos--logo"},t&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:t}))};var y=getIsTestMode();var b=function(){var t=new URLSearchParams(window.location.search);var o=t.get("zonosQaUrl");var r=t.get("zonosDebug");var n=t.get("zonosE2ETest");var s=e.overrideStagingMode||getIsStagingMode();return h("zonos-v-stack",null,h("div",{class:"zonos--logo-wrapper"},C(),y&&h("zonos-badge",{badgeColor:"orange",size:"small"},translate("Test mode")),s&&h("zonos-badge",{badgeColor:"red",size:"small"},translate("Staging mode")),r==="1"&&h("zonos-badge",{badgeColor:"cyan",size:"small"},"debug"),o&&h("zonos-badge",{badgeColor:"purple",size:"small"},o),n&&h("zonos-badge",{badgeColor:"gray",size:"small"},"E2E Test")),h("zonos-checkout-progress-tabs",{backgroundColor:e.isMobile?"--zonos-elements-gray-0":null}),k.map((function(e){return h("zonos-custom-message",{icon:MessageIcon,message:e.message})})))};var _=function(){if(cartStore.checkoutSessionTimeoutShow){return h("zonos-rest-state",{class:"zonos--session-timeout",restStateSubtitle:translate("Your checkout session has expired. Please reload the page to continue."),restStateTitle:translate("Session timed out"),restStateType:"Warning"},h("zonos-button",{onClick:function(){return e.reloadCheckoutSession()},variant:"primary"},translate("Reload")))}return h("div",{class:"zonos--content",style:{"--zonos--border-radius":getBorderRadius({overrideBorderStyle:l})}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":m,style:styles({"--zonos--primary-color":!e.isMobile?a:undefined})},!e.isMobile&&b(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:e.submitLoading,defaultAddress:e.getDefaultAddress(),isMobile:e.isMobile,onContinueClicked:function(){return e.handleCustomerInfoContinue()},submitBtnColor:g}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return e.handleShippingContinue()},submitBtnColor:g}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.handleStripePaymentContinue()];case 1:e.sent();return[2]}}))}))},submitBtnColor:g})),h("div",{class:"zonos--right","data-theme":f},e.isMobile&&b(),h("div",{class:"zonos--right-actions"},window.Zonos.showBaseForeign&&h("zonos-currency-toggle",null),!e.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return e.closeDialogHandler()}})),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:e.collapseReviewMobile,mobile:e.isMobile,onClick:function(){if(!e.isMobile){return}e.collapseReviewMobile=!e.collapseReviewMobile}}),h("zonos-collapse",{collapsed:e.collapseReviewMobile&&e.isMobile},h("zonos-cart-items",null),e.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",{submitBtnColor:g}),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:S})))),h("zonos-cart-restricted-items",null),!e.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:S}))))),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":f},h("div",{class:"zonos--header"},C(),!e.isRedirectAfterOrder&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return e.handleFinishClick()},theme:f})),h("zonos-checkout-finish",{borderRadius:l,onCloseClick:function(){return e.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:e.storybookPaymentStatusOverride})),h("zonos-checkout-footer",{"data-theme":f,mobile:e.isMobile,slot:!e.isMobile?"dialog-footer":undefined}))};return h(Host,{class:classes(["zonos--checkout zonos--elements",cartStore.step==="payment"&&"zonos--processing-payment",d&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile",this.isIframed&&"iframed",this.hiddenMode&&"hidden-mode"])},this.preview?_():h("zonos-dialog",{borderStyle:l,class:"zonos--checkout-dialog","data-theme":f,height:"980px",isLoading:s,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return e.closeDialogHandler()},open:this.open,width:"1200px"},_()),h("zonos-dialog",{isLoading:true,loadingText:translate("You will be redirected to international checkout shortly."),loadingTitle:translate("We detected that you are shipping to an international address."),noClickOutside:true,noCloseButton:true,open:this.detectedDomesticCheckoutDialogOpen,width:"450px"}),h("zonos-dialog",{isLoading:true,loadingText:translate("You will be redirected to domestic checkout shortly."),loadingTitle:translate("We detected that you are shipping to a domestic address."),noClickOutside:true,noCloseButton:true,open:this.redirectToDomesticCheckoutDialogOpen,width:"450px"}),h("zonos-confirm-dialog",{class:"zonos--close-confirm-dialog",dialogCancelBtnText:translate("Don't close"),dialogConfirmBtnText:translate("Close"),dialogIntent:"warn",dialogOpen:this.confirmDialogOpen,dialogSubtitle:translate("Would you like to close checkout and return to the site?"),dialogTitle:translate("Are you sure?"),onCancelClicked:function(){e.confirmDialogOpen=false},onConfirmClicked:function(){return e.closeDialogHandler({confirmed:true})}}),h("zonos-confirm-dialog",{class:"zonos--order-duplication-dialog",dialogCancelBtnText:translate("Return to merchant site"),dialogConfirmBtnText:translate("Proceed with order"),dialogIntent:"warn",dialogOpen:!!this.placedOrderInfo,dialogSubtitle:((o=this.placedOrderInfo)===null||o===void 0?void 0:o.zonosOrderNumber)?translate("It looks like you placed an order recently ([date] at [time]) under order number #[orderNumber]. Check your email for the order confirmation. Are you sure you want to place another order?",{date:this.formatDate(this.placedOrderInfo.time),orderNumber:this.placedOrderInfo.zonosOrderNumber,time:this.formatTime(this.placedOrderInfo.time)}):translate("It looks like you placed an order recently ([date] at [time]). Check your email for the order confirmation. Are you sure you want to place another one?",{date:this.formatDate(((r=this.placedOrderInfo)===null||r===void 0?void 0:r.time)||null),time:this.formatTime(((n=this.placedOrderInfo)===null||n===void 0?void 0:n.time)||null)}),dialogTitle:translate("Are you sure?"),dialogWidth:530,onCancelClicked:function(){e.handleCancelOrderDuplication()},onConfirmClicked:function(){e.confirmProceedWithOrderDuplication()}}),h("zonos-confirm-dialog",{class:"zonos--fedex-shipping-dialog",dialogConfirmBtnText:translate("Confirm"),dialogIntent:"info",dialogOpen:!!this.shouldShowFedexShippingConsentDialog,dialogSubtitle:h(Fragment,null,translate("If you select FedEx Ground as your shipping option, you'll need to complete a General Agency Agreement (GAA) after placing your order. This form allows FedEx to clear your package through Canadian customs on your behalf. FedEx will contact you directly—usually by email or phone—with instructions on how to complete the GAA. To avoid delays or the return of your package, please respond promptly to their request."),h("zonos-link",{href:"https://ftn.fedex.com/us/assets/docs/One-Time_GAA.pdf",target:"_blank"},translate("View GAA Form."))),dialogTitle:translate("Fedex Shipping Procedure"),dialogType:"alert",dialogWidth:500,onConfirmClicked:function(){return e.shouldShowFedexShippingConsentDialog=false}}),h("zonos-confirm-dialog",{class:"zonos--inventory-check-failure-dialog",dialogConfirmBtnText:translate("Return to cart"),dialogIntent:"danger",dialogOpen:!!cartStore.inventoryCheckErrorMessage,dialogSubtitle:cartStore.inventoryCheckErrorMessage,dialogTitle:translate("Couldn't place order"),dialogType:"alert",onConfirmClicked:function(){return e.handleInventoryCheckDialogConfirm()}}),w&&h("zonos-confirm-dialog",{class:"zonos--pay-in-usd-dialog",dialogCancelBtnText:translate("Cancel"),dialogConfirmBtnText:translate("Pay [orderTotal]",{orderTotal:currencyFormat({amount:w.settlementAmount,currency:"USD"})}),dialogIntent:"warn",dialogOpen:this.payInUsdConfirmDialogOpen,dialogSubtitle:translate("By paying in USD, your card will be charged directly with no currency conversion. However, using a non-USD based card may result in additional currency conversion fees at the bank level."),dialogTitle:translate("Pay in USD (United States Dollar)?"),dialogType:"confirm",dialogWidth:480,onCancelClicked:function(){e.payInUsdConfirmDialogOpen=false},onConfirmClicked:function(){return e.handleStripePaymentContinue()}}),h("zonos-confirm-dialog",{class:"zonos--shopping-cart-expired-dialog",dialogConfirmBtnText:translate("OK"),dialogIntent:"danger",dialogOpen:this.isCartExpired,dialogSubtitle:translate("You are being sent back to the shop to re-add items to your cart."),dialogTitle:translate("Shopping cart expired"),dialogType:"alert",onConfirmClicked:function(){return e.handleCartExpiredDialogConfirm()}}),h("zonos-loading-overlay",{open:this.isOverlayLoading}))};Object.defineProperty(e,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],overrideStagingMode:["overrideStagingModeChanged"],mobile:["handleMobileChange"],defaultAddress:["handleAddressChange"],customerProfile:["handleCustomerProfileChange"],clientSecret:["handleClientSecretChange"],stripeCustomerSessionClientSecret:["handleClientSecretChange"],open:["handleOpenChange"]}},enumerable:false,configurable:true});return e}();ZonosCheckout.style=ZonosCheckoutStyle0;export{ZonosCheckout as zonos_checkout};