@zonos/elements 1.3.134 → 1.3.135

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.
@@ -56,6 +56,36 @@ const getNextFallbackUrl = (currentCdnType) => {
56
56
  return nextFallbackCdnType || null;
57
57
  };
58
58
 
59
+ /**
60
+ * Attempt to get test public credential to window.Zonos.zonosApiKey if needed
61
+ */
62
+ const getWithTestPublicCredential = async () => {
63
+ const isTestMode = window.location.search.includes('zonosTestMode=1');
64
+ // Do nothing if the test mode is not enabled or the public credential
65
+ if (!isTestMode || !window.Zonos.zonosApiKey) {
66
+ return null;
67
+ }
68
+ handleFetch.log('[ZONOS - loadZonos] Attempt test public credential', 'info');
69
+ // Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
70
+ if (!!window.Zonos.zonosApiKey.includes('credential_test')) {
71
+ handleFetch.log('[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key', 'info');
72
+ return null;
73
+ }
74
+ const { errors: testPublicCredErrors, json: testPublicCredResult } = await handleFetch.handleFetch('/api/get-test-public-credential');
75
+ if (testPublicCredErrors.length || !testPublicCredResult) {
76
+ handleFetch.logError(`[ZONOS - loadZonos] Failed to get test public credential. Keep using production key`, testPublicCredErrors);
77
+ return null;
78
+ }
79
+ const testPublicCredential = testPublicCredResult.publicCredential;
80
+ if (!testPublicCredential) {
81
+ handleFetch.logError('[ZONOS - loadZonos] No test public key credential. Keep using production key');
82
+ return null;
83
+ }
84
+ // Set the test public credential to the window object
85
+ handleFetch.log(`[ZONOS - loadZonos] Retrieve new test public token ${testPublicCredential}`, 'info');
86
+ return testPublicCredential;
87
+ };
88
+
59
89
  /**
60
90
  * Extracts the zonosQaUrl from the url
61
91
  *
@@ -97,7 +127,7 @@ const getZonosQaUrl = () => {
97
127
  return null;
98
128
  }
99
129
  const qaUrl = extractZonosQaUrl(window.location.href);
100
- const cdnUrl = "https://v1.3.134.js.zonos.com";
130
+ const cdnUrl = "https://v1.3.135.js.zonos.com";
101
131
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
102
132
  if (!qaUrl &&
103
133
  (cdnUrl.includes('test.') ||
@@ -254,36 +284,6 @@ const zonosLoadStripe = async (...args) => {
254
284
  return stripePromise.then(maybeStripe => initStripe(maybeStripe, args, startTime));
255
285
  };
256
286
 
257
- /**
258
- * Attempt to get and override test public credential to window.Zonos.zonosApiKey if needed
259
- */
260
- const overrideWithTestPublicCredential = async () => {
261
- const isTestMode = window.location.search.includes('zonosTestMode=1');
262
- // Do nothing if the test mode is not enabled or the public credential
263
- if (!isTestMode || !window.Zonos.zonosApiKey) {
264
- return;
265
- }
266
- handleFetch.log('[ZONOS - loadZonos] Attempt test public credential', 'info');
267
- // Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
268
- if (!!window.Zonos.zonosApiKey.includes('test')) {
269
- handleFetch.log('[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key', 'info');
270
- return;
271
- }
272
- const { errors: testPublicCredErrors, json: testPublicCredResult } = await handleFetch.handleFetch('/api/get-test-public-credential');
273
- if (testPublicCredErrors.length || !testPublicCredResult) {
274
- handleFetch.logError(`[ZONOS - loadZonos] Failed to get test public credential. Keep using production key`, testPublicCredErrors);
275
- return;
276
- }
277
- const testPublicCredential = testPublicCredResult.publicCredential;
278
- if (!testPublicCredential) {
279
- handleFetch.logError('[ZONOS - loadZonos] No test public key credential. Keep using production key');
280
- return;
281
- }
282
- handleFetch.log(`[ZONOS - loadZonos] Using test API key: ${testPublicCredential} for test mode`, 'info');
283
- // Set the test public credential to the window object
284
- window.Zonos.zonosApiKey = testPublicCredential;
285
- };
286
-
287
287
  const TEMP_CART_ID_QUERY_PARAM = 'tempCartUUID';
288
288
  /**
289
289
  * Simple function to get the cart id from the query param.
@@ -311,10 +311,10 @@ const zonosLoadUrl = (() => {
311
311
  }
312
312
  return null;
313
313
  })();
314
- const ZONOS_URL = "https://v1.3.134.js.zonos.com";
315
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134";
316
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.134";
317
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";
314
+ const ZONOS_URL = "https://v1.3.135.js.zonos.com";
315
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";
316
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.135";
317
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";
318
318
  const INTER_FONT_URL = 'https://rsms.me';
319
319
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
320
320
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -329,7 +329,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
329
329
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
330
330
  Zonos._paypalMockResponse = null;
331
331
  Zonos.isBigCommerce = false;
332
- Zonos.releaseDate = "1732554842941";
332
+ Zonos.releaseDate = "1732640550316";
333
333
  Zonos.isLegacyCheckout = false;
334
334
  Zonos.domain = typeof window !== 'undefined'
335
335
  ? // domain that embeds the iframe
@@ -345,7 +345,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
345
345
  Zonos.isNpm = true;
346
346
  Zonos.zonosQaUrl = null;
347
347
  Zonos.zonosQaUrlApi = null;
348
- Zonos.version = `v${"1.3.134"}`;
348
+ Zonos.version = `v${"1.3.135"}`;
349
349
  Zonos.modeAlerted = false;
350
350
  Zonos.cartData = null;
351
351
  Zonos.paypal = null;
@@ -405,7 +405,10 @@ Zonos.init = async (params) => {
405
405
  _a.zonosApiKey = cartinfo.zonosApiKey;
406
406
  }
407
407
  // Try to request for test API key if the API key is production but query param isTestMode is provided
408
- await overrideWithTestPublicCredential();
408
+ const testPublicCredential = await getWithTestPublicCredential();
409
+ if (testPublicCredential) {
410
+ _a.zonosApiKey = testPublicCredential;
411
+ }
409
412
  }
410
413
  // inject hidden button to body to trigger checkout right away if we have cartData
411
414
  if (_a.cartId && _a.cartData) {
@@ -2,31 +2,31 @@ import { handleFetch } from "../components/utils/handleFetch";
2
2
  import { log } from "../components/utils/logging/log";
3
3
  import { logError } from "../components/utils/logging/logError";
4
4
  /**
5
- * Attempt to get and override test public credential to window.Zonos.zonosApiKey if needed
5
+ * Attempt to get test public credential to window.Zonos.zonosApiKey if needed
6
6
  */
7
- export const overrideWithTestPublicCredential = async () => {
7
+ export const getWithTestPublicCredential = async () => {
8
8
  const isTestMode = window.location.search.includes('zonosTestMode=1');
9
9
  // Do nothing if the test mode is not enabled or the public credential
10
10
  if (!isTestMode || !window.Zonos.zonosApiKey) {
11
- return;
11
+ return null;
12
12
  }
13
13
  log('[ZONOS - loadZonos] Attempt test public credential', 'info');
14
14
  // Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
15
- if (!!window.Zonos.zonosApiKey.includes('test')) {
15
+ if (!!window.Zonos.zonosApiKey.includes('credential_test')) {
16
16
  log('[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key', 'info');
17
- return;
17
+ return null;
18
18
  }
19
19
  const { errors: testPublicCredErrors, json: testPublicCredResult } = await handleFetch('/api/get-test-public-credential');
20
20
  if (testPublicCredErrors.length || !testPublicCredResult) {
21
21
  logError(`[ZONOS - loadZonos] Failed to get test public credential. Keep using production key`, testPublicCredErrors);
22
- return;
22
+ return null;
23
23
  }
24
24
  const testPublicCredential = testPublicCredResult.publicCredential;
25
25
  if (!testPublicCredential) {
26
26
  logError('[ZONOS - loadZonos] No test public key credential. Keep using production key');
27
- return;
27
+ return null;
28
28
  }
29
- log(`[ZONOS - loadZonos] Using test API key: ${testPublicCredential} for test mode`, 'info');
30
29
  // Set the test public credential to the window object
31
- window.Zonos.zonosApiKey = testPublicCredential;
30
+ log(`[ZONOS - loadZonos] Retrieve new test public token ${testPublicCredential}`, 'info');
31
+ return testPublicCredential;
32
32
  };
@@ -3,9 +3,9 @@ import { log } from "../components/utils/logging/log";
3
3
  import { logError } from "../components/utils/logging/logError";
4
4
  import { checkIfLoadVersionDomain } from "./_checkIfLoadVersionDomain";
5
5
  import { getNextFallbackUrl, MAIN_LOAD_CDN_TYPE, } from "./_getNextFallbackUrl";
6
+ import { getWithTestPublicCredential } from "./_getWithTestPublicCredential";
6
7
  import { getZonosQaUrl } from "./_getZonosQaUrl";
7
8
  import { zonosLoadStripe } from "./_loadStripe";
8
- import { overrideWithTestPublicCredential } from "./_overrideWithTestPublicCredential";
9
9
  import { getCartIdFromQueryParam } from "./cart/_getCartIdFromParam";
10
10
  import { setupCartData } from "./cart/_setupCartData";
11
11
  import { checkoutHiddenBtnSelector, } from "../types/checkout/CheckoutConfig";
@@ -119,7 +119,10 @@ Zonos.init = async (params) => {
119
119
  _a.zonosApiKey = cartinfo.zonosApiKey;
120
120
  }
121
121
  // Try to request for test API key if the API key is production but query param isTestMode is provided
122
- await overrideWithTestPublicCredential();
122
+ const testPublicCredential = await getWithTestPublicCredential();
123
+ if (testPublicCredential) {
124
+ _a.zonosApiKey = testPublicCredential;
125
+ }
123
126
  }
124
127
  // inject hidden button to body to trigger checkout right away if we have cartData
125
128
  if (_a.cartId && _a.cartData) {
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { l as log, a as logError, h as handleFetch } from './handleFetch-22cb914b.js';
1
+ import { l as log, h as handleFetch, a as logError } from './handleFetch-22cb914b.js';
2
2
  import { s as setupCartData, c as checkoutHiddenBtnSelector } from './CheckoutConfig-930107d4.js';
3
3
  export { c as checkoutHiddenBtnSelector, d as domesticRedirectedBtnSelector } from './CheckoutConfig-930107d4.js';
4
4
 
@@ -53,6 +53,36 @@ const getNextFallbackUrl = (currentCdnType) => {
53
53
  return nextFallbackCdnType || null;
54
54
  };
55
55
 
56
+ /**
57
+ * Attempt to get test public credential to window.Zonos.zonosApiKey if needed
58
+ */
59
+ const getWithTestPublicCredential = async () => {
60
+ const isTestMode = window.location.search.includes('zonosTestMode=1');
61
+ // Do nothing if the test mode is not enabled or the public credential
62
+ if (!isTestMode || !window.Zonos.zonosApiKey) {
63
+ return null;
64
+ }
65
+ log('[ZONOS - loadZonos] Attempt test public credential', 'info');
66
+ // Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
67
+ if (!!window.Zonos.zonosApiKey.includes('credential_test')) {
68
+ log('[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key', 'info');
69
+ return null;
70
+ }
71
+ const { errors: testPublicCredErrors, json: testPublicCredResult } = await handleFetch('/api/get-test-public-credential');
72
+ if (testPublicCredErrors.length || !testPublicCredResult) {
73
+ logError(`[ZONOS - loadZonos] Failed to get test public credential. Keep using production key`, testPublicCredErrors);
74
+ return null;
75
+ }
76
+ const testPublicCredential = testPublicCredResult.publicCredential;
77
+ if (!testPublicCredential) {
78
+ logError('[ZONOS - loadZonos] No test public key credential. Keep using production key');
79
+ return null;
80
+ }
81
+ // Set the test public credential to the window object
82
+ log(`[ZONOS - loadZonos] Retrieve new test public token ${testPublicCredential}`, 'info');
83
+ return testPublicCredential;
84
+ };
85
+
56
86
  /**
57
87
  * Extracts the zonosQaUrl from the url
58
88
  *
@@ -94,7 +124,7 @@ const getZonosQaUrl = () => {
94
124
  return null;
95
125
  }
96
126
  const qaUrl = extractZonosQaUrl(window.location.href);
97
- const cdnUrl = "https://v1.3.134.js.zonos.com";
127
+ const cdnUrl = "https://v1.3.135.js.zonos.com";
98
128
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
99
129
  if (!qaUrl &&
100
130
  (cdnUrl.includes('test.') ||
@@ -251,36 +281,6 @@ const zonosLoadStripe = async (...args) => {
251
281
  return stripePromise.then(maybeStripe => initStripe(maybeStripe, args, startTime));
252
282
  };
253
283
 
254
- /**
255
- * Attempt to get and override test public credential to window.Zonos.zonosApiKey if needed
256
- */
257
- const overrideWithTestPublicCredential = async () => {
258
- const isTestMode = window.location.search.includes('zonosTestMode=1');
259
- // Do nothing if the test mode is not enabled or the public credential
260
- if (!isTestMode || !window.Zonos.zonosApiKey) {
261
- return;
262
- }
263
- log('[ZONOS - loadZonos] Attempt test public credential', 'info');
264
- // Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
265
- if (!!window.Zonos.zonosApiKey.includes('test')) {
266
- log('[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key', 'info');
267
- return;
268
- }
269
- const { errors: testPublicCredErrors, json: testPublicCredResult } = await handleFetch('/api/get-test-public-credential');
270
- if (testPublicCredErrors.length || !testPublicCredResult) {
271
- logError(`[ZONOS - loadZonos] Failed to get test public credential. Keep using production key`, testPublicCredErrors);
272
- return;
273
- }
274
- const testPublicCredential = testPublicCredResult.publicCredential;
275
- if (!testPublicCredential) {
276
- logError('[ZONOS - loadZonos] No test public key credential. Keep using production key');
277
- return;
278
- }
279
- log(`[ZONOS - loadZonos] Using test API key: ${testPublicCredential} for test mode`, 'info');
280
- // Set the test public credential to the window object
281
- window.Zonos.zonosApiKey = testPublicCredential;
282
- };
283
-
284
284
  const TEMP_CART_ID_QUERY_PARAM = 'tempCartUUID';
285
285
  /**
286
286
  * Simple function to get the cart id from the query param.
@@ -308,10 +308,10 @@ const zonosLoadUrl = (() => {
308
308
  }
309
309
  return null;
310
310
  })();
311
- const ZONOS_URL = "https://v1.3.134.js.zonos.com";
312
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134";
313
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.134";
314
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";
311
+ const ZONOS_URL = "https://v1.3.135.js.zonos.com";
312
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";
313
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.135";
314
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";
315
315
  const INTER_FONT_URL = 'https://rsms.me';
316
316
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
317
317
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -326,7 +326,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
326
326
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
327
327
  Zonos._paypalMockResponse = null;
328
328
  Zonos.isBigCommerce = false;
329
- Zonos.releaseDate = "1732554842941";
329
+ Zonos.releaseDate = "1732640550316";
330
330
  Zonos.isLegacyCheckout = false;
331
331
  Zonos.domain = typeof window !== 'undefined'
332
332
  ? // domain that embeds the iframe
@@ -342,7 +342,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
342
342
  Zonos.isNpm = true;
343
343
  Zonos.zonosQaUrl = null;
344
344
  Zonos.zonosQaUrlApi = null;
345
- Zonos.version = `v${"1.3.134"}`;
345
+ Zonos.version = `v${"1.3.135"}`;
346
346
  Zonos.modeAlerted = false;
347
347
  Zonos.cartData = null;
348
348
  Zonos.paypal = null;
@@ -402,7 +402,10 @@ Zonos.init = async (params) => {
402
402
  _a.zonosApiKey = cartinfo.zonosApiKey;
403
403
  }
404
404
  // Try to request for test API key if the API key is production but query param isTestMode is provided
405
- await overrideWithTestPublicCredential();
405
+ const testPublicCredential = await getWithTestPublicCredential();
406
+ if (testPublicCredential) {
407
+ _a.zonosApiKey = testPublicCredential;
408
+ }
406
409
  }
407
410
  // inject hidden button to body to trigger checkout right away if we have cartData
408
411
  if (_a.cartId && _a.cartData) {
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,o,r){function t(n){return n instanceof o?n:new o((function(e){e(n)}))}return new(o||(o=Promise))((function(o,i){function a(n){try{u(r.next(n))}catch(n){i(n)}}function s(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?o(n.value):t(n.value).then(a,s)}u((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(n){return function(e){return u([n,e])}}function u(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(r=1,t&&(i=s[0]&2?t["return"]:s[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,s[1])).done)return i;if(t=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;t=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=e.call(n,o)}catch(n){s=[6,n];t=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{l as log,a as logError,h as handleFetch}from"./handleFetch-22cb914b.js";import{s as setupCartData,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-930107d4.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-930107d4.js";var checkIfLoadVersionDomain=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(e).origin;var i=o.some((function(n){return t.includes(n)}));var a=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(n){var e=fallbackList.indexOf(n);var o=fallbackList[e+1];return o||null};var extractZonosQaUrl=function(n){if(!n){return null}var e=new URL(n).searchParams;var o=e.get("zonosQaUrl");if(!o){return null}var r=/[^a-zA-Z0-9-_]+/.test(o);if(!!r){return null}return o};var getZonosQaUrl=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var e=extractZonosQaUrl(window.location.href);var o="https://v1.3.134.js.zonos.com";if(!e&&(o.includes("test.")||o.includes("test-"))){return o}if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!e){return null}if(e==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var t="https://".concat(e,".").concat(r);log("[ZONOS-WARNING] using '".concat(t,"' for loading elements script"),"warn");void fetch(t).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(t,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var o="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return t};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var n=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(e);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(o);return o};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(e,o){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){e(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(n){o(n);return}}));return stripePromise$1};var registerWrapper=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var initStripe=function(n,e,o){if(n===null){return null}var r=n.apply(undefined,e);registerWrapper(r,o);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(n){if(!loadCalled){console.warn(n)}}));var zonosLoadStripe=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(o){loadCalled=true;e=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,n,e)}))]}))}))};var overrideWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var n,e,o,r,t;return __generator(this,(function(i){switch(i.label){case 0:n=window.location.search.includes("zonosTestMode=1");if(!n||!window.Zonos.zonosApiKey){return[2]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2]}return[4,handleFetch("/api/get-test-public-credential")];case 1:e=i.sent(),o=e.errors,r=e.json;if(o.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);return[2]}t=r.publicCredential;if(!t){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2]}log("[ZONOS - loadZonos] Using test API key: ".concat(t," for test mode"),"info");window.Zonos.zonosApiKey=t;return[2]}}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var n=new URLSearchParams(window.location.search);var e=n.get(TEMP_CART_ID_QUERY_PARAM);return e};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),o=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return o}return null}();var ZONOS_URL="https://v1.3.134.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.134";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";var INTER_FONT_URL="https://rsms.me";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var INTER_FONT_REGEX=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var Zonos=function(){function n(){}return n}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1732554842941";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.version="v".concat("1.3.134");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o,r,t,i,a,s,u,c,l,d,f;return __generator(this,(function(v){switch(v.label){case 0:e=n.appearance,o=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,a=n.overrideCurrencyFormat,s=n.storeId,u=n.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");l=document.createElement("script");l.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(n)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));window.isZonosPreview=true;return[2]}if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartData(_a.cartId)];case 1:d=v.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;v.label=2;case 2:return[4,overrideWithTestPublicCredential()];case 3:v.sent();v.label=4;case 4:if(_a.cartId&&_a.cartData){log("Cart data is available, inject hidden button and trigger checkout");f=document.createElement("button");f.style.display="none";f.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(f)}log("init zonos");_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:e,checkoutSettings:o,currencyConverter:r,helloSettings:t,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};Zonos.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.showNotification(n))};Zonos.updateOrganizationName=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var e=n.autoEnable,o=e===void 0?true:e,r=n.config,t=n.disable,i=n.placeOrderButtonSelector;var a;if((a=r.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var u=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};s.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(t){n.setAttribute("disabled","true");n.addEventListener("click",u)}else{n.removeAttribute("disabled");n.removeEventListener("click",u)}}));if(o&&t){setTimeout((function(){s.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",u)}))}),5e3)}}};Zonos.injectController=function(n){var e=n.config;var o;if(document.querySelector("zonos-controller")){return}if((o=e.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=e.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r});var t=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r})}));t.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=e;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o;return __generator(this,(function(r){switch(r.label){case 0:e=n.detail;log("loading Stripe");return[4,zonosLoadStripe(e.publishableKey)];case 1:o=r.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(n){var e=n.cdnType,o=n.isModule,r=n.theRestUrl;var t=_a.getZonosUrl(e);var i="".concat(t,"/").concat(r);var a=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var u=document.createElement("script");if(!!o){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var n=getNextFallbackUrl(e);if(!n){return}_a.injectScript({cdnType:n,isModule:o,theRestUrl:r})};s.appendChild(u)};Zonos.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||e()}return e()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var e=n.cdnType,o=n.theRestUrl;var r=_a.getZonosUrl(e);var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(r,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var n=getNextFallbackUrl(e);if(!n){return}_a.injectStylesheet({cdnType:n,theRestUrl:o})};t.appendChild(a)};Zonos.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(INTER_FONT_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(INTER_FONT_REGEX.test(o.href)){continue}return o}return null};if(n()){log("Inter font already injected","warn");return}var e=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=INTER_FONT_URL;e.appendChild(o);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");e.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var e;log("[FONT] injecting ".concat(n));var o=(e=n.match(/family=(.*?):/))===null||e===void 0?void 0:e[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(n,e,o,r){function t(n){return n instanceof o?n:new o((function(e){e(n)}))}return new(o||(o=Promise))((function(o,i){function a(n){try{u(r.next(n))}catch(n){i(n)}}function s(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?o(n.value):t(n.value).then(a,s)}u((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(n){return function(e){return u([n,e])}}function u(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(r=1,t&&(i=s[0]&2?t["return"]:s[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,s[1])).done)return i;if(t=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;t=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=e.call(n,o)}catch(n){s=[6,n];t=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{l as log,h as handleFetch,a as logError}from"./handleFetch-22cb914b.js";import{s as setupCartData,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-930107d4.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-930107d4.js";var checkIfLoadVersionDomain=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(e).origin;var i=o.some((function(n){return t.includes(n)}));var a=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(n){var e=fallbackList.indexOf(n);var o=fallbackList[e+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var n,e,o,r,t;return __generator(this,(function(i){switch(i.label){case 0:n=window.location.search.includes("zonosTestMode=1");if(!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:e=i.sent(),o=e.errors,r=e.json;if(o.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);return[2,null]}t=r.publicCredential;if(!t){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(t),"info");return[2,t]}}))}))};var extractZonosQaUrl=function(n){if(!n){return null}var e=new URL(n).searchParams;var o=e.get("zonosQaUrl");if(!o){return null}var r=/[^a-zA-Z0-9-_]+/.test(o);if(!!r){return null}return o};var getZonosQaUrl=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var e=extractZonosQaUrl(window.location.href);var o="https://v1.3.135.js.zonos.com";if(!e&&(o.includes("test.")||o.includes("test-"))){return o}if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!e){return null}if(e==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var t="https://".concat(e,".").concat(r);log("[ZONOS-WARNING] using '".concat(t,"' for loading elements script"),"warn");void fetch(t).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(t,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var o="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return t};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var n=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(e);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(o);return o};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(e,o){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){e(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(n){o(n);return}}));return stripePromise$1};var registerWrapper=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var initStripe=function(n,e,o){if(n===null){return null}var r=n.apply(undefined,e);registerWrapper(r,o);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(n){if(!loadCalled){console.warn(n)}}));var zonosLoadStripe=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(o){loadCalled=true;e=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,n,e)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var n=new URLSearchParams(window.location.search);var e=n.get(TEMP_CART_ID_QUERY_PARAM);return e};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),o=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return o}return null}();var ZONOS_URL="https://v1.3.135.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.135";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";var INTER_FONT_URL="https://rsms.me";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var INTER_FONT_REGEX=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var Zonos=function(){function n(){}return n}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1732640550316";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.version="v".concat("1.3.135");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o,r,t,i,a,s,u,c,l,d,f,v;return __generator(this,(function(m){switch(m.label){case 0:e=n.appearance,o=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,a=n.overrideCurrencyFormat,s=n.storeId,u=n.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");l=document.createElement("script");l.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(n)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));window.isZonosPreview=true;return[2]}if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartData(_a.cartId)];case 1:d=m.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;m.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=m.sent();if(f){_a.zonosApiKey=f}m.label=4;case 4:if(_a.cartId&&_a.cartData){log("Cart data is available, inject hidden button and trigger checkout");v=document.createElement("button");v.style.display="none";v.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(v)}log("init zonos");_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:e,checkoutSettings:o,currencyConverter:r,helloSettings:t,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};Zonos.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.showNotification(n))};Zonos.updateOrganizationName=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var e=n.autoEnable,o=e===void 0?true:e,r=n.config,t=n.disable,i=n.placeOrderButtonSelector;var a;if((a=r.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var u=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};s.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(t){n.setAttribute("disabled","true");n.addEventListener("click",u)}else{n.removeAttribute("disabled");n.removeEventListener("click",u)}}));if(o&&t){setTimeout((function(){s.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",u)}))}),5e3)}}};Zonos.injectController=function(n){var e=n.config;var o;if(document.querySelector("zonos-controller")){return}if((o=e.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=e.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r});var t=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:r})}));t.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=e;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var e,o;return __generator(this,(function(r){switch(r.label){case 0:e=n.detail;log("loading Stripe");return[4,zonosLoadStripe(e.publishableKey)];case 1:o=r.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(n){var e=n.cdnType,o=n.isModule,r=n.theRestUrl;var t=_a.getZonosUrl(e);var i="".concat(t,"/").concat(r);var a=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var u=document.createElement("script");if(!!o){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var n=getNextFallbackUrl(e);if(!n){return}_a.injectScript({cdnType:n,isModule:o,theRestUrl:r})};s.appendChild(u)};Zonos.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||e()}return e()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var e=n.cdnType,o=n.theRestUrl;var r=_a.getZonosUrl(e);var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(r,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var n=getNextFallbackUrl(e);if(!n){return}_a.injectStylesheet({cdnType:n,theRestUrl:o})};t.appendChild(a)};Zonos.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(INTER_FONT_URL,'"]'));for(var e=0;e<n.length;e++){var o=n[e];if(!o){continue}if(INTER_FONT_REGEX.test(o.href)){continue}return o}return null};if(n()){log("Inter font already injected","warn");return}var e=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=INTER_FONT_URL;e.appendChild(o);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");e.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var e;void((e=_a.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var e;log("[FONT] injecting ".concat(n));var o=(e=n.match(/family=(.*?):/))===null||e===void 0?void 0:e[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.134.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},l="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&c.test(t.src))return t}return null})();r&&e?console.warn(d):r||(r=(e=>{const o=document.createElement("script");o.src=`${l}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),u),m=Promise.resolve().then((()=>p(null)));let w=!1;m.catch((e=>{w||console.warn(e)}));function h(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const y=["cloudflare","vercel"],f=y[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},v=g[f],b=(e=f)=>{const o=y.indexOf(e),t=y[o+1];return t||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=S(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},O=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},j=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await O({basePathType:i,options:o,path:n}),{errors:l,response:c}=a,d=h(a,["errors","response"]),u=b(i),p=!!l.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=b();if(!o)return;fetch(`${g[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:S(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(t(`=== "${n}" failed to fetch, trying next fallback ${u}`),j({basePathType:u,options:o,path:n})):Object.assign({errors:l,response:c},d)},Z=async(e,o)=>{const n=h(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),j({basePathType:l||f,options:a,path:e})},C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await Z("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),N="https://v1.3.134.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732554888464",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.134",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c,storeId:d,zonosApiKey:u}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=u,T.storeId=d,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=a();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!u&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:e,json:o}=await Z("/api/get-test-public-credential");if(e.length||!o)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e);const r=o.publicCredential;r?(t(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(T.cartId&&T.cartData){t("Cart data is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{w=!0;const o=Date.now();return m.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.134";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";case"vercel":return N}};if(T.isNpm){return a()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=R})();
1
+ (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null};function a(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 l=["cloudflare","vercel"],c=l[0],d={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},u=d[c],p=(e=c)=>{const o=l.indexOf(e),t=l[o+1];return t||null},m=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},w=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=m(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}},h=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||d[e]||c,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await w({response:n}),response:n,zonosMode:a}}const u=n.status.toString();try{const e=await w({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},y=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,l=await h({basePathType:i,options:o,path:n}),{errors:c,response:w}=l,f=a(l,["errors","response"]),g=p(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==w?void 0:w.status),b=g&&v;return v&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${u}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=p();if(!o)return;fetch(`${d[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:d[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:g,requestHeaders:null==o?void 0:o.headers,requestPayload:m(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==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${g}`),y({basePathType:g,options:o,path:n})):Object.assign({errors:c,response:w},f)},f=async(e,o)=>{const n=a(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),l=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),y({basePathType:d||c,options:l,path:e})},g=()=>{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.135.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},v="https://js.stripe.com/v3",b=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,S="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let z=null;const O=e=>(null!==z||(z=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(S),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${v}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&b.test(t.src))return t}return null})();r&&e?console.warn(S):r||(r=(e=>{const o=document.createElement("script");o.src=`${v}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),z),j=Promise.resolve().then((()=>O(null)));let Z=!1;j.catch((e=>{Z||console.warn(e)}));const C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),N="https://v1.3.135.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732640595058",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.135",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:c,zonosApiKey:d}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=d,T.storeId=c,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=g();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!d&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}const r=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!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:e,json:o}=await f("/api/get-test-public-credential");if(e.length||!o)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e),null;const r=o.publicCredential;return r?(t(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(T.zonosApiKey=r)}if(T.cartId&&T.cartData){t("Cart data is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{Z=!0;const o=Date.now();return j.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.135";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";case"vercel":return N}};if(T.isNpm){return g()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=R})();
@@ -1 +1 @@
1
- (function(){"use strict";function o(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const e=["cloudflare","vercel"],n=e[0],t={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},r=t[n],s=(o=n)=>{const t=e.indexOf(o),r=e[t+1];return r||null},i=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},a=performance.now(),c=o=>{if("string"==typeof o)return o;try{return JSON.stringify(o)}catch(e){if(o&&"function"==typeof o.toString){return o.toString()}return"Unable to stringify info"}},d=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-a,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(c).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===e&&console.error(o,...i));let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const l=(null===(r=d.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":l.warn(o,...i);break;case"info":l.info(o,...i);break;case"error":l.error(o,...i);break;default:l.groupCollapsed(o,...i),l.trace(),l.groupEnd()}},l=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(d("sendErrorLog","warn",o,n,e),i){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${r}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=s();if(!e)return;fetch(`${t[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},p=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=i(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},u=async({basePathType:o,options:e,path:r})=>{let s;const i=window.Zonos.zonosQaUrlApi||t[o]||n,a=new URL(i+r),c=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(c));try{s=await fetch(a.toString(),e)}catch(o){if(o instanceof Error)return{baseUrl:i,errors:[{message:o.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const d=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await p({response:s}),response:s,zonosMode:d}}const u=s.status.toString();try{const o=await p({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(o),type:u}],json:null,response:s,zonosMode:d}}catch(o){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:d}}},m=async({basePathType:e,options:n,path:r})=>{var a,c;const p=r.startsWith("/api/bigcommerce")?"vercel":e,w=await u({basePathType:p,options:n,path:r}),{errors:g,response:f}=w,y=o(w,["errors","response"]),h=s(p),v=!!g.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&l({endpoint:t[p]+r,errors:g.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:p,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(a=null==n?void 0:n.body)||void 0===a?void 0:a.toString())||(null===(c=null==n?void 0:n.body)||void 0===c?void 0:c.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(d(`=== "${r}" failed to fetch, trying next fallback ${h}`),m({basePathType:h,options:n,path:r})):Object.assign({errors:g,response:f},y)},w=async(e,t)=>{const r=o(t||{},[]),s=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return d(e,"info"),m({basePathType:l||n,options:c,path:e})},g=(o,...e)=>{d(o,"error",...e)},f=["jsdelivr","cdnjs","unpkg","vercel"],y=o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrl");if(!e)return null;return/[^a-zA-Z0-9-_]+/.test(e)?null:e},h=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,v=new RegExp(`^${h.source}$`),Z=new RegExp(`^cart_${h.source}$`),S=o=>o?Z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:v.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},z=async({cartId:o,retries:e})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:t,json:r}=await w("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),s=!r||t.length;return s&&e?(d("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),z({cartId:o,retries:e-1})):s?null:r};var O;const L=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=y(window.location.href),n="https://v1.3.134.js.zonos.com";if(!e&&(n.includes("test.")||n.includes("test-")))return n;if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const t=`https://${e}.preview.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const o=new URLSearchParams(window.location.search);o.delete("zonosQaUrl");const{pathname:e}=window.location,n=`${e}?${o.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),b=(()=>{const o=(o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrlApi");return e?/[^a-zA-Z0-9-_]+/.test(e)?null:e:null})(window.location.href),e=y(window.location.href),n=o||e;if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!o)return null;const t=`https://${o}.route.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class U{}O=U,U.isNpm=!1,U.isBigCommerce=!1,U.requested=!1,U.cartData=null,U.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,U.version="v1.3.134",U.isLegacyCheckout=!1,U.legacyStoreLogo=null,U.legacyStoreFavicon=null,U.parallelLoadTimes=[],U.parallelLoadState="off",U.releaseDate="1732554888464",U.loadScriptLogHandler=async({cdnLoadTime:o,fallbackLoadTime:e,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const o=window.performance.getEntriesByType("resource").find((o=>{const e=o;return e.name.includes(r)&&"script"===e.initiatorType}));null==o||o.transferSize;(async o=>{})((o&&(null==o?void 0:o.duration)>0?parseFloat(o.duration.toFixed(2)):parseFloat(e.toFixed(2)),Object.assign({decodedBodySize:null==o?void 0:o.decodedBodySize,encodedBodySize:null==o?void 0:o.encodedBodySize,fallbackLoadTime:e,isError:!!n},t)))}catch(o){}},U.loadScriptLogParallelHandler=async o=>{try{if(O.parallelLoadTimes.push(o),2===O.parallelLoadTimes.length){const o=O.parallelLoadTimes.find((o=>"vercel"===o.type)),e=O.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void l({endpoint:`<${o.scriptLoadUrl}> <${e.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:e.fallbackLoadTime,cdnType:e.type,vercelLoadTime:o.fallbackLoadTime}});O.loadScriptLogHandler({cdnLoadTime:e.fallbackLoadTime,fallbackLoadTime:o.fallbackLoadTime,isError:o.isError,metadata:{cdnScriptFallbackTime:e.fallbackLoadTime,cdnScriptIsError:!!e.isError,cdnScriptLoadUrl:e.scriptLoadUrl,cdnScriptType:e.type},scriptLoadUrl:o.scriptLoadUrl,storeId:o.storeId,type:o.type})}}catch(o){}},U.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{g(`[ZONOS - loadZonos] ${o}`),l({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:O.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},U.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.134");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},U.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:O.getGithubCdn({type:o,version:r}),a=L||i,c=a.replace("https://","").replace("http://",""),p=document.createElement("script"),u=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${c}/dist/scripts/${u}`,d(`[ZONOS - loadZonos] Injecting "${u}" from "${c}"`,"info");const m="4g"===(null===(s=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),g=f[0]===o,y=f[1],h="on"===O.parallelLoadState&&m&&g&&y&&!w;h&&O.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();p.addEventListener("load",(()=>{var t;if(h||n?O.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:O.storeId,type:o}):O.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:O.storeId,type:o}),O.isBigCommerce||(O.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.isBigCommerce=O.isBigCommerce,O.cartId){if(!O.zonosApiKey)throw O.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!O.cartData)throw O.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(O.legacyStoreFavicon&&O.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=O.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=O.cartData,window.Zonos.isLegacyCheckout=O.isLegacyCheckout;const o=O.isLegacyCheckout&&"CLOSE_MODAL"===(null===(t=e.checkoutSettings)||void 0===t?void 0:t.successBehavior),n=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:O.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:o?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:o?O.cartData.storeBaseUrl:void 0}),zonosApiKey:O.zonosApiKey});e=n}window.Zonos.version&&(d(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${c}"`,"info"),window.Zonos.init(e))})),p.addEventListener("error",(async()=>{const s=(o=>{const e=f.indexOf(o);return f[e+1]||null})(o);if(!h&&!n){if(!s)return;O.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||L)return;if(h||n)return void O.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:p.src,storeId:O.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?l({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):l({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(p)},U.init=async o=>{var e;if(d("=== Init zonos script release date","info",O.releaseDate),L&&!window.isZonosPreview){d(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${L}`,"info");const e=document.createElement("script");return e.src=`${L}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=O.isBigCommerce,window.Zonos.isLegacyCheckout=O.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${L}`)})),void(window.isZonosPreview=!0)}const n=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:t,isLegacyCartId:r}=S(n);if(n&&!r&&!t)return void O.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${n}`,metadata:{invalidCartId:!0}});O.cartId=n;const s="https://v1.3.134.js.zonos.com",i=document.querySelector('script[src*="/zonos.js"]'),a=null===(e=document.querySelector("script[src*='/loadZonos.js']"))||void 0===e?void 0:e.src;d(`[ZONOS - init] first load script src: ${a}`,"info"),window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.zonosQaUrl&&d(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&d(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==a?void 0:a.includes("timestamp=");if(!(O.isNpm||a&&c))return void g("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(i||!a||O.requested)return void d("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!O.cartId)return O.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void g("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(O.requested=!0,O.zonosApiKey=o.zonosApiKey,O.storeId=o.storeId,O.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=S(o);if(!n&&!e)return g("[ZONOS - loadZonos] invalid cart id"),null;const t=await z({cartId:o,retries:5});return d("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(g("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(O.cartId);if(!o)throw O.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");O.cartData=o.cartData,O.zonosApiKey=o.zonosApiKey,O.legacyStoreLogo=o.storeLogo,O.legacyStoreFavicon=o.storeFavicon,O.storeId=o.storeId,O.zonosApiKey=o.zonosApiKey}if(!O.zonosApiKey)return void g('"zonosApiKey" is required to initialize Zonos');if(await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(d("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void d("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:o,json:e}=await w("/api/get-test-public-credential");if(o.length||!e)return void g("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o);const n=e.publicCredential;n?(d(`[ZONOS - loadZonos] Using test API key: ${n} for test mode`,"info"),window.Zonos.zonosApiKey=n):g("[ZONOS - loadZonos] No test public key credential. Keep using production key")})(),!O.storeId)return d("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void O.injectZonos({initConfig:o,vercelUrl:s,version:null});const l=O.storeId||o.storeId;d(`[ZONOS - loadZonos] Store ID: ${l}`,"info");const p=new URLSearchParams;p.set("storeId",l.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&p.set("_enableStoreVersionPinned","1");const{errors:u,json:m}=await w(`/api/get-store-version?${p.toString()}`);if(u.length||!m)return d("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void O.injectZonos({initConfig:o,vercelUrl:s,version:null});const{isDifferent:f,source:y,version:h}=m;if(d(`[ZONOS - loadZonos] Store version: ${h}, source: ${y}`,"info"),f){d(`[ZONOS - loadZonos] Updating saved store version to ${h}`,"info");const o={storeId:l,version:h};w(`/api/set-store-version?${p.toString()}`,{body:o,method:"POST"}).catch((o=>g("Unable to save store's vesrion",o)))}if(!i){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:o})=>{if(!o)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const e=new URL(o).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((o=>e.includes(o))),t=["qa.js.zonos.com"].some((o=>e.includes(o)));return{currentLoadScriptUrl:e,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:a}),r=t&&!n?e:`${"alpha"===h?"alpha":`v${h}`}.js.zonos.com`,s=t&&!n?null:h;d("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:h}),O.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview)&&(window.Zonos=U)})();
1
+ (function(){"use strict";function o(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const e=["cloudflare","vercel"],n=e[0],t={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},r=t[n],s=(o=n)=>{const t=e.indexOf(o),r=e[t+1];return r||null},i=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},a=performance.now(),c=o=>{if("string"==typeof o)return o;try{return JSON.stringify(o)}catch(e){if(o&&"function"==typeof o.toString){return o.toString()}return"Unable to stringify info"}},d=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-a,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(c).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===e&&console.error(o,...i));let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const l=(null===(r=d.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":l.warn(o,...i);break;case"info":l.info(o,...i);break;case"error":l.error(o,...i);break;default:l.groupCollapsed(o,...i),l.trace(),l.groupEnd()}},l=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(d("sendErrorLog","warn",o,n,e),i){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${r}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=s();if(!e)return;fetch(`${t[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},p=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=i(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},u=async({basePathType:o,options:e,path:r})=>{let s;const i=window.Zonos.zonosQaUrlApi||t[o]||n,a=new URL(i+r),c=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(c));try{s=await fetch(a.toString(),e)}catch(o){if(o instanceof Error)return{baseUrl:i,errors:[{message:o.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const d=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await p({response:s}),response:s,zonosMode:d}}const u=s.status.toString();try{const o=await p({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(o),type:u}],json:null,response:s,zonosMode:d}}catch(o){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:d}}},m=async({basePathType:e,options:n,path:r})=>{var a,c;const p=r.startsWith("/api/bigcommerce")?"vercel":e,w=await u({basePathType:p,options:n,path:r}),{errors:g,response:f}=w,y=o(w,["errors","response"]),h=s(p),v=!!g.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&l({endpoint:t[p]+r,errors:g.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:p,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(a=null==n?void 0:n.body)||void 0===a?void 0:a.toString())||(null===(c=null==n?void 0:n.body)||void 0===c?void 0:c.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(d(`=== "${r}" failed to fetch, trying next fallback ${h}`),m({basePathType:h,options:n,path:r})):Object.assign({errors:g,response:f},y)},w=async(e,t)=>{const r=o(t||{},[]),s=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return d(e,"info"),m({basePathType:l||n,options:c,path:e})},g=(o,...e)=>{d(o,"error",...e)},f=["jsdelivr","cdnjs","unpkg","vercel"],y=o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrl");if(!e)return null;return/[^a-zA-Z0-9-_]+/.test(e)?null:e},h=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,v=new RegExp(`^${h.source}$`),Z=new RegExp(`^cart_${h.source}$`),S=o=>o?Z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:v.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},O=async({cartId:o,retries:e})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:t,json:r}=await w("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),s=!r||t.length;return s&&e?(d("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),O({cartId:o,retries:e-1})):s?null:r};var z;const L=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=y(window.location.href),n="https://v1.3.135.js.zonos.com";if(!e&&(n.includes("test.")||n.includes("test-")))return n;if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const t=`https://${e}.preview.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const o=new URLSearchParams(window.location.search);o.delete("zonosQaUrl");const{pathname:e}=window.location,n=`${e}?${o.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),b=(()=>{const o=(o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrlApi");return e?/[^a-zA-Z0-9-_]+/.test(e)?null:e:null})(window.location.href),e=y(window.location.href),n=o||e;if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!o)return null;const t=`https://${o}.route.js.zonos.com`;return d(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class U{}z=U,U.isNpm=!1,U.isBigCommerce=!1,U.requested=!1,U.cartData=null,U.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,U.version="v1.3.135",U.isLegacyCheckout=!1,U.legacyStoreLogo=null,U.legacyStoreFavicon=null,U.parallelLoadTimes=[],U.parallelLoadState="off",U.releaseDate="1732640595058",U.loadScriptLogHandler=async({cdnLoadTime:o,fallbackLoadTime:e,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const o=window.performance.getEntriesByType("resource").find((o=>{const e=o;return e.name.includes(r)&&"script"===e.initiatorType}));null==o||o.transferSize;(async o=>{})((o&&(null==o?void 0:o.duration)>0?parseFloat(o.duration.toFixed(2)):parseFloat(e.toFixed(2)),Object.assign({decodedBodySize:null==o?void 0:o.decodedBodySize,encodedBodySize:null==o?void 0:o.encodedBodySize,fallbackLoadTime:e,isError:!!n},t)))}catch(o){}},U.loadScriptLogParallelHandler=async o=>{try{if(z.parallelLoadTimes.push(o),2===z.parallelLoadTimes.length){const o=z.parallelLoadTimes.find((o=>"vercel"===o.type)),e=z.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void l({endpoint:`<${o.scriptLoadUrl}> <${e.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:e.fallbackLoadTime,cdnType:e.type,vercelLoadTime:o.fallbackLoadTime}});z.loadScriptLogHandler({cdnLoadTime:e.fallbackLoadTime,fallbackLoadTime:o.fallbackLoadTime,isError:o.isError,metadata:{cdnScriptFallbackTime:e.fallbackLoadTime,cdnScriptIsError:!!e.isError,cdnScriptLoadUrl:e.scriptLoadUrl,cdnScriptType:e.type},scriptLoadUrl:o.scriptLoadUrl,storeId:o.storeId,type:o.type})}}catch(o){}},U.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{g(`[ZONOS - loadZonos] ${o}`),l({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:z.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},U.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.135");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},U.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:z.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:z.getGithubCdn({type:o,version:r}),a=L||i,c=a.replace("https://","").replace("http://",""),p=document.createElement("script"),u=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${c}/dist/scripts/${u}`,d(`[ZONOS - loadZonos] Injecting "${u}" from "${c}"`,"info");const m="4g"===(null===(s=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),g=f[0]===o,y=f[1],h="on"===z.parallelLoadState&&m&&g&&y&&!w;h&&z.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();p.addEventListener("load",(()=>{var t;if(h||n?z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}):z.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}),z.isBigCommerce||(z.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.isBigCommerce=z.isBigCommerce,z.cartId){if(!z.zonosApiKey)throw z.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!z.cartData)throw z.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(z.legacyStoreFavicon&&z.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=z.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=z.cartData,window.Zonos.isLegacyCheckout=z.isLegacyCheckout;const o=z.isLegacyCheckout&&"CLOSE_MODAL"===(null===(t=e.checkoutSettings)||void 0===t?void 0:t.successBehavior),n=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:z.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:o?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:o?z.cartData.storeBaseUrl:void 0}),zonosApiKey:z.zonosApiKey});e=n}window.Zonos.version&&(d(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${c}"`,"info"),window.Zonos.init(e))})),p.addEventListener("error",(async()=>{const s=(o=>{const e=f.indexOf(o);return f[e+1]||null})(o);if(!h&&!n){if(!s)return;z.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||L)return;if(h||n)return void z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:p.src,storeId:z.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?l({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):l({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(p)},U.init=async o=>{var e;if(d("=== Init zonos script release date","info",z.releaseDate),L&&!window.isZonosPreview){d(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${L}`,"info");const e=document.createElement("script");return e.src=`${L}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=z.isBigCommerce,window.Zonos.isLegacyCheckout=z.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${L}`)})),void(window.isZonosPreview=!0)}const n=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:t,isLegacyCartId:r}=S(n);if(n&&!r&&!t)return void z.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${n}`,metadata:{invalidCartId:!0}});z.cartId=n;const s="https://v1.3.135.js.zonos.com",i=document.querySelector('script[src*="/zonos.js"]'),a=null===(e=document.querySelector("script[src*='/loadZonos.js']"))||void 0===e?void 0:e.src;d(`[ZONOS - init] first load script src: ${a}`,"info"),window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.zonosQaUrl&&d(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&d(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==a?void 0:a.includes("timestamp=");if(!(z.isNpm||a&&c))return void g("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(i||!a||z.requested)return void d("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!z.cartId)return z.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void g("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(z.requested=!0,z.zonosApiKey=o.zonosApiKey,z.storeId=o.storeId,z.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=S(o);if(!n&&!e)return g("[ZONOS - loadZonos] invalid cart id"),null;const t=await O({cartId:o,retries:5});return d("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(g("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(z.cartId);if(!o)throw z.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");z.cartData=o.cartData,z.legacyStoreLogo=o.storeLogo,z.legacyStoreFavicon=o.storeFavicon,z.storeId=o.storeId,z.zonosApiKey=o.zonosApiKey}if(!z.zonosApiKey)return void g('"zonosApiKey" is required to initialize Zonos');const l=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return null;if(d("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return d("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:e}=await w("/api/get-test-public-credential");if(o.length||!e)return g("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const n=e.publicCredential;return n?(d(`[ZONOS - loadZonos] Retrieve new test public token ${n}`,"info"),n):(g("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(l&&(d(`[ZONOS - loadZonos] Using test API key: ${l} for test mode`,"info"),z.zonosApiKey=l),!z.storeId)return d("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const p=z.storeId||o.storeId;d(`[ZONOS - loadZonos] Store ID: ${p}`,"info");const u=new URLSearchParams;u.set("storeId",p.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&u.set("_enableStoreVersionPinned","1");const{errors:m,json:f}=await w(`/api/get-store-version?${u.toString()}`);if(m.length||!f)return d("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const{isDifferent:y,source:h,version:v}=f;if(d(`[ZONOS - loadZonos] Store version: ${v}, source: ${h}`,"info"),y){d(`[ZONOS - loadZonos] Updating saved store version to ${v}`,"info");const o={storeId:p,version:v};w(`/api/set-store-version?${u.toString()}`,{body:o,method:"POST"}).catch((o=>g("Unable to save store's vesrion",o)))}if(!i){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:o})=>{if(!o)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const e=new URL(o).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((o=>e.includes(o))),t=["qa.js.zonos.com"].some((o=>e.includes(o)));return{currentLoadScriptUrl:e,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:a}),r=t&&!n?e:`${"alpha"===v?"alpha":`v${v}`}.js.zonos.com`,s=t&&!n?null:v;d("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:v}),z.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview)&&(window.Zonos=U)})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.134.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},l="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&c.test(t.src))return t}return null})();r&&e?console.warn(d):r||(r=(e=>{const o=document.createElement("script");o.src=`${l}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),u),m=Promise.resolve().then((()=>p(null)));let w=!1;m.catch((e=>{w||console.warn(e)}));function h(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const y=["cloudflare","vercel"],f=y[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},v=g[f],b=(e=f)=>{const o=y.indexOf(e),t=y[o+1];return t||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=S(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},O=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},Z=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await O({basePathType:i,options:o,path:n}),{errors:l,response:c}=a,d=h(a,["errors","response"]),u=b(i),p=!!l.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=b();if(!o)return;fetch(`${g[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:S(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(t(`=== "${n}" failed to fetch, trying next fallback ${u}`),Z({basePathType:u,options:o,path:n})):Object.assign({errors:l,response:c},d)},j=async(e,o)=>{const n=h(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),a=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),Z({basePathType:l||f,options:a,path:e})},C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await j("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),N="https://v1.3.134.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732554888464",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.134",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c,storeId:d,zonosApiKey:u}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=u,T.storeId=d,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=a();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!u&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:e,json:o}=await j("/api/get-test-public-credential");if(e.length||!o)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e);const r=o.publicCredential;r?(t(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(T.cartId&&T.cartData){t("Cart data is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:c}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{w=!0;const o=Date.now();return m.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.134";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";case"vercel":return N}};if(T.isNpm){return a()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=R)})();
1
+ (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null};function a(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 l=["cloudflare","vercel"],c=l[0],d={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},u=d[c],p=(e=c)=>{const o=l.indexOf(e),t=l[o+1];return t||null},m=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},w=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=m(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}},h=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||d[e]||c,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await w({response:n}),response:n,zonosMode:a}}const u=n.status.toString();try{const e=await w({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},y=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,l=await h({basePathType:i,options:o,path:n}),{errors:c,response:w}=l,f=a(l,["errors","response"]),g=p(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==w?void 0:w.status),b=g&&v;return v&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${u}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=p();if(!o)return;fetch(`${d[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:d[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:g,requestHeaders:null==o?void 0:o.headers,requestPayload:m(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==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${g}`),y({basePathType:g,options:o,path:n})):Object.assign({errors:c,response:w},f)},f=async(e,o)=>{const n=a(o||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),l=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),y({basePathType:d||c,options:l,path:e})},g=()=>{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.135.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},v="https://js.stripe.com/v3",b=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,S="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let z=null;const O=e=>(null!==z||(z=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(S),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${v}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&b.test(t.src))return t}return null})();r&&e?console.warn(S):r||(r=(e=>{const o=document.createElement("script");o.src=`${v}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),z),Z=Promise.resolve().then((()=>O(null)));let j=!1;Z.catch((e=>{j||console.warn(e)}));const C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await C({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var T;const $=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),N="https://v1.3.135.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1732640595058",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.135",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:c,zonosApiKey:d}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!T.doneInit){if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=d,T.storeId=c,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=g();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!d&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}const r=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!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:e,json:o}=await f("/api/get-test-public-credential");if(e.length||!o)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e),null;const r=o.publicCredential;return r?(t(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(T.zonosApiKey=r)}if(T.cartId&&T.cartData){t("Cart data is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),T.doneInit=!0}},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},R.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{j=!0;const o=Date.now();return Z.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.135";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";case"vercel":return N}};if(T.isNpm){return g()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=R)})();
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Attempt to get test public credential to window.Zonos.zonosApiKey if needed
3
+ */
4
+ export declare const getWithTestPublicCredential: () => Promise<string | null>;
@@ -1 +1 @@
1
- import{l as e,a as n,h as o}from"./p-860e46ab.js";import{s as t,c as s}from"./p-b7307c61.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b7307c61.js";const r=["jsdelivr","cdnjs","unpkg","vercel"],i="jsdelivr",l=e=>{const n=r.indexOf(e);return r[n+1]||null},a=()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const o=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),t="https://v1.3.134.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const s=`https://${o}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),s},u="https://js.stripe.com/v3",m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let p=null;const f=Promise.resolve().then((()=>{return e=null,null!==p||(p=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(w),window.Stripe)o(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&m.test(o.src))return o}return null})();s&&e?console.warn(w):s||(s=(e=>{const o=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${u}${o}`;const s=document.head||document.body;return s?(s.appendChild(t),t):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),p;var e}));let h=!1;var v;f.catch((e=>{h||console.warn(e)}));const y=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),z="https://v1.3.134.js.zonos.com",j=y||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134",S="https://rsms.me",g="https://fonts.googleapis.com",O=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class ${}v=$,$.doneInit=!1,$.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),$.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),$._paypalMockResponse=null,$.isBigCommerce=!1,$.releaseDate="1732554842941",$.isLegacyCheckout=!1,$.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",$.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),$.isNpm=!0,$.zonosQaUrl=null,$.zonosQaUrlApi=null,$.version="v1.3.134",$.modeAlerted=!1,$.cartData=null,$.paypal=null,$.getCurrentTimestamp=()=>(new Date).getTime(),$.zonosController=null,$.init=async r=>{const{appearance:i,checkoutSettings:d,currencyConverter:c,helloSettings:l,onCountryChange:u,overrideCurrencyFormat:m,storeId:w,zonosApiKey:p}=r;if(v.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!v.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${v.version}) ======`),v.zonosApiKey=p,v.storeId=w,v.isNpm){e("====== ZONOS LOADING FROM NPM ======");const s=a();if(s&&!window.isZonosPreview){e(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${s} ======`,"info");const n=document.createElement("script");return n.src=`${s}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=v.isNpm,window.Zonos.isBigCommerce=v.isBigCommerce,window.Zonos.isLegacyCheckout=v.isLegacyCheckout,window.Zonos.init(r)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${s}`)})),void(window.isZonosPreview=!0)}if(!p&&!v.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!v.cartData&&v.cartId){e("Initialize cart data");const o=await t(v.cartId);if(!o)return void n("Failed to get cart data");v.cartData=o.cartData,v.zonosApiKey=o.zonosApiKey}await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return;if(e("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("test"))return void e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");const{errors:t,json:s}=await o("/api/get-test-public-credential");if(t.length||!s)return void n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);const r=s.publicCredential;r?(e(`[ZONOS - loadZonos] Using test API key: ${r} for test mode`,"info"),window.Zonos.zonosApiKey=r):n("[ZONOS - loadZonos] No test public key credential. Keep using production key")})()}if(v.cartId&&v.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${s}`,document.body.appendChild(n)}e("init zonos"),v.injectZonosCdn(),v.injectZonosCss(),v.injectFonts(),v.injectController({config:{appearance:i,checkoutSettings:d,currencyConverter:c,helloSettings:l,onCountryChange:u,overrideCurrencyFormat:m}}),v.doneInit=!0}},$.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},$.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},$.showNotification=e=>{var n;null===(n=v.zonosController)||void 0===n||n.showNotification(e)},$.updateOrganizationName=e=>{var n;null===(n=v.zonosController)||void 0===n||n.updateOrganizationName(e)},$.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},$.injectController=({config:o})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=o.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;v.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{v.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=o,s.zonosApiKey=v.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async o=>{const{detail:t}=o;e("loading Stripe");const r=await(async(...e)=>{h=!0;const n=Date.now();return f.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),v.zonosController=s,e("Zonos controller injected!")},$.injectScript=({cdnType:o,isModule:t,theRestUrl:s})=>{const r=`${v.getZonosUrl(o)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const i=document.head||document.body,d=document.createElement("script");t?d.type="module":d.noModule=!0,d.src=r,d.crossOrigin="anonymous",d.onerror=()=>{n(`Failed to load ${d.src}`);const e=l(o);e&&v.injectScript({cdnType:e,isModule:t,theRestUrl:s})},i.appendChild(d)},$.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return j;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.134";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";case"vercel":return z}};return v.isNpm&&a()||n()},$.injectZonosCdn=()=>{v.injectScript({cdnType:i,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),v.injectScript({cdnType:i,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},$.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=v.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${z}/`,s.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{n(`Failed to load ${i.href}`);const t=l(e);t&&v.injectStylesheet({cdnType:t,theRestUrl:o})},s.appendChild(i)},$.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(v.injectStylesheet({cdnType:i,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},$.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!O.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=S,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${S}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},$.setupGoogleFont=e=>{var n;null===(n=v.zonosController)||void 0===n||n.setupGoogleFont(e)},$.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${g}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=g,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${t} font injected!`)};export{$ as Zonos}
1
+ import{l as e,h as n,a as o}from"./p-860e46ab.js";import{s as t,c as s}from"./p-b7307c61.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b7307c61.js";const r=["jsdelivr","cdnjs","unpkg","vercel"],i="jsdelivr",l=e=>{const n=r.indexOf(e);return r[n+1]||null},a=()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const o=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),t="https://v1.3.135.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const s=`https://${o}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),s},u="https://js.stripe.com/v3",m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let p=null;const f=Promise.resolve().then((()=>{return e=null,null!==p||(p=new Promise(((n,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(w),window.Stripe)n(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&m.test(o.src))return o}return null})();s&&e?console.warn(w):s||(s=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${u}${n}`;const s=document.head||document.body;return s?(s.appendChild(t),t):(o("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):t(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else n(null)}))),p;var e}));let h=!1;var v;f.catch((e=>{h||console.warn(e)}));const y=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),z="https://v1.3.135.js.zonos.com",j=y||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135",S="https://rsms.me",g="https://fonts.googleapis.com",O=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class b{}v=b,b.doneInit=!1,b.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),b.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),b._paypalMockResponse=null,b.isBigCommerce=!1,b.releaseDate="1732640550316",b.isLegacyCheckout=!1,b.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",b.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),b.isNpm=!0,b.zonosQaUrl=null,b.zonosQaUrlApi=null,b.version="v1.3.135",b.modeAlerted=!1,b.cartData=null,b.paypal=null,b.getCurrentTimestamp=()=>(new Date).getTime(),b.zonosController=null,b.init=async r=>{const{appearance:i,checkoutSettings:c,currencyConverter:l,helloSettings:d,onCountryChange:u,overrideCurrencyFormat:m,storeId:w,zonosApiKey:p}=r;if(v.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!v.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${v.version}) ======`),v.zonosApiKey=p,v.storeId=w,v.isNpm){e("====== ZONOS LOADING FROM NPM ======");const s=a();if(s&&!window.isZonosPreview){e(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${s} ======`,"info");const n=document.createElement("script");return n.src=`${s}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=v.isNpm,window.Zonos.isBigCommerce=v.isBigCommerce,window.Zonos.isLegacyCheckout=v.isLegacyCheckout,window.Zonos.init(r)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${s}`)})),void(window.isZonosPreview=!0)}if(!p&&!v.cartId)return void o("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!v.cartData&&v.cartId){e("Initialize cart data");const n=await t(v.cartId);if(!n)return void o("Failed to get cart data");v.cartData=n.cartData,v.zonosApiKey=n.zonosApiKey}const i=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return null;if(e("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:s}=await n("/api/get-test-public-credential");if(t.length||!s)return o("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const r=s.publicCredential;return r?(e(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(o("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();i&&(v.zonosApiKey=i)}if(v.cartId&&v.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${s}`,document.body.appendChild(n)}e("init zonos"),v.injectZonosCdn(),v.injectZonosCss(),v.injectFonts(),v.injectController({config:{appearance:i,checkoutSettings:c,currencyConverter:l,helloSettings:d,onCountryChange:u,overrideCurrencyFormat:m}}),v.doneInit=!0}},b.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},b.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},b.showNotification=e=>{var n;null===(n=v.zonosController)||void 0===n||n.showNotification(e)},b.updateOrganizationName=e=>{var n;null===(n=v.zonosController)||void 0===n||n.updateOrganizationName(e)},b.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)}},b.injectController=({config:n})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=n.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;v.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{v.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=v.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async n=>{const{detail:t}=n;e("loading Stripe");const r=await(async(...e)=>{h=!0;const n=Date.now();return f.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):o("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),v.zonosController=s,e("Zonos controller injected!")},b.injectScript=({cdnType:n,isModule:t,theRestUrl:s})=>{const r=`${v.getZonosUrl(n)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const i=document.head||document.body,c=document.createElement("script");t?c.type="module":c.noModule=!0,c.src=r,c.crossOrigin="anonymous",c.onerror=()=>{o(`Failed to load ${c.src}`);const e=l(n);e&&v.injectScript({cdnType:e,isModule:t,theRestUrl:s})},i.appendChild(c)},b.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return j;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.135";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";case"vercel":return z}};return v.isNpm&&a()||n()},b.injectZonosCdn=()=>{v.injectScript({cdnType:i,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),v.injectScript({cdnType:i,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},b.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const t=v.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${z}/`,s.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${n}`,i.onerror=()=>{o(`Failed to load ${i.href}`);const t=l(e);t&&v.injectStylesheet({cdnType:t,theRestUrl:n})},s.appendChild(i)},b.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(v.injectStylesheet({cdnType:i,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},b.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!O.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=S,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${S}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},b.setupGoogleFont=e=>{var n;null===(n=v.zonosController)||void 0===n||n.setupGoogleFont(e)},b.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${g}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=g,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${t} font injected!`)};export{b as Zonos}
@@ -0,0 +1 @@
1
+ var __awaiter=this&&this.__awaiter||function(n,e,t,r){function o(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,i){function u(n){try{a(r.next(n))}catch(n){i(n)}}function s(n){try{a(r["throw"](n))}catch(n){i(n)}}function a(n){n.done?t(n.value):o(n.value).then(u,s)}a((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(n){return function(e){return a([n,e])}}function a(s){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=e.call(n,t)}catch(n){s=[6,n];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-febc72e7.system.js","./p-bb418544.system.js"],(function(n){"use strict";var e,t,r,o,i;return{setters:[function(n){e=n.l;t=n.h;r=n.a},function(e){o=e.s;i=e.c;var t={};t.checkoutHiddenBtnSelector=e.c;t.domesticRedirectedBtnSelector=e.d;n(t)}],execute:function(){var u=this;var s=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(e).origin;var i=t.some((function(n){return o.includes(n)}));var u=r.some((function(n){return o.includes(n)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var a=["jsdelivr","cdnjs","unpkg","vercel"];var c="jsdelivr";var d=function(n){var e=a.indexOf(n);var t=a[e+1];return t||null};var l=function(){return __awaiter(u,void 0,void 0,(function(){var n,o,i,u,s;return __generator(this,(function(a){switch(a.label){case 0:n=window.location.search.includes("zonosTestMode=1");if(!n||!window.Zonos.zonosApiKey){return[2,null]}e("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,t("/api/get-test-public-credential")];case 1:o=a.sent(),i=o.errors,u=o.json;if(i.length||!u){r("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",i);return[2,null]}s=u.publicCredential;if(!s){r("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}e("[ZONOS - loadZonos] Retrieve new test public token ".concat(s),"info");return[2,s]}}))}))};var f=function(n){if(!n){return null}var e=new URL(n).searchParams;var t=e.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var v=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var t=f(window.location.href);var r="https://v1.3.135.js.zonos.com";if(!t&&(r.includes("test.")||r.includes("test-"))){return r}if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!t){return null}if(t==="dev-elements"){return"https://dev.elements.zonos.com"}var o="preview.js.zonos.com";var i="https://".concat(t,".").concat(o);e("[ZONOS-WARNING] using '".concat(i,"' for loading elements script"),"warn");void fetch(i).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(i,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var t="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return i};var m="https://js.stripe.com/v3";var w=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var p="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var h=function(){var n=document.querySelectorAll('script[src^="'.concat(m,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(!w.test(t.src)){continue}return t}return null};var y=null;var z=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var t=document.createElement("script");t.src="".concat(m).concat(e);var o=document.head||document.body;if(!o){r("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}o.appendChild(t);return t};var j=function(n){if(y!==null){return y}y=new Promise((function(e,t){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(p)}if(window.Stripe){e(window.Stripe);return}try{var r=h();if(r&&n){console.warn(p)}else if(!r){r=z(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(n){t(n);return}}));return y};var b=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var g=function(n,e,t){if(n===null){return null}var r=n.apply(undefined,e);b(r,t);return r};var O=Promise.resolve().then((function(){return j(null)}));var k=false;O.catch((function(n){if(!k){console.warn(n)}}));var S=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(u,void 0,void 0,(function(){var e;return __generator(this,(function(t){k=true;e=Date.now();return[2,O.then((function(t){return g(t,n,e)}))]}))}))};var N="tempCartUUID";var Z=function(){var n=new URLSearchParams(window.location.search);var e=n.get(N);return e};var _;var R=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=s({loadScriptSrc:n===null||n===void 0?void 0:n.src}),t=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return t}return null}();var U="https://v1.3.135.js.zonos.com";var L=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.135";var F="https://unpkg.com/@zonos/elements@1.3.135";var I="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.135";var A="https://rsms.me";var E="https://fonts.googleapis.com";var T=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var P=function(){function n(){}return n}();n("Zonos",P);_=P;P.doneInit=false;P.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);P.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);P._paypalMockResponse=null;P.isBigCommerce=false;P.releaseDate="1732640550316";P.isLegacyCheckout=false;P.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";P.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");P.isNpm=true;P.zonosQaUrl=null;P.zonosQaUrlApi=null;P.version="v".concat("1.3.135");P.modeAlerted=false;P.cartData=null;P.paypal=null;P.getCurrentTimestamp=function(){return(new Date).getTime()};P.zonosController=null;P.init=function(n){return __awaiter(u,void 0,void 0,(function(){var t,u,s,a,c,d,f,m,w,p,h,y,z;return __generator(this,(function(j){switch(j.label){case 0:t=n.appearance,u=n.checkoutSettings,s=n.currencyConverter,a=n.helloSettings,c=n.onCountryChange,d=n.overrideCurrencyFormat,f=n.storeId,m=n.zonosApiKey;_.cartId=Z();if(_.doneInit){return[2]}e("====== ZONOS DEBUG MODE: on (".concat(_.version,") ======"));_.zonosApiKey=m;_.storeId=f;if(!_.isNpm)return[3,4];e("====== ZONOS LOADING FROM NPM ======");w=v();if(w&&!window.isZonosPreview){e('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(w," ======"),"info");p=document.createElement("script");p.src="".concat(w,"/dist/scripts/zonos.js");document.head.appendChild(p);p.addEventListener("load",(function(){window.Zonos.isNpm=_.isNpm;window.Zonos.isBigCommerce=_.isBigCommerce;window.Zonos.isLegacyCheckout=_.isLegacyCheckout;void window.Zonos.init(n)}));p.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(w))}));window.isZonosPreview=true;return[2]}if(!m&&!_.cartId){r("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_.cartData&&_.cartId))return[3,2];e("Initialize cart data");return[4,o(_.cartId)];case 1:h=j.sent();if(!h){r("Failed to get cart data");return[2]}_.cartData=h.cartData;_.zonosApiKey=h.zonosApiKey;j.label=2;case 2:return[4,l()];case 3:y=j.sent();if(y){_.zonosApiKey=y}j.label=4;case 4:if(_.cartId&&_.cartData){e("Cart data is available, inject hidden button and trigger checkout");z=document.createElement("button");z.style.display="none";z.id="".concat(i);document.body.appendChild(z)}e("init zonos");_.injectZonosCdn();_.injectZonosCss();_.injectFonts();_.injectController({config:{appearance:t,checkoutSettings:u,currencyConverter:s,helloSettings:a,onCountryChange:c,overrideCurrencyFormat:d}});_.doneInit=true;return[2]}}))}))};P.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};P.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};P.showNotification=function(n){var e;void((e=_.zonosController)===null||e===void 0?void 0:e.showNotification(n))};P.updateOrganizationName=function(n){var e;void((e=_.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};P.disablePlaceOrderButtons=function(n){var e=n.autoEnable,t=e===void 0?true:e,r=n.config,o=n.disable,i=n.placeOrderButtonSelector;var u;if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var a=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};s.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(o){n.setAttribute("disabled","true");n.addEventListener("click",a)}else{n.removeAttribute("disabled");n.removeEventListener("click",a)}}));if(t&&o){setTimeout((function(){s.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",a)}))}),5e3)}}};P.injectController=function(n){var t=n.config;var o;if(document.querySelector("zonos-controller")){return}if((o=t.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var i=t.checkoutSettings.placeOrderButtonSelector;_.disablePlaceOrderButtons({config:t,disable:true,placeOrderButtonSelector:i});var s=new MutationObserver((function(){_.disablePlaceOrderButtons({config:t,disable:true,placeOrderButtonSelector:i})}));s.observe(document.body,{childList:true,subtree:true})}var a=document.createElement("zonos-controller");a.config=t;a.zonosApiKey=_.zonosApiKey||"";a.addEventListener("stripeInitEvent",(function(n){return __awaiter(u,void 0,void 0,(function(){var t,o;return __generator(this,(function(i){switch(i.label){case 0:t=n.detail;e("loading Stripe");return[4,S(t.publishableKey)];case 1:o=i.sent();if(!o){r("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void a.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(a);_.zonosController=a;e("Zonos controller injected!")};P.injectScript=function(n){var t=n.cdnType,o=n.isModule,i=n.theRestUrl;var u=_.getZonosUrl(t);var s="".concat(u,"/").concat(i);var a=function(){var n=document.querySelector('script[src="'.concat(s,'"]'));return!!n};if(a()){e('Zonos script "'.concat(s,'" already exists in the document'),"warn");return}var c=document.head||document.body;var l=document.createElement("script");if(!!o){l.type="module"}else{l.noModule=true}l.src=s;l.crossOrigin="anonymous";l.onerror=function(){r("Failed to load ".concat(l.src));var n=d(t);if(!n){return}_.injectScript({cdnType:n,isModule:o,theRestUrl:i})};c.appendChild(l)};P.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return L;case"unpkg":return F;case"cdnjs":return I;case"vercel":return U}};if(_.isNpm){var t=v();return t||e()}return e()};P.injectZonosCdn=function(){_.injectScript({cdnType:c,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_.injectScript({cdnType:c,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});e("Zonos cdn script injected!")};P.injectStylesheet=function(n){var e=n.cdnType,t=n.theRestUrl;var o=_.getZonosUrl(e);var i=document.head||document.body;var u=document.createElement("link");u.rel="preconnect";u.href="".concat(U,"/");i.appendChild(u);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(o,"/").concat(t);s.onerror=function(){r("Failed to load ".concat(s.href));var n=d(e);if(!n){return}_.injectStylesheet({cdnType:n,theRestUrl:t})};i.appendChild(s)};P.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){e("Zonos style links already injected","warn");return}_.injectStylesheet({cdnType:c,theRestUrl:"dist/zonos-elements/zonos-elements.css"});e("Zonos style css injected!")};P.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(A,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(T.test(t.href)){continue}return t}return null};if(n()){e("Inter font already injected","warn");return}var t=document.head||document.body;var r=document.createElement("link");r.rel="preconnect";r.href=A;t.appendChild(r);var o=document.createElement("link");o.rel="stylesheet";o.href="".concat(A,"/inter/inter.css");t.appendChild(o);e("Zonos font injected!")};P.setupGoogleFont=function(n){var e;void((e=_.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};P.injectSupportGoogleFont=function(n){var t;e("[FONT] injecting ".concat(n));var r=(t=n.match(/family=(.*?):/))===null||t===void 0?void 0:t[1];var o=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(E,'"]'))){var i=document.createElement("link");i.rel="preconnect";i.href=E;o.appendChild(i)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){e("[FONT] ".concat(r," font already injected"),"warn");return}var u=document.createElement("link");u.rel="stylesheet";u.href=n;o.appendChild(u);e("[FONT] ".concat(r," font injected!"))}}}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/elements",
3
- "version": "1.3.134",
3
+ "version": "1.3.135",
4
4
  "description": "Zonos component UI for Stripe elements",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs.js",
@@ -1,4 +0,0 @@
1
- /**
2
- * Attempt to get and override test public credential to window.Zonos.zonosApiKey if needed
3
- */
4
- export declare const overrideWithTestPublicCredential: () => Promise<void>;
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,t,r){function o(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,i){function u(n){try{a(r.next(n))}catch(n){i(n)}}function s(n){try{a(r["throw"](n))}catch(n){i(n)}}function a(n){n.done?t(n.value):o(n.value).then(u,s)}a((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(n){return function(e){return a([n,e])}}function a(s){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=e.call(n,t)}catch(n){s=[6,n];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-febc72e7.system.js","./p-bb418544.system.js"],(function(n){"use strict";var e,t,r,o,i;return{setters:[function(n){e=n.l;t=n.a;r=n.h},function(e){o=e.s;i=e.c;var t={};t.checkoutHiddenBtnSelector=e.c;t.domesticRedirectedBtnSelector=e.d;n(t)}],execute:function(){var u=this;var s=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(e).origin;var i=t.some((function(n){return o.includes(n)}));var u=r.some((function(n){return o.includes(n)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var a=["jsdelivr","cdnjs","unpkg","vercel"];var c="jsdelivr";var d=function(n){var e=a.indexOf(n);var t=a[e+1];return t||null};var l=function(n){if(!n){return null}var e=new URL(n).searchParams;var t=e.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var f=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var t=l(window.location.href);var r="https://v1.3.134.js.zonos.com";if(!t&&(r.includes("test.")||r.includes("test-"))){return r}if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!t){return null}if(t==="dev-elements"){return"https://dev.elements.zonos.com"}var o="preview.js.zonos.com";var i="https://".concat(t,".").concat(o);e("[ZONOS-WARNING] using '".concat(i,"' for loading elements script"),"warn");void fetch(i).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(i,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var t="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return i};var v="https://js.stripe.com/v3";var m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var p=function(){var n=document.querySelectorAll('script[src^="'.concat(v,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(!m.test(t.src)){continue}return t}return null};var h=null;var y=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var r=document.createElement("script");r.src="".concat(v).concat(e);var o=document.head||document.body;if(!o){t("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}o.appendChild(r);return r};var z=function(n){if(h!==null){return h}h=new Promise((function(e,t){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(w)}if(window.Stripe){e(window.Stripe);return}try{var r=p();if(r&&n){console.warn(w)}else if(!r){r=y(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(n){t(n);return}}));return h};var j=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var g=function(n,e,t){if(n===null){return null}var r=n.apply(undefined,e);j(r,t);return r};var b=Promise.resolve().then((function(){return z(null)}));var O=false;b.catch((function(n){if(!O){console.warn(n)}}));var k=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(u,void 0,void 0,(function(){var e;return __generator(this,(function(t){O=true;e=Date.now();return[2,b.then((function(t){return g(t,n,e)}))]}))}))};var S=function(){return __awaiter(u,void 0,void 0,(function(){var n,o,i,u,s;return __generator(this,(function(a){switch(a.label){case 0:n=window.location.search.includes("zonosTestMode=1");if(!n||!window.Zonos.zonosApiKey){return[2]}e("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("test")){e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2]}return[4,r("/api/get-test-public-credential")];case 1:o=a.sent(),i=o.errors,u=o.json;if(i.length||!u){t("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",i);return[2]}s=u.publicCredential;if(!s){t("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2]}e("[ZONOS - loadZonos] Using test API key: ".concat(s," for test mode"),"info");window.Zonos.zonosApiKey=s;return[2]}}))}))};var N="tempCartUUID";var Z=function(){var n=new URLSearchParams(window.location.search);var e=n.get(N);return e};var U;var _=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=s({loadScriptSrc:n===null||n===void 0?void 0:n.src}),t=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return t}return null}();var R="https://v1.3.134.js.zonos.com";var I=_||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.134";var L="https://unpkg.com/@zonos/elements@1.3.134";var A="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.134";var F="https://rsms.me";var E="https://fonts.googleapis.com";var T=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var P=function(){function n(){}return n}();n("Zonos",P);U=P;P.doneInit=false;P.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);P.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);P._paypalMockResponse=null;P.isBigCommerce=false;P.releaseDate="1732554842941";P.isLegacyCheckout=false;P.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";P.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");P.isNpm=true;P.zonosQaUrl=null;P.zonosQaUrlApi=null;P.version="v".concat("1.3.134");P.modeAlerted=false;P.cartData=null;P.paypal=null;P.getCurrentTimestamp=function(){return(new Date).getTime()};P.zonosController=null;P.init=function(n){return __awaiter(u,void 0,void 0,(function(){var r,u,s,a,c,d,l,v,m,w,p,h;return __generator(this,(function(y){switch(y.label){case 0:r=n.appearance,u=n.checkoutSettings,s=n.currencyConverter,a=n.helloSettings,c=n.onCountryChange,d=n.overrideCurrencyFormat,l=n.storeId,v=n.zonosApiKey;U.cartId=Z();if(U.doneInit){return[2]}e("====== ZONOS DEBUG MODE: on (".concat(U.version,") ======"));U.zonosApiKey=v;U.storeId=l;if(!U.isNpm)return[3,4];e("====== ZONOS LOADING FROM NPM ======");m=f();if(m&&!window.isZonosPreview){e('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(m," ======"),"info");w=document.createElement("script");w.src="".concat(m,"/dist/scripts/zonos.js");document.head.appendChild(w);w.addEventListener("load",(function(){window.Zonos.isNpm=U.isNpm;window.Zonos.isBigCommerce=U.isBigCommerce;window.Zonos.isLegacyCheckout=U.isLegacyCheckout;void window.Zonos.init(n)}));w.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(m))}));window.isZonosPreview=true;return[2]}if(!v&&!U.cartId){t("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!U.cartData&&U.cartId))return[3,2];e("Initialize cart data");return[4,o(U.cartId)];case 1:p=y.sent();if(!p){t("Failed to get cart data");return[2]}U.cartData=p.cartData;U.zonosApiKey=p.zonosApiKey;y.label=2;case 2:return[4,S()];case 3:y.sent();y.label=4;case 4:if(U.cartId&&U.cartData){e("Cart data is available, inject hidden button and trigger checkout");h=document.createElement("button");h.style.display="none";h.id="".concat(i);document.body.appendChild(h)}e("init zonos");U.injectZonosCdn();U.injectZonosCss();U.injectFonts();U.injectController({config:{appearance:r,checkoutSettings:u,currencyConverter:s,helloSettings:a,onCountryChange:c,overrideCurrencyFormat:d}});U.doneInit=true;return[2]}}))}))};P.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};P.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};P.showNotification=function(n){var e;void((e=U.zonosController)===null||e===void 0?void 0:e.showNotification(n))};P.updateOrganizationName=function(n){var e;void((e=U.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};P.disablePlaceOrderButtons=function(n){var e=n.autoEnable,t=e===void 0?true:e,r=n.config,o=n.disable,i=n.placeOrderButtonSelector;var u;if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var a=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};s.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(o){n.setAttribute("disabled","true");n.addEventListener("click",a)}else{n.removeAttribute("disabled");n.removeEventListener("click",a)}}));if(t&&o){setTimeout((function(){s.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",a)}))}),5e3)}}};P.injectController=function(n){var r=n.config;var o;if(document.querySelector("zonos-controller")){return}if((o=r.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var i=r.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:r,disable:true,placeOrderButtonSelector:i});var s=new MutationObserver((function(){U.disablePlaceOrderButtons({config:r,disable:true,placeOrderButtonSelector:i})}));s.observe(document.body,{childList:true,subtree:true})}var a=document.createElement("zonos-controller");a.config=r;a.zonosApiKey=U.zonosApiKey||"";a.addEventListener("stripeInitEvent",(function(n){return __awaiter(u,void 0,void 0,(function(){var r,o;return __generator(this,(function(i){switch(i.label){case 0:r=n.detail;e("loading Stripe");return[4,k(r.publishableKey)];case 1:o=i.sent();if(!o){t("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void a.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(a);U.zonosController=a;e("Zonos controller injected!")};P.injectScript=function(n){var r=n.cdnType,o=n.isModule,i=n.theRestUrl;var u=U.getZonosUrl(r);var s="".concat(u,"/").concat(i);var a=function(){var n=document.querySelector('script[src="'.concat(s,'"]'));return!!n};if(a()){e('Zonos script "'.concat(s,'" already exists in the document'),"warn");return}var c=document.head||document.body;var l=document.createElement("script");if(!!o){l.type="module"}else{l.noModule=true}l.src=s;l.crossOrigin="anonymous";l.onerror=function(){t("Failed to load ".concat(l.src));var n=d(r);if(!n){return}U.injectScript({cdnType:n,isModule:o,theRestUrl:i})};c.appendChild(l)};P.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return I;case"unpkg":return L;case"cdnjs":return A;case"vercel":return R}};if(U.isNpm){var t=f();return t||e()}return e()};P.injectZonosCdn=function(){U.injectScript({cdnType:c,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});U.injectScript({cdnType:c,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});e("Zonos cdn script injected!")};P.injectStylesheet=function(n){var e=n.cdnType,r=n.theRestUrl;var o=U.getZonosUrl(e);var i=document.head||document.body;var u=document.createElement("link");u.rel="preconnect";u.href="".concat(R,"/");i.appendChild(u);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(o,"/").concat(r);s.onerror=function(){t("Failed to load ".concat(s.href));var n=d(e);if(!n){return}U.injectStylesheet({cdnType:n,theRestUrl:r})};i.appendChild(s)};P.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){e("Zonos style links already injected","warn");return}U.injectStylesheet({cdnType:c,theRestUrl:"dist/zonos-elements/zonos-elements.css"});e("Zonos style css injected!")};P.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(F,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(T.test(t.href)){continue}return t}return null};if(n()){e("Inter font already injected","warn");return}var t=document.head||document.body;var r=document.createElement("link");r.rel="preconnect";r.href=F;t.appendChild(r);var o=document.createElement("link");o.rel="stylesheet";o.href="".concat(F,"/inter/inter.css");t.appendChild(o);e("Zonos font injected!")};P.setupGoogleFont=function(n){var e;void((e=U.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};P.injectSupportGoogleFont=function(n){var t;e("[FONT] injecting ".concat(n));var r=(t=n.match(/family=(.*?):/))===null||t===void 0?void 0:t[1];var o=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(E,'"]'))){var i=document.createElement("link");i.rel="preconnect";i.href=E;o.appendChild(i)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){e("[FONT] ".concat(r," font already injected"),"warn");return}var u=document.createElement("link");u.rel="stylesheet";u.href=n;o.appendChild(u);e("[FONT] ".concat(r," font injected!"))}}}}));