@zonos/elements 1.3.167 → 1.3.169
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.
- package/dist/cjs/{CheckoutConfig-626b48e5.js → CheckoutConfig-f5e68e14.js} +1 -1
- package/dist/cjs/{cart-dbeee1e9.js → cart-36799bbe.js} +4 -4
- package/dist/cjs/{getBorderRadius-d184b623.js → getBorderRadius-94ef609c.js} +1 -1
- package/dist/cjs/{handleFetch-3673a0c2.js → handleFetch-7b7f9f7c.js} +79 -1
- package/dist/cjs/index.cjs.js +46 -9
- package/dist/cjs/{isDarkColor-08d92ed7.js → isDarkColor-ec4a4e7d.js} +1 -1
- package/dist/cjs/{paypal-38ab2263.js → paypal-3eae38bd.js} +14 -6
- package/dist/cjs/zonos-address_7.cjs.entry.js +5 -5
- package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
- package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
- package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
- package/dist/cjs/zonos-card.cjs.entry.js +2 -2
- package/dist/cjs/zonos-cart-items_13.cjs.entry.js +6 -6
- package/dist/cjs/zonos-checkout.cjs.entry.js +32 -42
- package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +8 -6
- package/dist/cjs/zonos-country-flag.cjs.entry.js +5 -5
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +5 -5
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +6 -6
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +5 -5
- package/dist/cjs/zonos-hello.cjs.entry.js +5 -5
- package/dist/cjs/zonos-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +5 -5
- package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/zonos-toggle.cjs.entry.js +1 -1
- package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-7975e4b6.js → zonosStore-3812b318.js} +3 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +8 -0
- package/dist/collection/components/main/zonos-controller.js +3 -1
- package/dist/collection/components/store/checkout/paypal.js +8 -0
- package/dist/collection/components/store/zonosStore.js +3 -0
- package/dist/collection/components/utils/api/paypalCreateOrder.js +2 -2
- package/dist/collection/components/utils/handleFetch.js +14 -1
- package/dist/collection/components/utils/logging/getAdditionalLogMetadata.js +19 -0
- package/dist/collection/components/utils/logging/prepLoadTimeApiLog.js +29 -0
- package/dist/collection/components/utils/logging/sendBulkLoadTimeApiLog.js +30 -0
- package/dist/collection/components/utils/logging/sendLoadCheckoutFacadeLog.js +1 -1
- package/dist/collection/components/utils/logging/sendLoadNativeCheckoutLog.js +23 -0
- package/dist/collection/components/utils/logging/sendLoadScriptLog.js +1 -17
- package/dist/collection/scripts/_zonosBase.js +9 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +3 -0
- package/dist/collection/types/generated/graphql.internal.types.js +35 -0
- package/dist/esm/{CheckoutConfig-646aae20.js → CheckoutConfig-2994efd9.js} +1 -1
- package/dist/esm/{cart-f2f5f13f.js → cart-b2e57589.js} +4 -4
- package/dist/esm/{getBorderRadius-740610fb.js → getBorderRadius-ada3ccad.js} +1 -1
- package/dist/esm/{handleFetch-b4633675.js → handleFetch-8d72c8cd.js} +79 -2
- package/dist/esm/index.js +47 -10
- package/dist/esm/{isDarkColor-2f59d721.js → isDarkColor-446fccb7.js} +1 -1
- package/dist/esm/{paypal-7d253663.js → paypal-38da5d52.js} +14 -6
- package/dist/esm/zonos-address_7.entry.js +5 -5
- package/dist/esm/zonos-badge.entry.js +1 -1
- package/dist/esm/zonos-banner.entry.js +1 -1
- package/dist/esm/zonos-button_3.entry.js +3 -3
- package/dist/esm/zonos-card.entry.js +2 -2
- package/dist/esm/zonos-cart-items_13.entry.js +6 -6
- package/dist/esm/zonos-checkout.entry.js +31 -41
- package/dist/esm/zonos-collapse.entry.js +1 -1
- package/dist/esm/zonos-controller.entry.js +8 -6
- package/dist/esm/zonos-country-flag.entry.js +5 -5
- package/dist/esm/zonos-country-select_4.entry.js +5 -5
- package/dist/esm/zonos-empty-state-payment_4.entry.js +6 -6
- package/dist/esm/zonos-hello-dialog.entry.js +5 -5
- package/dist/esm/zonos-hello.entry.js +5 -5
- package/dist/esm/zonos-input.entry.js +2 -2
- package/dist/esm/zonos-language-select_2.entry.js +5 -5
- package/dist/esm/zonos-logo.entry.js +1 -1
- package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
- package/dist/esm/zonos-stripe-input.entry.js +3 -3
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/zonos-toggle.entry.js +1 -1
- package/dist/esm/zonos-v-stack.entry.js +1 -1
- package/dist/esm/{zonosStore-71d7e02f.js → zonosStore-d3c5a0a5.js} +3 -0
- package/dist/esm-es5/{CheckoutConfig-646aae20.js → CheckoutConfig-2994efd9.js} +1 -1
- package/dist/esm-es5/{cart-f2f5f13f.js → cart-b2e57589.js} +1 -1
- package/dist/esm-es5/{getBorderRadius-740610fb.js → getBorderRadius-ada3ccad.js} +1 -1
- package/dist/esm-es5/handleFetch-8d72c8cd.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{isDarkColor-2f59d721.js → isDarkColor-446fccb7.js} +1 -1
- package/dist/esm-es5/paypal-38da5d52.js +17 -0
- package/dist/esm-es5/zonos-address_7.entry.js +1 -1
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_3.entry.js +1 -1
- package/dist/esm-es5/zonos-card.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collapse.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-input.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/zonos-toggle.entry.js +1 -1
- package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-71d7e02f.js → zonosStore-d3c5a0a5.js} +1 -1
- package/dist/scripts/index.d.ts +24 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/store/checkout/paypal.d.ts +2 -0
- package/dist/types/components/utils/api/paypalCreateOrder.d.ts +1 -1
- package/dist/types/components/utils/logging/getAdditionalLogMetadata.d.ts +15 -0
- package/dist/types/components/utils/logging/prepLoadTimeApiLog.d.ts +23 -0
- package/dist/types/components/utils/logging/sendBulkLoadTimeApiLog.d.ts +1 -0
- package/dist/types/components/utils/logging/sendLoadNativeCheckoutLog.d.ts +3 -0
- package/dist/types/components/utils/logging/sendLoadScriptLog.d.ts +0 -12
- package/dist/types/scripts/_getNextFallbackUrl.d.ts +1 -1
- package/dist/types/scripts/_zonosBase.d.ts +5 -0
- package/dist/types/types/LogLoadScript.d.ts +1 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +4 -0
- package/dist/types/types/checkout/api/Paypal.d.ts +3 -1
- package/dist/types/types/generated/graphql.frontend.types.d.ts +11 -0
- package/dist/types/types/generated/graphql.frontend.types.ts +21 -0
- package/dist/types/types/generated/graphql.internal.types.d.ts +51 -5
- package/dist/types/types/generated/graphql.internal.types.ts +68 -5
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-68584880.entry.js → p-00ad3c73.entry.js} +1 -1
- package/dist/zonos-elements/{p-25ad92dc.system.entry.js → p-0bfca3a9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-82a0fcb7.system.entry.js → p-0def1397.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-09e4f412.system.entry.js → p-0e63259c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-466de014.system.entry.js → p-1a20922f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-16413274.system.entry.js → p-1edbfb1f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c7219337.system.entry.js → p-236f32c8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-dd999b44.js → p-30fdcbee.js} +1 -1
- package/dist/zonos-elements/{p-acabfba5.entry.js → p-3731e7f5.entry.js} +1 -1
- package/dist/zonos-elements/{p-6549915d.entry.js → p-3eac4b10.entry.js} +1 -1
- package/dist/zonos-elements/{p-7c028742.entry.js → p-41dfc828.entry.js} +1 -1
- package/dist/zonos-elements/{p-163425d9.entry.js → p-461ca324.entry.js} +1 -1
- package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
- package/dist/zonos-elements/{p-c9035262.js → p-47f79a6d.js} +1 -1
- package/dist/zonos-elements/p-48173901.js +17 -0
- package/dist/zonos-elements/{p-a9a95fae.system.js → p-5187ba8f.system.js} +1 -1
- package/dist/zonos-elements/{p-669a7b5d.system.entry.js → p-53cb8867.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8654b135.system.entry.js → p-56758218.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3edccfff.system.entry.js → p-56a8b1f6.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0febd074.system.entry.js → p-58f660d4.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5ac76fa9.system.entry.js +1 -0
- package/dist/zonos-elements/p-677e7b4b.entry.js +1 -0
- package/dist/zonos-elements/{p-b6fdbbf4.system.js → p-69255ed2.system.js} +1 -1
- package/dist/zonos-elements/{p-57281d6c.system.entry.js → p-6c0c8722.system.entry.js} +1 -1
- package/dist/zonos-elements/p-71539c8a.js +1 -0
- package/dist/zonos-elements/{p-ed74742d.system.entry.js → p-739014f8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-073bc210.entry.js → p-8048932d.entry.js} +1 -1
- package/dist/zonos-elements/{p-77581c1c.entry.js → p-829f6a40.entry.js} +1 -1
- package/dist/zonos-elements/{p-7011d8e2.entry.js → p-864c7c7d.entry.js} +1 -1
- package/dist/zonos-elements/{p-73e9a8f5.entry.js → p-90633d63.entry.js} +1 -1
- package/dist/zonos-elements/p-9261869c.system.js +1 -0
- package/dist/zonos-elements/{p-672707ce.js → p-98aa88b1.js} +1 -1
- package/dist/zonos-elements/{p-e4a52de7.entry.js → p-9f9e4f74.entry.js} +1 -1
- package/dist/zonos-elements/{p-98e9c9cf.js → p-a1cfbd0a.js} +1 -1
- package/dist/zonos-elements/{p-3bff5a9f.system.js → p-a3888f1d.system.js} +1 -1
- package/dist/zonos-elements/{p-405f70b1.entry.js → p-b0c39400.entry.js} +1 -1
- package/dist/zonos-elements/{p-72319b4d.entry.js → p-b5b9aa6c.entry.js} +1 -1
- package/dist/zonos-elements/{p-20ca31fd.system.entry.js → p-be9e1818.system.entry.js} +1 -1
- package/dist/zonos-elements/p-bf113a46.system.js +17 -0
- package/dist/zonos-elements/{p-0150bb1e.entry.js → p-bfa028a2.entry.js} +1 -1
- package/dist/zonos-elements/{p-85235fa0.system.entry.js → p-c4fa8524.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-73a3e5bb.system.js → p-c5c2976f.system.js} +1 -1
- package/dist/zonos-elements/{p-41688151.system.entry.js → p-c82f488b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ab699c84.entry.js → p-cb52cfdf.entry.js} +1 -1
- package/dist/zonos-elements/{p-75a8e67d.entry.js → p-cc6d9f7d.entry.js} +1 -1
- package/dist/zonos-elements/{p-82166888.system.entry.js → p-ce853f8f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-15971b78.entry.js → p-cedf08f0.entry.js} +1 -1
- package/dist/zonos-elements/{p-e174b37b.system.entry.js → p-d0944cc8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-eb5835d1.system.entry.js → p-d49c6a3e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c556ff98.js → p-dd0259f4.js} +1 -1
- package/dist/zonos-elements/{p-20802055.entry.js → p-e09cea9c.entry.js} +1 -1
- package/dist/zonos-elements/p-e4f8114a.system.js +1 -0
- package/dist/zonos-elements/{p-c371558a.system.entry.js → p-e99e75dd.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-83645bb4.entry.js → p-eb294265.entry.js} +1 -1
- package/dist/zonos-elements/p-ef4bad3a.system.js +1 -0
- package/dist/zonos-elements/{p-8addb07b.system.entry.js → p-f378b4d3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-718c9603.system.entry.js → p-fd352222.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-fa15b9b5.entry.js → p-fe2c27c4.entry.js} +1 -1
- package/dist/zonos-elements/{p-607a6750.entry.js → p-febb90e0.entry.js} +1 -1
- package/dist/zonos-elements/{p-93499c9b.entry.js → p-ff1c6d9a.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/handleFetch-b4633675.js +0 -1
- package/dist/esm-es5/paypal-7d253663.js +0 -17
- package/dist/zonos-elements/p-18e5b741.system.js +0 -1
- package/dist/zonos-elements/p-4508c22b.entry.js +0 -1
- package/dist/zonos-elements/p-4a0d1e3c.system.js +0 -17
- package/dist/zonos-elements/p-6658cc02.system.js +0 -1
- package/dist/zonos-elements/p-d0adc1b5.system.entry.js +0 -1
- package/dist/zonos-elements/p-d9b0094e.system.js +0 -1
- package/dist/zonos-elements/p-e97f9606.js +0 -17
- package/dist/zonos-elements/p-f0c8150e.js +0 -1
package/dist/scripts/index.js
CHANGED
|
@@ -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}})(),c=[`(${a})`,...r];c.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,...c));let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const d=(null===(i=l.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...c);break;case"info":d.info(t,...c);break;case"error":d.error(t,...c);break;default:d.groupCollapsed(t,...c),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=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function l(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 d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=y(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}},f=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,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"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:l}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:l}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${l}: ${"Unknown error"}`,type:l}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await f({basePathType:i,options:o,path:n}),{errors:c,response:d}=a,u=l(a,["errors","response"]),h=w(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==d?void 0:d.status),b=h&&v;return v&&(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(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:h,requestHeaders:null==o?void 0:o.headers,requestPayload:y(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==d?void 0:d.status,statusText:null==d?void 0:d.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:o,path:n})):Object.assign({errors:c,response:d},u)},v=async(e,o)=>{const n=l(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e]));const d=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),g({basePathType:p||u,options:d,path:e})},b=()=>{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.167.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},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let j=null;const O=e=>(null!==j||(j=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(C),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&z.test(t.src))return t}return null})();r&&e?console.warn(C):r||(r=(e=>{const o=document.createElement("script");o.src=`${S}`;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)}))),j),Z=Promise.resolve().then((()=>O(null)));let k=!1;Z.catch((e=>{k||console.warn(e)}));const I=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},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))),I({cartId:e,retries:o-1})):i?null:s},A=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${A.source}$`),L=new RegExp(`^cart_${A.source}$`),$=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,T=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:L.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 I({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 U;const P=(()=>{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})(),D="https://v1.3.167.js.zonos.com",F=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.167",R="https://fonts.googleapis.com",x=/^https:\/\/fonts\.googleapis\.com/;class M{}U=M,M.doneInit=!1,M.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),M.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),M._paypalMockResponse=null,M.isBigCommerce=!1,M.releaseDate="1741302062106",M.isLegacyCheckout=!1,M.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",M.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),M.isNpm=!0,M.zonosQaUrl=null,M.zonosQaUrlApi=null,M.version="v1.3.167",M.modeAlerted=!1,M.cartData=null,M.paypal=null,M.getCurrentTimestamp=()=>(new Date).getTime(),M.zonosController=null,M.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=b();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=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await T(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=c(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d}}),U.doneInit=!0},M.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},M.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},M.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},M.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},M.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},M.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)}},M.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},M.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;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.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=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{k=!0;const o=Date.now();return Z.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),U.zonosController=r,t("Zonos controller injected!")},M.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.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,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},M.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return F;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.167";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.167";case"vercel":return D}};if(U.isNpm){return b()||o()}return o()},M.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},M.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${D}/`,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&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},M.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},M.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${R}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!x.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=R,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${R}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},M.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},M.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^="${R}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=R,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=M})();
|
|
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)};function r(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 s=()=>window.location.search.includes("zonosStagingMode=1"),i=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},a=["cloudflare","vercel"],l=a[0],c={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},d=c[l],u=(e=l)=>{const o=a.indexOf(e),t=a[o+1];return t||null},p=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},m=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,screenHeight:window.screen.height,screenWidth:window.screen.width,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},w=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load"],h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=p(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}},y=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||c[e]||l,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"),d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&d&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const u=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:u}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var s,i;const a=n.startsWith("/api/bigcommerce")?"vercel":e,l=performance.now(),h=await y({basePathType:a,options:o,path:n}),{errors:f,response:v}=h,b=r(h,["errors","response"]),S=performance.now()-l;t(`${n} (${S.toFixed(2)}ms)`,"info");const z=null==v?void 0:v.headers.get("Zonos-Duration");(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(w.includes(e))return;const r={cache:"miss",cdnLoadTime:n-t,eventName:"jsdelivr",flag:"LOG_LOAD_TIME_API",href:e.split("?")[0]||e,loadTime:t,metadata:Object.assign(Object.assign({apiType:o},m()),{loadTimeClientMiddleware:n-t,loadTimeInternal:t,loadTimeTotal:n}),scriptLoadUrl:o,storeId:window.Zonos.storeId};window.Zonos.loadTimeApiInfoList.push(r)})({apiPath:n,apiType:a,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const I=u(a),C=!!f.find((({type:e})=>"unknown"===e))||404===(null==v?void 0:v.status),Z=I&&C;return C&&(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(`${d}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=u();if(!o)return;fetch(`${c[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:c[a]+n,errors:f.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:a,nextFallbackApiType:I,requestHeaders:null==o?void 0:o.headers,requestPayload:p(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString())||(null===(i=null==o?void 0:o.body)||void 0===i?void 0:i.toString()),status:null==v?void 0:v.status,statusText:null==v?void 0:v.statusText},shouldPostReleaseErrorReporting:!0}),Z?(t(`=== "${n}" failed to fetch, trying next fallback ${I}`),g({basePathType:I,options:o,path:n})):Object.assign({errors:f,response:v},b)},f=async(e,o)=>{const t=r(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,a=t.method||"GET",c=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":void 0,"Zonos-Test-Mode":i()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(c).forEach((e=>void 0===c[e]&&delete c[e]));const d=Object.assign(Object.assign({},t),{body:"GET"===a?void 0:n,headers:c,method:a}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return g({basePathType:u||l,options:d,path:e})};let v=0;const b=["jsdelivr","cdnjs","unpkg","vercel"],S="jsdelivr",z=e=>{const o=b.indexOf(e);return b[o+1]||null},I=()=>{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.169.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},C="https://js.stripe.com/v3",Z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,O="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let j=null;const k=e=>(null!==j||(j=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(O),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${C}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&Z.test(t.src))return t}return null})();r&&e?console.warn(O):r||(r=(e=>{const o=document.createElement("script");o.src=`${C}`;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)}))),j),T=Promise.resolve().then((()=>k(null)));let A=!1;T.catch((e=>{A||console.warn(e)}));const L=async({cartId:e,retries:o})=>{const n=i(),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),a=!s||r.length;return a&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),L({cartId:e,retries:o-1})):a?null:s},E=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${E.source}$`),N=new RegExp(`^cart_${E.source}$`),D=/^[a-zA-Z0-9]{2,}$/,P=/^cart_[a-zA-Z0-9]{2,}$/,U=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.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 L({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 F;const R=(()=>{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})(),x="https://v1.3.169.js.zonos.com",M=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.169",B="https://fonts.googleapis.com",q=/^https:\/\/fonts\.googleapis\.com/;class K{}F=K,K.doneInit=!1,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.isBigCommerce=!1,K.releaseDate="1741966499370",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.version="v1.3.169",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:a,helloSettings:l,onCountryChange:c,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=p,F.storeId=u,F.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=I();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=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!F.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){t("Initialize cart data");const e=await U(F.cartId);if(!e)return void n("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=i(),o=s();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:a}=await f("/api/get-test-public-credential");if(r.length||!a)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const l=a.publicCredential;return l?(t(`[ZONOS - loadZonos] Retrieve new test public token ${l}`,"info"),l):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(F.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(F.cartId&&F.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:a,helloSettings:l,onCountryChange:c,overrideCurrencyFormat:d}}),F.doneInit=!0,F.logIntervalId||(F.logIntervalId=setInterval((()=>{(async()=>{if(0===window.Zonos.loadTimeApiInfoList.length)return;t("Sending bulk load time api log","info",{loadTimeApiInfoList:window.Zonos.loadTimeApiInfoList});const e=[...window.Zonos.loadTimeApiInfoList];window.Zonos.loadTimeApiInfoList.length=0;const{errors:o}=await f("/api/zonos-elements/log-bulk-load",{body:e,method:"POST"});o.length&&(window.Zonos.loadTimeApiInfoList.push(...e),v++,v>5&&window.Zonos.logIntervalId&&clearInterval(window.Zonos.logIntervalId))})()}),2e3))},K.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},K.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},K.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},K.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)}},K.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},K.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;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=F.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{A=!0;const o=Date.now();return T.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),F.zonosController=r,t("Zonos controller injected!")},K.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${F.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=s,a.crossOrigin="anonymous",a.onerror=()=>{n(`Failed to load ${a.src}`);const t=z(e);t&&F.injectScript({cdnType:t,isModule:o,theRestUrl:r})},i.appendChild(a)},K.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return M;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.169";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.169";case"vercel":return x}};if(F.isNpm){return I()||o()}return o()},K.injectZonosCdn=()=>{F.injectScript({cdnType:S,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:S,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},K.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=F.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${x}/`,r.appendChild(s);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{n(`Failed to load ${i.href}`);const t=z(e);t&&F.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(i)},K.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:S,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${B}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!q.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=B,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${B}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},K.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},K.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^="${B}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=B,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=K})();
|
|
@@ -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=()=>window.location.search.includes("zonosStagingMode=1"),n=()=>{var o;return(null===(o=window.Zonos.zonosApiKey)||void 0===o?void 0:o.includes("test"))||window.location.search.includes("zonosTestMode=1")},t=["cloudflare","vercel"],r=t[0],s={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=s[r],a=(o=r)=>{const e=t.indexOf(o),n=t[e+1];return n||null},d=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},c=performance.now(),l=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"}},p=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-c,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(l).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 a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":d.warn(o,...i);break;case"info":d.info(o,...i);break;case"error":d.error(o,...i);break;default:d.groupCollapsed(o,...i),d.trace(),d.groupEnd()}},u=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(p("sendErrorLog","warn",o,n,e),t){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=a();if(!e)return;fetch(`${s[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},m=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=d(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}},w=async({basePathType:o,options:e,path:n})=>{let t;const i=window.Zonos.zonosQaUrlApi||s[o]||r,a=new URL(i+n),d=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("")}})(d));try{t=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 c=t.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&l&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:i,errors:[],json:await m({response:t}),response:t,zonosMode:c}}const p=t.status.toString();try{const o=await m({response:t,shouldThrow:!0});if(o&&"errors"in o&&Array.isArray(o.errors)){const e=o.errors;return{baseUrl:i,errors:e.map((o=>"string"==typeof o?{message:o,type:p}:o)),json:null,response:t,zonosMode:c}}return{baseUrl:i,errors:[{message:JSON.stringify(o),type:p}],json:null,response:t,zonosMode:c}}catch(o){return{baseUrl:i,errors:[{message:`${p}: ${"Unknown error"}`,type:p}],json:null,response:null,zonosMode:c}}},g=async({basePathType:e,options:n,path:t})=>{var r,i;const c=t.startsWith("/api/bigcommerce")?"vercel":e,l=await w({basePathType:c,options:n,path:t}),{errors:m,response:f}=l,y=o(l,["errors","response"]),h=a(c),v=!!m.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&u({endpoint:s[c]+t,errors:m.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:c,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(p(`=== "${t}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:n,path:t})):Object.assign({errors:m,response:f},y)},f=async(t,s)=>{const i=o(s||{},[]),a=i.body?JSON.stringify(i.body):void 0,d=i.method||"GET",c=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":e()?"1":void 0,"Zonos-Test-Mode":n()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},i.headers);Object.keys(c).forEach((o=>void 0===c[o]&&delete c[o]));const l=Object.assign(Object.assign({},i),{body:"GET"===d?void 0:a,headers:c,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return p(t,"info"),g({basePathType:u||r,options:l,path:t})},y=(o,...e)=>{p(o,"error",...e)},h=["jsdelivr","cdnjs","unpkg","vercel"],v=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},Z=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,S=new RegExp(`^${Z.source}$`),z=new RegExp(`^cart_${Z.source}$`),O=/^[a-zA-Z0-9]{2,}$/,L=/^cart_[a-zA-Z0-9]{2,}$/,b=o=>o?o.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:L.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:O.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:S.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},I=async({cartId:o,retries:e})=>{const t=n(),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:t,options:{noOnlineStoreSettings:!0},tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&e?(p("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),I({cartId:o,retries:e-1})):i?null:s};var C;const U=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=v(window.location.href),n="https://v1.3.167.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 p(`[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})(),j=(()=>{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=v(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 p(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class k{}C=k,k.isNpm=!1,k.isBigCommerce=!1,k.requested=!1,k.cartData=null,k.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,k.version="v1.3.167",k.isLegacyCheckout=!1,k.legacyStoreLogo=null,k.legacyStoreFavicon=null,k.parallelLoadTimes=[],k.parallelLoadState="off",k.releaseDate="1741302062106",k.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){}},k.loadScriptLogParallelHandler=async o=>{try{if(C.parallelLoadTimes.push(o),2===C.parallelLoadTimes.length){const o=C.parallelLoadTimes.find((o=>"vercel"===o.type)),e=C.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void u({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}});C.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){}},k.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{y(`[ZONOS - loadZonos] ${o}`),u({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:C.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},k.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.167";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.167":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.167");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},k.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:C.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:C.getGithubCdn({type:o,version:r}),a=U||i,d=a.replace("https://","").replace("http://",""),c=document.createElement("script"),l=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";c.src=`https://${d}/dist/scripts/${l}?timestamp=${Date.now()}`,p(`[ZONOS - loadZonos] Injecting "${l}" from "${d}"`,"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=h[0]===o,f=h[1],y="on"===C.parallelLoadState&&m&&g&&f&&!w;y&&C.injectZonos({cdnType:f,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();c.addEventListener("load",(()=>{if(y||n?C.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:c.src,storeId:C.storeId,type:o}):C.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:c.src,storeId:C.storeId,type:o}),C.isBigCommerce||(C.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=U,window.Zonos.zonosQaUrlApi=j,window.Zonos.isBigCommerce=C.isBigCommerce,C.cartId){if(!C.zonosApiKey)throw C.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!C.cartData)throw C.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(C.legacyStoreFavicon&&C.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=C.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=C.cartData,window.Zonos.isLegacyCheckout=C.isLegacyCheckout;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:C.legacyStoreLogo||""}),zonosApiKey:C.zonosApiKey});e=o}window.Zonos.version&&(p(`[ZONOS - loadZonos] Execute "Zonos.init" from "${l}" from "${d}"`,"info"),window.Zonos.init(e))})),c.addEventListener("error",(async()=>{const s=(o=>{const e=h.indexOf(o);return h[e+1]||null})(o);if(!y&&!n){if(!s)return;C.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||U)return;if(y||n)return void C.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:c.src,storeId:C.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?u({endpoint:c.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):u({endpoint:c.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(c)},k.init=async o=>{var t;if(p("=== Init zonos script release date","info",C.releaseDate),U&&!window.isZonosPreview){p(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${U}`,"info");const e=document.createElement("script");return e.src=`${U}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=C.isBigCommerce,window.Zonos.isLegacyCheckout=C.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${U}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=b(r);if(r&&!i&&!s)return void C.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});C.cartId=r;const a="https://v1.3.167.js.zonos.com",d=document.querySelector('script[src*="/zonos.js"]'),c=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src;p(`[ZONOS - init] first load script src: ${c}`,"info"),window.Zonos.zonosQaUrl=U,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosQaUrl&&p(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&p(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const l=null==c?void 0:c.includes("timestamp=");if(!(C.isNpm||c&&l))return void y("[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(d||!c||C.requested)return void p("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!C.cartId)return C.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void y("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(C.requested=!0,C.zonosApiKey=o.zonosApiKey,C.storeId=o.storeId,C.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=b(o);if(!n&&!e)return y("[ZONOS - loadZonos] invalid cart id"),null;const t=await I({cartId:o,retries:5});return p("[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}):(y("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(C.cartId);if(!o)throw C.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");C.cartData=o.cartData,C.legacyStoreLogo=o.storeLogo,C.legacyStoreFavicon=o.storeFavicon,C.storeId=o.storeId,C.zonosApiKey=o.zonosApiKey}if(!C.zonosApiKey)return void y('"zonosApiKey" is required to initialize Zonos');const u=await(async()=>{const o=n(),t=e();if(!o&&!t||!window.Zonos.zonosApiKey)return null;if(p("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return p("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await f("/api/get-test-public-credential");if(r.length||!s)return y("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(p(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(y("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(u&&(p(`[ZONOS - loadZonos] Using test API key: ${u} for test mode`,"info"),C.zonosApiKey=u),!C.storeId)return p("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void C.injectZonos({initConfig:o,vercelUrl:a,version:null});const m=C.storeId||o.storeId;p(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const w=new URLSearchParams;w.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:g,json:h}=await f(`/api/get-store-version?${w.toString()}`);if(g.length||!h)return p("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void C.injectZonos({initConfig:o,vercelUrl:a,version:null});const{isDifferent:v,source:Z,version:S}=h;if(p(`[ZONOS - loadZonos] Store version: ${S}, source: ${Z}`,"info"),v){p(`[ZONOS - loadZonos] Updating saved store version to ${S}`,"info");const o={storeId:m,version:S};f(`/api/set-store-version?${w.toString()}`,{body:o,method:"POST"}).catch((o=>y("Unable to save store's vesrion",o)))}if(!d){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:c}),r=t&&!n?e:`${"alpha"===S?"alpha":`v${S}`}.js.zonos.com`,s=t&&!n?null:S;p("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:S}),C.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=k)})();
|
|
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=()=>window.location.search.includes("zonosStagingMode=1"),n=()=>{var o;return(null===(o=window.Zonos.zonosApiKey)||void 0===o?void 0:o.includes("test"))||window.location.search.includes("zonosTestMode=1")},t=["cloudflare","vercel"],r=t[0],s={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=s[r],a=(o=r)=>{const e=t.indexOf(o),n=t[e+1];return n||null},d=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},l=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"}},p=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-l,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 a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":d.warn(o,...i);break;case"info":d.info(o,...i);break;case"error":d.error(o,...i);break;default:d.groupCollapsed(o,...i),d.trace(),d.groupEnd()}},u=()=>{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},m=()=>{const o="userAgentData"in window.navigator?window.navigator.userAgentData:null,e=u();return{connectionDownlink:null==e?void 0:e.downlink,connectionEffectiveType:null==e?void 0:e.effectiveType,connectionRtt:null==e?void 0:e.rtt,connectionSaveData:null==e?void 0:e.saveData,screenHeight:window.screen.height,screenWidth:window.screen.width,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent}},w=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load"],g=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(p("sendErrorLog","warn",o,n,e),t){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=a();if(!e)return;fetch(`${s[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},f=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=d(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}},y=async({basePathType:o,options:e,path:n})=>{let t;const i=window.Zonos.zonosQaUrlApi||s[o]||r,a=new URL(i+n),d=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("")}})(d));try{t=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 l=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&l&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:i,errors:[],json:await f({response:t}),response:t,zonosMode:l}}const p=t.status.toString();try{const o=await f({response:t,shouldThrow:!0});if(o&&"errors"in o&&Array.isArray(o.errors)){const e=o.errors;return{baseUrl:i,errors:e.map((o=>"string"==typeof o?{message:o,type:p}:o)),json:null,response:t,zonosMode:l}}return{baseUrl:i,errors:[{message:JSON.stringify(o),type:p}],json:null,response:t,zonosMode:l}}catch(o){return{baseUrl:i,errors:[{message:`${p}: ${"Unknown error"}`,type:p}],json:null,response:null,zonosMode:l}}},h=async({basePathType:e,options:n,path:t})=>{var r,i;const l=t.startsWith("/api/bigcommerce")?"vercel":e,c=performance.now(),u=await y({basePathType:l,options:n,path:t}),{errors:f,response:v}=u,Z=o(u,["errors","response"]),S=performance.now()-c;p(`${t} (${S.toFixed(2)}ms)`,"info");const z=null==v?void 0:v.headers.get("Zonos-Duration");(({apiPath:o,apiType:e,loadTimeInternal:n,loadTimeTotal:t})=>{if(w.includes(o))return;const r={cache:"miss",cdnLoadTime:t-n,eventName:"jsdelivr",flag:"LOG_LOAD_TIME_API",href:o.split("?")[0]||o,loadTime:n,metadata:Object.assign(Object.assign({apiType:e},m()),{loadTimeClientMiddleware:t-n,loadTimeInternal:n,loadTimeTotal:t}),scriptLoadUrl:e,storeId:window.Zonos.storeId};window.Zonos.loadTimeApiInfoList.push(r)})({apiPath:t,apiType:l,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const O=a(l),L=!!f.find((({type:o})=>"unknown"===o))||404===(null==v?void 0:v.status),b=O&&L;return L&&g({endpoint:s[l]+t,errors:f.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:l,nextFallbackApiType:O,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),status:null==v?void 0:v.status,statusText:null==v?void 0:v.statusText},shouldPostReleaseErrorReporting:!0}),b?(p(`=== "${t}" failed to fetch, trying next fallback ${O}`),h({basePathType:O,options:n,path:t})):Object.assign({errors:f,response:v},Z)},v=async(t,s)=>{const i=o(s||{},[]),a=i.body?JSON.stringify(i.body):void 0,d=i.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":e()?"1":void 0,"Zonos-Test-Mode":n()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},i.headers);Object.keys(l).forEach((o=>void 0===l[o]&&delete l[o]));const c=Object.assign(Object.assign({},i),{body:"GET"===d?void 0:a,headers:l,method:d}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return h({basePathType:p||r,options:c,path:t})},Z=(o,...e)=>{p(o,"error",...e)},S=["jsdelivr","cdnjs","unpkg","vercel"],z=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},O=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${O.source}$`),b=new RegExp(`^cart_${O.source}$`),I=/^[a-zA-Z0-9]{2,}$/,T=/^cart_[a-zA-Z0-9]{2,}$/,C=o=>o?o.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:T.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:I.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:b.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:L.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},U=async({cartId:o,retries:e})=>{const t=n(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:t,options:{noOnlineStoreSettings:!0},tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&e?(p("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),U({cartId:o,retries:e-1})):i?null:s};var A;const j=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=z(window.location.href),n="https://v1.3.169.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 p(`[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})(),k=(()=>{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=z(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 p(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class ${}A=$,$.isNpm=!1,$.isBigCommerce=!1,$.requested=!1,$.cartData=null,$.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,$.version="v1.3.169",$.isLegacyCheckout=!1,$.legacyStoreLogo=null,$.legacyStoreFavicon=null,$.parallelLoadTimes=[],$.parallelLoadState="off",$.releaseDate="1741966499370",$.loadTimeApiInfoList=[],$.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){}},$.loadScriptLogParallelHandler=async o=>{try{if(A.parallelLoadTimes.push(o),2===A.parallelLoadTimes.length){const o=A.parallelLoadTimes.find((o=>"vercel"===o.type)),e=A.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void g({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}});A.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){}},$.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{Z(`[ZONOS - loadZonos] ${o}`),g({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:A.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},$.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.169";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.169":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.169");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},$.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:A.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:A.getGithubCdn({type:o,version:r}),a=j||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),c=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${c}?timestamp=${Date.now()}`,p(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const m="4g"===(null===(s=u())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),f=S[0]===o,y=S[1],h="on"===A.parallelLoadState&&m&&f&&y&&!w;h&&A.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(()=>{if(h||n?A.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:A.storeId,type:o}):A.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:A.storeId,type:o}),A.isBigCommerce||(A.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=j,window.Zonos.zonosQaUrlApi=k,window.Zonos.isBigCommerce=A.isBigCommerce,window.Zonos.loadTimeApiInfoList=A.loadTimeApiInfoList,A.cartId){if(!A.zonosApiKey)throw A.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!A.cartData)throw A.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(A.legacyStoreFavicon&&A.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=A.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=A.cartData,window.Zonos.isLegacyCheckout=A.isLegacyCheckout;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:A.legacyStoreLogo||""}),zonosApiKey:A.zonosApiKey});e=o}window.Zonos.version&&(p(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(e))})),l.addEventListener("error",(async()=>{const s=(o=>{const e=S.indexOf(o);return S[e+1]||null})(o);if(!h&&!n){if(!s)return;A.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||j)return;if(h||n)return void A.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:A.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?g({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):g({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(l)},$.init=async o=>{var t;if(p("=== Init zonos script release date","info",A.releaseDate),j&&!window.isZonosPreview){p(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${j}`,"info");const e=document.createElement("script");return e.src=`${j}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=A.isBigCommerce,window.Zonos.isLegacyCheckout=A.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${j}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=C(r);if(r&&!i&&!s)return void A.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});A.cartId=r;const a="https://v1.3.169.js.zonos.com",d=document.querySelector('script[src*="/zonos.js"]'),l=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src;p(`[ZONOS - init] first load script src: ${l}`,"info"),window.Zonos.zonosQaUrl=j,window.Zonos.zonosQaUrlApi=k,window.Zonos.zonosQaUrl&&p(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&p(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==l?void 0:l.includes("timestamp=");if(!(A.isNpm||l&&c))return void Z("[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(d||!l||A.requested)return void p("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!A.cartId)return A.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void Z("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(A.requested=!0,A.zonosApiKey=o.zonosApiKey,A.storeId=o.storeId,A.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=C(o);if(!n&&!e)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await U({cartId:o,retries:5});return p("[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}):(Z("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(A.cartId);if(!o)throw A.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");A.cartData=o.cartData,A.legacyStoreLogo=o.storeLogo,A.legacyStoreFavicon=o.storeFavicon,A.storeId=o.storeId,A.zonosApiKey=o.zonosApiKey}if(!A.zonosApiKey)return void Z('"zonosApiKey" is required to initialize Zonos');const u=await(async()=>{const o=n(),t=e();if(!o&&!t||!window.Zonos.zonosApiKey)return null;if(p("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return p("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return Z("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(p(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(Z("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(u&&(p(`[ZONOS - loadZonos] Using test API key: ${u} for test mode`,"info"),A.zonosApiKey=u),!A.storeId)return p("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void A.injectZonos({initConfig:o,vercelUrl:a,version:null});const m=A.storeId||o.storeId;p(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const w=new URLSearchParams;w.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:g,json:f}=await v(`/api/get-store-version?${w.toString()}`);if(g.length||!f)return p("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void A.injectZonos({initConfig:o,vercelUrl:a,version:null});const{isDifferent:y,source:h,version:S}=f;if(p(`[ZONOS - loadZonos] Store version: ${S}, source: ${h}`,"info"),y){p(`[ZONOS - loadZonos] Updating saved store version to ${S}`,"info");const o={storeId:m,version:S};v(`/api/set-store-version?${w.toString()}`,{body:o,method:"POST"}).catch((o=>Z("Unable to save store's vesrion",o)))}if(!d){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:l}),r=t&&!n?e:`${"alpha"===S?"alpha":`v${S}`}.js.zonos.com`,s=t&&!n?null:S;p("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:S}),A.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=$)})();
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -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}})(),c=[`(${a})`,...r];c.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,...c));let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const d=(null===(i=l.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...c);break;case"info":d.info(t,...c);break;case"error":d.error(t,...c);break;default:d.groupCollapsed(t,...c),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=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function l(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 d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=y(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}},f=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,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"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:l}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:l}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${l}: ${"Unknown error"}`,type:l}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await f({basePathType:i,options:o,path:n}),{errors:c,response:d}=a,u=l(a,["errors","response"]),h=w(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==d?void 0:d.status),b=h&&v;return v&&(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(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:h,requestHeaders:null==o?void 0:o.headers,requestPayload:y(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==d?void 0:d.status,statusText:null==d?void 0:d.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:o,path:n})):Object.assign({errors:c,response:d},u)},v=async(e,o)=>{const n=l(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e]));const d=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),g({basePathType:p||u,options:d,path:e})},b=()=>{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.167.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},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let Z=null;const j=e=>(null!==Z||(Z=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(C),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&z.test(t.src))return t}return null})();r&&e?console.warn(C):r||(r=(e=>{const o=document.createElement("script");o.src=`${S}`;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)}))),Z),O=Promise.resolve().then((()=>j(null)));let k=!1;O.catch((e=>{k||console.warn(e)}));const I=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},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))),I({cartId:e,retries:o-1})):i?null:s},A=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${A.source}$`),L=new RegExp(`^cart_${A.source}$`),$=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,T=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:L.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 I({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 U;const P=(()=>{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})(),D="https://v1.3.167.js.zonos.com",F=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.167",R="https://fonts.googleapis.com",x=/^https:\/\/fonts\.googleapis\.com/;class M{}U=M,M.doneInit=!1,M.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),M.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),M._paypalMockResponse=null,M.isBigCommerce=!1,M.releaseDate="1741302062106",M.isLegacyCheckout=!1,M.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",M.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),M.isNpm=!0,M.zonosQaUrl=null,M.zonosQaUrlApi=null,M.version="v1.3.167",M.modeAlerted=!1,M.cartData=null,M.paypal=null,M.getCurrentTimestamp=()=>(new Date).getTime(),M.zonosController=null,M.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=b();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=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await T(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=c(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d}}),U.doneInit=!0},M.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},M.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},M.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},M.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},M.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},M.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)}},M.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},M.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;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.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=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{k=!0;const o=Date.now();return O.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),U.zonosController=r,t("Zonos controller injected!")},M.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.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,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},M.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return F;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.167";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.167";case"vercel":return D}};if(U.isNpm){return b()||o()}return o()},M.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},M.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${D}/`,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&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},M.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},M.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${R}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!x.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=R,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${R}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},M.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},M.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^="${R}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=R,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=M)})();
|
|
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)};function r(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 s=()=>window.location.search.includes("zonosStagingMode=1"),i=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},a=["cloudflare","vercel"],l=a[0],c={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},d=c[l],u=(e=l)=>{const o=a.indexOf(e),t=a[o+1];return t||null},p=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},m=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,screenHeight:window.screen.height,screenWidth:window.screen.width,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},w=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load"],h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=p(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}},y=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||c[e]||l,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"),d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&d&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const u=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:u}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var s,i;const a=n.startsWith("/api/bigcommerce")?"vercel":e,l=performance.now(),h=await y({basePathType:a,options:o,path:n}),{errors:f,response:v}=h,b=r(h,["errors","response"]),S=performance.now()-l;t(`${n} (${S.toFixed(2)}ms)`,"info");const z=null==v?void 0:v.headers.get("Zonos-Duration");(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(w.includes(e))return;const r={cache:"miss",cdnLoadTime:n-t,eventName:"jsdelivr",flag:"LOG_LOAD_TIME_API",href:e.split("?")[0]||e,loadTime:t,metadata:Object.assign(Object.assign({apiType:o},m()),{loadTimeClientMiddleware:n-t,loadTimeInternal:t,loadTimeTotal:n}),scriptLoadUrl:o,storeId:window.Zonos.storeId};window.Zonos.loadTimeApiInfoList.push(r)})({apiPath:n,apiType:a,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const I=u(a),Z=!!f.find((({type:e})=>"unknown"===e))||404===(null==v?void 0:v.status),C=I&&Z;return Z&&(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(`${d}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=u();if(!o)return;fetch(`${c[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:c[a]+n,errors:f.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:a,nextFallbackApiType:I,requestHeaders:null==o?void 0:o.headers,requestPayload:p(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString())||(null===(i=null==o?void 0:o.body)||void 0===i?void 0:i.toString()),status:null==v?void 0:v.status,statusText:null==v?void 0:v.statusText},shouldPostReleaseErrorReporting:!0}),C?(t(`=== "${n}" failed to fetch, trying next fallback ${I}`),g({basePathType:I,options:o,path:n})):Object.assign({errors:f,response:v},b)},f=async(e,o)=>{const t=r(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,a=t.method||"GET",c=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":void 0,"Zonos-Test-Mode":i()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(c).forEach((e=>void 0===c[e]&&delete c[e]));const d=Object.assign(Object.assign({},t),{body:"GET"===a?void 0:n,headers:c,method:a}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return g({basePathType:u||l,options:d,path:e})};let v=0;const b=["jsdelivr","cdnjs","unpkg","vercel"],S="jsdelivr",z=e=>{const o=b.indexOf(e);return b[o+1]||null},I=()=>{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.169.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},Z="https://js.stripe.com/v3",C=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,O="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let j=null;const k=e=>(null!==j||(j=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(O),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);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(O):r||(r=(e=>{const o=document.createElement("script");o.src=`${Z}`;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)}))),j),T=Promise.resolve().then((()=>k(null)));let A=!1;T.catch((e=>{A||console.warn(e)}));const L=async({cartId:e,retries:o})=>{const n=i(),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),a=!s||r.length;return a&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),L({cartId:e,retries:o-1})):a?null:s},E=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${E.source}$`),N=new RegExp(`^cart_${E.source}$`),D=/^[a-zA-Z0-9]{2,}$/,P=/^cart_[a-zA-Z0-9]{2,}$/,U=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.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 L({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 F;const R=(()=>{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})(),x="https://v1.3.169.js.zonos.com",M=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.169",B="https://fonts.googleapis.com",q=/^https:\/\/fonts\.googleapis\.com/;class K{}F=K,K.doneInit=!1,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.isBigCommerce=!1,K.releaseDate="1741966499370",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.version="v1.3.169",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:a,helloSettings:l,onCountryChange:c,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=p,F.storeId=u,F.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=I();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=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!F.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){t("Initialize cart data");const e=await U(F.cartId);if(!e)return void n("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=i(),o=s();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:a}=await f("/api/get-test-public-credential");if(r.length||!a)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const l=a.publicCredential;return l?(t(`[ZONOS - loadZonos] Retrieve new test public token ${l}`,"info"),l):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(F.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(F.cartId&&F.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:a,helloSettings:l,onCountryChange:c,overrideCurrencyFormat:d}}),F.doneInit=!0,F.logIntervalId||(F.logIntervalId=setInterval((()=>{(async()=>{if(0===window.Zonos.loadTimeApiInfoList.length)return;t("Sending bulk load time api log","info",{loadTimeApiInfoList:window.Zonos.loadTimeApiInfoList});const e=[...window.Zonos.loadTimeApiInfoList];window.Zonos.loadTimeApiInfoList.length=0;const{errors:o}=await f("/api/zonos-elements/log-bulk-load",{body:e,method:"POST"});o.length&&(window.Zonos.loadTimeApiInfoList.push(...e),v++,v>5&&window.Zonos.logIntervalId&&clearInterval(window.Zonos.logIntervalId))})()}),2e3))},K.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},K.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},K.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},K.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)}},K.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},K.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;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=F.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{A=!0;const o=Date.now();return T.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),F.zonosController=r,t("Zonos controller injected!")},K.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${F.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=s,a.crossOrigin="anonymous",a.onerror=()=>{n(`Failed to load ${a.src}`);const t=z(e);t&&F.injectScript({cdnType:t,isModule:o,theRestUrl:r})},i.appendChild(a)},K.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return M;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.169";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.169";case"vercel":return x}};if(F.isNpm){return I()||o()}return o()},K.injectZonosCdn=()=>{F.injectScript({cdnType:S,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:S,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},K.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=F.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${x}/`,r.appendChild(s);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{n(`Failed to load ${i.href}`);const t=z(e);t&&F.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(i)},K.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:S,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${B}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!q.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=B,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${B}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},K.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},K.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^="${B}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=B,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=K)})();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type PayPalButtonsComponent } from '@paypal/paypal-js';
|
|
2
|
+
import type { PaypalOrderIntent } from "../../../types/index";
|
|
2
3
|
import type { CurrencyCode, ElementsUiStyle } from "../../../types/generated/graphql.internal.types";
|
|
3
4
|
type PaypalStore = {
|
|
5
|
+
intent: PaypalOrderIntent;
|
|
4
6
|
/**
|
|
5
7
|
* Zonos order id created by paypal
|
|
6
8
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PaypalCreateOrderRequest } from "../../../types/checkout/api/Paypal";
|
|
2
2
|
import type { PaypalOrderCreateMutation } from "../../../types/generated/graphql.internal.types";
|
|
3
|
-
export declare const paypalCreateOrder: ({ checkoutSessionId, }: PaypalCreateOrderRequest) => Promise<{
|
|
3
|
+
export declare const paypalCreateOrder: ({ checkoutSessionId, intent, }: PaypalCreateOrderRequest) => Promise<{
|
|
4
4
|
errors: import("../../..").JsonError[];
|
|
5
5
|
json: PaypalOrderCreateMutation | null;
|
|
6
6
|
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type UserAgentData = {
|
|
2
|
+
brands: string[];
|
|
3
|
+
mobile: boolean;
|
|
4
|
+
platform: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const getAdditionalLogMetadata: () => {
|
|
7
|
+
connectionDownlink: number | undefined;
|
|
8
|
+
connectionEffectiveType: "slow-2g" | "2g" | "3g" | "4g" | undefined;
|
|
9
|
+
connectionRtt: number | undefined;
|
|
10
|
+
connectionSaveData: boolean | undefined;
|
|
11
|
+
screenHeight: number;
|
|
12
|
+
screenWidth: number;
|
|
13
|
+
userAgent: string | UserAgentData;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LogLoadScriptRequest } from "../../../types/LogLoadScript";
|
|
2
|
+
export type LoadTimeApiLogInfo = LogLoadScriptRequest & {
|
|
3
|
+
flag: 'LOG_LOAD_TIME_API';
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Prepares the load time api log for the given API call to send to the server later
|
|
7
|
+
* This function is used to prepare the load time api log for the given API call.
|
|
8
|
+
* It adds the load time api log to the loadTimeApiInfoList.
|
|
9
|
+
*/
|
|
10
|
+
export declare const prepLoadTimeApiLog: ({ apiPath, apiType, loadTimeInternal, loadTimeTotal, }: {
|
|
11
|
+
/**
|
|
12
|
+
* The path of the API call
|
|
13
|
+
* @example '/api/zonos-elements/log-script-load'
|
|
14
|
+
*/
|
|
15
|
+
apiPath: string;
|
|
16
|
+
/**
|
|
17
|
+
* The type of the API call
|
|
18
|
+
* @example 'vercel' | 'cloudflare'
|
|
19
|
+
*/
|
|
20
|
+
apiType: "vercel" | "cloudflare";
|
|
21
|
+
loadTimeInternal: number;
|
|
22
|
+
loadTimeTotal: number;
|
|
23
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sendBulkLoadTimeApiLog: () => Promise<void>;
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import type { LogLoadScriptRequest } from "../../../types/LogLoadScript";
|
|
2
2
|
type Params = Omit<LogLoadScriptRequest, 'href'>;
|
|
3
|
-
type UserAgentData = {
|
|
4
|
-
brands: string[];
|
|
5
|
-
mobile: boolean;
|
|
6
|
-
platform: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const getAdditionalLogMetadata: () => {
|
|
9
|
-
connectionDownlink: number | undefined;
|
|
10
|
-
connectionEffectiveType: "slow-2g" | "2g" | "3g" | "4g" | undefined;
|
|
11
|
-
connectionRtt: number | undefined;
|
|
12
|
-
connectionSaveData: boolean | undefined;
|
|
13
|
-
userAgent: string | UserAgentData;
|
|
14
|
-
};
|
|
15
3
|
export declare const sendLoadScriptLog: (params: Params) => Promise<void>;
|
|
16
4
|
export {};
|
|
@@ -5,4 +5,4 @@ export declare const MAIN_LOAD_CDN_TYPE: InjectScriptType;
|
|
|
5
5
|
* Get the next cdn type in the fallback list
|
|
6
6
|
* @param currentCdnType The current cdn type that want to get the next fallback url
|
|
7
7
|
*/
|
|
8
|
-
export declare const getNextFallbackUrl: (currentCdnType: InjectScriptType) => "vercel" | "jsdelivr" | "
|
|
8
|
+
export declare const getNextFallbackUrl: (currentCdnType: InjectScriptType) => "vercel" | "jsdelivr" | "unpkg" | "cdnjs";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PayPalNamespace } from '@paypal/paypal-js';
|
|
2
2
|
import type { Stripe } from '@stripe/stripe-js';
|
|
3
3
|
import type { AppearanceConfig } from "../components/store/zonosStore";
|
|
4
|
+
import type { LoadTimeApiLogInfo } from "../components/utils/logging/prepLoadTimeApiLog";
|
|
4
5
|
import type { NotificationInit } from "../types/index";
|
|
5
6
|
import type { NormalizedTempCart } from "../types/checkout/api/NormalizedTempCart";
|
|
6
7
|
import { type CheckoutConfig } from "../types/checkout/CheckoutConfig";
|
|
@@ -195,6 +196,8 @@ export interface Zonos {
|
|
|
195
196
|
*/
|
|
196
197
|
isLegacyCheckout: boolean;
|
|
197
198
|
isNpm: boolean;
|
|
199
|
+
loadTimeApiInfoList: LoadTimeApiLogInfo[];
|
|
200
|
+
logIntervalId: NodeJS.Timeout | null;
|
|
198
201
|
/** Flag if already alerted when preview domain is defined and it's connecting production environment */
|
|
199
202
|
modeAlerted: boolean;
|
|
200
203
|
paypal: PayPalNamespace | null;
|
|
@@ -254,6 +257,8 @@ export declare abstract class Zonos {
|
|
|
254
257
|
static getCurrentTimestamp: () => number;
|
|
255
258
|
static cartId: string | null;
|
|
256
259
|
private static zonosController;
|
|
260
|
+
static loadTimeApiInfoList: LoadTimeApiLogInfo[];
|
|
261
|
+
static logIntervalId: NodeJS.Timeout | null;
|
|
257
262
|
static init: (params: LoadZonosParams) => Promise<void>;
|
|
258
263
|
private static injectCustomScriptForHostedCheckout;
|
|
259
264
|
static displayCurrency: () => void;
|
|
@@ -43,6 +43,10 @@ export type CheckoutConfig = {
|
|
|
43
43
|
status: AnalyticsProviderStatus;
|
|
44
44
|
type: AnalyticsProviderType;
|
|
45
45
|
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Time that payment will be captured after the order is placed. Can't be overridden in Zonos.init
|
|
48
|
+
*/
|
|
49
|
+
captureDelay?: number;
|
|
46
50
|
/**
|
|
47
51
|
* Duration (in seconds) for which the cart remains valid for checkout in hosted checkout.
|
|
48
52
|
* @default 3_600 (1 hour)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { PaypalMockResponse } from "../../generated/graphql.internal.types";
|
|
1
|
+
import type { CheckoutPaypalOrderIntent, PaypalMockResponse } from "../../generated/graphql.internal.types";
|
|
2
2
|
export type PaypalCaptureOrderRequest = {
|
|
3
3
|
checkoutSessionId: string;
|
|
4
4
|
paypalMockResponse: PaypalMockResponse | null;
|
|
5
5
|
};
|
|
6
6
|
export type PaypalCreateOrderRequest = {
|
|
7
7
|
checkoutSessionId: string;
|
|
8
|
+
intent?: CheckoutPaypalOrderIntent;
|
|
8
9
|
};
|
|
10
|
+
export type PaypalOrderIntent = Lowercase<CheckoutPaypalOrderIntent>;
|
|
@@ -608,6 +608,14 @@ export type CreateScriptLoadEventMutation = {
|
|
|
608
608
|
}>;
|
|
609
609
|
} | null;
|
|
610
610
|
};
|
|
611
|
+
export type CreateBulkLoadEventMutation = {
|
|
612
|
+
insert_usage_scriptLoadEvent: {
|
|
613
|
+
affected_rows: number;
|
|
614
|
+
returning: Array<{
|
|
615
|
+
id: number;
|
|
616
|
+
}>;
|
|
617
|
+
} | null;
|
|
618
|
+
};
|
|
611
619
|
export type GetAudienceByAspectKeyQuery = {
|
|
612
620
|
feature_audienceAspectLink: Array<{
|
|
613
621
|
audience: {
|
|
@@ -792,6 +800,9 @@ export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionW
|
|
|
792
800
|
cleanupTestZonosElementSetting(variables?: {
|
|
793
801
|
[x: string]: never;
|
|
794
802
|
}, requestHeaders?: GraphQLClientRequestHeaders): Promise<CleanupTestZonosElementSettingMutation>;
|
|
803
|
+
createBulkLoadEvent(variables?: {
|
|
804
|
+
[x: string]: never;
|
|
805
|
+
}, requestHeaders?: GraphQLClientRequestHeaders): Promise<CreateBulkLoadEventMutation>;
|
|
795
806
|
createErrorEvent(variables?: {
|
|
796
807
|
[x: string]: never;
|
|
797
808
|
}, requestHeaders?: GraphQLClientRequestHeaders): Promise<CreateErrorEventMutation>;
|
|
@@ -617,6 +617,13 @@ export type CreateScriptLoadEventMutation = {
|
|
|
617
617
|
} | null;
|
|
618
618
|
};
|
|
619
619
|
|
|
620
|
+
export type CreateBulkLoadEventMutation = {
|
|
621
|
+
insert_usage_scriptLoadEvent: {
|
|
622
|
+
affected_rows: number;
|
|
623
|
+
returning: Array<{ id: number }>;
|
|
624
|
+
} | null;
|
|
625
|
+
};
|
|
626
|
+
|
|
620
627
|
export type GetAudienceByAspectKeyQuery = {
|
|
621
628
|
feature_audienceAspectLink: Array<{
|
|
622
629
|
audience: {
|
|
@@ -839,6 +846,20 @@ export function getSdk(
|
|
|
839
846
|
'mutation',
|
|
840
847
|
);
|
|
841
848
|
},
|
|
849
|
+
createBulkLoadEvent(
|
|
850
|
+
variables?: { [x: string]: never },
|
|
851
|
+
requestHeaders?: GraphQLClientRequestHeaders,
|
|
852
|
+
): Promise<CreateBulkLoadEventMutation> {
|
|
853
|
+
return withWrapper(
|
|
854
|
+
wrappedRequestHeaders =>
|
|
855
|
+
client.request<CreateBulkLoadEventMutation>('', variables, {
|
|
856
|
+
...requestHeaders,
|
|
857
|
+
...wrappedRequestHeaders,
|
|
858
|
+
}),
|
|
859
|
+
'createBulkLoadEvent',
|
|
860
|
+
'mutation',
|
|
861
|
+
);
|
|
862
|
+
},
|
|
842
863
|
createErrorEvent(
|
|
843
864
|
variables?: { [x: string]: never },
|
|
844
865
|
requestHeaders?: GraphQLClientRequestHeaders,
|