@zonos/elements 1.3.254 → 1.3.256
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-77640463.js → cart-e156c1e3.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-e93c64fd.js → hasInclusivePrice-d6d274bd.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-211ef96c.js → invoice-f4b5d538.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-14fb5ab4.js → isCollectMobileTablet-c9369cd8.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-be7afc1b.js → localization-5bb1e598.js} +243 -0
- package/dist/cjs/{paypal-c61ef042.js → paypal-f9641595.js} +2 -2
- package/dist/cjs/{placeTestOrder-0f7477c8.js → placeTestOrder-7ac7f91a.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-1ac02803.js → renderCheckoutCurrency-6b59a718.js} +2 -2
- package/dist/cjs/zonos-address-display_8.cjs.entry.js +2 -2
- package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +6 -6
- package/dist/cjs/zonos-checkout.cjs.entry.js +357 -78
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
- package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-store-credit.cjs.entry.js +3 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +60 -2
- package/dist/collection/components/store/hello/localization.js +3 -0
- package/dist/collection/components/store/translationStore/strings.arabic.js +12 -0
- package/dist/collection/components/store/translationStore/strings.base.js +12 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +12 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +12 -0
- package/dist/collection/components/store/translationStore/strings.french.js +12 -0
- package/dist/collection/components/store/translationStore/strings.german.js +12 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +12 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +12 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +12 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +12 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +12 -0
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +52 -0
- package/dist/collection/components/utils/checkout/buildBigcommerceRedirectUrl.js +22 -0
- package/dist/collection/components/utils/checkout/checkBigCommerceBypassCustomerGroup.js +122 -0
- package/dist/collection/components/utils/checkout/watchBigcommerceDomesticCheckout.js +5 -2
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +120 -86
- package/dist/esm/{cart-394c9ddb.js → cart-55b8dd7c.js} +1 -1
- package/dist/esm/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-ddae18fd.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-5ae81ae5.js → invoice-dbe85a18.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-8af0d16d.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-0ebc8356.js → localization-d11c973f.js} +243 -0
- package/dist/esm/{paypal-b6fa3ec3.js → paypal-f87fbee0.js} +2 -2
- package/dist/esm/{placeTestOrder-5756cbc3.js → placeTestOrder-8e8e97be.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-45c74af2.js} +2 -2
- package/dist/esm/zonos-address-display_8.entry.js +2 -2
- package/dist/esm/zonos-address_4.entry.js +2 -2
- package/dist/esm/zonos-card_5.entry.js +3 -3
- package/dist/esm/zonos-cart-items_12.entry.js +6 -6
- package/dist/esm/zonos-checkout.entry.js +358 -79
- package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
- package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
- package/dist/esm/zonos-collect.entry.js +4 -4
- package/dist/esm/zonos-controller.entry.js +2 -2
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
- package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
- package/dist/esm/zonos-invoice.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-store-credit.entry.js +3 -3
- package/dist/esm-es5/{cart-394c9ddb.js → cart-55b8dd7c.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-ddae18fd.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-5ae81ae5.js → invoice-dbe85a18.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-8af0d16d.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-d11c973f.js +1 -0
- package/dist/esm-es5/{paypal-b6fa3ec3.js → paypal-f87fbee0.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-5756cbc3.js → placeTestOrder-8e8e97be.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-45c74af2.js} +1 -1
- package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.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 +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-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-store-credit.entry.js +1 -1
- package/dist/scripts/index.d.ts +19 -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/checkout/zonos-checkout/zonos-checkout.d.ts +13 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +12 -0
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +36 -0
- package/dist/types/components/utils/checkout/buildBigcommerceRedirectUrl.d.ts +11 -0
- package/dist/types/components/utils/checkout/checkBigCommerceBypassCustomerGroup.d.ts +30 -0
- package/dist/types/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.d.ts +16 -1
- package/dist/types/types/utils/ZonosSettings.d.ts +7 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-bdaf2a38.entry.js → p-00728af1.entry.js} +1 -1
- package/dist/zonos-elements/{p-4a38ea5e.system.entry.js → p-08830a50.system.entry.js} +1 -1
- package/dist/zonos-elements/p-179bbeae.js +1 -0
- package/dist/zonos-elements/{p-b49b8da4.system.entry.js → p-1c9e9692.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-97fb5ad5.entry.js → p-225957b9.entry.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-27fad55a.system.js → p-2a28c7ac.system.js} +1 -1
- package/dist/zonos-elements/{p-92d91395.system.entry.js → p-2cb5ef7d.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b37a85f0.system.entry.js → p-2eeda8a9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0da3cc62.system.entry.js → p-32365d6a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-11d6de1a.entry.js → p-399f5ad6.entry.js} +1 -1
- package/dist/zonos-elements/{p-57b27c60.js → p-3a8925e9.js} +1 -1
- package/dist/zonos-elements/p-3f141999.system.js +1 -0
- package/dist/zonos-elements/{p-620ba943.js → p-3fae811a.js} +1 -1
- package/dist/zonos-elements/{p-93dec11b.entry.js → p-50d31f4f.entry.js} +1 -1
- package/dist/zonos-elements/{p-c6047442.system.entry.js → p-52b70520.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a0ac3ca2.system.entry.js → p-53275a0d.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5343c32b.system.js +1 -0
- package/dist/zonos-elements/{p-09d7a5cb.system.js → p-57b5d3e3.system.js} +1 -1
- package/dist/zonos-elements/{p-daaaa8f1.system.entry.js → p-59025df9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a1e23675.system.entry.js → p-5d0b0126.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8dfa0bb8.system.entry.js → p-664aff48.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c1ae7391.system.entry.js → p-6b45e9f3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-321e7920.system.js → p-70e069d3.system.js} +1 -1
- package/dist/zonos-elements/{p-fce715f1.system.entry.js → p-72de2fdc.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8abeab5a.entry.js → p-7d4a1565.entry.js} +1 -1
- package/dist/zonos-elements/{p-07ca3347.system.entry.js → p-8608c123.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-615b5d13.entry.js → p-89757efe.entry.js} +1 -1
- package/dist/zonos-elements/{p-920d9189.entry.js → p-8a593061.entry.js} +1 -1
- package/dist/zonos-elements/{p-efa69c89.entry.js → p-8ccf97ce.entry.js} +1 -1
- package/dist/zonos-elements/{p-4f23732f.js → p-93c64387.js} +1 -1
- package/dist/zonos-elements/p-93d6e13f.entry.js +1 -0
- package/dist/zonos-elements/p-9631c373.system.js +1 -0
- package/dist/zonos-elements/p-99e1734a.js +1 -0
- package/dist/zonos-elements/{p-a5adc047.system.entry.js → p-9b42f0ad.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8efb79ab.entry.js → p-aad014df.entry.js} +1 -1
- package/dist/zonos-elements/p-ae397ff8.system.entry.js +1 -0
- package/dist/zonos-elements/{p-d65cfa9b.system.entry.js → p-b439d38f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2bdc2206.entry.js → p-b85d4286.entry.js} +1 -1
- package/dist/zonos-elements/{p-2c2e5ee6.entry.js → p-befad3c4.entry.js} +1 -1
- package/dist/zonos-elements/{p-a5fb864a.system.entry.js → p-c66649fe.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d8610393.entry.js → p-d14e5c81.entry.js} +1 -1
- package/dist/zonos-elements/{p-a95ac160.entry.js → p-d155b9c6.entry.js} +1 -1
- package/dist/zonos-elements/{p-dcef3647.system.js → p-d280e9b6.system.js} +1 -1
- package/dist/zonos-elements/{p-9ff90151.entry.js → p-dba635e6.entry.js} +1 -1
- package/dist/zonos-elements/{p-1162b685.entry.js → p-ddde268d.entry.js} +1 -1
- package/dist/zonos-elements/p-e2adf04b.system.js +1 -0
- package/dist/zonos-elements/p-ee2c7a1e.js +1 -0
- package/dist/zonos-elements/{p-3d757163.entry.js → p-f36e907e.entry.js} +1 -1
- package/dist/zonos-elements/{p-29f7950c.js → p-f6733ffb.js} +1 -1
- package/dist/zonos-elements/{p-95f7f2a0.entry.js → p-f9ffff4e.entry.js} +1 -1
- package/dist/zonos-elements/p-fa0c5017.js +1 -0
- package/dist/zonos-elements/{p-fbccfa3e.system.js → p-fbd44c55.system.js} +1 -1
- package/dist/zonos-elements/{p-c2121663.system.entry.js → p-fc1c7fe5.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/localization-0ebc8356.js +0 -1
- package/dist/zonos-elements/p-0dd5a4b8.system.js +0 -1
- package/dist/zonos-elements/p-1282495f.system.js +0 -1
- package/dist/zonos-elements/p-13041752.js +0 -1
- package/dist/zonos-elements/p-2b118454.js +0 -1
- package/dist/zonos-elements/p-2c9c750e.system.js +0 -1
- package/dist/zonos-elements/p-4df85216.entry.js +0 -1
- package/dist/zonos-elements/p-ac353826.js +0 -1
- package/dist/zonos-elements/p-ca19a10a.js +0 -1
- package/dist/zonos-elements/p-cc9620e5.system.entry.js +0 -1
- package/dist/zonos-elements/p-cf69bcc4.system.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,n,i,e){function o(t){return t instanceof i?t:new i((function(n){n(t)}))}return new(i||(i=Promise))((function(i,s){function a(t){try{c(e.next(t))}catch(t){s(t)}}function r(t){try{c(e["throw"](t))}catch(t){s(t)}}function c(t){t.done?i(t.value):o(t.value).then(a,r)}c((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},e,o,s,a;return a={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function r(t){return function(n){return c([t,n])}}function c(r){if(e)throw new TypeError("Generator is already executing.");while(a&&(a=0,r[0]&&(i=0)),i)try{if(e=1,o&&(s=r[0]&2?o["return"]:r[0]?o["throw"]||((s=o["return"])&&s.call(o),0):o.next)&&!(s=s.call(o,r[1])).done)return s;if(o=0,s)r=[r[0]&2,s.value];switch(r[0]){case 0:case 1:s=r;break;case 4:i.label++;return{value:r[1],done:false};case 5:i.label++;o=r[1];r=[0];continue;case 7:r=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!s||r[1]>s[0]&&r[1]<s[3])){i.label=r[1];break}if(r[0]===6&&i.label<s[1]){i.label=s[1];s=r;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(r);break}if(s[2])i.ops.pop();i.trys.pop();continue}r=n.call(t,i)}catch(t){r=[6,t];o=0}finally{e=s=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};System.register(["./p-7261e245.system.js","./p-959918fe.system.js","./p-fbccfa3e.system.js","./p-cf69bcc4.system.js","./p-ac30b7a8.system.js","./p-01174496.system.js","./p-48d55793.system.js","./p-23e7c655.system.js","./p-d938f42f.system.js","./p-2b8345d8.system.js","./p-7501c637.system.js","./p-3fbd9cc0.system.js","./p-d18a2b2c.system.js","./p-655ec440.system.js"],(function(t){"use strict";var n,i,e,o,s,a,r,c,l,d,h,u,f,p,v,m,z,b,y,g,k,w,x,C,j,I,_,E,A,S;return{setters:[function(t){n=t.r;i=t.d;e=t.h;o=t.a;s=t.g},function(t){a=t.t},function(t){r=t.b;c=t.t;l=t.Q;d=t.E;h=t.q;u=t.d},function(t){f=t.s;p=t.r;v=t.t;m=t.q;z=t.l},function(t){b=t.z;y=t.g;g=t.f},function(t){k=t.l;w=t.i;x=t.s},function(t){C=t.a;j=t.s},function(t){I=t.c},function(t){_=t.l},function(t){E=t.c;A=t.s},function(t){S=t.g},function(){},function(){},function(){}],execute:function(){var O=".sc-zonos-address-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h .zonos--company-name-input.sc-zonos-address,.sc-zonos-address-h .zonos--tax-id-input.sc-zonos-address,.sc-zonos-address-h .zonos--short-address-code-input.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h zonos-banner.sc-zonos-address{margin-top:8px}";var L=O;var Z=t("zonos_address",function(){function t(t){n(this,t);this.invalidCharacters=i(this,"invalidCharacters",7);this.taxIdChanged=i(this,"taxIdChanged",7);this.storeUnsubscribeList=[];this.isAutoCompleteAdjusted=false;this.defaultAddress=[];this.taxIdErrorMessage="";this.shortAddressCodeErrorMessage="";this.stripe=window.Zonos.stripe;this.isDirtyAddress=false;this.isAddressFilled=false;this.checkoutSessionId=f.checkoutSessionId;this.prevCountry=null;this.prevPostalCode=null;this.trackingSent=false;this.prefetchLandedCost=a(h,1e3)}t.prototype.getStripeAddressInstance=function(){if(this.type==="billing"){return{stripeAddressElement:r.stripeBillingAddressElement,stripeAddressEventData:r.stripeBillingAddressEventData,stripeElements:r.stripeElementsForBillingAddress}}return{stripeAddressElement:r.stripeAddressElement,stripeAddressEventData:r.stripeAddressEventData,stripeElements:r.stripeElements}};t.prototype.updateAddressEventData=function(t){var n=t.event,i=t.type;switch(i){case"billing":r.stripeBillingAddressEventData=n;break;default:{r.stripeAddressEventData=n;break}}if(i==="shipping"){if(n.value.address.line1.length){void this.prefetchLandedCost()}}};t.prototype.isAddressFilledChanged=function(){if(!f.checkoutSessionId){return}if(this.isAddressFilled&&!this.trackingSent&&this.type==="shipping"){this.trackingSent=true;var t=f.checkoutSessionId;void c({checkoutSessionId:t,eventName:"checkout_customerInfoFilled"})}};t.prototype.updateAddressElement=function(t){var n=t.stripeAddressElement,i=t.type;if(i==="shipping"){r.stripeAddressElement=n;return}r.stripeBillingAddressElement=n};t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,i,e,o,s,a,r,c,d;var h=this;return __generator(this,(function(u){this.stripe=window.Zonos.stripe;t=this.getStripeAddressInstance(),n=t.stripeAddressEventData,i=t.stripeElements;if(!this.stripe||!i){k("Stripe is not initialized. Couldn't load stripe element.");return[2]}e=this.defaultAddress.map((function(t){return Object.assign(Object.assign({},t),{name:t.name,phone:t.phone||undefined})}));o=z.shippingZoneCountries;s=o?Object.values(o).map((function(t){return t.code})):[];a=new URLSearchParams(window.location.search).has("zonosCheckoutAllCountries");r=this.type==="shipping"?s:[];c=(n===null||n===void 0?void 0:n.value.address.country)||p(r);_("Stripe country code: ".concat(c),"info");d=i.create("address",{allowedCountries:a?[]:r,contacts:e.length&&!n?this.defaultAddress:[],defaultValues:{address:Object.assign(Object.assign({},n===null||n===void 0?void 0:n.value.address),{country:c}),firstName:n===null||n===void 0?void 0:n.value.firstName,lastName:n===null||n===void 0?void 0:n.value.lastName,phone:n===null||n===void 0?void 0:n.value.phone},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});d.mount(this.el.querySelector(".zonos--address-component"));if(n===null||n===void 0?void 0:n.value.address){this.prevCountry=n.value.address.country;this.prevPostalCode=n.value.address.postal_code}d.on("change",(function(t){var n=t.value;if(!h.isDirtyAddress&&n.address.line1.length>=3){h.isDirtyAddress=true;if(!h.isAutoCompleteAdjusted){var i=h.el.querySelector('iframe[src*="autocomplete-suggestions"]');if(i){i.style.zIndex="3"}h.isAutoCompleteAdjusted=true}setTimeout((function(){if(w()){h.el.scrollIntoView({behavior:"smooth",block:"end"})}else{var t=h.type==="shipping"?100:600;var n=h.el.closest(".zonos--group");var i=h.el.getBoundingClientRect().top+t;n===null||n===void 0?void 0:n.scrollTo({behavior:"smooth",top:i})}}),600)}var e=l({firstName:n.firstName,lastName:n.lastName,name:n.name}),o=e.firstName,s=e.lastName;h.updateAddressEventData({event:Object.assign(Object.assign({},t),{elementMode:h.type,elementType:"address",value:Object.assign(Object.assign({},n),{firstName:o,lastName:s})}),type:h.type})}));this.updateAddressElement({stripeAddressElement:d,type:this.type});return[2]}))}))};t.prototype.defaultAddressChanged=function(t,n){var i=JSON.stringify(n);var e=JSON.stringify(t);if(i===e){return}_("Reset address element when default address property is changed","info",{defaultAddress:this.defaultAddress});var o=this.getStripeAddressInstance().stripeAddressElement;o===null||o===void 0?void 0:o.clear();o===null||o===void 0?void 0:o.destroy();if(this.type==="shipping"){r.stripeAddressEventData=null}else{r.stripeBillingAddressEventData=null}void this.watchInitStripe()};t.prototype.isInTaxIdCountry=function(t){return E.includes(t)};t.prototype.renderTaxIdInput=function(){var t=this;var n;if(this.type==="billing"){return null}var i=(n=r.stripeAddressEventData)===null||n===void 0?void 0:n.value.address.country;if(!i){return null}if(!this.isInTaxIdCountry(i)){return null}var o=C({companyName:r.companyName,countryCode:i});if(!o){return null}var s=A[i];return e("div",{class:"zonos--tax-id-input"},e("zonos-stripe-input",{inputLabel:v(s.friendlyName),inputPlaceholder:s.placeholder,inputValue:r.taxId||"",isError:!!this.taxIdErrorMessage,onInputChange:function(n){r.taxId=n.detail;t.taxIdChanged.emit(n.detail)}}),this.taxIdErrorMessage&&e("zonos-text",{textColor:"red-600",type:"caption"},this.taxIdErrorMessage))};t.prototype.renderShortAddressCodeInput=function(){var t;if(this.type==="billing"){return null}var n=(t=r.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country;if(!n){return null}var i=j({countryCode:n});if(!i){return null}return e("div",{class:"zonos--short-address-code-input"},e("zonos-stripe-input",{inputLabel:v("Short address code"),inputPlaceholder:"RRRD2929",inputValue:r.shortAddressCode||"",isError:!!this.shortAddressCodeErrorMessage,onInputChange:function(t){r.shortAddressCode=t.detail}}),this.shortAddressCodeErrorMessage&&e("zonos-text",{textColor:"red-600",type:"caption"},this.shortAddressCodeErrorMessage))};t.prototype.renderCompanyNameInput=function(){if(this.type==="billing"&&!window.Zonos.isCollect&&!window.Zonos.isInvoice){return null}var t=b.checkoutSettings.companyFieldsStatus==="ENABLED"||!!window.Zonos.isCollect||!!window.Zonos.isInvoice;if(!t){return null}return e("zonos-stripe-input",{class:"zonos--company-name-input",inputLabel:v("Company name (optional)"),inputValue:r.companyName,onInputChange:function(t){r.companyName=t.detail}})};t.prototype.disconnectedCallback=function(){var t=this.getStripeAddressInstance().stripeAddressElement;t===null||t===void 0?void 0:t.destroy();try{this.storeUnsubscribeList.forEach((function(t){return t()}))}catch(t){}};t.prototype.componentDidLoad=function(){var t=this;var n=this.getStripeAddressInstance().stripeAddressEventData;this.isDirtyAddress=!!n&&n.value.address.line1.length>0;void this.watchInitStripe();this.checkoutSessionId=f.checkoutSessionId;this.storeUnsubscribeList=[m("checkoutSessionId",(function(){t.checkoutSessionId=f.checkoutSessionId})),d("stripeElements",(function(){if(t.type==="shipping"){void t.watchInitStripe()}})),d("stripeElementsForBillingAddress",(function(){if(t.type==="billing"){void t.watchInitStripe()}}))]};t.prototype.render=function(){var t;this.checkoutSessionId=f.checkoutSessionId;if((t=r.stripeAddressEventData)===null||t===void 0?void 0:t.complete){this.isAddressFilled=true}return e(o,{key:"5dc571d7c5e706ae9cb90de70deee22847e5ba7e",class:I(["zonos--address","zonos--elements","zonos--".concat(this.type,"-address")])},this.titleText&&e("zonos-text",{key:"a7c9f730bc9b64aa2c6e8cc24701e638481eac19",class:"zonos--title",type:"semiBoldLabel"},this.titleText),e("slot",{key:"3078529c201c7947ffc833485d46184bc79ab1d1",name:"below-title"}),this.renderCompanyNameInput(),this.renderTaxIdInput(),this.renderShortAddressCodeInput(),e("div",{key:"b4a9850ac30ad9c483e05743ff41b7de9756d826",class:"zonos--address-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{checkoutSessionId:["isAddressFilledChanged"],isAddressFilled:["isAddressFilledChanged"],stripe:["watchInitStripe"],defaultAddress:["defaultAddressChanged"]}},enumerable:false,configurable:true});return t}());Z.style=L;var N='<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-400)"></path>\n <path d="M12.75 9a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V9Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var B='<svg color="var(--zonos-elements-blue-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-blue-400)"></path>\n <path d="M10.25 10.25a1.75 1.75 0 1 1 2.431 1.613c-.616.26-1.431.885-1.431 1.887a.75.75 0 0 0 1.5 0c0-.053.02-.128.108-.228.092-.104.236-.205.408-.278A3.25 3.25 0 1 0 8.75 10.25a.75.75 0 0 0 1.5 0Zm2.5 5.75a.75.75 0 0 0-1.5 0v.25a.75.75 0 0 0 1.5 0V16Z" fill="currentColor"></path>\n</svg>';var D='<svg color="var(--zonos-elements-orange-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M14.46 5.492c-1.014-2.027-3.906-2.027-4.92 0L4.276 16.02c-.914 1.83.416 3.98 2.46 3.98h10.528c2.044 0 3.374-2.151 2.46-3.98L14.46 5.492Z" data-is-secondary-color="true" fill="var(--zonos-elements-orange-400)"></path>\n <path d="M12.75 10a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V10Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var M=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--backdrop,:host .zonos--confirm-layout{opacity:0;z-index:-999;visibility:hidden;-webkit-transition:opacity 0.3s, visibility 0.3s;transition:opacity 0.3s, visibility 0.3s}:host .zonos--backdrop{width:100vw;height:100vh;left:0;top:0;background:var(--zonos-elements-backdrop-color);position:fixed}:host .zonos--confirm-layout{width:100vw;height:100vh;left:0;top:0;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;color:var(--zonos-elements-text-color)}:host .zonos--confirm-dialog{position:relative;background:var(--zonos-elements-gray-0);max-width:90vw;max-height:90vh;width:var(--zonos--dialog-width);border-radius:var(--zonos--border-radius, 10px);outline:none;-webkit-box-shadow:var(--zonos-elements-v3-shadow-xxl);box-shadow:var(--zonos-elements-v3-shadow-xxl);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host .wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;gap:24px}:host .icon-wrapper{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:40px;width:40px;border-radius:50%;background:var(--zonos-elements-blue-100)}:host .warn .icon-wrapper{background:var(--zonos-elements-orange-100)}:host .danger .icon-wrapper{background:var(--zonos-elements-red-100)}:host .footer{display:-ms-flexbox;display:flex;width:100%;gap:8px}:host .footer zonos-button{-ms-flex:1;flex:1}:host .content{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .content zonos-text{text-align:center}:host(.open) .zonos--confirm-layout,:host(.open) .zonos--backdrop{visibility:visible}:host(.open) .zonos--backdrop{z-index:2147483009;opacity:0.65}:host(.open) .zonos--confirm-layout{opacity:1;z-index:2147483010;-webkit-transform:scale(1);transform:scale(1)}";var V=M;var T=t("zonos_confirm_dialog",function(){function t(t){var e=this;n(this,t);this.confirmClicked=i(this,"confirmClicked",7);this.cancelClicked=i(this,"cancelClicked",7);this.dialogTitle=v("Are you sure?");this.dialogIntent="info";this.dialogSubtitle=null;this.dialogWidth=350;this.dialogType="confirm";this.isMobile=false;this.noClickOutside=false;this.clickOutsideDialogHandler=function(t){if(t.target===t.currentTarget&&!e.noClickOutside){e.closeDialogHandler()}}}t.prototype.handleKeyDown=function(t){if(t.key==="Escape"){this.closeDialogHandler()}};t.prototype.focusDialog=function(){var t=this;if(this.dialogOpen){setTimeout((function(){var n,i;(i=(n=t.el.shadowRoot)===null||n===void 0?void 0:n.querySelector(".zonos--backdrop"))===null||i===void 0?void 0:i.focus()}),100)}};t.prototype.confirmDialogHandler=function(){if(!this.dialogOpen){return}this.confirmClicked.emit()};t.prototype.closeDialogHandler=function(){if(!this.dialogOpen){return}this.cancelClicked.emit()};t.prototype.renderIcon=function(){switch(this.dialogIntent){case"info":return e("zonos-icon",{content:B,iconColor:"blue-800"});case"danger":return e("zonos-icon",{content:N,iconColor:"red-800"});case"warn":return e("zonos-icon",{content:D,iconColor:"orange-800"})}};t.prototype.getButtonConfirmVariant=function(){switch(this.dialogIntent){case"warn":return"warning";case"danger":return"danger";default:return"primary"}};t.prototype.render=function(){var t=this;this.focusDialog();var n=S();var i=y(b.appearance.theme);return e(o,{key:"db0bfe0b8a125e806a97c9382faa938078000349",class:I([this.dialogOpen&&"open","zonos--elements"]),"data-dialog-type":this.dialogType,"data-theme":i,style:{"--zonos--border-radius":n,"--zonos--dialog-width":"".concat(this.dialogWidth,"px"),"--zonos--font-family":g()}},e("div",{key:"1676defad54705df4e9282bda6b5734592d0fb60",class:"zonos--backdrop",tabIndex:-1}),e("div",{key:"2a6ec6b5df7ea30304cfed5276e55618b40add93",class:I(["zonos--confirm-layout",this.dialogIntent]),onClick:function(n){return t.clickOutsideDialogHandler(n)}},e("div",{key:"d1c8358c3fd98c27a469fe7443d1983c1c134a7c",class:"zonos--confirm-dialog",onBlur:function(){t.focusDialog()}},e("div",{key:"137e9659aa7aec2e4604acf80809b35bce69ca79",class:"wrapper"},e("div",{key:"9c1057857ea095e7e88c8950469add2bc4c1318e",class:"icon-wrapper"},this.renderIcon()),e("div",{key:"48f0e0cd9ce62b425bae831d1387261bbd4162a1",class:"content"},e("div",{key:"0d3e681f350e5db547181beadf5c6bcf49a8bbd2",class:"title"},e("zonos-text",{key:"f16a43d2b3c9504911b1e36ba573873f80093c47",type:"subheader"},this.dialogTitle)),this.dialogSubtitle&&e("div",{key:"fd570f98bc736a68c16fedee72b1417dc6906fa6",class:"subtitle"},e("zonos-text",{key:"6785aa19dd44cf7f6fae7317e3924be6c6ee8af3",textColor:"gray-800"},this.dialogSubtitle))),e("div",{key:"4206cad3dcff0055fc5f3ea8e7c217ae33c63263",class:"footer"},this.dialogType==="confirm"&&e("zonos-button",{key:"72d1a216641d482bdbeae384963dcdff1cfc3f45",backgroundColor:"gray-0",class:"cancel-button",onClick:function(){return t.closeDialogHandler()},size:"lg",withBoxShadow:true},this.dialogCancelBtnText||v("Cancel")),e("zonos-button",{key:"a6a206eff11d1f42c33ef9113cc393d727c60f89",class:"confirm-button",onClick:function(){return t.confirmDialogHandler()},size:"lg",variant:this.getButtonConfirmVariant()},this.dialogConfirmBtnText))))))};Object.defineProperty(t,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});return t}());T.style=V;var P=function(t){var n=/^[a-zA-Z0-9.%_+-]*@[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z0-9]{2,}$/;return n.test(t)};var R=".sc-zonos-link-authentication-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:16px}.sc-zonos-link-authentication-h .zonos--input-invalid.sc-zonos-link-authentication{border:2px solid var(--zonos-elements-red-600);border-radius:var(--zonos--border-radius)}";var F=R;var J=51;var q=t("zonos_link_authentication",function(){function t(t){var e=this;n(this,t);this.linkAuthenticationChange=i(this,"linkAuthenticationChange",7);this.storeUnsubscribeList=[];this.defaultEmail=null;this.isEmailError=false;this.stripe=r.stripe;this.isStagingMode=u.isStagingMode;this.clientSecret=r.clientSecret;this.retriesInitializeLink=0;this.setCustomEmailInputToLinkEvent=function(t){var n=P(t);var i={complete:!!n,elementType:"linkAuthentication",empty:!t,value:{email:t}};r.stripeLinkEventData=i};this.handleNormalEmailInput=function(t){var n;var i=t.detail;e.setCustomEmailInputToLinkEvent(i);(n=e.linkAuthenticationChange)===null||n===void 0?void 0:n.emit()}}t.prototype.watchIsStagingMode=function(){var t=this;setTimeout((function(){void t.watchInitStripe()}),0)};t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,i,e;var o=this;return __generator(this,(function(s){switch(s.label){case 0:if(!this.stripe||!r.stripeElements){return[2]}if(u.isStagingMode||!this.clientSecret){return[2]}t=this.defaultEmail?{email:this.defaultEmail}:undefined;s.label=1;case 1:s.trys.push([1,2,,6]);n=r.stripeLinkElement||r.stripeElements.create("linkAuthentication",{defaultValues:t});i=this.el.querySelector(".zonos--link-authentication-component");if(!i){k("Cannot find container element for linkAuthenticationElement");return[2]}n.mount(i);n.on("change",(function(t){var n;r.stripeLinkEventData=t;(n=o.linkAuthenticationChange)===null||n===void 0?void 0:n.emit()}));r.stripeLinkElement=n;this.retriesInitializeLink=0;if(this.retriesInitializeLink>11){_("Stripe link element initialized","info",{retriesInitializeLink:this.retriesInitializeLink,stripe:this.stripe});void x({endpoint:"stripe-link-authentication-init-long-running",errors:["Stripe link element initialized after 20 retries - 10 seconds"],metadata:{retriesInitializeLink:this.retriesInitializeLink}})}return[3,6];case 2:e=s.sent();if(!(e instanceof Error))return[3,5];this.retriesInitializeLink++;if(!(this.retriesInitializeLink<J))return[3,4];return[4,new Promise((function(t){return setTimeout(t,500)}))];case 3:s.sent();void this.watchInitStripe();s.label=4;case 4:if(this.retriesInitializeLink===J){void x({endpoint:"stripe-link-authentication-init-error",errors:[e.message],metadata:{retriesInitializeLink:this.retriesInitializeLink}})}s.label=5;case 5:return[3,6];case 6:return[2]}}))}))};t.prototype.watchDefaultEmail=function(t,n){var i,e;_("Default email is changed","info",{newDefaultEmail:t,oldDefaultEmail:n});if(n===t){return}if(!t){r.stripeLinkEventData=null}if(u.isStagingMode){this.setCustomEmailInputToLinkEvent(t||"");return}(i=r.stripeLinkElement)===null||i===void 0?void 0:i.clear();(e=r.stripeLinkElement)===null||e===void 0?void 0:e.destroy();r.stripeLinkElement=null;r.stripeLinkEventData=null;_("Reset stripe link element when default email is changed","info",{defaultEmail:t});void this.watchInitStripe()};t.prototype.disconnectedCallback=function(){try{this.storeUnsubscribeList.forEach((function(t){return t()}))}catch(t){}};t.prototype.componentDidLoad=function(){var t=this;this.storeUnsubscribeList=[d("stripeElements",(function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){void this.watchInitStripe();return[2]}))}))})),d("clientSecret",(function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){this.clientSecret=r.clientSecret;return[2]}))}))})),d("stripe",(function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){this.stripe=r.stripe;return[2]}))}))}))];void this.watchInitStripe();if(!this.defaultEmail){return}this.setCustomEmailInputToLinkEvent(this.defaultEmail)};t.prototype.render=function(){var t=this;this.isStagingMode=u.isStagingMode;this.clientSecret=r.clientSecret;var n=function(){var n;if(u.isStagingMode){return e("zonos-stripe-input",{inputLabel:v("Email"),inputValue:t.defaultEmail||((n=r.stripeLinkEventData)===null||n===void 0?void 0:n.value.email)||"",isError:t.isEmailError,onBlur:function(){var n;var i=((n=r.stripeLinkEventData)===null||n===void 0?void 0:n.value.email)||"";if(!i){return}var e=P(i);t.isEmailError=!e},onInputChange:t.handleNormalEmailInput})}return e("div",{class:"zonos--link-authentication-component ".concat(t.isEmailError&&"zonos--input-invalid")})};return e(o,{class:"zonos--link-authentication zonos--elements",style:{"--zonos--border-radius":S()}},this.titleText&&e("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),n(),this.isEmailError&&e("zonos-text",{textColor:"red-600"},v("Please enter a valid email address.")))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{isStagingMode:["watchIsStagingMode"],stripe:["watchInitStripe"],clientSecret:["watchInitStripe"],defaultEmail:["watchDefaultEmail"]}},enumerable:false,configurable:true});return t}());q.style=F;var G=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{position:fixed;inset:0;z-index:2147483010;pointer-events:none;display:block}:host .zonos--loading-overlay{position:fixed;inset:0;width:100vw;height:100vh;background:var(--zonos-elements-backdrop-color);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;opacity:0;visibility:hidden;-webkit-transition:opacity 0.3s ease, visibility 0.3s ease;transition:opacity 0.3s ease, visibility 0.3s ease;z-index:2147483010}:host(.zonos--open){pointer-events:auto}:host(.zonos--open) .zonos--loading-overlay{opacity:0.65;visibility:visible}";var U=G;var $=t("zonos_loading_overlay",function(){function t(t){n(this,t);this.open=false;this.size=40}t.prototype.render=function(){return e(o,{key:"13154a3c9250f15d8dca292f0673c6465bfb15e0",class:I(["zonos--elements",this.open&&"zonos--open"])},e("div",{key:"4470fccd21e58bd7959ef3e20c8775ac637cace0",class:"zonos--loading-overlay"},e("zonos-spinner",{key:"5b32b821cea982866da56176eeaafd5d8958f25d",size:this.size,spinnerColor:this.spinnerColor})))};return t}());$.style=U}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,n,i,e){function o(t){return t instanceof i?t:new i((function(n){n(t)}))}return new(i||(i=Promise))((function(i,s){function a(t){try{c(e.next(t))}catch(t){s(t)}}function r(t){try{c(e["throw"](t))}catch(t){s(t)}}function c(t){t.done?i(t.value):o(t.value).then(a,r)}c((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},e,o,s,a;return a={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function r(t){return function(n){return c([t,n])}}function c(r){if(e)throw new TypeError("Generator is already executing.");while(a&&(a=0,r[0]&&(i=0)),i)try{if(e=1,o&&(s=r[0]&2?o["return"]:r[0]?o["throw"]||((s=o["return"])&&s.call(o),0):o.next)&&!(s=s.call(o,r[1])).done)return s;if(o=0,s)r=[r[0]&2,s.value];switch(r[0]){case 0:case 1:s=r;break;case 4:i.label++;return{value:r[1],done:false};case 5:i.label++;o=r[1];r=[0];continue;case 7:r=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!s||r[1]>s[0]&&r[1]<s[3])){i.label=r[1];break}if(r[0]===6&&i.label<s[1]){i.label=s[1];s=r;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(r);break}if(s[2])i.ops.pop();i.trys.pop();continue}r=n.call(t,i)}catch(t){r=[6,t];o=0}finally{e=s=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};System.register(["./p-7261e245.system.js","./p-959918fe.system.js","./p-fbd44c55.system.js","./p-e2adf04b.system.js","./p-ac30b7a8.system.js","./p-01174496.system.js","./p-48d55793.system.js","./p-23e7c655.system.js","./p-d938f42f.system.js","./p-2b8345d8.system.js","./p-7501c637.system.js","./p-3fbd9cc0.system.js","./p-d18a2b2c.system.js","./p-655ec440.system.js"],(function(t){"use strict";var n,i,e,o,s,a,r,c,l,d,h,u,f,p,v,m,z,b,y,g,k,w,x,C,j,I,_,E,A,S;return{setters:[function(t){n=t.r;i=t.d;e=t.h;o=t.a;s=t.g},function(t){a=t.t},function(t){r=t.b;c=t.t;l=t.Q;d=t.E;h=t.q;u=t.d},function(t){f=t.s;p=t.r;v=t.t;m=t.q;z=t.l},function(t){b=t.z;y=t.g;g=t.f},function(t){k=t.l;w=t.i;x=t.s},function(t){C=t.a;j=t.s},function(t){I=t.c},function(t){_=t.l},function(t){E=t.c;A=t.s},function(t){S=t.g},function(){},function(){},function(){}],execute:function(){var O=".sc-zonos-address-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h .zonos--company-name-input.sc-zonos-address,.sc-zonos-address-h .zonos--tax-id-input.sc-zonos-address,.sc-zonos-address-h .zonos--short-address-code-input.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h zonos-banner.sc-zonos-address{margin-top:8px}";var L=O;var Z=t("zonos_address",function(){function t(t){n(this,t);this.invalidCharacters=i(this,"invalidCharacters",7);this.taxIdChanged=i(this,"taxIdChanged",7);this.storeUnsubscribeList=[];this.isAutoCompleteAdjusted=false;this.defaultAddress=[];this.taxIdErrorMessage="";this.shortAddressCodeErrorMessage="";this.stripe=window.Zonos.stripe;this.isDirtyAddress=false;this.isAddressFilled=false;this.checkoutSessionId=f.checkoutSessionId;this.prevCountry=null;this.prevPostalCode=null;this.trackingSent=false;this.prefetchLandedCost=a(h,1e3)}t.prototype.getStripeAddressInstance=function(){if(this.type==="billing"){return{stripeAddressElement:r.stripeBillingAddressElement,stripeAddressEventData:r.stripeBillingAddressEventData,stripeElements:r.stripeElementsForBillingAddress}}return{stripeAddressElement:r.stripeAddressElement,stripeAddressEventData:r.stripeAddressEventData,stripeElements:r.stripeElements}};t.prototype.updateAddressEventData=function(t){var n=t.event,i=t.type;switch(i){case"billing":r.stripeBillingAddressEventData=n;break;default:{r.stripeAddressEventData=n;break}}if(i==="shipping"){if(n.value.address.line1.length){void this.prefetchLandedCost()}}};t.prototype.isAddressFilledChanged=function(){if(!f.checkoutSessionId){return}if(this.isAddressFilled&&!this.trackingSent&&this.type==="shipping"){this.trackingSent=true;var t=f.checkoutSessionId;void c({checkoutSessionId:t,eventName:"checkout_customerInfoFilled"})}};t.prototype.updateAddressElement=function(t){var n=t.stripeAddressElement,i=t.type;if(i==="shipping"){r.stripeAddressElement=n;return}r.stripeBillingAddressElement=n};t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,i,e,o,s,a,r,c,d;var h=this;return __generator(this,(function(u){this.stripe=window.Zonos.stripe;t=this.getStripeAddressInstance(),n=t.stripeAddressEventData,i=t.stripeElements;if(!this.stripe||!i){k("Stripe is not initialized. Couldn't load stripe element.");return[2]}e=this.defaultAddress.map((function(t){return Object.assign(Object.assign({},t),{name:t.name,phone:t.phone||undefined})}));o=z.shippingZoneCountries;s=o?Object.values(o).map((function(t){return t.code})):[];a=new URLSearchParams(window.location.search).has("zonosCheckoutAllCountries");r=this.type==="shipping"?s:[];c=(n===null||n===void 0?void 0:n.value.address.country)||p(r);_("Stripe country code: ".concat(c),"info");d=i.create("address",{allowedCountries:a?[]:r,contacts:e.length&&!n?this.defaultAddress:[],defaultValues:{address:Object.assign(Object.assign({},n===null||n===void 0?void 0:n.value.address),{country:c}),firstName:n===null||n===void 0?void 0:n.value.firstName,lastName:n===null||n===void 0?void 0:n.value.lastName,phone:n===null||n===void 0?void 0:n.value.phone},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});d.mount(this.el.querySelector(".zonos--address-component"));if(n===null||n===void 0?void 0:n.value.address){this.prevCountry=n.value.address.country;this.prevPostalCode=n.value.address.postal_code}d.on("change",(function(t){var n=t.value;if(!h.isDirtyAddress&&n.address.line1.length>=3){h.isDirtyAddress=true;if(!h.isAutoCompleteAdjusted){var i=h.el.querySelector('iframe[src*="autocomplete-suggestions"]');if(i){i.style.zIndex="3"}h.isAutoCompleteAdjusted=true}setTimeout((function(){if(w()){h.el.scrollIntoView({behavior:"smooth",block:"end"})}else{var t=h.type==="shipping"?100:600;var n=h.el.closest(".zonos--group");var i=h.el.getBoundingClientRect().top+t;n===null||n===void 0?void 0:n.scrollTo({behavior:"smooth",top:i})}}),600)}var e=l({firstName:n.firstName,lastName:n.lastName,name:n.name}),o=e.firstName,s=e.lastName;h.updateAddressEventData({event:Object.assign(Object.assign({},t),{elementMode:h.type,elementType:"address",value:Object.assign(Object.assign({},n),{firstName:o,lastName:s})}),type:h.type})}));this.updateAddressElement({stripeAddressElement:d,type:this.type});return[2]}))}))};t.prototype.defaultAddressChanged=function(t,n){var i=JSON.stringify(n);var e=JSON.stringify(t);if(i===e){return}_("Reset address element when default address property is changed","info",{defaultAddress:this.defaultAddress});var o=this.getStripeAddressInstance().stripeAddressElement;o===null||o===void 0?void 0:o.clear();o===null||o===void 0?void 0:o.destroy();if(this.type==="shipping"){r.stripeAddressEventData=null}else{r.stripeBillingAddressEventData=null}void this.watchInitStripe()};t.prototype.isInTaxIdCountry=function(t){return E.includes(t)};t.prototype.renderTaxIdInput=function(){var t=this;var n;if(this.type==="billing"){return null}var i=(n=r.stripeAddressEventData)===null||n===void 0?void 0:n.value.address.country;if(!i){return null}if(!this.isInTaxIdCountry(i)){return null}var o=C({companyName:r.companyName,countryCode:i});if(!o){return null}var s=A[i];return e("div",{class:"zonos--tax-id-input"},e("zonos-stripe-input",{inputLabel:v(s.friendlyName),inputPlaceholder:s.placeholder,inputValue:r.taxId||"",isError:!!this.taxIdErrorMessage,onInputChange:function(n){r.taxId=n.detail;t.taxIdChanged.emit(n.detail)}}),this.taxIdErrorMessage&&e("zonos-text",{textColor:"red-600",type:"caption"},this.taxIdErrorMessage))};t.prototype.renderShortAddressCodeInput=function(){var t;if(this.type==="billing"){return null}var n=(t=r.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country;if(!n){return null}var i=j({countryCode:n});if(!i){return null}return e("div",{class:"zonos--short-address-code-input"},e("zonos-stripe-input",{inputLabel:v("Short address code"),inputPlaceholder:"RRRD2929",inputValue:r.shortAddressCode||"",isError:!!this.shortAddressCodeErrorMessage,onInputChange:function(t){r.shortAddressCode=t.detail}}),this.shortAddressCodeErrorMessage&&e("zonos-text",{textColor:"red-600",type:"caption"},this.shortAddressCodeErrorMessage))};t.prototype.renderCompanyNameInput=function(){if(this.type==="billing"&&!window.Zonos.isCollect&&!window.Zonos.isInvoice){return null}var t=b.checkoutSettings.companyFieldsStatus==="ENABLED"||!!window.Zonos.isCollect||!!window.Zonos.isInvoice;if(!t){return null}return e("zonos-stripe-input",{class:"zonos--company-name-input",inputLabel:v("Company name (optional)"),inputValue:r.companyName,onInputChange:function(t){r.companyName=t.detail}})};t.prototype.disconnectedCallback=function(){var t=this.getStripeAddressInstance().stripeAddressElement;t===null||t===void 0?void 0:t.destroy();try{this.storeUnsubscribeList.forEach((function(t){return t()}))}catch(t){}};t.prototype.componentDidLoad=function(){var t=this;var n=this.getStripeAddressInstance().stripeAddressEventData;this.isDirtyAddress=!!n&&n.value.address.line1.length>0;void this.watchInitStripe();this.checkoutSessionId=f.checkoutSessionId;this.storeUnsubscribeList=[m("checkoutSessionId",(function(){t.checkoutSessionId=f.checkoutSessionId})),d("stripeElements",(function(){if(t.type==="shipping"){void t.watchInitStripe()}})),d("stripeElementsForBillingAddress",(function(){if(t.type==="billing"){void t.watchInitStripe()}}))]};t.prototype.render=function(){var t;this.checkoutSessionId=f.checkoutSessionId;if((t=r.stripeAddressEventData)===null||t===void 0?void 0:t.complete){this.isAddressFilled=true}return e(o,{key:"5dc571d7c5e706ae9cb90de70deee22847e5ba7e",class:I(["zonos--address","zonos--elements","zonos--".concat(this.type,"-address")])},this.titleText&&e("zonos-text",{key:"a7c9f730bc9b64aa2c6e8cc24701e638481eac19",class:"zonos--title",type:"semiBoldLabel"},this.titleText),e("slot",{key:"3078529c201c7947ffc833485d46184bc79ab1d1",name:"below-title"}),this.renderCompanyNameInput(),this.renderTaxIdInput(),this.renderShortAddressCodeInput(),e("div",{key:"b4a9850ac30ad9c483e05743ff41b7de9756d826",class:"zonos--address-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{checkoutSessionId:["isAddressFilledChanged"],isAddressFilled:["isAddressFilledChanged"],stripe:["watchInitStripe"],defaultAddress:["defaultAddressChanged"]}},enumerable:false,configurable:true});return t}());Z.style=L;var N='<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-400)"></path>\n <path d="M12.75 9a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V9Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var B='<svg color="var(--zonos-elements-blue-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-blue-400)"></path>\n <path d="M10.25 10.25a1.75 1.75 0 1 1 2.431 1.613c-.616.26-1.431.885-1.431 1.887a.75.75 0 0 0 1.5 0c0-.053.02-.128.108-.228.092-.104.236-.205.408-.278A3.25 3.25 0 1 0 8.75 10.25a.75.75 0 0 0 1.5 0Zm2.5 5.75a.75.75 0 0 0-1.5 0v.25a.75.75 0 0 0 1.5 0V16Z" fill="currentColor"></path>\n</svg>';var D='<svg color="var(--zonos-elements-orange-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M14.46 5.492c-1.014-2.027-3.906-2.027-4.92 0L4.276 16.02c-.914 1.83.416 3.98 2.46 3.98h10.528c2.044 0 3.374-2.151 2.46-3.98L14.46 5.492Z" data-is-secondary-color="true" fill="var(--zonos-elements-orange-400)"></path>\n <path d="M12.75 10a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V10Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>';var M=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--backdrop,:host .zonos--confirm-layout{opacity:0;z-index:-999;visibility:hidden;-webkit-transition:opacity 0.3s, visibility 0.3s;transition:opacity 0.3s, visibility 0.3s}:host .zonos--backdrop{width:100vw;height:100vh;left:0;top:0;background:var(--zonos-elements-backdrop-color);position:fixed}:host .zonos--confirm-layout{width:100vw;height:100vh;left:0;top:0;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;color:var(--zonos-elements-text-color)}:host .zonos--confirm-dialog{position:relative;background:var(--zonos-elements-gray-0);max-width:90vw;max-height:90vh;width:var(--zonos--dialog-width);border-radius:var(--zonos--border-radius, 10px);outline:none;-webkit-box-shadow:var(--zonos-elements-v3-shadow-xxl);box-shadow:var(--zonos-elements-v3-shadow-xxl);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host .wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;gap:24px}:host .icon-wrapper{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:40px;width:40px;border-radius:50%;background:var(--zonos-elements-blue-100)}:host .warn .icon-wrapper{background:var(--zonos-elements-orange-100)}:host .danger .icon-wrapper{background:var(--zonos-elements-red-100)}:host .footer{display:-ms-flexbox;display:flex;width:100%;gap:8px}:host .footer zonos-button{-ms-flex:1;flex:1}:host .content{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .content zonos-text{text-align:center}:host(.open) .zonos--confirm-layout,:host(.open) .zonos--backdrop{visibility:visible}:host(.open) .zonos--backdrop{z-index:2147483009;opacity:0.65}:host(.open) .zonos--confirm-layout{opacity:1;z-index:2147483010;-webkit-transform:scale(1);transform:scale(1)}";var V=M;var T=t("zonos_confirm_dialog",function(){function t(t){var e=this;n(this,t);this.confirmClicked=i(this,"confirmClicked",7);this.cancelClicked=i(this,"cancelClicked",7);this.dialogTitle=v("Are you sure?");this.dialogIntent="info";this.dialogSubtitle=null;this.dialogWidth=350;this.dialogType="confirm";this.isMobile=false;this.noClickOutside=false;this.clickOutsideDialogHandler=function(t){if(t.target===t.currentTarget&&!e.noClickOutside){e.closeDialogHandler()}}}t.prototype.handleKeyDown=function(t){if(t.key==="Escape"){this.closeDialogHandler()}};t.prototype.focusDialog=function(){var t=this;if(this.dialogOpen){setTimeout((function(){var n,i;(i=(n=t.el.shadowRoot)===null||n===void 0?void 0:n.querySelector(".zonos--backdrop"))===null||i===void 0?void 0:i.focus()}),100)}};t.prototype.confirmDialogHandler=function(){if(!this.dialogOpen){return}this.confirmClicked.emit()};t.prototype.closeDialogHandler=function(){if(!this.dialogOpen){return}this.cancelClicked.emit()};t.prototype.renderIcon=function(){switch(this.dialogIntent){case"info":return e("zonos-icon",{content:B,iconColor:"blue-800"});case"danger":return e("zonos-icon",{content:N,iconColor:"red-800"});case"warn":return e("zonos-icon",{content:D,iconColor:"orange-800"})}};t.prototype.getButtonConfirmVariant=function(){switch(this.dialogIntent){case"warn":return"warning";case"danger":return"danger";default:return"primary"}};t.prototype.render=function(){var t=this;this.focusDialog();var n=S();var i=y(b.appearance.theme);return e(o,{key:"db0bfe0b8a125e806a97c9382faa938078000349",class:I([this.dialogOpen&&"open","zonos--elements"]),"data-dialog-type":this.dialogType,"data-theme":i,style:{"--zonos--border-radius":n,"--zonos--dialog-width":"".concat(this.dialogWidth,"px"),"--zonos--font-family":g()}},e("div",{key:"1676defad54705df4e9282bda6b5734592d0fb60",class:"zonos--backdrop",tabIndex:-1}),e("div",{key:"2a6ec6b5df7ea30304cfed5276e55618b40add93",class:I(["zonos--confirm-layout",this.dialogIntent]),onClick:function(n){return t.clickOutsideDialogHandler(n)}},e("div",{key:"d1c8358c3fd98c27a469fe7443d1983c1c134a7c",class:"zonos--confirm-dialog",onBlur:function(){t.focusDialog()}},e("div",{key:"137e9659aa7aec2e4604acf80809b35bce69ca79",class:"wrapper"},e("div",{key:"9c1057857ea095e7e88c8950469add2bc4c1318e",class:"icon-wrapper"},this.renderIcon()),e("div",{key:"48f0e0cd9ce62b425bae831d1387261bbd4162a1",class:"content"},e("div",{key:"0d3e681f350e5db547181beadf5c6bcf49a8bbd2",class:"title"},e("zonos-text",{key:"f16a43d2b3c9504911b1e36ba573873f80093c47",type:"subheader"},this.dialogTitle)),this.dialogSubtitle&&e("div",{key:"fd570f98bc736a68c16fedee72b1417dc6906fa6",class:"subtitle"},e("zonos-text",{key:"6785aa19dd44cf7f6fae7317e3924be6c6ee8af3",textColor:"gray-800"},this.dialogSubtitle))),e("div",{key:"4206cad3dcff0055fc5f3ea8e7c217ae33c63263",class:"footer"},this.dialogType==="confirm"&&e("zonos-button",{key:"72d1a216641d482bdbeae384963dcdff1cfc3f45",backgroundColor:"gray-0",class:"cancel-button",onClick:function(){return t.closeDialogHandler()},size:"lg",withBoxShadow:true},this.dialogCancelBtnText||v("Cancel")),e("zonos-button",{key:"a6a206eff11d1f42c33ef9113cc393d727c60f89",class:"confirm-button",onClick:function(){return t.confirmDialogHandler()},size:"lg",variant:this.getButtonConfirmVariant()},this.dialogConfirmBtnText))))))};Object.defineProperty(t,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});return t}());T.style=V;var P=function(t){var n=/^[a-zA-Z0-9.%_+-]*@[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z0-9]{2,}$/;return n.test(t)};var R=".sc-zonos-link-authentication-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:16px}.sc-zonos-link-authentication-h .zonos--input-invalid.sc-zonos-link-authentication{border:2px solid var(--zonos-elements-red-600);border-radius:var(--zonos--border-radius)}";var F=R;var J=51;var q=t("zonos_link_authentication",function(){function t(t){var e=this;n(this,t);this.linkAuthenticationChange=i(this,"linkAuthenticationChange",7);this.storeUnsubscribeList=[];this.defaultEmail=null;this.isEmailError=false;this.stripe=r.stripe;this.isStagingMode=u.isStagingMode;this.clientSecret=r.clientSecret;this.retriesInitializeLink=0;this.setCustomEmailInputToLinkEvent=function(t){var n=P(t);var i={complete:!!n,elementType:"linkAuthentication",empty:!t,value:{email:t}};r.stripeLinkEventData=i};this.handleNormalEmailInput=function(t){var n;var i=t.detail;e.setCustomEmailInputToLinkEvent(i);(n=e.linkAuthenticationChange)===null||n===void 0?void 0:n.emit()}}t.prototype.watchIsStagingMode=function(){var t=this;setTimeout((function(){void t.watchInitStripe()}),0)};t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,i,e;var o=this;return __generator(this,(function(s){switch(s.label){case 0:if(!this.stripe||!r.stripeElements){return[2]}if(u.isStagingMode||!this.clientSecret){return[2]}t=this.defaultEmail?{email:this.defaultEmail}:undefined;s.label=1;case 1:s.trys.push([1,2,,6]);n=r.stripeLinkElement||r.stripeElements.create("linkAuthentication",{defaultValues:t});i=this.el.querySelector(".zonos--link-authentication-component");if(!i){k("Cannot find container element for linkAuthenticationElement");return[2]}n.mount(i);n.on("change",(function(t){var n;r.stripeLinkEventData=t;(n=o.linkAuthenticationChange)===null||n===void 0?void 0:n.emit()}));r.stripeLinkElement=n;this.retriesInitializeLink=0;if(this.retriesInitializeLink>11){_("Stripe link element initialized","info",{retriesInitializeLink:this.retriesInitializeLink,stripe:this.stripe});void x({endpoint:"stripe-link-authentication-init-long-running",errors:["Stripe link element initialized after 20 retries - 10 seconds"],metadata:{retriesInitializeLink:this.retriesInitializeLink}})}return[3,6];case 2:e=s.sent();if(!(e instanceof Error))return[3,5];this.retriesInitializeLink++;if(!(this.retriesInitializeLink<J))return[3,4];return[4,new Promise((function(t){return setTimeout(t,500)}))];case 3:s.sent();void this.watchInitStripe();s.label=4;case 4:if(this.retriesInitializeLink===J){void x({endpoint:"stripe-link-authentication-init-error",errors:[e.message],metadata:{retriesInitializeLink:this.retriesInitializeLink}})}s.label=5;case 5:return[3,6];case 6:return[2]}}))}))};t.prototype.watchDefaultEmail=function(t,n){var i,e;_("Default email is changed","info",{newDefaultEmail:t,oldDefaultEmail:n});if(n===t){return}if(!t){r.stripeLinkEventData=null}if(u.isStagingMode){this.setCustomEmailInputToLinkEvent(t||"");return}(i=r.stripeLinkElement)===null||i===void 0?void 0:i.clear();(e=r.stripeLinkElement)===null||e===void 0?void 0:e.destroy();r.stripeLinkElement=null;r.stripeLinkEventData=null;_("Reset stripe link element when default email is changed","info",{defaultEmail:t});void this.watchInitStripe()};t.prototype.disconnectedCallback=function(){try{this.storeUnsubscribeList.forEach((function(t){return t()}))}catch(t){}};t.prototype.componentDidLoad=function(){var t=this;this.storeUnsubscribeList=[d("stripeElements",(function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){void this.watchInitStripe();return[2]}))}))})),d("clientSecret",(function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){this.clientSecret=r.clientSecret;return[2]}))}))})),d("stripe",(function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){this.stripe=r.stripe;return[2]}))}))}))];void this.watchInitStripe();if(!this.defaultEmail){return}this.setCustomEmailInputToLinkEvent(this.defaultEmail)};t.prototype.render=function(){var t=this;this.isStagingMode=u.isStagingMode;this.clientSecret=r.clientSecret;var n=function(){var n;if(u.isStagingMode){return e("zonos-stripe-input",{inputLabel:v("Email"),inputValue:t.defaultEmail||((n=r.stripeLinkEventData)===null||n===void 0?void 0:n.value.email)||"",isError:t.isEmailError,onBlur:function(){var n;var i=((n=r.stripeLinkEventData)===null||n===void 0?void 0:n.value.email)||"";if(!i){return}var e=P(i);t.isEmailError=!e},onInputChange:t.handleNormalEmailInput})}return e("div",{class:"zonos--link-authentication-component ".concat(t.isEmailError&&"zonos--input-invalid")})};return e(o,{class:"zonos--link-authentication zonos--elements",style:{"--zonos--border-radius":S()}},this.titleText&&e("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),n(),this.isEmailError&&e("zonos-text",{textColor:"red-600"},v("Please enter a valid email address.")))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{isStagingMode:["watchIsStagingMode"],stripe:["watchInitStripe"],clientSecret:["watchInitStripe"],defaultEmail:["watchDefaultEmail"]}},enumerable:false,configurable:true});return t}());q.style=F;var G=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{position:fixed;inset:0;z-index:2147483010;pointer-events:none;display:block}:host .zonos--loading-overlay{position:fixed;inset:0;width:100vw;height:100vh;background:var(--zonos-elements-backdrop-color);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;opacity:0;visibility:hidden;-webkit-transition:opacity 0.3s ease, visibility 0.3s ease;transition:opacity 0.3s ease, visibility 0.3s ease;z-index:2147483010}:host(.zonos--open){pointer-events:auto}:host(.zonos--open) .zonos--loading-overlay{opacity:0.65;visibility:visible}";var U=G;var $=t("zonos_loading_overlay",function(){function t(t){n(this,t);this.open=false;this.size=40}t.prototype.render=function(){return e(o,{key:"13154a3c9250f15d8dca292f0673c6465bfb15e0",class:I(["zonos--elements",this.open&&"zonos--open"])},e("div",{key:"4470fccd21e58bd7959ef3e20c8775ac637cace0",class:"zonos--loading-overlay"},e("zonos-spinner",{key:"5b32b821cea982866da56176eeaafd5d8958f25d",size:this.size,spinnerColor:this.spinnerColor})))};return t}());$.style=U}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,h as e,a as t,g as s}from"./p-ce75b047.js";import{d as i}from"./p-908f13ae.js";import{l,i as n,t as r,g as h,j as a,k as d,m as c,n as m,d as p}from"./p-13041752.js";import{z as g,g as w,m as f}from"./p-058f6124.js";import{c as z}from"./p-b4b7f705.js";import{h as u,l as b}from"./p-41dd1cb8.js";import{g as v}from"./p-5883217a.js";import{l as x}from"./p-0a377722.js";const y=o=>{const e=null==o?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)},k=()=>{var o,e;const{productAddToCartElementSelector:t,productDescriptionElementSelector:s,productTitleElementSelector:i,restrictionBehavior:l}=g.helloSettings;i&&s||x("Hello could not check item restrictions - must provide title and description selectors.");const r=i&&n(i)&&document.querySelectorAll(i)||[],h=s&&n(s)&&document.querySelectorAll(s)||[];if(r.length!==h.length)return x("Hello could not check item restrictions - Title and description selectors do not match"),[];const a="RESTRICT_AND_BLOCK"===l,d=a&&t&&n(t)&&document.querySelectorAll(t)||[];a&&d.length!==h.length&&x('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match');const c=[];for(let t=0;t<r.length;t++){const s=r[t],i=h[t];if(s&&i){const l={cartButtonNode:d[t]||null,description:(null===(o=i.textContent)||void 0===o?void 0:o.trim())||"",title:(null===(e=s.textContent)||void 0===e?void 0:e.trim())||""};c.push(l)}}return c},L=class{constructor(e){o(this,e),this.showPeekMessage=!1,this.zonosStoreHelloSettings=g.helloSettings,this.showDialog=!1,this.peekMessage="",this.initialUrl="",this.allRestrictedItems=[],this.allFoundProducts=[],this.productsOnPage=[],this.isHelloWidgetRendered=!1,this.isMobile=!1,this.getHelloPeekMessage=o=>{if(("productDetail"===g.currentHelloPage||"productList"===g.currentHelloPage)&&this.allRestrictedItems.length){const o=r("click to learn more");return`${r("productDetail"===g.currentHelloPage?"Restricted item":"Restricted items found")} - ${o}`}switch(g.currentHelloPage){case"cart":return r("Prepay duties and taxes at checkout");case"productList":case"productDetail":return r("See duty and tax thresholds");default:return r("Welcome to [storeName]",{storeName:o})}},this.enableShowPeekMessage=()=>{this.peekMessage&&(this.showPeekMessage=!0)},this.getNewItemRestrictions=async o=>"productDetail"!==g.currentHelloPage&&"productList"!==g.currentHelloPage||"DISABLED"===g.helloSettings.restrictionBehavior?[]:await(async o=>{if(!o.length)return[];const{selectedCountryCode:e}=l;if(!e)return b("Hello could not check item restrictions - No country code selected"),[];const t=o.map((o=>({description:o.description,name:o.title})));return(await(async({items:o,shipFrom:e,shipTo:t})=>{var s;const i={items:o,shipFrom:e,shipTo:t},{errors:l,json:n}=await u("/api/zonos-elements/check-item-restrictions",{body:i,method:"POST"});return l.length||!n?(b(`Error fetching item restrictions: ${null===(s=l.find(Boolean))||void 0===s?void 0:s.message}`),[]):n.filter(Boolean)})({items:t,shipFrom:"AD",shipTo:e})).map((o=>{var e;const s=(null===(e=t.filter((e=>e.description===o.itemDescription)).find(Boolean))||void 0===e?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:s})}))})(o),this.triggerShowPeekMessage=()=>{this.peekMessage=this.getHelloPeekMessage(g.organizationName);const{peekMessageBehavior:o,peekMessageDelay:e}=g.helloSettings;"ENABLED"===o&&setTimeout((()=>{this.enableShowPeekMessage(),this.allRestrictedItems.some((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))))||setTimeout((()=>{this.showPeekMessage=!1}),3e3)}),1e3*e)},this.disableAddToCartButtons=()=>{this.productsOnPage.length&&this.productsOnPage.forEach((o=>{var e,t;this.allRestrictedItems.some((e=>e.itemDescription===o.description))?null===(e=o.cartButtonNode)||void 0===e||e.setAttribute("disabled","disabled"):null===(t=o.cartButtonNode)||void 0===t||t.removeAttribute("disabled")}))},this.handleItemRestrictions=async()=>{this.productsOnPage=k();const o=this.productsOnPage.filter((o=>!this.allFoundProducts.some((e=>e.title===o.title)))),e=await this.getNewItemRestrictions(o);this.allRestrictedItems.push(...e),this.allFoundProducts.push(...o),this.disableAddToCartButtons()},this.reloadHelloData=async()=>{await this.handleItemRestrictions(),this.triggerShowPeekMessage()},this.handleProductCountChange=i((()=>{const{productTitleElementSelector:o}=g.helloSettings;if(o){const o=k();if(this.allFoundProducts.length!==o.length&&window.location.href===this.initialUrl){if(!this.allFoundProducts.length)return;this.reloadHelloData()}}}),1e3),this.watchProductCountChange=()=>{var o;const e=new MutationObserver(this.handleProductCountChange);e.observe(document.body,{childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.watchPriceChange=()=>{var o;const e=new MutationObserver((()=>{this.displayCurrency()}));e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.updateHelloOnPageChange=()=>{this.watchProductCountChange(),setInterval((()=>{if(window.location.href!==this.initialUrl){const o=this.initialUrl&&new URL(this.initialUrl);(o&&h(o.searchParams))!==l.selectedCountryCode&&(this.allFoundProducts=[],this.allRestrictedItems=[],this.productsOnPage=[]),this.initialUrl=window.location.href,g.currentHelloPage=(()=>{const{cartUrlPattern:o,homepageUrlPattern:e,productDetailUrlPattern:t,productListUrlPattern:s}=g.helloSettings;return y(o)?"cart":y(t)?"productDetail":y(s)?"productList":y(e)?"home":""})();const e=new URL(window.location.href);if(!h(e.searchParams))return void a(l.selectedCountryCode);this.reloadHelloData()}}),1e3)},this.changeShowDialog=o=>{this.showDialog=o},this.shouldAnimateLeftDesktop=()=>{const o=this.helloRef&&getComputedStyle(this.helloRef).position;if(this.helloRef&&"relative"===o)return v(this.helloRef)},this.shouldRenderHello=(o=!0)=>{if(!l.localizationLoaded)return!1;const{showForCountries:e}=g.helloSettings;return o&&(l.isShippableCountry||x(`Hello: not shippable country - Show for countries: ${e}`)),"ONLY_SHIPPABLE"===e?l.isShippableCountry:"ALL"===e||(null==e?void 0:e.includes(l.selectedCountryCode||""))}}showDialogHandler(o){var e;if(o){const o=null===(e=this.helloElement)||void 0===e?void 0:e.parentElement;o&&o.parentElement===document.body&&(o.style.zIndex="2147483647",document.body.appendChild(o))}}async getCountryList(){return l.helloCountryList}componentWillLoad(){const o=setInterval((async()=>{this.helloRef&&g.loadedConfig&&(this.helloRef.setAttribute("data-zonos-hello-loaded",""),this.updateHelloOnPageChange(),this.watchPriceChange(),this.handleAppearanceSettingsOverrideChange(),clearInterval(o))}),100)}disconnectedCallback(){var o;null===(o=this.observerWatcher)||void 0===o||o.forEach((o=>o.disconnect()))}async displayCurrency(){"DISABLED"!==g.helloSettings.currencyBehavior&&(l.exchangeRate?d():x("Could not display currency. Exchange rate and format data is not available.","warn"))}async convertAndFormat(o){return c(o)}async convert(o){return m(o)}async format(o){return p({amount:o})}async openHelloDialog(o){this.changeShowDialog(o)}handleResize(){this.isMobile=window.innerWidth<=768}handleHelloWidgetInitializedState({countryCode:o,currencyCode:e}){var t,s;this.isHelloWidgetRendered||l.selectedCountryCode&&"function"==typeof g.helloSettings.onInitSuccess&&(this.isHelloWidgetRendered=!0,null===(s=(t=g.helloSettings).onInitSuccess)||void 0===s||s.call(t,{countryCode:o,currencyCode:e}))}getHelloLocation(){const o=this.mobileLocationOverride||g.helloSettings.mobileLocation,e=g.helloSettings.desktopLocation,t=this.isMobile;if(!0===t)return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==o?void 0:o.includes("LEFT")),isOnTop:null==o?void 0:o.includes("TOP"),shouldFloat:!!o};{const o=!g.helloSettings.anchorElementSelector&&!!e;return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==e?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop(),isOnTop:null==e?void 0:e.includes("TOP"),shouldFloat:o}}}handleAppearanceSettingsOverrideChange(){var o;(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)&&(this.appearanceSettingsOverride.theme=w(this.appearanceSettingsOverride.theme))}componentDidLoad(){this.isMobile=window.innerWidth<=768}render(){var o,s;if(null===(o=g.helloSettings.excludedUrlPatterns)||void 0===o?void 0:o.some((o=>o&&new RegExp(o).test(window.location.href))))return x("Hello is excluded on this url","warn"),null;const{selectedCountryCode:i,targetCurrency:n}=l,{isOnLeft:r,isOnTop:h,shouldFloat:a}=this.getHelloLocation(),d=f(g.appearance,this.appearanceSettingsOverride||null),{theme:c}=d,m=null===(s=this.allRestrictedItems)||void 0===s?void 0:s.filter((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))));this.peekMessage=this.getHelloPeekMessage(g.organizationName);const p=this.shouldRenderHello()&&!!i;return p&&!this.isHelloWidgetRendered&&this.handleHelloWidgetInitializedState({countryCode:i,currencyCode:n}),e(t,{class:"zonos--hello zonos--elements","data-theme":c},p&&e("div",{class:z(["zonos--hello-wrapper",a&&"zonos--hello-widget-float"])},e("button",{class:z(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",a&&"zonos--hello-widget-float"]),onClick:()=>{this.changeShowDialog(!this.showDialog)},onMouseEnter:()=>this.enableShowPeekMessage(),onMouseLeave:()=>this.showPeekMessage=!1,ref:o=>o&&(this.helloRef=o),type:"button"},e("zonos-text",{class:"zonos--hello-message"},this.peekMessage),i&&e("div",{class:"zonos--hello-country-flag-wrapper"},e("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:i}))),e("div",{class:z(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",a&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},e("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:d,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:m,setIsOpen:this.changeShowDialog}))))}get helloElement(){return s(this)}static get watchers(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}}};L.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}@media screen and (min-width: 769px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px;width:auto;height:auto;z-index:1001}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";export{L as zonos_hello}
|
|
1
|
+
import{r as o,h as e,a as t,g as s}from"./p-ce75b047.js";import{d as i}from"./p-908f13ae.js";import{l,i as n,t as r,g as h,j as a,k as d,m as c,n as m,d as p}from"./p-99e1734a.js";import{z as g,g as w,m as f}from"./p-058f6124.js";import{c as z}from"./p-b4b7f705.js";import{h as u,l as b}from"./p-41dd1cb8.js";import{g as v}from"./p-5883217a.js";import{l as x}from"./p-0a377722.js";const y=o=>{const e=null==o?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)},k=()=>{var o,e;const{productAddToCartElementSelector:t,productDescriptionElementSelector:s,productTitleElementSelector:i,restrictionBehavior:l}=g.helloSettings;i&&s||x("Hello could not check item restrictions - must provide title and description selectors.");const r=i&&n(i)&&document.querySelectorAll(i)||[],h=s&&n(s)&&document.querySelectorAll(s)||[];if(r.length!==h.length)return x("Hello could not check item restrictions - Title and description selectors do not match"),[];const a="RESTRICT_AND_BLOCK"===l,d=a&&t&&n(t)&&document.querySelectorAll(t)||[];a&&d.length!==h.length&&x('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match');const c=[];for(let t=0;t<r.length;t++){const s=r[t],i=h[t];if(s&&i){const l={cartButtonNode:d[t]||null,description:(null===(o=i.textContent)||void 0===o?void 0:o.trim())||"",title:(null===(e=s.textContent)||void 0===e?void 0:e.trim())||""};c.push(l)}}return c},L=class{constructor(e){o(this,e),this.showPeekMessage=!1,this.zonosStoreHelloSettings=g.helloSettings,this.showDialog=!1,this.peekMessage="",this.initialUrl="",this.allRestrictedItems=[],this.allFoundProducts=[],this.productsOnPage=[],this.isHelloWidgetRendered=!1,this.isMobile=!1,this.getHelloPeekMessage=o=>{if(("productDetail"===g.currentHelloPage||"productList"===g.currentHelloPage)&&this.allRestrictedItems.length){const o=r("click to learn more");return`${r("productDetail"===g.currentHelloPage?"Restricted item":"Restricted items found")} - ${o}`}switch(g.currentHelloPage){case"cart":return r("Prepay duties and taxes at checkout");case"productList":case"productDetail":return r("See duty and tax thresholds");default:return r("Welcome to [storeName]",{storeName:o})}},this.enableShowPeekMessage=()=>{this.peekMessage&&(this.showPeekMessage=!0)},this.getNewItemRestrictions=async o=>"productDetail"!==g.currentHelloPage&&"productList"!==g.currentHelloPage||"DISABLED"===g.helloSettings.restrictionBehavior?[]:await(async o=>{if(!o.length)return[];const{selectedCountryCode:e}=l;if(!e)return b("Hello could not check item restrictions - No country code selected"),[];const t=o.map((o=>({description:o.description,name:o.title})));return(await(async({items:o,shipFrom:e,shipTo:t})=>{var s;const i={items:o,shipFrom:e,shipTo:t},{errors:l,json:n}=await u("/api/zonos-elements/check-item-restrictions",{body:i,method:"POST"});return l.length||!n?(b(`Error fetching item restrictions: ${null===(s=l.find(Boolean))||void 0===s?void 0:s.message}`),[]):n.filter(Boolean)})({items:t,shipFrom:"AD",shipTo:e})).map((o=>{var e;const s=(null===(e=t.filter((e=>e.description===o.itemDescription)).find(Boolean))||void 0===e?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:s})}))})(o),this.triggerShowPeekMessage=()=>{this.peekMessage=this.getHelloPeekMessage(g.organizationName);const{peekMessageBehavior:o,peekMessageDelay:e}=g.helloSettings;"ENABLED"===o&&setTimeout((()=>{this.enableShowPeekMessage(),this.allRestrictedItems.some((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))))||setTimeout((()=>{this.showPeekMessage=!1}),3e3)}),1e3*e)},this.disableAddToCartButtons=()=>{this.productsOnPage.length&&this.productsOnPage.forEach((o=>{var e,t;this.allRestrictedItems.some((e=>e.itemDescription===o.description))?null===(e=o.cartButtonNode)||void 0===e||e.setAttribute("disabled","disabled"):null===(t=o.cartButtonNode)||void 0===t||t.removeAttribute("disabled")}))},this.handleItemRestrictions=async()=>{this.productsOnPage=k();const o=this.productsOnPage.filter((o=>!this.allFoundProducts.some((e=>e.title===o.title)))),e=await this.getNewItemRestrictions(o);this.allRestrictedItems.push(...e),this.allFoundProducts.push(...o),this.disableAddToCartButtons()},this.reloadHelloData=async()=>{await this.handleItemRestrictions(),this.triggerShowPeekMessage()},this.handleProductCountChange=i((()=>{const{productTitleElementSelector:o}=g.helloSettings;if(o){const o=k();if(this.allFoundProducts.length!==o.length&&window.location.href===this.initialUrl){if(!this.allFoundProducts.length)return;this.reloadHelloData()}}}),1e3),this.watchProductCountChange=()=>{var o;const e=new MutationObserver(this.handleProductCountChange);e.observe(document.body,{childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.watchPriceChange=()=>{var o;const e=new MutationObserver((()=>{this.displayCurrency()}));e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.updateHelloOnPageChange=()=>{this.watchProductCountChange(),setInterval((()=>{if(window.location.href!==this.initialUrl){const o=this.initialUrl&&new URL(this.initialUrl);(o&&h(o.searchParams))!==l.selectedCountryCode&&(this.allFoundProducts=[],this.allRestrictedItems=[],this.productsOnPage=[]),this.initialUrl=window.location.href,g.currentHelloPage=(()=>{const{cartUrlPattern:o,homepageUrlPattern:e,productDetailUrlPattern:t,productListUrlPattern:s}=g.helloSettings;return y(o)?"cart":y(t)?"productDetail":y(s)?"productList":y(e)?"home":""})();const e=new URL(window.location.href);if(!h(e.searchParams))return void a(l.selectedCountryCode);this.reloadHelloData()}}),1e3)},this.changeShowDialog=o=>{this.showDialog=o},this.shouldAnimateLeftDesktop=()=>{const o=this.helloRef&&getComputedStyle(this.helloRef).position;if(this.helloRef&&"relative"===o)return v(this.helloRef)},this.shouldRenderHello=(o=!0)=>{if(!l.localizationLoaded)return!1;const{showForCountries:e}=g.helloSettings;return o&&(l.isShippableCountry||x(`Hello: not shippable country - Show for countries: ${e}`)),"ONLY_SHIPPABLE"===e?l.isShippableCountry:"ALL"===e||(null==e?void 0:e.includes(l.selectedCountryCode||""))}}showDialogHandler(o){var e;if(o){const o=null===(e=this.helloElement)||void 0===e?void 0:e.parentElement;o&&o.parentElement===document.body&&(o.style.zIndex="2147483647",document.body.appendChild(o))}}async getCountryList(){return l.helloCountryList}componentWillLoad(){const o=setInterval((async()=>{this.helloRef&&g.loadedConfig&&(this.helloRef.setAttribute("data-zonos-hello-loaded",""),this.updateHelloOnPageChange(),this.watchPriceChange(),this.handleAppearanceSettingsOverrideChange(),clearInterval(o))}),100)}disconnectedCallback(){var o;null===(o=this.observerWatcher)||void 0===o||o.forEach((o=>o.disconnect()))}async displayCurrency(){"DISABLED"!==g.helloSettings.currencyBehavior&&(l.exchangeRate?d():x("Could not display currency. Exchange rate and format data is not available.","warn"))}async convertAndFormat(o){return c(o)}async convert(o){return m(o)}async format(o){return p({amount:o})}async openHelloDialog(o){this.changeShowDialog(o)}handleResize(){this.isMobile=window.innerWidth<=768}handleHelloWidgetInitializedState({countryCode:o,currencyCode:e}){var t,s;this.isHelloWidgetRendered||l.selectedCountryCode&&"function"==typeof g.helloSettings.onInitSuccess&&(this.isHelloWidgetRendered=!0,null===(s=(t=g.helloSettings).onInitSuccess)||void 0===s||s.call(t,{countryCode:o,currencyCode:e}))}getHelloLocation(){const o=this.mobileLocationOverride||g.helloSettings.mobileLocation,e=g.helloSettings.desktopLocation,t=this.isMobile;if(!0===t)return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==o?void 0:o.includes("LEFT")),isOnTop:null==o?void 0:o.includes("TOP"),shouldFloat:!!o};{const o=!g.helloSettings.anchorElementSelector&&!!e;return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==e?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop(),isOnTop:null==e?void 0:e.includes("TOP"),shouldFloat:o}}}handleAppearanceSettingsOverrideChange(){var o;(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)&&(this.appearanceSettingsOverride.theme=w(this.appearanceSettingsOverride.theme))}componentDidLoad(){this.isMobile=window.innerWidth<=768}render(){var o,s;if(null===(o=g.helloSettings.excludedUrlPatterns)||void 0===o?void 0:o.some((o=>o&&new RegExp(o).test(window.location.href))))return x("Hello is excluded on this url","warn"),null;const{selectedCountryCode:i,targetCurrency:n}=l,{isOnLeft:r,isOnTop:h,shouldFloat:a}=this.getHelloLocation(),d=f(g.appearance,this.appearanceSettingsOverride||null),{theme:c}=d,m=null===(s=this.allRestrictedItems)||void 0===s?void 0:s.filter((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))));this.peekMessage=this.getHelloPeekMessage(g.organizationName);const p=this.shouldRenderHello()&&!!i;return p&&!this.isHelloWidgetRendered&&this.handleHelloWidgetInitializedState({countryCode:i,currencyCode:n}),e(t,{class:"zonos--hello zonos--elements","data-theme":c},p&&e("div",{class:z(["zonos--hello-wrapper",a&&"zonos--hello-widget-float"])},e("button",{class:z(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",a&&"zonos--hello-widget-float"]),onClick:()=>{this.changeShowDialog(!this.showDialog)},onMouseEnter:()=>this.enableShowPeekMessage(),onMouseLeave:()=>this.showPeekMessage=!1,ref:o=>o&&(this.helloRef=o),type:"button"},e("zonos-text",{class:"zonos--hello-message"},this.peekMessage),i&&e("div",{class:"zonos--hello-country-flag-wrapper"},e("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:i}))),e("div",{class:z(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",a&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},e("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:d,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:m,setIsOpen:this.changeShowDialog}))))}get helloElement(){return s(this)}static get watchers(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}}};L.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}@media screen and (min-width: 769px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px;width:auto;height:auto;z-index:1001}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";export{L as zonos_hello}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,z as o}from"./p-058f6124.js";import{b as a,G as t,d as s,H as d}from"./p-
|
|
1
|
+
import{c as e,z as o}from"./p-058f6124.js";import{b as a,G as t,d as s,H as d}from"./p-3fae811a.js";import{s as n}from"./p-99e1734a.js";import{h as r,s as i,l}from"./p-41dd1cb8.js";import{b as c}from"./p-0a377722.js";const{state:p}=e((()=>({amountTotalDue:null,isFetchingPayorInfo:!0,landedCostShortId:null,partyBillingId:null,payorAddress:null}))),u=async({landedCostId:e,retries:a=5})=>{var t,d,n;p.isFetchingPayorInfo=!0;const l=await r("/api/zonos-elements/invoice/get-payor-info-by-lc-id",{body:{landedCostId:e},method:"POST"});if(l.errors.length)return a>0?(await new Promise((e=>setTimeout(e,1e3))),u({landedCostId:e,retries:a-1})):null;p.landedCostShortId=(null===(t=l.json)||void 0===t?void 0:t.landedCostShortId)||null,p.isFetchingPayorInfo=!1,p.payorAddress=(null===(d=l.json)||void 0===d?void 0:d.payor)||null;const c=null===(n=s.checkoutSession)||void 0===n?void 0:n.subtotals;p.amountTotalDue=(null==c?void 0:c.items)||0,0===p.amountTotalDue&&i({endpoint:"INVOICE_NO_TOTAL_DUE",errors:[],metadata:{landedCostId:e,organizationId:o.organizationId}})},I=async()=>{var e,o,d,u;if(!(null===(e=a.stripeBillingAddressEventData)||void 0===e?void 0:e.complete))return{partiesCreated:!1};const I=null===(d=null===(o=s.checkoutSession)||void 0===o?void 0:o.landedCost)||void 0===d?void 0:d.rootId;if(!I)return i({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId}}),{partiesCreated:!1};if(!n.checkoutSessionId)return i({endpoint:"INVOICE_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:I}}),{partiesCreated:!1};const m=t({address:a.stripeBillingAddressEventData.value.address,firstName:a.stripeBillingAddressEventData.value.firstName,lastName:a.stripeBillingAddressEventData.value.lastName,name:a.stripeBillingAddressEventData.value.name,phone:a.stripeBillingAddressEventData.value.phone}),C="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:O,json:v}=await r("/api/zonos-elements/create-billing-party",{body:{billingAddress:m,checkoutSessionId:n.checkoutSessionId,companyName:a.companyName,email:(null===(u=a.stripeLinkEventData)||void 0===u?void 0:u.value.email)||"",isTest:C,rootId:I},method:"POST"});return O.length||!v?(l("Error occurs when creating billing party",JSON.stringify(O,null,2)),i({endpoint:"INVOICE_BILLING_PARTY_CREATE_FAILED",errors:["[INVOICE] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,errors:O,json:v}}),{partiesCreated:!1}):(p.partyBillingId=v.billToPartyId,{partiesCreated:!0})},m=async e=>{const o=e.landedCost;return!!o&&(s.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},o),landedCostId:o.id})],d({applySubtotalsOnly:!0,landedCostId:o.id,selectedShippingOption:o.shipmentRating}))};export{u as a,I as b,p as c,m as i}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
System.register(["./p-fbd44c55.system.js","./p-e2adf04b.system.js"],(function(r){"use strict";var n,v,u;return{setters:[function(r){n=r.d},function(r){v=r.o;u=r.d}],execute:function(){var t=function(){var r,v;var u=n.displayBaseCurrency;var t=u&&((r=n.exchangeRate)===null||r===void 0?void 0:r.sourceCurrencyCode)?(v=n.exchangeRate)===null||v===void 0?void 0:v.sourceCurrencyCode:n.currency;return t};var a=r("r",(function(r){var a=r.amount,e=r.isForeign;var i,o;var c=((i=n.exchangeRate)===null||i===void 0?void 0:i.rate)||1;var s=e?a:v(a);var d=n.currency;var f=(o=n.items[0])===null||o===void 0?void 0:o.currencyCode;if(f===d){return u({amount:s,currency:d})}var l=n.displayBaseCurrency;var m=t();if(e){var y=l?s/c:s;return u({amount:y,currency:m})}var b=l?s:s*c;return u({amount:b,currency:m})}))}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,z as t}from"./p-058f6124.js";import{s as o,l as n,e as r,t as s,f as i,b as a}from"./p-13041752.js";import{l as d,b as l}from"./p-0a377722.js";import{h as c,l as u,f as m,g as v,a as p,s as h,j as y}from"./p-41dd1cb8.js";import{i as f}from"./p-67897a0d.js";import{g as w}from"./p-f830f800.js";const g=async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await c(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}},{reset:b,state:S}=e((()=>({amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:!1,isEnabled:!1,orderIdCreated:null,remainingBalance:null,useFullBalance:!0}))),C=()=>{b()},O=e=>{d("Store credit balance from session","info",e),S.availableBalance=e},A=async()=>{var e,t;const{errors:o,json:n}=await g();if(o.length||!n)return void u("Failed to refresh store credit balance");const r=null!==(t=null===(e=n.checkoutSession.customerProfile)||void 0===e?void 0:e.storeCreditBalance)&&void 0!==t?t:null;O(r)},I=async()=>{var e;const t=o.checkoutSessionId;if(!t){const e="No checkout session found";return u(e),S.error=e,{error:e,success:!1}}d("Applying store credit","info",{checkoutSessionId:t}),S.isApplying=!0,S.error=null;try{const{errors:o,json:n}=await c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:t},method:"POST"});if(o.length>0||!n){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}return S.appliedAmount=n.amountApplied,S.remainingBalance=n.remainingBalance,S.isApplying=!1,d("Store credit applied","info",{amountApplied:n.amountApplied,remainingBalance:n.remainingBalance}),{error:null,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}},k=e=>{S.isEnabled=e,S.error=null,e||(S.amountToApply=null)},N=e=>{if(null===e)return S.amountToApply=null,void(S.error=null);e<=0?S.error="Amount must be greater than zero":null!==S.availableBalance&&e>S.availableBalance?S.error="Amount exceeds available balance":e>we.total+(we.storeCredit||0)?S.error="Amount exceeds order total":(S.error=null,S.amountToApply=e)},T=e=>{if(S.useFullBalance=e,S.error=null,e&&null!==S.availableBalance){const e=Math.min(S.availableBalance,we.total+(we.storeCredit||0));S.amountToApply=e}else e||(S.amountToApply=null)},j=()=>S.isEnabled&&null!==S.availableBalance?S.useFullBalance?Math.min(S.availableBalance,we.total+(we.storeCredit||0)):S.amountToApply||0:0,E=()=>null!==S.amountToApply&&S.amountToApply>0&&we.storeCredit>0&&we.total<=0,P=async()=>{var e,t,n;const r=o.checkoutSessionId;if(!r){const e="No checkout session found";return u(e),S.error=e,{error:e,orderId:null,success:!1}}d("Creating store credit order","info",{checkoutSessionId:r});try{const{errors:o,json:s}=await c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:r},method:"POST"});if(o.length>0||!s){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}const i=(null===(n=null===(t=s.checkoutSessionStoreCreditOrderCreate)||void 0===t?void 0:t.order)||void 0===n?void 0:n.id)||null;return S.orderIdCreated=i,d("Store credit order created","info",{orderId:i}),{error:null,orderId:i,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}},D=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const r=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=r[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||r.slice(1).join(" ").trim()||""}},L=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:v}=e.value.address,p=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(r=t.line2)||void 0===r?void 0:r[u||""])||u||"",name:(null===(s=t.name)||void 0===s?void 0:s[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[v])||v}},x=e=>{var t;const s="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),i=q.stripeLinkEventData,a=q.stripeAddressEventData,d=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(!a||!d)throw new Error("Missing stripe address data");const l=L({currentAddress:a,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=L({currentAddress:d,translatedAddress:q.translatedAddress.address}),{firstName:v,lastName:p}=D({name:m.name}),h=r()||"US";return{billingAddress:{addressLine1:m.line1,addressLine2:m.line2||"",city:m.city,country:m.country,postalCode:m.postal_code,state:m.state},billingContact:{firstName:v,lastName:p,phone:m.phone},cartCurrencyCode:null===(t=we.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:h||n.selectedCountryCode||void 0,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==i?void 0:i.value.email,firstName:c,lastName:u,phone:l.phone},isTest:!!s,landedCostAdjustments:we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:l.line1,addressLine2:l.line2,city:l.city,country:l.country,postalCode:l.postal_code,state:l.state}}},R=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=q.stripeLinkEventData,n=q.stripeAddressEventData,r=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(d({stripeAddressData:n,stripeBillingAddressData:r},"info"),!n||!r)throw new Error("Missing stripe address data");const s=L({currentAddress:n,translatedAddress:q.translatedAddress.address}),{firstName:i,lastName:a}=D({name:s.name}),l=L({currentAddress:r,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=we.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),v=we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"},...m]:m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:s.phone},isTest:e,items:we.items,landedCostAdjustments:v,shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};const z=async e=>{const o=window.Zonos.cartId;if(!o)return await(async e=>{var o;const n=t.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,r,s;const i=R(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:m.vercel},{promoCode:we.promoCode});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(r=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===r?void 0:r.message)||"Unknown error"}`);const{errors:d,json:l}=await c("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!l||d.length)throw new Error(`Invalid landed cost object: ${(null===(s=d.find(Boolean))||void 0===s?void 0:s.message)||"Unknown error"}`);return a})(n);return e}const{errors:r,json:s}=await c("/api/zonos-elements/calculate-landed-cost",{body:R(),method:"POST",signal:null==e?void 0:e.signal});if(r.length||!s){if("The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(r.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!s)throw new Error("Failed to calculate landed cost");return s}return s})(e);const n=await(async({abortController:e,cartId:t})=>{var o,n,r,s,i;const{errors:a,json:d}=await c("/api/zonos-elements/cart-calculate-landed-cost",{body:x(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(r=a[0])||void 0===r?void 0:r.message.includes("signal is aborted"))||(null===(s=a[0])||void 0===s?void 0:s.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:e,cartId:o}),{cartWorkflow:r}=n,s=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},s),{itemCreateWorkflow:r.items})},U=async({checkoutSessionId:e,eventName:o,metadata:r})=>{var s,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:e,eventCreated:a,eventName:o});const u=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(s=window.Zonos)||void 0===s?void 0:s.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((v()||p()||u)&&!window.Zonos.zonosConversionTest)return;const m=n.selectedCountryCode,y=t.organizationId;if(!e)return void h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});y||h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});const f={checkoutSessionId:e,countryCode:m,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},r),{trackEventLogs:d}),organizationId:y};await c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})},_=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},B=e=>e.sort(((e,t)=>e.amount-t.amount)),F=async()=>{var e;const{errors:t,json:o}=await g();return t.length||!o?(u("Failed to retrieve checkout session info before confirming payment ",t),h({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:l}}),{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=o.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(u("Landed cost is not found in the checkout session before confirming payment."),h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}}),{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},J=({theme:e})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:t.appearance.fontSizeInputValue?`${t.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:t.appearance.fontSizeInputLabel?`${t.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===e?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},M=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:W,reset:$,state:q}=e((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),Y=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},H=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},K=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return y(e)},G=async e=>{var o,r;const s=q.clientSecret;if(!q.stripe)return void d("Skip. Stripe is not initialized");const i=(({clientSecret:e,overrideBorderRadius:o,overridePrimaryColor:r,overrideSecondaryColor:s,overrideTheme:i,paypalEnabled:a})=>{const d=r||t.appearance.colorPrimary,l=s||t.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===t.appearance.theme:d&&f(d))?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},J({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},M({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:e||void 0,customerSessionClientSecret:q.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:s,overrideBorderRadius:null==e?void 0:e.overrideBorderRadius,overridePrimaryColor:null==e?void 0:e.overridePrimaryColor,overrideSecondaryColor:null==e?void 0:e.overrideSecondaryColor,overrideTheme:null==e?void 0:e.overrideTheme,paypalEnabled:null==e?void 0:e.paypalEnabled}),a=JSON.stringify(i)===JSON.stringify(q.stripeElementsOptions);if(!q.stripeElements||!q.stripeElementsForBillingAddress)return q.stripeElementsForBillingAddress=null===(o=q.stripe)||void 0===o?void 0:o.elements(i),d("Stripe elements for billing address initialized"),q.stripeElements=null===(r=q.stripe)||void 0===r?void 0:r.elements(i),q.stripeElementsOptions=i,void d("Stripe elements initialized");a||(q.stripeElements.update(i),q.stripeElementsForBillingAddress.update(i),q.stripeElementsOptions=i,q.stripeElements.fetchUpdates()),d("Stripe elements updated")},V=()=>{sessionStorage.removeItem("zonos--client-secret"),$(),q.stripe=window.Zonos.stripe},Z=({address:e,firstName:t,lastName:n,name:r,phone:s})=>{const{firstName:i,lastName:a}=D({firstName:t,lastName:n,name:r});return i&&a||h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:r}}),s||h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:s}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:s||"",postal_code:e.postal_code,state:e.state}},Q=async()=>{var e,t,n,r;if(!(null===(e=q.stripeAddressEventData)||void 0===e?void 0:e.complete)||!q.stripeShippingSameAsBilling&&!(null===(t=q.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!q.stripeBillingAddressEventData)return{partiesCreated:!1};if(!we.landedCostData)return{partiesCreated:!1};const s=null===(n=we.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!s)return h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,r,s,i,a;const d=null===(e=we.partiesData.find((e=>"DESTINATION"===e.type)))||void 0===e?void 0:e.id,l=null===(t=we.partiesData.find((e=>"PAYOR"===e.type)))||void 0===t?void 0:t.id;if(!d||!l)return!1;if(q.partyShippingId!==d||q.partyBillingId!==l)return!0;const c=JSON.stringify(null===(o=q.stripeLinkUsedWhenFetchingLC)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeLinkEventData)||void 0===n?void 0:n.value),u=JSON.stringify(null===(r=q.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=q.stripeAddressEventData)||void 0===s?void 0:s.value),m=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(i=q.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===i?void 0:i.value)!==JSON.stringify(null===(a=q.stripeBillingAddressEventData)||void 0===a?void 0:a.value);return c||u||m||q.taxIdUsedWhenAsyncAddressUpdate!==q.taxId||q.companyNameUsedWhenAsyncAddressUpdate!==q.companyName})();if(!i)return{partiesCreated:!1};const a=Z({address:q.stripeAddressEventData.value.address,firstName:q.stripeAddressEventData.value.firstName,lastName:q.stripeAddressEventData.value.lastName,name:q.stripeAddressEventData.value.name,phone:q.stripeAddressEventData.value.phone}),d=q.stripeShippingSameAsBilling?a:Z({address:q.stripeBillingAddressEventData.value.address,firstName:q.stripeBillingAddressEventData.value.firstName,lastName:q.stripeBillingAddressEventData.value.lastName,name:q.stripeBillingAddressEventData.value.name,phone:q.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:v,json:p}=await c("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:q.companyName,email:(null===(r=q.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:s,shortAddressCode:q.shortAddressCode,taxId:q.taxId},method:"POST"});return v.length||!p?(u("Error occurs when creating parties",JSON.stringify(v,null,2)),h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:v,json:p}}),{partiesCreated:!1}):(q.companyNameUsedWhenAsyncAddressUpdate=q.companyName,q.stripeAddressUsedWhenAsyncAddressUpdate=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenAsyncAddressUpdate=q.stripeBillingAddressEventData,q.taxIdUsedWhenAsyncAddressUpdate=q.taxId,q.partyBillingId=p.billToPartyId,q.partyShippingId=p.shipToPartyId,we.partiesData=we.partiesData.map((e=>"DESTINATION"===e.type&&e.id!==p.shipToPartyId?Object.assign(Object.assign({},e),{id:p.shipToPartyId}):"PAYOR"===e.type&&e.id!==p.billToPartyId?Object.assign(Object.assign({},e),{id:p.billToPartyId}):e)),{partiesCreated:!0})},X=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),ee=async e=>{var n,r,s,i;const a=(null==e?void 0:e.retries)||0,l=!!(null==e?void 0:e.applyingPromocode),c=(()=>{var e;const t=we.landedCostData&&(null===(e=we.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==we.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=q.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeLinkEventData)||void 0===t?void 0:t.value),n=q.stripeAddressEventData&&JSON.stringify(X(q.stripeAddressEventData.value))!==JSON.stringify(q.stripeAddressUsedWhenFetchingLC),r=!q.stripeShippingSameAsBilling&&q.stripeBillingAddressEventData&&JSON.stringify(X(q.stripeBillingAddressEventData.value))!==JSON.stringify(q.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return d("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!we.landedCostData&&!q.isFetchingLandedCost||o||t})();if(!(()=>{var e,o,n,r;const s=!!(null===(e=q.stripeLinkEventData)||void 0===e?void 0:e.complete),i=!!(null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.complete),a=q.stripeShippingSameAsBilling?i:!!(null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(e=>{var o,n;const r=null===(o=t.genericSettings)||void 0===o?void 0:o.countryFields,s=null===(n=t.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===we.addressFormRenderType&&(s&&e in s?s[e]:null)||(r&&e in r?r[e]:null)})((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US");return!!(i&&a&&s)||(d&&q.stripeAddressEventData?s&&q.stripeAddressEventData.value.firstName&&q.stripeAddressEventData.value.lastName&&q.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&q.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&q.stripeAddressEventData.value.address.postal_code.length>=3)&&q.stripeAddressEventData.value.phone&&q.stripeAddressEventData.value.phone.length>0:i&&a&&s)})())return{isRequestNotReady:!0};if(c&&(null===(n=q.fetchingLandedCostAbortController)||void 0===n||n.abort(),q.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};a?(q.isFetchingLandedCost=!1,setTimeout((()=>{q.isFetchingLandedCost=!0}),300)):q.isFetchingLandedCost=!0,q.stripeAddressEventData&&(q.stripeAddressUsedWhenFetchingLC={countryCode:q.stripeAddressEventData.value.address.country,postalCode:q.stripeAddressEventData.value.address.postal_code,state:q.stripeAddressEventData.value.address.state}),q.stripeBillingAddressEventData&&(q.stripeBillingAddressUsedWhenFetchingLC={countryCode:q.stripeBillingAddressEventData.value.address.country,postalCode:q.stripeBillingAddressEventData.value.address.postal_code,state:q.stripeBillingAddressEventData.value.address.state}),q.stripeLinkEventData&&(q.stripeLinkUsedWhenFetchingLC=Object.assign({},q.stripeLinkEventData));try{xe(),await(async()=>{var e;const t=new AbortController;q.fetchingLandedCostAbortController=t,xe();const{checkoutSessionWorkflow:n,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await z(t);we.customQuotingError=(null===(e=null==r?void 0:r.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,we.shippingData=B((null==d?void 0:d.filter(Boolean))||[]),Ce(s),q.fetchingLandedCostAbortController=null,we.partiesData=(null==a?void 0:a.filter(Boolean))||[],we.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&U({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=we.promoCodeApplied&&!we.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));we.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",we.promoCode)})();const e=null===(r=we.shippingData)||void 0===r?void 0:r.find(Boolean),t=null===(s=we.landedCostData)||void 0===s?void 0:s.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ke({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(t){if(we.landedCostData=[],we.shippingData=[],t instanceof Error&&t.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(t.message)){if(a<1)return await ee(Object.assign(Object.assign({},e),{retries:(a||0)+1})),{isRequestNotReady:!1};const o=null===(i=q.stripeAddressEventData)||void 0===i?void 0:i.value;h({endpoint:`Failed to fetch landed cost (${a} retries)`,errors:[t.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}u(t)}return q.isFetchingLandedCost=!1,{isRequestNotReady:!1}},te=async()=>{var e,t;await ee({applyingPromocode:!0}),"payment"===we.step&&ze(),await Q();const o=null===(e=we.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=we.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await Pe({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},oe=()=>{we.promoCode="",sessionStorage.removeItem("zonos--promo-code"),we.promoCodeError=!1,we.promoCodeApplied=!1},ne=async()=>{"payment"===we.step&&ze(),oe(),await te()},re=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,r=window.Zonos.isInvoice;switch(e){case"succeeded":t=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")],(n||r)&&(t=[s("Thank you for submitting your payment. We appreciate your prompt attention."),"",s("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]),o=!1;break;case"requires_capture":case"processing":t=[s("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[s("Payment failed. Please try another payment method.")],n&&(t=[s("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[s("Something went wrong.")]}return{isError:o,messages:t}},se=async()=>{var e,o;const{onInventoryCheck:n}=t.checkoutSettings,r=!!(null===(o=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&r){const{errors:e,json:t}=await c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(u("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(q.shouldInventoryRefund=!0,null):null:s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")}if("function"!=typeof n)return null;try{return await n({items:we.items},{translate:s,zonosApiRoute:m.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw h({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:we.items}}),e}},ie=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},ae=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=re(t);return{error:e,messages:o}}const o=e||q.clientSecret;if(!q.stripe||!o)return u("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[s("Something went wrong.")]};const{paymentIntent:n}=await q.stripe.retrievePaymentIntent(o),r=null==n?void 0:n.status,{isError:i,messages:a}=re(r);return{amount:null==n?void 0:n.amount,currency:null==n?void 0:n.currency,error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:r}},de=async e=>{var t,n;const r=!!(null===(t=q.stripePaymentEventData)||void 0===t?void 0:t.complete),i=q.stripeElements,a=q.stripe,l=q.clientSecret;if(q.customErrorMessage=null,!(null===(n=we.selectedLandedCost)||void 0===n?void 0:n.landedCost.id)&&!(null==e?void 0:e.noLandedCostCheck))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const c=await F();if(!c.valid)throw q.customErrorMessage=c.errorMessage,new Error(c.errorMessage);const u=o.checkoutSessionId;if(a&&i&&r&&l&&u){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",l),e.searchParams.set("zonosCheckoutSessionId",u),U({checkoutSessionId:u,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(d("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."));if(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(s("Payment failed. Please try another payment method."))}},le=()=>{var e;const t=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),r=o.enabledVariantTestKeys||[];return{adjustmentsAmount:we.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:we.customerAuthenticationToken||void 0,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:q.skipPaymentIntent,varianceTestInput:r}},ce=async()=>{var e;if(!o.checkoutSessionId)return h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}}),void Ie({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});const{errors:t,json:n}=await c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),r=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!r)return u("Error occurs when getting payment intent",JSON.stringify(t,null,2)),h({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:r}}),void Ie({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});Te(n.checkoutSessionPaymentIntentCreate)},ue=async()=>{var e,t;if(!n.targetCurrency)return u("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;q.isFetchingSession=!0;const o=le();d("Checkout session body","info",o);const{errors:r,json:s}=await c("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(q.isFetchingSession=!1,r.length||!s){const t=null===(e=r.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return u("Error occurred when creating checkout session",JSON.stringify(r,null,2)),!1}const i=s.checkoutSessionCreate;return Te(i),ke({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),d("Exchange rate updated for cart items (checkout session create)","info",we.exchangeRate),d("done-init-checkout-session"),!0},me=async()=>{const e=o.checkoutSessionId;if(!e)return u("Failed to update checkout session base currency"),!1;if("LOCAL"===t.checkoutSettings.allowedSettlementCurrencies)return d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:q.checkoutSettlementCurrency},method:"POST"}),r=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&r===q.checkoutSettlementCurrency?(d(`Updated checkout session to settlement currency "${r}".`),!0):(u("Failed to update checkout session base currency"),!1)},ve=async({adjustmentsAmount:e,cartId:t,currency:r,id:s,itemsAmount:i,landedCostId:a,presentmentCountryCode:d,storeCreditApplication:l})=>{const m=o.enabledVariantTestKeys||[],{errors:v,json:p}=await c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,customerAuthenticationToken:we.customerAuthenticationToken||void 0,id:s,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:q.partyShippingId,skipPaymentIntent:q.skipPaymentIntent,storeCreditApplication:l,varianceTestInput:m},method:"POST"});return v.length||!p?(u("Error occurs when updating checkout session",JSON.stringify(v,null,2)),{errors:v,json:p}):{errors:[],json:p}},pe=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:r,line2:s,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&r&&(o.line1={[e.line1]:r}),e.line2&&s&&(o.line2={[e.line2]:s}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},he=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,r,s;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:r})=>{const s=!!(null==o?void 0:o.complete);if(!s||!(r?s:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=D({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=D({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),v=u&&m?`${u} ${m}`:"",p=i.address,h=null==a?void 0:a.address;return{address:_({address:Object.assign(Object.assign({},p),{name:c}),invalidAdddressList:e}),billingAddress:r?void 0:_({address:h?Object.assign(Object.assign({},h),{name:v}):null,invalidAdddressList:t}),destinationCountry:p.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:q.stripeAddressEventData,stripeBillingAddressEventData:q.stripeBillingAddressEventData,stripeShippingSameAsBilling:q.stripeShippingSameAsBilling});if(!i)return void(q.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=q.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeAddressEventData)||void 0===t?void 0:t.value),s=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(o=q.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();if(!a)return;const{errors:d,json:l}=await c("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!l)return u("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(q.translatedAddress={address:{},billingAddress:{}});q.stripeAddressUsedWhenValidatingAddress=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenValidatingAddress=q.stripeBillingAddressEventData;const m=null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.value.address,v=null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;q.translatedAddress={address:m?pe({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:q.stripeShippingSameAsBilling?{}:pe({currentAddress:Object.assign(Object.assign({},v),{name:null===(s=q.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:l.billingAddress||null})}};W("clientSecret",(e=>{e&&q.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:ye,reset:fe,state:we}=e((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:p(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),ge=e=>{switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");default:return s("business days")}},be=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:ge(o.type)}:null},Se=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),Ce=e=>{d("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=we.items.find((t=>Se({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return we.restrictedItems=t,we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>Se({item1:t,item2:e})))}))),{cartItems:we.items,restrictedItems:t}};let Oe=null;const Ae=()=>{o.checkoutSessionId=null,Oe&&(clearTimeout(Oe),Oe=null),C(),fe()},Ie=({messages:e,title:t})=>{Ae(),V(),we.step="error",we.error={messages:e,title:t}},ke=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{var n;we.exchangeRate=o.exchangeRate,we.adjustmentTotal=o.adjustments,we.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,we.storeCredit=null!==(n=o.storeCredit)&&void 0!==n?n:0,we.subtotal=o.items,we.total=o.total,we.currency=o.presentmentCurrencyCode,we.dutiesTaxesFeesEstimate=e||null},Ne=()=>!!we.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),Te=e=>{var t,n,r,s,c,u,m;q.clientSecret=e.clientSecret,q.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,q.customerProfile=e.customerProfile,we.checkoutSession=e,O(null!==(n=null===(t=e.customerProfile)||void 0===t?void 0:t.storeCreditBalance)&&void 0!==n?n:null),e.id||h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const v=i(e.varianceTestResults||[]);a(v);const p=(null===(c=null===(s=null===(r=we.checkoutSession)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===c?void 0:c.value)||(null===(m=null===(u=window.Zonos.cartData)||void 0===u?void 0:u.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===m?void 0:m.value)||null;p&&(d(`Found externalConfirmationPageURL: ${p}`),we.externalConfirmationPageURL=p)},je=async({adjustmentsAmount:e,cartId:t,currency:r,dutiesTaxesFeesEstimate:i,itemsAmount:a,landedCostId:l,shouldInitSessionOnFailure:c})=>{var m;if(l&&we.selectedLandedCost&&(ke({dutiesTaxesFeesEstimate:i,method:we.landedCostMethod,subtotals:we.selectedLandedCost.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate)),!o.checkoutSessionId)return d("Could not update cart total without checkout session id","info"),!1;const{errors:v,json:p}=await ve({adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,id:o.checkoutSessionId,itemsAmount:a,landedCostId:l,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(v.length>0||!p){if(u("Error occurs when updating checkout session."),c){d("Initiating checkout session on failure","info");const e=await ue();return d(`stripeStoreInitCheckoutSession: ${e}`),!!e||(Ie({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")}),!1)}return!1}return l||(ke({method:(null===(m=p.checkoutSessionUpdate.landedCost)||void 0===m?void 0:m.method)||"DDP",subtotals:p.checkoutSessionUpdate.subtotals}),d("Exchange rate updated for cart items (checkout session update)","info",we.exchangeRate)),Te(p.checkoutSessionUpdate),!0},Ee=e=>{var o,n,r;return"DAP"===e.method&&(null===(n=null===(o=t.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US"))||"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method},Pe=async({applySubtotalsOnly:e,landedCostId:n,selectedShippingOption:r})=>{var s,i,a,l,c,u,m,v,p,h,y;d("Updating selected shipping option","info",{landedCostId:n,selectedShippingOption:r}),we.selectedShippingOption=r;const f=be(we.selectedShippingOption);if(f){const{maxTransit:e,minTransit:t,unit:o}=f;we.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else we.selectedShippingOptionTransitTime="";const w=null===(s=we.landedCostData)||void 0===s?void 0:s.find((e=>e.landedCostId===n));if(we.selectedLandedCost=w||null,!w)return!1;const g=((null===(i=w.landedCost.amountSubtotals)||void 0===i?void 0:i.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&d(`DAP quote, using estimate: ${g}`,"info"),we.landedCostMethod=Ee(w.landedCost),we.shipping=w.subtotals.shipping;const b="ZONOS"===(null===(a=null==w?void 0:w.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),S=!!(null===(c=null===(l=null==w?void 0:w.landedCost)||void 0===l?void 0:l.deMinimis)||void 0===c?void 0:c.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));we.isSelectedShippingAboveDeminimis=S,we.isSelectedShippingGuarantee=b;let C=!1;e?(ke({dutiesTaxesFeesEstimate:g,method:we.landedCostMethod,subtotals:w.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate),C=!0):C=await je({adjustmentsAmount:we.adjustmentTotal,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(u=w.landedCost)||void 0===u?void 0:u.id,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});const O=null===(m=we.items.find(Boolean))||void 0===m?void 0:m.currencyCode,A=(null===(v=q.stripeAddressEventData)||void 0===v?void 0:v.value.address.country)||"US";return q.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===t.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(p=we.checkoutSession)||void 0===p?void 0:p.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(h=t.genericSettings)||void 0===h?void 0:h.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),C},De=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;d(`==START CHECKOUT TIMEOUT - ${n}==`),we.checkoutTimeoutInterval=setTimeout((()=>{we.checkoutSessionTimeoutShow=!0}),n)},Le=()=>{we.checkoutTimeoutInterval&&(clearTimeout(we.checkoutTimeoutInterval),we.checkoutTimeoutInterval=null)},xe=()=>{we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),we.restrictedItems=[]},Re=async({adjustments:e,cartItems:t,landedCostId:n,shouldInitSessionOnFailure:r=!0})=>{var s;we.adjustments=e,we.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const i=null===(s=t.find(Boolean))||void 0===s?void 0:s.currencyCode,a=t.reduce(((e,t)=>e+t.amount*t.quantity),0),d=e.reduce(((e,t)=>e+t.amount),0);i&&a&&(we.currency=i,q.isFetchingSession=!0,await je({adjustmentsAmount:d,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,currency:i,dutiesTaxesFeesEstimate:0,itemsAmount:a,landedCostId:n,shipToPartyId:q.partyShippingId,shouldInitSessionOnFailure:r,varianceTestInput:o.enabledVariantTestKeys||[]}),q.isFetchingSession=!1)},ze=()=>{"shipping"===we.step?(we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"payment"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"finish"===we.step&&(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1})}))},Ue=()=>{"customer-info"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!0})})):"shipping"===we.step?(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!0})})):"payment"===we.step&&(we.step="finish")},_e=()=>{we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})}),we.selectedShippingOption=null,we.isSelectedShippingAboveDeminimis=!1,we.isSelectedShippingGuarantee=!1,we.selectedShippingOptionTransitTime="",we.dutiesTaxesFees=0,we.dutiesTaxesFeesEstimate=0,we.shipping=0,we.total=we.subtotal},Be=()=>{Oe&&clearTimeout(Oe),Oe=setTimeout((()=>{Oe=null,(async()=>{var e,t;if(!o.checkoutSessionId)return void d("Could not update store credit without checkout session id","info");const r=we.selectedLandedCost,s=we.currency||(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",i=we.adjustments.reduce(((e,t)=>e+t.amount),0),a=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),{errors:l,json:c}=await ve({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:s,id:o.checkoutSessionId,itemsAmount:a,landedCostId:null==r?void 0:r.landedCostId,presentmentCountryCode:n.selectedCountryCode,storeCreditApplication:S.isEnabled&&null!==S.amountToApply?S.useFullBalance?{mode:"FULL"}:{amount:S.amountToApply,mode:"PARTIAL"}:{mode:"NONE"}});l.length>0||!c?u("Error updating checkout session with store credit"):(ke({method:(null===(t=c.checkoutSessionUpdate.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals}),Te(c.checkoutSessionUpdate))})()}),300)};export{de as A,ie as B,V as C,ye as D,W as E,j as F,Z as G,Pe as H,Ne as I,te as J,ne as K,oe as L,re as M,S as N,C as O,he as P,D as Q,Q as R,be as S,Ee as T,B as U,k as V,T as W,Be as X,N as Y,A as Z,H as a,q as b,ae as c,we as d,Re as e,Ae as f,_e as g,Le as h,G as i,ue as j,ce as k,De as l,le as m,Ie as n,Y as o,Te as p,ee as q,Ue as r,K as s,U as t,me as u,se as v,I as w,E as x,F as y,P as z}
|
|
1
|
+
import{c as e,z as t}from"./p-058f6124.js";import{s as o,l as n,e as r,t as s,f as i,b as a}from"./p-99e1734a.js";import{l as d,b as l}from"./p-0a377722.js";import{h as c,l as u,f as m,g as v,a as p,s as h,j as y}from"./p-41dd1cb8.js";import{i as f}from"./p-67897a0d.js";import{g as w}from"./p-f830f800.js";const g=async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await c(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}},{reset:b,state:S}=e((()=>({amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:!1,isEnabled:!1,orderIdCreated:null,remainingBalance:null,useFullBalance:!0}))),C=()=>{b()},O=e=>{d("Store credit balance from session","info",e),S.availableBalance=e},A=async()=>{var e,t;const{errors:o,json:n}=await g();if(o.length||!n)return void u("Failed to refresh store credit balance");const r=null!==(t=null===(e=n.checkoutSession.customerProfile)||void 0===e?void 0:e.storeCreditBalance)&&void 0!==t?t:null;O(r)},I=async()=>{var e;const t=o.checkoutSessionId;if(!t){const e="No checkout session found";return u(e),S.error=e,{error:e,success:!1}}d("Applying store credit","info",{checkoutSessionId:t}),S.isApplying=!0,S.error=null;try{const{errors:o,json:n}=await c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:t},method:"POST"});if(o.length>0||!n){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}return S.appliedAmount=n.amountApplied,S.remainingBalance=n.remainingBalance,S.isApplying=!1,d("Store credit applied","info",{amountApplied:n.amountApplied,remainingBalance:n.remainingBalance}),{error:null,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to apply store credit";return u(t),S.error=t,S.isApplying=!1,{error:t,success:!1}}},k=e=>{S.isEnabled=e,S.error=null,e||(S.amountToApply=null)},N=e=>{if(null===e)return S.amountToApply=null,void(S.error=null);e<=0?S.error="Amount must be greater than zero":null!==S.availableBalance&&e>S.availableBalance?S.error="Amount exceeds available balance":e>we.total+(we.storeCredit||0)?S.error="Amount exceeds order total":(S.error=null,S.amountToApply=e)},T=e=>{if(S.useFullBalance=e,S.error=null,e&&null!==S.availableBalance){const e=Math.min(S.availableBalance,we.total+(we.storeCredit||0));S.amountToApply=e}else e||(S.amountToApply=null)},j=()=>S.isEnabled&&null!==S.availableBalance?S.useFullBalance?Math.min(S.availableBalance,we.total+(we.storeCredit||0)):S.amountToApply||0:0,E=()=>null!==S.amountToApply&&S.amountToApply>0&&we.storeCredit>0&&we.total<=0,P=async()=>{var e,t,n;const r=o.checkoutSessionId;if(!r){const e="No checkout session found";return u(e),S.error=e,{error:e,orderId:null,success:!1}}d("Creating store credit order","info",{checkoutSessionId:r});try{const{errors:o,json:s}=await c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:r},method:"POST"});if(o.length>0||!s){const t=(null===(e=o[0])||void 0===e?void 0:e.message)||"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}const i=(null===(n=null===(t=s.checkoutSessionStoreCreditOrderCreate)||void 0===t?void 0:t.order)||void 0===n?void 0:n.id)||null;return S.orderIdCreated=i,d("Store credit order created","info",{orderId:i}),{error:null,orderId:i,success:!0}}catch(e){const t=e instanceof Error?e.message:"Failed to create store credit order";return u(t),S.error=t,{error:t,orderId:null,success:!1}}},D=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const r=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=r[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||r.slice(1).join(" ").trim()||""}},L=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:v}=e.value.address,p=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(r=t.line2)||void 0===r?void 0:r[u||""])||u||"",name:(null===(s=t.name)||void 0===s?void 0:s[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[v])||v}},x=e=>{var t;const s="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),i=q.stripeLinkEventData,a=q.stripeAddressEventData,d=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(!a||!d)throw new Error("Missing stripe address data");const l=L({currentAddress:a,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=L({currentAddress:d,translatedAddress:q.translatedAddress.address}),{firstName:v,lastName:p}=D({name:m.name}),h=r()||"US";return{billingAddress:{addressLine1:m.line1,addressLine2:m.line2||"",city:m.city,country:m.country,postalCode:m.postal_code,state:m.state},billingContact:{firstName:v,lastName:p,phone:m.phone},cartCurrencyCode:null===(t=we.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:h||n.selectedCountryCode||void 0,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==i?void 0:i.value.email,firstName:c,lastName:u,phone:l.phone},isTest:!!s,landedCostAdjustments:we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:l.line1,addressLine2:l.line2,city:l.city,country:l.country,postalCode:l.postal_code,state:l.state}}},R=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=q.stripeLinkEventData,n=q.stripeAddressEventData,r=q.stripeShippingSameAsBilling?q.stripeAddressEventData:q.stripeBillingAddressEventData;if(d({stripeAddressData:n,stripeBillingAddressData:r},"info"),!n||!r)throw new Error("Missing stripe address data");const s=L({currentAddress:n,translatedAddress:q.translatedAddress.address}),{firstName:i,lastName:a}=D({name:s.name}),l=L({currentAddress:r,translatedAddress:q.translatedAddress.address}),{firstName:c,lastName:u}=D({name:l.name}),m=we.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),v=we.promoCode?[{amount:0,productId:null,promoCode:we.promoCode,sku:null,type:"PROMO_CODE"},...m]:m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:q.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:s.phone},isTest:e,items:we.items,landedCostAdjustments:v,shipToShortAddressCode:q.shortAddressCode,shipToTaxId:q.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};const z=async e=>{const o=window.Zonos.cartId;if(!o)return await(async e=>{var o;const n=t.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,r,s;const i=R(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:m.vercel},{promoCode:we.promoCode});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(r=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===r?void 0:r.message)||"Unknown error"}`);const{errors:d,json:l}=await c("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!l||d.length)throw new Error(`Invalid landed cost object: ${(null===(s=d.find(Boolean))||void 0===s?void 0:s.message)||"Unknown error"}`);return a})(n);return e}const{errors:r,json:s}=await c("/api/zonos-elements/calculate-landed-cost",{body:R(),method:"POST",signal:null==e?void 0:e.signal});if(r.length||!s){if("The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(r.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!s)throw new Error("Failed to calculate landed cost");return s}return s})(e);const n=await(async({abortController:e,cartId:t})=>{var o,n,r,s,i;const{errors:a,json:d}=await c("/api/zonos-elements/cart-calculate-landed-cost",{body:x(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(r=a[0])||void 0===r?void 0:r.message.includes("signal is aborted"))||(null===(s=a[0])||void 0===s?void 0:s.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:e,cartId:o}),{cartWorkflow:r}=n,s=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},s),{itemCreateWorkflow:r.items})},U=async({checkoutSessionId:e,eventName:o,metadata:r})=>{var s,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:e,eventCreated:a,eventName:o});const u=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(s=window.Zonos)||void 0===s?void 0:s.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((v()||p()||u)&&!window.Zonos.zonosConversionTest)return;const m=n.selectedCountryCode,y=t.organizationId;if(!e)return void h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});y||h({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:l,checkoutSessionId:e,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});const f={checkoutSessionId:e,countryCode:m,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},r),{trackEventLogs:d}),organizationId:y};await c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})},_=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},B=e=>e.sort(((e,t)=>e.amount-t.amount)),F=async()=>{var e;const{errors:t,json:o}=await g();return t.length||!o?(u("Failed to retrieve checkout session info before confirming payment ",t),h({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:l}}),{errorMessage:s("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=o.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(u("Landed cost is not found in the checkout session before confirming payment."),h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}}),{errorMessage:s('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},J=({theme:e})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:t.appearance.fontSizeInputValue?`${t.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:t.appearance.fontSizeInputLabel?`${t.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===e?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},M=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:W,reset:$,state:q}=e((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),Y=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},H=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},K=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return y(e)},G=async e=>{var o,r;const s=q.clientSecret;if(!q.stripe)return void d("Skip. Stripe is not initialized");const i=(({clientSecret:e,overrideBorderRadius:o,overridePrimaryColor:r,overrideSecondaryColor:s,overrideTheme:i,paypalEnabled:a})=>{const d=r||t.appearance.colorPrimary,l=s||t.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===t.appearance.theme:d&&f(d))?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},J({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},M({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:e||void 0,customerSessionClientSecret:q.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:s,overrideBorderRadius:null==e?void 0:e.overrideBorderRadius,overridePrimaryColor:null==e?void 0:e.overridePrimaryColor,overrideSecondaryColor:null==e?void 0:e.overrideSecondaryColor,overrideTheme:null==e?void 0:e.overrideTheme,paypalEnabled:null==e?void 0:e.paypalEnabled}),a=JSON.stringify(i)===JSON.stringify(q.stripeElementsOptions);if(!q.stripeElements||!q.stripeElementsForBillingAddress)return q.stripeElementsForBillingAddress=null===(o=q.stripe)||void 0===o?void 0:o.elements(i),d("Stripe elements for billing address initialized"),q.stripeElements=null===(r=q.stripe)||void 0===r?void 0:r.elements(i),q.stripeElementsOptions=i,void d("Stripe elements initialized");a||(q.stripeElements.update(i),q.stripeElementsForBillingAddress.update(i),q.stripeElementsOptions=i,q.stripeElements.fetchUpdates()),d("Stripe elements updated")},V=()=>{sessionStorage.removeItem("zonos--client-secret"),$(),q.stripe=window.Zonos.stripe},Z=({address:e,firstName:t,lastName:n,name:r,phone:s})=>{const{firstName:i,lastName:a}=D({firstName:t,lastName:n,name:r});return i&&a||h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:r}}),s||h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:s}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:s||"",postal_code:e.postal_code,state:e.state}},Q=async()=>{var e,t,n,r;if(!(null===(e=q.stripeAddressEventData)||void 0===e?void 0:e.complete)||!q.stripeShippingSameAsBilling&&!(null===(t=q.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!q.stripeBillingAddressEventData)return{partiesCreated:!1};if(!we.landedCostData)return{partiesCreated:!1};const s=null===(n=we.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!s)return h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,r,s,i,a;const d=null===(e=we.partiesData.find((e=>"DESTINATION"===e.type)))||void 0===e?void 0:e.id,l=null===(t=we.partiesData.find((e=>"PAYOR"===e.type)))||void 0===t?void 0:t.id;if(!d||!l)return!1;if(q.partyShippingId!==d||q.partyBillingId!==l)return!0;const c=JSON.stringify(null===(o=q.stripeLinkUsedWhenFetchingLC)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeLinkEventData)||void 0===n?void 0:n.value),u=JSON.stringify(null===(r=q.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=q.stripeAddressEventData)||void 0===s?void 0:s.value),m=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(i=q.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===i?void 0:i.value)!==JSON.stringify(null===(a=q.stripeBillingAddressEventData)||void 0===a?void 0:a.value);return c||u||m||q.taxIdUsedWhenAsyncAddressUpdate!==q.taxId||q.companyNameUsedWhenAsyncAddressUpdate!==q.companyName})();if(!i)return{partiesCreated:!1};const a=Z({address:q.stripeAddressEventData.value.address,firstName:q.stripeAddressEventData.value.firstName,lastName:q.stripeAddressEventData.value.lastName,name:q.stripeAddressEventData.value.name,phone:q.stripeAddressEventData.value.phone}),d=q.stripeShippingSameAsBilling?a:Z({address:q.stripeBillingAddressEventData.value.address,firstName:q.stripeBillingAddressEventData.value.firstName,lastName:q.stripeBillingAddressEventData.value.lastName,name:q.stripeBillingAddressEventData.value.name,phone:q.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:v,json:p}=await c("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:q.companyName,email:(null===(r=q.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:s,shortAddressCode:q.shortAddressCode,taxId:q.taxId},method:"POST"});return v.length||!p?(u("Error occurs when creating parties",JSON.stringify(v,null,2)),h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:v,json:p}}),{partiesCreated:!1}):(q.companyNameUsedWhenAsyncAddressUpdate=q.companyName,q.stripeAddressUsedWhenAsyncAddressUpdate=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenAsyncAddressUpdate=q.stripeBillingAddressEventData,q.taxIdUsedWhenAsyncAddressUpdate=q.taxId,q.partyBillingId=p.billToPartyId,q.partyShippingId=p.shipToPartyId,we.partiesData=we.partiesData.map((e=>"DESTINATION"===e.type&&e.id!==p.shipToPartyId?Object.assign(Object.assign({},e),{id:p.shipToPartyId}):"PAYOR"===e.type&&e.id!==p.billToPartyId?Object.assign(Object.assign({},e),{id:p.billToPartyId}):e)),{partiesCreated:!0})},X=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),ee=async e=>{var n,r,s,i;const a=(null==e?void 0:e.retries)||0,l=!!(null==e?void 0:e.applyingPromocode),c=(()=>{var e;const t=we.landedCostData&&(null===(e=we.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==we.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=q.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeLinkEventData)||void 0===t?void 0:t.value),n=q.stripeAddressEventData&&JSON.stringify(X(q.stripeAddressEventData.value))!==JSON.stringify(q.stripeAddressUsedWhenFetchingLC),r=!q.stripeShippingSameAsBilling&&q.stripeBillingAddressEventData&&JSON.stringify(X(q.stripeBillingAddressEventData.value))!==JSON.stringify(q.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return d("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!we.landedCostData&&!q.isFetchingLandedCost||o||t})();if(!(()=>{var e,o,n,r;const s=!!(null===(e=q.stripeLinkEventData)||void 0===e?void 0:e.complete),i=!!(null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.complete),a=q.stripeShippingSameAsBilling?i:!!(null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(e=>{var o,n;const r=null===(o=t.genericSettings)||void 0===o?void 0:o.countryFields,s=null===(n=t.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===we.addressFormRenderType&&(s&&e in s?s[e]:null)||(r&&e in r?r[e]:null)})((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US");return!!(i&&a&&s)||(d&&q.stripeAddressEventData?s&&q.stripeAddressEventData.value.firstName&&q.stripeAddressEventData.value.lastName&&q.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&q.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&q.stripeAddressEventData.value.address.postal_code.length>=3)&&q.stripeAddressEventData.value.phone&&q.stripeAddressEventData.value.phone.length>0:i&&a&&s)})())return{isRequestNotReady:!0};if(c&&(null===(n=q.fetchingLandedCostAbortController)||void 0===n||n.abort(),q.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};a?(q.isFetchingLandedCost=!1,setTimeout((()=>{q.isFetchingLandedCost=!0}),300)):q.isFetchingLandedCost=!0,q.stripeAddressEventData&&(q.stripeAddressUsedWhenFetchingLC={countryCode:q.stripeAddressEventData.value.address.country,postalCode:q.stripeAddressEventData.value.address.postal_code,state:q.stripeAddressEventData.value.address.state}),q.stripeBillingAddressEventData&&(q.stripeBillingAddressUsedWhenFetchingLC={countryCode:q.stripeBillingAddressEventData.value.address.country,postalCode:q.stripeBillingAddressEventData.value.address.postal_code,state:q.stripeBillingAddressEventData.value.address.state}),q.stripeLinkEventData&&(q.stripeLinkUsedWhenFetchingLC=Object.assign({},q.stripeLinkEventData));try{xe(),await(async()=>{var e;const t=new AbortController;q.fetchingLandedCostAbortController=t,xe();const{checkoutSessionWorkflow:n,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await z(t);we.customQuotingError=(null===(e=null==r?void 0:r.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,we.shippingData=B((null==d?void 0:d.filter(Boolean))||[]),Ce(s),q.fetchingLandedCostAbortController=null,we.partiesData=(null==a?void 0:a.filter(Boolean))||[],we.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&U({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=we.promoCodeApplied&&!we.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));we.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",we.promoCode)})();const e=null===(r=we.shippingData)||void 0===r?void 0:r.find(Boolean),t=null===(s=we.landedCostData)||void 0===s?void 0:s.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ke({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(t){if(we.landedCostData=[],we.shippingData=[],t instanceof Error&&t.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(t.message)){if(a<1)return await ee(Object.assign(Object.assign({},e),{retries:(a||0)+1})),{isRequestNotReady:!1};const o=null===(i=q.stripeAddressEventData)||void 0===i?void 0:i.value;h({endpoint:`Failed to fetch landed cost (${a} retries)`,errors:[t.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}u(t)}return q.isFetchingLandedCost=!1,{isRequestNotReady:!1}},te=async()=>{var e,t;await ee({applyingPromocode:!0}),"payment"===we.step&&ze(),await Q();const o=null===(e=we.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=we.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await Pe({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},oe=()=>{we.promoCode="",sessionStorage.removeItem("zonos--promo-code"),we.promoCodeError=!1,we.promoCodeApplied=!1},ne=async()=>{"payment"===we.step&&ze(),oe(),await te()},re=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,r=window.Zonos.isInvoice;switch(e){case"succeeded":t=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")],(n||r)&&(t=[s("Thank you for submitting your payment. We appreciate your prompt attention."),"",s("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]),o=!1;break;case"requires_capture":case"processing":t=[s("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[s("Payment failed. Please try another payment method.")],n&&(t=[s("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[s("Something went wrong.")]}return{isError:o,messages:t}},se=async()=>{var e,o;const{onInventoryCheck:n}=t.checkoutSettings,r=!!(null===(o=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&r){const{errors:e,json:t}=await c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(u("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(q.shouldInventoryRefund=!0,null):null:s("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")}if("function"!=typeof n)return null;try{return await n({items:we.items},{translate:s,zonosApiRoute:m.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw h({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:we.items}}),e}},ie=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},ae=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=re(t);return{error:e,messages:o}}const o=e||q.clientSecret;if(!q.stripe||!o)return u("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[s("Something went wrong.")]};const{paymentIntent:n}=await q.stripe.retrievePaymentIntent(o),r=null==n?void 0:n.status,{isError:i,messages:a}=re(r);return{amount:null==n?void 0:n.amount,currency:null==n?void 0:n.currency,error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:r}},de=async e=>{var t,n;const r=!!(null===(t=q.stripePaymentEventData)||void 0===t?void 0:t.complete),i=q.stripeElements,a=q.stripe,l=q.clientSecret;if(q.customErrorMessage=null,!(null===(n=we.selectedLandedCost)||void 0===n?void 0:n.landedCost.id)&&!(null==e?void 0:e.noLandedCostCheck))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const c=await F();if(!c.valid)throw q.customErrorMessage=c.errorMessage,new Error(c.errorMessage);const u=o.checkoutSessionId;if(a&&i&&r&&l&&u){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",l),e.searchParams.set("zonosCheckoutSessionId",u),U({checkoutSessionId:u,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(d("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(s("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."));if(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(s("Payment failed. Please try another payment method."))}},le=()=>{var e;const t=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),r=o.enabledVariantTestKeys||[];return{adjustmentsAmount:we.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:we.customerAuthenticationToken||void 0,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:q.skipPaymentIntent,varianceTestInput:r}},ce=async()=>{var e;if(!o.checkoutSessionId)return h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}}),void Ie({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});const{errors:t,json:n}=await c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),r=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!r)return u("Error occurs when getting payment intent",JSON.stringify(t,null,2)),h({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:r}}),void Ie({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")});Te(n.checkoutSessionPaymentIntentCreate)},ue=async()=>{var e,t;if(!n.targetCurrency)return u("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;q.isFetchingSession=!0;const o=le();d("Checkout session body","info",o);const{errors:r,json:s}=await c("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(q.isFetchingSession=!1,r.length||!s){const t=null===(e=r.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return u("Error occurred when creating checkout session",JSON.stringify(r,null,2)),!1}const i=s.checkoutSessionCreate;return Te(i),ke({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),d("Exchange rate updated for cart items (checkout session create)","info",we.exchangeRate),d("done-init-checkout-session"),!0},me=async()=>{const e=o.checkoutSessionId;if(!e)return u("Failed to update checkout session base currency"),!1;if("LOCAL"===t.checkoutSettings.allowedSettlementCurrencies)return d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:q.checkoutSettlementCurrency},method:"POST"}),r=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&r===q.checkoutSettlementCurrency?(d(`Updated checkout session to settlement currency "${r}".`),!0):(u("Failed to update checkout session base currency"),!1)},ve=async({adjustmentsAmount:e,cartId:t,currency:r,id:s,itemsAmount:i,landedCostId:a,presentmentCountryCode:d,storeCreditApplication:l})=>{const m=o.enabledVariantTestKeys||[],{errors:v,json:p}=await c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,customerAuthenticationToken:we.customerAuthenticationToken||void 0,id:s,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:q.partyShippingId,skipPaymentIntent:q.skipPaymentIntent,storeCreditApplication:l,varianceTestInput:m},method:"POST"});return v.length||!p?(u("Error occurs when updating checkout session",JSON.stringify(v,null,2)),{errors:v,json:p}):{errors:[],json:p}},pe=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:r,line2:s,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&r&&(o.line1={[e.line1]:r}),e.line2&&s&&(o.line2={[e.line2]:s}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},he=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,r,s;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:r})=>{const s=!!(null==o?void 0:o.complete);if(!s||!(r?s:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=D({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=D({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),v=u&&m?`${u} ${m}`:"",p=i.address,h=null==a?void 0:a.address;return{address:_({address:Object.assign(Object.assign({},p),{name:c}),invalidAdddressList:e}),billingAddress:r?void 0:_({address:h?Object.assign(Object.assign({},h),{name:v}):null,invalidAdddressList:t}),destinationCountry:p.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:q.stripeAddressEventData,stripeBillingAddressEventData:q.stripeBillingAddressEventData,stripeShippingSameAsBilling:q.stripeShippingSameAsBilling});if(!i)return void(q.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=q.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=q.stripeAddressEventData)||void 0===t?void 0:t.value),s=!q.stripeShippingSameAsBilling&&JSON.stringify(null===(o=q.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=q.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();if(!a)return;const{errors:d,json:l}=await c("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!l)return u("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(q.translatedAddress={address:{},billingAddress:{}});q.stripeAddressUsedWhenValidatingAddress=q.stripeAddressEventData,q.stripeBillingAddressUsedWhenValidatingAddress=q.stripeBillingAddressEventData;const m=null===(o=q.stripeAddressEventData)||void 0===o?void 0:o.value.address,v=null===(n=q.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;q.translatedAddress={address:m?pe({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:q.stripeShippingSameAsBilling?{}:pe({currentAddress:Object.assign(Object.assign({},v),{name:null===(s=q.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:l.billingAddress||null})}};W("clientSecret",(e=>{e&&q.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:ye,reset:fe,state:we}=e((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:p(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),ge=e=>{switch(e){case"DAYS":return s("days");case"WEEKS":return s("weeks");default:return s("business days")}},be=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:ge(o.type)}:null},Se=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),Ce=e=>{d("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=we.items.find((t=>Se({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return we.restrictedItems=t,we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>Se({item1:t,item2:e})))}))),{cartItems:we.items,restrictedItems:t}};let Oe=null;const Ae=()=>{o.checkoutSessionId=null,Oe&&(clearTimeout(Oe),Oe=null),C(),fe()},Ie=({messages:e,title:t})=>{Ae(),V(),we.step="error",we.error={messages:e,title:t}},ke=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{var n;we.exchangeRate=o.exchangeRate,we.adjustmentTotal=o.adjustments,we.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,we.storeCredit=null!==(n=o.storeCredit)&&void 0!==n?n:0,we.subtotal=o.items,we.total=o.total,we.currency=o.presentmentCurrencyCode,we.dutiesTaxesFeesEstimate=e||null},Ne=()=>!!we.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),Te=e=>{var t,n,r,s,c,u,m;q.clientSecret=e.clientSecret,q.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,q.customerProfile=e.customerProfile,we.checkoutSession=e,O(null!==(n=null===(t=e.customerProfile)||void 0===t?void 0:t.storeCreditBalance)&&void 0!==n?n:null),e.id||h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const v=i(e.varianceTestResults||[]);a(v);const p=(null===(c=null===(s=null===(r=we.checkoutSession)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===c?void 0:c.value)||(null===(m=null===(u=window.Zonos.cartData)||void 0===u?void 0:u.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===m?void 0:m.value)||null;p&&(d(`Found externalConfirmationPageURL: ${p}`),we.externalConfirmationPageURL=p)},je=async({adjustmentsAmount:e,cartId:t,currency:r,dutiesTaxesFeesEstimate:i,itemsAmount:a,landedCostId:l,shouldInitSessionOnFailure:c})=>{var m;if(l&&we.selectedLandedCost&&(ke({dutiesTaxesFeesEstimate:i,method:we.landedCostMethod,subtotals:we.selectedLandedCost.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate)),!o.checkoutSessionId)return d("Could not update cart total without checkout session id","info"),!1;const{errors:v,json:p}=await ve({adjustmentsAmount:e,billToPartyId:q.partyBillingId,cartId:t,currency:r,id:o.checkoutSessionId,itemsAmount:a,landedCostId:l,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(v.length>0||!p){if(u("Error occurs when updating checkout session."),c){d("Initiating checkout session on failure","info");const e=await ue();return d(`stripeStoreInitCheckoutSession: ${e}`),!!e||(Ie({messages:[s("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error creating Checkout")}),!1)}return!1}return l||(ke({method:(null===(m=p.checkoutSessionUpdate.landedCost)||void 0===m?void 0:m.method)||"DDP",subtotals:p.checkoutSessionUpdate.subtotals}),d("Exchange rate updated for cart items (checkout session update)","info",we.exchangeRate)),Te(p.checkoutSessionUpdate),!0},Ee=e=>{var o,n,r;return"DAP"===e.method&&(null===(n=null===(o=t.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(r=q.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US"))||"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method},Pe=async({applySubtotalsOnly:e,landedCostId:n,selectedShippingOption:r})=>{var s,i,a,l,c,u,m,v,p,h,y;d("Updating selected shipping option","info",{landedCostId:n,selectedShippingOption:r}),we.selectedShippingOption=r;const f=be(we.selectedShippingOption);if(f){const{maxTransit:e,minTransit:t,unit:o}=f;we.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else we.selectedShippingOptionTransitTime="";const w=null===(s=we.landedCostData)||void 0===s?void 0:s.find((e=>e.landedCostId===n));if(we.selectedLandedCost=w||null,!w)return!1;const g=((null===(i=w.landedCost.amountSubtotals)||void 0===i?void 0:i.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&d(`DAP quote, using estimate: ${g}`,"info"),we.landedCostMethod=Ee(w.landedCost),we.shipping=w.subtotals.shipping;const b="ZONOS"===(null===(a=null==w?void 0:w.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),S=!!(null===(c=null===(l=null==w?void 0:w.landedCost)||void 0===l?void 0:l.deMinimis)||void 0===c?void 0:c.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));we.isSelectedShippingAboveDeminimis=S,we.isSelectedShippingGuarantee=b;let C=!1;e?(ke({dutiesTaxesFeesEstimate:g,method:we.landedCostMethod,subtotals:w.subtotals}),d("Exchange rate updated for cart items (landed cost subtotal)","info",we.exchangeRate),C=!0):C=await je({adjustmentsAmount:we.adjustmentTotal,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(u=w.landedCost)||void 0===u?void 0:u.id,shipToPartyId:q.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});const O=null===(m=we.items.find(Boolean))||void 0===m?void 0:m.currencyCode,A=(null===(v=q.stripeAddressEventData)||void 0===v?void 0:v.value.address.country)||"US";return q.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===t.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(p=we.checkoutSession)||void 0===p?void 0:p.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(h=t.genericSettings)||void 0===h?void 0:h.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),C},De=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;d(`==START CHECKOUT TIMEOUT - ${n}==`),we.checkoutTimeoutInterval=setTimeout((()=>{we.checkoutSessionTimeoutShow=!0}),n)},Le=()=>{we.checkoutTimeoutInterval&&(clearTimeout(we.checkoutTimeoutInterval),we.checkoutTimeoutInterval=null)},xe=()=>{we.items=we.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),we.restrictedItems=[]},Re=async({adjustments:e,cartItems:t,landedCostId:n,shouldInitSessionOnFailure:r=!0})=>{var s;we.adjustments=e,we.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const i=null===(s=t.find(Boolean))||void 0===s?void 0:s.currencyCode,a=t.reduce(((e,t)=>e+t.amount*t.quantity),0),d=e.reduce(((e,t)=>e+t.amount),0);i&&a&&(we.currency=i,q.isFetchingSession=!0,await je({adjustmentsAmount:d,billToPartyId:q.partyBillingId,cartId:window.Zonos.cartId,currency:i,dutiesTaxesFeesEstimate:0,itemsAmount:a,landedCostId:n,shipToPartyId:q.partyShippingId,shouldInitSessionOnFailure:r,varianceTestInput:o.enabledVariantTestKeys||[]}),q.isFetchingSession=!1)},ze=()=>{"shipping"===we.step?(we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"payment"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})})):"finish"===we.step&&(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1})}))},Ue=()=>{"customer-info"===we.step?(we.step="shipping",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!0})})):"shipping"===we.step?(we.step="payment",we.tabItems=Object.assign(Object.assign({},we.tabItems),{shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!0})})):"payment"===we.step&&(we.step="finish")},_e=()=>{we.step="customer-info",we.tabItems=Object.assign(Object.assign({},we.tabItems),{"customer-info":Object.assign(Object.assign({},we.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},we.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},we.tabItems.shipping),{isDone:!1})}),we.selectedShippingOption=null,we.isSelectedShippingAboveDeminimis=!1,we.isSelectedShippingGuarantee=!1,we.selectedShippingOptionTransitTime="",we.dutiesTaxesFees=0,we.dutiesTaxesFeesEstimate=0,we.shipping=0,we.total=we.subtotal},Be=()=>{Oe&&clearTimeout(Oe),Oe=setTimeout((()=>{Oe=null,(async()=>{var e,t;if(!o.checkoutSessionId)return void d("Could not update store credit without checkout session id","info");const r=we.selectedLandedCost,s=we.currency||(null===(e=we.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",i=we.adjustments.reduce(((e,t)=>e+t.amount),0),a=we.items.reduce(((e,t)=>e+t.amount*t.quantity),0),{errors:l,json:c}=await ve({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:s,id:o.checkoutSessionId,itemsAmount:a,landedCostId:null==r?void 0:r.landedCostId,presentmentCountryCode:n.selectedCountryCode,storeCreditApplication:S.isEnabled&&null!==S.amountToApply?S.useFullBalance?{mode:"FULL"}:{amount:S.amountToApply,mode:"PARTIAL"}:{mode:"NONE"}});l.length>0||!c?u("Error updating checkout session with store credit"):(ke({method:(null===(t=c.checkoutSessionUpdate.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals}),Te(c.checkoutSessionUpdate))})()}),300)};export{de as A,ie as B,V as C,ye as D,W as E,j as F,Z as G,Pe as H,Ne as I,te as J,ne as K,oe as L,re as M,S as N,C as O,he as P,D as Q,Q as R,be as S,Ee as T,B as U,k as V,T as W,Be as X,N as Y,A as Z,H as a,q as b,ae as c,we as d,Re as e,Ae as f,_e as g,Le as h,G as i,ue as j,ce as k,De as l,le as m,Ie as n,Y as o,Te as p,ee as q,Ue as r,K as s,U as t,me as u,se as v,I as w,E as x,F as y,P as z}
|