@zonos/elements 1.3.185 → 1.3.187

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.
Files changed (32) hide show
  1. package/dist/cjs/index.cjs.js +7 -7
  2. package/dist/cjs/zonos-address_11.cjs.entry.js +10 -7
  3. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +18 -3
  4. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  5. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +20 -3
  6. package/dist/collection/components/main/zonos-controller.js +2 -2
  7. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +10 -7
  8. package/dist/esm/index.js +7 -7
  9. package/dist/esm/zonos-address_11.entry.js +10 -7
  10. package/dist/esm/zonos-cart-items_13.entry.js +18 -3
  11. package/dist/esm/zonos-controller.entry.js +2 -2
  12. package/dist/esm-es5/index.js +1 -1
  13. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  14. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  15. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  16. package/dist/scripts/index.js +1 -1
  17. package/dist/scripts/loadZonos.js +1 -1
  18. package/dist/scripts/zonos.js +1 -1
  19. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  20. package/dist/zonos-elements/index.esm.js +1 -1
  21. package/dist/zonos-elements/{p-5e15616f.entry.js → p-175e242e.entry.js} +1 -1
  22. package/dist/zonos-elements/{p-991c85f1.system.entry.js → p-25c47bf9.system.entry.js} +1 -1
  23. package/dist/zonos-elements/p-33bdbcfd.entry.js +1 -0
  24. package/dist/zonos-elements/{p-314fbfe1.entry.js → p-36bb3cbb.entry.js} +1 -1
  25. package/dist/zonos-elements/{p-15dd7ea4.system.entry.js → p-6fd6af48.system.entry.js} +1 -1
  26. package/dist/zonos-elements/p-92d83e23.system.entry.js +1 -0
  27. package/dist/zonos-elements/{p-afa34aff.system.js → p-d6a43167.system.js} +1 -1
  28. package/dist/zonos-elements/p-ea6d87a1.system.js +1 -1
  29. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  30. package/package.json +1 -1
  31. package/dist/zonos-elements/p-9a6eb099.entry.js +0 -1
  32. package/dist/zonos-elements/p-a2dab25e.system.entry.js +0 -1
@@ -130,7 +130,7 @@ const getZonosQaUrl = () => {
130
130
  return null;
131
131
  }
132
132
  const qaUrl = extractZonosQaUrl(window.location.href);
133
- const cdnUrl = "https://v1.3.185.js.zonos.com";
133
+ const cdnUrl = "https://v1.3.187.js.zonos.com";
134
134
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
135
135
  if (!qaUrl &&
136
136
  (cdnUrl.includes('test.') ||
@@ -371,10 +371,10 @@ const zonosLoadUrl = (() => {
371
371
  }
372
372
  return null;
373
373
  })();
374
- const ZONOS_URL = "https://v1.3.185.js.zonos.com";
375
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.185";
376
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.185";
377
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.185";
374
+ const ZONOS_URL = "https://v1.3.187.js.zonos.com";
375
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.187";
376
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.187";
377
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.187";
378
378
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
379
379
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
380
380
  class Zonos {
@@ -392,7 +392,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
392
392
  ? new URLSearchParams(window.location.search).get('iframeLogType')
393
393
  : null;
394
394
  Zonos.isBigCommerce = false;
395
- Zonos.releaseDate = "1745528309782";
395
+ Zonos.releaseDate = "1745613545163";
396
396
  Zonos.isLegacyCheckout = false;
397
397
  Zonos.domain = typeof window !== 'undefined'
398
398
  ? // domain that embeds the iframe
@@ -410,7 +410,7 @@ Zonos.isNpm = true;
410
410
  Zonos.zonosQaUrl = null;
411
411
  Zonos.zonosQaUrlApi = null;
412
412
  Zonos.trackEventLogs = [];
413
- Zonos.version = `v${"1.3.185"}`;
413
+ Zonos.version = `v${"1.3.187"}`;
414
414
  Zonos.modeAlerted = false;
415
415
  Zonos.cartData = null;
416
416
  Zonos.paypal = null;
@@ -825,11 +825,12 @@ const ZonosAddress = class {
825
825
  : cart.stripeStore.customBillingAddressErrors;
826
826
  };
827
827
  this.validate = ({ phoneValidateInfo, type, value, valueType, }) => {
828
- var _a, _b, _c;
828
+ var _a, _b, _c, _d, _e;
829
829
  const customErrors = Object.assign({}, this.getCustomAddressErrors());
830
830
  switch (valueType) {
831
831
  case 'city': {
832
- const isValid = ((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
832
+ const isValid = !((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) ||
833
+ (((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim()));
833
834
  customErrors.city = '';
834
835
  if (!isValid) {
835
836
  customErrors.city = cart.translate('The field is incomplete');
@@ -837,7 +838,8 @@ const ZonosAddress = class {
837
838
  break;
838
839
  }
839
840
  case 'state': {
840
- const isValid = ((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
841
+ const isValid = !((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.stateRequired) ||
842
+ (((_d = this.countryField) === null || _d === void 0 ? void 0 : _d.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim()));
841
843
  customErrors.state = '';
842
844
  if (!isValid) {
843
845
  customErrors.state = cart.translate('The field is incomplete');
@@ -852,7 +854,7 @@ const ZonosAddress = class {
852
854
  customErrors.postalCode = '';
853
855
  if (!isValid) {
854
856
  customErrors.postalCode = cart.translate('Your [zipLabel] is invalid', {
855
- zipLabel: ((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.zipLabel) || 'ZIP',
857
+ zipLabel: ((_e = this.countryField) === null || _e === void 0 ? void 0 : _e.zipLabel) || 'ZIP',
856
858
  });
857
859
  }
858
860
  break;
@@ -1196,7 +1198,8 @@ const ZonosAddress = class {
1196
1198
  this.setFormValues({
1197
1199
  city: city,
1198
1200
  country: country,
1199
- line1: addressLine1 || subtituteAddressLine1,
1201
+ // Use the address line 1 from the address suggestion if it's available, otherwise use the address line 1 from the custom address form that the user has entered
1202
+ line1: addressLine1 || subtituteAddressLine1 || this.line1,
1200
1203
  line2: addressLine2,
1201
1204
  postal_code: postalCode,
1202
1205
  state: state,
@@ -1501,10 +1504,10 @@ const ZonosAddress = class {
1501
1504
  this.country = cart.localizationStore.selectedCountryCode;
1502
1505
  }
1503
1506
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
1504
- return (index.h(index.Host, { key: '9460547ea10813bdd211ed19c01ece0a8ec07a41', class: classes.classes([
1507
+ return (index.h(index.Host, { key: '9e681487105fcb1b24173a72d491d874b66a51bb', class: classes.classes([
1505
1508
  'zonos--address zonos--elements',
1506
1509
  `zonos--${this.type}-address`,
1507
- ]) }, index.h("zonos-text", { key: '700b00ddfd9eb1ec55370c9a3d7e69dcb6bc9668', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
1510
+ ]) }, index.h("zonos-text", { key: '4712893040c7b88590048c0d1d636fa331cdcc66', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
1508
1511
  }
1509
1512
  get el() { return index.getElement(this); }
1510
1513
  static get watchers() { return {
@@ -2450,10 +2450,25 @@ const ZonosCustomerInfo = class {
2450
2450
  }
2451
2451
  // Only use the default address for shipping address
2452
2452
  const defaultAddress = type === 'shipping' ? this.defaultAddress : [];
2453
- // Render custom address component if the custom address form is enabled
2454
- if (cart.localizationStore.selectedCountryCode &&
2453
+ const shouldUseCustomAddressForm = cart.localizationStore.selectedCountryCode &&
2455
2454
  this.shouldEnabledCustomAddress &&
2456
- ((_b = (_a = zonosStore.zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryCustomAddressEnabled) === null || _b === void 0 ? void 0 : _b.includes(cart.localizationStore.selectedCountryCode))) {
2455
+ ((_b = (_a = zonosStore.zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryCustomAddressEnabled) === null || _b === void 0 ? void 0 : _b.includes(cart.localizationStore.selectedCountryCode));
2456
+ if (type === 'shipping' && cart.cartStore.checkoutSessionId) {
2457
+ void handleFetch.handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
2458
+ body: {
2459
+ id: cart.cartStore.checkoutSessionId,
2460
+ metadata: [
2461
+ {
2462
+ key: 'ZONOS_FORM_TYPE_USING',
2463
+ value: shouldUseCustomAddressForm ? 'custom' : 'stripe',
2464
+ },
2465
+ ],
2466
+ },
2467
+ method: 'POST',
2468
+ });
2469
+ }
2470
+ // Render custom address component if the custom address form is enabled
2471
+ if (shouldUseCustomAddressForm) {
2457
2472
  return (index.h("zonos-custom-address", { defaultAddress: defaultAddress, titleText: cart.translate('Address'), type: type }));
2458
2473
  }
2459
2474
  // Render Stripe address component by default
@@ -495,7 +495,7 @@ const ZonosController = class {
495
495
  // init checkout address service
496
496
  zonosStore.zonosStore.checkoutAddressService = new CheckoutAddressService();
497
497
  },
498
- src: `${"https://route.js.zonos.com"}/iframe/google-maps?signedToken=${signedPayload}`,
498
+ src: `${"https://route.elements.zonos.com"}/iframe/google-maps?signedToken=${signedPayload}`,
499
499
  });
500
500
  }
501
501
  async componentWillLoad() {
@@ -634,7 +634,7 @@ const ZonosController = class {
634
634
  zonosStore.zonosStore.organizationName = organizationName;
635
635
  }
636
636
  render() {
637
- return index.h(index.Host, { key: '44123a5f1c76f9bb6309aaf1f72defc9dad729ce', class: "zonos--elements" });
637
+ return index.h(index.Host, { key: '525180de311aea6ffaf2ecaa3fc35befd6bd9142', class: "zonos--elements" });
638
638
  }
639
639
  };
640
640
  ZonosController.style = ZonosControllerStyle0;
@@ -1,9 +1,11 @@
1
1
  import { h, Host, } from "@stencil/core";
2
+ import { cartStore } from "../../../store/checkout/cart";
2
3
  import { stripeStore, stripeStoreTranslateAddressToLatin, } from "../../../store/checkout/stripe";
3
4
  import { localizationStore } from "../../../store/hello/localization";
4
5
  import { translate } from "../../../store/translationStore";
5
6
  import { getZonosStoreTheme, zonosStore, } from "../../../store/zonosStore";
6
7
  import { containsNonLatinChars } from "../../../utils/containsNonLatinChars";
8
+ import { handleFetch } from "../../../utils/handleFetch";
7
9
  import { log } from "../../../utils/logging/log";
8
10
  import { sendErrorLog } from "../../../utils/logging/sendErrorLog";
9
11
  import { taxIdValidationResult } from "../../../utils/taxIdValidationResult";
@@ -211,10 +213,25 @@ export class ZonosCustomerInfo {
211
213
  }
212
214
  // Only use the default address for shipping address
213
215
  const defaultAddress = type === 'shipping' ? this.defaultAddress : [];
214
- // Render custom address component if the custom address form is enabled
215
- if (localizationStore.selectedCountryCode &&
216
+ const shouldUseCustomAddressForm = localizationStore.selectedCountryCode &&
216
217
  this.shouldEnabledCustomAddress &&
217
- ((_b = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryCustomAddressEnabled) === null || _b === void 0 ? void 0 : _b.includes(localizationStore.selectedCountryCode))) {
218
+ ((_b = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryCustomAddressEnabled) === null || _b === void 0 ? void 0 : _b.includes(localizationStore.selectedCountryCode));
219
+ if (type === 'shipping' && cartStore.checkoutSessionId) {
220
+ void handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
221
+ body: {
222
+ id: cartStore.checkoutSessionId,
223
+ metadata: [
224
+ {
225
+ key: 'ZONOS_FORM_TYPE_USING',
226
+ value: shouldUseCustomAddressForm ? 'custom' : 'stripe',
227
+ },
228
+ ],
229
+ },
230
+ method: 'POST',
231
+ });
232
+ }
233
+ // Render custom address component if the custom address form is enabled
234
+ if (shouldUseCustomAddressForm) {
218
235
  return (h("zonos-custom-address", { defaultAddress: defaultAddress, titleText: translate('Address'), type: type }));
219
236
  }
220
237
  // Render Stripe address component by default
@@ -135,7 +135,7 @@ export class ZonosController {
135
135
  // init checkout address service
136
136
  zonosStore.checkoutAddressService = new CheckoutAddressService();
137
137
  },
138
- src: `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/iframe/google-maps?signedToken=${signedPayload}`,
138
+ src: `${process.env.NEXT_PUBLIC_ZONOS_CLOUDFLARE_URL}/iframe/google-maps?signedToken=${signedPayload}`,
139
139
  });
140
140
  }
141
141
  async componentWillLoad() {
@@ -274,7 +274,7 @@ export class ZonosController {
274
274
  zonosStore.organizationName = organizationName;
275
275
  }
276
276
  render() {
277
- return h(Host, { key: '44123a5f1c76f9bb6309aaf1f72defc9dad729ce', class: "zonos--elements" });
277
+ return h(Host, { key: '525180de311aea6ffaf2ecaa3fc35befd6bd9142', class: "zonos--elements" });
278
278
  }
279
279
  static get is() { return "zonos-controller"; }
280
280
  static get encapsulation() { return "shadow"; }
@@ -95,11 +95,12 @@ export class ZonosAddress {
95
95
  : stripeStore.customBillingAddressErrors;
96
96
  };
97
97
  this.validate = ({ phoneValidateInfo, type, value, valueType, }) => {
98
- var _a, _b, _c;
98
+ var _a, _b, _c, _d, _e;
99
99
  const customErrors = Object.assign({}, this.getCustomAddressErrors());
100
100
  switch (valueType) {
101
101
  case 'city': {
102
- const isValid = ((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
102
+ const isValid = !((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) ||
103
+ (((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim()));
103
104
  customErrors.city = '';
104
105
  if (!isValid) {
105
106
  customErrors.city = translate('The field is incomplete');
@@ -107,7 +108,8 @@ export class ZonosAddress {
107
108
  break;
108
109
  }
109
110
  case 'state': {
110
- const isValid = ((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
111
+ const isValid = !((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.stateRequired) ||
112
+ (((_d = this.countryField) === null || _d === void 0 ? void 0 : _d.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim()));
111
113
  customErrors.state = '';
112
114
  if (!isValid) {
113
115
  customErrors.state = translate('The field is incomplete');
@@ -122,7 +124,7 @@ export class ZonosAddress {
122
124
  customErrors.postalCode = '';
123
125
  if (!isValid) {
124
126
  customErrors.postalCode = translate('Your [zipLabel] is invalid', {
125
- zipLabel: ((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.zipLabel) || 'ZIP',
127
+ zipLabel: ((_e = this.countryField) === null || _e === void 0 ? void 0 : _e.zipLabel) || 'ZIP',
126
128
  });
127
129
  }
128
130
  break;
@@ -466,7 +468,8 @@ export class ZonosAddress {
466
468
  this.setFormValues({
467
469
  city: city,
468
470
  country: country,
469
- line1: addressLine1 || subtituteAddressLine1,
471
+ // Use the address line 1 from the address suggestion if it's available, otherwise use the address line 1 from the custom address form that the user has entered
472
+ line1: addressLine1 || subtituteAddressLine1 || this.line1,
470
473
  line2: addressLine2,
471
474
  postal_code: postalCode,
472
475
  state: state,
@@ -771,10 +774,10 @@ export class ZonosAddress {
771
774
  this.country = localizationStore.selectedCountryCode;
772
775
  }
773
776
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
774
- return (h(Host, { key: '9460547ea10813bdd211ed19c01ece0a8ec07a41', class: classes([
777
+ return (h(Host, { key: '9e681487105fcb1b24173a72d491d874b66a51bb', class: classes([
775
778
  'zonos--address zonos--elements',
776
779
  `zonos--${this.type}-address`,
777
- ]) }, h("zonos-text", { key: '700b00ddfd9eb1ec55370c9a3d7e69dcb6bc9668', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
780
+ ]) }, h("zonos-text", { key: '4712893040c7b88590048c0d1d636fa331cdcc66', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
778
781
  }
779
782
  static get is() { return "zonos-custom-address"; }
780
783
  static get encapsulation() { return "scoped"; }
package/dist/esm/index.js CHANGED
@@ -127,7 +127,7 @@ const getZonosQaUrl = () => {
127
127
  return null;
128
128
  }
129
129
  const qaUrl = extractZonosQaUrl(window.location.href);
130
- const cdnUrl = "https://v1.3.185.js.zonos.com";
130
+ const cdnUrl = "https://v1.3.187.js.zonos.com";
131
131
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
132
132
  if (!qaUrl &&
133
133
  (cdnUrl.includes('test.') ||
@@ -368,10 +368,10 @@ const zonosLoadUrl = (() => {
368
368
  }
369
369
  return null;
370
370
  })();
371
- const ZONOS_URL = "https://v1.3.185.js.zonos.com";
372
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.185";
373
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.185";
374
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.185";
371
+ const ZONOS_URL = "https://v1.3.187.js.zonos.com";
372
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.187";
373
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.187";
374
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.187";
375
375
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
376
376
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
377
377
  class Zonos {
@@ -389,7 +389,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
389
389
  ? new URLSearchParams(window.location.search).get('iframeLogType')
390
390
  : null;
391
391
  Zonos.isBigCommerce = false;
392
- Zonos.releaseDate = "1745528309782";
392
+ Zonos.releaseDate = "1745613545163";
393
393
  Zonos.isLegacyCheckout = false;
394
394
  Zonos.domain = typeof window !== 'undefined'
395
395
  ? // domain that embeds the iframe
@@ -407,7 +407,7 @@ Zonos.isNpm = true;
407
407
  Zonos.zonosQaUrl = null;
408
408
  Zonos.zonosQaUrlApi = null;
409
409
  Zonos.trackEventLogs = [];
410
- Zonos.version = `v${"1.3.185"}`;
410
+ Zonos.version = `v${"1.3.187"}`;
411
411
  Zonos.modeAlerted = false;
412
412
  Zonos.cartData = null;
413
413
  Zonos.paypal = null;
@@ -821,11 +821,12 @@ const ZonosAddress = class {
821
821
  : stripeStore.customBillingAddressErrors;
822
822
  };
823
823
  this.validate = ({ phoneValidateInfo, type, value, valueType, }) => {
824
- var _a, _b, _c;
824
+ var _a, _b, _c, _d, _e;
825
825
  const customErrors = Object.assign({}, this.getCustomAddressErrors());
826
826
  switch (valueType) {
827
827
  case 'city': {
828
- const isValid = ((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
828
+ const isValid = !((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) ||
829
+ (((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim()));
829
830
  customErrors.city = '';
830
831
  if (!isValid) {
831
832
  customErrors.city = translate('The field is incomplete');
@@ -833,7 +834,8 @@ const ZonosAddress = class {
833
834
  break;
834
835
  }
835
836
  case 'state': {
836
- const isValid = ((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
837
+ const isValid = !((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.stateRequired) ||
838
+ (((_d = this.countryField) === null || _d === void 0 ? void 0 : _d.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim()));
837
839
  customErrors.state = '';
838
840
  if (!isValid) {
839
841
  customErrors.state = translate('The field is incomplete');
@@ -848,7 +850,7 @@ const ZonosAddress = class {
848
850
  customErrors.postalCode = '';
849
851
  if (!isValid) {
850
852
  customErrors.postalCode = translate('Your [zipLabel] is invalid', {
851
- zipLabel: ((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.zipLabel) || 'ZIP',
853
+ zipLabel: ((_e = this.countryField) === null || _e === void 0 ? void 0 : _e.zipLabel) || 'ZIP',
852
854
  });
853
855
  }
854
856
  break;
@@ -1192,7 +1194,8 @@ const ZonosAddress = class {
1192
1194
  this.setFormValues({
1193
1195
  city: city,
1194
1196
  country: country,
1195
- line1: addressLine1 || subtituteAddressLine1,
1197
+ // Use the address line 1 from the address suggestion if it's available, otherwise use the address line 1 from the custom address form that the user has entered
1198
+ line1: addressLine1 || subtituteAddressLine1 || this.line1,
1196
1199
  line2: addressLine2,
1197
1200
  postal_code: postalCode,
1198
1201
  state: state,
@@ -1497,10 +1500,10 @@ const ZonosAddress = class {
1497
1500
  this.country = localizationStore.selectedCountryCode;
1498
1501
  }
1499
1502
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
1500
- return (h(Host, { key: '9460547ea10813bdd211ed19c01ece0a8ec07a41', class: classes([
1503
+ return (h(Host, { key: '9e681487105fcb1b24173a72d491d874b66a51bb', class: classes([
1501
1504
  'zonos--address zonos--elements',
1502
1505
  `zonos--${this.type}-address`,
1503
- ]) }, h("zonos-text", { key: '700b00ddfd9eb1ec55370c9a3d7e69dcb6bc9668', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
1506
+ ]) }, h("zonos-text", { key: '4712893040c7b88590048c0d1d636fa331cdcc66', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
1504
1507
  }
1505
1508
  get el() { return getElement(this); }
1506
1509
  static get watchers() { return {
@@ -2446,10 +2446,25 @@ const ZonosCustomerInfo = class {
2446
2446
  }
2447
2447
  // Only use the default address for shipping address
2448
2448
  const defaultAddress = type === 'shipping' ? this.defaultAddress : [];
2449
- // Render custom address component if the custom address form is enabled
2450
- if (localizationStore.selectedCountryCode &&
2449
+ const shouldUseCustomAddressForm = localizationStore.selectedCountryCode &&
2451
2450
  this.shouldEnabledCustomAddress &&
2452
- ((_b = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryCustomAddressEnabled) === null || _b === void 0 ? void 0 : _b.includes(localizationStore.selectedCountryCode))) {
2451
+ ((_b = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryCustomAddressEnabled) === null || _b === void 0 ? void 0 : _b.includes(localizationStore.selectedCountryCode));
2452
+ if (type === 'shipping' && cartStore.checkoutSessionId) {
2453
+ void handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
2454
+ body: {
2455
+ id: cartStore.checkoutSessionId,
2456
+ metadata: [
2457
+ {
2458
+ key: 'ZONOS_FORM_TYPE_USING',
2459
+ value: shouldUseCustomAddressForm ? 'custom' : 'stripe',
2460
+ },
2461
+ ],
2462
+ },
2463
+ method: 'POST',
2464
+ });
2465
+ }
2466
+ // Render custom address component if the custom address form is enabled
2467
+ if (shouldUseCustomAddressForm) {
2453
2468
  return (h("zonos-custom-address", { defaultAddress: defaultAddress, titleText: translate('Address'), type: type }));
2454
2469
  }
2455
2470
  // Render Stripe address component by default
@@ -491,7 +491,7 @@ const ZonosController = class {
491
491
  // init checkout address service
492
492
  zonosStore.checkoutAddressService = new CheckoutAddressService();
493
493
  },
494
- src: `${"https://route.js.zonos.com"}/iframe/google-maps?signedToken=${signedPayload}`,
494
+ src: `${"https://route.elements.zonos.com"}/iframe/google-maps?signedToken=${signedPayload}`,
495
495
  });
496
496
  }
497
497
  async componentWillLoad() {
@@ -630,7 +630,7 @@ const ZonosController = class {
630
630
  zonosStore.organizationName = organizationName;
631
631
  }
632
632
  render() {
633
- return h(Host, { key: '44123a5f1c76f9bb6309aaf1f72defc9dad729ce', class: "zonos--elements" });
633
+ return h(Host, { key: '525180de311aea6ffaf2ecaa3fc35befd6bd9142', class: "zonos--elements" });
634
634
  }
635
635
  };
636
636
  ZonosController.style = ZonosControllerStyle0;
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,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(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=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++;r=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=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-0bc3e118.js";import{g as getIsTestMode,a as getIsStagingMode,l as log,h as handleFetch,b as logError}from"./handleFetch-621e45bc.js";import{_ as _getIsValidCartId,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./TaxId-915ef042.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){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 t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!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:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.185.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};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 e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,c;var u=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){t.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4,handleFetch("/api/zonos-elements/get-cart?".concat(t.toString()),{body:{isTestMode:n,tempCartUUID:u},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:r=e.sent(),i=r.errors,a=r.json,s=r.zonosMode;c=!a||i.length;if(!(c&&l))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:u,retries:l-1})];case 3:if(c){return[2,null]}return[2,Object.assign(Object.assign({},a),{zonosMode:s})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var ZONOS_URL="https://v1.3.185.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.185";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.185";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.185";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;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.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1745528309782";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.overrideUseCustomAddressForm=false;Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.185");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,l,d,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");l=document.createElement("script");l.src="".concat(u,"/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(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_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,setupCartDataWithSettings(_a.cartId)];case 1:d=_.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_a.cartSettings=d.settings;_.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void s.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){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||n()}return n()};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(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){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 e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,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(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=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++;r=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=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-0bc3e118.js";import{g as getIsTestMode,a as getIsStagingMode,l as log,h as handleFetch,b as logError}from"./handleFetch-621e45bc.js";import{_ as _getIsValidCartId,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./TaxId-915ef042.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){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 t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!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:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.187.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};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 e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,c;var u=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){t.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4,handleFetch("/api/zonos-elements/get-cart?".concat(t.toString()),{body:{isTestMode:n,tempCartUUID:u},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:r=e.sent(),i=r.errors,a=r.json,s=r.zonosMode;c=!a||i.length;if(!(c&&l))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:u,retries:l-1})];case 3:if(c){return[2,null]}return[2,Object.assign(Object.assign({},a),{zonosMode:s})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var ZONOS_URL="https://v1.3.187.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.187";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.187";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.187";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;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.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1745613545163";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.overrideUseCustomAddressForm=false;Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.187");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,l,d,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");l=document.createElement("script");l.src="".concat(u,"/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(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_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,setupCartDataWithSettings(_a.cartId)];case 1:d=_.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_a.cartSettings=d.settings;_.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void s.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){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||n()}return n()};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(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){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 e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};