@zonos/elements 1.3.225 → 1.3.227

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.
@@ -260,6 +260,13 @@ export const billingCompanyAccountType = {
260
260
 
261
261
  export type BillingCompanyAccountType =
262
262
  (typeof billingCompanyAccountType)[keyof typeof billingCompanyAccountType];
263
+ export const billingCompanyBusinessUnit = {
264
+ Ecommerce: 'ECOMMERCE',
265
+ SupplyChain: 'SUPPLY_CHAIN',
266
+ } as const;
267
+
268
+ export type BillingCompanyBusinessUnit =
269
+ (typeof billingCompanyBusinessUnit)[keyof typeof billingCompanyBusinessUnit];
263
270
 
264
271
  export const billingOptionCode = {
265
272
  DdpAndDdu: 'DDP_AND_DDU',
@@ -379,6 +386,13 @@ export const carrierApiRatingSignatureOptionType = {
379
386
 
380
387
  export type CarrierApiRatingSignatureOptionType =
381
388
  (typeof carrierApiRatingSignatureOptionType)[keyof typeof carrierApiRatingSignatureOptionType];
389
+ export const carrierApiRatingSource = {
390
+ Cache: 'CACHE',
391
+ Live: 'LIVE',
392
+ } as const;
393
+
394
+ export type CarrierApiRatingSource =
395
+ (typeof carrierApiRatingSource)[keyof typeof carrierApiRatingSource];
382
396
  export type CarrierApiRatingSpecialServiceDetail = {
383
397
  batteryDetail?: InputMaybe<CarrierApiRatingBatteryDetail>;
384
398
  serviceTypes: Array<CarrierApiRatingSpecialServiceType>;
@@ -1504,6 +1518,7 @@ export const currencyCode = {
1504
1518
  } as const;
1505
1519
 
1506
1520
  export type CurrencyCode = (typeof currencyCode)[keyof typeof currencyCode];
1521
+
1507
1522
  export const currencyDefaultStatus = {
1508
1523
  Disabled: 'DISABLED',
1509
1524
  Enabled: 'ENABLED',
@@ -1529,6 +1544,7 @@ export type CustomsDocumentCarrier =
1529
1544
  (typeof customsDocumentCarrier)[keyof typeof customsDocumentCarrier];
1530
1545
 
1531
1546
  export const customsDocumentFileType = {
1547
+ Html: 'HTML',
1532
1548
  Jpg: 'JPG',
1533
1549
  Pdf: 'PDF',
1534
1550
  Png: 'PNG',
@@ -1541,6 +1557,7 @@ export type CustomsDocumentFileType =
1541
1557
  export const customsDocumentType = {
1542
1558
  CertificateOfOrigin: 'CERTIFICATE_OF_ORIGIN',
1543
1559
  CommercialInvoice: 'COMMERCIAL_INVOICE',
1560
+ ControlLogReceipt: 'CONTROL_LOG_RECEIPT',
1544
1561
  Other: 'OTHER',
1545
1562
  ProFormaInvoice: 'PRO_FORMA_INVOICE',
1546
1563
  } as const;
@@ -1849,6 +1866,17 @@ export const errorType = {
1849
1866
 
1850
1867
  export type ErrorType = (typeof errorType)[keyof typeof errorType];
1851
1868
 
1869
+ export const exchangeRateTargetType = {
1870
+ BillingCompany: 'BILLING_COMPANY',
1871
+ MerchantBase: 'MERCHANT_BASE',
1872
+ MerchantProvided: 'MERCHANT_PROVIDED',
1873
+ MerchantSettled: 'MERCHANT_SETTLED',
1874
+ ShopperPresented: 'SHOPPER_PRESENTED',
1875
+ ZonosBase: 'ZONOS_BASE',
1876
+ } as const;
1877
+
1878
+ export type ExchangeRateTargetType =
1879
+ (typeof exchangeRateTargetType)[keyof typeof exchangeRateTargetType];
1852
1880
  export const exchangeRateType = {
1853
1881
  Guaranteed: 'GUARANTEED',
1854
1882
  MidMarket: 'MID_MARKET',
@@ -2077,6 +2105,13 @@ export const inclusivePriceCatalogValidationJobComplianceStatus = {
2077
2105
 
2078
2106
  export type InclusivePriceCatalogValidationJobComplianceStatus =
2079
2107
  (typeof inclusivePriceCatalogValidationJobComplianceStatus)[keyof typeof inclusivePriceCatalogValidationJobComplianceStatus];
2108
+ export const inclusivePriceCheckoutStatus = {
2109
+ Disabled: 'DISABLED',
2110
+ Enabled: 'ENABLED',
2111
+ } as const;
2112
+
2113
+ export type InclusivePriceCheckoutStatus =
2114
+ (typeof inclusivePriceCheckoutStatus)[keyof typeof inclusivePriceCheckoutStatus];
2080
2115
 
2081
2116
  export const inclusivePriceConfigurationStatus = {
2082
2117
  Disabled: 'DISABLED',
@@ -2550,6 +2585,7 @@ export const landedCostBillingRuleDetailCategoryIdCreateType = {
2550
2585
  ShopifyGuaranteePercentInclusive: 'SHOPIFY_GUARANTEE_PERCENT_INCLUSIVE',
2551
2586
  ShopifyTransactionPercent: 'SHOPIFY_TRANSACTION_PERCENT',
2552
2587
  Tax: 'TAX',
2588
+ ZonosShipping: 'ZONOS_SHIPPING',
2553
2589
  } as const;
2554
2590
 
2555
2591
  export type LandedCostBillingRuleDetailCategoryIdCreateType =
@@ -2656,6 +2692,7 @@ export const landedCostQuoteType = {
2656
2692
 
2657
2693
  export type LandedCostQuoteType =
2658
2694
  (typeof landedCostQuoteType)[keyof typeof landedCostQuoteType];
2695
+
2659
2696
  export const landedCostTariffRate = {
2660
2697
  Exact: 'EXACT',
2661
2698
  Maximum: 'MAXIMUM',
@@ -4062,6 +4099,9 @@ export const webhookStatus = {
4062
4099
  export type WebhookStatus = (typeof webhookStatus)[keyof typeof webhookStatus];
4063
4100
  export const webhookType = {
4064
4101
  InclusivePriceConfigurationChanged: 'INCLUSIVE_PRICE_CONFIGURATION_CHANGED',
4102
+ InclusivePriceConfigurationCreated: 'INCLUSIVE_PRICE_CONFIGURATION_CREATED',
4103
+ InclusivePriceConfigurationDeleted: 'INCLUSIVE_PRICE_CONFIGURATION_DELETED',
4104
+ InclusivePriceConfigurationUpdated: 'INCLUSIVE_PRICE_CONFIGURATION_UPDATED',
4065
4105
  InclusivePriceSyncReady: 'INCLUSIVE_PRICE_SYNC_READY',
4066
4106
  InventoryCheck: 'INVENTORY_CHECK',
4067
4107
  InventoryRefund: 'INVENTORY_REFUND',
@@ -4993,6 +5033,24 @@ export type ExchangeRateCreateMutation = {
4993
5033
  } | null;
4994
5034
  };
4995
5035
 
5036
+ export type CurrencyConversionCreateMutation = {
5037
+ currencyConversionCreate: {
5038
+ exchangeRate: {
5039
+ expiresAt: string;
5040
+ rate: number;
5041
+ targetFormat: {
5042
+ currencyCode: CurrencyCode;
5043
+ decimalDelimiter: string;
5044
+ scale: number;
5045
+ symbol: string;
5046
+ symbolLocation: CurrencySymbolLocation | null;
5047
+ thousandsDelimiter: string;
5048
+ } | null;
5049
+ type: ExchangeRateType;
5050
+ };
5051
+ };
5052
+ };
5053
+
4996
5054
  export type CartCheckoutWorkflowQuery = {
4997
5055
  cartCheckoutWorkflow: {
4998
5056
  appearanceSettings: {
@@ -6488,6 +6546,20 @@ export function getSdk(
6488
6546
  'mutation',
6489
6547
  );
6490
6548
  },
6549
+ currencyConversionCreate(
6550
+ variables?: { [x: string]: never },
6551
+ requestHeaders?: GraphQLClientRequestHeaders,
6552
+ ): Promise<CurrencyConversionCreateMutation> {
6553
+ return withWrapper(
6554
+ wrappedRequestHeaders =>
6555
+ client.request<CurrencyConversionCreateMutation>('', variables, {
6556
+ ...requestHeaders,
6557
+ ...wrappedRequestHeaders,
6558
+ }),
6559
+ 'currencyConversionCreate',
6560
+ 'mutation',
6561
+ );
6562
+ },
6491
6563
  deleteWebhook(
6492
6564
  variables?: { [x: string]: never },
6493
6565
  requestHeaders?: GraphQLClientRequestHeaders,
@@ -1 +1 @@
1
- import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{l as r}from"./p-0a377722.js";export{a as availableTestKeys}from"./p-0a377722.js";import{g as i,a as l,h as u,l as m}from"./p-41dd1cb8.js";import{g as p,_ as w,c as f,a as h}from"./p-b2d81c98.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b2d81c98.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const y=["jsdelivr","cdnjs","unpkg","vercel"],v="jsdelivr",O=e=>{const n=y.indexOf(e);return y[n+1]||null},S=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.225.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},g="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let b=null;const N=Promise.resolve().then((()=>{return e=null,null!==b||(b=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${g}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&z.test(o.src))return o}return null})();t&&e?console.warn(j):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${g}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),b;var e}));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=i(),s=o(),c=p()||void 0,d=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&d.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:l,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${d.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:c,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||l.length;return w&&n?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var T;const R=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),$=Date.now(),Z="https://v1.3.225.js.zonos.com",L=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.225",U="https://fonts.googleapis.com",A=/^https:\/\/fonts\.googleapis\.com/;class C{}T=C,C.doneInit=!1,C.cartSettings=null,C.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),C.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),C._paypalMockResponse=null,C.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,C.isBigCommerce=!1,C.releaseDate="1753286018445",C.isLegacyCheckout=!1,C.startLoadTime=$,C.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",C.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),C.overrideUseCustomAddressForm=!1,C.isCollect=!1,C.isNpm=!0,C.zonosQaUrl=null,C.zonosQaUrlApi=null,C.trackEventLogs=[],C.version="v1.3.225",C.modeAlerted=!1,C.cartData=null,C.paypal=null,C.zonosMode=null,C.IframeService=t,C.getCurrentTimestamp=()=>(new Date).getTime(),C.zonosController=null,C.loadTimeApiInfoList=[],C.logIntervalId=null,C.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=p,T.storeId=a,T.isNpm){r("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.zonosMode=T.zonosMode,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!T.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){r("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(T.cartId);if(!e)return void m("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey,T.cartSettings=e.settings}const o=await(async()=>{const e=i(),n=l();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(r(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(T.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||h){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}r("init zonos"),T.restoreNativeBrowserFunctions(),T.injectCustomScriptForHostedCheckout(),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectCheckoutInternationalButton(),T.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),T.doneInit=!0},C.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},C.injectCustomScriptForHostedCheckout=()=>{const e=T.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},C.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},C.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},C.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},C.showNotification=e=>{var n;null===(n=T.zonosController)||void 0===n||n.showNotification(e)},C.updateOrganizationName=e=>{var n;null===(n=T.zonosController)||void 0===n||n.updateOrganizationName(e)},C.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},C.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},C.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=T.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;r("loading Stripe");const o=await(async(...e)=>{I=!0;const n=Date.now();return N.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,window.Zonos.isCollect?t.initCollectElement(o):t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),T.zonosController=t,r("Zonos controller injected!")},C.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${T.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void r(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,i=document.createElement("script");n?i.type="module":i.noModule=!0,i.src=t,i.crossOrigin="anonymous",i.onerror=()=>{m(`Failed to load ${i.src}`);const t=O(e);t&&T.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(i)},C.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return L;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.225";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.225";case"vercel":return Z}};return T.isNpm&&S()||n()},C.injectZonosCdn=()=>{T.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},C.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=T.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${Z}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&T.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},C.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},C.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${U}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!A.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=U,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${U}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),r("Zonos font injected!")},C.setupGoogleFont=e=>{var n;null===(n=T.zonosController)||void 0===n||n.setupGoogleFont(e)},C.injectSupportGoogleFont=e=>{var n;r(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${U}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=U,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),r(`[FONT] ${o} font injected!`)};const E=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],P=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],F=[...E,...P];export{C as Zonos,F as checkoutSessionAttributeKeys,P as checkoutSessionImmutableAttributeKeys,E as checkoutSessionMutableAttributeKeys}
1
+ import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{l as r}from"./p-0a377722.js";export{a as availableTestKeys}from"./p-0a377722.js";import{g as i,a as l,h as u,l as m}from"./p-41dd1cb8.js";import{g as p,_ as w,c as f,a as h}from"./p-b2d81c98.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b2d81c98.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const y=["jsdelivr","cdnjs","unpkg","vercel"],v="jsdelivr",O=e=>{const n=y.indexOf(e);return y[n+1]||null},S=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.227.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},g="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let b=null;const N=Promise.resolve().then((()=>{return e=null,null!==b||(b=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${g}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&z.test(o.src))return o}return null})();t&&e?console.warn(j):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${g}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),b;var e}));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=i(),s=o(),c=p()||void 0,d=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&d.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:l,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${d.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:c,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||l.length;return w&&n?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var T;const R=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),$=Date.now(),Z="https://v1.3.227.js.zonos.com",L=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.227",U="https://fonts.googleapis.com",A=/^https:\/\/fonts\.googleapis\.com/;class C{}T=C,C.doneInit=!1,C.cartSettings=null,C.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),C.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),C._paypalMockResponse=null,C.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,C.isBigCommerce=!1,C.releaseDate="1753824338266",C.isLegacyCheckout=!1,C.startLoadTime=$,C.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",C.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),C.overrideUseCustomAddressForm=!1,C.isCollect=!1,C.isNpm=!0,C.zonosQaUrl=null,C.zonosQaUrlApi=null,C.trackEventLogs=[],C.version="v1.3.227",C.modeAlerted=!1,C.cartData=null,C.paypal=null,C.zonosMode=null,C.IframeService=t,C.getCurrentTimestamp=()=>(new Date).getTime(),C.zonosController=null,C.loadTimeApiInfoList=[],C.logIntervalId=null,C.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=p,T.storeId=a,T.isNpm){r("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.zonosMode=T.zonosMode,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!T.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){r("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(T.cartId);if(!e)return void m("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey,T.cartSettings=e.settings}const o=await(async()=>{const e=i(),n=l();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(r(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(T.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||h){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}r("init zonos"),T.restoreNativeBrowserFunctions(),T.injectCustomScriptForHostedCheckout(),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectCheckoutInternationalButton(),T.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),T.doneInit=!0},C.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},C.injectCustomScriptForHostedCheckout=()=>{const e=T.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},C.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},C.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},C.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},C.showNotification=e=>{var n;null===(n=T.zonosController)||void 0===n||n.showNotification(e)},C.updateOrganizationName=e=>{var n;null===(n=T.zonosController)||void 0===n||n.updateOrganizationName(e)},C.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},C.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},C.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=T.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;r("loading Stripe");const o=await(async(...e)=>{I=!0;const n=Date.now();return N.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,window.Zonos.isCollect?t.initCollectElement(o):t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),T.zonosController=t,r("Zonos controller injected!")},C.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${T.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void r(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,i=document.createElement("script");n?i.type="module":i.noModule=!0,i.src=t,i.crossOrigin="anonymous",i.onerror=()=>{m(`Failed to load ${i.src}`);const t=O(e);t&&T.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(i)},C.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return L;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.227";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.227";case"vercel":return Z}};return T.isNpm&&S()||n()},C.injectZonosCdn=()=>{T.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},C.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=T.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${Z}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&T.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},C.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},C.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${U}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!A.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=U,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${U}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),r("Zonos font injected!")},C.setupGoogleFont=e=>{var n;null===(n=T.zonosController)||void 0===n||n.setupGoogleFont(e)},C.injectSupportGoogleFont=e=>{var n;r(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${U}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=U,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),r(`[FONT] ${o} font injected!`)};const E=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],P=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],F=[...E,...P];export{C as Zonos,F as checkoutSessionAttributeKeys,P as checkoutSessionImmutableAttributeKeys,E as checkoutSessionMutableAttributeKeys}