@zonos/elements 1.2.4-alpha.8 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -1
- package/dist/cjs/{cart-90f7c8c0.js → cart-cfa5d5fd.js} +4 -4
- package/dist/cjs/{getBorderRadius-bf4a4276.js → getBorderRadius-c3c63ee6.js} +1 -1
- package/dist/cjs/index.cjs.js +5 -5
- package/dist/cjs/{isDarkColor-ff6ff183.js → isDarkColor-fc8c294a.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-9caf3397.js → localization-4746acf7.js} +2 -2
- package/dist/cjs/{submitGtag-b141b45d.js → submitGtag-ca175427.js} +2 -2
- package/dist/cjs/zonos-address_2.cjs.entry.js +5 -5
- package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
- package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
- package/dist/cjs/zonos-button_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-card_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +9 -15
- package/dist/cjs/zonos-checkout.cjs.entry.js +6 -6
- package/dist/cjs/zonos-controller.cjs.entry.js +14 -8
- package/dist/cjs/zonos-country-flag_4.cjs.entry.js +3 -3
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +8 -5
- package/dist/cjs/zonos-icon.cjs.entry.js +1 -1
- package/dist/cjs/zonos-notification.cjs.entry.js +1 -1
- package/dist/cjs/zonos-payment.cjs.entry.js +5 -5
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-b43ef5db.js → zonosStore-10d1d6ff.js} +0 -8
- package/dist/collection/__tests__/build-utils/urlCheckOne.js +4 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +4 -10
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +6 -3
- package/dist/collection/components/main/zonos-controller.js +35 -8
- package/dist/collection/components/store/zonosStore.js +0 -8
- package/dist/collection/components/utils/api/{getZonosSetting.js → getZonosSettings.js} +2 -2
- package/dist/collection/components/utils/handleFetch.js +1 -1
- package/dist/collection/environment.js +14 -3
- package/dist/collection/scripts/{zonos.js → zonosBase.js} +7 -19
- package/dist/collection/types/generated/graphql.customer.types.js +31 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +9 -0
- package/dist/components/localization.js +1 -1
- package/dist/components/zonos-checkout-finish2.js +5 -10
- package/dist/components/zonos-controller.js +11 -4
- package/dist/components/zonos-hello.js +6 -3
- package/dist/components/zonosStore.js +0 -8
- package/dist/esm/{cart-b439be00.js → cart-d81b92ea.js} +4 -4
- package/dist/esm/{getBorderRadius-178a0a05.js → getBorderRadius-77e97943.js} +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/{isDarkColor-416d6047.js → isDarkColor-69090b29.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-a51ccbc2.js → localization-0c5b29fd.js} +2 -2
- package/dist/esm/{submitGtag-521826a2.js → submitGtag-8a0fbd41.js} +2 -2
- package/dist/esm/zonos-address_2.entry.js +5 -5
- package/dist/esm/zonos-badge.entry.js +1 -1
- package/dist/esm/zonos-banner.entry.js +1 -1
- package/dist/esm/zonos-button_2.entry.js +3 -3
- package/dist/esm/zonos-card_2.entry.js +1 -1
- package/dist/esm/zonos-cart-items_10.entry.js +9 -15
- package/dist/esm/zonos-checkout.entry.js +6 -6
- package/dist/esm/zonos-controller.entry.js +14 -8
- package/dist/esm/zonos-country-flag_4.entry.js +3 -3
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +8 -5
- package/dist/esm/zonos-icon.entry.js +1 -1
- package/dist/esm/zonos-notification.entry.js +1 -1
- package/dist/esm/zonos-payment.entry.js +5 -5
- package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/{zonosStore-61e74f58.js → zonosStore-34f07ee8.js} +0 -8
- package/dist/esm-es5/{cart-b439be00.js → cart-d81b92ea.js} +1 -1
- package/dist/esm-es5/{getBorderRadius-178a0a05.js → getBorderRadius-77e97943.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{isDarkColor-416d6047.js → isDarkColor-69090b29.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{localization-a51ccbc2.js → localization-0c5b29fd.js} +1 -1
- package/dist/esm-es5/{submitGtag-521826a2.js → submitGtag-8a0fbd41.js} +1 -1
- package/dist/esm-es5/zonos-address_2.entry.js +1 -1
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_2.entry.js +1 -1
- package/dist/esm-es5/zonos-card_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-icon.entry.js +1 -1
- package/dist/esm-es5/zonos-notification.entry.js +1 -1
- package/dist/esm-es5/zonos-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-61e74f58.js → zonosStore-34f07ee8.js} +1 -1
- package/dist/scripts/extractZonosQaUrl.js +1 -30
- package/dist/scripts/loadStripe.js +1 -118
- package/dist/scripts/loadZonos.js +1 -565
- package/dist/scripts/stripe.js +1 -126
- package/dist/scripts/zonos.js +1 -565
- package/dist/scripts/zonosBase.js +1 -0
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +2 -3
- package/dist/types/components/main/zonos-controller.d.ts +5 -1
- package/dist/types/components/store/zonosStore.d.ts +1 -3
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/api/{getZonosSetting.d.ts → getZonosSettings.d.ts} +1 -1
- package/dist/types/components.d.ts +6 -2
- package/dist/types/scripts/{zonos.d.ts → zonosBase.d.ts} +6 -3
- package/dist/types/types/checkout/CheckoutConfig.d.ts +3 -2
- package/dist/types/types/generated/graphql.customer.types.d.ts +35 -0
- package/dist/types/types/generated/graphql.customer.types.ts +44 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +34 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +69 -1
- package/dist/types/types/global.d.ts +10 -2
- package/dist/types/types/hello/HelloConfig.d.ts +0 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-1685c8df.js → p-06a332cd.js} +1 -1
- package/dist/zonos-elements/{p-4ed71bd7.entry.js → p-124857ae.entry.js} +1 -1
- package/dist/zonos-elements/{p-e98be2d0.system.entry.js → p-1f494581.system.entry.js} +1 -1
- package/dist/zonos-elements/p-24fbe845.system.js +1 -1
- package/dist/zonos-elements/{p-4846796a.js → p-2b41549a.js} +1 -1
- package/dist/zonos-elements/p-2e1e9074.js +1 -0
- package/dist/zonos-elements/{p-2801d868.entry.js → p-3509ffaa.entry.js} +1 -1
- package/dist/zonos-elements/{p-1d4a970b.entry.js → p-3c8763a7.entry.js} +1 -1
- package/dist/zonos-elements/{p-49f09b91.entry.js → p-3e7444c6.entry.js} +1 -1
- package/dist/zonos-elements/p-436faf98.system.entry.js +1 -0
- package/dist/zonos-elements/{p-55f49f1e.js → p-4b3baf99.js} +1 -1
- package/dist/zonos-elements/{p-a504f64f.system.js → p-5066955b.system.js} +1 -1
- package/dist/zonos-elements/{p-e5ae22a9.system.entry.js → p-53ea93c2.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f367f2fe.system.entry.js → p-5bada106.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5e87609f.entry.js +1 -0
- package/dist/zonos-elements/{p-b85be1ab.system.js → p-7730250d.system.js} +1 -1
- package/dist/zonos-elements/{p-089ba905.js → p-86f22026.js} +1 -1
- package/dist/zonos-elements/{p-a0e36ed3.entry.js → p-88600956.entry.js} +1 -1
- package/dist/zonos-elements/{p-89c210d6.entry.js → p-8b1cb8a4.entry.js} +1 -1
- package/dist/zonos-elements/p-8bd04aaa.entry.js +1 -0
- package/dist/zonos-elements/{p-47390db7.system.entry.js → p-935fa685.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-639396bb.entry.js → p-9c1f19b6.entry.js} +1 -1
- package/dist/zonos-elements/{p-4d93275c.entry.js → p-a063c4b7.entry.js} +1 -1
- package/dist/zonos-elements/p-a174d834.system.js +1 -0
- package/dist/zonos-elements/{p-3c6988d7.js → p-a244579e.js} +1 -1
- package/dist/zonos-elements/{p-24eed2a8.system.js → p-a54d8db3.system.js} +1 -1
- package/dist/zonos-elements/{p-e1f6ab97.entry.js → p-ab00288a.entry.js} +1 -1
- package/dist/zonos-elements/{p-b51de536.system.js → p-ab179c88.system.js} +1 -1
- package/dist/zonos-elements/{p-afe26069.entry.js → p-ad2b4bda.entry.js} +1 -1
- package/dist/zonos-elements/{p-4bee0bff.system.entry.js → p-b3a71ae4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d856a200.system.entry.js → p-b3e034bb.system.entry.js} +1 -1
- package/dist/zonos-elements/p-b7e061e7.entry.js +1 -0
- package/dist/zonos-elements/{p-3cea383b.system.entry.js → p-bb7de2c4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-da060b1c.system.js → p-c1665c4f.system.js} +1 -1
- package/dist/zonos-elements/{p-2f43da39.system.entry.js → p-c1e298d5.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8c5595d9.system.entry.js → p-c520d819.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c9348bb0.system.entry.js → p-ca875e60.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b4601210.system.entry.js → p-ccd1794a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f141519c.system.entry.js → p-daa10b8c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b6148206.entry.js → p-e3bca405.entry.js} +1 -1
- package/dist/zonos-elements/{p-a376a37f.entry.js → p-e58cc024.entry.js} +1 -1
- package/dist/zonos-elements/{p-938803f4.entry.js → p-e6556b0d.entry.js} +1 -1
- package/dist/zonos-elements/{p-d2217f09.system.js → p-ed074fbf.system.js} +1 -1
- package/dist/zonos-elements/{p-560aa686.system.entry.js → p-f1e9b431.system.entry.js} +1 -1
- package/dist/zonos-elements/p-f7b07128.system.entry.js +1 -0
- package/dist/zonos-elements/{p-4a15c5c7.system.entry.js → p-fbc09dae.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +9 -6
- package/dist/collection/types/online-store/OnlineStoreConfig.js +0 -1
- package/dist/types/types/online-store/OnlineStoreConfig.d.ts +0 -3
- package/dist/zonos-elements/p-06fb9d1f.system.entry.js +0 -1
- package/dist/zonos-elements/p-19942abb.system.entry.js +0 -1
- package/dist/zonos-elements/p-494c77a7.entry.js +0 -1
- package/dist/zonos-elements/p-8c48b75e.system.js +0 -1
- package/dist/zonos-elements/p-a3a8b5e7.entry.js +0 -1
- package/dist/zonos-elements/p-e9b832c5.entry.js +0 -1
- package/dist/zonos-elements/p-ff95f098.js +0 -1
|
@@ -1,565 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log = (message, type, ...additionalInfo) => {
|
|
4
|
-
var _a;
|
|
5
|
-
// if type is error and debug is false, do not log
|
|
6
|
-
if (!window.Zonos.debug) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
|
|
10
|
-
if (!loggingIframe) {
|
|
11
|
-
// add a hidden iframe
|
|
12
|
-
loggingIframe = document.createElement('iframe');
|
|
13
|
-
loggingIframe.id = 'zonos---debug-logging-iframe';
|
|
14
|
-
loggingIframe.style.display = 'none';
|
|
15
|
-
loggingIframe.style.opacity = '0';
|
|
16
|
-
loggingIframe.style.position = 'absolute';
|
|
17
|
-
loggingIframe.style.top = '-9999px';
|
|
18
|
-
loggingIframe.style.left = '-9999px';
|
|
19
|
-
loggingIframe.style.width = '1px';
|
|
20
|
-
loggingIframe.style.height = '1px';
|
|
21
|
-
loggingIframe.style.border = 'none';
|
|
22
|
-
loggingIframe.style.overflow = 'hidden';
|
|
23
|
-
loggingIframe.style.visibility = 'hidden';
|
|
24
|
-
document.body.appendChild(loggingIframe);
|
|
25
|
-
}
|
|
26
|
-
// use the logging iframe's console to log just in case the console is disabled (overriden) by the site owner
|
|
27
|
-
const console = ((_a = loggingIframe.contentWindow) === null || _a === void 0 ? void 0 : _a.window.console) || window.console;
|
|
28
|
-
switch (type) {
|
|
29
|
-
case 'warn':
|
|
30
|
-
// eslint-disable-next-line no-console
|
|
31
|
-
console.warn(message, ...additionalInfo);
|
|
32
|
-
break;
|
|
33
|
-
case 'info':
|
|
34
|
-
// eslint-disable-next-line no-console
|
|
35
|
-
console.info(message, ...additionalInfo);
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
// eslint-disable-next-line no-console
|
|
39
|
-
console.groupCollapsed(message, ...additionalInfo);
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
|
-
console.trace();
|
|
42
|
-
// eslint-disable-next-line no-console
|
|
43
|
-
console.groupEnd();
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const logError = (message, ...rest) => {
|
|
49
|
-
// eslint-disable-next-line no-console
|
|
50
|
-
console.error(message, ...rest);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Extracts the zonosQaUrl from the url
|
|
55
|
-
*
|
|
56
|
-
* @param url - url to extract zonosQaUrl from
|
|
57
|
-
*
|
|
58
|
-
* **NOTE**: value of zonosQaUrl param should be without protocol, allowed characters are: a-z, A-Z, 0-9, -, _
|
|
59
|
-
* @example
|
|
60
|
-
* valid: https://www.zonos.com/?zonosQaUrl=some-feature-v988
|
|
61
|
-
* invalid: https://www.zonos.com/?zonosQaUrl=https://zonos-something
|
|
62
|
-
*/
|
|
63
|
-
const extractZonosQaUrl = (url) => {
|
|
64
|
-
if (!url) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
// get params from url
|
|
68
|
-
const param = new URL(url).searchParams;
|
|
69
|
-
const zonosQaUrl = param.get('zonosQaUrl');
|
|
70
|
-
if (!zonosQaUrl) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
const hasInvalidCharacters = /[^a-zA-Z0-9-_]+/.test(zonosQaUrl);
|
|
74
|
-
if (!!hasInvalidCharacters) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
return zonosQaUrl;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/* eslint-disable no-console */
|
|
81
|
-
/** Loading stripe script extracted from stripe.js repository */
|
|
82
|
-
const V3_URL = 'https://js.stripe.com/v3';
|
|
83
|
-
const V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
84
|
-
const EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
85
|
-
const zonosStripeFindScript = () => {
|
|
86
|
-
const scripts = document.querySelectorAll(`script[src^="${V3_URL}"]`);
|
|
87
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
88
|
-
const script = scripts[i];
|
|
89
|
-
if (!script) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (!V3_URL_REGEX.test(script.src)) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
return script;
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
};
|
|
99
|
-
let stripePromise$1 = null;
|
|
100
|
-
const injectScript = (params) => {
|
|
101
|
-
const queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
|
|
102
|
-
const script = document.createElement('script');
|
|
103
|
-
script.src = `${V3_URL}${queryString}`;
|
|
104
|
-
const headBody = document.head || document.body;
|
|
105
|
-
if (!headBody) {
|
|
106
|
-
logError('Expected document.body not to be null. Stripe.js requires a <body> element.');
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
headBody.appendChild(script);
|
|
110
|
-
return script;
|
|
111
|
-
};
|
|
112
|
-
const zonosStripeLoadScript = (params) => {
|
|
113
|
-
// Ensure that we only attempt to load Stripe.js at most once
|
|
114
|
-
if (stripePromise$1 !== null) {
|
|
115
|
-
return stripePromise$1;
|
|
116
|
-
}
|
|
117
|
-
stripePromise$1 = new Promise((resolve, reject) => {
|
|
118
|
-
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
119
|
-
// Resolve to null when imported server side. This makes the module
|
|
120
|
-
// safe to import in an isomorphic code base.
|
|
121
|
-
resolve(null);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (window.Stripe && params) {
|
|
125
|
-
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
126
|
-
}
|
|
127
|
-
if (window.Stripe) {
|
|
128
|
-
resolve(window.Stripe);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
let script = zonosStripeFindScript();
|
|
133
|
-
if (script && params) {
|
|
134
|
-
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
135
|
-
}
|
|
136
|
-
else if (!script) {
|
|
137
|
-
script = injectScript(params);
|
|
138
|
-
}
|
|
139
|
-
script === null || script === void 0 ? void 0 : script.addEventListener('load', () => {
|
|
140
|
-
if (window.Stripe) {
|
|
141
|
-
resolve(window.Stripe);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
reject(new Error('Stripe.js not available'));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
script === null || script === void 0 ? void 0 : script.addEventListener('error', () => {
|
|
148
|
-
reject(new Error('Failed to load Stripe.js'));
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
reject(error);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return stripePromise$1;
|
|
157
|
-
};
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
-
const registerWrapper = (stripe, startTime) => {
|
|
160
|
-
if (!stripe || !stripe._registerWrapper) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
stripe._registerWrapper({ name: 'stripe-js', startTime });
|
|
164
|
-
};
|
|
165
|
-
const initStripe = (maybeStripe, args, startTime) => {
|
|
166
|
-
if (maybeStripe === null) {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
const stripe = maybeStripe.apply(undefined, args);
|
|
170
|
-
registerWrapper(stripe, startTime);
|
|
171
|
-
return stripe;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// Execute our own script injection after a tick to give users time to do their
|
|
175
|
-
// own script injection.
|
|
176
|
-
const stripePromise = Promise.resolve().then(() => zonosStripeLoadScript(null));
|
|
177
|
-
let loadCalled = false;
|
|
178
|
-
stripePromise.catch((err) => {
|
|
179
|
-
if (!loadCalled) {
|
|
180
|
-
// eslint-disable-next-line no-console
|
|
181
|
-
console.warn(err);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
const zonosLoadStripe = async (...args) => {
|
|
185
|
-
loadCalled = true;
|
|
186
|
-
const startTime = Date.now();
|
|
187
|
-
return stripePromise.then(maybeStripe => initStripe(maybeStripe, args, startTime));
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
var _a;
|
|
191
|
-
const zonosQaUrl = (() => {
|
|
192
|
-
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
193
|
-
if (!qaUrl) {
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
196
|
-
const suffixDomain = 'preview.js.zonos.com';
|
|
197
|
-
const fullUrl = `https://${qaUrl}.${suffixDomain}`;
|
|
198
|
-
// eslint-disable-next-line no-console
|
|
199
|
-
console.warn(`[ZONOS-WARNING] using '${fullUrl}' for loading script`);
|
|
200
|
-
// request to the url and check if the request has an error
|
|
201
|
-
void fetch(fullUrl)
|
|
202
|
-
.then(() => {
|
|
203
|
-
// cleanup checkout session to avoid using the prod session in preview domain
|
|
204
|
-
window.sessionStorage.removeItem('zonos--checkout-session-id');
|
|
205
|
-
window.sessionStorage.removeItem('zonos--client-secret');
|
|
206
|
-
})
|
|
207
|
-
.catch(() => {
|
|
208
|
-
// eslint-disable-next-line no-console
|
|
209
|
-
alert(`[ZONOS-WARNING] '${fullUrl}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);
|
|
210
|
-
// remove the zonosQaUrl param from url
|
|
211
|
-
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
212
|
-
urlSearchParams.delete('zonosQaUrl');
|
|
213
|
-
const { pathname } = window.location;
|
|
214
|
-
const newUrl = `${pathname}?${urlSearchParams.toString()}`;
|
|
215
|
-
window.history.replaceState({}, '', newUrl);
|
|
216
|
-
window.location.reload();
|
|
217
|
-
return null;
|
|
218
|
-
});
|
|
219
|
-
return fullUrl;
|
|
220
|
-
})();
|
|
221
|
-
const ZONOS_URL = zonosQaUrl || "https://v1.2.4-alpha.8.js.zonos.com";
|
|
222
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.4-alpha.8";
|
|
223
|
-
const INTER_FONT_URL = 'https://rsms.me';
|
|
224
|
-
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
225
|
-
const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
|
|
226
|
-
class Zonos {
|
|
227
|
-
}
|
|
228
|
-
_a = Zonos;
|
|
229
|
-
Zonos.doneInit = false;
|
|
230
|
-
// if query 'zonosDebug=1' param from url, debug mode is on
|
|
231
|
-
Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
232
|
-
Zonos.isBigCommerce = false;
|
|
233
|
-
Zonos.internationalHideSelector = '';
|
|
234
|
-
Zonos.zonosQaUrl = zonosQaUrl;
|
|
235
|
-
Zonos.version = `v${"1.2.4-alpha.8"}`;
|
|
236
|
-
Zonos.modeAlerted = false;
|
|
237
|
-
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
238
|
-
Zonos.zonosController = null;
|
|
239
|
-
Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }) => {
|
|
240
|
-
if (_a.doneInit) {
|
|
241
|
-
// do nothing if zonos is already initializeds
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
log(`====== ZONOS DEBUG MODE: on (${_a.version}) ======`);
|
|
245
|
-
if (!zonosApiKey) {
|
|
246
|
-
logError('Missing Zonos API key');
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
_a.zonosApiKey = zonosApiKey;
|
|
250
|
-
log('init zonos');
|
|
251
|
-
// add sentry to the project
|
|
252
|
-
_a.injectSentryScript();
|
|
253
|
-
// inject zonos cdn
|
|
254
|
-
_a.injectZonosCdn();
|
|
255
|
-
// inject css for zonos elements
|
|
256
|
-
_a.injectZonosCss();
|
|
257
|
-
// inject fonts for zonos elements
|
|
258
|
-
_a.injectFonts();
|
|
259
|
-
// init zonos controller
|
|
260
|
-
_a.injectController({
|
|
261
|
-
config: {
|
|
262
|
-
appearance,
|
|
263
|
-
checkoutSettings,
|
|
264
|
-
currencyConverter,
|
|
265
|
-
helloSettings,
|
|
266
|
-
},
|
|
267
|
-
zonosApiKey,
|
|
268
|
-
});
|
|
269
|
-
_a.doneInit = true;
|
|
270
|
-
};
|
|
271
|
-
Zonos.displayCurrency = () => {
|
|
272
|
-
const zonosHello = document.querySelector('zonos-hello');
|
|
273
|
-
if (zonosHello) {
|
|
274
|
-
void zonosHello.displayCurrency();
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
Zonos.showNotification = (notification) => {
|
|
278
|
-
var _b;
|
|
279
|
-
void ((_b = _a.zonosController) === null || _b === void 0 ? void 0 : _b.showNotification(notification));
|
|
280
|
-
};
|
|
281
|
-
Zonos.disablePlaceOrderButtons = ({ autoEnable = true, disable, placeOrderButtonSelector, }) => {
|
|
282
|
-
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
283
|
-
if (placeOrderButtonSelector) {
|
|
284
|
-
const placeOrderButton = document.querySelectorAll(placeOrderButtonSelector);
|
|
285
|
-
const disableEvent = (e) => {
|
|
286
|
-
const target = e.target;
|
|
287
|
-
// prevent default and propagation when the item has disabled attribute
|
|
288
|
-
if (target.getAttribute('disabled')) {
|
|
289
|
-
e.preventDefault();
|
|
290
|
-
e.stopPropagation();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
placeOrderButton.forEach(button => {
|
|
294
|
-
if (disable) {
|
|
295
|
-
button.setAttribute('disabled', 'true');
|
|
296
|
-
// prevent the selector to perform default action when it's disabled
|
|
297
|
-
button.addEventListener('click', disableEvent);
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
button.removeAttribute('disabled');
|
|
301
|
-
// clean up the event listener
|
|
302
|
-
button.removeEventListener('click', disableEvent);
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
// only auto enable if autoEnable is true and we are setting button disable
|
|
306
|
-
if (autoEnable && disable) {
|
|
307
|
-
setTimeout(() => {
|
|
308
|
-
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
309
|
-
placeOrderButton.forEach(button => {
|
|
310
|
-
button.removeAttribute('disabled');
|
|
311
|
-
// clean up the event listener if exists
|
|
312
|
-
button.removeEventListener('click', disableEvent);
|
|
313
|
-
});
|
|
314
|
-
}, 5000);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
Zonos.injectController = ({ config, zonosApiKey, }) => {
|
|
319
|
-
var _b;
|
|
320
|
-
if (document.querySelector('zonos-controller')) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
324
|
-
if ((_b = config.checkoutSettings) === null || _b === void 0 ? void 0 : _b.placeOrderButtonSelector) {
|
|
325
|
-
const placeOrderButtonSelector = config.checkoutSettings.placeOrderButtonSelector;
|
|
326
|
-
_a.disablePlaceOrderButtons({
|
|
327
|
-
disable: true,
|
|
328
|
-
placeOrderButtonSelector,
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
const zonosController = document.createElement('zonos-controller');
|
|
332
|
-
zonosController.config = config;
|
|
333
|
-
zonosController.zonosApiKey = zonosApiKey;
|
|
334
|
-
zonosController.addEventListener('stripeInitEvent', async (event) => {
|
|
335
|
-
const { detail } = event;
|
|
336
|
-
log('loading Stripe');
|
|
337
|
-
const stripe = await zonosLoadStripe(detail.publishableKey);
|
|
338
|
-
if (!stripe) {
|
|
339
|
-
logError('API seems to be invalid or missing. Failed to load Stripe');
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
window.Zonos.stripe = stripe;
|
|
343
|
-
void zonosController.initCheckoutElement(stripe);
|
|
344
|
-
});
|
|
345
|
-
document.body.appendChild(zonosController);
|
|
346
|
-
// set zonos controller to be global
|
|
347
|
-
_a.zonosController = zonosController;
|
|
348
|
-
log('Zonos controller injected!');
|
|
349
|
-
};
|
|
350
|
-
Zonos.injectSentryScript = () => {
|
|
351
|
-
const scriptUrl = 'https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js';
|
|
352
|
-
const findScript = () => {
|
|
353
|
-
const script = document.querySelector(`script[src="${scriptUrl}"]`);
|
|
354
|
-
return !!script;
|
|
355
|
-
};
|
|
356
|
-
if (findScript()) {
|
|
357
|
-
// eslint-disable-next-line no-console
|
|
358
|
-
log('Sentry script already exists in the document', 'warn');
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
const headOrBody = document.head || document.body;
|
|
362
|
-
// init zonos elements when the zonosKey is valid
|
|
363
|
-
// inject esmodule cdn for zonos elements
|
|
364
|
-
const script = document.createElement('script');
|
|
365
|
-
script.crossOrigin = 'anonymous';
|
|
366
|
-
script.src = scriptUrl;
|
|
367
|
-
script.integrity =
|
|
368
|
-
'sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l';
|
|
369
|
-
script.setAttribute('data-lazy', 'no');
|
|
370
|
-
script.onerror = () => {
|
|
371
|
-
logError(`Failed to load ${script.src}`);
|
|
372
|
-
};
|
|
373
|
-
script.onload = () => {
|
|
374
|
-
var _b;
|
|
375
|
-
(_b = window.Sentry) === null || _b === void 0 ? void 0 : _b.init({
|
|
376
|
-
denyUrls: [
|
|
377
|
-
// Facebook flakiness
|
|
378
|
-
/graph\.facebook\.com/i,
|
|
379
|
-
// Facebook blocked
|
|
380
|
-
/connect\.facebook\.net\/en_US\/all\.js/i,
|
|
381
|
-
// Woopra flakiness
|
|
382
|
-
/eatdifferent\.com\.woopra-ns\.com/i,
|
|
383
|
-
/static\.woopra\.com\/js\/woopra\.js/i,
|
|
384
|
-
// Chrome extensions
|
|
385
|
-
/extensions\//i,
|
|
386
|
-
/^chrome:\/\//i,
|
|
387
|
-
/^chrome-extension:\/\//i,
|
|
388
|
-
// Other plugins
|
|
389
|
-
/webappstoolbarba\.texthelp\.com\//i,
|
|
390
|
-
/metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
|
|
391
|
-
/dev.elements.zonos.com/i,
|
|
392
|
-
/js.zonos.com/,
|
|
393
|
-
],
|
|
394
|
-
dsn: 'https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760',
|
|
395
|
-
release: `zonos-elements@${_a.version}`,
|
|
396
|
-
});
|
|
397
|
-
};
|
|
398
|
-
headOrBody.appendChild(script);
|
|
399
|
-
};
|
|
400
|
-
Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) => {
|
|
401
|
-
const fullScriptUrl = `${scriptDomain}/${theRestUrl}`;
|
|
402
|
-
const findScript = () => {
|
|
403
|
-
const script = document.querySelector(`script[src="${fullScriptUrl}"]`);
|
|
404
|
-
return !!script;
|
|
405
|
-
};
|
|
406
|
-
if (findScript()) {
|
|
407
|
-
// eslint-disable-next-line no-console
|
|
408
|
-
log(`Zonos script "${fullScriptUrl}" already exists in the document`, 'warn');
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
const headOrBody = document.head || document.body;
|
|
412
|
-
// init zonos elements when the zonosKey is valid
|
|
413
|
-
// inject esmodule cdn for zonos elements
|
|
414
|
-
const script = document.createElement('script');
|
|
415
|
-
if (!!isModule) {
|
|
416
|
-
script.type = 'module';
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
script.noModule = true;
|
|
420
|
-
}
|
|
421
|
-
script.src = fullScriptUrl;
|
|
422
|
-
script.crossOrigin = 'anonymous';
|
|
423
|
-
script.onerror = () => {
|
|
424
|
-
// only fallback if the stylesheetDomain is versioned. (https://v1.2.3.something.com || https://v1.something.com)
|
|
425
|
-
const isVersioned = /\/\/v\d+\./g.test(scriptDomain);
|
|
426
|
-
if (!isVersioned) {
|
|
427
|
-
log('No need to fallback since this is not a versioned domain', 'warn');
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
if (fallBackDomain) {
|
|
431
|
-
_a.injectScript({
|
|
432
|
-
isModule,
|
|
433
|
-
scriptDomain: fallBackDomain,
|
|
434
|
-
theRestUrl,
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
logError(`Failed to load ${script.src}`);
|
|
438
|
-
};
|
|
439
|
-
headOrBody.appendChild(script);
|
|
440
|
-
};
|
|
441
|
-
Zonos.injectZonosCdn = () => {
|
|
442
|
-
// init zonos elements when the zonosKey is valid
|
|
443
|
-
// inject esmodule cdn for zonos elements
|
|
444
|
-
_a.injectScript({
|
|
445
|
-
fallBackDomain: UNPKG_ZONOS_URL,
|
|
446
|
-
isModule: true,
|
|
447
|
-
scriptDomain: ZONOS_URL,
|
|
448
|
-
theRestUrl: 'dist/zonos-elements/zonos-elements.esm.js',
|
|
449
|
-
});
|
|
450
|
-
// inject non module cdn for zonos elements
|
|
451
|
-
_a.injectScript({
|
|
452
|
-
fallBackDomain: UNPKG_ZONOS_URL,
|
|
453
|
-
isModule: false,
|
|
454
|
-
scriptDomain: ZONOS_URL,
|
|
455
|
-
theRestUrl: 'dist/zonos-elements/zonos-elements.js',
|
|
456
|
-
});
|
|
457
|
-
// eslint-disable-next-line no-console
|
|
458
|
-
log('Zonos cdn script injected!');
|
|
459
|
-
};
|
|
460
|
-
Zonos.injectStylesheet = ({ fallBackDomain, stylesheetDomain, theRestUrl, }) => {
|
|
461
|
-
const headOrBody = document.head || document.body;
|
|
462
|
-
// inject preconnect css for zonos elements
|
|
463
|
-
const zonosCssPreconnect = document.createElement('link');
|
|
464
|
-
zonosCssPreconnect.rel = 'preconnect';
|
|
465
|
-
zonosCssPreconnect.href = `${ZONOS_URL}/`;
|
|
466
|
-
headOrBody.appendChild(zonosCssPreconnect);
|
|
467
|
-
// inject css for zonos elements
|
|
468
|
-
const zonosCss = document.createElement('link');
|
|
469
|
-
zonosCss.rel = 'stylesheet';
|
|
470
|
-
zonosCss.href = `${stylesheetDomain}/${theRestUrl}`;
|
|
471
|
-
zonosCss.onerror = () => {
|
|
472
|
-
// only fallback if the stylesheetDomain is versioned. (https://v1.2.3.something.com || https://v1.something.com)
|
|
473
|
-
const isVersioned = /\/\/v\d+\./g.test(stylesheetDomain);
|
|
474
|
-
if (!isVersioned) {
|
|
475
|
-
log('No need to fallback since this is not a versioned domain', 'warn');
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
if (fallBackDomain && isVersioned) {
|
|
479
|
-
_a.injectStylesheet({
|
|
480
|
-
stylesheetDomain: fallBackDomain,
|
|
481
|
-
theRestUrl,
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
logError(`Failed to load ${zonosCss.href}`);
|
|
485
|
-
};
|
|
486
|
-
headOrBody.appendChild(zonosCss);
|
|
487
|
-
};
|
|
488
|
-
Zonos.injectZonosCss = () => {
|
|
489
|
-
const findStyleLink = () => {
|
|
490
|
-
return !!document.querySelector(`link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]`);
|
|
491
|
-
};
|
|
492
|
-
if (findStyleLink()) {
|
|
493
|
-
log('Zonos style links already injected', 'warn');
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
// inject css for zonos elements
|
|
497
|
-
_a.injectStylesheet({
|
|
498
|
-
fallBackDomain: UNPKG_ZONOS_URL,
|
|
499
|
-
stylesheetDomain: ZONOS_URL,
|
|
500
|
-
theRestUrl: 'dist/zonos-elements/zonos-elements.css',
|
|
501
|
-
});
|
|
502
|
-
log('Zonos style css injected!');
|
|
503
|
-
};
|
|
504
|
-
Zonos.injectFonts = () => {
|
|
505
|
-
const findFont = () => {
|
|
506
|
-
const links = document.querySelectorAll(`link[rel="stylesheet"][href^="${INTER_FONT_URL}"]`);
|
|
507
|
-
for (let i = 0; i < links.length; i++) {
|
|
508
|
-
const link = links[i];
|
|
509
|
-
if (!link) {
|
|
510
|
-
continue;
|
|
511
|
-
}
|
|
512
|
-
if (INTER_FONT_REGEX.test(link.href)) {
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
return link;
|
|
516
|
-
}
|
|
517
|
-
return null;
|
|
518
|
-
};
|
|
519
|
-
if (findFont()) {
|
|
520
|
-
log('Inter font already injected', 'warn');
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
const headOrBody = document.head || document.body;
|
|
524
|
-
// inject font css for zonos elements
|
|
525
|
-
const fontPreconnect = document.createElement('link');
|
|
526
|
-
fontPreconnect.rel = 'preconnect';
|
|
527
|
-
fontPreconnect.href = INTER_FONT_URL;
|
|
528
|
-
headOrBody.appendChild(fontPreconnect);
|
|
529
|
-
// inject font css for zonos elements
|
|
530
|
-
const font = document.createElement('link');
|
|
531
|
-
font.rel = 'stylesheet';
|
|
532
|
-
font.href = `${INTER_FONT_URL}/inter/inter.css`;
|
|
533
|
-
headOrBody.appendChild(font);
|
|
534
|
-
log('Zonos font injected!');
|
|
535
|
-
};
|
|
536
|
-
// apply font for zonos elements and inject font if needed
|
|
537
|
-
Zonos.setupGoogleFont = (fontFamily) => {
|
|
538
|
-
var _b;
|
|
539
|
-
void ((_b = _a.zonosController) === null || _b === void 0 ? void 0 : _b.setupGoogleFont(fontFamily));
|
|
540
|
-
};
|
|
541
|
-
// this function is to inject google font to the browser, not apply the font for zonos elements, to apply the font and inject font if needed, use `setupGoogleFont` instead
|
|
542
|
-
Zonos.injectSupportGoogleFont = (fontUrl) => {
|
|
543
|
-
var _b;
|
|
544
|
-
log(`[FONT] injecting ${fontUrl}`);
|
|
545
|
-
const fontFamily = (_b = fontUrl.match(/family=(.*?):/)) === null || _b === void 0 ? void 0 : _b[1];
|
|
546
|
-
const headOrBody = document.head || document.body;
|
|
547
|
-
// inject font css for zonos elements
|
|
548
|
-
if (!document.querySelector(`link[rel="preconnect"][href^="${GOOGLE_FONT_URL}"]`)) {
|
|
549
|
-
const customFontPreconnect = document.createElement('link');
|
|
550
|
-
customFontPreconnect.rel = 'preconnect';
|
|
551
|
-
customFontPreconnect.href = GOOGLE_FONT_URL;
|
|
552
|
-
headOrBody.appendChild(customFontPreconnect);
|
|
553
|
-
}
|
|
554
|
-
if (document.querySelector(`link[rel="stylesheet"][href="${fontUrl}"]`)) {
|
|
555
|
-
log(`[FONT] ${fontFamily} font already injected`, 'warn');
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
const customFont = document.createElement('link');
|
|
559
|
-
customFont.rel = 'stylesheet';
|
|
560
|
-
customFont.href = fontUrl;
|
|
561
|
-
headOrBody.appendChild(customFont);
|
|
562
|
-
log(`[FONT] ${fontFamily} font injected!`);
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
window.Zonos = Zonos;
|
|
1
|
+
(function(){"use strict";"function"==typeof SuppressedError&&SuppressedError;const e=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{return await e.json()}catch(e){if(n)throw e;return o&&console.error(e),null}};const o=async(o,n)=>{const t=(function(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(t=Object.getOwnPropertySymbols(e);s<t.length;s++)o.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(e,t[s])&&(n[t[s]]=e[t[s]])}return n})(n||{},[]),s=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",i=new URL(o);i.searchParams.set("zToken",(function(e){try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));const c=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},t.headers),a=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:s,headers:c,method:r});return(async(o,n)=>{let t;try{t=await fetch(o,n)}catch(e){return e instanceof Error?{errors:[{message:e.message,type:"unknown"}],json:null,response:null}:{errors:[{message:"Fail to fetch",type:"unknown"}],json:null,response:null}}const s=t.headers.get("Zonos-Mode"),r=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&s&&r&&("production"===s&&alert("Please be aware that you are currently operating in the production environment. Any interactions with the customer store, including payments, will be processed as real transactions!"),"test"===s&&alert("For testing payments, you can utilize the test payment information provided at this link: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-test-the-integration"),window.Zonos.modeAlerted=!0),t.ok)return{errors:[],json:await e({response:t}),response:t};const i=t.status.toString();try{const o=await e({response:t,shouldThrow:!0});return{errors:[{message:`${i}: ${JSON.stringify(o)}`,type:i}],json:null,response:t}}catch(e){return{errors:[{message:`${i}: Unknown error`,type:i}],json:null,response:null}}})(i.toString(),a)};var n;class t{}n=t,t.isBigCommerce=!1,t.requested=!1,t.internationalHideSelector="",t.injectZonos=({initConfig:e,url:o,version:t})=>{const s=o.replace("https://","").replace("http://",""),r=document.createElement("script"),i=t&&t<"1.2.5"?"loadZonos.js":"zonos.js";r.src=`https://${s}/dist/scripts/${i}`,r.addEventListener("load",(()=>{n.isBigCommerce||(n.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.internationalHideSelector=n.internationalHideSelector,window.Zonos.isBigCommerce=n.isBigCommerce,window.Zonos.version&&window.Zonos.init(e)})),document.head.appendChild(r)},t.init=async e=>{const t="https://v1.3.2.js.zonos.com",s=document.querySelector('script[src*="/zonos.js"]');if(s||n.requested)return;if(n.requested=!0,!e.storeId)return console.log("[ZONOS] loading latest script since storeId is not provided."),void n.injectZonos({initConfig:e,url:t,version:null});const r=new URL("https://v1.route.js.zonos.com/api/get-store-version");r.searchParams.set("storeId",e.storeId.toString());const{errors:i,json:c}=await o(r.toString()),a=t.replace("https://","").replace("http://","");if(i.length||!c)return void n.injectZonos({initConfig:e,url:t,version:null});const{version:l}=c;if(!s){const o=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>a.includes(e))),t=o?a:`v${l}.js.zonos.com`,s=o?null:l;n.injectZonos({initConfig:e,url:t,version:s})}},window.Zonos=t})();
|