@zonos/elements 1.3.216 → 1.3.218

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cjs/{cart-96520eab.js → cart-c54d05ce.js} +2 -2
  2. package/dist/cjs/{handleFetch-b821ed5d.js → handleFetch-45f35cac.js} +1 -0
  3. package/dist/cjs/index.cjs.js +8 -8
  4. package/dist/cjs/{localization-e241e025.js → localization-ab7e1902.js} +1 -1
  5. package/dist/cjs/{paypal-97ac0999.js → paypal-d36b5dd1.js} +3 -3
  6. package/dist/cjs/{updateCheckoutSessionAttributes-5f794550.js → updateCheckoutSessionAttributes-c0853fdd.js} +1 -1
  7. package/dist/cjs/zonos-address_11.cjs.entry.js +3 -3
  8. package/dist/cjs/zonos-cart-items_14.cjs.entry.js +5 -5
  9. package/dist/cjs/zonos-checkout.cjs.entry.js +5 -5
  10. package/dist/cjs/zonos-controller.cjs.entry.js +3 -3
  11. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  12. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +4 -4
  14. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  15. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  17. package/dist/collection/components/utils/handleFetch.js +1 -0
  18. package/dist/esm/{cart-011aa510.js → cart-bb0ee971.js} +2 -2
  19. package/dist/esm/{handleFetch-bb221e63.js → handleFetch-99218189.js} +1 -0
  20. package/dist/esm/index.js +8 -8
  21. package/dist/esm/{localization-b3bdf691.js → localization-d8326254.js} +1 -1
  22. package/dist/esm/{paypal-8af04edf.js → paypal-bd4520eb.js} +3 -3
  23. package/dist/esm/{updateCheckoutSessionAttributes-fa58ba66.js → updateCheckoutSessionAttributes-92f42882.js} +1 -1
  24. package/dist/esm/zonos-address_11.entry.js +3 -3
  25. package/dist/esm/zonos-cart-items_14.entry.js +5 -5
  26. package/dist/esm/zonos-checkout.entry.js +5 -5
  27. package/dist/esm/zonos-controller.entry.js +3 -3
  28. package/dist/esm/zonos-country-flag.entry.js +2 -2
  29. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  30. package/dist/esm/zonos-empty-state-payment_4.entry.js +4 -4
  31. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  32. package/dist/esm/zonos-hello.entry.js +2 -2
  33. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  34. package/dist/esm-es5/{cart-011aa510.js → cart-bb0ee971.js} +1 -1
  35. package/dist/esm-es5/{handleFetch-bb221e63.js → handleFetch-99218189.js} +1 -1
  36. package/dist/esm-es5/index.js +1 -1
  37. package/dist/esm-es5/{localization-b3bdf691.js → localization-d8326254.js} +1 -1
  38. package/dist/esm-es5/{paypal-8af04edf.js → paypal-bd4520eb.js} +1 -1
  39. package/dist/esm-es5/{updateCheckoutSessionAttributes-fa58ba66.js → updateCheckoutSessionAttributes-92f42882.js} +1 -1
  40. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  41. package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
  42. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  43. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  44. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  45. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  46. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  47. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  48. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  49. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  50. package/dist/scripts/index.js +1 -1
  51. package/dist/scripts/loadZonos.js +1 -1
  52. package/dist/scripts/zonos.js +1 -1
  53. package/dist/zonos-elements/index.esm.js +1 -1
  54. package/dist/zonos-elements/{p-56a2d942.system.js → p-062430f9.system.js} +1 -1
  55. package/dist/zonos-elements/{p-f08d180a.js → p-0631d2b9.js} +1 -1
  56. package/dist/zonos-elements/{p-9d717d8d.system.js → p-0a6ac265.system.js} +1 -1
  57. package/dist/zonos-elements/p-0e28207a.js +1 -0
  58. package/dist/zonos-elements/p-0ed63ce0.system.js +1 -0
  59. package/dist/zonos-elements/{p-62cb568d.system.entry.js → p-0f041dc5.system.entry.js} +1 -1
  60. package/dist/zonos-elements/{p-a3e6cf3e.system.entry.js → p-1432a217.system.entry.js} +1 -1
  61. package/dist/zonos-elements/{p-24043e4f.system.entry.js → p-1b51b738.system.entry.js} +1 -1
  62. package/dist/zonos-elements/{p-592cdd54.entry.js → p-3b8d11dd.entry.js} +1 -1
  63. package/dist/zonos-elements/{p-3940f15d.entry.js → p-4333afcb.entry.js} +1 -1
  64. package/dist/zonos-elements/{p-f04bad33.system.entry.js → p-4d0d89da.system.entry.js} +1 -1
  65. package/dist/zonos-elements/{p-4f2994f9.system.entry.js → p-5dd9cb44.system.entry.js} +1 -1
  66. package/dist/zonos-elements/{p-54fd7799.system.js → p-674981ad.system.js} +1 -1
  67. package/dist/zonos-elements/{p-48b2fbb7.entry.js → p-6d090b53.entry.js} +1 -1
  68. package/dist/zonos-elements/{p-2fa8f2b8.system.entry.js → p-73c8c551.system.entry.js} +1 -1
  69. package/dist/zonos-elements/{p-8037d54c.entry.js → p-795d223d.entry.js} +1 -1
  70. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  71. package/dist/zonos-elements/{p-573b0565.system.entry.js → p-8218ff62.system.entry.js} +1 -1
  72. package/dist/zonos-elements/{p-8cafb9a4.entry.js → p-82f80c8a.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-b6dfa589.js → p-88f7256d.js} +1 -1
  74. package/dist/zonos-elements/{p-5a7130da.entry.js → p-8b083884.entry.js} +1 -1
  75. package/dist/zonos-elements/{p-f530cb04.entry.js → p-a449940d.entry.js} +1 -1
  76. package/dist/zonos-elements/{p-547babdd.entry.js → p-a5a4ad2f.entry.js} +1 -1
  77. package/dist/zonos-elements/{p-c4b7b1a4.system.entry.js → p-a5d45585.system.entry.js} +1 -1
  78. package/dist/zonos-elements/{p-4ec7abf7.system.entry.js → p-a751e819.system.entry.js} +1 -1
  79. package/dist/zonos-elements/{p-e4d475c3.js → p-a8a312b2.js} +1 -1
  80. package/dist/zonos-elements/{p-f1ba6a31.entry.js → p-b4792af0.entry.js} +1 -1
  81. package/dist/zonos-elements/{p-6cd4160d.system.js → p-d3dbae8c.system.js} +1 -1
  82. package/dist/zonos-elements/{p-801919e5.system.js → p-ebb9b902.system.js} +1 -1
  83. package/dist/zonos-elements/{p-da079b20.js → p-ef75da6f.js} +1 -1
  84. package/dist/zonos-elements/{p-db07e61c.entry.js → p-f3dbe934.entry.js} +1 -1
  85. package/dist/zonos-elements/{p-cd62465e.system.entry.js → p-f741407e.system.entry.js} +1 -1
  86. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  87. package/package.json +1 -1
  88. package/dist/zonos-elements/p-0627d793.js +0 -1
  89. package/dist/zonos-elements/p-ef76be6f.system.js +0 -1
@@ -1 +1 @@
1
- import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{g as r,a as i,l,h as u,b as m}from"./p-e4d475c3.js";import{g as p,_ as w,c as f,a as h}from"./p-b2d81c98.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b2d81c98.js";export{a as availableTestKeys}from"./p-04a01cb1.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const y=["jsdelivr","cdnjs","unpkg","vercel"],v="jsdelivr",O=e=>{const n=y.indexOf(e);return y[n+1]||null},S=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.216.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"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return l(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},g="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let b=null;const N=Promise.resolve().then((()=>{return e=null,null!==b||(b=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${g}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&z.test(o.src))return o}return null})();t&&e?console.warn(j):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${g}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),b;var e}));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=r(),s=o(),i=p()||void 0,c=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&c.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:d,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${c.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:i,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||d.length;return w&&n?(l("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var T;const R=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),$="https://v1.3.216.js.zonos.com",Z=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.216",L="https://fonts.googleapis.com",U=/^https:\/\/fonts\.googleapis\.com/;class A{}T=A,A.doneInit=!1,A.cartSettings=null,A.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),A.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),A._paypalMockResponse=null,A.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,A.isBigCommerce=!1,A.releaseDate="1749769356368",A.isLegacyCheckout=!1,A.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",A.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),A.overrideUseCustomAddressForm=!1,A.isNpm=!0,A.zonosQaUrl=null,A.zonosQaUrlApi=null,A.trackEventLogs=[],A.version="v1.3.216",A.modeAlerted=!1,A.cartData=null,A.paypal=null,A.zonosMode=null,A.IframeService=t,A.getCurrentTimestamp=()=>(new Date).getTime(),A.zonosController=null,A.loadTimeApiInfoList=[],A.logIntervalId=null,A.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=p,T.storeId=a,T.isNpm){l("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){l(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!T.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){l("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return l("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(T.cartId);if(!e)return void m("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey,T.cartSettings=e.settings}const o=await(async()=>{const e=r(),n=i();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(l("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return l("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(l(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(T.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||h){l("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}l("init zonos"),T.restoreNativeBrowserFunctions(),T.injectCustomScriptForHostedCheckout(),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectCheckoutInternationalButton(),T.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),T.doneInit=!0},A.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},A.injectCustomScriptForHostedCheckout=()=>{const e=T.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){l("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},A.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},A.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},A.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},A.showNotification=e=>{var n;null===(n=T.zonosController)||void 0===n||n.showNotification(e)},A.updateOrganizationName=e=>{var n;null===(n=T.zonosController)||void 0===n||n.updateOrganizationName(e)},A.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},A.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},A.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=T.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;l("loading Stripe");const o=await(async(...e)=>{I=!0;const n=Date.now();return N.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),T.zonosController=t,l("Zonos controller injected!")},A.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${T.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void l(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");n?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{m(`Failed to load ${r.src}`);const t=O(e);t&&T.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(r)},A.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return Z;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.216";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.216";case"vercel":return $}};return T.isNpm&&S()||n()},A.injectZonosCdn=()=>{T.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},A.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=T.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${$}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&T.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},A.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},A.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!U.test(o.href))return o}return null})())return void l("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=L,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${L}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),l("Zonos font injected!")},A.setupGoogleFont=e=>{var n;null===(n=T.zonosController)||void 0===n||n.setupGoogleFont(e)},A.injectSupportGoogleFont=e=>{var n;l(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${L}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=L,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void l(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),l(`[FONT] ${o} font injected!`)};const C=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],E=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],P=[...C,...E];export{A as Zonos,P as checkoutSessionAttributeKeys,E as checkoutSessionImmutableAttributeKeys,C as checkoutSessionMutableAttributeKeys}
1
+ import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{g as r,a as i,l,h as u,b as m}from"./p-a8a312b2.js";import{g as p,_ as w,c as f,a as h}from"./p-b2d81c98.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b2d81c98.js";export{a as availableTestKeys}from"./p-04a01cb1.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const y=["jsdelivr","cdnjs","unpkg","vercel"],v="jsdelivr",O=e=>{const n=y.indexOf(e);return y[n+1]||null},S=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.218.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"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return l(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},g="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let b=null;const N=Promise.resolve().then((()=>{return e=null,null!==b||(b=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${g}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&z.test(o.src))return o}return null})();t&&e?console.warn(j):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${g}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),b;var e}));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=r(),s=o(),i=p()||void 0,c=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&c.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:d,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${c.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:i,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||d.length;return w&&n?(l("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var T;const R=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),$="https://v1.3.218.js.zonos.com",Z=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.218",L="https://fonts.googleapis.com",U=/^https:\/\/fonts\.googleapis\.com/;class A{}T=A,A.doneInit=!1,A.cartSettings=null,A.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),A.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),A._paypalMockResponse=null,A.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,A.isBigCommerce=!1,A.releaseDate="1749830895070",A.isLegacyCheckout=!1,A.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",A.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),A.overrideUseCustomAddressForm=!1,A.isNpm=!0,A.zonosQaUrl=null,A.zonosQaUrlApi=null,A.trackEventLogs=[],A.version="v1.3.218",A.modeAlerted=!1,A.cartData=null,A.paypal=null,A.zonosMode=null,A.IframeService=t,A.getCurrentTimestamp=()=>(new Date).getTime(),A.zonosController=null,A.loadTimeApiInfoList=[],A.logIntervalId=null,A.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=p,T.storeId=a,T.isNpm){l("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){l(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!T.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){l("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return l("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(T.cartId);if(!e)return void m("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey,T.cartSettings=e.settings}const o=await(async()=>{const e=r(),n=i();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(l("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return l("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(l(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(T.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||h){l("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}l("init zonos"),T.restoreNativeBrowserFunctions(),T.injectCustomScriptForHostedCheckout(),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectCheckoutInternationalButton(),T.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),T.doneInit=!0},A.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},A.injectCustomScriptForHostedCheckout=()=>{const e=T.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){l("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},A.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},A.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},A.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},A.showNotification=e=>{var n;null===(n=T.zonosController)||void 0===n||n.showNotification(e)},A.updateOrganizationName=e=>{var n;null===(n=T.zonosController)||void 0===n||n.updateOrganizationName(e)},A.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},A.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},A.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=T.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;l("loading Stripe");const o=await(async(...e)=>{I=!0;const n=Date.now();return N.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),T.zonosController=t,l("Zonos controller injected!")},A.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${T.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void l(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");n?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{m(`Failed to load ${r.src}`);const t=O(e);t&&T.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(r)},A.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return Z;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.218";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.218";case"vercel":return $}};return T.isNpm&&S()||n()},A.injectZonosCdn=()=>{T.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},A.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=T.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${$}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&T.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},A.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},A.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!U.test(o.href))return o}return null})())return void l("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=L,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${L}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),l("Zonos font injected!")},A.setupGoogleFont=e=>{var n;null===(n=T.zonosController)||void 0===n||n.setupGoogleFont(e)},A.injectSupportGoogleFont=e=>{var n;l(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${L}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=L,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void l(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),l(`[FONT] ${o} font injected!`)};const C=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],E=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],P=[...C,...E];export{A as Zonos,P as checkoutSessionAttributeKeys,E as checkoutSessionImmutableAttributeKeys,C as checkoutSessionMutableAttributeKeys}
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,r,o){function t(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o["throw"](e))}catch(e){i(e)}}function s(e){e.done?r(e.value):t(e.value).then(a,u)}s((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(n){return s([e,n])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=n.call(e,r)}catch(e){u=[6,e];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var o=0,t=n.length,i;o<t;o++){if(i||!(o in n)){if(!i)i=Array.prototype.slice.call(n,0,o);i[o]=n[o]}}return e.concat(i||Array.prototype.slice.call(n))};System.register([],(function(e){"use strict";return{execute:function(){var n=this;var r=performance.now();var o=e("d",[]);var t=e("c",(function(){var e=performance.now()-r;var n=e>1e3?"".concat((e/1e3).toFixed(2),"s"):"".concat(e.toFixed(2),"ms");return{elapsedTime:e,elapsedTimePretty:n}}));var i=function(e){if(typeof e==="string"){return e}try{var n=JSON.stringify(e);return n}catch(n){if(e&&typeof e.toString==="function"){var r=e.toString();return r}return"Unable to stringify info"}};var a=e("l",(function(e,n){var r=[];for(var a=2;a<arguments.length;a++){r[a-2]=arguments[a]}var u,s;var d=t().elapsedTimePretty;var c=__spreadArray(["(".concat(d,")")],r,true);var l=c.map(i).join(" ");o.push([n,e,l].filter(Boolean).join(" "));var f=!!((u=window.Zonos)===null||u===void 0?void 0:u.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/);if(!f){return}var v=document.querySelector("iframe#zonos---debug-logging-iframe");if(!v){v=document.createElement("iframe");v.id="zonos---debug-logging-iframe";v.style.display="none";v.style.opacity="0";v.style.position="absolute";v.style.top="-9999px";v.style.left="-9999px";v.style.width="1px";v.style.height="1px";v.style.border="none";v.style.overflow="hidden";v.style.visibility="hidden";document.body.appendChild(v)}var w=((s=v.contentWindow)===null||s===void 0?void 0:s.window.console)||window.console;switch(n){case"warn":w.warn.apply(w,__spreadArray([e],c,false));break;case"info":w.info.apply(w,__spreadArray([e],c,false));break;case"error":w.error.apply(w,__spreadArray([e],c,false));break;default:w.groupCollapsed.apply(w,__spreadArray([e],c,false));w.trace();w.groupEnd();break}}));var u=e("b",(function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}a.apply(void 0,__spreadArray([e,"error"],n,false))}));var s=e("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var d=e("g",(function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var c=["cloudflare","vercel"];var l=c[0];var f=e("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var v=f[l];var w=function(e){if(e===void 0){e=l}var n=c.indexOf(e);var r=c[n+1];if(!r){return null}return r};var p=e("j",(function(e){if(typeof e==="string"){try{var n=JSON.parse(e);return n}catch(e){return null}}return null}));var h=890;var b=e("i",(function(e){return e||window.innerWidth<h}));var y=function(){var e="connection"in window.navigator?window.navigator.connection:null;var n="mozConnection"in window.navigator?window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;var o=e||n||r;return o};var m=e("e",(function(){var e="userAgentData"in window.navigator?window.navigator.userAgentData:null;var n=y();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}}));var g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];var _=function(e){var n=e.apiPath,r=e.apiType,o=e.loadTimeInternal,t=e.loadTimeTotal;if(g.includes(n)){return}var i=t-o;if(i<0){return}var a=n.split("?")[0]||n;var u=m();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var d={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:b(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var T=1*3600*1e3;var k=e("s",(function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i;var u=e.endpoint,s=e.errors,d=e.metadata,c=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){a("sendErrorLog","warn",u,d,s);if(c){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>T){return[2]}}o="userAgentData"in window.navigator?window.navigator.userAgentData:null;t={endpoint:u,errors:s,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent},d)};try{void fetch("".concat(v,"/api/zonos-elements/log-error"),{body:JSON.stringify(t),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=w();if(!i){return[2]}void fetch("".concat(f[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(t),method:"POST"})}return[2]}))}))}));var j=undefined&&undefined.__rest||function(e,n){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(e);t<o.length;t++){if(n.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(e,o[t]))r[o[t]]=e[o[t]]}return r};var z=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o;var t=e.response,i=e.shouldLog,a=i===void 0?true:i,u=e.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,t.text()];case 1:n=e.sent();r=p(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2,r];case 2:o=e.sent();if(s){throw o}if(a){console.error(o)}return[2,null];case 3:return[2]}}))}))};var A=function(e){try{var n=btoa(e).replace(/=/g,"");return n}catch(n){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var O=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,a,u,s,d,c,v,c,w,p,u,h,u;var b=e.basePathType,y=e.options,m=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||f[b]||l;o=r+m;t=new URL(o);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",A(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4,fetch(t.toString(),y)];case 2:n=e.sent();return[3,4];case 3:a=e.sent();if(a instanceof Error){return[2,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}u="Failed to fetch";return[2,{baseUrl:r,errors:[{message:u,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:s=n.headers.get("Zonos-Mode");d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&s&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3,6];return[4,z({response:n})];case 5:c=e.sent();return[2,{baseUrl:r,errors:[],json:c,response:n,zonosMode:s}];case 6:v=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4,z({response:n,shouldThrow:true})];case 8:c=e.sent();if(c&&"errors"in c&&Array.isArray(c.errors)){w=c.errors;p=w.map((function(e){if(typeof e==="string"){return{message:e,type:v}}return e}));return[2,{baseUrl:r,errors:p,json:null,response:n,zonosMode:s}]}u=JSON.stringify(c);return[2,{baseUrl:r,errors:[{message:u,type:v}],json:null,response:n,zonosMode:s}];case 9:h=e.sent();u="Unknown error";return[2,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(u),type:v}],json:null,response:null,zonosMode:s}];case 10:return[2]}}))}))};var S=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,u,s,d,c,l,v,h,b,y,m,g,T;var z=e.basePathType,A=e.options,P=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=P.startsWith("/api/bigcommerce");t=o?"vercel":z;i=performance.now();return[4,O({basePathType:t,options:A,path:P})];case 1:u=e.sent(),s=u.errors,d=u.response,c=j(u,["errors","response"]);l=performance.now();v=l-i;a("".concat(P," (").concat(v.toFixed(2),"ms)"),"info");h=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");if((d===null||d===void 0?void 0:d.status)===200){_({apiPath:P,apiType:t,loadTimeInternal:h?Number(h):0,loadTimeTotal:v})}b=w(t);y=s.find((function(e){var n=e.type;return n==="unknown"}));m=s.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));g=!!y||(d===null||d===void 0?void 0:d.status)===404||(d===null||d===void 0?void 0:d.status)===500;T=b&&g;if(g&&!m){void k({endpoint:f[t]+P,errors:s.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:t,nextFallbackApiType:b,requestHeaders:A===null||A===void 0?void 0:A.headers,requestPayload:p((n=A===null||A===void 0?void 0:A.body)===null||n===void 0?void 0:n.toString())||((r=A===null||A===void 0?void 0:A.body)===null||r===void 0?void 0:r.toString()),status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.statusText},shouldPostReleaseErrorReporting:true})}if(T){a('=== "'.concat(P,'" failed to fetch, trying next fallback ').concat(b));return[2,S({basePathType:b,options:A,path:P})]}return[2,Object.assign({errors:s,response:d},c)]}}))}))};var P=e("h",(function(e,r){return __awaiter(n,void 0,void 0,(function(){var n,o,t,i,a,u;return __generator(this,(function(c){n=j(r||{},[]);o=n.body?JSON.stringify(n.body):undefined;t=n.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":undefined,"Zonos-Test-Mode":d()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},n),{body:t==="GET"?undefined:o,headers:i,method:t});u=new URLSearchParams(window.location.search).get("useFallbackApi");return[2,S({basePathType:u||l,options:a,path:e})]}))}))}))}}}));
1
+ var __awaiter=this&&this.__awaiter||function(e,n,r,o){function t(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o["throw"](e))}catch(e){i(e)}}function s(e){e.done?r(e.value):t(e.value).then(a,u)}s((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(n){return s([e,n])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=n.call(e,r)}catch(e){u=[6,e];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var o=0,t=n.length,i;o<t;o++){if(i||!(o in n)){if(!i)i=Array.prototype.slice.call(n,0,o);i[o]=n[o]}}return e.concat(i||Array.prototype.slice.call(n))};System.register([],(function(e){"use strict";return{execute:function(){var n=this;var r=performance.now();var o=e("d",[]);var t=e("c",(function(){var e=performance.now()-r;var n=e>1e3?"".concat((e/1e3).toFixed(2),"s"):"".concat(e.toFixed(2),"ms");return{elapsedTime:e,elapsedTimePretty:n}}));var i=function(e){if(typeof e==="string"){return e}try{var n=JSON.stringify(e);return n}catch(n){if(e&&typeof e.toString==="function"){var r=e.toString();return r}return"Unable to stringify info"}};var a=e("l",(function(e,n){var r=[];for(var a=2;a<arguments.length;a++){r[a-2]=arguments[a]}var u,s;var d=t().elapsedTimePretty;var c=__spreadArray(["(".concat(d,")")],r,true);var l=c.map(i).join(" ");o.push([n,e,l].filter(Boolean).join(" "));var f=!!((u=window.Zonos)===null||u===void 0?void 0:u.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/);if(!f){return}var v=document.querySelector("iframe#zonos---debug-logging-iframe");if(!v){v=document.createElement("iframe");v.id="zonos---debug-logging-iframe";v.style.display="none";v.style.opacity="0";v.style.position="absolute";v.style.top="-9999px";v.style.left="-9999px";v.style.width="1px";v.style.height="1px";v.style.border="none";v.style.overflow="hidden";v.style.visibility="hidden";document.body.appendChild(v)}var w=((s=v.contentWindow)===null||s===void 0?void 0:s.window.console)||window.console;switch(n){case"warn":w.warn.apply(w,__spreadArray([e],c,false));break;case"info":w.info.apply(w,__spreadArray([e],c,false));break;case"error":w.error.apply(w,__spreadArray([e],c,false));break;default:w.groupCollapsed.apply(w,__spreadArray([e],c,false));w.trace();w.groupEnd();break}}));var u=e("b",(function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}a.apply(void 0,__spreadArray([e,"error"],n,false))}));var s=e("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var d=e("g",(function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var c=["cloudflare","vercel"];var l=c[0];var f=e("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var v=f[l];var w=function(e){if(e===void 0){e=l}var n=c.indexOf(e);var r=c[n+1];if(!r){return null}return r};var p=e("j",(function(e){if(typeof e==="string"){try{var n=JSON.parse(e);return n}catch(e){return null}}return null}));var h=890;var b=e("i",(function(e){return e||window.innerWidth<h}));var y=function(){var e="connection"in window.navigator?window.navigator.connection:null;var n="mozConnection"in window.navigator?window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;var o=e||n||r;return o};var m=e("e",(function(){var e="userAgentData"in window.navigator?window.navigator.userAgentData:null;var n=y();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}}));var g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];var _=function(e){var n=e.apiPath,r=e.apiType,o=e.loadTimeInternal,t=e.loadTimeTotal;if(g.includes(n)){return}var i=t-o;if(i<0){return}var a=n.split("?")[0]||n;var u=m();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var d={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:b(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var T=1*3600*1e3;var k=e("s",(function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i;var u=e.endpoint,s=e.errors,d=e.metadata,c=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){a("sendErrorLog","warn",u,d,s);if(c){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>T){return[2]}}o="userAgentData"in window.navigator?window.navigator.userAgentData:null;t={endpoint:u,errors:s,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent},d)};try{void fetch("".concat(v,"/api/zonos-elements/log-error"),{body:JSON.stringify(t),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=w();if(!i){return[2]}void fetch("".concat(f[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(t),method:"POST"})}return[2]}))}))}));var j=undefined&&undefined.__rest||function(e,n){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(e);t<o.length;t++){if(n.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(e,o[t]))r[o[t]]=e[o[t]]}return r};var z=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o;var t=e.response,i=e.shouldLog,a=i===void 0?true:i,u=e.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,t.text()];case 1:n=e.sent();r=p(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2,r];case 2:o=e.sent();if(s){throw o}if(a){console.error(o)}return[2,null];case 3:return[2]}}))}))};var A=function(e){try{var n=btoa(e).replace(/=/g,"");return n}catch(n){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var O=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,a,u,s,d,c,v,c,w,p,u,h,u;var b=e.basePathType,y=e.options,m=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||f[b]||l;o=r+m;t=new URL(o);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",A(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4,fetch(t.toString(),y)];case 2:n=e.sent();return[3,4];case 3:a=e.sent();if(a instanceof Error){return[2,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}u="Failed to fetch";return[2,{baseUrl:r,errors:[{message:u,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:s=n.headers.get("Zonos-Mode");d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&s&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3,6];return[4,z({response:n})];case 5:c=e.sent();return[2,{baseUrl:r,errors:[],json:c,response:n,zonosMode:s}];case 6:v=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4,z({response:n,shouldThrow:true})];case 8:c=e.sent();if(c&&"errors"in c&&Array.isArray(c.errors)){w=c.errors;p=w.map((function(e){if(typeof e==="string"){return{message:e,type:v}}return e}));return[2,{baseUrl:r,errors:p,json:null,response:n,zonosMode:s}]}u=JSON.stringify(c);return[2,{baseUrl:r,errors:[{message:u,type:v}],json:null,response:n,zonosMode:s}];case 9:h=e.sent();u="Unknown error";return[2,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(u),type:v}],json:null,response:null,zonosMode:s}];case 10:return[2]}}))}))};var S=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,u,s,d,c,l,v,h,b,y,m,g,T;var z=e.basePathType,A=e.options,P=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=P.startsWith("/api/bigcommerce");t=o?"vercel":z;i=performance.now();return[4,O({basePathType:t,options:A,path:P})];case 1:u=e.sent(),s=u.errors,d=u.response,c=j(u,["errors","response"]);l=performance.now();v=l-i;a("".concat(P," (").concat(v.toFixed(2),"ms)"),"info");h=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");if((d===null||d===void 0?void 0:d.status)===200){_({apiPath:P,apiType:t,loadTimeInternal:h?Number(h):0,loadTimeTotal:v})}b=w(t);y=s.find((function(e){var n=e.type;return n==="unknown"}));m=s.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));g=!!y||(d===null||d===void 0?void 0:d.status)===404||(d===null||d===void 0?void 0:d.status)===500;T=b&&g;if(g&&!m){void k({endpoint:f[t]+P,errors:s.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:t,nextFallbackApiType:b,requestHeaders:A===null||A===void 0?void 0:A.headers,requestPayload:p((n=A===null||A===void 0?void 0:A.body)===null||n===void 0?void 0:n.toString())||((r=A===null||A===void 0?void 0:A.body)===null||r===void 0?void 0:r.toString()),shouldCallFallback:T,status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.statusText},shouldPostReleaseErrorReporting:true})}if(T){a('=== "'.concat(P,'" failed to fetch, trying next fallback ').concat(b));return[2,S({basePathType:b,options:A,path:P})]}return[2,Object.assign({errors:s,response:d},c)]}}))}))};var P=e("h",(function(e,r){return __awaiter(n,void 0,void 0,(function(){var n,o,t,i,a,u;return __generator(this,(function(c){n=j(r||{},[]);o=n.body?JSON.stringify(n.body):undefined;t=n.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":undefined,"Zonos-Test-Mode":d()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},n),{body:t==="GET"?undefined:o,headers:i,method:t});u=new URLSearchParams(window.location.search).get("useFallbackApi");return[2,S({basePathType:u||l,options:a,path:e})]}))}))}))}}}));
@@ -1 +1 @@
1
- import{z as e,c as t}from"./p-7ce093aa.js";import{s as o,l as n,t as s,f as r,b as i}from"./p-b6dfa589.js";import{l as a,f as d,h as l,g as c,a as u,s as m,d as v,b as p,j as h}from"./p-e4d475c3.js";import{i as y}from"./p-56e0ed65.js";import{g as w}from"./p-2b9c124d.js";const g=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const s=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=s[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||s.slice(1).join(" ").trim()||""}},f=({currentAddress:e,translatedAddress:t})=>{var o,n,s,r,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:v}=e.value.address,p=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(s=t.line2)||void 0===s?void 0:s[u||""])||u||"",name:(null===(r=t.name)||void 0===r?void 0:r[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[v])||v}},b=e=>{var t;const n="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),s=P.stripeLinkEventData,r=P.stripeAddressEventData,i=P.stripeShippingSameAsBilling?P.stripeAddressEventData:P.stripeBillingAddressEventData;if(!r||!i)throw new Error("Missing stripe address data");const a=f({currentAddress:r,translatedAddress:P.translatedAddress.address}),{firstName:d,lastName:l}=g({name:a.name}),c=f({currentAddress:i,translatedAddress:P.translatedAddress.address}),{firstName:u,lastName:m}=g({name:c.name});return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:u,lastName:m,phone:c.phone},cartCurrencyCode:null===(t=ne.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:P.companyName,email:null==s?void 0:s.value.email,firstName:d,lastName:l,phone:a.phone},isTest:!!n,landedCostAdjustments:ne.promoCode?[{amount:0,productId:null,promoCode:ne.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:P.taxId,shippingAddress:{addressLine1:a.line1,addressLine2:a.line2,city:a.city,country:a.country,postalCode:a.postal_code,state:a.state}}},S=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=P.stripeLinkEventData,n=P.stripeAddressEventData,s=P.stripeShippingSameAsBilling?P.stripeAddressEventData:P.stripeBillingAddressEventData;if(a({stripeAddressData:n,stripeBillingAddressData:s},"info"),!n||!s)throw new Error("Missing stripe address data");const r=f({currentAddress:n,translatedAddress:P.translatedAddress.address}),{firstName:i,lastName:d}=g({name:r.name}),l=f({currentAddress:s,translatedAddress:P.translatedAddress.address}),{firstName:c,lastName:u}=g({name:l.name}),m=ne.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),v=ne.promoCode?[{amount:0,productId:null,promoCode:ne.promoCode,sku:null,type:"PROMO_CODE"},...m]:m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:P.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:d,phone:r.phone},isTest:e,items:ne.items,landedCostAdjustments:v,shipToTaxId:P.taxId,shippingAddress:{addressLine1:r.line1,addressLine2:r.line2,city:r.city,country:r.country,postalCode:r.postal_code,state:r.state}}};const C=async t=>{const o=window.Zonos.cartId;if(!o)return await(async t=>{var o;const n=e.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,s,r;const i=S(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:d.vercel});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(s=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===s?void 0:s.message)||"Unknown error"}`);const{errors:c,json:u}=await l("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!u||c.length)throw new Error(`Invalid landed cost object: ${(null===(r=c.find(Boolean))||void 0===r?void 0:r.message)||"Unknown error"}`);return a})(n);return e}const{errors:s,json:r}=await l("/api/zonos-elements/calculate-landed-cost",{body:S(),method:"POST",signal:null==t?void 0:t.signal});if(s.length||!r){if("The user aborted a request."===(null===(o=s[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(s.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!r)throw new Error("Failed to calculate landed cost");return r}return r})(t);const n=await(async({abortController:e,cartId:t})=>{var o,n,s,r,i;const{errors:a,json:d}=await l("/api/zonos-elements/cart-calculate-landed-cost",{body:b(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(s=a[0])||void 0===s?void 0:s.message.includes("signal is aborted"))||(null===(r=a[0])||void 0===r?void 0:r.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:t,cartId:o}),{cartWorkflow:s}=n,r=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},r),{itemCreateWorkflow:s.items})},O=async({checkoutSessionId:t,eventName:o,metadata:s})=>{var r,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:t,eventCreated:a,eventName:o});const p=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(r=window.Zonos)||void 0===r?void 0:r.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((c()||u()||p)&&!window.Zonos.zonosConversionTest)return;const h=n.selectedCountryCode,y=e.organizationId;if(!t)return void m({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:v,checkoutSessionId:t,eventName:o,metadata:s,organizationId:y,trackEventLogs:d}});y||m({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:v,checkoutSessionId:t,eventName:o,metadata:s,organizationId:y,trackEventLogs:d}});const w={checkoutSessionId:t,countryCode:h,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},s),{trackEventLogs:d}),organizationId:y};await l("/api/zonos-elements/track-conversion-event",{body:w,method:"POST"})},A=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},k=e=>e.sort(((e,t)=>e.amount-t.amount)),I=async()=>{var e;const{errors:t,json:n}=await(async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await l(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}})();return t.length||!n?(p("Failed to retrieve checkout session info before confirming payment ",t),m({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:v}}),{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=n.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(p("Landed cost is not found in the checkout session before confirming payment."),m({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:v}}),{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},N=({theme:t})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:e.appearance.fontSizeInputValue?`${e.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:e.appearance.fontSizeInputLabel?`${e.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===t?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},j=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:T,reset:E,state:P}=t((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),L=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},D=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},x=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return h(e)},R=async t=>{var o,s;const r=P.clientSecret;if(!P.stripe)return void a("Skip. Stripe is not initialized");const i=(({clientSecret:t,overrideBorderRadius:o,overridePrimaryColor:s,overrideSecondaryColor:r,overrideTheme:i,paypalEnabled:a})=>{const d=s||e.appearance.colorPrimary,l=r||e.appearance.colorSecondary,c=d&&y(d)?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},N({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},j({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||void 0,customerSessionClientSecret:P.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:r,overrideBorderRadius:null==t?void 0:t.overrideBorderRadius,overridePrimaryColor:null==t?void 0:t.overridePrimaryColor,overrideSecondaryColor:null==t?void 0:t.overrideSecondaryColor,overrideTheme:null==t?void 0:t.overrideTheme,paypalEnabled:null==t?void 0:t.paypalEnabled}),d=JSON.stringify(i)===JSON.stringify(P.stripeElementsOptions);if(!P.stripeElements||!P.stripeElementsForBillingAddress)return P.stripeElements=null===(o=P.stripe)||void 0===o?void 0:o.elements(i),P.stripeElementsOptions=i,a("Stripe elements initialized"),P.stripeElementsForBillingAddress=null===(s=P.stripe)||void 0===s?void 0:s.elements(i),void a("Stripe elements for billing address initialized");d||(P.stripeElements.update(i),P.stripeElementsForBillingAddress.update(i),P.stripeElementsOptions=i,P.stripeElements.fetchUpdates()),a("Stripe elements updated")},_=()=>{sessionStorage.removeItem("zonos--client-secret"),E(),P.stripe=window.Zonos.stripe},z=({address:e,firstName:t,lastName:n,name:s,phone:r})=>{const{firstName:i,lastName:a}=g({firstName:t,lastName:n,name:s});return i&&a||m({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:s}}),r||m({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:r}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:r||"",postal_code:e.postal_code,state:e.state}},U=async()=>{var e,t,n,s;if(!(null===(e=P.stripeAddressEventData)||void 0===e?void 0:e.complete)||!P.stripeShippingSameAsBilling&&!(null===(t=P.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!P.stripeBillingAddressEventData)return{partiesCreated:!1};if(!ne.landedCostData)return{partiesCreated:!1};const r=null===(n=ne.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!r)return m({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,s,r;const i=JSON.stringify(null===(e=P.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=P.stripeLinkEventData)||void 0===t?void 0:t.value),a=JSON.stringify(null===(o=P.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=P.stripeAddressEventData)||void 0===n?void 0:n.value),d=!P.stripeShippingSameAsBilling&&JSON.stringify(null===(s=P.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===s?void 0:s.value)!==JSON.stringify(null===(r=P.stripeBillingAddressEventData)||void 0===r?void 0:r.value);return i||a||d||P.taxIdUsedWhenAsyncAddressUpdate!==P.taxId||P.companyNameUsedWhenAsyncAddressUpdate!==P.companyName})();if(!i)return{partiesCreated:!1};const a=z({address:P.stripeAddressEventData.value.address,firstName:P.stripeAddressEventData.value.firstName,lastName:P.stripeAddressEventData.value.lastName,name:P.stripeAddressEventData.value.name,phone:P.stripeAddressEventData.value.phone}),d=P.stripeShippingSameAsBilling?a:z({address:P.stripeBillingAddressEventData.value.address,firstName:P.stripeBillingAddressEventData.value.firstName,lastName:P.stripeBillingAddressEventData.value.lastName,name:P.stripeBillingAddressEventData.value.name,phone:P.stripeBillingAddressEventData.value.phone}),c="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:u,json:h}=await l("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:P.companyName,email:(null===(s=P.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"",isTest:c,rootId:r,taxId:P.taxId},method:"POST"});return u.length||!h?(p("Error occurs when creating parties",JSON.stringify(u,null,2)),m({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:u,json:h}}),{partiesCreated:!1}):(P.companyNameUsedWhenAsyncAddressUpdate=P.companyName,P.stripeAddressUsedWhenAsyncAddressUpdate=P.stripeAddressEventData,P.stripeBillingAddressUsedWhenAsyncAddressUpdate=P.stripeBillingAddressEventData,P.taxIdUsedWhenAsyncAddressUpdate=P.taxId,P.partyBillingId=h.billToPartyId,P.partyShippingId=h.shipToPartyId,{partiesCreated:!0})},B=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),F=async t=>{var n,s,r,i;const d=(null==t?void 0:t.retries)||0,l=!!(null==t?void 0:t.applyingPromocode),c=(()=>{var e;const t=ne.landedCostData&&(null===(e=ne.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==ne.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=P.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=P.stripeLinkEventData)||void 0===t?void 0:t.value),n=P.stripeAddressEventData&&JSON.stringify(B(P.stripeAddressEventData.value))!==JSON.stringify(P.stripeAddressUsedWhenFetchingLC),s=!P.stripeShippingSameAsBilling&&P.stripeBillingAddressEventData&&JSON.stringify(B(P.stripeBillingAddressEventData.value))!==JSON.stringify(P.stripeBillingAddressUsedWhenFetchingLC);return o||n||s})();return a("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!ne.landedCostData&&!P.isFetchingLandedCost||o||t})();if(!(()=>{var t,o,n,s;const r=!!(null===(t=P.stripeLinkEventData)||void 0===t?void 0:t.complete),i=!!(null===(o=P.stripeAddressEventData)||void 0===o?void 0:o.complete),a=P.stripeShippingSameAsBilling?i:!!(null===(n=P.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(t=>{var o,n;const s=null===(o=e.genericSettings)||void 0===o?void 0:o.countryFields,r=null===(n=e.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===ne.addressFormRenderType&&(r&&t in r?r[t]:null)||(s&&t in s?s[t]:null)})((null===(s=P.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US");return!!(i&&a&&r)||(d&&P.stripeAddressEventData?r&&P.stripeAddressEventData.value.firstName&&P.stripeAddressEventData.value.lastName&&P.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&P.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&P.stripeAddressEventData.value.address.postal_code.length>=3)&&P.stripeAddressEventData.value.phone&&P.stripeAddressEventData.value.phone.length>0:i&&a&&r)})())return{isRequestNotReady:!0};if(c&&(null===(n=P.fetchingLandedCostAbortController)||void 0===n||n.abort(),P.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};d?(P.isFetchingLandedCost=!1,setTimeout((()=>{P.isFetchingLandedCost=!0}),300)):P.isFetchingLandedCost=!0,P.stripeAddressEventData&&(P.stripeAddressUsedWhenFetchingLC={countryCode:P.stripeAddressEventData.value.address.country,postalCode:P.stripeAddressEventData.value.address.postal_code,state:P.stripeAddressEventData.value.address.state}),P.stripeBillingAddressEventData&&(P.stripeBillingAddressUsedWhenFetchingLC={countryCode:P.stripeBillingAddressEventData.value.address.country,postalCode:P.stripeBillingAddressEventData.value.address.postal_code,state:P.stripeBillingAddressEventData.value.address.state}),P.stripeLinkEventData&&(P.stripeLinkUsedWhenFetchingLC=Object.assign({},P.stripeLinkEventData));try{ge(),await(async()=>{var e;const t=new AbortController;P.fetchingLandedCostAbortController=t,ge();const{checkoutSessionWorkflow:n,errors:s,itemCreateWorkflow:r,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await C(t);ne.customQuotingError=(null===(e=null==s?void 0:s.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,ne.shippingData=k((null==d?void 0:d.filter(Boolean))||[]),ae(r),P.fetchingLandedCostAbortController=null,ne.partiesData=(null==a?void 0:a.filter(Boolean))||[],ne.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&O({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=ne.promoCodeApplied&&!ne.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));ne.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",ne.promoCode)})();const e=null===(s=ne.shippingData)||void 0===s?void 0:s.find(Boolean),t=null===(r=ne.landedCostData)||void 0===r?void 0:r.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ce({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(e){if(ne.landedCostData=[],ne.shippingData=[],e instanceof Error&&e.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(e.message)){if(d<1)return await F(Object.assign(Object.assign({},t),{retries:(d||0)+1})),{isRequestNotReady:!1};const o=null===(i=P.stripeAddressEventData)||void 0===i?void 0:i.value;m({endpoint:`Failed to fetch landed cost (${d} retries)`,errors:[e.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}p(e)}return P.isFetchingLandedCost=!1,{isRequestNotReady:!1}},J=async()=>{var e,t;await F({applyingPromocode:!0}),"payment"===ne.step&&be(),await U();const o=null===(e=ne.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=ne.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await he(o,n.landedCostId)},M=()=>{ne.promoCode="",sessionStorage.removeItem("zonos--promo-code"),ne.promoCodeError=!1,ne.promoCodeApplied=!1},$=async()=>{"payment"===ne.step&&be(),M(),await J()},W=e=>{let t=[],o=!0;switch(e){case"succeeded":t=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")],o=!1;break;case"requires_capture":case"processing":t=[s("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[s("Payment failed. Please try another payment method.")];break;case"requires_action":o=!1,t=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[s("Something went wrong.")]}return{isError:o,messages:t}},q=async()=>{var t,o;const{onInventoryCheck:n}=e.checkoutSettings,r=!!(null===(o=null===(t=window.Zonos.cartData)||void 0===t?void 0:t.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&r){const{errors:e,json:t}=await l("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(p("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(P.shouldInventoryRefund=!0,null):null:s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")}if("function"!=typeof n)return null;try{return await n({items:ne.items})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw m({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:ne.items}}),e}},Y=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await l("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},H=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=W(t);return{error:e,messages:o}}const o=e||P.clientSecret;if(!P.stripe||!o)return p("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[s("Something went wrong.")]};const{paymentIntent:n}=await P.stripe.retrievePaymentIntent(o),r=null==n?void 0:n.status,{isError:i,messages:a}=W(r);return{error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:r}},K=async()=>{var e,t;const n=!!(null===(e=P.stripePaymentEventData)||void 0===e?void 0:e.complete),r=P.stripeElements,i=P.stripe,d=P.clientSecret;if(P.customErrorMessage=null,!(null===(t=ne.selectedLandedCost)||void 0===t?void 0:t.landedCost.id))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const l=await I();if(!l.valid)throw P.customErrorMessage=l.errorMessage,new Error(l.errorMessage);const c=o.checkoutSessionId;if(i&&r&&n&&d&&c){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",d),e.searchParams.set("zonosCheckoutSessionId",c),O({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await i.confirmPayment({confirmParams:{return_url:e.toString()},elements:r,redirect:"if_required"});if(a("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."));if(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(s("Payment failed. Please try another payment method."))}},G=()=>{var e;const t=ne.items.reduce(((e,t)=>e+t.amount*t.quantity),0),s=o.enabledVariantTestKeys||[];return{adjustmentsAmount:ne.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=ne.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:ne.customerAuthenticationToken||void 0,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:P.skipPaymentIntent,varianceTestInput:s}},V=async()=>{var e;if(!o.checkoutSessionId)return m({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:v,cartId:window.Zonos.cartId}}),void le({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});const{errors:t,json:n}=await l("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),r=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!r)return p("Error occurs when getting payment intent",JSON.stringify(t,null,2)),m({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:r}}),void le({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});me(n.checkoutSessionPaymentIntentCreate)},Z=async()=>{var e,t;if(!n.targetCurrency)return p("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;P.isFetchingSession=!0;const o=G();a("Checkout session body","info",o);const{errors:s,json:r}=await l("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(P.isFetchingSession=!1,s.length||!r){const t=null===(e=s.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return p("Error occurred when creating checkout session",JSON.stringify(s,null,2)),!1}const i=r.checkoutSessionCreate;return me(i),ce({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),a("Exchange rate updated for cart items (checkout session create)","info",ne.exchangeRate),a("done-init-checkout-session"),!0},Q=async()=>{const t=o.checkoutSessionId;if(!t)return p("Failed to update checkout session base currency"),!1;if("LOCAL"===e.checkoutSettings.allowedSettlementCurrencies)return a('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await l("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:t,currencyCode:P.checkoutSettlementCurrency},method:"POST"}),s=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&s===P.checkoutSettlementCurrency?(a(`Updated checkout session to settlement currency "${s}".`),!0):(p("Failed to update checkout session base currency"),!1)},X=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:s,line2:r,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&s&&(o.line1={[e.line1]:s}),e.line2&&r&&(o.line2={[e.line2]:r}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},ee=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,s,r;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:s})=>{const r=!!(null==o?void 0:o.complete);if(!r||!(s?r:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=g({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=g({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),v=u&&m?`${u} ${m}`:"",p=i.address,h=null==a?void 0:a.address;return{address:A({address:Object.assign(Object.assign({},p),{name:c}),invalidAdddressList:e}),billingAddress:s?void 0:A({address:h?Object.assign(Object.assign({},h),{name:v}):null,invalidAdddressList:t}),destinationCountry:p.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:P.stripeAddressEventData,stripeBillingAddressEventData:P.stripeBillingAddressEventData,stripeShippingSameAsBilling:P.stripeShippingSameAsBilling});if(!i)return void(P.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const s=JSON.stringify(null===(e=P.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=P.stripeAddressEventData)||void 0===t?void 0:t.value),r=!P.stripeShippingSameAsBilling&&JSON.stringify(null===(o=P.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=P.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return s||r})();if(!a)return;const{errors:d,json:c}=await l("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!c)return p("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(P.translatedAddress={address:{},billingAddress:{}});P.stripeAddressUsedWhenValidatingAddress=P.stripeAddressEventData,P.stripeBillingAddressUsedWhenValidatingAddress=P.stripeBillingAddressEventData;const u=null===(o=P.stripeAddressEventData)||void 0===o?void 0:o.value.address,m=null===(n=P.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;P.translatedAddress={address:u?X({currentAddress:Object.assign(Object.assign({},u),{name:null===(s=P.stripeAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:c.address||null}):{},billingAddress:P.stripeShippingSameAsBilling?{}:X({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=P.stripeBillingAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:c.billingAddress||null})}};T("clientSecret",(e=>{e&&P.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:te,reset:oe,state:ne}=t((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:u(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),se=e=>{switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");default:return s("business days")}},re=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:se(o.type)}:null},ie=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),ae=e=>{a("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=ne.items.find((t=>ie({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return ne.restrictedItems=t,ne.items=ne.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>ie({item1:t,item2:e})))}))),{cartItems:ne.items,restrictedItems:t}},de=()=>{o.checkoutSessionId=null,oe()},le=({messages:e,title:t})=>{de(),_(),ne.step="error",ne.error={messages:e,title:t}},ce=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{ne.exchangeRate=o.exchangeRate,ne.adjustmentTotal=o.adjustments,ne.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,ne.subtotal=o.items,ne.total=o.total,ne.currency=o.presentmentCurrencyCode,ne.dutiesTaxesFeesEstimate=e||null},ue=()=>!!ne.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),me=e=>{var t,n,s,d,l;P.clientSecret=e.clientSecret,P.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,P.customerProfile=e.customerProfile,ne.checkoutSession=e,e.id||m({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:v,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const c=r(e.varianceTestResults||[]);i(c);const u=(null===(s=null===(n=null===(t=ne.checkoutSession)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===s?void 0:s.value)||(null===(l=null===(d=window.Zonos.cartData)||void 0===d?void 0:d.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===l?void 0:l.value)||null;u&&(a(`Found externalConfirmationPageURL: ${u}`),ne.externalConfirmationPageURL=u)},ve=async({adjustmentsAmount:e,cartId:t,currency:r,dutiesTaxesFeesEstimate:i,itemsAmount:d,landedCostId:c,shouldInitSessionOnFailure:u})=>{var m;if(c&&ne.selectedLandedCost&&(ce({dutiesTaxesFeesEstimate:i,method:ne.landedCostMethod,subtotals:ne.selectedLandedCost.subtotals}),a("Exchange rate updated for cart items (landed cost subtotal)","info",ne.exchangeRate)),!o.checkoutSessionId)return a("Could not update cart total without checkout session id","info"),!1;const{errors:v,json:h}=await(async({adjustmentsAmount:e,cartId:t,currency:s,id:r,itemsAmount:i,landedCostId:a,presentmentCountryCode:d})=>{const c=o.enabledVariantTestKeys||[],{errors:u,json:m}=await l("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:P.partyBillingId,cartId:t,currency:s,customerAuthenticationToken:ne.customerAuthenticationToken||void 0,id:r,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:P.partyShippingId,skipPaymentIntent:P.skipPaymentIntent,varianceTestInput:c},method:"POST"});return u.length||!m?(p("Error occurs when updating checkout session",JSON.stringify(u,null,2)),{errors:u,json:m}):{errors:[],json:m}})({adjustmentsAmount:e,billToPartyId:P.partyBillingId,cartId:t,currency:r,id:o.checkoutSessionId,itemsAmount:d,landedCostId:c,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:P.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(v.length>0||!h){if(p("Error occurs when updating checkout session."),u){a("Initiating checkout session on failure","info");const e=await Z();return a(`stripeStoreInitCheckoutSession: ${e}`),!!e||(le({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")}),!1)}return!1}return c||(ce({method:(null===(m=h.checkoutSessionUpdate.landedCost)||void 0===m?void 0:m.method)||"DDP",subtotals:h.checkoutSessionUpdate.subtotals}),a("Exchange rate updated for cart items (checkout session update)","info",ne.exchangeRate)),me(h.checkoutSessionUpdate),!0},pe=t=>{var o,n,s;return"DAP"===t.method&&(null===(n=null===(o=e.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(s=P.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US"))||"DAP"===t.method&&t.remittance.length&&"ZONOS"===t.landedCostGuaranteeCode?"DDP":t.method},he=async(t,n)=>{var s,r,i,d,l,c,u,m,v,p,h;ne.selectedShippingOption=t;const y=re(ne.selectedShippingOption);if(y){const{maxTransit:e,minTransit:t,unit:o}=y;ne.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else ne.selectedShippingOptionTransitTime="";const w=null===(s=ne.landedCostData)||void 0===s?void 0:s.find((e=>e.landedCostId===n));if(ne.selectedLandedCost=w||null,!w)return!1;const g=((null===(r=w.landedCost.amountSubtotals)||void 0===r?void 0:r.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&a(`DAP quote, using estimate: ${g}`,"info"),ne.landedCostMethod=pe(w.landedCost),ne.shipping=w.subtotals.shipping;const f="ZONOS"===(null===(i=null==w?void 0:w.landedCost)||void 0===i?void 0:i.landedCostGuaranteeCode),b=!!(null===(l=null===(d=null==w?void 0:w.landedCost)||void 0===d?void 0:d.deMinimis)||void 0===l?void 0:l.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));ne.isSelectedShippingAboveDeminimis=b,ne.isSelectedShippingGuarantee=f;const S=await ve({adjustmentsAmount:ne.adjustmentTotal,billToPartyId:P.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(c=w.landedCost)||void 0===c?void 0:c.id,shipToPartyId:P.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]}),C=null===(u=ne.items.find(Boolean))||void 0===u?void 0:u.currencyCode,O=(null===(m=P.stripeAddressEventData)||void 0===m?void 0:m.value.address.country)||"US";return P.shouldRenderPayInUsdButton="USD"===C&&"LOCAL_AND_USD"===e.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(v=ne.checkoutSession)||void 0===v?void 0:v.subtotals.presentmentCurrencyCode)&&!!(null===(h=null===(p=e.genericSettings)||void 0===p?void 0:p.usdSettlementCountryEnabled)||void 0===h?void 0:h.includes(O)),S},ye=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;a(`==START CHECKOUT TIMEOUT - ${n}==`),ne.checkoutTimeoutInterval=setTimeout((()=>{ne.checkoutSessionTimeoutShow=!0}),n)},we=()=>{ne.checkoutTimeoutInterval&&(clearTimeout(ne.checkoutTimeoutInterval),ne.checkoutTimeoutInterval=null)},ge=()=>{ne.items=ne.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),ne.restrictedItems=[]},fe=async({adjustments:e,cartItems:t})=>{var n;ne.adjustments=e,ne.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const s=null===(n=t.find(Boolean))||void 0===n?void 0:n.currencyCode,r=t.reduce(((e,t)=>e+t.amount*t.quantity),0),i=e.reduce(((e,t)=>e+t.amount),0);s&&r&&(ne.currency=s,P.isFetchingSession=!0,await ve({adjustmentsAmount:i,billToPartyId:P.partyBillingId,cartId:window.Zonos.cartId,currency:s,dutiesTaxesFeesEstimate:0,itemsAmount:r,shipToPartyId:P.partyShippingId,shouldInitSessionOnFailure:!0,varianceTestInput:o.enabledVariantTestKeys||[]}),P.isFetchingSession=!1)},be=()=>{"shipping"===ne.step?(ne.step="customer-info",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{"customer-info":Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!1})})):"payment"===ne.step?(ne.step="shipping",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{shipping:Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!1})})):"finish"===ne.step&&(ne.step="payment",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{payment:Object.assign(Object.assign({},ne.tabItems.payment),{isDone:!1})}))},Se=()=>{"customer-info"===ne.step?(ne.step="shipping",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{"customer-info":Object.assign(Object.assign({},ne.tabItems["customer-info"]),{isDone:!0})})):"shipping"===ne.step?(ne.step="payment",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{shipping:Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!0})})):"payment"===ne.step&&(ne.step="finish")},Ce=()=>{ne.step="customer-info",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{"customer-info":Object.assign(Object.assign({},ne.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},ne.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!1})}),ne.selectedShippingOption=null,ne.isSelectedShippingAboveDeminimis=!1,ne.isSelectedShippingGuarantee=!1,ne.selectedShippingOptionTransitTime="",ne.dutiesTaxesFees=0,ne.dutiesTaxesFeesEstimate=0,ne.shipping=0,ne.total=ne.subtotal};export{ue as A,J as B,$ as C,M as D,W as E,ee as F,g as G,te as H,U as I,he as J,re as K,pe as L,k as M,L as a,D as b,P as c,H as d,ne as e,fe as f,de as g,Ce as h,R as i,we as j,Z as k,V as l,ye as m,G as n,le as o,me as p,F as q,Se as r,x as s,O as t,Q as u,q as v,K as w,Y as x,_ as y,I as z}
1
+ import{z as e,c as t}from"./p-7ce093aa.js";import{s as o,l as n,t as s,f as r,b as i}from"./p-88f7256d.js";import{l as a,f as d,h as l,g as c,a as u,s as m,d as v,b as p,j as h}from"./p-a8a312b2.js";import{i as y}from"./p-56e0ed65.js";import{g as w}from"./p-2b9c124d.js";const g=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const s=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=s[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||s.slice(1).join(" ").trim()||""}},f=({currentAddress:e,translatedAddress:t})=>{var o,n,s,r,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:v}=e.value.address,p=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(s=t.line2)||void 0===s?void 0:s[u||""])||u||"",name:(null===(r=t.name)||void 0===r?void 0:r[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[v])||v}},b=e=>{var t;const n="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),s=P.stripeLinkEventData,r=P.stripeAddressEventData,i=P.stripeShippingSameAsBilling?P.stripeAddressEventData:P.stripeBillingAddressEventData;if(!r||!i)throw new Error("Missing stripe address data");const a=f({currentAddress:r,translatedAddress:P.translatedAddress.address}),{firstName:d,lastName:l}=g({name:a.name}),c=f({currentAddress:i,translatedAddress:P.translatedAddress.address}),{firstName:u,lastName:m}=g({name:c.name});return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:u,lastName:m,phone:c.phone},cartCurrencyCode:null===(t=ne.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:P.companyName,email:null==s?void 0:s.value.email,firstName:d,lastName:l,phone:a.phone},isTest:!!n,landedCostAdjustments:ne.promoCode?[{amount:0,productId:null,promoCode:ne.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:P.taxId,shippingAddress:{addressLine1:a.line1,addressLine2:a.line2,city:a.city,country:a.country,postalCode:a.postal_code,state:a.state}}},S=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=P.stripeLinkEventData,n=P.stripeAddressEventData,s=P.stripeShippingSameAsBilling?P.stripeAddressEventData:P.stripeBillingAddressEventData;if(a({stripeAddressData:n,stripeBillingAddressData:s},"info"),!n||!s)throw new Error("Missing stripe address data");const r=f({currentAddress:n,translatedAddress:P.translatedAddress.address}),{firstName:i,lastName:d}=g({name:r.name}),l=f({currentAddress:s,translatedAddress:P.translatedAddress.address}),{firstName:c,lastName:u}=g({name:l.name}),m=ne.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),v=ne.promoCode?[{amount:0,productId:null,promoCode:ne.promoCode,sku:null,type:"PROMO_CODE"},...m]:m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:P.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:d,phone:r.phone},isTest:e,items:ne.items,landedCostAdjustments:v,shipToTaxId:P.taxId,shippingAddress:{addressLine1:r.line1,addressLine2:r.line2,city:r.city,country:r.country,postalCode:r.postal_code,state:r.state}}};const C=async t=>{const o=window.Zonos.cartId;if(!o)return await(async t=>{var o;const n=e.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,s,r;const i=S(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:d.vercel});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(s=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===s?void 0:s.message)||"Unknown error"}`);const{errors:c,json:u}=await l("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!u||c.length)throw new Error(`Invalid landed cost object: ${(null===(r=c.find(Boolean))||void 0===r?void 0:r.message)||"Unknown error"}`);return a})(n);return e}const{errors:s,json:r}=await l("/api/zonos-elements/calculate-landed-cost",{body:S(),method:"POST",signal:null==t?void 0:t.signal});if(s.length||!r){if("The user aborted a request."===(null===(o=s[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(s.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!r)throw new Error("Failed to calculate landed cost");return r}return r})(t);const n=await(async({abortController:e,cartId:t})=>{var o,n,s,r,i;const{errors:a,json:d}=await l("/api/zonos-elements/cart-calculate-landed-cost",{body:b(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(s=a[0])||void 0===s?void 0:s.message.includes("signal is aborted"))||(null===(r=a[0])||void 0===r?void 0:r.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:t,cartId:o}),{cartWorkflow:s}=n,r=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},r),{itemCreateWorkflow:s.items})},O=async({checkoutSessionId:t,eventName:o,metadata:s})=>{var r,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:t,eventCreated:a,eventName:o});const p=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(r=window.Zonos)||void 0===r?void 0:r.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((c()||u()||p)&&!window.Zonos.zonosConversionTest)return;const h=n.selectedCountryCode,y=e.organizationId;if(!t)return void m({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:v,checkoutSessionId:t,eventName:o,metadata:s,organizationId:y,trackEventLogs:d}});y||m({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:v,checkoutSessionId:t,eventName:o,metadata:s,organizationId:y,trackEventLogs:d}});const w={checkoutSessionId:t,countryCode:h,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},s),{trackEventLogs:d}),organizationId:y};await l("/api/zonos-elements/track-conversion-event",{body:w,method:"POST"})},A=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},k=e=>e.sort(((e,t)=>e.amount-t.amount)),I=async()=>{var e;const{errors:t,json:n}=await(async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await l(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}})();return t.length||!n?(p("Failed to retrieve checkout session info before confirming payment ",t),m({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:v}}),{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=n.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(p("Landed cost is not found in the checkout session before confirming payment."),m({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:v}}),{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},N=({theme:t})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:e.appearance.fontSizeInputValue?`${e.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:e.appearance.fontSizeInputLabel?`${e.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===t?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},j=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:T,reset:E,state:P}=t((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),L=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},D=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},x=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return h(e)},R=async t=>{var o,s;const r=P.clientSecret;if(!P.stripe)return void a("Skip. Stripe is not initialized");const i=(({clientSecret:t,overrideBorderRadius:o,overridePrimaryColor:s,overrideSecondaryColor:r,overrideTheme:i,paypalEnabled:a})=>{const d=s||e.appearance.colorPrimary,l=r||e.appearance.colorSecondary,c=d&&y(d)?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},N({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},j({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||void 0,customerSessionClientSecret:P.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:r,overrideBorderRadius:null==t?void 0:t.overrideBorderRadius,overridePrimaryColor:null==t?void 0:t.overridePrimaryColor,overrideSecondaryColor:null==t?void 0:t.overrideSecondaryColor,overrideTheme:null==t?void 0:t.overrideTheme,paypalEnabled:null==t?void 0:t.paypalEnabled}),d=JSON.stringify(i)===JSON.stringify(P.stripeElementsOptions);if(!P.stripeElements||!P.stripeElementsForBillingAddress)return P.stripeElements=null===(o=P.stripe)||void 0===o?void 0:o.elements(i),P.stripeElementsOptions=i,a("Stripe elements initialized"),P.stripeElementsForBillingAddress=null===(s=P.stripe)||void 0===s?void 0:s.elements(i),void a("Stripe elements for billing address initialized");d||(P.stripeElements.update(i),P.stripeElementsForBillingAddress.update(i),P.stripeElementsOptions=i,P.stripeElements.fetchUpdates()),a("Stripe elements updated")},_=()=>{sessionStorage.removeItem("zonos--client-secret"),E(),P.stripe=window.Zonos.stripe},z=({address:e,firstName:t,lastName:n,name:s,phone:r})=>{const{firstName:i,lastName:a}=g({firstName:t,lastName:n,name:s});return i&&a||m({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:s}}),r||m({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:r}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:r||"",postal_code:e.postal_code,state:e.state}},U=async()=>{var e,t,n,s;if(!(null===(e=P.stripeAddressEventData)||void 0===e?void 0:e.complete)||!P.stripeShippingSameAsBilling&&!(null===(t=P.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!P.stripeBillingAddressEventData)return{partiesCreated:!1};if(!ne.landedCostData)return{partiesCreated:!1};const r=null===(n=ne.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!r)return m({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,s,r;const i=JSON.stringify(null===(e=P.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=P.stripeLinkEventData)||void 0===t?void 0:t.value),a=JSON.stringify(null===(o=P.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=P.stripeAddressEventData)||void 0===n?void 0:n.value),d=!P.stripeShippingSameAsBilling&&JSON.stringify(null===(s=P.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===s?void 0:s.value)!==JSON.stringify(null===(r=P.stripeBillingAddressEventData)||void 0===r?void 0:r.value);return i||a||d||P.taxIdUsedWhenAsyncAddressUpdate!==P.taxId||P.companyNameUsedWhenAsyncAddressUpdate!==P.companyName})();if(!i)return{partiesCreated:!1};const a=z({address:P.stripeAddressEventData.value.address,firstName:P.stripeAddressEventData.value.firstName,lastName:P.stripeAddressEventData.value.lastName,name:P.stripeAddressEventData.value.name,phone:P.stripeAddressEventData.value.phone}),d=P.stripeShippingSameAsBilling?a:z({address:P.stripeBillingAddressEventData.value.address,firstName:P.stripeBillingAddressEventData.value.firstName,lastName:P.stripeBillingAddressEventData.value.lastName,name:P.stripeBillingAddressEventData.value.name,phone:P.stripeBillingAddressEventData.value.phone}),c="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:u,json:h}=await l("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:P.companyName,email:(null===(s=P.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"",isTest:c,rootId:r,taxId:P.taxId},method:"POST"});return u.length||!h?(p("Error occurs when creating parties",JSON.stringify(u,null,2)),m({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:u,json:h}}),{partiesCreated:!1}):(P.companyNameUsedWhenAsyncAddressUpdate=P.companyName,P.stripeAddressUsedWhenAsyncAddressUpdate=P.stripeAddressEventData,P.stripeBillingAddressUsedWhenAsyncAddressUpdate=P.stripeBillingAddressEventData,P.taxIdUsedWhenAsyncAddressUpdate=P.taxId,P.partyBillingId=h.billToPartyId,P.partyShippingId=h.shipToPartyId,{partiesCreated:!0})},B=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),F=async t=>{var n,s,r,i;const d=(null==t?void 0:t.retries)||0,l=!!(null==t?void 0:t.applyingPromocode),c=(()=>{var e;const t=ne.landedCostData&&(null===(e=ne.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==ne.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=P.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=P.stripeLinkEventData)||void 0===t?void 0:t.value),n=P.stripeAddressEventData&&JSON.stringify(B(P.stripeAddressEventData.value))!==JSON.stringify(P.stripeAddressUsedWhenFetchingLC),s=!P.stripeShippingSameAsBilling&&P.stripeBillingAddressEventData&&JSON.stringify(B(P.stripeBillingAddressEventData.value))!==JSON.stringify(P.stripeBillingAddressUsedWhenFetchingLC);return o||n||s})();return a("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!ne.landedCostData&&!P.isFetchingLandedCost||o||t})();if(!(()=>{var t,o,n,s;const r=!!(null===(t=P.stripeLinkEventData)||void 0===t?void 0:t.complete),i=!!(null===(o=P.stripeAddressEventData)||void 0===o?void 0:o.complete),a=P.stripeShippingSameAsBilling?i:!!(null===(n=P.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(t=>{var o,n;const s=null===(o=e.genericSettings)||void 0===o?void 0:o.countryFields,r=null===(n=e.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===ne.addressFormRenderType&&(r&&t in r?r[t]:null)||(s&&t in s?s[t]:null)})((null===(s=P.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US");return!!(i&&a&&r)||(d&&P.stripeAddressEventData?r&&P.stripeAddressEventData.value.firstName&&P.stripeAddressEventData.value.lastName&&P.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&P.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&P.stripeAddressEventData.value.address.postal_code.length>=3)&&P.stripeAddressEventData.value.phone&&P.stripeAddressEventData.value.phone.length>0:i&&a&&r)})())return{isRequestNotReady:!0};if(c&&(null===(n=P.fetchingLandedCostAbortController)||void 0===n||n.abort(),P.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};d?(P.isFetchingLandedCost=!1,setTimeout((()=>{P.isFetchingLandedCost=!0}),300)):P.isFetchingLandedCost=!0,P.stripeAddressEventData&&(P.stripeAddressUsedWhenFetchingLC={countryCode:P.stripeAddressEventData.value.address.country,postalCode:P.stripeAddressEventData.value.address.postal_code,state:P.stripeAddressEventData.value.address.state}),P.stripeBillingAddressEventData&&(P.stripeBillingAddressUsedWhenFetchingLC={countryCode:P.stripeBillingAddressEventData.value.address.country,postalCode:P.stripeBillingAddressEventData.value.address.postal_code,state:P.stripeBillingAddressEventData.value.address.state}),P.stripeLinkEventData&&(P.stripeLinkUsedWhenFetchingLC=Object.assign({},P.stripeLinkEventData));try{ge(),await(async()=>{var e;const t=new AbortController;P.fetchingLandedCostAbortController=t,ge();const{checkoutSessionWorkflow:n,errors:s,itemCreateWorkflow:r,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await C(t);ne.customQuotingError=(null===(e=null==s?void 0:s.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,ne.shippingData=k((null==d?void 0:d.filter(Boolean))||[]),ae(r),P.fetchingLandedCostAbortController=null,ne.partiesData=(null==a?void 0:a.filter(Boolean))||[],ne.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&O({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=ne.promoCodeApplied&&!ne.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));ne.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",ne.promoCode)})();const e=null===(s=ne.shippingData)||void 0===s?void 0:s.find(Boolean),t=null===(r=ne.landedCostData)||void 0===r?void 0:r.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ce({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(e){if(ne.landedCostData=[],ne.shippingData=[],e instanceof Error&&e.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(e.message)){if(d<1)return await F(Object.assign(Object.assign({},t),{retries:(d||0)+1})),{isRequestNotReady:!1};const o=null===(i=P.stripeAddressEventData)||void 0===i?void 0:i.value;m({endpoint:`Failed to fetch landed cost (${d} retries)`,errors:[e.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}p(e)}return P.isFetchingLandedCost=!1,{isRequestNotReady:!1}},J=async()=>{var e,t;await F({applyingPromocode:!0}),"payment"===ne.step&&be(),await U();const o=null===(e=ne.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=ne.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await he(o,n.landedCostId)},M=()=>{ne.promoCode="",sessionStorage.removeItem("zonos--promo-code"),ne.promoCodeError=!1,ne.promoCodeApplied=!1},$=async()=>{"payment"===ne.step&&be(),M(),await J()},W=e=>{let t=[],o=!0;switch(e){case"succeeded":t=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")],o=!1;break;case"requires_capture":case"processing":t=[s("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[s("Payment failed. Please try another payment method.")];break;case"requires_action":o=!1,t=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[s("Something went wrong.")]}return{isError:o,messages:t}},q=async()=>{var t,o;const{onInventoryCheck:n}=e.checkoutSettings,r=!!(null===(o=null===(t=window.Zonos.cartData)||void 0===t?void 0:t.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&r){const{errors:e,json:t}=await l("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(p("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(P.shouldInventoryRefund=!0,null):null:s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")}if("function"!=typeof n)return null;try{return await n({items:ne.items})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw m({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:ne.items}}),e}},Y=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await l("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},H=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=W(t);return{error:e,messages:o}}const o=e||P.clientSecret;if(!P.stripe||!o)return p("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[s("Something went wrong.")]};const{paymentIntent:n}=await P.stripe.retrievePaymentIntent(o),r=null==n?void 0:n.status,{isError:i,messages:a}=W(r);return{error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:r}},K=async()=>{var e,t;const n=!!(null===(e=P.stripePaymentEventData)||void 0===e?void 0:e.complete),r=P.stripeElements,i=P.stripe,d=P.clientSecret;if(P.customErrorMessage=null,!(null===(t=ne.selectedLandedCost)||void 0===t?void 0:t.landedCost.id))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const l=await I();if(!l.valid)throw P.customErrorMessage=l.errorMessage,new Error(l.errorMessage);const c=o.checkoutSessionId;if(i&&r&&n&&d&&c){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",d),e.searchParams.set("zonosCheckoutSessionId",c),O({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await i.confirmPayment({confirmParams:{return_url:e.toString()},elements:r,redirect:"if_required"});if(a("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."));if(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(s("Payment failed. Please try another payment method."))}},G=()=>{var e;const t=ne.items.reduce(((e,t)=>e+t.amount*t.quantity),0),s=o.enabledVariantTestKeys||[];return{adjustmentsAmount:ne.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=ne.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:ne.customerAuthenticationToken||void 0,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:P.skipPaymentIntent,varianceTestInput:s}},V=async()=>{var e;if(!o.checkoutSessionId)return m({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:v,cartId:window.Zonos.cartId}}),void le({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});const{errors:t,json:n}=await l("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),r=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!r)return p("Error occurs when getting payment intent",JSON.stringify(t,null,2)),m({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:v,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:r}}),void le({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});me(n.checkoutSessionPaymentIntentCreate)},Z=async()=>{var e,t;if(!n.targetCurrency)return p("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;P.isFetchingSession=!0;const o=G();a("Checkout session body","info",o);const{errors:s,json:r}=await l("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(P.isFetchingSession=!1,s.length||!r){const t=null===(e=s.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return p("Error occurred when creating checkout session",JSON.stringify(s,null,2)),!1}const i=r.checkoutSessionCreate;return me(i),ce({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),a("Exchange rate updated for cart items (checkout session create)","info",ne.exchangeRate),a("done-init-checkout-session"),!0},Q=async()=>{const t=o.checkoutSessionId;if(!t)return p("Failed to update checkout session base currency"),!1;if("LOCAL"===e.checkoutSettings.allowedSettlementCurrencies)return a('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await l("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:t,currencyCode:P.checkoutSettlementCurrency},method:"POST"}),s=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&s===P.checkoutSettlementCurrency?(a(`Updated checkout session to settlement currency "${s}".`),!0):(p("Failed to update checkout session base currency"),!1)},X=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:s,line2:r,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&s&&(o.line1={[e.line1]:s}),e.line2&&r&&(o.line2={[e.line2]:r}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},ee=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,s,r;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:s})=>{const r=!!(null==o?void 0:o.complete);if(!r||!(s?r:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=g({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=g({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),v=u&&m?`${u} ${m}`:"",p=i.address,h=null==a?void 0:a.address;return{address:A({address:Object.assign(Object.assign({},p),{name:c}),invalidAdddressList:e}),billingAddress:s?void 0:A({address:h?Object.assign(Object.assign({},h),{name:v}):null,invalidAdddressList:t}),destinationCountry:p.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:P.stripeAddressEventData,stripeBillingAddressEventData:P.stripeBillingAddressEventData,stripeShippingSameAsBilling:P.stripeShippingSameAsBilling});if(!i)return void(P.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const s=JSON.stringify(null===(e=P.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=P.stripeAddressEventData)||void 0===t?void 0:t.value),r=!P.stripeShippingSameAsBilling&&JSON.stringify(null===(o=P.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=P.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return s||r})();if(!a)return;const{errors:d,json:c}=await l("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!c)return p("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(P.translatedAddress={address:{},billingAddress:{}});P.stripeAddressUsedWhenValidatingAddress=P.stripeAddressEventData,P.stripeBillingAddressUsedWhenValidatingAddress=P.stripeBillingAddressEventData;const u=null===(o=P.stripeAddressEventData)||void 0===o?void 0:o.value.address,m=null===(n=P.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;P.translatedAddress={address:u?X({currentAddress:Object.assign(Object.assign({},u),{name:null===(s=P.stripeAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:c.address||null}):{},billingAddress:P.stripeShippingSameAsBilling?{}:X({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=P.stripeBillingAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:c.billingAddress||null})}};T("clientSecret",(e=>{e&&P.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:te,reset:oe,state:ne}=t((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:u(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),se=e=>{switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");default:return s("business days")}},re=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:se(o.type)}:null},ie=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),ae=e=>{a("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=ne.items.find((t=>ie({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return ne.restrictedItems=t,ne.items=ne.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>ie({item1:t,item2:e})))}))),{cartItems:ne.items,restrictedItems:t}},de=()=>{o.checkoutSessionId=null,oe()},le=({messages:e,title:t})=>{de(),_(),ne.step="error",ne.error={messages:e,title:t}},ce=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{ne.exchangeRate=o.exchangeRate,ne.adjustmentTotal=o.adjustments,ne.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,ne.subtotal=o.items,ne.total=o.total,ne.currency=o.presentmentCurrencyCode,ne.dutiesTaxesFeesEstimate=e||null},ue=()=>!!ne.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),me=e=>{var t,n,s,d,l;P.clientSecret=e.clientSecret,P.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,P.customerProfile=e.customerProfile,ne.checkoutSession=e,e.id||m({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:v,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const c=r(e.varianceTestResults||[]);i(c);const u=(null===(s=null===(n=null===(t=ne.checkoutSession)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===s?void 0:s.value)||(null===(l=null===(d=window.Zonos.cartData)||void 0===d?void 0:d.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===l?void 0:l.value)||null;u&&(a(`Found externalConfirmationPageURL: ${u}`),ne.externalConfirmationPageURL=u)},ve=async({adjustmentsAmount:e,cartId:t,currency:r,dutiesTaxesFeesEstimate:i,itemsAmount:d,landedCostId:c,shouldInitSessionOnFailure:u})=>{var m;if(c&&ne.selectedLandedCost&&(ce({dutiesTaxesFeesEstimate:i,method:ne.landedCostMethod,subtotals:ne.selectedLandedCost.subtotals}),a("Exchange rate updated for cart items (landed cost subtotal)","info",ne.exchangeRate)),!o.checkoutSessionId)return a("Could not update cart total without checkout session id","info"),!1;const{errors:v,json:h}=await(async({adjustmentsAmount:e,cartId:t,currency:s,id:r,itemsAmount:i,landedCostId:a,presentmentCountryCode:d})=>{const c=o.enabledVariantTestKeys||[],{errors:u,json:m}=await l("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:P.partyBillingId,cartId:t,currency:s,customerAuthenticationToken:ne.customerAuthenticationToken||void 0,id:r,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:P.partyShippingId,skipPaymentIntent:P.skipPaymentIntent,varianceTestInput:c},method:"POST"});return u.length||!m?(p("Error occurs when updating checkout session",JSON.stringify(u,null,2)),{errors:u,json:m}):{errors:[],json:m}})({adjustmentsAmount:e,billToPartyId:P.partyBillingId,cartId:t,currency:r,id:o.checkoutSessionId,itemsAmount:d,landedCostId:c,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:P.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(v.length>0||!h){if(p("Error occurs when updating checkout session."),u){a("Initiating checkout session on failure","info");const e=await Z();return a(`stripeStoreInitCheckoutSession: ${e}`),!!e||(le({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")}),!1)}return!1}return c||(ce({method:(null===(m=h.checkoutSessionUpdate.landedCost)||void 0===m?void 0:m.method)||"DDP",subtotals:h.checkoutSessionUpdate.subtotals}),a("Exchange rate updated for cart items (checkout session update)","info",ne.exchangeRate)),me(h.checkoutSessionUpdate),!0},pe=t=>{var o,n,s;return"DAP"===t.method&&(null===(n=null===(o=e.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(s=P.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US"))||"DAP"===t.method&&t.remittance.length&&"ZONOS"===t.landedCostGuaranteeCode?"DDP":t.method},he=async(t,n)=>{var s,r,i,d,l,c,u,m,v,p,h;ne.selectedShippingOption=t;const y=re(ne.selectedShippingOption);if(y){const{maxTransit:e,minTransit:t,unit:o}=y;ne.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else ne.selectedShippingOptionTransitTime="";const w=null===(s=ne.landedCostData)||void 0===s?void 0:s.find((e=>e.landedCostId===n));if(ne.selectedLandedCost=w||null,!w)return!1;const g=((null===(r=w.landedCost.amountSubtotals)||void 0===r?void 0:r.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&a(`DAP quote, using estimate: ${g}`,"info"),ne.landedCostMethod=pe(w.landedCost),ne.shipping=w.subtotals.shipping;const f="ZONOS"===(null===(i=null==w?void 0:w.landedCost)||void 0===i?void 0:i.landedCostGuaranteeCode),b=!!(null===(l=null===(d=null==w?void 0:w.landedCost)||void 0===d?void 0:d.deMinimis)||void 0===l?void 0:l.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));ne.isSelectedShippingAboveDeminimis=b,ne.isSelectedShippingGuarantee=f;const S=await ve({adjustmentsAmount:ne.adjustmentTotal,billToPartyId:P.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(c=w.landedCost)||void 0===c?void 0:c.id,shipToPartyId:P.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]}),C=null===(u=ne.items.find(Boolean))||void 0===u?void 0:u.currencyCode,O=(null===(m=P.stripeAddressEventData)||void 0===m?void 0:m.value.address.country)||"US";return P.shouldRenderPayInUsdButton="USD"===C&&"LOCAL_AND_USD"===e.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(v=ne.checkoutSession)||void 0===v?void 0:v.subtotals.presentmentCurrencyCode)&&!!(null===(h=null===(p=e.genericSettings)||void 0===p?void 0:p.usdSettlementCountryEnabled)||void 0===h?void 0:h.includes(O)),S},ye=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;a(`==START CHECKOUT TIMEOUT - ${n}==`),ne.checkoutTimeoutInterval=setTimeout((()=>{ne.checkoutSessionTimeoutShow=!0}),n)},we=()=>{ne.checkoutTimeoutInterval&&(clearTimeout(ne.checkoutTimeoutInterval),ne.checkoutTimeoutInterval=null)},ge=()=>{ne.items=ne.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),ne.restrictedItems=[]},fe=async({adjustments:e,cartItems:t})=>{var n;ne.adjustments=e,ne.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const s=null===(n=t.find(Boolean))||void 0===n?void 0:n.currencyCode,r=t.reduce(((e,t)=>e+t.amount*t.quantity),0),i=e.reduce(((e,t)=>e+t.amount),0);s&&r&&(ne.currency=s,P.isFetchingSession=!0,await ve({adjustmentsAmount:i,billToPartyId:P.partyBillingId,cartId:window.Zonos.cartId,currency:s,dutiesTaxesFeesEstimate:0,itemsAmount:r,shipToPartyId:P.partyShippingId,shouldInitSessionOnFailure:!0,varianceTestInput:o.enabledVariantTestKeys||[]}),P.isFetchingSession=!1)},be=()=>{"shipping"===ne.step?(ne.step="customer-info",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{"customer-info":Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!1})})):"payment"===ne.step?(ne.step="shipping",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{shipping:Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!1})})):"finish"===ne.step&&(ne.step="payment",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{payment:Object.assign(Object.assign({},ne.tabItems.payment),{isDone:!1})}))},Se=()=>{"customer-info"===ne.step?(ne.step="shipping",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{"customer-info":Object.assign(Object.assign({},ne.tabItems["customer-info"]),{isDone:!0})})):"shipping"===ne.step?(ne.step="payment",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{shipping:Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!0})})):"payment"===ne.step&&(ne.step="finish")},Ce=()=>{ne.step="customer-info",ne.tabItems=Object.assign(Object.assign({},ne.tabItems),{"customer-info":Object.assign(Object.assign({},ne.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},ne.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},ne.tabItems.shipping),{isDone:!1})}),ne.selectedShippingOption=null,ne.isSelectedShippingAboveDeminimis=!1,ne.isSelectedShippingGuarantee=!1,ne.selectedShippingOptionTransitTime="",ne.dutiesTaxesFees=0,ne.dutiesTaxesFeesEstimate=0,ne.shipping=0,ne.total=ne.subtotal};export{ue as A,J as B,$ as C,M as D,W as E,ee as F,g as G,te as H,U as I,he as J,re as K,pe as L,k as M,L as a,D as b,P as c,H as d,ne as e,fe as f,de as g,Ce as h,R as i,we as j,Z as k,V as l,ye as m,G as n,le as o,me as p,F as q,Se as r,x as s,O as t,Q as u,q as v,K as w,Y as x,_ as y,I as z}
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function u(e){try{s(r.next(e))}catch(e){i(e)}}function a(e){try{s(r["throw"](e))}catch(e){i(e)}}function s(e){e.done?t(e.value):o(e.value).then(u,a)}s((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(n){return s([e,n])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=n.call(e,t)}catch(e){a=[6,e];o=0}finally{r=i=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,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-bf37ccc7.system.js","./p-4160bbc2.system.js","./p-56a2d942.system.js","./p-40a4c8a2.system.js","./p-5a2dd041.system.js","./p-2b8345d8.system.js"],(function(e){"use strict";var n,t,r,o,i,u,a,s,c,d,l,f;return{setters:[function(e){n=e.c},function(e){t=e.g;r=e.I},function(e){o=e.g;i=e.a;u=e.l;a=e.h;s=e.b},function(n){c=n.g;d=n._;l=n.c;f=n.a;var t={};t.checkoutHiddenBtnSelector=n.c;t.checkoutHiddenInternationalBtnSelector=n.a;t.domesticRedirectedBtnSelector=n.d;e(t)},function(n){e("availableTestKeys",n.a)},function(n){var t={};t.countryRequireTaxId=n.c;t.euCountryCodes=n.e;t.shipToTaxIdLabels=n.s;e(t)}],execute:function(){var v=this;var m=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(n).origin;var i=t.some((function(e){return o.includes(e)}));var u=r.some((function(e){return o.includes(e)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var w=["jsdelivr","cdnjs","unpkg","vercel"];var p="jsdelivr";var h=function(e){var n=w.indexOf(e);var t=w[n+1];return t||null};var y=function(){return __awaiter(v,void 0,void 0,(function(){var e,n,t,r,c,d;return __generator(this,(function(l){switch(l.label){case 0:e=o();n=i();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}u("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){u("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,a("/api/get-test-public-credential")];case 1:t=l.sent(),r=t.errors,c=t.json;if(r.length||!c){s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2,null]}d=c.publicCredential;if(!d){s("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}u("[ZONOS - loadZonos] Retrieve new test public token ".concat(d),"info");return[2,d]}}))}))};var O=function(e){if(!e){return null}var n=new URL(e).searchParams;var t=n.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var g=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=O(window.location.href);var t="https://v1.3.216.js.zonos.com";if(!n&&(t.includes("test.")||t.includes("test-"))){return t}if(!n&&["dev.demo.elements.zonos.com","dev.checkout.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 r="preview.js.zonos.com";var o="https://".concat(n,".").concat(r);u("[ZONOS-WARNING] using '".concat(o,"' for loading elements script"),"warn");void fetch(o).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(o,"' 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 t="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return o};var S="https://js.stripe.com/v3";var _=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var b="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var z=function(){var e=document.querySelectorAll('script[src^="'.concat(S,'"]'));for(var n=0;n<e.length;n++){var t=e[n];if(!t){continue}if(!_.test(t.src)){continue}return t}return null};var j=null;var k=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var t=document.createElement("script");t.src="".concat(S).concat(n);var r=document.head||document.body;if(!r){s("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(t);return t};var N=function(e){if(j!==null){return j}j=new Promise((function(n,t){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(b)}if(window.Stripe){n(window.Stripe);return}try{var r=z();if(r&&e){console.warn(b)}else if(!r){r=k(e)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(e){t(e);return}}));return j};var A=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var I=function(e,n,t){if(e===null){return null}var r=e.apply(undefined,n);A(r,t);return r};var Z=Promise.resolve().then((function(){return N(null)}));var T=false;Z.catch((function(e){if(!T){console.warn(e)}}));var R=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(v,void 0,void 0,(function(){var n;return __generator(this,(function(t){T=true;n=Date.now();return[2,Z.then((function(t){return I(t,e,n)}))]}))}))};var E="tempCartUUID";var U=function(){var e=new URLSearchParams(window.location.search);var n=e.get(E);return n};var L=function(e){return __awaiter(v,[e],void 0,(function(e){var n,r,i,s,d,l,f,v,m;var w=e.cartId,p=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=o();r=t();i=c()||undefined;s=new URLSearchParams;if(r.overrideShouldEnabledCustomAddress){s.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress)}return[4,a("/api/zonos-elements/get-cart?".concat(s.toString()),{body:{isTestMode:n,renewCartExpirationToken:i,tempCartUUID:w},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:d=e.sent(),l=d.errors,f=d.json,v=d.zonosMode;m=!f||l.length;if(!(m&&p))return[3,3];u("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:p});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,L({cartId:w,retries:p-1})];case 3:if(m){return[2,null]}return[2,Object.assign(Object.assign({},f),{zonosMode:v})]}}))}))};var P=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:n=d(e),t=n.isDgsCartId,r=n.isLegacyCartId;if(!r&&!t){s("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,L({cartId:e,retries:5})];case 1:o=i.sent();u("[ZONOS - loadZonos] getting temp cart data","info",o);if(!o){s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=o.cartData.storeId;window.Zonos.zonosApiKey=o.cartData.credentialToken;window.Zonos.zonosMode=o.zonosMode;return[2,{cartData:o.cartData,settings:o.settings,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}]}}))}))};var C;var F=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=m({loadScriptSrc:e===null||e===void 0?void 0:e.src}),t=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return t}return null}();var D="https://v1.3.216.js.zonos.com";var M=F||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.216";var x="https://unpkg.com/@zonos/elements@1.3.216";var G="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.216";var K="https://fonts.googleapis.com";var B=/^https:\/\/fonts\.googleapis\.com/;var V=function(){function e(){}return e}();e("Zonos",V);C=V;V.doneInit=false;V.cartSettings=null;V.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);V.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);V._paypalMockResponse=null;V.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;V.isBigCommerce=false;V.releaseDate="1749769356368";V.isLegacyCheckout=false;V.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";V.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");V.overrideUseCustomAddressForm=false;V.isNpm=true;V.zonosQaUrl=null;V.zonosQaUrlApi=null;V.trackEventLogs=[];V.version="v".concat("1.3.216");V.modeAlerted=false;V.cartData=null;V.paypal=null;V.zonosMode=null;V.IframeService=r;V.getCurrentTimestamp=function(){return(new Date).getTime()};V.zonosController=null;V.loadTimeApiInfoList=[];V.logIntervalId=null;V.init=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,o,i,a,c,d,f,v,m,w,p,h,O;return __generator(this,(function(S){switch(S.label){case 0:n=e.appearance,t=e.checkoutSettings,r=e.currencyConverter,o=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,c=e.storeId,d=e.zonosApiKey;C.cartId=U();if(C.doneInit){return[2]}u("====== ZONOS DEBUG MODE: on (".concat(C.version,") ======"));C.zonosApiKey=d;C.storeId=c;if(!C.isNpm)return[3,4];u("====== ZONOS LOADING FROM NPM ======");f=g();if(f&&!window.isZonosPreview){u('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(f," ======"),"info");v=document.createElement("script");v.src="".concat(f,"/dist/scripts/zonos.js");document.head.appendChild(v);v.addEventListener("load",(function(){window.Zonos.isNpm=C.isNpm;window.Zonos.isBigCommerce=C.isBigCommerce;window.Zonos.isLegacyCheckout=C.isLegacyCheckout;void window.Zonos.init(e)}));v.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(f))}));window.isZonosPreview=true;return[2]}if(!d&&!C.cartId){s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!C.cartData&&C.cartId))return[3,2];u("Initialize cart data");return[4,P(C.cartId)];case 1:m=S.sent();if(!m){s("Failed to get cart data");return[2]}C.cartData=m.cartData;C.zonosApiKey=m.zonosApiKey;C.cartSettings=m.settings;S.label=2;case 2:return[4,y()];case 3:w=S.sent();if(w){C.zonosApiKey=w}S.label=4;case 4:p=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");h=C.cartId&&C.cartData||!!p;if(h){u("Cart data or stripe client secret is available, inject hidden button and trigger checkout");O=document.createElement("button");O.style.display="none";O.id="".concat(l);document.body.appendChild(O)}u("init zonos");C.restoreNativeBrowserFunctions();C.injectCustomScriptForHostedCheckout();C.injectZonosCdn();C.injectZonosCss();C.injectFonts();C.injectCheckoutInternationalButton();C.injectController({config:{appearance:n,checkoutSettings:t,currencyConverter:r,helloSettings:o,onCountryChange:i,overrideCurrencyFormat:a}});C.doneInit=true;return[2]}}))}))};V.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(f))){var e=document.createElement("button");e.id=f;e.style.display="none";document.body.appendChild(e)}};V.injectCustomScriptForHostedCheckout=function(){var e=C.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var t=n.find((function(e){return e.key==="customHeaderScript"}));var r=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!t&&!r){u("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(t){u("Injecting custom header script");var o=document.createElement("script");o.textContent=t.value;document.head.appendChild(o)}if(r){u("Injecting custom footer script");var o=document.createElement("script");o.textContent=r.value;document.body.appendChild(o)}};V.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};V.triggerCheckoutInternational=function(){return __awaiter(v,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=document.querySelector("#".concat(f));setTimeout((function(){if(e){e.dispatchEvent(n("click"))}}),10);return[2]}))}))};V.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};V.showNotification=function(e){var n;void((n=C.zonosController)===null||n===void 0?void 0:n.showNotification(e))};V.updateOrganizationName=function(e){var n;void((n=C.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};V.disablePlaceOrderButtons=function(e){var n=e.autoEnable,t=n===void 0?true:n,r=e.config,o=e.disable,i=e.placeOrderButtonSelector;var u;if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}if(i){var a=document.querySelectorAll(i);var s=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};a.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(o){e.setAttribute("disabled","true");e.addEventListener("click",s)}else{e.removeAttribute("disabled");e.removeEventListener("click",s)}}));if(t&&o){setTimeout((function(){a.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",s)}))}),5e3)}}};V.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var t="zonos---native-browser";var r=document.querySelector("iframe#".concat(t));if(!r){r=document.createElement("iframe");r.id=t;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}var o=((e=r.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=o;document.body.removeChild(r)};V.injectController=function(e){var n=e.config;var t,r;if(document.querySelector("zonos-controller")){return}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.placeOrderButtonSelector){var o=n.checkoutSettings.placeOrderButtonSelector;C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:o});var i=new MutationObserver((function(){C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:o})}));i.observe(document.body,{childList:true,subtree:true})}if((r=n.checkoutSettings)===null||r===void 0?void 0:r.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=n;c.zonosApiKey=C.zonosApiKey||"";c.addEventListener("stripeInitEvent",(function(e){return __awaiter(v,void 0,void 0,(function(){var n,t;return __generator(this,(function(r){switch(r.label){case 0:n=e.detail;u("loading Stripe");return[4,R(n.publishableKey)];case 1:t=r.sent();if(!t){s("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=t;void c.initCheckoutElement(t);return[2]}}))}))}));document.body.appendChild(c);C.zonosController=c;u("Zonos controller injected!")};V.injectScript=function(e){var n=e.cdnType,t=e.isModule,r=e.theRestUrl;var o=C.getZonosUrl(n);var i="".concat(o,"/").concat(r);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){u('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var c=document.head||document.body;var d=document.createElement("script");if(!!t){d.type="module"}else{d.noModule=true}d.src=i;d.crossOrigin="anonymous";d.onerror=function(){s("Failed to load ".concat(d.src));var e=h(n);if(!e){return}C.injectScript({cdnType:e,isModule:t,theRestUrl:r})};c.appendChild(d)};V.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return M;case"unpkg":return x;case"cdnjs":return G;case"vercel":return D}};if(C.isNpm){var t=g();return t||n()}return n()};V.injectZonosCdn=function(){C.injectScript({cdnType:p,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});C.injectScript({cdnType:p,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});u("Zonos cdn script injected!")};V.injectStylesheet=function(e){var n=e.cdnType,t=e.theRestUrl;var r=C.getZonosUrl(n);var o=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(D,"/");o.appendChild(i);var u=document.createElement("link");u.rel="stylesheet";u.href="".concat(r,"/").concat(t);u.onerror=function(){s("Failed to load ".concat(u.href));var e=h(n);if(!e){return}C.injectStylesheet({cdnType:e,theRestUrl:t})};o.appendChild(u)};V.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){u("Zonos style links already injected","warn");return}C.injectStylesheet({cdnType:p,theRestUrl:"dist/zonos-elements/zonos-elements.css"});u("Zonos style css injected!")};V.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){u("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(K,'"]'));for(var t=0;t<n.length;t++){var r=n[t];if(!r){continue}if(B.test(r.href)){continue}return r}return null};if(e()){u("Inter font already injected","warn");return}var n=document.head||document.body;var t=document.createElement("link");t.rel="preconnect";t.href=K;n.appendChild(t);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(K,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(r);u("Zonos font injected!")};V.setupGoogleFont=function(e){var n;void((n=C.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};V.injectSupportGoogleFont=function(e){var n;u("[FONT] injecting ".concat(e));var t=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(K,'"]'))){var o=document.createElement("link");o.rel="preconnect";o.href=K;r.appendChild(o)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){u("[FONT] ".concat(t," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;r.appendChild(i);u("[FONT] ".concat(t," font injected!"))};var W=e("checkoutSessionMutableAttributeKeys",["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"]);var q=e("checkoutSessionImmutableAttributeKeys",["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"]);var H=e("checkoutSessionAttributeKeys",__spreadArray(__spreadArray([],W,true),q,true))}}}));
1
+ var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function u(e){try{s(r.next(e))}catch(e){i(e)}}function a(e){try{s(r["throw"](e))}catch(e){i(e)}}function s(e){e.done?t(e.value):o(e.value).then(u,a)}s((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(n){return s([e,n])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=n.call(e,t)}catch(e){a=[6,e];o=0}finally{r=i=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,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-bf37ccc7.system.js","./p-4160bbc2.system.js","./p-062430f9.system.js","./p-40a4c8a2.system.js","./p-5a2dd041.system.js","./p-2b8345d8.system.js"],(function(e){"use strict";var n,t,r,o,i,u,a,s,c,d,l,f;return{setters:[function(e){n=e.c},function(e){t=e.g;r=e.I},function(e){o=e.g;i=e.a;u=e.l;a=e.h;s=e.b},function(n){c=n.g;d=n._;l=n.c;f=n.a;var t={};t.checkoutHiddenBtnSelector=n.c;t.checkoutHiddenInternationalBtnSelector=n.a;t.domesticRedirectedBtnSelector=n.d;e(t)},function(n){e("availableTestKeys",n.a)},function(n){var t={};t.countryRequireTaxId=n.c;t.euCountryCodes=n.e;t.shipToTaxIdLabels=n.s;e(t)}],execute:function(){var v=this;var m=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(n).origin;var i=t.some((function(e){return o.includes(e)}));var u=r.some((function(e){return o.includes(e)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var w=["jsdelivr","cdnjs","unpkg","vercel"];var p="jsdelivr";var h=function(e){var n=w.indexOf(e);var t=w[n+1];return t||null};var y=function(){return __awaiter(v,void 0,void 0,(function(){var e,n,t,r,c,d;return __generator(this,(function(l){switch(l.label){case 0:e=o();n=i();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}u("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){u("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,a("/api/get-test-public-credential")];case 1:t=l.sent(),r=t.errors,c=t.json;if(r.length||!c){s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2,null]}d=c.publicCredential;if(!d){s("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}u("[ZONOS - loadZonos] Retrieve new test public token ".concat(d),"info");return[2,d]}}))}))};var O=function(e){if(!e){return null}var n=new URL(e).searchParams;var t=n.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var g=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=O(window.location.href);var t="https://v1.3.218.js.zonos.com";if(!n&&(t.includes("test.")||t.includes("test-"))){return t}if(!n&&["dev.demo.elements.zonos.com","dev.checkout.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 r="preview.js.zonos.com";var o="https://".concat(n,".").concat(r);u("[ZONOS-WARNING] using '".concat(o,"' for loading elements script"),"warn");void fetch(o).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(o,"' 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 t="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return o};var S="https://js.stripe.com/v3";var _=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var b="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var z=function(){var e=document.querySelectorAll('script[src^="'.concat(S,'"]'));for(var n=0;n<e.length;n++){var t=e[n];if(!t){continue}if(!_.test(t.src)){continue}return t}return null};var j=null;var k=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var t=document.createElement("script");t.src="".concat(S).concat(n);var r=document.head||document.body;if(!r){s("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(t);return t};var N=function(e){if(j!==null){return j}j=new Promise((function(n,t){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(b)}if(window.Stripe){n(window.Stripe);return}try{var r=z();if(r&&e){console.warn(b)}else if(!r){r=k(e)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(e){t(e);return}}));return j};var A=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var I=function(e,n,t){if(e===null){return null}var r=e.apply(undefined,n);A(r,t);return r};var Z=Promise.resolve().then((function(){return N(null)}));var T=false;Z.catch((function(e){if(!T){console.warn(e)}}));var R=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(v,void 0,void 0,(function(){var n;return __generator(this,(function(t){T=true;n=Date.now();return[2,Z.then((function(t){return I(t,e,n)}))]}))}))};var E="tempCartUUID";var U=function(){var e=new URLSearchParams(window.location.search);var n=e.get(E);return n};var L=function(e){return __awaiter(v,[e],void 0,(function(e){var n,r,i,s,d,l,f,v,m;var w=e.cartId,p=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=o();r=t();i=c()||undefined;s=new URLSearchParams;if(r.overrideShouldEnabledCustomAddress){s.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress)}return[4,a("/api/zonos-elements/get-cart?".concat(s.toString()),{body:{isTestMode:n,renewCartExpirationToken:i,tempCartUUID:w},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:d=e.sent(),l=d.errors,f=d.json,v=d.zonosMode;m=!f||l.length;if(!(m&&p))return[3,3];u("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:p});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,L({cartId:w,retries:p-1})];case 3:if(m){return[2,null]}return[2,Object.assign(Object.assign({},f),{zonosMode:v})]}}))}))};var P=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:n=d(e),t=n.isDgsCartId,r=n.isLegacyCartId;if(!r&&!t){s("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,L({cartId:e,retries:5})];case 1:o=i.sent();u("[ZONOS - loadZonos] getting temp cart data","info",o);if(!o){s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=o.cartData.storeId;window.Zonos.zonosApiKey=o.cartData.credentialToken;window.Zonos.zonosMode=o.zonosMode;return[2,{cartData:o.cartData,settings:o.settings,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}]}}))}))};var C;var F=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=m({loadScriptSrc:e===null||e===void 0?void 0:e.src}),t=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return t}return null}();var D="https://v1.3.218.js.zonos.com";var M=F||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.218";var x="https://unpkg.com/@zonos/elements@1.3.218";var G="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.218";var K="https://fonts.googleapis.com";var B=/^https:\/\/fonts\.googleapis\.com/;var V=function(){function e(){}return e}();e("Zonos",V);C=V;V.doneInit=false;V.cartSettings=null;V.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);V.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);V._paypalMockResponse=null;V.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;V.isBigCommerce=false;V.releaseDate="1749830895070";V.isLegacyCheckout=false;V.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";V.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");V.overrideUseCustomAddressForm=false;V.isNpm=true;V.zonosQaUrl=null;V.zonosQaUrlApi=null;V.trackEventLogs=[];V.version="v".concat("1.3.218");V.modeAlerted=false;V.cartData=null;V.paypal=null;V.zonosMode=null;V.IframeService=r;V.getCurrentTimestamp=function(){return(new Date).getTime()};V.zonosController=null;V.loadTimeApiInfoList=[];V.logIntervalId=null;V.init=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,o,i,a,c,d,f,v,m,w,p,h,O;return __generator(this,(function(S){switch(S.label){case 0:n=e.appearance,t=e.checkoutSettings,r=e.currencyConverter,o=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,c=e.storeId,d=e.zonosApiKey;C.cartId=U();if(C.doneInit){return[2]}u("====== ZONOS DEBUG MODE: on (".concat(C.version,") ======"));C.zonosApiKey=d;C.storeId=c;if(!C.isNpm)return[3,4];u("====== ZONOS LOADING FROM NPM ======");f=g();if(f&&!window.isZonosPreview){u('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(f," ======"),"info");v=document.createElement("script");v.src="".concat(f,"/dist/scripts/zonos.js");document.head.appendChild(v);v.addEventListener("load",(function(){window.Zonos.isNpm=C.isNpm;window.Zonos.isBigCommerce=C.isBigCommerce;window.Zonos.isLegacyCheckout=C.isLegacyCheckout;void window.Zonos.init(e)}));v.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(f))}));window.isZonosPreview=true;return[2]}if(!d&&!C.cartId){s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!C.cartData&&C.cartId))return[3,2];u("Initialize cart data");return[4,P(C.cartId)];case 1:m=S.sent();if(!m){s("Failed to get cart data");return[2]}C.cartData=m.cartData;C.zonosApiKey=m.zonosApiKey;C.cartSettings=m.settings;S.label=2;case 2:return[4,y()];case 3:w=S.sent();if(w){C.zonosApiKey=w}S.label=4;case 4:p=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");h=C.cartId&&C.cartData||!!p;if(h){u("Cart data or stripe client secret is available, inject hidden button and trigger checkout");O=document.createElement("button");O.style.display="none";O.id="".concat(l);document.body.appendChild(O)}u("init zonos");C.restoreNativeBrowserFunctions();C.injectCustomScriptForHostedCheckout();C.injectZonosCdn();C.injectZonosCss();C.injectFonts();C.injectCheckoutInternationalButton();C.injectController({config:{appearance:n,checkoutSettings:t,currencyConverter:r,helloSettings:o,onCountryChange:i,overrideCurrencyFormat:a}});C.doneInit=true;return[2]}}))}))};V.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(f))){var e=document.createElement("button");e.id=f;e.style.display="none";document.body.appendChild(e)}};V.injectCustomScriptForHostedCheckout=function(){var e=C.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var t=n.find((function(e){return e.key==="customHeaderScript"}));var r=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!t&&!r){u("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(t){u("Injecting custom header script");var o=document.createElement("script");o.textContent=t.value;document.head.appendChild(o)}if(r){u("Injecting custom footer script");var o=document.createElement("script");o.textContent=r.value;document.body.appendChild(o)}};V.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};V.triggerCheckoutInternational=function(){return __awaiter(v,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=document.querySelector("#".concat(f));setTimeout((function(){if(e){e.dispatchEvent(n("click"))}}),10);return[2]}))}))};V.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};V.showNotification=function(e){var n;void((n=C.zonosController)===null||n===void 0?void 0:n.showNotification(e))};V.updateOrganizationName=function(e){var n;void((n=C.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};V.disablePlaceOrderButtons=function(e){var n=e.autoEnable,t=n===void 0?true:n,r=e.config,o=e.disable,i=e.placeOrderButtonSelector;var u;if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}if(i){var a=document.querySelectorAll(i);var s=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};a.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(o){e.setAttribute("disabled","true");e.addEventListener("click",s)}else{e.removeAttribute("disabled");e.removeEventListener("click",s)}}));if(t&&o){setTimeout((function(){a.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",s)}))}),5e3)}}};V.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var t="zonos---native-browser";var r=document.querySelector("iframe#".concat(t));if(!r){r=document.createElement("iframe");r.id=t;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}var o=((e=r.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=o;document.body.removeChild(r)};V.injectController=function(e){var n=e.config;var t,r;if(document.querySelector("zonos-controller")){return}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.placeOrderButtonSelector){var o=n.checkoutSettings.placeOrderButtonSelector;C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:o});var i=new MutationObserver((function(){C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:o})}));i.observe(document.body,{childList:true,subtree:true})}if((r=n.checkoutSettings)===null||r===void 0?void 0:r.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){C.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=n;c.zonosApiKey=C.zonosApiKey||"";c.addEventListener("stripeInitEvent",(function(e){return __awaiter(v,void 0,void 0,(function(){var n,t;return __generator(this,(function(r){switch(r.label){case 0:n=e.detail;u("loading Stripe");return[4,R(n.publishableKey)];case 1:t=r.sent();if(!t){s("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=t;void c.initCheckoutElement(t);return[2]}}))}))}));document.body.appendChild(c);C.zonosController=c;u("Zonos controller injected!")};V.injectScript=function(e){var n=e.cdnType,t=e.isModule,r=e.theRestUrl;var o=C.getZonosUrl(n);var i="".concat(o,"/").concat(r);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){u('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var c=document.head||document.body;var d=document.createElement("script");if(!!t){d.type="module"}else{d.noModule=true}d.src=i;d.crossOrigin="anonymous";d.onerror=function(){s("Failed to load ".concat(d.src));var e=h(n);if(!e){return}C.injectScript({cdnType:e,isModule:t,theRestUrl:r})};c.appendChild(d)};V.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return M;case"unpkg":return x;case"cdnjs":return G;case"vercel":return D}};if(C.isNpm){var t=g();return t||n()}return n()};V.injectZonosCdn=function(){C.injectScript({cdnType:p,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});C.injectScript({cdnType:p,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});u("Zonos cdn script injected!")};V.injectStylesheet=function(e){var n=e.cdnType,t=e.theRestUrl;var r=C.getZonosUrl(n);var o=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(D,"/");o.appendChild(i);var u=document.createElement("link");u.rel="stylesheet";u.href="".concat(r,"/").concat(t);u.onerror=function(){s("Failed to load ".concat(u.href));var e=h(n);if(!e){return}C.injectStylesheet({cdnType:e,theRestUrl:t})};o.appendChild(u)};V.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){u("Zonos style links already injected","warn");return}C.injectStylesheet({cdnType:p,theRestUrl:"dist/zonos-elements/zonos-elements.css"});u("Zonos style css injected!")};V.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){u("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(K,'"]'));for(var t=0;t<n.length;t++){var r=n[t];if(!r){continue}if(B.test(r.href)){continue}return r}return null};if(e()){u("Inter font already injected","warn");return}var n=document.head||document.body;var t=document.createElement("link");t.rel="preconnect";t.href=K;n.appendChild(t);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(K,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(r);u("Zonos font injected!")};V.setupGoogleFont=function(e){var n;void((n=C.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};V.injectSupportGoogleFont=function(e){var n;u("[FONT] injecting ".concat(e));var t=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(K,'"]'))){var o=document.createElement("link");o.rel="preconnect";o.href=K;r.appendChild(o)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){u("[FONT] ".concat(t," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;r.appendChild(i);u("[FONT] ".concat(t," font injected!"))};var W=e("checkoutSessionMutableAttributeKeys",["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"]);var q=e("checkoutSessionImmutableAttributeKeys",["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"]);var H=e("checkoutSessionAttributeKeys",__spreadArray(__spreadArray([],W,true),q,true))}}}));
@@ -0,0 +1 @@
1
+ import{d as s}from"./p-0ae53ff0.js";import{h as t,b as e}from"./p-a8a312b2.js";const a={},o={},r=async({attributes:r,checkoutSessionId:i})=>{var u;if(a[i]||(a[i]=new Map),r.forEach((s=>{var t;s.value&&(null===(t=a[i])||void 0===t||t.set(s.key,s.value))})),r.length)return o[i]||(o[i]=(u=i,s((async()=>{var s,o;const r=Array.from((null===(s=a[u])||void 0===s?void 0:s.entries())||[]).map((([s,t])=>({key:s,value:t}))),{errors:i,json:n}=await t("/api/zonos-elements/update-checkout-session-attributes",{body:{attributes:r,id:u},method:"POST"});return i.length?(e("Error updating checkout session attributes",i),{success:!1}):(null===(o=a[u])||void 0===o||o.clear(),{success:!!(null==n?void 0:n.success)})}),1e3,{maxWait:5e3}))),o[i]()};export{r as u}
@@ -0,0 +1 @@
1
+ var __awaiter=this&&this.__awaiter||function(t,n,e,r){function i(t){return t instanceof e?t:new e((function(n){n(t)}))}return new(e||(e=Promise))((function(e,u){function o(t){try{a(r.next(t))}catch(t){u(t)}}function c(t){try{a(r["throw"](t))}catch(t){u(t)}}function a(t){t.done?e(t.value):i(t.value).then(o,c)}a((r=r.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var e={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},r,i,u,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(t){return function(n){return a([t,n])}}function a(c){if(r)throw new TypeError("Generator is already executing.");while(o&&(o=0,c[0]&&(e=0)),e)try{if(r=1,i&&(u=c[0]&2?i["return"]:c[0]?i["throw"]||((u=i["return"])&&u.call(i),0):i.next)&&!(u=u.call(i,c[1])).done)return u;if(i=0,u)c=[c[0]&2,u.value];switch(c[0]){case 0:case 1:u=c;break;case 4:e.label++;return{value:c[1],done:false};case 5:e.label++;i=c[1];c=[0];continue;case 7:c=e.ops.pop();e.trys.pop();continue;default:if(!(u=e.trys,u=u.length>0&&u[u.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!u||c[1]>u[0]&&c[1]<u[3])){e.label=c[1];break}if(c[0]===6&&e.label<u[1]){e.label=u[1];u=c;break}if(u&&e.label<u[2]){e.label=u[2];e.ops.push(c);break}if(u[2])e.ops.pop();e.trys.pop();continue}c=n.call(t,e)}catch(t){c=[6,t];i=0}finally{r=u=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};System.register(["./p-cd1ebef9.system.js","./p-062430f9.system.js"],(function(t){"use strict";var n,e,r;return{setters:[function(t){n=t.d},function(t){e=t.h;r=t.b}],execute:function(){var i=this;var u={};var o={};var c=function(t){return n((function(){return __awaiter(i,void 0,void 0,(function(){var n,i,o,c,a,s;return __generator(this,(function(f){switch(f.label){case 0:o=Array.from(((n=u[t])===null||n===void 0?void 0:n.entries())||[]).map((function(t){var n=t[0],e=t[1];return{key:n,value:e}}));return[4,e("/api/zonos-elements/update-checkout-session-attributes",{body:{attributes:o,id:t},method:"POST"})];case 1:c=f.sent(),a=c.errors,s=c.json;if(a.length){r("Error updating checkout session attributes",a);return[2,{success:false}]}(i=u[t])===null||i===void 0?void 0:i.clear();return[2,{success:!!(s===null||s===void 0?void 0:s.success)}]}}))}))}),1e3,{maxWait:5e3})};var a=t("u",(function(t){return __awaiter(i,[t],void 0,(function(t){var n=t.attributes,e=t.checkoutSessionId;return __generator(this,(function(t){u[e]||(u[e]=new Map);n.forEach((function(t){var n;if(t.value){(n=u[e])===null||n===void 0?void 0:n.set(t.key,t.value)}}));if(!n.length){return[2]}if(!o[e]){o[e]=c(e)}return[2,o[e]()]}))}))}))}}}));