@zonos/elements 1.5.2 → 1.5.3
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/_isBigCommerceNativeCheckout-3-xbKbAO.js +133 -0
- package/dist/cjs/{cart-BJpqPdFU.js → cart-C39TMSgB.js} +14 -0
- package/dist/cjs/{collect-CyUttsvB.js → collect-lF9DenLk.js} +2 -2
- package/dist/cjs/{getMissingRequiredShippingFields-DEbNbRAZ.js → getMissingRequiredShippingFields-svcnpumn.js} +1 -1
- package/dist/cjs/index.cjs.js +61 -42
- package/dist/cjs/{invoice-DzRkkpLu.js → invoice-BD3pCr8P.js} +1 -1
- package/dist/cjs/{paypal-DCSqbdjW.js → paypal-Bd1qmwiv.js} +1 -1
- package/dist/cjs/{placeTestOrder-Bkip4PUT.js → placeTestOrder-BMQRvX2q.js} +1 -1
- package/dist/cjs/{renderCheckoutCurrency-BDvEZ3Hv.js → renderCheckoutCurrency-DE2p8CT8.js} +1 -1
- package/dist/cjs/{taxIdFields-e4OCgr8K.js → taxIdFields-BKbk2bhi.js} +1 -1
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +4 -4
- package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +2 -2
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +5 -5
- package/dist/cjs/zonos-checkout.cjs.entry.js +41 -15
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +5 -5
- package/dist/cjs/zonos-collect.cjs.entry.js +3 -3
- package/dist/cjs/zonos-controller.cjs.entry.js +63 -38
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +5 -5
- package/dist/cjs/zonos-invoice.cjs.entry.js +3 -3
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +10 -1
- package/dist/collection/components/main/mountCheckoutWithoutStripe.js +12 -0
- package/dist/collection/components/main/zonos-controller.js +24 -9
- package/dist/collection/components/store/checkout/stripe.js +13 -1
- package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +2 -1
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +32 -12
- package/dist/collection/scripts/_bigcommerceCheckoutPath.js +16 -0
- package/dist/collection/scripts/_detectBigCommerceHost.js +12 -0
- package/dist/collection/scripts/_isBigCommerceNativeCheckout.js +107 -0
- package/dist/collection/scripts/_loadStripe.js +15 -4
- package/dist/collection/scripts/_zonosBase.js +40 -31
- package/dist/esm/_isBigCommerceNativeCheckout-Bb90IMVt.js +128 -0
- package/dist/esm/{cart-BS5mSI8x.js → cart-b84n0nhi.js} +14 -2
- package/dist/esm/{collect-B9ZxDDl7.js → collect-B_AEVONL.js} +3 -3
- package/dist/esm/{getMissingRequiredShippingFields-BkEV865q.js → getMissingRequiredShippingFields-EY10c34-.js} +1 -1
- package/dist/esm/{hasInclusivePrice-zSvDReDb.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
- package/dist/esm/index.js +61 -42
- package/dist/esm/{invoice-6iTuS6ek.js → invoice-dQ0ONK5Q.js} +2 -2
- package/dist/esm/{localization-CXHiWcJp.js → localization-B5CRzthT.js} +1 -1
- package/dist/esm/{paypal-BE_NVBoy.js → paypal-CF_oM0B6.js} +2 -2
- package/dist/esm/{placeTestOrder-BXA9K9Iy.js → placeTestOrder-BTpfyqPL.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-KMa4HlAf.js → renderCheckoutCurrency-CpeuDWx-.js} +2 -2
- package/dist/esm/{shouldShowLanguageSelect-BI_ApEsQ.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
- package/dist/esm/{taxIdFields-BUKnHMaL.js → taxIdFields-BCyXnc9O.js} +2 -2
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +5 -5
- package/dist/esm/zonos-address-display_2.entry.js +1 -1
- package/dist/esm/zonos-address_4.entry.js +3 -3
- 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 +42 -16
- 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 +63 -38
- 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/_isBigCommerceNativeCheckout-Bb90IMVt.js +40 -0
- package/dist/esm-es5/{cart-BS5mSI8x.js → cart-b84n0nhi.js} +9 -9
- package/dist/esm-es5/{collect-B9ZxDDl7.js → collect-B_AEVONL.js} +2 -2
- package/dist/esm-es5/{getMissingRequiredShippingFields-BkEV865q.js → getMissingRequiredShippingFields-EY10c34-.js} +3 -3
- package/dist/esm-es5/{hasInclusivePrice-zSvDReDb.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
- package/dist/esm-es5/index.js +76 -65
- package/dist/esm-es5/{invoice-6iTuS6ek.js → invoice-dQ0ONK5Q.js} +1 -1
- package/dist/esm-es5/{localization-CXHiWcJp.js → localization-B5CRzthT.js} +1 -1
- package/dist/esm-es5/{paypal-BE_NVBoy.js → paypal-CF_oM0B6.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-BXA9K9Iy.js → placeTestOrder-BTpfyqPL.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-KMa4HlAf.js → renderCheckoutCurrency-CpeuDWx-.js} +4 -4
- package/dist/esm-es5/{shouldShowLanguageSelect-BI_ApEsQ.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
- package/dist/esm-es5/{taxIdFields-BUKnHMaL.js → taxIdFields-BCyXnc9O.js} +2 -2
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +2 -2
- 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 +20 -9
- 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 +6 -6
- package/dist/esm-es5/zonos-controller.entry.js +22 -13
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- 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.d.ts +16 -0
- 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/main/mountCheckoutWithoutStripe.d.ts +8 -0
- package/dist/types/components/store/checkout/stripe.d.ts +4 -1
- package/dist/types/scripts/_bigcommerceCheckoutPath.d.ts +12 -0
- package/dist/types/scripts/_detectBigCommerceHost.d.ts +5 -0
- package/dist/types/scripts/_isBigCommerceNativeCheckout.d.ts +21 -0
- package/dist/types/scripts/_zonosBase.d.ts +16 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-08b01c96.entry.js → p-02faff47.entry.js} +1 -1
- package/dist/zonos-elements/{p-573a4e7c.system.entry.js → p-0c68cbbb.system.entry.js} +6 -6
- package/dist/zonos-elements/{p-68325c5a.system.entry.js → p-1cd2d097.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-af741506.entry.js → p-255e411a.entry.js} +1 -1
- package/dist/zonos-elements/{p-dJcbnNlE.system.js → p-2c_UqKJL.system.js} +2 -2
- package/dist/zonos-elements/{p-BUfCTQXY.system.js → p-3AUMK-5E.system.js} +113 -113
- package/dist/zonos-elements/{p-dd003161.entry.js → p-3ee87d8b.entry.js} +1 -1
- package/dist/zonos-elements/{p-8f9f859f.system.entry.js → p-42fa5694.system.entry.js} +5 -5
- package/dist/zonos-elements/p-49eaaab8.entry.js +1 -0
- package/dist/zonos-elements/{p-ebc7ea54.system.entry.js → p-4ce4c49f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9b3668a4.system.entry.js → p-5622fc50.system.entry.js} +263 -252
- package/dist/zonos-elements/{p-3a506614.system.entry.js → p-59457fd9.system.entry.js} +71 -62
- package/dist/zonos-elements/{p-7fe83919.entry.js → p-66398133.entry.js} +1 -1
- package/dist/zonos-elements/{p-9df31243.system.entry.js → p-674323ac.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-97729873.entry.js → p-71d9a5b7.entry.js} +1 -1
- package/dist/zonos-elements/{p-30bf4700.system.entry.js → p-81780f8f.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-1986cc37.entry.js → p-821b83a2.entry.js} +1 -1
- package/dist/zonos-elements/{p-5a296dbc.system.entry.js → p-877a82d2.system.entry.js} +61 -61
- package/dist/zonos-elements/p-8daec112.entry.js +1 -0
- package/dist/zonos-elements/{p-150047b3.system.entry.js → p-93bc75fd.system.entry.js} +19 -19
- package/dist/zonos-elements/{p-b540c636.system.entry.js → p-976b3bf3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4b65f192.entry.js → p-9a4947a5.entry.js} +1 -1
- package/dist/zonos-elements/p-9f7693bf.entry.js +1 -0
- package/dist/zonos-elements/{p-D4xpkSsK.js → p-BIJM2Kj-.js} +1 -1
- package/dist/zonos-elements/{p-D-Lnf8mS.system.js → p-BOh4ifdL.system.js} +2 -2
- package/dist/zonos-elements/p-BZAX-HmS.js +1 -0
- package/dist/zonos-elements/p-Bb90IMVt.js +1 -0
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-DC1OPJDq.system.js → p-BvoPE_nb.system.js} +1 -1
- package/dist/zonos-elements/{p-C5fs3rIR.js → p-C3E55OqH.js} +1 -1
- package/dist/zonos-elements/{p-BnQyot7Y.system.js → p-C3gF3UV5.system.js} +29 -29
- package/dist/zonos-elements/{p-BKUlQxBd.system.js → p-CD2ahEZn.system.js} +1 -1
- package/dist/zonos-elements/p-CEBBLbvF.js +1 -0
- package/dist/zonos-elements/{p-Cp1IAJvW.system.js → p-CEV0O_IQ.system.js} +4 -4
- package/dist/zonos-elements/{p-yv7ekcdG.system.js → p-CZ-uYiCo.system.js} +2 -2
- package/dist/zonos-elements/{p-CP7KnfR3.system.js → p-Cn2xE-9t.system.js} +79 -68
- package/dist/zonos-elements/p-CtvXi9wL.system.js +41 -0
- package/dist/zonos-elements/{p-Dv5a-V6w.system.js → p-Cw_Qnyow.system.js} +1 -1
- package/dist/zonos-elements/p-CzXNXgyI.js +1 -0
- package/dist/zonos-elements/{p-CVRbGFV3.js → p-D9OPKqLg.js} +1 -1
- package/dist/zonos-elements/{p-DrbN3rPL.js → p-Df62LRNs.js} +2 -2
- package/dist/zonos-elements/{p-DKnphvmJ.js → p-Lsqrpzc5.js} +1 -1
- package/dist/zonos-elements/{p-DrS-0mk7.system.js → p-YQFbWtjn.system.js} +1 -1
- package/dist/zonos-elements/p-a27f48e4.entry.js +1 -0
- package/dist/zonos-elements/{p-bb1b414a.system.entry.js → p-a6bb296c.system.entry.js} +6 -6
- package/dist/zonos-elements/{p-13015d34.system.entry.js → p-abb85879.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-383343c7.entry.js → p-b8653024.entry.js} +1 -1
- package/dist/zonos-elements/p-b9d7a3b6.entry.js +1 -0
- package/dist/zonos-elements/{p-96b250d8.system.entry.js → p-be067e12.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-Cl5yV0ak.js → p-bmrOH9oh.js} +1 -1
- package/dist/zonos-elements/{p-71d29603.entry.js → p-c185bc23.entry.js} +1 -1
- package/dist/zonos-elements/{p-13d5b2f9.entry.js → p-c6e78de2.entry.js} +1 -1
- package/dist/zonos-elements/{p-a3c147d2.system.entry.js → p-ca97a1cd.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-0909ef77.entry.js → p-cbb96382.entry.js} +1 -1
- package/dist/zonos-elements/{p-6db7317a.system.entry.js → p-dbf4d156.system.entry.js} +14 -14
- package/dist/zonos-elements/{p-e43470f7.system.entry.js → p-df240119.system.entry.js} +17 -17
- package/dist/zonos-elements/{p-f2ed52bc.system.entry.js → p-e16e4db6.system.entry.js} +15 -15
- package/dist/zonos-elements/{p-7214c953.system.entry.js → p-eb016dd8.system.entry.js} +16 -16
- package/dist/zonos-elements/{p-709d1561.system.entry.js → p-eb5c67a0.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e374aaa4.entry.js → p-ed8a7a7f.entry.js} +1 -1
- package/dist/zonos-elements/{p-3466bcba.entry.js → p-ef932fda.entry.js} +1 -1
- package/dist/zonos-elements/{p-bfa9e32a.entry.js → p-f792ba5f.entry.js} +1 -1
- package/dist/zonos-elements/{p-aK18R41t.js → p-fZcKMzE-.js} +1 -1
- package/dist/zonos-elements/{p-C-zdj7MK.js → p-fdritVtG.js} +1 -1
- package/dist/zonos-elements/p-fffe6376.entry.js +1 -0
- package/dist/zonos-elements/{p-CMneHjck.system.js → p-v8IEjQ2z.system.js} +10 -10
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +10 -10
- package/dist/zonos-elements/p-43c0ebe9.entry.js +0 -1
- package/dist/zonos-elements/p-8ac26831.entry.js +0 -1
- package/dist/zonos-elements/p-BI6VAB5B.js +0 -1
- package/dist/zonos-elements/p-BJ_kE5rM.js +0 -1
- package/dist/zonos-elements/p-DATNIakn.js +0 -1
- package/dist/zonos-elements/p-af4ad54b.entry.js +0 -1
- package/dist/zonos-elements/p-bac94956.entry.js +0 -1
- package/dist/zonos-elements/p-cf6bf7a4.entry.js +0 -1
- package/dist/zonos-elements/p-db40b9c3.entry.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?r(e.value):n(e.value).then(a,s)}d((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return d([e,t])}}function d(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{c as createStore,z as zonosStore,e as getShouldRequirePeruTaxId}from"./zonosStore-BXP9FvIt.js";import{s as storageStore,t as translate,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?r(e.value):n(e.value).then(a,s)}d((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return d([e,t])}}function d(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{c as createStore,z as zonosStore,e as getShouldRequirePeruTaxId}from"./zonosStore-BXP9FvIt.js";import{s as storageStore,t as translate,n as getOverridenZCountry,l as localizationStore,f as filterValidTests,e as storageStoreSetEnabledVariantTestKeys}from"./localization-B5CRzthT.js";import{b as isPeruTaxIdActive,e as taxIdTypeOptionsForCheckout}from"./taxIdRules-xYlx7ZXW.js";import{e as euCountryCodes,i as isCountryRequireTaxId}from"./TaxId-DMIgN_sT.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{h as handleFetch,l as logError,f as fallbackApiList,g as getIsTestMode,a as getIsStagingMode,s as sendErrorLog,c as safeGetItem,e as safeSetItem,b as safeRemoveItem,j as jsonParse}from"./handleFetch-BFVO7oAR.js";import{i as isDarkColor}from"./isDarkColor-YdrG78th.js";import{g as getBorderRadius}from"./getBorderRadius-BiGd45jw.js";var getCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:if(!storageStore.checkoutSessionId){return[2/*return*/,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",storageStore.checkoutSessionId);return[4/*yield*/,handleFetch("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:t=n.sent(),r=t.errors,o=t.json;return[2/*return*/,{errors:r,json:o}]}}))}))};var _o=createStore((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),reset$2=_o.reset,storeCreditStore=_o.state;
|
|
2
2
|
/**
|
|
3
3
|
* Reset store credit store to initial state
|
|
4
4
|
*/var storeCreditStoreReset=function(){reset$2()};
|
|
@@ -189,9 +189,9 @@ theme:i?u:l,variables:Object.assign(Object.assign({},defaultVariable({borderStyl
|
|
|
189
189
|
// use the button background color for input glow color
|
|
190
190
|
colorPrimary:d})},
|
|
191
191
|
// Client secret can be undefined since we will load other elements that doesn't require client secret first, then load client secret and render one that requires it later
|
|
192
|
-
clientSecret:v,customerSessionClientSecret:stripeStore.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],S,true),locale:localizationStore.selectedLocale}};var stripeStoreCleanupDomesticShippingSession=function(){safeRemoveItem("session","zonos--bigcommerce-domestic-checkout-shipping")};
|
|
192
|
+
clientSecret:v,customerSessionClientSecret:stripeStore.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],S,true),locale:localizationStore.selectedLocale}};var DOMESTIC_SESSION_REDIRECT_MARKER="zonos--bc-domestic-session-redirected";var clearDomesticSessionRedirectMarker=function(){safeRemoveItem("session",DOMESTIC_SESSION_REDIRECT_MARKER)};var stripeStoreHasDomesticSessionRedirectMarker=function(){return safeGetItem("session",DOMESTIC_SESSION_REDIRECT_MARKER)==="1"};var stripeStoreMarkDomesticSessionRedirected=function(){safeSetItem("session",DOMESTIC_SESSION_REDIRECT_MARKER,"1")};var stripeStoreCleanupDomesticShippingSession=function(){safeRemoveItem("session","zonos--bigcommerce-domestic-checkout-shipping");clearDomesticSessionRedirectMarker()};
|
|
193
193
|
// Save shipping address to session storage
|
|
194
|
-
var stripeStoreSaveDomesticShippingSession=function(e){safeSetItem("session","zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))};var stripeStoreGetDomesticShippingSession=function(){var e=safeGetItem("session","zonos--bigcommerce-domestic-checkout-shipping");return jsonParse(e)};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){o=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2/*return*/]}n=getStripeOptions({clientSecret:o,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(n)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements||!stripeStore.stripeElementsForBillingAddress){
|
|
194
|
+
var stripeStoreSaveDomesticShippingSession=function(e){clearDomesticSessionRedirectMarker();safeSetItem("session","zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))};var stripeStoreGetDomesticShippingSession=function(){var e=safeGetItem("session","zonos--bigcommerce-domestic-checkout-shipping");return jsonParse(e)};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){o=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2/*return*/]}n=getStripeOptions({clientSecret:o,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(n)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements||!stripeStore.stripeElementsForBillingAddress){
|
|
195
195
|
// init stripe elements for billing address
|
|
196
196
|
stripeStore.stripeElementsForBillingAddress=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(n);log("Stripe elements for billing address initialized");
|
|
197
197
|
// init stripe elements if it doesn't exist
|
|
@@ -485,17 +485,17 @@ cartStoreApplySubtotals({method:((t=i.checkoutSessionUpdate.landedCost)===null||
|
|
|
485
485
|
if(e.method==="DAP"&&((o=(r=zonosStore.genericSettings)===null||r===void 0?void 0:r.domesticCountries)===null||o===void 0?void 0:o.includes(((n=stripeStore.stripeAddressEventData)===null||n===void 0?void 0:n.value.address.country)||"US"))){return"DDP"}
|
|
486
486
|
// EU 3-EUR cutover (05CHECK-893): keep EU POSTAL remittance quotes as DAP so
|
|
487
487
|
// the shopper is told duties are paid upon delivery, even though we remit.
|
|
488
|
-
if(isEuDapRemittance({deliveryType:t,landedCost:e,shipToCountry:(i=stripeStore.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,l,u,S,v,p,f,m,h,g,C,y,w,b,A,
|
|
488
|
+
if(isEuDapRemittance({deliveryType:t,landedCost:e,shipToCountry:(i=stripeStore.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,l,u,S,v,p,f,m,h,g,C,y,w,I,b,A,O,_;var T=e.applySubtotalsOnly,E=e.landedCostId,k=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:log("Updating selected shipping option","info",{landedCostId:E,selectedShippingOption:k});cartStore.selectedShippingOption=k;v=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);if(v){p=v.maxTransit,f=v.minTransit,m=v.unit;cartStore.selectedShippingOptionTransitTime="".concat(f,"-").concat(p," ").concat(m)}else{cartStore.selectedShippingOptionTransitTime=""}h=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===E}));
|
|
489
489
|
// save selected landed cost for later use
|
|
490
490
|
cartStore.selectedLandedCost=h||null;if(!h){
|
|
491
491
|
// do nothing if we can't find landed cost for selected shipping option
|
|
492
|
-
return[2/*return*/,false]}g=((r=h.landedCost.amountSubtotals)===null||r===void 0?void 0:r.landedCostTotal)||0;C=h.subtotals.exchangeRate.rate;y=g*C;if(y){log("DAP quote, using estimate: ".concat(y),"info")}cartStore.landedCostMethod=cartStoreGetMethod(h.landedCost,(o=
|
|
492
|
+
return[2/*return*/,false]}g=((r=h.landedCost.amountSubtotals)===null||r===void 0?void 0:r.landedCostTotal)||0;C=h.subtotals.exchangeRate.rate;y=g*C;if(y){log("DAP quote, using estimate: ".concat(y),"info")}cartStore.landedCostMethod=cartStoreGetMethod(h.landedCost,(o=k.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.deliveryType);
|
|
493
493
|
// update shipping value and dutiesTaxFees on selectedShippingOption change
|
|
494
|
-
cartStore.shipping=h.subtotals.shipping;w=((n=h===null||h===void 0?void 0:h.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";
|
|
494
|
+
cartStore.shipping=h.subtotals.shipping;w=((n=h===null||h===void 0?void 0:h.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";I=!!((a=(i=h===null||h===void 0?void 0:h.landedCost)===null||i===void 0?void 0:i.deMinimis)===null||a===void 0?void 0:a.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=I;cartStore.isSelectedShippingGuarantee=w;b=false;if(!T)return[3/*break*/,1];A=h.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:y,method:cartStore.landedCostMethod,subtotals:A});log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate);b=true;return[3/*break*/,3];case 1:return[4/*yield*/,cartStoreReCalculateTotal({adjustmentsAmount:cartStore.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:y,landedCostId:(s=h.landedCost)===null||s===void 0?void 0:s.id})];case 2:
|
|
495
495
|
// update session with selected landed cost
|
|
496
|
-
|
|
496
|
+
b=e.sent();e.label=3;case 3:O=(d=cartStore.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;_=((c=stripeStore.stripeAddressEventData)===null||c===void 0?void 0:c.value.address.country)||"US";
|
|
497
497
|
// Only show pay in USD button if item's currency is in USD, the setting is enabled and the order presentment currency is not USD, also only in USD settlement ship to country list
|
|
498
|
-
stripeStore.shouldRenderPayInUsdButton=O==="USD"&&zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((l=cartStore.checkoutSession)===null||l===void 0?void 0:l.subtotals.presentmentCurrencyCode)!=="USD"&&!!((S=(u=zonosStore.genericSettings)===null||u===void 0?void 0:u.usdSettlementCountryEnabled)===null||S===void 0?void 0:S.includes(_));return[2/*return*/,
|
|
498
|
+
stripeStore.shouldRenderPayInUsdButton=O==="USD"&&zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((l=cartStore.checkoutSession)===null||l===void 0?void 0:l.subtotals.presentmentCurrencyCode)!=="USD"&&!!((S=(u=zonosStore.genericSettings)===null||u===void 0?void 0:u.usdSettlementCountryEnabled)===null||S===void 0?void 0:S.includes(_));return[2/*return*/,b]}}))}))};var cartStoreStartCheckoutInterval=function(e){var t=e.isPreview,r=e.sessionTimeout;
|
|
499
499
|
// do nothing if in preview mode
|
|
500
500
|
if(t){return}var o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var n=
|
|
501
501
|
// timeout query is mainly for testing purpose
|
|
@@ -525,4 +525,4 @@ cartStoreApplySubtotals({method:((t=d.checkoutSessionUpdate.landedCost)===null||
|
|
|
525
525
|
/**
|
|
526
526
|
* Update the checkout session with the current store credit selection.
|
|
527
527
|
* Debounced to prevent multiple rapid requests when store changes cascade.
|
|
528
|
-
*/var cartStoreUpdateStoreCredit=function(){if(storeCreditUpdateTimeout){clearTimeout(storeCreditUpdateTimeout)}storeCreditUpdateTimeout=setTimeout((function(){storeCreditUpdateTimeout=null;void cartStoreUpdateStoreCreditImmediate()}),300)};export{
|
|
528
|
+
*/var cartStoreUpdateStoreCredit=function(){if(storeCreditUpdateTimeout){clearTimeout(storeCreditUpdateTimeout)}storeCreditUpdateTimeout=setTimeout((function(){storeCreditUpdateTimeout=null;void cartStoreUpdateStoreCreditImmediate()}),300)};export{cartStoreUpdateSelectedShippingOption as $,isPolicyConsentRequired as A,stripeStoreUpdateCheckoutSessionBaseCurrency as B,storeCreditStoreApplyCredit as C,storeCreditStoreCoversFullAmount as D,validateCheckoutSession as E,storeCreditStoreCreateOrder as F,stripeStoreConfirmPayment as G,stripeStoreHandleInventoryRefund as H,policyConsentStore as I,stripeStoreReset as J,cartStoreOnChange as K,stripeStoreOnChange as L,storeCreditStoreGetEffectiveAmount as M,cartStoreHasOneEligibleItem as N,isEuDapRemittance as O,stripeStoreApplyPromoCode as P,stripeStoreRemovePromoCode as Q,stripeStoreResetPromoCode as R,stripeStoreMessageBasedOnStatus as S,storeCreditStore as T,storeCreditStoreReset as U,stripeStoreRecordPolicyConsent as V,extractName as W,resolveTaxIdSelection as X,stripeStoreTranslateAddressToLatin as Y,getCountryField as Z,stripeStoreAsyncAddressUpdate as _,stripeStoreHasDomesticSessionRedirectMarker as a,cartStoreGetShippingTransitInfo as a0,cartStoreGetMethod as a1,sortServiceLevelOptionsByAmount as a2,stripeStoreBuildAddressForPartyCreate as a3,getEnabledPolicies as a4,storeCreditStoreSetEnabled as a5,storeCreditStoreSetUseFullBalance as a6,cartStoreUpdateStoreCredit as a7,storeCreditStoreSetAmount as a8,storeCreditStoreRefreshBalance as a9,stripeStoreCleanupDomesticShippingSession as b,stripeStoreMarkDomesticSessionRedirected as c,stripeStoreSaveDomesticShippingSession as d,stripeStore as e,stripeStoreRetrievePayment as f,getCheckoutSession as g,cartStore as h,initStripeElements as i,cartStoreUpdateItems as j,cartStoreReset as k,cartStoreResetTabItems as l,cartStoreClearCheckoutInterval as m,stripeStoreInitCheckoutSession as n,stripeStoreGetPaymentIntent as o,policyConsentStoreReset as p,cartStoreIsOrderModificationPaymentOnlySession as q,stripeStoreHandleInventoryCheck as r,stripeStoreGetDomesticShippingSession as s,cartStoreStartCheckoutInterval as t,trackConversionEvent as u,getCheckoutSessionBody as v,cartStoreUpdateToErrorState as w,cartStoreSetCheckoutSession as x,stripeStorePrefetchLandedCost as y,cartStoreNextStep as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((n=n.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-BXP9FvIt.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((n=n.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-BXP9FvIt.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-B5CRzthT.js";import{l as logError$1,h as handleFetch,s as sendErrorLog}from"./handleFetch-BFVO7oAR.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{h as cartStore,$ as cartStoreUpdateSelectedShippingOption,e as stripeStore,a3 as stripeStoreBuildAddressForPartyCreate}from"./cart-b84n0nhi.js";
|
|
2
2
|
// src/constant/common.ts
|
|
3
3
|
function _array_like_to_array(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,r,t,n,i,o,a){try{var s=e[o](a);var u=s.value}catch(e){t(e);return}if(s.done){r(u)}else{Promise.resolve(u).then(n,i)}}function _async_to_generator(e){return function(){var r=this,t=arguments;return new Promise((function(n,i){var o=e.apply(r,t);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(undefined)}))}}function _class_call_check(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){if(r)_defineProperties(e.prototype,r);return e}function _define_property(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function _instanceof(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function _iterable_to_array(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _iterable_to_array_limit(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var i=true;var o=false;var a,s;try{for(t=t.call(e);!(i=(a=t.next()).done);i=true){n.push(a.value);if(n.length===r)break}}catch(e){o=true;s=e}finally{try{if(!i&&t["return"]!=null)t["return"]()}finally{if(o)throw s}}return n}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))}n.forEach((function(r){_define_property(e,r,t[r])}))}return e}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}function _object_spread_props(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _sliced_to_array(e,r){return _array_with_holes(e)||_iterable_to_array_limit(e,r)||_unsupported_iterable_to_array(e,r)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(!e)return;if(typeof e==="string")return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor)t=e.constructor.name;if(t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(e,r)}function _ts_generator(e,r){var t,n,i,o,a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(r){return u([e,r])}}function u(o){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(i=o[0]&2?n["return"]:o[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;if(n=0,i)o=[o[0]&2,i.value];switch(o[0]){case 0:case 1:i=o;break;case 4:a.label++;return{value:o[1],done:false};case 5:a.label++;n=o[1];o=[0];continue;case 7:o=a.ops.pop();a.trys.pop();continue;default:if(!(i=a.trys,i=i.length>0&&i[i.length-1])&&(o[0]===6||o[0]===2)){a=0;continue}if(o[0]===3&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(o[0]===6&&a.label<i[1]){a.label=i[1];i=o;break}if(i&&a.label<i[2]){a.label=i[2];a.ops.push(o);break}if(i[2])a.ops.pop();a.trys.pop();continue}o=r.call(e,a)}catch(e){o=[6,e];n=0}finally{t=i=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}var Environment=function(e){e["production"]="prod";e["demo"]="demo";e["staging"]="staging";return e}(Environment||{});
|
|
4
4
|
// src/constant/config.ts
|
|
@@ -96,7 +96,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
96
96
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
97
97
|
PERFORMANCE OF THIS SOFTWARE.
|
|
98
98
|
***************************************************************************** */
|
|
99
|
-
/* global Reflect, Promise, SuppressedError, Symbol */var extendStatics=function(e,r){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))e[t]=r[t]};return extendStatics(e,r)};function __extends(e,r){if(typeof r!=="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");extendStatics(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var __assign=function(){__assign=Object.assign||function e(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[o]=t[o]}return r};return __assign.apply(this,arguments)};function __awaiter(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(r,t){function o(e){try{s(n.next(e))}catch(e){t(e)}}function a(e){try{s(n["throw"](e))}catch(e){t(e)}}function s(e){e.done?r(e.value):i(e.value).then(o,a)}s((n=n.apply(e,[])).next())}))}function __generator(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}function __spreadArray(e,r,t){for(var n=0,i=r.length,o;n<i;n++){if(o||!(n in r)){if(!o)o=Array.prototype.slice.call(r,0,n);o[n]=r[n]}}return e.concat(o||Array.prototype.slice.call(r))}typeof SuppressedError==="function"?SuppressedError:function(e,r,t){var n=new Error(t);return n.name="SuppressedError",n.error=e,n.suppressed=r,n};var version="1.35.
|
|
99
|
+
/* global Reflect, Promise, SuppressedError, Symbol */var extendStatics=function(e,r){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))e[t]=r[t]};return extendStatics(e,r)};function __extends(e,r){if(typeof r!=="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");extendStatics(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var __assign=function(){__assign=Object.assign||function e(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[o]=t[o]}return r};return __assign.apply(this,arguments)};function __awaiter(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(r,t){function o(e){try{s(n.next(e))}catch(e){t(e)}}function a(e){try{s(n["throw"](e))}catch(e){t(e)}}function s(e){e.done?r(e.value):i(e.value).then(o,a)}s((n=n.apply(e,[])).next())}))}function __generator(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}function __spreadArray(e,r,t){for(var n=0,i=r.length,o;n<i;n++){if(o||!(n in r)){if(!o)o=Array.prototype.slice.call(r,0,n);o[n]=r[n]}}return e.concat(o||Array.prototype.slice.call(r))}typeof SuppressedError==="function"?SuppressedError:function(e,r,t){var n=new Error(t);return n.name="SuppressedError",n.error=e,n.suppressed=r,n};var version="1.35.2";var packageJson={version:version};var airTrackerENV={dev:Environment.staging,staging:Environment.staging,demo:Environment.demo,prod:Environment.production};var initializeAirTracker=function(e,r){if(e===void 0){e=Environment.production}if(!window._AirwallexSDKs.airTracker){window._AirwallexSDKs.airTracker=new src_default({config:{appName:"components-sdk",appVersion:packageJson.version,env:airTrackerENV[e]||Environment.production}});window._AirwallexSDKs.airTracker.updateCommonData({clientId:r})}return window._AirwallexSDKs.airTracker};var maskPII=function(e){if(typeof e!=="object"){return e}try{var r=JSON.parse(JSON.stringify(e));Object.keys(r).forEach((function(e){if(typeof e==="string"&&["auth","code"].some((function(r){return e.includes(r)}))){r[e]="***"}}));return r}catch(r){return e}};var logError=function(e,r){var t,n;(n=(t=window._AirwallexSDKs)===null||t===void 0?void 0:t.airTracker)===null||n===void 0?void 0:n.error(e,__assign(__assign({},r),{context:"components-sdk"}))};var logWarning=function(e,r){var t;(t=window._AirwallexSDKs.airTracker)===null||t===void 0?void 0:t.warn(e,__assign(__assign({},r),{context:"components-sdk"}))};var logInfo=function(e,r){var t;(t=window._AirwallexSDKs.airTracker)===null||t===void 0?void 0:t.info(e,__assign(__assign({},r),{context:"components-sdk"}))};var LoadScriptError=/** @class */function(e){__extends(r,e);function r(r){var t=e.call(this,r)||this;t.code="LOAD_SCRIPT_ERROR";return t}return r}(Error);var _a,_b;var ENV;(function(e){e["dev"]="dev";e["staging"]="staging";e["demo"]="demo";e["prod"]="prod";e["sandbox"]="sandbox"})(ENV||(ENV={}));var PA_STATIC_HOST=(_a={},_a[ENV.dev]="https://checkout-staging.airwallex.com",_a[ENV.staging]="https://checkout-staging.airwallex.com",_a[ENV.demo]="https://checkout-demo.airwallex.com",_a[ENV.prod]="https://checkout.airwallex.com",_a[ENV.sandbox]="https://checkout.sandbox.airwallex.com",_a);var STATIC_HOST=(_b={},_b[ENV.dev]="https://static-staging.airwallex.com",_b[ENV.staging]="https://static-staging.airwallex.com",_b[ENV.demo]="https://static-demo.airwallex.com",_b[ENV.prod]="https://static.airwallex.com",_b[ENV.sandbox]="https://static.sandbox.airwallex.com",_b);var SDK_CONTROLLER="sdkController";var PAYMENTS="payments";var SDK_URL_MAPPING={kyc:"/widgets/kyc/sdk/v1/index.js",rfi:"/widgets/kycRfi/sdk/v1/index.js",paymentsKyb:"/widgets/paymentsKyb/sdk/v1/index.js",sdkController:"/widgets/sdk-controller/sdk/v1/index.js",payouts:"/widgets/payouts/sdk/v1/index.js",payments:"/assets/elements.bundle.min.js",sca:"/hosted-sca/sdk/v1/index.js",taxForm:"/widgets/taxForm/sdk/v1/index.js",billing:"/widgets/checkout/sdk/v1/index.js",balance:"/widgets/embedded-balance/sdk/v1/index.js"};var ELEMENT_TO_SDK={
|
|
100
100
|
// legacy
|
|
101
101
|
kyc:"kyc",paymentsKyb:"paymentsKyb",
|
|
102
102
|
// rfi elements
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{W as extractName}from"./cart-b84n0nhi.js";
|
|
2
2
|
/**
|
|
3
3
|
* Minimum number of characters we treat as a valid postal code. Mirrors the
|
|
4
4
|
* landed-cost readiness check in `stripe.ts` (`isAddressReadyToRequestLandedCost`).
|
|
@@ -14,7 +14,7 @@ import{U as extractName}from"./cart-BS5mSI8x.js";
|
|
|
14
14
|
*
|
|
15
15
|
* Pure: the caller resolves `countryField` (via `getCountryField`) and passes it in, so
|
|
16
16
|
* this can be unit-tested without the stores.
|
|
17
|
-
*/var getMissingRequiredShippingFields=function(i){var e=i.countryField,a=i.event;var r,t,
|
|
17
|
+
*/var getMissingRequiredShippingFields=function(i){var e=i.countryField,a=i.event;var r,t,n;if(!a){return[]}var v=a.value;var l=[];
|
|
18
18
|
// Last name is always required for international shipping. Link's single name input
|
|
19
19
|
// often provides only a first name, leaving the extracted last name empty.
|
|
20
|
-
var
|
|
20
|
+
var o=extractName({firstName:v.firstName,lastName:v.lastName,name:v.name}).lastName;if(!o.trim()){l.push({key:"lastName"})}if((e===null||e===void 0?void 0:e.stateRequired)&&!((r=v.address.state)===null||r===void 0?void 0:r.trim())){l.push({key:"state"})}if((e===null||e===void 0?void 0:e.zipRequired)&&((n=(t=v.address.postal_code)===null||t===void 0?void 0:t.trim().length)!==null&&n!==void 0?n:0)<MIN_POSTAL_CODE_LENGTH){l.push({key:"postal_code"})}return l};export{MIN_POSTAL_CODE_LENGTH as M,getMissingRequiredShippingFields as g};
|
package/dist/esm-es5/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,n,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,o,n,t){function r(e){return e instanceof n?e:new n((function(o){o(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):r(e.value).then(a,s)}u((t=t.apply(e,o||[])).next())}))};var __generator=this&&this.__generator||function(e,o){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(o){return u([e,o])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;r=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=o.call(e,n)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,o,n){if(n||arguments.length===2)for(var t=0,r=o.length,i;t<r;t++){if(i||!(t in o)){if(!i)i=Array.prototype.slice.call(o,0,t);i[t]=o[t]}}return e.concat(i||Array.prototype.slice.call(o))};export{c as curpRegex,i as isMexicoTaxIdType,a as isPeruTaxIdType,p as peruTaxIdTypeFromValue,s as stripTaxIdSeparators}from"./taxIdRules-xYlx7ZXW.js";import{c as createCustomEvent}from"./createCustomEvent-XQfWgQLB.js";import{g as getGenericSettingsOverride,I as IframeService}from"./getGenericSettingsOverride-HeAZDwVW.js";import{t as thrownMessage,s as sendErrorLog,g as getIsTestMode,a as getIsStagingMode,h as handleFetch,l as logError,b as safeRemoveItem,c as safeGetItem}from"./handleFetch-BFVO7oAR.js";import{l as log}from"./VarianceTest-BJmZPrZl.js";export{a as availableTestKeys}from"./VarianceTest-BJmZPrZl.js";import{h as holdStripeForNativeCheckout,m as markBigCommerceHostChecked,i as isBigCommerceNativeCheckout}from"./_isBigCommerceNativeCheckout-Bb90IMVt.js";import{g as getAbandonedCartRenewTokenValue,_ as _getIsValidCartId,c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector}from"./CheckoutConfig-D5SpFsQJ.js";export{d as domesticRedirectedBtnSelector}from"./CheckoutConfig-D5SpFsQJ.js";export{c as countryRequireShortAddressCode}from"./ShortAddressCode-nJ6oI8-n.js";export{a as checkoutTaxIdTypeValues,c as countryRequireTaxId,e as euCountryCodes,i as isCountryRequireTaxId,p as peruTaxIdDigitLength,b as peruTaxIdFormatError,s as shipToTaxIdLabels,t as taxIdTypeOptions}from"./TaxId-DMIgN_sT.js";var constructorNotFound=/^Constructor for .+ was not found/;var constructorTag=/^Constructor for "?([^#"]+)#/;var recordConstructorFailure=function(e){var o;var n=thrownMessage(e,"");if(!n||!constructorNotFound.test(n)){return}if(typeof window.Zonos==="undefined"){return}var t=window.__zonosConstructorCapture;if(!t){return}var r=constructorTag.exec(n);var i=(o=r===null||r===void 0?void 0:r[1])!==null&&o!==void 0?o:"";if(t.reported.has(i)){return}t.reported.add(i);void sendErrorLog({endpoint:"stencil://constructor",errors:[n],metadata:{shape:"constructor-not-found",tag:i}})};
|
|
2
2
|
/**
|
|
3
3
|
* Copy a missing-constructor failure onto the existing error log.
|
|
4
4
|
* Stencil catches `Constructor for "tag#mode" was not found` and passes that
|
|
@@ -6,9 +6,9 @@ var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e ins
|
|
|
6
6
|
* console.error still runs. This does not request the chunk again.
|
|
7
7
|
*/var installConstructorCapture=function(){if(window.__zonosConstructorCapture){return}var e=function(e){recordConstructorFailure(e.reason)};window.__zonosConstructorCapture={listener:e,reported:new Set};window.addEventListener("unhandledrejection",e);
|
|
8
8
|
// eslint-disable-next-line no-console -- Stencil reports the missing constructor here
|
|
9
|
-
var
|
|
9
|
+
var o=console.error.bind(console);
|
|
10
10
|
// eslint-disable-next-line no-console -- record the Stencil diagnostic, then forward it
|
|
11
|
-
console.error=function(){var e=[];for(var
|
|
11
|
+
console.error=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}recordConstructorFailure(e[0]);o.apply(void 0,e)}};var reportInitRejection=function(e){
|
|
12
12
|
// sendErrorLog prints only when zonosDebug is on. Keep the failure in the
|
|
13
13
|
// merchant console without leaving an unhandled rejection.
|
|
14
14
|
// eslint-disable-next-line no-console -- the page console is the support signal
|
|
@@ -16,11 +16,11 @@ console.error(e);if(typeof window.Zonos==="undefined"){return}void sendErrorLog(
|
|
|
16
16
|
/**
|
|
17
17
|
* Run an init that the caller is not waiting on. The rejection is recorded
|
|
18
18
|
* and not rethrown, so startup does not become an unhandled rejection.
|
|
19
|
-
*/var startZonosInit=function(e){var
|
|
19
|
+
*/var startZonosInit=function(e){var o;try{o=e()}catch(e){reportInitRejection(e);return}void o.catch((function(e){reportInitRejection(e)}))};
|
|
20
20
|
/**
|
|
21
21
|
* Get the load version and url based on the loadScriptSrc and version
|
|
22
22
|
* @returns
|
|
23
|
-
*/var checkIfLoadVersionDomain=function(e){var
|
|
23
|
+
*/var checkIfLoadVersionDomain=function(e){var o=e.loadScriptSrc;if(!o){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var n=[
|
|
24
24
|
// local domain
|
|
25
25
|
"dev.elements.zonos.com","dev.assets-checkout.zonos.com",
|
|
26
26
|
// any domain with prefix , no need to version it
|
|
@@ -30,7 +30,7 @@ console.error(e);if(typeof window.Zonos==="undefined"){return}void sendErrorLog(
|
|
|
30
30
|
// force load version for qa domain, this is to test the load version behavior
|
|
31
31
|
"qa.js.zonos.com"];
|
|
32
32
|
// get the domain that's used to load the loadZonos.js
|
|
33
|
-
var r=new URL(
|
|
33
|
+
var r=new URL(o).origin;var i=n.some((function(e){
|
|
34
34
|
// check if the current domain is in the white listed domains
|
|
35
35
|
return r.includes(e)}));var a=t.some((function(e){
|
|
36
36
|
// check if the current domain is in the force load version domains list
|
|
@@ -40,16 +40,16 @@ return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a
|
|
|
40
40
|
* @param currentCdnType The current cdn type that want to get the next fallback url
|
|
41
41
|
*/var getNextFallbackUrl=function(e){
|
|
42
42
|
// get current index of the current fail cdn type in the fallback list
|
|
43
|
-
var
|
|
43
|
+
var o=fallbackList.indexOf(e);
|
|
44
44
|
// get the next fallback cdn type
|
|
45
|
-
var
|
|
45
|
+
var n=fallbackList[o+1];return n||null};
|
|
46
46
|
/**
|
|
47
47
|
* Attempt to get test public credential to window.Zonos.zonosApiKey if needed
|
|
48
|
-
*/var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,
|
|
48
|
+
*/var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,o,n,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();o=getIsStagingMode();
|
|
49
49
|
// Do nothing if the test mode is not enabled or the public credential
|
|
50
|
-
if(!e&&!
|
|
50
|
+
if(!e&&!o||!window.Zonos.zonosApiKey){return[2/*return*/,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");
|
|
51
51
|
// Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
|
|
52
|
-
if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2/*return*/,null]}return[4/*yield*/,handleFetch("/api/get-test-public-credential")];case 1:
|
|
52
|
+
if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2/*return*/,null]}return[4/*yield*/,handleFetch("/api/get-test-public-credential")];case 1:n=a.sent(),t=n.errors,r=n.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2/*return*/,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2/*return*/,null]}
|
|
53
53
|
// Set the test public credential to the window object
|
|
54
54
|
log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2/*return*/,i]}}))}))};
|
|
55
55
|
/**
|
|
@@ -63,7 +63,7 @@ log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");retu
|
|
|
63
63
|
* invalid: https://www.zonos.com/?zonosQaUrl=https://zonos-something
|
|
64
64
|
*/var extractZonosQaUrl=function(e){if(!e){return null}
|
|
65
65
|
// get params from url
|
|
66
|
-
var
|
|
66
|
+
var o=new URL(e).searchParams;var n=o.get("zonosQaUrl");if(!n){return null}var t=/[^a-zA-Z0-9-_]+/.test(n);if(!!t){return null}return n};
|
|
67
67
|
/**
|
|
68
68
|
* Get the Zonos QA URL and return it. Will remove `zonosQaUrl` from the url query if it doesn't exists.
|
|
69
69
|
*/var getZonosQaUrl=function(){
|
|
@@ -72,67 +72,74 @@ var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t
|
|
|
72
72
|
* When developing, if the script load is from `dev.elements.zonos.com`,
|
|
73
73
|
* it would load script from that same domain instead of loading from cdn
|
|
74
74
|
*/
|
|
75
|
-
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var
|
|
75
|
+
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var o=extractZonosQaUrl(window.location.href);var n="https://v1.5.3.js.zonos.com";
|
|
76
76
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
77
|
-
if(!
|
|
77
|
+
if(!o&&(n.includes("test.")||
|
|
78
78
|
// Vercel git domain
|
|
79
|
-
|
|
79
|
+
n.includes("test-"))){return n}
|
|
80
80
|
// when local demo app is running, it needs to use the local dev script unless the qaUrl is set
|
|
81
|
-
if(!
|
|
81
|
+
if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!o){return null}
|
|
82
82
|
// If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
|
|
83
|
-
if(
|
|
83
|
+
if(o==="dev-elements"){return"https://dev.elements.zonos.com"}
|
|
84
84
|
// The worker alias selects the API host only. Scripts stay on the normal CDN.
|
|
85
|
-
if(
|
|
85
|
+
if(o==="worker"){return null}var t="preview.js.zonos.com";var r="https://".concat(o,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");
|
|
86
86
|
// request to the url and check if the request has an error
|
|
87
87
|
void fetch(r).then((function(){
|
|
88
88
|
// cleanup checkout session to avoid using the prod session in preview domain
|
|
89
89
|
safeRemoveItem("session","zonos--checkout-session-id");safeRemoveItem("session","zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));
|
|
90
90
|
// remove the zonosQaUrl param from url
|
|
91
|
-
var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var
|
|
91
|
+
var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var o=window.location.pathname;var n="".concat(o,"?").concat(e.toString());
|
|
92
92
|
/**
|
|
93
93
|
* Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
|
|
94
94
|
* @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
|
|
95
|
-
**/window.history.replaceState(window.history.state,"",
|
|
95
|
+
**/window.history.replaceState(window.history.state,"",n);window.location.reload();return null}));return r};
|
|
96
96
|
/* eslint-disable no-console */
|
|
97
|
-
/** Loading stripe script extracted from stripe.js repository */var STRIPE_API_VERSION="2025-02-24.acacia";var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var V3_VERSION=3;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var
|
|
97
|
+
/** Loading stripe script extracted from stripe.js repository */var STRIPE_API_VERSION="2025-02-24.acacia";var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var V3_VERSION=3;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var o=0;o<e.length;o++){var n=e[o];if(!n){continue}if(!V3_URL_REGEX.test(n.src)){continue}return n}return null};var stripePromise$1=null;var injectScript=function(e){var o="";var n=document.createElement("script");n.src="".concat(V3_URL).concat(o);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(n);return n};var zonosStripeLoadScript=function(e){
|
|
98
98
|
// Ensure that we only attempt to load Stripe.js at most once
|
|
99
|
-
if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n
|
|
99
|
+
if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(o,n){if(typeof window==="undefined"||typeof document==="undefined"){
|
|
100
100
|
// Resolve to null when imported server side. This makes the module
|
|
101
101
|
// safe to import in an isomorphic code base.
|
|
102
|
-
|
|
102
|
+
o(null);return}if(window.Stripe){o(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript()}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){o(window.Stripe)}else{n(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){n(e);return}}));return stripePromise$1};var registerWrapper=function(e,o){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:o})};var getStripeVersion=function(e){if(!("version"in e)){return}var o=e.version;return typeof o==="number"||typeof o==="string"?o:undefined};var initStripe=function(e,o,n){if(e===null){return null}var t=o[0],r=o[1];var i=Object.assign({},r);var a=getStripeVersion(e);var s=typeof a==="string"&&a!==V3_VERSION.toString();if(s){delete i.apiVersion}else{i.apiVersion=STRIPE_API_VERSION}var u=e(t,i);registerWrapper(u,n);return u};
|
|
103
103
|
// Execute our own script injection after a tick to give users time to do their
|
|
104
104
|
// own script injection.
|
|
105
|
-
var hasCheckoutCartCallback=function(){var e,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
var hasCheckoutCartCallback=function(){var e,o;return typeof window!=="undefined"&&(typeof((e=window.Zonos)===null||e===void 0?void 0:e.createCartId)==="function"||typeof((o=window.Zonos)===null||o===void 0?void 0:o.buildCartDetail)==="function")};
|
|
106
|
+
/**
|
|
107
|
+
* The only function that may inject Stripe.js. Native BigCommerce checkout
|
|
108
|
+
* returns null before `window.Stripe` is read or `js.stripe.com/v3` is added.
|
|
109
|
+
* Callers decide whether to ask for Stripe. They do not load it themselves.
|
|
110
|
+
*/var loadStripeScript=function(){if(holdStripeForNativeCheckout()){return Promise.resolve(null)}return zonosStripeLoadScript(null)};var stripePromise=Promise.resolve().then((function(){
|
|
111
|
+
// Hello-only pages have no cart callback, so they skip the eager preload.
|
|
112
|
+
if(!hasCheckoutCartCallback()){return null}return loadStripeScript()}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){
|
|
109
113
|
// eslint-disable-next-line no-console
|
|
110
|
-
console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var
|
|
114
|
+
console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var o=0;o<arguments.length;o++){e[o]=arguments[o]}return __awaiter(void 0,void 0,void 0,(function(){var o,n,t,r;return __generator(this,(function(i){switch(i.label){case 0:loadCalled=true;n=Date.now();return[4/*yield*/,stripePromise];case 1:if(!((o=i.sent())!==null&&o!==void 0))return[3/*break*/,2];r=o;return[3/*break*/,4];case 2:return[4/*yield*/,loadStripeScript()];case 3:r=i.sent();i.label=4;case 4:t=r;return[2/*return*/,initStripe(t,e,n)]}}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";
|
|
111
115
|
/**
|
|
112
116
|
* Simple function to get the cart id from the query param.
|
|
113
|
-
*/var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var
|
|
117
|
+
*/var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var o=e.get(TEMP_CART_ID_QUERY_PARAM);return o};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var o,n,t,r,i,a,s,u,c;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:o=getIsTestMode();n=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(n.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress)}return[4/*yield*/,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:o,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,u=i.zonosMode;c=!s||a.length;if(!(c&&l))return[3/*break*/,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});
|
|
114
118
|
// wait 1 second before retrying
|
|
115
119
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
|
|
116
120
|
// wait 1 second before retrying
|
|
117
|
-
e.sent();return[2/*return*/,getCartInfoById({cartId:d,retries:l-1})];case 3:if(c){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},s),{zonosMode:u})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,
|
|
121
|
+
e.sent();return[2/*return*/,getCartInfoById({cartId:d,retries:l-1})];case 3:if(c){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},s),{zonosMode:u})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var o,n,t,r;return __generator(this,(function(i){switch(i.label){case 0:o=_getIsValidCartId(e),n=o.isDgsCartId,t=o.isLegacyCartId;if(!t&&!n){logError("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2/*return*/,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;
|
|
118
122
|
/**
|
|
119
123
|
* Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
|
|
120
|
-
*/var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var
|
|
124
|
+
*/var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var o=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),n=o.currentLoadScriptUrl,t=o.isWhiteListed;if(t){return n}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.5.3.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.3";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.5.3";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.3";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=/** @class */function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;
|
|
121
125
|
// if query 'zonosDebug=1' param from url, debug mode is on
|
|
122
|
-
Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="
|
|
126
|
+
Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1794098254078";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?// domain that embeds the iframe
|
|
123
127
|
window.location!=window.parent.location&&document.referrer||
|
|
124
128
|
// current domain
|
|
125
129
|
document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;
|
|
126
130
|
/**
|
|
127
131
|
* By default, the package will load from npm
|
|
128
|
-
*/Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.5.
|
|
132
|
+
*/Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.5.3");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var o,n,t,r,i,a,s,u,c,d,l,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:installConstructorCapture();o=e.appearance,n=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,u=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();
|
|
129
133
|
// Expose the checkout cart callbacks on the global so Stripe loading can be
|
|
130
134
|
// gated on whether at least one of them is configured.
|
|
131
|
-
_a.createCartId=
|
|
135
|
+
_a.createCartId=n===null||n===void 0?void 0:n.createCartId;
|
|
132
136
|
// eslint-disable-next-line @typescript-eslint/no-deprecated -- intentionally mirror the (deprecated) callback so Stripe loading can be gated on it
|
|
133
|
-
_a.buildCartDetail=
|
|
137
|
+
_a.buildCartDetail=n===null||n===void 0?void 0:n.buildCartDetail;if(_a.doneInit){
|
|
134
138
|
// do nothing if zonos is already initialized
|
|
135
|
-
return[2/*return*/]}
|
|
139
|
+
return[2/*return*/]}
|
|
140
|
+
// Host detection has already copied `isBigCommerce`. Settle the
|
|
141
|
+
// native-checkout answer once, before buttons or Stripe are touched.
|
|
142
|
+
markBigCommerceHostChecked();log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;
|
|
136
143
|
// When not in iframe, providers are ready (gtag/fbq work directly). When in iframe, relay sets these after parent configures.
|
|
137
144
|
if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true;_a.facebookPixelReady=true}if(!_a.isNpm)return[3/*break*/,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();
|
|
138
145
|
// if zonosQaUrl is available, inject the script from the zonosQaUrl and then call init again
|
|
@@ -156,23 +163,23 @@ _a.injectFonts();
|
|
|
156
163
|
// inject checkout international button
|
|
157
164
|
_a.injectCheckoutInternationalButton();
|
|
158
165
|
// init zonos controller
|
|
159
|
-
_a.injectController({config:{appearance:
|
|
166
|
+
_a.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2/*return*/]}}))}))};
|
|
160
167
|
/**
|
|
161
168
|
* Inject the hidden international checkout button to trigger checkout regardless of shipping zones
|
|
162
169
|
*/Zonos.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector))){
|
|
163
170
|
// inject the hidden international checkout button
|
|
164
|
-
var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var
|
|
171
|
+
var e=document.createElement("button");e.id=checkoutHiddenInternationalBtnSelector;e.style.display="none";document.body.appendChild(e)}};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var o=(e===null||e===void 0?void 0:e.metadata)||[];var n=o.find((function(e){return e.key==="customHeaderScript"}));var t=o.find((function(e){return e.key==="customFooterScript"}));
|
|
165
172
|
// googleAnalyticId / facebookPixelId are set by customHTML in checkoutSettings (e.g. <script>window.Zonos.googleAnalyticId = "G-XXX"; window.Zonos.facebookPixelId = "1234567890";<\/script>), injected by zonos-controller
|
|
166
173
|
// Only inject the script if checkout is on Zonos hosted checkout and custom script is available
|
|
167
|
-
if(!window.Zonos.isLegacyCheckout||!
|
|
174
|
+
if(!window.Zonos.isLegacyCheckout||!n&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(n){log("Injecting custom header script");var r=document.createElement("script");r.textContent=n.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.triggerCheckoutInternational=function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(o){e=document.querySelector("#".concat(checkoutHiddenInternationalBtnSelector));setTimeout((function(){if(e){e.dispatchEvent(createCustomEvent("click"))}}),10);return[2/*return*/]}))}))};
|
|
168
175
|
// Called openHelloDialog because the main use case is to simply open the dialog
|
|
169
|
-
Zonos.openHelloDialog=function(e){var
|
|
176
|
+
Zonos.openHelloDialog=function(e){var o=document.querySelector("zonos-hello");if(o){void o.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.showNotification(e))};Zonos.updateOrganizationName=function(e){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var o=e.autoEnable,n=o===void 0?true:o,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;
|
|
170
177
|
// if disablePlaceOrderButtonActivation is true, do nothing
|
|
171
178
|
if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}
|
|
172
179
|
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
173
|
-
if(i){var s=document.querySelectorAll(i);var u=function(e){var
|
|
180
|
+
if(i){var s=document.querySelectorAll(i);var u=function(e){var o=e.target;
|
|
174
181
|
// prevent default and propagation when the item has disabled attribute
|
|
175
|
-
if(
|
|
182
|
+
if(o.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var o=e.getAttribute("data-zonos-checkout-attached");if(o){
|
|
176
183
|
// do nothing if event is already attached
|
|
177
184
|
return}if(r){e.setAttribute("disabled","true");
|
|
178
185
|
// prevent the selector to perform default action when it's disabled
|
|
@@ -180,7 +187,7 @@ e.addEventListener("click",u)}else{e.removeAttribute("disabled");
|
|
|
180
187
|
// clean up the event listener
|
|
181
188
|
e.removeEventListener("click",u)}}));
|
|
182
189
|
// only auto enable if autoEnable is true and we are setting button disable
|
|
183
|
-
if(
|
|
190
|
+
if(n&&r){setTimeout((function(){
|
|
184
191
|
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
185
192
|
s.forEach((function(e){e.removeAttribute("disabled");
|
|
186
193
|
// clean up the event listener if exists
|
|
@@ -191,55 +198,59 @@ e.removeEventListener("click",u)}))}),5e3)}}};
|
|
|
191
198
|
* If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions. This allows testing checkout compatibility with merchant polyfills.
|
|
192
199
|
*/Zonos.restoreNativeBrowserFunctions=function(){var e;
|
|
193
200
|
// If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions.
|
|
194
|
-
var
|
|
201
|
+
var o=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(o){return}var n="zonos---native-browser";var t=document.querySelector("iframe#".concat(n));if(!t){
|
|
195
202
|
// add a hidden iframe
|
|
196
|
-
t=document.createElement("iframe");t.id=
|
|
203
|
+
t=document.createElement("iframe");t.id=n;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}
|
|
197
204
|
/**
|
|
198
205
|
* Override Array.from if the site is using the obsolete prototype.js (last updated 2015).
|
|
199
206
|
* If old browser is being used and Array.from is not available, just use Array from the prototype.js polyfill
|
|
200
|
-
*/var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var
|
|
207
|
+
*/var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var o=e.config;var n,t;if(document.querySelector("zonos-controller")){return}
|
|
208
|
+
// Native BigCommerce checkout never calls attachCheckout, which is what
|
|
209
|
+
// marks these buttons handled. Disabling them here would flicker the
|
|
210
|
+
// store's own buttons after every DOM mutation.
|
|
211
|
+
if(!isBigCommerceNativeCheckout()){
|
|
201
212
|
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
202
|
-
if((o
|
|
213
|
+
if((n=o.checkoutSettings)===null||n===void 0?void 0:n.placeOrderButtonSelector){var r=o.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:r});
|
|
203
214
|
// create a mutation observer to see if any new elements that match our selector is added to the DOM
|
|
204
|
-
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:
|
|
215
|
+
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}
|
|
205
216
|
// if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
206
|
-
if((t=
|
|
217
|
+
if((t=o.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=o.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:a});
|
|
207
218
|
// create a mutation observer to see if any new elements that match our selector is added to the DOM
|
|
208
|
-
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:
|
|
219
|
+
var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:o,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}}var s=document.createElement("zonos-controller");s.config=o;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var o,n;return __generator(this,(function(t){switch(t.label){case 0:o=e.detail;log("loading Stripe");return[4/*yield*/,zonosLoadStripe(o.publishableKey)];case 1:n=t.sent();if(!n){logError("API seems to be invalid or missing. Failed to load Stripe");return[2/*return*/]}window.Zonos.stripe=n;if(window.Zonos.isCollect){void s.initCollectElement(n)}else if(window.Zonos.isInvoice){void s.initInvoiceElement(n)}else{void s.initCheckoutElement(n)}return[2/*return*/]}}))}))}));document.body.appendChild(s);
|
|
209
220
|
// set zonos controller to be global
|
|
210
|
-
_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var
|
|
221
|
+
_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var o=e.cdnType,n=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(o);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;
|
|
211
222
|
// init zonos elements when the zonosKey is valid
|
|
212
223
|
// inject esmodule cdn for zonos elements
|
|
213
|
-
var u=document.createElement("script");if(!!
|
|
224
|
+
var u=document.createElement("script");if(!!n){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var e=getNextFallbackUrl(o);
|
|
214
225
|
// if next fallback cdn type exists, inject the script with the next fallback cdn type
|
|
215
|
-
if(!e){return}_a.injectScript({cdnType:e,isModule:
|
|
226
|
+
if(!e){return}_a.injectScript({cdnType:e,isModule:n,theRestUrl:t})};s.appendChild(u)};
|
|
216
227
|
/**
|
|
217
228
|
* We now support loading Zonos via npm. For clients using npm, `zonosBase` will always load from the server side. Therefore, the `zonosLoadUrl` defined earlier won't work since it lacks access to client-side APIs such as `window` and `document`.
|
|
218
|
-
*/Zonos.getZonosUrl=function(e){var
|
|
229
|
+
*/Zonos.getZonosUrl=function(e){var o=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};
|
|
219
230
|
// To ensure that sites using zonos-elements load the script from a specific domain when using npm, we need to check for zonosQaUrl and use it if available. Otherwise it will always load from the compiled versioned domain
|
|
220
|
-
if(_a.isNpm){var
|
|
231
|
+
if(_a.isNpm){var n=getZonosQaUrl();
|
|
221
232
|
// Default to hard coded domain if zonosQaUrl is not available
|
|
222
|
-
return o
|
|
233
|
+
return n||o()}return o()};Zonos.injectZonosCdn=function(){
|
|
223
234
|
// init zonos elements when the zonosKey is valid
|
|
224
235
|
// inject esmodule cdn for zonos elements
|
|
225
236
|
_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});
|
|
226
237
|
// inject non module cdn for zonos elements
|
|
227
|
-
_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var
|
|
238
|
+
_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var o=e.cdnType,n=e.theRestUrl;var t=_a.getZonosUrl(o);var r=document.head||document.body;
|
|
228
239
|
// inject preconnect css for zonos elements
|
|
229
240
|
var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);
|
|
230
241
|
// inject css for zonos elements
|
|
231
|
-
var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(
|
|
242
|
+
var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(n);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(o);
|
|
232
243
|
// if the css failed to load, try to load the next fallback cdn if exists
|
|
233
|
-
if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:
|
|
244
|
+
if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:n})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}
|
|
234
245
|
// inject css for zonos elements
|
|
235
|
-
_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var
|
|
246
|
+
_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var o=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var n=0;n<o.length;n++){var t=o[n];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var o=document.head||document.body;
|
|
236
247
|
// inject font css for zonos elements
|
|
237
|
-
var
|
|
248
|
+
var n=document.createElement("link");n.rel="preconnect";n.href=GOOGLE_FONT_URL;o.appendChild(n);
|
|
238
249
|
// inject font css for zonos elements
|
|
239
|
-
var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");
|
|
250
|
+
var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");o.appendChild(t);log("Zonos font injected!")};
|
|
240
251
|
// apply font for zonos elements and inject font if needed
|
|
241
|
-
Zonos.setupGoogleFont=function(e){var
|
|
252
|
+
Zonos.setupGoogleFont=function(e){var o;void((o=_a.zonosController)===null||o===void 0?void 0:o.setupGoogleFont(e))};
|
|
242
253
|
// this function is to inject google font to the browser, not apply the font for zonos elements, to apply the font and inject font if needed, use `setupGoogleFont` instead
|
|
243
|
-
Zonos.injectSupportGoogleFont=function(e){var
|
|
254
|
+
Zonos.injectSupportGoogleFont=function(e){var o;log("[FONT] injecting ".concat(e));var n=(o=e.match(/family=(.*?):/))===null||o===void 0?void 0:o[1];var t=document.head||document.body;
|
|
244
255
|
// inject font css for zonos elements
|
|
245
|
-
if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(
|
|
256
|
+
if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(n," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(n," font injected!"))};var checkoutSessionMutableAttributeKeys=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"];var checkoutSessionImmutableAttributeKeys=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"];var checkoutSessionAttributeKeys=__spreadArray(__spreadArray([],checkoutSessionMutableAttributeKeys,true),checkoutSessionImmutableAttributeKeys,true);export{Zonos,checkoutHiddenBtnSelector,checkoutHiddenInternationalBtnSelector,checkoutSessionAttributeKeys,checkoutSessionImmutableAttributeKeys,checkoutSessionMutableAttributeKeys};
|