@zonos/elements 1.3.132 → 1.3.134

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 (193) hide show
  1. package/dist/cjs/{CheckoutConfig-1d38a21d.js → CheckoutConfig-165db6b6.js} +1 -1
  2. package/dist/cjs/{cart-1bab358a.js → cart-0f32f556.js} +1 -1
  3. package/dist/cjs/{handleFetch-a8dfb07c.js → handleFetch-4a90f091.js} +1 -1
  4. package/dist/cjs/index.cjs.js +9 -9
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{paypal-f1874626.js → paypal-045033fb.js} +2 -2
  7. package/dist/cjs/zonos-address_7.cjs.entry.js +11 -18
  8. package/dist/cjs/zonos-badge.cjs.entry.js +3 -3
  9. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  10. package/dist/cjs/zonos-card.cjs.entry.js +4 -4
  11. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +39 -22
  12. package/dist/cjs/zonos-checkout.cjs.entry.js +36 -6
  13. package/dist/cjs/zonos-collapse.cjs.entry.js +2 -2
  14. package/dist/cjs/zonos-component.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-controller.cjs.entry.js +3 -3
  16. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  17. package/dist/cjs/zonos-country-select_4.cjs.entry.js +10 -10
  18. package/dist/cjs/zonos-elements.cjs.js +1 -1
  19. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +6 -6
  20. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  21. package/dist/cjs/zonos-input.cjs.entry.js +4 -4
  22. package/dist/cjs/zonos-language-select_2.cjs.entry.js +6 -6
  23. package/dist/cjs/zonos-link.cjs.entry.js +1 -1
  24. package/dist/cjs/zonos-logo.cjs.entry.js +2 -2
  25. package/dist/cjs/zonos-notification_3.cjs.entry.js +5 -5
  26. package/dist/cjs/zonos-toggle.cjs.entry.js +2 -2
  27. package/dist/cjs/zonos-tooltip.cjs.entry.js +2 -2
  28. package/dist/cjs/zonos-v-stack.cjs.entry.js +2 -2
  29. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +25 -7
  30. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.js +2 -2
  31. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +34 -1
  32. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +2 -2
  33. package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
  34. package/dist/collection/components/common/zonos-button/zonos-button.js +3 -3
  35. package/dist/collection/components/common/zonos-card/zonos-card.js +4 -4
  36. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
  37. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +3 -3
  38. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +2 -2
  39. package/dist/collection/components/common/zonos-confirm-dialog/zonos-confirm-dialog.js +3 -3
  40. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +2 -2
  41. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  42. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -10
  43. package/dist/collection/components/common/zonos-input/zonos-input.js +4 -4
  44. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
  45. package/dist/collection/components/common/zonos-link/zonos-link.js +1 -1
  46. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
  47. package/dist/collection/components/common/zonos-rest-state/zonos-rest-state.js +3 -3
  48. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +2 -2
  49. package/dist/collection/components/common/zonos-toggle/zonos-toggle.js +2 -2
  50. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +2 -2
  51. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -2
  52. package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.js +2 -2
  53. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  54. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +2 -2
  55. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +4 -4
  56. package/dist/collection/components/main/zonos-controller.js +1 -1
  57. package/dist/collection/components/paypal/zonos-paypal-payment.js +1 -1
  58. package/dist/collection/components/stripe/zonos-address/zonos-address.js +1 -1
  59. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +2 -2
  60. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +1 -1
  61. package/dist/collection/components/utils/logging/sendErrorLog.js +1 -1
  62. package/dist/collection/types/generated/graphql.frontend.types.js +3 -0
  63. package/dist/collection/types/generated/graphql.internal.types.js +1 -0
  64. package/dist/esm/{CheckoutConfig-56c63bdf.js → CheckoutConfig-930107d4.js} +1 -1
  65. package/dist/esm/{cart-a5a8ec74.js → cart-3e0e4d5c.js} +1 -1
  66. package/dist/esm/{handleFetch-40fc3562.js → handleFetch-22cb914b.js} +1 -1
  67. package/dist/esm/index.js +10 -10
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/{paypal-828b4297.js → paypal-7f41ff20.js} +2 -2
  70. package/dist/esm/zonos-address_7.entry.js +11 -18
  71. package/dist/esm/zonos-badge.entry.js +3 -3
  72. package/dist/esm/zonos-button_3.entry.js +3 -3
  73. package/dist/esm/zonos-card.entry.js +4 -4
  74. package/dist/esm/zonos-cart-items_13.entry.js +39 -22
  75. package/dist/esm/zonos-checkout.entry.js +36 -6
  76. package/dist/esm/zonos-collapse.entry.js +2 -2
  77. package/dist/esm/zonos-component.entry.js +1 -1
  78. package/dist/esm/zonos-controller.entry.js +3 -3
  79. package/dist/esm/zonos-country-flag.entry.js +2 -2
  80. package/dist/esm/zonos-country-select_4.entry.js +10 -10
  81. package/dist/esm/zonos-elements.js +1 -1
  82. package/dist/esm/zonos-hello-dialog.entry.js +6 -6
  83. package/dist/esm/zonos-hello.entry.js +2 -2
  84. package/dist/esm/zonos-input.entry.js +4 -4
  85. package/dist/esm/zonos-language-select_2.entry.js +6 -6
  86. package/dist/esm/zonos-link.entry.js +1 -1
  87. package/dist/esm/zonos-logo.entry.js +2 -2
  88. package/dist/esm/zonos-notification_3.entry.js +5 -5
  89. package/dist/esm/zonos-toggle.entry.js +2 -2
  90. package/dist/esm/zonos-tooltip.entry.js +2 -2
  91. package/dist/esm/zonos-v-stack.entry.js +2 -2
  92. package/dist/esm-es5/{CheckoutConfig-56c63bdf.js → CheckoutConfig-930107d4.js} +1 -1
  93. package/dist/esm-es5/{cart-a5a8ec74.js → cart-3e0e4d5c.js} +1 -1
  94. package/dist/esm-es5/handleFetch-22cb914b.js +1 -0
  95. package/dist/esm-es5/index.js +1 -1
  96. package/dist/esm-es5/loader.js +1 -1
  97. package/dist/esm-es5/{paypal-828b4297.js → paypal-7f41ff20.js} +1 -1
  98. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  99. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  100. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  101. package/dist/esm-es5/zonos-card.entry.js +1 -1
  102. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  103. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  104. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  105. package/dist/esm-es5/zonos-component.entry.js +1 -1
  106. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  107. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  108. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  109. package/dist/esm-es5/zonos-elements.js +1 -1
  110. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  111. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  112. package/dist/esm-es5/zonos-input.entry.js +1 -1
  113. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  114. package/dist/esm-es5/zonos-link.entry.js +1 -1
  115. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  116. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  117. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  118. package/dist/esm-es5/zonos-tooltip.entry.js +1 -1
  119. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  120. package/dist/scripts/index.js +1 -1
  121. package/dist/scripts/loadZonos.js +1 -1
  122. package/dist/scripts/zonos.js +1 -1
  123. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +9 -0
  124. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +2 -0
  125. package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
  126. package/dist/types/types/generated/graphql.frontend.types.d.ts +27 -1
  127. package/dist/types/types/generated/graphql.frontend.types.ts +43 -1
  128. package/dist/types/types/generated/graphql.internal.types.d.ts +1 -1
  129. package/dist/types/types/generated/graphql.internal.types.ts +2 -4
  130. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  131. package/dist/zonos-elements/index.esm.js +1 -1
  132. package/dist/zonos-elements/{p-f0ea7e98.system.entry.js → p-05826697.system.entry.js} +1 -1
  133. package/dist/zonos-elements/{p-0082eefd.system.entry.js → p-1360c4b5.system.entry.js} +1 -1
  134. package/dist/zonos-elements/{p-eb6d1e26.system.entry.js → p-1393d259.system.entry.js} +1 -1
  135. package/dist/zonos-elements/{p-4953542e.system.entry.js → p-16e5df29.system.entry.js} +1 -1
  136. package/dist/zonos-elements/{p-4794c0ab.system.js → p-1856c3fa.system.js} +1 -1
  137. package/dist/zonos-elements/{p-22458c90.system.entry.js → p-1ac0f941.system.entry.js} +1 -1
  138. package/dist/zonos-elements/{p-3cfa90d1.system.entry.js → p-22d099fb.system.entry.js} +1 -1
  139. package/dist/zonos-elements/{p-d963d9d4.entry.js → p-22e2f162.entry.js} +1 -1
  140. package/dist/zonos-elements/{p-92fbf9e6.entry.js → p-234b3f74.entry.js} +1 -1
  141. package/dist/zonos-elements/{p-c39dc3e9.system.entry.js → p-24488838.system.entry.js} +1 -1
  142. package/dist/zonos-elements/{p-3a89fb48.system.entry.js → p-31a776aa.system.entry.js} +1 -1
  143. package/dist/zonos-elements/{p-31e85dce.system.entry.js → p-3a5fb01a.system.entry.js} +1 -1
  144. package/dist/zonos-elements/{p-937d08c1.entry.js → p-3f2ea446.entry.js} +1 -1
  145. package/dist/zonos-elements/{p-db70f65a.system.entry.js → p-49cecdf9.system.entry.js} +1 -1
  146. package/dist/zonos-elements/{p-bdc7e244.system.entry.js → p-4b680c1e.system.entry.js} +1 -1
  147. package/dist/zonos-elements/{p-3efbcf88.system.entry.js → p-5775cd68.system.entry.js} +1 -1
  148. package/dist/zonos-elements/{p-7b2ee5b0.js → p-69045ca3.js} +1 -1
  149. package/dist/zonos-elements/{p-f7f481be.entry.js → p-6b8db2d3.entry.js} +1 -1
  150. package/dist/zonos-elements/{p-34471cab.system.js → p-798bb828.system.js} +1 -1
  151. package/dist/zonos-elements/{p-0cf44851.entry.js → p-84df573a.entry.js} +1 -1
  152. package/dist/zonos-elements/{p-fe899c47.entry.js → p-856bf7a4.entry.js} +1 -1
  153. package/dist/zonos-elements/{p-e9a565d0.entry.js → p-85fbb5f0.entry.js} +1 -1
  154. package/dist/zonos-elements/p-860e46ab.js +1 -0
  155. package/dist/zonos-elements/{p-dd517bcb.js → p-8759f66b.js} +1 -1
  156. package/dist/zonos-elements/{p-78227a4e.system.entry.js → p-887b05eb.system.entry.js} +1 -1
  157. package/dist/zonos-elements/{p-817741b7.entry.js → p-897c809a.entry.js} +1 -1
  158. package/dist/zonos-elements/{p-db5e0d2b.entry.js → p-95f26bc3.entry.js} +1 -1
  159. package/dist/zonos-elements/p-99d47e1c.entry.js +1 -0
  160. package/dist/zonos-elements/{p-4170b042.entry.js → p-a0cc4dd2.entry.js} +1 -1
  161. package/dist/zonos-elements/p-a0de6e0f.system.entry.js +1 -0
  162. package/dist/zonos-elements/{p-296aee8a.system.entry.js → p-a28f3298.system.entry.js} +1 -1
  163. package/dist/zonos-elements/{p-f61c142c.system.entry.js → p-aaa3addd.system.entry.js} +1 -1
  164. package/dist/zonos-elements/{p-0cfab69e.entry.js → p-acae88db.entry.js} +1 -1
  165. package/dist/zonos-elements/p-acb45eb6.system.entry.js +1 -0
  166. package/dist/zonos-elements/{p-40579074.entry.js → p-b1bb00a8.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-68cfdd01.system.entry.js → p-b500f0d1.system.entry.js} +1 -1
  168. package/dist/zonos-elements/{p-0e067b2e.entry.js → p-b6fea87a.entry.js} +1 -1
  169. package/dist/zonos-elements/{p-942a0605.js → p-b7307c61.js} +1 -1
  170. package/dist/zonos-elements/{p-fb6cf324.entry.js → p-b9e4e410.entry.js} +1 -1
  171. package/dist/zonos-elements/{p-40596087.system.js → p-bb418544.system.js} +1 -1
  172. package/dist/zonos-elements/{p-6b00344a.entry.js → p-bbd5119f.entry.js} +1 -1
  173. package/dist/zonos-elements/{p-320e7cb9.system.entry.js → p-be468605.system.entry.js} +1 -1
  174. package/dist/zonos-elements/{p-c127846c.entry.js → p-bec4d2c7.entry.js} +1 -1
  175. package/dist/zonos-elements/{p-e5f27005.system.entry.js → p-c0719959.system.entry.js} +1 -1
  176. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  177. package/dist/zonos-elements/{p-e933cbf0.system.entry.js → p-de020c11.system.entry.js} +1 -1
  178. package/dist/zonos-elements/{p-311f6702.entry.js → p-e44ab8b8.entry.js} +1 -1
  179. package/dist/zonos-elements/p-e9db73d9.entry.js +1 -0
  180. package/dist/zonos-elements/{p-1da0c1cb.entry.js → p-f9f48476.entry.js} +1 -1
  181. package/dist/zonos-elements/{p-81bb0bde.system.js → p-fa790aaf.system.js} +1 -1
  182. package/dist/zonos-elements/p-fb7d8b52.entry.js +1 -0
  183. package/dist/zonos-elements/p-febc72e7.system.js +1 -0
  184. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  185. package/package.json +1 -1
  186. package/dist/esm-es5/handleFetch-40fc3562.js +0 -1
  187. package/dist/zonos-elements/p-0cfb97ae.js +0 -1
  188. package/dist/zonos-elements/p-3972da4c.entry.js +0 -1
  189. package/dist/zonos-elements/p-6305e92c.system.js +0 -1
  190. package/dist/zonos-elements/p-76f17790.entry.js +0 -1
  191. package/dist/zonos-elements/p-8aaada48.system.entry.js +0 -1
  192. package/dist/zonos-elements/p-a0614f3a.system.entry.js +0 -1
  193. package/dist/zonos-elements/p-b2641a83.entry.js +0 -1
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),o=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"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));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 d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>{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.3.132.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.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";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' 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})),r},l="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&c.test(t.src))return t}return null})();r&&e?console.warn(d):r||(r=(e=>{const o=document.createElement("script");o.src=`${l}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),u),m=Promise.resolve().then((()=>p(null)));let w=!1;m.catch((e=>{w||console.warn(e)}));function h(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 y=["cloudflare","vercel"],f=y[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},v=g[f],b=(e=f)=>{const o=y.indexOf(e),t=y[o+1];return t||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=S(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}},O=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},j=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await O({basePathType:i,options:o,path:n}),{errors:l,response:c}=a,d=h(a,["errors","response"]),u=b(i),p=!!l.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({domain:window.Zonos.domain,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=b();if(!o)return;fetch(`${g[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:S(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(t(`=== "${n}" failed to fetch, trying next fallback ${u}`),j({basePathType:u,options:o,path:n})):Object.assign({errors:l,response:c},d)},Z=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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),j({basePathType:l||f,options:a,path:e})},C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await Z("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{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})(),N="https://v1.3.132.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.132",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732306696728",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.132",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c,storeId:d,zonosApiKey:u}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=u,T.storeId=d,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=a();if(o&&!window.isZonosPreview){t(`====== 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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!u&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:e,json:o}=await Z("/api/get-test-public-credential");if(e.length||!o)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e);const r=o.publicCredential;r?(t(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(T.cartId&&T.cartData){t("Cart data 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)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.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)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{w=!0;const o=Date.now();return m.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.132";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.132";case"vercel":return N}};if(T.isNpm){return a()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=R})();
1
+ (function(){"use strict";const e=performance.now(),o=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"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));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 d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>{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.3.134.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.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";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' 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})),r},l="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&c.test(t.src))return t}return null})();r&&e?console.warn(d):r||(r=(e=>{const o=document.createElement("script");o.src=`${l}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),u),m=Promise.resolve().then((()=>p(null)));let w=!1;m.catch((e=>{w||console.warn(e)}));function h(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 y=["cloudflare","vercel"],f=y[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},v=g[f],b=(e=f)=>{const o=y.indexOf(e),t=y[o+1];return t||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=S(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}},O=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},j=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await O({basePathType:i,options:o,path:n}),{errors:l,response:c}=a,d=h(a,["errors","response"]),u=b(i),p=!!l.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=b();if(!o)return;fetch(`${g[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:S(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(t(`=== "${n}" failed to fetch, trying next fallback ${u}`),j({basePathType:u,options:o,path:n})):Object.assign({errors:l,response:c},d)},Z=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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),j({basePathType:l||f,options:a,path:e})},C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await Z("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{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})(),N="https://v1.3.134.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732554888464",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.134",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c,storeId:d,zonosApiKey:u}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=u,T.storeId=d,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=a();if(o&&!window.isZonosPreview){t(`====== 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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!u&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:e,json:o}=await Z("/api/get-test-public-credential");if(e.length||!o)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e);const r=o.publicCredential;r?(t(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(T.cartId&&T.cartData){t("Cart data 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)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.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)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{w=!0;const o=Date.now();return m.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.134";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";case"vercel":return N}};if(T.isNpm){return a()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=R})();
@@ -1 +1 @@
1
- (function(){"use strict";function o(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const e=["cloudflare","vercel"],n=e[0],t={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},r=t[n],s=(o=n)=>{const t=e.indexOf(o),r=e[t+1];return r||null},i=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},a=performance.now(),c=o=>{if("string"==typeof o)return o;try{return JSON.stringify(o)}catch(e){if(o&&"function"==typeof o.toString){return o.toString()}return"Unable to stringify info"}},d=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-a,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(c).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===e&&console.error(o,...i));let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const l=(null===(r=d.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":l.warn(o,...i);break;case"info":l.info(o,...i);break;case"error":l.error(o,...i);break;default:l.groupCollapsed(o,...i),l.trace(),l.groupEnd()}},l=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(d("sendErrorLog","warn",o,n,e),i){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({domain:window.Zonos.domain,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${r}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=s();if(!e)return;fetch(`${t[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},p=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=i(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},u=async({basePathType:o,options:e,path:r})=>{let s;const i=window.Zonos.zonosQaUrlApi||t[o]||n,a=new URL(i+r),c=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(c));try{s=await fetch(a.toString(),e)}catch(o){if(o instanceof Error)return{baseUrl:i,errors:[{message:o.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 d=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await p({response:s}),response:s,zonosMode:d}}const u=s.status.toString();try{const o=await p({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(o),type:u}],json:null,response:s,zonosMode:d}}catch(o){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:d}}},m=async({basePathType:e,options:n,path:r})=>{var a,c;const p=r.startsWith("/api/bigcommerce")?"vercel":e,w=await u({basePathType:p,options:n,path:r}),{errors:g,response:f}=w,y=o(w,["errors","response"]),h=s(p),v=!!g.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&l({endpoint:t[p]+r,errors:g.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:p,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(a=null==n?void 0:n.body)||void 0===a?void 0:a.toString())||(null===(c=null==n?void 0:n.body)||void 0===c?void 0:c.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(d(`=== "${r}" failed to fetch, trying next fallback ${h}`),m({basePathType:h,options:n,path:r})):Object.assign({errors:g,response:f},y)},w=async(e,t)=>{const r=o(t||{},[]),s=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return d(e,"info"),m({basePathType:l||n,options:c,path:e})},g=(o,...e)=>{d(o,"error",...e)},f=["jsdelivr","cdnjs","unpkg","vercel"],y=o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrl");if(!e)return null;return/[^a-zA-Z0-9-_]+/.test(e)?null:e},h=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,v=new RegExp(`^${h.source}$`),Z=new RegExp(`^cart_${h.source}$`),S=o=>o?Z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:v.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},O=async({cartId:o,retries:e})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:t,json:r}=await w("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),s=!r||t.length;return s&&e?(d("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),O({cartId:o,retries:e-1})):s?null:r};var z;const L=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=y(window.location.href),n="https://v1.3.132.js.zonos.com";if(!e&&(n.includes("test.")||n.includes("test-")))return n;if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const t=`https://${e}.preview.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const o=new URLSearchParams(window.location.search);o.delete("zonosQaUrl");const{pathname:e}=window.location,n=`${e}?${o.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),b=(()=>{const o=(o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrlApi");return e?/[^a-zA-Z0-9-_]+/.test(e)?null:e:null})(window.location.href),e=y(window.location.href),n=o||e;if(!n&&["dev.demo.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(!o)return null;const t=`https://${o}.route.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class U{}z=U,U.isNpm=!1,U.isBigCommerce=!1,U.requested=!1,U.cartData=null,U.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,U.version="v1.3.132",U.isLegacyCheckout=!1,U.legacyStoreLogo=null,U.legacyStoreFavicon=null,U.parallelLoadTimes=[],U.parallelLoadState="off",U.releaseDate="1732306696728",U.loadScriptLogHandler=async({cdnLoadTime:o,fallbackLoadTime:e,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const o=window.performance.getEntriesByType("resource").find((o=>{const e=o;return e.name.includes(r)&&"script"===e.initiatorType}));null==o||o.transferSize;(async o=>{})((o&&(null==o?void 0:o.duration)>0?parseFloat(o.duration.toFixed(2)):parseFloat(e.toFixed(2)),Object.assign({decodedBodySize:null==o?void 0:o.decodedBodySize,encodedBodySize:null==o?void 0:o.encodedBodySize,fallbackLoadTime:e,isError:!!n},t)))}catch(o){}},U.loadScriptLogParallelHandler=async o=>{try{if(z.parallelLoadTimes.push(o),2===z.parallelLoadTimes.length){const o=z.parallelLoadTimes.find((o=>"vercel"===o.type)),e=z.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void l({endpoint:`<${o.scriptLoadUrl}> <${e.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:e.fallbackLoadTime,cdnType:e.type,vercelLoadTime:o.fallbackLoadTime}});z.loadScriptLogHandler({cdnLoadTime:e.fallbackLoadTime,fallbackLoadTime:o.fallbackLoadTime,isError:o.isError,metadata:{cdnScriptFallbackTime:e.fallbackLoadTime,cdnScriptIsError:!!e.isError,cdnScriptLoadUrl:e.scriptLoadUrl,cdnScriptType:e.type},scriptLoadUrl:o.scriptLoadUrl,storeId:o.storeId,type:o.type})}}catch(o){}},U.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{g(`[ZONOS - loadZonos] ${o}`),l({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:z.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},U.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.132";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.132":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.132");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},U.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:z.getGithubCdn({type:o,version:r}),a=L||i,c=a.replace("https://","").replace("http://",""),p=document.createElement("script"),u=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${c}/dist/scripts/${u}`,d(`[ZONOS - loadZonos] Injecting "${u}" from "${c}"`,"info");const m="4g"===(null===(s=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),g=f[0]===o,y=f[1],h="on"===z.parallelLoadState&&m&&g&&y&&!w;h&&z.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();p.addEventListener("load",(()=>{var t;if(h||n?z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}):z.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}),z.isBigCommerce||(z.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.isBigCommerce=z.isBigCommerce,z.cartId){if(!z.zonosApiKey)throw z.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!z.cartData)throw z.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(z.legacyStoreFavicon&&z.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=z.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=z.cartData,window.Zonos.isLegacyCheckout=z.isLegacyCheckout;const o=z.isLegacyCheckout&&"CLOSE_MODAL"===(null===(t=e.checkoutSettings)||void 0===t?void 0:t.successBehavior),n=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:z.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:o?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:o?z.cartData.storeBaseUrl:void 0}),zonosApiKey:z.zonosApiKey});e=n}window.Zonos.version&&(d(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${c}"`,"info"),window.Zonos.init(e))})),p.addEventListener("error",(async()=>{const s=(o=>{const e=f.indexOf(o);return f[e+1]||null})(o);if(!h&&!n){if(!s)return;z.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||L)return;if(h||n)return void z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:p.src,storeId:z.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?l({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):l({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(p)},U.init=async o=>{var e;if(d("=== Init zonos script release date","info",z.releaseDate),L&&!window.isZonosPreview){d(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${L}`,"info");const e=document.createElement("script");return e.src=`${L}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=z.isBigCommerce,window.Zonos.isLegacyCheckout=z.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${L}`)})),void(window.isZonosPreview=!0)}const n=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:t,isLegacyCartId:r}=S(n);if(n&&!r&&!t)return void z.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${n}`,metadata:{invalidCartId:!0}});z.cartId=n;const s="https://v1.3.132.js.zonos.com",i=document.querySelector('script[src*="/zonos.js"]'),a=null===(e=document.querySelector("script[src*='/loadZonos.js']"))||void 0===e?void 0:e.src;d(`[ZONOS - init] first load script src: ${a}`,"info"),window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.zonosQaUrl&&d(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&d(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==a?void 0:a.includes("timestamp=");if(!(z.isNpm||a&&c))return void g("[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(i||!a||z.requested)return void d("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!z.cartId)return z.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void g("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(z.requested=!0,z.zonosApiKey=o.zonosApiKey,z.storeId=o.storeId,z.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=S(o);if(!n&&!e)return g("[ZONOS - loadZonos] invalid cart id"),null;const t=await O({cartId:o,retries:5});return d("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(g("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(z.cartId);if(!o)throw z.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");z.cartData=o.cartData,z.zonosApiKey=o.zonosApiKey,z.legacyStoreLogo=o.storeLogo,z.legacyStoreFavicon=o.storeFavicon,z.storeId=o.storeId,z.zonosApiKey=o.zonosApiKey}if(!z.zonosApiKey)return void g('"zonosApiKey" is required to initialize Zonos');if(await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(d("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void d("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:o,json:e}=await w("/api/get-test-public-credential");if(o.length||!e)return void g("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);const n=e.publicCredential;n?(d(`[ZONOS - loadZonos] Using test API key: ${n} for test mode`,"info"),window.Zonos.zonosApiKey=n):g("[ZONOS - loadZonos] No test public key credential. Keep using production key")})(),!z.storeId)return d("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const l=z.storeId||o.storeId;d(`[ZONOS - loadZonos] Store ID: ${l}`,"info");const p=new URLSearchParams;p.set("storeId",l.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&p.set("_enableStoreVersionPinned","1");const{errors:u,json:m}=await w(`/api/get-store-version?${p.toString()}`);if(u.length||!m)return d("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const{isDifferent:f,source:y,version:h}=m;if(d(`[ZONOS - loadZonos] Store version: ${h}, source: ${y}`,"info"),f){d(`[ZONOS - loadZonos] Updating saved store version to ${h}`,"info");const o={storeId:l,version:h};w(`/api/set-store-version?${p.toString()}`,{body:o,method:"POST"}).catch((o=>g("Unable to save store's vesrion",o)))}if(!i){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:o})=>{if(!o)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const e=new URL(o).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((o=>e.includes(o))),t=["qa.js.zonos.com"].some((o=>e.includes(o)));return{currentLoadScriptUrl:e,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:a}),r=t&&!n?e:`${"alpha"===h?"alpha":`v${h}`}.js.zonos.com`,s=t&&!n?null:h;d("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:h}),z.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview)&&(window.Zonos=U)})();
1
+ (function(){"use strict";function o(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const e=["cloudflare","vercel"],n=e[0],t={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},r=t[n],s=(o=n)=>{const t=e.indexOf(o),r=e[t+1];return r||null},i=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},a=performance.now(),c=o=>{if("string"==typeof o)return o;try{return JSON.stringify(o)}catch(e){if(o&&"function"==typeof o.toString){return o.toString()}return"Unable to stringify info"}},d=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-a,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(c).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===e&&console.error(o,...i));let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const l=(null===(r=d.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":l.warn(o,...i);break;case"info":l.info(o,...i);break;case"error":l.error(o,...i);break;default:l.groupCollapsed(o,...i),l.trace(),l.groupEnd()}},l=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(d("sendErrorLog","warn",o,n,e),i){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:o,errors:e,href:window.location.href,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(`${r}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=s();if(!e)return;fetch(`${t[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},p=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=i(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},u=async({basePathType:o,options:e,path:r})=>{let s;const i=window.Zonos.zonosQaUrlApi||t[o]||n,a=new URL(i+r),c=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(c));try{s=await fetch(a.toString(),e)}catch(o){if(o instanceof Error)return{baseUrl:i,errors:[{message:o.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 d=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await p({response:s}),response:s,zonosMode:d}}const u=s.status.toString();try{const o=await p({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(o),type:u}],json:null,response:s,zonosMode:d}}catch(o){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:d}}},m=async({basePathType:e,options:n,path:r})=>{var a,c;const p=r.startsWith("/api/bigcommerce")?"vercel":e,w=await u({basePathType:p,options:n,path:r}),{errors:g,response:f}=w,y=o(w,["errors","response"]),h=s(p),v=!!g.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&l({endpoint:t[p]+r,errors:g.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:p,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(a=null==n?void 0:n.body)||void 0===a?void 0:a.toString())||(null===(c=null==n?void 0:n.body)||void 0===c?void 0:c.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(d(`=== "${r}" failed to fetch, trying next fallback ${h}`),m({basePathType:h,options:n,path:r})):Object.assign({errors:g,response:f},y)},w=async(e,t)=>{const r=o(t||{},[]),s=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return d(e,"info"),m({basePathType:l||n,options:c,path:e})},g=(o,...e)=>{d(o,"error",...e)},f=["jsdelivr","cdnjs","unpkg","vercel"],y=o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrl");if(!e)return null;return/[^a-zA-Z0-9-_]+/.test(e)?null:e},h=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,v=new RegExp(`^${h.source}$`),Z=new RegExp(`^cart_${h.source}$`),S=o=>o?Z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:v.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},z=async({cartId:o,retries:e})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:t,json:r}=await w("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),s=!r||t.length;return s&&e?(d("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),z({cartId:o,retries:e-1})):s?null:r};var O;const L=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=y(window.location.href),n="https://v1.3.134.js.zonos.com";if(!e&&(n.includes("test.")||n.includes("test-")))return n;if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const t=`https://${e}.preview.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const o=new URLSearchParams(window.location.search);o.delete("zonosQaUrl");const{pathname:e}=window.location,n=`${e}?${o.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),b=(()=>{const o=(o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrlApi");return e?/[^a-zA-Z0-9-_]+/.test(e)?null:e:null})(window.location.href),e=y(window.location.href),n=o||e;if(!n&&["dev.demo.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(!o)return null;const t=`https://${o}.route.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class U{}O=U,U.isNpm=!1,U.isBigCommerce=!1,U.requested=!1,U.cartData=null,U.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,U.version="v1.3.134",U.isLegacyCheckout=!1,U.legacyStoreLogo=null,U.legacyStoreFavicon=null,U.parallelLoadTimes=[],U.parallelLoadState="off",U.releaseDate="1732554888464",U.loadScriptLogHandler=async({cdnLoadTime:o,fallbackLoadTime:e,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const o=window.performance.getEntriesByType("resource").find((o=>{const e=o;return e.name.includes(r)&&"script"===e.initiatorType}));null==o||o.transferSize;(async o=>{})((o&&(null==o?void 0:o.duration)>0?parseFloat(o.duration.toFixed(2)):parseFloat(e.toFixed(2)),Object.assign({decodedBodySize:null==o?void 0:o.decodedBodySize,encodedBodySize:null==o?void 0:o.encodedBodySize,fallbackLoadTime:e,isError:!!n},t)))}catch(o){}},U.loadScriptLogParallelHandler=async o=>{try{if(O.parallelLoadTimes.push(o),2===O.parallelLoadTimes.length){const o=O.parallelLoadTimes.find((o=>"vercel"===o.type)),e=O.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void l({endpoint:`<${o.scriptLoadUrl}> <${e.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:e.fallbackLoadTime,cdnType:e.type,vercelLoadTime:o.fallbackLoadTime}});O.loadScriptLogHandler({cdnLoadTime:e.fallbackLoadTime,fallbackLoadTime:o.fallbackLoadTime,isError:o.isError,metadata:{cdnScriptFallbackTime:e.fallbackLoadTime,cdnScriptIsError:!!e.isError,cdnScriptLoadUrl:e.scriptLoadUrl,cdnScriptType:e.type},scriptLoadUrl:o.scriptLoadUrl,storeId:o.storeId,type:o.type})}}catch(o){}},U.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{g(`[ZONOS - loadZonos] ${o}`),l({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:O.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},U.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.134");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},U.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:O.getGithubCdn({type:o,version:r}),a=L||i,c=a.replace("https://","").replace("http://",""),p=document.createElement("script"),u=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${c}/dist/scripts/${u}`,d(`[ZONOS - loadZonos] Injecting "${u}" from "${c}"`,"info");const m="4g"===(null===(s=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),g=f[0]===o,y=f[1],h="on"===O.parallelLoadState&&m&&g&&y&&!w;h&&O.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();p.addEventListener("load",(()=>{var t;if(h||n?O.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:O.storeId,type:o}):O.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:O.storeId,type:o}),O.isBigCommerce||(O.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.isBigCommerce=O.isBigCommerce,O.cartId){if(!O.zonosApiKey)throw O.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!O.cartData)throw O.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(O.legacyStoreFavicon&&O.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=O.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=O.cartData,window.Zonos.isLegacyCheckout=O.isLegacyCheckout;const o=O.isLegacyCheckout&&"CLOSE_MODAL"===(null===(t=e.checkoutSettings)||void 0===t?void 0:t.successBehavior),n=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:O.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:o?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:o?O.cartData.storeBaseUrl:void 0}),zonosApiKey:O.zonosApiKey});e=n}window.Zonos.version&&(d(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${c}"`,"info"),window.Zonos.init(e))})),p.addEventListener("error",(async()=>{const s=(o=>{const e=f.indexOf(o);return f[e+1]||null})(o);if(!h&&!n){if(!s)return;O.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||L)return;if(h||n)return void O.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:p.src,storeId:O.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?l({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):l({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(p)},U.init=async o=>{var e;if(d("=== Init zonos script release date","info",O.releaseDate),L&&!window.isZonosPreview){d(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${L}`,"info");const e=document.createElement("script");return e.src=`${L}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=O.isBigCommerce,window.Zonos.isLegacyCheckout=O.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${L}`)})),void(window.isZonosPreview=!0)}const n=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:t,isLegacyCartId:r}=S(n);if(n&&!r&&!t)return void O.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${n}`,metadata:{invalidCartId:!0}});O.cartId=n;const s="https://v1.3.134.js.zonos.com",i=document.querySelector('script[src*="/zonos.js"]'),a=null===(e=document.querySelector("script[src*='/loadZonos.js']"))||void 0===e?void 0:e.src;d(`[ZONOS - init] first load script src: ${a}`,"info"),window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.zonosQaUrl&&d(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&d(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==a?void 0:a.includes("timestamp=");if(!(O.isNpm||a&&c))return void g("[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(i||!a||O.requested)return void d("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!O.cartId)return O.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void g("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(O.requested=!0,O.zonosApiKey=o.zonosApiKey,O.storeId=o.storeId,O.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=S(o);if(!n&&!e)return g("[ZONOS - loadZonos] invalid cart id"),null;const t=await z({cartId:o,retries:5});return d("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(g("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(O.cartId);if(!o)throw O.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");O.cartData=o.cartData,O.zonosApiKey=o.zonosApiKey,O.legacyStoreLogo=o.storeLogo,O.legacyStoreFavicon=o.storeFavicon,O.storeId=o.storeId,O.zonosApiKey=o.zonosApiKey}if(!O.zonosApiKey)return void g('"zonosApiKey" is required to initialize Zonos');if(await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(d("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void d("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:o,json:e}=await w("/api/get-test-public-credential");if(o.length||!e)return void g("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);const n=e.publicCredential;n?(d(`[ZONOS - loadZonos] Using test API key: ${n} for test mode`,"info"),window.Zonos.zonosApiKey=n):g("[ZONOS - loadZonos] No test public key credential. Keep using production key")})(),!O.storeId)return d("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void O.injectZonos({initConfig:o,vercelUrl:s,version:null});const l=O.storeId||o.storeId;d(`[ZONOS - loadZonos] Store ID: ${l}`,"info");const p=new URLSearchParams;p.set("storeId",l.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&p.set("_enableStoreVersionPinned","1");const{errors:u,json:m}=await w(`/api/get-store-version?${p.toString()}`);if(u.length||!m)return d("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void O.injectZonos({initConfig:o,vercelUrl:s,version:null});const{isDifferent:f,source:y,version:h}=m;if(d(`[ZONOS - loadZonos] Store version: ${h}, source: ${y}`,"info"),f){d(`[ZONOS - loadZonos] Updating saved store version to ${h}`,"info");const o={storeId:l,version:h};w(`/api/set-store-version?${p.toString()}`,{body:o,method:"POST"}).catch((o=>g("Unable to save store's vesrion",o)))}if(!i){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:o})=>{if(!o)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const e=new URL(o).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((o=>e.includes(o))),t=["qa.js.zonos.com"].some((o=>e.includes(o)));return{currentLoadScriptUrl:e,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:a}),r=t&&!n?e:`${"alpha"===h?"alpha":`v${h}`}.js.zonos.com`,s=t&&!n?null:h;d("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:h}),O.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview)&&(window.Zonos=U)})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),o=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"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));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 d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>{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.3.132.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.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";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' 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})),r},l="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&c.test(t.src))return t}return null})();r&&e?console.warn(d):r||(r=(e=>{const o=document.createElement("script");o.src=`${l}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),u),m=Promise.resolve().then((()=>p(null)));let w=!1;m.catch((e=>{w||console.warn(e)}));function h(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 y=["cloudflare","vercel"],f=y[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},v=g[f],b=(e=f)=>{const o=y.indexOf(e),t=y[o+1];return t||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=S(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}},O=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},j=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await O({basePathType:i,options:o,path:n}),{errors:l,response:c}=a,d=h(a,["errors","response"]),u=b(i),p=!!l.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({domain:window.Zonos.domain,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=b();if(!o)return;fetch(`${g[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:S(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(t(`=== "${n}" failed to fetch, trying next fallback ${u}`),j({basePathType:u,options:o,path:n})):Object.assign({errors:l,response:c},d)},Z=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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),j({basePathType:l||f,options:a,path:e})},C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await Z("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{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})(),N="https://v1.3.132.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.132",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732306696728",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.132",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c,storeId:d,zonosApiKey:u}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=u,T.storeId=d,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=a();if(o&&!window.isZonosPreview){t(`====== 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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!u&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:e,json:o}=await Z("/api/get-test-public-credential");if(e.length||!o)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e);const r=o.publicCredential;r?(t(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(T.cartId&&T.cartData){t("Cart data 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)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.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)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{w=!0;const o=Date.now();return m.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.132";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.132";case"vercel":return N}};if(T.isNpm){return a()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=R)})();
1
+ (function(){"use strict";const e=performance.now(),o=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"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));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 d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>{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.3.134.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.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";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' 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})),r},l="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&c.test(t.src))return t}return null})();r&&e?console.warn(d):r||(r=(e=>{const o=document.createElement("script");o.src=`${l}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),u),m=Promise.resolve().then((()=>p(null)));let w=!1;m.catch((e=>{w||console.warn(e)}));function h(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 y=["cloudflare","vercel"],f=y[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},v=g[f],b=(e=f)=>{const o=y.indexOf(e),t=y[o+1];return t||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=S(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}},O=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},Z=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await O({basePathType:i,options:o,path:n}),{errors:l,response:c}=a,d=h(a,["errors","response"]),u=b(i),p=!!l.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=b();if(!o)return;fetch(`${g[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:S(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(t(`=== "${n}" failed to fetch, trying next fallback ${u}`),Z({basePathType:u,options:o,path:n})):Object.assign({errors:l,response:c},d)},j=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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),Z({basePathType:l||f,options:a,path:e})},C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await j("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{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})(),N="https://v1.3.134.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732554888464",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.134",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c,storeId:d,zonosApiKey:u}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=u,T.storeId=d,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=a();if(o&&!window.isZonosPreview){t(`====== 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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!u&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:e,json:o}=await j("/api/get-test-public-credential");if(e.length||!o)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e);const r=o.publicCredential;r?(t(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(T.cartId&&T.cartData){t("Cart data 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)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.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)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{w=!0;const o=Date.now();return m.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.134";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";case"vercel":return N}};if(T.isNpm){return a()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=R)})();
@@ -30,12 +30,21 @@ export declare class ZonosCheckoutFinish {
30
30
  notificationMessages: string[];
31
31
  notificationActionText: string;
32
32
  order: ZonosOrder | null;
33
+ /**
34
+ * Is waiting to redirect to a different page
35
+ */
36
+ isWaitingToRedirect: boolean;
33
37
  private pullOrder;
34
38
  private redirectToUrl;
39
+ private isRedirectBehavior;
35
40
  /**
36
41
  * It would make more sense to have keep shopping button if the success behavior is not redirecting to a different page
37
42
  */
38
43
  private shouldRenderKeepShoppingButton;
44
+ /**
45
+ * Should render close button for redirect behavior when the success behavior is redirecting to a different page
46
+ */
47
+ private shouldRenderCloseButtonForRedirectBehavior;
39
48
  private handleSuccessBehavior;
40
49
  private getPullOrder;
41
50
  private useOverrideSuccessNotification;
@@ -9,6 +9,7 @@ export declare class ZonosCheckout {
9
9
  * Listener for locale change in localization store
10
10
  */
11
11
  private onChangeLocaleListener;
12
+ private isRedirectAfterOrder;
12
13
  /**
13
14
  * Override appearance config
14
15
  */
@@ -123,6 +124,7 @@ export declare class ZonosCheckout {
123
124
  handleMobileChange(): void;
124
125
  handleAppearanceSettingsOverrideChange(): void;
125
126
  handleAddressChange(): void;
127
+ handleOpenChange(): void;
126
128
  componentWillLoad(): void;
127
129
  disconnectedCallback(): void;
128
130
  render(): any;
@@ -4,7 +4,7 @@ export declare const getLocaleMessages: ({ countryCode, localeTo, storeId, }: {
4
4
  localeTo?: string;
5
5
  storeId: number;
6
6
  }) => Promise<{
7
- countryCodes: string[] | null;
7
+ countryCodes: string[];
8
8
  countryCodesPageMessageLinks: {
9
9
  id: number;
10
10
  message: {
@@ -537,12 +537,35 @@ export type FailToGetQuoteErrorsQuery = {
537
537
  count: number;
538
538
  } | null;
539
539
  nodes: Array<{
540
+ cartId: Record<string, unknown> | Record<string, unknown>[] | null;
540
541
  createdAt: string;
542
+ domain: Record<string, unknown> | Record<string, unknown>[] | null;
541
543
  endpoint: string;
542
544
  errors: Record<string, unknown> | Record<string, unknown>[];
543
545
  href: string | null;
544
546
  id: number;
545
547
  metadata: Record<string, unknown> | Record<string, unknown>[] | null;
548
+ requestLocation: Record<string, unknown> | Record<string, unknown>[] | null;
549
+ requestPayload: Record<string, unknown> | Record<string, unknown>[];
550
+ responseBody: Record<string, unknown> | Record<string, unknown>[] | null;
551
+ shipToAddress: Record<string, unknown> | Record<string, unknown>[] | null;
552
+ status: number;
553
+ }>;
554
+ };
555
+ };
556
+ export type FailedToGetOrderQuery = {
557
+ error_event_aggregate: {
558
+ aggregate: {
559
+ count: number;
560
+ } | null;
561
+ nodes: Array<{
562
+ allLogs: Record<string, unknown> | Record<string, unknown>[] | null;
563
+ createdAt: string;
564
+ endpoint: string;
565
+ errors: Record<string, unknown> | Record<string, unknown>[];
566
+ id: number;
567
+ metadata: Record<string, unknown> | Record<string, unknown>[] | null;
568
+ publicCredential: Record<string, unknown> | Record<string, unknown>[] | null;
546
569
  requestPayload: Record<string, unknown> | Record<string, unknown>[];
547
570
  responseBody: Record<string, unknown> | Record<string, unknown>[] | null;
548
571
  status: number;
@@ -551,7 +574,7 @@ export type FailToGetQuoteErrorsQuery = {
551
574
  };
552
575
  export type LocaleCountryMessagesQuery = {
553
576
  locale_countryCodesPage: Array<{
554
- countryCodes: Array<string> | null;
577
+ countryCodes: Array<string>;
555
578
  countryCodesPageMessageLinks: Array<{
556
579
  id: number;
557
580
  message: {
@@ -808,6 +831,9 @@ export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionW
808
831
  failToGetQuoteErrors(variables?: {
809
832
  [x: string]: never;
810
833
  }, requestHeaders?: GraphQLClientRequestHeaders): Promise<FailToGetQuoteErrorsQuery>;
834
+ failedToGetOrder(variables?: {
835
+ [x: string]: never;
836
+ }, requestHeaders?: GraphQLClientRequestHeaders): Promise<FailedToGetOrderQuery>;
811
837
  getAudienceByAspectKey(variables?: {
812
838
  [x: string]: never;
813
839
  }, requestHeaders?: GraphQLClientRequestHeaders): Promise<GetAudienceByAspectKeyQuery>;
@@ -541,12 +541,40 @@ export type FailToGetQuoteErrorsQuery = {
541
541
  error_event_aggregate: {
542
542
  aggregate: { count: number } | null;
543
543
  nodes: Array<{
544
+ cartId: Record<string, unknown> | Record<string, unknown>[] | null;
544
545
  createdAt: string;
546
+ domain: Record<string, unknown> | Record<string, unknown>[] | null;
545
547
  endpoint: string;
546
548
  errors: Record<string, unknown> | Record<string, unknown>[];
547
549
  href: string | null;
548
550
  id: number;
549
551
  metadata: Record<string, unknown> | Record<string, unknown>[] | null;
552
+ requestLocation:
553
+ | Record<string, unknown>
554
+ | Record<string, unknown>[]
555
+ | null;
556
+ requestPayload: Record<string, unknown> | Record<string, unknown>[];
557
+ responseBody: Record<string, unknown> | Record<string, unknown>[] | null;
558
+ shipToAddress: Record<string, unknown> | Record<string, unknown>[] | null;
559
+ status: number;
560
+ }>;
561
+ };
562
+ };
563
+
564
+ export type FailedToGetOrderQuery = {
565
+ error_event_aggregate: {
566
+ aggregate: { count: number } | null;
567
+ nodes: Array<{
568
+ allLogs: Record<string, unknown> | Record<string, unknown>[] | null;
569
+ createdAt: string;
570
+ endpoint: string;
571
+ errors: Record<string, unknown> | Record<string, unknown>[];
572
+ id: number;
573
+ metadata: Record<string, unknown> | Record<string, unknown>[] | null;
574
+ publicCredential:
575
+ | Record<string, unknown>
576
+ | Record<string, unknown>[]
577
+ | null;
550
578
  requestPayload: Record<string, unknown> | Record<string, unknown>[];
551
579
  responseBody: Record<string, unknown> | Record<string, unknown>[] | null;
552
580
  status: number;
@@ -556,7 +584,7 @@ export type FailToGetQuoteErrorsQuery = {
556
584
 
557
585
  export type LocaleCountryMessagesQuery = {
558
586
  locale_countryCodesPage: Array<{
559
- countryCodes: Array<string> | null;
587
+ countryCodes: Array<string>;
560
588
  countryCodesPageMessageLinks: Array<{
561
589
  id: number;
562
590
  message: {
@@ -940,6 +968,20 @@ export function getSdk(
940
968
  'query',
941
969
  );
942
970
  },
971
+ failedToGetOrder(
972
+ variables?: { [x: string]: never },
973
+ requestHeaders?: GraphQLClientRequestHeaders,
974
+ ): Promise<FailedToGetOrderQuery> {
975
+ return withWrapper(
976
+ wrappedRequestHeaders =>
977
+ client.request<FailedToGetOrderQuery>('', variables, {
978
+ ...requestHeaders,
979
+ ...wrappedRequestHeaders,
980
+ }),
981
+ 'failedToGetOrder',
982
+ 'query',
983
+ );
984
+ },
943
985
  getAudienceByAspectKey(
944
986
  variables?: { [x: string]: never },
945
987
  requestHeaders?: GraphQLClientRequestHeaders,
@@ -2114,6 +2114,7 @@ export declare const orderNoteType: {
2114
2114
  };
2115
2115
  export type OrderNoteType = (typeof orderNoteType)[keyof typeof orderNoteType];
2116
2116
  export declare const orderRefundSubtotalType: {
2117
+ readonly Discount: "DISCOUNT";
2117
2118
  readonly DutyTaxFee: "DUTY_TAX_FEE";
2118
2119
  readonly Item: "ITEM";
2119
2120
  readonly Shipping: "SHIPPING";
@@ -3798,7 +3799,6 @@ export type GetCartOrganizationInfoQuery = {
3798
3799
  url: string;
3799
3800
  };
3800
3801
  organization: {
3801
- id: string;
3802
3802
  references: {
3803
3803
  storeId: number | null;
3804
3804
  } | null;
@@ -2538,6 +2538,7 @@ export const orderNoteType = {
2538
2538
  export type OrderNoteType = (typeof orderNoteType)[keyof typeof orderNoteType];
2539
2539
 
2540
2540
  export const orderRefundSubtotalType = {
2541
+ Discount: 'DISCOUNT',
2541
2542
  DutyTaxFee: 'DUTY_TAX_FEE',
2542
2543
  Item: 'ITEM',
2543
2544
  Shipping: 'SHIPPING',
@@ -4313,10 +4314,7 @@ export type CartQuery = {
4313
4314
 
4314
4315
  export type GetCartOrganizationInfoQuery = {
4315
4316
  onlineStoreSettings: { url: string };
4316
- organization: {
4317
- id: string;
4318
- references: { storeId: number | null } | null;
4319
- } | null;
4317
+ organization: { references: { storeId: number | null } | null } | null;
4320
4318
  };
4321
4319
 
4322
4320
  export type CartCreateMutation = {
@@ -1 +1 @@
1
- <svg color="var(--zonos-elements-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
1
+ <svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
@@ -1 +1 @@
1
- import{l as e,a as n,h as o}from"./p-0cfb97ae.js";import{s as t,c as s}from"./p-942a0605.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-942a0605.js";const r=["jsdelivr","cdnjs","unpkg","vercel"],i="jsdelivr",l=e=>{const n=r.indexOf(e);return r[n+1]||null},a=()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const o=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),t="https://v1.3.132.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.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";const s=`https://${o}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),s},u="https://js.stripe.com/v3",m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let p=null;const f=Promise.resolve().then((()=>{return e=null,null!==p||(p=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(w),window.Stripe)o(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&m.test(o.src))return o}return null})();s&&e?console.warn(w):s||(s=(e=>{const o=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${u}${o}`;const s=document.head||document.body;return s?(s.appendChild(t),t):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),p;var e}));let h=!1;var v;f.catch((e=>{h||console.warn(e)}));const y=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),z="https://v1.3.132.js.zonos.com",j=y||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.132",S="https://rsms.me",g="https://fonts.googleapis.com",O=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class ${}v=$,$.doneInit=!1,$.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),$.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),$._paypalMockResponse=null,$.isBigCommerce=!1,$.releaseDate="1732306651064",$.isLegacyCheckout=!1,$.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",$.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),$.isNpm=!0,$.zonosQaUrl=null,$.zonosQaUrlApi=null,$.version="v1.3.132",$.modeAlerted=!1,$.cartData=null,$.paypal=null,$.getCurrentTimestamp=()=>(new Date).getTime(),$.zonosController=null,$.init=async r=>{const{appearance:i,checkoutSettings:d,currencyConverter:c,helloSettings:l,onCountryChange:u,overrideCurrencyFormat:m,storeId:w,zonosApiKey:p}=r;if(v.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!v.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${v.version}) ======`),v.zonosApiKey=p,v.storeId=w,v.isNpm){e("====== ZONOS LOADING FROM NPM ======");const s=a();if(s&&!window.isZonosPreview){e(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${s} ======`,"info");const n=document.createElement("script");return n.src=`${s}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=v.isNpm,window.Zonos.isBigCommerce=v.isBigCommerce,window.Zonos.isLegacyCheckout=v.isLegacyCheckout,window.Zonos.init(r)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${s}`)})),void(window.isZonosPreview=!0)}if(!p&&!v.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!v.cartData&&v.cartId){e("Initialize cart data");const o=await t(v.cartId);if(!o)return void n("Failed to get cart data");v.cartData=o.cartData,v.zonosApiKey=o.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(e("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:t,json:s}=await o("/api/get-test-public-credential");if(t.length||!s)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);const r=s.publicCredential;r?(e(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(v.cartId&&v.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${s}`,document.body.appendChild(n)}e("init zonos"),v.injectZonosCdn(),v.injectZonosCss(),v.injectFonts(),v.injectController({config:{appearance:i,checkoutSettings:d,currencyConverter:c,helloSettings:l,onCountryChange:u,overrideCurrencyFormat:m}}),v.doneInit=!0}},$.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},$.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},$.showNotification=e=>{var n;null===(n=v.zonosController)||void 0===n||n.showNotification(e)},$.updateOrganizationName=e=>{var n;null===(n=v.zonosController)||void 0===n||n.updateOrganizationName(e)},$.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},$.injectController=({config:o})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=o.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;v.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{v.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=o,s.zonosApiKey=v.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async o=>{const{detail:t}=o;e("loading Stripe");const r=await(async(...e)=>{h=!0;const n=Date.now();return f.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),v.zonosController=s,e("Zonos controller injected!")},$.injectScript=({cdnType:o,isModule:t,theRestUrl:s})=>{const r=`${v.getZonosUrl(o)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const i=document.head||document.body,d=document.createElement("script");t?d.type="module":d.noModule=!0,d.src=r,d.crossOrigin="anonymous",d.onerror=()=>{n(`Failed to load ${d.src}`);const e=l(o);e&&v.injectScript({cdnType:e,isModule:t,theRestUrl:s})},i.appendChild(d)},$.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return j;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.132";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.132";case"vercel":return z}};return v.isNpm&&a()||n()},$.injectZonosCdn=()=>{v.injectScript({cdnType:i,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),v.injectScript({cdnType:i,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},$.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=v.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${z}/`,s.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{n(`Failed to load ${i.href}`);const t=l(e);t&&v.injectStylesheet({cdnType:t,theRestUrl:o})},s.appendChild(i)},$.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(v.injectStylesheet({cdnType:i,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},$.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!O.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=S,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${S}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},$.setupGoogleFont=e=>{var n;null===(n=v.zonosController)||void 0===n||n.setupGoogleFont(e)},$.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${g}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=g,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${t} font injected!`)};export{$ as Zonos}
1
+ import{l as e,a as n,h as o}from"./p-860e46ab.js";import{s as t,c as s}from"./p-b7307c61.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b7307c61.js";const r=["jsdelivr","cdnjs","unpkg","vercel"],i="jsdelivr",l=e=>{const n=r.indexOf(e);return r[n+1]||null},a=()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const o=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),t="https://v1.3.134.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.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";const s=`https://${o}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),s},u="https://js.stripe.com/v3",m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let p=null;const f=Promise.resolve().then((()=>{return e=null,null!==p||(p=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(w),window.Stripe)o(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&m.test(o.src))return o}return null})();s&&e?console.warn(w):s||(s=(e=>{const o=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${u}${o}`;const s=document.head||document.body;return s?(s.appendChild(t),t):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),p;var e}));let h=!1;var v;f.catch((e=>{h||console.warn(e)}));const y=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),z="https://v1.3.134.js.zonos.com",j=y||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134",S="https://rsms.me",g="https://fonts.googleapis.com",O=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class ${}v=$,$.doneInit=!1,$.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),$.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),$._paypalMockResponse=null,$.isBigCommerce=!1,$.releaseDate="1732554842941",$.isLegacyCheckout=!1,$.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",$.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),$.isNpm=!0,$.zonosQaUrl=null,$.zonosQaUrlApi=null,$.version="v1.3.134",$.modeAlerted=!1,$.cartData=null,$.paypal=null,$.getCurrentTimestamp=()=>(new Date).getTime(),$.zonosController=null,$.init=async r=>{const{appearance:i,checkoutSettings:d,currencyConverter:c,helloSettings:l,onCountryChange:u,overrideCurrencyFormat:m,storeId:w,zonosApiKey:p}=r;if(v.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!v.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${v.version}) ======`),v.zonosApiKey=p,v.storeId=w,v.isNpm){e("====== ZONOS LOADING FROM NPM ======");const s=a();if(s&&!window.isZonosPreview){e(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${s} ======`,"info");const n=document.createElement("script");return n.src=`${s}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=v.isNpm,window.Zonos.isBigCommerce=v.isBigCommerce,window.Zonos.isLegacyCheckout=v.isLegacyCheckout,window.Zonos.init(r)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${s}`)})),void(window.isZonosPreview=!0)}if(!p&&!v.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!v.cartData&&v.cartId){e("Initialize cart data");const o=await t(v.cartId);if(!o)return void n("Failed to get cart data");v.cartData=o.cartData,v.zonosApiKey=o.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(e("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:t,json:s}=await o("/api/get-test-public-credential");if(t.length||!s)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);const r=s.publicCredential;r?(e(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(v.cartId&&v.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${s}`,document.body.appendChild(n)}e("init zonos"),v.injectZonosCdn(),v.injectZonosCss(),v.injectFonts(),v.injectController({config:{appearance:i,checkoutSettings:d,currencyConverter:c,helloSettings:l,onCountryChange:u,overrideCurrencyFormat:m}}),v.doneInit=!0}},$.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},$.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},$.showNotification=e=>{var n;null===(n=v.zonosController)||void 0===n||n.showNotification(e)},$.updateOrganizationName=e=>{var n;null===(n=v.zonosController)||void 0===n||n.updateOrganizationName(e)},$.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},$.injectController=({config:o})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=o.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;v.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{v.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=o,s.zonosApiKey=v.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async o=>{const{detail:t}=o;e("loading Stripe");const r=await(async(...e)=>{h=!0;const n=Date.now();return f.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),v.zonosController=s,e("Zonos controller injected!")},$.injectScript=({cdnType:o,isModule:t,theRestUrl:s})=>{const r=`${v.getZonosUrl(o)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const i=document.head||document.body,d=document.createElement("script");t?d.type="module":d.noModule=!0,d.src=r,d.crossOrigin="anonymous",d.onerror=()=>{n(`Failed to load ${d.src}`);const e=l(o);e&&v.injectScript({cdnType:e,isModule:t,theRestUrl:s})},i.appendChild(d)},$.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return j;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.134";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";case"vercel":return z}};return v.isNpm&&a()||n()},$.injectZonosCdn=()=>{v.injectScript({cdnType:i,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),v.injectScript({cdnType:i,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},$.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=v.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${z}/`,s.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{n(`Failed to load ${i.href}`);const t=l(e);t&&v.injectStylesheet({cdnType:t,theRestUrl:o})},s.appendChild(i)},$.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(v.injectStylesheet({cdnType:i,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},$.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!O.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=S,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${S}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},$.setupGoogleFont=e=>{var n;null===(n=v.zonosController)||void 0===n||n.setupGoogleFont(e)},$.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${g}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=g,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${t} font injected!`)};export{$ as Zonos}