@zonos/elements 1.5.2 → 1.5.3

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 (189) hide show
  1. package/dist/cjs/_isBigCommerceNativeCheckout-3-xbKbAO.js +133 -0
  2. package/dist/cjs/{cart-BJpqPdFU.js → cart-C39TMSgB.js} +14 -0
  3. package/dist/cjs/{collect-CyUttsvB.js → collect-lF9DenLk.js} +2 -2
  4. package/dist/cjs/{getMissingRequiredShippingFields-DEbNbRAZ.js → getMissingRequiredShippingFields-svcnpumn.js} +1 -1
  5. package/dist/cjs/index.cjs.js +61 -42
  6. package/dist/cjs/{invoice-DzRkkpLu.js → invoice-BD3pCr8P.js} +1 -1
  7. package/dist/cjs/{paypal-DCSqbdjW.js → paypal-Bd1qmwiv.js} +1 -1
  8. package/dist/cjs/{placeTestOrder-Bkip4PUT.js → placeTestOrder-BMQRvX2q.js} +1 -1
  9. package/dist/cjs/{renderCheckoutCurrency-BDvEZ3Hv.js → renderCheckoutCurrency-DE2p8CT8.js} +1 -1
  10. package/dist/cjs/{taxIdFields-e4OCgr8K.js → taxIdFields-BKbk2bhi.js} +1 -1
  11. package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +4 -4
  12. package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +2 -2
  14. package/dist/cjs/zonos-card_5.cjs.entry.js +2 -2
  15. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +5 -5
  16. package/dist/cjs/zonos-checkout.cjs.entry.js +41 -15
  17. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +1 -1
  18. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +5 -5
  19. package/dist/cjs/zonos-collect.cjs.entry.js +3 -3
  20. package/dist/cjs/zonos-controller.cjs.entry.js +63 -38
  21. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +3 -3
  22. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +5 -5
  23. package/dist/cjs/zonos-invoice.cjs.entry.js +3 -3
  24. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +2 -2
  25. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +10 -1
  26. package/dist/collection/components/main/mountCheckoutWithoutStripe.js +12 -0
  27. package/dist/collection/components/main/zonos-controller.js +24 -9
  28. package/dist/collection/components/store/checkout/stripe.js +13 -1
  29. package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +2 -1
  30. package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +32 -12
  31. package/dist/collection/scripts/_bigcommerceCheckoutPath.js +16 -0
  32. package/dist/collection/scripts/_detectBigCommerceHost.js +12 -0
  33. package/dist/collection/scripts/_isBigCommerceNativeCheckout.js +107 -0
  34. package/dist/collection/scripts/_loadStripe.js +15 -4
  35. package/dist/collection/scripts/_zonosBase.js +40 -31
  36. package/dist/esm/_isBigCommerceNativeCheckout-Bb90IMVt.js +128 -0
  37. package/dist/esm/{cart-BS5mSI8x.js → cart-b84n0nhi.js} +14 -2
  38. package/dist/esm/{collect-B9ZxDDl7.js → collect-B_AEVONL.js} +3 -3
  39. package/dist/esm/{getMissingRequiredShippingFields-BkEV865q.js → getMissingRequiredShippingFields-EY10c34-.js} +1 -1
  40. package/dist/esm/{hasInclusivePrice-zSvDReDb.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
  41. package/dist/esm/index.js +61 -42
  42. package/dist/esm/{invoice-6iTuS6ek.js → invoice-dQ0ONK5Q.js} +2 -2
  43. package/dist/esm/{localization-CXHiWcJp.js → localization-B5CRzthT.js} +1 -1
  44. package/dist/esm/{paypal-BE_NVBoy.js → paypal-CF_oM0B6.js} +2 -2
  45. package/dist/esm/{placeTestOrder-BXA9K9Iy.js → placeTestOrder-BTpfyqPL.js} +2 -2
  46. package/dist/esm/{renderCheckoutCurrency-KMa4HlAf.js → renderCheckoutCurrency-CpeuDWx-.js} +2 -2
  47. package/dist/esm/{shouldShowLanguageSelect-BI_ApEsQ.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
  48. package/dist/esm/{taxIdFields-BUKnHMaL.js → taxIdFields-BCyXnc9O.js} +2 -2
  49. package/dist/esm/zonos-address-completion-dialog_7.entry.js +5 -5
  50. package/dist/esm/zonos-address-display_2.entry.js +1 -1
  51. package/dist/esm/zonos-address_4.entry.js +3 -3
  52. package/dist/esm/zonos-airwallex-payment.entry.js +3 -3
  53. package/dist/esm/zonos-card_5.entry.js +3 -3
  54. package/dist/esm/zonos-cart-items_12.entry.js +8 -8
  55. package/dist/esm/zonos-checkout.entry.js +42 -16
  56. package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
  57. package/dist/esm/zonos-collect-finish_6.entry.js +7 -7
  58. package/dist/esm/zonos-collect.entry.js +4 -4
  59. package/dist/esm/zonos-controller.entry.js +63 -38
  60. package/dist/esm/zonos-country-flag.entry.js +1 -1
  61. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  62. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  63. package/dist/esm/zonos-hello.entry.js +1 -1
  64. package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
  65. package/dist/esm/zonos-invoice-finish_5.entry.js +7 -7
  66. package/dist/esm/zonos-invoice.entry.js +4 -4
  67. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  68. package/dist/esm/zonos-policy-consent_2.entry.js +3 -3
  69. package/dist/esm-es5/_isBigCommerceNativeCheckout-Bb90IMVt.js +40 -0
  70. package/dist/esm-es5/{cart-BS5mSI8x.js → cart-b84n0nhi.js} +9 -9
  71. package/dist/esm-es5/{collect-B9ZxDDl7.js → collect-B_AEVONL.js} +2 -2
  72. package/dist/esm-es5/{getMissingRequiredShippingFields-BkEV865q.js → getMissingRequiredShippingFields-EY10c34-.js} +3 -3
  73. package/dist/esm-es5/{hasInclusivePrice-zSvDReDb.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
  74. package/dist/esm-es5/index.js +76 -65
  75. package/dist/esm-es5/{invoice-6iTuS6ek.js → invoice-dQ0ONK5Q.js} +1 -1
  76. package/dist/esm-es5/{localization-CXHiWcJp.js → localization-B5CRzthT.js} +1 -1
  77. package/dist/esm-es5/{paypal-BE_NVBoy.js → paypal-CF_oM0B6.js} +1 -1
  78. package/dist/esm-es5/{placeTestOrder-BXA9K9Iy.js → placeTestOrder-BTpfyqPL.js} +1 -1
  79. package/dist/esm-es5/{renderCheckoutCurrency-KMa4HlAf.js → renderCheckoutCurrency-CpeuDWx-.js} +4 -4
  80. package/dist/esm-es5/{shouldShowLanguageSelect-BI_ApEsQ.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
  81. package/dist/esm-es5/{taxIdFields-BUKnHMaL.js → taxIdFields-BCyXnc9O.js} +2 -2
  82. package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +2 -2
  83. package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
  84. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  85. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  86. package/dist/esm-es5/zonos-card_5.entry.js +1 -1
  87. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  88. package/dist/esm-es5/zonos-checkout.entry.js +20 -9
  89. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  90. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  91. package/dist/esm-es5/zonos-collect.entry.js +6 -6
  92. package/dist/esm-es5/zonos-controller.entry.js +22 -13
  93. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  94. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  95. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  96. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  97. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  98. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  99. package/dist/esm-es5/zonos-invoice.entry.js +1 -1
  100. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  101. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  102. package/dist/scripts/index.d.ts +16 -0
  103. package/dist/scripts/index.js +1 -1
  104. package/dist/scripts/loadZonos.js +1 -1
  105. package/dist/scripts/zonos.js +1 -1
  106. package/dist/types/components/main/mountCheckoutWithoutStripe.d.ts +8 -0
  107. package/dist/types/components/store/checkout/stripe.d.ts +4 -1
  108. package/dist/types/scripts/_bigcommerceCheckoutPath.d.ts +12 -0
  109. package/dist/types/scripts/_detectBigCommerceHost.d.ts +5 -0
  110. package/dist/types/scripts/_isBigCommerceNativeCheckout.d.ts +21 -0
  111. package/dist/types/scripts/_zonosBase.d.ts +16 -0
  112. package/dist/zonos-elements/index.esm.js +1 -1
  113. package/dist/zonos-elements/{p-08b01c96.entry.js → p-02faff47.entry.js} +1 -1
  114. package/dist/zonos-elements/{p-573a4e7c.system.entry.js → p-0c68cbbb.system.entry.js} +6 -6
  115. package/dist/zonos-elements/{p-68325c5a.system.entry.js → p-1cd2d097.system.entry.js} +4 -4
  116. package/dist/zonos-elements/{p-af741506.entry.js → p-255e411a.entry.js} +1 -1
  117. package/dist/zonos-elements/{p-dJcbnNlE.system.js → p-2c_UqKJL.system.js} +2 -2
  118. package/dist/zonos-elements/{p-BUfCTQXY.system.js → p-3AUMK-5E.system.js} +113 -113
  119. package/dist/zonos-elements/{p-dd003161.entry.js → p-3ee87d8b.entry.js} +1 -1
  120. package/dist/zonos-elements/{p-8f9f859f.system.entry.js → p-42fa5694.system.entry.js} +5 -5
  121. package/dist/zonos-elements/p-49eaaab8.entry.js +1 -0
  122. package/dist/zonos-elements/{p-ebc7ea54.system.entry.js → p-4ce4c49f.system.entry.js} +1 -1
  123. package/dist/zonos-elements/{p-9b3668a4.system.entry.js → p-5622fc50.system.entry.js} +263 -252
  124. package/dist/zonos-elements/{p-3a506614.system.entry.js → p-59457fd9.system.entry.js} +71 -62
  125. package/dist/zonos-elements/{p-7fe83919.entry.js → p-66398133.entry.js} +1 -1
  126. package/dist/zonos-elements/{p-9df31243.system.entry.js → p-674323ac.system.entry.js} +1 -1
  127. package/dist/zonos-elements/{p-97729873.entry.js → p-71d9a5b7.entry.js} +1 -1
  128. package/dist/zonos-elements/{p-30bf4700.system.entry.js → p-81780f8f.system.entry.js} +2 -2
  129. package/dist/zonos-elements/{p-1986cc37.entry.js → p-821b83a2.entry.js} +1 -1
  130. package/dist/zonos-elements/{p-5a296dbc.system.entry.js → p-877a82d2.system.entry.js} +61 -61
  131. package/dist/zonos-elements/p-8daec112.entry.js +1 -0
  132. package/dist/zonos-elements/{p-150047b3.system.entry.js → p-93bc75fd.system.entry.js} +19 -19
  133. package/dist/zonos-elements/{p-b540c636.system.entry.js → p-976b3bf3.system.entry.js} +1 -1
  134. package/dist/zonos-elements/{p-4b65f192.entry.js → p-9a4947a5.entry.js} +1 -1
  135. package/dist/zonos-elements/p-9f7693bf.entry.js +1 -0
  136. package/dist/zonos-elements/{p-D4xpkSsK.js → p-BIJM2Kj-.js} +1 -1
  137. package/dist/zonos-elements/{p-D-Lnf8mS.system.js → p-BOh4ifdL.system.js} +2 -2
  138. package/dist/zonos-elements/p-BZAX-HmS.js +1 -0
  139. package/dist/zonos-elements/p-Bb90IMVt.js +1 -0
  140. package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
  141. package/dist/zonos-elements/{p-DC1OPJDq.system.js → p-BvoPE_nb.system.js} +1 -1
  142. package/dist/zonos-elements/{p-C5fs3rIR.js → p-C3E55OqH.js} +1 -1
  143. package/dist/zonos-elements/{p-BnQyot7Y.system.js → p-C3gF3UV5.system.js} +29 -29
  144. package/dist/zonos-elements/{p-BKUlQxBd.system.js → p-CD2ahEZn.system.js} +1 -1
  145. package/dist/zonos-elements/p-CEBBLbvF.js +1 -0
  146. package/dist/zonos-elements/{p-Cp1IAJvW.system.js → p-CEV0O_IQ.system.js} +4 -4
  147. package/dist/zonos-elements/{p-yv7ekcdG.system.js → p-CZ-uYiCo.system.js} +2 -2
  148. package/dist/zonos-elements/{p-CP7KnfR3.system.js → p-Cn2xE-9t.system.js} +79 -68
  149. package/dist/zonos-elements/p-CtvXi9wL.system.js +41 -0
  150. package/dist/zonos-elements/{p-Dv5a-V6w.system.js → p-Cw_Qnyow.system.js} +1 -1
  151. package/dist/zonos-elements/p-CzXNXgyI.js +1 -0
  152. package/dist/zonos-elements/{p-CVRbGFV3.js → p-D9OPKqLg.js} +1 -1
  153. package/dist/zonos-elements/{p-DrbN3rPL.js → p-Df62LRNs.js} +2 -2
  154. package/dist/zonos-elements/{p-DKnphvmJ.js → p-Lsqrpzc5.js} +1 -1
  155. package/dist/zonos-elements/{p-DrS-0mk7.system.js → p-YQFbWtjn.system.js} +1 -1
  156. package/dist/zonos-elements/p-a27f48e4.entry.js +1 -0
  157. package/dist/zonos-elements/{p-bb1b414a.system.entry.js → p-a6bb296c.system.entry.js} +6 -6
  158. package/dist/zonos-elements/{p-13015d34.system.entry.js → p-abb85879.system.entry.js} +3 -3
  159. package/dist/zonos-elements/{p-383343c7.entry.js → p-b8653024.entry.js} +1 -1
  160. package/dist/zonos-elements/p-b9d7a3b6.entry.js +1 -0
  161. package/dist/zonos-elements/{p-96b250d8.system.entry.js → p-be067e12.system.entry.js} +2 -2
  162. package/dist/zonos-elements/{p-Cl5yV0ak.js → p-bmrOH9oh.js} +1 -1
  163. package/dist/zonos-elements/{p-71d29603.entry.js → p-c185bc23.entry.js} +1 -1
  164. package/dist/zonos-elements/{p-13d5b2f9.entry.js → p-c6e78de2.entry.js} +1 -1
  165. package/dist/zonos-elements/{p-a3c147d2.system.entry.js → p-ca97a1cd.system.entry.js} +3 -3
  166. package/dist/zonos-elements/{p-0909ef77.entry.js → p-cbb96382.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-6db7317a.system.entry.js → p-dbf4d156.system.entry.js} +14 -14
  168. package/dist/zonos-elements/{p-e43470f7.system.entry.js → p-df240119.system.entry.js} +17 -17
  169. package/dist/zonos-elements/{p-f2ed52bc.system.entry.js → p-e16e4db6.system.entry.js} +15 -15
  170. package/dist/zonos-elements/{p-7214c953.system.entry.js → p-eb016dd8.system.entry.js} +16 -16
  171. package/dist/zonos-elements/{p-709d1561.system.entry.js → p-eb5c67a0.system.entry.js} +1 -1
  172. package/dist/zonos-elements/{p-e374aaa4.entry.js → p-ed8a7a7f.entry.js} +1 -1
  173. package/dist/zonos-elements/{p-3466bcba.entry.js → p-ef932fda.entry.js} +1 -1
  174. package/dist/zonos-elements/{p-bfa9e32a.entry.js → p-f792ba5f.entry.js} +1 -1
  175. package/dist/zonos-elements/{p-aK18R41t.js → p-fZcKMzE-.js} +1 -1
  176. package/dist/zonos-elements/{p-C-zdj7MK.js → p-fdritVtG.js} +1 -1
  177. package/dist/zonos-elements/p-fffe6376.entry.js +1 -0
  178. package/dist/zonos-elements/{p-CMneHjck.system.js → p-v8IEjQ2z.system.js} +10 -10
  179. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  180. package/package.json +10 -10
  181. package/dist/zonos-elements/p-43c0ebe9.entry.js +0 -1
  182. package/dist/zonos-elements/p-8ac26831.entry.js +0 -1
  183. package/dist/zonos-elements/p-BI6VAB5B.js +0 -1
  184. package/dist/zonos-elements/p-BJ_kE5rM.js +0 -1
  185. package/dist/zonos-elements/p-DATNIakn.js +0 -1
  186. package/dist/zonos-elements/p-af4ad54b.entry.js +0 -1
  187. package/dist/zonos-elements/p-bac94956.entry.js +0 -1
  188. package/dist/zonos-elements/p-cf6bf7a4.entry.js +0 -1
  189. package/dist/zonos-elements/p-db40b9c3.entry.js +0 -1
@@ -1 +1 @@
1
- (function(){"use strict";const e=()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}},o=e=>/^[A-Z]{2}$/.test(e),n=["cloudflare","vercel"],t=n[0],r={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},s=r[t],i=(e=t)=>{const o=n.indexOf(e),r=n[o+1];return r||null},a=performance.now(),d=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},c=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-a,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(d).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const l=(null===(r=c.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":l.warn(e,...i);break;case"info":l.info(e,...i);break;case"error":l.error(e,...i);break;default:l.groupCollapsed(e,...i),l.trace(),l.groupEnd()}},l=()=>{const e=new URL(window.location.href);return e.searchParams.delete("payment_intent"),e.searchParams.delete("payment_intent_client_secret"),e.searchParams.delete("redirect_status"),e.toString()},u=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(c("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:e,errors:o,href:l(),metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${s}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=i();if(!o)return;fetch(`${r[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},p=(e,o)=>"string"==typeof e&&e?e:e instanceof Error&&e.message||"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message&&e.message?e.message:o,w=(e,o,n,t)=>{if(void 0===window.Zonos)return;const r=`${e}\0${o}\0${n}`,s=(window.__zonosReportedBlockedStorage||(window.__zonosReportedBlockedStorage=new Set),window.__zonosReportedBlockedStorage);s.has(r)||(s.add(r),u({endpoint:`storage://${e}/${n}`,errors:[p(t,"SecurityError")],metadata:{area:e,key:n,operation:o,shape:"blocked-storage"}}))},m=e=>{const o="local"===e?window.localStorage:window.sessionStorage;if(!o)throw new DOMException("","SecurityError");return o},g=(e,o)=>{try{m(e).removeItem(o)}catch(n){w(e,"removeItem",o,n)}},y=e=>{const n=((e,o)=>{try{return m(e).getItem(o)}catch(n){return w(e,"getItem",o,n),null}})(e,"zonos--country");return n&&o(n)?n:null},f=()=>(e=>{const n=new URLSearchParams(e||window.location.search),t=e=>{const t=n.get(e);return t&&o(t)?t:null},r=t("zCountry"),s=t("country"),i=t("customerCountry");return r||s||i})(new URL(window.location.href).searchParams)||(()=>{var e;return null!==(e=y("local"))&&void 0!==e?e:y("session")})();function h(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const v=()=>window.location.search.includes("zonosStagingMode=1"),S=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},z=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},Z=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n},C=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(C.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=(()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=Z();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(c=a,c||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var c;window.Zonos.loadTimeApiInfoList.push(d)},I=e=>502===e||503===e||504===e,L=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=z(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},O=async({basePathType:e,options:o,path:n})=>{let s;const i=window.Zonos.zonosQaUrlApi||r[e]||t,a=new URL(i+n),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(d));try{s=await fetch(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await L({response:s}),response:s,zonosMode:c}}const u=s.status.toString();try{const e=await L({response:s,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:i,errors:o.map(e=>"string"==typeof e?{message:e,type:u}:e),json:null,response:s,zonosMode:c}}return{baseUrl:i,errors:[{message:JSON.stringify(e),type:u}],json:null,response:s,zonosMode:c}}catch(e){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:I(s.status)?s:null,zonosMode:c}}},T=async({basePathType:e,options:o,path:n})=>{var t,s,a;const d=n.startsWith("/api/bigcommerce")?"vercel":e,l=performance.now(),p=await O({basePathType:d,options:o,path:n}),{errors:w,response:m}=p,g=h(p,["errors","response"]),y=performance.now()-l;c(`${n} (${y.toFixed(2)}ms)`,"info");const f=null==m?void 0:m.headers.get("Zonos-Duration");200===(null==m?void 0:m.status)&&b({apiPath:n,apiType:d,loadTimeInternal:f?Number(f):0,loadTimeTotal:y});const v=i(d),S=w.find(({type:e})=>"unknown"===e),Z=w.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),C=null==m?void 0:m.status,L=void 0!==C&&I(C),A="GET"===(null!==(t=null==o?void 0:o.method)&&void 0!==t?t:"GET").toUpperCase(),k=!!S||404===C||500===C,U=v&&(k||L&&A);return(k||L)&&!Z&&u({endpoint:r[d]+n,errors:w.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:d,nextFallbackApiType:v,requestHeaders:null==o?void 0:o.headers,requestPayload:z(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString())||(null===(a=null==o?void 0:o.body)||void 0===a?void 0:a.toString()),shouldCallFallback:U,status:null==m?void 0:m.status,statusText:null==m?void 0:m.statusText},shouldPostReleaseErrorReporting:!0}),U?(c(`=== "${n}" failed to fetch, trying next fallback ${v}`),T({basePathType:v,options:o,path:n})):Object.assign({errors:w,response:m},g)},A=async(e,o)=>{const n=h(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=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":v()?"1":void 0,"Zonos-Test-Mode":S()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach(e=>void 0===i[e]&&delete i[e]);const a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return T({basePathType:d||t,options:a,path:e})},k=(e,...o)=>{c(e,"error",...o)},U=/^Constructor for .+ was not found/,j=/^Constructor for "?([^#"]+)#/,E=e=>{var o;const n=p(e,"");if(!n||!U.test(n))return;if(void 0===window.Zonos)return;const t=window.__zonosConstructorCapture;if(!t)return;const r=j.exec(n),s=null!==(o=null==r?void 0:r[1])&&void 0!==o?o:"";t.reported.has(s)||(t.reported.add(s),u({endpoint:"stencil://constructor",errors:[n],metadata:{shape:"constructor-not-found",tag:s}}))},$=e=>{console.error(e),void 0!==window.Zonos&&u({endpoint:"zonos://init",errors:[p(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})},P=e=>{let o;try{o=e()}catch(e){return void $(e)}o.catch(e=>{$(e)})},D=["jsdelivr","cdnjs","unpkg","vercel"],N=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},R=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,F=new RegExp(`^${R.source}$`),B=new RegExp(`^cart_${R.source}$`),M=/^[a-zA-Z0-9]{2,}$/,x=/^cart_[a-zA-Z0-9]{2,}$/,K=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:x.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:M.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:B.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:F.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},_=async({cartId:o,retries:n})=>{const t=S(),r=e(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;r.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress);const{errors:a,json:d,zonosMode:l}=await A(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),u=!d||a.length;return u&&n?(c("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise(e=>setTimeout(e,500)),_({cartId:o,retries:n-1})):u?null:Object.assign(Object.assign({},d),{zonosMode:l})},q="z--blur",H=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;if(!e)return;await new Promise(e=>setTimeout(e,500)),clearInterval(e);document.querySelectorAll(`.${q}`).forEach(e=>{e.classList.remove(q)}),window.zonosBlurCurrencyOnInitIntervalId=void 0},Q=({currencySelector:e,specificSelector:o})=>{if(e||o)if(o)o.classList.add(q);else{document.querySelectorAll([e].filter(Boolean).join(",")).forEach(e=>{e.classList.add(q)})}};var W;const G=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=N(window.location.href),n="https://v1.5.2.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const t=`https://${o}.preview.js.zonos.com`;return c(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then(()=>{g("session","zonos--checkout-session-id"),g("session","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:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null}),t})(),V=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrlApi");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),o=N(window.location.href),n=e||o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if("worker"===n)return"https://worker.iglobalstores.com";if(!e)return null;const t=`https://${e}.route.js.zonos.com`;return c(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})(),J=Date.now();class X{}W=X,X.isNpm=!1,X.isBigCommerce=!1,X.googleAnalyticId=null,X.googleAnalyticReady=!1,X.facebookPixelId=null,X.facebookPixelReady=!1,X.requested=!1,X.zonosMode=null,X.cartData=null,X.startLoadTime=J,X.overrideUseCustomAddressForm=!1,X.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,X.version="v1.5.2",X.isLegacyCheckout=!1,X.isCollect=!1,X.isInvoice=!1,X.legacyStoreLogo=null,X.legacyStoreFavicon=null,X.parallelLoadTimes=[],X.parallelLoadState="off",X.releaseDate="1793899943651",X.loadTimeApiInfoList=[],X.cartSettings=null,X.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find(e=>{const o=e;return o.name.includes(r)&&"script"===o.initiatorType});null==e||e.transferSize;(async()=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},t)))}catch(e){}},X.loadScriptLogParallelHandler=async e=>{try{if(W.parallelLoadTimes.push(e),2===W.parallelLoadTimes.length){const e=W.parallelLoadTimes.find(e=>"vercel"===e.type),o=W.parallelLoadTimes.find(e=>"jsdelivr"===e.type);if(!e||!o)return;if(e.isError&&o.isError)return void u({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});W.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},X.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{k(`[ZONOS - loadZonos] ${e}`),u({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:W.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},X.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.2";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.2":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.5.2");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},X.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:W.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:W.getGithubCdn({type:e,version:r}),a=G||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),p=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${p}?timestamp=${Date.now()}`,c(`[ZONOS - loadZonos] Injecting "${p}" from "${d}"`,"info");const w="4g"===(null===(s=Z())||void 0===s?void 0:s.effectiveType),m=["dev.elements.zonos.com","zonos.com"].some(e=>window.location.href.includes(e)),g=D[0]===e,y=D[1],f="on"===W.parallelLoadState&&w&&g&&y&&!m;f&&W.injectZonos({cdnType:y,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const h=performance.now();l.addEventListener("load",async()=>{if(f||n?W.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:W.storeId||0,type:e}):W.loadScriptLogHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:W.storeId||0,type:e}),W.isBigCommerce||(W.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=G,window.Zonos.zonosQaUrlApi=V,window.Zonos.zonosMode=W.zonosMode,window.Zonos.isBigCommerce=W.isBigCommerce,window.Zonos.loadTimeApiInfoList=W.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=W.overrideUseCustomAddressForm,window.Zonos.startLoadTime=W.startLoadTime,W.cartSettings&&(window.Zonos.cartSettings=W.cartSettings),W.cartId){const e=W.isCollect?"Collect":"hosted Checkout";if(!W.zonosApiKey)throw W.legacyCheckoutErrorHandler({message:`zonosApiKey is missing to initiate ${e}`}),new Error(`zonosApiKey is required for ${e}`);if(!W.cartData)throw W.legacyCheckoutErrorHandler({message:`cartData is missing to initiate ${e}`}),new Error(`cartData is required for ${e}`);if(W.legacyStoreFavicon&&W.isLegacyCheckout&&!W.isCollect)try{if(200!==(await fetch(W.legacyStoreFavicon)).status)throw new Error("Custom favicon is not available");const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=W.legacyStoreFavicon,document.head.appendChild(e)}catch(e){}window.Zonos.cartData=W.cartData,window.Zonos.isLegacyCheckout=W.isLegacyCheckout,window.Zonos.cartSettings=W.cartSettings,window.Zonos.isCollect=W.isCollect,window.Zonos.isInvoice=W.isInvoice;const n=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:W.isLegacyCheckout&&!W.isCollect&&W.legacyStoreLogo?W.legacyStoreLogo:void 0}),zonosApiKey:W.zonosApiKey});o=n}window.Zonos.version&&(c(`[ZONOS - loadZonos] Execute "Zonos.init" from "${p}" from "${d}"`,"info"),P(()=>window.Zonos.init(o)))}),l.addEventListener("error",async()=>{const s=(e=>{const o=D.indexOf(e);return D[o+1]||null})(e);if(!f&&!n){if(!s)return;W.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some(e=>window.location.href.includes(e))||G)return;if(f||n)return void W.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,isError:!0,scriptLoadUrl:l.src,storeId:W.storeId||0,type:e});["unpkg","cdnjs","vercel"].includes(e)?u({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-h,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):u({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-h}})}),document.head.appendChild(l)},X.handlePerformBlurCurrency=()=>{var e,o,n;!(null===(o=null===(e=W.cartSettings)||void 0===e?void 0:e.genericSettings)||void 0===o?void 0:o.blurCurrencyOnInit)?H():(window.zonosBlurCurrencyOnInitCurrencySelector=window.zonosBlurCurrencyOnInitCurrencySelector||(null===(n=W.cartSettings)||void 0===n?void 0:n.helloSettings.currencyElementSelector),(()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;Q({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval(()=>{Q({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})},10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout(()=>{H()},7e3)})())},X.init=async o=>{var n,t;if((()=>{if(window.__zonosConstructorCapture)return;const e=e=>{E(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set},window.addEventListener("unhandledrejection",e);const o=console.error.bind(console);console.error=(...e)=>{E(e[0]),o(...e)}})(),c("=== Init zonos script release date","info",W.releaseDate),G&&!window.isZonosPreview){c(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${G}`,"info");const e=document.createElement("script");return e.src=`${G}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=W.isBigCommerce,window.Zonos.isLegacyCheckout=W.isLegacyCheckout,window.Zonos.startLoadTime=W.startLoadTime,P(()=>window.Zonos.init(o))}),e.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${G}`)}),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=K(r);if(r&&!i&&!s)return void W.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});W.cartId=r;const a=document.querySelector('script[src*="/zonos.js"]'),d=null===(n=document.querySelector("script[src*='/loadZonos.js']"))||void 0===n?void 0:n.src;c(`[ZONOS - init] first load script src: ${d}`,"info"),window.Zonos.zonosQaUrl=G,window.Zonos.zonosQaUrlApi=V,window.Zonos.zonosQaUrl&&c(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&c(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const l=null==d?void 0:d.includes("timestamp=");if(!(W.isNpm||d&&l))return void k("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(a||!d||W.requested)return void c("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!W.cartId)return W.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void k("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(W.requested=!0,W.zonosApiKey=o.zonosApiKey,W.storeId=o.storeId,W.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=K(e);if(!n&&!o)return k("[ZONOS - loadZonos] invalid cart id"),null;const t=await _({cartId:e,retries:5});return c("[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}):(k("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(W.cartId);if(!e)throw W.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");W.cartData=e.cartData,W.cartSettings=e.settings,W.legacyStoreLogo=e.storeLogo,W.legacyStoreFavicon=e.storeFavicon,W.storeId=e.storeId,W.zonosApiKey=e.zonosApiKey,W.isCollect=e.cartData.type.includes("COLLECT"),W.isInvoice="INVOICE"===e.cartData.type}if(!W.zonosApiKey)return void k('"zonosApiKey" is required to initialize Zonos');const u=await(async()=>{const e=S(),o=v();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(c("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return c("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:t}=await A("/api/get-test-public-credential");if(n.length||!t)return k("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const r=t.publicCredential;return r?(c(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(k("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(u&&(c(`[ZONOS - loadZonos] Using test API key: ${u} for test mode`,"info"),W.zonosApiKey=u),!W.cartId){const{json:o,zonosMode:n}=await(async()=>{if(window.Zonos.cartSettings)return c("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const o=e(),n=new URLSearchParams;o.overrideShouldEnabledCustomAddress&&n.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress);const t=f();t&&n.set("zCountry",t);const{errors:r,json:s,zonosMode:i}=await A(`/api/zonos-elements/zonos-settings?${n.toString()}`);return r.length?(k("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:r,json:null,zonosMode:i}):{errors:[],json:s,zonosMode:i}})();(null==o?void 0:o.appearanceSettings)&&(null==o?void 0:o.checkoutSettings)&&(null==o?void 0:o.helloSettings)&&(null==o?void 0:o.organization)&&(c("[ZONOS - loadZonos] Prefetching zonos settings","info"),W.cartSettings={appearanceSettings:o.appearanceSettings,checkoutSettings:o.checkoutSettings,credentialTokenId:W.zonosApiKey,genericSettings:o.genericSettings,helloSettings:o.helloSettings,inclusivePriceConfigurations:o.inclusivePriceConfigurations,landedCostSettings:o.landedCostSettings,onlineStoreSettings:o.onlineStoreSettings,organization:o.organization,organizationId:(null===(t=o.organization)||void 0===t?void 0:t.id)||"",shippingZones:o.shippingZones},W.zonosMode=n)}W.handlePerformBlurCurrency();const p=W.storeId||o.storeId||0;c(`[ZONOS - loadZonos] Store ID: ${p}`,"info");const w=new URLSearchParams;w.set("storeId",p.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:m,json:g}=await A(`/api/get-store-version?${w.toString()}`);if(m.length||!g)return c("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void W.injectZonos({initConfig:o,vercelUrl:"https://v1.5.2.js.zonos.com",version:null});const{isDifferent:y,source:h,version:z}=g;if(c(`[ZONOS - loadZonos] Store version: ${z}, source: ${h}`,"info"),y){c(`[ZONOS - loadZonos] Updating saved store version to ${z}`,"info");const e={storeId:p,version:z};A(`/api/set-store-version?${w.toString()}`,{body:e,method:"POST"}).catch(e=>k("Unable to save store's vesrion",e))}if(!a){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),t=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:d}),r=t&&!n?e:`${"alpha"===z?"alpha":`v${z}`}.js.zonos.com`,s=t&&!n?null:z;c("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:z}),W.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=X)})();
1
+ (function(){"use strict";const e=()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}},o=e=>/^[A-Z]{2}$/.test(e),n=["cloudflare","vercel"],t=n[0],r={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},s=r[t],i=(e=t)=>{const o=n.indexOf(e),r=n[o+1];return r||null},a=performance.now(),d=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},c=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-a,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(d).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const l=(null===(r=c.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":l.warn(e,...i);break;case"info":l.info(e,...i);break;case"error":l.error(e,...i);break;default:l.groupCollapsed(e,...i),l.trace(),l.groupEnd()}},l=()=>{const e=new URL(window.location.href);return e.searchParams.delete("payment_intent"),e.searchParams.delete("payment_intent_client_secret"),e.searchParams.delete("redirect_status"),e.toString()},u=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(c("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:e,errors:o,href:l(),metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${s}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=i();if(!o)return;fetch(`${r[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},w=(e,o)=>"string"==typeof e&&e?e:e instanceof Error&&e.message||"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message&&e.message?e.message:o,p=(e,o,n,t)=>{if(void 0===window.Zonos)return;const r=`${e}\0${o}\0${n}`,s=(window.__zonosReportedBlockedStorage||(window.__zonosReportedBlockedStorage=new Set),window.__zonosReportedBlockedStorage);s.has(r)||(s.add(r),u({endpoint:`storage://${e}/${n}`,errors:[w(t,"SecurityError")],metadata:{area:e,key:n,operation:o,shape:"blocked-storage"}}))},m=e=>{const o="local"===e?window.localStorage:window.sessionStorage;if(!o)throw new DOMException("","SecurityError");return o},g=(e,o)=>{try{m(e).removeItem(o)}catch(n){p(e,"removeItem",o,n)}},f=e=>{const n=((e,o)=>{try{return m(e).getItem(o)}catch(n){return p(e,"getItem",o,n),null}})(e,"zonos--country");return n&&o(n)?n:null},y=()=>(e=>{const n=new URLSearchParams(e||window.location.search),t=e=>{const t=n.get(e);return t&&o(t)?t:null},r=t("zCountry"),s=t("country"),i=t("customerCountry");return r||s||i})(new URL(window.location.href).searchParams)||(()=>{var e;return null!==(e=f("local"))&&void 0!==e?e:f("session")})();function h(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const v=()=>window.location.search.includes("zonosStagingMode=1"),S=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},z=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},Z=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n},C=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(C.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=(()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=Z();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(c=a,c||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var c;window.Zonos.loadTimeApiInfoList.push(d)},I=e=>502===e||503===e||504===e,L=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=z(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},O=async({basePathType:e,options:o,path:n})=>{let s;const i=window.Zonos.zonosQaUrlApi||r[e]||t,a=new URL(i+n),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(d));try{s=await fetch(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await L({response:s}),response:s,zonosMode:c}}const u=s.status.toString();try{const e=await L({response:s,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:i,errors:o.map(e=>"string"==typeof e?{message:e,type:u}:e),json:null,response:s,zonosMode:c}}return{baseUrl:i,errors:[{message:JSON.stringify(e),type:u}],json:null,response:s,zonosMode:c}}catch(e){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:I(s.status)?s:null,zonosMode:c}}},T=async({basePathType:e,options:o,path:n})=>{var t,s,a;const d=n.startsWith("/api/bigcommerce")?"vercel":e,l=performance.now(),w=await O({basePathType:d,options:o,path:n}),{errors:p,response:m}=w,g=h(w,["errors","response"]),f=performance.now()-l;c(`${n} (${f.toFixed(2)}ms)`,"info");const y=null==m?void 0:m.headers.get("Zonos-Duration");200===(null==m?void 0:m.status)&&b({apiPath:n,apiType:d,loadTimeInternal:y?Number(y):0,loadTimeTotal:f});const v=i(d),S=p.find(({type:e})=>"unknown"===e),Z=p.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),C=null==m?void 0:m.status,L=void 0!==C&&I(C),A="GET"===(null!==(t=null==o?void 0:o.method)&&void 0!==t?t:"GET").toUpperCase(),k=!!S||404===C||500===C,U=v&&(k||L&&A);return(k||L)&&!Z&&u({endpoint:r[d]+n,errors:p.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:d,nextFallbackApiType:v,requestHeaders:null==o?void 0:o.headers,requestPayload:z(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString())||(null===(a=null==o?void 0:o.body)||void 0===a?void 0:a.toString()),shouldCallFallback:U,status:null==m?void 0:m.status,statusText:null==m?void 0:m.statusText},shouldPostReleaseErrorReporting:!0}),U?(c(`=== "${n}" failed to fetch, trying next fallback ${v}`),T({basePathType:v,options:o,path:n})):Object.assign({errors:p,response:m},g)},A=async(e,o)=>{const n=h(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=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":v()?"1":void 0,"Zonos-Test-Mode":S()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach(e=>void 0===i[e]&&delete i[e]);const a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return T({basePathType:d||t,options:a,path:e})},k=(e,...o)=>{c(e,"error",...o)},U=/^Constructor for .+ was not found/,j=/^Constructor for "?([^#"]+)#/,E=e=>{var o;const n=w(e,"");if(!n||!U.test(n))return;if(void 0===window.Zonos)return;const t=window.__zonosConstructorCapture;if(!t)return;const r=j.exec(n),s=null!==(o=null==r?void 0:r[1])&&void 0!==o?o:"";t.reported.has(s)||(t.reported.add(s),u({endpoint:"stencil://constructor",errors:[n],metadata:{shape:"constructor-not-found",tag:s}}))},$=e=>{console.error(e),void 0!==window.Zonos&&u({endpoint:"zonos://init",errors:[w(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})},P=e=>{let o;try{o=e()}catch(e){return void $(e)}o.catch(e=>{$(e)})},N=()=>"undefined"!=typeof window&&"undefined"!=typeof document&&(!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),D=["jsdelivr","cdnjs","unpkg","vercel"],R=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},B=()=>{if("undefined"!=typeof window&&"Zonos"in window)return window.Zonos},F=()=>{if("undefined"==typeof window||"undefined"==typeof document)return;const e=B();if(void 0===e)return;const o=window.location.pathname.split("/").some(e=>"checkout"===e)&&(N()||(()=>{var e;return!0===(null===(e=B())||void 0===e?void 0:e.isBigCommerce)})());e.isBigCommerceNativeCheckout=o,e.isBigCommerceNativeCheckoutPath=window.location.pathname},M=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,x=new RegExp(`^${M.source}$`),K=new RegExp(`^cart_${M.source}$`),_=/^[a-zA-Z0-9]{2,}$/,q=/^cart_[a-zA-Z0-9]{2,}$/,H=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:q.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:_.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:K.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:x.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},Q=async({cartId:o,retries:n})=>{const t=S(),r=e(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;r.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress);const{errors:a,json:d,zonosMode:l}=await A(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),u=!d||a.length;return u&&n?(c("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise(e=>setTimeout(e,500)),Q({cartId:o,retries:n-1})):u?null:Object.assign(Object.assign({},d),{zonosMode:l})},W="z--blur",G=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;if(!e)return;await new Promise(e=>setTimeout(e,500)),clearInterval(e);document.querySelectorAll(`.${W}`).forEach(e=>{e.classList.remove(W)}),window.zonosBlurCurrencyOnInitIntervalId=void 0},V=({currencySelector:e,specificSelector:o})=>{if(e||o)if(o)o.classList.add(W);else{document.querySelectorAll([e].filter(Boolean).join(",")).forEach(e=>{e.classList.add(W)})}};var J;const X=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=R(window.location.href),n="https://v1.5.3.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const t=`https://${o}.preview.js.zonos.com`;return c(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then(()=>{g("session","zonos--checkout-session-id"),g("session","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:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null}),t})(),Y=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrlApi");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),o=R(window.location.href),n=e||o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if("worker"===n)return"https://worker.iglobalstores.com";if(!e)return null;const t=`https://${e}.route.js.zonos.com`;return c(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})(),ee=Date.now();class oe{}J=oe,oe.isNpm=!1,oe.isBigCommerce=!1,oe.googleAnalyticId=null,oe.googleAnalyticReady=!1,oe.facebookPixelId=null,oe.facebookPixelReady=!1,oe.requested=!1,oe.zonosMode=null,oe.cartData=null,oe.startLoadTime=ee,oe.overrideUseCustomAddressForm=!1,oe.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,oe.version="v1.5.3",oe.isLegacyCheckout=!1,oe.isCollect=!1,oe.isInvoice=!1,oe.legacyStoreLogo=null,oe.legacyStoreFavicon=null,oe.parallelLoadTimes=[],oe.parallelLoadState="off",oe.releaseDate="1794098304815",oe.loadTimeApiInfoList=[],oe.cartSettings=null,oe.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find(e=>{const o=e;return o.name.includes(r)&&"script"===o.initiatorType});null==e||e.transferSize;(async()=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},t)))}catch(e){}},oe.loadScriptLogParallelHandler=async e=>{try{if(J.parallelLoadTimes.push(e),2===J.parallelLoadTimes.length){const e=J.parallelLoadTimes.find(e=>"vercel"===e.type),o=J.parallelLoadTimes.find(e=>"jsdelivr"===e.type);if(!e||!o)return;if(e.isError&&o.isError)return void u({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});J.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},oe.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{k(`[ZONOS - loadZonos] ${e}`),u({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:J.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},oe.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.3";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.3":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.5.3");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},oe.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:J.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:J.getGithubCdn({type:e,version:r}),a=X||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),w=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${w}?timestamp=${Date.now()}`,c(`[ZONOS - loadZonos] Injecting "${w}" from "${d}"`,"info");const p="4g"===(null===(s=Z())||void 0===s?void 0:s.effectiveType),m=["dev.elements.zonos.com","zonos.com"].some(e=>window.location.href.includes(e)),g=D[0]===e,f=D[1],y="on"===J.parallelLoadState&&p&&g&&f&&!m;y&&J.injectZonos({cdnType:f,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const h=performance.now();l.addEventListener("load",async()=>{if(y||n?J.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:J.storeId||0,type:e}):J.loadScriptLogHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:J.storeId||0,type:e}),J.isBigCommerce||(J.isBigCommerce=N()),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=X,window.Zonos.zonosQaUrlApi=Y,window.Zonos.zonosMode=J.zonosMode,window.Zonos.isBigCommerce=J.isBigCommerce,F(),window.Zonos.loadTimeApiInfoList=J.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=J.overrideUseCustomAddressForm,window.Zonos.startLoadTime=J.startLoadTime,J.cartSettings&&(window.Zonos.cartSettings=J.cartSettings),J.cartId){const e=J.isCollect?"Collect":"hosted Checkout";if(!J.zonosApiKey)throw J.legacyCheckoutErrorHandler({message:`zonosApiKey is missing to initiate ${e}`}),new Error(`zonosApiKey is required for ${e}`);if(!J.cartData)throw J.legacyCheckoutErrorHandler({message:`cartData is missing to initiate ${e}`}),new Error(`cartData is required for ${e}`);if(J.legacyStoreFavicon&&J.isLegacyCheckout&&!J.isCollect)try{if(200!==(await fetch(J.legacyStoreFavicon)).status)throw new Error("Custom favicon is not available");const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=J.legacyStoreFavicon,document.head.appendChild(e)}catch(e){}window.Zonos.cartData=J.cartData,window.Zonos.isLegacyCheckout=J.isLegacyCheckout,window.Zonos.cartSettings=J.cartSettings,window.Zonos.isCollect=J.isCollect,window.Zonos.isInvoice=J.isInvoice;const n=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:J.isLegacyCheckout&&!J.isCollect&&J.legacyStoreLogo?J.legacyStoreLogo:void 0}),zonosApiKey:J.zonosApiKey});o=n}window.Zonos.version&&(c(`[ZONOS - loadZonos] Execute "Zonos.init" from "${w}" from "${d}"`,"info"),P(()=>window.Zonos.init(o)))}),l.addEventListener("error",async()=>{const s=(e=>{const o=D.indexOf(e);return D[o+1]||null})(e);if(!y&&!n){if(!s)return;J.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some(e=>window.location.href.includes(e))||X)return;if(y||n)return void J.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,isError:!0,scriptLoadUrl:l.src,storeId:J.storeId||0,type:e});["unpkg","cdnjs","vercel"].includes(e)?u({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-h,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):u({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-h}})}),document.head.appendChild(l)},oe.handlePerformBlurCurrency=()=>{var e,o,n;!(null===(o=null===(e=J.cartSettings)||void 0===e?void 0:e.genericSettings)||void 0===o?void 0:o.blurCurrencyOnInit)?G():(window.zonosBlurCurrencyOnInitCurrencySelector=window.zonosBlurCurrencyOnInitCurrencySelector||(null===(n=J.cartSettings)||void 0===n?void 0:n.helloSettings.currencyElementSelector),(()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;V({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval(()=>{V({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})},10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout(()=>{G()},7e3)})())},oe.init=async o=>{var n,t;if((()=>{if(window.__zonosConstructorCapture)return;const e=e=>{E(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set},window.addEventListener("unhandledrejection",e);const o=console.error.bind(console);console.error=(...e)=>{E(e[0]),o(...e)}})(),c("=== Init zonos script release date","info",J.releaseDate),X&&!window.isZonosPreview){c(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${X}`,"info");const e=document.createElement("script");return e.src=`${X}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=J.isBigCommerce,window.Zonos.isLegacyCheckout=J.isLegacyCheckout,window.Zonos.startLoadTime=J.startLoadTime,P(()=>window.Zonos.init(o))}),e.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${X}`)}),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=H(r);if(r&&!i&&!s)return void J.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});J.cartId=r;const a=document.querySelector('script[src*="/zonos.js"]'),d=null===(n=document.querySelector("script[src*='/loadZonos.js']"))||void 0===n?void 0:n.src;c(`[ZONOS - init] first load script src: ${d}`,"info"),window.Zonos.zonosQaUrl=X,window.Zonos.zonosQaUrlApi=Y,window.Zonos.zonosQaUrl&&c(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&c(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const l=null==d?void 0:d.includes("timestamp=");if(!(J.isNpm||d&&l))return void k("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(a||!d||J.requested)return void c("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!J.cartId)return J.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void k("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(J.requested=!0,J.zonosApiKey=o.zonosApiKey,J.storeId=o.storeId,J.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=H(e);if(!n&&!o)return k("[ZONOS - loadZonos] invalid cart id"),null;const t=await Q({cartId:e,retries:5});return c("[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}):(k("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(J.cartId);if(!e)throw J.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");J.cartData=e.cartData,J.cartSettings=e.settings,J.legacyStoreLogo=e.storeLogo,J.legacyStoreFavicon=e.storeFavicon,J.storeId=e.storeId,J.zonosApiKey=e.zonosApiKey,J.isCollect=e.cartData.type.includes("COLLECT"),J.isInvoice="INVOICE"===e.cartData.type}if(!J.zonosApiKey)return void k('"zonosApiKey" is required to initialize Zonos');const u=await(async()=>{const e=S(),o=v();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(c("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return c("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:t}=await A("/api/get-test-public-credential");if(n.length||!t)return k("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const r=t.publicCredential;return r?(c(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(k("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(u&&(c(`[ZONOS - loadZonos] Using test API key: ${u} for test mode`,"info"),J.zonosApiKey=u),!J.cartId){const{json:o,zonosMode:n}=await(async()=>{if(window.Zonos.cartSettings)return c("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const o=e(),n=new URLSearchParams;o.overrideShouldEnabledCustomAddress&&n.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress);const t=y();t&&n.set("zCountry",t);const{errors:r,json:s,zonosMode:i}=await A(`/api/zonos-elements/zonos-settings?${n.toString()}`);return r.length?(k("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:r,json:null,zonosMode:i}):{errors:[],json:s,zonosMode:i}})();(null==o?void 0:o.appearanceSettings)&&(null==o?void 0:o.checkoutSettings)&&(null==o?void 0:o.helloSettings)&&(null==o?void 0:o.organization)&&(c("[ZONOS - loadZonos] Prefetching zonos settings","info"),J.cartSettings={appearanceSettings:o.appearanceSettings,checkoutSettings:o.checkoutSettings,credentialTokenId:J.zonosApiKey,genericSettings:o.genericSettings,helloSettings:o.helloSettings,inclusivePriceConfigurations:o.inclusivePriceConfigurations,landedCostSettings:o.landedCostSettings,onlineStoreSettings:o.onlineStoreSettings,organization:o.organization,organizationId:(null===(t=o.organization)||void 0===t?void 0:t.id)||"",shippingZones:o.shippingZones},J.zonosMode=n)}J.handlePerformBlurCurrency();const w=J.storeId||o.storeId||0;c(`[ZONOS - loadZonos] Store ID: ${w}`,"info");const p=new URLSearchParams;p.set("storeId",w.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&p.set("_enableStoreVersionPinned","1");const{errors:m,json:g}=await A(`/api/get-store-version?${p.toString()}`);if(m.length||!g)return c("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void J.injectZonos({initConfig:o,vercelUrl:"https://v1.5.3.js.zonos.com",version:null});const{isDifferent:f,source:h,version:z}=g;if(c(`[ZONOS - loadZonos] Store version: ${z}, source: ${h}`,"info"),f){c(`[ZONOS - loadZonos] Updating saved store version to ${z}`,"info");const e={storeId:w,version:z};A(`/api/set-store-version?${p.toString()}`,{body:e,method:"POST"}).catch(e=>k("Unable to save store's vesrion",e))}if(!a){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),t=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:d}),r=t&&!n?e:`${"alpha"===z?"alpha":`v${z}`}.js.zonos.com`,s=t&&!n?null:z;c("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:z}),J.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=oe)})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=["cloudflare","vercel"],n=t[0],r={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},s=r[n],i=(e=n)=>{const o=t.indexOf(e),r=t[o+1];return r||null},a=performance.now(),d=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},l=(e,o,...t)=>{var n,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-a,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...t];i.map(d).join(" ");if(!(!!(null===(n=window.Zonos)||void 0===n?void 0:n.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const c=(null===(r=l.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":c.warn(e,...i);break;case"info":c.info(e,...i);break;case"error":c.error(e,...i);break;default:c.groupCollapsed(e,...i),c.trace(),c.groupEnd()}},c=()=>{const e=new URL(window.location.href);return e.searchParams.delete("payment_intent"),e.searchParams.delete("payment_intent_client_secret"),e.searchParams.delete("redirect_status"),e.toString()},u=async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{if(l("sendErrorLog","warn",e,t,o),n){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:e,errors:o,href:c(),metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},t)};try{fetch(`${s}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=i();if(!o)return;fetch(`${r[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},p=(e,o)=>"string"==typeof e&&e?e:e instanceof Error&&e.message||"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message&&e.message?e.message:o,m=/^Constructor for .+ was not found/,w=/^Constructor for "?([^#"]+)#/,h=e=>{var o;const t=p(e,"");if(!t||!m.test(t))return;if(void 0===window.Zonos)return;const n=window.__zonosConstructorCapture;if(!n)return;const r=w.exec(t),s=null!==(o=null==r?void 0:r[1])&&void 0!==o?o:"";n.reported.has(s)||(n.reported.add(s),u({endpoint:"stencil://constructor",errors:[t],metadata:{shape:"constructor-not-found",tag:s}}))},y=(e,...o)=>{l(e,"error",...o)},g=e=>{console.error(e),void 0!==window.Zonos&&u({endpoint:"zonos://init",errors:[p(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})},f=(e,o,t,n)=>{if(void 0===window.Zonos)return;const r=`${e}\0${o}\0${t}`,s=(window.__zonosReportedBlockedStorage||(window.__zonosReportedBlockedStorage=new Set),window.__zonosReportedBlockedStorage);s.has(r)||(s.add(r),u({endpoint:`storage://${e}/${t}`,errors:[p(n,"SecurityError")],metadata:{area:e,key:t,operation:o,shape:"blocked-storage"}}))},v=e=>{const o="local"===e?window.localStorage:window.sessionStorage;if(!o)throw new DOMException("","SecurityError");return o},b=(e,o)=>{try{v(e).removeItem(o)}catch(t){f(e,"removeItem",o,t)}},S=["jsdelivr","cdnjs","unpkg","vercel"],C="jsdelivr",z=e=>{const o=S.indexOf(e);return S[o+1]||null},k=()=>window.location.search.includes("zonosStagingMode=1"),Z=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function j(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const I=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},O=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},E=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],A=e=>502===e||503===e||504===e,T=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=I(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},L=async({basePathType:e,options:o,path:t})=>{let s;const i=window.Zonos.zonosQaUrlApi||r[e]||n,a=new URL(i+t),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(d));try{s=await fetch(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const l=s.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&l&&c&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await T({response:s}),response:s,zonosMode:l}}const u=s.status.toString();try{const e=await T({response:s,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:i,errors:o.map(e=>"string"==typeof e?{message:e,type:u}:e),json:null,response:s,zonosMode:l}}return{baseUrl:i,errors:[{message:JSON.stringify(e),type:u}],json:null,response:s,zonosMode:l}}catch(e){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:A(s.status)?s:null,zonosMode:l}}},P=async({basePathType:e,options:o,path:t})=>{var n,s,a;const d=t.startsWith("/api/bigcommerce")?"vercel":e,c=performance.now(),p=await L({basePathType:d,options:o,path:t}),{errors:m,response:w}=p,h=j(p,["errors","response"]),y=performance.now()-c;l(`${t} (${y.toFixed(2)}ms)`,"info");const g=null==w?void 0:w.headers.get("Zonos-Duration");200===(null==w?void 0:w.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(E.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=O(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)})({apiPath:t,apiType:d,loadTimeInternal:g?Number(g):0,loadTimeTotal:y});const f=i(d),v=m.find(({type:e})=>"unknown"===e),b=m.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),S=null==w?void 0:w.status,C=void 0!==S&&A(S),z="GET"===(null!==(n=null==o?void 0:o.method)&&void 0!==n?n:"GET").toUpperCase(),k=!!v||404===S||500===S,Z=f&&(k||C&&z);return(k||C)&&!b&&u({endpoint:r[d]+t,errors:m.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:d,nextFallbackApiType:f,requestHeaders:null==o?void 0:o.headers,requestPayload:I(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString())||(null===(a=null==o?void 0:o.body)||void 0===a?void 0:a.toString()),shouldCallFallback:Z,status:null==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),Z?(l(`=== "${t}" failed to fetch, trying next fallback ${f}`),P({basePathType:f,options:o,path:t})):Object.assign({errors:m,response:w},h)},$=async(e,o)=>{const t=j(o||{},[]),r=t.body?JSON.stringify(t.body):void 0,s=t.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":k()?"1":void 0,"Zonos-Test-Mode":Z()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(i).forEach(e=>void 0===i[e]&&delete i[e]);const a=Object.assign(Object.assign({},t),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return P({basePathType:d||n,options:a,path:e})},U=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.5.2.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const n=`https://${o}.preview.js.zonos.com`;return l(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then(()=>{b("session","zonos--checkout-session-id"),b("session","zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null}),n},D="https://js.stripe.com/v3",N=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let R=null;const x=e=>(null!==R||(R=new Promise((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${D}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&N.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(()=>{const e=document.createElement("script");e.src=`${D}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(y("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}),null==n||n.addEventListener("error",()=>{t(new Error("Failed to load Stripe.js"))})}catch(e){return void t(e)}else o(null)})),R),F=Promise.resolve().then(()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?x(null):null);let M=!1;F.catch(e=>{M||console.warn(e)});const B=async(...e)=>{var o;M=!0;const t=Date.now();return((e,o,t)=>{if(null===e)return null;const[n,r]=o,s=Object.assign({},r),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete s.apiVersion:s.apiVersion="2025-02-24.acacia";const a=e(n,s);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(a,t),a})(null!==(o=await F)&&void 0!==o?o:await x(null),e,t)},_=async({cartId:e,retries:o})=>{const t=Z(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),r=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,s=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&s.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:i,json:a,zonosMode:d}=await $(`/api/zonos-elements/get-cart?${s.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:r,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),c=!a||i.length;return c&&o?(l("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise(e=>setTimeout(e,500)),_({cartId:e,retries:o-1})):c?null:Object.assign(Object.assign({},a),{zonosMode:d})},q=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,W=new RegExp(`^${q.source}$`),G=new RegExp(`^cart_${q.source}$`),K=/^[a-zA-Z0-9]{2,}$/,H=/^cart_[a-zA-Z0-9]{2,}$/,V=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:H.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:K.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:G.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:W.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return y("[ZONOS - loadZonos] invalid cart id"),null;const n=await _({cartId:e,retries:5});return l("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(y("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},Q="zonos--checkout-hidden-international-button";var J;const X=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),n=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),Y=Date.now(),ee="https://v1.5.2.js.zonos.com",oe=X||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.2",te="https://fonts.googleapis.com",ne=/^https:\/\/fonts\.googleapis\.com/;class re{}J=re,re.doneInit=!1,re.cartSettings=null,re.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),re.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),re._paypalMockResponse=null,re.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,re.isBigCommerce=!1,re.releaseDate="1793899943651",re.isLegacyCheckout=!1,re.googleAnalyticId=null,re.googleAnalyticReady=!1,re.facebookPixelId=null,re.facebookPixelReady=!1,re.startLoadTime=Y,re.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",re.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),re.overrideUseCustomAddressForm=!1,re.isCollect=!1,re.isInvoice=!1,re.isNpm=!0,re.zonosQaUrl=null,re.zonosQaUrlApi=null,re.trackEventLogs=[],re.version="v1.5.2",re.modeAlerted=!1,re.cartData=null,re.paypal=null,re.zonosMode=null,re.IframeService=o,re.getCurrentTimestamp=()=>(new Date).getTime(),re.zonosController=null,re.loadTimeApiInfoList=[],re.logIntervalId=null,re.init=async e=>{(()=>{if(window.__zonosConstructorCapture)return;const e=e=>{h(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set},window.addEventListener("unhandledrejection",e);const o=console.error.bind(console);console.error=(...e)=>{h(e[0]),o(...e)}})();const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:r,onCountryChange:s,overrideCurrencyFormat:i,storeId:a,zonosApiKey:d}=e;if(J.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),J.createCartId=null==t?void 0:t.createCartId,J.buildCartDetail=null==t?void 0:t.buildCartDetail,J.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${J.version}) ======`),J.zonosApiKey=d,J.storeId=a,"undefined"!=typeof window&&window.parent===window&&(J.googleAnalyticReady=!0,J.facebookPixelReady=!0),J.isNpm){l("====== ZONOS LOADING FROM NPM ======");const o=U();if(o&&!window.isZonosPreview){l(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",()=>{window.Zonos.isNpm=J.isNpm,window.Zonos.isBigCommerce=J.isBigCommerce,window.Zonos.isLegacyCheckout=J.isLegacyCheckout,window.Zonos.zonosMode=J.zonosMode,(e=>{let o;try{o=e()}catch(e){return void g(e)}o.catch(e=>{g(e)})})(()=>window.Zonos.init(e))}),t.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)}),void(window.isZonosPreview=!0)}if(!d&&!J.cartId)return void y("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!J.cartData&&J.cartId){l("Initialize cart data");const e=await V(J.cartId);if(!e)return void y("Failed to get cart data");J.cartData=e.cartData,J.zonosApiKey=e.zonosApiKey,J.cartSettings=e.settings}const t=await(async()=>{const e=Z(),o=k();if(!e&&!o||!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:t,json:n}=await $("/api/get-test-public-credential");if(t.length||!n)return y("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const r=n.publicCredential;return r?(l(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(y("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(J.zonosApiKey=t)}const c=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||((e,o)=>{try{return v(e).getItem(o)}catch(t){return f(e,"getItem",o,t),null}})("session","zonos--client-secret");if(J.cartId&&J.cartData||!!c){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="zonos--checkout-hidden-button",document.body.appendChild(e)}l("init zonos"),J.restoreNativeBrowserFunctions(),J.injectCustomScriptForHostedCheckout(),J.injectZonosCdn(),J.injectZonosCss(),J.injectFonts(),J.injectCheckoutInternationalButton(),J.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:r,onCountryChange:s,overrideCurrencyFormat:i}}),J.doneInit=!0},re.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${Q}`)){const e=document.createElement("button");e.id=Q,e.style.display="none",document.body.appendChild(e)}},re.injectCustomScriptForHostedCheckout=()=>{const e=J.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find(e=>"customHeaderScript"===e.key),n=o.find(e=>"customFooterScript"===e.key);if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){l("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},re.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},re.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${Q}`);setTimeout(()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))},10)},re.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},re.showNotification=e=>{var o;null===(o=J.zonosController)||void 0===o||o.showNotification(e)},re.updateOrganizationName=e=>{var o;null===(o=J.zonosController)||void 0===o||o.updateOrganizationName(e)},re.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach(e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))}),e&&t&&setTimeout(()=>{o.forEach(e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)})},5e3)}},re.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},re.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;J.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{J.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;J.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{J.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=J.zonosApiKey||"",n.addEventListener("stripeInitEvent",async e=>{const{detail:o}=e;l("loading Stripe");const t=await B(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):y("API seems to be invalid or missing. Failed to load Stripe")}),document.body.appendChild(n),J.zonosController=n,l("Zonos controller injected!")},re.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${J.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void l(`Zonos script "${n}" already exists in the document`,"warn");const r=document.head||document.body,s=document.createElement("script");o?s.type="module":s.noModule=!0,s.src=n,s.crossOrigin="anonymous",s.onerror=()=>{y(`Failed to load ${s.src}`);const n=z(e);n&&J.injectScript({cdnType:n,isModule:o,theRestUrl:t})},r.appendChild(s)},re.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return oe;case"unpkg":return"https://unpkg.com/@zonos/elements@1.5.2";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.2";case"vercel":return ee}};if(J.isNpm){return U()||o()}return o()},re.injectZonosCdn=()=>{J.injectScript({cdnType:C,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),J.injectScript({cdnType:C,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},re.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=J.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${ee}/`,n.appendChild(r);const s=document.createElement("link");s.rel="stylesheet",s.href=`${t}/${o}`,s.onerror=()=>{y(`Failed to load ${s.href}`);const t=z(e);t&&J.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(s)},re.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(J.injectStylesheet({cdnType:C,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},re.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${te}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!ne.test(t.href))return t}return null})())return void l("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=te,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${te}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),l("Zonos font injected!")},re.setupGoogleFont=e=>{var o;null===(o=J.zonosController)||void 0===o||o.setupGoogleFont(e)},re.injectSupportGoogleFont=e=>{var o;l(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${te}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=te,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void l(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=e,n.appendChild(r),l(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=re)})();
1
+ (function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=["cloudflare","vercel"],n=t[0],r={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},s=r[n],i=(e=n)=>{const o=t.indexOf(e),r=t[o+1];return r||null},a=performance.now(),d=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},c=(e,o,...t)=>{var n,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-a,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...t];i.map(d).join(" ");if(!(!!(null===(n=window.Zonos)||void 0===n?void 0:n.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const l=(null===(r=c.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":l.warn(e,...i);break;case"info":l.info(e,...i);break;case"error":l.error(e,...i);break;default:l.groupCollapsed(e,...i),l.trace(),l.groupEnd()}},l=()=>{const e=new URL(window.location.href);return e.searchParams.delete("payment_intent"),e.searchParams.delete("payment_intent_client_secret"),e.searchParams.delete("redirect_status"),e.toString()},u=async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{if(c("sendErrorLog","warn",e,t,o),n){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:e,errors:o,href:l(),metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},t)};try{fetch(`${s}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=i();if(!o)return;fetch(`${r[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},p=(e,o)=>"string"==typeof e&&e?e:e instanceof Error&&e.message||"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message&&e.message?e.message:o,m=/^Constructor for .+ was not found/,w=/^Constructor for "?([^#"]+)#/,h=e=>{var o;const t=p(e,"");if(!t||!m.test(t))return;if(void 0===window.Zonos)return;const n=window.__zonosConstructorCapture;if(!n)return;const r=w.exec(t),s=null!==(o=null==r?void 0:r[1])&&void 0!==o?o:"";n.reported.has(s)||(n.reported.add(s),u({endpoint:"stencil://constructor",errors:[t],metadata:{shape:"constructor-not-found",tag:s}}))},y=(e,...o)=>{c(e,"error",...o)},g=e=>{console.error(e),void 0!==window.Zonos&&u({endpoint:"zonos://init",errors:[p(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})},f=(e,o,t,n)=>{if(void 0===window.Zonos)return;const r=`${e}\0${o}\0${t}`,s=(window.__zonosReportedBlockedStorage||(window.__zonosReportedBlockedStorage=new Set),window.__zonosReportedBlockedStorage);s.has(r)||(s.add(r),u({endpoint:`storage://${e}/${t}`,errors:[p(n,"SecurityError")],metadata:{area:e,key:t,operation:o,shape:"blocked-storage"}}))},v=e=>{const o="local"===e?window.localStorage:window.sessionStorage;if(!o)throw new DOMException("","SecurityError");return o},b=(e,o)=>{try{v(e).removeItem(o)}catch(t){f(e,"removeItem",o,t)}},C=["jsdelivr","cdnjs","unpkg","vercel"],S="jsdelivr",z=e=>{const o=C.indexOf(e);return C[o+1]||null},k=()=>window.location.search.includes("zonosStagingMode=1"),Z=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function j(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const I=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},O=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},E=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],A=e=>502===e||503===e||504===e,T=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=I(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},L=async({basePathType:e,options:o,path:t})=>{let s;const i=window.Zonos.zonosQaUrlApi||r[e]||n,a=new URL(i+t),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(d));try{s=await fetch(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await T({response:s}),response:s,zonosMode:c}}const u=s.status.toString();try{const e=await T({response:s,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:i,errors:o.map(e=>"string"==typeof e?{message:e,type:u}:e),json:null,response:s,zonosMode:c}}return{baseUrl:i,errors:[{message:JSON.stringify(e),type:u}],json:null,response:s,zonosMode:c}}catch(e){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:A(s.status)?s:null,zonosMode:c}}},P=async({basePathType:e,options:o,path:t})=>{var n,s,a;const d=t.startsWith("/api/bigcommerce")?"vercel":e,l=performance.now(),p=await L({basePathType:d,options:o,path:t}),{errors:m,response:w}=p,h=j(p,["errors","response"]),y=performance.now()-l;c(`${t} (${y.toFixed(2)}ms)`,"info");const g=null==w?void 0:w.headers.get("Zonos-Duration");200===(null==w?void 0:w.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(E.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=O(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(c=a,c||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var c;window.Zonos.loadTimeApiInfoList.push(d)})({apiPath:t,apiType:d,loadTimeInternal:g?Number(g):0,loadTimeTotal:y});const f=i(d),v=m.find(({type:e})=>"unknown"===e),b=m.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),C=null==w?void 0:w.status,S=void 0!==C&&A(C),z="GET"===(null!==(n=null==o?void 0:o.method)&&void 0!==n?n:"GET").toUpperCase(),k=!!v||404===C||500===C,Z=f&&(k||S&&z);return(k||S)&&!b&&u({endpoint:r[d]+t,errors:m.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:d,nextFallbackApiType:f,requestHeaders:null==o?void 0:o.headers,requestPayload:I(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString())||(null===(a=null==o?void 0:o.body)||void 0===a?void 0:a.toString()),shouldCallFallback:Z,status:null==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),Z?(c(`=== "${t}" failed to fetch, trying next fallback ${f}`),P({basePathType:f,options:o,path:t})):Object.assign({errors:m,response:w},h)},$=async(e,o)=>{const t=j(o||{},[]),r=t.body?JSON.stringify(t.body):void 0,s=t.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":k()?"1":void 0,"Zonos-Test-Mode":Z()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(i).forEach(e=>void 0===i[e]&&delete i[e]);const a=Object.assign(Object.assign({},t),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return P({basePathType:d||n,options:a,path:e})},N=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.5.3.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const n=`https://${o}.preview.js.zonos.com`;return c(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then(()=>{b("session","zonos--checkout-session-id"),b("session","zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null}),n},U=()=>"undefined"!=typeof window&&"undefined"!=typeof document&&(!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),D=()=>window.location.pathname.split("/").some(e=>"checkout"===e),R=()=>{if("undefined"!=typeof window&&"Zonos"in window)return window.Zonos},x=()=>{var e;return!0===(null===(e=R())||void 0===e?void 0:e.isBigCommerce)},F=e=>{const o=R();return void 0!==o&&(o.isBigCommerceNativeCheckout=e,o.isBigCommerceNativeCheckoutPath=window.location.pathname),e},M=()=>{if("undefined"==typeof window||"undefined"==typeof document)return!1;const e=(()=>{const e=R();if(void 0===e)return;if(e.isBigCommerceNativeCheckoutPath!==window.location.pathname)return;const o=e.isBigCommerceNativeCheckout;return!0===o||!1===o?o:void 0})();return void 0!==e?e:D()?U()||x()?F(!0):void 0:F(!1)},B="https://js.stripe.com/v3",_=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let q=null;const W=e=>(null!==q||(q=new Promise((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${B}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&_.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(()=>{const e=document.createElement("script");e.src=`${B}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(y("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}),null==n||n.addEventListener("error",()=>{t(new Error("Failed to load Stripe.js"))})}catch(e){return void t(e)}else o(null)})),q),G=()=>(()=>{const e=M();return void 0===e||e})()?Promise.resolve(null):W(null),K=Promise.resolve().then(()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?G():null);let H=!1;K.catch(e=>{H||console.warn(e)});const V=async(...e)=>{var o;H=!0;const t=Date.now();return((e,o,t)=>{if(null===e)return null;const[n,r]=o,s=Object.assign({},r),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete s.apiVersion:s.apiVersion="2025-02-24.acacia";const a=e(n,s);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(a,t),a})(null!==(o=await K)&&void 0!==o?o:await G(),e,t)},Q=async({cartId:e,retries:o})=>{const t=Z(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),r=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,s=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&s.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:i,json:a,zonosMode:d}=await $(`/api/zonos-elements/get-cart?${s.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:r,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),l=!a||i.length;return l&&o?(c("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise(e=>setTimeout(e,500)),Q({cartId:e,retries:o-1})):l?null:Object.assign(Object.assign({},a),{zonosMode:d})},J=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,X=new RegExp(`^${J.source}$`),Y=new RegExp(`^cart_${J.source}$`),ee=/^[a-zA-Z0-9]{2,}$/,oe=/^cart_[a-zA-Z0-9]{2,}$/,te=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:oe.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:ee.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:Y.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:X.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return y("[ZONOS - loadZonos] invalid cart id"),null;const n=await Q({cartId:e,retries:5});return c("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(y("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},ne="zonos--checkout-hidden-international-button";var re;const se=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),n=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),ie=Date.now(),ae="https://v1.5.3.js.zonos.com",de=se||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.3",ce="https://fonts.googleapis.com",le=/^https:\/\/fonts\.googleapis\.com/;class ue{}re=ue,ue.doneInit=!1,ue.cartSettings=null,ue.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),ue.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),ue._paypalMockResponse=null,ue.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,ue.isBigCommerce=!1,ue.releaseDate="1794098304815",ue.isLegacyCheckout=!1,ue.googleAnalyticId=null,ue.googleAnalyticReady=!1,ue.facebookPixelId=null,ue.facebookPixelReady=!1,ue.startLoadTime=ie,ue.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",ue.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),ue.overrideUseCustomAddressForm=!1,ue.isCollect=!1,ue.isInvoice=!1,ue.isNpm=!0,ue.zonosQaUrl=null,ue.zonosQaUrlApi=null,ue.trackEventLogs=[],ue.version="v1.5.3",ue.modeAlerted=!1,ue.cartData=null,ue.paypal=null,ue.zonosMode=null,ue.IframeService=o,ue.getCurrentTimestamp=()=>(new Date).getTime(),ue.zonosController=null,ue.loadTimeApiInfoList=[],ue.logIntervalId=null,ue.init=async e=>{(()=>{if(window.__zonosConstructorCapture)return;const e=e=>{h(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set},window.addEventListener("unhandledrejection",e);const o=console.error.bind(console);console.error=(...e)=>{h(e[0]),o(...e)}})();const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:r,onCountryChange:s,overrideCurrencyFormat:i,storeId:a,zonosApiKey:d}=e;if(re.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),re.createCartId=null==t?void 0:t.createCartId,re.buildCartDetail=null==t?void 0:t.buildCartDetail,re.doneInit)return;if((()=>{if("undefined"==typeof window||"undefined"==typeof document)return;const e=R();if(void 0===e)return;const o=D()&&(U()||x());e.isBigCommerceNativeCheckout=o,e.isBigCommerceNativeCheckoutPath=window.location.pathname})(),c(`====== ZONOS DEBUG MODE: on (${re.version}) ======`),re.zonosApiKey=d,re.storeId=a,"undefined"!=typeof window&&window.parent===window&&(re.googleAnalyticReady=!0,re.facebookPixelReady=!0),re.isNpm){c("====== ZONOS LOADING FROM NPM ======");const o=N();if(o&&!window.isZonosPreview){c(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",()=>{window.Zonos.isNpm=re.isNpm,window.Zonos.isBigCommerce=re.isBigCommerce,window.Zonos.isLegacyCheckout=re.isLegacyCheckout,window.Zonos.zonosMode=re.zonosMode,(e=>{let o;try{o=e()}catch(e){return void g(e)}o.catch(e=>{g(e)})})(()=>window.Zonos.init(e))}),t.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)}),void(window.isZonosPreview=!0)}if(!d&&!re.cartId)return void y("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!re.cartData&&re.cartId){c("Initialize cart data");const e=await te(re.cartId);if(!e)return void y("Failed to get cart data");re.cartData=e.cartData,re.zonosApiKey=e.zonosApiKey,re.cartSettings=e.settings}const t=await(async()=>{const e=Z(),o=k();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(c("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return c("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await $("/api/get-test-public-credential");if(t.length||!n)return y("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const r=n.publicCredential;return r?(c(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(y("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(re.zonosApiKey=t)}const l=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||((e,o)=>{try{return v(e).getItem(o)}catch(t){return f(e,"getItem",o,t),null}})("session","zonos--client-secret");if(re.cartId&&re.cartData||!!l){c("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="zonos--checkout-hidden-button",document.body.appendChild(e)}c("init zonos"),re.restoreNativeBrowserFunctions(),re.injectCustomScriptForHostedCheckout(),re.injectZonosCdn(),re.injectZonosCss(),re.injectFonts(),re.injectCheckoutInternationalButton(),re.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:r,onCountryChange:s,overrideCurrencyFormat:i}}),re.doneInit=!0},ue.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${ne}`)){const e=document.createElement("button");e.id=ne,e.style.display="none",document.body.appendChild(e)}},ue.injectCustomScriptForHostedCheckout=()=>{const e=re.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find(e=>"customHeaderScript"===e.key),n=o.find(e=>"customFooterScript"===e.key);if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){c("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){c("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else c("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},ue.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},ue.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${ne}`);setTimeout(()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))},10)},ue.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},ue.showNotification=e=>{var o;null===(o=re.zonosController)||void 0===o||o.showNotification(e)},ue.updateOrganizationName=e=>{var o;null===(o=re.zonosController)||void 0===o||o.updateOrganizationName(e)},ue.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach(e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))}),e&&t&&setTimeout(()=>{o.forEach(e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)})},5e3)}},ue.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},ue.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(!0!==M()){if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;re.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{re.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;re.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{re.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=re.zonosApiKey||"",n.addEventListener("stripeInitEvent",async e=>{const{detail:o}=e;c("loading Stripe");const t=await V(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):y("API seems to be invalid or missing. Failed to load Stripe")}),document.body.appendChild(n),re.zonosController=n,c("Zonos controller injected!")},ue.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${re.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void c(`Zonos script "${n}" already exists in the document`,"warn");const r=document.head||document.body,s=document.createElement("script");o?s.type="module":s.noModule=!0,s.src=n,s.crossOrigin="anonymous",s.onerror=()=>{y(`Failed to load ${s.src}`);const n=z(e);n&&re.injectScript({cdnType:n,isModule:o,theRestUrl:t})},r.appendChild(s)},ue.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return de;case"unpkg":return"https://unpkg.com/@zonos/elements@1.5.3";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.3";case"vercel":return ae}};if(re.isNpm){return N()||o()}return o()},ue.injectZonosCdn=()=>{re.injectScript({cdnType:S,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),re.injectScript({cdnType:S,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),c("Zonos cdn script injected!")},ue.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=re.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${ae}/`,n.appendChild(r);const s=document.createElement("link");s.rel="stylesheet",s.href=`${t}/${o}`,s.onerror=()=>{y(`Failed to load ${s.href}`);const t=z(e);t&&re.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(s)},ue.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?c("Zonos style links already injected","warn"):(re.injectStylesheet({cdnType:S,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),c("Zonos style css injected!"))},ue.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void c("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${ce}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!le.test(t.href))return t}return null})())return void c("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=ce,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${ce}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),c("Zonos font injected!")},ue.setupGoogleFont=e=>{var o;null===(o=re.zonosController)||void 0===o||o.setupGoogleFont(e)},ue.injectSupportGoogleFont=e=>{var o;c(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${ce}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=ce,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void c(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=e,n.appendChild(r),c(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=ue)})();
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Mount `<zonos-checkout>` without a Stripe instance.
3
+ *
4
+ * Native BigCommerce checkout must not receive Stripe.js. Creating the
5
+ * element still runs `zonos-checkout.init()`, which registers the
6
+ * international-address watcher and then returns before the Stripe poll.
7
+ */
8
+ export declare const mountCheckoutWithoutStripe: () => void;
@@ -146,6 +146,9 @@ export type DomesticShippingSession = {
146
146
  postalCode: string;
147
147
  state: string;
148
148
  };
149
+ declare const DOMESTIC_SESSION_REDIRECT_MARKER = "zonos--bc-domestic-session-redirected";
150
+ declare const stripeStoreHasDomesticSessionRedirectMarker: () => boolean;
151
+ declare const stripeStoreMarkDomesticSessionRedirected: () => void;
149
152
  declare const stripeStoreCleanupDomesticShippingSession: () => void;
150
153
  declare const stripeStoreSaveDomesticShippingSession: (props: DomesticShippingSession) => void;
151
154
  declare const stripeStoreGetDomesticShippingSession: () => DomesticShippingSession | null;
@@ -268,4 +271,4 @@ declare const stripeStoreTranslateAddressToLatin: ({ addressInvalidCharactersLis
268
271
  addressInvalidCharactersList: ReturnType<typeof containsNonLatinChars> | null;
269
272
  billingAddressInvalidCharactersList: ReturnType<typeof containsNonLatinChars> | null;
270
273
  }) => Promise<void>;
271
- export { initStripeElements, stripeCalculateLandedCost, stripeStore, stripeStoreApplyPromoCode, stripeStoreAsyncAddressUpdate, stripeStoreBuildAddressForPartyCreate, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreGetPaymentIntent, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStoreMessageBasedOnStatus, stripeStoreOnChange, stripeStorePrefetchLandedCost, stripeStoreRemovePromoCode, stripeStoreReset, stripeStoreResetPromoCode, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreTranslateAddressToLatin, stripeStoreUpdateCheckoutSession, stripeStoreUpdateCheckoutSessionBaseCurrency, };
274
+ export { DOMESTIC_SESSION_REDIRECT_MARKER, initStripeElements, stripeCalculateLandedCost, stripeStore, stripeStoreApplyPromoCode, stripeStoreAsyncAddressUpdate, stripeStoreBuildAddressForPartyCreate, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreGetPaymentIntent, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreHasDomesticSessionRedirectMarker, stripeStoreInitCheckoutSession, stripeStoreMarkDomesticSessionRedirected, stripeStoreMessageBasedOnStatus, stripeStoreOnChange, stripeStorePrefetchLandedCost, stripeStoreRemovePromoCode, stripeStoreReset, stripeStoreResetPromoCode, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreTranslateAddressToLatin, stripeStoreUpdateCheckoutSession, stripeStoreUpdateCheckoutSessionBaseCurrency, };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Two checkout-path rules, kept together so they cannot drift in separate files.
3
+ *
4
+ * `pathContainsCheckout` is the broad rule for zBypass and address detection.
5
+ * It still matches paths such as `checkout-page`.
6
+ *
7
+ * `hasExactCheckoutSegment` is the strict rule for the Stripe.js skip. Only a
8
+ * segment exactly equal to `checkout` counts, so a slug does not drop the
9
+ * payment script.
10
+ */
11
+ export declare const pathContainsCheckout: (pathname: string) => boolean;
12
+ export declare const hasExactCheckoutSegment: (pathname: string) => boolean;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Storefront signals BigCommerce sets before Zonos copies `isBigCommerce`.
3
+ * Shared by the loader script and the Stripe skip so the two cannot drift.
4
+ */
5
+ export declare const detectBigCommerceHost: () => boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Call after `isBigCommerce` has been copied from host detection. Writes the
3
+ * settled boolean onto `window.Zonos` for this pathname.
4
+ */
5
+ export declare const markBigCommerceHostChecked: () => void;
6
+ /** Test helper. Production pages keep the answer for the document. */
7
+ export declare const resetBigCommerceNativeCheckoutCache: () => void;
8
+ /**
9
+ * True when this document is BigCommerce native checkout.
10
+ * Stripe.js injection is owned by `loadStripeScript` in `_loadStripe.ts`.
11
+ * Other callers use this for a different job: skip `attachCheckout`, leave
12
+ * the store's buttons enabled, or hand a leftover domestic session to `/`.
13
+ * An undecided checkout path returns false and is not stored.
14
+ */
15
+ export declare const isBigCommerceNativeCheckout: () => boolean;
16
+ /**
17
+ * True when Stripe.js must not be injected. An undecided checkout path
18
+ * holds the script until host detection finishes, instead of storing "not
19
+ * native checkout" and injecting v3 early.
20
+ */
21
+ export declare const holdStripeForNativeCheckout: () => boolean;
@@ -237,6 +237,13 @@ export interface Zonos {
237
237
  */
238
238
  iframeLogType: string | null;
239
239
  isBigCommerce: boolean;
240
+ /**
241
+ * Settled native-checkout answer for `isBigCommerceNativeCheckoutPath`.
242
+ * `undefined` means that checkout path is still waiting for host detection.
243
+ */
244
+ isBigCommerceNativeCheckout?: boolean;
245
+ /** Pathname `isBigCommerceNativeCheckout` was settled for. */
246
+ isBigCommerceNativeCheckoutPath?: string;
240
247
  /**
241
248
  * This will be set to true when it's called form collect
242
249
  */
@@ -316,6 +323,15 @@ export declare abstract class Zonos {
316
323
  static _paypalMockResponse: PaypalMockResponse | null;
317
324
  static iframeLogType: string | null;
318
325
  static isBigCommerce: boolean;
326
+ /**
327
+ * Settled native-checkout answer for `isBigCommerceNativeCheckoutPath`.
328
+ * Stored on `window.Zonos` so loadZonos.js, zonos.js, and the component
329
+ * bundle read the same value. `undefined` means that checkout path is
330
+ * still waiting for host detection.
331
+ */
332
+ static isBigCommerceNativeCheckout?: boolean;
333
+ /** Pathname `isBigCommerceNativeCheckout` was settled for. */
334
+ static isBigCommerceNativeCheckoutPath?: string;
319
335
  static releaseDate: string;
320
336
  static isLegacyCheckout: boolean;
321
337
  static googleAnalyticId: string | null;
@@ -1 +1 @@
1
- export{c as curpRegex,i as isMexicoTaxIdType,a as isPeruTaxIdType,p as peruTaxIdTypeFromValue,s as stripTaxIdSeparators}from"./p-Dwg61Ft_.js";import{c as o}from"./p-XQfWgQLB.js";import{g as n,I as r}from"./p-HeAZDwVW.js";import{t as l,s as u,g as m,a as w,h as f,l as y,b as v,c as h}from"./p-gEViRqvf.js";import{l as g}from"./p-BJmZPrZl.js";export{a as availableTestKeys}from"./p-BJmZPrZl.js";import{g as O,_ as S,c as j,a as z}from"./p-D5SpFsQJ.js";export{d as domesticRedirectedBtnSelector}from"./p-D5SpFsQJ.js";export{c as countryRequireShortAddressCode}from"./p-nJ6oI8-n.js";export{a as checkoutTaxIdTypeValues,c as countryRequireTaxId,e as euCountryCodes,i as isCountryRequireTaxId,p as peruTaxIdDigitLength,b as peruTaxIdFormatError,s as shipToTaxIdLabels,t as taxIdTypeOptions}from"./p-DMIgN_sT.js";const I=/^Constructor for .+ was not found/,T=/^Constructor for "?([^#"]+)#/,N=e=>{var o;const n=l(e,"");if(!n||!I.test(n))return;if(void 0===window.Zonos)return;const t=window.__zonosConstructorCapture;if(!t)return;const s=T.exec(n),r=null!==(o=null==s?void 0:s[1])&&void 0!==o?o:"";t.reported.has(r)||(t.reported.add(r),u({endpoint:"stencil://constructor",errors:[n],metadata:{shape:"constructor-not-found",tag:r}}))},k=e=>{console.error(e),void 0!==window.Zonos&&u({endpoint:"zonos://init",errors:[l(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})},R=["jsdelivr","cdnjs","unpkg","vercel"],Z="jsdelivr",C=e=>{const o=R.indexOf(e);return R[o+1]||null},L=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.5.2.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const t=`https://${o}.preview.js.zonos.com`;return g(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{v("session","zonos--checkout-session-id"),v("session","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:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t},$="https://js.stripe.com/v3",A=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let U=null;const E=e=>(null!==U||(U=new Promise(((o,n)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${$}"]`);for(let o=0;o<e.length;o++){const n=e[o];if(n&&A.test(n.src))return n}return null})();t&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):t||(t=(()=>{const e=document.createElement("script");e.src=`${$}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(y("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==t||t.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):n(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else o(null)}))),U),x=Promise.resolve().then((()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?E(null):null));let D=!1;x.catch((e=>{D||console.warn(e)}));const P=async({cartId:e,retries:o})=>{const t=m(),s=n(),r=O()||void 0,i=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:c,json:d,zonosMode:l}=await f(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:r,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),a=!d||c.length;return a&&o?(g("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),P({cartId:e,retries:o-1})):a?null:Object.assign(Object.assign({},d),{zonosMode:l})};var F;const _=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),t=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?o:null})(),M=Date.now(),B="https://v1.5.2.js.zonos.com",G=_||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.2",V="https://fonts.googleapis.com",W=/^https:\/\/fonts\.googleapis\.com/;class q{}F=q,q.doneInit=!1,q.cartSettings=null,q.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),q.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),q._paypalMockResponse=null,q.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,q.isBigCommerce=!1,q.releaseDate="1793899893283",q.isLegacyCheckout=!1,q.googleAnalyticId=null,q.googleAnalyticReady=!1,q.facebookPixelId=null,q.facebookPixelReady=!1,q.startLoadTime=M,q.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",q.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),q.overrideUseCustomAddressForm=!1,q.isCollect=!1,q.isInvoice=!1,q.isNpm=!0,q.zonosQaUrl=null,q.zonosQaUrlApi=null,q.trackEventLogs=[],q.version="v1.5.2",q.modeAlerted=!1,q.cartData=null,q.paypal=null,q.zonosMode=null,q.IframeService=r,q.getCurrentTimestamp=()=>(new Date).getTime(),q.zonosController=null,q.loadTimeApiInfoList=[],q.logIntervalId=null,q.init=async e=>{(()=>{if(window.__zonosConstructorCapture)return;const e=e=>{N(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set},window.addEventListener("unhandledrejection",e);const o=console.error.bind(console);console.error=(...e)=>{N(e[0]),o(...e)}})();const{appearance:o,checkoutSettings:n,currencyConverter:t,helloSettings:s,onCountryChange:r,overrideCurrencyFormat:i,storeId:c,zonosApiKey:d}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.createCartId=null==n?void 0:n.createCartId,F.buildCartDetail=null==n?void 0:n.buildCartDetail,F.doneInit)return;if(g(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=d,F.storeId=c,"undefined"!=typeof window&&window.parent===window&&(F.googleAnalyticReady=!0,F.facebookPixelReady=!0),F.isNpm){g("====== ZONOS LOADING FROM NPM ======");const o=L();if(o&&!window.isZonosPreview){g(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.zonosMode=F.zonosMode,(()=>{let o;try{o=window.Zonos.init(e)}catch(e){return void k(e)}o.catch((e=>{k(e)}))})()})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!d&&!F.cartId)return void y("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){g("Initialize cart data");const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=S(e);if(!n&&!o)return y("[ZONOS - loadZonos] invalid cart id"),null;const t=await P({cartId:e,retries:5});return g("[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}):(y("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(F.cartId);if(!e)return void y("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey,F.cartSettings=e.settings}const n=await(async()=>{const e=m(),o=w();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(g("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return g("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:t}=await f("/api/get-test-public-credential");if(n.length||!t)return y("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const s=t.publicCredential;return s?(g(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(y("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();n&&(F.zonosApiKey=n)}const l=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||h("session","zonos--client-secret");if(F.cartId&&F.cartData||l){g("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=`${j}`,document.body.appendChild(e)}g("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectCheckoutInternationalButton(),F.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:t,helloSettings:s,onCountryChange:r,overrideCurrencyFormat:i}}),F.doneInit=!0},q.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${z}`)){const e=document.createElement("button");e.id=z,e.style.display="none",document.body.appendChild(e)}},q.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),t=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||t)){if(n){g("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(t){g("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else g("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},q.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},q.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${z}`);setTimeout((()=>{e&&e.dispatchEvent(o("click"))}),10)},q.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},q.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},q.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},q.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:n,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=o.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const o=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(n?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&n&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},q.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let n=document.querySelector(`iframe#${o}`);n||(n=document.createElement("iframe"),n.id=o,n.style.display="none",n.style.opacity="0",n.style.position="absolute",n.style.top="-9999px",n.style.left="-9999px",n.style.width="1px",n.style.height="1px",n.style.border="none",n.style.overflow="hidden",n.style.visibility="hidden",document.body.appendChild(n));const t=(null===(e=n.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(n)},q.injectController=({config:e})=>{var o,n;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o}),new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o}),new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=F.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;g("loading Stripe");const n=await(async(...e)=>{var o;D=!0;const n=Date.now();return((e,o,n)=>{if(null===e)return null;const[t,s]=o,r=Object.assign({},s),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete r.apiVersion:r.apiVersion="2025-02-24.acacia";const c=e(t,r);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(c,n),c})(null!==(o=await x)&&void 0!==o?o:await E(null),e,n)})(o.publishableKey);n?(window.Zonos.stripe=n,window.Zonos.isCollect?t.initCollectElement(n):window.Zonos.isInvoice?t.initInvoiceElement(n):t.initCheckoutElement(n)):y("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),F.zonosController=t,g("Zonos controller injected!")},q.injectScript=({cdnType:e,isModule:o,theRestUrl:n})=>{const t=`${F.getZonosUrl(e)}/${n}`;if(document.querySelector(`script[src="${t}"]`))return void g(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");o?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{y(`Failed to load ${r.src}`);const t=C(e);t&&F.injectScript({cdnType:t,isModule:o,theRestUrl:n})},s.appendChild(r)},q.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return G;case"unpkg":return"https://unpkg.com/@zonos/elements@1.5.2";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.2";case"vercel":return B}};return F.isNpm&&L()||o()},q.injectZonosCdn=()=>{F.injectScript({cdnType:Z,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:Z,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),g("Zonos cdn script injected!")},q.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const n=F.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${B}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${n}/${o}`,r.onerror=()=>{y(`Failed to load ${r.href}`);const n=C(e);n&&F.injectStylesheet({cdnType:n,theRestUrl:o})},t.appendChild(r)},q.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?g("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:Z,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),g("Zonos style css injected!"))},q.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void g("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${V}"]`);for(let o=0;o<e.length;o++){const n=e[o];if(n&&!W.test(n.href))return n}return null})())return void g("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=V,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${V}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),g("Zonos font injected!")},q.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},q.injectSupportGoogleFont=e=>{var o;g(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${V}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=V,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void g(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),g(`[FONT] ${n} font injected!`)};const Q=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],K=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],J=[...Q,...K];export{q as Zonos,j as checkoutHiddenBtnSelector,z as checkoutHiddenInternationalBtnSelector,J as checkoutSessionAttributeKeys,K as checkoutSessionImmutableAttributeKeys,Q as checkoutSessionMutableAttributeKeys}
1
+ export{c as curpRegex,i as isMexicoTaxIdType,a as isPeruTaxIdType,p as peruTaxIdTypeFromValue,s as stripTaxIdSeparators}from"./p-Dwg61Ft_.js";import{c as o}from"./p-XQfWgQLB.js";import{g as n,I as r}from"./p-HeAZDwVW.js";import{t as l,s as u,g as m,a as w,h as f,l as v,b as y,c as h}from"./p-gEViRqvf.js";import{l as g}from"./p-BJmZPrZl.js";export{a as availableTestKeys}from"./p-BJmZPrZl.js";import{h as O,m as S,i as j}from"./p-Bb90IMVt.js";import{g as z,_ as I,c as T,a as N}from"./p-D5SpFsQJ.js";export{d as domesticRedirectedBtnSelector}from"./p-D5SpFsQJ.js";export{c as countryRequireShortAddressCode}from"./p-nJ6oI8-n.js";export{a as checkoutTaxIdTypeValues,c as countryRequireTaxId,e as euCountryCodes,i as isCountryRequireTaxId,p as peruTaxIdDigitLength,b as peruTaxIdFormatError,s as shipToTaxIdLabels,t as taxIdTypeOptions}from"./p-DMIgN_sT.js";const k=/^Constructor for .+ was not found/,R=/^Constructor for "?([^#"]+)#/,Z=e=>{var o;const n=l(e,"");if(!n||!k.test(n))return;if(void 0===window.Zonos)return;const t=window.__zonosConstructorCapture;if(!t)return;const s=R.exec(n),r=null!==(o=null==s?void 0:s[1])&&void 0!==o?o:"";t.reported.has(r)||(t.reported.add(r),u({endpoint:"stencil://constructor",errors:[n],metadata:{shape:"constructor-not-found",tag:r}}))},C=e=>{console.error(e),void 0!==window.Zonos&&u({endpoint:"zonos://init",errors:[l(e,"Unknown init rejection")],metadata:{shape:"init-rejection"}})},L=["jsdelivr","cdnjs","unpkg","vercel"],$="jsdelivr",A=e=>{const o=L.indexOf(e);return L[o+1]||null},U=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.5.3.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const t=`https://${o}.preview.js.zonos.com`;return g(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{y("session","zonos--checkout-session-id"),y("session","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:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t},E="https://js.stripe.com/v3",x=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let P=null;const D=()=>{return O()?Promise.resolve(null):(e=null,null!==P||(P=new Promise(((o,n)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${E}"]`);for(let o=0;o<e.length;o++){const n=e[o];if(n&&x.test(n.src))return n}return null})();t&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):t||(t=(()=>{const e=document.createElement("script");e.src=`${E}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(v("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==t||t.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):n(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else o(null)}))),P);var e},F=Promise.resolve().then((()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?D():null));let _=!1;F.catch((e=>{_||console.warn(e)}));const M=async({cartId:e,retries:o})=>{const t=m(),s=n(),r=z()||void 0,i=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:c,json:d,zonosMode:l}=await f(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:r,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),a=!d||c.length;return a&&o?(g("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),M({cartId:e,retries:o-1})):a?null:Object.assign(Object.assign({},d),{zonosMode:l})};var B;const V=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),t=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?o:null})(),G=Date.now(),W="https://v1.5.3.js.zonos.com",q=V||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.3",Q="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class J{}B=J,J.doneInit=!1,J.cartSettings=null,J.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),J.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),J._paypalMockResponse=null,J.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,J.isBigCommerce=!1,J.releaseDate="1794098254078",J.isLegacyCheckout=!1,J.googleAnalyticId=null,J.googleAnalyticReady=!1,J.facebookPixelId=null,J.facebookPixelReady=!1,J.startLoadTime=G,J.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",J.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),J.overrideUseCustomAddressForm=!1,J.isCollect=!1,J.isInvoice=!1,J.isNpm=!0,J.zonosQaUrl=null,J.zonosQaUrlApi=null,J.trackEventLogs=[],J.version="v1.5.3",J.modeAlerted=!1,J.cartData=null,J.paypal=null,J.zonosMode=null,J.IframeService=r,J.getCurrentTimestamp=()=>(new Date).getTime(),J.zonosController=null,J.loadTimeApiInfoList=[],J.logIntervalId=null,J.init=async e=>{(()=>{if(window.__zonosConstructorCapture)return;const e=e=>{Z(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set},window.addEventListener("unhandledrejection",e);const o=console.error.bind(console);console.error=(...e)=>{Z(e[0]),o(...e)}})();const{appearance:o,checkoutSettings:n,currencyConverter:t,helloSettings:s,onCountryChange:r,overrideCurrencyFormat:i,storeId:c,zonosApiKey:d}=e;if(B.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),B.createCartId=null==n?void 0:n.createCartId,B.buildCartDetail=null==n?void 0:n.buildCartDetail,B.doneInit)return;if(S(),g(`====== ZONOS DEBUG MODE: on (${B.version}) ======`),B.zonosApiKey=d,B.storeId=c,"undefined"!=typeof window&&window.parent===window&&(B.googleAnalyticReady=!0,B.facebookPixelReady=!0),B.isNpm){g("====== ZONOS LOADING FROM NPM ======");const o=U();if(o&&!window.isZonosPreview){g(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=B.isNpm,window.Zonos.isBigCommerce=B.isBigCommerce,window.Zonos.isLegacyCheckout=B.isLegacyCheckout,window.Zonos.zonosMode=B.zonosMode,(()=>{let o;try{o=window.Zonos.init(e)}catch(e){return void C(e)}o.catch((e=>{C(e)}))})()})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!d&&!B.cartId)return void v("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!B.cartData&&B.cartId){g("Initialize cart data");const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=I(e);if(!n&&!o)return v("[ZONOS - loadZonos] invalid cart id"),null;const t=await M({cartId:e,retries:5});return g("[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}):(v("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(B.cartId);if(!e)return void v("Failed to get cart data");B.cartData=e.cartData,B.zonosApiKey=e.zonosApiKey,B.cartSettings=e.settings}const n=await(async()=>{const e=m(),o=w();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(g("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return g("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:t}=await f("/api/get-test-public-credential");if(n.length||!t)return v("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const s=t.publicCredential;return s?(g(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(v("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();n&&(B.zonosApiKey=n)}const l=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||h("session","zonos--client-secret");if(B.cartId&&B.cartData||l){g("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=`${T}`,document.body.appendChild(e)}g("init zonos"),B.restoreNativeBrowserFunctions(),B.injectCustomScriptForHostedCheckout(),B.injectZonosCdn(),B.injectZonosCss(),B.injectFonts(),B.injectCheckoutInternationalButton(),B.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:t,helloSettings:s,onCountryChange:r,overrideCurrencyFormat:i}}),B.doneInit=!0},J.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${N}`)){const e=document.createElement("button");e.id=N,e.style.display="none",document.body.appendChild(e)}},J.injectCustomScriptForHostedCheckout=()=>{const e=B.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),t=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||t)){if(n){g("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(t){g("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else g("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},J.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},J.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${N}`);setTimeout((()=>{e&&e.dispatchEvent(o("click"))}),10)},J.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},J.showNotification=e=>{var o;null===(o=B.zonosController)||void 0===o||o.showNotification(e)},J.updateOrganizationName=e=>{var o;null===(o=B.zonosController)||void 0===o||o.updateOrganizationName(e)},J.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:n,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=o.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const o=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(n?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&n&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},J.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let n=document.querySelector(`iframe#${o}`);n||(n=document.createElement("iframe"),n.id=o,n.style.display="none",n.style.opacity="0",n.style.position="absolute",n.style.top="-9999px",n.style.left="-9999px",n.style.width="1px",n.style.height="1px",n.style.border="none",n.style.overflow="hidden",n.style.visibility="hidden",document.body.appendChild(n));const t=(null===(e=n.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(n)},J.injectController=({config:e})=>{var o,n;if(document.querySelector("zonos-controller"))return;if(!j()){if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;B.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o}),new MutationObserver((()=>{B.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;B.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o}),new MutationObserver((()=>{B.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=B.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;g("loading Stripe");const n=await(async(...e)=>{var o;_=!0;const n=Date.now();return((e,o,n)=>{if(null===e)return null;const[t,s]=o,r=Object.assign({},s),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete r.apiVersion:r.apiVersion="2025-02-24.acacia";const c=e(t,r);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(c,n),c})(null!==(o=await F)&&void 0!==o?o:await D(),e,n)})(o.publishableKey);n?(window.Zonos.stripe=n,window.Zonos.isCollect?t.initCollectElement(n):window.Zonos.isInvoice?t.initInvoiceElement(n):t.initCheckoutElement(n)):v("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),B.zonosController=t,g("Zonos controller injected!")},J.injectScript=({cdnType:e,isModule:o,theRestUrl:n})=>{const t=`${B.getZonosUrl(e)}/${n}`;if(document.querySelector(`script[src="${t}"]`))return void g(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");o?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{v(`Failed to load ${r.src}`);const t=A(e);t&&B.injectScript({cdnType:t,isModule:o,theRestUrl:n})},s.appendChild(r)},J.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.5.3";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.3";case"vercel":return W}};return B.isNpm&&U()||o()},J.injectZonosCdn=()=>{B.injectScript({cdnType:$,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),B.injectScript({cdnType:$,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),g("Zonos cdn script injected!")},J.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const n=B.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${W}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${n}/${o}`,r.onerror=()=>{v(`Failed to load ${r.href}`);const n=A(e);n&&B.injectStylesheet({cdnType:n,theRestUrl:o})},t.appendChild(r)},J.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?g("Zonos style links already injected","warn"):(B.injectStylesheet({cdnType:$,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),g("Zonos style css injected!"))},J.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void g("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${Q}"]`);for(let o=0;o<e.length;o++){const n=e[o];if(n&&!K.test(n.href))return n}return null})())return void g("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=Q,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${Q}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),g("Zonos font injected!")},J.setupGoogleFont=e=>{var o;null===(o=B.zonosController)||void 0===o||o.setupGoogleFont(e)},J.injectSupportGoogleFont=e=>{var o;g(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${Q}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=Q,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void g(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),g(`[FONT] ${n} font injected!`)};const H=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],Y=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],X=[...H,...Y];export{J as Zonos,T as checkoutHiddenBtnSelector,N as checkoutHiddenInternationalBtnSelector,X as checkoutSessionAttributeKeys,Y as checkoutSessionImmutableAttributeKeys,H as checkoutSessionMutableAttributeKeys}