@zonos/elements 1.3.19 → 1.3.20-alpha.0

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 (28) hide show
  1. package/dist/cjs/index.cjs.js +3 -3
  2. package/dist/cjs/zonos-cart-items_11.cjs.entry.js +49 -23
  3. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +1 -1
  4. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +40 -23
  5. package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +2 -2
  6. package/dist/collection/components/utils/checkout/sortServiceLevelOptions.js +9 -0
  7. package/dist/esm/index.js +3 -3
  8. package/dist/esm/zonos-cart-items_11.entry.js +49 -23
  9. package/dist/esm/zonos-shipping-rich-radio.entry.js +1 -1
  10. package/dist/esm-es5/index.js +1 -1
  11. package/dist/esm-es5/zonos-cart-items_11.entry.js +1 -1
  12. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  13. package/dist/scripts/index.d.ts +1 -0
  14. package/dist/scripts/index.js +1 -1
  15. package/dist/scripts/loadZonos.js +1 -1
  16. package/dist/scripts/zonos.js +1 -1
  17. package/dist/types/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.d.ts +1 -0
  18. package/dist/types/components/utils/checkout/sortServiceLevelOptions.d.ts +5 -0
  19. package/dist/zonos-elements/index.esm.js +1 -1
  20. package/dist/zonos-elements/{p-14ff42fe.system.entry.js → p-147d540a.system.entry.js} +1 -1
  21. package/dist/zonos-elements/{p-80442f16.entry.js → p-2fb9388c.entry.js} +1 -1
  22. package/dist/zonos-elements/{p-0d0f9694.system.entry.js → p-b2752239.system.entry.js} +1 -1
  23. package/dist/zonos-elements/p-bd4f72a2.system.js +1 -0
  24. package/dist/zonos-elements/{p-7487ef47.entry.js → p-d545a444.entry.js} +1 -1
  25. package/dist/zonos-elements/p-e0bf9666.system.js +1 -1
  26. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/zonos-elements/p-3db250f7.system.js +0 -1
@@ -236,8 +236,8 @@ const zonosLoadUrl = (() => {
236
236
  }
237
237
  return null;
238
238
  })();
239
- const ZONOS_URL = zonosLoadUrl || "https://v1.3.19.js.zonos.com";
240
- const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.19";
239
+ const ZONOS_URL = zonosLoadUrl || "https://v1.3.20-alpha.0.js.zonos.com";
240
+ const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.0";
241
241
  const INTER_FONT_URL = 'https://rsms.me';
242
242
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
243
243
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -257,7 +257,7 @@ Zonos.isBigCommerce = false;
257
257
  Zonos.isNpm = true;
258
258
  Zonos.internationalHideSelector = '';
259
259
  Zonos.zonosQaUrl = null;
260
- Zonos.version = `v${"1.3.19"}`;
260
+ Zonos.version = `v${"1.3.20-alpha.0"}`;
261
261
  Zonos.modeAlerted = false;
262
262
  Zonos.tempCartData = null;
263
263
  Zonos.getCurrentTimestamp = () => new Date().getTime();
@@ -887,6 +887,16 @@ const ZonosReview = class {
887
887
  };
888
888
  ZonosReview.style = ZonosReviewStyle0;
889
889
 
890
+ /**
891
+ * Sorts service levels with lower cost first
892
+ */
893
+ const sortServiceLevelOptions = (serviceLevels) => {
894
+ const sortedServiceLevels = serviceLevels.sort((a, b) => {
895
+ return a.amount - b.amount;
896
+ });
897
+ return sortedServiceLevels;
898
+ };
899
+
890
900
  const zonosShippingCss = ".sc-zonos-shipping-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-shipping-h *.sc-zonos-shipping{font-family:var(--font-family, Inter), Inter}.sc-zonos-shipping-h img.sc-zonos-shipping{max-width:100%}.sc-zonos-shipping-h dl.sc-zonos-shipping,.sc-zonos-shipping-h dd.sc-zonos-shipping,.sc-zonos-shipping-h h1.sc-zonos-shipping,.sc-zonos-shipping-h h2.sc-zonos-shipping,.sc-zonos-shipping-h h3.sc-zonos-shipping,.sc-zonos-shipping-h h4.sc-zonos-shipping,.sc-zonos-shipping-h h5.sc-zonos-shipping,.sc-zonos-shipping-h h6.sc-zonos-shipping,.sc-zonos-shipping-h hr.sc-zonos-shipping,.sc-zonos-shipping-h figure.sc-zonos-shipping,.sc-zonos-shipping-h p.sc-zonos-shipping,.sc-zonos-shipping-h pre.sc-zonos-shipping{margin:0}.sc-zonos-shipping-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-shipping-h{overflow:hidden;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-shipping-h .zonos--title.sc-zonos-shipping{margin-bottom:24px}.sc-zonos-shipping-h .zonos--shipping-method-title.sc-zonos-shipping{margin-bottom:16px}.sc-zonos-shipping-h .zonos-shipping-rich-radio.sc-zonos-shipping{margin-bottom:24px}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping{margin-bottom:20px;overflow:auto;padding:5px}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar{width:10px}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-shipping-h .zonos--error-banner.sc-zonos-shipping{margin-bottom:16px}.sc-zonos-shipping-h zonos-button.sc-zonos-shipping{-webkit-box-shadow:0 0 1px 0 var(--zonos-elements-gray-600);box-shadow:0 0 1px 0 var(--zonos-elements-gray-600)}.sc-zonos-shipping-h .zonos--group-btn.sc-zonos-shipping{position:-webkit-sticky;position:sticky;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;bottom:0;margin-top:12px;background:var(--primary-color, var(--zonos-elements-gray-0))}.sc-zonos-shipping-h .zonos--group-btn.sc-zonos-shipping zonos-button.sc-zonos-shipping{width:100%}.sc-zonos-shipping-h zonos-banner.sc-zonos-shipping{margin-top:24px}";
891
901
  const ZonosShippingStyle0 = zonosShippingCss;
892
902
 
@@ -935,28 +945,35 @@ const ZonosShipping = class {
935
945
  };
936
946
  this.initServiceLevels = () => {
937
947
  var _a;
938
- this.serviceLevels =
939
- ((_a = cart.cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.flatMap((item) => {
940
- var _a, _b;
941
- const { expectedDate, maxTransit, minTransit } = cart.cartStoreGetShippingTransitInfo(item);
942
- const sublabel = expectedDate
943
- ? `${cart.translate('Expected delivery')} ${expectedDate}`
944
- : '';
945
- const caption = minTransit && maxTransit
946
- ? `(${minTransit}-${maxTransit} ${cart.translate('business days')})`
947
- : '';
948
- const shippingAmount = ((_b = (_a = cart.cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(landedCostItem => { var _a; return ((_a = landedCostItem.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating.id) === item.id; })) === null || _b === void 0 ? void 0 : _b.subtotals.shipping) || 0;
949
- return {
950
- caption,
951
- label: item.displayName,
952
- price: formatCurrency({
953
- amount: shippingAmount,
954
- currency: cart.cartStore.currency,
955
- }),
956
- sublabel,
957
- value: item.id,
958
- };
959
- })) || [];
948
+ const serviceLevels = ((_a = cart.cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.map((item) => {
949
+ var _a;
950
+ const { expectedDate, maxTransit, minTransit } = cart.cartStoreGetShippingTransitInfo(item);
951
+ const sublabel = expectedDate
952
+ ? `${cart.translate('Expected delivery')} ${expectedDate}`
953
+ : '';
954
+ const caption = minTransit && maxTransit
955
+ ? `(${minTransit}-${maxTransit} ${cart.translate('business days')})`
956
+ : '';
957
+ const foundShipmentRating = (_a = cart.cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(landedCostItem => { var _a; return ((_a = landedCostItem.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating.id) === item.id; });
958
+ if (!foundShipmentRating) {
959
+ // exclude shipping method if there is no matching landed cost data
960
+ return null;
961
+ }
962
+ const shippingAmount = foundShipmentRating.subtotals.shipping;
963
+ return {
964
+ amount: shippingAmount,
965
+ caption,
966
+ label: item.displayName,
967
+ price: formatCurrency({
968
+ amount: shippingAmount,
969
+ currency: cart.cartStore.currency,
970
+ }),
971
+ sublabel,
972
+ value: item.id,
973
+ };
974
+ }).filter(Boolean)) || [];
975
+ // sort service level by price
976
+ this.serviceLevels = sortServiceLevelOptions(serviceLevels);
960
977
  };
961
978
  this.continueLoading = false;
962
979
  this.submitBtnColor = undefined;
@@ -970,7 +987,16 @@ const ZonosShipping = class {
970
987
  this.initServiceLevels();
971
988
  const selectedServiceLevel = this.serviceLevels.find(item => { var _a; return item.value === ((_a = cart.cartStore.selectedShippingOption) === null || _a === void 0 ? void 0 : _a.id); }) || null;
972
989
  if (selectedServiceLevel) {
990
+ // keep the selected shipping method
973
991
  this.selectedShippingMethod = selectedServiceLevel;
992
+ return;
993
+ }
994
+ const firstServiceLevel = this.serviceLevels.find(Boolean);
995
+ if (firstServiceLevel) {
996
+ // preselect the first shipping method
997
+ void this.handleRadioSelected({
998
+ detail: firstServiceLevel,
999
+ });
974
1000
  }
975
1001
  }
976
1002
  render() {
@@ -979,7 +1005,7 @@ const ZonosShipping = class {
979
1005
  if (this.showErrorBanner) {
980
1006
  this.showErrorBanner = !this.handleValidate();
981
1007
  }
982
- return (index.h(index.Host, { key: '032c917dd5510a6a5801f0bf86a84bcf4096759e', class: "zonos--shipping zonos--elements" }, index.h("div", { key: 'b5052414ae56dc46908e53a1676acf96701bafa8', class: "zonos--group" }, index.h("zonos-text", { key: '41bb421c0fc620f8373be5453e872e83ad19150e', class: "zonos--title", type: "semiBoldSubheader" }, cart.translate('Delivery options')), this.showErrorBanner && !!((_a = this.serviceLevels) === null || _a === void 0 ? void 0 : _a.length) && (index.h("zonos-banner", { key: '4b0119b9c1991ab31c15220ed26f0eac18c7229e', class: "zonos--error-banner", intent: "error" }, cart.translate('No shipping method selected'))), index.h("zonos-text", { key: '61ea64f33b2b4bd54c4f2c4d273bac9e13d67040', class: "zonos--shipping-method-title", type: "semiBoldLabel" }, cart.translate('Shipping method')), !((_b = this.serviceLevels) === null || _b === void 0 ? void 0 : _b.length) ? (index.h("zonos-banner", { bannerTitle: cart.translate('No shipping methods found - please review and update your address details by selecting the "Customer" tab above. If you continue to encounter issues, contact our support team for assistance.'), intent: "error" })) : (index.h("zonos-shipping-rich-radio", { initialSelectedValue: (_c = this.selectedShippingMethod) === null || _c === void 0 ? void 0 : _c.value, items: this.serviceLevels, onRadioSelected: e => this.handleRadioSelected(e) })), index.h("div", { key: '1908b7445ef7158402882265af8a357f48096937', class: "zonos--group-btn" }, index.h("zonos-button", { key: 'b73ca7298b5c020c237703e4ce1f9b877cb96605', backgroundColor: this.submitBtnColor, loading: this.continueLoading || this.isSelecting, onClick: () => this.continueClickHandler(), size: "lg",
1008
+ return (index.h(index.Host, { key: '7d55ffefe3cb926587a9b2d6617d732b52cf1a82', class: "zonos--shipping zonos--elements" }, index.h("div", { key: 'dfe3d7d7e0be1857a428c7c3dff5a60f45e2c843', class: "zonos--group" }, index.h("zonos-text", { key: 'dccf7b24862e88ee3ab8914b04a4ee02f02324fb', class: "zonos--title", type: "semiBoldSubheader" }, cart.translate('Delivery options')), this.showErrorBanner && !!((_a = this.serviceLevels) === null || _a === void 0 ? void 0 : _a.length) && (index.h("zonos-banner", { key: 'c343522911e886a2365b795a9b95b17acbfa59c8', class: "zonos--error-banner", intent: "error" }, cart.translate('No shipping method selected'))), index.h("zonos-text", { key: '83c873c95e5b7466cfba997a4385ea55771f2571', class: "zonos--shipping-method-title", type: "semiBoldLabel" }, cart.translate('Shipping method')), !((_b = this.serviceLevels) === null || _b === void 0 ? void 0 : _b.length) ? (index.h("zonos-banner", { bannerTitle: cart.translate('No shipping methods found - please review and update your address details by selecting the "Customer" tab above. If you continue to encounter issues, contact our support team for assistance.'), intent: "error" })) : (index.h("zonos-shipping-rich-radio", { initialSelectedValue: (_c = this.selectedShippingMethod) === null || _c === void 0 ? void 0 : _c.value, items: this.serviceLevels, onRadioSelected: e => this.handleRadioSelected(e) })), index.h("div", { key: 'c7dd64a8d84fa04629010d20010e89ea51c3b634', class: "zonos--group-btn" }, index.h("zonos-button", { key: '8d5ec0f9896be564ab659affd578939eff1c62dc', backgroundColor: this.submitBtnColor, loading: this.continueLoading || this.isSelecting, onClick: () => this.continueClickHandler(), size: "lg",
983
1009
  // use primary type when on mobile mode
984
1010
  variant: this.submitBtnType }, cart.translate('Go to payment'))))));
985
1011
  }
@@ -49,7 +49,7 @@ const ZonosShippingRichRadio = class {
49
49
  }
50
50
  render() {
51
51
  var _a;
52
- return (index.h(index.Host, { key: '14a3885f1e1513e9987cb27217cdb8722eab55fa', class: "zonos--shipping-rich-radio zonos--elements", "data-theme": this.theme, style: Object.assign(Object.assign({}, this.getRadioItemStyleVariables()), { '--font-family': zonosStore.zonosStoreFontFamily() }) }, (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(item => {
52
+ return (index.h(index.Host, { key: '48381df130f6021b73c543c7244a71e7b1e8cd05', class: "zonos--shipping-rich-radio zonos--elements", "data-theme": this.theme, style: Object.assign(Object.assign({}, this.getRadioItemStyleVariables()), { '--font-family': zonosStore.zonosStoreFontFamily() }) }, (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(item => {
53
53
  var _a;
54
54
  const selected = ((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.value) === item.value;
55
55
  return (index.h("div", { "aria-hidden": "true", class: classes.classes([
@@ -2,6 +2,7 @@ import { h, Host, } from "@stencil/core";
2
2
  import { cartStore, cartStoreGetShippingTransitInfo, cartStoreUpdateSelectedShippingOption, } from "../../../store/checkout/cart";
3
3
  import { translate } from "../../../store/translationStore";
4
4
  import { trackConversionEvent } from "../../../utils/api/trackConversionEvent";
5
+ import { sortServiceLevelOptions } from "../../../utils/checkout/sortServiceLevelOptions";
5
6
  import { formatCurrency } from "../../../utils/formatCurrency";
6
7
  import { submitGtag } from "../../../utils/submitGtag";
7
8
  export class ZonosShipping {
@@ -47,28 +48,35 @@ export class ZonosShipping {
47
48
  };
48
49
  this.initServiceLevels = () => {
49
50
  var _a;
50
- this.serviceLevels =
51
- ((_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.flatMap((item) => {
52
- var _a, _b;
53
- const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(item);
54
- const sublabel = expectedDate
55
- ? `${translate('Expected delivery')} ${expectedDate}`
56
- : '';
57
- const caption = minTransit && maxTransit
58
- ? `(${minTransit}-${maxTransit} ${translate('business days')})`
59
- : '';
60
- const shippingAmount = ((_b = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(landedCostItem => { var _a; return ((_a = landedCostItem.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating.id) === item.id; })) === null || _b === void 0 ? void 0 : _b.subtotals.shipping) || 0;
61
- return {
62
- caption,
63
- label: item.displayName,
64
- price: formatCurrency({
65
- amount: shippingAmount,
66
- currency: cartStore.currency,
67
- }),
68
- sublabel,
69
- value: item.id,
70
- };
71
- })) || [];
51
+ const serviceLevels = ((_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.map((item) => {
52
+ var _a;
53
+ const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(item);
54
+ const sublabel = expectedDate
55
+ ? `${translate('Expected delivery')} ${expectedDate}`
56
+ : '';
57
+ const caption = minTransit && maxTransit
58
+ ? `(${minTransit}-${maxTransit} ${translate('business days')})`
59
+ : '';
60
+ const foundShipmentRating = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(landedCostItem => { var _a; return ((_a = landedCostItem.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating.id) === item.id; });
61
+ if (!foundShipmentRating) {
62
+ // exclude shipping method if there is no matching landed cost data
63
+ return null;
64
+ }
65
+ const shippingAmount = foundShipmentRating.subtotals.shipping;
66
+ return {
67
+ amount: shippingAmount,
68
+ caption,
69
+ label: item.displayName,
70
+ price: formatCurrency({
71
+ amount: shippingAmount,
72
+ currency: cartStore.currency,
73
+ }),
74
+ sublabel,
75
+ value: item.id,
76
+ };
77
+ }).filter(Boolean)) || [];
78
+ // sort service level by price
79
+ this.serviceLevels = sortServiceLevelOptions(serviceLevels);
72
80
  };
73
81
  this.continueLoading = false;
74
82
  this.submitBtnColor = undefined;
@@ -82,7 +90,16 @@ export class ZonosShipping {
82
90
  this.initServiceLevels();
83
91
  const selectedServiceLevel = this.serviceLevels.find(item => { var _a; return item.value === ((_a = cartStore.selectedShippingOption) === null || _a === void 0 ? void 0 : _a.id); }) || null;
84
92
  if (selectedServiceLevel) {
93
+ // keep the selected shipping method
85
94
  this.selectedShippingMethod = selectedServiceLevel;
95
+ return;
96
+ }
97
+ const firstServiceLevel = this.serviceLevels.find(Boolean);
98
+ if (firstServiceLevel) {
99
+ // preselect the first shipping method
100
+ void this.handleRadioSelected({
101
+ detail: firstServiceLevel,
102
+ });
86
103
  }
87
104
  }
88
105
  render() {
@@ -91,7 +108,7 @@ export class ZonosShipping {
91
108
  if (this.showErrorBanner) {
92
109
  this.showErrorBanner = !this.handleValidate();
93
110
  }
94
- return (h(Host, { key: '032c917dd5510a6a5801f0bf86a84bcf4096759e', class: "zonos--shipping zonos--elements" }, h("div", { key: 'b5052414ae56dc46908e53a1676acf96701bafa8', class: "zonos--group" }, h("zonos-text", { key: '41bb421c0fc620f8373be5453e872e83ad19150e', class: "zonos--title", type: "semiBoldSubheader" }, translate('Delivery options')), this.showErrorBanner && !!((_a = this.serviceLevels) === null || _a === void 0 ? void 0 : _a.length) && (h("zonos-banner", { key: '4b0119b9c1991ab31c15220ed26f0eac18c7229e', class: "zonos--error-banner", intent: "error" }, translate('No shipping method selected'))), h("zonos-text", { key: '61ea64f33b2b4bd54c4f2c4d273bac9e13d67040', class: "zonos--shipping-method-title", type: "semiBoldLabel" }, translate('Shipping method')), !((_b = this.serviceLevels) === null || _b === void 0 ? void 0 : _b.length) ? (h("zonos-banner", { bannerTitle: translate('No shipping methods found - please review and update your address details by selecting the "Customer" tab above. If you continue to encounter issues, contact our support team for assistance.'), intent: "error" })) : (h("zonos-shipping-rich-radio", { initialSelectedValue: (_c = this.selectedShippingMethod) === null || _c === void 0 ? void 0 : _c.value, items: this.serviceLevels, onRadioSelected: e => this.handleRadioSelected(e) })), h("div", { key: '1908b7445ef7158402882265af8a357f48096937', class: "zonos--group-btn" }, h("zonos-button", { key: 'b73ca7298b5c020c237703e4ce1f9b877cb96605', backgroundColor: this.submitBtnColor, loading: this.continueLoading || this.isSelecting, onClick: () => this.continueClickHandler(), size: "lg",
111
+ return (h(Host, { key: '7d55ffefe3cb926587a9b2d6617d732b52cf1a82', class: "zonos--shipping zonos--elements" }, h("div", { key: 'dfe3d7d7e0be1857a428c7c3dff5a60f45e2c843', class: "zonos--group" }, h("zonos-text", { key: 'dccf7b24862e88ee3ab8914b04a4ee02f02324fb', class: "zonos--title", type: "semiBoldSubheader" }, translate('Delivery options')), this.showErrorBanner && !!((_a = this.serviceLevels) === null || _a === void 0 ? void 0 : _a.length) && (h("zonos-banner", { key: 'c343522911e886a2365b795a9b95b17acbfa59c8', class: "zonos--error-banner", intent: "error" }, translate('No shipping method selected'))), h("zonos-text", { key: '83c873c95e5b7466cfba997a4385ea55771f2571', class: "zonos--shipping-method-title", type: "semiBoldLabel" }, translate('Shipping method')), !((_b = this.serviceLevels) === null || _b === void 0 ? void 0 : _b.length) ? (h("zonos-banner", { bannerTitle: translate('No shipping methods found - please review and update your address details by selecting the "Customer" tab above. If you continue to encounter issues, contact our support team for assistance.'), intent: "error" })) : (h("zonos-shipping-rich-radio", { initialSelectedValue: (_c = this.selectedShippingMethod) === null || _c === void 0 ? void 0 : _c.value, items: this.serviceLevels, onRadioSelected: e => this.handleRadioSelected(e) })), h("div", { key: 'c7dd64a8d84fa04629010d20010e89ea51c3b634', class: "zonos--group-btn" }, h("zonos-button", { key: '8d5ec0f9896be564ab659affd578939eff1c62dc', backgroundColor: this.submitBtnColor, loading: this.continueLoading || this.isSelecting, onClick: () => this.continueClickHandler(), size: "lg",
95
112
  // use primary type when on mobile mode
96
113
  variant: this.submitBtnType }, translate('Go to payment'))))));
97
114
  }
@@ -39,7 +39,7 @@ export class ZonosShippingRichRadio {
39
39
  }
40
40
  render() {
41
41
  var _a;
42
- return (h(Host, { key: '14a3885f1e1513e9987cb27217cdb8722eab55fa', class: "zonos--shipping-rich-radio zonos--elements", "data-theme": this.theme, style: Object.assign(Object.assign({}, this.getRadioItemStyleVariables()), { '--font-family': zonosStoreFontFamily() }) }, (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(item => {
42
+ return (h(Host, { key: '48381df130f6021b73c543c7244a71e7b1e8cd05', class: "zonos--shipping-rich-radio zonos--elements", "data-theme": this.theme, style: Object.assign(Object.assign({}, this.getRadioItemStyleVariables()), { '--font-family': zonosStoreFontFamily() }) }, (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(item => {
43
43
  var _a;
44
44
  const selected = ((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.value) === item.value;
45
45
  return (h("div", { "aria-hidden": "true", class: classes([
@@ -189,7 +189,7 @@ export class ZonosShippingRichRadio {
189
189
  },
190
190
  "complexType": {
191
191
  "original": "ShippingRichRadioItem",
192
- "resolved": "{ caption?: string | undefined; label: string; price: string; sublabel?: string | undefined; value: string | number; }",
192
+ "resolved": "{ amount: number; caption?: string | undefined; label: string; price: string; sublabel?: string | undefined; value: string | number; }",
193
193
  "references": {
194
194
  "ShippingRichRadioItem": {
195
195
  "location": "local",
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sorts service levels with lower cost first
3
+ */
4
+ export const sortServiceLevelOptions = (serviceLevels) => {
5
+ const sortedServiceLevels = serviceLevels.sort((a, b) => {
6
+ return a.amount - b.amount;
7
+ });
8
+ return sortedServiceLevels;
9
+ };
package/dist/esm/index.js CHANGED
@@ -232,8 +232,8 @@ const zonosLoadUrl = (() => {
232
232
  }
233
233
  return null;
234
234
  })();
235
- const ZONOS_URL = zonosLoadUrl || "https://v1.3.19.js.zonos.com";
236
- const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.19";
235
+ const ZONOS_URL = zonosLoadUrl || "https://v1.3.20-alpha.0.js.zonos.com";
236
+ const JS_DELIVR_ZONOS_URL = "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.0";
237
237
  const INTER_FONT_URL = 'https://rsms.me';
238
238
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
239
239
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -253,7 +253,7 @@ Zonos.isBigCommerce = false;
253
253
  Zonos.isNpm = true;
254
254
  Zonos.internationalHideSelector = '';
255
255
  Zonos.zonosQaUrl = null;
256
- Zonos.version = `v${"1.3.19"}`;
256
+ Zonos.version = `v${"1.3.20-alpha.0"}`;
257
257
  Zonos.modeAlerted = false;
258
258
  Zonos.tempCartData = null;
259
259
  Zonos.getCurrentTimestamp = () => new Date().getTime();
@@ -883,6 +883,16 @@ const ZonosReview = class {
883
883
  };
884
884
  ZonosReview.style = ZonosReviewStyle0;
885
885
 
886
+ /**
887
+ * Sorts service levels with lower cost first
888
+ */
889
+ const sortServiceLevelOptions = (serviceLevels) => {
890
+ const sortedServiceLevels = serviceLevels.sort((a, b) => {
891
+ return a.amount - b.amount;
892
+ });
893
+ return sortedServiceLevels;
894
+ };
895
+
886
896
  const zonosShippingCss = ".sc-zonos-shipping-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-shipping-h *.sc-zonos-shipping{font-family:var(--font-family, Inter), Inter}.sc-zonos-shipping-h img.sc-zonos-shipping{max-width:100%}.sc-zonos-shipping-h dl.sc-zonos-shipping,.sc-zonos-shipping-h dd.sc-zonos-shipping,.sc-zonos-shipping-h h1.sc-zonos-shipping,.sc-zonos-shipping-h h2.sc-zonos-shipping,.sc-zonos-shipping-h h3.sc-zonos-shipping,.sc-zonos-shipping-h h4.sc-zonos-shipping,.sc-zonos-shipping-h h5.sc-zonos-shipping,.sc-zonos-shipping-h h6.sc-zonos-shipping,.sc-zonos-shipping-h hr.sc-zonos-shipping,.sc-zonos-shipping-h figure.sc-zonos-shipping,.sc-zonos-shipping-h p.sc-zonos-shipping,.sc-zonos-shipping-h pre.sc-zonos-shipping{margin:0}.sc-zonos-shipping-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-shipping-h{overflow:hidden;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-shipping-h .zonos--title.sc-zonos-shipping{margin-bottom:24px}.sc-zonos-shipping-h .zonos--shipping-method-title.sc-zonos-shipping{margin-bottom:16px}.sc-zonos-shipping-h .zonos-shipping-rich-radio.sc-zonos-shipping{margin-bottom:24px}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping{margin-bottom:20px;overflow:auto;padding:5px}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar{width:10px}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-shipping-h .zonos--group.sc-zonos-shipping::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-shipping-h .zonos--error-banner.sc-zonos-shipping{margin-bottom:16px}.sc-zonos-shipping-h zonos-button.sc-zonos-shipping{-webkit-box-shadow:0 0 1px 0 var(--zonos-elements-gray-600);box-shadow:0 0 1px 0 var(--zonos-elements-gray-600)}.sc-zonos-shipping-h .zonos--group-btn.sc-zonos-shipping{position:-webkit-sticky;position:sticky;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;bottom:0;margin-top:12px;background:var(--primary-color, var(--zonos-elements-gray-0))}.sc-zonos-shipping-h .zonos--group-btn.sc-zonos-shipping zonos-button.sc-zonos-shipping{width:100%}.sc-zonos-shipping-h zonos-banner.sc-zonos-shipping{margin-top:24px}";
887
897
  const ZonosShippingStyle0 = zonosShippingCss;
888
898
 
@@ -931,28 +941,35 @@ const ZonosShipping = class {
931
941
  };
932
942
  this.initServiceLevels = () => {
933
943
  var _a;
934
- this.serviceLevels =
935
- ((_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.flatMap((item) => {
936
- var _a, _b;
937
- const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(item);
938
- const sublabel = expectedDate
939
- ? `${translate('Expected delivery')} ${expectedDate}`
940
- : '';
941
- const caption = minTransit && maxTransit
942
- ? `(${minTransit}-${maxTransit} ${translate('business days')})`
943
- : '';
944
- const shippingAmount = ((_b = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(landedCostItem => { var _a; return ((_a = landedCostItem.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating.id) === item.id; })) === null || _b === void 0 ? void 0 : _b.subtotals.shipping) || 0;
945
- return {
946
- caption,
947
- label: item.displayName,
948
- price: formatCurrency({
949
- amount: shippingAmount,
950
- currency: cartStore.currency,
951
- }),
952
- sublabel,
953
- value: item.id,
954
- };
955
- })) || [];
944
+ const serviceLevels = ((_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.map((item) => {
945
+ var _a;
946
+ const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(item);
947
+ const sublabel = expectedDate
948
+ ? `${translate('Expected delivery')} ${expectedDate}`
949
+ : '';
950
+ const caption = minTransit && maxTransit
951
+ ? `(${minTransit}-${maxTransit} ${translate('business days')})`
952
+ : '';
953
+ const foundShipmentRating = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(landedCostItem => { var _a; return ((_a = landedCostItem.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating.id) === item.id; });
954
+ if (!foundShipmentRating) {
955
+ // exclude shipping method if there is no matching landed cost data
956
+ return null;
957
+ }
958
+ const shippingAmount = foundShipmentRating.subtotals.shipping;
959
+ return {
960
+ amount: shippingAmount,
961
+ caption,
962
+ label: item.displayName,
963
+ price: formatCurrency({
964
+ amount: shippingAmount,
965
+ currency: cartStore.currency,
966
+ }),
967
+ sublabel,
968
+ value: item.id,
969
+ };
970
+ }).filter(Boolean)) || [];
971
+ // sort service level by price
972
+ this.serviceLevels = sortServiceLevelOptions(serviceLevels);
956
973
  };
957
974
  this.continueLoading = false;
958
975
  this.submitBtnColor = undefined;
@@ -966,7 +983,16 @@ const ZonosShipping = class {
966
983
  this.initServiceLevels();
967
984
  const selectedServiceLevel = this.serviceLevels.find(item => { var _a; return item.value === ((_a = cartStore.selectedShippingOption) === null || _a === void 0 ? void 0 : _a.id); }) || null;
968
985
  if (selectedServiceLevel) {
986
+ // keep the selected shipping method
969
987
  this.selectedShippingMethod = selectedServiceLevel;
988
+ return;
989
+ }
990
+ const firstServiceLevel = this.serviceLevels.find(Boolean);
991
+ if (firstServiceLevel) {
992
+ // preselect the first shipping method
993
+ void this.handleRadioSelected({
994
+ detail: firstServiceLevel,
995
+ });
970
996
  }
971
997
  }
972
998
  render() {
@@ -975,7 +1001,7 @@ const ZonosShipping = class {
975
1001
  if (this.showErrorBanner) {
976
1002
  this.showErrorBanner = !this.handleValidate();
977
1003
  }
978
- return (h(Host, { key: '032c917dd5510a6a5801f0bf86a84bcf4096759e', class: "zonos--shipping zonos--elements" }, h("div", { key: 'b5052414ae56dc46908e53a1676acf96701bafa8', class: "zonos--group" }, h("zonos-text", { key: '41bb421c0fc620f8373be5453e872e83ad19150e', class: "zonos--title", type: "semiBoldSubheader" }, translate('Delivery options')), this.showErrorBanner && !!((_a = this.serviceLevels) === null || _a === void 0 ? void 0 : _a.length) && (h("zonos-banner", { key: '4b0119b9c1991ab31c15220ed26f0eac18c7229e', class: "zonos--error-banner", intent: "error" }, translate('No shipping method selected'))), h("zonos-text", { key: '61ea64f33b2b4bd54c4f2c4d273bac9e13d67040', class: "zonos--shipping-method-title", type: "semiBoldLabel" }, translate('Shipping method')), !((_b = this.serviceLevels) === null || _b === void 0 ? void 0 : _b.length) ? (h("zonos-banner", { bannerTitle: translate('No shipping methods found - please review and update your address details by selecting the "Customer" tab above. If you continue to encounter issues, contact our support team for assistance.'), intent: "error" })) : (h("zonos-shipping-rich-radio", { initialSelectedValue: (_c = this.selectedShippingMethod) === null || _c === void 0 ? void 0 : _c.value, items: this.serviceLevels, onRadioSelected: e => this.handleRadioSelected(e) })), h("div", { key: '1908b7445ef7158402882265af8a357f48096937', class: "zonos--group-btn" }, h("zonos-button", { key: 'b73ca7298b5c020c237703e4ce1f9b877cb96605', backgroundColor: this.submitBtnColor, loading: this.continueLoading || this.isSelecting, onClick: () => this.continueClickHandler(), size: "lg",
1004
+ return (h(Host, { key: '7d55ffefe3cb926587a9b2d6617d732b52cf1a82', class: "zonos--shipping zonos--elements" }, h("div", { key: 'dfe3d7d7e0be1857a428c7c3dff5a60f45e2c843', class: "zonos--group" }, h("zonos-text", { key: 'dccf7b24862e88ee3ab8914b04a4ee02f02324fb', class: "zonos--title", type: "semiBoldSubheader" }, translate('Delivery options')), this.showErrorBanner && !!((_a = this.serviceLevels) === null || _a === void 0 ? void 0 : _a.length) && (h("zonos-banner", { key: 'c343522911e886a2365b795a9b95b17acbfa59c8', class: "zonos--error-banner", intent: "error" }, translate('No shipping method selected'))), h("zonos-text", { key: '83c873c95e5b7466cfba997a4385ea55771f2571', class: "zonos--shipping-method-title", type: "semiBoldLabel" }, translate('Shipping method')), !((_b = this.serviceLevels) === null || _b === void 0 ? void 0 : _b.length) ? (h("zonos-banner", { bannerTitle: translate('No shipping methods found - please review and update your address details by selecting the "Customer" tab above. If you continue to encounter issues, contact our support team for assistance.'), intent: "error" })) : (h("zonos-shipping-rich-radio", { initialSelectedValue: (_c = this.selectedShippingMethod) === null || _c === void 0 ? void 0 : _c.value, items: this.serviceLevels, onRadioSelected: e => this.handleRadioSelected(e) })), h("div", { key: 'c7dd64a8d84fa04629010d20010e89ea51c3b634', class: "zonos--group-btn" }, h("zonos-button", { key: '8d5ec0f9896be564ab659affd578939eff1c62dc', backgroundColor: this.submitBtnColor, loading: this.continueLoading || this.isSelecting, onClick: () => this.continueClickHandler(), size: "lg",
979
1005
  // use primary type when on mobile mode
980
1006
  variant: this.submitBtnType }, translate('Go to payment'))))));
981
1007
  }
@@ -45,7 +45,7 @@ const ZonosShippingRichRadio = class {
45
45
  }
46
46
  render() {
47
47
  var _a;
48
- return (h(Host, { key: '14a3885f1e1513e9987cb27217cdb8722eab55fa', class: "zonos--shipping-rich-radio zonos--elements", "data-theme": this.theme, style: Object.assign(Object.assign({}, this.getRadioItemStyleVariables()), { '--font-family': zonosStoreFontFamily() }) }, (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(item => {
48
+ return (h(Host, { key: '48381df130f6021b73c543c7244a71e7b1e8cd05', class: "zonos--shipping-rich-radio zonos--elements", "data-theme": this.theme, style: Object.assign(Object.assign({}, this.getRadioItemStyleVariables()), { '--font-family': zonosStoreFontFamily() }) }, (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(item => {
49
49
  var _a;
50
50
  const selected = ((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.value) === item.value;
51
51
  return (h("div", { "aria-hidden": "true", class: classes([
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,o,e,r){function t(n){return n instanceof e?n:new e((function(o){o(n)}))}return new(e||(e=Promise))((function(e,i){function s(n){try{u(r.next(n))}catch(n){i(n)}}function a(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?e(n.value):t(n.value).then(s,a)}u((r=r.apply(n,o||[])).next())}))};var __generator=this&&this.__generator||function(n,o){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(o){return u([n,o])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(e=0)),e)try{if(r=1,t&&(i=a[0]&2?t["return"]:a[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,a[1])).done)return i;if(t=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;t=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){e.label=a[1];break}if(a[0]===6&&e.label<i[1]){e.label=i[1];i=a;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(a);break}if(i[2])e.ops.pop();e.trys.pop();continue}a=o.call(n,e)}catch(n){a=[6,n];t=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{l as log,a as logError}from"./logError-c456c092.js";var checkIfLoadVersionDomain=function(n){var o=n.loadScriptSrc;if(!o){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var e=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(o).origin;var i=e.some((function(n){return t.includes(n)}));var s=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:s,isWhiteListed:i}};var extractZonosQaUrl=function(n){if(!n){return null}var o=new URL(n).searchParams;var e=o.get("zonosQaUrl");if(!e){return null}var r=/[^a-zA-Z0-9-_]+/.test(e);if(!!r){return null}return e};var getZonosQaUrl=function(){if(typeof window==="undefined"){return null}var n=extractZonosQaUrl(window.location.href);if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var o="preview.js.zonos.com";var e="https://".concat(n,".").concat(o);log("[ZONOS-WARNING] using '".concat(e,"' for loading script"),"warn");void fetch(e).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(e,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var o=window.location.pathname;var r="".concat(o,"?").concat(n.toString());window.history.replaceState(window.history.state,"",r);window.location.reload();return null}));return e};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var n=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(!V3_URL_REGEX.test(e.src)){continue}return e}return null};var stripePromise$1=null;var injectScript=function(n){var o=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var e=document.createElement("script");e.src="".concat(V3_URL).concat(o);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(e);return e};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(o,e){if(typeof window==="undefined"||typeof document==="undefined"){o(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){o(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){o(window.Stripe)}else{e(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){e(new Error("Failed to load Stripe.js"))}))}catch(n){e(n);return}}));return stripePromise$1};var registerWrapper=function(n,o){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:o})};var initStripe=function(n,o,e){if(n===null){return null}var r=n.apply(undefined,o);registerWrapper(r,e);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(n){if(!loadCalled){console.warn(n)}}));var zonosLoadStripe=function(){var n=[];for(var o=0;o<arguments.length;o++){n[o]=arguments[o]}return __awaiter(void 0,void 0,void 0,(function(){var o;return __generator(this,(function(e){loadCalled=true;o=Date.now();return[2,stripePromise.then((function(e){return initStripe(e,n,o)}))]}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var o=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),e=o.currentLoadScriptUrl,r=o.isWhiteListed;if(r){return e}return null}();var ZONOS_URL=zonosLoadUrl||"https://v1.3.19.js.zonos.com";var JS_DELIVR_ZONOS_URL="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.19";var INTER_FONT_URL="https://rsms.me";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var INTER_FONT_REGEX=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var Zonos=function(){function n(){}return n}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos.isBigCommerce=false;Zonos.isNpm=true;Zonos.internationalHideSelector="";Zonos.zonosQaUrl=null;Zonos.version="v".concat("1.3.19");Zonos.modeAlerted=false;Zonos.tempCartData=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,[n],void 0,(function(n){var o=n.appearance,e=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,s=n.storeId,a=n.zonosApiKey;return __generator(this,(function(n){if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));if(!a){logError("Missing Zonos API key");return[2]}_a.zonosApiKey=a;_a.storeId=s;log("init zonos");_a.injectSentryScript();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:o,checkoutSettings:e,currencyConverter:r,helloSettings:t,onCountryChange:i},zonosApiKey:a});_a.doneInit=true;return[2]}))}))};Zonos.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};Zonos.openHelloDialog=function(n){var o=document.querySelector("zonos-hello");if(o){void o.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.showNotification(n))};Zonos.updateOrganizationName=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var o=n.autoEnable,e=o===void 0?true:o,r=n.disable,t=n.placeOrderButtonSelector;if(t){var i=document.querySelectorAll(t);var s=function(n){var o=n.target;if(o.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};i.forEach((function(n){var o=n.getAttribute("data-zonos-checkout-attached");if(o){return}if(r){n.setAttribute("disabled","true");n.addEventListener("click",s)}else{n.removeAttribute("disabled");n.removeEventListener("click",s)}}));if(e&&r){setTimeout((function(){i.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",s)}))}),5e3)}}};Zonos.injectController=function(n){var o=n.config,e=n.zonosApiKey;var r;if(document.querySelector("zonos-controller")){return}if((r=o.checkoutSettings)===null||r===void 0?void 0:r.placeOrderButtonSelector){var t=o.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=o;s.zonosApiKey=e;s.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var o,e;return __generator(this,(function(r){switch(r.label){case 0:o=n.detail;log("loading Stripe");return[4,zonosLoadStripe(o.publishableKey)];case 1:e=r.sent();if(!e){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=e;void s.initCheckoutElement(e);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectSentryScript=function(){var n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";var o=function(){var o=document.querySelector('script[src="'.concat(n,'"]'));return!!o};if(o()){log("Sentry script already exists in the document","warn");return}var e=document.head||document.body;var r=document.createElement("script");r.crossOrigin="anonymous";r.src=n;r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l";r.setAttribute("data-lazy","no");r.onerror=function(){logError("Failed to load ".concat(r.src))};r.onload=function(){var n;(n=window.Sentry)===null||n===void 0?void 0:n.init({beforeSend:function(n){var o,e,r,t,i,s;var a=(s=(i=(t=(r=(e=(o=n.exception)===null||o===void 0?void 0:o.values)===null||e===void 0?void 0:e[0])===null||r===void 0?void 0:r.stacktrace)===null||t===void 0?void 0:t.frames)===null||i===void 0?void 0:i[0])===null||s===void 0?void 0:s.filename;var u=(a===null||a===void 0?void 0:a.includes("js.zonos.com"))||(a===null||a===void 0?void 0:a.includes("@zonos/elements"));var l=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");if(u&&!l){return n}return null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:"zonos-elements@".concat(_a.version),tracesSampler:function(){return.01}})};e.appendChild(r)};Zonos.injectScript=function(n){var o=n.fallBackDomain,e=n.isModule,r=n.scriptDomain,t=n.theRestUrl;var i="".concat(r,"/").concat(t);var s=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(s()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var a=document.head||document.body;var u=document.createElement("script");if(!!e){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){var n=/\/\/v\d+\./g.test(r);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o){_a.injectScript({isModule:e,scriptDomain:o,theRestUrl:t})}logError("Failed to load ".concat(u.src))};a.appendChild(u)};Zonos.getZonosUrl=function(){if(_a.isNpm){var n=getZonosQaUrl();return n||ZONOS_URL}return ZONOS_URL};Zonos.injectZonosCdn=function(){var n=_a.getZonosUrl();_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:true,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:false,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var o=n.fallBackDomain,e=n.stylesheetDomain,r=n.theRestUrl;var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(e,"/").concat(r);s.onerror=function(){var n=/\/\/v\d+\./g.test(e);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o&&n){_a.injectStylesheet({stylesheetDomain:o,theRestUrl:r})}logError("Failed to load ".concat(s.href))};t.appendChild(s)};Zonos.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({fallBackDomain:JS_DELIVR_ZONOS_URL,stylesheetDomain:ZONOS_URL,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(INTER_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(INTER_FONT_REGEX.test(e.href)){continue}return e}return null};if(n()){log("Inter font already injected","warn");return}var o=document.head||document.body;var e=document.createElement("link");e.rel="preconnect";e.href=INTER_FONT_URL;o.appendChild(e);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");o.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var o;log("[FONT] injecting ".concat(n));var e=(o=n.match(/family=(.*?):/))===null||o===void 0?void 0:o[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){log("[FONT] ".concat(e," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(e," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(n,o,e,r){function t(n){return n instanceof e?n:new e((function(o){o(n)}))}return new(e||(e=Promise))((function(e,i){function s(n){try{u(r.next(n))}catch(n){i(n)}}function a(n){try{u(r["throw"](n))}catch(n){i(n)}}function u(n){n.done?e(n.value):t(n.value).then(s,a)}u((r=r.apply(n,o||[])).next())}))};var __generator=this&&this.__generator||function(n,o){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(o){return u([n,o])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(e=0)),e)try{if(r=1,t&&(i=a[0]&2?t["return"]:a[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,a[1])).done)return i;if(t=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;t=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){e.label=a[1];break}if(a[0]===6&&e.label<i[1]){e.label=i[1];i=a;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(a);break}if(i[2])e.ops.pop();e.trys.pop();continue}a=o.call(n,e)}catch(n){a=[6,n];t=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{l as log,a as logError}from"./logError-c456c092.js";var checkIfLoadVersionDomain=function(n){var o=n.loadScriptSrc;if(!o){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var e=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(o).origin;var i=e.some((function(n){return t.includes(n)}));var s=r.some((function(n){return t.includes(n)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:s,isWhiteListed:i}};var extractZonosQaUrl=function(n){if(!n){return null}var o=new URL(n).searchParams;var e=o.get("zonosQaUrl");if(!e){return null}var r=/[^a-zA-Z0-9-_]+/.test(e);if(!!r){return null}return e};var getZonosQaUrl=function(){if(typeof window==="undefined"){return null}var n=extractZonosQaUrl(window.location.href);if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var o="preview.js.zonos.com";var e="https://".concat(n,".").concat(o);log("[ZONOS-WARNING] using '".concat(e,"' for loading script"),"warn");void fetch(e).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(e,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var o=window.location.pathname;var r="".concat(o,"?").concat(n.toString());window.history.replaceState(window.history.state,"",r);window.location.reload();return null}));return e};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var n=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(!V3_URL_REGEX.test(e.src)){continue}return e}return null};var stripePromise$1=null;var injectScript=function(n){var o=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var e=document.createElement("script");e.src="".concat(V3_URL).concat(o);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(e);return e};var zonosStripeLoadScript=function(n){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(o,e){if(typeof window==="undefined"||typeof document==="undefined"){o(null);return}if(window.Stripe&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){o(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&n){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){o(window.Stripe)}else{e(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){e(new Error("Failed to load Stripe.js"))}))}catch(n){e(n);return}}));return stripePromise$1};var registerWrapper=function(n,o){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:o})};var initStripe=function(n,o,e){if(n===null){return null}var r=n.apply(undefined,o);registerWrapper(r,e);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(n){if(!loadCalled){console.warn(n)}}));var zonosLoadStripe=function(){var n=[];for(var o=0;o<arguments.length;o++){n[o]=arguments[o]}return __awaiter(void 0,void 0,void 0,(function(){var o;return __generator(this,(function(e){loadCalled=true;o=Date.now();return[2,stripePromise.then((function(e){return initStripe(e,n,o)}))]}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var o=checkIfLoadVersionDomain({loadScriptSrc:n===null||n===void 0?void 0:n.src}),e=o.currentLoadScriptUrl,r=o.isWhiteListed;if(r){return e}return null}();var ZONOS_URL=zonosLoadUrl||"https://v1.3.20-alpha.0.js.zonos.com";var JS_DELIVR_ZONOS_URL="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.20-alpha.0";var INTER_FONT_URL="https://rsms.me";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var INTER_FONT_REGEX=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;var Zonos=function(){function n(){}return n}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos.isBigCommerce=false;Zonos.isNpm=true;Zonos.internationalHideSelector="";Zonos.zonosQaUrl=null;Zonos.version="v".concat("1.3.20-alpha.0");Zonos.modeAlerted=false;Zonos.tempCartData=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.init=function(n){return __awaiter(void 0,[n],void 0,(function(n){var o=n.appearance,e=n.checkoutSettings,r=n.currencyConverter,t=n.helloSettings,i=n.onCountryChange,s=n.storeId,a=n.zonosApiKey;return __generator(this,(function(n){if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));if(!a){logError("Missing Zonos API key");return[2]}_a.zonosApiKey=a;_a.storeId=s;log("init zonos");_a.injectSentryScript();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:o,checkoutSettings:e,currencyConverter:r,helloSettings:t,onCountryChange:i},zonosApiKey:a});_a.doneInit=true;return[2]}))}))};Zonos.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};Zonos.openHelloDialog=function(n){var o=document.querySelector("zonos-hello");if(o){void o.openHelloDialog(n!==null&&n!==void 0?n:true)}};Zonos.showNotification=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.showNotification(n))};Zonos.updateOrganizationName=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.updateOrganizationName(n))};Zonos.disablePlaceOrderButtons=function(n){var o=n.autoEnable,e=o===void 0?true:o,r=n.disable,t=n.placeOrderButtonSelector;if(t){var i=document.querySelectorAll(t);var s=function(n){var o=n.target;if(o.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};i.forEach((function(n){var o=n.getAttribute("data-zonos-checkout-attached");if(o){return}if(r){n.setAttribute("disabled","true");n.addEventListener("click",s)}else{n.removeAttribute("disabled");n.removeEventListener("click",s)}}));if(e&&r){setTimeout((function(){i.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",s)}))}),5e3)}}};Zonos.injectController=function(n){var o=n.config,e=n.zonosApiKey;var r;if(document.querySelector("zonos-controller")){return}if((r=o.checkoutSettings)===null||r===void 0?void 0:r.placeOrderButtonSelector){var t=o.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({disable:true,placeOrderButtonSelector:t})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=o;s.zonosApiKey=e;s.addEventListener("stripeInitEvent",(function(n){return __awaiter(void 0,void 0,void 0,(function(){var o,e;return __generator(this,(function(r){switch(r.label){case 0:o=n.detail;log("loading Stripe");return[4,zonosLoadStripe(o.publishableKey)];case 1:e=r.sent();if(!e){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=e;void s.initCheckoutElement(e);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectSentryScript=function(){var n="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";var o=function(){var o=document.querySelector('script[src="'.concat(n,'"]'));return!!o};if(o()){log("Sentry script already exists in the document","warn");return}var e=document.head||document.body;var r=document.createElement("script");r.crossOrigin="anonymous";r.src=n;r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l";r.setAttribute("data-lazy","no");r.onerror=function(){logError("Failed to load ".concat(r.src))};r.onload=function(){var n;(n=window.Sentry)===null||n===void 0?void 0:n.init({beforeSend:function(n){var o,e,r,t,i,s;var a=(s=(i=(t=(r=(e=(o=n.exception)===null||o===void 0?void 0:o.values)===null||e===void 0?void 0:e[0])===null||r===void 0?void 0:r.stacktrace)===null||t===void 0?void 0:t.frames)===null||i===void 0?void 0:i[0])===null||s===void 0?void 0:s.filename;var u=(a===null||a===void 0?void 0:a.includes("js.zonos.com"))||(a===null||a===void 0?void 0:a.includes("@zonos/elements"));var l=window.location.href.includes("dev.elements")||window.location.href.includes("route.js.zonos.com");if(u&&!l){return n}return null},dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:"zonos-elements@".concat(_a.version),tracesSampler:function(){return.01}})};e.appendChild(r)};Zonos.injectScript=function(n){var o=n.fallBackDomain,e=n.isModule,r=n.scriptDomain,t=n.theRestUrl;var i="".concat(r,"/").concat(t);var s=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(s()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var a=document.head||document.body;var u=document.createElement("script");if(!!e){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){var n=/\/\/v\d+\./g.test(r);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o){_a.injectScript({isModule:e,scriptDomain:o,theRestUrl:t})}logError("Failed to load ".concat(u.src))};a.appendChild(u)};Zonos.getZonosUrl=function(){if(_a.isNpm){var n=getZonosQaUrl();return n||ZONOS_URL}return ZONOS_URL};Zonos.injectZonosCdn=function(){var n=_a.getZonosUrl();_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:true,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({fallBackDomain:JS_DELIVR_ZONOS_URL,isModule:false,scriptDomain:n,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(n){var o=n.fallBackDomain,e=n.stylesheetDomain,r=n.theRestUrl;var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var s=document.createElement("link");s.rel="stylesheet";s.href="".concat(e,"/").concat(r);s.onerror=function(){var n=/\/\/v\d+\./g.test(e);if(!n){log("No need to fallback since this is not a versioned domain","warn");return}if(o&&n){_a.injectStylesheet({stylesheetDomain:o,theRestUrl:r})}logError("Failed to load ".concat(s.href))};t.appendChild(s)};Zonos.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({fallBackDomain:JS_DELIVR_ZONOS_URL,stylesheetDomain:ZONOS_URL,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var n=function(){var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(INTER_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var e=n[o];if(!e){continue}if(INTER_FONT_REGEX.test(e.href)){continue}return e}return null};if(n()){log("Inter font already injected","warn");return}var o=document.head||document.body;var e=document.createElement("link");e.rel="preconnect";e.href=INTER_FONT_URL;o.appendChild(e);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(INTER_FONT_URL,"/inter/inter.css");o.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(n){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.setupGoogleFont(n))};Zonos.injectSupportGoogleFont=function(n){var o;log("[FONT] injecting ".concat(n));var e=(o=n.match(/family=(.*?):/))===null||o===void 0?void 0:o[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){log("[FONT] ".concat(e," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);log("[FONT] ".concat(e," font injected!"))};export{Zonos};