@zonos/elements 1.3.183 → 1.3.184
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/index.cjs.js +29 -8
- package/dist/cjs/zonos-checkout.cjs.entry.js +15 -3
- package/dist/cjs/zonos-controller.cjs.entry.js +8 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +15 -3
- package/dist/collection/components/utils/checkout/initCheckout.js +8 -1
- package/dist/collection/scripts/_zonosBase.js +22 -1
- package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
- package/dist/collection/types/generated/graphql.internal.types.js +33 -0
- package/dist/esm/index.js +29 -8
- package/dist/esm/zonos-checkout.entry.js +15 -3
- package/dist/esm/zonos-controller.entry.js +8 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/scripts/index.d.ts +7 -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/types/checkout/CheckoutConfig.d.ts +7 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +2 -0
- package/dist/types/types/generated/graphql.frontend.types.ts +3 -0
- package/dist/types/types/generated/graphql.internal.types.d.ts +53 -8
- package/dist/types/types/generated/graphql.internal.types.ts +63 -8
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-09041efe.entry.js +1 -0
- package/dist/zonos-elements/p-16e4cdb1.entry.js +1 -0
- package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
- package/dist/zonos-elements/p-642bf613.system.entry.js +1 -0
- package/dist/zonos-elements/{p-59e31080.system.js → p-b1020237.system.js} +1 -1
- package/dist/zonos-elements/p-d5d39db4.system.entry.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-358043a2.system.entry.js +0 -1
- package/dist/zonos-elements/p-4aca92c5.system.entry.js +0 -1
- package/dist/zonos-elements/p-ac889f52.entry.js +0 -1
- package/dist/zonos-elements/p-b998494a.entry.js +0 -1
|
@@ -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},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},w=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],m=({apiPath:o,apiType:e,loadTimeInternal:n,loadTimeTotal:t})=>{if(w.includes(o))return;const r=t-n;if(r<0)return;const s=o.split("?")[0]||o,i=(()=>{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,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:e,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((o=>o.brand)).filter((o=>!/Not.*A.*Brand.*/.test(o))).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)},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:w,response:f}=u,v=o(u,["errors","response"]),Z=performance.now()-c;p(`${t} (${Z.toFixed(2)}ms)`,"info");const z=null==f?void 0:f.headers.get("Zonos-Duration");200===(null==f?void 0:f.status)&&m({apiPath:t,apiType:l,loadTimeInternal:z?Number(z):0,loadTimeTotal:Z});const S=a(l),b=!!w.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),O=S&&b;return b&&g({endpoint:s[l]+t,errors:w.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:l,nextFallbackApiType:S,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}),O?(p(`=== "${t}" failed to fetch, trying next fallback ${S}`),h({basePathType:S,options:n,path:t})):Object.assign({errors:w,response:f},v)},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)},z=["jsdelivr","cdnjs","unpkg","vercel"],S=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},b=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,O=new RegExp(`^${b.source}$`),L=new RegExp(`^cart_${b.source}$`),I=/^[a-zA-Z0-9]{2,}$/,T=/^cart_[a-zA-Z0-9]{2,}$/,A=o=>o?o.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:T.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:I.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:L.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:O.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},C=async({cartId:o,retries:e})=>{const t=n(),{errors:r,json:s,zonosMode:i}=await v("/api/zonos-elements/get-cart",{body:{isTestMode:t,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),a=!s||r.length;return a&&e?(p("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),C({cartId:o,retries:e-1})):a?null:Object.assign(Object.assign({},s),{zonosMode:i})};var U;const k=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=S(window.location.href),n="https://v1.3.183.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=S(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 ${}U=$,$.isNpm=!1,$.isBigCommerce=!1,$.requested=!1,$.zonosMode=null,$.cartData=null,$.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,$.version="v1.3.183",$.isLegacyCheckout=!1,$.legacyStoreLogo=null,$.legacyStoreFavicon=null,$.parallelLoadTimes=[],$.parallelLoadState="off",$.releaseDate="1744403404288",$.loadTimeApiInfoList=[],$.cartSettings=null,$.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(U.parallelLoadTimes.push(o),2===U.parallelLoadTimes.length){const o=U.parallelLoadTimes.find((o=>"vercel"===o.type)),e=U.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}});U.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:U.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},$.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.183";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.183":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.183");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:U.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:U.getGithubCdn({type:o,version:r}),a=k||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 w="4g"===(null===(s=u())||void 0===s?void 0:s.effectiveType),m=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),f=z[0]===o,y=z[1],h="on"===U.parallelLoadState&&w&&f&&y&&!m;h&&U.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(()=>{if(h||n?U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:o}):U.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:o}),U.isBigCommerce||(U.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=k,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosMode=U.zonosMode,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.loadTimeApiInfoList=U.loadTimeApiInfoList,U.cartId){if(!U.zonosApiKey)throw U.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!U.cartData)throw U.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(U.legacyStoreFavicon&&U.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=U.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=U.cartData,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.cartSettings=U.cartSettings;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:U.legacyStoreLogo||""}),zonosApiKey:U.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=z.indexOf(o);return z[e+1]||null})(o);if(!h&&!n){if(!s)return;U.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||k)return;if(h||n)return void U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:U.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",U.releaseDate),k&&!window.isZonosPreview){p(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${k}`,"info");const e=document.createElement("script");return e.src=`${k}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${k}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=A(r);if(r&&!i&&!s)return void U.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});U.cartId=r;const a="https://v1.3.183.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=k,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 c=null==l?void 0:l.includes("timestamp=");if(!(U.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||U.requested)return void p("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!U.cartId)return U.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(U.requested=!0,U.zonosApiKey=o.zonosApiKey,U.storeId=o.storeId,U.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=A(o);if(!n&&!e)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await C({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,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(Z("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(U.cartId);if(!o)throw U.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");U.cartData=o.cartData,U.cartSettings=o.settings,U.legacyStoreLogo=o.storeLogo,U.legacyStoreFavicon=o.storeFavicon,U.storeId=o.storeId,U.zonosApiKey=o.zonosApiKey}if(!U.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"),U.zonosApiKey=u),!U.storeId)return p("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void U.injectZonos({initConfig:o,vercelUrl:a,version:null});const w=U.storeId||o.storeId;p(`[ZONOS - loadZonos] Store ID: ${w}`,"info");const m=new URLSearchParams;m.set("storeId",w.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&m.set("_enableStoreVersionPinned","1");const{errors:g,json:f}=await v(`/api/get-store-version?${m.toString()}`);if(g.length||!f)return p("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void U.injectZonos({initConfig:o,vercelUrl:a,version:null});const{isDifferent:y,source:h,version:z}=f;if(p(`[ZONOS - loadZonos] Store version: ${z}, source: ${h}`,"info"),y){p(`[ZONOS - loadZonos] Updating saved store version to ${z}`,"info");const o={storeId:w,version:z};v(`/api/set-store-version?${m.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"===z?"alpha":`v${z}`}.js.zonos.com`,s=t&&!n?null:z;p("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:z}),U.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=$)})();
|
|
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},w=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],m=({apiPath:o,apiType:e,loadTimeInternal:n,loadTimeTotal:t})=>{if(w.includes(o))return;const r=t-n;if(r<0)return;const s=o.split("?")[0]||o,i=(()=>{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,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:e,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((o=>o.brand)).filter((o=>!/Not.*A.*Brand.*/.test(o))).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)},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:w,response:f}=u,v=o(u,["errors","response"]),Z=performance.now()-c;p(`${t} (${Z.toFixed(2)}ms)`,"info");const z=null==f?void 0:f.headers.get("Zonos-Duration");200===(null==f?void 0:f.status)&&m({apiPath:t,apiType:l,loadTimeInternal:z?Number(z):0,loadTimeTotal:Z});const S=a(l),b=!!w.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),O=S&&b;return b&&g({endpoint:s[l]+t,errors:w.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:l,nextFallbackApiType:S,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}),O?(p(`=== "${t}" failed to fetch, trying next fallback ${S}`),h({basePathType:S,options:n,path:t})):Object.assign({errors:w,response:f},v)},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)},z=["jsdelivr","cdnjs","unpkg","vercel"],S=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},b=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,O=new RegExp(`^${b.source}$`),L=new RegExp(`^cart_${b.source}$`),I=/^[a-zA-Z0-9]{2,}$/,T=/^cart_[a-zA-Z0-9]{2,}$/,A=o=>o?o.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:T.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:I.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:L.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:O.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},C=async({cartId:o,retries:e})=>{const t=n(),{errors:r,json:s,zonosMode:i}=await v("/api/zonos-elements/get-cart",{body:{isTestMode:t,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),a=!s||r.length;return a&&e?(p("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),C({cartId:o,retries:e-1})):a?null:Object.assign(Object.assign({},s),{zonosMode:i})};var U;const k=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=S(window.location.href),n="https://v1.3.184.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=S(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 ${}U=$,$.isNpm=!1,$.isBigCommerce=!1,$.requested=!1,$.zonosMode=null,$.cartData=null,$.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,$.version="v1.3.184",$.isLegacyCheckout=!1,$.legacyStoreLogo=null,$.legacyStoreFavicon=null,$.parallelLoadTimes=[],$.parallelLoadState="off",$.releaseDate="1745332640034",$.loadTimeApiInfoList=[],$.cartSettings=null,$.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(U.parallelLoadTimes.push(o),2===U.parallelLoadTimes.length){const o=U.parallelLoadTimes.find((o=>"vercel"===o.type)),e=U.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}});U.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:U.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},$.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.184";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.184":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.184");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:U.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:U.getGithubCdn({type:o,version:r}),a=k||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 w="4g"===(null===(s=u())||void 0===s?void 0:s.effectiveType),m=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),f=z[0]===o,y=z[1],h="on"===U.parallelLoadState&&w&&f&&y&&!m;h&&U.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(()=>{if(h||n?U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:o}):U.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:o}),U.isBigCommerce||(U.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=k,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosMode=U.zonosMode,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.loadTimeApiInfoList=U.loadTimeApiInfoList,U.cartId){if(!U.zonosApiKey)throw U.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!U.cartData)throw U.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(U.legacyStoreFavicon&&U.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=U.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=U.cartData,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.cartSettings=U.cartSettings;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:U.legacyStoreLogo||""}),zonosApiKey:U.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=z.indexOf(o);return z[e+1]||null})(o);if(!h&&!n){if(!s)return;U.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||k)return;if(h||n)return void U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:U.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",U.releaseDate),k&&!window.isZonosPreview){p(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${k}`,"info");const e=document.createElement("script");return e.src=`${k}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${k}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=A(r);if(r&&!i&&!s)return void U.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});U.cartId=r;const a="https://v1.3.184.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=k,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 c=null==l?void 0:l.includes("timestamp=");if(!(U.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||U.requested)return void p("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!U.cartId)return U.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(U.requested=!0,U.zonosApiKey=o.zonosApiKey,U.storeId=o.storeId,U.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=A(o);if(!n&&!e)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await C({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,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(Z("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(U.cartId);if(!o)throw U.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");U.cartData=o.cartData,U.cartSettings=o.settings,U.legacyStoreLogo=o.storeLogo,U.legacyStoreFavicon=o.storeFavicon,U.storeId=o.storeId,U.zonosApiKey=o.zonosApiKey}if(!U.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"),U.zonosApiKey=u),!U.storeId)return p("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void U.injectZonos({initConfig:o,vercelUrl:a,version:null});const w=U.storeId||o.storeId;p(`[ZONOS - loadZonos] Store ID: ${w}`,"info");const m=new URLSearchParams;m.set("storeId",w.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&m.set("_enableStoreVersionPinned","1");const{errors:g,json:f}=await v(`/api/get-store-version?${m.toString()}`);if(g.length||!f)return p("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void U.injectZonos({initConfig:o,vercelUrl:a,version:null});const{isDifferent:y,source:h,version:z}=f;if(p(`[ZONOS - loadZonos] Store version: ${z}, source: ${h}`,"info"),y){p(`[ZONOS - loadZonos] Updating saved store version to ${z}`,"info");const o={storeId:w,version:z};v(`/api/set-store-version?${m.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"===z?"alpha":`v${z}`}.js.zonos.com`,s=t&&!n?null:z;p("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:z}),U.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},h=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},y=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],f=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=h(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}},v=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 f({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await f({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}}},b=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),c=await v({basePathType:i,options:o,path:n}),{errors:d,response:u}=c,f=l(c,["errors","response"]),S=performance.now()-a;t(`${n} (${S.toFixed(2)}ms)`,"info");const z=null==u?void 0:u.headers.get("Zonos-Duration");200===(null==u?void 0:u.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(g.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=y(),a="object"==typeof i.userAgent&&i.userAgent.mobile,c={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(c)})({apiPath:n,apiType:i,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const C=w(i),Z=!!d.find((({type:e})=>"unknown"===e))||404===(null==u?void 0:u.status),j=C&&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(`${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:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:C,requestHeaders:null==o?void 0:o.headers,requestPayload:h(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==u?void 0:u.status,statusText:null==u?void 0:u.statusText},shouldPostReleaseErrorReporting:!0}),j?(t(`=== "${n}" failed to fetch, trying next fallback ${C}`),b({basePathType:C,options:o,path:n})):Object.assign({errors:d,response:u},f)},S=async(e,o)=>{const t=l(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=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"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return b({basePathType:d||u,options:i,path:e})},z=()=>{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.183.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\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let O=null;const k=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),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(j):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)}))),O),A=Promise.resolve().then((()=>k(null)));let I=!1;A.catch((e=>{I||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s,zonosMode:i}=await S("/api/zonos-elements/get-cart",{body:{isTestMode:n,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))),T({cartId:e,retries:o-1})):a?null:Object.assign(Object.assign({},s),{zonosMode:i})},E=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${E.source}$`),$=new RegExp(`^cart_${E.source}$`),N=/^[a-zA-Z0-9]{2,}$/,D=/^cart_[a-zA-Z0-9]{2,}$/,P=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:L.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 T({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,window.Zonos.zonosMode=s.zonosMode,{cartData:s.cartData,settings:s.settings,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 F=(()=>{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})(),R="https://v1.3.183.js.zonos.com",M=F||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.183",x="https://fonts.googleapis.com",B=/^https:\/\/fonts\.googleapis\.com/;class q{}U=q,q.doneInit=!1,q.cartSettings=null,q.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),q.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),q._paypalMockResponse=null,q.isBigCommerce=!1,q.releaseDate="1744403404288",q.isLegacyCheckout=!1,q.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",q.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),q.isNpm=!0,q.zonosQaUrl=null,q.zonosQaUrlApi=null,q.trackEventLogs=[],q.version="v1.3.183",q.modeAlerted=!1,q.cartData=null,q.paypal=null,q.zonosMode=null,q.getCurrentTimestamp=()=>(new Date).getTime(),q.zonosController=null,q.loadTimeApiInfoList=[],q.logIntervalId=null,q.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=z();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 P(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey,U.cartSettings=e.settings}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 S("/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},q.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})},q.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},q.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},q.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},q.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},q.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)}},q.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)},q.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)=>{I=!0;const o=Date.now();return A.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!")},q.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)},q.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return M;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.183";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.183";case"vercel":return R}};if(U.isNpm){return z()||o()}return o()},q.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!")},q.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${R}/`,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)},q.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!"))},q.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${x}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!B.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=x,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${x}/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!")},q.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},q.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^="${x}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=x,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=q)})();
|
|
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},h=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},y=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],f=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=h(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}},v=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 f({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await f({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}}},b=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),c=await v({basePathType:i,options:o,path:n}),{errors:d,response:u}=c,f=l(c,["errors","response"]),S=performance.now()-a;t(`${n} (${S.toFixed(2)}ms)`,"info");const z=null==u?void 0:u.headers.get("Zonos-Duration");200===(null==u?void 0:u.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(g.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=y(),a="object"==typeof i.userAgent&&i.userAgent.mobile,c={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(c)})({apiPath:n,apiType:i,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const C=w(i),O=!!d.find((({type:e})=>"unknown"===e))||404===(null==u?void 0:u.status),Z=C&&O;return O&&(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:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:C,requestHeaders:null==o?void 0:o.headers,requestPayload:h(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==u?void 0:u.status,statusText:null==u?void 0:u.statusText},shouldPostReleaseErrorReporting:!0}),Z?(t(`=== "${n}" failed to fetch, trying next fallback ${C}`),b({basePathType:C,options:o,path:n})):Object.assign({errors:d,response:u},f)},S=async(e,o)=>{const t=l(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=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"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return b({basePathType:d||u,options:i,path:e})},z=()=>{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.184.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",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Z="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(Z),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&&O.test(t.src))return t}return null})();r&&e?console.warn(Z):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),I=Promise.resolve().then((()=>k(null)));let A=!1;I.catch((e=>{A||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s,zonosMode:i}=await S("/api/zonos-elements/get-cart",{body:{isTestMode:n,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))),T({cartId:e,retries:o-1})):a?null:Object.assign(Object.assign({},s),{zonosMode:i})},E=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${E.source}$`),$=new RegExp(`^cart_${E.source}$`),N=/^[a-zA-Z0-9]{2,}$/,D=/^cart_[a-zA-Z0-9]{2,}$/,P=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:L.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 T({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,window.Zonos.zonosMode=s.zonosMode,{cartData:s.cartData,settings:s.settings,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 F=(()=>{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})(),R="https://v1.3.184.js.zonos.com",M=F||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.184",x="https://fonts.googleapis.com",B=/^https:\/\/fonts\.googleapis\.com/;class q{}U=q,q.doneInit=!1,q.cartSettings=null,q.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),q.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),q._paypalMockResponse=null,q.isBigCommerce=!1,q.releaseDate="1745332640034",q.isLegacyCheckout=!1,q.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",q.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),q.isNpm=!0,q.zonosQaUrl=null,q.zonosQaUrlApi=null,q.trackEventLogs=[],q.version="v1.3.184",q.modeAlerted=!1,q.cartData=null,q.paypal=null,q.zonosMode=null,q.getCurrentTimestamp=()=>(new Date).getTime(),q.zonosController=null,q.loadTimeApiInfoList=[],q.logIntervalId=null,q.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=z();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 P(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey,U.cartSettings=e.settings}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 S("/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},q.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})},q.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},q.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},q.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},q.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},q.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)}},q.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)},q.injectController=({config:e})=>{var o,r;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})}if(null===(r=e.checkoutSettings)||void 0===r?void 0:r.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;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 s=document.createElement("zonos-controller");s.config=e,s.zonosApiKey=U.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const r=await(async(...e)=>{A=!0;const o=Date.now();return I.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);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),U.zonosController=s,t("Zonos controller injected!")},q.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)},q.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return M;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.184";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.184";case"vercel":return R}};if(U.isNpm){return z()||o()}return o()},q.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!")},q.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${R}/`,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)},q.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!"))},q.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${x}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!B.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=x,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${x}/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!")},q.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},q.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^="${x}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=x,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=q)})();
|
|
@@ -40,6 +40,10 @@ export type CheckoutConfig = {
|
|
|
40
40
|
* @default LOCAL
|
|
41
41
|
*/
|
|
42
42
|
allowedSettlementCurrencies: AllowedSettlementCurrencies;
|
|
43
|
+
/**
|
|
44
|
+
* Always trigger International Checkout with this selector regardless of shipping zone
|
|
45
|
+
*/
|
|
46
|
+
alwaysTriggerInternationalCheckoutSelector?: string | null;
|
|
43
47
|
analyticsProviders: Array<{
|
|
44
48
|
status: AnalyticsProviderStatus;
|
|
45
49
|
type: AnalyticsProviderType;
|
|
@@ -90,6 +94,9 @@ export type CheckoutConfig = {
|
|
|
90
94
|
};
|
|
91
95
|
};
|
|
92
96
|
organization: string;
|
|
97
|
+
/**
|
|
98
|
+
* Place order button selector that only trigger International Checkout when shopper is in merchant's shipping zones
|
|
99
|
+
*/
|
|
93
100
|
placeOrderButtonSelector: string | null;
|
|
94
101
|
/**
|
|
95
102
|
* @param subscriptionStatus subscription status for checkout, checkout only available if subscription status is ENABLED and visibility status is ENABLED
|
|
@@ -85,6 +85,7 @@ export declare const featureAspectKeyEnum: {
|
|
|
85
85
|
readonly ClassifySingleRequest: "classify_single_request";
|
|
86
86
|
readonly ComConsolidation: "com_consolidation";
|
|
87
87
|
readonly DashboardCheckout_2Settings: "dashboard_checkout_2_settings";
|
|
88
|
+
readonly DashboardChurnedNotification: "dashboard_churned_notification";
|
|
88
89
|
readonly DashboardHello_2Settings: "dashboard_hello_2_settings";
|
|
89
90
|
readonly DashboardNewLabelUi: "dashboard_new_label_ui";
|
|
90
91
|
readonly DashboardOrderApprove: "dashboard_order_approve";
|
|
@@ -112,6 +113,7 @@ export declare const featureAudienceNameEnum: {
|
|
|
112
113
|
readonly ClassifyBulkMerchant: "classify_bulk_merchant";
|
|
113
114
|
readonly ClassifyBulkMerchantExportConfidenceScore: "classify_bulk_merchant_export_confidence_score";
|
|
114
115
|
readonly CustomerSuccess: "customer_success";
|
|
116
|
+
readonly DashboardChurnedNotificationMerchant: "dashboard_churned_notification_merchant";
|
|
115
117
|
readonly DashboardLabelBetaMerchant: "dashboard_label_beta_merchant";
|
|
116
118
|
readonly Designer: "designer";
|
|
117
119
|
readonly DocsContributor: "docs_contributor";
|
|
@@ -64,6 +64,7 @@ export const featureAspectKeyEnum = {
|
|
|
64
64
|
ClassifySingleRequest: 'classify_single_request',
|
|
65
65
|
ComConsolidation: 'com_consolidation',
|
|
66
66
|
DashboardCheckout_2Settings: 'dashboard_checkout_2_settings',
|
|
67
|
+
DashboardChurnedNotification: 'dashboard_churned_notification',
|
|
67
68
|
DashboardHello_2Settings: 'dashboard_hello_2_settings',
|
|
68
69
|
DashboardNewLabelUi: 'dashboard_new_label_ui',
|
|
69
70
|
DashboardOrderApprove: 'dashboard_order_approve',
|
|
@@ -95,6 +96,8 @@ export const featureAudienceNameEnum = {
|
|
|
95
96
|
ClassifyBulkMerchantExportConfidenceScore:
|
|
96
97
|
'classify_bulk_merchant_export_confidence_score',
|
|
97
98
|
CustomerSuccess: 'customer_success',
|
|
99
|
+
DashboardChurnedNotificationMerchant:
|
|
100
|
+
'dashboard_churned_notification_merchant',
|
|
98
101
|
DashboardLabelBetaMerchant: 'dashboard_label_beta_merchant',
|
|
99
102
|
Designer: 'designer',
|
|
100
103
|
DocsContributor: 'docs_contributor',
|
|
@@ -1861,6 +1861,22 @@ export declare const itemRestrictionType: {
|
|
|
1861
1861
|
readonly Restriction: "RESTRICTION";
|
|
1862
1862
|
};
|
|
1863
1863
|
export type ItemRestrictionType = (typeof itemRestrictionType)[keyof typeof itemRestrictionType];
|
|
1864
|
+
export declare const itemReverseAmountStatus: {
|
|
1865
|
+
readonly Applied: "APPLIED";
|
|
1866
|
+
readonly NotAppliedNegativeValue: "NOT_APPLIED_NEGATIVE_VALUE";
|
|
1867
|
+
readonly NotAppliedUnderDeMinimis: "NOT_APPLIED_UNDER_DE_MINIMIS";
|
|
1868
|
+
};
|
|
1869
|
+
export type ItemReverseAmountStatus = (typeof itemReverseAmountStatus)[keyof typeof itemReverseAmountStatus];
|
|
1870
|
+
export declare const itemReverseAmountType: {
|
|
1871
|
+
readonly Duty: "DUTY";
|
|
1872
|
+
readonly DutyFee: "DUTY_FEE";
|
|
1873
|
+
readonly DutyTax: "DUTY_TAX";
|
|
1874
|
+
readonly DutyTaxFee: "DUTY_TAX_FEE";
|
|
1875
|
+
readonly None: "NONE";
|
|
1876
|
+
readonly Tax: "TAX";
|
|
1877
|
+
readonly TaxFee: "TAX_FEE";
|
|
1878
|
+
};
|
|
1879
|
+
export type ItemReverseAmountType = (typeof itemReverseAmountType)[keyof typeof itemReverseAmountType];
|
|
1864
1880
|
export declare const itemType: {
|
|
1865
1881
|
readonly Bundle: "BUNDLE";
|
|
1866
1882
|
readonly DigitalGood: "DIGITAL_GOOD";
|
|
@@ -2343,6 +2359,7 @@ export declare const orderPaymentStatus: {
|
|
|
2343
2359
|
readonly PartiallyRefunded: "PARTIALLY_REFUNDED";
|
|
2344
2360
|
readonly Refunded: "REFUNDED";
|
|
2345
2361
|
readonly Unpaid: "UNPAID";
|
|
2362
|
+
readonly Voided: "VOIDED";
|
|
2346
2363
|
};
|
|
2347
2364
|
export type OrderPaymentStatus = (typeof orderPaymentStatus)[keyof typeof orderPaymentStatus];
|
|
2348
2365
|
export declare const orderRefundSubtotalType: {
|
|
@@ -2608,6 +2625,22 @@ export declare const result: {
|
|
|
2608
2625
|
readonly Success: "SUCCESS";
|
|
2609
2626
|
};
|
|
2610
2627
|
export type Result = (typeof result)[keyof typeof result];
|
|
2628
|
+
export declare const reverseAmountStatus: {
|
|
2629
|
+
readonly Applied: "APPLIED";
|
|
2630
|
+
readonly NotAppliedNegativeValue: "NOT_APPLIED_NEGATIVE_VALUE";
|
|
2631
|
+
readonly NotAppliedUnderDeMinimis: "NOT_APPLIED_UNDER_DE_MINIMIS";
|
|
2632
|
+
};
|
|
2633
|
+
export type ReverseAmountStatus = (typeof reverseAmountStatus)[keyof typeof reverseAmountStatus];
|
|
2634
|
+
export declare const reverseAmountType: {
|
|
2635
|
+
readonly Duty: "DUTY";
|
|
2636
|
+
readonly DutyFee: "DUTY_FEE";
|
|
2637
|
+
readonly DutyTax: "DUTY_TAX";
|
|
2638
|
+
readonly DutyTaxFee: "DUTY_TAX_FEE";
|
|
2639
|
+
readonly None: "NONE";
|
|
2640
|
+
readonly Tax: "TAX";
|
|
2641
|
+
readonly TaxFee: "TAX_FEE";
|
|
2642
|
+
};
|
|
2643
|
+
export type ReverseAmountType = (typeof reverseAmountType)[keyof typeof reverseAmountType];
|
|
2611
2644
|
export declare const roundingMethod: {
|
|
2612
2645
|
readonly Custom: "CUSTOM";
|
|
2613
2646
|
readonly Hundredth: "HUNDREDTH";
|
|
@@ -2619,9 +2652,13 @@ export declare const roundingMethod: {
|
|
|
2619
2652
|
export type RoundingMethod = (typeof roundingMethod)[keyof typeof roundingMethod];
|
|
2620
2653
|
export declare const searchIndex: {
|
|
2621
2654
|
readonly Catalog: "CATALOG";
|
|
2655
|
+
readonly CatalogRecent: "CATALOG_RECENT";
|
|
2622
2656
|
readonly Orders: "ORDERS";
|
|
2657
|
+
readonly OrdersRecent: "ORDERS_RECENT";
|
|
2623
2658
|
readonly Quotes: "QUOTES";
|
|
2659
|
+
readonly QuotesRecent: "QUOTES_RECENT";
|
|
2624
2660
|
readonly Shipments: "SHIPMENTS";
|
|
2661
|
+
readonly ShipmentsRecent: "SHIPMENTS_RECENT";
|
|
2625
2662
|
};
|
|
2626
2663
|
export type SearchIndex = (typeof searchIndex)[keyof typeof searchIndex];
|
|
2627
2664
|
export declare const serviceLevelAvailability: {
|
|
@@ -3590,26 +3627,34 @@ export type ShipmentRatingFragment = {
|
|
|
3590
3627
|
};
|
|
3591
3628
|
export type FulfillmentCenterQuery = {
|
|
3592
3629
|
fulfillmentCenters: Array<{
|
|
3593
|
-
name: string;
|
|
3594
3630
|
party: {
|
|
3595
3631
|
location: {
|
|
3596
3632
|
administrativeArea: string | null;
|
|
3597
3633
|
administrativeAreaCode: string | null;
|
|
3598
3634
|
countryCode: CountryCode;
|
|
3599
|
-
latitude: number | null;
|
|
3600
3635
|
line1: string | null;
|
|
3601
|
-
line2: string | null;
|
|
3602
|
-
line3: string | null;
|
|
3603
|
-
line4: string | null;
|
|
3604
3636
|
locality: string | null;
|
|
3605
|
-
longitude: number | null;
|
|
3606
|
-
plusCode: string | null;
|
|
3607
3637
|
postalCode: string | null;
|
|
3608
|
-
propertyType: PropertyType | null;
|
|
3609
3638
|
} | null;
|
|
3610
3639
|
};
|
|
3611
3640
|
type: FulfillmentCenterType;
|
|
3612
3641
|
}> | null;
|
|
3642
|
+
shippingZones: Array<{
|
|
3643
|
+
countryCodes: Array<CountryCode> | null;
|
|
3644
|
+
fulfillmentCenter: {
|
|
3645
|
+
party: {
|
|
3646
|
+
location: {
|
|
3647
|
+
administrativeArea: string | null;
|
|
3648
|
+
administrativeAreaCode: string | null;
|
|
3649
|
+
countryCode: CountryCode;
|
|
3650
|
+
line1: string | null;
|
|
3651
|
+
locality: string | null;
|
|
3652
|
+
postalCode: string | null;
|
|
3653
|
+
} | null;
|
|
3654
|
+
};
|
|
3655
|
+
type: FulfillmentCenterType;
|
|
3656
|
+
} | null;
|
|
3657
|
+
} | null> | null;
|
|
3613
3658
|
};
|
|
3614
3659
|
export type PartyInfoQuery = {
|
|
3615
3660
|
party: {
|
|
@@ -2230,6 +2230,27 @@ export const itemRestrictionType = {
|
|
|
2230
2230
|
export type ItemRestrictionType =
|
|
2231
2231
|
(typeof itemRestrictionType)[keyof typeof itemRestrictionType];
|
|
2232
2232
|
|
|
2233
|
+
export const itemReverseAmountStatus = {
|
|
2234
|
+
Applied: 'APPLIED',
|
|
2235
|
+
NotAppliedNegativeValue: 'NOT_APPLIED_NEGATIVE_VALUE',
|
|
2236
|
+
NotAppliedUnderDeMinimis: 'NOT_APPLIED_UNDER_DE_MINIMIS',
|
|
2237
|
+
} as const;
|
|
2238
|
+
|
|
2239
|
+
export type ItemReverseAmountStatus =
|
|
2240
|
+
(typeof itemReverseAmountStatus)[keyof typeof itemReverseAmountStatus];
|
|
2241
|
+
export const itemReverseAmountType = {
|
|
2242
|
+
Duty: 'DUTY',
|
|
2243
|
+
DutyFee: 'DUTY_FEE',
|
|
2244
|
+
DutyTax: 'DUTY_TAX',
|
|
2245
|
+
DutyTaxFee: 'DUTY_TAX_FEE',
|
|
2246
|
+
None: 'NONE',
|
|
2247
|
+
Tax: 'TAX',
|
|
2248
|
+
TaxFee: 'TAX_FEE',
|
|
2249
|
+
} as const;
|
|
2250
|
+
|
|
2251
|
+
export type ItemReverseAmountType =
|
|
2252
|
+
(typeof itemReverseAmountType)[keyof typeof itemReverseAmountType];
|
|
2253
|
+
|
|
2233
2254
|
export const itemType = {
|
|
2234
2255
|
Bundle: 'BUNDLE',
|
|
2235
2256
|
DigitalGood: 'DIGITAL_GOOD',
|
|
@@ -2826,6 +2847,7 @@ export const orderPaymentStatus = {
|
|
|
2826
2847
|
PartiallyRefunded: 'PARTIALLY_REFUNDED',
|
|
2827
2848
|
Refunded: 'REFUNDED',
|
|
2828
2849
|
Unpaid: 'UNPAID',
|
|
2850
|
+
Voided: 'VOIDED',
|
|
2829
2851
|
} as const;
|
|
2830
2852
|
|
|
2831
2853
|
export type OrderPaymentStatus =
|
|
@@ -3183,6 +3205,27 @@ export const result = {
|
|
|
3183
3205
|
|
|
3184
3206
|
export type Result = (typeof result)[keyof typeof result];
|
|
3185
3207
|
|
|
3208
|
+
export const reverseAmountStatus = {
|
|
3209
|
+
Applied: 'APPLIED',
|
|
3210
|
+
NotAppliedNegativeValue: 'NOT_APPLIED_NEGATIVE_VALUE',
|
|
3211
|
+
NotAppliedUnderDeMinimis: 'NOT_APPLIED_UNDER_DE_MINIMIS',
|
|
3212
|
+
} as const;
|
|
3213
|
+
|
|
3214
|
+
export type ReverseAmountStatus =
|
|
3215
|
+
(typeof reverseAmountStatus)[keyof typeof reverseAmountStatus];
|
|
3216
|
+
export const reverseAmountType = {
|
|
3217
|
+
Duty: 'DUTY',
|
|
3218
|
+
DutyFee: 'DUTY_FEE',
|
|
3219
|
+
DutyTax: 'DUTY_TAX',
|
|
3220
|
+
DutyTaxFee: 'DUTY_TAX_FEE',
|
|
3221
|
+
None: 'NONE',
|
|
3222
|
+
Tax: 'TAX',
|
|
3223
|
+
TaxFee: 'TAX_FEE',
|
|
3224
|
+
} as const;
|
|
3225
|
+
|
|
3226
|
+
export type ReverseAmountType =
|
|
3227
|
+
(typeof reverseAmountType)[keyof typeof reverseAmountType];
|
|
3228
|
+
|
|
3186
3229
|
export const roundingMethod = {
|
|
3187
3230
|
Custom: 'CUSTOM',
|
|
3188
3231
|
Hundredth: 'HUNDREDTH',
|
|
@@ -3197,9 +3240,13 @@ export type RoundingMethod =
|
|
|
3197
3240
|
|
|
3198
3241
|
export const searchIndex = {
|
|
3199
3242
|
Catalog: 'CATALOG',
|
|
3243
|
+
CatalogRecent: 'CATALOG_RECENT',
|
|
3200
3244
|
Orders: 'ORDERS',
|
|
3245
|
+
OrdersRecent: 'ORDERS_RECENT',
|
|
3201
3246
|
Quotes: 'QUOTES',
|
|
3247
|
+
QuotesRecent: 'QUOTES_RECENT',
|
|
3202
3248
|
Shipments: 'SHIPMENTS',
|
|
3249
|
+
ShipmentsRecent: 'SHIPMENTS_RECENT',
|
|
3203
3250
|
} as const;
|
|
3204
3251
|
|
|
3205
3252
|
export type SearchIndex = (typeof searchIndex)[keyof typeof searchIndex];
|
|
@@ -4217,26 +4264,34 @@ export type ShipmentRatingFragment = {
|
|
|
4217
4264
|
|
|
4218
4265
|
export type FulfillmentCenterQuery = {
|
|
4219
4266
|
fulfillmentCenters: Array<{
|
|
4220
|
-
name: string;
|
|
4221
4267
|
party: {
|
|
4222
4268
|
location: {
|
|
4223
4269
|
administrativeArea: string | null;
|
|
4224
4270
|
administrativeAreaCode: string | null;
|
|
4225
4271
|
countryCode: CountryCode;
|
|
4226
|
-
latitude: number | null;
|
|
4227
4272
|
line1: string | null;
|
|
4228
|
-
line2: string | null;
|
|
4229
|
-
line3: string | null;
|
|
4230
|
-
line4: string | null;
|
|
4231
4273
|
locality: string | null;
|
|
4232
|
-
longitude: number | null;
|
|
4233
|
-
plusCode: string | null;
|
|
4234
4274
|
postalCode: string | null;
|
|
4235
|
-
propertyType: PropertyType | null;
|
|
4236
4275
|
} | null;
|
|
4237
4276
|
};
|
|
4238
4277
|
type: FulfillmentCenterType;
|
|
4239
4278
|
}> | null;
|
|
4279
|
+
shippingZones: Array<{
|
|
4280
|
+
countryCodes: Array<CountryCode> | null;
|
|
4281
|
+
fulfillmentCenter: {
|
|
4282
|
+
party: {
|
|
4283
|
+
location: {
|
|
4284
|
+
administrativeArea: string | null;
|
|
4285
|
+
administrativeAreaCode: string | null;
|
|
4286
|
+
countryCode: CountryCode;
|
|
4287
|
+
line1: string | null;
|
|
4288
|
+
locality: string | null;
|
|
4289
|
+
postalCode: string | null;
|
|
4290
|
+
} | null;
|
|
4291
|
+
};
|
|
4292
|
+
type: FulfillmentCenterType;
|
|
4293
|
+
} | null;
|
|
4294
|
+
} | null> | null;
|
|
4240
4295
|
};
|
|
4241
4296
|
|
|
4242
4297
|
export type PartyInfoQuery = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg color="var(--zonos-elements-
|
|
1
|
+
<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,a as n,l as t,h as o,b as r}from"./p-0fc02cde.js";import{_ as i,c as l}from"./p-fe253cc1.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-fe253cc1.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./p-5bd927f2.js";const a=["jsdelivr","cdnjs","unpkg","vercel"],u="jsdelivr",m=e=>{const n=a.indexOf(e);return a[n+1]||null},p=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.183.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const s=`https://${n}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),s},w="https://js.stripe.com/v3",f=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,h="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let y=null;const v=Promise.resolve().then((()=>{return e=null,null!==y||(y=new Promise(((n,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(h),window.Stripe)n(window.Stripe);else try{let o=(()=>{const e=document.querySelectorAll(`script[src^="${w}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&f.test(t.src))return t}return null})();o&&e?console.warn(h):o||(o=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${w}${n}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(r("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==o||o.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):t(new Error("Stripe.js not available"))})),null==o||o.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else n(null)}))),y;var e}));let g=!1;v.catch((e=>{g||console.warn(e)}));const z=async({cartId:n,retries:s})=>{const r=e(),{errors:i,json:c,zonosMode:d}=await o("/api/zonos-elements/get-cart",{body:{isTestMode:r,tempCartUUID:n},headers:{"Content-Type":"application/json"},method:"POST"}),l=!c||i.length;return l&&s?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:s}),await new Promise((e=>setTimeout(e,500))),z({cartId:n,retries:s-1})):l?null:Object.assign(Object.assign({},c),{zonosMode:d})};var S;const j=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=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=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),O="https://v1.3.183.js.zonos.com",b=j||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.183",k="https://fonts.googleapis.com",Z=/^https:\/\/fonts\.googleapis\.com/;class I{}S=I,I.doneInit=!1,I.cartSettings=null,I.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),I.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),I._paypalMockResponse=null,I.isBigCommerce=!1,I.releaseDate="1744403359888",I.isLegacyCheckout=!1,I.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",I.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),I.isNpm=!0,I.zonosQaUrl=null,I.zonosQaUrlApi=null,I.trackEventLogs=[],I.version="v1.3.183",I.modeAlerted=!1,I.cartData=null,I.paypal=null,I.zonosMode=null,I.getCurrentTimestamp=()=>(new Date).getTime(),I.zonosController=null,I.loadTimeApiInfoList=[],I.logIntervalId=null,I.init=async s=>{const{appearance:c,checkoutSettings:d,currencyConverter:a,helloSettings:u,onCountryChange:m,overrideCurrencyFormat:w,storeId:f,zonosApiKey:h}=s;if(S.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),S.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${S.version}) ======`),S.zonosApiKey=h,S.storeId=f,S.isNpm){t("====== ZONOS LOADING FROM NPM ======");const c=p();if(c&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${c} ======`,"info");const e=document.createElement("script");return e.src=`${c}/dist/scripts/zonos.js`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=S.isNpm,window.Zonos.isBigCommerce=S.isBigCommerce,window.Zonos.isLegacyCheckout=S.isLegacyCheckout,window.Zonos.init(s)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${c}`)})),void(window.isZonosPreview=!0)}if(!h&&!S.cartId)return void r("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!S.cartData&&S.cartId){t("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=i(e);if(!o&&!n)return r("[ZONOS - loadZonos] invalid cart id"),null;const s=await z({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,window.Zonos.zonosMode=s.zonosMode,{cartData:s.cartData,settings:s.settings,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(r("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(S.cartId);if(!e)return void r("Failed to get cart data");S.cartData=e.cartData,S.zonosApiKey=e.zonosApiKey,S.cartSettings=e.settings}const d=await(async()=>{const s=e(),i=n();if(!s&&!i||!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:c,json:d}=await o("/api/get-test-public-credential");if(c.length||!d)return r("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",c),null;const l=d.publicCredential;return l?(t(`[ZONOS - loadZonos] Retrieve new test public token ${l}`,"info"),l):(r("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();d&&(S.zonosApiKey=d)}const y=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(S.cartId&&S.cartData||y){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=`${l}`,document.body.appendChild(e)}t("init zonos"),S.restoreNativeBrowserFunctions(),S.injectCustomScriptForHostedCheckout(),S.injectZonosCdn(),S.injectZonosCss(),S.injectFonts(),S.injectController({config:{appearance:c,checkoutSettings:d,currencyConverter:a,helloSettings:u,onCountryChange:m,overrideCurrencyFormat:w}}),S.doneInit=!0},I.injectCustomScriptForHostedCheckout=()=>{const e=S.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),s=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||s)){if(o){t("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(s){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=s.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:s,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},I.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},I.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},I.showNotification=e=>{var n;null===(n=S.zonosController)||void 0===n||n.showNotification(e)},I.updateOrganizationName=e=>{var n;null===(n=S.zonosController)||void 0===n||n.updateOrganizationName(e)},I.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:t,placeOrderButtonSelector:o})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&o){const n=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},I.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let t=document.querySelector(`iframe#${n}`);t||(t=document.createElement("iframe"),t.id=n,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 o=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=o,document.body.removeChild(t)},I.injectController=({config:e})=>{var n;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;S.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{S.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const o=document.createElement("zonos-controller");o.config=e,o.zonosApiKey=S.zonosApiKey||"",o.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;t("loading Stripe");const s=await(async(...e)=>{g=!0;const n=Date.now();return v.then((t=>((e,n,t)=>{if(null===e)return null;const o=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(o,t),o})(t,e,n)))})(n.publishableKey);s?(window.Zonos.stripe=s,o.initCheckoutElement(s)):r("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(o),S.zonosController=o,t("Zonos controller injected!")},I.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const s=`${S.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const i=document.head||document.body,c=document.createElement("script");n?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{r(`Failed to load ${c.src}`);const t=m(e);t&&S.injectScript({cdnType:t,isModule:n,theRestUrl:o})},i.appendChild(c)},I.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return b;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.183";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.183";case"vercel":return O}};return S.isNpm&&p()||n()},I.injectZonosCdn=()=>{S.injectScript({cdnType:u,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),S.injectScript({cdnType:u,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},I.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const t=S.getZonosUrl(e),o=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${O}/`,o.appendChild(s);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${n}`,i.onerror=()=>{r(`Failed to load ${i.href}`);const t=m(e);t&&S.injectStylesheet({cdnType:t,theRestUrl:n})},o.appendChild(i)},I.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(S.injectStylesheet({cdnType:u,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},I.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${k}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!Z.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=k,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${k}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),t("Zonos font injected!")},I.setupGoogleFont=e=>{var n;null===(n=S.zonosController)||void 0===n||n.setupGoogleFont(e)},I.injectSupportGoogleFont=e=>{var n;t(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${k}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=k,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${o} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=e,s.appendChild(r),t(`[FONT] ${o} font injected!`)};export{I as Zonos}
|
|
1
|
+
import{g as e,a as n,l as t,h as o,b as r}from"./p-0fc02cde.js";import{_ as i,c as l}from"./p-fe253cc1.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-fe253cc1.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./p-5bd927f2.js";const a=["jsdelivr","cdnjs","unpkg","vercel"],u="jsdelivr",m=e=>{const n=a.indexOf(e);return a[n+1]||null},p=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.184.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const s=`https://${n}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),s},w="https://js.stripe.com/v3",f=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,h="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let y=null;const v=Promise.resolve().then((()=>{return e=null,null!==y||(y=new Promise(((n,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(h),window.Stripe)n(window.Stripe);else try{let o=(()=>{const e=document.querySelectorAll(`script[src^="${w}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&f.test(t.src))return t}return null})();o&&e?console.warn(h):o||(o=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${w}${n}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(r("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==o||o.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):t(new Error("Stripe.js not available"))})),null==o||o.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else n(null)}))),y;var e}));let g=!1;v.catch((e=>{g||console.warn(e)}));const z=async({cartId:n,retries:s})=>{const r=e(),{errors:i,json:c,zonosMode:d}=await o("/api/zonos-elements/get-cart",{body:{isTestMode:r,tempCartUUID:n},headers:{"Content-Type":"application/json"},method:"POST"}),l=!c||i.length;return l&&s?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:s}),await new Promise((e=>setTimeout(e,500))),z({cartId:n,retries:s-1})):l?null:Object.assign(Object.assign({},c),{zonosMode:d})};var S;const O=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=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=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),j="https://v1.3.184.js.zonos.com",b=O||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.184",k="https://fonts.googleapis.com",Z=/^https:\/\/fonts\.googleapis\.com/;class I{}S=I,I.doneInit=!1,I.cartSettings=null,I.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),I.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),I._paypalMockResponse=null,I.isBigCommerce=!1,I.releaseDate="1745332596232",I.isLegacyCheckout=!1,I.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",I.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),I.isNpm=!0,I.zonosQaUrl=null,I.zonosQaUrlApi=null,I.trackEventLogs=[],I.version="v1.3.184",I.modeAlerted=!1,I.cartData=null,I.paypal=null,I.zonosMode=null,I.getCurrentTimestamp=()=>(new Date).getTime(),I.zonosController=null,I.loadTimeApiInfoList=[],I.logIntervalId=null,I.init=async s=>{const{appearance:c,checkoutSettings:d,currencyConverter:a,helloSettings:u,onCountryChange:m,overrideCurrencyFormat:w,storeId:f,zonosApiKey:h}=s;if(S.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),S.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${S.version}) ======`),S.zonosApiKey=h,S.storeId=f,S.isNpm){t("====== ZONOS LOADING FROM NPM ======");const c=p();if(c&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${c} ======`,"info");const e=document.createElement("script");return e.src=`${c}/dist/scripts/zonos.js`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=S.isNpm,window.Zonos.isBigCommerce=S.isBigCommerce,window.Zonos.isLegacyCheckout=S.isLegacyCheckout,window.Zonos.init(s)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${c}`)})),void(window.isZonosPreview=!0)}if(!h&&!S.cartId)return void r("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!S.cartData&&S.cartId){t("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=i(e);if(!o&&!n)return r("[ZONOS - loadZonos] invalid cart id"),null;const s=await z({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,window.Zonos.zonosMode=s.zonosMode,{cartData:s.cartData,settings:s.settings,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(r("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(S.cartId);if(!e)return void r("Failed to get cart data");S.cartData=e.cartData,S.zonosApiKey=e.zonosApiKey,S.cartSettings=e.settings}const d=await(async()=>{const s=e(),i=n();if(!s&&!i||!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:c,json:d}=await o("/api/get-test-public-credential");if(c.length||!d)return r("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",c),null;const l=d.publicCredential;return l?(t(`[ZONOS - loadZonos] Retrieve new test public token ${l}`,"info"),l):(r("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();d&&(S.zonosApiKey=d)}const y=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(S.cartId&&S.cartData||y){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=`${l}`,document.body.appendChild(e)}t("init zonos"),S.restoreNativeBrowserFunctions(),S.injectCustomScriptForHostedCheckout(),S.injectZonosCdn(),S.injectZonosCss(),S.injectFonts(),S.injectController({config:{appearance:c,checkoutSettings:d,currencyConverter:a,helloSettings:u,onCountryChange:m,overrideCurrencyFormat:w}}),S.doneInit=!0},I.injectCustomScriptForHostedCheckout=()=>{const e=S.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),s=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||s)){if(o){t("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(s){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=s.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:s,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},I.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},I.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},I.showNotification=e=>{var n;null===(n=S.zonosController)||void 0===n||n.showNotification(e)},I.updateOrganizationName=e=>{var n;null===(n=S.zonosController)||void 0===n||n.updateOrganizationName(e)},I.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:t,placeOrderButtonSelector:o})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&o){const n=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},I.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let t=document.querySelector(`iframe#${n}`);t||(t=document.createElement("iframe"),t.id=n,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 o=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=o,document.body.removeChild(t)},I.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;S.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{S.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;S.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{S.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=e,s.zonosApiKey=S.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;t("loading Stripe");const o=await(async(...e)=>{g=!0;const n=Date.now();return v.then((t=>((e,n,t)=>{if(null===e)return null;const o=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(o,t),o})(t,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,s.initCheckoutElement(o)):r("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),S.zonosController=s,t("Zonos controller injected!")},I.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const s=`${S.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const i=document.head||document.body,c=document.createElement("script");n?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{r(`Failed to load ${c.src}`);const t=m(e);t&&S.injectScript({cdnType:t,isModule:n,theRestUrl:o})},i.appendChild(c)},I.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return b;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.184";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.184";case"vercel":return j}};return S.isNpm&&p()||n()},I.injectZonosCdn=()=>{S.injectScript({cdnType:u,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),S.injectScript({cdnType:u,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},I.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const t=S.getZonosUrl(e),o=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${j}/`,o.appendChild(s);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${n}`,i.onerror=()=>{r(`Failed to load ${i.href}`);const t=m(e);t&&S.injectStylesheet({cdnType:t,theRestUrl:n})},o.appendChild(i)},I.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(S.injectStylesheet({cdnType:u,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},I.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${k}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!Z.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=k,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${k}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),t("Zonos font injected!")},I.setupGoogleFont=e=>{var n;null===(n=S.zonosController)||void 0===n||n.setupGoogleFont(e)},I.injectSupportGoogleFont=e=>{var n;t(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${k}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=k,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${o} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=e,s.appendChild(r),t(`[FONT] ${o} font injected!`)};export{I as Zonos}
|