@zonos/elements 1.3.290 → 1.3.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-7DceSLKl.js → cart-B6Aty-21.js} +1 -1
- package/dist/cjs/{collect-C08DUE1L.js → collect-Oeo5tjN5.js} +2 -2
- package/dist/cjs/{getMissingRequiredShippingFields-Duz8xpmf.js → getMissingRequiredShippingFields-D03ICqss.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-C-iyXqJ0.js → hasInclusivePrice-CPCoVeU3.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-DSuHUQpi.js → invoice-Cj8W7NW0.js} +2 -2
- package/dist/cjs/{localization-BJqYz_PB.js → localization-BzNeXeDe.js} +24 -15
- package/dist/cjs/{paypal-CZoctP9S.js → paypal-CuKshRmZ.js} +2 -2
- package/dist/cjs/{placeTestOrder-D7baFuaV.js → placeTestOrder-7czjwkjm.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-Ca2HH1Gc.js → renderCheckoutCurrency-BH8t2b2x.js} +2 -2
- package/dist/cjs/{shouldShowLanguageSelect-FyTdz7U_.js → shouldShowLanguageSelect-yAbtCmd8.js} +1 -1
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +3 -3
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +3 -3
- package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +8 -8
- package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +7 -7
- package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +7 -7
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +3 -3
- package/dist/collection/components/store/hello/localization.js +4 -1
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +20 -14
- package/dist/esm/{cart-Cleo1j5P.js → cart-BoQp8Ema.js} +1 -1
- package/dist/esm/{collect-CspdWIRo.js → collect-CdrR5OBy.js} +2 -2
- package/dist/esm/{getMissingRequiredShippingFields-B1IL1-gn.js → getMissingRequiredShippingFields-Ks6_tpjn.js} +1 -1
- package/dist/esm/{hasInclusivePrice-DKRplpLX.js → hasInclusivePrice-CbEfIhI5.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-D49igPQ9.js → invoice-S1KahJ_Z.js} +2 -2
- package/dist/esm/{localization-BiL8bPsY.js → localization-BIh-4pc_.js} +24 -15
- package/dist/esm/{paypal-D4vWRxHJ.js → paypal-DNfvnuUU.js} +2 -2
- package/dist/esm/{placeTestOrder-BNmc5RCo.js → placeTestOrder-CQaMKFOg.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-BNbwijGo.js → renderCheckoutCurrency-C2Tw73uR.js} +2 -2
- package/dist/esm/{shouldShowLanguageSelect-B82gTfHz.js → shouldShowLanguageSelect-CCD7gpSY.js} +1 -1
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +3 -3
- package/dist/esm/zonos-address-display_2.entry.js +1 -1
- package/dist/esm/zonos-address_4.entry.js +2 -2
- package/dist/esm/zonos-airwallex-payment.entry.js +3 -3
- package/dist/esm/zonos-card_5.entry.js +3 -3
- package/dist/esm/zonos-cart-items_12.entry.js +8 -8
- package/dist/esm/zonos-checkout.entry.js +3 -3
- package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
- package/dist/esm/zonos-collect-finish_6.entry.js +7 -7
- package/dist/esm/zonos-collect.entry.js +4 -4
- package/dist/esm/zonos-controller.entry.js +2 -2
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +2 -2
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
- package/dist/esm/zonos-invoice-finish_5.entry.js +7 -7
- package/dist/esm/zonos-invoice.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +3 -3
- package/dist/esm-es5/{cart-Cleo1j5P.js → cart-BoQp8Ema.js} +8 -8
- package/dist/esm-es5/{collect-CspdWIRo.js → collect-CdrR5OBy.js} +1 -1
- package/dist/esm-es5/{getMissingRequiredShippingFields-B1IL1-gn.js → getMissingRequiredShippingFields-Ks6_tpjn.js} +3 -3
- package/dist/esm-es5/{hasInclusivePrice-DKRplpLX.js → hasInclusivePrice-CbEfIhI5.js} +1 -1
- package/dist/esm-es5/index.js +4 -4
- package/dist/esm-es5/{invoice-D49igPQ9.js → invoice-S1KahJ_Z.js} +1 -1
- package/dist/esm-es5/{localization-BiL8bPsY.js → localization-BIh-4pc_.js} +13 -3
- package/dist/esm-es5/{paypal-D4vWRxHJ.js → paypal-DNfvnuUU.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-BNmc5RCo.js → placeTestOrder-CQaMKFOg.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-BNbwijGo.js → renderCheckoutCurrency-C2Tw73uR.js} +2 -2
- package/dist/esm-es5/{shouldShowLanguageSelect-B82gTfHz.js → shouldShowLanguageSelect-CCD7gpSY.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +1 -1
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +3 -3
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +2 -2
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +2 -2
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/hello/countryOverrideStorage.d.ts +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-0ee74bf3.system.entry.js → p-04bded81.system.entry.js} +22 -22
- package/dist/zonos-elements/{p-c3b02dbf.entry.js → p-06fe2939.entry.js} +1 -1
- package/dist/zonos-elements/{p-13d3a372.system.entry.js → p-0b81f8b9.system.entry.js} +14 -14
- package/dist/zonos-elements/{p-d6b72f6d.entry.js → p-0fca452b.entry.js} +1 -1
- package/dist/zonos-elements/{p-a571beaa.system.entry.js → p-11defdca.system.entry.js} +16 -16
- package/dist/zonos-elements/{p-fb869759.system.entry.js → p-17c7ea4a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9ef0f69e.system.entry.js → p-23352709.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-a5c25829.system.entry.js → p-249c1ee1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-52d9fd3a.entry.js → p-34656e6c.entry.js} +1 -1
- package/dist/zonos-elements/{p-c4ad6d4b.entry.js → p-39ee1558.entry.js} +1 -1
- package/dist/zonos-elements/{p-23f6346b.system.entry.js → p-4806b264.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3c800376.system.entry.js → p-5016d71b.system.entry.js} +59 -59
- package/dist/zonos-elements/{p-5f347f91.system.entry.js → p-51400242.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-35509b10.system.entry.js → p-5236c676.system.entry.js} +20 -20
- package/dist/zonos-elements/{p-ddca5ee1.entry.js → p-550d4eea.entry.js} +1 -1
- package/dist/zonos-elements/{p-481ecc23.system.entry.js → p-552fbde1.system.entry.js} +20 -20
- package/dist/zonos-elements/{p-1b77464d.system.entry.js → p-5b80aff2.system.entry.js} +13 -13
- package/dist/zonos-elements/{p-079af8c0.system.entry.js → p-69c3e367.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-7d284341.system.entry.js → p-6abec43f.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-5df25a1a.entry.js → p-6c41b00c.entry.js} +1 -1
- package/dist/zonos-elements/{p-f37b8aaf.system.entry.js → p-6db7c0b1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-990b49f2.entry.js → p-6e296228.entry.js} +1 -1
- package/dist/zonos-elements/{p-BDrM4x5N.js → p-7abqRc9V.js} +2 -2
- package/dist/zonos-elements/{p-ba510730.entry.js → p-82595838.entry.js} +1 -1
- package/dist/zonos-elements/{p-84c9ce16.entry.js → p-938fc1e4.entry.js} +1 -1
- package/dist/zonos-elements/{p-DVITR-Eu.system.js → p-Be3Hpms1.system.js} +1 -1
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-BT9_ehlh.system.js → p-CEK_Wk6v.system.js} +1 -1
- package/dist/zonos-elements/p-CFbfEmjN.js +1 -0
- package/dist/zonos-elements/p-D-bZg-Pc.js +1 -0
- package/dist/zonos-elements/{p-CASTsiDR.system.js → p-D4MevhAL.system.js} +3 -3
- package/dist/zonos-elements/{p-tGJYTlGL.system.js → p-DI2vXnXc.system.js} +3 -3
- package/dist/zonos-elements/{p-Cpe_ISNt.system.js → p-DNc279vN.system.js} +27 -27
- package/dist/zonos-elements/{p-CEmXVahp.system.js → p-DOD2I44l.system.js} +92 -82
- package/dist/zonos-elements/{p-uuZUZPIm.system.js → p-DS-qw_qc.system.js} +10 -10
- package/dist/zonos-elements/p-DZ2mevDK.js +1 -0
- package/dist/zonos-elements/{p-B5NDhB1w.system.js → p-DuufSrhH.system.js} +4 -4
- package/dist/zonos-elements/{p-CewmhMGk.js → p-DzLNk-Pf.js} +1 -1
- package/dist/zonos-elements/{p-DwkyNtpD.js → p-FRWZayxL.js} +1 -1
- package/dist/zonos-elements/p-Mrz_lnC1.js +1 -0
- package/dist/zonos-elements/{p-B_5RofQ9.system.js → p-XDxdMlQl.system.js} +23 -23
- package/dist/zonos-elements/{p-DYIisqF7.system.js → p-XqkqjeNV.system.js} +1 -1
- package/dist/zonos-elements/{p-4fd78ecf.system.entry.js → p-a40fd99b.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-79ddb12a.system.entry.js → p-b2dd7f02.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-11bab88b.entry.js → p-b79036fc.entry.js} +1 -1
- package/dist/zonos-elements/{p-26295311.entry.js → p-bb3546c0.entry.js} +1 -1
- package/dist/zonos-elements/p-c1cbfdba.entry.js +1 -0
- package/dist/zonos-elements/{p-7e1050dd.system.entry.js → p-c3646ae6.system.entry.js} +15 -15
- package/dist/zonos-elements/{p-028e0500.entry.js → p-c47ce656.entry.js} +1 -1
- package/dist/zonos-elements/{p-34c5e145.entry.js → p-c5bab786.entry.js} +1 -1
- package/dist/zonos-elements/{p-234c202c.entry.js → p-c961caaf.entry.js} +1 -1
- package/dist/zonos-elements/{p-NJVOYjda.js → p-c9QtIdJX.js} +1 -1
- package/dist/zonos-elements/{p-Cuk0LLGQ.js → p-clDfq9AL.js} +1 -1
- package/dist/zonos-elements/{p-db75322d.entry.js → p-d168023b.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b06f069.entry.js → p-db87b0dd.entry.js} +1 -1
- package/dist/zonos-elements/{p-ab54d0a1.entry.js → p-dea26048.entry.js} +1 -1
- package/dist/zonos-elements/{p-dd8ca91e.entry.js → p-defc2d18.entry.js} +1 -1
- package/dist/zonos-elements/{p-7ee2af6e.system.entry.js → p-e005b6a5.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0dca8a26.system.entry.js → p-e0e9cff5.system.entry.js} +26 -26
- package/dist/zonos-elements/p-f8b50aa0.entry.js +1 -0
- package/dist/zonos-elements/{p-tkSf-lrO.system.js → p-kaOxUR9u.system.js} +5 -5
- package/dist/zonos-elements/p-rVp8hgWw.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-35539d3d.entry.js +0 -1
- package/dist/zonos-elements/p-BJzAgoqz.js +0 -1
- package/dist/zonos-elements/p-BKoLoalh.js +0 -1
- package/dist/zonos-elements/p-BaF00SfB.js +0 -1
- package/dist/zonos-elements/p-BtWDzGMx.js +0 -1
- package/dist/zonos-elements/p-CX_vfdWt.js +0 -1
- package/dist/zonos-elements/p-ca3175d9.entry.js +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,t,r){function o(e){return e instanceof t?e:new t((function(a){a(e)}))}return new(t||(t=Promise))((function(t,n){function
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,a,t,r){function o(e){return e instanceof t?e:new t((function(a){a(e)}))}return new(t||(t=Promise))((function(t,n){function i(e){try{s(r.next(e))}catch(e){n(e)}}function l(e){try{s(r["throw"](e))}catch(e){n(e)}}function s(e){e.done?t(e.value):o(e.value).then(i,l)}s((r=r.apply(e,a||[])).next())}))};var __generator=this&&this.__generator||function(e,a){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,o,n,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=l(0),i["throw"]=l(1),i["return"]=l(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(e){return function(a){return s([e,a])}}function s(l){if(r)throw new TypeError("Generator is already executing.");while(i&&(i=0,l[0]&&(t=0)),t)try{if(r=1,o&&(n=l[0]&2?o["return"]:l[0]?o["throw"]||((n=o["return"])&&n.call(o),0):o.next)&&!(n=n.call(o,l[1])).done)return n;if(o=0,n)l=[l[0]&2,n.value];switch(l[0]){case 0:case 1:n=l;break;case 4:t.label++;return{value:l[1],done:false};case 5:t.label++;o=l[1];l=[0];continue;case 7:l=t.ops.pop();t.trys.pop();continue;default:if(!(n=t.trys,n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){t.label=l[1];break}if(l[0]===6&&t.label<n[1]){t.label=n[1];n=l;break}if(n&&t.label<n[2]){t.label=n[2];t.ops.push(l);break}if(n[2])t.ops.pop();t.trys.pop();continue}l=a.call(e,t)}catch(e){l=[6,e];o=0}finally{r=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,a,t){if(t||arguments.length===2)for(var r=0,o=a.length,n;r<o;r++){if(n||!(r in a)){if(!n)n=Array.prototype.slice.call(a,0,r);n[r]=a[r]}}return e.concat(n||Array.prototype.slice.call(a))};System.register(["./p-BuU_p5DP.system.js","./p-zVLAvre1.system.js","./p-BbgqQIHv.system.js"],(function(e){"use strict";var a,t,r,o,n,i,l;return{setters:[function(e){a=e.c;t=e.z},function(e){r=e.j;o=e.h;n=e.l},function(e){i=e.a;l=e.l}],execute:function(){var s=this;
|
|
2
2
|
/**
|
|
3
3
|
* Check if the response contains at least one available test key that we support
|
|
4
|
-
*/var u=function(e){var a=!!e.find((function(e){return e.testKey in
|
|
4
|
+
*/var u=function(e){var a=!!e.find((function(e){return e.testKey in i}));if(!a){l("No available test key found in response","info",{response:e})}return!!e.find((function(e){return e.testKey in i}))};
|
|
5
5
|
/**
|
|
6
6
|
* Filter the response to only include test keys and variants key that we support
|
|
7
7
|
*/var d=e("f",(function(e){
|
|
8
8
|
// Type guard the response to ensure it matches the expected structure
|
|
9
9
|
if(!u(e)){return[]}
|
|
10
10
|
// Filter the response to only include test keys that we support
|
|
11
|
-
return e.filter((function(e){var a;var t=
|
|
11
|
+
return e.filter((function(e){var a;var t=i[e.testKey]&&!e.selectedVariantKey;var r=e.selectedVariantKey&&!!((a=i[e.testKey])===null||a===void 0?void 0:a["availableVariants"].includes(e.selectedVariantKey));return t||r})).map((function(e){return Object.assign(Object.assign({},e),{expiresAt:e.expiresAt||Date.now()+c,selectedVariantKey:e.selectedVariantKey||null})}))}));
|
|
12
12
|
/**
|
|
13
13
|
* Expiration time for variant test keys in milliseconds
|
|
14
14
|
* @default 1 day
|
|
@@ -26,49 +26,55 @@ City:{value:"City"},"City/Town":{value:"City/Town"},"Click to copy the card numb
|
|
|
26
26
|
* translate('Above de minimis threshold for')
|
|
27
27
|
*/var X=e("t",(function(){var e=[];for(var a=0;a<arguments.length;a++){e[a]=arguments[a]}var t=e[0],r=e[1];var o,n;if(r){
|
|
28
28
|
// replace all variables in the string
|
|
29
|
-
var
|
|
29
|
+
var i=((o=R.translatedChunks[t])===null||o===void 0?void 0:o.value)||t;Object.entries(r).forEach((function(e){var a=e[0],t=e[1];i=i.replace(new RegExp("\\[".concat(a,"\\]"),"g"),t.toString())}));return i}return((n=R.translatedChunks[t])===null||n===void 0?void 0:n.value)||t}));var B=function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t,r;return __generator(this,(function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4/*yield*/,o("/api/zonos-elements/get-countries",{method:"GET"})];case 1:e=n.sent(),a=e.errors,t=e.json;if(a.length||!t){return[2/*return*/,null]}return[2/*return*/,t];case 2:r=n.sent();return[2/*return*/,null];case 3:return[2/*return*/]}}))}))};var O=function(e){return __awaiter(s,void 0,void 0,(function(){var a,t,r,i,l;return __generator(this,(function(s){switch(s.label){case 0:if(!e){return[2/*return*/,null]}t="/api/zonos-elements/country-landed-cost/".concat(e);return[4/*yield*/,o(t)];case 1:r=s.sent(),i=r.errors,l=r.json;if(i.length||!l){n("Error fetching country landed cost: ".concat((a=i.find(Boolean))===null||a===void 0?void 0:a.message));return[2/*return*/,null]}return[2/*return*/,l||null]}}))}))};var K={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null};var W=e("w",(function(e){return __awaiter(s,[e],void 0,(function(e){var a,t,r,i,l,s,u,d,c,v;var p=e.country,m=e.isGuaranteed,h=e.sourceCurrency,g=e.targetCurrency;return __generator(this,(function(e){switch(e.label){case 0:
|
|
30
30
|
// If source currency matches target currency (US -> US) and is not a guaranteed rate, return default exchange rate so we still format properly.
|
|
31
|
-
if(h===g&&!m){return[2/*return*/,K]}t=new URLSearchParams;t.set("sourceCurrency",h);t.set("targetCurrency",g);t.set("isGuaranteed",String(m));t.set("country",p||"");return[4/*yield*/,o("/api/zonos-elements/exchange-rates?".concat(t.toString()))];case 1:r=e.sent(),
|
|
31
|
+
if(h===g&&!m){return[2/*return*/,K]}t=new URLSearchParams;t.set("sourceCurrency",h);t.set("targetCurrency",g);t.set("isGuaranteed",String(m));t.set("country",p||"");return[4/*yield*/,o("/api/zonos-elements/exchange-rates?".concat(t.toString()))];case 1:r=e.sent(),i=r.errors,l=r.json;if(i.length||!l){n("Error fetching country landed cost: ".concat((a=i.find(Boolean))===null||a===void 0?void 0:a.message));return[2/*return*/,K]}s=l.exchangeRateCreate,u=s.rate,d=s.targetFormat;c=l.maxAge;if(u){sessionStorage.setItem(p+"_rate",JSON.stringify(u));v={rate:u,targetFormat:d};return[2/*return*/,{exchangeRate:v,maxAge:c}]}return[2/*return*/,K]}}))}))}));var q=function(e){return __awaiter(s,void 0,void 0,(function(){var a,t,r,i;return __generator(this,(function(l){switch(l.label){case 0:if(!e){return[2/*return*/,null]}return[4/*yield*/,o("/api/zonos-elements/inclusive-prices/".concat(e))];case 1:t=l.sent(),r=t.errors,i=t.json;if(r.length||!i){n("Error fetching country inclusive price setting: ".concat((a=r.find(Boolean))===null||a===void 0?void 0:a.message));return[2/*return*/,null]}return[2/*return*/,i||null]}}))}))};var Y=function(e){return __awaiter(s,[e],void 0,(function(e){var a,t,r,i,l;var s=e.countryCode,u=e.localeTo,d=e.storeId;return __generator(this,(function(e){switch(e.label){case 0:t=new URLSearchParams;t.set("countryCode",s);t.set("storeId",d.toString());if(u){t.set("localeTo",u)}return[4/*yield*/,o("/api/zonos-elements/locale-messages?".concat(t.toString()))];case 1:r=e.sent(),i=r.errors,l=r.json;if(i.length||!l){n("Error fetching exchange rate",(a=i.find(Boolean))===null||a===void 0?void 0:a.message);return[2/*return*/,[]]}return[2/*return*/,l.locale_countryCodesPage]}}))}))};var M=function(e){return/^[A-Z]{2}$/.test(e)};var Z="zonos--country";var H=function(e){try{e()}catch(e){
|
|
32
32
|
// localStorage/sessionStorage can throw in blocked-storage contexts
|
|
33
33
|
// (Safari private mode, cross-origin iframes).
|
|
34
|
-
}};var J=function(
|
|
34
|
+
}};var J=function(e){try{var a=e.getItem(Z);if(!a||!M(a)){return null}return a}catch(e){return null}};var _=function(e,a){e.setItem(Z,a)};var Q=function(e){H((function(){return e(window.localStorage)}));H((function(){return e(window.sessionStorage)}))};var $=function(){var e;return(e=J(window.localStorage))!==null&&e!==void 0?e:J(window.sessionStorage)};var ee=function(e){if(!e){return}H((function(){var a=J(window.localStorage);
|
|
35
|
+
// Only mirror the country Hello actually kept. A failed localStorage
|
|
36
|
+
// clear can leave a discarded country in local; never copy that to
|
|
37
|
+
// session for older Elements. Never copy session → local.
|
|
38
|
+
if(a===e){_(window.sessionStorage,a)}}))};var ae=function(e){
|
|
39
|
+
// Dual-write so older Elements that only read sessionStorage see the pick.
|
|
40
|
+
Q((function(a){return _(a,e)}))};var te=function(){Q((function(e){return e.removeItem(Z)}))};var re=e("g",(function(e){var a=new URLSearchParams(e||window.location.search);var t=function(e){var t=a.get(e);if(t&&M(t)){return t}return null};var r=t("zCountry");
|
|
35
41
|
// Fallback to legacy 'country'
|
|
36
42
|
var o=t("country");
|
|
37
43
|
// Fallback to customerCountry
|
|
38
44
|
var n=t("customerCountry");return r||o||n}));
|
|
39
45
|
/**
|
|
40
46
|
* Retrieve the shopper country override from the URL or remembered storage.
|
|
41
|
-
*/var
|
|
47
|
+
*/var oe=e("m",(function(){var e=new URL(window.location.href);return re(e.searchParams)||$()}));var ne=function(){var e=[];for(var a=0;a<arguments.length;a++){e[a]=arguments[a]}return __awaiter(s,__spreadArray([],e,true),void 0,(function(e){var a,t,r,n,i,l;var s=e===void 0?{}:e,u=s.ignoreCountryOverride,d=u===void 0?false:u;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);a=d?null:oe();t=new URLSearchParams;if(a){t.set("zCountry",a)}return[4/*yield*/,o("/api/zonos-elements/localization?".concat(t.toString()))];case 1:r=e.sent(),n=r.errors,i=r.json;if(n.length||!i){return[2/*return*/,{country:null,locale:null}]}return[2/*return*/,{country:i.country,locale:i.locale}];case 2:l=e.sent();return[2/*return*/,{country:null,locale:null}];case 3:return[2/*return*/]}}))}))};var ie=function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t,r,i,l,s;return __generator(this,(function(u){switch(u.label){case 0:if((e=window.Zonos.cartSettings)===null||e===void 0?void 0:e.shippingZones){return[2/*return*/,window.Zonos.cartSettings.shippingZones.flatMap((function(e){return e===null||e===void 0?void 0:e.countryCodes})).filter(Boolean)]}return[4/*yield*/,o("/api/zonos-elements/shipping-zones")];case 1:r=u.sent(),i=r.errors,l=r.json;if(i.length||!l){n("Error fetching shipping zones: ".concat((a=i.find(Boolean))===null||a===void 0?void 0:a.message));return[2/*return*/,null]}s=(t=l===null||l===void 0?void 0:l.shippingZones)===null||t===void 0?void 0:t.flatMap((function(e){return e===null||e===void 0?void 0:e.countryCodes})).filter(Boolean);return[2/*return*/,s||null]}}))}))};
|
|
42
48
|
/**
|
|
43
49
|
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
44
50
|
* The `/checkout` page URL does not include the checkout ID, so we
|
|
45
51
|
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
46
|
-
*/var le=e("a",(function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t,r,o;return __generator(this,(function(
|
|
52
|
+
*/var le=e("a",(function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4/*yield*/,fetch("/api/storefront/cart",{credentials:"same-origin",headers:{Accept:"application/json"}})];case 1:t=i.sent();if(!t.ok){l("Failed to fetch BigCommerce cart: ".concat(String(t.status)),"error");return[2/*return*/,null]}return[4/*yield*/,t.json()];case 2:r=i.sent();return[2/*return*/,(a=(e=r===null||r===void 0?void 0:r[0])===null||e===void 0?void 0:e.id)!==null&&a!==void 0?a:null];case 3:o=i.sent();n("Error fetching BigCommerce cart data",o);return[2/*return*/,null];case 4:return[2/*return*/]}}))}))}));
|
|
47
53
|
/**
|
|
48
54
|
* Fetch checkout data from the BigCommerce Storefront API.
|
|
49
55
|
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
50
|
-
*/var
|
|
56
|
+
*/var se=e("b",(function(e){return __awaiter(s,void 0,void 0,(function(){var a,t;return __generator(this,(function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4/*yield*/,fetch("/api/storefront/checkouts/".concat(e,"?include=customer.customerGroup,customer.addresses"),{credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}})];case 1:a=r.sent();if(!a.ok){l("Failed to fetch BigCommerce checkout: ".concat(String(a.status)),"error");return[2/*return*/,null]}return[4/*yield*/,a.json()];case 2:return[2/*return*/,r.sent()];case 3:t=r.sent();n("Error fetching BigCommerce checkout data",t);return[2/*return*/,null];case 4:return[2/*return*/]}}))}))}));
|
|
51
57
|
/**
|
|
52
58
|
* Delete a consignment (a saved shipping selection, e.g. a domestic shipping
|
|
53
59
|
* quote the shopper added on the cart page) from the active BigCommerce
|
|
54
60
|
* checkout via the Storefront API. Cookie-authenticated (same-origin), so no
|
|
55
61
|
* token is needed. Returns the updated checkout on success, or null on
|
|
56
62
|
* failure.
|
|
57
|
-
*/var
|
|
63
|
+
*/var ue=function(e,a){return __awaiter(s,void 0,void 0,(function(){var t,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4/*yield*/,fetch("/api/storefront/checkouts/".concat(e,"/consignments/").concat(a),{credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},method:"DELETE"})];case 1:t=o.sent();if(!t.ok){l("Failed to delete BigCommerce consignment: ".concat(String(t.status)),"error");return[2/*return*/,null]}return[4/*yield*/,t.json()];case 2:return[2/*return*/,o.sent()];case 3:r=o.sent();n("Error deleting BigCommerce consignment",r);return[2/*return*/,null];case 4:return[2/*return*/]}}))}))};
|
|
58
64
|
/**
|
|
59
65
|
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
60
66
|
* customer's numeric `id` since the storefront API populates it only for
|
|
61
67
|
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
62
|
-
*/var
|
|
68
|
+
*/var de=e("i",(function(e){var a;return!!((a=e===null||e===void 0?void 0:e.customer)===null||a===void 0?void 0:a.id)}));var ce=e("c",(function(e){var a;return!!e&&!!((a=Ke.shippingZoneCountries)===null||a===void 0?void 0:a[e])&&!t.disabledCountries.includes(e)}));
|
|
63
69
|
/**
|
|
64
70
|
* Visibility rules for Hello, ignoring whether localization has finished
|
|
65
71
|
* loading. Used during init reconcile before `localizationLoaded` is set.
|
|
66
72
|
* Pass `countryCode` to evaluate a remembered country instead of the
|
|
67
73
|
* currently selected one.
|
|
68
|
-
*/var
|
|
74
|
+
*/var ve=function(e,a){if(e===void 0){e=true}if(a===void 0){a=Ke.selectedCountryCode}var r,o;var n=t.helloSettings,i=n.countryDisplayRules,s=n.showForCountries;var u=i===null||i===void 0?void 0:i.widgetVisibility;var d=a;var c=ce(a);
|
|
69
75
|
// Resolve behavior: deprecated showForCountries overrides widgetVisibility.behavior
|
|
70
76
|
// If showForCountries is an array of country codes, treat as legacy explicit list
|
|
71
|
-
var v=Array.isArray(s)?s:s!==null&&s!==void 0?s:u===null||u===void 0?void 0:u.behavior;if(e&&!c){
|
|
77
|
+
var v=Array.isArray(s)?s:s!==null&&s!==void 0?s:u===null||u===void 0?void 0:u.behavior;if(e&&!c){l("Hello: not shippable country - Show for countries: ".concat(v))}
|
|
72
78
|
// Legacy: explicit list of country codes from deprecated showForCountries
|
|
73
79
|
if(Array.isArray(v)){return!!d&&v.includes(d)}
|
|
74
80
|
// Determine base visibility from behavior
|
|
@@ -89,13 +95,13 @@ if(p&&d&&((o=u===null||u===void 0?void 0:u.excludedCountries)===null||o===void 0
|
|
|
89
95
|
* @param showLog - emit a debug log when the shopper is not in a shipping zone.
|
|
90
96
|
* Defaults to `true`; pass `false` from non-rendering callers to avoid log
|
|
91
97
|
* noise.
|
|
92
|
-
*/var
|
|
98
|
+
*/var pe=e("v",(function(e){if(e===void 0){e=true}if(!Ke.localizationLoaded){return false}return ve(e)}));
|
|
93
99
|
/**
|
|
94
100
|
* Guard against overlapping passes. `removeBigcommerceCartShipping` is fired on
|
|
95
101
|
* every country change; without this flag, rapid country switches could stack
|
|
96
102
|
* concurrent fetch/DELETE cycles against the same cart before the reload kicks
|
|
97
103
|
* in.
|
|
98
|
-
*/var
|
|
104
|
+
*/var me=false;
|
|
99
105
|
/**
|
|
100
106
|
* On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
101
107
|
* shopper added before they switched to an international country, then reload
|
|
@@ -112,120 +118,120 @@ if(p&&d&&((o=u===null||u===void 0?void 0:u.excludedCountries)===null||o===void 0
|
|
|
112
118
|
* active checkout actually has a consignment. Because the reload happens only
|
|
113
119
|
* when a consignment is found and removed, the freshly-loaded page has none —
|
|
114
120
|
* so this cannot loop.
|
|
115
|
-
*/var
|
|
121
|
+
*/var he=function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t,r,o,i,s,u;return __generator(this,(function(d){switch(d.label){case 0:if(typeof window==="undefined"||!((e=window.Zonos)===null||e===void 0?void 0:e.isBigCommerce)){return[2/*return*/]}
|
|
116
122
|
// Only on the cart page and only when Hello is shown — elsewhere there is no
|
|
117
123
|
// Grand Total to correct. Gate on Hello visibility (not raw shipping-zone
|
|
118
124
|
// membership) so include/exclude country overrides are respected.
|
|
119
|
-
if(window.location.pathname!=="/cart.php"||!
|
|
125
|
+
if(window.location.pathname!=="/cart.php"||!Ke.isShippableCountry||!pe(false)){return[2/*return*/]}if(me){return[2/*return*/]}me=true;d.label=1;case 1:d.trys.push([1,5,6,7]);return[4/*yield*/,le()];case 2:t=d.sent();if(!t){return[2/*return*/]}return[4/*yield*/,se(t)];case 3:r=d.sent();o=((a=r===null||r===void 0?void 0:r.consignments)!==null&&a!==void 0?a:[]).map((function(e){return e.id})).filter((function(e){return!!e}));
|
|
120
126
|
// Nothing to do if there is no domestic shipping quote on the cart.
|
|
121
|
-
if(!o.length){return[2/*return*/]}
|
|
127
|
+
if(!o.length){return[2/*return*/]}l("Removing ".concat(String(o.length)," BigCommerce cart consignment(s) for international shopper"),"info");return[4/*yield*/,Promise.all(o.map((function(e){return ue(t,e)})))];case 4:i=d.sent();s=i.filter(Boolean).length;
|
|
122
128
|
// Only reload when at least one consignment was actually removed. If every
|
|
123
129
|
// DELETE failed, reloading would re-run this on init with the same
|
|
124
130
|
// consignments still present and trap the shopper in a reload loop.
|
|
125
|
-
if(!s){
|
|
131
|
+
if(!s){l("No BigCommerce cart consignments were removed; skipping reload to avoid a reload loop","warn");return[2/*return*/]}
|
|
126
132
|
// Reload so the server re-renders the cart consistently without the removed
|
|
127
133
|
// shipping, instead of surgically patching the DOM total.
|
|
128
|
-
window.location.reload();return[3/*break*/,7];case 5:u=d.sent();n("Error removing BigCommerce cart shipping consignment",u);return[3/*break*/,7];case 6:
|
|
134
|
+
window.location.reload();return[3/*break*/,7];case 5:u=d.sent();n("Error removing BigCommerce cart shipping consignment",u);return[3/*break*/,7];case 6:me=false;return[7/*endfinally*/];case 7:return[2/*return*/]}}))}))};var ge=e("k",[{code:"en",label:"English",translatedLabel:"English"},{code:"es",label:"Spanish",translatedLabel:"Español"},{code:"pt",label:"Portuguese",translatedLabel:"Português"},{code:"ru",label:"Russian",translatedLabel:"русский"},{code:"da",label:"Danish",translatedLabel:"dansk"},{code:"it",label:"Italian",translatedLabel:"Italiano"},{code:"pl",label:"Polish",translatedLabel:"Polskie"},{code:"ar",label:"Arabic",translatedLabel:"عربى"},{code:"de",label:"German",translatedLabel:"Deutsch"},{code:"ja",label:"Japanese",translatedLabel:"日本語"},{code:"no",label:"Norwegian",translatedLabel:"norsk"},{code:"vi",label:"Vietnamese",translatedLabel:"Tiếng Việt"},{code:"tr",label:"Turkish",translatedLabel:"Türkçe"},{code:"he",label:"Hebrew",translatedLabel:"עִברִית"},{code:"fr",label:"French",translatedLabel:"Français"},{code:"nl",label:"Dutch",translatedLabel:"Nederlands"},{code:"zh",label:"Chinese",translatedLabel:"中文"},{code:"sv",label:"Swedish",translatedLabel:"svenska"},{code:"id",label:"Indonesian",translatedLabel:"bahasa Indonesia"},{code:"ko",label:"Korean",translatedLabel:"한국어"}]);
|
|
129
135
|
/**
|
|
130
136
|
* The languages offered in the language selector, honoring the merchant's
|
|
131
137
|
* `appearanceSettings.supportedLocales`. Falls back to every supported language when the
|
|
132
138
|
* merchant has not restricted the list, or when their selection matches nothing we ship
|
|
133
139
|
* translations for — an empty selector is never the right answer.
|
|
134
|
-
*/var
|
|
140
|
+
*/var ye=e("A",(function(){var e=t.appearance.supportedLocales;if(!(e===null||e===void 0?void 0:e.length)){return ge}var a=new Set(e);var r=ge.filter((function(e){return a.has(e.code)}));return r.length?r:ge}));var fe=e("B",(function(e){var a=Ke.inclusivePricingConfigurations.find((function(e){return e.shipToCountry===Ke.selectedCountryCode}));if(!a){return e}var t=a.effectiveRate;
|
|
135
141
|
// Just multiply the amount by the effective rate to get the new amount for inclusive pricing
|
|
136
|
-
return e*(1+t)}));var
|
|
142
|
+
return e*(1+t)}));var be=e("u",(function(e){
|
|
137
143
|
// TODO(potentially): Bring over the code for vanity checks
|
|
138
|
-
var a=
|
|
144
|
+
var a=Ke.exchangeRate;if(!a||!e||isNaN(e)){return e}var t=(a===null||a===void 0?void 0:a.targetFormat.scale)||2;var r=e*a.rate;var o=r.toFixed(t);return Number(o)}));
|
|
139
145
|
/**
|
|
140
146
|
* This function only to format the number in
|
|
141
147
|
* @returns
|
|
142
|
-
*/var
|
|
148
|
+
*/var ke=e("x",(function(e){var a=e.amount,t=e.currency,r=e.targetFormat;var o=t||Ke.targetCurrency;var n=(r===null||r===void 0?void 0:r.scale)||2;var i=window.navigator.userAgent.indexOf("MSIE ")!==-1;var l=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(i||!l){
|
|
143
149
|
// use native number formatting if it's IE.
|
|
144
|
-
var s=Number(a).toFixed(n).replace(".","|dec|").replace(",",(r===null||r===void 0?void 0:r.thousandsDelimiter)||"").replace("|dec|",(r===null||r===void 0?void 0:r.decimalDelimiter)||"");return s}var u=new Intl.NumberFormat(window.navigator.language,{currency:o,currencyDisplay:"code",minimumFractionDigits:n,style:"currency"}).format(a);return u.replace(new RegExp("".concat(o,"\\s+")),"")}));var
|
|
150
|
+
var s=Number(a).toFixed(n).replace(".","|dec|").replace(",",(r===null||r===void 0?void 0:r.thousandsDelimiter)||"").replace("|dec|",(r===null||r===void 0?void 0:r.decimalDelimiter)||"");return s}var u=new Intl.NumberFormat(window.navigator.language,{currency:o,currencyDisplay:"code",minimumFractionDigits:n,style:"currency"}).format(a);return u.replace(new RegExp("".concat(o,"\\s+")),"")}));var we=e("j",(function(e){var a=e.amount,r=e.currency;if(isNaN(a)||a!==0&&!a){return""}var o=t.overrideCurrencyFormat;var n=Ke.exchangeRate;var i=r||Ke.targetCurrency;
|
|
145
151
|
// Use user-defined currency format
|
|
146
|
-
if(typeof o==="function"){return o({amount:a,currencyCode:
|
|
152
|
+
if(typeof o==="function"){return o({amount:a,currencyCode:i,numberFormat:function(e){var a=e.amount;return ke({amount:a,currency:i,targetFormat:(n===null||n===void 0?void 0:n.targetFormat)||null})}})}var l=(n||{}).targetFormat;var s=l===null||l===void 0?void 0:l.scale;var u=window.navigator.userAgent.indexOf("MSIE ")!==-1;var d=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(u||!d){
|
|
147
153
|
// target format is mainly used to get the minimum fraction digits for IE or no Intl.NumberFormat is available
|
|
148
|
-
if(!
|
|
154
|
+
if(!l||!n){
|
|
149
155
|
// Return the amount as a string if no exchange rate is available
|
|
150
|
-
return"".concat(a.toFixed(2)," ").concat(
|
|
156
|
+
return"".concat(a.toFixed(2)," ").concat(i)}
|
|
151
157
|
// use native number formatting if it's IE.
|
|
152
|
-
var c=Number(a).toFixed(s||2).replace(".","|dec|").replace(",",
|
|
158
|
+
var c=Number(a).toFixed(s||2).replace(".","|dec|").replace(",",l.thousandsDelimiter||"").replace("|dec|",l.decimalDelimiter||"");var v="".concat(c).concat(l.currencyCode!=="USD"?" ".concat(l.currencyCode):"");return v}var p=(o===null||o===void 0?void 0:o.currencyDisplay)||"symbol";var m=new Intl.NumberFormat(t.sourceCurrency==="AUD"?"en-AU":window.navigator.language,{currency:i,currencyDisplay:p,minimumFractionDigits:s,style:"currency"}).format(a);
|
|
153
159
|
// Move currency code to the end of the string if currencyDisplay is 'code'
|
|
154
|
-
var h=p==="code"?"".concat(m.replace(new RegExp("".concat(
|
|
160
|
+
var h=p==="code"?"".concat(m.replace(new RegExp("".concat(i,"\\s+")),"")," ").concat(i):m;return h}));var Pe=e("r",(function(e){var a=be(e);var t=we({amount:a});return t}));
|
|
155
161
|
/**
|
|
156
162
|
* Check if selector user pass is valid
|
|
157
163
|
* @example
|
|
158
164
|
* isValidSelector('div') // true
|
|
159
165
|
* isValidSelector('div + >>> span') // false
|
|
160
|
-
*/var
|
|
166
|
+
*/var Se=e("n",(function(e){try{
|
|
161
167
|
// this will error out if the selector is invalid in the DOM
|
|
162
|
-
document.createDocumentFragment().querySelector(e)}catch(e){return false}return true}));var
|
|
168
|
+
document.createDocumentFragment().querySelector(e)}catch(e){return false}return true}));var Ce=function(e){var a=e||".money";if(!Se(a)){n('Currency element selector "'.concat(a,'" is not valid.'));return null}var t=document.querySelectorAll(a);if(!t.length){l('No currency elements found with selector "'.concat(a,'"'),"warn");return null}
|
|
163
169
|
// return array of currency elements instead of a NodeList
|
|
164
|
-
return Array.from(t)};var
|
|
170
|
+
return Array.from(t)};var ze=function(e){var a;var t=e.getAttribute("data-domestic");var r=e.getAttribute("data-zintl");
|
|
165
171
|
// Only keep numbers, decimal, and hyphens
|
|
166
172
|
var o=(a=e.textContent)===null||a===void 0?void 0:a.replace(/[^\d.-]/g,"");if(!o){return null}
|
|
167
173
|
// If the element has no data-domestic attribute, or the text content is different from the data-zintl attribute, set the data-domestic attribute
|
|
168
174
|
if(!t||e.textContent!==r&&r){
|
|
169
175
|
// Store the original value on the element once, and international on every new conversion
|
|
170
|
-
e.setAttribute("data-domestic",o);return parseFloat(o)}return parseFloat(t)};var
|
|
176
|
+
e.setAttribute("data-domestic",o);return parseFloat(o)}return parseFloat(t)};var Ae=7e3;var Te="z--blur";var xe=function(){return __awaiter(s,void 0,void 0,(function(){var e,a;return __generator(this,(function(t){switch(t.label){case 0:e=window.zonosBlurCurrencyOnInitIntervalId;if(!e){
|
|
171
177
|
// Do nothing if the interval is not set
|
|
172
178
|
return[2/*return*/]}
|
|
173
179
|
// Wait a bit to make sure price is fully rendered in DOM
|
|
174
180
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 1:
|
|
175
181
|
// Wait a bit to make sure price is fully rendered in DOM
|
|
176
|
-
t.sent();clearInterval(e);a=document.querySelectorAll(".".concat(
|
|
182
|
+
t.sent();clearInterval(e);a=document.querySelectorAll(".".concat(Te));a.forEach((function(e){e.classList.remove(Te)}));window.zonosBlurCurrencyOnInitIntervalId=undefined;return[2/*return*/]}}))}))};
|
|
177
183
|
/**
|
|
178
184
|
* This function is used to remove the blur effect from a specific element. (combined with performBlurSpecificElement)
|
|
179
185
|
* @returns void
|
|
180
|
-
*/var
|
|
186
|
+
*/var De=function(e){return __awaiter(s,[e],void 0,(function(e){var a=e.specificSelector,t=e.timeoutId;return __generator(this,(function(e){switch(e.label){case 0:
|
|
181
187
|
// Wait a bit to make sure price is fully rendered in DOM
|
|
182
188
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 1:
|
|
183
189
|
// Wait a bit to make sure price is fully rendered in DOM
|
|
184
|
-
e.sent();if(t){clearTimeout(t)}a.classList.remove(
|
|
190
|
+
e.sent();if(t){clearTimeout(t)}a.classList.remove(Te);return[2/*return*/]}}))}))};var Ne=function(e){var a=e.currencySelector,t=e.specificSelector;
|
|
185
191
|
// Do nothing if the currency selector is not provided or blurCurrencyOnInit is false
|
|
186
|
-
if(!a&&!t){return}if(t){t.classList.add(
|
|
192
|
+
if(!a&&!t){return}if(t){t.classList.add(Te)}else{var r=document.querySelectorAll([a].filter(Boolean).join(","));r.forEach((function(e){e.classList.add(Te)}))}};var Ie=function(e){if(typeof window==="undefined"){return}Ne({specificSelector:e});
|
|
187
193
|
// The blur will be removed as soon as we got the exchange rate back. But if the exchange rate is not available for some reason, the blur effect will be automatically removed after 10 seconds
|
|
188
|
-
var a=setTimeout((function(){void
|
|
194
|
+
var a=setTimeout((function(){void De({specificSelector:e,timeoutId:a})}),Ae);return a};var Ue=function(){if(typeof window==="undefined"){return}
|
|
189
195
|
// If the interval is already in progress, do nothing
|
|
190
|
-
if(window.zonosBlurCurrencyOnInitIntervalId){return}
|
|
196
|
+
if(window.zonosBlurCurrencyOnInitIntervalId){return}Ne({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});
|
|
191
197
|
// Add blur effect to the currency elements
|
|
192
|
-
var e=setInterval((function(){
|
|
198
|
+
var e=setInterval((function(){Ne({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=e;
|
|
193
199
|
// The blur will be removed as soon as we got the exchange rate back. But if the exchange rate is not available for some reason, the blur effect will be automatically removed after 10 seconds
|
|
194
|
-
setTimeout((function(){void
|
|
200
|
+
setTimeout((function(){void xe()}),Ae)};var Le=function(e){var a;var r=ze(e);if(r===null||isNaN(r)){return}var o=e.getAttribute("data-zintl");
|
|
195
201
|
// get rate
|
|
196
|
-
var n=parseFloat(e.getAttribute("data-zrate")||"1");var
|
|
202
|
+
var n=parseFloat(e.getAttribute("data-zrate")||"1");var i=e.getAttribute("data-zcountry-code");
|
|
197
203
|
// do nothing if the target currency is the same
|
|
198
|
-
var
|
|
204
|
+
var l=Ke.exchangeRate&&Ke.targetCurrency===Ke.exchangeRate.targetFormat.currencyCode;var s=((a=Ke.exchangeRate)===null||a===void 0?void 0:a.rate)||1;
|
|
199
205
|
// if the current value on the element is different from the current intl value, update the data-zintl attribute
|
|
200
|
-
if(
|
|
206
|
+
if(l&&(
|
|
201
207
|
// Update currency if the value is not yet formatted
|
|
202
208
|
e.textContent!==o||
|
|
203
209
|
// Update rate when new rate is available
|
|
204
210
|
s!==n||
|
|
205
211
|
// Update currency when the country code changes
|
|
206
|
-
|
|
212
|
+
i!==Ke.selectedCountryCode)){var u=void 0;
|
|
207
213
|
// Only trigger blur effect if the source currency is different from the target currency
|
|
208
|
-
if(t.sourceCurrency!==
|
|
214
|
+
if(t.sourceCurrency!==Ke.targetCurrency){
|
|
209
215
|
// Hide the currency until DOM is ready to display the new value
|
|
210
|
-
u=
|
|
216
|
+
u=Ie(e)}var d=fe(r);var c=typeof t.currencyConverter==="function"&&t.currencyConverter({convert:be,convertAndFormat:Pe,currencyCode:Ke.targetCurrency,format:function(e){return we({amount:e})},originalAmount:d,selector:e});
|
|
211
217
|
// default to the currencyConvertAndFormat if the currencyConverter function does not return a value, or invalid value. This is to make sure we don't break the merchant's price.
|
|
212
|
-
var v=c||
|
|
218
|
+
var v=c||Pe(d);if(v!==e.textContent){
|
|
213
219
|
// Only set textContent if the value has changed, this is to prevent it redrawing the element if the value is the same
|
|
214
220
|
e.textContent=v}
|
|
215
221
|
// save the new rate to the data-zrate attribute
|
|
216
222
|
e.setAttribute("data-zrate",s.toString());
|
|
217
223
|
// save the new value to the data-zintl attribute
|
|
218
|
-
e.setAttribute("data-zintl",v);e.setAttribute("data-zcountry-code",
|
|
224
|
+
e.setAttribute("data-zintl",v);e.setAttribute("data-zcountry-code",Ke.selectedCountryCode||"");void De({specificSelector:e,timeoutId:u})}};var Ee=function(){var e=t.helloSettings.currencyElementSelector;var a=Ce(e);
|
|
219
225
|
// do nothing if none of the currency elements are found
|
|
220
|
-
if(!(a===null||a===void 0?void 0:a.length)){return}if(!
|
|
226
|
+
if(!(a===null||a===void 0?void 0:a.length)){return}if(!Ke.exchangeRate){n("Could not display currency. Exchange rate and format data is not available.");return}a.forEach((function(e){
|
|
221
227
|
// convert the currency and save the formatted value to the data-zintl attribute
|
|
222
|
-
|
|
228
|
+
Le(e)}))};var je=e("q",(function(){if(t.helloSettings.currencyBehavior==="DISABLED"||window.Zonos.isLegacyCheckout){void xe();return}
|
|
223
229
|
// BigCommerce renders prices server-side using its native currency selector
|
|
224
230
|
// (exposed via `document.body.dataset.currencyCode`). When that currency
|
|
225
231
|
// differs from `zonosStore.sourceCurrency`, the DOM amounts are not in the
|
|
226
232
|
// currency Hello would convert *from* — running conversion would double-
|
|
227
233
|
// convert and produce wrong prices.
|
|
228
|
-
if(window.Zonos.isBigCommerce){var e=document.body.dataset.currencyCode;if(e&&e!==t.sourceCurrency){
|
|
234
|
+
if(window.Zonos.isBigCommerce){var e=document.body.dataset.currencyCode;if(e&&e!==t.sourceCurrency){l('Skipping Hello currency conversion: BigCommerce native currency "'.concat(e,'" does not match sourceCurrency "').concat(t.sourceCurrency,'".'),"info");void xe();return}}Ee()}));var Ge=function(e){var a;var t=(a=Ke.shippingZoneCountries)===null||a===void 0?void 0:a[e];if(t){return t.currencyCode}return null};
|
|
229
235
|
/**
|
|
230
236
|
* Drop a remembered Hello country when widgetVisibility would hide the
|
|
231
237
|
* widget for it, then fall back to geo.
|
|
@@ -238,7 +244,7 @@ if(window.Zonos.isBigCommerce){var e=document.body.dataset.currencyCode;if(e&&e!
|
|
|
238
244
|
* default is `null`, not the current URL. Storage is cleared when geo
|
|
239
245
|
* succeeds, or when a load-time URL country won and the stored country
|
|
240
246
|
* would be hidden.
|
|
241
|
-
*/var
|
|
247
|
+
*/var Fe=function(){var e=[];for(var a=0;a<arguments.length;a++){e[a]=arguments[a]}return __awaiter(s,__spreadArray([],e,true),void 0,(function(e){var a,t,r;var o=e===void 0?{}:e,n=o.geoCountry,i=o.urlCountryAtLoad,l=i===void 0?null:i;return __generator(this,(function(e){switch(e.label){case 0:a=$();if(!a){return[2/*return*/,null]}if(ve(false,a)){return[2/*return*/,null]}if(l){te();return[2/*return*/,null]}if(!(n!==undefined))return[3/*break*/,1];r=n;return[3/*break*/,3];case 1:return[4/*yield*/,ne({ignoreCountryOverride:true})];case 2:r=e.sent().country;e.label=3;case 3:t=r;if(!t){return[2/*return*/,null]}te();return[2/*return*/,t]}}))}))};var Re=e("p",(function(e){if(!e){return}var a=new URLSearchParams(window.location.search);
|
|
242
248
|
// Only append zCountry if it's already in the URL or the countryOverrideBehavior is URL_PARAM
|
|
243
249
|
var r=a.has("zCountry")||t.helloSettings.countryOverrideBehavior==="URL_PARAM";if(r){
|
|
244
250
|
// Only append zCountry if it's not already in the URL
|
|
@@ -246,7 +252,7 @@ a.set("zCountry",e);var o="".concat(window.location.pathname,"?").concat(a.toStr
|
|
|
246
252
|
/**
|
|
247
253
|
* Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
|
|
248
254
|
* @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
|
|
249
|
-
**/window.history.replaceState(window.history.state,document.title,o)}}));var
|
|
255
|
+
**/window.history.replaceState(window.history.state,document.title,o)}}));var Ve="z--bc-currency-hide";
|
|
250
256
|
/**
|
|
251
257
|
* Hides BigCommerce's native currency selector while Hello is actively
|
|
252
258
|
* converting prices, and restores it otherwise. The selector is hidden
|
|
@@ -262,77 +268,81 @@ a.set("zCountry",e);var o="".concat(window.location.pathname,"?").concat(a.toStr
|
|
|
262
268
|
* If those conditions don't hold (non-BC platform, non-shippable country,
|
|
263
269
|
* BC currency differs from source, or the selector is not configured), the
|
|
264
270
|
* function removes the class so any previously hidden element re-appears.
|
|
265
|
-
*/var
|
|
271
|
+
*/var Xe=function(){var e,a;if(typeof window==="undefined"||!((e=window.Zonos)===null||e===void 0?void 0:e.isBigCommerce)){return}var r=(a=t.genericSettings)===null||a===void 0?void 0:a.bigcommerceNativeCurrencySelector;if(!r){return}var o=document.body.dataset.currencyCode;var i=(pe(false)||Ke.isShippableCountry)&&!!o&&o===t.sourceCurrency;try{var l=document.querySelectorAll(r);l.forEach((function(e){if(i){e.classList.add(Ve)}else{e.classList.remove(Ve)}}))}catch(e){n("Error toggling BigCommerce native currency selector: ".concat(e))}};var Be=a({allCountries:null,countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricingConfigurations:[],inclusivePricingIsFetching:false,isDisabledCountry:true,isShippableCountry:false,localizationLoaded:false,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),Oe=Be.onChange,Ke=Be.state;e({h:Oe,l:Ke});var We=function(e){return __awaiter(s,void 0,void 0,(function(){var a,r,o;return __generator(this,(function(n){switch(n.label){case 0:return[4/*yield*/,W({country:Ke.selectedCountryCode,isGuaranteed:e,sourceCurrency:t.sourceCurrency,targetCurrency:Ke.targetCurrency})];case 1:a=n.sent(),r=a.exchangeRate,o=a.maxAge;if(r){Ke.exchangeRate=r;je()}return[2/*return*/,{maxAge:o}]}}))}))};
|
|
266
272
|
/**
|
|
267
273
|
* CHORE: This is mostly for legacy checkout as the country param is not guaranteed.
|
|
268
|
-
*/var
|
|
274
|
+
*/var qe="CA";var Ye=e("C",(function(e){if(Ke.selectedCountryCode&&e.includes(Ke.selectedCountryCode)){return Ke.selectedCountryCode}
|
|
269
275
|
// Don't check if it is allowed. If it is not allowed it will fallback to Albania (first option).
|
|
270
|
-
return
|
|
276
|
+
return qe}));var Me=function(e){return __awaiter(s,void 0,void 0,(function(){var a;return __generator(this,(function(t){switch(t.label){case 0:if(!e){return[2/*return*/]}
|
|
271
277
|
// These requests are only needed for Hello, so we can skip them for legacy checkout
|
|
272
|
-
|
|
278
|
+
Ke.inclusivePricingIsFetching=true;return[4/*yield*/,q(e)];case 1:a=t.sent();Ke.inclusivePricingConfigurations=a||[];Ke.inclusivePricingIsFetching=false;return[2/*return*/]}}))}))};
|
|
273
279
|
// This recursive function is for users who step away from their computer and come back needing a new exchange rate
|
|
274
|
-
var
|
|
280
|
+
var Ze=function(e){var a=e.isGuaranteed,t=e.maxAge;if(Ke.exchangeRateTimeout){clearTimeout(Ke.exchangeRateTimeout)}
|
|
275
281
|
// maxAge comes in seconds, convert to milliseconds
|
|
276
282
|
var r=5*60;var o=t||r;
|
|
277
283
|
// Recursively set timeouts to get new exchange rates when the current one expires
|
|
278
|
-
|
|
284
|
+
Ke.exchangeRateTimeout=setTimeout((function(){return __awaiter(s,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:
|
|
279
285
|
// Refresh inclusive pricing configurations before getting a new exchange rate, so hello can use the new effective rate
|
|
280
|
-
return[4/*yield*/,
|
|
286
|
+
return[4/*yield*/,Me(Ke.selectedCountryCode)];case 1:
|
|
281
287
|
// Refresh inclusive pricing configurations before getting a new exchange rate, so hello can use the new effective rate
|
|
282
|
-
t.sent();return[4/*yield*/,
|
|
288
|
+
t.sent();return[4/*yield*/,We(a)];case 2:e=t.sent().maxAge;Ze({isGuaranteed:a,maxAge:e});return[2/*return*/]}}))}))}),o*1e3)};var He=function(e){return __awaiter(s,[e],void 0,(function(e){var a,r,o,n,i,s,u,d;var c=e.isInitializing;return __generator(this,(function(e){switch(e.label){case 0:l("get new localization store");o=Ke.isDisabledCountry,n=Ke.isShippableCountry,i=Ke.selectedCountryCode;if(t.helloSettings.currencyBehavior==="DISABLED"||!n||o||!i){return[2/*return*/]}s=t.checkoutSettings.visibilityStatus==="ENABLED";
|
|
283
289
|
// blur currency out before getting exchange rate
|
|
284
|
-
|
|
290
|
+
Ue();return[4/*yield*/,We(s)];case 1:u=e.sent().maxAge;Ze({isGuaranteed:s,maxAge:u});if(c&&((a=window.Zonos.cartSettings)===null||a===void 0?void 0:a.inclusivePriceConfigurations)){Ke.inclusivePricingConfigurations=((r=window.Zonos.cartSettings)===null||r===void 0?void 0:r.inclusivePriceConfigurations)||[];void xe()}if(!!window.Zonos.isLegacyCheckout)return[3/*break*/,3];Ke.inclusivePricingIsFetching=true;return[4/*yield*/,Promise.all([O(Ke.selectedCountryCode),Me(Ke.selectedCountryCode)])];case 2:d=e.sent()[0];Ke.countryLandedCost=d;
|
|
285
291
|
// Remove blur effect after the currency is converted
|
|
286
|
-
void
|
|
292
|
+
void xe();return[3/*break*/,4];case 3:l("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout");e.label=4;case 4:return[2/*return*/]}}))}))};var Je=function(){return __awaiter(s,void 0,void 0,(function(){var e,a,r;return __generator(this,(function(o){switch(o.label){case 0:e=Ke.selectedCountryCode;l("Getting custom messages for ".concat(e));if(!e||!t.storeId){return[2/*return*/]}return[4/*yield*/,Y({countryCode:e,localeTo:Ke.selectedLocale,storeId:t.storeId})];case 1:a=o.sent();if(Ke.selectedCountryCode!==e){return[2/*return*/]}r=a.flatMap((function(a){var t;return{countryCode:e,message:(t=a.countryCodesPageMessageLinks.find(Boolean))===null||t===void 0?void 0:t.message.textTo,pageName:a.pageName}}));Ke.customMessages=r;return[2/*return*/]}}))}))};var _e=function(){var e=new URL(window.location.href);var a=e.searchParams.get("zonosLocale");return a};var Qe=function(){if(Ke.isShippableCountry){document.body.classList.add("z-intl")}else{document.body.classList.remove("z-intl")}};var $e=function(e){if(e==="UK"){return"GB"}return e};
|
|
287
293
|
/**
|
|
288
294
|
* Clamps a locale to what the merchant offers. The requested locale comes from geolocation, the
|
|
289
295
|
* browser, or the `zonosLocale` param — none of which know about
|
|
290
296
|
* `appearanceSettings.supportedLocales` — so without this a shopper could land on a language the
|
|
291
297
|
* merchant has removed, with no way to switch back to it once the selector hides it.
|
|
292
|
-
*/var
|
|
298
|
+
*/var ea=function(e){var a=ye();if(a.some((function(a){return a.code===e}))){return e}
|
|
293
299
|
// prefer English when it is on offer, otherwise take the first language the merchant kept
|
|
294
|
-
var t=a.find((function(e){return e.code==="en"}))||a[0];
|
|
300
|
+
var t=a.find((function(e){return e.code==="en"}))||a[0];l("Locale ".concat(e," is not offered, falling back to ").concat(t===null||t===void 0?void 0:t.code));return(t===null||t===void 0?void 0:t.code)||"en"};var aa=function(e){var a;Re(e);(a=document.querySelector("zonos-hello"))===null||a===void 0?void 0:a.setAttribute("z-country",e)};var ta=e("d",(function(e){var a=e.isInitializing,r=e.newSelectedCountryCode,o=e.persistOverride;var n;l("Updating selected country code to ".concat(r));var i=!Ke.selectedCountryCode;Ke.selectedCountryCode=$e(r);var s=Ke.selectedCountryCode;var u=ce(s);
|
|
295
301
|
// update shippable country
|
|
296
|
-
|
|
302
|
+
Ke.isShippableCountry=u;l("".concat(Ke.selectedCountryCode," is a shippable country: ").concat(Ke.isShippableCountry));var d=!!s&&t.disabledCountries.includes(s);Ke.isDisabledCountry=d;l("".concat(Ke.selectedCountryCode," is a disabled country: ").concat(Ke.isDisabledCountry));Qe();
|
|
297
303
|
// Hide / restore BC's native currency selector based on the new
|
|
298
304
|
// shipping-zone state. Runs here (rather than inside `currencyDisplay`)
|
|
299
305
|
// because `currencyDisplay` is also invoked from the price-mutation
|
|
300
306
|
// observer in `zonos-hello.tsx`, which fires on every DOM render.
|
|
301
|
-
|
|
307
|
+
Xe();
|
|
302
308
|
// On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
303
309
|
// shopper added before switching to an international country so the Grand
|
|
304
310
|
// Total reflects only subtotal + coupon. No-ops off-cart, off-BigCommerce,
|
|
305
311
|
// for non-shippable countries, or when the cart has no consignment.
|
|
306
|
-
void
|
|
312
|
+
void he();if(!s){return}var c=Ge(s);var v=o!==null&&o!==void 0?o:!a;
|
|
307
313
|
// Only trigger onCountryChange after init — the first apply, and any
|
|
308
314
|
// reconcile fallback during init, are not shopper-selected changes.
|
|
309
|
-
if(!
|
|
315
|
+
if(!i&&!a){(n=t.onCountryChange)===null||n===void 0?void 0:n.call(t,{countryCode:s,currencyCode:c,isShippableCountry:u})}if(!c){
|
|
310
316
|
// Non-shippable country: revert any previously-converted international
|
|
311
317
|
// prices back to the merchant's domestic (source) currency before bailing.
|
|
312
|
-
if(
|
|
318
|
+
if(Ke.exchangeRateTimeout){clearTimeout(Ke.exchangeRateTimeout);Ke.exchangeRateTimeout=undefined}var p=t.sourceCurrency;Ke.targetCurrency=p;Ke.exchangeRate={rate:1,targetFormat:{currencyCode:p,decimalDelimiter:".",scale:2,symbol:"",symbolLocation:"before",thousandsDelimiter:","}};Ke.countryLandedCost=null;Ke.inclusivePricingConfigurations=[];je()}else{Ke.targetCurrency=c;
|
|
313
319
|
// Init may apply a remembered country that reconcile then discards. Fetch
|
|
314
320
|
// exchange rates once after reconcile for the final country instead.
|
|
315
|
-
if(!a){void
|
|
321
|
+
if(!a){void He({isInitializing:false})}}if(!a){void Je()}if(v){ae(s)}if(!a){aa(s)}}));var ra=function(e){var a,r,o,n,i,s;var u=t.helloSettings,d=u.countryDisplayRules,c=u.showCountryList;var v=Ke.shippingZoneCountries;var p=d===null||d===void 0?void 0:d.countrySelector;
|
|
316
322
|
// Resolve behavior: deprecated showCountryList overrides countrySelector.behavior
|
|
317
323
|
// If showCountryList is an array of country codes, treat as legacy explicit list
|
|
318
|
-
var m=Array.isArray(c)?c:c!==null&&c!==void 0?c:p===null||p===void 0?void 0:p.behavior;
|
|
324
|
+
var m=Array.isArray(c)?c:c!==null&&c!==void 0?c:p===null||p===void 0?void 0:p.behavior;l("Country selector behavior","info",{behavior:p===null||p===void 0?void 0:p.behavior,excludedCount:(r=(a=p===null||p===void 0?void 0:p.excludedCountries)===null||a===void 0?void 0:a.length)!==null&&r!==void 0?r:0,includedCount:(n=(o=p===null||p===void 0?void 0:p.includedCountries)===null||o===void 0?void 0:o.length)!==null&&n!==void 0?n:0,showCountryList:c});
|
|
319
325
|
// Legacy: explicit list of country codes from deprecated showCountryList
|
|
320
|
-
if(Array.isArray(m)){
|
|
326
|
+
if(Array.isArray(m)){Ke.helloCountryList=m.reduce((function(a,t){var r;var o=e===null||e===void 0?void 0:e[t];return o?Object.assign(Object.assign({},a),(r={},r[t]=o,r)):a}),{});return}
|
|
321
327
|
// Determine base country list from behavior
|
|
322
328
|
var h;if(m==="ALL"){h=Object.assign({},e)}else{
|
|
323
329
|
// Default: ONLY_SHIPPABLE
|
|
324
330
|
h=v?Object.assign({},v):{}}
|
|
325
331
|
// Apply includedCountries — add countries not already in the list
|
|
326
|
-
if((
|
|
332
|
+
if((i=p===null||p===void 0?void 0:p.includedCountries)===null||i===void 0?void 0:i.length){for(var g=0,y=p.includedCountries;g<y.length;g++){var f=y[g];if(!h[f]&&e[f]){h[f]=e[f]}}}
|
|
327
333
|
// Apply excludedCountries — remove countries from the list
|
|
328
|
-
if((s=p===null||p===void 0?void 0:p.excludedCountries)===null||s===void 0?void 0:s.length){for(var b=0,k=p.excludedCountries;b<k.length;b++){var f=k[b];delete h[f]}}
|
|
334
|
+
if((s=p===null||p===void 0?void 0:p.excludedCountries)===null||s===void 0?void 0:s.length){for(var b=0,k=p.excludedCountries;b<k.length;b++){var f=k[b];delete h[f]}}Ke.helloCountryList=h};var oa=function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t;return __generator(this,(function(r){switch(r.label){case 0:if(!m.checkoutSessionId){return[2/*return*/,null]}return[4/*yield*/,o("/api/zonos-elements/update-checkout-session-metadata",{body:{id:m.checkoutSessionId,metadata:[
|
|
329
335
|
// This is being used from the backend to determine the language of the checkout session
|
|
330
|
-
{key:"language",value:
|
|
336
|
+
{key:"language",value:Ke.selectedLocale}]},method:"POST"})];case 1:e=r.sent(),a=e.errors,t=e.json;if(a.length||!t){n("Error occurs when updating checkout session",JSON.stringify(a,null,2));return[2/*return*/,{errors:a,json:t}]}return[2/*return*/,{errors:[],json:t}]}}))}))};var na=e("D",(function(e){var a=ea(e);Ke.selectedLocale=a;V(a);void oa();if(Ke.localizationLoaded){void Je()}}));var ia=e("o",(function(){return __awaiter(s,void 0,void 0,(function(){var e,a,t,r,o,n,i,s,u,d,c,v,p,m,h,g;return __generator(this,(function(y){switch(y.label){case 0:a=re();t=$();r=!!t&&!a;return[4/*yield*/,Promise.all([B(),ie(),ne(),r?ne({ignoreCountryOverride:true}):Promise.resolve(undefined)])];case 1:o=y.sent(),n=o[0],i=o[1],s=o[2],u=o[3];d=i===null||i===void 0?void 0:i.reduce((function(e,a){var t;var r=n===null||n===void 0?void 0:n[a];return r?Object.assign(Object.assign({},e),(t={},t[a]=r,t)):e}),{});Ke.allCountries=n;Ke.shippingZoneCountries=d||null;Ke.inclusivePricingConfigurations=((e=window.Zonos.cartSettings)===null||e===void 0?void 0:e.inclusivePriceConfigurations)||[];
|
|
331
337
|
// Initialize the country list for the hello widget
|
|
332
|
-
|
|
338
|
+
ra(n||{});c=s.country,v=s.locale;l("Country code from localization: ".concat(c));l("Locale from localization: ".concat(v));
|
|
333
339
|
// update selected country code in store
|
|
334
|
-
|
|
340
|
+
ta({isInitializing:true,newSelectedCountryCode:c||t});p=_e();na(p||v||"en");m=["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"];h=new URLSearchParams(window.location.search);
|
|
335
341
|
// If the country code is not set, set it to the US for development (vercel can't get geo country in dev)
|
|
336
|
-
if(!
|
|
342
|
+
if(!Ke.selectedCountryCode&&(m.some((function(e){return window.location.origin.includes(e)}))||h.get("zonosQaUrl")==="dev-elements")){
|
|
337
343
|
// update selected country code in store
|
|
338
|
-
|
|
344
|
+
ta({isInitializing:true,newSelectedCountryCode:"CA"})}return[4/*yield*/,Fe({geoCountry:u===null||u===void 0?void 0:u.country,urlCountryAtLoad:a})];case 2:g=y.sent();if(g){ta({isInitializing:true,newSelectedCountryCode:g})}
|
|
345
|
+
// After reconcile + fallback: only then is selectedCountryCode the
|
|
346
|
+
// country Hello kept. Mirroring earlier (or without this match) can
|
|
347
|
+
// publish a discarded localStorage leftover into sessionStorage.
|
|
348
|
+
ee(Ke.selectedCountryCode);if(Ke.selectedCountryCode){aa(Ke.selectedCountryCode)}void Je();void He({isInitializing:true});if(!Ke.localizationLoaded){Ke.localizationLoaded=true;void he();void Xe()}return[2/*return*/]}}))}))}))}}}));
|